xref: /linux/drivers/gpu/drm/xe/xe_rtp_types.h (revision 889600e21e3be388a6817c2a0dac0411df860751)
1 /* SPDX-License-Identifier: MIT */
2 /*
3  * Copyright © 2022 Intel Corporation
4  */
5 
6 #ifndef _XE_RTP_TYPES_H_
7 #define _XE_RTP_TYPES_H_
8 
9 #include <linux/types.h>
10 
11 #include "regs/xe_reg_defs.h"
12 
13 struct xe_device;
14 struct xe_hw_engine;
15 struct xe_gt;
16 
17 /**
18  * struct xe_rtp_action - action to take for any matching rule
19  *
20  * This struct records what action should be taken in a register that has a
21  * matching rule. Example of actions: set/clear bits.
22  */
23 struct xe_rtp_action {
24 	/** @reg: Register */
25 	struct xe_reg reg;
26 
27 	/**
28 	 * @clr_bits: bits to clear when updating register. It's always a
29 	 * superset of bits being modified
30 	 */
31 	u32 clr_bits;
32 
33 	union {
34 		/** @set_bits: bits to set when updating register */
35 		u32 set_bits;
36 
37 		/** @set_func: function to provide bits to set when updating register */
38 		u32 (*set_func)(struct xe_gt *gt,
39 				struct xe_hw_engine *hwe);
40 	};
41 
42 #define XE_RTP_NOCHECK		.read_mask = 0
43 	/** @read_mask: mask for bits to consider when reading value back */
44 	u32 read_mask;
45 
46 #define XE_RTP_ACTION_FLAG_ENGINE_BASE		BIT(0)
47 	/** @flags: flags to apply on rule evaluation or action */
48 	u8 flags;
49 
50 	/**
51 	 * @use_func:
52 	 *   Internal flag indicating @set_func should be called instead of
53 	 *   using @set_bits.
54 	 */
55 	u8 use_func:1;
56 };
57 
58 enum {
59 	XE_RTP_MATCH_PLATFORM,
60 	XE_RTP_MATCH_SUBPLATFORM,
61 	XE_RTP_MATCH_PLATFORM_STEP,
62 	XE_RTP_MATCH_GRAPHICS_VERSION,
63 	XE_RTP_MATCH_GRAPHICS_VERSION_RANGE,
64 	XE_RTP_MATCH_GRAPHICS_VERSION_ANY_GT,
65 	XE_RTP_MATCH_GRAPHICS_STEP,
66 	XE_RTP_MATCH_MEDIA_VERSION,
67 	XE_RTP_MATCH_MEDIA_VERSION_RANGE,
68 	XE_RTP_MATCH_MEDIA_VERSION_ANY_GT,
69 	XE_RTP_MATCH_MEDIA_STEP,
70 	XE_RTP_MATCH_INTEGRATED,
71 	XE_RTP_MATCH_DISCRETE,
72 	XE_RTP_MATCH_ENGINE_CLASS,
73 	XE_RTP_MATCH_NOT_ENGINE_CLASS,
74 	XE_RTP_MATCH_FUNC,
75 	XE_RTP_MATCH_OR,
76 };
77 
78 /** struct xe_rtp_rule - match rule for processing entry */
79 struct xe_rtp_rule {
80 	u8 match_type;
81 
82 	/* match filters */
83 	union {
84 		/* MATCH_PLATFORM / MATCH_SUBPLATFORM */
85 		struct {
86 			u8 platform;
87 			u8 subplatform;
88 		};
89 
90 		/*
91 		 * MATCH_GRAPHICS_VERSION / XE_RTP_MATCH_GRAPHICS_VERSION_RANGE /
92 		 * MATCH_MEDIA_VERSION  / XE_RTP_MATCH_MEDIA_VERSION_RANGE
93 		 */
94 		struct {
95 			u32 ver_start;
96 #define XE_RTP_END_VERSION_UNDEFINED	U32_MAX
97 			u32 ver_end;
98 		};
99 
100 		/* MATCH_STEP */
101 		struct {
102 			u8 step_start;
103 			u8 step_end;
104 		};
105 
106 		/* MATCH_ENGINE_CLASS / MATCH_NOT_ENGINE_CLASS */
107 		struct {
108 			u8 engine_class;
109 		};
110 
111 		/* MATCH_FUNC */
112 		bool (*match_func)(const struct xe_device *xe,
113 				   const struct xe_gt *gt,
114 				   const struct xe_hw_engine *hwe);
115 	};
116 };
117 
118 /** struct xe_rtp_entry_sr - Entry in an rtp table */
119 struct xe_rtp_entry_sr {
120 	const char *name;
121 	const struct xe_rtp_action *actions;
122 	const struct xe_rtp_rule *rules;
123 	u8 n_rules;
124 	u8 n_actions;
125 #define XE_RTP_ENTRY_FLAG_FOREACH_ENGINE	BIT(0)
126 	u8 flags;
127 };
128 
129 /** struct xe_rtp_entry - Entry in an rtp table, with no action associated */
130 struct xe_rtp_entry {
131 	const char *name;
132 	const struct xe_rtp_rule *rules;
133 	u8 n_rules;
134 };
135 
136 struct xe_rtp_table_sr {
137 	const struct xe_rtp_entry_sr *entries;
138 	size_t n_entries;
139 };
140 
141 struct xe_rtp_table {
142 	const struct xe_rtp_entry *entries;
143 	size_t n_entries;
144 };
145 
146 enum xe_rtp_process_type {
147 	XE_RTP_PROCESS_TYPE_DEVICE,
148 	XE_RTP_PROCESS_TYPE_GT,
149 	XE_RTP_PROCESS_TYPE_ENGINE,
150 };
151 
152 struct xe_rtp_process_ctx {
153 	union {
154 		struct xe_device *xe;
155 		struct xe_gt *gt;
156 		struct xe_hw_engine *hwe;
157 	};
158 	enum xe_rtp_process_type type;
159 	unsigned long *active_entries;
160 	size_t n_entries;
161 };
162 
163 #endif
164