Path: blob/main/sys/contrib/dev/iwlwifi/fw/api/cmdhdr.h
48425 views
/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */1/*2* Copyright (C) 2005-2014 Intel Corporation3* Copyright (C) 2013-2015 Intel Mobile Communications GmbH4* Copyright (C) 2016-2017 Intel Deutschland GmbH5*/6#ifndef __iwl_fw_api_cmdhdr_h__7#define __iwl_fw_api_cmdhdr_h__89/**10* DOC: Host command section11*12* A host command is a command issued by the upper layer to the fw. There are13* several versions of fw that have several APIs. The transport layer is14* completely agnostic to these differences.15* The transport does provide helper functionality (i.e. SYNC / ASYNC mode),16*/17#define SEQ_TO_QUEUE(s) (((s) >> 8) & 0x1f)18#define QUEUE_TO_SEQ(q) (((q) & 0x1f) << 8)19#define SEQ_TO_INDEX(s) ((s) & 0xff)20#define INDEX_TO_SEQ(i) ((i) & 0xff)21#define SEQ_RX_FRAME cpu_to_le16(0x8000)2223/*24* those functions retrieve specific information from25* the id field in the iwl_host_cmd struct which contains26* the command id, the group id and the version of the command27* and vice versa28*/29static inline u8 iwl_cmd_opcode(u32 cmdid)30{31return cmdid & 0xFF;32}3334static inline u8 iwl_cmd_groupid(u32 cmdid)35{36return ((cmdid & 0xFF00) >> 8);37}3839static inline u8 iwl_cmd_version(u32 cmdid)40{41return ((cmdid & 0xFF0000) >> 16);42}4344static inline u32 iwl_cmd_id(u8 opcode, u8 groupid, u8 version)45{46return opcode + (groupid << 8) + (version << 16);47}4849/* make u16 wide id out of u8 group and opcode */50#define WIDE_ID(grp, opcode) (((grp) << 8) | (opcode))51#define DEF_ID(opcode) ((1 << 8) | (opcode))5253/* due to the conversion, this group is special; new groups54* should be defined in the appropriate fw-api header files55*/56#define IWL_ALWAYS_LONG_GROUP 15758/**59* struct iwl_cmd_header - (short) command header format60*61* This header format appears in the beginning of each command sent from the62* driver, and each response/notification received from uCode.63*/64struct iwl_cmd_header {65/**66* @cmd: Command ID: REPLY_RXON, etc.67*/68u8 cmd;69/**70* @group_id: group ID, for commands with groups71*/72u8 group_id;73/**74* @sequence:75* Sequence number for the command.76*77* The driver sets up the sequence number to values of its choosing.78* uCode does not use this value, but passes it back to the driver79* when sending the response to each driver-originated command, so80* the driver can match the response to the command. Since the values81* don't get used by uCode, the driver may set up an arbitrary format.82*83* There is one exception: uCode sets bit 15 when it originates84* the response/notification, i.e. when the response/notification85* is not a direct response to a command sent by the driver. For86* example, uCode issues REPLY_RX when it sends a received frame87* to the driver; it is not a direct response to any driver command.88*89* The Linux driver uses the following format:90*91* 0:7 tfd index - position within TX queue92* 8:12 TX queue id93* 13:14 reserved94* 15 unsolicited RX or uCode-originated notification95*/96__le16 sequence;97} __packed;9899/**100* struct iwl_cmd_header_wide101*102* This header format appears in the beginning of each command sent from the103* driver, and each response/notification received from uCode.104* this is the wide version that contains more information about the command105* like length, version and command type106*107* @cmd: command ID, like in &struct iwl_cmd_header108* @group_id: group ID, like in &struct iwl_cmd_header109* @sequence: sequence, like in &struct iwl_cmd_header110* @length: length of the command111* @reserved: reserved112* @version: command version113*/114struct iwl_cmd_header_wide {115u8 cmd;116u8 group_id;117__le16 sequence;118__le16 length;119u8 reserved;120u8 version;121} __packed;122123/**124* struct iwl_calib_res_notif_phy_db - Receive phy db chunk after calibrations125* @type: type of the result - mostly ignored126* @length: length of the data127* @data: data, length in @length128*/129struct iwl_calib_res_notif_phy_db {130__le16 type;131__le16 length;132u8 data[];133} __packed;134135/**136* struct iwl_phy_db_cmd - configure operational ucode137* @type: type of the data138* @length: length of the data139* @data: data, length in @length140*/141struct iwl_phy_db_cmd {142__le16 type;143__le16 length;144u8 data[];145} __packed;146147/**148* struct iwl_cmd_response - generic response struct for most commands149* @status: status of the command asked, changes for each one150*/151struct iwl_cmd_response {152__le32 status;153};154155#endif /* __iwl_fw_api_cmdhdr_h__ */156157158