1 /* SPDX-License-Identifier: MIT */
2 /*
3  * Copyright © 2023 Intel Corporation
4  */
5 
6 #ifndef _INTEL_GSC_UC_HECI_CMD_SUBMIT_H_
7 #define _INTEL_GSC_UC_HECI_CMD_SUBMIT_H_
8 
9 #include <linux/types.h>
10 
11 struct i915_vma;
12 struct intel_context;
13 struct intel_gsc_uc;
14 
15 struct intel_gsc_mtl_header {
16 	u32 validity_marker;
17 #define GSC_HECI_VALIDITY_MARKER 0xA578875A
18 
19 	u8 heci_client_id;
20 #define HECI_MEADDRESS_MKHI 7
21 #define HECI_MEADDRESS_PROXY 10
22 #define HECI_MEADDRESS_PXP 17
23 #define HECI_MEADDRESS_HDCP 18
24 
25 	u8 reserved1;
26 
27 	u16 header_version;
28 #define MTL_GSC_HEADER_VERSION 1
29 
30 	/*
31 	 * FW allows host to decide host_session handle
32 	 * as it sees fit.
33 	 * For intertracebility reserving select bits(60-63)
34 	 * to differentiate caller-target subsystem
35 	 * 0000 - HDCP
36 	 * 0001 - PXP Single Session
37 	 */
38 	u64 host_session_handle;
39 #define HOST_SESSION_MASK	REG_GENMASK64(63, 60)
40 #define HOST_SESSION_PXP_SINGLE BIT_ULL(60)
41 	u64 gsc_message_handle;
42 
43 	u32 message_size; /* lower 20 bits only, upper 12 are reserved */
44 
45 	/*
46 	 * Flags mask:
47 	 * Bit 0: Pending
48 	 * Bit 1: Session Cleanup;
49 	 * Bits 2-15: Flags
50 	 * Bits 16-31: Extension Size
51 	 * According to internal spec flags are either input or output
52 	 * we distinguish the flags using OUTFLAG or INFLAG
53 	 */
54 	u32 flags;
55 #define GSC_OUTFLAG_MSG_PENDING	BIT(0)
56 #define GSC_INFLAG_MSG_CLEANUP	BIT(1)
57 
58 	u32 status;
59 } __packed;
60 
61 int intel_gsc_uc_heci_cmd_submit_packet(struct intel_gsc_uc *gsc,
62 					u64 addr_in, u32 size_in,
63 					u64 addr_out, u32 size_out);
64 void intel_gsc_uc_heci_cmd_emit_mtl_header(struct intel_gsc_mtl_header *header,
65 					   u8 heci_client_id, u32 message_size,
66 					   u64 host_session_id);
67 
68 struct intel_gsc_heci_non_priv_pkt {
69 	u64 addr_in;
70 	u32 size_in;
71 	u64 addr_out;
72 	u32 size_out;
73 	struct i915_vma *heci_pkt_vma;
74 	struct i915_vma *bb_vma;
75 };
76 
77 void
78 intel_gsc_uc_heci_cmd_emit_mtl_header(struct intel_gsc_mtl_header *header,
79 				      u8 heci_client_id, u32 msg_size,
80 				      u64 host_session_id);
81 
82 int
83 intel_gsc_uc_heci_cmd_submit_nonpriv(struct intel_gsc_uc *gsc,
84 				     struct intel_context *ce,
85 				     struct intel_gsc_heci_non_priv_pkt *pkt,
86 				     u32 *cs, int timeout_ms);
87 #endif
88