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 */
26 * FW page size for DMA allocations
28 #define MEI_FW_PAGE_SIZE 4096UL
33 #define HBM_MINOR_VERSION 2
34 #define HBM_MAJOR_VERSION 2
37 * MEI version with PGI support
39 #define HBM_MINOR_VERSION_PGI 1
40 #define HBM_MAJOR_VERSION_PGI 1
43 * MEI version with Dynamic clients support
45 #define HBM_MINOR_VERSION_DC 0
46 #define HBM_MAJOR_VERSION_DC 2
49 * MEI version with immediate reply to enum request support
51 #define HBM_MINOR_VERSION_IE 0
52 #define HBM_MAJOR_VERSION_IE 2
55 * MEI version with disconnect on connection timeout support
57 #define HBM_MINOR_VERSION_DOT 0
58 #define HBM_MAJOR_VERSION_DOT 2
61 * MEI version with notification support
63 #define HBM_MINOR_VERSION_EV 0
64 #define HBM_MAJOR_VERSION_EV 2
67 * MEI version with fixed address client support
69 #define HBM_MINOR_VERSION_FA 0
70 #define HBM_MAJOR_VERSION_FA 2
73 * MEI version with OS ver message support
75 #define HBM_MINOR_VERSION_OS 0
76 #define HBM_MAJOR_VERSION_OS 2
79 * MEI version with dma ring support
81 #define HBM_MINOR_VERSION_DR 1
82 #define HBM_MAJOR_VERSION_DR 2
85 * MEI version with vm tag support
87 #define HBM_MINOR_VERSION_VT 2
88 #define HBM_MAJOR_VERSION_VT 2
91 * MEI version with capabilities message support
93 #define HBM_MINOR_VERSION_CAP 2
94 #define HBM_MAJOR_VERSION_CAP 2
97 * MEI version with client DMA support
99 #define HBM_MINOR_VERSION_CD 2
100 #define HBM_MAJOR_VERSION_CD 2
102 /* Host bus message command opcode */
103 #define MEI_HBM_CMD_OP_MSK 0x7f
104 /* Host bus message command RESPONSE */
105 #define MEI_HBM_CMD_RES_MSK 0x80
108 * MEI Bus Message Command IDs
110 #define HOST_START_REQ_CMD 0x01
111 #define HOST_START_RES_CMD 0x81
113 #define HOST_STOP_REQ_CMD 0x02
114 #define HOST_STOP_RES_CMD 0x82
116 #define ME_STOP_REQ_CMD 0x03
118 #define HOST_ENUM_REQ_CMD 0x04
119 #define HOST_ENUM_RES_CMD 0x84
121 #define HOST_CLIENT_PROPERTIES_REQ_CMD 0x05
122 #define HOST_CLIENT_PROPERTIES_RES_CMD 0x85
124 #define CLIENT_CONNECT_REQ_CMD 0x06
125 #define CLIENT_CONNECT_RES_CMD 0x86
127 #define CLIENT_DISCONNECT_REQ_CMD 0x07
128 #define CLIENT_DISCONNECT_RES_CMD 0x87
130 #define MEI_FLOW_CONTROL_CMD 0x08
132 #define MEI_PG_ISOLATION_ENTRY_REQ_CMD 0x0a
133 #define MEI_PG_ISOLATION_ENTRY_RES_CMD 0x8a
134 #define MEI_PG_ISOLATION_EXIT_REQ_CMD 0x0b
135 #define MEI_PG_ISOLATION_EXIT_RES_CMD 0x8b
137 #define MEI_HBM_ADD_CLIENT_REQ_CMD 0x0f
138 #define MEI_HBM_ADD_CLIENT_RES_CMD 0x8f
140 #define MEI_HBM_NOTIFY_REQ_CMD 0x10
141 #define MEI_HBM_NOTIFY_RES_CMD 0x90
142 #define MEI_HBM_NOTIFICATION_CMD 0x11
144 #define MEI_HBM_DMA_SETUP_REQ_CMD 0x12
145 #define MEI_HBM_DMA_SETUP_RES_CMD 0x92
147 #define MEI_HBM_CAPABILITIES_REQ_CMD 0x13
148 #define MEI_HBM_CAPABILITIES_RES_CMD 0x93
150 #define MEI_HBM_CLIENT_DMA_MAP_REQ_CMD 0x14
151 #define MEI_HBM_CLIENT_DMA_MAP_RES_CMD 0x94
153 #define MEI_HBM_CLIENT_DMA_UNMAP_REQ_CMD 0x15
154 #define MEI_HBM_CLIENT_DMA_UNMAP_RES_CMD 0x95
158 * used by hbm_host_stop_request.reason
160 enum mei_stop_reason_types {
161 DRIVER_STOP_REQUEST = 0x00,
162 DEVICE_D1_ENTRY = 0x01,
163 DEVICE_D2_ENTRY = 0x02,
164 DEVICE_D3_ENTRY = 0x03,
165 SYSTEM_S1_ENTRY = 0x04,
166 SYSTEM_S2_ENTRY = 0x05,
167 SYSTEM_S3_ENTRY = 0x06,
168 SYSTEM_S4_ENTRY = 0x07,
169 SYSTEM_S5_ENTRY = 0x08
174 * enum mei_hbm_status - mei host bus messages return values
176 * @MEI_HBMS_SUCCESS : status success
177 * @MEI_HBMS_CLIENT_NOT_FOUND : client not found
178 * @MEI_HBMS_ALREADY_EXISTS : connection already established
179 * @MEI_HBMS_REJECTED : connection is rejected
180 * @MEI_HBMS_INVALID_PARAMETER : invalid parameter
181 * @MEI_HBMS_NOT_ALLOWED : operation not allowed
182 * @MEI_HBMS_ALREADY_STARTED : system is already started
183 * @MEI_HBMS_NOT_STARTED : system not started
185 * @MEI_HBMS_MAX : sentinel
187 enum mei_hbm_status {
188 MEI_HBMS_SUCCESS = 0,
189 MEI_HBMS_CLIENT_NOT_FOUND = 1,
190 MEI_HBMS_ALREADY_EXISTS = 2,
191 MEI_HBMS_REJECTED = 3,
192 MEI_HBMS_INVALID_PARAMETER = 4,
193 MEI_HBMS_NOT_ALLOWED = 5,
194 MEI_HBMS_ALREADY_STARTED = 6,
195 MEI_HBMS_NOT_STARTED = 7,
202 * Client Connect Status
203 * used by hbm_client_connect_response.status
205 enum mei_cl_connect_status {
206 MEI_CL_CONN_SUCCESS = MEI_HBMS_SUCCESS,
207 MEI_CL_CONN_NOT_FOUND = MEI_HBMS_CLIENT_NOT_FOUND,
208 MEI_CL_CONN_ALREADY_STARTED = MEI_HBMS_ALREADY_EXISTS,
209 MEI_CL_CONN_OUT_OF_RESOURCES = MEI_HBMS_REJECTED,
210 MEI_CL_CONN_MESSAGE_SMALL = MEI_HBMS_INVALID_PARAMETER,
211 MEI_CL_CONN_NOT_ALLOWED = MEI_HBMS_NOT_ALLOWED,
215 * Client Disconnect Status
217 enum mei_cl_disconnect_status {
218 MEI_CL_DISCONN_SUCCESS = MEI_HBMS_SUCCESS
222 * enum mei_ext_hdr_type - extended header type used in
223 * extended header TLV
225 * @MEI_EXT_HDR_NONE: sentinel
226 * @MEI_EXT_HDR_VTAG: vtag header
228 enum mei_ext_hdr_type {
229 MEI_EXT_HDR_NONE = 0,
230 MEI_EXT_HDR_VTAG = 1,
234 * struct mei_ext_hdr - extend header descriptor (TLV)
235 * @type: enum mei_ext_hdr_type
236 * @length: length excluding descriptor
237 * @ext_payload: payload of the specific extended header
238 * @hdr: place holder for actual header
247 * struct mei_ext_meta_hdr - extend header meta data
248 * @count: number of headers
249 * @size: total size of the extended header list excluding meta header
250 * @reserved: reserved
251 * @hdrs: extended headers TLV list
253 struct mei_ext_meta_hdr {
261 * struct mei_ext_hdr_vtag - extend header for vtag
263 * @hdr: standard extend header
265 * @reserved: reserved
267 struct mei_ext_hdr_vtag {
268 struct mei_ext_hdr hdr;
274 * Extended header iterator functions
277 * mei_ext_hdr - extended header iterator begin
279 * @meta: meta header of the extended header list
282 * The first extended header
284 static inline struct mei_ext_hdr *mei_ext_begin(struct mei_ext_meta_hdr *meta)
286 return (struct mei_ext_hdr *)meta->hdrs;
290 * mei_ext_last - check if the ext is the last one in the TLV list
292 * @meta: meta header of the extended header list
293 * @ext: a meta header on the list
295 * Return: true if ext is the last header on the list
297 static inline bool mei_ext_last(struct mei_ext_meta_hdr *meta,
298 struct mei_ext_hdr *ext)
300 return (u8 *)ext >= (u8 *)meta + sizeof(*meta) + (meta->size * 4);
304 * mei_ext_next - following extended header on the TLV list
306 * @ext: current extend header
308 * Context: The function does not check for the overflows,
309 * one should call mei_ext_last before.
311 * Return: The following extend header after @ext
313 static inline struct mei_ext_hdr *mei_ext_next(struct mei_ext_hdr *ext)
315 return (struct mei_ext_hdr *)((u8 *)ext + (ext->length * 4));
319 * struct mei_msg_hdr - MEI BUS Interface Section
321 * @me_addr: device address
322 * @host_addr: host address
323 * @length: message length
324 * @reserved: reserved
325 * @extended: message has extended header
326 * @dma_ring: message is on dma ring
327 * @internal: message is internal
328 * @msg_complete: last packet of the message
329 * @extension: extension of the header
343 /* The length is up to 9 bits */
344 #define MEI_MSG_MAX_LEN_MASK GENMASK(9, 0)
346 struct mei_bus_message {
352 * struct hbm_cl_cmd - client specific host bus command
353 * CONNECT, DISCONNECT, and FlOW CONTROL
355 * @hbm_cmd: bus message command header
356 * @me_addr: address of the client in ME
357 * @host_addr: address of the client in the driver
358 * @data: generic data
360 struct mei_hbm_cl_cmd {
372 struct hbm_host_version_request {
375 struct hbm_version host_version;
378 struct hbm_host_version_response {
380 u8 host_version_supported;
381 struct hbm_version me_max_version;
384 struct hbm_host_stop_request {
390 struct hbm_host_stop_response {
395 struct hbm_me_stop_request {
402 * enum hbm_host_enum_flags - enumeration request flags (HBM version >= 2.0)
404 * @MEI_HBM_ENUM_F_ALLOW_ADD: allow dynamic clients add
405 * @MEI_HBM_ENUM_F_IMMEDIATE_ENUM: allow FW to send answer immediately
407 enum hbm_host_enum_flags {
408 MEI_HBM_ENUM_F_ALLOW_ADD = BIT(0),
409 MEI_HBM_ENUM_F_IMMEDIATE_ENUM = BIT(1),
413 * struct hbm_host_enum_request - enumeration request from host to fw
415 * @hbm_cmd : bus message command header
416 * @flags : request flags
417 * @reserved: reserved
419 struct hbm_host_enum_request {
425 struct hbm_host_enum_response {
428 u8 valid_addresses[32];
432 * struct mei_client_properties - mei client properties
434 * @protocol_name: guid of the client
435 * @protocol_version: client protocol version
436 * @max_number_of_connections: number of possible connections.
437 * @fixed_address: fixed me address (0 if the client is dynamic)
438 * @single_recv_buf: 1 if all connections share a single receive buffer.
439 * @vt_supported: the client support vtag
440 * @reserved: reserved
441 * @max_msg_length: MTU of the client
443 struct mei_client_properties {
444 uuid_le protocol_name;
446 u8 max_number_of_connections;
448 u8 single_recv_buf:1;
454 struct hbm_props_request {
460 struct hbm_props_response {
465 struct mei_client_properties client_properties;
469 * struct hbm_add_client_request - request to add a client
470 * might be sent by fw after enumeration has already completed
472 * @hbm_cmd: bus message command header
473 * @me_addr: address of the client in ME
474 * @reserved: reserved
475 * @client_properties: client properties
477 struct hbm_add_client_request {
481 struct mei_client_properties client_properties;
485 * struct hbm_add_client_response - response to add a client
486 * sent by the host to report client addition status to fw
488 * @hbm_cmd: bus message command header
489 * @me_addr: address of the client in ME
490 * @status: if HBMS_SUCCESS then the client can now accept connections.
491 * @reserved: reserved
493 struct hbm_add_client_response {
501 * struct hbm_power_gate - power gate request/response
503 * @hbm_cmd: bus message command header
504 * @reserved: reserved
506 struct hbm_power_gate {
512 * struct hbm_client_connect_request - connect/disconnect request
514 * @hbm_cmd: bus message command header
515 * @me_addr: address of the client in ME
516 * @host_addr: address of the client in the driver
517 * @reserved: reserved
519 struct hbm_client_connect_request {
527 * struct hbm_client_connect_response - connect/disconnect response
529 * @hbm_cmd: bus message command header
530 * @me_addr: address of the client in ME
531 * @host_addr: address of the client in the driver
532 * @status: status of the request
534 struct hbm_client_connect_response {
542 #define MEI_FC_MESSAGE_RESERVED_LENGTH 5
544 struct hbm_flow_control {
548 u8 reserved[MEI_FC_MESSAGE_RESERVED_LENGTH];
551 #define MEI_HBM_NOTIFICATION_START 1
552 #define MEI_HBM_NOTIFICATION_STOP 0
554 * struct hbm_notification_request - start/stop notification request
556 * @hbm_cmd: bus message command header
557 * @me_addr: address of the client in ME
558 * @host_addr: address of the client in the driver
559 * @start: start = 1 or stop = 0 asynchronous notifications
561 struct hbm_notification_request {
569 * struct hbm_notification_response - start/stop notification response
571 * @hbm_cmd: bus message command header
572 * @me_addr: address of the client in ME
573 * @host_addr: - address of the client in the driver
574 * @status: (mei_hbm_status) response status for the request
575 * - MEI_HBMS_SUCCESS: successful stop/start
576 * - MEI_HBMS_CLIENT_NOT_FOUND: if the connection could not be found.
577 * - MEI_HBMS_ALREADY_STARTED: for start requests for a previously
578 * started notification.
579 * - MEI_HBMS_NOT_STARTED: for stop request for a connected client for whom
580 * asynchronous notifications are currently disabled.
582 * @start: start = 1 or stop = 0 asynchronous notifications
583 * @reserved: reserved
585 struct hbm_notification_response {
595 * struct hbm_notification - notification event
597 * @hbm_cmd: bus message command header
598 * @me_addr: address of the client in ME
599 * @host_addr: address of the client in the driver
600 * @reserved: reserved for alignment
602 struct hbm_notification {
610 * struct hbm_dma_mem_dscr - dma ring
612 * @addr_hi: the high 32bits of 64 bit address
613 * @addr_lo: the low 32bits of 64 bit address
614 * @size : size in bytes (must be power of 2)
616 struct hbm_dma_mem_dscr {
630 * struct hbm_dma_setup_request - dma setup request
632 * @hbm_cmd: bus message command header
633 * @reserved: reserved for alignment
634 * @dma_dscr: dma descriptor for HOST, DEVICE, and CTRL
636 struct hbm_dma_setup_request {
639 struct hbm_dma_mem_dscr dma_dscr[DMA_DSCR_NUM];
643 * struct hbm_dma_setup_response - dma setup response
645 * @hbm_cmd: bus message command header
646 * @status: 0 on success; otherwise DMA setup failed.
647 * @reserved: reserved for alignment
649 struct hbm_dma_setup_response {
656 * struct mei_dma_ring_ctrl - dma ring control block
658 * @hbuf_wr_idx: host circular buffer write index in slots
659 * @reserved1: reserved for alignment
660 * @hbuf_rd_idx: host circular buffer read index in slots
661 * @reserved2: reserved for alignment
662 * @dbuf_wr_idx: device circular buffer write index in slots
663 * @reserved3: reserved for alignment
664 * @dbuf_rd_idx: device circular buffer read index in slots
665 * @reserved4: reserved for alignment
667 struct hbm_dma_ring_ctrl {
678 /* virtual tag supported */
679 #define HBM_CAP_VT BIT(0)
680 /* client dma supported */
681 #define HBM_CAP_CD BIT(2)
684 * struct hbm_capability_request - capability request from host to fw
686 * @hbm_cmd : bus message command header
687 * @capability_requested: bitmask of capabilities requested by host
689 struct hbm_capability_request {
691 u8 capability_requested[3];
695 * struct hbm_capability_response - capability response from fw to host
697 * @hbm_cmd : bus message command header
698 * @capability_granted: bitmask of capabilities granted by FW
700 struct hbm_capability_response {
702 u8 capability_granted[3];
706 * struct hbm_client_dma_map_request - client dma map request from host to fw
708 * @hbm_cmd: bus message command header
709 * @client_buffer_id: client buffer id
710 * @reserved: reserved
711 * @address_lsb: DMA address LSB
712 * @address_msb: DMA address MSB
715 struct hbm_client_dma_map_request {
725 * struct hbm_client_dma_unmap_request
726 * client dma unmap request from the host to the firmware
728 * @hbm_cmd: bus message command header
729 * @status: unmap status
730 * @client_buffer_id: client buffer id
731 * @reserved: reserved
733 struct hbm_client_dma_unmap_request {
741 * struct hbm_client_dma_response
742 * client dma unmap response from the firmware to the host
744 * @hbm_cmd: bus message command header
745 * @status: command status
747 struct hbm_client_dma_response {