1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (c) 2003-2022, 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_CL_CONNECT_TIMEOUT_SLOW 30 /* HPS: Client Connect Timeout, slow FW */
20 #define MEI_CLIENTS_INIT_TIMEOUT 15 /* HPS: Clients Enumeration Timeout */
22 #define MEI_PGI_TIMEOUT 1 /* PG Isolation time response 1 sec */
23 #define MEI_D0I3_TIMEOUT 5 /* D0i3 set/unset max response time */
24 #define MEI_HBM_TIMEOUT 1 /* 1 second */
25 #define MEI_HBM_TIMEOUT_SLOW 5 /* 5 second, slow FW */
27 #define MKHI_RCV_TIMEOUT 500 /* receive timeout in msec */
28 #define MKHI_RCV_TIMEOUT_SLOW 10000 /* receive timeout in msec, slow FW */
31 * FW page size for DMA allocations
33 #define MEI_FW_PAGE_SIZE 4096UL
38 #define HBM_MINOR_VERSION 2
39 #define HBM_MAJOR_VERSION 2
42 * MEI version with PGI support
44 #define HBM_MINOR_VERSION_PGI 1
45 #define HBM_MAJOR_VERSION_PGI 1
48 * MEI version with Dynamic clients support
50 #define HBM_MINOR_VERSION_DC 0
51 #define HBM_MAJOR_VERSION_DC 2
54 * MEI version with immediate reply to enum request support
56 #define HBM_MINOR_VERSION_IE 0
57 #define HBM_MAJOR_VERSION_IE 2
60 * MEI version with disconnect on connection timeout support
62 #define HBM_MINOR_VERSION_DOT 0
63 #define HBM_MAJOR_VERSION_DOT 2
66 * MEI version with notification support
68 #define HBM_MINOR_VERSION_EV 0
69 #define HBM_MAJOR_VERSION_EV 2
72 * MEI version with fixed address client support
74 #define HBM_MINOR_VERSION_FA 0
75 #define HBM_MAJOR_VERSION_FA 2
78 * MEI version with OS ver message support
80 #define HBM_MINOR_VERSION_OS 0
81 #define HBM_MAJOR_VERSION_OS 2
84 * MEI version with dma ring support
86 #define HBM_MINOR_VERSION_DR 1
87 #define HBM_MAJOR_VERSION_DR 2
90 * MEI version with vm tag support
92 #define HBM_MINOR_VERSION_VT 2
93 #define HBM_MAJOR_VERSION_VT 2
96 * MEI version with capabilities message support
98 #define HBM_MINOR_VERSION_CAP 2
99 #define HBM_MAJOR_VERSION_CAP 2
102 * MEI version with client DMA support
104 #define HBM_MINOR_VERSION_CD 2
105 #define HBM_MAJOR_VERSION_CD 2
107 /* Host bus message command opcode */
108 #define MEI_HBM_CMD_OP_MSK 0x7f
109 /* Host bus message command RESPONSE */
110 #define MEI_HBM_CMD_RES_MSK 0x80
113 * MEI Bus Message Command IDs
115 #define HOST_START_REQ_CMD 0x01
116 #define HOST_START_RES_CMD 0x81
118 #define HOST_STOP_REQ_CMD 0x02
119 #define HOST_STOP_RES_CMD 0x82
121 #define ME_STOP_REQ_CMD 0x03
123 #define HOST_ENUM_REQ_CMD 0x04
124 #define HOST_ENUM_RES_CMD 0x84
126 #define HOST_CLIENT_PROPERTIES_REQ_CMD 0x05
127 #define HOST_CLIENT_PROPERTIES_RES_CMD 0x85
129 #define CLIENT_CONNECT_REQ_CMD 0x06
130 #define CLIENT_CONNECT_RES_CMD 0x86
132 #define CLIENT_DISCONNECT_REQ_CMD 0x07
133 #define CLIENT_DISCONNECT_RES_CMD 0x87
135 #define MEI_FLOW_CONTROL_CMD 0x08
137 #define MEI_PG_ISOLATION_ENTRY_REQ_CMD 0x0a
138 #define MEI_PG_ISOLATION_ENTRY_RES_CMD 0x8a
139 #define MEI_PG_ISOLATION_EXIT_REQ_CMD 0x0b
140 #define MEI_PG_ISOLATION_EXIT_RES_CMD 0x8b
142 #define MEI_HBM_ADD_CLIENT_REQ_CMD 0x0f
143 #define MEI_HBM_ADD_CLIENT_RES_CMD 0x8f
145 #define MEI_HBM_NOTIFY_REQ_CMD 0x10
146 #define MEI_HBM_NOTIFY_RES_CMD 0x90
147 #define MEI_HBM_NOTIFICATION_CMD 0x11
149 #define MEI_HBM_DMA_SETUP_REQ_CMD 0x12
150 #define MEI_HBM_DMA_SETUP_RES_CMD 0x92
152 #define MEI_HBM_CAPABILITIES_REQ_CMD 0x13
153 #define MEI_HBM_CAPABILITIES_RES_CMD 0x93
155 #define MEI_HBM_CLIENT_DMA_MAP_REQ_CMD 0x14
156 #define MEI_HBM_CLIENT_DMA_MAP_RES_CMD 0x94
158 #define MEI_HBM_CLIENT_DMA_UNMAP_REQ_CMD 0x15
159 #define MEI_HBM_CLIENT_DMA_UNMAP_RES_CMD 0x95
163 * used by hbm_host_stop_request.reason
165 enum mei_stop_reason_types {
166 DRIVER_STOP_REQUEST = 0x00,
167 DEVICE_D1_ENTRY = 0x01,
168 DEVICE_D2_ENTRY = 0x02,
169 DEVICE_D3_ENTRY = 0x03,
170 SYSTEM_S1_ENTRY = 0x04,
171 SYSTEM_S2_ENTRY = 0x05,
172 SYSTEM_S3_ENTRY = 0x06,
173 SYSTEM_S4_ENTRY = 0x07,
174 SYSTEM_S5_ENTRY = 0x08
179 * enum mei_hbm_status - mei host bus messages return values
181 * @MEI_HBMS_SUCCESS : status success
182 * @MEI_HBMS_CLIENT_NOT_FOUND : client not found
183 * @MEI_HBMS_ALREADY_EXISTS : connection already established
184 * @MEI_HBMS_REJECTED : connection is rejected
185 * @MEI_HBMS_INVALID_PARAMETER : invalid parameter
186 * @MEI_HBMS_NOT_ALLOWED : operation not allowed
187 * @MEI_HBMS_ALREADY_STARTED : system is already started
188 * @MEI_HBMS_NOT_STARTED : system not started
190 * @MEI_HBMS_MAX : sentinel
192 enum mei_hbm_status {
193 MEI_HBMS_SUCCESS = 0,
194 MEI_HBMS_CLIENT_NOT_FOUND = 1,
195 MEI_HBMS_ALREADY_EXISTS = 2,
196 MEI_HBMS_REJECTED = 3,
197 MEI_HBMS_INVALID_PARAMETER = 4,
198 MEI_HBMS_NOT_ALLOWED = 5,
199 MEI_HBMS_ALREADY_STARTED = 6,
200 MEI_HBMS_NOT_STARTED = 7,
207 * Client Connect Status
208 * used by hbm_client_connect_response.status
210 enum mei_cl_connect_status {
211 MEI_CL_CONN_SUCCESS = MEI_HBMS_SUCCESS,
212 MEI_CL_CONN_NOT_FOUND = MEI_HBMS_CLIENT_NOT_FOUND,
213 MEI_CL_CONN_ALREADY_STARTED = MEI_HBMS_ALREADY_EXISTS,
214 MEI_CL_CONN_OUT_OF_RESOURCES = MEI_HBMS_REJECTED,
215 MEI_CL_CONN_MESSAGE_SMALL = MEI_HBMS_INVALID_PARAMETER,
216 MEI_CL_CONN_NOT_ALLOWED = MEI_HBMS_NOT_ALLOWED,
220 * Client Disconnect Status
222 enum mei_cl_disconnect_status {
223 MEI_CL_DISCONN_SUCCESS = MEI_HBMS_SUCCESS
227 * enum mei_ext_hdr_type - extended header type used in
228 * extended header TLV
230 * @MEI_EXT_HDR_NONE: sentinel
231 * @MEI_EXT_HDR_VTAG: vtag header
233 enum mei_ext_hdr_type {
234 MEI_EXT_HDR_NONE = 0,
235 MEI_EXT_HDR_VTAG = 1,
239 * struct mei_ext_hdr - extend header descriptor (TLV)
240 * @type: enum mei_ext_hdr_type
241 * @length: length excluding descriptor
242 * @ext_payload: payload of the specific extended header
243 * @hdr: place holder for actual header
252 * struct mei_ext_meta_hdr - extend header meta data
253 * @count: number of headers
254 * @size: total size of the extended header list excluding meta header
255 * @reserved: reserved
256 * @hdrs: extended headers TLV list
258 struct mei_ext_meta_hdr {
266 * struct mei_ext_hdr_vtag - extend header for vtag
268 * @hdr: standard extend header
270 * @reserved: reserved
272 struct mei_ext_hdr_vtag {
273 struct mei_ext_hdr hdr;
279 * Extended header iterator functions
282 * mei_ext_hdr - extended header iterator begin
284 * @meta: meta header of the extended header list
287 * The first extended header
289 static inline struct mei_ext_hdr *mei_ext_begin(struct mei_ext_meta_hdr *meta)
291 return (struct mei_ext_hdr *)meta->hdrs;
295 * mei_ext_last - check if the ext is the last one in the TLV list
297 * @meta: meta header of the extended header list
298 * @ext: a meta header on the list
300 * Return: true if ext is the last header on the list
302 static inline bool mei_ext_last(struct mei_ext_meta_hdr *meta,
303 struct mei_ext_hdr *ext)
305 return (u8 *)ext >= (u8 *)meta + sizeof(*meta) + (meta->size * 4);
309 * mei_ext_next - following extended header on the TLV list
311 * @ext: current extend header
313 * Context: The function does not check for the overflows,
314 * one should call mei_ext_last before.
316 * Return: The following extend header after @ext
318 static inline struct mei_ext_hdr *mei_ext_next(struct mei_ext_hdr *ext)
320 return (struct mei_ext_hdr *)((u8 *)ext + (ext->length * 4));
324 * struct mei_msg_hdr - MEI BUS Interface Section
326 * @me_addr: device address
327 * @host_addr: host address
328 * @length: message length
329 * @reserved: reserved
330 * @extended: message has extended header
331 * @dma_ring: message is on dma ring
332 * @internal: message is internal
333 * @msg_complete: last packet of the message
334 * @extension: extension of the header
348 /* The length is up to 9 bits */
349 #define MEI_MSG_MAX_LEN_MASK GENMASK(9, 0)
351 struct mei_bus_message {
357 * struct hbm_cl_cmd - client specific host bus command
358 * CONNECT, DISCONNECT, and FlOW CONTROL
360 * @hbm_cmd: bus message command header
361 * @me_addr: address of the client in ME
362 * @host_addr: address of the client in the driver
363 * @data: generic data
365 struct mei_hbm_cl_cmd {
377 struct hbm_host_version_request {
380 struct hbm_version host_version;
383 struct hbm_host_version_response {
385 u8 host_version_supported;
386 struct hbm_version me_max_version;
389 struct hbm_host_stop_request {
395 struct hbm_host_stop_response {
400 struct hbm_me_stop_request {
407 * enum hbm_host_enum_flags - enumeration request flags (HBM version >= 2.0)
409 * @MEI_HBM_ENUM_F_ALLOW_ADD: allow dynamic clients add
410 * @MEI_HBM_ENUM_F_IMMEDIATE_ENUM: allow FW to send answer immediately
412 enum hbm_host_enum_flags {
413 MEI_HBM_ENUM_F_ALLOW_ADD = BIT(0),
414 MEI_HBM_ENUM_F_IMMEDIATE_ENUM = BIT(1),
418 * struct hbm_host_enum_request - enumeration request from host to fw
420 * @hbm_cmd : bus message command header
421 * @flags : request flags
422 * @reserved: reserved
424 struct hbm_host_enum_request {
430 struct hbm_host_enum_response {
433 u8 valid_addresses[32];
437 * struct mei_client_properties - mei client properties
439 * @protocol_name: guid of the client
440 * @protocol_version: client protocol version
441 * @max_number_of_connections: number of possible connections.
442 * @fixed_address: fixed me address (0 if the client is dynamic)
443 * @single_recv_buf: 1 if all connections share a single receive buffer.
444 * @vt_supported: the client support vtag
445 * @reserved: reserved
446 * @max_msg_length: MTU of the client
448 struct mei_client_properties {
449 uuid_le protocol_name;
451 u8 max_number_of_connections;
453 u8 single_recv_buf:1;
459 struct hbm_props_request {
465 struct hbm_props_response {
470 struct mei_client_properties client_properties;
474 * struct hbm_add_client_request - request to add a client
475 * might be sent by fw after enumeration has already completed
477 * @hbm_cmd: bus message command header
478 * @me_addr: address of the client in ME
479 * @reserved: reserved
480 * @client_properties: client properties
482 struct hbm_add_client_request {
486 struct mei_client_properties client_properties;
490 * struct hbm_add_client_response - response to add a client
491 * sent by the host to report client addition status to fw
493 * @hbm_cmd: bus message command header
494 * @me_addr: address of the client in ME
495 * @status: if HBMS_SUCCESS then the client can now accept connections.
496 * @reserved: reserved
498 struct hbm_add_client_response {
506 * struct hbm_power_gate - power gate request/response
508 * @hbm_cmd: bus message command header
509 * @reserved: reserved
511 struct hbm_power_gate {
517 * struct hbm_client_connect_request - connect/disconnect request
519 * @hbm_cmd: bus message command header
520 * @me_addr: address of the client in ME
521 * @host_addr: address of the client in the driver
522 * @reserved: reserved
524 struct hbm_client_connect_request {
532 * struct hbm_client_connect_response - connect/disconnect response
534 * @hbm_cmd: bus message command header
535 * @me_addr: address of the client in ME
536 * @host_addr: address of the client in the driver
537 * @status: status of the request
539 struct hbm_client_connect_response {
547 #define MEI_FC_MESSAGE_RESERVED_LENGTH 5
549 struct hbm_flow_control {
553 u8 reserved[MEI_FC_MESSAGE_RESERVED_LENGTH];
556 #define MEI_HBM_NOTIFICATION_START 1
557 #define MEI_HBM_NOTIFICATION_STOP 0
559 * struct hbm_notification_request - start/stop notification request
561 * @hbm_cmd: bus message command header
562 * @me_addr: address of the client in ME
563 * @host_addr: address of the client in the driver
564 * @start: start = 1 or stop = 0 asynchronous notifications
566 struct hbm_notification_request {
574 * struct hbm_notification_response - start/stop notification response
576 * @hbm_cmd: bus message command header
577 * @me_addr: address of the client in ME
578 * @host_addr: - address of the client in the driver
579 * @status: (mei_hbm_status) response status for the request
580 * - MEI_HBMS_SUCCESS: successful stop/start
581 * - MEI_HBMS_CLIENT_NOT_FOUND: if the connection could not be found.
582 * - MEI_HBMS_ALREADY_STARTED: for start requests for a previously
583 * started notification.
584 * - MEI_HBMS_NOT_STARTED: for stop request for a connected client for whom
585 * asynchronous notifications are currently disabled.
587 * @start: start = 1 or stop = 0 asynchronous notifications
588 * @reserved: reserved
590 struct hbm_notification_response {
600 * struct hbm_notification - notification event
602 * @hbm_cmd: bus message command header
603 * @me_addr: address of the client in ME
604 * @host_addr: address of the client in the driver
605 * @reserved: reserved for alignment
607 struct hbm_notification {
615 * struct hbm_dma_mem_dscr - dma ring
617 * @addr_hi: the high 32bits of 64 bit address
618 * @addr_lo: the low 32bits of 64 bit address
619 * @size : size in bytes (must be power of 2)
621 struct hbm_dma_mem_dscr {
635 * struct hbm_dma_setup_request - dma setup request
637 * @hbm_cmd: bus message command header
638 * @reserved: reserved for alignment
639 * @dma_dscr: dma descriptor for HOST, DEVICE, and CTRL
641 struct hbm_dma_setup_request {
644 struct hbm_dma_mem_dscr dma_dscr[DMA_DSCR_NUM];
648 * struct hbm_dma_setup_response - dma setup response
650 * @hbm_cmd: bus message command header
651 * @status: 0 on success; otherwise DMA setup failed.
652 * @reserved: reserved for alignment
654 struct hbm_dma_setup_response {
661 * struct mei_dma_ring_ctrl - dma ring control block
663 * @hbuf_wr_idx: host circular buffer write index in slots
664 * @reserved1: reserved for alignment
665 * @hbuf_rd_idx: host circular buffer read index in slots
666 * @reserved2: reserved for alignment
667 * @dbuf_wr_idx: device circular buffer write index in slots
668 * @reserved3: reserved for alignment
669 * @dbuf_rd_idx: device circular buffer read index in slots
670 * @reserved4: reserved for alignment
672 struct hbm_dma_ring_ctrl {
683 /* virtual tag supported */
684 #define HBM_CAP_VT BIT(0)
685 /* client dma supported */
686 #define HBM_CAP_CD BIT(2)
689 * struct hbm_capability_request - capability request from host to fw
691 * @hbm_cmd : bus message command header
692 * @capability_requested: bitmask of capabilities requested by host
694 struct hbm_capability_request {
696 u8 capability_requested[3];
700 * struct hbm_capability_response - capability response from fw to host
702 * @hbm_cmd : bus message command header
703 * @capability_granted: bitmask of capabilities granted by FW
705 struct hbm_capability_response {
707 u8 capability_granted[3];
711 * struct hbm_client_dma_map_request - client dma map request from host to fw
713 * @hbm_cmd: bus message command header
714 * @client_buffer_id: client buffer id
715 * @reserved: reserved
716 * @address_lsb: DMA address LSB
717 * @address_msb: DMA address MSB
720 struct hbm_client_dma_map_request {
730 * struct hbm_client_dma_unmap_request
731 * client dma unmap request from the host to the firmware
733 * @hbm_cmd: bus message command header
734 * @status: unmap status
735 * @client_buffer_id: client buffer id
736 * @reserved: reserved
738 struct hbm_client_dma_unmap_request {
746 * struct hbm_client_dma_response
747 * client dma unmap response from the firmware to the host
749 * @hbm_cmd: bus message command header
750 * @status: command status
752 struct hbm_client_dma_response {