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

@@ -30,10 +30,19 @@
 #include <sys/scsi/adapters/mpt_sas/mptsas_ioctl.h>
 
 #include "disk.h"
 #include "disk_drivers.h"
 
+/*
+ * Request the SAS address of the disk (if any) attached to this mpt_sas
+ * instance at (Enclosure Number, Slot Number).
+ *
+ * Returns:
+ *   -2   /devices node (*devctl) does not exist
+ *   -1   All other failures
+ *    0   Success
+ */
 static int
 get_sas_address(topo_mod_t *mod, char *devctl, uint32_t enclosure,
     uint32_t slot, char **sas_address)
 {
         int fd, err, i;

@@ -42,13 +51,14 @@
         size_t disz;
 
         bzero(&gdi, sizeof (gdi));
 
         if ((fd = open(devctl, O_RDWR)) == -1) {
+                int rc = (errno == ENOENT ? -2 : -1);
                 topo_mod_dprintf(mod, "could not open '%s' for ioctl: %s\n",
                     devctl, strerror(errno));
-                return (-1);
+                return (rc);
         }
 
         if (ioctl(fd, MPTIOCTL_GET_DISK_INFO, &gdi) == -1) {
                 topo_mod_dprintf(mod, "ioctl 1 on '%s' failed: %s\n", devctl,
                     strerror(errno));

@@ -95,10 +105,12 @@
 disk_mptsas_find_disk(topo_mod_t *mod, tnode_t *baynode, char **sas_address)
 {
         char *devctl = NULL;
         uint32_t enclosure, slot;
         int err;
+        char *elem, *lastp;
+        int ret = -1;
 
         /*
          * Get the required properties from the node.  These come from
          * the static XML mapping.
          */

@@ -113,8 +125,36 @@
                 topo_mod_dprintf(mod, "bay node was missing mpt_sas binding "
                     "properties\n");
                 return (-1);
         }
 
-        return (get_sas_address(mod, devctl, enclosure, slot, sas_address));
+        /*
+         * devctl is a (potentially) pipe-separated list of different device
+         * paths to try.
+         */
+        if ((elem = topo_mod_strsplit(mod, devctl, "|", &lastp)) != NULL) {
+                do {
+                        topo_mod_dprintf(mod, "trying mpt_sas instance at %s\n",
+                            elem);
+
+                        ret = get_sas_address(mod, elem, enclosure,
+                            slot, sas_address);
+
+                        topo_mod_strfree(mod, elem);
+
+                        /*
+                         * Only try further devctl paths from the list if this
+                         * one was not found:
+                         */
+                        if (ret != -2) {
+                                break;
+                        } else {
+                                topo_mod_dprintf(mod, "instance not found\n");
+                        }
+
+                } while ((elem = topo_mod_strsplit(mod, NULL, "|",
+                    &lastp)) != NULL);
+        }
 
+        topo_mod_strfree(mod, devctl);
+        return (ret);
 }