xref: /titanic_41/usr/src/lib/fm/topo/modules/common/pcibus/pcibus_labels.h (revision a4aef2bab3a15f31b03de3834937be168fb83b36)
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 2009 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 	int (*srw_test)(topo_mod_t *, did_t *);	/* test function */
66 } slot_rwd_t;
67 
68 typedef struct plat_rwd {
69 	const char *prw_platform;	/* platform on which the names apply */
70 	int prw_nrewrites;		/* number of rewrites */
71 	struct slot_rwd *prw_rewrites;	/* array of rewrites */
72 } plat_rwd_t;
73 
74 typedef struct slotnm_rewrite {
75 	int srw_nplats;
76 	struct plat_rwd *srw_platrewrites;
77 } slotnm_rewrite_t;
78 
79 /*
80  * We can locate a label without help from OBP slot-names or a
81  * physical slot-name, if need be.  Having to resort to this, though is
82  * really an indication that there's a bug in the platform OBP.
83  */
84 typedef struct devlab {
85 	int dl_board;				/* board number */
86 	int dl_bridge;				/* hostbridge number */
87 	int dl_rc;				/* root complex number */
88 	int dl_bus;				/* bus number */
89 	int dl_dev;				/* device number */
90 	const char *dl_label;			/* label to use */
91 	int (*dl_test)(topo_mod_t *, did_t *);	/* test function */
92 } devlab_t;
93 
94 typedef struct pdevlabs {
95 	const char *pdl_platform;	/* Name of the platform */
96 	int pdl_nnames;			/* number of missing names */
97 	struct devlab *pdl_names;	/* the missing names */
98 } pdevlabs_t;
99 
100 typedef struct missing_names {
101 	int mn_nplats;			/* number of platforms with entries */
102 	struct pdevlabs *mn_names;	/* platform entries */
103 } missing_names_t;
104 
105 extern int pci_label_cmn(topo_mod_t *mod, tnode_t *, nvlist_t *, nvlist_t **);
106 extern int pci_fru_cmn(topo_mod_t *mod, tnode_t *, nvlist_t *, nvlist_t **);
107 extern char *pci_slot_label_lookup(topo_mod_t *, tnode_t *, did_t *, did_t *);
108 
109 #ifdef __cplusplus
110 }
111 #endif
112 
113 #endif /* _PCIBUS_LABELS_H */
114