Johannes Berg | 0aaece8 | 2017-03-30 14:30:40 +0200 | [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) 2007 - 2014 Intel Corporation. All rights reserved. |
| 9 | * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH |
| 10 | * Copyright(c) 2016 - 2017 Intel Deutschland GmbH |
| 11 | * |
| 12 | * This program is free software; you can redistribute it and/or modify |
| 13 | * it under the terms of version 2 of the GNU General Public License as |
| 14 | * published by the Free Software Foundation. |
| 15 | * |
| 16 | * This program is distributed in the hope that it will be useful, but |
| 17 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 19 | * General Public License for more details. |
| 20 | * |
| 21 | * The full GNU General Public License is included in this distribution |
| 22 | * in the file called COPYING. |
| 23 | * |
| 24 | * Contact Information: |
| 25 | * Intel Linux Wireless <linuxwifi@intel.com> |
| 26 | * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 |
| 27 | * |
| 28 | * BSD LICENSE |
| 29 | * |
| 30 | * Copyright(c) 2005 - 2014 Intel Corporation. All rights reserved. |
| 31 | * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH |
| 32 | * Copyright(c) 2016 - 2017 Intel Deutschland GmbH |
| 33 | * All rights reserved. |
| 34 | * |
| 35 | * Redistribution and use in source and binary forms, with or without |
| 36 | * modification, are permitted provided that the following conditions |
| 37 | * are met: |
| 38 | * |
| 39 | * * Redistributions of source code must retain the above copyright |
| 40 | * notice, this list of conditions and the following disclaimer. |
| 41 | * * Redistributions in binary form must reproduce the above copyright |
| 42 | * notice, this list of conditions and the following disclaimer in |
| 43 | * the documentation and/or other materials provided with the |
| 44 | * distribution. |
| 45 | * * Neither the name Intel Corporation nor the names of its |
| 46 | * contributors may be used to endorse or promote products derived |
| 47 | * from this software without specific prior written permission. |
| 48 | * |
| 49 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 50 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 51 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 52 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 53 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 54 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 55 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 56 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 57 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 58 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 59 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 60 | * |
| 61 | *****************************************************************************/ |
| 62 | #ifndef __iwl_fw_api_h__ |
| 63 | #define __iwl_fw_api_h__ |
| 64 | |
| 65 | /** |
| 66 | * DOC: Host command section |
| 67 | * |
| 68 | * A host command is a command issued by the upper layer to the fw. There are |
| 69 | * several versions of fw that have several APIs. The transport layer is |
| 70 | * completely agnostic to these differences. |
| 71 | * The transport does provide helper functionality (i.e. SYNC / ASYNC mode), |
| 72 | */ |
| 73 | #define SEQ_TO_QUEUE(s) (((s) >> 8) & 0x1f) |
| 74 | #define QUEUE_TO_SEQ(q) (((q) & 0x1f) << 8) |
| 75 | #define SEQ_TO_INDEX(s) ((s) & 0xff) |
| 76 | #define INDEX_TO_SEQ(i) ((i) & 0xff) |
| 77 | #define SEQ_RX_FRAME cpu_to_le16(0x8000) |
| 78 | |
| 79 | /* |
| 80 | * those functions retrieve specific information from |
| 81 | * the id field in the iwl_host_cmd struct which contains |
| 82 | * the command id, the group id and the version of the command |
| 83 | * and vice versa |
| 84 | */ |
| 85 | static inline u8 iwl_cmd_opcode(u32 cmdid) |
| 86 | { |
| 87 | return cmdid & 0xFF; |
| 88 | } |
| 89 | |
| 90 | static inline u8 iwl_cmd_groupid(u32 cmdid) |
| 91 | { |
| 92 | return ((cmdid & 0xFF00) >> 8); |
| 93 | } |
| 94 | |
| 95 | static inline u8 iwl_cmd_version(u32 cmdid) |
| 96 | { |
| 97 | return ((cmdid & 0xFF0000) >> 16); |
| 98 | } |
| 99 | |
| 100 | static inline u32 iwl_cmd_id(u8 opcode, u8 groupid, u8 version) |
| 101 | { |
| 102 | return opcode + (groupid << 8) + (version << 16); |
| 103 | } |
| 104 | |
| 105 | /* make u16 wide id out of u8 group and opcode */ |
| 106 | #define WIDE_ID(grp, opcode) (((grp) << 8) | (opcode)) |
| 107 | #define DEF_ID(opcode) ((1 << 8) | (opcode)) |
| 108 | |
| 109 | /* due to the conversion, this group is special; new groups |
| 110 | * should be defined in the appropriate fw-api header files |
| 111 | */ |
| 112 | #define IWL_ALWAYS_LONG_GROUP 1 |
| 113 | |
| 114 | /** |
| 115 | * struct iwl_cmd_header |
| 116 | * |
| 117 | * This header format appears in the beginning of each command sent from the |
| 118 | * driver, and each response/notification received from uCode. |
| 119 | */ |
| 120 | struct iwl_cmd_header { |
| 121 | u8 cmd; /* Command ID: REPLY_RXON, etc. */ |
| 122 | u8 group_id; |
| 123 | /* |
| 124 | * The driver sets up the sequence number to values of its choosing. |
| 125 | * uCode does not use this value, but passes it back to the driver |
| 126 | * when sending the response to each driver-originated command, so |
| 127 | * the driver can match the response to the command. Since the values |
| 128 | * don't get used by uCode, the driver may set up an arbitrary format. |
| 129 | * |
| 130 | * There is one exception: uCode sets bit 15 when it originates |
| 131 | * the response/notification, i.e. when the response/notification |
| 132 | * is not a direct response to a command sent by the driver. For |
| 133 | * example, uCode issues REPLY_RX when it sends a received frame |
| 134 | * to the driver; it is not a direct response to any driver command. |
| 135 | * |
| 136 | * The Linux driver uses the following format: |
| 137 | * |
| 138 | * 0:7 tfd index - position within TX queue |
| 139 | * 8:12 TX queue id |
| 140 | * 13:14 reserved |
| 141 | * 15 unsolicited RX or uCode-originated notification |
| 142 | */ |
| 143 | __le16 sequence; |
| 144 | } __packed; |
| 145 | |
| 146 | /** |
| 147 | * struct iwl_cmd_header_wide |
| 148 | * |
| 149 | * This header format appears in the beginning of each command sent from the |
| 150 | * driver, and each response/notification received from uCode. |
| 151 | * this is the wide version that contains more information about the command |
| 152 | * like length, version and command type |
| 153 | */ |
| 154 | struct iwl_cmd_header_wide { |
| 155 | u8 cmd; |
| 156 | u8 group_id; |
| 157 | __le16 sequence; |
| 158 | __le16 length; |
| 159 | u8 reserved; |
| 160 | u8 version; |
| 161 | } __packed; |
| 162 | |
| 163 | /** |
| 164 | * iwl_tx_queue_cfg_actions - TXQ config options |
| 165 | * @TX_QUEUE_CFG_ENABLE_QUEUE: enable a queue |
| 166 | * @TX_QUEUE_CFG_TFD_SHORT_FORMAT: use short TFD format |
| 167 | */ |
| 168 | enum iwl_tx_queue_cfg_actions { |
| 169 | TX_QUEUE_CFG_ENABLE_QUEUE = BIT(0), |
| 170 | TX_QUEUE_CFG_TFD_SHORT_FORMAT = BIT(1), |
| 171 | }; |
| 172 | |
| 173 | /** |
| 174 | * struct iwl_tx_queue_cfg_cmd - txq hw scheduler config command |
| 175 | * @sta_id: station id |
| 176 | * @tid: tid of the queue |
| 177 | * @flags: see &enum iwl_tx_queue_cfg_actions |
| 178 | * @cb_size: size of TFD cyclic buffer. Value is exponent - 3. |
| 179 | * Minimum value 0 (8 TFDs), maximum value 5 (256 TFDs) |
| 180 | * @byte_cnt_addr: address of byte count table |
| 181 | * @tfdq_addr: address of TFD circular buffer |
| 182 | */ |
| 183 | struct iwl_tx_queue_cfg_cmd { |
| 184 | u8 sta_id; |
| 185 | u8 tid; |
| 186 | __le16 flags; |
| 187 | __le32 cb_size; |
| 188 | __le64 byte_cnt_addr; |
| 189 | __le64 tfdq_addr; |
| 190 | } __packed; /* TX_QUEUE_CFG_CMD_API_S_VER_2 */ |
| 191 | |
| 192 | /** |
| 193 | * struct iwl_tx_queue_cfg_rsp - response to txq hw scheduler config |
| 194 | * @queue_number: queue number assigned to this RA -TID |
| 195 | * @flags: set on failure |
| 196 | * @write_pointer: initial value for write pointer |
| 197 | */ |
| 198 | struct iwl_tx_queue_cfg_rsp { |
| 199 | __le16 queue_number; |
| 200 | __le16 flags; |
| 201 | __le16 write_pointer; |
| 202 | __le16 reserved; |
| 203 | } __packed; /* TX_QUEUE_CFG_RSP_API_S_VER_2 */ |
| 204 | |
| 205 | #endif /* __iwl_fw_api_h__*/ |