brintos

brintos / linux-shallow public Read only

0
0
Text · 4.3 KiB · d130d4f Raw
157 lines · c
1/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */2/*3 * Copyright (C) 2005-2014 Intel Corporation4 * Copyright (C) 2013-2015 Intel Mobile Communications GmbH5 * Copyright (C) 2016-2017 Intel Deutschland GmbH6 */7#ifndef __iwl_fw_api_cmdhdr_h__8#define __iwl_fw_api_cmdhdr_h__9 10/**11 * DOC: Host command section12 *13 * A host command is a command issued by the upper layer to the fw. There are14 * several versions of fw that have several APIs. The transport layer is15 * 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 from26 * the id field in the iwl_host_cmd struct which contains27 * the command id, the group id and the version of the command28 * and vice versa29*/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 groups55 * should be defined in the appropriate fw-api header files56 */57#define IWL_ALWAYS_LONG_GROUP	158 59/**60 * struct iwl_cmd_header - (short) command header format61 *62 * This header format appears in the beginning of each command sent from the63 * 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 groups72	 */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 driver80	 * when sending the response to each driver-originated command, so81	 * the driver can match the response to the command.  Since the values82	 * 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 originates85	 * the response/notification, i.e. when the response/notification86	 * is not a direct response to a command sent by the driver.  For87	 * example, uCode issues REPLY_RX when it sends a received frame88	 * 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 queue93	 *  8:12	TX queue id94	 *  13:14	reserved95	 *  15		unsolicited RX or uCode-originated notification96	 */97	__le16 sequence;98} __packed;99 100/**101 * struct iwl_cmd_header_wide102 *103 * This header format appears in the beginning of each command sent from the104 * driver, and each response/notification received from uCode.105 * this is the wide version that contains more information about the command106 * like length, version and command type107 *108 * @cmd: command ID, like in &struct iwl_cmd_header109 * @group_id: group ID, like in &struct iwl_cmd_header110 * @sequence: sequence, like in &struct iwl_cmd_header111 * @length: length of the command112 * @reserved: reserved113 * @version: command version114 */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 calibrations126 * @type: type of the result - mostly ignored127 * @length: length of the data128 * @data: data, length in @length129 */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 ucode138 * @type: type of the data139 * @length: length of the data140 * @data: data, length in @length141 */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 commands150 * @status: status of the command asked, changes for each one151 */152struct iwl_cmd_response {153	__le32 status;154};155 156#endif /* __iwl_fw_api_cmdhdr_h__ */157