xref: /linux/drivers/gpu/drm/xe/xe_guc_klv_thresholds_set.h (revision 7f4f3b14e8079ecde096bd734af10e30d40c27b7)
1 /* SPDX-License-Identifier: MIT */
2 /*
3  * Copyright © 2024 Intel Corporation
4  */
5 
6 #ifndef _XE_GUC_KLV_THRESHOLDS_SET_H_
7 #define _XE_GUC_KLV_THRESHOLDS_SET_H_
8 
9 #include "abi/guc_klvs_abi.h"
10 #include "xe_guc_klv_helpers.h"
11 #include "xe_guc_klv_thresholds_set_types.h"
12 
13 /**
14  * MAKE_GUC_KLV_VF_CFG_THRESHOLD_KEY - Prepare the name of the KLV key constant.
15  * @TAG: unique tag of the GuC threshold KLV key.
16  */
17 #define MAKE_GUC_KLV_VF_CFG_THRESHOLD_KEY(TAG) \
18 	MAKE_GUC_KLV_KEY(CONCATENATE(VF_CFG_THRESHOLD_, TAG))
19 
20 /**
21  * MAKE_GUC_KLV_VF_CFG_THRESHOLD_LEN - Prepare the name of the KLV length constant.
22  * @TAG: unique tag of the GuC threshold KLV key.
23  */
24 #define MAKE_GUC_KLV_VF_CFG_THRESHOLD_LEN(TAG) \
25 	MAKE_GUC_KLV_LEN(CONCATENATE(VF_CFG_THRESHOLD_, TAG))
26 
27 /**
28  * xe_guc_klv_threshold_key_to_index - Find index of the tracked GuC threshold.
29  * @key: GuC threshold KLV key.
30  *
31  * This translation is automatically generated using &MAKE_XE_GUC_KLV_THRESHOLDS_SET.
32  * Return: index of the GuC threshold KLV or -1 if not found.
33  */
34 static inline int xe_guc_klv_threshold_key_to_index(u32 key)
35 {
36 	switch (key) {
37 #define define_xe_guc_klv_threshold_key_to_index_case(TAG, ...)		\
38 									\
39 	case MAKE_GUC_KLV_VF_CFG_THRESHOLD_KEY(TAG):			\
40 		return MAKE_XE_GUC_KLV_THRESHOLD_INDEX(TAG);
41 
42 	/* private: auto-generated case statements */
43 	MAKE_XE_GUC_KLV_THRESHOLDS_SET(define_xe_guc_klv_threshold_key_to_index_case)
44 	}
45 	return -1;
46 #undef define_xe_guc_klv_threshold_key_to_index_case
47 }
48 
49 /**
50  * xe_guc_klv_threshold_index_to_key - Get tracked GuC threshold KLV key.
51  * @index: GuC threshold KLV index.
52  *
53  * This translation is automatically generated using &MAKE_XE_GUC_KLV_THRESHOLDS_SET.
54  * Return: key of the GuC threshold KLV or 0 on malformed index.
55  */
56 static inline u32 xe_guc_klv_threshold_index_to_key(enum xe_guc_klv_threshold_index index)
57 {
58 	switch (index) {
59 #define define_xe_guc_klv_threshold_index_to_key_case(TAG, ...)		\
60 									\
61 	case MAKE_XE_GUC_KLV_THRESHOLD_INDEX(TAG):			\
62 		return MAKE_GUC_KLV_VF_CFG_THRESHOLD_KEY(TAG);
63 
64 	/* private: auto-generated case statements */
65 	MAKE_XE_GUC_KLV_THRESHOLDS_SET(define_xe_guc_klv_threshold_index_to_key_case)
66 	}
67 	return 0; /* unreachable */
68 #undef define_xe_guc_klv_threshold_index_to_key_case
69 }
70 
71 #endif
72