1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
3 * Copyright (C) 2005-2014 Intel Corporation
4 * Copyright (C) 2013-2015 Intel Mobile Communications GmbH
5 * Copyright (C) 2016-2017 Intel Deutschland GmbH
7 #ifndef __iwl_fw_api_cmdhdr_h__
8 #define __iwl_fw_api_cmdhdr_h__
11 * DOC: Host command section
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),
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)
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
30 static inline u8 iwl_cmd_opcode(u32 cmdid)
35 static inline u8 iwl_cmd_groupid(u32 cmdid)
37 return ((cmdid & 0xFF00) >> 8);
40 static inline u8 iwl_cmd_version(u32 cmdid)
42 return ((cmdid & 0xFF0000) >> 16);
45 static inline u32 iwl_cmd_id(u8 opcode, u8 groupid, u8 version)
47 return opcode + (groupid << 8) + (version << 16);
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))
54 /* due to the conversion, this group is special; new groups
55 * should be defined in the appropriate fw-api header files
57 #define IWL_ALWAYS_LONG_GROUP 1
60 * struct iwl_cmd_header - (short) command header format
62 * This header format appears in the beginning of each command sent from the
63 * driver, and each response/notification received from uCode.
65 struct iwl_cmd_header {
67 * @cmd: Command ID: REPLY_RXON, etc.
71 * @group_id: group ID, for commands with groups
76 * Sequence number for the command.
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.
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.
90 * The Linux driver uses the following format:
92 * 0:7 tfd index - position within TX queue
95 * 15 unsolicited RX or uCode-originated notification
101 * struct iwl_cmd_header_wide
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
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
115 struct iwl_cmd_header_wide {
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
130 struct iwl_calib_res_notif_phy_db {
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
142 struct iwl_phy_db_cmd {
149 * struct iwl_cmd_response - generic response struct for most commands
150 * @status: status of the command asked, changes for each one
152 struct iwl_cmd_response {
156 #endif /* __iwl_fw_api_cmdhdr_h__ */