iwl-commands.h revision 600c0e11ea6161e00e8cb4b4dda39a64ce988c60
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 *
8eb7ae89cb0b03e6e6e39737b1c8bcc1912281a00Reinette Chatre * Copyright(c) 2005 - 2008 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 *
33eb7ae89cb0b03e6e6e39737b1c8bcc1912281a00Reinette Chatre * Copyright(c) 2005 - 2008 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
72c02b3acd29766c6f79c2411cb5b85e1ee72c4c8fChatre, Reinette/* uCode version contains 4 values: Major/Minor/API/Serial */
73c02b3acd29766c6f79c2411cb5b85e1ee72c4c8fChatre, Reinette#define IWL_UCODE_MAJOR(ver)	(((ver) & 0xFF000000) >> 24)
74c02b3acd29766c6f79c2411cb5b85e1ee72c4c8fChatre, Reinette#define IWL_UCODE_MINOR(ver)	(((ver) & 0x00FF0000) >> 16)
75c02b3acd29766c6f79c2411cb5b85e1ee72c4c8fChatre, Reinette#define IWL_UCODE_API(ver)	(((ver) & 0x0000FF00) >> 8)
76c02b3acd29766c6f79c2411cb5b85e1ee72c4c8fChatre, Reinette#define IWL_UCODE_SERIAL(ver)	((ver) & 0x000000FF)
77c02b3acd29766c6f79c2411cb5b85e1ee72c4c8fChatre, Reinette
78b481de9ca074528fe8c429604e2777db8b89806aZhu Yienum {
79b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_ALIVE = 0x1,
80b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_ERROR = 0x2,
81b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
82b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	/* RXON and QOS commands */
83b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_RXON = 0x10,
84b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_RXON_ASSOC = 0x11,
85b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_QOS_PARAM = 0x13,
86b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_RXON_TIMING = 0x14,
87b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
88b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	/* Multi-Station support */
89b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_ADD_STA = 0x18,
90b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_REMOVE_STA = 0x19,	/* not used */
91b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_REMOVE_ALL_STA = 0x1a,	/* not used */
92b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
930a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach	/* Security */
940a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach	REPLY_WEPKEY = 0x20,
950a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach
96b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	/* RX, TX, LEDs */
972aa6ab86bc475a115f56645591d2413981846509Tomas Winkler	REPLY_3945_RX = 0x1b,           /* 3945 only */
98b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_TX = 0x1c,
99b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_RATE_SCALE = 0x47,	/* 3945 only */
100b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_LEDS_CMD = 0x48,
101b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_TX_LINK_QUALITY_CMD = 0x4e, /* 4965 only */
102b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1039636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	/* WiMAX coexistence */
1049636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	COEX_PRIORITY_TABLE_CMD = 0x5a,	/*5000 only */
1059636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	COEX_MEDIUM_NOTIFICATION = 0x5b,
1069636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	COEX_EVENT_CMD = 0x5c,
1079636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky
108be5d56ed885a2897ec813eab4a8055d495816e9aTomas Winkler	/* Calibration */
109be5d56ed885a2897ec813eab4a8055d495816e9aTomas Winkler	CALIBRATION_CFG_CMD = 0x65,
110be5d56ed885a2897ec813eab4a8055d495816e9aTomas Winkler	CALIBRATION_RES_NOTIFICATION = 0x66,
111be5d56ed885a2897ec813eab4a8055d495816e9aTomas Winkler	CALIBRATION_COMPLETE_NOTIFICATION = 0x67,
112be5d56ed885a2897ec813eab4a8055d495816e9aTomas Winkler
113b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	/* 802.11h related */
114b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	RADAR_NOTIFICATION = 0x70,	/* not used */
115b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_QUIET_CMD = 0x71,		/* not used */
116b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_CHANNEL_SWITCH = 0x72,
117b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	CHANNEL_SWITCH_NOTIFICATION = 0x73,
118b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_SPECTRUM_MEASUREMENT_CMD = 0x74,
119b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	SPECTRUM_MEASURE_NOTIFICATION = 0x75,
120b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
121b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	/* Power Management */
122b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	POWER_TABLE_CMD = 0x77,
123b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	PM_SLEEP_NOTIFICATION = 0x7A,
124b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	PM_DEBUG_STATISTIC_NOTIFIC = 0x7B,
125b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
126b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	/* Scan commands and notifications */
127b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_SCAN_CMD = 0x80,
128b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_SCAN_ABORT_CMD = 0x81,
129b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	SCAN_START_NOTIFICATION = 0x82,
130b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	SCAN_RESULTS_NOTIFICATION = 0x83,
131b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	SCAN_COMPLETE_NOTIFICATION = 0x84,
132b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
133b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	/* IBSS/AP commands */
134b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	BEACON_NOTIFICATION = 0x90,
135b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_TX_BEACON = 0x91,
136b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	WHO_IS_AWAKE_NOTIFICATION = 0x94,	/* not used */
137b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
138b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	/* Miscellaneous commands */
139b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	QUIET_NOTIFICATION = 0x96,		/* not used */
140b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_TX_PWR_TABLE_CMD = 0x97,
141630fe9b6f774dd55b71fe94392101eb00df58762Tomas Winkler	REPLY_TX_POWER_DBM_CMD = 0x98,
142b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	MEASURE_ABORT_NOTIFICATION = 0x99,	/* not used */
143b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
144a96a27f97f2bbfc1fca54bc3c0b0d41484152740Tomas Winkler	/* Bluetooth device coexistence config command */
145b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_BT_CONFIG = 0x9b,
146b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
14780cc0c382db318de88577eff027d5c4097abef81Ben M Cahill	/* Statistics */
148b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_STATISTICS_CMD = 0x9c,
149b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	STATISTICS_NOTIFICATION = 0x9d,
150b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
151b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	/* RF-KILL commands and notifications */
152b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_CARD_STATE_CMD = 0xa0,
153b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	CARD_STATE_NOTIFICATION = 0xa1,
154b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
155b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	/* Missed beacons notification */
156b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	MISSED_BEACONS_NOTIFICATION = 0xa2,
157b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
158b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_CT_KILL_CONFIG_CMD = 0xa4,
159b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	SENSITIVITY_CMD = 0xa8,
160b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_PHY_CALIBRATION_CMD = 0xb0,
161b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_RX_PHY_CMD = 0xc0,
162b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_RX_MPDU_CMD = 0xc1,
163857485c0c46ceee5c658c1761bba4d9a5ddf433fTomas Winkler	REPLY_RX = 0xc3,
164b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_COMPRESSED_BA = 0xc5,
165b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_MAX = 0xff
166b481de9ca074528fe8c429604e2777db8b89806aZhu Yi};
167b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
168b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/******************************************************************************
169b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * (0)
170abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill * Commonly used structures and definitions:
17180cc0c382db318de88577eff027d5c4097abef81Ben M Cahill * Command header, rate_n_flags, txpower
172b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
173b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *****************************************************************************/
174b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
175857485c0c46ceee5c658c1761bba4d9a5ddf433fTomas Winkler/* iwl_cmd_header flags value */
176b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define IWL_CMD_FAILED_MSK 0x40
177b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1789734cb23a02f8de5fa99225ca61c7019ca9f232fTomas Winkler#define SEQ_TO_QUEUE(s)	(((s) >> 8) & 0x1f)
1799734cb23a02f8de5fa99225ca61c7019ca9f232fTomas Winkler#define QUEUE_TO_SEQ(q)	(((q) & 0x1f) << 8)
1809734cb23a02f8de5fa99225ca61c7019ca9f232fTomas Winkler#define SEQ_TO_INDEX(s)	((s) & 0xff)
1819734cb23a02f8de5fa99225ca61c7019ca9f232fTomas Winkler#define INDEX_TO_SEQ(i)	((i) & 0xff)
18251e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define SEQ_HUGE_FRAME	cpu_to_le16(0x4000)
18351e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define SEQ_RX_FRAME	cpu_to_le16(0x8000)
1849734cb23a02f8de5fa99225ca61c7019ca9f232fTomas Winkler
185075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill/**
186857485c0c46ceee5c658c1761bba4d9a5ddf433fTomas Winkler * struct iwl_cmd_header
187075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *
188075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill * This header format appears in the beginning of each command sent from the
189075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill * driver, and each response/notification received from uCode.
190075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill */
191857485c0c46ceee5c658c1761bba4d9a5ddf433fTomas Winklerstruct iwl_cmd_header {
192075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill	u8 cmd;		/* Command ID:  REPLY_RXON, etc. */
1939734cb23a02f8de5fa99225ca61c7019ca9f232fTomas Winkler	u8 flags;	/* 0:5 reserved, 6 abort, 7 internal */
194075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill	/*
195a96a27f97f2bbfc1fca54bc3c0b0d41484152740Tomas Winkler	 * The driver sets up the sequence number to values of its choosing.
196075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill	 * uCode does not use this value, but passes it back to the driver
197075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill	 * when sending the response to each driver-originated command, so
198075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill	 * the driver can match the response to the command.  Since the values
199075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill	 * don't get used by uCode, the driver may set up an arbitrary format.
200b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 *
201075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill	 * There is one exception:  uCode sets bit 15 when it originates
202075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill	 * the response/notification, i.e. when the response/notification
203075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill	 * is not a direct response to a command sent by the driver.  For
204075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill	 * example, uCode issues REPLY_3945_RX when it sends a received frame
205075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill	 * to the driver; it is not a direct response to any driver command.
206b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 *
207075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill	 * The Linux driver uses the following format:
208075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill	 *
2099734cb23a02f8de5fa99225ca61c7019ca9f232fTomas Winkler	 *  0:7		tfd index - position within TX queue
2109734cb23a02f8de5fa99225ca61c7019ca9f232fTomas Winkler	 *  8:12	TX queue id
2119734cb23a02f8de5fa99225ca61c7019ca9f232fTomas Winkler	 *  13		reserved
2129734cb23a02f8de5fa99225ca61c7019ca9f232fTomas Winkler	 *  14		huge - driver sets this to indicate command is in the
2139734cb23a02f8de5fa99225ca61c7019ca9f232fTomas Winkler	 *  		'huge' storage at the end of the command buffers
2149734cb23a02f8de5fa99225ca61c7019ca9f232fTomas Winkler	 *  15		unsolicited RX or uCode-originated notification
215b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 */
216b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 sequence;
217b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
218075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill	/* command or response/notification data follows immediately */
219b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 data[0];
220b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
221b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
222abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill/**
2235c5aa3f13a50881b8f6e529e321bbefb5faec37bHalperin, Daniel C * iwlagn rate_n_flags bit fields
224abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill *
2255c5aa3f13a50881b8f6e529e321bbefb5faec37bHalperin, Daniel C * rate_n_flags format is used in following iwlagn commands:
226857485c0c46ceee5c658c1761bba4d9a5ddf433fTomas Winkler *  REPLY_RX (response only)
2275c5aa3f13a50881b8f6e529e321bbefb5faec37bHalperin, Daniel C *  REPLY_RX_MPDU (response only)
228abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill *  REPLY_TX (both command and response)
229abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill *  REPLY_TX_LINK_QUALITY_CMD
230abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill *
231abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill * High-throughput (HT) rate format for bits 7:0 (bit 8 must be "1"):
232abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill *  2-0:  0)   6 Mbps
233abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill *        1)  12 Mbps
234abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill *        2)  18 Mbps
235abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill *        3)  24 Mbps
236abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill *        4)  36 Mbps
237abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill *        5)  48 Mbps
238abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill *        6)  54 Mbps
239abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill *        7)  60 Mbps
240abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill *
2415c5aa3f13a50881b8f6e529e321bbefb5faec37bHalperin, Daniel C *  4-3:  0)  Single stream (SISO)
242abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill *        1)  Dual stream (MIMO)
2435c5aa3f13a50881b8f6e529e321bbefb5faec37bHalperin, Daniel C *        2)  Triple stream (MIMO)
244abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill *
245abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill *    5:  Value of 0x20 in bits 7:0 indicates 6 Mbps FAT duplicate data
246abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill *
247abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill * Legacy OFDM rate format for bits 7:0 (bit 8 must be "0", bit 9 "0"):
248abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill *  3-0:  0xD)   6 Mbps
249abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill *        0xF)   9 Mbps
250abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill *        0x5)  12 Mbps
251abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill *        0x7)  18 Mbps
252abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill *        0x9)  24 Mbps
253abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill *        0xB)  36 Mbps
254abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill *        0x1)  48 Mbps
255abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill *        0x3)  54 Mbps
256abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill *
257abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill * Legacy CCK rate format for bits 7:0 (bit 8 must be "0", bit 9 "1"):
2581061787967db03975dc02030d6815811f4eb9231Daniel Wu *  6-0:   10)  1 Mbps
259abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill *         20)  2 Mbps
260abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill *         55)  5.5 Mbps
261abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill *        110)  11 Mbps
262abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill */
263abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill#define RATE_MCS_CODE_MSK 0x7
2645c5aa3f13a50881b8f6e529e321bbefb5faec37bHalperin, Daniel C#define RATE_MCS_SPATIAL_POS 3
2655c5aa3f13a50881b8f6e529e321bbefb5faec37bHalperin, Daniel C#define RATE_MCS_SPATIAL_MSK 0x18
266abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill#define RATE_MCS_HT_DUP_POS 5
267abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill#define RATE_MCS_HT_DUP_MSK 0x20
268abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill
269075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill/* Bit 8: (1) HT format, (0) legacy format in bits 7:0 */
270abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill#define RATE_MCS_FLAGS_POS 8
271abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill#define RATE_MCS_HT_POS 8
272abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill#define RATE_MCS_HT_MSK 0x100
273abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill
274075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill/* Bit 9: (1) CCK, (0) OFDM.  HT (bit 8) must be "0" for this bit to be valid */
275abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill#define RATE_MCS_CCK_POS 9
276abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill#define RATE_MCS_CCK_MSK 0x200
277abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill
278075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill/* Bit 10: (1) Use Green Field preamble */
279abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill#define RATE_MCS_GF_POS 10
280abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill#define RATE_MCS_GF_MSK 0x400
281abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill
282075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill/* Bit 11: (1) Use 40Mhz FAT chnl width, (0) use 20 MHz legacy chnl width */
283abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill#define RATE_MCS_FAT_POS 11
284abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill#define RATE_MCS_FAT_MSK 0x800
285abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill
286075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill/* Bit 12: (1) Duplicate data on both 20MHz chnls.  FAT (bit 11) must be set. */
287abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill#define RATE_MCS_DUP_POS 12
288abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill#define RATE_MCS_DUP_MSK 0x1000
289abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill
290075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill/* Bit 13: (1) Short guard interval (0.4 usec), (0) normal GI (0.8 usec) */
291abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill#define RATE_MCS_SGI_POS 13
292abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill#define RATE_MCS_SGI_MSK 0x2000
293abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill
294abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill/**
29576eff18bdc5feaa53f1be33709b67df02f1d55e9Tomas Winkler * rate_n_flags Tx antenna masks
29676eff18bdc5feaa53f1be33709b67df02f1d55e9Tomas Winkler * 4965 has 2 transmitters
29776eff18bdc5feaa53f1be33709b67df02f1d55e9Tomas Winkler * 5100 has 1 transmitter B
29876eff18bdc5feaa53f1be33709b67df02f1d55e9Tomas Winkler * 5150 has 1 transmitter A
29976eff18bdc5feaa53f1be33709b67df02f1d55e9Tomas Winkler * 5300 has 3 transmitters
30076eff18bdc5feaa53f1be33709b67df02f1d55e9Tomas Winkler * 5350 has 3 transmitters
30176eff18bdc5feaa53f1be33709b67df02f1d55e9Tomas Winkler * bit14:16
302abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill */
303600c0e11ea6161e00e8cb4b4dda39a64ce988c60Tomas Winkler#define RATE_MCS_ANT_POS	14
304600c0e11ea6161e00e8cb4b4dda39a64ce988c60Tomas Winkler#define RATE_MCS_ANT_A_MSK	0x04000
305600c0e11ea6161e00e8cb4b4dda39a64ce988c60Tomas Winkler#define RATE_MCS_ANT_B_MSK	0x08000
306600c0e11ea6161e00e8cb4b4dda39a64ce988c60Tomas Winkler#define RATE_MCS_ANT_C_MSK	0x10000
307600c0e11ea6161e00e8cb4b4dda39a64ce988c60Tomas Winkler#define RATE_MCS_ANT_AB_MSK	(RATE_MCS_ANT_A_MSK | RATE_MCS_ANT_B_MSK)
308600c0e11ea6161e00e8cb4b4dda39a64ce988c60Tomas Winkler#define RATE_MCS_ANT_ABC_MSK	(RATE_MCS_ANT_AB_MSK | RATE_MCS_ANT_C_MSK)
30976eff18bdc5feaa53f1be33709b67df02f1d55e9Tomas Winkler#define RATE_ANT_NUM 3
31080cc0c382db318de88577eff027d5c4097abef81Ben M Cahill
31180cc0c382db318de88577eff027d5c4097abef81Ben M Cahill#define POWER_TABLE_NUM_ENTRIES			33
31280cc0c382db318de88577eff027d5c4097abef81Ben M Cahill#define POWER_TABLE_NUM_HT_OFDM_ENTRIES		32
31380cc0c382db318de88577eff027d5c4097abef81Ben M Cahill#define POWER_TABLE_CCK_ENTRY			32
31480cc0c382db318de88577eff027d5c4097abef81Ben M Cahill
31580cc0c382db318de88577eff027d5c4097abef81Ben M Cahill/**
31680cc0c382db318de88577eff027d5c4097abef81Ben M Cahill * union iwl4965_tx_power_dual_stream
31780cc0c382db318de88577eff027d5c4097abef81Ben M Cahill *
31880cc0c382db318de88577eff027d5c4097abef81Ben M Cahill * Host format used for REPLY_TX_PWR_TABLE_CMD, REPLY_CHANNEL_SWITCH
31980cc0c382db318de88577eff027d5c4097abef81Ben M Cahill * Use __le32 version (struct tx_power_dual_stream) when building command.
32080cc0c382db318de88577eff027d5c4097abef81Ben M Cahill *
32180cc0c382db318de88577eff027d5c4097abef81Ben M Cahill * Driver provides radio gain and DSP attenuation settings to device in pairs,
32280cc0c382db318de88577eff027d5c4097abef81Ben M Cahill * one value for each transmitter chain.  The first value is for transmitter A,
32380cc0c382db318de88577eff027d5c4097abef81Ben M Cahill * second for transmitter B.
32480cc0c382db318de88577eff027d5c4097abef81Ben M Cahill *
32580cc0c382db318de88577eff027d5c4097abef81Ben M Cahill * For SISO bit rates, both values in a pair should be identical.
32680cc0c382db318de88577eff027d5c4097abef81Ben M Cahill * For MIMO rates, one value may be different from the other,
32780cc0c382db318de88577eff027d5c4097abef81Ben M Cahill * in order to balance the Tx output between the two transmitters.
32880cc0c382db318de88577eff027d5c4097abef81Ben M Cahill *
32980cc0c382db318de88577eff027d5c4097abef81Ben M Cahill * See more details in doc for TXPOWER in iwl-4965-hw.h.
33080cc0c382db318de88577eff027d5c4097abef81Ben M Cahill */
33180cc0c382db318de88577eff027d5c4097abef81Ben M Cahillunion iwl4965_tx_power_dual_stream {
33280cc0c382db318de88577eff027d5c4097abef81Ben M Cahill	struct {
33380cc0c382db318de88577eff027d5c4097abef81Ben M Cahill		u8 radio_tx_gain[2];
33480cc0c382db318de88577eff027d5c4097abef81Ben M Cahill		u8 dsp_predis_atten[2];
33580cc0c382db318de88577eff027d5c4097abef81Ben M Cahill	} s;
33680cc0c382db318de88577eff027d5c4097abef81Ben M Cahill	u32 dw;
33780cc0c382db318de88577eff027d5c4097abef81Ben M Cahill};
33880cc0c382db318de88577eff027d5c4097abef81Ben M Cahill
33980cc0c382db318de88577eff027d5c4097abef81Ben M Cahill/**
34080cc0c382db318de88577eff027d5c4097abef81Ben M Cahill * struct tx_power_dual_stream
34180cc0c382db318de88577eff027d5c4097abef81Ben M Cahill *
34280cc0c382db318de88577eff027d5c4097abef81Ben M Cahill * Table entries in REPLY_TX_PWR_TABLE_CMD, REPLY_CHANNEL_SWITCH
34380cc0c382db318de88577eff027d5c4097abef81Ben M Cahill *
34480cc0c382db318de88577eff027d5c4097abef81Ben M Cahill * Same format as iwl_tx_power_dual_stream, but __le32
34580cc0c382db318de88577eff027d5c4097abef81Ben M Cahill */
34680cc0c382db318de88577eff027d5c4097abef81Ben M Cahillstruct tx_power_dual_stream {
34780cc0c382db318de88577eff027d5c4097abef81Ben M Cahill	__le32 dw;
34880cc0c382db318de88577eff027d5c4097abef81Ben M Cahill} __attribute__ ((packed));
34980cc0c382db318de88577eff027d5c4097abef81Ben M Cahill
35080cc0c382db318de88577eff027d5c4097abef81Ben M Cahill/**
35180cc0c382db318de88577eff027d5c4097abef81Ben M Cahill * struct iwl4965_tx_power_db
35280cc0c382db318de88577eff027d5c4097abef81Ben M Cahill *
35380cc0c382db318de88577eff027d5c4097abef81Ben M Cahill * Entire table within REPLY_TX_PWR_TABLE_CMD, REPLY_CHANNEL_SWITCH
35480cc0c382db318de88577eff027d5c4097abef81Ben M Cahill */
35580cc0c382db318de88577eff027d5c4097abef81Ben M Cahillstruct iwl4965_tx_power_db {
35680cc0c382db318de88577eff027d5c4097abef81Ben M Cahill	struct tx_power_dual_stream power_tbl[POWER_TABLE_NUM_ENTRIES];
35780cc0c382db318de88577eff027d5c4097abef81Ben M Cahill} __attribute__ ((packed));
35880cc0c382db318de88577eff027d5c4097abef81Ben M Cahill
359630fe9b6f774dd55b71fe94392101eb00df58762Tomas Winkler/**
360a96a27f97f2bbfc1fca54bc3c0b0d41484152740Tomas Winkler * Command REPLY_TX_POWER_DBM_CMD = 0x98
361630fe9b6f774dd55b71fe94392101eb00df58762Tomas Winkler * struct iwl5000_tx_power_dbm_cmd
362630fe9b6f774dd55b71fe94392101eb00df58762Tomas Winkler */
363630fe9b6f774dd55b71fe94392101eb00df58762Tomas Winkler#define IWL50_TX_POWER_AUTO 0x7f
364853554accce19d16b03476676bdcb1ccdd44caaeGregory Greenman#define IWL50_TX_POWER_NO_CLOSED (0x1 << 6)
365853554accce19d16b03476676bdcb1ccdd44caaeGregory Greenman
366630fe9b6f774dd55b71fe94392101eb00df58762Tomas Winklerstruct iwl5000_tx_power_dbm_cmd {
367630fe9b6f774dd55b71fe94392101eb00df58762Tomas Winkler	s8 global_lmt; /*in half-dBm (e.g. 30 = 15 dBm) */
368630fe9b6f774dd55b71fe94392101eb00df58762Tomas Winkler	u8 flags;
369630fe9b6f774dd55b71fe94392101eb00df58762Tomas Winkler	s8 srv_chan_lmt; /*in half-dBm (e.g. 30 = 15 dBm) */
370630fe9b6f774dd55b71fe94392101eb00df58762Tomas Winkler	u8 reserved;
371630fe9b6f774dd55b71fe94392101eb00df58762Tomas Winkler} __attribute__ ((packed));
37280cc0c382db318de88577eff027d5c4097abef81Ben M Cahill
373b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/******************************************************************************
374b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * (0a)
375b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Alive and Error Commands & Responses:
376b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
377b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *****************************************************************************/
378b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
37951e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define UCODE_VALID_OK	cpu_to_le32(0x1)
380b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define INITIALIZE_SUBTYPE    (9)
381b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
382b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
383075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill * ("Initialize") REPLY_ALIVE = 0x1 (response only, not a command)
384075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *
385075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill * uCode issues this "initialize alive" notification once the initialization
386075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill * uCode image has completed its work, and is ready to load the runtime image.
387075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill * This is the *first* "alive" notification that the driver will receive after
388075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill * rebooting uCode; the "initialize" alive is indicated by subtype field == 9.
389075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *
390075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill * See comments documenting "BSM" (bootstrap state machine).
391075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *
392075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill * For 4965, this notification contains important calibration data for
393075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill * calculating txpower settings:
394075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *
395075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill * 1)  Power supply voltage indication.  The voltage sensor outputs higher
396a96a27f97f2bbfc1fca54bc3c0b0d41484152740Tomas Winkler *     values for lower voltage, and vice verse.
397075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *
398075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill * 2)  Temperature measurement parameters, for each of two channel widths
399075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *     (20 MHz and 40 MHz) supported by the radios.  Temperature sensing
400075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *     is done via one of the receiver chains, and channel width influences
401075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *     the results.
402075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *
403075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill * 3)  Tx gain compensation to balance 4965's 2 Tx chains for MIMO operation,
404075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *     for each of 5 frequency ranges.
405b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
406885ba202cabd90b8ade1fe59185dc96ed4d69e02Tomas Winklerstruct iwl_init_alive_resp {
407b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 ucode_minor;
408b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 ucode_major;
409b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 reserved1;
410b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 sw_rev[8];
411b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 ver_type;
412075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill	u8 ver_subtype;		/* "9" for initialize alive */
413b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 reserved2;
414b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 log_event_table_ptr;
415b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 error_event_table_ptr;
416b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 timestamp;
417b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 is_valid;
418075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill
419075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill	/* calibration values from "initialize" uCode */
420075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill	__le32 voltage;		/* signed, higher value is lower voltage */
421075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill	__le32 therm_r1[2];	/* signed, 1st for normal, 2nd for FAT channel*/
422075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill	__le32 therm_r2[2];	/* signed */
423075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill	__le32 therm_r3[2];	/* signed */
424075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill	__le32 therm_r4[2];	/* signed */
425075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill	__le32 tx_atten[5][2];	/* signed MIMO gain comp, 5 freq groups,
426075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill				 * 2 Tx chains */
427b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
428b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
429075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill
430075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill/**
431075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill * REPLY_ALIVE = 0x1 (response only, not a command)
432075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *
433075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill * uCode issues this "alive" notification once the runtime image is ready
434075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill * to receive commands from the driver.  This is the *second* "alive"
435075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill * notification that the driver will receive after rebooting uCode;
436075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill * this "alive" is indicated by subtype field != 9.
437075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *
438075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill * See comments documenting "BSM" (bootstrap state machine).
439075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *
440075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill * This response includes two pointers to structures within the device's
441075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill * data SRAM (access via HBUS_TARG_MEM_* regs) that are useful for debugging:
442075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *
443075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill * 1)  log_event_table_ptr indicates base of the event log.  This traces
444075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *     a 256-entry history of uCode execution within a circular buffer.
445075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *     Its header format is:
446075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *
447075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *	__le32 log_size;     log capacity (in number of entries)
448075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *	__le32 type;         (1) timestamp with each entry, (0) no timestamp
449075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *	__le32 wraps;        # times uCode has wrapped to top of circular buffer
450075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *      __le32 write_index;  next circular buffer entry that uCode would fill
451075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *
452075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *     The header is followed by the circular buffer of log entries.  Entries
453075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *     with timestamps have the following format:
454075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *
455075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *	__le32 event_id;     range 0 - 1500
456075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *	__le32 timestamp;    low 32 bits of TSF (of network, if associated)
457075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *	__le32 data;         event_id-specific data value
458075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *
459075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *     Entries without timestamps contain only event_id and data.
460075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *
461075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill * 2)  error_event_table_ptr indicates base of the error log.  This contains
462075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *     information about any uCode error that occurs.  For 4965, the format
463075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *     of the error log is:
464075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *
465075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *	__le32 valid;        (nonzero) valid, (0) log is empty
466075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *	__le32 error_id;     type of error
467075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *	__le32 pc;           program counter
468075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *	__le32 blink1;       branch link
469075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *	__le32 blink2;       branch link
470075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *	__le32 ilink1;       interrupt link
471075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *	__le32 ilink2;       interrupt link
472075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *	__le32 data1;        error-specific data
473075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *	__le32 data2;        error-specific data
474075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *	__le32 line;         source code line of error
475075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *	__le32 bcon_time;    beacon timer
476075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *	__le32 tsf_low;      network timestamp function timer
477075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *	__le32 tsf_hi;       network timestamp function timer
478075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *
479075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill * The Linux driver can print both logs to the system log when a uCode error
480075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill * occurs.
481075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill */
482885ba202cabd90b8ade1fe59185dc96ed4d69e02Tomas Winklerstruct iwl_alive_resp {
483b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 ucode_minor;
484b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 ucode_major;
485b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 reserved1;
486b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 sw_rev[8];
487b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 ver_type;
488075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill	u8 ver_subtype;			/* not "9" for runtime alive */
489b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 reserved2;
490075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill	__le32 log_event_table_ptr;	/* SRAM address for event log */
491075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill	__le32 error_event_table_ptr;	/* SRAM address for error log */
492b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 timestamp;
493b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 is_valid;
494b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
495b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
496075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill
497b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
498b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
499b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_ERROR = 0x2 (response only, not a command)
500b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
501885ba202cabd90b8ade1fe59185dc96ed4d69e02Tomas Winklerstruct iwl_error_resp {
502b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 error_type;
503b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 cmd_id;
504b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 reserved1;
505b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 bad_cmd_seq_num;
506b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 error_info;
5073195c1f3499912b207ae600968488759b16037fcTomas Winkler	__le64 timestamp;
508b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
509b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
510b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/******************************************************************************
511b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * (1)
512b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * RXON Commands & Responses:
513b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
514b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *****************************************************************************/
515b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
516b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
517b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Rx config defines & structure
518b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
519b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* rx_config device types  */
520b481de9ca074528fe8c429604e2777db8b89806aZhu Yienum {
521b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	RXON_DEV_TYPE_AP = 1,
522b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	RXON_DEV_TYPE_ESS = 3,
523b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	RXON_DEV_TYPE_IBSS = 4,
524b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	RXON_DEV_TYPE_SNIFFER = 6,
525b481de9ca074528fe8c429604e2777db8b89806aZhu Yi};
526b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
52714519a0b46085db68e610147098d03386c34801fBen M Cahill
52851e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_RX_CHAIN_DRIVER_FORCE_MSK		cpu_to_le16(0x1 << 0)
52951e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_RX_CHAIN_VALID_MSK			cpu_to_le16(0x7 << 1)
53014519a0b46085db68e610147098d03386c34801fBen M Cahill#define RXON_RX_CHAIN_VALID_POS			(1)
53151e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_RX_CHAIN_FORCE_SEL_MSK		cpu_to_le16(0x7 << 4)
53214519a0b46085db68e610147098d03386c34801fBen M Cahill#define RXON_RX_CHAIN_FORCE_SEL_POS		(4)
53351e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_RX_CHAIN_FORCE_MIMO_SEL_MSK	cpu_to_le16(0x7 << 7)
53414519a0b46085db68e610147098d03386c34801fBen M Cahill#define RXON_RX_CHAIN_FORCE_MIMO_SEL_POS	(7)
53551e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_RX_CHAIN_CNT_MSK			cpu_to_le16(0x3 << 10)
53614519a0b46085db68e610147098d03386c34801fBen M Cahill#define RXON_RX_CHAIN_CNT_POS			(10)
53751e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_RX_CHAIN_MIMO_CNT_MSK		cpu_to_le16(0x3 << 12)
53814519a0b46085db68e610147098d03386c34801fBen M Cahill#define RXON_RX_CHAIN_MIMO_CNT_POS		(12)
53951e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_RX_CHAIN_MIMO_FORCE_MSK		cpu_to_le16(0x1 << 14)
54014519a0b46085db68e610147098d03386c34801fBen M Cahill#define RXON_RX_CHAIN_MIMO_FORCE_POS		(14)
54114519a0b46085db68e610147098d03386c34801fBen M Cahill
542b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* rx_config flags */
543b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* band & modulation selection */
54451e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FLG_BAND_24G_MSK           cpu_to_le32(1 << 0)
54551e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FLG_CCK_MSK                cpu_to_le32(1 << 1)
546b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* auto detection enable */
54751e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FLG_AUTO_DETECT_MSK        cpu_to_le32(1 << 2)
548b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* TGg protection when tx */
54951e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FLG_TGG_PROTECT_MSK        cpu_to_le32(1 << 3)
550b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* cck short slot & preamble */
55151e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FLG_SHORT_SLOT_MSK          cpu_to_le32(1 << 4)
55251e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FLG_SHORT_PREAMBLE_MSK     cpu_to_le32(1 << 5)
553b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* antenna selection */
55451e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FLG_DIS_DIV_MSK            cpu_to_le32(1 << 7)
55551e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FLG_ANT_SEL_MSK            cpu_to_le32(0x0f00)
55651e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FLG_ANT_A_MSK              cpu_to_le32(1 << 8)
55751e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FLG_ANT_B_MSK              cpu_to_le32(1 << 9)
558b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* radar detection enable */
55951e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FLG_RADAR_DETECT_MSK       cpu_to_le32(1 << 12)
56051e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FLG_TGJ_NARROW_BAND_MSK    cpu_to_le32(1 << 13)
561b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* rx response to host with 8-byte TSF
562b481de9ca074528fe8c429604e2777db8b89806aZhu Yi* (according to ON_AIR deassertion) */
56351e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FLG_TSF2HOST_MSK           cpu_to_le32(1 << 15)
564b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
56514519a0b46085db68e610147098d03386c34801fBen M Cahill
56614519a0b46085db68e610147098d03386c34801fBen M Cahill/* HT flags */
56714519a0b46085db68e610147098d03386c34801fBen M Cahill#define RXON_FLG_CTRL_CHANNEL_LOC_POS		(22)
56851e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK	cpu_to_le32(0x1 << 22)
56914519a0b46085db68e610147098d03386c34801fBen M Cahill
57014519a0b46085db68e610147098d03386c34801fBen M Cahill#define RXON_FLG_HT_OPERATING_MODE_POS		(23)
57114519a0b46085db68e610147098d03386c34801fBen M Cahill
57251e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FLG_HT_PROT_MSK			cpu_to_le32(0x1 << 23)
57351e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FLG_FAT_PROT_MSK			cpu_to_le32(0x2 << 23)
57414519a0b46085db68e610147098d03386c34801fBen M Cahill
57514519a0b46085db68e610147098d03386c34801fBen M Cahill#define RXON_FLG_CHANNEL_MODE_POS		(25)
57651e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FLG_CHANNEL_MODE_MSK		cpu_to_le32(0x3 << 25)
57751e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FLG_CHANNEL_MODE_PURE_40_MSK	cpu_to_le32(0x1 << 25)
57851e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FLG_CHANNEL_MODE_MIXED_MSK		cpu_to_le32(0x2 << 25)
579a326a5d096f031af46c0073dd78eb80dea1f311aEmmanuel Grumbach/* CTS to self (if spec allows) flag */
58051e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FLG_SELF_CTS_EN			cpu_to_le32(0x1<<30)
58114519a0b46085db68e610147098d03386c34801fBen M Cahill
582b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* rx_config filter flags */
583b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* accept all data frames */
58451e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FILTER_PROMISC_MSK         cpu_to_le32(1 << 0)
585b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* pass control & management to host */
58651e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FILTER_CTL2HOST_MSK        cpu_to_le32(1 << 1)
587b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* accept multi-cast */
58851e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FILTER_ACCEPT_GRP_MSK      cpu_to_le32(1 << 2)
589b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* don't decrypt uni-cast frames */
59051e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FILTER_DIS_DECRYPT_MSK     cpu_to_le32(1 << 3)
591b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* don't decrypt multi-cast frames */
59251e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FILTER_DIS_GRP_DECRYPT_MSK cpu_to_le32(1 << 4)
593b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* STA is associated */
59451e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FILTER_ASSOC_MSK           cpu_to_le32(1 << 5)
595b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* transfer to host non bssid beacons in associated state */
59651e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FILTER_BCON_AWARE_MSK      cpu_to_le32(1 << 6)
597b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
59880cc0c382db318de88577eff027d5c4097abef81Ben M Cahill/**
599b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_RXON = 0x10 (command, has simple generic response)
60080cc0c382db318de88577eff027d5c4097abef81Ben M Cahill *
60180cc0c382db318de88577eff027d5c4097abef81Ben M Cahill * RXON tunes the radio tuner to a service channel, and sets up a number
60280cc0c382db318de88577eff027d5c4097abef81Ben M Cahill * of parameters that are used primarily for Rx, but also for Tx operations.
60380cc0c382db318de88577eff027d5c4097abef81Ben M Cahill *
60480cc0c382db318de88577eff027d5c4097abef81Ben M Cahill * NOTE:  When tuning to a new channel, driver must set the
60580cc0c382db318de88577eff027d5c4097abef81Ben M Cahill *        RXON_FILTER_ASSOC_MSK to 0.  This will clear station-dependent
60680cc0c382db318de88577eff027d5c4097abef81Ben M Cahill *        info within the device, including the station tables, tx retry
60780cc0c382db318de88577eff027d5c4097abef81Ben M Cahill *        rate tables, and txpower tables.  Driver must build a new station
60880cc0c382db318de88577eff027d5c4097abef81Ben M Cahill *        table and txpower table before transmitting anything on the RXON
60980cc0c382db318de88577eff027d5c4097abef81Ben M Cahill *        channel.
61080cc0c382db318de88577eff027d5c4097abef81Ben M Cahill *
61180cc0c382db318de88577eff027d5c4097abef81Ben M Cahill * NOTE:  All RXONs wipe clean the internal txpower table.  Driver must
61280cc0c382db318de88577eff027d5c4097abef81Ben M Cahill *        issue a new REPLY_TX_PWR_TABLE_CMD after each REPLY_RXON (0x10),
61380cc0c382db318de88577eff027d5c4097abef81Ben M Cahill *        regardless of whether RXON_FILTER_ASSOC_MSK is set.
614b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
615bb8c093bdea62f2ae371b98ebff81b0407852fafChristoph Hellwigstruct iwl4965_rxon_cmd {
616b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 node_addr[6];
617b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 reserved1;
618b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 bssid_addr[6];
619b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 reserved2;
620b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 wlap_bssid_addr[6];
621b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 reserved3;
622b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 dev_type;
623b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 air_propagation;
624b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 rx_chain;
625b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 ofdm_basic_rates;
626b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 cck_basic_rates;
627b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 assoc_id;
628b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 flags;
629b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 filter_flags;
630b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 channel;
631b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 ofdm_ht_single_stream_basic_rates;
632b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 ofdm_ht_dual_stream_basic_rates;
633b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
634b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
635a96a27f97f2bbfc1fca54bc3c0b0d41484152740Tomas Winkler/* 5000 HW just extend this command */
636c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenmanstruct iwl_rxon_cmd {
637c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	u8 node_addr[6];
638c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	__le16 reserved1;
639c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	u8 bssid_addr[6];
640c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	__le16 reserved2;
641c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	u8 wlap_bssid_addr[6];
642c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	__le16 reserved3;
643c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	u8 dev_type;
644c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	u8 air_propagation;
645c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	__le16 rx_chain;
646c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	u8 ofdm_basic_rates;
647c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	u8 cck_basic_rates;
648c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	__le16 assoc_id;
649c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	__le32 flags;
650c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	__le32 filter_flags;
651c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	__le16 channel;
652c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	u8 ofdm_ht_single_stream_basic_rates;
653c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	u8 ofdm_ht_dual_stream_basic_rates;
654c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	u8 ofdm_ht_triple_stream_basic_rates;
655c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	u8 reserved5;
656c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	__le16 acquisition_data;
657c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	__le16 reserved6;
658c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman} __attribute__ ((packed));
659c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman
660fe7a90c2b73f0c1da0882861cd015c835ed28781Ron Rindjunskystruct iwl5000_rxon_assoc_cmd {
661fe7a90c2b73f0c1da0882861cd015c835ed28781Ron Rindjunsky	__le32 flags;
662fe7a90c2b73f0c1da0882861cd015c835ed28781Ron Rindjunsky	__le32 filter_flags;
663fe7a90c2b73f0c1da0882861cd015c835ed28781Ron Rindjunsky	u8 ofdm_basic_rates;
664fe7a90c2b73f0c1da0882861cd015c835ed28781Ron Rindjunsky	u8 cck_basic_rates;
665fe7a90c2b73f0c1da0882861cd015c835ed28781Ron Rindjunsky	__le16 reserved1;
666fe7a90c2b73f0c1da0882861cd015c835ed28781Ron Rindjunsky	u8 ofdm_ht_single_stream_basic_rates;
667fe7a90c2b73f0c1da0882861cd015c835ed28781Ron Rindjunsky	u8 ofdm_ht_dual_stream_basic_rates;
668fe7a90c2b73f0c1da0882861cd015c835ed28781Ron Rindjunsky	u8 ofdm_ht_triple_stream_basic_rates;
669fe7a90c2b73f0c1da0882861cd015c835ed28781Ron Rindjunsky	u8 reserved2;
670fe7a90c2b73f0c1da0882861cd015c835ed28781Ron Rindjunsky	__le16 rx_chain_select_flags;
671fe7a90c2b73f0c1da0882861cd015c835ed28781Ron Rindjunsky	__le16 acquisition_data;
672fe7a90c2b73f0c1da0882861cd015c835ed28781Ron Rindjunsky	__le32 reserved3;
673fe7a90c2b73f0c1da0882861cd015c835ed28781Ron Rindjunsky} __attribute__ ((packed));
674c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman
675b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
676b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_RXON_ASSOC = 0x11 (command, has simple generic response)
677b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
678bb8c093bdea62f2ae371b98ebff81b0407852fafChristoph Hellwigstruct iwl4965_rxon_assoc_cmd {
679b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 flags;
680b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 filter_flags;
681b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 ofdm_basic_rates;
682b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 cck_basic_rates;
683b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 ofdm_ht_single_stream_basic_rates;
684b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 ofdm_ht_dual_stream_basic_rates;
685b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 rx_chain_select_flags;
686b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 reserved;
687b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
688b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
689b5d7be5e665f29274cfe6645b661acb38cb1d19bTomas Winkler#define IWL_CONN_MAX_LISTEN_INTERVAL	10
690fe7a90c2b73f0c1da0882861cd015c835ed28781Ron Rindjunsky
691b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
692b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_RXON_TIMING = 0x14 (command, has simple generic response)
693b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
6943195c1f3499912b207ae600968488759b16037fcTomas Winklerstruct iwl_rxon_time_cmd {
6953195c1f3499912b207ae600968488759b16037fcTomas Winkler	__le64 timestamp;
696b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 beacon_interval;
697b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 atim_window;
698b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 beacon_init_val;
699b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 listen_interval;
700b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 reserved;
701b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
702b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
703b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
704b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_CHANNEL_SWITCH = 0x72 (command, has simple generic response)
705b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
7062aa6ab86bc475a115f56645591d2413981846509Tomas Winklerstruct iwl_channel_switch_cmd {
707b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 band;
708b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 expect_beacon;
709b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 channel;
710b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 rxon_flags;
711b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 rxon_filter_flags;
712b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 switch_time;
713bb8c093bdea62f2ae371b98ebff81b0407852fafChristoph Hellwig	struct iwl4965_tx_power_db tx_power;
714b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
715b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
716b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
717b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * CHANNEL_SWITCH_NOTIFICATION = 0x73 (notification only, not a command)
718b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
7192aa6ab86bc475a115f56645591d2413981846509Tomas Winklerstruct iwl_csa_notification {
720b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 band;
721b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 channel;
722b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 status;		/* 0 - OK, 1 - fail */
723b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
724b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
725b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/******************************************************************************
726b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * (2)
727b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Quality-of-Service (QOS) Commands & Responses:
728b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
729b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *****************************************************************************/
7302054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill
7312054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill/**
7322054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * struct iwl_ac_qos -- QOS timing params for REPLY_QOS_PARAM
7332054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * One for each of 4 EDCA access categories in struct iwl_qosparam_cmd
7342054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *
7352054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * @cw_min: Contention window, start value in numbers of slots.
7362054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *          Should be a power-of-2, minus 1.  Device's default is 0x0f.
7372054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * @cw_max: Contention window, max value in numbers of slots.
7382054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *          Should be a power-of-2, minus 1.  Device's default is 0x3f.
7392054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * @aifsn:  Number of slots in Arbitration Interframe Space (before
7402054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *          performing random backoff timing prior to Tx).  Device default 1.
7412054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * @edca_txop:  Length of Tx opportunity, in uSecs.  Device default is 0.
7422054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *
7432054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * Device will automatically increase contention window by (2*CW) + 1 for each
7442054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * transmission retry.  Device uses cw_max as a bit mask, ANDed with new CW
7452054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * value, to cap the CW value.
7462054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill */
7471ff50bda6eef4466366e197541508fc69af0f0c0Emmanuel Grumbachstruct iwl_ac_qos {
748b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 cw_min;
749b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 cw_max;
750b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 aifsn;
751b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 reserved1;
752b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 edca_txop;
753b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
754b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
755b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* QoS flags defines */
75651e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define QOS_PARAM_FLG_UPDATE_EDCA_MSK	cpu_to_le32(0x01)
75751e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define QOS_PARAM_FLG_TGN_MSK		cpu_to_le32(0x02)
75851e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define QOS_PARAM_FLG_TXOP_TYPE_MSK	cpu_to_le32(0x10)
759b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
7602054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill/* Number of Access Categories (AC) (EDCA), queues 0..3 */
761b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define AC_NUM                4
762b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
763b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
764b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_QOS_PARAM = 0x13 (command, has simple generic response)
7652054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *
7662054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * This command sets up timings for each of the 4 prioritized EDCA Tx FIFOs
7672054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * 0: Background, 1: Best Effort, 2: Video, 3: Voice.
768b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
7691ff50bda6eef4466366e197541508fc69af0f0c0Emmanuel Grumbachstruct iwl_qosparam_cmd {
770b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 qos_flags;
7711ff50bda6eef4466366e197541508fc69af0f0c0Emmanuel Grumbach	struct iwl_ac_qos ac[AC_NUM];
772b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
773b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
774b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/******************************************************************************
775b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * (3)
776b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Add/Modify Stations Commands & Responses:
777b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
778b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *****************************************************************************/
779b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
780b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Multi station support
781b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
7822054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill
7832054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill/* Special, dedicated locations within device's station table */
784b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define	IWL_AP_ID		0
785b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define IWL_MULTICAST_ID	1
786b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define	IWL_STA_ID		2
787b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define IWL4965_BROADCAST_ID	31
788b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define	IWL4965_STATION_COUNT	32
789fdd3e8a4ff96d03121b21946bfa684f3b5d783c6Tomas Winkler#define IWL5000_BROADCAST_ID	15
790fdd3e8a4ff96d03121b21946bfa684f3b5d783c6Tomas Winkler#define	IWL5000_STATION_COUNT	16
791b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
792b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define	IWL_STATION_COUNT	32 	/* MAX(3945,4965)*/
793b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define	IWL_INVALID_STATION 	255
794b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
79551e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define STA_FLG_PWR_SAVE_MSK		cpu_to_le32(1 << 8);
79651e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define STA_FLG_RTS_MIMO_PROT_MSK	cpu_to_le32(1 << 17)
79751e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define STA_FLG_AGG_MPDU_8US_MSK	cpu_to_le32(1 << 18)
79874093ddf4c42da74922b63fb6844989e21164d9eBen M Cahill#define STA_FLG_MAX_AGG_SIZE_POS	(19)
79951e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define STA_FLG_MAX_AGG_SIZE_MSK	cpu_to_le32(3 << 19)
80051e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define STA_FLG_FAT_EN_MSK		cpu_to_le32(1 << 21)
80151e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define STA_FLG_MIMO_DIS_MSK		cpu_to_le32(1 << 22)
80274093ddf4c42da74922b63fb6844989e21164d9eBen M Cahill#define STA_FLG_AGG_MPDU_DENSITY_POS	(23)
80351e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define STA_FLG_AGG_MPDU_DENSITY_MSK	cpu_to_le32(7 << 23)
804b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
8052054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill/* Use in mode field.  1: modify existing entry, 0: add new station entry */
806b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define STA_CONTROL_MODIFY_MSK		0x01
807b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
808b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* key flags __le16*/
80951e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define STA_KEY_FLG_ENCRYPT_MSK	cpu_to_le16(0x0007)
81051e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define STA_KEY_FLG_NO_ENC	cpu_to_le16(0x0000)
81151e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define STA_KEY_FLG_WEP		cpu_to_le16(0x0001)
81251e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define STA_KEY_FLG_CCMP	cpu_to_le16(0x0002)
81351e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define STA_KEY_FLG_TKIP	cpu_to_le16(0x0003)
814b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
815b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define STA_KEY_FLG_KEYID_POS	8
81651e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define STA_KEY_FLG_INVALID 	cpu_to_le16(0x0800)
817eaaf7894959d413d1e01443a622c507e1b4f61dbEmmanuel Grumbach/* wep key is either from global key (0) or from station info array (1) */
81851e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define STA_KEY_FLG_MAP_KEY_MSK	cpu_to_le16(0x0008)
819eaaf7894959d413d1e01443a622c507e1b4f61dbEmmanuel Grumbach
820eaaf7894959d413d1e01443a622c507e1b4f61dbEmmanuel Grumbach/* wep key in STA: 5-bytes (0) or 13-bytes (1) */
82151e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define STA_KEY_FLG_KEY_SIZE_MSK     cpu_to_le16(0x1000)
82251e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define STA_KEY_MULTICAST_MSK        cpu_to_le16(0x4000)
823deb09c435e3f947f8b2c9d5df6a9c0a5b472b125Emmanuel Grumbach#define STA_KEY_MAX_NUM		8
824b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
8252054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill/* Flags indicate whether to modify vs. don't change various station params */
826b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define	STA_MODIFY_KEY_MASK		0x01
827b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define	STA_MODIFY_TID_DISABLE_TX	0x02
828b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define	STA_MODIFY_TX_RATE_MSK		0x04
829b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define STA_MODIFY_ADDBA_TID_MSK	0x08
830b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define STA_MODIFY_DELBA_TID_MSK	0x10
8312054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill
8322054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill/* Receiver address (actually, Rx station's index into station table),
8332054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * combined with Traffic ID (QOS priority), in format used by Tx Scheduler */
834b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define BUILD_RAxTID(sta_id, tid)	(((sta_id) << 4) + (tid))
835b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
836bb8c093bdea62f2ae371b98ebff81b0407852fafChristoph Hellwigstruct iwl4965_keyinfo {
837b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 key_flags;
838b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 tkip_rx_tsc_byte2;	/* TSC[2] for key mix ph1 detection */
839b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 reserved1;
840b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 tkip_rx_ttak[5];	/* 10-byte unicast TKIP TTAK */
841eaaf7894959d413d1e01443a622c507e1b4f61dbEmmanuel Grumbach	u8 key_offset;
842eaaf7894959d413d1e01443a622c507e1b4f61dbEmmanuel Grumbach	u8 reserved2;
843b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 key[16];		/* 16-byte unicast decryption key */
844b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
845b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
846133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler/* 5000 */
847133636deffc86809f59a0c8b768408d13237a9a2Tomas Winklerstruct iwl_keyinfo {
848133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	__le16 key_flags;
849133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	u8 tkip_rx_tsc_byte2;	/* TSC[2] for key mix ph1 detection */
850133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	u8 reserved1;
851133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	__le16 tkip_rx_ttak[5];	/* 10-byte unicast TKIP TTAK */
852133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	u8 key_offset;
853133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	u8 reserved2;
854133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	u8 key[16];		/* 16-byte unicast decryption key */
855133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	__le64 tx_secur_seq_cnt;
856133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	__le64 hw_tkip_mic_rx_key;
857133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	__le64 hw_tkip_mic_tx_key;
858133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler} __attribute__ ((packed));
859133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler
8602054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill/**
8612054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * struct sta_id_modify
8622054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * @addr[ETH_ALEN]: station's MAC address
8632054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * @sta_id: index of station in uCode's station table
8642054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * @modify_mask: STA_MODIFY_*, 1: modify, 0: don't change
8652054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *
8662054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * Driver selects unused table index when adding new station,
8672054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * or the index to a pre-existing station entry when modifying that station.
8682054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * Some indexes have special purposes (IWL_AP_ID, index 0, is for AP).
8692054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *
8702054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * modify_mask flags select which parameters to modify vs. leave alone.
8712054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill */
872b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct sta_id_modify {
873b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 addr[ETH_ALEN];
874b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 reserved1;
875b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 sta_id;
876b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 modify_mask;
877b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 reserved2;
878b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
879b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
880b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
881b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_ADD_STA = 0x18 (command)
8822054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *
8832054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * The device contains an internal table of per-station information,
8842054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * with info on security keys, aggregation parameters, and Tx rates for
8852054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * initial Tx attempt and any retries (4965 uses REPLY_TX_LINK_QUALITY_CMD,
8862054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * 3945 uses REPLY_RATE_SCALE to set up rate tables).
8872054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *
8882054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * REPLY_ADD_STA sets up the table entry for one station, either creating
8892054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * a new entry, or modifying a pre-existing one.
8902054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *
8912054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * NOTE:  RXON command (without "associated" bit set) wipes the station table
8922054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *        clean.  Moving into RF_KILL state does this also.  Driver must set up
8932054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *        new station table before transmitting anything on the RXON channel
8942054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *        (except active scans or active measurements; those commands carry
8952054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *        their own txpower/rate setup data).
8962054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *
8972054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *        When getting started on a new channel, driver must set up the
8982054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *        IWL_BROADCAST_ID entry (last entry in the table).  For a client
8992054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *        station in a BSS, once an AP is selected, driver sets up the AP STA
9002054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *        in the IWL_AP_ID entry (1st entry in the table).  BROADCAST and AP
9012054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *        are all that are needed for a BSS client station.  If the device is
9022054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *        used as AP, or in an IBSS network, driver must set up station table
9032054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *        entries for all STAs in network, starting with index IWL_STA_ID.
904b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
905bb8c093bdea62f2ae371b98ebff81b0407852fafChristoph Hellwigstruct iwl4965_addsta_cmd {
9062054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill	u8 mode;		/* 1: modify existing, 0: add new station */
907b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 reserved[3];
908b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct sta_id_modify sta;
909bb8c093bdea62f2ae371b98ebff81b0407852fafChristoph Hellwig	struct iwl4965_keyinfo key;
9102054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill	__le32 station_flags;		/* STA_FLG_* */
9112054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill	__le32 station_flags_msk;	/* STA_FLG_* */
9122054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill
9132054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill	/* bit field to disable (1) or enable (0) Tx for Traffic ID (TID)
9142054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill	 * corresponding to bit (e.g. bit 5 controls TID 5).
9152054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill	 * Set modify_mask bit STA_MODIFY_TID_DISABLE_TX to use this field. */
916b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 tid_disable_tx;
9172054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill
918b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16	reserved1;
9192054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill
9202054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill	/* TID for which to add block-ack support.
9212054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill	 * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */
922b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 add_immediate_ba_tid;
9232054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill
9242054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill	/* TID for which to remove block-ack support.
9252054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill	 * Set modify_mask bit STA_MODIFY_DELBA_TID_MSK to use this field. */
926b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 remove_immediate_ba_tid;
9272054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill
9282054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill	/* Starting Sequence Number for added block-ack support.
9292054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill	 * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */
930b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 add_immediate_ba_ssn;
9312054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill
932b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 reserved2;
933b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
934b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
935133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler/* 5000 */
936133636deffc86809f59a0c8b768408d13237a9a2Tomas Winklerstruct iwl_addsta_cmd {
937133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	u8 mode;		/* 1: modify existing, 0: add new station */
938133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	u8 reserved[3];
939133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	struct sta_id_modify sta;
940133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	struct iwl_keyinfo key;
941133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	__le32 station_flags;		/* STA_FLG_* */
942133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	__le32 station_flags_msk;	/* STA_FLG_* */
943133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler
944133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	/* bit field to disable (1) or enable (0) Tx for Traffic ID (TID)
945133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	 * corresponding to bit (e.g. bit 5 controls TID 5).
946133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	 * Set modify_mask bit STA_MODIFY_TID_DISABLE_TX to use this field. */
947133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	__le16 tid_disable_tx;
948133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler
949133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	__le16	reserved1;
950133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler
951133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	/* TID for which to add block-ack support.
952133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	 * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */
953133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	u8 add_immediate_ba_tid;
954133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler
955133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	/* TID for which to remove block-ack support.
956133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	 * Set modify_mask bit STA_MODIFY_DELBA_TID_MSK to use this field. */
957133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	u8 remove_immediate_ba_tid;
958133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler
959133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	/* Starting Sequence Number for added block-ack support.
960133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	 * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */
961133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	__le16 add_immediate_ba_ssn;
962133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler
963133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	__le32 reserved2;
964133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler} __attribute__ ((packed));
965133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler
966133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler
9672054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill#define ADD_STA_SUCCESS_MSK		0x1
9682054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill#define ADD_STA_NO_ROOM_IN_TABLE	0x2
9692054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill#define ADD_STA_NO_BLOCK_ACK_RESOURCE	0x4
9702054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill#define ADD_STA_MODIFY_NON_EXIST_STA	0x8
971b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
972b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_ADD_STA = 0x18 (response)
973b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
9747a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winklerstruct iwl_add_sta_resp {
9752054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill	u8 status;	/* ADD_STA_* */
976b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
977b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
9787a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winkler#define REM_STA_SUCCESS_MSK              0x1
9797a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winkler/*
9807a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winkler *  REPLY_REM_STA = 0x19 (response)
9817a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winkler */
9827a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winklerstruct iwl_rem_sta_resp {
9837a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winkler	u8 status;
9847a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winkler} __attribute__ ((packed));
9857a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winkler
9867a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winkler/*
9877a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winkler *  REPLY_REM_STA = 0x19 (command)
9887a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winkler */
9897a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winklerstruct iwl_rem_sta_cmd {
9907a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winkler	u8 num_sta;     /* number of removed stations */
9917a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winkler	u8 reserved[3];
9927a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winkler	u8 addr[ETH_ALEN]; /* MAC addr of the first station */
9937a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winkler	u8 reserved2[2];
9947a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winkler} __attribute__ ((packed));
9957a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winkler
9960a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach/*
9970a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach * REPLY_WEP_KEY = 0x20
9980a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach */
9990a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbachstruct iwl_wep_key {
10000a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach	u8 key_index;
10010a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach	u8 key_offset;
10020a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach	u8 reserved1[2];
10030a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach	u8 key_size;
10040a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach	u8 reserved2[3];
10050a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach	u8 key[16];
10060a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach} __attribute__ ((packed));
10070a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach
10080a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbachstruct iwl_wep_cmd {
10090a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach	u8 num_keys;
10100a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach	u8 global_key_type;
10110a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach	u8 flags;
10120a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach	u8 reserved;
10130a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach	struct iwl_wep_key key[0];
10140a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach} __attribute__ ((packed));
10150a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach
10160a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach#define WEP_KEY_WEP_TYPE 1
10170a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach#define WEP_KEYS_MAX 4
10180a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach#define WEP_INVALID_OFFSET 0xff
10194564ce8b0e17d91d047aa875843deb2cccf3f268Emmanuel Grumbach#define WEP_KEY_LEN_64 5
10200a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach#define WEP_KEY_LEN_128 13
1021b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1022b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/******************************************************************************
1023b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * (4)
1024b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Rx Responses:
1025b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
1026b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *****************************************************************************/
1027b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
102851e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RX_RES_STATUS_NO_CRC32_ERROR	cpu_to_le32(1 << 0)
102951e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RX_RES_STATUS_NO_RXE_OVERFLOW	cpu_to_le32(1 << 1)
10308211ef78d9023a8772e5acf6b7934598156b2fc8Tomas Winkler
103151e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RX_RES_PHY_FLAGS_BAND_24_MSK	cpu_to_le16(1 << 0)
103251e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RX_RES_PHY_FLAGS_MOD_CCK_MSK		cpu_to_le16(1 << 1)
103351e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RX_RES_PHY_FLAGS_SHORT_PREAMBLE_MSK	cpu_to_le16(1 << 2)
103451e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RX_RES_PHY_FLAGS_NARROW_BAND_MSK	cpu_to_le16(1 << 3)
103551e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RX_RES_PHY_FLAGS_ANTENNA_MSK		cpu_to_le16(0xf0)
10368211ef78d9023a8772e5acf6b7934598156b2fc8Tomas Winkler
10378211ef78d9023a8772e5acf6b7934598156b2fc8Tomas Winkler#define RX_RES_STATUS_SEC_TYPE_MSK	(0x7 << 8)
10388211ef78d9023a8772e5acf6b7934598156b2fc8Tomas Winkler#define RX_RES_STATUS_SEC_TYPE_NONE	(0x0 << 8)
10398211ef78d9023a8772e5acf6b7934598156b2fc8Tomas Winkler#define RX_RES_STATUS_SEC_TYPE_WEP	(0x1 << 8)
10408211ef78d9023a8772e5acf6b7934598156b2fc8Tomas Winkler#define RX_RES_STATUS_SEC_TYPE_CCMP	(0x2 << 8)
10418211ef78d9023a8772e5acf6b7934598156b2fc8Tomas Winkler#define RX_RES_STATUS_SEC_TYPE_TKIP	(0x3 << 8)
104217e476b8db13790c03e2c46d93abc71468fca47eEmmanuel Grumbach#define	RX_RES_STATUS_SEC_TYPE_ERR	(0x7 << 8)
104317e476b8db13790c03e2c46d93abc71468fca47eEmmanuel Grumbach
104417e476b8db13790c03e2c46d93abc71468fca47eEmmanuel Grumbach#define RX_RES_STATUS_STATION_FOUND	(1<<6)
104517e476b8db13790c03e2c46d93abc71468fca47eEmmanuel Grumbach#define RX_RES_STATUS_NO_STATION_INFO_MISMATCH	(1<<7)
10468211ef78d9023a8772e5acf6b7934598156b2fc8Tomas Winkler
10478211ef78d9023a8772e5acf6b7934598156b2fc8Tomas Winkler#define RX_RES_STATUS_DECRYPT_TYPE_MSK	(0x3 << 11)
10488211ef78d9023a8772e5acf6b7934598156b2fc8Tomas Winkler#define RX_RES_STATUS_NOT_DECRYPT	(0x0 << 11)
10498211ef78d9023a8772e5acf6b7934598156b2fc8Tomas Winkler#define RX_RES_STATUS_DECRYPT_OK	(0x3 << 11)
10508211ef78d9023a8772e5acf6b7934598156b2fc8Tomas Winkler#define RX_RES_STATUS_BAD_ICV_MIC	(0x1 << 11)
10518211ef78d9023a8772e5acf6b7934598156b2fc8Tomas Winkler#define RX_RES_STATUS_BAD_KEY_TTAK	(0x2 << 11)
1052b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
105317e476b8db13790c03e2c46d93abc71468fca47eEmmanuel Grumbach#define RX_MPDU_RES_STATUS_ICV_OK	(0x20)
105417e476b8db13790c03e2c46d93abc71468fca47eEmmanuel Grumbach#define RX_MPDU_RES_STATUS_MIC_OK	(0x40)
105517e476b8db13790c03e2c46d93abc71468fca47eEmmanuel Grumbach#define RX_MPDU_RES_STATUS_TTAK_OK	(1 << 7)
105617e476b8db13790c03e2c46d93abc71468fca47eEmmanuel Grumbach#define RX_MPDU_RES_STATUS_DEC_DONE_MSK	(0x800)
105717e476b8db13790c03e2c46d93abc71468fca47eEmmanuel Grumbach
1058b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* Fixed (non-configurable) rx data from phy */
1059caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler
1060caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler#define IWL49_RX_RES_PHY_CNT 14
1061caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler#define IWL49_RX_PHY_FLAGS_ANTENNAE_OFFSET	(4)
1062caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler#define IWL49_RX_PHY_FLAGS_ANTENNAE_MASK	(0x70)
1063caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler#define IWL49_AGC_DB_MASK			(0x3f80)	/* MASK(7,13) */
1064caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler#define IWL49_AGC_DB_POS			(7)
1065b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct iwl4965_rx_non_cfg_phy {
1066b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 ant_selection;	/* ant A bit 4, ant B bit 5, ant C bit 6 */
1067b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 agc_info;	/* agc code 0:6, agc dB 7:13, reserved 14:15 */
1068b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 rssi_info[6];	/* we use even entries, 0/2/4 for A/B/C rssi */
1069b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 pad[0];
1070b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
1071b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1072caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler
1073caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler#define IWL50_RX_RES_PHY_CNT 8
1074caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler#define IWL50_RX_RES_AGC_IDX     1
1075caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler#define IWL50_RX_RES_RSSI_AB_IDX 2
1076caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler#define IWL50_RX_RES_RSSI_C_IDX  3
1077caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler#define IWL50_OFDM_AGC_MSK 0xfe00
1078caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler#define IWL50_OFDM_AGC_BIT_POS 9
1079caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler#define IWL50_OFDM_RSSI_A_MSK 0x00ff
1080caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler#define IWL50_OFDM_RSSI_A_BIT_POS 0
1081caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler#define IWL50_OFDM_RSSI_B_MSK 0xff0000
1082caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler#define IWL50_OFDM_RSSI_B_BIT_POS 16
1083caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler#define IWL50_OFDM_RSSI_C_MSK 0x00ff
1084caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler#define IWL50_OFDM_RSSI_C_BIT_POS 0
1085caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler
1086caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winklerstruct iwl5000_non_cfg_phy {
1087a96a27f97f2bbfc1fca54bc3c0b0d41484152740Tomas Winkler	__le32 non_cfg_phy[IWL50_RX_RES_PHY_CNT];  /* up to 8 phy entries */
1088caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler} __attribute__ ((packed));
1089caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler
1090caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler
1091b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
1092857485c0c46ceee5c658c1761bba4d9a5ddf433fTomas Winkler * REPLY_RX = 0xc3 (response only, not a command)
1093b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Used only for legacy (non 11n) frames.
1094b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
1095caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winklerstruct iwl_rx_phy_res {
1096b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 non_cfg_phy_cnt;     /* non configurable DSP phy data byte count */
1097b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 cfg_phy_cnt;		/* configurable DSP phy data byte count */
1098b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 stat_id;		/* configurable DSP phy data set ID */
1099b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 reserved1;
1100b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le64 timestamp;	/* TSF at on air rise */
1101b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 beacon_time_stamp; /* beacon at on-air rise */
1102b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 phy_flags;	/* general phy flags: band, modulation, ... */
1103b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 channel;		/* channel number */
1104caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler	u8 non_cfg_phy_buf[32]; /* for various implementations of non_cfg_phy */
1105529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	__le32 rate_n_flags;	/* RATE_MCS_* */
1106529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	__le16 byte_count;	/* frame's byte-count */
1107b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 reserved3;
1108b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
1109b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1110b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct iwl4965_rx_mpdu_res_start {
1111b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 byte_count;
1112b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 reserved;
1113b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
1114b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1115b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1116b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/******************************************************************************
1117b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * (5)
1118b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Tx Commands & Responses:
1119b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
1120529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * Driver must place each REPLY_TX command into one of the prioritized Tx
1121529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * queues in host DRAM, shared between driver and device (see comments for
1122529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * SCD registers and Tx/Rx Queues).  When the device's Tx scheduler and uCode
1123529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * are preparing to transmit, the device pulls the Tx command over the PCI
1124529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * bus via one of the device's Tx DMA channels, to fill an internal FIFO
1125529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * from which data will be transmitted.
1126529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *
1127529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * uCode handles all timing and protocol related to control frames
1128529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * (RTS/CTS/ACK), based on flags in the Tx command.  uCode and Tx scheduler
1129529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * handle reception of block-acks; uCode updates the host driver via
1130529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * REPLY_COMPRESSED_BA (4965).
1131529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *
1132529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * uCode handles retrying Tx when an ACK is expected but not received.
1133529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * This includes trying lower data rates than the one requested in the Tx
1134529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * command, as set up by the REPLY_RATE_SCALE (for 3945) or
1135529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * REPLY_TX_LINK_QUALITY_CMD (4965).
1136529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *
1137529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * Driver sets up transmit power for various rates via REPLY_TX_PWR_TABLE_CMD.
1138529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * This command must be executed after every RXON command, before Tx can occur.
1139b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *****************************************************************************/
1140b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1141529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill/* REPLY_TX Tx flags field */
1142529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1143a96a27f97f2bbfc1fca54bc3c0b0d41484152740Tomas Winkler/* 1: Use RTS/CTS protocol or CTS-to-self if spec allows it
1144a326a5d096f031af46c0073dd78eb80dea1f311aEmmanuel Grumbach * before this frame. if CTS-to-self required check
1145a326a5d096f031af46c0073dd78eb80dea1f311aEmmanuel Grumbach * RXON_FLG_SELF_CTS_EN status. */
114651e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define TX_CMD_FLG_RTS_CTS_MSK cpu_to_le32(1 << 0)
1147a326a5d096f031af46c0073dd78eb80dea1f311aEmmanuel Grumbach
1148529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill/* 1: Use Request-To-Send protocol before this frame.
1149529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * Mutually exclusive vs. TX_CMD_FLG_CTS_MSK. */
115051e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define TX_CMD_FLG_RTS_MSK cpu_to_le32(1 << 1)
1151529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1152529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill/* 1: Transmit Clear-To-Send to self before this frame.
1153529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * Driver should set this for AUTH/DEAUTH/ASSOC-REQ/REASSOC mgmnt frames.
1154529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * Mutually exclusive vs. TX_CMD_FLG_RTS_MSK. */
115551e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define TX_CMD_FLG_CTS_MSK cpu_to_le32(1 << 2)
1156529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1157529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill/* 1: Expect ACK from receiving station
1158529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * 0: Don't expect ACK (MAC header's duration field s/b 0)
1159529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * Set this for unicast frames, but not broadcast/multicast. */
116051e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define TX_CMD_FLG_ACK_MSK cpu_to_le32(1 << 3)
1161529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1162529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill/* For 4965:
1163529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * 1: Use rate scale table (see REPLY_TX_LINK_QUALITY_CMD).
1164529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *    Tx command's initial_rate_index indicates first rate to try;
1165529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *    uCode walks through table for additional Tx attempts.
1166529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * 0: Use Tx rate/MCS from Tx command's rate_n_flags field.
1167529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *    This rate will be used for all Tx attempts; it will not be scaled. */
116851e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define TX_CMD_FLG_STA_RATE_MSK cpu_to_le32(1 << 4)
1169529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1170529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill/* 1: Expect immediate block-ack.
1171529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * Set when Txing a block-ack request frame.  Also set TX_CMD_FLG_ACK_MSK. */
117251e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define TX_CMD_FLG_IMM_BA_RSP_MASK  cpu_to_le32(1 << 6)
1173529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1174529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill/* 1: Frame requires full Tx-Op protection.
1175529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * Set this if either RTS or CTS Tx Flag gets set. */
117651e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define TX_CMD_FLG_FULL_TXOP_PROT_MSK cpu_to_le32(1 << 7)
1177529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1178529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill/* Tx antenna selection field; used only for 3945, reserved (0) for 4965.
1179529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * Set field to "0" to allow 3945 uCode to select antenna (normal usage). */
118051e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define TX_CMD_FLG_ANT_SEL_MSK cpu_to_le32(0xf00)
118151e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define TX_CMD_FLG_ANT_A_MSK cpu_to_le32(1 << 8)
118251e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define TX_CMD_FLG_ANT_B_MSK cpu_to_le32(1 << 9)
1183b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1184529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill/* 1: Ignore Bluetooth priority for this frame.
1185529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * 0: Delay Tx until Bluetooth device is done (normal usage). */
118651e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define TX_CMD_FLG_BT_DIS_MSK cpu_to_le32(1 << 12)
1187b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1188529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill/* 1: uCode overrides sequence control field in MAC header.
1189529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * 0: Driver provides sequence control field in MAC header.
1190529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * Set this for management frames, non-QOS data frames, non-unicast frames,
1191529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * and also in Tx command embedded in REPLY_SCAN_CMD for active scans. */
119251e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define TX_CMD_FLG_SEQ_CTL_MSK cpu_to_le32(1 << 13)
1193b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1194529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill/* 1: This frame is non-last MPDU; more fragments are coming.
1195529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * 0: Last fragment, or not using fragmentation. */
119651e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define TX_CMD_FLG_MORE_FRAG_MSK cpu_to_le32(1 << 14)
1197b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1198529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill/* 1: uCode calculates and inserts Timestamp Function (TSF) in outgoing frame.
1199529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * 0: No TSF required in outgoing frame.
1200529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * Set this for transmitting beacons and probe responses. */
120151e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define TX_CMD_FLG_TSF_MSK cpu_to_le32(1 << 16)
1202b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1203529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill/* 1: Driver inserted 2 bytes pad after the MAC header, for (required) dword
1204529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *    alignment of frame's payload data field.
1205529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * 0: No pad
1206529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * Set this for MAC headers with 26 or 30 bytes, i.e. those with QOS or ADDR4
1207529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * field (but not both).  Driver must align frame data (i.e. data following
1208529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * MAC header) to DWORD boundary. */
120951e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define TX_CMD_FLG_MH_PAD_MSK cpu_to_le32(1 << 20)
1210b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
12118236e183fc53be2b5d81a4f547f9c5b645e10fe0Max Stepanov/* accelerate aggregation support
12128236e183fc53be2b5d81a4f547f9c5b645e10fe0Max Stepanov * 0 - no CCMP encryption; 1 - CCMP encryption */
121351e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define TX_CMD_FLG_AGG_CCMP_MSK cpu_to_le32(1 << 22)
12148236e183fc53be2b5d81a4f547f9c5b645e10fe0Max Stepanov
1215b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* HCCA-AP - disable duration overwriting. */
121651e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define TX_CMD_FLG_DUR_MSK cpu_to_le32(1 << 25)
1217b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1218529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1219b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
1220b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * TX command security control
1221b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
1222b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define TX_CMD_SEC_WEP  	0x01
1223b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define TX_CMD_SEC_CCM  	0x02
1224b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define TX_CMD_SEC_TKIP		0x03
1225b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define TX_CMD_SEC_MSK		0x03
1226b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define TX_CMD_SEC_SHIFT	6
1227b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define TX_CMD_SEC_KEY128	0x08
1228b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1229b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
12303195cdb7424b4207f6903f1f3ddadcab49fa22f2Tomas Winkler * security overhead sizes
12313195cdb7424b4207f6903f1f3ddadcab49fa22f2Tomas Winkler */
12323195cdb7424b4207f6903f1f3ddadcab49fa22f2Tomas Winkler#define WEP_IV_LEN 4
12333195cdb7424b4207f6903f1f3ddadcab49fa22f2Tomas Winkler#define WEP_ICV_LEN 4
12343195cdb7424b4207f6903f1f3ddadcab49fa22f2Tomas Winkler#define CCMP_MIC_LEN 8
12353195cdb7424b4207f6903f1f3ddadcab49fa22f2Tomas Winkler#define TKIP_ICV_LEN 4
12363195cdb7424b4207f6903f1f3ddadcab49fa22f2Tomas Winkler
12373195cdb7424b4207f6903f1f3ddadcab49fa22f2Tomas Winkler/*
1238529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * 4965 uCode updates these Tx attempt count values in host DRAM.
1239529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * Used for managing Tx retries when expecting block-acks.
1240529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * Driver should set these fields to 0.
1241b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
12422aa6ab86bc475a115f56645591d2413981846509Tomas Winklerstruct iwl_dram_scratch {
1243529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	u8 try_cnt;		/* Tx attempts */
1244529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	u8 bt_kill_cnt;		/* Tx attempts blocked by Bluetooth device */
1245b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 reserved;
1246b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
1247b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1248b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
1249b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_TX = 0x1c (command)
1250b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
125183d527d9e8f9aff92cbd33f208f77c055dabb499Tomas Winklerstruct iwl_tx_cmd {
1252529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	/*
1253529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * MPDU byte count:
1254529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * MAC header (24/26/30/32 bytes) + 2 bytes pad if 26/30 header size,
1255529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * + 8 byte IV for CCM or TKIP (not used for WEP)
1256529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * + Data payload
1257529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * + 8-byte MIC (not used for CCM/WEP)
1258529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * NOTE:  Does not include Tx command bytes, post-MAC pad bytes,
1259529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 *        MIC (CCM) 8 bytes, ICV (WEP/TKIP/CKIP) 4 bytes, CRC 4 bytes.i
1260529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * Range: 14-2342 bytes.
1261529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 */
1262b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 len;
1263529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1264529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	/*
1265529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * MPDU or MSDU byte count for next frame.
1266529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * Used for fragmentation and bursting, but not 11n aggregation.
1267529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * Same as "len", but for next frame.  Set to 0 if not applicable.
1268529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 */
1269b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 next_frame_len;
1270529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1271529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	__le32 tx_flags;	/* TX_CMD_FLG_* */
1272529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
12732aa6ab86bc475a115f56645591d2413981846509Tomas Winkler	/* uCode may modify this field of the Tx command (in host DRAM!).
1274529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * Driver must also set dram_lsb_ptr and dram_msb_ptr in this cmd. */
12752aa6ab86bc475a115f56645591d2413981846509Tomas Winkler	struct iwl_dram_scratch scratch;
1276529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1277529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	/* Rate for *all* Tx attempts, if TX_CMD_FLG_STA_RATE_MSK is cleared. */
1278529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	__le32 rate_n_flags;	/* RATE_MCS_* */
1279529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1280529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	/* Index of destination station in uCode's station table */
1281b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 sta_id;
1282529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1283529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	/* Type of security encryption:  CCM or TKIP */
1284529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	u8 sec_ctl;		/* TX_CMD_SEC_* */
1285529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1286529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	/*
1287529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * Index into rate table (see REPLY_TX_LINK_QUALITY_CMD) for initial
1288529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * Tx attempt, if TX_CMD_FLG_STA_RATE_MSK is set.  Normally "0" for
1289529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * data frames, this field may be used to selectively reduce initial
1290529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * rate (via non-0 value) for special frames (e.g. management), while
1291529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * still supporting rate scaling for all frames.
1292529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 */
1293b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 initial_rate_index;
1294b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 reserved;
1295b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 key[16];
1296b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 next_frame_flags;
1297b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 reserved2;
1298b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	union {
1299b481de9ca074528fe8c429604e2777db8b89806aZhu Yi		__le32 life_time;
1300b481de9ca074528fe8c429604e2777db8b89806aZhu Yi		__le32 attempt;
1301b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	} stop_time;
1302529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1303529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	/* Host DRAM physical address pointer to "scratch" in this command.
1304529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * Must be dword aligned.  "0" in dram_lsb_ptr disables usage. */
1305b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 dram_lsb_ptr;
1306b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 dram_msb_ptr;
1307529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1308b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 rts_retry_limit;	/*byte 50 */
1309b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 data_retry_limit;	/*byte 51 */
1310b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 tid_tspec;
1311b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	union {
1312b481de9ca074528fe8c429604e2777db8b89806aZhu Yi		__le16 pm_frame_timeout;
1313b481de9ca074528fe8c429604e2777db8b89806aZhu Yi		__le16 attempt_duration;
1314b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	} timeout;
1315529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1316529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	/*
1317529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * Duration of EDCA burst Tx Opportunity, in 32-usec units.
1318529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * Set this if txop time is not specified by HCCA protocol (e.g. by AP).
1319529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 */
1320b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 driver_txop;
1321529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1322529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	/*
1323529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * MAC header goes here, followed by 2 bytes padding if MAC header
1324529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * length is 26 or 30 bytes, followed by payload data
1325529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 */
1326b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 payload[0];
1327b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct ieee80211_hdr hdr[0];
1328b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
1329b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1330b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* TX command response is sent after *all* transmission attempts.
1331b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
1332b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * NOTES:
1333b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
1334b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * TX_STATUS_FAIL_NEXT_FRAG
1335b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
1336b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * If the fragment flag in the MAC header for the frame being transmitted
1337b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * is set and there is insufficient time to transmit the next frame, the
1338b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * TX status will be returned with 'TX_STATUS_FAIL_NEXT_FRAG'.
1339b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
1340b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * TX_STATUS_FIFO_UNDERRUN
1341b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
1342b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Indicates the host did not provide bytes to the FIFO fast enough while
1343b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * a TX was in progress.
1344b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
1345b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * TX_STATUS_FAIL_MGMNT_ABORT
1346b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
1347b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * This status is only possible if the ABORT ON MGMT RX parameter was
1348b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * set to true with the TX command.
1349b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
1350b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * If the MSB of the status parameter is set then an abort sequence is
1351b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * required.  This sequence consists of the host activating the TX Abort
1352b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * control line, and then waiting for the TX Abort command response.  This
1353b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * indicates that a the device is no longer in a transmit state, and that the
1354b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * command FIFO has been cleared.  The host must then deactivate the TX Abort
1355b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * control line.  Receiving is still allowed in this case.
1356b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
1357b481de9ca074528fe8c429604e2777db8b89806aZhu Yienum {
1358b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_SUCCESS = 0x01,
1359b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_DIRECT_DONE = 0x02,
1360b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_FAIL_SHORT_LIMIT = 0x82,
1361b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_FAIL_LONG_LIMIT = 0x83,
1362b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_FAIL_FIFO_UNDERRUN = 0x84,
1363b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_FAIL_MGMNT_ABORT = 0x85,
1364b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_FAIL_NEXT_FRAG = 0x86,
1365b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_FAIL_LIFE_EXPIRE = 0x87,
1366b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_FAIL_DEST_PS = 0x88,
1367b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_FAIL_ABORTED = 0x89,
1368b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_FAIL_BT_RETRY = 0x8a,
1369b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_FAIL_STA_INVALID = 0x8b,
1370b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_FAIL_FRAG_DROPPED = 0x8c,
1371b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_FAIL_TID_DISABLE = 0x8d,
1372b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_FAIL_FRAME_FLUSHED = 0x8e,
1373b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_FAIL_INSUFFICIENT_CF_POLL = 0x8f,
1374b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_FAIL_TX_LOCKED = 0x90,
1375b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_FAIL_NO_BEACON_ON_RADAR = 0x91,
1376b481de9ca074528fe8c429604e2777db8b89806aZhu Yi};
1377b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1378b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define	TX_PACKET_MODE_REGULAR		0x0000
1379b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define	TX_PACKET_MODE_BURST_SEQ	0x0100
1380b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define	TX_PACKET_MODE_BURST_FIRST	0x0200
1381b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1382b481de9ca074528fe8c429604e2777db8b89806aZhu Yienum {
1383b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_POWER_PA_NOT_ACTIVE = 0x0,
1384b481de9ca074528fe8c429604e2777db8b89806aZhu Yi};
1385b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1386b481de9ca074528fe8c429604e2777db8b89806aZhu Yienum {
13873fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler	TX_STATUS_MSK = 0x000000ff,		/* bits 0:7 */
1388b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_DELAY_MSK = 0x00000040,
1389b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_ABORT_MSK = 0x00000080,
1390b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_PACKET_MODE_MSK = 0x0000ff00,	/* bits 8:15 */
1391b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_FIFO_NUMBER_MSK = 0x00070000,	/* bits 16:18 */
13923fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler	TX_RESERVED = 0x00780000,		/* bits 19:22 */
1393b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_POWER_PA_DETECT_MSK = 0x7f800000,	/* bits 23:30 */
1394b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_ABORT_REQUIRED_MSK = 0x80000000,	/* bits 31:31 */
1395b481de9ca074528fe8c429604e2777db8b89806aZhu Yi};
1396b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
13973fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winklerstatic inline bool iwl_is_tx_success(u32 status)
1398a332f8d618a7bdb0096c7b21555120a1822cedecTomas Winkler{
1399a332f8d618a7bdb0096c7b21555120a1822cedecTomas Winkler	status &= TX_STATUS_MSK;
14003fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler	return (status == TX_STATUS_SUCCESS) ||
14013fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler	       (status == TX_STATUS_DIRECT_DONE);
1402a332f8d618a7bdb0096c7b21555120a1822cedecTomas Winkler}
1403a332f8d618a7bdb0096c7b21555120a1822cedecTomas Winkler
1404a332f8d618a7bdb0096c7b21555120a1822cedecTomas Winkler
1405a332f8d618a7bdb0096c7b21555120a1822cedecTomas Winkler
1406b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* *******************************
1407529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * TX aggregation status
1408b481de9ca074528fe8c429604e2777db8b89806aZhu Yi ******************************* */
1409b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1410b481de9ca074528fe8c429604e2777db8b89806aZhu Yienum {
1411b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	AGG_TX_STATE_TRANSMITTED = 0x00,
1412b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	AGG_TX_STATE_UNDERRUN_MSK = 0x01,
1413b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	AGG_TX_STATE_BT_PRIO_MSK = 0x02,
1414b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	AGG_TX_STATE_FEW_BYTES_MSK = 0x04,
1415b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	AGG_TX_STATE_ABORT_MSK = 0x08,
1416b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	AGG_TX_STATE_LAST_SENT_TTL_MSK = 0x10,
1417b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	AGG_TX_STATE_LAST_SENT_TRY_CNT_MSK = 0x20,
1418b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	AGG_TX_STATE_LAST_SENT_BT_KILL_MSK = 0x40,
1419b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	AGG_TX_STATE_SCD_QUERY_MSK = 0x80,
1420b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	AGG_TX_STATE_TEST_BAD_CRC32_MSK = 0x100,
1421b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	AGG_TX_STATE_RESPONSE_MSK = 0x1ff,
1422b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	AGG_TX_STATE_DUMP_TX_MSK = 0x200,
1423b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	AGG_TX_STATE_DELAY_TX_MSK = 0x400
1424b481de9ca074528fe8c429604e2777db8b89806aZhu Yi};
1425b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
14263fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler#define AGG_TX_STATE_LAST_SENT_MSK  (AGG_TX_STATE_LAST_SENT_TTL_MSK | \
14273fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler				     AGG_TX_STATE_LAST_SENT_TRY_CNT_MSK | \
14283fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler				     AGG_TX_STATE_LAST_SENT_BT_KILL_MSK)
1429b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1430529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill/* # tx attempts for first frame in aggregation */
1431b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define AGG_TX_STATE_TRY_CNT_POS 12
1432b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define AGG_TX_STATE_TRY_CNT_MSK 0xf000
1433b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1434529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill/* Command ID and sequence number of Tx command for this frame */
1435b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define AGG_TX_STATE_SEQ_NUM_POS 16
1436b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define AGG_TX_STATE_SEQ_NUM_MSK 0xffff0000
1437b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1438b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
1439b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_TX = 0x1c (response)
1440529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *
1441529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * This response may be in one of two slightly different formats, indicated
1442529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * by the frame_count field:
1443529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *
1444529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * 1)  No aggregation (frame_count == 1).  This reports Tx results for
1445529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *     a single frame.  Multiple attempts, at various bit rates, may have
1446529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *     been made for this frame.
1447529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *
1448529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * 2)  Aggregation (frame_count > 1).  This reports Tx results for
1449529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *     2 or more frames that used block-acknowledge.  All frames were
1450529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *     transmitted at same rate.  Rate scaling may have been used if first
1451529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *     frame in this new agg block failed in previous agg block(s).
1452529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *
1453529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *     Note that, for aggregation, ACK (block-ack) status is not delivered here;
1454529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *     block-ack has not been received by the time the 4965 records this status.
1455529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *     This status relates to reasons the tx might have been blocked or aborted
1456529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *     within the sending station (this 4965), rather than whether it was
1457529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *     received successfully by the destination station.
1458b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
1459001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunskystruct agg_tx_status {
1460001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	__le16 status;
1461001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	__le16 sequence;
1462001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky} __attribute__ ((packed));
1463001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky
1464bb8c093bdea62f2ae371b98ebff81b0407852fafChristoph Hellwigstruct iwl4965_tx_resp {
1465b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 frame_count;		/* 1 no aggregation, >1 aggregation */
1466529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	u8 bt_kill_count;	/* # blocked by bluetooth (unused for agg) */
1467529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	u8 failure_rts;		/* # failures due to unsuccessful RTS */
1468529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	u8 failure_frame;	/* # failures due to no ACK (unused for agg) */
1469529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1470529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	/* For non-agg:  Rate at which frame was successful.
1471529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * For agg:  Rate at which all frames were transmitted. */
1472529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	__le32 rate_n_flags;	/* RATE_MCS_*  */
1473529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1474529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	/* For non-agg:  RTS + CTS + frame tx attempts time + ACK.
1475529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * For agg:  RTS + CTS + aggregation tx time + block-ack time. */
1476529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	__le16 wireless_media_time;	/* uSecs */
1477529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1478b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 reserved;
1479529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	__le32 pa_power1;	/* RF power amplifier measurement (not used) */
1480b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 pa_power2;
1481529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1482529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	/*
1483529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * For non-agg:  frame status TX_STATUS_*
1484529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * For agg:  status of 1st frame, AGG_TX_STATE_*; other frame status
1485529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 *           fields follow this one, up to frame_count.
1486529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 *           Bit fields:
1487529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 *           11- 0:  AGG_TX_STATE_* status code
1488529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 *           15-12:  Retry count for 1st frame in aggregation (retries
1489529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 *                   occur if tx failed for this frame when it was a
1490529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 *                   member of a previous aggregation block).  If rate
1491529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 *                   scaling is used, retry count indicates the rate
1492529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 *                   table entry used for all frames in the new agg.
1493529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 *           31-16:  Sequence # for this frame's Tx cmd (not SSN!)
1494529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 */
149525a6572cc13ba2a3fefc02a63a077ff3664a1ca9Tomas Winkler	union {
149625a6572cc13ba2a3fefc02a63a077ff3664a1ca9Tomas Winkler		__le32 status;
149725a6572cc13ba2a3fefc02a63a077ff3664a1ca9Tomas Winkler		struct agg_tx_status agg_status[0]; /* for each agg frame */
149825a6572cc13ba2a3fefc02a63a077ff3664a1ca9Tomas Winkler	} u;
1499fe01b477bbd23e69c3bdc6bce5be510ddad8297dRon Rindjunsky} __attribute__ ((packed));
1500fe01b477bbd23e69c3bdc6bce5be510ddad8297dRon Rindjunsky
15013fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler/*
15023fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler * definitions for initial rate index field
1503a96a27f97f2bbfc1fca54bc3c0b0d41484152740Tomas Winkler * bits [3:0] initial rate index
15043fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler * bits [6:4] rate table color, used for the initial rate
15053fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler * bit-7 invalid rate indication
15063fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler *   i.e. rate was not chosen from rate table
15073fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler *   or rate table color was changed during frame retries
15083fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler * refer tlc rate info
15093fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler */
15103fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler
15113fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler#define IWL50_TX_RES_INIT_RATE_INDEX_POS	0
15123fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler#define IWL50_TX_RES_INIT_RATE_INDEX_MSK	0x0f
15133fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler#define IWL50_TX_RES_RATE_TABLE_COLOR_POS	4
15143fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler#define IWL50_TX_RES_RATE_TABLE_COLOR_MSK	0x70
15153fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler#define IWL50_TX_RES_INV_RATE_INDEX_MSK	0x80
15163fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler
15173fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler/* refer to ra_tid */
15183fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler#define IWL50_TX_RES_TID_POS	0
15193fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler#define IWL50_TX_RES_TID_MSK	0x0f
15203fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler#define IWL50_TX_RES_RA_POS	4
15213fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler#define IWL50_TX_RES_RA_MSK	0xf0
15223fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler
1523001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunskystruct iwl5000_tx_resp {
1524001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	u8 frame_count;		/* 1 no aggregation, >1 aggregation */
1525001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	u8 bt_kill_count;	/* # blocked by bluetooth (unused for agg) */
1526001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	u8 failure_rts;		/* # failures due to unsuccessful RTS */
1527001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	u8 failure_frame;	/* # failures due to no ACK (unused for agg) */
1528001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky
1529001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	/* For non-agg:  Rate at which frame was successful.
1530001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	 * For agg:  Rate at which all frames were transmitted. */
1531001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	__le32 rate_n_flags;	/* RATE_MCS_*  */
1532001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky
1533001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	/* For non-agg:  RTS + CTS + frame tx attempts time + ACK.
1534001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	 * For agg:  RTS + CTS + aggregation tx time + block-ack time. */
1535001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	__le16 wireless_media_time;	/* uSecs */
1536001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky
15373fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler	u8 pa_status;		/* RF power amplifier measurement (not used) */
15383fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler	u8 pa_integ_res_a[3];
15393fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler	u8 pa_integ_res_b[3];
15403fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler	u8 pa_integ_res_C[3];
1541001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky
1542001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	__le32 tfd_info;
1543001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	__le16 seq_ctl;
1544001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	__le16 byte_cnt;
15453fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler	u8 tlc_info;
15463fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler	u8 ra_tid;		/* tid (0:3), sta_id (4:7) */
15473fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler	__le16 frame_ctrl;
1548001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	/*
1549001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	 * For non-agg:  frame status TX_STATUS_*
1550001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	 * For agg:  status of 1st frame, AGG_TX_STATE_*; other frame status
1551001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	 *           fields follow this one, up to frame_count.
1552001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	 *           Bit fields:
1553001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	 *           11- 0:  AGG_TX_STATE_* status code
1554001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	 *           15-12:  Retry count for 1st frame in aggregation (retries
1555001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	 *                   occur if tx failed for this frame when it was a
1556001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	 *                   member of a previous aggregation block).  If rate
1557001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	 *                   scaling is used, retry count indicates the rate
1558001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	 *                   table entry used for all frames in the new agg.
1559001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	 *           31-16:  Sequence # for this frame's Tx cmd (not SSN!)
1560001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	 */
1561001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	struct agg_tx_status status;	/* TX status (in aggregation -
1562001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky					 * status of 1st frame) */
1563001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky} __attribute__ ((packed));
1564b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
1565b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_COMPRESSED_BA = 0xc5 (response only, not a command)
1566529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *
1567529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * Reports Block-Acknowledge from recipient station
1568b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
1569653fa4a07525e4cd9e7b90e6fc1f792119910636Emmanuel Grumbachstruct iwl_compressed_ba_resp {
1570b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 sta_addr_lo32;
1571b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 sta_addr_hi16;
1572b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 reserved;
1573529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1574529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	/* Index of recipient (BA-sending) station in uCode's station table */
1575b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 sta_id;
1576b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 tid;
1577fe01b477bbd23e69c3bdc6bce5be510ddad8297dRon Rindjunsky	__le16 seq_ctl;
1578fe01b477bbd23e69c3bdc6bce5be510ddad8297dRon Rindjunsky	__le64 bitmap;
1579b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 scd_flow;
1580b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 scd_ssn;
1581b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
1582b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1583b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
1584b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_TX_PWR_TABLE_CMD = 0x97 (command, has simple generic response)
15852bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
15862bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * See details under "TXPOWER" in iwl-4965-hw.h.
1587b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
1588bb8c093bdea62f2ae371b98ebff81b0407852fafChristoph Hellwigstruct iwl4965_txpowertable_cmd {
1589b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 band;		/* 0: 5 GHz, 1: 2.4 GHz */
1590b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 reserved;
1591b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 channel;
1592bb8c093bdea62f2ae371b98ebff81b0407852fafChristoph Hellwig	struct iwl4965_tx_power_db tx_power;
1593b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
1594b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1595b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*RS_NEW_API: only TLC_RTS remains and moved to bit 0 */
15968a1b02452862dd30980ad0ef493eed687bc81474Reinette Chatre#define  LINK_QUAL_FLAGS_SET_STA_TLC_RTS_MSK	(1 << 0)
1597b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
15982bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill/* # of EDCA prioritized tx fifos */
1599b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define  LINK_QUAL_AC_NUM AC_NUM
16002bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill
16012bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill/* # entries in rate scale table to support Tx retries */
1602b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define  LINK_QUAL_MAX_RETRY_NUM 16
1603b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
16042bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill/* Tx antenna selection values */
16058a1b02452862dd30980ad0ef493eed687bc81474Reinette Chatre#define  LINK_QUAL_ANT_A_MSK (1 << 0)
16068a1b02452862dd30980ad0ef493eed687bc81474Reinette Chatre#define  LINK_QUAL_ANT_B_MSK (1 << 1)
1607b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define  LINK_QUAL_ANT_MSK   (LINK_QUAL_ANT_A_MSK|LINK_QUAL_ANT_B_MSK)
1608b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
16092bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill
16102bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill/**
161166c73db7c6f7672e40c0bb1d2689f2d0d0922aadTomas Winkler * struct iwl_link_qual_general_params
16122bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
16132bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * Used in REPLY_TX_LINK_QUALITY_CMD
16142bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill */
161566c73db7c6f7672e40c0bb1d2689f2d0d0922aadTomas Winklerstruct iwl_link_qual_general_params {
1616b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 flags;
16172bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill
16182bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	/* No entries at or above this (driver chosen) index contain MIMO */
1619b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 mimo_delimiter;
16202bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill
16212bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	/* Best single antenna to use for single stream (legacy, SISO). */
16222bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	u8 single_stream_ant_msk;	/* LINK_QUAL_ANT_* */
16232bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill
16242bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	/* Best antennas to use for MIMO (unused for 4965, assumes both). */
16252bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	u8 dual_stream_ant_msk;		/* LINK_QUAL_ANT_* */
16262bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill
16272bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	/*
16282bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 * If driver needs to use different initial rates for different
16292bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 * EDCA QOS access categories (as implemented by tx fifos 0-3),
16302bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 * this table will set that up, by indicating the indexes in the
16312bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 * rs_table[LINK_QUAL_MAX_RETRY_NUM] rate table at which to start.
16322bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 * Otherwise, driver should set all entries to 0.
16332bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 *
16342bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 * Entry usage:
16352bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 * 0 = Background, 1 = Best Effort (normal), 2 = Video, 3 = Voice
16362bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 * TX FIFOs above 3 use same value (typically 0) as TX FIFO 3.
16372bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 */
1638b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 start_rate_index[LINK_QUAL_AC_NUM];
1639b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
1640b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
16412bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill/**
164266c73db7c6f7672e40c0bb1d2689f2d0d0922aadTomas Winkler * struct iwl_link_qual_agg_params
16432bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
16442bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * Used in REPLY_TX_LINK_QUALITY_CMD
16452bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill */
164666c73db7c6f7672e40c0bb1d2689f2d0d0922aadTomas Winklerstruct iwl_link_qual_agg_params {
16472bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill
16482bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	/* Maximum number of uSec in aggregation.
16492bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 * Driver should set this to 4000 (4 milliseconds). */
1650b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 agg_time_limit;
16512bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill
16522bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	/*
16532bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 * Number of Tx retries allowed for a frame, before that frame will
16542bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 * no longer be considered for the start of an aggregation sequence
16552bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 * (scheduler will then try to tx it as single frame).
16562bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 * Driver should set this to 3.
16572bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 */
1658b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 agg_dis_start_th;
16592bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill
16602bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	/*
16612bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 * Maximum number of frames in aggregation.
16622bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 * 0 = no limit (default).  1 = no aggregation.
16632bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 * Other values = max # frames in aggregation.
16642bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 */
1665b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 agg_frame_cnt_limit;
16662bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill
1667b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 reserved;
1668b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
1669b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1670b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
1671b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_TX_LINK_QUALITY_CMD = 0x4e (command, has simple generic response)
16722bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
16732bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * For 4965 only; 3945 uses REPLY_RATE_SCALE.
16742bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
16752bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * Each station in the 4965's internal station table has its own table of 16
16762bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * Tx rates and modulation modes (e.g. legacy/SISO/MIMO) for retrying Tx when
16772bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * an ACK is not received.  This command replaces the entire table for
16782bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * one station.
16792bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
16802bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * NOTE:  Station must already be in 4965's station table.  Use REPLY_ADD_STA.
16812bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
16822bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * The rate scaling procedures described below work well.  Of course, other
16832bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * procedures are possible, and may work better for particular environments.
16842bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
16852bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
16862bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * FILLING THE RATE TABLE
16872bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
16882bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * Given a particular initial rate and mode, as determined by the rate
16892bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * scaling algorithm described below, the Linux driver uses the following
16902bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * formula to fill the rs_table[LINK_QUAL_MAX_RETRY_NUM] rate table in the
16912bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * Link Quality command:
16922bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
16932bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
16942bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * 1)  If using High-throughput (HT) (SISO or MIMO) initial rate:
16952bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     a) Use this same initial rate for first 3 entries.
16962bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     b) Find next lower available rate using same mode (SISO or MIMO),
16972bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *        use for next 3 entries.  If no lower rate available, switch to
16982bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *        legacy mode (no FAT channel, no MIMO, no short guard interval).
16992bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     c) If using MIMO, set command's mimo_delimiter to number of entries
17002bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *        using MIMO (3 or 6).
17012bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     d) After trying 2 HT rates, switch to legacy mode (no FAT channel,
17022bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *        no MIMO, no short guard interval), at the next lower bit rate
17032bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *        (e.g. if second HT bit rate was 54, try 48 legacy), and follow
17042bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *        legacy procedure for remaining table entries.
17052bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
17062bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * 2)  If using legacy initial rate:
17072bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     a) Use the initial rate for only one entry.
17082bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     b) For each following entry, reduce the rate to next lower available
17092bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *        rate, until reaching the lowest available rate.
17102bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     c) When reducing rate, also switch antenna selection.
17112bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     d) Once lowest available rate is reached, repeat this rate until
17122bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *        rate table is filled (16 entries), switching antenna each entry.
17132bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
17142bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
17152bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * ACCUMULATING HISTORY
17162bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
17172bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * The rate scaling algorithm for 4965, as implemented in Linux driver, uses
17182bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * two sets of frame Tx success history:  One for the current/active modulation
17192bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * mode, and one for a speculative/search mode that is being attempted.  If the
17202bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * speculative mode turns out to be more effective (i.e. actual transfer
17212bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * rate is better), then the driver continues to use the speculative mode
17222bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * as the new current active mode.
17232bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
17242bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * Each history set contains, separately for each possible rate, data for a
17252bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * sliding window of the 62 most recent tx attempts at that rate.  The data
17262bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * includes a shifting bitmap of success(1)/failure(0), and sums of successful
17272bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * and attempted frames, from which the driver can additionally calculate a
17282bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * success ratio (success / attempted) and number of failures
17292bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * (attempted - success), and control the size of the window (attempted).
17302bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * The driver uses the bit map to remove successes from the success sum, as
17312bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * the oldest tx attempts fall out of the window.
17322bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
17332bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * When the 4965 makes multiple tx attempts for a given frame, each attempt
17342bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * might be at a different rate, and have different modulation characteristics
17352bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * (e.g. antenna, fat channel, short guard interval), as set up in the rate
17362bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * scaling table in the Link Quality command.  The driver must determine
17372bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * which rate table entry was used for each tx attempt, to determine which
17382bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * rate-specific history to update, and record only those attempts that
17392bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * match the modulation characteristics of the history set.
17402bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
17412bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * When using block-ack (aggregation), all frames are transmitted at the same
1742a96a27f97f2bbfc1fca54bc3c0b0d41484152740Tomas Winkler * rate, since there is no per-attempt acknowledgment from the destination
17432bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * station.  The Tx response struct iwl_tx_resp indicates the Tx rate in
17442bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * rate_n_flags field.  After receiving a block-ack, the driver can update
17452bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * history for the entire block all at once.
17462bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
17472bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
17482bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * FINDING BEST STARTING RATE:
17492bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
17502bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * When working with a selected initial modulation mode (see below), the
17512bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * driver attempts to find a best initial rate.  The initial rate is the
17522bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * first entry in the Link Quality command's rate table.
17532bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
17542bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * 1)  Calculate actual throughput (success ratio * expected throughput, see
17552bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     table below) for current initial rate.  Do this only if enough frames
17562bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     have been attempted to make the value meaningful:  at least 6 failed
17572bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     tx attempts, or at least 8 successes.  If not enough, don't try rate
17582bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     scaling yet.
17592bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
17602bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * 2)  Find available rates adjacent to current initial rate.  Available means:
17612bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     a)  supported by hardware &&
17622bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     b)  supported by association &&
17632bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     c)  within any constraints selected by user
17642bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
17652bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * 3)  Gather measured throughputs for adjacent rates.  These might not have
17662bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     enough history to calculate a throughput.  That's okay, we might try
17672bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     using one of them anyway!
17682bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
17692bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * 4)  Try decreasing rate if, for current rate:
17702bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     a)  success ratio is < 15% ||
17712bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     b)  lower adjacent rate has better measured throughput ||
17722bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     c)  higher adjacent rate has worse throughput, and lower is unmeasured
17732bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
17742bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     As a sanity check, if decrease was determined above, leave rate
17752bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     unchanged if:
17762bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     a)  lower rate unavailable
17772bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     b)  success ratio at current rate > 85% (very good)
17782bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     c)  current measured throughput is better than expected throughput
17792bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *         of lower rate (under perfect 100% tx conditions, see table below)
17802bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
17812bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * 5)  Try increasing rate if, for current rate:
17822bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     a)  success ratio is < 15% ||
17832bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     b)  both adjacent rates' throughputs are unmeasured (try it!) ||
17842bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     b)  higher adjacent rate has better measured throughput ||
17852bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     c)  lower adjacent rate has worse throughput, and higher is unmeasured
17862bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
17872bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     As a sanity check, if increase was determined above, leave rate
17882bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     unchanged if:
17892bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     a)  success ratio at current rate < 70%.  This is not particularly
17902bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *         good performance; higher rate is sure to have poorer success.
17912bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
17922bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * 6)  Re-evaluate the rate after each tx frame.  If working with block-
17932bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     acknowledge, history and statistics may be calculated for the entire
17942bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     block (including prior history that fits within the history windows),
17952bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     before re-evaluation.
17962bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
17972bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * FINDING BEST STARTING MODULATION MODE:
17982bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
17992bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * After working with a modulation mode for a "while" (and doing rate scaling),
18002bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * the driver searches for a new initial mode in an attempt to improve
18012bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * throughput.  The "while" is measured by numbers of attempted frames:
18022bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
18032bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * For legacy mode, search for new mode after:
18042bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *   480 successful frames, or 160 failed frames
18052bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * For high-throughput modes (SISO or MIMO), search for new mode after:
18062bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *   4500 successful frames, or 400 failed frames
18072bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
18082bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * Mode switch possibilities are (3 for each mode):
18092bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
18102bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * For legacy:
18112bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *   Change antenna, try SISO (if HT association), try MIMO (if HT association)
18122bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * For SISO:
18132bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *   Change antenna, try MIMO, try shortened guard interval (SGI)
18142bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * For MIMO:
18152bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *   Try SISO antenna A, SISO antenna B, try shortened guard interval (SGI)
18162bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
18172bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * When trying a new mode, use the same bit rate as the old/current mode when
18182bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * trying antenna switches and shortened guard interval.  When switching to
18192bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * SISO from MIMO or legacy, or to MIMO from SISO or legacy, use a rate
18202bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * for which the expected throughput (under perfect conditions) is about the
18212bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * same or slightly better than the actual measured throughput delivered by
18222bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * the old/current mode.
18232bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
18242bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * Actual throughput can be estimated by multiplying the expected throughput
18252bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * by the success ratio (successful / attempted tx frames).  Frame size is
18262bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * not considered in this calculation; it assumes that frame size will average
18272bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * out to be fairly consistent over several samples.  The following are
18282bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * metric values for expected throughput assuming 100% success ratio.
18292bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * Only G band has support for CCK rates:
18302bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
18312bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *           RATE:  1    2    5   11    6   9   12   18   24   36   48   54   60
18322bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
18332bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *              G:  7   13   35   58   40  57   72   98  121  154  177  186  186
18342bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *              A:  0    0    0    0   40  57   72   98  121  154  177  186  186
18352bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     SISO 20MHz:  0    0    0    0   42  42   76  102  124  159  183  193  202
18362bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * SGI SISO 20MHz:  0    0    0    0   46  46   82  110  132  168  192  202  211
18372bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     MIMO 20MHz:  0    0    0    0   74  74  123  155  179  214  236  244  251
18382bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * SGI MIMO 20MHz:  0    0    0    0   81  81  131  164  188  222  243  251  257
18392bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     SISO 40MHz:  0    0    0    0   77  77  127  160  184  220  242  250  257
18402bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * SGI SISO 40MHz:  0    0    0    0   83  83  135  169  193  229  250  257  264
18412bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     MIMO 40MHz:  0    0    0    0  123 123  182  214  235  264  279  285  289
18422bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * SGI MIMO 40MHz:  0    0    0    0  131 131  191  222  242  270  284  289  293
18432bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
18442bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * After the new mode has been tried for a short while (minimum of 6 failed
18452bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * frames or 8 successful frames), compare success ratio and actual throughput
18462bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * estimate of the new mode with the old.  If either is better with the new
18472bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * mode, continue to use the new mode.
18482bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
18492bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * Continue comparing modes until all 3 possibilities have been tried.
18502bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * If moving from legacy to HT, try all 3 possibilities from the new HT
18512bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * mode.  After trying all 3, a best mode is found.  Continue to use this mode
18522bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * for the longer "while" described above (e.g. 480 successful frames for
18532bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * legacy), and then repeat the search process.
18542bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
1855b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
185666c73db7c6f7672e40c0bb1d2689f2d0d0922aadTomas Winklerstruct iwl_link_quality_cmd {
18572bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill
18582bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	/* Index of destination/recipient station in uCode's station table */
1859b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 sta_id;
1860b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 reserved1;
18612bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	__le16 control;		/* not used */
186266c73db7c6f7672e40c0bb1d2689f2d0d0922aadTomas Winkler	struct iwl_link_qual_general_params general_params;
186366c73db7c6f7672e40c0bb1d2689f2d0d0922aadTomas Winkler	struct iwl_link_qual_agg_params agg_params;
18642bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill
18652bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	/*
18662bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 * Rate info; when using rate-scaling, Tx command's initial_rate_index
18672bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 * specifies 1st Tx rate attempted, via index into this table.
18682bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 * 4965 works its way through table when retrying Tx.
18692bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 */
1870b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct {
18712bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill		__le32 rate_n_flags;	/* RATE_MCS_*, IWL_RATE_* */
1872b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	} rs_table[LINK_QUAL_MAX_RETRY_NUM];
1873b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 reserved2;
1874b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
1875b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1876b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
1877b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_BT_CONFIG = 0x9b (command, has simple generic response)
18783058f02137359efb412975cf94a9fa7c25413387Ben M Cahill *
18793058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * 3945 and 4965 support hardware handshake with Bluetooth device on
18803058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * same platform.  Bluetooth device alerts wireless device when it will Tx;
1881a96a27f97f2bbfc1fca54bc3c0b0d41484152740Tomas Winkler * wireless device can delay or kill its own Tx to accommodate.
1882b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
18832aa6ab86bc475a115f56645591d2413981846509Tomas Winklerstruct iwl_bt_cmd {
1884b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 flags;
1885b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 lead_time;
1886b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 max_kill;
1887b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 reserved;
1888b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 kill_ack_mask;
1889b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 kill_cts_mask;
1890b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
1891b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1892b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/******************************************************************************
1893b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * (6)
1894b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Spectrum Management (802.11h) Commands, Responses, Notifications:
1895b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
1896b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *****************************************************************************/
1897b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1898b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
1899b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Spectrum Management
1900b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
1901b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define MEASUREMENT_FILTER_FLAG (RXON_FILTER_PROMISC_MSK         | \
1902b481de9ca074528fe8c429604e2777db8b89806aZhu Yi				 RXON_FILTER_CTL2HOST_MSK        | \
1903b481de9ca074528fe8c429604e2777db8b89806aZhu Yi				 RXON_FILTER_ACCEPT_GRP_MSK      | \
1904b481de9ca074528fe8c429604e2777db8b89806aZhu Yi				 RXON_FILTER_DIS_DECRYPT_MSK     | \
1905b481de9ca074528fe8c429604e2777db8b89806aZhu Yi				 RXON_FILTER_DIS_GRP_DECRYPT_MSK | \
1906b481de9ca074528fe8c429604e2777db8b89806aZhu Yi				 RXON_FILTER_ASSOC_MSK           | \
1907b481de9ca074528fe8c429604e2777db8b89806aZhu Yi				 RXON_FILTER_BCON_AWARE_MSK)
1908b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
19092aa6ab86bc475a115f56645591d2413981846509Tomas Winklerstruct iwl_measure_channel {
1910b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 duration;	/* measurement duration in extended beacon
1911b481de9ca074528fe8c429604e2777db8b89806aZhu Yi				 * format */
1912b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 channel;		/* channel to measure */
19132aa6ab86bc475a115f56645591d2413981846509Tomas Winkler	u8 type;		/* see enum iwl_measure_type */
1914b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 reserved;
1915b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
1916b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1917b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
1918b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_SPECTRUM_MEASUREMENT_CMD = 0x74 (command)
1919b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
19202aa6ab86bc475a115f56645591d2413981846509Tomas Winklerstruct iwl_spectrum_cmd {
1921b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 len;		/* number of bytes starting from token */
1922b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 token;		/* token id */
1923b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 id;			/* measurement id -- 0 or 1 */
1924b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 origin;		/* 0 = TGh, 1 = other, 2 = TGk */
1925b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 periodic;		/* 1 = periodic */
1926b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 path_loss_timeout;
1927b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 start_time;	/* start time in extended beacon format */
1928b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 reserved2;
1929b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 flags;		/* rxon flags */
1930b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 filter_flags;	/* rxon filter flags */
1931b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 channel_count;	/* minimum 1, maximum 10 */
1932b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 reserved3;
19332aa6ab86bc475a115f56645591d2413981846509Tomas Winkler	struct iwl_measure_channel channels[10];
1934b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
1935b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1936b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
1937b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_SPECTRUM_MEASUREMENT_CMD = 0x74 (response)
1938b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
19392aa6ab86bc475a115f56645591d2413981846509Tomas Winklerstruct iwl_spectrum_resp {
1940b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 token;
1941b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 id;			/* id of the prior command replaced, or 0xff */
1942b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 status;		/* 0 - command will be handled
1943b481de9ca074528fe8c429604e2777db8b89806aZhu Yi				 * 1 - cannot handle (conflicts with another
1944b481de9ca074528fe8c429604e2777db8b89806aZhu Yi				 *     measurement) */
1945b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
1946b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
19472aa6ab86bc475a115f56645591d2413981846509Tomas Winklerenum iwl_measurement_state {
1948b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_MEASUREMENT_START = 0,
1949b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_MEASUREMENT_STOP = 1,
1950b481de9ca074528fe8c429604e2777db8b89806aZhu Yi};
1951b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
19522aa6ab86bc475a115f56645591d2413981846509Tomas Winklerenum iwl_measurement_status {
1953b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_MEASUREMENT_OK = 0,
1954b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_MEASUREMENT_CONCURRENT = 1,
1955b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_MEASUREMENT_CSA_CONFLICT = 2,
1956b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_MEASUREMENT_TGH_CONFLICT = 3,
1957b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	/* 4-5 reserved */
1958b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_MEASUREMENT_STOPPED = 6,
1959b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_MEASUREMENT_TIMEOUT = 7,
1960b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_MEASUREMENT_PERIODIC_FAILED = 8,
1961b481de9ca074528fe8c429604e2777db8b89806aZhu Yi};
1962b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1963b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define NUM_ELEMENTS_IN_HISTOGRAM 8
1964b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
19652aa6ab86bc475a115f56645591d2413981846509Tomas Winklerstruct iwl_measurement_histogram {
1966b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 ofdm[NUM_ELEMENTS_IN_HISTOGRAM];	/* in 0.8usec counts */
1967b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 cck[NUM_ELEMENTS_IN_HISTOGRAM];	/* in 1usec counts */
1968b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
1969b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1970b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* clear channel availability counters */
19712aa6ab86bc475a115f56645591d2413981846509Tomas Winklerstruct iwl_measurement_cca_counters {
1972b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 ofdm;
1973b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 cck;
1974b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
1975b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
19762aa6ab86bc475a115f56645591d2413981846509Tomas Winklerenum iwl_measure_type {
1977b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_MEASURE_BASIC = (1 << 0),
1978b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_MEASURE_CHANNEL_LOAD = (1 << 1),
1979b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_MEASURE_HISTOGRAM_RPI = (1 << 2),
1980b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_MEASURE_HISTOGRAM_NOISE = (1 << 3),
1981b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_MEASURE_FRAME = (1 << 4),
1982b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	/* bits 5:6 are reserved */
1983b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_MEASURE_IDLE = (1 << 7),
1984b481de9ca074528fe8c429604e2777db8b89806aZhu Yi};
1985b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1986b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
1987b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * SPECTRUM_MEASURE_NOTIFICATION = 0x75 (notification only, not a command)
1988b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
19892aa6ab86bc475a115f56645591d2413981846509Tomas Winklerstruct iwl_spectrum_notification {
1990b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 id;			/* measurement id -- 0 or 1 */
1991b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 token;
1992b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 channel_index;	/* index in measurement channel list */
1993b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 state;		/* 0 - start, 1 - stop */
1994b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 start_time;	/* lower 32-bits of TSF */
1995b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 band;		/* 0 - 5.2GHz, 1 - 2.4GHz */
1996b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 channel;
19972aa6ab86bc475a115f56645591d2413981846509Tomas Winkler	u8 type;		/* see enum iwl_measurement_type */
1998b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 reserved1;
1999b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	/* NOTE:  cca_ofdm, cca_cck, basic_type, and histogram are only only
2000b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 * valid if applicable for measurement type requested. */
2001b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 cca_ofdm;	/* cca fraction time in 40Mhz clock periods */
2002b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 cca_cck;		/* cca fraction time in 44Mhz clock periods */
2003b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 cca_time;	/* channel load time in usecs */
2004b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 basic_type;		/* 0 - bss, 1 - ofdm preamble, 2 -
2005b481de9ca074528fe8c429604e2777db8b89806aZhu Yi				 * unidentified */
2006b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 reserved2[3];
20072aa6ab86bc475a115f56645591d2413981846509Tomas Winkler	struct iwl_measurement_histogram histogram;
2008b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 stop_time;	/* lower 32-bits of TSF */
20092aa6ab86bc475a115f56645591d2413981846509Tomas Winkler	__le32 status;		/* see iwl_measurement_status */
2010b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
2011b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2012b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/******************************************************************************
2013b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * (7)
2014b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Power Management Commands, Responses, Notifications:
2015b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
2016b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *****************************************************************************/
2017b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2018b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/**
2019ca579617d81baf5865498eb5fae58e453ee77c2cMohamed Abbas * struct iwl_powertable_cmd - Power Table Command
2020b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * @flags: See below:
2021b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
2022b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * POWER_TABLE_CMD = 0x77 (command, has simple generic response)
2023b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
2024b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * PM allow:
2025b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *   bit 0 - '0' Driver not allow power management
2026b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *           '1' Driver allow PM (use rest of parameters)
2027b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * uCode send sleep notifications:
2028b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *   bit 1 - '0' Don't send sleep notification
2029b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *           '1' send sleep notification (SEND_PM_NOTIFICATION)
2030b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Sleep over DTIM
2031b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *   bit 2 - '0' PM have to walk up every DTIM
2032b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *           '1' PM could sleep over DTIM till listen Interval.
2033b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * PCI power managed
2034e7b635814b640c6fd9dca1c254dc22fac6fb9a1aTomas Winkler *   bit 3 - '0' (PCI_CFG_LINK_CTRL & 0x1)
2035e7b635814b640c6fd9dca1c254dc22fac6fb9a1aTomas Winkler *           '1' !(PCI_CFG_LINK_CTRL & 0x1)
2036b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Force sleep Modes
2037b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *   bit 31/30- '00' use both mac/xtal sleeps
2038b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *              '01' force Mac sleep
2039b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *              '10' force xtal sleep
2040b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *              '11' Illegal set
2041b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
2042b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * NOTE: if sleep_interval[SLEEP_INTRVL_TABLE_SIZE-1] > DTIM period then
2043a96a27f97f2bbfc1fca54bc3c0b0d41484152740Tomas Winkler * ucode assume sleep over DTIM is allowed and we don't need to wake up
2044b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * for every DTIM.
2045b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
2046b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define IWL_POWER_VEC_SIZE 5
2047b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2048600c0e11ea6161e00e8cb4b4dda39a64ce988c60Tomas Winkler#define IWL_POWER_DRIVER_ALLOW_SLEEP_MSK	cpu_to_le16(BIT(0))
2049600c0e11ea6161e00e8cb4b4dda39a64ce988c60Tomas Winkler#define IWL_POWER_SLEEP_OVER_DTIM_MSK		cpu_to_le16(BIT(2))
2050600c0e11ea6161e00e8cb4b4dda39a64ce988c60Tomas Winkler#define IWL_POWER_PCI_PM_MSK			cpu_to_le16(BIT(3))
2051600c0e11ea6161e00e8cb4b4dda39a64ce988c60Tomas Winkler#define IWL_POWER_FAST_PD			cpu_to_le16(BIT(4))
2052600c0e11ea6161e00e8cb4b4dda39a64ce988c60Tomas Winkler
2053600c0e11ea6161e00e8cb4b4dda39a64ce988c60Tomas Winklerstruct iwl3945_powertable_cmd {
2054600c0e11ea6161e00e8cb4b4dda39a64ce988c60Tomas Winkler	__le16 flags;
2055600c0e11ea6161e00e8cb4b4dda39a64ce988c60Tomas Winkler	u8 reserved[2];
2056600c0e11ea6161e00e8cb4b4dda39a64ce988c60Tomas Winkler	__le32 rx_data_timeout;
2057600c0e11ea6161e00e8cb4b4dda39a64ce988c60Tomas Winkler	__le32 tx_data_timeout;
2058600c0e11ea6161e00e8cb4b4dda39a64ce988c60Tomas Winkler	__le32 sleep_interval[IWL_POWER_VEC_SIZE];
2059600c0e11ea6161e00e8cb4b4dda39a64ce988c60Tomas Winkler} __attribute__ ((packed));
2060b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2061ca579617d81baf5865498eb5fae58e453ee77c2cMohamed Abbasstruct iwl_powertable_cmd {
2062b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 flags;
2063600c0e11ea6161e00e8cb4b4dda39a64ce988c60Tomas Winkler	u8 keep_alive_seconds;		/* 3945 reserved */
2064600c0e11ea6161e00e8cb4b4dda39a64ce988c60Tomas Winkler	u8 debug_flags;			/* 3945 reserved */
2065b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 rx_data_timeout;
2066b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 tx_data_timeout;
2067b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 sleep_interval[IWL_POWER_VEC_SIZE];
2068b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 keep_alive_beacons;
2069b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
2070b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2071b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
2072b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * PM_SLEEP_NOTIFICATION = 0x7A (notification only, not a command)
2073b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * 3945 and 4965 identical.
2074b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
20752aa6ab86bc475a115f56645591d2413981846509Tomas Winklerstruct iwl_sleep_notification {
2076b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 pm_sleep_mode;
2077b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 pm_wakeup_src;
2078b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 reserved;
2079b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 sleep_time;
2080b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 tsf_low;
2081b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 bcon_timer;
2082b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
2083b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2084b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* Sleep states.  3945 and 4965 identical. */
2085b481de9ca074528fe8c429604e2777db8b89806aZhu Yienum {
2086b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_PM_NO_SLEEP = 0,
2087b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_PM_SLP_MAC = 1,
2088b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_PM_SLP_FULL_MAC_UNASSOCIATE = 2,
2089b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_PM_SLP_FULL_MAC_CARD_STATE = 3,
2090b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_PM_SLP_PHY = 4,
2091b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_PM_SLP_REPENT = 5,
2092b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_PM_WAKEUP_BY_TIMER = 6,
2093b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_PM_WAKEUP_BY_DRIVER = 7,
2094b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_PM_WAKEUP_BY_RFKILL = 8,
2095b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	/* 3 reserved */
2096b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_PM_NUM_OF_MODES = 12,
2097b481de9ca074528fe8c429604e2777db8b89806aZhu Yi};
2098b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2099b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
2100b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_CARD_STATE_CMD = 0xa0 (command, has simple generic response)
2101b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
2102b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define CARD_STATE_CMD_DISABLE 0x00	/* Put card to sleep */
2103b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define CARD_STATE_CMD_ENABLE  0x01	/* Wake up card */
2104b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define CARD_STATE_CMD_HALT    0x02	/* Power down permanently */
21052aa6ab86bc475a115f56645591d2413981846509Tomas Winklerstruct iwl_card_state_cmd {
2106b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 status;		/* CARD_STATE_CMD_* request new power state */
2107b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
2108b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2109b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
2110b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * CARD_STATE_NOTIFICATION = 0xa1 (notification only, not a command)
2111b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
21122aa6ab86bc475a115f56645591d2413981846509Tomas Winklerstruct iwl_card_state_notif {
2113b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 flags;
2114b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
2115b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2116b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define HW_CARD_DISABLED   0x01
2117b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define SW_CARD_DISABLED   0x02
2118b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define RF_CARD_DISABLED   0x04
2119b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define RXON_CARD_DISABLED 0x10
2120b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
212147f4a5871614756627d7209e0569b58faf99b0d9Emmanuel Grumbachstruct iwl_ct_kill_config {
2122b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32   reserved;
2123b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32   critical_temperature_M;
2124b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32   critical_temperature_R;
2125b481de9ca074528fe8c429604e2777db8b89806aZhu Yi}  __attribute__ ((packed));
2126b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2127b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/******************************************************************************
2128b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * (8)
2129b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Scan Commands, Responses, Notifications:
2130b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
2131b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *****************************************************************************/
2132b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
213351e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define SCAN_CHANNEL_TYPE_PASSIVE cpu_to_le32(0)
213451e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define SCAN_CHANNEL_TYPE_ACTIVE  cpu_to_le32(1)
2135d16dc48a2ea14af9980d0ea79d041f4b53e47b62Tomas Winkler
21363058f02137359efb412975cf94a9fa7c25413387Ben M Cahill/**
21372a421b91d6fe89e27ded7544a25449c0b050098fTomas Winkler * struct iwl_scan_channel - entry in REPLY_SCAN_CMD channel table
21383058f02137359efb412975cf94a9fa7c25413387Ben M Cahill *
21393058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * One for each channel in the scan list.
21403058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * Each channel can independently select:
21413058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * 1)  SSID for directed active scans
21423058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * 2)  Txpower setting (for rate specified within Tx command)
21433058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * 3)  How long to stay on-channel (behavior may be modified by quiet_time,
21443058f02137359efb412975cf94a9fa7c25413387Ben M Cahill *     quiet_plcp_th, good_CRC_th)
21453058f02137359efb412975cf94a9fa7c25413387Ben M Cahill *
21463058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * To avoid uCode errors, make sure the following are true (see comments
21472a421b91d6fe89e27ded7544a25449c0b050098fTomas Winkler * under struct iwl_scan_cmd about max_out_time and quiet_time):
21483058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * 1)  If using passive_dwell (i.e. passive_dwell != 0):
21493058f02137359efb412975cf94a9fa7c25413387Ben M Cahill *     active_dwell <= passive_dwell (< max_out_time if max_out_time != 0)
21503058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * 2)  quiet_time <= active_dwell
21513058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * 3)  If restricting off-channel time (i.e. max_out_time !=0):
21523058f02137359efb412975cf94a9fa7c25413387Ben M Cahill *     passive_dwell < max_out_time
21533058f02137359efb412975cf94a9fa7c25413387Ben M Cahill *     active_dwell < max_out_time
21543058f02137359efb412975cf94a9fa7c25413387Ben M Cahill */
21552a421b91d6fe89e27ded7544a25449c0b050098fTomas Winklerstruct iwl_scan_channel {
21563058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	/*
21573058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	 * type is defined as:
21583058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	 * 0:0 1 = active, 0 = passive
2159d16dc48a2ea14af9980d0ea79d041f4b53e47b62Tomas Winkler	 * 1:20 SSID direct bit map; if a bit is set, then corresponding
21603058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	 *     SSID IE is transmitted in probe request.
2161d16dc48a2ea14af9980d0ea79d041f4b53e47b62Tomas Winkler	 * 21:31 reserved
2162b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 */
2163d16dc48a2ea14af9980d0ea79d041f4b53e47b62Tomas Winkler	__le32 type;
2164d16dc48a2ea14af9980d0ea79d041f4b53e47b62Tomas Winkler	__le16 channel;	/* band is selected by iwl_scan_cmd "flags" field */
2165f53696de6722a4aac00b76e25a5321c01e88a55fTomas Winkler	u8 tx_gain;		/* gain for analog radio */
2166f53696de6722a4aac00b76e25a5321c01e88a55fTomas Winkler	u8 dsp_atten;		/* gain for DSP */
21673058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	__le16 active_dwell;	/* in 1024-uSec TU (time units), typ 5-50 */
21683058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	__le16 passive_dwell;	/* in 1024-uSec TU (time units), typ 20-500 */
2169b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
2170b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
21713058f02137359efb412975cf94a9fa7c25413387Ben M Cahill/**
21722a421b91d6fe89e27ded7544a25449c0b050098fTomas Winkler * struct iwl_ssid_ie - directed scan network information element
21733058f02137359efb412975cf94a9fa7c25413387Ben M Cahill *
21743058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * Up to 4 of these may appear in REPLY_SCAN_CMD, selected by "type" field
21752aa6ab86bc475a115f56645591d2413981846509Tomas Winkler * in struct iwl_scan_channel; each channel may select different ssids from
21763058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * among the 4 entries.  SSID IEs get transmitted in reverse order of entry.
21773058f02137359efb412975cf94a9fa7c25413387Ben M Cahill */
21782a421b91d6fe89e27ded7544a25449c0b050098fTomas Winklerstruct iwl_ssid_ie {
2179b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 id;
2180b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 len;
2181b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 ssid[32];
2182b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
2183b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2184d16dc48a2ea14af9980d0ea79d041f4b53e47b62Tomas Winkler#define PROBE_OPTION_MAX        	0x14
218551e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define TX_CMD_LIFE_TIME_INFINITE	cpu_to_le32(0xFFFFFFFF)
218651e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define IWL_GOOD_CRC_TH			cpu_to_le16(1)
2187b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define IWL_MAX_SCAN_SIZE 1024
2188b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2189b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
2190b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_SCAN_CMD = 0x80 (command)
21913058f02137359efb412975cf94a9fa7c25413387Ben M Cahill *
21923058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * The hardware scan command is very powerful; the driver can set it up to
21933058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * maintain (relatively) normal network traffic while doing a scan in the
21943058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * background.  The max_out_time and suspend_time control the ratio of how
21953058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * long the device stays on an associated network channel ("service channel")
21963058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * vs. how long it's away from the service channel, i.e. tuned to other channels
21973058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * for scanning.
21983058f02137359efb412975cf94a9fa7c25413387Ben M Cahill *
21993058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * max_out_time is the max time off-channel (in usec), and suspend_time
22003058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * is how long (in "extended beacon" format) that the scan is "suspended"
22013058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * after returning to the service channel.  That is, suspend_time is the
22023058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * time that we stay on the service channel, doing normal work, between
22033058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * scan segments.  The driver may set these parameters differently to support
22043058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * scanning when associated vs. not associated, and light vs. heavy traffic
22053058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * loads when associated.
22063058f02137359efb412975cf94a9fa7c25413387Ben M Cahill *
22073058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * After receiving this command, the device's scan engine does the following;
22083058f02137359efb412975cf94a9fa7c25413387Ben M Cahill *
22093058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * 1)  Sends SCAN_START notification to driver
22103058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * 2)  Checks to see if it has time to do scan for one channel
22113058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * 3)  Sends NULL packet, with power-save (PS) bit set to 1,
22123058f02137359efb412975cf94a9fa7c25413387Ben M Cahill *     to tell AP that we're going off-channel
22133058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * 4)  Tunes to first channel in scan list, does active or passive scan
22143058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * 5)  Sends SCAN_RESULT notification to driver
22153058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * 6)  Checks to see if it has time to do scan on *next* channel in list
22163058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * 7)  Repeats 4-6 until it no longer has time to scan the next channel
22173058f02137359efb412975cf94a9fa7c25413387Ben M Cahill *     before max_out_time expires
22183058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * 8)  Returns to service channel
22193058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * 9)  Sends NULL packet with PS=0 to tell AP that we're back
22203058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * 10) Stays on service channel until suspend_time expires
22213058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * 11) Repeats entire process 2-10 until list is complete
22223058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * 12) Sends SCAN_COMPLETE notification
22233058f02137359efb412975cf94a9fa7c25413387Ben M Cahill *
22243058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * For fast, efficient scans, the scan command also has support for staying on
22253058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * a channel for just a short time, if doing active scanning and getting no
22263058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * responses to the transmitted probe request.  This time is controlled by
22273058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * quiet_time, and the number of received packets below which a channel is
22283058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * considered "quiet" is controlled by quiet_plcp_threshold.
22293058f02137359efb412975cf94a9fa7c25413387Ben M Cahill *
22303058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * For active scanning on channels that have regulatory restrictions against
22313058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * blindly transmitting, the scan can listen before transmitting, to make sure
22323058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * that there is already legitimate activity on the channel.  If enough
22333058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * packets are cleanly received on the channel (controlled by good_CRC_th,
22343058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * typical value 1), the scan engine starts transmitting probe requests.
22353058f02137359efb412975cf94a9fa7c25413387Ben M Cahill *
22363058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * Driver must use separate scan commands for 2.4 vs. 5 GHz bands.
22373058f02137359efb412975cf94a9fa7c25413387Ben M Cahill *
22383058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * To avoid uCode errors, see timing restrictions described under
22392a421b91d6fe89e27ded7544a25449c0b050098fTomas Winkler * struct iwl_scan_channel.
2240b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
22412a421b91d6fe89e27ded7544a25449c0b050098fTomas Winklerstruct iwl_scan_cmd {
2242b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 len;
2243b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 reserved0;
22443058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	u8 channel_count;	/* # channels in channel list */
22453058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	__le16 quiet_time;	/* dwell only this # millisecs on quiet channel
22463058f02137359efb412975cf94a9fa7c25413387Ben M Cahill				 * (only for active scan) */
22473058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	__le16 quiet_plcp_th;	/* quiet chnl is < this # pkts (typ. 1) */
22483058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	__le16 good_CRC_th;	/* passive -> active promotion threshold */
22493058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	__le16 rx_chain;	/* RXON_RX_CHAIN_* */
22503058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	__le32 max_out_time;	/* max usec to be away from associated (service)
22513058f02137359efb412975cf94a9fa7c25413387Ben M Cahill				 * channel */
22523058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	__le32 suspend_time;	/* pause scan this long (in "extended beacon
22533058f02137359efb412975cf94a9fa7c25413387Ben M Cahill				 * format") when returning to service chnl:
22543058f02137359efb412975cf94a9fa7c25413387Ben M Cahill				 * 3945; 31:24 # beacons, 19:0 additional usec,
22553058f02137359efb412975cf94a9fa7c25413387Ben M Cahill				 * 4965; 31:22 # beacons, 21:0 additional usec.
22563058f02137359efb412975cf94a9fa7c25413387Ben M Cahill				 */
22573058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	__le32 flags;		/* RXON_FLG_* */
22583058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	__le32 filter_flags;	/* RXON_FILTER_* */
22593058f02137359efb412975cf94a9fa7c25413387Ben M Cahill
22603058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	/* For active scans (set to all-0s for passive scans).
22613058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	 * Does not include payload.  Must specify Tx rate; no rate scaling. */
226283d527d9e8f9aff92cbd33f208f77c055dabb499Tomas Winkler	struct iwl_tx_cmd tx_cmd;
22633058f02137359efb412975cf94a9fa7c25413387Ben M Cahill
22643058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	/* For directed active scans (set to all-0s otherwise) */
22652a421b91d6fe89e27ded7544a25449c0b050098fTomas Winkler	struct iwl_ssid_ie direct_scan[PROBE_OPTION_MAX];
2266b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2267b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	/*
22683058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	 * Probe request frame, followed by channel list.
22693058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	 *
22703058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	 * Size of probe request frame is specified by byte count in tx_cmd.
22713058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	 * Channel list follows immediately after probe request frame.
22723058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	 * Number of channels in list is specified by channel_count.
22733058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	 * Each channel in list is of type:
2274b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 *
22752aa6ab86bc475a115f56645591d2413981846509Tomas Winkler	 * struct iwl_scan_channel channels[0];
2276b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 *
2277b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 * NOTE:  Only one band of channels can be scanned per pass.  You
22783058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	 * must not mix 2.4GHz channels and 5.2GHz channels, and you must wait
22793058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	 * for one scan to complete (i.e. receive SCAN_COMPLETE_NOTIFICATION)
22803058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	 * before requesting another scan.
2281b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 */
22823058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	u8 data[0];
2283b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
2284b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2285b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* Can abort will notify by complete notification with abort status. */
228651e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define CAN_ABORT_STATUS	cpu_to_le32(0x1)
2287b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* complete notification statuses */
2288b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define ABORT_STATUS            0x2
2289b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2290b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
2291b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_SCAN_CMD = 0x80 (response)
2292b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
22932a421b91d6fe89e27ded7544a25449c0b050098fTomas Winklerstruct iwl_scanreq_notification {
2294b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 status;		/* 1: okay, 2: cannot fulfill request */
2295b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
2296b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2297b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
2298b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * SCAN_START_NOTIFICATION = 0x82 (notification only, not a command)
2299b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
23002a421b91d6fe89e27ded7544a25449c0b050098fTomas Winklerstruct iwl_scanstart_notification {
2301b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 tsf_low;
2302b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 tsf_high;
2303b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 beacon_timer;
2304b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 channel;
2305b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 band;
2306b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 reserved[2];
2307b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 status;
2308b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
2309b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2310b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define  SCAN_OWNER_STATUS 0x1;
2311b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define  MEASURE_OWNER_STATUS 0x2;
2312b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2313b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define NUMBER_OF_STATISTICS 1	/* first __le32 is good CRC */
2314b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
2315b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * SCAN_RESULTS_NOTIFICATION = 0x83 (notification only, not a command)
2316b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
23172a421b91d6fe89e27ded7544a25449c0b050098fTomas Winklerstruct iwl_scanresults_notification {
2318b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 channel;
2319b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 band;
2320b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 reserved[2];
2321b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 tsf_low;
2322b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 tsf_high;
2323b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 statistics[NUMBER_OF_STATISTICS];
2324b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
2325b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2326b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
2327b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * SCAN_COMPLETE_NOTIFICATION = 0x84 (notification only, not a command)
2328b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
23292a421b91d6fe89e27ded7544a25449c0b050098fTomas Winklerstruct iwl_scancomplete_notification {
2330b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 scanned_channels;
2331b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 status;
2332b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 reserved;
2333b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 last_channel;
2334b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 tsf_low;
2335b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 tsf_high;
2336b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
2337b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2338b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2339b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/******************************************************************************
2340b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * (9)
2341b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * IBSS/AP Commands and Notifications:
2342b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
2343b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *****************************************************************************/
2344b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2345b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
2346b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * BEACON_NOTIFICATION = 0x90 (notification only, not a command)
2347b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
2348bb8c093bdea62f2ae371b98ebff81b0407852fafChristoph Hellwigstruct iwl4965_beacon_notif {
2349bb8c093bdea62f2ae371b98ebff81b0407852fafChristoph Hellwig	struct iwl4965_tx_resp beacon_notify_hdr;
2350b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 low_tsf;
2351b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 high_tsf;
2352b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 ibss_mgr_status;
2353b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
2354b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2355b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
2356b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_TX_BEACON = 0x91 (command, has simple generic response)
2357b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
23584bf64efd26f5610cde4fb7846e2f37bd1f62d3a9Tomas Winklerstruct iwl_tx_beacon_cmd {
235983d527d9e8f9aff92cbd33f208f77c055dabb499Tomas Winkler	struct iwl_tx_cmd tx;
2360b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 tim_idx;
2361b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 tim_size;
2362b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 reserved1;
2363b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct ieee80211_hdr frame[0];	/* beacon frame */
2364b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
2365b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2366b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/******************************************************************************
2367b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * (10)
2368b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Statistics Commands and Notifications:
2369b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
2370b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *****************************************************************************/
2371b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2372b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define IWL_TEMP_CONVERT 260
2373b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2374b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define SUP_RATE_11A_MAX_NUM_CHANNELS  8
2375b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define SUP_RATE_11B_MAX_NUM_CHANNELS  4
2376b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define SUP_RATE_11G_MAX_NUM_CHANNELS  12
2377b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2378b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* Used for passing to driver number of successes and failures per rate */
2379b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct rate_histogram {
2380b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	union {
2381b481de9ca074528fe8c429604e2777db8b89806aZhu Yi		__le32 a[SUP_RATE_11A_MAX_NUM_CHANNELS];
2382b481de9ca074528fe8c429604e2777db8b89806aZhu Yi		__le32 b[SUP_RATE_11B_MAX_NUM_CHANNELS];
2383b481de9ca074528fe8c429604e2777db8b89806aZhu Yi		__le32 g[SUP_RATE_11G_MAX_NUM_CHANNELS];
2384b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	} success;
2385b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	union {
2386b481de9ca074528fe8c429604e2777db8b89806aZhu Yi		__le32 a[SUP_RATE_11A_MAX_NUM_CHANNELS];
2387b481de9ca074528fe8c429604e2777db8b89806aZhu Yi		__le32 b[SUP_RATE_11B_MAX_NUM_CHANNELS];
2388b481de9ca074528fe8c429604e2777db8b89806aZhu Yi		__le32 g[SUP_RATE_11G_MAX_NUM_CHANNELS];
2389b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	} failed;
2390b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
2391b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2392b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* statistics command response */
2393b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2394b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct statistics_rx_phy {
2395b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 ina_cnt;
2396b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 fina_cnt;
2397b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 plcp_err;
2398b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 crc32_err;
2399b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 overrun_err;
2400b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 early_overrun_err;
2401b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 crc32_good;
2402b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 false_alarm_cnt;
2403b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 fina_sync_err_cnt;
2404b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 sfd_timeout;
2405b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 fina_timeout;
2406b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 unresponded_rts;
2407b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 rxe_frame_limit_overrun;
2408b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 sent_ack_cnt;
2409b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 sent_cts_cnt;
2410b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 sent_ba_rsp_cnt;
2411b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 dsp_self_kill;
2412b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 mh_format_err;
2413b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 re_acq_main_rssi_sum;
2414b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 reserved3;
2415b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
2416b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2417b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct statistics_rx_ht_phy {
2418b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 plcp_err;
2419b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 overrun_err;
2420b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 early_overrun_err;
2421b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 crc32_good;
2422b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 crc32_err;
2423b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 mh_format_err;
2424b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 agg_crc32_good;
2425b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 agg_mpdu_cnt;
2426b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 agg_cnt;
2427b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 reserved2;
2428b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
2429b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
243034c22cf93d1446791c966c878cc691e07c39d8d3Winkler, Tomas#define INTERFERENCE_DATA_AVAILABLE      __constant_cpu_to_le32(1)
243134c22cf93d1446791c966c878cc691e07c39d8d3Winkler, Tomas
2432b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct statistics_rx_non_phy {
2433b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 bogus_cts;	/* CTS received when not expecting CTS */
2434b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 bogus_ack;	/* ACK received when not expecting ACK */
2435b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 non_bssid_frames;	/* number of frames with BSSID that
2436b481de9ca074528fe8c429604e2777db8b89806aZhu Yi					 * doesn't belong to the STA BSSID */
2437b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 filtered_frames;	/* count frames that were dumped in the
2438b481de9ca074528fe8c429604e2777db8b89806aZhu Yi				 * filtering process */
2439b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 non_channel_beacons;	/* beacons with our bss id but not on
2440b481de9ca074528fe8c429604e2777db8b89806aZhu Yi					 * our serving channel */
2441b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 channel_beacons;	/* beacons with our bss id and in our
2442b481de9ca074528fe8c429604e2777db8b89806aZhu Yi				 * serving channel */
2443b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 num_missed_bcon;	/* number of missed beacons */
2444b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 adc_rx_saturation_time;	/* count in 0.8us units the time the
2445b481de9ca074528fe8c429604e2777db8b89806aZhu Yi					 * ADC was in saturation */
2446b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 ina_detection_search_time;/* total time (in 0.8us) searched
2447b481de9ca074528fe8c429604e2777db8b89806aZhu Yi					  * for INA */
2448b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 beacon_silence_rssi_a;	/* RSSI silence after beacon frame */
2449b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 beacon_silence_rssi_b;	/* RSSI silence after beacon frame */
2450b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 beacon_silence_rssi_c;	/* RSSI silence after beacon frame */
2451b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 interference_data_flag;	/* flag for interference data
2452b481de9ca074528fe8c429604e2777db8b89806aZhu Yi					 * availability. 1 when data is
2453b481de9ca074528fe8c429604e2777db8b89806aZhu Yi					 * available. */
24543058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	__le32 channel_load;		/* counts RX Enable time in uSec */
2455b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 dsp_false_alarms;	/* DSP false alarm (both OFDM
2456b481de9ca074528fe8c429604e2777db8b89806aZhu Yi					 * and CCK) counter */
2457b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 beacon_rssi_a;
2458b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 beacon_rssi_b;
2459b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 beacon_rssi_c;
2460b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 beacon_energy_a;
2461b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 beacon_energy_b;
2462b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 beacon_energy_c;
2463b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
2464b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2465b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct statistics_rx {
2466b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct statistics_rx_phy ofdm;
2467b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct statistics_rx_phy cck;
2468b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct statistics_rx_non_phy general;
2469b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct statistics_rx_ht_phy ofdm_ht;
2470b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
2471b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2472b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct statistics_tx_non_phy_agg {
2473b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 ba_timeout;
2474b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 ba_reschedule_frames;
2475b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 scd_query_agg_frame_cnt;
2476b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 scd_query_no_agg;
2477b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 scd_query_agg;
2478b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 scd_query_mismatch;
2479b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 frame_not_ready;
2480b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 underrun;
2481b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 bt_prio_kill;
2482b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 rx_ba_rsp_cnt;
2483b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 reserved2;
2484b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 reserved3;
2485b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
2486b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2487b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct statistics_tx {
2488b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 preamble_cnt;
2489b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 rx_detected_cnt;
2490b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 bt_prio_defer_cnt;
2491b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 bt_prio_kill_cnt;
2492b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 few_bytes_cnt;
2493b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 cts_timeout;
2494b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 ack_timeout;
2495b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 expected_ack_cnt;
2496b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 actual_ack_cnt;
2497b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 dump_msdu_cnt;
2498b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 burst_abort_next_frame_mismatch_cnt;
2499b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 burst_abort_missing_next_frame_cnt;
2500b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 cts_timeout_collision;
2501b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 ack_or_ba_timeout_collision;
2502b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct statistics_tx_non_phy_agg agg;
2503b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
2504b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2505b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct statistics_dbg {
2506b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 burst_check;
2507b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 burst_count;
2508b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 reserved[4];
2509b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
2510b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2511b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct statistics_div {
2512b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 tx_on_a;
2513b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 tx_on_b;
2514b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 exec_time;
2515b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 probe_time;
2516b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 reserved1;
2517b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 reserved2;
2518b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
2519b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2520b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct statistics_general {
2521b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 temperature;
2522b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 temperature_m;
2523b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct statistics_dbg dbg;
2524b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 sleep_time;
2525b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 slots_out;
2526b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 slots_idle;
2527b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 ttl_timestamp;
2528b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct statistics_div div;
2529b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 rx_enable_counter;
2530b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 reserved1;
2531b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 reserved2;
2532b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 reserved3;
2533b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
2534b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2535b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
2536b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_STATISTICS_CMD = 0x9c,
2537b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * 3945 and 4965 identical.
2538b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
2539b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * This command triggers an immediate response containing uCode statistics.
2540b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * The response is in the same format as STATISTICS_NOTIFICATION 0x9d, below.
2541b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
2542b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * If the CLEAR_STATS configuration flag is set, uCode will clear its
2543b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * internal copy of the statistics (counters) after issuing the response.
2544b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * This flag does not affect STATISTICS_NOTIFICATIONs after beacons (see below).
2545b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
2546b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * If the DISABLE_NOTIF configuration flag is set, uCode will not issue
2547b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * STATISTICS_NOTIFICATIONs after received beacons (see below).  This flag
2548b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * does not affect the response to the REPLY_STATISTICS_CMD 0x9c itself.
2549b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
255051e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define IWL_STATS_CONF_CLEAR_STATS cpu_to_le32(0x1)	/* see above */
255151e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define IWL_STATS_CONF_DISABLE_NOTIF cpu_to_le32(0x2)/* see above */
25528f91aecb4cdc2d786df8941e827b9dff3c10a4e4Emmanuel Grumbachstruct iwl_statistics_cmd {
2553b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 configuration_flags;	/* IWL_STATS_CONF_* */
2554b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
2555b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2556b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
2557b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * STATISTICS_NOTIFICATION = 0x9d (notification only, not a command)
2558b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
2559b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * By default, uCode issues this notification after receiving a beacon
2560b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * while associated.  To disable this behavior, set DISABLE_NOTIF flag in the
2561b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_STATISTICS_CMD 0x9c, above.
2562b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
2563b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Statistics counters continue to increment beacon after beacon, but are
2564b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * cleared when changing channels or when driver issues REPLY_STATISTICS_CMD
2565b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * 0x9c with CLEAR_STATS bit set (see above).
2566b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
2567b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * uCode also issues this notification during scans.  uCode clears statistics
2568b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * appropriately so that each notification contains statistics for only the
2569b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * one channel that has just been scanned.
2570b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
257151e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define STATISTICS_REPLY_FLG_BAND_24G_MSK         cpu_to_le32(0x2)
257251e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define STATISTICS_REPLY_FLG_FAT_MODE_MSK         cpu_to_le32(0x8)
25738f91aecb4cdc2d786df8941e827b9dff3c10a4e4Emmanuel Grumbachstruct iwl_notif_statistics {
2574b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 flag;
2575b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct statistics_rx rx;
2576b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct statistics_tx tx;
2577b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct statistics_general general;
2578b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
2579b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2580b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2581b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
2582b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * MISSED_BEACONS_NOTIFICATION = 0xa2 (notification only, not a command)
2583b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
2584b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* if ucode missed CONSECUTIVE_MISSED_BCONS_TH beacons in a row,
2585b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * then this notification will be sent. */
2586b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define CONSECUTIVE_MISSED_BCONS_TH 20
2587b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
25882aa6ab86bc475a115f56645591d2413981846509Tomas Winklerstruct iwl_missed_beacon_notif {
2589b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 consequtive_missed_beacons;
2590b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 total_missed_becons;
2591b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 num_expected_beacons;
2592b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 num_recvd_beacons;
2593b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
2594b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2595f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill
2596b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/******************************************************************************
2597b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * (11)
2598b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Rx Calibration Commands:
2599b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
2600f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * With the uCode used for open source drivers, most Tx calibration (except
2601f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * for Tx Power) and most Rx calibration is done by uCode during the
2602f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * "initialize" phase of uCode boot.  Driver must calibrate only:
2603f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
2604f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * 1)  Tx power (depends on temperature), described elsewhere
2605f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * 2)  Receiver gain balance (optimize MIMO, and detect disconnected antennas)
2606f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * 3)  Receiver sensitivity (to optimize signal detection)
2607f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
2608b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *****************************************************************************/
2609b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2610f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill/**
2611f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * SENSITIVITY_CMD = 0xa8 (command, has simple generic response)
2612f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
2613f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * This command sets up the Rx signal detector for a sensitivity level that
2614f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * is high enough to lock onto all signals within the associated network,
2615f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * but low enough to ignore signals that are below a certain threshold, so as
2616f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * not to have too many "false alarms".  False alarms are signals that the
2617f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * Rx DSP tries to lock onto, but then discards after determining that they
2618f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * are noise.
2619f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
2620f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * The optimum number of false alarms is between 5 and 50 per 200 TUs
2621f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * (200 * 1024 uSecs, i.e. 204.8 milliseconds) of actual Rx time (i.e.
2622f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * time listening, not transmitting).  Driver must adjust sensitivity so that
2623f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * the ratio of actual false alarms to actual Rx time falls within this range.
2624f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
2625f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * While associated, uCode delivers STATISTICS_NOTIFICATIONs after each
2626f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * received beacon.  These provide information to the driver to analyze the
2627f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * sensitivity.  Don't analyze statistics that come in from scanning, or any
2628f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * other non-associated-network source.  Pertinent statistics include:
2629f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
2630f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * From "general" statistics (struct statistics_rx_non_phy):
2631f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
2632f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * (beacon_energy_[abc] & 0x0FF00) >> 8 (unsigned, higher value is lower level)
2633f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   Measure of energy of desired signal.  Used for establishing a level
2634f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   below which the device does not detect signals.
2635f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
2636f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * (beacon_silence_rssi_[abc] & 0x0FF00) >> 8 (unsigned, units in dB)
2637f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   Measure of background noise in silent period after beacon.
2638f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
2639f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * channel_load
2640f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   uSecs of actual Rx time during beacon period (varies according to
2641f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   how much time was spent transmitting).
2642f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
2643f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * From "cck" and "ofdm" statistics (struct statistics_rx_phy), separately:
2644f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
2645f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * false_alarm_cnt
2646f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   Signal locks abandoned early (before phy-level header).
2647f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
2648f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * plcp_err
2649f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   Signal locks abandoned late (during phy-level header).
2650f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
2651f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * NOTE:  Both false_alarm_cnt and plcp_err increment monotonically from
2652f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        beacon to beacon, i.e. each value is an accumulation of all errors
2653f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        before and including the latest beacon.  Values will wrap around to 0
2654f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        after counting up to 2^32 - 1.  Driver must differentiate vs.
2655f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        previous beacon's values to determine # false alarms in the current
2656f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        beacon period.
2657f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
2658f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * Total number of false alarms = false_alarms + plcp_errs
2659f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
2660f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * For OFDM, adjust the following table entries in struct iwl_sensitivity_cmd
2661f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * (notice that the start points for OFDM are at or close to settings for
2662f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * maximum sensitivity):
2663f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
2664f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *                                             START  /  MIN  /  MAX
2665f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   HD_AUTO_CORR32_X1_TH_ADD_MIN_INDEX          90   /   85  /  120
2666f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   HD_AUTO_CORR32_X1_TH_ADD_MIN_MRC_INDEX     170   /  170  /  210
2667f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   HD_AUTO_CORR32_X4_TH_ADD_MIN_INDEX         105   /  105  /  140
2668f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   HD_AUTO_CORR32_X4_TH_ADD_MIN_MRC_INDEX     220   /  220  /  270
2669f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
2670f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   If actual rate of OFDM false alarms (+ plcp_errors) is too high
2671f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   (greater than 50 for each 204.8 msecs listening), reduce sensitivity
2672f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   by *adding* 1 to all 4 of the table entries above, up to the max for
2673f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   each entry.  Conversely, if false alarm rate is too low (less than 5
2674f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   for each 204.8 msecs listening), *subtract* 1 from each entry to
2675f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   increase sensitivity.
2676f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
2677f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * For CCK sensitivity, keep track of the following:
2678f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
2679f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   1).  20-beacon history of maximum background noise, indicated by
2680f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        (beacon_silence_rssi_[abc] & 0x0FF00), units in dB, across the
2681f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        3 receivers.  For any given beacon, the "silence reference" is
2682f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        the maximum of last 60 samples (20 beacons * 3 receivers).
2683f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
2684f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   2).  10-beacon history of strongest signal level, as indicated
2685f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        by (beacon_energy_[abc] & 0x0FF00) >> 8, across the 3 receivers,
2686f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        i.e. the strength of the signal through the best receiver at the
2687f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        moment.  These measurements are "upside down", with lower values
2688f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        for stronger signals, so max energy will be *minimum* value.
2689f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
2690f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        Then for any given beacon, the driver must determine the *weakest*
2691f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        of the strongest signals; this is the minimum level that needs to be
2692f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        successfully detected, when using the best receiver at the moment.
2693f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        "Max cck energy" is the maximum (higher value means lower energy!)
2694f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        of the last 10 minima.  Once this is determined, driver must add
2695f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        a little margin by adding "6" to it.
2696f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
2697f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   3).  Number of consecutive beacon periods with too few false alarms.
2698f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        Reset this to 0 at the first beacon period that falls within the
2699f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        "good" range (5 to 50 false alarms per 204.8 milliseconds rx).
2700f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
2701f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * Then, adjust the following CCK table entries in struct iwl_sensitivity_cmd
2702f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * (notice that the start points for CCK are at maximum sensitivity):
2703f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
2704f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *                                             START  /  MIN  /  MAX
2705f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX         125   /  125  /  200
2706f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX     200   /  200  /  400
2707f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   HD_MIN_ENERGY_CCK_DET_INDEX                100   /    0  /  100
2708f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
2709f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   If actual rate of CCK false alarms (+ plcp_errors) is too high
2710f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   (greater than 50 for each 204.8 msecs listening), method for reducing
2711f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   sensitivity is:
2712f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
2713f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   1)  *Add* 3 to value in HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX,
2714f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *       up to max 400.
2715f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
2716f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   2)  If current value in HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX is < 160,
2717f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *       sensitivity has been reduced a significant amount; bring it up to
2718f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *       a moderate 161.  Otherwise, *add* 3, up to max 200.
2719f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
2720f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   3)  a)  If current value in HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX is > 160,
2721f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *       sensitivity has been reduced only a moderate or small amount;
2722f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *       *subtract* 2 from value in HD_MIN_ENERGY_CCK_DET_INDEX,
2723f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *       down to min 0.  Otherwise (if gain has been significantly reduced),
2724f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *       don't change the HD_MIN_ENERGY_CCK_DET_INDEX value.
2725f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
2726f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *       b)  Save a snapshot of the "silence reference".
2727f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
2728f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   If actual rate of CCK false alarms (+ plcp_errors) is too low
2729f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   (less than 5 for each 204.8 msecs listening), method for increasing
2730f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   sensitivity is used only if:
2731f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
2732f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   1a)  Previous beacon did not have too many false alarms
2733f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   1b)  AND difference between previous "silence reference" and current
2734f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        "silence reference" (prev - current) is 2 or more,
2735f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   OR 2)  100 or more consecutive beacon periods have had rate of
2736f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *          less than 5 false alarms per 204.8 milliseconds rx time.
2737f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
2738f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   Method for increasing sensitivity:
2739f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
2740f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   1)  *Subtract* 3 from value in HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX,
2741f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *       down to min 125.
2742f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
2743f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   2)  *Subtract* 3 from value in HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX,
2744f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *       down to min 200.
2745f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
2746f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   3)  *Add* 2 to value in HD_MIN_ENERGY_CCK_DET_INDEX, up to max 100.
2747f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
2748f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   If actual rate of CCK false alarms (+ plcp_errors) is within good range
2749f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   (between 5 and 50 for each 204.8 msecs listening):
2750f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
2751f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   1)  Save a snapshot of the silence reference.
2752f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
2753f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   2)  If previous beacon had too many CCK false alarms (+ plcp_errors),
2754f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *       give some extra margin to energy threshold by *subtracting* 8
2755f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *       from value in HD_MIN_ENERGY_CCK_DET_INDEX.
2756f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
2757f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   For all cases (too few, too many, good range), make sure that the CCK
2758f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   detection threshold (energy) is below the energy level for robust
2759f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   detection over the past 10 beacon periods, the "Max cck energy".
2760f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   Lower values mean higher energy; this means making sure that the value
2761f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   in HD_MIN_ENERGY_CCK_DET_INDEX is at or *above* "Max cck energy".
2762f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
2763f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * Driver should set the following entries to fixed values:
2764f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
2765f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   HD_MIN_ENERGY_OFDM_DET_INDEX               100
2766f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   HD_BARKER_CORR_TH_ADD_MIN_INDEX            190
2767f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   HD_BARKER_CORR_TH_ADD_MIN_MRC_INDEX        390
2768f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   HD_OFDM_ENERGY_TH_IN_INDEX                  62
2769f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill */
2770f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill
2771f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill/*
2772f0832f137c21d130998a0f97f97ac01a2d97210bEmmanuel Grumbach * Table entries in SENSITIVITY_CMD (struct iwl_sensitivity_cmd)
2773f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill */
2774f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill#define HD_TABLE_SIZE  (11)	/* number of entries */
2775f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill#define HD_MIN_ENERGY_CCK_DET_INDEX                 (0)	/* table indexes */
2776f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill#define HD_MIN_ENERGY_OFDM_DET_INDEX                (1)
2777f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill#define HD_AUTO_CORR32_X1_TH_ADD_MIN_INDEX          (2)
2778f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill#define HD_AUTO_CORR32_X1_TH_ADD_MIN_MRC_INDEX      (3)
2779f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill#define HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX      (4)
2780f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill#define HD_AUTO_CORR32_X4_TH_ADD_MIN_INDEX          (5)
2781f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill#define HD_AUTO_CORR32_X4_TH_ADD_MIN_MRC_INDEX      (6)
2782f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill#define HD_BARKER_CORR_TH_ADD_MIN_INDEX             (7)
2783f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill#define HD_BARKER_CORR_TH_ADD_MIN_MRC_INDEX         (8)
2784f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill#define HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX          (9)
2785f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill#define HD_OFDM_ENERGY_TH_IN_INDEX                  (10)
2786f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill
2787f0832f137c21d130998a0f97f97ac01a2d97210bEmmanuel Grumbach/* Control field in struct iwl_sensitivity_cmd */
278851e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define SENSITIVITY_CMD_CONTROL_DEFAULT_TABLE	cpu_to_le16(0)
278951e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define SENSITIVITY_CMD_CONTROL_WORK_TABLE	cpu_to_le16(1)
2790b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2791f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill/**
2792f0832f137c21d130998a0f97f97ac01a2d97210bEmmanuel Grumbach * struct iwl_sensitivity_cmd
2793f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * @control:  (1) updates working table, (0) updates default table
2794f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * @table:  energy threshold values, use HD_* as index into table
2795f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
2796f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * Always use "1" in "control" to update uCode's working table and DSP.
2797f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill */
2798f0832f137c21d130998a0f97f97ac01a2d97210bEmmanuel Grumbachstruct iwl_sensitivity_cmd {
2799f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill	__le16 control;			/* always use "1" */
2800f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill	__le16 table[HD_TABLE_SIZE];	/* use HD_* as index */
2801b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
2802b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2803f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill
2804f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill/**
2805f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * REPLY_PHY_CALIBRATION_CMD = 0xb0 (command, has simple generic response)
2806f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
2807f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * This command sets the relative gains of 4965's 3 radio receiver chains.
2808f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
2809f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * After the first association, driver should accumulate signal and noise
2810f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * statistics from the STATISTICS_NOTIFICATIONs that follow the first 20
2811f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * beacons from the associated network (don't collect statistics that come
2812f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * in from scanning, or any other non-network source).
2813f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
2814f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * DISCONNECTED ANTENNA:
2815f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
2816f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * Driver should determine which antennas are actually connected, by comparing
2817f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * average beacon signal levels for the 3 Rx chains.  Accumulate (add) the
2818f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * following values over 20 beacons, one accumulator for each of the chains
2819f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * a/b/c, from struct statistics_rx_non_phy:
2820f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
2821f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * beacon_rssi_[abc] & 0x0FF (unsigned, units in dB)
2822f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
2823f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * Find the strongest signal from among a/b/c.  Compare the other two to the
2824f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * strongest.  If any signal is more than 15 dB (times 20, unless you
2825f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * divide the accumulated values by 20) below the strongest, the driver
2826f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * considers that antenna to be disconnected, and should not try to use that
2827f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * antenna/chain for Rx or Tx.  If both A and B seem to be disconnected,
2828f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * driver should declare the stronger one as connected, and attempt to use it
2829f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * (A and B are the only 2 Tx chains!).
2830f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
2831f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
2832f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * RX BALANCE:
2833f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
2834f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * Driver should balance the 3 receivers (but just the ones that are connected
2835f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * to antennas, see above) for gain, by comparing the average signal levels
2836f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * detected during the silence after each beacon (background noise).
2837f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * Accumulate (add) the following values over 20 beacons, one accumulator for
2838f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * each of the chains a/b/c, from struct statistics_rx_non_phy:
2839f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
2840f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * beacon_silence_rssi_[abc] & 0x0FF (unsigned, units in dB)
2841f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
2842f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * Find the weakest background noise level from among a/b/c.  This Rx chain
2843f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * will be the reference, with 0 gain adjustment.  Attenuate other channels by
2844f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * finding noise difference:
2845f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
2846f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * (accum_noise[i] - accum_noise[reference]) / 30
2847f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
2848f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * The "30" adjusts the dB in the 20 accumulated samples to units of 1.5 dB.
2849f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * For use in diff_gain_[abc] fields of struct iwl_calibration_cmd, the
2850f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * driver should limit the difference results to a range of 0-3 (0-4.5 dB),
2851f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * and set bit 2 to indicate "reduce gain".  The value for the reference
2852f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * (weakest) chain should be "0".
2853f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
2854f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * diff_gain_[abc] bit fields:
2855f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   2: (1) reduce gain, (0) increase gain
2856f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * 1-0: amount of gain, units of 1.5 dB
2857f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill */
2858f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill
2859f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler/* Phy calibration command for series */
286033fd503346ad86bd7470a0f8c4c3080393d14233Emmanuel Grumbach
286133fd503346ad86bd7470a0f8c4c3080393d14233Emmanuel Grumbachenum {
2862f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler	IWL_PHY_CALIBRATE_DIFF_GAIN_CMD		= 7,
2863f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler	IWL_PHY_CALIBRATE_DC_CMD		= 8,
2864f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler	IWL_PHY_CALIBRATE_LO_CMD		= 9,
2865f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler	IWL_PHY_CALIBRATE_RX_BB_CMD		= 10,
2866f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler	IWL_PHY_CALIBRATE_TX_IQ_CMD		= 11,
2867f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler	IWL_PHY_CALIBRATE_RX_IQ_CMD		= 12,
2868f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler	IWL_PHY_CALIBRATION_NOISE_CMD		= 13,
2869f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler	IWL_PHY_CALIBRATE_AGC_TABLE_CMD		= 14,
2870f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler	IWL_PHY_CALIBRATE_CRYSTAL_FRQ_CMD	= 15,
2871f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler	IWL_PHY_CALIBRATE_BASE_BAND_CMD		= 16,
2872f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler	IWL_PHY_CALIBRATE_TX_IQ_PERD_CMD	= 17,
2873f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler	IWL_PHY_CALIBRATE_CHAIN_NOISE_RESET_CMD	= 18,
2874f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler	IWL_PHY_CALIBRATE_CHAIN_NOISE_GAIN_CMD	= 19,
287533fd503346ad86bd7470a0f8c4c3080393d14233Emmanuel Grumbach};
287633fd503346ad86bd7470a0f8c4c3080393d14233Emmanuel Grumbach
2877f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler
287851e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define IWL_CALIB_INIT_CFG_ALL	cpu_to_le32(0xffffffff)
28797c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler
28807c616cba240cd0d579c996be3f3603456acfb0adTomas Winklerstruct iwl_calib_cfg_elmnt_s {
28817c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler	__le32 is_enable;
28827c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler	__le32 start;
28837c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler	__le32 send_res;
28847c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler	__le32 apply_res;
28857c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler	__le32 reserved;
28867c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler} __attribute__ ((packed));
28877c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler
28887c616cba240cd0d579c996be3f3603456acfb0adTomas Winklerstruct iwl_calib_cfg_status_s {
28897c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler	struct iwl_calib_cfg_elmnt_s once;
28907c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler	struct iwl_calib_cfg_elmnt_s perd;
28917c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler	__le32 flags;
28927c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler} __attribute__ ((packed));
28937c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler
2894f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winklerstruct iwl_calib_cfg_cmd {
28957c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler	struct iwl_calib_cfg_status_s ucd_calib_cfg;
28967c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler	struct iwl_calib_cfg_status_s drv_calib_cfg;
28977c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler	__le32 reserved1;
28987c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler} __attribute__ ((packed));
28997c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler
2900f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winklerstruct iwl_calib_hdr {
29017c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler	u8 op_code;
29027c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler	u8 first_group;
29037c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler	u8 groups_num;
29047c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler	u8 data_valid;
29057c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler} __attribute__ ((packed));
29067c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler
2907f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winklerstruct iwl_calib_cmd {
2908f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler	struct iwl_calib_hdr hdr;
2909be5d56ed885a2897ec813eab4a8055d495816e9aTomas Winkler	u8 data[0];
2910be5d56ed885a2897ec813eab4a8055d495816e9aTomas Winkler} __attribute__ ((packed));
2911be5d56ed885a2897ec813eab4a8055d495816e9aTomas Winkler
29120d950d84d9d16f7d4edf380a238c5b534ff00d11Tomas Winkler/* IWL_PHY_CALIBRATE_DIFF_GAIN_CMD (7) */
2913f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winklerstruct iwl_calib_diff_gain_cmd {
29140d950d84d9d16f7d4edf380a238c5b534ff00d11Tomas Winkler	struct iwl_calib_hdr hdr;
2915f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler	s8 diff_gain_a;		/* see above */
2916f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler	s8 diff_gain_b;
2917f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler	s8 diff_gain_c;
2918f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler	u8 reserved1;
2919f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler} __attribute__ ((packed));
2920f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler
29210d950d84d9d16f7d4edf380a238c5b534ff00d11Tomas Winklerstruct iwl_calib_xtal_freq_cmd {
29220d950d84d9d16f7d4edf380a238c5b534ff00d11Tomas Winkler	struct iwl_calib_hdr hdr;
29230d950d84d9d16f7d4edf380a238c5b534ff00d11Tomas Winkler	u8 cap_pin1;
29240d950d84d9d16f7d4edf380a238c5b534ff00d11Tomas Winkler	u8 cap_pin2;
29250d950d84d9d16f7d4edf380a238c5b534ff00d11Tomas Winkler	u8 pad[2];
292633fd503346ad86bd7470a0f8c4c3080393d14233Emmanuel Grumbach} __attribute__ ((packed));
292733fd503346ad86bd7470a0f8c4c3080393d14233Emmanuel Grumbach
29280d950d84d9d16f7d4edf380a238c5b534ff00d11Tomas Winkler/* IWL_PHY_CALIBRATE_CHAIN_NOISE_RESET_CMD */
29290d950d84d9d16f7d4edf380a238c5b534ff00d11Tomas Winklerstruct iwl_calib_chain_noise_reset_cmd {
29300d950d84d9d16f7d4edf380a238c5b534ff00d11Tomas Winkler	struct iwl_calib_hdr hdr;
29310d950d84d9d16f7d4edf380a238c5b534ff00d11Tomas Winkler	u8 data[0];
29320d950d84d9d16f7d4edf380a238c5b534ff00d11Tomas Winkler};
29330d950d84d9d16f7d4edf380a238c5b534ff00d11Tomas Winkler
29340d950d84d9d16f7d4edf380a238c5b534ff00d11Tomas Winkler/* IWL_PHY_CALIBRATE_CHAIN_NOISE_GAIN_CMD */
2935f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winklerstruct iwl_calib_chain_noise_gain_cmd {
29360d950d84d9d16f7d4edf380a238c5b534ff00d11Tomas Winkler	struct iwl_calib_hdr hdr;
293733fd503346ad86bd7470a0f8c4c3080393d14233Emmanuel Grumbach	u8 delta_gain_1;
293833fd503346ad86bd7470a0f8c4c3080393d14233Emmanuel Grumbach	u8 delta_gain_2;
29390d950d84d9d16f7d4edf380a238c5b534ff00d11Tomas Winkler	u8 pad[2];
294033fd503346ad86bd7470a0f8c4c3080393d14233Emmanuel Grumbach} __attribute__ ((packed));
294133fd503346ad86bd7470a0f8c4c3080393d14233Emmanuel Grumbach
2942b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/******************************************************************************
2943b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * (12)
2944b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Miscellaneous Commands:
2945b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
2946b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *****************************************************************************/
2947b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2948b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
2949b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * LEDs Command & Response
2950b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_LEDS_CMD = 0x48 (command, has simple generic response)
2951b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
2952b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * For each of 3 possible LEDs (Activity/Link/Tech, selected by "id" field),
2953b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * this command turns it on or off, or sets up a periodic blinking cycle.
2954b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
2955ec1a746042ea4c1c93065185897d6e8d3e7de894Tomas Winklerstruct iwl_led_cmd {
2956b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 interval;	/* "interval" in uSec */
2957b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 id;			/* 1: Activity, 2: Link, 3: Tech */
2958b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 off;			/* # intervals off while blinking;
2959b481de9ca074528fe8c429604e2777db8b89806aZhu Yi				 * "0", with >0 "on" value, turns LED on */
2960b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 on;			/* # intervals on while blinking;
2961b481de9ca074528fe8c429604e2777db8b89806aZhu Yi				 * "0", regardless of "off", turns LED off */
2962b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 reserved;
2963b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
2964b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
29659636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky/*
29669636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky * Coexistence WIFI/WIMAX  Command
29679636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky * COEX_PRIORITY_TABLE_CMD = 0x5a
29689636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky *
29699636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky */
29709636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunskyenum {
29719636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	COEX_UNASSOC_IDLE		= 0,
29729636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	COEX_UNASSOC_MANUAL_SCAN	= 1,
29739636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	COEX_UNASSOC_AUTO_SCAN		= 2,
29749636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	COEX_CALIBRATION		= 3,
29759636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	COEX_PERIODIC_CALIBRATION	= 4,
29769636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	COEX_CONNECTION_ESTAB		= 5,
29779636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	COEX_ASSOCIATED_IDLE		= 6,
29789636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	COEX_ASSOC_MANUAL_SCAN		= 7,
29799636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	COEX_ASSOC_AUTO_SCAN		= 8,
29809636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	COEX_ASSOC_ACTIVE_LEVEL		= 9,
29819636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	COEX_RF_ON			= 10,
29829636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	COEX_RF_OFF			= 11,
29839636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	COEX_STAND_ALONE_DEBUG		= 12,
29849636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	COEX_IPAN_ASSOC_LEVEL		= 13,
29859636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	COEX_RSRVD1			= 14,
29869636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	COEX_RSRVD2			= 15,
29879636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	COEX_NUM_OF_EVENTS		= 16
29889636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky};
29899636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky
29909636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunskystruct iwl_wimax_coex_event_entry {
29919636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	u8 request_prio;
29929636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	u8 win_medium_prio;
29939636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	u8 reserved;
29949636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	u8 flags;
29959636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky} __attribute__ ((packed));
29969636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky
29979636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky/* COEX flag masks */
29989636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky
2999a96a27f97f2bbfc1fca54bc3c0b0d41484152740Tomas Winkler/* Station table is valid */
30009636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky#define COEX_FLAGS_STA_TABLE_VALID_MSK      (0x1)
3001a96a27f97f2bbfc1fca54bc3c0b0d41484152740Tomas Winkler/* UnMask wake up src at unassociated sleep */
30029636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky#define COEX_FLAGS_UNASSOC_WA_UNMASK_MSK    (0x4)
3003a96a27f97f2bbfc1fca54bc3c0b0d41484152740Tomas Winkler/* UnMask wake up src at associated sleep */
30049636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky#define COEX_FLAGS_ASSOC_WA_UNMASK_MSK      (0x8)
30059636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky/* Enable CoEx feature. */
30069636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky#define COEX_FLAGS_COEX_ENABLE_MSK          (0x80)
30079636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky
30089636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunskystruct iwl_wimax_coex_cmd {
30099636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	u8 flags;
30109636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	u8 reserved[3];
30119636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	struct iwl_wimax_coex_event_entry sta_prio[COEX_NUM_OF_EVENTS];
30129636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky} __attribute__ ((packed));
30139636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky
3014b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/******************************************************************************
3015b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * (13)
3016b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Union of all expected notifications/responses:
3017b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
3018b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *****************************************************************************/
3019b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
3020db11d6343aa14ab61258bfad9178042d4be49333Tomas Winklerstruct iwl_rx_packet {
3021b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 len;
3022857485c0c46ceee5c658c1761bba4d9a5ddf433fTomas Winkler	struct iwl_cmd_header hdr;
3023b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	union {
3024885ba202cabd90b8ade1fe59185dc96ed4d69e02Tomas Winkler		struct iwl_alive_resp alive_frame;
30252aa6ab86bc475a115f56645591d2413981846509Tomas Winkler		struct iwl_spectrum_notification spectrum_notif;
30262aa6ab86bc475a115f56645591d2413981846509Tomas Winkler		struct iwl_csa_notification csa_notif;
3027885ba202cabd90b8ade1fe59185dc96ed4d69e02Tomas Winkler		struct iwl_error_resp err_resp;
30282aa6ab86bc475a115f56645591d2413981846509Tomas Winkler		struct iwl_card_state_notif card_state_notif;
30297a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winkler		struct iwl_add_sta_resp add_sta;
30307a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winkler		struct iwl_rem_sta_resp rem_sta;
30312aa6ab86bc475a115f56645591d2413981846509Tomas Winkler		struct iwl_sleep_notification sleep_notif;
30322aa6ab86bc475a115f56645591d2413981846509Tomas Winkler		struct iwl_spectrum_resp spectrum;
30338f91aecb4cdc2d786df8941e827b9dff3c10a4e4Emmanuel Grumbach		struct iwl_notif_statistics stats;
3034653fa4a07525e4cd9e7b90e6fc1f792119910636Emmanuel Grumbach		struct iwl_compressed_ba_resp compressed_ba;
30352aa6ab86bc475a115f56645591d2413981846509Tomas Winkler		struct iwl_missed_beacon_notif missed_beacon;
3036b481de9ca074528fe8c429604e2777db8b89806aZhu Yi		__le32 status;
3037b481de9ca074528fe8c429604e2777db8b89806aZhu Yi		u8 raw[0];
3038b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	} u;
3039b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
3040b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
30418f5c87dcf6d1a5e6d7ffe642cfd4debb5ccbec49Winkler, Tomasint iwl_agn_check_rxon_cmd(struct iwl_rxon_cmd *rxon);
30428f5c87dcf6d1a5e6d7ffe642cfd4debb5ccbec49Winkler, Tomas
30436a63578ddf6148927a80c07a73b40ccc8f3ac8e2Emmanuel Grumbach#endif				/* __iwl_commands_h__ */
3044