xref: /illumos-gate/usr/src/lib/fm/topo/modules/common/pcibus/pcibus_labels.h (revision a724c049b7e0dd8612bc3aaec84e96e80511050d)
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 2008 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _PCIBUS_LABELS_H
28 #define	_PCIBUS_LABELS_H
29 
30 #include <hostbridge.h>
31 #include <did.h>
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 /*
38  * When all we're provided is a physical slot number, these structures
39  * allow us to attach an accompanying label.
40  */
41 typedef struct physnm {
42 	int ps_num;
43 	const char *ps_label;
44 } physnm_t;
45 
46 typedef struct pphysnm {
47 	const char *pnm_platform;	/* platform on which the names apply */
48 	int pnm_nnames;			/* number of names */
49 	struct physnm *pnm_names;	/* array of labels */
50 } pphysnm_t;
51 
52 typedef struct physlot_names {
53 	int psn_nplats;
54 	struct pphysnm *psn_names;
55 } physlot_names_t;
56 
57 /*
58  * Sometimes OBP gets it wrong, there's a slot-names property, but it
59  * is incorrect.  These structures allow us to replace a given label A
60  * with a different label B prior to attaching the label to a topology node.
61  */
62 typedef struct slot_rwd {
63 	const char *srw_obp;		/* slot name found */
64 	const char *srw_new;		/* replacement slot name */
65 } slot_rwd_t;
66 
67 typedef struct plat_rwd {
68 	const char *prw_platform;	/* platform on which the names apply */
69 	int prw_nrewrites;		/* number of rewrites */
70 	struct slot_rwd *prw_rewrites;	/* array of rewrites */
71 } plat_rwd_t;
72 
73 typedef struct slotnm_rewrite {
74 	int srw_nplats;
75 	struct plat_rwd *srw_platrewrites;
76 } slotnm_rewrite_t;
77 
78 /*
79  * We can locate a label without help from OBP slot-names or a
80  * physical slot-name, if need be.  Having to resort to this, though is
81  * really an indication that there's a bug in the platform OBP.
82  */
83 typedef struct devlab {
84 	int dl_board;
85 	int dl_bridge;
86 	int dl_rc;
87 	int dl_bus;
88 	int dl_dev;
89 	const char *dl_label;
90 } devlab_t;
91 
92 typedef struct pdevlabs {
93 	const char *pdl_platform;	/* Name of the platform */
94 	int pdl_nnames;			/* number of missing names */
95 	struct devlab *pdl_names;	/* the missing names */
96 } pdevlabs_t;
97 
98 typedef struct missing_names {
99 	int mn_nplats;			/* number of platforms with entries */
100 	struct pdevlabs *mn_names;	/* platform entries */
101 } missing_names_t;
102 
103 extern int pci_label_cmn(topo_mod_t *mod, tnode_t *, nvlist_t *, nvlist_t **);
104 extern int pci_fru_cmn(topo_mod_t *mod, tnode_t *, nvlist_t *, nvlist_t **);
105 extern char *pci_slot_label_lookup(topo_mod_t *, tnode_t *, did_t *, did_t *);
106 
107 #ifdef __cplusplus
108 }
109 #endif
110 
111 #endif /* _PCIBUS_LABELS_H */
112