1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (c) 2003-2020, Intel Corporation. All rights reserved
4 * Intel Management Engine Interface (Intel MEI) Linux driver
7 #ifndef _MEI_HW_TYPES_H_
8 #define _MEI_HW_TYPES_H_
10 #include <linux/uuid.h>
15 #define MEI_HW_READY_TIMEOUT 2 /* Timeout on ready message */
16 #define MEI_CONNECT_TIMEOUT 3 /* HPS: at least 2 seconds */
18 #define MEI_CL_CONNECT_TIMEOUT 15 /* HPS: Client Connect Timeout */
19 #define MEI_CLIENTS_INIT_TIMEOUT 15 /* HPS: Clients Enumeration Timeout */
21 #define MEI_PGI_TIMEOUT 1 /* PG Isolation time response 1 sec */
22 #define MEI_D0I3_TIMEOUT 5 /* D0i3 set/unset max response time */
23 #define MEI_HBM_TIMEOUT 1 /* 1 second */
28 #define HBM_MINOR_VERSION 2
29 #define HBM_MAJOR_VERSION 2
32 * MEI version with PGI support
34 #define HBM_MINOR_VERSION_PGI 1
35 #define HBM_MAJOR_VERSION_PGI 1
38 * MEI version with Dynamic clients support
40 #define HBM_MINOR_VERSION_DC 0
41 #define HBM_MAJOR_VERSION_DC 2
44 * MEI version with immediate reply to enum request support
46 #define HBM_MINOR_VERSION_IE 0
47 #define HBM_MAJOR_VERSION_IE 2
50 * MEI version with disconnect on connection timeout support
52 #define HBM_MINOR_VERSION_DOT 0
53 #define HBM_MAJOR_VERSION_DOT 2
56 * MEI version with notification support
58 #define HBM_MINOR_VERSION_EV 0
59 #define HBM_MAJOR_VERSION_EV 2
62 * MEI version with fixed address client support
64 #define HBM_MINOR_VERSION_FA 0
65 #define HBM_MAJOR_VERSION_FA 2
68 * MEI version with OS ver message support
70 #define HBM_MINOR_VERSION_OS 0
71 #define HBM_MAJOR_VERSION_OS 2
74 * MEI version with dma ring support
76 #define HBM_MINOR_VERSION_DR 1
77 #define HBM_MAJOR_VERSION_DR 2
80 * MEI version with vm tag support
82 #define HBM_MINOR_VERSION_VT 2
83 #define HBM_MAJOR_VERSION_VT 2
86 * MEI version with capabilities message support
88 #define HBM_MINOR_VERSION_CAP 2
89 #define HBM_MAJOR_VERSION_CAP 2
92 * MEI version with client DMA support
94 #define HBM_MINOR_VERSION_CD 2
95 #define HBM_MAJOR_VERSION_CD 2
97 /* Host bus message command opcode */
98 #define MEI_HBM_CMD_OP_MSK 0x7f
99 /* Host bus message command RESPONSE */
100 #define MEI_HBM_CMD_RES_MSK 0x80
103 * MEI Bus Message Command IDs
105 #define HOST_START_REQ_CMD 0x01
106 #define HOST_START_RES_CMD 0x81
108 #define HOST_STOP_REQ_CMD 0x02
109 #define HOST_STOP_RES_CMD 0x82
111 #define ME_STOP_REQ_CMD 0x03
113 #define HOST_ENUM_REQ_CMD 0x04
114 #define HOST_ENUM_RES_CMD 0x84
116 #define HOST_CLIENT_PROPERTIES_REQ_CMD 0x05
117 #define HOST_CLIENT_PROPERTIES_RES_CMD 0x85
119 #define CLIENT_CONNECT_REQ_CMD 0x06
120 #define CLIENT_CONNECT_RES_CMD 0x86
122 #define CLIENT_DISCONNECT_REQ_CMD 0x07
123 #define CLIENT_DISCONNECT_RES_CMD 0x87
125 #define MEI_FLOW_CONTROL_CMD 0x08
127 #define MEI_PG_ISOLATION_ENTRY_REQ_CMD 0x0a
128 #define MEI_PG_ISOLATION_ENTRY_RES_CMD 0x8a
129 #define MEI_PG_ISOLATION_EXIT_REQ_CMD 0x0b
130 #define MEI_PG_ISOLATION_EXIT_RES_CMD 0x8b
132 #define MEI_HBM_ADD_CLIENT_REQ_CMD 0x0f
133 #define MEI_HBM_ADD_CLIENT_RES_CMD 0x8f
135 #define MEI_HBM_NOTIFY_REQ_CMD 0x10
136 #define MEI_HBM_NOTIFY_RES_CMD 0x90
137 #define MEI_HBM_NOTIFICATION_CMD 0x11
139 #define MEI_HBM_DMA_SETUP_REQ_CMD 0x12
140 #define MEI_HBM_DMA_SETUP_RES_CMD 0x92
142 #define MEI_HBM_CAPABILITIES_REQ_CMD 0x13
143 #define MEI_HBM_CAPABILITIES_RES_CMD 0x93
145 #define MEI_HBM_CLIENT_DMA_MAP_REQ_CMD 0x14
146 #define MEI_HBM_CLIENT_DMA_MAP_RES_CMD 0x94
148 #define MEI_HBM_CLIENT_DMA_UNMAP_REQ_CMD 0x15
149 #define MEI_HBM_CLIENT_DMA_UNMAP_RES_CMD 0x95
153 * used by hbm_host_stop_request.reason
155 enum mei_stop_reason_types {
156 DRIVER_STOP_REQUEST = 0x00,
157 DEVICE_D1_ENTRY = 0x01,
158 DEVICE_D2_ENTRY = 0x02,
159 DEVICE_D3_ENTRY = 0x03,
160 SYSTEM_S1_ENTRY = 0x04,
161 SYSTEM_S2_ENTRY = 0x05,
162 SYSTEM_S3_ENTRY = 0x06,
163 SYSTEM_S4_ENTRY = 0x07,
164 SYSTEM_S5_ENTRY = 0x08
169 * enum mei_hbm_status - mei host bus messages return values
171 * @MEI_HBMS_SUCCESS : status success
172 * @MEI_HBMS_CLIENT_NOT_FOUND : client not found
173 * @MEI_HBMS_ALREADY_EXISTS : connection already established
174 * @MEI_HBMS_REJECTED : connection is rejected
175 * @MEI_HBMS_INVALID_PARAMETER : invalid parameter
176 * @MEI_HBMS_NOT_ALLOWED : operation not allowed
177 * @MEI_HBMS_ALREADY_STARTED : system is already started
178 * @MEI_HBMS_NOT_STARTED : system not started
180 * @MEI_HBMS_MAX : sentinel
182 enum mei_hbm_status {
183 MEI_HBMS_SUCCESS = 0,
184 MEI_HBMS_CLIENT_NOT_FOUND = 1,
185 MEI_HBMS_ALREADY_EXISTS = 2,
186 MEI_HBMS_REJECTED = 3,
187 MEI_HBMS_INVALID_PARAMETER = 4,
188 MEI_HBMS_NOT_ALLOWED = 5,
189 MEI_HBMS_ALREADY_STARTED = 6,
190 MEI_HBMS_NOT_STARTED = 7,
197 * Client Connect Status
198 * used by hbm_client_connect_response.status
200 enum mei_cl_connect_status {
201 MEI_CL_CONN_SUCCESS = MEI_HBMS_SUCCESS,
202 MEI_CL_CONN_NOT_FOUND = MEI_HBMS_CLIENT_NOT_FOUND,
203 MEI_CL_CONN_ALREADY_STARTED = MEI_HBMS_ALREADY_EXISTS,
204 MEI_CL_CONN_OUT_OF_RESOURCES = MEI_HBMS_REJECTED,
205 MEI_CL_CONN_MESSAGE_SMALL = MEI_HBMS_INVALID_PARAMETER,
206 MEI_CL_CONN_NOT_ALLOWED = MEI_HBMS_NOT_ALLOWED,
210 * Client Disconnect Status
212 enum mei_cl_disconnect_status {
213 MEI_CL_DISCONN_SUCCESS = MEI_HBMS_SUCCESS
217 * enum mei_ext_hdr_type - extended header type used in
218 * extended header TLV
220 * @MEI_EXT_HDR_NONE: sentinel
221 * @MEI_EXT_HDR_VTAG: vtag header
223 enum mei_ext_hdr_type {
224 MEI_EXT_HDR_NONE = 0,
225 MEI_EXT_HDR_VTAG = 1,
229 * struct mei_ext_hdr - extend header descriptor (TLV)
230 * @type: enum mei_ext_hdr_type
231 * @length: length excluding descriptor
232 * @ext_payload: payload of the specific extended header
233 * @hdr: place holder for actual header
242 * struct mei_ext_meta_hdr - extend header meta data
243 * @count: number of headers
244 * @size: total size of the extended header list excluding meta header
245 * @reserved: reserved
246 * @hdrs: extended headers TLV list
248 struct mei_ext_meta_hdr {
256 * struct mei_ext_hdr_vtag - extend header for vtag
258 * @hdr: standard extend header
260 * @reserved: reserved
262 struct mei_ext_hdr_vtag {
263 struct mei_ext_hdr hdr;
269 * Extended header iterator functions
272 * mei_ext_hdr - extended header iterator begin
274 * @meta: meta header of the extended header list
277 * The first extended header
279 static inline struct mei_ext_hdr *mei_ext_begin(struct mei_ext_meta_hdr *meta)
281 return (struct mei_ext_hdr *)meta->hdrs;
285 * mei_ext_last - check if the ext is the last one in the TLV list
287 * @meta: meta header of the extended header list
288 * @ext: a meta header on the list
290 * Return: true if ext is the last header on the list
292 static inline bool mei_ext_last(struct mei_ext_meta_hdr *meta,
293 struct mei_ext_hdr *ext)
295 return (u8 *)ext >= (u8 *)meta + sizeof(*meta) + (meta->size * 4);
299 * mei_ext_next - following extended header on the TLV list
301 * @ext: current extend header
303 * Context: The function does not check for the overflows,
304 * one should call mei_ext_last before.
306 * Return: The following extend header after @ext
308 static inline struct mei_ext_hdr *mei_ext_next(struct mei_ext_hdr *ext)
310 return (struct mei_ext_hdr *)((u8 *)ext + (ext->length * 4));
314 * struct mei_msg_hdr - MEI BUS Interface Section
316 * @me_addr: device address
317 * @host_addr: host address
318 * @length: message length
319 * @reserved: reserved
320 * @extended: message has extended header
321 * @dma_ring: message is on dma ring
322 * @internal: message is internal
323 * @msg_complete: last packet of the message
324 * @extension: extension of the header
338 /* The length is up to 9 bits */
339 #define MEI_MSG_MAX_LEN_MASK GENMASK(9, 0)
341 struct mei_bus_message {
347 * struct hbm_cl_cmd - client specific host bus command
348 * CONNECT, DISCONNECT, and FlOW CONTROL
350 * @hbm_cmd: bus message command header
351 * @me_addr: address of the client in ME
352 * @host_addr: address of the client in the driver
353 * @data: generic data
355 struct mei_hbm_cl_cmd {
367 struct hbm_host_version_request {
370 struct hbm_version host_version;
373 struct hbm_host_version_response {
375 u8 host_version_supported;
376 struct hbm_version me_max_version;
379 struct hbm_host_stop_request {
385 struct hbm_host_stop_response {
390 struct hbm_me_stop_request {
397 * enum hbm_host_enum_flags - enumeration request flags (HBM version >= 2.0)
399 * @MEI_HBM_ENUM_F_ALLOW_ADD: allow dynamic clients add
400 * @MEI_HBM_ENUM_F_IMMEDIATE_ENUM: allow FW to send answer immediately
402 enum hbm_host_enum_flags {
403 MEI_HBM_ENUM_F_ALLOW_ADD = BIT(0),
404 MEI_HBM_ENUM_F_IMMEDIATE_ENUM = BIT(1),
408 * struct hbm_host_enum_request - enumeration request from host to fw
410 * @hbm_cmd : bus message command header
411 * @flags : request flags
412 * @reserved: reserved
414 struct hbm_host_enum_request {
420 struct hbm_host_enum_response {
423 u8 valid_addresses[32];
427 * struct mei_client_properties - mei client properties
429 * @protocol_name: guid of the client
430 * @protocol_version: client protocol version
431 * @max_number_of_connections: number of possible connections.
432 * @fixed_address: fixed me address (0 if the client is dynamic)
433 * @single_recv_buf: 1 if all connections share a single receive buffer.
434 * @vt_supported: the client support vtag
435 * @reserved: reserved
436 * @max_msg_length: MTU of the client
438 struct mei_client_properties {
439 uuid_le protocol_name;
441 u8 max_number_of_connections;
443 u8 single_recv_buf:1;
449 struct hbm_props_request {
455 struct hbm_props_response {
460 struct mei_client_properties client_properties;
464 * struct hbm_add_client_request - request to add a client
465 * might be sent by fw after enumeration has already completed
467 * @hbm_cmd: bus message command header
468 * @me_addr: address of the client in ME
469 * @reserved: reserved
470 * @client_properties: client properties
472 struct hbm_add_client_request {
476 struct mei_client_properties client_properties;
480 * struct hbm_add_client_response - response to add a client
481 * sent by the host to report client addition status to fw
483 * @hbm_cmd: bus message command header
484 * @me_addr: address of the client in ME
485 * @status: if HBMS_SUCCESS then the client can now accept connections.
486 * @reserved: reserved
488 struct hbm_add_client_response {
496 * struct hbm_power_gate - power gate request/response
498 * @hbm_cmd: bus message command header
499 * @reserved: reserved
501 struct hbm_power_gate {
507 * struct hbm_client_connect_request - connect/disconnect request
509 * @hbm_cmd: bus message command header
510 * @me_addr: address of the client in ME
511 * @host_addr: address of the client in the driver
512 * @reserved: reserved
514 struct hbm_client_connect_request {
522 * struct hbm_client_connect_response - connect/disconnect response
524 * @hbm_cmd: bus message command header
525 * @me_addr: address of the client in ME
526 * @host_addr: address of the client in the driver
527 * @status: status of the request
529 struct hbm_client_connect_response {
537 #define MEI_FC_MESSAGE_RESERVED_LENGTH 5
539 struct hbm_flow_control {
543 u8 reserved[MEI_FC_MESSAGE_RESERVED_LENGTH];
546 #define MEI_HBM_NOTIFICATION_START 1
547 #define MEI_HBM_NOTIFICATION_STOP 0
549 * struct hbm_notification_request - start/stop notification request
551 * @hbm_cmd: bus message command header
552 * @me_addr: address of the client in ME
553 * @host_addr: address of the client in the driver
554 * @start: start = 1 or stop = 0 asynchronous notifications
556 struct hbm_notification_request {
564 * struct hbm_notification_response - start/stop notification response
566 * @hbm_cmd: bus message command header
567 * @me_addr: address of the client in ME
568 * @host_addr: - address of the client in the driver
569 * @status: (mei_hbm_status) response status for the request
570 * - MEI_HBMS_SUCCESS: successful stop/start
571 * - MEI_HBMS_CLIENT_NOT_FOUND: if the connection could not be found.
572 * - MEI_HBMS_ALREADY_STARTED: for start requests for a previously
573 * started notification.
574 * - MEI_HBMS_NOT_STARTED: for stop request for a connected client for whom
575 * asynchronous notifications are currently disabled.
577 * @start: start = 1 or stop = 0 asynchronous notifications
578 * @reserved: reserved
580 struct hbm_notification_response {
590 * struct hbm_notification - notification event
592 * @hbm_cmd: bus message command header
593 * @me_addr: address of the client in ME
594 * @host_addr: address of the client in the driver
595 * @reserved: reserved for alignment
597 struct hbm_notification {
605 * struct hbm_dma_mem_dscr - dma ring
607 * @addr_hi: the high 32bits of 64 bit address
608 * @addr_lo: the low 32bits of 64 bit address
609 * @size : size in bytes (must be power of 2)
611 struct hbm_dma_mem_dscr {
625 * struct hbm_dma_setup_request - dma setup request
627 * @hbm_cmd: bus message command header
628 * @reserved: reserved for alignment
629 * @dma_dscr: dma descriptor for HOST, DEVICE, and CTRL
631 struct hbm_dma_setup_request {
634 struct hbm_dma_mem_dscr dma_dscr[DMA_DSCR_NUM];
638 * struct hbm_dma_setup_response - dma setup response
640 * @hbm_cmd: bus message command header
641 * @status: 0 on success; otherwise DMA setup failed.
642 * @reserved: reserved for alignment
644 struct hbm_dma_setup_response {
651 * struct mei_dma_ring_ctrl - dma ring control block
653 * @hbuf_wr_idx: host circular buffer write index in slots
654 * @reserved1: reserved for alignment
655 * @hbuf_rd_idx: host circular buffer read index in slots
656 * @reserved2: reserved for alignment
657 * @dbuf_wr_idx: device circular buffer write index in slots
658 * @reserved3: reserved for alignment
659 * @dbuf_rd_idx: device circular buffer read index in slots
660 * @reserved4: reserved for alignment
662 struct hbm_dma_ring_ctrl {
673 /* virtual tag supported */
674 #define HBM_CAP_VT BIT(0)
675 /* client dma supported */
676 #define HBM_CAP_CD BIT(2)
679 * struct hbm_capability_request - capability request from host to fw
681 * @hbm_cmd : bus message command header
682 * @capability_requested: bitmask of capabilities requested by host
684 struct hbm_capability_request {
686 u8 capability_requested[3];
690 * struct hbm_capability_response - capability response from fw to host
692 * @hbm_cmd : bus message command header
693 * @capability_granted: bitmask of capabilities granted by FW
695 struct hbm_capability_response {
697 u8 capability_granted[3];
701 * struct hbm_client_dma_map_request - client dma map request from host to fw
703 * @hbm_cmd: bus message command header
704 * @client_buffer_id: client buffer id
705 * @reserved: reserved
706 * @address_lsb: DMA address LSB
707 * @address_msb: DMA address MSB
710 struct hbm_client_dma_map_request {
720 * struct hbm_client_dma_unmap_request
721 * client dma unmap request from the host to the firmware
723 * @hbm_cmd: bus message command header
724 * @status: unmap status
725 * @client_buffer_id: client buffer id
726 * @reserved: reserved
728 struct hbm_client_dma_unmap_request {
736 * struct hbm_client_dma_response
737 * client dma unmap response from the firmware to the host
739 * @hbm_cmd: bus message command header
740 * @status: command status
742 struct hbm_client_dma_response {