xref: /openbmc/linux/drivers/misc/mei/hw.h (revision 88021836)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Copyright (c) 2003-2022, Intel Corporation. All rights reserved
4  * Intel Management Engine Interface (Intel MEI) Linux driver
5  */
6 
7 #ifndef _MEI_HW_TYPES_H_
8 #define _MEI_HW_TYPES_H_
9 
10 #include <linux/mei.h>
11 
12 /*
13  * Timeouts in Seconds
14  */
15 #define MEI_HW_READY_TIMEOUT        2  /* Timeout on ready message */
16 #define MEI_CONNECT_TIMEOUT         3  /* HPS: at least 2 seconds */
17 
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 */
21 
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 */
26 
27 #define MKHI_RCV_TIMEOUT 500 /* receive timeout in msec */
28 #define MKHI_RCV_TIMEOUT_SLOW 10000 /* receive timeout in msec, slow FW */
29 
30 /*
31  * FW page size for DMA allocations
32  */
33 #define MEI_FW_PAGE_SIZE 4096UL
34 
35 /*
36  * MEI Version
37  */
38 #define HBM_MINOR_VERSION                   2
39 #define HBM_MAJOR_VERSION                   2
40 
41 /*
42  * MEI version with PGI support
43  */
44 #define HBM_MINOR_VERSION_PGI               1
45 #define HBM_MAJOR_VERSION_PGI               1
46 
47 /*
48  * MEI version with Dynamic clients support
49  */
50 #define HBM_MINOR_VERSION_DC               0
51 #define HBM_MAJOR_VERSION_DC               2
52 
53 /*
54  * MEI version with immediate reply to enum request support
55  */
56 #define HBM_MINOR_VERSION_IE               0
57 #define HBM_MAJOR_VERSION_IE               2
58 
59 /*
60  * MEI version with disconnect on connection timeout support
61  */
62 #define HBM_MINOR_VERSION_DOT              0
63 #define HBM_MAJOR_VERSION_DOT              2
64 
65 /*
66  * MEI version with notification support
67  */
68 #define HBM_MINOR_VERSION_EV               0
69 #define HBM_MAJOR_VERSION_EV               2
70 
71 /*
72  * MEI version with fixed address client support
73  */
74 #define HBM_MINOR_VERSION_FA               0
75 #define HBM_MAJOR_VERSION_FA               2
76 
77 /*
78  * MEI version with OS ver message support
79  */
80 #define HBM_MINOR_VERSION_OS               0
81 #define HBM_MAJOR_VERSION_OS               2
82 
83 /*
84  * MEI version with dma ring support
85  */
86 #define HBM_MINOR_VERSION_DR               1
87 #define HBM_MAJOR_VERSION_DR               2
88 
89 /*
90  * MEI version with vm tag support
91  */
92 #define HBM_MINOR_VERSION_VT               2
93 #define HBM_MAJOR_VERSION_VT               2
94 
95 /*
96  * MEI version with GSC support
97  */
98 #define HBM_MINOR_VERSION_GSC              2
99 #define HBM_MAJOR_VERSION_GSC              2
100 
101 /*
102  * MEI version with capabilities message support
103  */
104 #define HBM_MINOR_VERSION_CAP              2
105 #define HBM_MAJOR_VERSION_CAP              2
106 
107 /*
108  * MEI version with client DMA support
109  */
110 #define HBM_MINOR_VERSION_CD               2
111 #define HBM_MAJOR_VERSION_CD               2
112 
113 /* Host bus message command opcode */
114 #define MEI_HBM_CMD_OP_MSK                  0x7f
115 /* Host bus message command RESPONSE */
116 #define MEI_HBM_CMD_RES_MSK                 0x80
117 
118 /*
119  * MEI Bus Message Command IDs
120  */
121 #define HOST_START_REQ_CMD                  0x01
122 #define HOST_START_RES_CMD                  0x81
123 
124 #define HOST_STOP_REQ_CMD                   0x02
125 #define HOST_STOP_RES_CMD                   0x82
126 
127 #define ME_STOP_REQ_CMD                     0x03
128 
129 #define HOST_ENUM_REQ_CMD                   0x04
130 #define HOST_ENUM_RES_CMD                   0x84
131 
132 #define HOST_CLIENT_PROPERTIES_REQ_CMD      0x05
133 #define HOST_CLIENT_PROPERTIES_RES_CMD      0x85
134 
135 #define CLIENT_CONNECT_REQ_CMD              0x06
136 #define CLIENT_CONNECT_RES_CMD              0x86
137 
138 #define CLIENT_DISCONNECT_REQ_CMD           0x07
139 #define CLIENT_DISCONNECT_RES_CMD           0x87
140 
141 #define MEI_FLOW_CONTROL_CMD                0x08
142 
143 #define MEI_PG_ISOLATION_ENTRY_REQ_CMD      0x0a
144 #define MEI_PG_ISOLATION_ENTRY_RES_CMD      0x8a
145 #define MEI_PG_ISOLATION_EXIT_REQ_CMD       0x0b
146 #define MEI_PG_ISOLATION_EXIT_RES_CMD       0x8b
147 
148 #define MEI_HBM_ADD_CLIENT_REQ_CMD          0x0f
149 #define MEI_HBM_ADD_CLIENT_RES_CMD          0x8f
150 
151 #define MEI_HBM_NOTIFY_REQ_CMD              0x10
152 #define MEI_HBM_NOTIFY_RES_CMD              0x90
153 #define MEI_HBM_NOTIFICATION_CMD            0x11
154 
155 #define MEI_HBM_DMA_SETUP_REQ_CMD           0x12
156 #define MEI_HBM_DMA_SETUP_RES_CMD           0x92
157 
158 #define MEI_HBM_CAPABILITIES_REQ_CMD        0x13
159 #define MEI_HBM_CAPABILITIES_RES_CMD        0x93
160 
161 #define MEI_HBM_CLIENT_DMA_MAP_REQ_CMD      0x14
162 #define MEI_HBM_CLIENT_DMA_MAP_RES_CMD      0x94
163 
164 #define MEI_HBM_CLIENT_DMA_UNMAP_REQ_CMD    0x15
165 #define MEI_HBM_CLIENT_DMA_UNMAP_RES_CMD    0x95
166 
167 /*
168  * MEI Stop Reason
169  * used by hbm_host_stop_request.reason
170  */
171 enum mei_stop_reason_types {
172 	DRIVER_STOP_REQUEST = 0x00,
173 	DEVICE_D1_ENTRY = 0x01,
174 	DEVICE_D2_ENTRY = 0x02,
175 	DEVICE_D3_ENTRY = 0x03,
176 	SYSTEM_S1_ENTRY = 0x04,
177 	SYSTEM_S2_ENTRY = 0x05,
178 	SYSTEM_S3_ENTRY = 0x06,
179 	SYSTEM_S4_ENTRY = 0x07,
180 	SYSTEM_S5_ENTRY = 0x08
181 };
182 
183 
184 /**
185  * enum mei_hbm_status  - mei host bus messages return values
186  *
187  * @MEI_HBMS_SUCCESS           : status success
188  * @MEI_HBMS_CLIENT_NOT_FOUND  : client not found
189  * @MEI_HBMS_ALREADY_EXISTS    : connection already established
190  * @MEI_HBMS_REJECTED          : connection is rejected
191  * @MEI_HBMS_INVALID_PARAMETER : invalid parameter
192  * @MEI_HBMS_NOT_ALLOWED       : operation not allowed
193  * @MEI_HBMS_ALREADY_STARTED   : system is already started
194  * @MEI_HBMS_NOT_STARTED       : system not started
195  *
196  * @MEI_HBMS_MAX               : sentinel
197  */
198 enum mei_hbm_status {
199 	MEI_HBMS_SUCCESS           = 0,
200 	MEI_HBMS_CLIENT_NOT_FOUND  = 1,
201 	MEI_HBMS_ALREADY_EXISTS    = 2,
202 	MEI_HBMS_REJECTED          = 3,
203 	MEI_HBMS_INVALID_PARAMETER = 4,
204 	MEI_HBMS_NOT_ALLOWED       = 5,
205 	MEI_HBMS_ALREADY_STARTED   = 6,
206 	MEI_HBMS_NOT_STARTED       = 7,
207 
208 	MEI_HBMS_MAX
209 };
210 
211 
212 /*
213  * Client Connect Status
214  * used by hbm_client_connect_response.status
215  */
216 enum mei_cl_connect_status {
217 	MEI_CL_CONN_SUCCESS          = MEI_HBMS_SUCCESS,
218 	MEI_CL_CONN_NOT_FOUND        = MEI_HBMS_CLIENT_NOT_FOUND,
219 	MEI_CL_CONN_ALREADY_STARTED  = MEI_HBMS_ALREADY_EXISTS,
220 	MEI_CL_CONN_OUT_OF_RESOURCES = MEI_HBMS_REJECTED,
221 	MEI_CL_CONN_MESSAGE_SMALL    = MEI_HBMS_INVALID_PARAMETER,
222 	MEI_CL_CONN_NOT_ALLOWED      = MEI_HBMS_NOT_ALLOWED,
223 };
224 
225 /*
226  * Client Disconnect Status
227  */
228 enum mei_cl_disconnect_status {
229 	MEI_CL_DISCONN_SUCCESS = MEI_HBMS_SUCCESS
230 };
231 
232 /**
233  * enum mei_ext_hdr_type - extended header type used in
234  *    extended header TLV
235  *
236  * @MEI_EXT_HDR_NONE: sentinel
237  * @MEI_EXT_HDR_VTAG: vtag header
238  * @MEI_EXT_HDR_GSC: gsc header
239  */
240 enum mei_ext_hdr_type {
241 	MEI_EXT_HDR_NONE = 0,
242 	MEI_EXT_HDR_VTAG = 1,
243 	MEI_EXT_HDR_GSC = 2,
244 };
245 
246 /**
247  * struct mei_ext_hdr - extend header descriptor (TLV)
248  * @type: enum mei_ext_hdr_type
249  * @length: length excluding descriptor
250  * @data: the extended header payload
251  */
252 struct mei_ext_hdr {
253 	u8 type;
254 	u8 length;
255 	u8 data[];
256 } __packed;
257 
258 /**
259  * struct mei_ext_meta_hdr - extend header meta data
260  * @count: number of headers
261  * @size: total size of the extended header list excluding meta header
262  * @reserved: reserved
263  * @hdrs: extended headers TLV list
264  */
265 struct mei_ext_meta_hdr {
266 	u8 count;
267 	u8 size;
268 	u8 reserved[2];
269 	u8 hdrs[];
270 } __packed;
271 
272 /**
273  * struct mei_ext_hdr_vtag - extend header for vtag
274  *
275  * @hdr: standard extend header
276  * @vtag: virtual tag
277  * @reserved: reserved
278  */
279 struct mei_ext_hdr_vtag {
280 	struct mei_ext_hdr hdr;
281 	u8 vtag;
282 	u8 reserved;
283 } __packed;
284 
285 /*
286  * Extended header iterator functions
287  */
288 /**
289  * mei_ext_begin - extended header iterator begin
290  *
291  * @meta: meta header of the extended header list
292  *
293  * Return: The first extended header
294  */
295 static inline struct mei_ext_hdr *mei_ext_begin(struct mei_ext_meta_hdr *meta)
296 {
297 	return (struct mei_ext_hdr *)meta->hdrs;
298 }
299 
300 /**
301  * mei_ext_last - check if the ext is the last one in the TLV list
302  *
303  * @meta: meta header of the extended header list
304  * @ext: a meta header on the list
305  *
306  * Return: true if ext is the last header on the list
307  */
308 static inline bool mei_ext_last(struct mei_ext_meta_hdr *meta,
309 				struct mei_ext_hdr *ext)
310 {
311 	return (u8 *)ext >= (u8 *)meta + sizeof(*meta) + (meta->size * 4);
312 }
313 
314 struct mei_gsc_sgl {
315 	u32 low;
316 	u32 high;
317 	u32 length;
318 } __packed;
319 
320 #define GSC_HECI_MSG_KERNEL 0
321 #define GSC_HECI_MSG_USER   1
322 
323 #define GSC_ADDRESS_TYPE_GTT   0
324 #define GSC_ADDRESS_TYPE_PPGTT 1
325 #define GSC_ADDRESS_TYPE_PHYSICAL_CONTINUOUS 2 /* max of 64K */
326 #define GSC_ADDRESS_TYPE_PHYSICAL_SGL 3
327 
328 /**
329  * struct mei_ext_hdr_gsc_h2f - extended header: gsc host to firmware interface
330  *
331  * @hdr: extended header
332  * @client_id: GSC_HECI_MSG_KERNEL or GSC_HECI_MSG_USER
333  * @addr_type: GSC_ADDRESS_TYPE_{GTT, PPGTT, PHYSICAL_CONTINUOUS, PHYSICAL_SGL}
334  * @fence_id: synchronization marker
335  * @input_address_count: number of input sgl buffers
336  * @output_address_count: number of output sgl buffers
337  * @reserved: reserved
338  * @sgl: sg list
339  */
340 struct mei_ext_hdr_gsc_h2f {
341 	struct mei_ext_hdr hdr;
342 	u8                 client_id;
343 	u8                 addr_type;
344 	u32                fence_id;
345 	u8                 input_address_count;
346 	u8                 output_address_count;
347 	u8                 reserved[2];
348 	struct mei_gsc_sgl sgl[];
349 } __packed;
350 
351 /**
352  * struct mei_ext_hdr_gsc_f2h - gsc firmware to host interface
353  *
354  * @hdr: extended header
355  * @client_id: GSC_HECI_MSG_KERNEL or GSC_HECI_MSG_USER
356  * @reserved: reserved
357  * @fence_id: synchronization marker
358  * @written: number of bytes written to firmware
359  */
360 struct mei_ext_hdr_gsc_f2h {
361 	struct mei_ext_hdr hdr;
362 	u8                 client_id;
363 	u8                 reserved;
364 	u32                fence_id;
365 	u32                written;
366 } __packed;
367 
368 /**
369  * mei_ext_next - following extended header on the TLV list
370  *
371  * @ext: current extend header
372  *
373  * Context: The function does not check for the overflows,
374  *          one should call mei_ext_last before.
375  *
376  * Return: The following extend header after @ext
377  */
378 static inline struct mei_ext_hdr *mei_ext_next(struct mei_ext_hdr *ext)
379 {
380 	return (struct mei_ext_hdr *)((u8 *)ext + (ext->length * 4));
381 }
382 
383 /**
384  * mei_ext_hdr_len - get ext header length in bytes
385  *
386  * @ext: extend header
387  *
388  * Return: extend header length in bytes
389  */
390 static inline u32 mei_ext_hdr_len(const struct mei_ext_hdr *ext)
391 {
392 	if (!ext)
393 		return 0;
394 
395 	return ext->length * sizeof(u32);
396 }
397 
398 /**
399  * struct mei_msg_hdr - MEI BUS Interface Section
400  *
401  * @me_addr: device address
402  * @host_addr: host address
403  * @length: message length
404  * @reserved: reserved
405  * @extended: message has extended header
406  * @dma_ring: message is on dma ring
407  * @internal: message is internal
408  * @msg_complete: last packet of the message
409  * @extension: extension of the header
410  */
411 struct mei_msg_hdr {
412 	u32 me_addr:8;
413 	u32 host_addr:8;
414 	u32 length:9;
415 	u32 reserved:3;
416 	u32 extended:1;
417 	u32 dma_ring:1;
418 	u32 internal:1;
419 	u32 msg_complete:1;
420 	u32 extension[];
421 } __packed;
422 
423 /* The length is up to 9 bits */
424 #define MEI_MSG_MAX_LEN_MASK GENMASK(9, 0)
425 
426 struct mei_bus_message {
427 	u8 hbm_cmd;
428 	u8 data[];
429 } __packed;
430 
431 /**
432  * struct hbm_cl_cmd - client specific host bus command
433  *	CONNECT, DISCONNECT, and FlOW CONTROL
434  *
435  * @hbm_cmd: bus message command header
436  * @me_addr: address of the client in ME
437  * @host_addr: address of the client in the driver
438  * @data: generic data
439  */
440 struct mei_hbm_cl_cmd {
441 	u8 hbm_cmd;
442 	u8 me_addr;
443 	u8 host_addr;
444 	u8 data;
445 };
446 
447 struct hbm_version {
448 	u8 minor_version;
449 	u8 major_version;
450 } __packed;
451 
452 struct hbm_host_version_request {
453 	u8 hbm_cmd;
454 	u8 reserved;
455 	struct hbm_version host_version;
456 } __packed;
457 
458 struct hbm_host_version_response {
459 	u8 hbm_cmd;
460 	u8 host_version_supported;
461 	struct hbm_version me_max_version;
462 } __packed;
463 
464 struct hbm_host_stop_request {
465 	u8 hbm_cmd;
466 	u8 reason;
467 	u8 reserved[2];
468 } __packed;
469 
470 struct hbm_host_stop_response {
471 	u8 hbm_cmd;
472 	u8 reserved[3];
473 } __packed;
474 
475 struct hbm_me_stop_request {
476 	u8 hbm_cmd;
477 	u8 reason;
478 	u8 reserved[2];
479 } __packed;
480 
481 /**
482  * enum hbm_host_enum_flags - enumeration request flags (HBM version >= 2.0)
483  *
484  * @MEI_HBM_ENUM_F_ALLOW_ADD: allow dynamic clients add
485  * @MEI_HBM_ENUM_F_IMMEDIATE_ENUM: allow FW to send answer immediately
486  */
487 enum hbm_host_enum_flags {
488 	MEI_HBM_ENUM_F_ALLOW_ADD = BIT(0),
489 	MEI_HBM_ENUM_F_IMMEDIATE_ENUM = BIT(1),
490 };
491 
492 /**
493  * struct hbm_host_enum_request - enumeration request from host to fw
494  *
495  * @hbm_cmd : bus message command header
496  * @flags   : request flags
497  * @reserved: reserved
498  */
499 struct hbm_host_enum_request {
500 	u8 hbm_cmd;
501 	u8 flags;
502 	u8 reserved[2];
503 } __packed;
504 
505 struct hbm_host_enum_response {
506 	u8 hbm_cmd;
507 	u8 reserved[3];
508 	u8 valid_addresses[32];
509 } __packed;
510 
511 /**
512  * struct mei_client_properties - mei client properties
513  *
514  * @protocol_name: guid of the client
515  * @protocol_version: client protocol version
516  * @max_number_of_connections: number of possible connections.
517  * @fixed_address: fixed me address (0 if the client is dynamic)
518  * @single_recv_buf: 1 if all connections share a single receive buffer.
519  * @vt_supported: the client support vtag
520  * @reserved: reserved
521  * @max_msg_length: MTU of the client
522  */
523 struct mei_client_properties {
524 	uuid_le protocol_name;
525 	u8 protocol_version;
526 	u8 max_number_of_connections;
527 	u8 fixed_address;
528 	u8 single_recv_buf:1;
529 	u8 vt_supported:1;
530 	u8 reserved:6;
531 	u32 max_msg_length;
532 } __packed;
533 
534 struct hbm_props_request {
535 	u8 hbm_cmd;
536 	u8 me_addr;
537 	u8 reserved[2];
538 } __packed;
539 
540 struct hbm_props_response {
541 	u8 hbm_cmd;
542 	u8 me_addr;
543 	u8 status;
544 	u8 reserved;
545 	struct mei_client_properties client_properties;
546 } __packed;
547 
548 /**
549  * struct hbm_add_client_request - request to add a client
550  *     might be sent by fw after enumeration has already completed
551  *
552  * @hbm_cmd: bus message command header
553  * @me_addr: address of the client in ME
554  * @reserved: reserved
555  * @client_properties: client properties
556  */
557 struct hbm_add_client_request {
558 	u8 hbm_cmd;
559 	u8 me_addr;
560 	u8 reserved[2];
561 	struct mei_client_properties client_properties;
562 } __packed;
563 
564 /**
565  * struct hbm_add_client_response - response to add a client
566  *     sent by the host to report client addition status to fw
567  *
568  * @hbm_cmd: bus message command header
569  * @me_addr: address of the client in ME
570  * @status: if HBMS_SUCCESS then the client can now accept connections.
571  * @reserved: reserved
572  */
573 struct hbm_add_client_response {
574 	u8 hbm_cmd;
575 	u8 me_addr;
576 	u8 status;
577 	u8 reserved;
578 } __packed;
579 
580 /**
581  * struct hbm_power_gate - power gate request/response
582  *
583  * @hbm_cmd: bus message command header
584  * @reserved: reserved
585  */
586 struct hbm_power_gate {
587 	u8 hbm_cmd;
588 	u8 reserved[3];
589 } __packed;
590 
591 /**
592  * struct hbm_client_connect_request - connect/disconnect request
593  *
594  * @hbm_cmd: bus message command header
595  * @me_addr: address of the client in ME
596  * @host_addr: address of the client in the driver
597  * @reserved: reserved
598  */
599 struct hbm_client_connect_request {
600 	u8 hbm_cmd;
601 	u8 me_addr;
602 	u8 host_addr;
603 	u8 reserved;
604 } __packed;
605 
606 /**
607  * struct hbm_client_connect_response - connect/disconnect response
608  *
609  * @hbm_cmd: bus message command header
610  * @me_addr: address of the client in ME
611  * @host_addr: address of the client in the driver
612  * @status: status of the request
613  */
614 struct hbm_client_connect_response {
615 	u8 hbm_cmd;
616 	u8 me_addr;
617 	u8 host_addr;
618 	u8 status;
619 } __packed;
620 
621 
622 #define MEI_FC_MESSAGE_RESERVED_LENGTH           5
623 
624 struct hbm_flow_control {
625 	u8 hbm_cmd;
626 	u8 me_addr;
627 	u8 host_addr;
628 	u8 reserved[MEI_FC_MESSAGE_RESERVED_LENGTH];
629 } __packed;
630 
631 #define MEI_HBM_NOTIFICATION_START 1
632 #define MEI_HBM_NOTIFICATION_STOP  0
633 /**
634  * struct hbm_notification_request - start/stop notification request
635  *
636  * @hbm_cmd: bus message command header
637  * @me_addr: address of the client in ME
638  * @host_addr: address of the client in the driver
639  * @start:  start = 1 or stop = 0 asynchronous notifications
640  */
641 struct hbm_notification_request {
642 	u8 hbm_cmd;
643 	u8 me_addr;
644 	u8 host_addr;
645 	u8 start;
646 } __packed;
647 
648 /**
649  * struct hbm_notification_response - start/stop notification response
650  *
651  * @hbm_cmd: bus message command header
652  * @me_addr: address of the client in ME
653  * @host_addr: - address of the client in the driver
654  * @status: (mei_hbm_status) response status for the request
655  *  - MEI_HBMS_SUCCESS: successful stop/start
656  *  - MEI_HBMS_CLIENT_NOT_FOUND: if the connection could not be found.
657  *  - MEI_HBMS_ALREADY_STARTED: for start requests for a previously
658  *                         started notification.
659  *  - MEI_HBMS_NOT_STARTED: for stop request for a connected client for whom
660  *                         asynchronous notifications are currently disabled.
661  *
662  * @start:  start = 1 or stop = 0 asynchronous notifications
663  * @reserved: reserved
664  */
665 struct hbm_notification_response {
666 	u8 hbm_cmd;
667 	u8 me_addr;
668 	u8 host_addr;
669 	u8 status;
670 	u8 start;
671 	u8 reserved[3];
672 } __packed;
673 
674 /**
675  * struct hbm_notification - notification event
676  *
677  * @hbm_cmd: bus message command header
678  * @me_addr:  address of the client in ME
679  * @host_addr:  address of the client in the driver
680  * @reserved: reserved for alignment
681  */
682 struct hbm_notification {
683 	u8 hbm_cmd;
684 	u8 me_addr;
685 	u8 host_addr;
686 	u8 reserved;
687 } __packed;
688 
689 /**
690  * struct hbm_dma_mem_dscr - dma ring
691  *
692  * @addr_hi: the high 32bits of 64 bit address
693  * @addr_lo: the low  32bits of 64 bit address
694  * @size   : size in bytes (must be power of 2)
695  */
696 struct hbm_dma_mem_dscr {
697 	u32 addr_hi;
698 	u32 addr_lo;
699 	u32 size;
700 } __packed;
701 
702 enum {
703 	DMA_DSCR_HOST = 0,
704 	DMA_DSCR_DEVICE = 1,
705 	DMA_DSCR_CTRL = 2,
706 	DMA_DSCR_NUM,
707 };
708 
709 /**
710  * struct hbm_dma_setup_request - dma setup request
711  *
712  * @hbm_cmd: bus message command header
713  * @reserved: reserved for alignment
714  * @dma_dscr: dma descriptor for HOST, DEVICE, and CTRL
715  */
716 struct hbm_dma_setup_request {
717 	u8 hbm_cmd;
718 	u8 reserved[3];
719 	struct hbm_dma_mem_dscr dma_dscr[DMA_DSCR_NUM];
720 } __packed;
721 
722 /**
723  * struct hbm_dma_setup_response - dma setup response
724  *
725  * @hbm_cmd: bus message command header
726  * @status: 0 on success; otherwise DMA setup failed.
727  * @reserved: reserved for alignment
728  */
729 struct hbm_dma_setup_response {
730 	u8 hbm_cmd;
731 	u8 status;
732 	u8 reserved[2];
733 } __packed;
734 
735 /**
736  * struct mei_dma_ring_ctrl - dma ring control block
737  *
738  * @hbuf_wr_idx: host circular buffer write index in slots
739  * @reserved1: reserved for alignment
740  * @hbuf_rd_idx: host circular buffer read index in slots
741  * @reserved2: reserved for alignment
742  * @dbuf_wr_idx: device circular buffer write index in slots
743  * @reserved3: reserved for alignment
744  * @dbuf_rd_idx: device circular buffer read index in slots
745  * @reserved4: reserved for alignment
746  */
747 struct hbm_dma_ring_ctrl {
748 	u32 hbuf_wr_idx;
749 	u32 reserved1;
750 	u32 hbuf_rd_idx;
751 	u32 reserved2;
752 	u32 dbuf_wr_idx;
753 	u32 reserved3;
754 	u32 dbuf_rd_idx;
755 	u32 reserved4;
756 } __packed;
757 
758 /* virtual tag supported */
759 #define HBM_CAP_VT BIT(0)
760 
761 /* gsc extended header support */
762 #define HBM_CAP_GSC BIT(1)
763 
764 /* client dma supported */
765 #define HBM_CAP_CD BIT(2)
766 
767 /**
768  * struct hbm_capability_request - capability request from host to fw
769  *
770  * @hbm_cmd : bus message command header
771  * @capability_requested: bitmask of capabilities requested by host
772  */
773 struct hbm_capability_request {
774 	u8 hbm_cmd;
775 	u8 capability_requested[3];
776 } __packed;
777 
778 /**
779  * struct hbm_capability_response - capability response from fw to host
780  *
781  * @hbm_cmd : bus message command header
782  * @capability_granted: bitmask of capabilities granted by FW
783  */
784 struct hbm_capability_response {
785 	u8 hbm_cmd;
786 	u8 capability_granted[3];
787 } __packed;
788 
789 /**
790  * struct hbm_client_dma_map_request - client dma map request from host to fw
791  *
792  * @hbm_cmd: bus message command header
793  * @client_buffer_id: client buffer id
794  * @reserved: reserved
795  * @address_lsb: DMA address LSB
796  * @address_msb: DMA address MSB
797  * @size: DMA size
798  */
799 struct hbm_client_dma_map_request {
800 	u8 hbm_cmd;
801 	u8 client_buffer_id;
802 	u8 reserved[2];
803 	u32 address_lsb;
804 	u32 address_msb;
805 	u32 size;
806 } __packed;
807 
808 /**
809  * struct hbm_client_dma_unmap_request
810  *    client dma unmap request from the host to the firmware
811  *
812  * @hbm_cmd: bus message command header
813  * @status: unmap status
814  * @client_buffer_id: client buffer id
815  * @reserved: reserved
816  */
817 struct hbm_client_dma_unmap_request {
818 	u8 hbm_cmd;
819 	u8 status;
820 	u8 client_buffer_id;
821 	u8 reserved;
822 } __packed;
823 
824 /**
825  * struct hbm_client_dma_response
826  *   client dma unmap response from the firmware to the host
827  *
828  * @hbm_cmd: bus message command header
829  * @status: command status
830  */
831 struct hbm_client_dma_response {
832 	u8 hbm_cmd;
833 	u8 status;
834 } __packed;
835 
836 #endif
837