Print this page
    
8699 Want NIC transceiver visibility (fix lint)
    
      
        | Split | 
	Close | 
      
      | Expand all | 
      | Collapse all | 
    
    
          --- old/usr/src/test/util-tests/tests/libsff/libsff_8636_tech.c
          +++ new/usr/src/test/util-tests/tests/libsff/libsff_8636_tech.c
   1    1  /*
   2    2   * This file and its contents are supplied under the terms of the
   3    3   * Common Development and Distribution License ("CDDL"), version 1.0.
   4    4   * You may only use this file in accordance with the terms of version
   5    5   * 1.0 of the CDDL.
   6    6   *
   7    7   * A full copy of the text of the CDDL should have accompanied this
   8    8   * source.  A copy of the CDDL is also available via the Internet at
   9    9   * http://www.illumos.org/license/CDDL.
  10   10   */
  11   11  
  12   12  /*
  13   13   * Copyright (c) 2017, Joyent, Inc.
  14   14   */
  15   15  
  16   16  /*
  17   17   * Print SFF 8636 device tech values.
  18   18   */
  19   19  
  20   20  #include <stdio.h>
  21   21  #include <errno.h>
  22   22  #include <strings.h>
  23   23  #include <err.h>
  24   24  #include <libsff.h>
  25   25  
  26   26  /*
  27   27   * Pick up private sff header file with offsets from lib/libsff.
  28   28   */
  29   29  #include "sff.h"
  30   30  
  31   31  static void
  32   32  lst_print_array(nvlist_t *nvl, const char *key)
  33   33  {
  34   34          int ret;
  35   35          uint_t i, count;
  36   36          char **vals;
  37   37  
  38   38          if ((ret = nvlist_lookup_string_array(nvl, key, &vals, &count)) != 0) {
  39   39                  errx(1, "TEST FAILED failed to find key %s: %s\n", key,
  40   40                      strerror(ret));
  41   41          }
  42   42  
  43   43          (void) puts(key);
  44   44          for (i = 0; i < count; i++) {
  45   45                  (void) printf("\t%d\t%s\n", i, vals[i]);
  46   46          }
  47   47  }
  48   48  
  49   49  int
  50   50  main(void)
  51   51  {
  52   52          uint_t i;
  53   53          uint8_t buf[256];
  54   54  
  55   55          bzero(buf, sizeof (buf));
  56   56          buf[SFF_8472_IDENTIFIER] = SFF_8024_ID_QSFP;
  57   57  
  58   58          /*
  59   59           * The upper four bits of this value are used as a 4-bit identifier. The
  60   60           * lower four bits are used as options.
  
    | 
      ↓ open down ↓ | 
    60 lines elided | 
    
      ↑ open up ↑ | 
  
  61   61           */
  62   62          for (i = 0; i < 16; i++) {
  63   63                  int ret;
  64   64                  nvlist_t *nvl;
  65   65  
  66   66                  buf[SFF_8636_DEVICE_TECH] = i << 4;
  67   67                  buf[SFF_8636_DEVICE_TECH] |= (i % 16);
  68   68  
  69   69                  if ((ret = libsff_parse(buf, sizeof (buf), 0xa0, &nvl)) != 0) {
  70   70                          errx(1, "TEST FAILED: failed to parse QSFP device tech "
  71      -                            "%d: %s\n", i, strerror(errno));
       71 +                            "%d: %s\n", i, strerror(ret));
  72   72                  }
  73   73  
  74   74                  lst_print_array(nvl, LIBSFF_KEY_TRAN_TECH);
  75   75                  nvlist_free(nvl);
  76   76          }
  77   77  
  78   78          return (0);
  79   79  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX