9820 Want risc-v disassembler
[unleashed.git] / usr / src / test / util-tests / tests / libsff / libsff_8636_extspec.c
blob03d58658f6b053314a5a009ae1f6e4fb88f1c4cb
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.
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.
13 * Copyright (c) 2017, Joyent, Inc.
17 * Print all SFF 8636 / 8024 extended specification values
20 #include <stdio.h>
21 #include <errno.h>
22 #include <strings.h>
23 #include <err.h>
24 #include <libsff.h>
27 * Pick up private sff header file with offsets from lib/libsff.
29 #include "sff.h"
31 int
32 main(void)
34 uint_t i;
35 uint8_t buf[256];
37 bzero(buf, sizeof (buf));
38 buf[SFF_8472_IDENTIFIER] = SFF_8024_ID_QSFP;
39 for (i = 0; i < UINT8_MAX; i++) {
40 int ret;
41 nvlist_t *nvl;
42 char *val;
44 buf[SFF_8636_LINK_CODES] = i;
45 if ((ret = libsff_parse(buf, sizeof (buf), 0xa0, &nvl)) != 0) {
46 errx(1, "TEST FAILED: failed to parse QSFP link code "
47 "%d: %s\n", i, strerror(errno));
50 if ((ret = nvlist_lookup_string(nvl, LIBSFF_KEY_EXT_SPEC,
51 &val)) != 0) {
52 errx(1, "TEST FAILED: failed to find key %s with "
53 "value %d: %s", LIBSFF_KEY_EXT_SPEC, i,
54 strerror(ret));
57 (void) puts(val);
58 nvlist_free(nvl);
61 return (0);