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
243 * struct mei_ext_meta_hdr - extend header meta data
244 * @count: number of headers
245 * @size: total size of the extended header list excluding meta header
246 * @reserved: reserved
247 * @hdrs: extended headers TLV list
249 struct mei_ext_meta_hdr {
253 struct mei_ext_hdr hdrs[];
257 * Extended header iterator functions
260 * mei_ext_hdr - extended header iterator begin
262 * @meta: meta header of the extended header list
265 * The first extended header
267 static inline struct mei_ext_hdr *mei_ext_begin(struct mei_ext_meta_hdr *meta)
273 * mei_ext_last - check if the ext is the last one in the TLV list
275 * @meta: meta header of the extended header list
276 * @ext: a meta header on the list
278 * Return: true if ext is the last header on the list
280 static inline bool mei_ext_last(struct mei_ext_meta_hdr *meta,
281 struct mei_ext_hdr *ext)
283 return (u8 *)ext >= (u8 *)meta + sizeof(*meta) + (meta->size * 4);
287 *mei_ext_next - following extended header on the TLV list
289 * @ext: current extend header
291 * Context: The function does not check for the overflows,
292 * one should call mei_ext_last before.
294 * Return: The following extend header after @ext
296 static inline struct mei_ext_hdr *mei_ext_next(struct mei_ext_hdr *ext)
298 return (struct mei_ext_hdr *)(ext->hdr + (ext->length * 4));
302 * struct mei_msg_hdr - MEI BUS Interface Section
304 * @me_addr: device address
305 * @host_addr: host address
306 * @length: message length
307 * @reserved: reserved
308 * @extended: message has extended header
309 * @dma_ring: message is on dma ring
310 * @internal: message is internal
311 * @msg_complete: last packet of the message
312 * @extension: extension of the header
326 /* The length is up to 9 bits */
327 #define MEI_MSG_MAX_LEN_MASK GENMASK(9, 0)
329 struct mei_bus_message {
335 * struct hbm_cl_cmd - client specific host bus command
336 * CONNECT, DISCONNECT, and FlOW CONTROL
338 * @hbm_cmd: bus message command header
339 * @me_addr: address of the client in ME
340 * @host_addr: address of the client in the driver
341 * @data: generic data
343 struct mei_hbm_cl_cmd {
355 struct hbm_host_version_request {
358 struct hbm_version host_version;
361 struct hbm_host_version_response {
363 u8 host_version_supported;
364 struct hbm_version me_max_version;
367 struct hbm_host_stop_request {
373 struct hbm_host_stop_response {
378 struct hbm_me_stop_request {
385 * enum hbm_host_enum_flags - enumeration request flags (HBM version >= 2.0)
387 * @MEI_HBM_ENUM_F_ALLOW_ADD: allow dynamic clients add
388 * @MEI_HBM_ENUM_F_IMMEDIATE_ENUM: allow FW to send answer immediately
390 enum hbm_host_enum_flags {
391 MEI_HBM_ENUM_F_ALLOW_ADD = BIT(0),
392 MEI_HBM_ENUM_F_IMMEDIATE_ENUM = BIT(1),
396 * struct hbm_host_enum_request - enumeration request from host to fw
398 * @hbm_cmd : bus message command header
399 * @flags : request flags
400 * @reserved: reserved
402 struct hbm_host_enum_request {
408 struct hbm_host_enum_response {
411 u8 valid_addresses[32];
415 * struct mei_client_properties - mei client properties
417 * @protocol_name: guid of the client
418 * @protocol_version: client protocol version
419 * @max_number_of_connections: number of possible connections.
420 * @fixed_address: fixed me address (0 if the client is dynamic)
421 * @single_recv_buf: 1 if all connections share a single receive buffer.
422 * @vt_supported: the client support vtag
423 * @reserved: reserved
424 * @max_msg_length: MTU of the client
426 struct mei_client_properties {
427 uuid_le protocol_name;
429 u8 max_number_of_connections;
431 u8 single_recv_buf:1;
437 struct hbm_props_request {
443 struct hbm_props_response {
448 struct mei_client_properties client_properties;
452 * struct hbm_add_client_request - request to add a client
453 * might be sent by fw after enumeration has already completed
455 * @hbm_cmd: bus message command header
456 * @me_addr: address of the client in ME
457 * @reserved: reserved
458 * @client_properties: client properties
460 struct hbm_add_client_request {
464 struct mei_client_properties client_properties;
468 * struct hbm_add_client_response - response to add a client
469 * sent by the host to report client addition status to fw
471 * @hbm_cmd: bus message command header
472 * @me_addr: address of the client in ME
473 * @status: if HBMS_SUCCESS then the client can now accept connections.
474 * @reserved: reserved
476 struct hbm_add_client_response {
484 * struct hbm_power_gate - power gate request/response
486 * @hbm_cmd: bus message command header
487 * @reserved: reserved
489 struct hbm_power_gate {
495 * struct hbm_client_connect_request - connect/disconnect request
497 * @hbm_cmd: bus message command header
498 * @me_addr: address of the client in ME
499 * @host_addr: address of the client in the driver
500 * @reserved: reserved
502 struct hbm_client_connect_request {
510 * struct hbm_client_connect_response - connect/disconnect response
512 * @hbm_cmd: bus message command header
513 * @me_addr: address of the client in ME
514 * @host_addr: address of the client in the driver
515 * @status: status of the request
517 struct hbm_client_connect_response {
525 #define MEI_FC_MESSAGE_RESERVED_LENGTH 5
527 struct hbm_flow_control {
531 u8 reserved[MEI_FC_MESSAGE_RESERVED_LENGTH];
534 #define MEI_HBM_NOTIFICATION_START 1
535 #define MEI_HBM_NOTIFICATION_STOP 0
537 * struct hbm_notification_request - start/stop notification request
539 * @hbm_cmd: bus message command header
540 * @me_addr: address of the client in ME
541 * @host_addr: address of the client in the driver
542 * @start: start = 1 or stop = 0 asynchronous notifications
544 struct hbm_notification_request {
552 * struct hbm_notification_response - start/stop notification response
554 * @hbm_cmd: bus message command header
555 * @me_addr: address of the client in ME
556 * @host_addr: - address of the client in the driver
557 * @status: (mei_hbm_status) response status for the request
558 * - MEI_HBMS_SUCCESS: successful stop/start
559 * - MEI_HBMS_CLIENT_NOT_FOUND: if the connection could not be found.
560 * - MEI_HBMS_ALREADY_STARTED: for start requests for a previously
561 * started notification.
562 * - MEI_HBMS_NOT_STARTED: for stop request for a connected client for whom
563 * asynchronous notifications are currently disabled.
565 * @start: start = 1 or stop = 0 asynchronous notifications
566 * @reserved: reserved
568 struct hbm_notification_response {
578 * struct hbm_notification - notification event
580 * @hbm_cmd: bus message command header
581 * @me_addr: address of the client in ME
582 * @host_addr: address of the client in the driver
583 * @reserved: reserved for alignment
585 struct hbm_notification {
593 * struct hbm_dma_mem_dscr - dma ring
595 * @addr_hi: the high 32bits of 64 bit address
596 * @addr_lo: the low 32bits of 64 bit address
597 * @size : size in bytes (must be power of 2)
599 struct hbm_dma_mem_dscr {
613 * struct hbm_dma_setup_request - dma setup request
615 * @hbm_cmd: bus message command header
616 * @reserved: reserved for alignment
617 * @dma_dscr: dma descriptor for HOST, DEVICE, and CTRL
619 struct hbm_dma_setup_request {
622 struct hbm_dma_mem_dscr dma_dscr[DMA_DSCR_NUM];
626 * struct hbm_dma_setup_response - dma setup response
628 * @hbm_cmd: bus message command header
629 * @status: 0 on success; otherwise DMA setup failed.
630 * @reserved: reserved for alignment
632 struct hbm_dma_setup_response {
639 * struct mei_dma_ring_ctrl - dma ring control block
641 * @hbuf_wr_idx: host circular buffer write index in slots
642 * @reserved1: reserved for alignment
643 * @hbuf_rd_idx: host circular buffer read index in slots
644 * @reserved2: reserved for alignment
645 * @dbuf_wr_idx: device circular buffer write index in slots
646 * @reserved3: reserved for alignment
647 * @dbuf_rd_idx: device circular buffer read index in slots
648 * @reserved4: reserved for alignment
650 struct hbm_dma_ring_ctrl {
661 /* virtual tag supported */
662 #define HBM_CAP_VT BIT(0)
663 /* client dma supported */
664 #define HBM_CAP_CD BIT(2)
667 * struct hbm_capability_request - capability request from host to fw
669 * @hbm_cmd : bus message command header
670 * @capability_requested: bitmask of capabilities requested by host
672 struct hbm_capability_request {
674 u8 capability_requested[3];
678 * struct hbm_capability_response - capability response from fw to host
680 * @hbm_cmd : bus message command header
681 * @capability_granted: bitmask of capabilities granted by FW
683 struct hbm_capability_response {
685 u8 capability_granted[3];
689 * struct hbm_client_dma_map_request - client dma map request from host to fw
691 * @hbm_cmd: bus message command header
692 * @client_buffer_id: client buffer id
693 * @reserved: reserved
694 * @address_lsb: DMA address LSB
695 * @address_msb: DMA address MSB
698 struct hbm_client_dma_map_request {
708 * struct hbm_client_dma_unmap_request
709 * client dma unmap request from the host to the firmware
711 * @hbm_cmd: bus message command header
712 * @status: unmap status
713 * @client_buffer_id: client buffer id
714 * @reserved: reserved
716 struct hbm_client_dma_unmap_request {
724 * struct hbm_client_dma_response
725 * client dma unmap response from the firmware to the host
727 * @hbm_cmd: bus message command header
728 * @status: command status
730 struct hbm_client_dma_response {