1 /****************************************************************************** 2 * 3 * This file is provided under a dual BSD/GPLv2 license. When using or 4 * redistributing this file, you may do so under either license. 5 * 6 * GPL LICENSE SUMMARY 7 * 8 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved. 9 * Copyright(c) 2017 Intel Deutschland GmbH 10 * 11 * This program is free software; you can redistribute it and/or modify 12 * it under the terms of version 2 of the GNU General Public License as 13 * published by the Free Software Foundation. 14 * 15 * This program is distributed in the hope that it will be useful, but 16 * WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 * General Public License for more details. 19 * 20 * The full GNU General Public License is included in this distribution 21 * in the file called COPYING. 22 * 23 * Contact Information: 24 * Intel Linux Wireless <linuxwifi@intel.com> 25 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 26 * 27 * BSD LICENSE 28 * 29 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved. 30 * Copyright(c) 2017 Intel Deutschland GmbH 31 * All rights reserved. 32 * 33 * Redistribution and use in source and binary forms, with or without 34 * modification, are permitted provided that the following conditions 35 * are met: 36 * 37 * * Redistributions of source code must retain the above copyright 38 * notice, this list of conditions and the following disclaimer. 39 * * Redistributions in binary form must reproduce the above copyright 40 * notice, this list of conditions and the following disclaimer in 41 * the documentation and/or other materials provided with the 42 * distribution. 43 * * Neither the name Intel Corporation nor the names of its 44 * contributors may be used to endorse or promote products derived 45 * from this software without specific prior written permission. 46 * 47 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 48 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 49 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 50 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 51 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 52 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 53 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 54 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 55 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 56 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 57 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 58 *****************************************************************************/ 59 60 #ifndef __iwl_fw_api_rs_h__ 61 #define __iwl_fw_api_rs_h__ 62 63 #include "mac.h" 64 65 /* 66 * These serve as indexes into 67 * struct iwl_rate_info fw_rate_idx_to_plcp[IWL_RATE_COUNT]; 68 * TODO: avoid overlap between legacy and HT rates 69 */ 70 enum { 71 IWL_RATE_1M_INDEX = 0, 72 IWL_FIRST_CCK_RATE = IWL_RATE_1M_INDEX, 73 IWL_RATE_2M_INDEX, 74 IWL_RATE_5M_INDEX, 75 IWL_RATE_11M_INDEX, 76 IWL_LAST_CCK_RATE = IWL_RATE_11M_INDEX, 77 IWL_RATE_6M_INDEX, 78 IWL_FIRST_OFDM_RATE = IWL_RATE_6M_INDEX, 79 IWL_RATE_MCS_0_INDEX = IWL_RATE_6M_INDEX, 80 IWL_FIRST_HT_RATE = IWL_RATE_MCS_0_INDEX, 81 IWL_FIRST_VHT_RATE = IWL_RATE_MCS_0_INDEX, 82 IWL_RATE_9M_INDEX, 83 IWL_RATE_12M_INDEX, 84 IWL_RATE_MCS_1_INDEX = IWL_RATE_12M_INDEX, 85 IWL_RATE_18M_INDEX, 86 IWL_RATE_MCS_2_INDEX = IWL_RATE_18M_INDEX, 87 IWL_RATE_24M_INDEX, 88 IWL_RATE_MCS_3_INDEX = IWL_RATE_24M_INDEX, 89 IWL_RATE_36M_INDEX, 90 IWL_RATE_MCS_4_INDEX = IWL_RATE_36M_INDEX, 91 IWL_RATE_48M_INDEX, 92 IWL_RATE_MCS_5_INDEX = IWL_RATE_48M_INDEX, 93 IWL_RATE_54M_INDEX, 94 IWL_RATE_MCS_6_INDEX = IWL_RATE_54M_INDEX, 95 IWL_LAST_NON_HT_RATE = IWL_RATE_54M_INDEX, 96 IWL_RATE_60M_INDEX, 97 IWL_RATE_MCS_7_INDEX = IWL_RATE_60M_INDEX, 98 IWL_LAST_HT_RATE = IWL_RATE_MCS_7_INDEX, 99 IWL_RATE_MCS_8_INDEX, 100 IWL_RATE_MCS_9_INDEX, 101 IWL_LAST_VHT_RATE = IWL_RATE_MCS_9_INDEX, 102 IWL_RATE_COUNT_LEGACY = IWL_LAST_NON_HT_RATE + 1, 103 IWL_RATE_COUNT = IWL_LAST_VHT_RATE + 1, 104 }; 105 106 #define IWL_RATE_BIT_MSK(r) BIT(IWL_RATE_##r##M_INDEX) 107 108 /* fw API values for legacy bit rates, both OFDM and CCK */ 109 enum { 110 IWL_RATE_6M_PLCP = 13, 111 IWL_RATE_9M_PLCP = 15, 112 IWL_RATE_12M_PLCP = 5, 113 IWL_RATE_18M_PLCP = 7, 114 IWL_RATE_24M_PLCP = 9, 115 IWL_RATE_36M_PLCP = 11, 116 IWL_RATE_48M_PLCP = 1, 117 IWL_RATE_54M_PLCP = 3, 118 IWL_RATE_1M_PLCP = 10, 119 IWL_RATE_2M_PLCP = 20, 120 IWL_RATE_5M_PLCP = 55, 121 IWL_RATE_11M_PLCP = 110, 122 IWL_RATE_INVM_PLCP = -1, 123 }; 124 125 /* 126 * rate_n_flags bit fields 127 * 128 * The 32-bit value has different layouts in the low 8 bites depending on the 129 * format. There are three formats, HT, VHT and legacy (11abg, with subformats 130 * for CCK and OFDM). 131 * 132 * High-throughput (HT) rate format 133 * bit 8 is 1, bit 26 is 0, bit 9 is 0 (OFDM) 134 * Very High-throughput (VHT) rate format 135 * bit 8 is 0, bit 26 is 1, bit 9 is 0 (OFDM) 136 * Legacy OFDM rate format for bits 7:0 137 * bit 8 is 0, bit 26 is 0, bit 9 is 0 (OFDM) 138 * Legacy CCK rate format for bits 7:0: 139 * bit 8 is 0, bit 26 is 0, bit 9 is 1 (CCK) 140 */ 141 142 /* Bit 8: (1) HT format, (0) legacy or VHT format */ 143 #define RATE_MCS_HT_POS 8 144 #define RATE_MCS_HT_MSK (1 << RATE_MCS_HT_POS) 145 146 /* Bit 9: (1) CCK, (0) OFDM. HT (bit 8) must be "0" for this bit to be valid */ 147 #define RATE_MCS_CCK_POS 9 148 #define RATE_MCS_CCK_MSK (1 << RATE_MCS_CCK_POS) 149 150 /* Bit 26: (1) VHT format, (0) legacy format in bits 8:0 */ 151 #define RATE_MCS_VHT_POS 26 152 #define RATE_MCS_VHT_MSK (1 << RATE_MCS_VHT_POS) 153 154 155 /* 156 * High-throughput (HT) rate format for bits 7:0 157 * 158 * 2-0: MCS rate base 159 * 0) 6 Mbps 160 * 1) 12 Mbps 161 * 2) 18 Mbps 162 * 3) 24 Mbps 163 * 4) 36 Mbps 164 * 5) 48 Mbps 165 * 6) 54 Mbps 166 * 7) 60 Mbps 167 * 4-3: 0) Single stream (SISO) 168 * 1) Dual stream (MIMO) 169 * 2) Triple stream (MIMO) 170 * 5: Value of 0x20 in bits 7:0 indicates 6 Mbps HT40 duplicate data 171 * (bits 7-6 are zero) 172 * 173 * Together the low 5 bits work out to the MCS index because we don't 174 * support MCSes above 15/23, and 0-7 have one stream, 8-15 have two 175 * streams and 16-23 have three streams. We could also support MCS 32 176 * which is the duplicate 20 MHz MCS (bit 5 set, all others zero.) 177 */ 178 #define RATE_HT_MCS_RATE_CODE_MSK 0x7 179 #define RATE_HT_MCS_NSS_POS 3 180 #define RATE_HT_MCS_NSS_MSK (3 << RATE_HT_MCS_NSS_POS) 181 182 /* Bit 10: (1) Use Green Field preamble */ 183 #define RATE_HT_MCS_GF_POS 10 184 #define RATE_HT_MCS_GF_MSK (1 << RATE_HT_MCS_GF_POS) 185 186 #define RATE_HT_MCS_INDEX_MSK 0x3f 187 188 /* 189 * Very High-throughput (VHT) rate format for bits 7:0 190 * 191 * 3-0: VHT MCS (0-9) 192 * 5-4: number of streams - 1: 193 * 0) Single stream (SISO) 194 * 1) Dual stream (MIMO) 195 * 2) Triple stream (MIMO) 196 */ 197 198 /* Bit 4-5: (0) SISO, (1) MIMO2 (2) MIMO3 */ 199 #define RATE_VHT_MCS_RATE_CODE_MSK 0xf 200 #define RATE_VHT_MCS_NSS_POS 4 201 #define RATE_VHT_MCS_NSS_MSK (3 << RATE_VHT_MCS_NSS_POS) 202 203 /* 204 * Legacy OFDM rate format for bits 7:0 205 * 206 * 3-0: 0xD) 6 Mbps 207 * 0xF) 9 Mbps 208 * 0x5) 12 Mbps 209 * 0x7) 18 Mbps 210 * 0x9) 24 Mbps 211 * 0xB) 36 Mbps 212 * 0x1) 48 Mbps 213 * 0x3) 54 Mbps 214 * (bits 7-4 are 0) 215 * 216 * Legacy CCK rate format for bits 7:0: 217 * bit 8 is 0, bit 26 is 0, bit 9 is 1 (CCK): 218 * 219 * 6-0: 10) 1 Mbps 220 * 20) 2 Mbps 221 * 55) 5.5 Mbps 222 * 110) 11 Mbps 223 * (bit 7 is 0) 224 */ 225 #define RATE_LEGACY_RATE_MSK 0xff 226 227 /* Bit 10 - OFDM HE */ 228 #define RATE_MCS_OFDM_HE_POS 10 229 #define RATE_MCS_OFDM_HE_MSK BIT(RATE_MCS_OFDM_HE_POS) 230 231 /* 232 * Bit 11-12: (0) 20MHz, (1) 40MHz, (2) 80MHz, (3) 160MHz 233 * 0 and 1 are valid for HT and VHT, 2 and 3 only for VHT 234 */ 235 #define RATE_MCS_CHAN_WIDTH_POS 11 236 #define RATE_MCS_CHAN_WIDTH_MSK (3 << RATE_MCS_CHAN_WIDTH_POS) 237 #define RATE_MCS_CHAN_WIDTH_20 (0 << RATE_MCS_CHAN_WIDTH_POS) 238 #define RATE_MCS_CHAN_WIDTH_40 (1 << RATE_MCS_CHAN_WIDTH_POS) 239 #define RATE_MCS_CHAN_WIDTH_80 (2 << RATE_MCS_CHAN_WIDTH_POS) 240 #define RATE_MCS_CHAN_WIDTH_160 (3 << RATE_MCS_CHAN_WIDTH_POS) 241 242 /* Bit 13: (1) Short guard interval (0.4 usec), (0) normal GI (0.8 usec) */ 243 #define RATE_MCS_SGI_POS 13 244 #define RATE_MCS_SGI_MSK (1 << RATE_MCS_SGI_POS) 245 246 /* Bit 14-16: Antenna selection (1) Ant A, (2) Ant B, (4) Ant C */ 247 #define RATE_MCS_ANT_POS 14 248 #define RATE_MCS_ANT_A_MSK (1 << RATE_MCS_ANT_POS) 249 #define RATE_MCS_ANT_B_MSK (2 << RATE_MCS_ANT_POS) 250 #define RATE_MCS_ANT_C_MSK (4 << RATE_MCS_ANT_POS) 251 #define RATE_MCS_ANT_AB_MSK (RATE_MCS_ANT_A_MSK | \ 252 RATE_MCS_ANT_B_MSK) 253 #define RATE_MCS_ANT_ABC_MSK (RATE_MCS_ANT_AB_MSK | \ 254 RATE_MCS_ANT_C_MSK) 255 #define RATE_MCS_ANT_MSK RATE_MCS_ANT_ABC_MSK 256 #define RATE_MCS_ANT_NUM 3 257 258 /* Bit 17: (0) SS, (1) SS*2 */ 259 #define RATE_MCS_STBC_POS 17 260 #define RATE_MCS_STBC_MSK BIT(RATE_MCS_STBC_POS) 261 262 /* Bit 18: OFDM-HE dual carrier mode */ 263 #define RATE_HE_DUAL_CARRIER_MODE 18 264 #define RATE_HE_DUAL_CARRIER_MODE_MSK BIT(RATE_HE_DUAL_CARRIER_MODE) 265 266 /* Bit 19: (0) Beamforming is off, (1) Beamforming is on */ 267 #define RATE_MCS_BF_POS 19 268 #define RATE_MCS_BF_MSK (1 << RATE_MCS_BF_POS) 269 270 /* 271 * Bit 20-21: HE guard interval and LTF type. 272 * (0) 1xLTF+1.6us, (1) 2xLTF+0.8us, 273 * (2) 2xLTF+1.6us, (3) 4xLTF+3.2us 274 */ 275 #define RATE_MCS_HE_GI_LTF_POS 20 276 #define RATE_MCS_HE_GI_LTF_MSK (3 << RATE_MCS_HE_GI_LTF_POS) 277 278 /* Bit 22-23: HE type. (0) SU, (1) SU_EXT, (2) MU, (3) trigger based */ 279 #define RATE_MCS_HE_TYPE_POS 22 280 #define RATE_MCS_HE_TYPE_MSK (3 << RATE_MCS_HE_TYPE_POS) 281 282 /* Bit 24-25: (0) 20MHz (no dup), (1) 2x20MHz, (2) 4x20MHz, 3 8x20MHz */ 283 #define RATE_MCS_DUP_POS 24 284 #define RATE_MCS_DUP_MSK (3 << RATE_MCS_DUP_POS) 285 286 /* Bit 27: (1) LDPC enabled, (0) LDPC disabled */ 287 #define RATE_MCS_LDPC_POS 27 288 #define RATE_MCS_LDPC_MSK (1 << RATE_MCS_LDPC_POS) 289 290 291 /* Link Quality definitions */ 292 293 /* # entries in rate scale table to support Tx retries */ 294 #define LQ_MAX_RETRY_NUM 16 295 296 /* Link quality command flags bit fields */ 297 298 /* Bit 0: (0) Don't use RTS (1) Use RTS */ 299 #define LQ_FLAG_USE_RTS_POS 0 300 #define LQ_FLAG_USE_RTS_MSK (1 << LQ_FLAG_USE_RTS_POS) 301 302 /* Bit 1-3: LQ command color. Used to match responses to LQ commands */ 303 #define LQ_FLAG_COLOR_POS 1 304 #define LQ_FLAG_COLOR_MSK (7 << LQ_FLAG_COLOR_POS) 305 #define LQ_FLAG_COLOR_GET(_f) (((_f) & LQ_FLAG_COLOR_MSK) >>\ 306 LQ_FLAG_COLOR_POS) 307 #define LQ_FLAGS_COLOR_INC(_c) ((((_c) + 1) << LQ_FLAG_COLOR_POS) &\ 308 LQ_FLAG_COLOR_MSK) 309 #define LQ_FLAG_COLOR_SET(_f, _c) ((_c) | ((_f) & ~LQ_FLAG_COLOR_MSK)) 310 311 /* Bit 4-5: Tx RTS BW Signalling 312 * (0) No RTS BW signalling 313 * (1) Static BW signalling 314 * (2) Dynamic BW signalling 315 */ 316 #define LQ_FLAG_RTS_BW_SIG_POS 4 317 #define LQ_FLAG_RTS_BW_SIG_NONE (0 << LQ_FLAG_RTS_BW_SIG_POS) 318 #define LQ_FLAG_RTS_BW_SIG_STATIC (1 << LQ_FLAG_RTS_BW_SIG_POS) 319 #define LQ_FLAG_RTS_BW_SIG_DYNAMIC (2 << LQ_FLAG_RTS_BW_SIG_POS) 320 321 /* Bit 6: (0) No dynamic BW selection (1) Allow dynamic BW selection 322 * Dyanmic BW selection allows Tx with narrower BW then requested in rates 323 */ 324 #define LQ_FLAG_DYNAMIC_BW_POS 6 325 #define LQ_FLAG_DYNAMIC_BW_MSK (1 << LQ_FLAG_DYNAMIC_BW_POS) 326 327 /* Single Stream Tx Parameters (lq_cmd->ss_params) 328 * Flags to control a smart FW decision about whether BFER/STBC/SISO will be 329 * used for single stream Tx. 330 */ 331 332 /* Bit 0-1: Max STBC streams allowed. Can be 0-3. 333 * (0) - No STBC allowed 334 * (1) - 2x1 STBC allowed (HT/VHT) 335 * (2) - 4x2 STBC allowed (HT/VHT) 336 * (3) - 3x2 STBC allowed (HT only) 337 * All our chips are at most 2 antennas so only (1) is valid for now. 338 */ 339 #define LQ_SS_STBC_ALLOWED_POS 0 340 #define LQ_SS_STBC_ALLOWED_MSK (3 << LQ_SS_STBC_ALLOWED_MSK) 341 342 /* 2x1 STBC is allowed */ 343 #define LQ_SS_STBC_1SS_ALLOWED (1 << LQ_SS_STBC_ALLOWED_POS) 344 345 /* Bit 2: Beamformer (VHT only) is allowed */ 346 #define LQ_SS_BFER_ALLOWED_POS 2 347 #define LQ_SS_BFER_ALLOWED (1 << LQ_SS_BFER_ALLOWED_POS) 348 349 /* Bit 3: Force BFER or STBC for testing 350 * If this is set: 351 * If BFER is allowed then force the ucode to choose BFER else 352 * If STBC is allowed then force the ucode to choose STBC over SISO 353 */ 354 #define LQ_SS_FORCE_POS 3 355 #define LQ_SS_FORCE (1 << LQ_SS_FORCE_POS) 356 357 /* Bit 31: ss_params field is valid. Used for FW backward compatibility 358 * with other drivers which don't support the ss_params API yet 359 */ 360 #define LQ_SS_PARAMS_VALID_POS 31 361 #define LQ_SS_PARAMS_VALID (1 << LQ_SS_PARAMS_VALID_POS) 362 363 /** 364 * struct iwl_lq_cmd - link quality command 365 * @sta_id: station to update 366 * @reduced_tpc: reduced transmit power control value 367 * @control: not used 368 * @flags: combination of LQ_FLAG_* 369 * @mimo_delim: the first SISO index in rs_table, which separates MIMO 370 * and SISO rates 371 * @single_stream_ant_msk: best antenna for SISO (can be dual in CDD). 372 * Should be ANT_[ABC] 373 * @dual_stream_ant_msk: best antennas for MIMO, combination of ANT_[ABC] 374 * @initial_rate_index: first index from rs_table per AC category 375 * @agg_time_limit: aggregation max time threshold in usec/100, meaning 376 * value of 100 is one usec. Range is 100 to 8000 377 * @agg_disable_start_th: try-count threshold for starting aggregation. 378 * If a frame has higher try-count, it should not be selected for 379 * starting an aggregation sequence. 380 * @agg_frame_cnt_limit: max frame count in an aggregation. 381 * 0: no limit 382 * 1: no aggregation (one frame per aggregation) 383 * 2 - 0x3f: maximal number of frames (up to 3f == 63) 384 * @reserved2: reserved 385 * @rs_table: array of rates for each TX try, each is rate_n_flags, 386 * meaning it is a combination of RATE_MCS_* and IWL_RATE_*_PLCP 387 * @ss_params: single stream features. declare whether STBC or BFER are allowed. 388 */ 389 struct iwl_lq_cmd { 390 u8 sta_id; 391 u8 reduced_tpc; 392 __le16 control; 393 /* LINK_QUAL_GENERAL_PARAMS_API_S_VER_1 */ 394 u8 flags; 395 u8 mimo_delim; 396 u8 single_stream_ant_msk; 397 u8 dual_stream_ant_msk; 398 u8 initial_rate_index[AC_NUM]; 399 /* LINK_QUAL_AGG_PARAMS_API_S_VER_1 */ 400 __le16 agg_time_limit; 401 u8 agg_disable_start_th; 402 u8 agg_frame_cnt_limit; 403 __le32 reserved2; 404 __le32 rs_table[LQ_MAX_RETRY_NUM]; 405 __le32 ss_params; 406 }; /* LINK_QUALITY_CMD_API_S_VER_1 */ 407 408 #endif /* __iwl_fw_api_rs_h__ */ 409