1 /*
2  * This file and its contents are supplied under the terms of the
3  * Common Development and Distribution License ("CDDL"), version 1.0.
4  * You may only use this file in accordance with the terms of version
5  * 1.0 of the CDDL.
6  *
7  * A full copy of the text of the CDDL should have accompanied this
8  * source.  A copy of the CDDL is also available via the Internet at
9  * http://www.illumos.org/license/CDDL.
10  */
11 
12 /*
13  * Copyright 2019 Joyent, Inc.
14  */
15 
16 #include "imc_test.h"
17 
18 /*
19  * Verify that we properly detect loops on Skylake based multi-socket systems.
20  * This represents an erroneous condition.
21  */
22 
23 /*
24  * This is a multi-socket bare bones Skylake structure (we don't bother with
25  * anything past the SAD as we should never need it. This checks to make sure
26  * that we detect such a loop.
27  */
28 static const imc_t imc_skx_loop_2s = {
29 	.imc_gen = IMC_GEN_SKYLAKE,
30 	.imc_nsockets = 2,
31 	.imc_sockets[0] = {
32 		.isock_nodeid = 0,
33 		.isock_valid = IMC_SOCKET_V_VALID,
34 		.isock_sad = {
35 			.isad_flags = 0,
36 			.isad_valid = IMC_SAD_V_VALID,
37 			.isad_tolm = 0x80000000,
38 			.isad_tohm = 0,
39 			.isad_nrules = 24,
40 			.isad_rules[0] = {
41 				.isr_enable = B_TRUE,
42 				.isr_limit = 0x80000000,
43 				.isr_imode = IMC_SAD_IMODE_8t6,
44 				.isr_ntargets = IMC_MAX_SAD_INTERLEAVE,
45 				.isr_targets = { 1, 1, 1, 1, 1, 1, 1, 1 }
46 			},
47 			.isad_mcroute = {
48 				.ismc_nroutes = 6,
49 				.ismc_mcroutes[0] = { 0, 0 },
50 			}
51 		}
52 	},
53 	.imc_sockets[1] = {
54 		.isock_nodeid = 1,
55 		.isock_valid = IMC_SOCKET_V_VALID,
56 		.isock_sad = {
57 			.isad_flags = 0,
58 			.isad_valid = IMC_SAD_V_VALID,
59 			.isad_tolm = 0x80000000,
60 			.isad_tohm = 0,
61 			.isad_nrules = 24,
62 			.isad_rules[0] = {
63 				.isr_enable = B_TRUE,
64 				.isr_limit = 0x80000000,
65 				.isr_imode = IMC_SAD_IMODE_8t6,
66 				.isr_ntargets = IMC_MAX_SAD_INTERLEAVE,
67 				.isr_targets = { 0, 0, 0, 0, 0, 0, 0, 0 }
68 			},
69 			.isad_mcroute = {
70 				.ismc_nroutes = 6,
71 				.ismc_mcroutes[0] = { 0, 0 },
72 			}
73 		}
74 	}
75 };
76 
77 /*
78  * This has a target that causes us to loop back to ourselves.
79  */
80 static const imc_t imc_skx_loop_self = {
81 	.imc_gen = IMC_GEN_SKYLAKE,
82 	.imc_nsockets = 1,
83 	.imc_sockets[0] = {
84 		.isock_nodeid = 0,
85 		.isock_valid = IMC_SOCKET_V_VALID,
86 		.isock_sad = {
87 			.isad_flags = 0,
88 			.isad_valid = IMC_SAD_V_VALID,
89 			.isad_tolm = 0x80000000,
90 			.isad_tohm = 0,
91 			.isad_nrules = 24,
92 			.isad_rules[0] = {
93 				.isr_enable = B_TRUE,
94 				.isr_limit = 0x80000000,
95 				.isr_imode = IMC_SAD_IMODE_8t6,
96 				.isr_ntargets = IMC_MAX_SAD_INTERLEAVE,
97 				.isr_targets = { 0, 0, 0, 0, 0, 0, 0, 0 }
98 			},
99 			.isad_mcroute = {
100 				.ismc_nroutes = 6,
101 				.ismc_mcroutes[0] = { 0, 0 },
102 			}
103 		}
104 	}
105 };
106 
107 /*
108  * This referes to a non-existant socket in the search loop.
109  */
110 static const imc_t imc_skx_loop_badsock = {
111 	.imc_gen = IMC_GEN_SKYLAKE,
112 	.imc_nsockets = 1,
113 	.imc_sockets[0] = {
114 		.isock_nodeid = 0,
115 		.isock_valid = IMC_SOCKET_V_VALID,
116 		.isock_sad = {
117 			.isad_flags = 0,
118 			.isad_valid = IMC_SAD_V_VALID,
119 			.isad_tolm = 0x80000000,
120 			.isad_tohm = 0,
121 			.isad_nrules = 24,
122 			.isad_rules[0] = {
123 				.isr_enable = B_TRUE,
124 				.isr_limit = 0x80000000,
125 				.isr_imode = IMC_SAD_IMODE_8t6,
126 				.isr_ntargets = IMC_MAX_SAD_INTERLEAVE,
127 				.isr_targets = { 5, 5, 5, 5, 5, 5, 5, 5 }
128 			},
129 			.isad_mcroute = {
130 				.ismc_nroutes = 6,
131 				.ismc_mcroutes[0] = { 0, 0 },
132 			}
133 		}
134 	}
135 };
136 
137 const imc_test_case_t imc_test_skx_loop[] = { {
138 	.itc_desc = "Skylake loop detection, 2s (1)",
139 	.itc_imc = &imc_skx_loop_2s,
140 	.itc_pa = 0x0,
141 	.itc_pass = B_FALSE,
142 	.itc_fail = IMC_DECODE_F_SAD_SEARCH_LOOP
143 }, {
144 	.itc_desc = "Skylake loop detection, 2s (2)",
145 	.itc_imc = &imc_skx_loop_2s,
146 	.itc_pa = 0x7fffffff,
147 	.itc_pass = B_FALSE,
148 	.itc_fail = IMC_DECODE_F_SAD_SEARCH_LOOP
149 }, {
150 	.itc_desc = "Skylake loop detection, self (1)",
151 	.itc_imc = &imc_skx_loop_self,
152 	.itc_pa = 0x0,
153 	.itc_pass = B_FALSE,
154 	.itc_fail = IMC_DECODE_F_SAD_SEARCH_LOOP
155 }, {
156 	.itc_desc = "Skylake loop detection, self (2)",
157 	.itc_imc = &imc_skx_loop_self,
158 	.itc_pa = 0x7fffffff,
159 	.itc_pass = B_FALSE,
160 	.itc_fail = IMC_DECODE_F_SAD_SEARCH_LOOP
161 }, {
162 	.itc_desc = "Skylake loop detection, bad sock (1)",
163 	.itc_imc = &imc_skx_loop_badsock,
164 	.itc_pa = 0x0,
165 	.itc_pass = B_FALSE,
166 	.itc_fail = IMC_DECODE_F_BAD_REMOTE_MC_ROUTE
167 }, {
168 	.itc_desc = "Skylake loop detection, bad sock (2)",
169 	.itc_imc = &imc_skx_loop_badsock,
170 	.itc_pa = 0x7fffffff,
171 	.itc_pass = B_FALSE,
172 	.itc_fail = IMC_DECODE_F_BAD_REMOTE_MC_ROUTE
173 }, {
174 	.itc_desc = NULL
175 } };
176