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_cmdhdr_h__ 63 #define __iwl_fw_api_cmdhdr_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 * struct iwl_calib_res_notif_phy_db - Receive phy db chunk after calibrations 165 * @type: type of the result - mostly ignored 166 * @length: length of the data 167 * @data: data, length in @length 168 */ 169 struct iwl_calib_res_notif_phy_db { 170 __le16 type; 171 __le16 length; 172 u8 data[]; 173 } __packed; 174 175 /** 176 * struct iwl_phy_db_cmd - configure operational ucode 177 * @type: type of the data 178 * @length: length of the data 179 * @data: data, length in @length 180 */ 181 struct iwl_phy_db_cmd { 182 __le16 type; 183 __le16 length; 184 u8 data[]; 185 } __packed; 186 187 /** 188 * struct iwl_cmd_response - generic response struct for most commands 189 * @status: status of the command asked, changes for each one 190 */ 191 struct iwl_cmd_response { 192 __le32 status; 193 }; 194 195 #endif /* __iwl_fw_api_cmdhdr_h__ */ 196