1 // SPDX-License-Identifier: GPL-2.0 2 /* 3 * Copyright © 2026 Intel Corporation 4 */ 5 6 #include <kunit/test.h> 7 8 #include "xe_reg_whitelist.h" 9 #include "xe_rtp_types.h" 10 #include "xe_tuning.h" 11 #include "xe_wa.h" 12 13 #define RTP_TABLE_PARAM(table) \ 14 static const void *table##_gen_params(struct kunit *test, \ 15 const void *prev, char *desc) \ 16 { \ 17 typeof((table.entries)[0]) *__next = prev ? \ 18 ((typeof(__next))prev) + 1 : (table.entries); \ 19 if (__next - table.entries < table.n_entries) { \ 20 scnprintf(desc, KUNIT_PARAM_DESC_SIZE, #table "/%s", __next->name); \ 21 return __next; \ 22 } \ 23 return NULL; \ 24 } 25 26 static void xe_rtp_table_gt_test(struct kunit *test) 27 { 28 const struct xe_rtp_entry_sr *entry = test->param_value; 29 30 for (int i = 0; i < entry->n_rules; i++) { 31 KUNIT_EXPECT_TRUE(test, 32 entry->rules[i].match_type != XE_RTP_MATCH_ENGINE_CLASS || 33 entry->flags & XE_RTP_ENTRY_FLAG_FOREACH_ENGINE); 34 KUNIT_EXPECT_TRUE(test, 35 entry->rules[i].match_type != XE_RTP_MATCH_NOT_ENGINE_CLASS || 36 entry->flags & XE_RTP_ENTRY_FLAG_FOREACH_ENGINE); 37 } 38 } 39 40 RTP_TABLE_PARAM(gt_was); 41 RTP_TABLE_PARAM(gt_tunings); 42 43 static void xe_rtp_table_oob_test(struct kunit *test) 44 { 45 const struct xe_rtp_entry *entry = test->param_value; 46 47 for (int i = 0; i < entry->n_rules; i++) { 48 u8 match_type = entry->rules[i].match_type; 49 50 KUNIT_EXPECT_NE(test, match_type, XE_RTP_MATCH_ENGINE_CLASS); 51 KUNIT_EXPECT_NE(test, match_type, XE_RTP_MATCH_NOT_ENGINE_CLASS); 52 } 53 } 54 55 RTP_TABLE_PARAM(oob_was); 56 57 static void xe_rtp_table_dev_oob_test(struct kunit *test) 58 { 59 const struct xe_rtp_entry *entry = test->param_value; 60 61 for (int i = 0; i < entry->n_rules; i++) { 62 u8 match_type = entry->rules[i].match_type; 63 64 KUNIT_EXPECT_NE(test, match_type, XE_RTP_MATCH_ENGINE_CLASS); 65 KUNIT_EXPECT_NE(test, match_type, XE_RTP_MATCH_NOT_ENGINE_CLASS); 66 KUNIT_EXPECT_NE(test, match_type, XE_RTP_MATCH_GRAPHICS_VERSION); 67 KUNIT_EXPECT_NE(test, match_type, XE_RTP_MATCH_GRAPHICS_VERSION_RANGE); 68 KUNIT_EXPECT_NE(test, match_type, XE_RTP_MATCH_GRAPHICS_VERSION_ANY_GT); 69 KUNIT_EXPECT_NE(test, match_type, XE_RTP_MATCH_GRAPHICS_STEP); 70 KUNIT_EXPECT_NE(test, match_type, XE_RTP_MATCH_MEDIA_VERSION); 71 KUNIT_EXPECT_NE(test, match_type, XE_RTP_MATCH_MEDIA_VERSION_RANGE); 72 KUNIT_EXPECT_NE(test, match_type, XE_RTP_MATCH_MEDIA_VERSION_ANY_GT); 73 KUNIT_EXPECT_NE(test, match_type, XE_RTP_MATCH_MEDIA_STEP); 74 } 75 } 76 77 RTP_TABLE_PARAM(device_oob_was); 78 79 static void xe_rtp_table_missing_upper_bound_test(struct kunit *test) 80 { 81 const struct xe_rtp_entry_sr *entry = test->param_value; 82 83 for (int i = 0; i < entry->n_rules; i++) { 84 u8 match_type = entry->rules[i].match_type; 85 86 KUNIT_EXPECT_FALSE(test, 87 match_type == XE_RTP_MATCH_GRAPHICS_VERSION_RANGE && 88 entry->rules[i].ver_end == XE_RTP_END_VERSION_UNDEFINED); 89 KUNIT_EXPECT_FALSE(test, 90 match_type == XE_RTP_MATCH_MEDIA_VERSION_RANGE && 91 entry->rules[i].ver_end == XE_RTP_END_VERSION_UNDEFINED); 92 } 93 } 94 95 RTP_TABLE_PARAM(register_whitelist); 96 97 static struct kunit_case xe_rtp_table_tests[] = { 98 KUNIT_CASE_PARAM(xe_rtp_table_gt_test, gt_was_gen_params), 99 KUNIT_CASE_PARAM(xe_rtp_table_gt_test, gt_tunings_gen_params), 100 KUNIT_CASE_PARAM(xe_rtp_table_oob_test, oob_was_gen_params), 101 KUNIT_CASE_PARAM(xe_rtp_table_dev_oob_test, device_oob_was_gen_params), 102 KUNIT_CASE_PARAM(xe_rtp_table_missing_upper_bound_test, 103 register_whitelist_gen_params), 104 {} 105 }; 106 107 static struct kunit_suite xe_rtp_tables_test_suite = { 108 .name = "xe_rtp_tables_test", 109 .test_cases = xe_rtp_table_tests, 110 }; 111 112 kunit_test_suite(xe_rtp_tables_test_suite); 113