hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/drivers/misc/mei/hw.h
....@@ -1,17 +1,7 @@
1
+/* SPDX-License-Identifier: GPL-2.0 */
12 /*
2
- *
3
+ * Copyright (c) 2003-2020, Intel Corporation. All rights reserved
34 * Intel Management Engine Interface (Intel MEI) Linux driver
4
- * Copyright (c) 2003-2012, Intel Corporation.
5
- *
6
- * This program is free software; you can redistribute it and/or modify it
7
- * under the terms and conditions of the GNU General Public License,
8
- * version 2, as published by the Free Software Foundation.
9
- *
10
- * This program is distributed in the hope it will be useful, but WITHOUT
11
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13
- * more details.
14
- *
155 */
166
177 #ifndef _MEI_HW_TYPES_H_
....@@ -35,7 +25,7 @@
3525 /*
3626 * MEI Version
3727 */
38
-#define HBM_MINOR_VERSION 0
28
+#define HBM_MINOR_VERSION 2
3929 #define HBM_MAJOR_VERSION 2
4030
4131 /*
....@@ -86,6 +76,18 @@
8676 #define HBM_MINOR_VERSION_DR 1
8777 #define HBM_MAJOR_VERSION_DR 2
8878
79
+/*
80
+ * MEI version with vm tag support
81
+ */
82
+#define HBM_MINOR_VERSION_VT 2
83
+#define HBM_MAJOR_VERSION_VT 2
84
+
85
+/*
86
+ * MEI version with capabilities message support
87
+ */
88
+#define HBM_MINOR_VERSION_CAP 2
89
+#define HBM_MAJOR_VERSION_CAP 2
90
+
8991 /* Host bus message command opcode */
9092 #define MEI_HBM_CMD_OP_MSK 0x7f
9193 /* Host bus message command RESPONSE */
....@@ -130,6 +132,9 @@
130132
131133 #define MEI_HBM_DMA_SETUP_REQ_CMD 0x12
132134 #define MEI_HBM_DMA_SETUP_RES_CMD 0x92
135
+
136
+#define MEI_HBM_CAPABILITIES_REQ_CMD 0x13
137
+#define MEI_HBM_CAPABILITIES_RES_CMD 0x93
133138
134139 /*
135140 * MEI Stop Reason
....@@ -192,9 +197,94 @@
192197 /*
193198 * Client Disconnect Status
194199 */
195
-enum mei_cl_disconnect_status {
200
+enum mei_cl_disconnect_status {
196201 MEI_CL_DISCONN_SUCCESS = MEI_HBMS_SUCCESS
197202 };
203
+
204
+/**
205
+ * enum mei_ext_hdr_type - extended header type used in
206
+ * extended header TLV
207
+ *
208
+ * @MEI_EXT_HDR_NONE: sentinel
209
+ * @MEI_EXT_HDR_VTAG: vtag header
210
+ */
211
+enum mei_ext_hdr_type {
212
+ MEI_EXT_HDR_NONE = 0,
213
+ MEI_EXT_HDR_VTAG = 1,
214
+};
215
+
216
+/**
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
222
+ */
223
+struct mei_ext_hdr {
224
+ u8 type;
225
+ u8 length;
226
+ u8 ext_payload[2];
227
+ u8 hdr[];
228
+};
229
+
230
+/**
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
236
+ */
237
+struct mei_ext_meta_hdr {
238
+ u8 count;
239
+ u8 size;
240
+ u8 reserved[2];
241
+ struct mei_ext_hdr hdrs[];
242
+};
243
+
244
+/*
245
+ * Extended header iterator functions
246
+ */
247
+/**
248
+ * mei_ext_hdr - extended header iterator begin
249
+ *
250
+ * @meta: meta header of the extended header list
251
+ *
252
+ * Return:
253
+ * The first extended header
254
+ */
255
+static inline struct mei_ext_hdr *mei_ext_begin(struct mei_ext_meta_hdr *meta)
256
+{
257
+ return meta->hdrs;
258
+}
259
+
260
+/**
261
+ * mei_ext_last - check if the ext is the last one in the TLV list
262
+ *
263
+ * @meta: meta header of the extended header list
264
+ * @ext: a meta header on the list
265
+ *
266
+ * Return: true if ext is the last header on the list
267
+ */
268
+static inline bool mei_ext_last(struct mei_ext_meta_hdr *meta,
269
+ struct mei_ext_hdr *ext)
270
+{
271
+ return (u8 *)ext >= (u8 *)meta + sizeof(*meta) + (meta->size * 4);
272
+}
273
+
274
+/**
275
+ *mei_ext_next - following extended header on the TLV list
276
+ *
277
+ * @ext: current extend header
278
+ *
279
+ * Context: The function does not check for the overflows,
280
+ * one should call mei_ext_last before.
281
+ *
282
+ * Return: The following extend header after @ext
283
+ */
284
+static inline struct mei_ext_hdr *mei_ext_next(struct mei_ext_hdr *ext)
285
+{
286
+ return (struct mei_ext_hdr *)(ext->hdr + (ext->length * 4));
287
+}
198288
199289 /**
200290 * struct mei_msg_hdr - MEI BUS Interface Section
....@@ -203,23 +293,30 @@
203293 * @host_addr: host address
204294 * @length: message length
205295 * @reserved: reserved
296
+ * @extended: message has extended header
206297 * @dma_ring: message is on dma ring
207298 * @internal: message is internal
208299 * @msg_complete: last packet of the message
300
+ * @extension: extension of the header
209301 */
210302 struct mei_msg_hdr {
211303 u32 me_addr:8;
212304 u32 host_addr:8;
213305 u32 length:9;
214
- u32 reserved:4;
306
+ u32 reserved:3;
307
+ u32 extended:1;
215308 u32 dma_ring:1;
216309 u32 internal:1;
217310 u32 msg_complete:1;
311
+ u32 extension[];
218312 } __packed;
313
+
314
+/* The length is up to 9 bits */
315
+#define MEI_MSG_MAX_LEN_MASK GENMASK(9, 0)
219316
220317 struct mei_bus_message {
221318 u8 hbm_cmd;
222
- u8 data[0];
319
+ u8 data[];
223320 } __packed;
224321
225322 /**
....@@ -302,12 +399,26 @@
302399 u8 valid_addresses[32];
303400 } __packed;
304401
402
+/**
403
+ * struct mei_client_properties - mei client properties
404
+ *
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
413
+ */
305414 struct mei_client_properties {
306415 uuid_le protocol_name;
307416 u8 protocol_version;
308417 u8 max_number_of_connections;
309418 u8 fixed_address;
310
- u8 single_recv_buf;
419
+ u8 single_recv_buf:1;
420
+ u8 vt_supported:1;
421
+ u8 reserved:6;
311422 u32 max_msg_length;
312423 } __packed;
313424
....@@ -321,7 +432,7 @@
321432 u8 hbm_cmd;
322433 u8 me_addr;
323434 u8 status;
324
- u8 reserved[1];
435
+ u8 reserved;
325436 struct mei_client_properties client_properties;
326437 } __packed;
327438
....@@ -354,7 +465,7 @@
354465 u8 hbm_cmd;
355466 u8 me_addr;
356467 u8 status;
357
- u8 reserved[1];
468
+ u8 reserved;
358469 } __packed;
359470
360471 /**
....@@ -463,7 +574,7 @@
463574 u8 hbm_cmd;
464575 u8 me_addr;
465576 u8 host_addr;
466
- u8 reserved[1];
577
+ u8 reserved;
467578 } __packed;
468579
469580 /**
....@@ -512,4 +623,52 @@
512623 u8 reserved[2];
513624 } __packed;
514625
626
+/**
627
+ * struct mei_dma_ring_ctrl - dma ring control block
628
+ *
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
637
+ */
638
+struct hbm_dma_ring_ctrl {
639
+ u32 hbuf_wr_idx;
640
+ u32 reserved1;
641
+ u32 hbuf_rd_idx;
642
+ u32 reserved2;
643
+ u32 dbuf_wr_idx;
644
+ u32 reserved3;
645
+ u32 dbuf_rd_idx;
646
+ u32 reserved4;
647
+} __packed;
648
+
649
+/* virtual tag supported */
650
+#define HBM_CAP_VT BIT(0)
651
+
652
+/**
653
+ * struct hbm_capability_request - capability request from host to fw
654
+ *
655
+ * @hbm_cmd : bus message command header
656
+ * @capability_requested: bitmask of capabilities requested by host
657
+ */
658
+struct hbm_capability_request {
659
+ u8 hbm_cmd;
660
+ u8 capability_requested[3];
661
+} __packed;
662
+
663
+/**
664
+ * struct hbm_capability_response - capability response from fw to host
665
+ *
666
+ * @hbm_cmd : bus message command header
667
+ * @capability_granted: bitmask of capabilities granted by FW
668
+ */
669
+struct hbm_capability_response {
670
+ u8 hbm_cmd;
671
+ u8 capability_granted[3];
672
+} __packed;
673
+
515674 #endif