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
91 /* Host bus message command opcode */
92 #define MEI_HBM_CMD_OP_MSK 0x7f
93 /* Host bus message command RESPONSE */
94 #define MEI_HBM_CMD_RES_MSK 0x80
97 * MEI Bus Message Command IDs
99 #define HOST_START_REQ_CMD 0x01
100 #define HOST_START_RES_CMD 0x81
102 #define HOST_STOP_REQ_CMD 0x02
103 #define HOST_STOP_RES_CMD 0x82
105 #define ME_STOP_REQ_CMD 0x03
107 #define HOST_ENUM_REQ_CMD 0x04
108 #define HOST_ENUM_RES_CMD 0x84
110 #define HOST_CLIENT_PROPERTIES_REQ_CMD 0x05
111 #define HOST_CLIENT_PROPERTIES_RES_CMD 0x85
113 #define CLIENT_CONNECT_REQ_CMD 0x06
114 #define CLIENT_CONNECT_RES_CMD 0x86
116 #define CLIENT_DISCONNECT_REQ_CMD 0x07
117 #define CLIENT_DISCONNECT_RES_CMD 0x87
119 #define MEI_FLOW_CONTROL_CMD 0x08
121 #define MEI_PG_ISOLATION_ENTRY_REQ_CMD 0x0a
122 #define MEI_PG_ISOLATION_ENTRY_RES_CMD 0x8a
123 #define MEI_PG_ISOLATION_EXIT_REQ_CMD 0x0b
124 #define MEI_PG_ISOLATION_EXIT_RES_CMD 0x8b
126 #define MEI_HBM_ADD_CLIENT_REQ_CMD 0x0f
127 #define MEI_HBM_ADD_CLIENT_RES_CMD 0x8f
129 #define MEI_HBM_NOTIFY_REQ_CMD 0x10
130 #define MEI_HBM_NOTIFY_RES_CMD 0x90
131 #define MEI_HBM_NOTIFICATION_CMD 0x11
133 #define MEI_HBM_DMA_SETUP_REQ_CMD 0x12
134 #define MEI_HBM_DMA_SETUP_RES_CMD 0x92
136 #define MEI_HBM_CAPABILITIES_REQ_CMD 0x13
137 #define MEI_HBM_CAPABILITIES_RES_CMD 0x93
141 * used by hbm_host_stop_request.reason
143 enum mei_stop_reason_types {
144 DRIVER_STOP_REQUEST = 0x00,
145 DEVICE_D1_ENTRY = 0x01,
146 DEVICE_D2_ENTRY = 0x02,
147 DEVICE_D3_ENTRY = 0x03,
148 SYSTEM_S1_ENTRY = 0x04,
149 SYSTEM_S2_ENTRY = 0x05,
150 SYSTEM_S3_ENTRY = 0x06,
151 SYSTEM_S4_ENTRY = 0x07,
152 SYSTEM_S5_ENTRY = 0x08
157 * enum mei_hbm_status - mei host bus messages return values
159 * @MEI_HBMS_SUCCESS : status success
160 * @MEI_HBMS_CLIENT_NOT_FOUND : client not found
161 * @MEI_HBMS_ALREADY_EXISTS : connection already established
162 * @MEI_HBMS_REJECTED : connection is rejected
163 * @MEI_HBMS_INVALID_PARAMETER : invalid parameter
164 * @MEI_HBMS_NOT_ALLOWED : operation not allowed
165 * @MEI_HBMS_ALREADY_STARTED : system is already started
166 * @MEI_HBMS_NOT_STARTED : system not started
168 * @MEI_HBMS_MAX : sentinel
170 enum mei_hbm_status {
171 MEI_HBMS_SUCCESS = 0,
172 MEI_HBMS_CLIENT_NOT_FOUND = 1,
173 MEI_HBMS_ALREADY_EXISTS = 2,
174 MEI_HBMS_REJECTED = 3,
175 MEI_HBMS_INVALID_PARAMETER = 4,
176 MEI_HBMS_NOT_ALLOWED = 5,
177 MEI_HBMS_ALREADY_STARTED = 6,
178 MEI_HBMS_NOT_STARTED = 7,
185 * Client Connect Status
186 * used by hbm_client_connect_response.status
188 enum mei_cl_connect_status {
189 MEI_CL_CONN_SUCCESS = MEI_HBMS_SUCCESS,
190 MEI_CL_CONN_NOT_FOUND = MEI_HBMS_CLIENT_NOT_FOUND,
191 MEI_CL_CONN_ALREADY_STARTED = MEI_HBMS_ALREADY_EXISTS,
192 MEI_CL_CONN_OUT_OF_RESOURCES = MEI_HBMS_REJECTED,
193 MEI_CL_CONN_MESSAGE_SMALL = MEI_HBMS_INVALID_PARAMETER,
194 MEI_CL_CONN_NOT_ALLOWED = MEI_HBMS_NOT_ALLOWED,
198 * Client Disconnect Status
200 enum mei_cl_disconnect_status {
201 MEI_CL_DISCONN_SUCCESS = MEI_HBMS_SUCCESS
205 * enum mei_ext_hdr_type - extended header type used in
206 * extended header TLV
208 * @MEI_EXT_HDR_NONE: sentinel
209 * @MEI_EXT_HDR_VTAG: vtag header
211 enum mei_ext_hdr_type {
212 MEI_EXT_HDR_NONE = 0,
213 MEI_EXT_HDR_VTAG = 1,
217 * struct mei_ext_hdr - extend header descriptor (TLV)
218 * @type: enum mei_ext_hdr_type
219 * @length: length excluding descriptor
220 * @ext_payload: payload of the specific extended header
221 * @hdr: place holder for actual header
231 * struct mei_ext_meta_hdr - extend header meta data
232 * @count: number of headers
233 * @size: total size of the extended header list excluding meta header
234 * @reserved: reserved
235 * @hdrs: extended headers TLV list
237 struct mei_ext_meta_hdr {
241 struct mei_ext_hdr hdrs[];
245 * Extended header iterator functions
248 * mei_ext_hdr - extended header iterator begin
250 * @meta: meta header of the extended header list
253 * The first extended header
255 static inline struct mei_ext_hdr *mei_ext_begin(struct mei_ext_meta_hdr *meta)
261 * mei_ext_last - check if the ext is the last one in the TLV list
263 * @meta: meta header of the extended header list
264 * @ext: a meta header on the list
266 * Return: true if ext is the last header on the list
268 static inline bool mei_ext_last(struct mei_ext_meta_hdr *meta,
269 struct mei_ext_hdr *ext)
271 return (u8 *)ext >= (u8 *)meta + sizeof(*meta) + (meta->size * 4);
275 *mei_ext_next - following extended header on the TLV list
277 * @ext: current extend header
279 * Context: The function does not check for the overflows,
280 * one should call mei_ext_last before.
282 * Return: The following extend header after @ext
284 static inline struct mei_ext_hdr *mei_ext_next(struct mei_ext_hdr *ext)
286 return (struct mei_ext_hdr *)(ext->hdr + (ext->length * 4));
290 * struct mei_msg_hdr - MEI BUS Interface Section
292 * @me_addr: device address
293 * @host_addr: host address
294 * @length: message length
295 * @reserved: reserved
296 * @extended: message has extended header
297 * @dma_ring: message is on dma ring
298 * @internal: message is internal
299 * @msg_complete: last packet of the message
300 * @extension: extension of the header
314 /* The length is up to 9 bits */
315 #define MEI_MSG_MAX_LEN_MASK GENMASK(9, 0)
317 struct mei_bus_message {
323 * struct hbm_cl_cmd - client specific host bus command
324 * CONNECT, DISCONNECT, and FlOW CONTROL
326 * @hbm_cmd: bus message command header
327 * @me_addr: address of the client in ME
328 * @host_addr: address of the client in the driver
329 * @data: generic data
331 struct mei_hbm_cl_cmd {
343 struct hbm_host_version_request {
346 struct hbm_version host_version;
349 struct hbm_host_version_response {
351 u8 host_version_supported;
352 struct hbm_version me_max_version;
355 struct hbm_host_stop_request {
361 struct hbm_host_stop_response {
366 struct hbm_me_stop_request {
373 * enum hbm_host_enum_flags - enumeration request flags (HBM version >= 2.0)
375 * @MEI_HBM_ENUM_F_ALLOW_ADD: allow dynamic clients add
376 * @MEI_HBM_ENUM_F_IMMEDIATE_ENUM: allow FW to send answer immediately
378 enum hbm_host_enum_flags {
379 MEI_HBM_ENUM_F_ALLOW_ADD = BIT(0),
380 MEI_HBM_ENUM_F_IMMEDIATE_ENUM = BIT(1),
384 * struct hbm_host_enum_request - enumeration request from host to fw
386 * @hbm_cmd : bus message command header
387 * @flags : request flags
388 * @reserved: reserved
390 struct hbm_host_enum_request {
396 struct hbm_host_enum_response {
399 u8 valid_addresses[32];
403 * struct mei_client_properties - mei client properties
405 * @protocol_name: guid of the client
406 * @protocol_version: client protocol version
407 * @max_number_of_connections: number of possible connections.
408 * @fixed_address: fixed me address (0 if the client is dynamic)
409 * @single_recv_buf: 1 if all connections share a single receive buffer.
410 * @vt_supported: the client support vtag
411 * @reserved: reserved
412 * @max_msg_length: MTU of the client
414 struct mei_client_properties {
415 uuid_le protocol_name;
417 u8 max_number_of_connections;
419 u8 single_recv_buf:1;
425 struct hbm_props_request {
431 struct hbm_props_response {
436 struct mei_client_properties client_properties;
440 * struct hbm_add_client_request - request to add a client
441 * might be sent by fw after enumeration has already completed
443 * @hbm_cmd: bus message command header
444 * @me_addr: address of the client in ME
445 * @reserved: reserved
446 * @client_properties: client properties
448 struct hbm_add_client_request {
452 struct mei_client_properties client_properties;
456 * struct hbm_add_client_response - response to add a client
457 * sent by the host to report client addition status to fw
459 * @hbm_cmd: bus message command header
460 * @me_addr: address of the client in ME
461 * @status: if HBMS_SUCCESS then the client can now accept connections.
462 * @reserved: reserved
464 struct hbm_add_client_response {
472 * struct hbm_power_gate - power gate request/response
474 * @hbm_cmd: bus message command header
475 * @reserved: reserved
477 struct hbm_power_gate {
483 * struct hbm_client_connect_request - connect/disconnect request
485 * @hbm_cmd: bus message command header
486 * @me_addr: address of the client in ME
487 * @host_addr: address of the client in the driver
488 * @reserved: reserved
490 struct hbm_client_connect_request {
498 * struct hbm_client_connect_response - connect/disconnect response
500 * @hbm_cmd: bus message command header
501 * @me_addr: address of the client in ME
502 * @host_addr: address of the client in the driver
503 * @status: status of the request
505 struct hbm_client_connect_response {
513 #define MEI_FC_MESSAGE_RESERVED_LENGTH 5
515 struct hbm_flow_control {
519 u8 reserved[MEI_FC_MESSAGE_RESERVED_LENGTH];
522 #define MEI_HBM_NOTIFICATION_START 1
523 #define MEI_HBM_NOTIFICATION_STOP 0
525 * struct hbm_notification_request - start/stop notification request
527 * @hbm_cmd: bus message command header
528 * @me_addr: address of the client in ME
529 * @host_addr: address of the client in the driver
530 * @start: start = 1 or stop = 0 asynchronous notifications
532 struct hbm_notification_request {
540 * struct hbm_notification_response - start/stop notification response
542 * @hbm_cmd: bus message command header
543 * @me_addr: address of the client in ME
544 * @host_addr: - address of the client in the driver
545 * @status: (mei_hbm_status) response status for the request
546 * - MEI_HBMS_SUCCESS: successful stop/start
547 * - MEI_HBMS_CLIENT_NOT_FOUND: if the connection could not be found.
548 * - MEI_HBMS_ALREADY_STARTED: for start requests for a previously
549 * started notification.
550 * - MEI_HBMS_NOT_STARTED: for stop request for a connected client for whom
551 * asynchronous notifications are currently disabled.
553 * @start: start = 1 or stop = 0 asynchronous notifications
554 * @reserved: reserved
556 struct hbm_notification_response {
566 * struct hbm_notification - notification event
568 * @hbm_cmd: bus message command header
569 * @me_addr: address of the client in ME
570 * @host_addr: address of the client in the driver
571 * @reserved: reserved for alignment
573 struct hbm_notification {
581 * struct hbm_dma_mem_dscr - dma ring
583 * @addr_hi: the high 32bits of 64 bit address
584 * @addr_lo: the low 32bits of 64 bit address
585 * @size : size in bytes (must be power of 2)
587 struct hbm_dma_mem_dscr {
601 * struct hbm_dma_setup_request - dma setup request
603 * @hbm_cmd: bus message command header
604 * @reserved: reserved for alignment
605 * @dma_dscr: dma descriptor for HOST, DEVICE, and CTRL
607 struct hbm_dma_setup_request {
610 struct hbm_dma_mem_dscr dma_dscr[DMA_DSCR_NUM];
614 * struct hbm_dma_setup_response - dma setup response
616 * @hbm_cmd: bus message command header
617 * @status: 0 on success; otherwise DMA setup failed.
618 * @reserved: reserved for alignment
620 struct hbm_dma_setup_response {
627 * struct mei_dma_ring_ctrl - dma ring control block
629 * @hbuf_wr_idx: host circular buffer write index in slots
630 * @reserved1: reserved for alignment
631 * @hbuf_rd_idx: host circular buffer read index in slots
632 * @reserved2: reserved for alignment
633 * @dbuf_wr_idx: device circular buffer write index in slots
634 * @reserved3: reserved for alignment
635 * @dbuf_rd_idx: device circular buffer read index in slots
636 * @reserved4: reserved for alignment
638 struct hbm_dma_ring_ctrl {
649 /* virtual tag supported */
650 #define HBM_CAP_VT BIT(0)
653 * struct hbm_capability_request - capability request from host to fw
655 * @hbm_cmd : bus message command header
656 * @capability_requested: bitmask of capabilities requested by host
658 struct hbm_capability_request {
660 u8 capability_requested[3];
664 * struct hbm_capability_response - capability response from fw to host
666 * @hbm_cmd : bus message command header
667 * @capability_granted: bitmask of capabilities granted by FW
669 struct hbm_capability_response {
671 u8 capability_granted[3];