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 - 2013 Intel Corporation. All rights reserved. 9 * 10 * This program is free software; you can redistribute it and/or modify 11 * it under the terms of version 2 of the GNU General Public License as 12 * published by the Free Software Foundation. 13 * 14 * This program is distributed in the hope that it will be useful, but 15 * WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 * General Public License for more details. 18 * 19 * You should have received a copy of the GNU General Public License 20 * along with this program; if not, write to the Free Software 21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, 22 * USA 23 * 24 * The full GNU General Public License is included in this distribution 25 * in the file called COPYING. 26 * 27 * Contact Information: 28 * Intel Linux Wireless <ilw@linux.intel.com> 29 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 30 * 31 * BSD LICENSE 32 * 33 * Copyright(c) 2012 - 2013 Intel Corporation. All rights reserved. 34 * All rights reserved. 35 * 36 * Redistribution and use in source and binary forms, with or without 37 * modification, are permitted provided that the following conditions 38 * are met: 39 * 40 * * Redistributions of source code must retain the above copyright 41 * notice, this list of conditions and the following disclaimer. 42 * * Redistributions in binary form must reproduce the above copyright 43 * notice, this list of conditions and the following disclaimer in 44 * the documentation and/or other materials provided with the 45 * distribution. 46 * * Neither the name Intel Corporation nor the names of its 47 * contributors may be used to endorse or promote products derived 48 * from this software without specific prior written permission. 49 * 50 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 51 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 52 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 53 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 54 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 55 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 56 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 57 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 58 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 59 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 60 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 61 *****************************************************************************/ 62 63#ifndef __fw_api_mac_h__ 64#define __fw_api_mac_h__ 65 66/* 67 * The first MAC indices (starting from 0) 68 * are available to the driver, AUX follows 69 */ 70#define MAC_INDEX_AUX 4 71#define MAC_INDEX_MIN_DRIVER 0 72#define NUM_MAC_INDEX_DRIVER MAC_INDEX_AUX 73 74enum iwl_ac { 75 AC_BK, 76 AC_BE, 77 AC_VI, 78 AC_VO, 79 AC_NUM, 80}; 81 82/** 83 * enum iwl_mac_protection_flags - MAC context flags 84 * @MAC_PROT_FLG_TGG_PROTECT: 11g protection when transmitting OFDM frames, 85 * this will require CCK RTS/CTS2self. 86 * RTS/CTS will protect full burst time. 87 * @MAC_PROT_FLG_HT_PROT: enable HT protection 88 * @MAC_PROT_FLG_FAT_PROT: protect 40 MHz transmissions 89 * @MAC_PROT_FLG_SELF_CTS_EN: allow CTS2self 90 */ 91enum iwl_mac_protection_flags { 92 MAC_PROT_FLG_TGG_PROTECT = BIT(3), 93 MAC_PROT_FLG_HT_PROT = BIT(23), 94 MAC_PROT_FLG_FAT_PROT = BIT(24), 95 MAC_PROT_FLG_SELF_CTS_EN = BIT(30), 96}; 97 98#define MAC_FLG_SHORT_SLOT BIT(4) 99#define MAC_FLG_SHORT_PREAMBLE BIT(5) 100 101/** 102 * enum iwl_mac_types - Supported MAC types 103 * @FW_MAC_TYPE_FIRST: lowest supported MAC type 104 * @FW_MAC_TYPE_AUX: Auxiliary MAC (internal) 105 * @FW_MAC_TYPE_LISTENER: monitor MAC type (?) 106 * @FW_MAC_TYPE_PIBSS: Pseudo-IBSS 107 * @FW_MAC_TYPE_IBSS: IBSS 108 * @FW_MAC_TYPE_BSS_STA: BSS (managed) station 109 * @FW_MAC_TYPE_P2P_DEVICE: P2P Device 110 * @FW_MAC_TYPE_P2P_STA: P2P client 111 * @FW_MAC_TYPE_GO: P2P GO 112 * @FW_MAC_TYPE_TEST: ? 113 * @FW_MAC_TYPE_MAX: highest support MAC type 114 */ 115enum iwl_mac_types { 116 FW_MAC_TYPE_FIRST = 1, 117 FW_MAC_TYPE_AUX = FW_MAC_TYPE_FIRST, 118 FW_MAC_TYPE_LISTENER, 119 FW_MAC_TYPE_PIBSS, 120 FW_MAC_TYPE_IBSS, 121 FW_MAC_TYPE_BSS_STA, 122 FW_MAC_TYPE_P2P_DEVICE, 123 FW_MAC_TYPE_P2P_STA, 124 FW_MAC_TYPE_GO, 125 FW_MAC_TYPE_TEST, 126 FW_MAC_TYPE_MAX = FW_MAC_TYPE_TEST 127}; /* MAC_CONTEXT_TYPE_API_E_VER_1 */ 128 129/** 130 * enum iwl_tsf_id - TSF hw timer ID 131 * @TSF_ID_A: use TSF A 132 * @TSF_ID_B: use TSF B 133 * @TSF_ID_C: use TSF C 134 * @TSF_ID_D: use TSF D 135 * @NUM_TSF_IDS: number of TSF timers available 136 */ 137enum iwl_tsf_id { 138 TSF_ID_A = 0, 139 TSF_ID_B = 1, 140 TSF_ID_C = 2, 141 TSF_ID_D = 3, 142 NUM_TSF_IDS = 4, 143}; /* TSF_ID_API_E_VER_1 */ 144 145/** 146 * struct iwl_mac_data_ap - configuration data for AP MAC context 147 * @beacon_time: beacon transmit time in system time 148 * @beacon_tsf: beacon transmit time in TSF 149 * @bi: beacon interval in TU 150 * @bi_reciprocal: 2^32 / bi 151 * @dtim_interval: dtim transmit time in TU 152 * @dtim_reciprocal: 2^32 / dtim_interval 153 * @mcast_qid: queue ID for multicast traffic 154 * @beacon_template: beacon template ID 155 */ 156struct iwl_mac_data_ap { 157 __le32 beacon_time; 158 __le64 beacon_tsf; 159 __le32 bi; 160 __le32 bi_reciprocal; 161 __le32 dtim_interval; 162 __le32 dtim_reciprocal; 163 __le32 mcast_qid; 164 __le32 beacon_template; 165} __packed; /* AP_MAC_DATA_API_S_VER_1 */ 166 167/** 168 * struct iwl_mac_data_ibss - configuration data for IBSS MAC context 169 * @beacon_time: beacon transmit time in system time 170 * @beacon_tsf: beacon transmit time in TSF 171 * @bi: beacon interval in TU 172 * @bi_reciprocal: 2^32 / bi 173 */ 174struct iwl_mac_data_ibss { 175 __le32 beacon_time; 176 __le64 beacon_tsf; 177 __le32 bi; 178 __le32 bi_reciprocal; 179} __packed; /* IBSS_MAC_DATA_API_S_VER_1 */ 180 181/** 182 * struct iwl_mac_data_sta - configuration data for station MAC context 183 * @is_assoc: 1 for associated state, 0 otherwise 184 * @dtim_time: DTIM arrival time in system time 185 * @dtim_tsf: DTIM arrival time in TSF 186 * @bi: beacon interval in TU, applicable only when associated 187 * @bi_reciprocal: 2^32 / bi , applicable only when associated 188 * @dtim_interval: DTIM interval in TU, applicable only when associated 189 * @dtim_reciprocal: 2^32 / dtim_interval , applicable only when associated 190 * @listen_interval: in beacon intervals, applicable only when associated 191 * @assoc_id: unique ID assigned by the AP during association 192 */ 193struct iwl_mac_data_sta { 194 __le32 is_assoc; 195 __le32 dtim_time; 196 __le64 dtim_tsf; 197 __le32 bi; 198 __le32 bi_reciprocal; 199 __le32 dtim_interval; 200 __le32 dtim_reciprocal; 201 __le32 listen_interval; 202 __le32 assoc_id; 203 __le32 assoc_beacon_arrive_time; 204} __packed; /* STA_MAC_DATA_API_S_VER_1 */ 205 206/** 207 * struct iwl_mac_data_go - configuration data for P2P GO MAC context 208 * @ap: iwl_mac_data_ap struct with most config data 209 * @ctwin: client traffic window in TU (period after TBTT when GO is present). 210 * 0 indicates that there is no CT window. 211 * @opp_ps_enabled: indicate that opportunistic PS allowed 212 */ 213struct iwl_mac_data_go { 214 struct iwl_mac_data_ap ap; 215 __le32 ctwin; 216 __le32 opp_ps_enabled; 217} __packed; /* GO_MAC_DATA_API_S_VER_1 */ 218 219/** 220 * struct iwl_mac_data_p2p_sta - configuration data for P2P client MAC context 221 * @sta: iwl_mac_data_sta struct with most config data 222 * @ctwin: client traffic window in TU (period after TBTT when GO is present). 223 * 0 indicates that there is no CT window. 224 */ 225struct iwl_mac_data_p2p_sta { 226 struct iwl_mac_data_sta sta; 227 __le32 ctwin; 228} __packed; /* P2P_STA_MAC_DATA_API_S_VER_1 */ 229 230/** 231 * struct iwl_mac_data_pibss - Pseudo IBSS config data 232 * @stats_interval: interval in TU between statistics notifications to host. 233 */ 234struct iwl_mac_data_pibss { 235 __le32 stats_interval; 236} __packed; /* PIBSS_MAC_DATA_API_S_VER_1 */ 237 238/* 239 * struct iwl_mac_data_p2p_dev - configuration data for the P2P Device MAC 240 * context. 241 * @is_disc_extended: if set to true, P2P Device discoverability is enabled on 242 * other channels as well. This should be to true only in case that the 243 * device is discoverable and there is an active GO. Note that setting this 244 * field when not needed, will increase the number of interrupts and have 245 * effect on the platform power, as this setting opens the Rx filters on 246 * all macs. 247 */ 248struct iwl_mac_data_p2p_dev { 249 __le32 is_disc_extended; 250} __packed; /* _P2P_DEV_MAC_DATA_API_S_VER_1 */ 251 252/** 253 * enum iwl_mac_filter_flags - MAC context filter flags 254 * @MAC_FILTER_IN_PROMISC: accept all data frames 255 * @MAC_FILTER_IN_CONTROL_AND_MGMT: pass all mangement and 256 * control frames to the host 257 * @MAC_FILTER_ACCEPT_GRP: accept multicast frames 258 * @MAC_FILTER_DIS_DECRYPT: don't decrypt unicast frames 259 * @MAC_FILTER_DIS_GRP_DECRYPT: don't decrypt multicast frames 260 * @MAC_FILTER_IN_BEACON: transfer foreign BSS's beacons to host 261 * (in station mode when associated) 262 * @MAC_FILTER_OUT_BCAST: filter out all broadcast frames 263 * @MAC_FILTER_IN_CRC32: extract FCS and append it to frames 264 * @MAC_FILTER_IN_PROBE_REQUEST: pass probe requests to host 265 */ 266enum iwl_mac_filter_flags { 267 MAC_FILTER_IN_PROMISC = BIT(0), 268 MAC_FILTER_IN_CONTROL_AND_MGMT = BIT(1), 269 MAC_FILTER_ACCEPT_GRP = BIT(2), 270 MAC_FILTER_DIS_DECRYPT = BIT(3), 271 MAC_FILTER_DIS_GRP_DECRYPT = BIT(4), 272 MAC_FILTER_IN_BEACON = BIT(6), 273 MAC_FILTER_OUT_BCAST = BIT(8), 274 MAC_FILTER_IN_CRC32 = BIT(11), 275 MAC_FILTER_IN_PROBE_REQUEST = BIT(12), 276}; 277 278/** 279 * enum iwl_mac_qos_flags - QoS flags 280 * @MAC_QOS_FLG_UPDATE_EDCA: ? 281 * @MAC_QOS_FLG_TGN: HT is enabled 282 * @MAC_QOS_FLG_TXOP_TYPE: ? 283 * 284 */ 285enum iwl_mac_qos_flags { 286 MAC_QOS_FLG_UPDATE_EDCA = BIT(0), 287 MAC_QOS_FLG_TGN = BIT(1), 288 MAC_QOS_FLG_TXOP_TYPE = BIT(4), 289}; 290 291/** 292 * struct iwl_ac_qos - QOS timing params for MAC_CONTEXT_CMD 293 * @cw_min: Contention window, start value in numbers of slots. 294 * Should be a power-of-2, minus 1. Device's default is 0x0f. 295 * @cw_max: Contention window, max value in numbers of slots. 296 * Should be a power-of-2, minus 1. Device's default is 0x3f. 297 * @aifsn: Number of slots in Arbitration Interframe Space (before 298 * performing random backoff timing prior to Tx). Device default 1. 299 * @fifos_mask: FIFOs used by this MAC for this AC 300 * @edca_txop: Length of Tx opportunity, in uSecs. Device default is 0. 301 * 302 * One instance of this config struct for each of 4 EDCA access categories 303 * in struct iwl_qosparam_cmd. 304 * 305 * Device will automatically increase contention window by (2*CW) + 1 for each 306 * transmission retry. Device uses cw_max as a bit mask, ANDed with new CW 307 * value, to cap the CW value. 308 */ 309struct iwl_ac_qos { 310 __le16 cw_min; 311 __le16 cw_max; 312 u8 aifsn; 313 u8 fifos_mask; 314 __le16 edca_txop; 315} __packed; /* AC_QOS_API_S_VER_2 */ 316 317/** 318 * struct iwl_mac_ctx_cmd - command structure to configure MAC contexts 319 * ( MAC_CONTEXT_CMD = 0x28 ) 320 * @id_and_color: ID and color of the MAC 321 * @action: action to perform, one of FW_CTXT_ACTION_* 322 * @mac_type: one of FW_MAC_TYPE_* 323 * @tsd_id: TSF HW timer, one of TSF_ID_* 324 * @node_addr: MAC address 325 * @bssid_addr: BSSID 326 * @cck_rates: basic rates available for CCK 327 * @ofdm_rates: basic rates available for OFDM 328 * @protection_flags: combination of MAC_PROT_FLG_FLAG_* 329 * @cck_short_preamble: 0x20 for enabling short preamble, 0 otherwise 330 * @short_slot: 0x10 for enabling short slots, 0 otherwise 331 * @filter_flags: combination of MAC_FILTER_* 332 * @qos_flags: from MAC_QOS_FLG_* 333 * @ac: one iwl_mac_qos configuration for each AC 334 * @mac_specific: one of struct iwl_mac_data_*, according to mac_type 335 */ 336struct iwl_mac_ctx_cmd { 337 /* COMMON_INDEX_HDR_API_S_VER_1 */ 338 __le32 id_and_color; 339 __le32 action; 340 /* MAC_CONTEXT_COMMON_DATA_API_S_VER_1 */ 341 __le32 mac_type; 342 __le32 tsf_id; 343 u8 node_addr[6]; 344 __le16 reserved_for_node_addr; 345 u8 bssid_addr[6]; 346 __le16 reserved_for_bssid_addr; 347 __le32 cck_rates; 348 __le32 ofdm_rates; 349 __le32 protection_flags; 350 __le32 cck_short_preamble; 351 __le32 short_slot; 352 __le32 filter_flags; 353 /* MAC_QOS_PARAM_API_S_VER_1 */ 354 __le32 qos_flags; 355 struct iwl_ac_qos ac[AC_NUM+1]; 356 /* MAC_CONTEXT_COMMON_DATA_API_S */ 357 union { 358 struct iwl_mac_data_ap ap; 359 struct iwl_mac_data_go go; 360 struct iwl_mac_data_sta sta; 361 struct iwl_mac_data_p2p_sta p2p_sta; 362 struct iwl_mac_data_p2p_dev p2p_dev; 363 struct iwl_mac_data_pibss pibss; 364 struct iwl_mac_data_ibss ibss; 365 }; 366} __packed; /* MAC_CONTEXT_CMD_API_S_VER_1 */ 367 368static inline u32 iwl_mvm_reciprocal(u32 v) 369{ 370 if (!v) 371 return 0; 372 return 0xFFFFFFFF / v; 373} 374 375#endif /* __fw_api_mac_h__ */ 376