8699 Want NIC transceiver visibility
[unleashed.git] / usr / src / test / util-tests / tests / libsff / libsff_8636_diag.c
blobbf84ea9f390da4f764b7381870b55a7c3cb7f871
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 diagnostic monitoring
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 int ret;
35 uint8_t buf[256];
36 char **vals;
37 uint_t count, i;
38 nvlist_t *nvl;
40 bzero(buf, sizeof (buf));
41 buf[SFF_8472_IDENTIFIER] = SFF_8024_ID_QSFP;
42 buf[SFF_8636_DIAG_MONITORING] = 0xff;
44 if ((ret = libsff_parse(buf, sizeof (buf), 0xa0, &nvl)) != 0) {
45 errx(1, "TEST FAILED: failed to parse QSFP diagnostics: "
46 "%s\n", strerror(errno));
49 if ((ret = nvlist_lookup_string_array(nvl, LIBSFF_KEY_DIAG_MONITOR,
50 &vals, &count)) != 0) {
51 errx(1, "TEST FAILED: failed to find key %s: %s ",
52 LIBSFF_KEY_EXT_SPEC, strerror(ret));
55 for (i = 0; i < count; i++) {
56 (void) printf("%d\t%s\n", i, vals[i]);
59 nvlist_free(nvl);
60 return (0);