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
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 * Copyright (c) 2013, Joyent, Inc. All rights reserved.
13 13 */
14 14
15 15 #include <stdlib.h>
16 16 #include <sys/types.h>
17 17 #include <sys/stat.h>
18 18 #include <fcntl.h>
19 19 #include <unistd.h>
20 20 #include <stropts.h>
21 21 #include <string.h>
22 22 #include <strings.h>
23 23
24 24 #include <fm/topo_mod.h>
↓ 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) *
60 70 gdi.DiskCount;
61 71 gdi.PtrDiskInfoArray = di = topo_mod_alloc(mod, disz);
62 72 if (di == NULL) {
63 73 topo_mod_dprintf(mod, "memory allocation failed\n");
64 74 (void) close(fd);
65 75 return (-1);
66 76 }
67 77
68 78 if (ioctl(fd, MPTIOCTL_GET_DISK_INFO, &gdi) == -1) {
69 79 topo_mod_dprintf(mod, "ioctl 2 on '%s' failed: %s\n", devctl,
70 80 strerror(errno));
71 81 topo_mod_free(mod, di, disz);
72 82 (void) close(fd);
73 83 return (-1);
74 84 }
75 85
76 86 err = -1;
77 87 for (i = 0; i < gdi.DiskCount; i++) {
78 88 if (di[i].Enclosure == enclosure && di[i].Slot == slot) {
79 89 char sas[17]; /* 16 hex digits and NUL */
80 90 (void) snprintf(sas, 17, "%llx", di[i].SasAddress);
81 91 topo_mod_dprintf(mod, "found mpt_sas disk (%d/%d) "
82 92 "with adddress %s\n", enclosure, slot, sas);
83 93 *sas_address = topo_mod_strdup(mod, sas);
84 94 err = 0;
85 95 break;
86 96 }
87 97 }
88 98
89 99 topo_mod_free(mod, di, disz);
↓ 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