Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 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 LICENSE.GPL. |
| 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 | |
| 74 | #define AC_NUM 4 /* Number of access categories */ |
| 75 | |
| 76 | /** |
| 77 | * enum iwl_mac_protection_flags - MAC context flags |
| 78 | * @MAC_PROT_FLG_TGG_PROTECT: 11g protection when transmitting OFDM frames, |
| 79 | * this will require CCK RTS/CTS2self. |
| 80 | * RTS/CTS will protect full burst time. |
| 81 | * @MAC_PROT_FLG_HT_PROT: enable HT protection |
| 82 | * @MAC_PROT_FLG_FAT_PROT: protect 40 MHz transmissions |
| 83 | * @MAC_PROT_FLG_SELF_CTS_EN: allow CTS2self |
| 84 | */ |
| 85 | enum iwl_mac_protection_flags { |
| 86 | MAC_PROT_FLG_TGG_PROTECT = BIT(3), |
| 87 | MAC_PROT_FLG_HT_PROT = BIT(23), |
| 88 | MAC_PROT_FLG_FAT_PROT = BIT(24), |
| 89 | MAC_PROT_FLG_SELF_CTS_EN = BIT(30), |
| 90 | }; |
| 91 | |
| 92 | #define MAC_FLG_SHORT_SLOT BIT(4) |
| 93 | #define MAC_FLG_SHORT_PREAMBLE BIT(5) |
| 94 | |
| 95 | /** |
| 96 | * enum iwl_mac_types - Supported MAC types |
| 97 | * @FW_MAC_TYPE_FIRST: lowest supported MAC type |
| 98 | * @FW_MAC_TYPE_AUX: Auxiliary MAC (internal) |
| 99 | * @FW_MAC_TYPE_LISTENER: monitor MAC type (?) |
| 100 | * @FW_MAC_TYPE_PIBSS: Pseudo-IBSS |
| 101 | * @FW_MAC_TYPE_IBSS: IBSS |
| 102 | * @FW_MAC_TYPE_BSS_STA: BSS (managed) station |
| 103 | * @FW_MAC_TYPE_P2P_DEVICE: P2P Device |
| 104 | * @FW_MAC_TYPE_P2P_STA: P2P client |
| 105 | * @FW_MAC_TYPE_GO: P2P GO |
| 106 | * @FW_MAC_TYPE_TEST: ? |
| 107 | * @FW_MAC_TYPE_MAX: highest support MAC type |
| 108 | */ |
| 109 | enum iwl_mac_types { |
| 110 | FW_MAC_TYPE_FIRST = 1, |
| 111 | FW_MAC_TYPE_AUX = FW_MAC_TYPE_FIRST, |
| 112 | FW_MAC_TYPE_LISTENER, |
| 113 | FW_MAC_TYPE_PIBSS, |
| 114 | FW_MAC_TYPE_IBSS, |
| 115 | FW_MAC_TYPE_BSS_STA, |
| 116 | FW_MAC_TYPE_P2P_DEVICE, |
| 117 | FW_MAC_TYPE_P2P_STA, |
| 118 | FW_MAC_TYPE_GO, |
| 119 | FW_MAC_TYPE_TEST, |
| 120 | FW_MAC_TYPE_MAX = FW_MAC_TYPE_TEST |
| 121 | }; /* MAC_CONTEXT_TYPE_API_E_VER_1 */ |
| 122 | |
| 123 | /** |
| 124 | * enum iwl_tsf_id - TSF hw timer ID |
| 125 | * @TSF_ID_A: use TSF A |
| 126 | * @TSF_ID_B: use TSF B |
| 127 | * @TSF_ID_C: use TSF C |
| 128 | * @TSF_ID_D: use TSF D |
| 129 | * @NUM_TSF_IDS: number of TSF timers available |
| 130 | */ |
| 131 | enum iwl_tsf_id { |
| 132 | TSF_ID_A = 0, |
| 133 | TSF_ID_B = 1, |
| 134 | TSF_ID_C = 2, |
| 135 | TSF_ID_D = 3, |
| 136 | NUM_TSF_IDS = 4, |
| 137 | }; /* TSF_ID_API_E_VER_1 */ |
| 138 | |
| 139 | /** |
| 140 | * struct iwl_mac_data_ap - configuration data for AP MAC context |
| 141 | * @beacon_time: beacon transmit time in system time |
| 142 | * @beacon_tsf: beacon transmit time in TSF |
| 143 | * @bi: beacon interval in TU |
| 144 | * @bi_reciprocal: 2^32 / bi |
| 145 | * @dtim_interval: dtim transmit time in TU |
| 146 | * @dtim_reciprocal: 2^32 / dtim_interval |
| 147 | * @mcast_qid: queue ID for multicast traffic |
| 148 | * @beacon_template: beacon template ID |
| 149 | */ |
| 150 | struct iwl_mac_data_ap { |
| 151 | __le32 beacon_time; |
| 152 | __le64 beacon_tsf; |
| 153 | __le32 bi; |
| 154 | __le32 bi_reciprocal; |
| 155 | __le32 dtim_interval; |
| 156 | __le32 dtim_reciprocal; |
| 157 | __le32 mcast_qid; |
| 158 | __le32 beacon_template; |
| 159 | } __packed; /* AP_MAC_DATA_API_S_VER_1 */ |
| 160 | |
| 161 | /** |
| 162 | * struct iwl_mac_data_ibss - configuration data for IBSS MAC context |
| 163 | * @beacon_time: beacon transmit time in system time |
| 164 | * @beacon_tsf: beacon transmit time in TSF |
| 165 | * @bi: beacon interval in TU |
| 166 | * @bi_reciprocal: 2^32 / bi |
| 167 | */ |
| 168 | struct iwl_mac_data_ibss { |
| 169 | __le32 beacon_time; |
| 170 | __le64 beacon_tsf; |
| 171 | __le32 bi; |
| 172 | __le32 bi_reciprocal; |
| 173 | } __packed; /* IBSS_MAC_DATA_API_S_VER_1 */ |
| 174 | |
| 175 | /** |
| 176 | * struct iwl_mac_data_sta - configuration data for station MAC context |
| 177 | * @is_assoc: 1 for associated state, 0 otherwise |
| 178 | * @dtim_time: DTIM arrival time in system time |
| 179 | * @dtim_tsf: DTIM arrival time in TSF |
| 180 | * @bi: beacon interval in TU, applicable only when associated |
| 181 | * @bi_reciprocal: 2^32 / bi , applicable only when associated |
| 182 | * @dtim_interval: DTIM interval in TU, applicable only when associated |
| 183 | * @dtim_reciprocal: 2^32 / dtim_interval , applicable only when associated |
| 184 | * @listen_interval: in beacon intervals, applicable only when associated |
| 185 | * @assoc_id: unique ID assigned by the AP during association |
| 186 | */ |
| 187 | struct iwl_mac_data_sta { |
| 188 | __le32 is_assoc; |
| 189 | __le32 dtim_time; |
| 190 | __le64 dtim_tsf; |
| 191 | __le32 bi; |
| 192 | __le32 bi_reciprocal; |
| 193 | __le32 dtim_interval; |
| 194 | __le32 dtim_reciprocal; |
| 195 | __le32 listen_interval; |
| 196 | __le32 assoc_id; |
| 197 | __le32 assoc_beacon_arrive_time; |
| 198 | } __packed; /* STA_MAC_DATA_API_S_VER_1 */ |
| 199 | |
| 200 | /** |
| 201 | * struct iwl_mac_data_go - configuration data for P2P GO MAC context |
| 202 | * @ap: iwl_mac_data_ap struct with most config data |
| 203 | * @ctwin: client traffic window in TU (period after TBTT when GO is present). |
| 204 | * 0 indicates that there is no CT window. |
| 205 | * @opp_ps_enabled: indicate that opportunistic PS allowed |
| 206 | */ |
| 207 | struct iwl_mac_data_go { |
| 208 | struct iwl_mac_data_ap ap; |
| 209 | __le32 ctwin; |
| 210 | __le32 opp_ps_enabled; |
| 211 | } __packed; /* GO_MAC_DATA_API_S_VER_1 */ |
| 212 | |
| 213 | /** |
| 214 | * struct iwl_mac_data_p2p_sta - configuration data for P2P client MAC context |
| 215 | * @sta: iwl_mac_data_sta struct with most config data |
| 216 | * @ctwin: client traffic window in TU (period after TBTT when GO is present). |
| 217 | * 0 indicates that there is no CT window. |
| 218 | */ |
| 219 | struct iwl_mac_data_p2p_sta { |
| 220 | struct iwl_mac_data_sta sta; |
| 221 | __le32 ctwin; |
| 222 | } __packed; /* P2P_STA_MAC_DATA_API_S_VER_1 */ |
| 223 | |
| 224 | /** |
| 225 | * struct iwl_mac_data_pibss - Pseudo IBSS config data |
| 226 | * @stats_interval: interval in TU between statistics notifications to host. |
| 227 | */ |
| 228 | struct iwl_mac_data_pibss { |
| 229 | __le32 stats_interval; |
| 230 | } __packed; /* PIBSS_MAC_DATA_API_S_VER_1 */ |
| 231 | |
| 232 | /* |
| 233 | * struct iwl_mac_data_p2p_dev - configuration data for the P2P Device MAC |
| 234 | * context. |
| 235 | * @is_disc_extended: if set to true, P2P Device discoverability is enabled on |
| 236 | * other channels as well. This should be to true only in case that the |
| 237 | * device is discoverable and there is an active GO. Note that setting this |
| 238 | * field when not needed, will increase the number of interrupts and have |
| 239 | * effect on the platform power, as this setting opens the Rx filters on |
| 240 | * all macs. |
| 241 | */ |
| 242 | struct iwl_mac_data_p2p_dev { |
| 243 | __le32 is_disc_extended; |
| 244 | } __packed; /* _P2P_DEV_MAC_DATA_API_S_VER_1 */ |
| 245 | |
| 246 | /** |
| 247 | * enum iwl_mac_filter_flags - MAC context filter flags |
| 248 | * @MAC_FILTER_IN_PROMISC: accept all data frames |
| 249 | * @MAC_FILTER_IN_CONTROL_AND_MGMT: pass all mangement and |
| 250 | * control frames to the host |
| 251 | * @MAC_FILTER_ACCEPT_GRP: accept multicast frames |
| 252 | * @MAC_FILTER_DIS_DECRYPT: don't decrypt unicast frames |
| 253 | * @MAC_FILTER_DIS_GRP_DECRYPT: don't decrypt multicast frames |
| 254 | * @MAC_FILTER_IN_BEACON: transfer foreign BSS's beacons to host |
| 255 | * (in station mode when associated) |
| 256 | * @MAC_FILTER_OUT_BCAST: filter out all broadcast frames |
| 257 | * @MAC_FILTER_IN_CRC32: extract FCS and append it to frames |
| 258 | * @MAC_FILTER_IN_PROBE_REQUEST: pass probe requests to host |
| 259 | */ |
| 260 | enum iwl_mac_filter_flags { |
| 261 | MAC_FILTER_IN_PROMISC = BIT(0), |
| 262 | MAC_FILTER_IN_CONTROL_AND_MGMT = BIT(1), |
| 263 | MAC_FILTER_ACCEPT_GRP = BIT(2), |
| 264 | MAC_FILTER_DIS_DECRYPT = BIT(3), |
| 265 | MAC_FILTER_DIS_GRP_DECRYPT = BIT(4), |
| 266 | MAC_FILTER_IN_BEACON = BIT(6), |
| 267 | MAC_FILTER_OUT_BCAST = BIT(8), |
| 268 | MAC_FILTER_IN_CRC32 = BIT(11), |
| 269 | MAC_FILTER_IN_PROBE_REQUEST = BIT(12), |
| 270 | }; |
| 271 | |
| 272 | /** |
| 273 | * enum iwl_mac_qos_flags - QoS flags |
| 274 | * @MAC_QOS_FLG_UPDATE_EDCA: ? |
| 275 | * @MAC_QOS_FLG_TGN: HT is enabled |
| 276 | * @MAC_QOS_FLG_TXOP_TYPE: ? |
| 277 | * |
| 278 | */ |
| 279 | enum iwl_mac_qos_flags { |
| 280 | MAC_QOS_FLG_UPDATE_EDCA = BIT(0), |
| 281 | MAC_QOS_FLG_TGN = BIT(1), |
| 282 | MAC_QOS_FLG_TXOP_TYPE = BIT(4), |
| 283 | }; |
| 284 | |
| 285 | /** |
| 286 | * struct iwl_ac_qos - QOS timing params for MAC_CONTEXT_CMD |
| 287 | * @cw_min: Contention window, start value in numbers of slots. |
| 288 | * Should be a power-of-2, minus 1. Device's default is 0x0f. |
| 289 | * @cw_max: Contention window, max value in numbers of slots. |
| 290 | * Should be a power-of-2, minus 1. Device's default is 0x3f. |
| 291 | * @aifsn: Number of slots in Arbitration Interframe Space (before |
| 292 | * performing random backoff timing prior to Tx). Device default 1. |
| 293 | * @fifos_mask: FIFOs used by this MAC for this AC |
| 294 | * @edca_txop: Length of Tx opportunity, in uSecs. Device default is 0. |
| 295 | * |
| 296 | * One instance of this config struct for each of 4 EDCA access categories |
| 297 | * in struct iwl_qosparam_cmd. |
| 298 | * |
| 299 | * Device will automatically increase contention window by (2*CW) + 1 for each |
| 300 | * transmission retry. Device uses cw_max as a bit mask, ANDed with new CW |
| 301 | * value, to cap the CW value. |
| 302 | */ |
| 303 | struct iwl_ac_qos { |
| 304 | __le16 cw_min; |
| 305 | __le16 cw_max; |
| 306 | u8 aifsn; |
| 307 | u8 fifos_mask; |
| 308 | __le16 edca_txop; |
| 309 | } __packed; /* AC_QOS_API_S_VER_2 */ |
| 310 | |
| 311 | /** |
| 312 | * struct iwl_mac_ctx_cmd - command structure to configure MAC contexts |
| 313 | * ( MAC_CONTEXT_CMD = 0x28 ) |
| 314 | * @id_and_color: ID and color of the MAC |
| 315 | * @action: action to perform, one of FW_CTXT_ACTION_* |
| 316 | * @mac_type: one of FW_MAC_TYPE_* |
| 317 | * @tsd_id: TSF HW timer, one of TSF_ID_* |
| 318 | * @node_addr: MAC address |
| 319 | * @bssid_addr: BSSID |
| 320 | * @cck_rates: basic rates available for CCK |
| 321 | * @ofdm_rates: basic rates available for OFDM |
| 322 | * @protection_flags: combination of MAC_PROT_FLG_FLAG_* |
| 323 | * @cck_short_preamble: 0x20 for enabling short preamble, 0 otherwise |
| 324 | * @short_slot: 0x10 for enabling short slots, 0 otherwise |
| 325 | * @filter_flags: combination of MAC_FILTER_* |
| 326 | * @qos_flags: from MAC_QOS_FLG_* |
| 327 | * @ac: one iwl_mac_qos configuration for each AC |
| 328 | * @mac_specific: one of struct iwl_mac_data_*, according to mac_type |
| 329 | */ |
| 330 | struct iwl_mac_ctx_cmd { |
| 331 | /* COMMON_INDEX_HDR_API_S_VER_1 */ |
| 332 | __le32 id_and_color; |
| 333 | __le32 action; |
| 334 | /* MAC_CONTEXT_COMMON_DATA_API_S_VER_1 */ |
| 335 | __le32 mac_type; |
| 336 | __le32 tsf_id; |
| 337 | u8 node_addr[6]; |
| 338 | __le16 reserved_for_node_addr; |
| 339 | u8 bssid_addr[6]; |
| 340 | __le16 reserved_for_bssid_addr; |
| 341 | __le32 cck_rates; |
| 342 | __le32 ofdm_rates; |
| 343 | __le32 protection_flags; |
| 344 | __le32 cck_short_preamble; |
| 345 | __le32 short_slot; |
| 346 | __le32 filter_flags; |
| 347 | /* MAC_QOS_PARAM_API_S_VER_1 */ |
| 348 | __le32 qos_flags; |
| 349 | struct iwl_ac_qos ac[AC_NUM+1]; |
| 350 | /* MAC_CONTEXT_COMMON_DATA_API_S */ |
| 351 | union { |
| 352 | struct iwl_mac_data_ap ap; |
| 353 | struct iwl_mac_data_go go; |
| 354 | struct iwl_mac_data_sta sta; |
| 355 | struct iwl_mac_data_p2p_sta p2p_sta; |
| 356 | struct iwl_mac_data_p2p_dev p2p_dev; |
| 357 | struct iwl_mac_data_pibss pibss; |
| 358 | struct iwl_mac_data_ibss ibss; |
| 359 | }; |
| 360 | } __packed; /* MAC_CONTEXT_CMD_API_S_VER_1 */ |
| 361 | |
| 362 | static inline u32 iwl_mvm_reciprocal(u32 v) |
| 363 | { |
| 364 | if (!v) |
| 365 | return 0; |
| 366 | return 0xFFFFFFFF / v; |
| 367 | } |
| 368 | |
| 369 | #endif /* __fw_api_mac_h__ */ |