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