xref: /illumos-gate/usr/src/lib/fm/topo/modules/common/disk/disk.h (revision 74e12c43fe52f2c30f36e65a4d0fb0e8dfd7068a)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
24  */
25 /*
26  * Copyright 2020 Joyent, Inc.
27  */
28 
29 #ifndef _DISK_H
30 #define	_DISK_H
31 
32 #include <sys/fm/protocol.h>
33 #include <fm/topo_mod.h>
34 #include <libdevinfo.h>
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 /* Topo plugin version */
41 #define	DISK_VERSION			TOPO_VERSION
42 
43 /* Max. number of devices for thumper */
44 #define	DEVID_MAX		48
45 
46 /*
47  * Given a /devices path for a whole disk, appending this extension gives the
48  * path to a raw device that can be opened.
49  */
50 #if defined(__i386) || defined(__amd64)
51 #define	PHYS_EXTN	":q,raw"
52 #elif defined(__sparc) || defined(__sparcv9)
53 #define	PHYS_EXTN	":c,raw"
54 #else
55 #error	Unknown architecture
56 #endif
57 
58 /* Properties added to the "storage" pgroup: */
59 #define	TOPO_PGROUP_STORAGE		"storage"
60 #define	TOPO_STORAGE_LOGICAL_DISK_NAME	"logical-disk"
61 #define	TOPO_STORAGE_MODEL		"model"
62 #define	TOPO_STORAGE_MANUFACTURER	"manufacturer"
63 #define	TOPO_STORAGE_SERIAL_NUM		"serial-number"
64 #define	TOPO_STORAGE_FIRMWARE_REV	"firmware-revision"
65 #define	TOPO_STORAGE_CAPACITY		"capacity-in-bytes"
66 #define	TOPO_STORAGE_RPM		"speed-in-rpm"
67 
68 static const topo_pgroup_info_t io_pgroup = {
69 	TOPO_PGROUP_IO,
70 	TOPO_STABILITY_PRIVATE,
71 	TOPO_STABILITY_PRIVATE,
72 	1
73 };
74 
75 static const topo_pgroup_info_t disk_auth_pgroup = {
76 	FM_FMRI_AUTHORITY,
77 	TOPO_STABILITY_PRIVATE,
78 	TOPO_STABILITY_PRIVATE,
79 	1
80 };
81 
82 static const topo_pgroup_info_t storage_pgroup = {
83 	TOPO_PGROUP_STORAGE,
84 	TOPO_STABILITY_PRIVATE,
85 	TOPO_STABILITY_PRIVATE,
86 	1
87 };
88 
89 /*
90  * device node information.
91  */
92 typedef struct dev_di_node {
93 	topo_list_t	ddn_list;	/* list of devices */
94 
95 	/* the following two fields are always defined */
96 	char		*ddn_devid;	/* devid of device */
97 	char		*ddn_dpath;	/* path to devinfo (may be vhci) */
98 	char		**ddn_ppath;	/* physical path to device (phci) */
99 	/*
100 	 * the ppath count also indicates number of target port and
101 	 * possible number of attached port and bridge port.
102 	 */
103 	int		ddn_ppath_count;
104 
105 	char		*ddn_lpath;	/* logical path (public /dev name) */
106 
107 	char		*ddn_mfg;	/* misc information about device */
108 	char		*ddn_model;
109 	char		*ddn_serial;
110 	char		*ddn_firm;
111 	char		*ddn_cap;
112 	uchar_t		ddn_dtype;	/* scsi inquiry device type. */
113 
114 	char		**ddn_target_port;  /* target-port devinfo prop */
115 	char		**ddn_attached_port; /* attached-port devinfo prop */
116 	char		**ddn_bridge_port;  /* bridge-port devinfo prop */
117 } dev_di_node_t;
118 
119 struct topo_list;
120 
121 /* Methods shared with the ses module (disk_common.c) */
122 extern int dev_list_gather(topo_mod_t *, struct topo_list *);
123 extern void dev_list_free(topo_mod_t *, struct topo_list *);
124 extern int disk_declare_non_enumerated(topo_mod_t *, tnode_t *, tnode_t **);
125 extern int disk_declare_path(topo_mod_t *, tnode_t *,
126     struct topo_list *, const char *);
127 extern int disk_declare_addr(topo_mod_t *, tnode_t *,
128     struct topo_list *, const char *, tnode_t **);
129 extern int disk_declare_bridge(topo_mod_t *, tnode_t *,
130     struct topo_list *, const char *, tnode_t **);
131 extern char *disk_auth_clean(topo_mod_t *, const char *);
132 
133 #ifdef __cplusplus
134 }
135 #endif
136 
137 #endif /* _DISK_H */
138