Print this page
OS-2444 richmond hardware maps need to support ivy bridge

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/fm/topo/modules/common/disk/disk_mptsas.c
          +++ new/usr/src/lib/fm/topo/modules/common/disk/disk_mptsas.c
↓ open down ↓ 24 lines elided ↑ open up ↑
  25   25  #include <fm/topo_list.h>
  26   26  
  27   27  #include <sys/scsi/adapters/mpt_sas/mpi/mpi2_type.h>
  28   28  #include <sys/scsi/adapters/mpt_sas/mpi/mpi2.h>
  29   29  #include <sys/scsi/adapters/mpt_sas/mpi/mpi2_init.h>
  30   30  #include <sys/scsi/adapters/mpt_sas/mptsas_ioctl.h>
  31   31  
  32   32  #include "disk.h"
  33   33  #include "disk_drivers.h"
  34   34  
       35 +/*
       36 + * Request the SAS address of the disk (if any) attached to this mpt_sas
       37 + * instance at (Enclosure Number, Slot Number).
       38 + *
       39 + * Returns:
       40 + *   -2   /devices node (*devctl) does not exist
       41 + *   -1   All other failures
       42 + *    0   Success
       43 + */
  35   44  static int
  36   45  get_sas_address(topo_mod_t *mod, char *devctl, uint32_t enclosure,
  37   46      uint32_t slot, char **sas_address)
  38   47  {
  39   48          int fd, err, i;
  40   49          mptsas_get_disk_info_t gdi;
  41   50          mptsas_disk_info_t *di;
  42   51          size_t disz;
  43   52  
  44   53          bzero(&gdi, sizeof (gdi));
  45   54  
  46   55          if ((fd = open(devctl, O_RDWR)) == -1) {
       56 +                int rc = (errno == ENOENT ? -2 : -1);
  47   57                  topo_mod_dprintf(mod, "could not open '%s' for ioctl: %s\n",
  48   58                      devctl, strerror(errno));
  49      -                return (-1);
       59 +                return (rc);
  50   60          }
  51   61  
  52   62          if (ioctl(fd, MPTIOCTL_GET_DISK_INFO, &gdi) == -1) {
  53   63                  topo_mod_dprintf(mod, "ioctl 1 on '%s' failed: %s\n", devctl,
  54   64                      strerror(errno));
  55   65                  (void) close(fd);
  56   66                  return (-1);
  57   67          }
  58   68  
  59   69          gdi.DiskInfoArraySize = disz = sizeof (mptsas_disk_info_t) *
↓ open down ↓ 30 lines elided ↑ open up ↑
  90  100          (void) close(fd);
  91  101          return (err);
  92  102  }
  93  103  
  94  104  int
  95  105  disk_mptsas_find_disk(topo_mod_t *mod, tnode_t *baynode, char **sas_address)
  96  106  {
  97  107          char *devctl = NULL;
  98  108          uint32_t enclosure, slot;
  99  109          int err;
      110 +        char *elem, *lastp;
      111 +        int ret = -1;
 100  112  
 101  113          /*
 102  114           * Get the required properties from the node.  These come from
 103  115           * the static XML mapping.
 104  116           */
 105  117          if (topo_prop_get_string(baynode, TOPO_PGROUP_BINDING,
 106  118              TOPO_BINDING_DEVCTL, &devctl, &err) != 0 ||
 107  119              topo_prop_get_uint32(baynode, TOPO_PGROUP_BINDING,
 108  120              TOPO_BINDING_ENCLOSURE, &enclosure, &err) != 0 ||
 109  121              topo_prop_get_uint32(baynode, TOPO_PGROUP_BINDING,
 110  122              TOPO_BINDING_SLOT, &slot, &err) != 0) {
 111  123                  if (devctl != NULL)
 112  124                          topo_mod_strfree(mod, devctl);
 113  125                  topo_mod_dprintf(mod, "bay node was missing mpt_sas binding "
 114  126                      "properties\n");
 115  127                  return (-1);
 116  128          }
 117  129  
 118      -        return (get_sas_address(mod, devctl, enclosure, slot, sas_address));
      130 +        /*
      131 +         * devctl is a (potentially) pipe-separated list of different device
      132 +         * paths to try.
      133 +         */
      134 +        if ((elem = topo_mod_strsplit(mod, devctl, "|", &lastp)) != NULL) {
      135 +                do {
      136 +                        topo_mod_dprintf(mod, "trying mpt_sas instance at %s\n",
      137 +                            elem);
      138 +
      139 +                        ret = get_sas_address(mod, elem, enclosure,
      140 +                            slot, sas_address);
      141 +
      142 +                        topo_mod_strfree(mod, elem);
      143 +
      144 +                        /*
      145 +                         * Only try further devctl paths from the list if this
      146 +                         * one was not found:
      147 +                         */
      148 +                        if (ret != -2) {
      149 +                                break;
      150 +                        } else {
      151 +                                topo_mod_dprintf(mod, "instance not found\n");
      152 +                        }
      153 +
      154 +                } while ((elem = topo_mod_strsplit(mod, NULL, "|",
      155 +                    &lastp)) != NULL);
      156 +        }
 119  157  
      158 +        topo_mod_strfree(mod, devctl);
      159 +        return (ret);
 120  160  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX