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 #define	TOPO_STORAGE_LOG_BLOCK_SIZE	"logical-block-size"
68 #define	TOPO_STORAGE_PHYS_BLOCK_SIZE	"physical-block-size"
69 
70 static const topo_pgroup_info_t io_pgroup = {
71 	TOPO_PGROUP_IO,
72 	TOPO_STABILITY_PRIVATE,
73 	TOPO_STABILITY_PRIVATE,
74 	1
75 };
76 
77 static const topo_pgroup_info_t disk_auth_pgroup = {
78 	FM_FMRI_AUTHORITY,
79 	TOPO_STABILITY_PRIVATE,
80 	TOPO_STABILITY_PRIVATE,
81 	1
82 };
83 
84 static const topo_pgroup_info_t storage_pgroup = {
85 	TOPO_PGROUP_STORAGE,
86 	TOPO_STABILITY_PRIVATE,
87 	TOPO_STABILITY_PRIVATE,
88 	1
89 };
90 
91 /*
92  * device node information.
93  */
94 typedef struct dev_di_node {
95 	topo_list_t	ddn_list;	/* list of devices */
96 
97 	/* the following two fields are always defined */
98 	char		*ddn_devid;	/* devid of device */
99 	char		*ddn_dpath;	/* path to devinfo (may be vhci) */
100 	char		**ddn_ppath;	/* physical path to device (phci) */
101 	/*
102 	 * the ppath count also indicates number of target port and
103 	 * possible number of attached port and bridge port.
104 	 */
105 	int		ddn_ppath_count;
106 
107 	char		*ddn_lpath;	/* logical path (public /dev name) */
108 
109 	char		*ddn_mfg;	/* misc information about device */
110 	char		*ddn_model;
111 	char		*ddn_serial;
112 	char		*ddn_firm;
113 	char		*ddn_cap;
114 	uchar_t		ddn_dtype;	/* scsi inquiry device type. */
115 
116 	char		**ddn_target_port;  /* target-port devinfo prop */
117 	char		**ddn_attached_port; /* attached-port devinfo prop */
118 	char		**ddn_bridge_port;  /* bridge-port devinfo prop */
119 } dev_di_node_t;
120 
121 struct topo_list;
122 
123 /* Methods shared with the ses module (disk_common.c) */
124 extern int dev_list_gather(topo_mod_t *, struct topo_list *);
125 extern void dev_list_free(topo_mod_t *, struct topo_list *);
126 extern int disk_declare_non_enumerated(topo_mod_t *, tnode_t *, tnode_t **);
127 extern int disk_declare_path(topo_mod_t *, tnode_t *,
128     struct topo_list *, const char *);
129 extern int disk_declare_addr(topo_mod_t *, tnode_t *,
130     struct topo_list *, const char *, tnode_t **);
131 extern int disk_declare_bridge(topo_mod_t *, tnode_t *,
132     struct topo_list *, const char *, tnode_t **);
133 extern char *disk_auth_clean(topo_mod_t *, const char *);
134 
135 #ifdef __cplusplus
136 }
137 #endif
138 
139 #endif /* _DISK_H */
140