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
13struct xe_device;
14struct xe_hw_engine;
15struct 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 */
23struct xe_rtp_action {
24 /** @reg: Register */
25 struct xe_reg reg;
26 /**
27 * @clr_bits: bits to clear when updating register. It's always a
28 * superset of bits being modified
29 */
30 u32 clr_bits;
31 /** @set_bits: bits to set when updating register */
32 u32 set_bits;
33#define XE_RTP_NOCHECK .read_mask = 0
34 /** @read_mask: mask for bits to consider when reading value back */
35 u32 read_mask;
36#define XE_RTP_ACTION_FLAG_ENGINE_BASE BIT(0)
37 /** @flags: flags to apply on rule evaluation or action */
38 u8 flags;
39};
40
41enum {
42 XE_RTP_MATCH_PLATFORM,
43 XE_RTP_MATCH_SUBPLATFORM,
44 XE_RTP_MATCH_GRAPHICS_VERSION,
45 XE_RTP_MATCH_GRAPHICS_VERSION_RANGE,
46 XE_RTP_MATCH_GRAPHICS_VERSION_ANY_GT,
47 XE_RTP_MATCH_GRAPHICS_STEP,
48 XE_RTP_MATCH_MEDIA_VERSION,
49 XE_RTP_MATCH_MEDIA_VERSION_RANGE,
50 XE_RTP_MATCH_MEDIA_VERSION_ANY_GT,
51 XE_RTP_MATCH_MEDIA_STEP,
52 XE_RTP_MATCH_INTEGRATED,
53 XE_RTP_MATCH_DISCRETE,
54 XE_RTP_MATCH_ENGINE_CLASS,
55 XE_RTP_MATCH_NOT_ENGINE_CLASS,
56 XE_RTP_MATCH_FUNC,
57 XE_RTP_MATCH_OR,
58};
59
60/** struct xe_rtp_rule - match rule for processing entry */
61struct xe_rtp_rule {
62 u8 match_type;
63
64 /* match filters */
65 union {
66 /* MATCH_PLATFORM / MATCH_SUBPLATFORM */
67 struct {
68 u8 platform;
69 u8 subplatform;
70 };
71 /*
72 * MATCH_GRAPHICS_VERSION / XE_RTP_MATCH_GRAPHICS_VERSION_RANGE /
73 * MATCH_MEDIA_VERSION / XE_RTP_MATCH_MEDIA_VERSION_RANGE
74 */
75 struct {
76 u32 ver_start;
77#define XE_RTP_END_VERSION_UNDEFINED U32_MAX
78 u32 ver_end;
79 };
80 /* MATCH_STEP */
81 struct {
82 u8 step_start;
83 u8 step_end;
84 };
85 /* MATCH_ENGINE_CLASS / MATCH_NOT_ENGINE_CLASS */
86 struct {
87 u8 engine_class;
88 };
89 /* MATCH_FUNC */
90 bool (*match_func)(const struct xe_device *xe,
91 const struct xe_gt *gt,
92 const struct xe_hw_engine *hwe);
93 };
94};
95
96/** struct xe_rtp_entry_sr - Entry in an rtp table */
97struct xe_rtp_entry_sr {
98 const char *name;
99 const struct xe_rtp_action *actions;
100 const struct xe_rtp_rule *rules;
101 u8 n_rules;
102 u8 n_actions;
103#define XE_RTP_ENTRY_FLAG_FOREACH_ENGINE BIT(0)
104 u8 flags;
105};
106
107/** struct xe_rtp_entry - Entry in an rtp table, with no action associated */
108struct xe_rtp_entry {
109 const char *name;
110 const struct xe_rtp_rule *rules;
111 u8 n_rules;
112};
113
114enum xe_rtp_process_type {
115 XE_RTP_PROCESS_TYPE_DEVICE,
116 XE_RTP_PROCESS_TYPE_GT,
117 XE_RTP_PROCESS_TYPE_ENGINE,
118};
119
120struct xe_rtp_process_ctx {
121 union {
122 struct xe_device *xe;
123 struct xe_gt *gt;
124 struct xe_hw_engine *hwe;
125 };
126 enum xe_rtp_process_type type;
127 unsigned long *active_entries;
128 size_t n_entries;
129};
130
131#endif
132

source code of linux/drivers/gpu/drm/xe/xe_rtp_types.h