xref: /illumos-gate/usr/src/test/util-tests/tests/smbios/smbios_test_chassis.c (revision ba2b435afc094312a669141557d7db936139fcb7)
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 2025 Oxide Computer Company
14  */
15 
16 /*
17  * Tests for SMBIOS Type 3 - SMB_TYPE_CHASSIS.
18  */
19 
20 #include "smbios_test.h"
21 
22 static const char *smbios_chassis_mfg = "Shrina";
23 static const char *smbios_chassis_vers = "7R";
24 static const char *smbios_chassis_serial = "What's my number?";
25 static const char *smbios_chassis_asset = "lost";
26 static const char *smbios_chassis_sku = "Proud";
27 static const uint32_t smbios_chassis_oem = 0x36105997;
28 static const uint8_t smbios_chassis_uheight = 7;
29 
30 boolean_t
smbios_test_chassis_mktable_invlen_base(smbios_test_table_t * table)31 smbios_test_chassis_mktable_invlen_base(smbios_test_table_t *table)
32 {
33 	smb_header_t hdr;
34 
35 	hdr.smbh_type = SMB_TYPE_CHASSIS;
36 	hdr.smbh_len = sizeof (hdr);
37 
38 	(void) smbios_test_table_append(table, &hdr, sizeof (hdr));
39 	smbios_test_table_append_eot(table);
40 
41 	return (B_TRUE);
42 }
43 
44 static void
smbios_test_chassis_mktable_fill_chassis(smb_chassis_t * ch)45 smbios_test_chassis_mktable_fill_chassis(smb_chassis_t *ch)
46 {
47 	ch->smbch_hdr.smbh_type = SMB_TYPE_CHASSIS;
48 	ch->smbch_hdr.smbh_len = sizeof (*ch);
49 	ch->smbch_manufacturer = 1;
50 	ch->smbch_type = SMB_CHT_LUNCHBOX;
51 	ch->smbch_version = 2;
52 	ch->smbch_serial = 3;
53 	ch->smbch_asset = 4;
54 	ch->smbch_bustate = SMB_CHST_SAFE;
55 	ch->smbch_psstate = SMB_CHST_NONREC;
56 	ch->smbch_thstate = SMB_CHST_WARNING;
57 	ch->smbch_security = SMB_CHSC_NONE;
58 	ch->smbch_oemdata = htole32(smbios_chassis_oem);
59 	ch->smbch_uheight = smbios_chassis_uheight;
60 	ch->smbch_cords = smbios_chassis_uheight - 1;
61 	ch->smbch_cn = 0;
62 	ch->smbch_cm = sizeof (smb_chassis_entry_t);
63 }
64 
65 static void
smbios_test_chassis_mktable_fill_entries(smb_chassis_entry_t * ents)66 smbios_test_chassis_mktable_fill_entries(smb_chassis_entry_t *ents)
67 {
68 	ents[0].smbce_type = SMB_TYPE_COOLDEV | (1 << 7);
69 	ents[0].smbce_min = 1;
70 	ents[0].smbce_max = 42;
71 	ents[1].smbce_type = SMB_BBT_IO;
72 	ents[1].smbce_min = 5;
73 	ents[1].smbce_max = 123;
74 }
75 
76 static void
smbios_test_chassis_mktable_append_strings(smbios_test_table_t * table)77 smbios_test_chassis_mktable_append_strings(smbios_test_table_t *table)
78 {
79 	smbios_test_table_append_string(table, smbios_chassis_mfg);
80 	smbios_test_table_append_string(table, smbios_chassis_vers);
81 	smbios_test_table_append_string(table, smbios_chassis_serial);
82 	smbios_test_table_append_string(table, smbios_chassis_asset);
83 }
84 
85 /*
86  * This is an SMBIOS 2.4-esque table.
87  */
88 boolean_t
smbios_test_chassis_mktable_base(smbios_test_table_t * table)89 smbios_test_chassis_mktable_base(smbios_test_table_t *table)
90 {
91 	smb_chassis_t ch;
92 
93 	smbios_test_chassis_mktable_fill_chassis(&ch);
94 	(void) smbios_test_table_append(table, &ch, sizeof (ch));
95 	smbios_test_chassis_mktable_append_strings(table);
96 	smbios_test_table_str_fini(table);
97 	smbios_test_table_append_eot(table);
98 
99 	return (B_TRUE);
100 }
101 
102 /*
103  * A variant of the base that doesn't include the element length becaue there
104  * are no elements.
105  */
106 boolean_t
smbios_test_chassis_mktable_part(smbios_test_table_t * table)107 smbios_test_chassis_mktable_part(smbios_test_table_t *table)
108 {
109 	smb_chassis_t ch;
110 	size_t len = offsetof(smb_chassis_t, smbch_cn);
111 
112 	smbios_test_chassis_mktable_fill_chassis(&ch);
113 	ch.smbch_hdr.smbh_len = len;
114 	(void) smbios_test_table_append(table, &ch, len);
115 	smbios_test_chassis_mktable_append_strings(table);
116 	smbios_test_table_str_fini(table);
117 	smbios_test_table_append_eot(table);
118 
119 	return (B_TRUE);
120 }
121 
122 boolean_t
smbios_test_chassis_mktable_comps(smbios_test_table_t * table)123 smbios_test_chassis_mktable_comps(smbios_test_table_t *table)
124 {
125 	smb_chassis_t ch;
126 	smb_chassis_entry_t ents[2];
127 
128 	smbios_test_chassis_mktable_fill_chassis(&ch);
129 	smbios_test_chassis_mktable_fill_entries(ents);
130 	ch.smbch_cn = ARRAY_SIZE(ents);
131 	ch.smbch_hdr.smbh_len += ch.smbch_cn * ch.smbch_cm;
132 	(void) smbios_test_table_append(table, &ch, sizeof (ch));
133 	smbios_test_table_append_raw(table, ents, sizeof (ents));
134 	smbios_test_chassis_mktable_append_strings(table);
135 	smbios_test_table_str_fini(table);
136 	smbios_test_table_append_eot(table);
137 
138 	return (B_TRUE);
139 }
140 
141 boolean_t
smbios_test_chassis_mktable_sku_nocomps(smbios_test_table_t * table)142 smbios_test_chassis_mktable_sku_nocomps(smbios_test_table_t *table)
143 {
144 	smb_chassis_t ch;
145 	const uint8_t sku_str = 5;
146 
147 	smbios_test_chassis_mktable_fill_chassis(&ch);
148 	ch.smbch_hdr.smbh_len++;
149 	(void) smbios_test_table_append(table, &ch, sizeof (ch));
150 	smbios_test_table_append_raw(table, &sku_str, sizeof (sku_str));
151 	smbios_test_chassis_mktable_append_strings(table);
152 	smbios_test_table_append_string(table, smbios_chassis_sku);
153 	smbios_test_table_str_fini(table);
154 	smbios_test_table_append_eot(table);
155 
156 	return (B_TRUE);
157 }
158 
159 /*
160  * This is a version of the SKU with components, but none of the 3.9+ features.
161  */
162 boolean_t
smbios_test_chassis_mktable_sku(smbios_test_table_t * table)163 smbios_test_chassis_mktable_sku(smbios_test_table_t *table)
164 {
165 	smb_chassis_t ch;
166 	const uint8_t sku_str = 5;
167 	smb_chassis_entry_t ents[2];
168 
169 
170 	smbios_test_chassis_mktable_fill_chassis(&ch);
171 	smbios_test_chassis_mktable_fill_entries(ents);
172 	ch.smbch_cn = ARRAY_SIZE(ents);
173 	ch.smbch_hdr.smbh_len += ch.smbch_cn * ch.smbch_cm + 1;
174 	(void) smbios_test_table_append(table, &ch, sizeof (ch));
175 	smbios_test_table_append_raw(table, ents, sizeof (ents));
176 	smbios_test_table_append_raw(table, &sku_str, sizeof (sku_str));
177 	smbios_test_chassis_mktable_append_strings(table);
178 	smbios_test_table_append_string(table, smbios_chassis_sku);
179 	smbios_test_table_str_fini(table);
180 	smbios_test_table_append_eot(table);
181 
182 	return (B_TRUE);
183 }
184 
185 boolean_t
smbios_test_chassis_mktable_39(smbios_test_table_t * table)186 smbios_test_chassis_mktable_39(smbios_test_table_t *table)
187 {
188 	smb_chassis_t ch;
189 	smb_chassis_entry_t ents[2];
190 	smb_chassis_bonus_t b;
191 
192 	b.smbcb_sku = 5;
193 	b.smbcb_rtype = SMB_CRT_OU;
194 	b.smbcb_rheight = 0x77;
195 
196 	smbios_test_chassis_mktable_fill_chassis(&ch);
197 	smbios_test_chassis_mktable_fill_entries(ents);
198 	ch.smbch_cn = ARRAY_SIZE(ents);
199 	ch.smbch_hdr.smbh_len += ch.smbch_cn * ch.smbch_cm + sizeof (b);
200 	(void) smbios_test_table_append(table, &ch, sizeof (ch));
201 	smbios_test_table_append_raw(table, ents, sizeof (ents));
202 	smbios_test_table_append_raw(table, &b, sizeof (b));
203 	smbios_test_chassis_mktable_append_strings(table);
204 	smbios_test_table_append_string(table, smbios_chassis_sku);
205 	smbios_test_table_str_fini(table);
206 	smbios_test_table_append_eot(table);
207 
208 	return (B_TRUE);
209 }
210 
211 
212 boolean_t
smbios_test_chassis_verify_invlen(smbios_hdl_t * hdl)213 smbios_test_chassis_verify_invlen(smbios_hdl_t *hdl)
214 {
215 	smbios_struct_t sp;
216 	smbios_chassis_t ch;
217 
218 	if (smbios_lookup_type(hdl, SMB_TYPE_CHASSIS, &sp) == -1) {
219 		warnx("failed to lookup SMBIOS chassis: %s",
220 		    smbios_errmsg(smbios_errno(hdl)));
221 		return (B_FALSE);
222 	}
223 
224 	if (smbios_info_chassis(hdl, sp.smbstr_id, &ch) != -1) {
225 		warnx("accidentally parsed invalid chassis as valid");
226 		return (B_FALSE);
227 	}
228 
229 	if (smbios_errno(hdl) != ESMB_SHORT) {
230 		warnx("encountered wrong error for chassis, expected: "
231 		    "0x%x, found: 0x%x", ESMB_SHORT, smbios_errno(hdl));
232 		return (B_FALSE);
233 	}
234 
235 	return (B_TRUE);
236 }
237 
238 static boolean_t
smbios_test_chassis_verify_common(smbios_hdl_t * hdl,smbios_struct_t * sp,smbios_chassis_t * ch)239 smbios_test_chassis_verify_common(smbios_hdl_t *hdl, smbios_struct_t *sp,
240     smbios_chassis_t *ch)
241 {
242 	boolean_t ret = B_TRUE;
243 	smbios_info_t info;
244 
245 	if (ch->smbc_oemdata != smbios_chassis_oem) {
246 		warnx("chassis state mismatch, found unexpected oem data: 0x%x",
247 		    ch->smbc_oemdata);
248 		ret = B_FALSE;
249 	}
250 
251 	if (ch->smbc_lock != 0) {
252 		warnx("chassis state mismatch, found unexpected lock: 0x%x",
253 		    ch->smbc_lock);
254 		ret = B_FALSE;
255 	}
256 
257 	if (ch->smbc_type != SMB_CHT_LUNCHBOX) {
258 		warnx("chassis state mismatch, found unexpected type: 0x%x",
259 		    ch->smbc_type);
260 		ret = B_FALSE;
261 	}
262 
263 	if (ch->smbc_bustate != SMB_CHST_SAFE) {
264 		warnx("chassis state mismatch, found unexpected boot state: "
265 		    "0x%x", ch->smbc_bustate);
266 		ret = B_FALSE;
267 	}
268 
269 	if (ch->smbc_psstate != SMB_CHST_NONREC) {
270 		warnx("chassis state mismatch, found unexpected power state: "
271 		    "0x%x", ch->smbc_psstate);
272 		ret = B_FALSE;
273 	}
274 
275 	if (ch->smbc_thstate != SMB_CHST_WARNING) {
276 		warnx("chassis state mismatch, found unexpected thermal state: "
277 		    "0x%x", ch->smbc_thstate);
278 		ret = B_FALSE;
279 	}
280 
281 	if (ch->smbc_security != SMB_CHSC_NONE) {
282 		warnx("chassis state mismatch, found unexpected security "
283 		    "value: 0x%x", ch->smbc_security);
284 		ret = B_FALSE;
285 	}
286 
287 	if (ch->smbc_uheight != smbios_chassis_uheight) {
288 		warnx("chassis state mismatch, found unexpected uheight value: "
289 		    "0x%x", ch->smbc_uheight);
290 		ret = B_FALSE;
291 	}
292 
293 	if (ch->smbc_cords != smbios_chassis_uheight - 1) {
294 		warnx("chassis state mismatch, found unexpected cords value: "
295 		    "0x%x", ch->smbc_cords);
296 		ret = B_FALSE;
297 	}
298 
299 	if (smbios_info_common(hdl, sp->smbstr_id, &info) != 0) {
300 		warnx("failed to get common chassis info: %s",
301 		    smbios_errmsg(smbios_errno(hdl)));
302 		return (B_FALSE);
303 	}
304 
305 	if (strcmp(info.smbi_manufacturer, smbios_chassis_mfg) != 0) {
306 		warnx("chassis state mismatch, found unexpected mfg: "
307 		    "%s", info.smbi_manufacturer);
308 		ret = B_FALSE;
309 	}
310 
311 	if (strcmp(info.smbi_version, smbios_chassis_vers) != 0) {
312 		warnx("chassis state mismatch, found unexpected version: %s",
313 		    info.smbi_version);
314 		ret = B_FALSE;
315 	}
316 
317 	if (strcmp(info.smbi_serial, smbios_chassis_serial) != 0) {
318 		warnx("chassis state mismatch, found unexpected serial: %s",
319 		    info.smbi_serial);
320 		ret = B_FALSE;
321 	}
322 
323 	if (strcmp(info.smbi_asset, smbios_chassis_asset) != 0) {
324 		warnx("chassis state mismatch, found unexpected asset: %s",
325 		    info.smbi_asset);
326 		ret = B_FALSE;
327 	}
328 
329 	return (ret);
330 }
331 
332 boolean_t
smbios_test_chassis_verify_base(smbios_hdl_t * hdl)333 smbios_test_chassis_verify_base(smbios_hdl_t *hdl)
334 {
335 	boolean_t ret = B_TRUE;
336 	smbios_struct_t sp;
337 	smbios_chassis_t ch;
338 	smbios_chassis_entry_t *elts;
339 	uint_t nelts;
340 
341 	if (smbios_lookup_type(hdl, SMB_TYPE_CHASSIS, &sp) == -1) {
342 		warnx("failed to lookup SMBIOS chassis: %s",
343 		    smbios_errmsg(smbios_errno(hdl)));
344 		return (B_FALSE);
345 	}
346 
347 	if (smbios_info_chassis(hdl, sp.smbstr_id, &ch) == -1) {
348 		warnx("failed to get chassis: %s",
349 		    smbios_errmsg(smbios_errno(hdl)));
350 		return (B_FALSE);
351 	}
352 
353 	if (!smbios_test_chassis_verify_common(hdl, &sp, &ch)) {
354 		ret = B_FALSE;
355 	}
356 
357 	if (ch.smbc_elems != 0) {
358 		warnx("chassis state mismatch, found unexpected number of "
359 		    "elements: 0x%x", ch.smbc_elems);
360 		ret = B_FALSE;
361 	}
362 
363 	if (strcmp(ch.smbc_sku, "") != 0) {
364 		warnx("chassis state mismatch, found unexpected sku: %s",
365 		    ch.smbc_sku);
366 		ret = B_FALSE;
367 	}
368 
369 	if (smbios_info_chassis_elts(hdl, sp.smbstr_id, &nelts, &elts) != 0) {
370 		warnx("failed to get chassis elements: %s",
371 		    smbios_errmsg(smbios_errno(hdl)));
372 		return (B_FALSE);
373 	}
374 
375 	if (nelts != 0) {
376 		warnx("chassis state mismatch, smbios_info_chassis_elts() "
377 		    "returned a non-zero number of entries: %u", nelts);
378 		ret = B_FALSE;
379 	}
380 
381 	if (elts != NULL) {
382 		warnx("chassis state mismatch, smbios_info_chassis_elts() "
383 		    "returned a non-NULL pointer: %p", elts);
384 		ret = B_FALSE;
385 	}
386 
387 	return (ret);
388 }
389 
390 boolean_t
smbios_test_chassis_verify_sku_nocomps(smbios_hdl_t * hdl)391 smbios_test_chassis_verify_sku_nocomps(smbios_hdl_t *hdl)
392 {
393 	boolean_t ret = B_TRUE;
394 	smbios_struct_t sp;
395 	smbios_chassis_t ch;
396 	smbios_chassis_entry_t *elts;
397 	uint_t nelts;
398 
399 	if (smbios_lookup_type(hdl, SMB_TYPE_CHASSIS, &sp) == -1) {
400 		warnx("failed to lookup SMBIOS chassis: %s",
401 		    smbios_errmsg(smbios_errno(hdl)));
402 		return (B_FALSE);
403 	}
404 
405 	if (smbios_info_chassis(hdl, sp.smbstr_id, &ch) == -1) {
406 		warnx("failed to get chassis: %s",
407 		    smbios_errmsg(smbios_errno(hdl)));
408 		return (B_FALSE);
409 	}
410 
411 	if (!smbios_test_chassis_verify_common(hdl, &sp, &ch)) {
412 		ret = B_FALSE;
413 	}
414 
415 	if (ch.smbc_elems != 0) {
416 		warnx("chassis state mismatch, found unexpected number of "
417 		    "elements: 0x%x", ch.smbc_elems);
418 		ret = B_FALSE;
419 	}
420 
421 	if (ch.smbc_elemlen != sizeof (smb_chassis_entry_t)) {
422 		warnx("chassis state mismatch, found unexpected elemlen value: "
423 		    "0x%x", ch.smbc_elemlen);
424 		ret = B_FALSE;
425 	}
426 
427 	if (strcmp(ch.smbc_sku, smbios_chassis_sku) != 0) {
428 		warnx("chassis state mismatch, found unexpected sku: %s",
429 		    ch.smbc_sku);
430 		ret = B_FALSE;
431 	}
432 
433 	if (smbios_info_chassis_elts(hdl, sp.smbstr_id, &nelts, &elts) != 0) {
434 		warnx("failed to get chassis elements: %s",
435 		    smbios_errmsg(smbios_errno(hdl)));
436 		return (B_FALSE);
437 	}
438 
439 	if (nelts != 0) {
440 		warnx("chassis state mismatch, smbios_info_chassis_elts() "
441 		    "returned a non-zero number of entries: %u", nelts);
442 		ret = B_FALSE;
443 	}
444 
445 	if (elts != NULL) {
446 		warnx("chassis state mismatch, smbios_info_chassis_elts() "
447 		    "returned a non-NULL pointer: %p", elts);
448 		ret = B_FALSE;
449 	}
450 
451 
452 	return (ret);
453 }
454 
455 static boolean_t
smbios_test_chassis_verify_common_comps(smbios_hdl_t * hdl,smbios_struct_t * sp)456 smbios_test_chassis_verify_common_comps(smbios_hdl_t *hdl, smbios_struct_t *sp)
457 {
458 	boolean_t ret = B_TRUE;
459 	smbios_chassis_entry_t *elts;
460 	uint_t nelts;
461 
462 	if (smbios_info_chassis_elts(hdl, sp->smbstr_id, &nelts, &elts) != 0) {
463 		warnx("failed to get chassis elements: %s",
464 		    smbios_errmsg(smbios_errno(hdl)));
465 		return (B_FALSE);
466 	}
467 
468 	if (nelts != 2) {
469 		warnx("chassis state mismatch, smbios_info_chassis_elts() "
470 		    "returned the wrong number of entries: %u", nelts);
471 		return (B_FALSE);
472 	}
473 
474 	if (elts[0].smbce_type != SMB_CELT_SMBIOS) {
475 		warnx("chassis elts[0] type mismatch, found: %u",
476 		    elts[0].smbce_type);
477 		ret = B_FALSE;
478 	}
479 
480 	if (elts[0].smbce_elt != SMB_TYPE_COOLDEV) {
481 		warnx("chassis elts[0] elt type mismatch, found: %u",
482 		    elts[0].smbce_elt);
483 		ret = B_FALSE;
484 	}
485 
486 	if (elts[0].smbce_min != 1) {
487 		warnx("chassis elts[0] minimum number mismatch, found: %u",
488 		    elts[0].smbce_min);
489 		ret = B_FALSE;
490 	}
491 
492 	if (elts[0].smbce_max != 42) {
493 		warnx("chassis elts[0] maximum number mismatch, found: %u",
494 		    elts[0].smbce_max);
495 		ret = B_FALSE;
496 	}
497 
498 	if (elts[1].smbce_type != SMB_CELT_BBOARD) {
499 		warnx("chassis elts[1] type mismatch, found: %u",
500 		    elts[1].smbce_type);
501 		ret = B_FALSE;
502 	}
503 
504 	if (elts[1].smbce_elt != SMB_BBT_IO) {
505 		warnx("chassis elts[1] elt type mismatch, found: %u",
506 		    elts[1].smbce_elt);
507 		ret = B_FALSE;
508 	}
509 
510 	if (elts[1].smbce_min != 5) {
511 		warnx("chassis elts[1] minimum number mismatch, found: %u",
512 		    elts[1].smbce_min);
513 		ret = B_FALSE;
514 	}
515 
516 	if (elts[1].smbce_max != 123) {
517 		warnx("chassis elts[1] maximum number mismatch, found: %u",
518 		    elts[1].smbce_max);
519 		ret = B_FALSE;
520 	}
521 	return (ret);
522 }
523 
524 boolean_t
smbios_test_chassis_verify_comps(smbios_hdl_t * hdl)525 smbios_test_chassis_verify_comps(smbios_hdl_t *hdl)
526 {
527 	boolean_t ret = B_TRUE;
528 	smbios_struct_t sp;
529 	smbios_chassis_t ch;
530 
531 	if (smbios_lookup_type(hdl, SMB_TYPE_CHASSIS, &sp) == -1) {
532 		warnx("failed to lookup SMBIOS chassis: %s",
533 		    smbios_errmsg(smbios_errno(hdl)));
534 		return (B_FALSE);
535 	}
536 
537 	if (smbios_info_chassis(hdl, sp.smbstr_id, &ch) == -1) {
538 		warnx("failed to get chassis: %s",
539 		    smbios_errmsg(smbios_errno(hdl)));
540 		return (B_FALSE);
541 	}
542 
543 	if (!smbios_test_chassis_verify_common(hdl, &sp, &ch)) {
544 		ret = B_FALSE;
545 	}
546 
547 	if (ch.smbc_elems != 2) {
548 		warnx("chassis state mismatch, found unexpected number of "
549 		    "elements: 0x%x", ch.smbc_elems);
550 		ret = B_FALSE;
551 	}
552 
553 	if (ch.smbc_elemlen != sizeof (smb_chassis_entry_t)) {
554 		warnx("chassis state mismatch, found unexpected elemlen value: "
555 		    "0x%x", ch.smbc_elemlen);
556 		ret = B_FALSE;
557 	}
558 
559 	if (strcmp(ch.smbc_sku, "") != 0) {
560 		warnx("chassis state mismatch, found unexpected sku: %s",
561 		    ch.smbc_sku);
562 		ret = B_FALSE;
563 	}
564 
565 	if (!smbios_test_chassis_verify_common_comps(hdl, &sp)) {
566 		ret = B_FALSE;
567 	}
568 
569 	return (ret);
570 }
571 
572 
573 boolean_t
smbios_test_chassis_verify_sku(smbios_hdl_t * hdl)574 smbios_test_chassis_verify_sku(smbios_hdl_t *hdl)
575 {
576 	boolean_t ret = B_TRUE;
577 	smbios_struct_t sp;
578 	smbios_chassis_t ch;
579 
580 	if (smbios_lookup_type(hdl, SMB_TYPE_CHASSIS, &sp) == -1) {
581 		warnx("failed to lookup SMBIOS chassis: %s",
582 		    smbios_errmsg(smbios_errno(hdl)));
583 		return (B_FALSE);
584 	}
585 
586 	if (smbios_info_chassis(hdl, sp.smbstr_id, &ch) == -1) {
587 		warnx("failed to get chassis: %s",
588 		    smbios_errmsg(smbios_errno(hdl)));
589 		return (B_FALSE);
590 	}
591 
592 	if (!smbios_test_chassis_verify_common(hdl, &sp, &ch)) {
593 		ret = B_FALSE;
594 	}
595 
596 	if (ch.smbc_elems != 2) {
597 		warnx("chassis state mismatch, found unexpected number of "
598 		    "elements: 0x%x", ch.smbc_elems);
599 		ret = B_FALSE;
600 	}
601 
602 	if (ch.smbc_elemlen != sizeof (smb_chassis_entry_t)) {
603 		warnx("chassis state mismatch, found unexpected elemlen value: "
604 		    "0x%x", ch.smbc_elemlen);
605 		ret = B_FALSE;
606 	}
607 
608 	if (strcmp(ch.smbc_sku, smbios_chassis_sku) != 0) {
609 		warnx("chassis state mismatch, found unexpected sku: %s",
610 		    ch.smbc_sku);
611 		ret = B_FALSE;
612 	}
613 
614 	if (!smbios_test_chassis_verify_common_comps(hdl, &sp)) {
615 		ret = B_FALSE;
616 	}
617 
618 	return (ret);
619 }
620 
621 boolean_t
smbios_test_chassis_verify_39(smbios_hdl_t * hdl)622 smbios_test_chassis_verify_39(smbios_hdl_t *hdl)
623 {
624 	boolean_t ret = B_TRUE;
625 	smbios_struct_t sp;
626 	smbios_chassis_t ch;
627 
628 	if (smbios_lookup_type(hdl, SMB_TYPE_CHASSIS, &sp) == -1) {
629 		warnx("failed to lookup SMBIOS chassis: %s",
630 		    smbios_errmsg(smbios_errno(hdl)));
631 		return (B_FALSE);
632 	}
633 
634 	if (smbios_info_chassis(hdl, sp.smbstr_id, &ch) == -1) {
635 		warnx("failed to get chassis: %s",
636 		    smbios_errmsg(smbios_errno(hdl)));
637 		return (B_FALSE);
638 	}
639 
640 	if (!smbios_test_chassis_verify_common(hdl, &sp, &ch)) {
641 		ret = B_FALSE;
642 	}
643 
644 	if (ch.smbc_elems != 2) {
645 		warnx("chassis state mismatch, found unexpected number of "
646 		    "elements: 0x%x", ch.smbc_elems);
647 		ret = B_FALSE;
648 	}
649 
650 	if (ch.smbc_elemlen != sizeof (smb_chassis_entry_t)) {
651 		warnx("chassis state mismatch, found unexpected elemlen value: "
652 		    "0x%x", ch.smbc_elemlen);
653 		ret = B_FALSE;
654 	}
655 
656 	if (strcmp(ch.smbc_sku, smbios_chassis_sku) != 0) {
657 		warnx("chassis state mismatch, found unexpected sku: %s",
658 		    ch.smbc_sku);
659 		ret = B_FALSE;
660 	}
661 
662 	if (!smbios_test_chassis_verify_common_comps(hdl, &sp)) {
663 		ret = B_FALSE;
664 	}
665 
666 	if (ch.smbc_rtype != SMB_CRT_OU) {
667 		warnx("chassis state mismatch, found unexpected rack type "
668 		    "value: 0x%x", ch.smbc_rtype);
669 		ret = B_FALSE;
670 	}
671 
672 	if (ch.smbc_rheight != 0x77) {
673 		warnx("chassis state mismatch, found unexpected rack height "
674 		    "value: 0x%x", ch.smbc_rheight);
675 		ret = B_FALSE;
676 	}
677 
678 	return (ret);
679 }
680 
681 /*
682  * Verify the variant version of the table with the old embedded sku variant.
683  */
684 boolean_t
smbios_test_chassis_verify_sku_pre35(smbios_hdl_t * hdl)685 smbios_test_chassis_verify_sku_pre35(smbios_hdl_t *hdl)
686 {
687 	boolean_t ret = B_TRUE;
688 	smbios_struct_t sp;
689 	smb_chassis_pre35_t ch;
690 	smbios_info_t info;
691 
692 	if (smbios_lookup_type(hdl, SMB_TYPE_CHASSIS, &sp) == -1) {
693 		warnx("failed to lookup SMBIOS chassis: %s",
694 		    smbios_errmsg(smbios_errno(hdl)));
695 		return (B_FALSE);
696 	}
697 
698 	if (smbios_info_chassis(hdl, sp.smbstr_id,
699 	    (smbios_chassis_t *)&ch) == -1) {
700 		warnx("failed to get chassis: %s",
701 		    smbios_errmsg(smbios_errno(hdl)));
702 		return (B_FALSE);
703 	}
704 
705 	if (ch.smbc_oemdata != smbios_chassis_oem) {
706 		warnx("chassis state mismatch, found unexpected oem data: 0x%x",
707 		    ch.smbc_oemdata);
708 		ret = B_FALSE;
709 	}
710 
711 	if (ch.smbc_lock != 0) {
712 		warnx("chassis state mismatch, found unexpected lock: 0x%x",
713 		    ch.smbc_lock);
714 		ret = B_FALSE;
715 	}
716 
717 	if (ch.smbc_type != SMB_CHT_LUNCHBOX) {
718 		warnx("chassis state mismatch, found unexpected type: 0x%x",
719 		    ch.smbc_type);
720 		ret = B_FALSE;
721 	}
722 
723 	if (ch.smbc_bustate != SMB_CHST_SAFE) {
724 		warnx("chassis state mismatch, found unexpected boot state: "
725 		    "0x%x", ch.smbc_bustate);
726 		ret = B_FALSE;
727 	}
728 
729 	if (ch.smbc_psstate != SMB_CHST_NONREC) {
730 		warnx("chassis state mismatch, found unexpected power state: "
731 		    "0x%x", ch.smbc_psstate);
732 		ret = B_FALSE;
733 	}
734 
735 	if (ch.smbc_thstate != SMB_CHST_WARNING) {
736 		warnx("chassis state mismatch, found unexpected thermal state: "
737 		    "0x%x", ch.smbc_thstate);
738 		ret = B_FALSE;
739 	}
740 
741 	if (ch.smbc_security != SMB_CHSC_NONE) {
742 		warnx("chassis state mismatch, found unexpected security "
743 		    "value: 0x%x", ch.smbc_security);
744 		ret = B_FALSE;
745 	}
746 
747 	if (ch.smbc_uheight != smbios_chassis_uheight) {
748 		warnx("chassis state mismatch, found unexpected uheight value: "
749 		    "0x%x", ch.smbc_uheight);
750 		ret = B_FALSE;
751 	}
752 
753 	if (ch.smbc_cords != smbios_chassis_uheight - 1) {
754 		warnx("chassis state mismatch, found unexpected cords value: "
755 		    "0x%x", ch.smbc_cords);
756 		ret = B_FALSE;
757 	}
758 
759 	if (smbios_info_common(hdl, sp.smbstr_id, &info) != 0) {
760 		warnx("failed to get common chassis info: %s",
761 		    smbios_errmsg(smbios_errno(hdl)));
762 		return (B_FALSE);
763 	}
764 
765 	if (strcmp(info.smbi_manufacturer, smbios_chassis_mfg) != 0) {
766 		warnx("chassis state mismatch, found unexpected mfg: "
767 		    "%s", info.smbi_manufacturer);
768 		ret = B_FALSE;
769 	}
770 
771 	if (strcmp(info.smbi_version, smbios_chassis_vers) != 0) {
772 		warnx("chassis state mismatch, found unexpected version: %s",
773 		    info.smbi_version);
774 		ret = B_FALSE;
775 	}
776 
777 	if (strcmp(info.smbi_serial, smbios_chassis_serial) != 0) {
778 		warnx("chassis state mismatch, found unexpected serial: %s",
779 		    info.smbi_serial);
780 		ret = B_FALSE;
781 	}
782 
783 	if (strcmp(info.smbi_asset, smbios_chassis_asset) != 0) {
784 		warnx("chassis state mismatch, found unexpected asset: %s",
785 		    info.smbi_asset);
786 		ret = B_FALSE;
787 	}
788 
789 
790 	if (ch.smbc_elems != 2) {
791 		warnx("chassis state mismatch, found unexpected number of "
792 		    "elements: 0x%x", ch.smbc_elems);
793 		ret = B_FALSE;
794 	}
795 
796 	if (ch.smbc_elemlen != sizeof (smb_chassis_entry_t)) {
797 		warnx("chassis state mismatch, found unexpected elemlen value: "
798 		    "0x%x", ch.smbc_elemlen);
799 		ret = B_FALSE;
800 	}
801 
802 	if (strcmp(ch.smbc_sku, smbios_chassis_sku) != 0) {
803 		warnx("chassis state mismatch, found unexpected sku: %s",
804 		    ch.smbc_sku);
805 		ret = B_FALSE;
806 	}
807 
808 	if (!smbios_test_chassis_verify_common_comps(hdl, &sp)) {
809 		ret = B_FALSE;
810 	}
811 
812 	return (ret);
813 }
814