Print this page
LOCAL: fma: enumerate static mpt_sas disk mappings
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/lib/fm/topo/modules/common/disk/disk.c
+++ new/usr/src/lib/fm/topo/modules/common/disk/disk.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
23 23 */
24 24
25 25 #include <strings.h>
↓ open down ↓ |
25 lines elided |
↑ open up ↑ |
26 26 #include <devid.h>
27 27 #include <pthread.h>
28 28 #include <inttypes.h>
29 29 #include <sys/dkio.h>
30 30 #include <sys/scsi/scsi_types.h>
31 31 #include <fm/topo_mod.h>
32 32 #include <fm/topo_list.h>
33 33 #include <fm/libdiskstatus.h>
34 34 #include <sys/fm/protocol.h>
35 35 #include "disk.h"
36 +#include "disk_drivers.h"
36 37
37 38 static int disk_enum(topo_mod_t *, tnode_t *, const char *,
38 39 topo_instance_t, topo_instance_t, void *, void *);
39 40
40 41 static const topo_modops_t disk_ops =
41 42 { disk_enum, NULL };
42 43
43 44 static const topo_modinfo_t disk_info =
44 45 {DISK, FM_FMRI_SCHEME_HC, DISK_VERSION, &disk_ops};
45 46
47 +static int
48 +disk_declare_driver(topo_mod_t *mod, tnode_t *baynode, topo_list_t *dlistp,
49 + char *driver)
50 +{
51 + int err;
52 +
53 + if (strcmp("mpt_sas", driver) == 0) {
54 + char *sas_address = NULL;
55 + tnode_t *child = NULL;
56 +
57 + if (disk_mptsas_find_disk(mod, baynode, &sas_address) != 0)
58 + return (err);
59 +
60 + err = disk_declare_addr(mod, baynode, dlistp,
61 + sas_address, &child);
62 + topo_mod_strfree(mod, sas_address);
63 +
64 + return (err);
65 + }
66 +
67 + topo_mod_dprintf(mod, "unknown disk driver '%s'\n", driver);
68 + return (-1);
69 +}
70 +
46 71 /*ARGSUSED*/
47 72 static int
48 73 disk_enum(topo_mod_t *mod, tnode_t *baynode,
49 74 const char *name, topo_instance_t min, topo_instance_t max,
50 75 void *arg, void *notused)
51 76 {
52 - char *device;
77 + char *device, *driver;
53 78 int err;
54 79 nvlist_t *fmri;
55 80 topo_list_t *dlistp = topo_mod_getspecific(mod);
56 81
57 82 if (strcmp(name, DISK) != 0) {
58 83 topo_mod_dprintf(mod, "disk_enum: "
59 84 "only know how to enumerate %s components.\n", DISK);
60 85 return (-1);
61 86 }
62 87
63 88 /* set the parent fru */
64 89 if (topo_node_resource(baynode, &fmri, &err) != 0) {
65 90 topo_mod_dprintf(mod, "disk_enum: "
66 91 "topo_node_resource error %s\n", topo_strerror(err));
67 92 return (-1);
↓ open down ↓ |
5 lines elided |
↑ open up ↑ |
68 93 }
69 94 if (topo_node_fru_set(baynode, fmri, 0, &err) != 0) {
70 95 topo_mod_dprintf(mod, "disk_enum: "
71 96 "topo_node_fru error %s\n", topo_strerror(err));
72 97 nvlist_free(fmri);
73 98 return (-1);
74 99 }
75 100 nvlist_free(fmri);
76 101
77 102 /*
103 + * For internal storage, first check to see if we need to
104 + * request more detail from an HBA driver.
105 + */
106 + if (topo_prop_get_string(baynode, TOPO_PGROUP_BINDING,
107 + TOPO_BINDING_DRIVER, &driver, &err) == 0) {
108 + err = disk_declare_driver(mod, baynode, dlistp, driver);
109 +
110 + topo_mod_strfree(mod, driver);
111 + return (err);
112 + } else if (err != ETOPO_PROP_NOENT) {
113 + topo_mod_dprintf(mod, "disk_enum: "
114 + "binding error %s\n", topo_strerror(err));
115 + return (-1);
116 + }
117 +
118 + /*
78 119 * For internal storage, get the path to the occupant from the
79 120 * binding group of the bay node
80 121 */
81 122 if (topo_prop_get_string(baynode, TOPO_PGROUP_BINDING,
82 123 TOPO_BINDING_OCCUPANT, &device, &err) != 0) {
83 124 topo_mod_dprintf(mod, "disk_enum: "
84 125 "binding error %s\n", topo_strerror(err));
85 126 return (-1);
86 127 }
87 128
88 129
89 130 /* locate and topo enumerate the disk with that path */
90 131 err = disk_declare_path(mod, baynode, dlistp, device);
91 132
92 133 topo_mod_strfree(mod, device);
93 134 return (err);
94 135 }
95 136
96 137 /*ARGSUSED*/
97 138 int
98 139 _topo_init(topo_mod_t *mod, topo_version_t version)
99 140 {
100 141 topo_list_t *dlistp;
101 142
102 143 /*
103 144 * Turn on module debugging output
104 145 */
105 146 if (getenv("TOPODISKDEBUG") != NULL)
106 147 topo_mod_setdebug(mod);
107 148 topo_mod_dprintf(mod, "_topo_init: "
108 149 "initializing %s enumerator\n", DISK);
109 150
110 151 if (topo_mod_register(mod, &disk_info, TOPO_VERSION) != 0) {
111 152 topo_mod_dprintf(mod, "_topo_init: "
112 153 "%s registration failed: %s\n", DISK, topo_mod_errmsg(mod));
113 154 return (-1); /* mod errno already set */
114 155 }
115 156
116 157 if ((dlistp = topo_mod_zalloc(mod, sizeof (topo_list_t))) == NULL) {
117 158 topo_mod_dprintf(mod, "_topo_inti: failed to allocate "
118 159 "disk list");
119 160 return (-1);
120 161 }
121 162
122 163 if (dev_list_gather(mod, dlistp) != 0) {
123 164 topo_mod_unregister(mod);
124 165 topo_mod_free(mod, dlistp, sizeof (topo_list_t));
125 166 topo_mod_dprintf(mod, "_topo_init: "
126 167 "failed to locate disks");
127 168 return (-1);
128 169 }
129 170
130 171 topo_mod_dprintf(mod, "_topo_init: "
131 172 "%s enumerator initialized\n", DISK);
132 173
133 174 topo_mod_setspecific(mod, dlistp);
134 175
135 176 return (0);
136 177 }
137 178
138 179 void
139 180 _topo_fini(topo_mod_t *mod)
140 181 {
141 182 topo_list_t *dlistp = topo_mod_getspecific(mod);
142 183 dev_list_free(mod, dlistp);
143 184 topo_mod_free(mod, dlistp, sizeof (topo_list_t));
144 185 topo_mod_unregister(mod);
145 186 topo_mod_dprintf(mod, "_topo_fini: "
146 187 "%s enumerator uninitialized\n", DISK);
147 188 }
↓ open down ↓ |
60 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX