cmdhdr.h (4439B)
1/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ 2/* 3 * Copyright (C) 2005-2014 Intel Corporation 4 * Copyright (C) 2013-2015 Intel Mobile Communications GmbH 5 * Copyright (C) 2016-2017 Intel Deutschland GmbH 6 */ 7#ifndef __iwl_fw_api_cmdhdr_h__ 8#define __iwl_fw_api_cmdhdr_h__ 9 10/** 11 * DOC: Host command section 12 * 13 * A host command is a command issued by the upper layer to the fw. There are 14 * several versions of fw that have several APIs. The transport layer is 15 * completely agnostic to these differences. 16 * The transport does provide helper functionality (i.e. SYNC / ASYNC mode), 17 */ 18#define SEQ_TO_QUEUE(s) (((s) >> 8) & 0x1f) 19#define QUEUE_TO_SEQ(q) (((q) & 0x1f) << 8) 20#define SEQ_TO_INDEX(s) ((s) & 0xff) 21#define INDEX_TO_SEQ(i) ((i) & 0xff) 22#define SEQ_RX_FRAME cpu_to_le16(0x8000) 23 24/* 25 * those functions retrieve specific information from 26 * the id field in the iwl_host_cmd struct which contains 27 * the command id, the group id and the version of the command 28 * and vice versa 29*/ 30static inline u8 iwl_cmd_opcode(u32 cmdid) 31{ 32 return cmdid & 0xFF; 33} 34 35static inline u8 iwl_cmd_groupid(u32 cmdid) 36{ 37 return ((cmdid & 0xFF00) >> 8); 38} 39 40static inline u8 iwl_cmd_version(u32 cmdid) 41{ 42 return ((cmdid & 0xFF0000) >> 16); 43} 44 45static inline u32 iwl_cmd_id(u8 opcode, u8 groupid, u8 version) 46{ 47 return opcode + (groupid << 8) + (version << 16); 48} 49 50/* make u16 wide id out of u8 group and opcode */ 51#define WIDE_ID(grp, opcode) (((grp) << 8) | (opcode)) 52#define DEF_ID(opcode) ((1 << 8) | (opcode)) 53 54/* due to the conversion, this group is special; new groups 55 * should be defined in the appropriate fw-api header files 56 */ 57#define IWL_ALWAYS_LONG_GROUP 1 58 59/** 60 * struct iwl_cmd_header - (short) command header format 61 * 62 * This header format appears in the beginning of each command sent from the 63 * driver, and each response/notification received from uCode. 64 */ 65struct iwl_cmd_header { 66 /** 67 * @cmd: Command ID: REPLY_RXON, etc. 68 */ 69 u8 cmd; 70 /** 71 * @group_id: group ID, for commands with groups 72 */ 73 u8 group_id; 74 /** 75 * @sequence: 76 * Sequence number for the command. 77 * 78 * The driver sets up the sequence number to values of its choosing. 79 * uCode does not use this value, but passes it back to the driver 80 * when sending the response to each driver-originated command, so 81 * the driver can match the response to the command. Since the values 82 * don't get used by uCode, the driver may set up an arbitrary format. 83 * 84 * There is one exception: uCode sets bit 15 when it originates 85 * the response/notification, i.e. when the response/notification 86 * is not a direct response to a command sent by the driver. For 87 * example, uCode issues REPLY_RX when it sends a received frame 88 * to the driver; it is not a direct response to any driver command. 89 * 90 * The Linux driver uses the following format: 91 * 92 * 0:7 tfd index - position within TX queue 93 * 8:12 TX queue id 94 * 13:14 reserved 95 * 15 unsolicited RX or uCode-originated notification 96 */ 97 __le16 sequence; 98} __packed; 99 100/** 101 * struct iwl_cmd_header_wide 102 * 103 * This header format appears in the beginning of each command sent from the 104 * driver, and each response/notification received from uCode. 105 * this is the wide version that contains more information about the command 106 * like length, version and command type 107 * 108 * @cmd: command ID, like in &struct iwl_cmd_header 109 * @group_id: group ID, like in &struct iwl_cmd_header 110 * @sequence: sequence, like in &struct iwl_cmd_header 111 * @length: length of the command 112 * @reserved: reserved 113 * @version: command version 114 */ 115struct iwl_cmd_header_wide { 116 u8 cmd; 117 u8 group_id; 118 __le16 sequence; 119 __le16 length; 120 u8 reserved; 121 u8 version; 122} __packed; 123 124/** 125 * struct iwl_calib_res_notif_phy_db - Receive phy db chunk after calibrations 126 * @type: type of the result - mostly ignored 127 * @length: length of the data 128 * @data: data, length in @length 129 */ 130struct iwl_calib_res_notif_phy_db { 131 __le16 type; 132 __le16 length; 133 u8 data[]; 134} __packed; 135 136/** 137 * struct iwl_phy_db_cmd - configure operational ucode 138 * @type: type of the data 139 * @length: length of the data 140 * @data: data, length in @length 141 */ 142struct iwl_phy_db_cmd { 143 __le16 type; 144 __le16 length; 145 u8 data[]; 146} __packed; 147 148/** 149 * struct iwl_cmd_response - generic response struct for most commands 150 * @status: status of the command asked, changes for each one 151 */ 152struct iwl_cmd_response { 153 __le32 status; 154}; 155 156#endif /* __iwl_fw_api_cmdhdr_h__ */