xref: /onnv-gate/usr/src/lib/fm/topo/modules/i86pc/pcibus/pci_i86pc.c (revision 12054:bcacc803343d)
11414Scindi /*
21414Scindi  * CDDL HEADER START
31414Scindi  *
41414Scindi  * The contents of this file are subject to the terms of the
51414Scindi  * Common Development and Distribution License (the "License").
61414Scindi  * You may not use this file except in compliance with the License.
71414Scindi  *
81414Scindi  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
91414Scindi  * or http://www.opensolaris.org/os/licensing.
101414Scindi  * See the License for the specific language governing permissions
111414Scindi  * and limitations under the License.
121414Scindi  *
131414Scindi  * When distributing Covered Code, include this CDDL HEADER in each
141414Scindi  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
151414Scindi  * If applicable, add the following below this CDDL HEADER, with the
161414Scindi  * fields enclosed by brackets "[]" replaced with your own identifying
171414Scindi  * information: Portions Copyright [yyyy] [name of copyright owner]
181414Scindi  *
191414Scindi  * CDDL HEADER END
201414Scindi  */
211414Scindi 
221414Scindi /*
23*12054SStephen.Hanson@Sun.COM  * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
241414Scindi  */
251414Scindi 
261414Scindi #include <fm/topo_mod.h>
271414Scindi 
281414Scindi #include "pcibus.h"
291414Scindi #include "pcibus_labels.h"
303895Szx143588 #include <string.h>
313895Szx143588 #include <strings.h>
321414Scindi 
33*12054SStephen.Hanson@Sun.COM /*
34*12054SStephen.Hanson@Sun.COM  * Including the following file gives us definitions of the three
35*12054SStephen.Hanson@Sun.COM  * global arrays used to adjust labels, Slot_Rewrites, Physlot_Names,
36*12054SStephen.Hanson@Sun.COM  * and Missing_Names.  With those defined we can use the common labeling
37*12054SStephen.Hanson@Sun.COM  * routines for pci.
38*12054SStephen.Hanson@Sun.COM  */
39*12054SStephen.Hanson@Sun.COM #include "pci_i86pc.h"
401414Scindi 
411414Scindi int
platform_pci_label(topo_mod_t * mod,tnode_t * node,nvlist_t * in,nvlist_t ** out)423062Scindi platform_pci_label(topo_mod_t *mod, tnode_t *node, nvlist_t *in,
433062Scindi     nvlist_t **out)
441414Scindi {
453062Scindi 	return (pci_label_cmn(mod, node, in, out));
461414Scindi }
473895Szx143588 /*ARGSUSED*/
483895Szx143588 int
platform_pci_fru(topo_mod_t * mod,tnode_t * node,nvlist_t * in,nvlist_t ** out)493895Szx143588 platform_pci_fru(topo_mod_t *mod, tnode_t *node, nvlist_t *in,
503895Szx143588     nvlist_t **out)
513895Szx143588 {
525204Sstephh 	return (pci_fru_cmn(mod, node, in, out));
533895Szx143588 }
54*12054SStephen.Hanson@Sun.COM 
55*12054SStephen.Hanson@Sun.COM /*
56*12054SStephen.Hanson@Sun.COM  * return true if pciexbus node whose parent is a pciexrc node
57*12054SStephen.Hanson@Sun.COM  */
58*12054SStephen.Hanson@Sun.COM /*ARGSUSED*/
59*12054SStephen.Hanson@Sun.COM int
parent_is_rc(topo_mod_t * mod,did_t * dp)60*12054SStephen.Hanson@Sun.COM parent_is_rc(topo_mod_t *mod, did_t *dp)
61*12054SStephen.Hanson@Sun.COM {
62*12054SStephen.Hanson@Sun.COM 	return (strcmp(topo_node_name(did_gettnode(dp)), PCIEX_ROOT) == 0);
63*12054SStephen.Hanson@Sun.COM }
64*12054SStephen.Hanson@Sun.COM 
65*12054SStephen.Hanson@Sun.COM /*
66*12054SStephen.Hanson@Sun.COM  * Look for down-stream switch "2" on riser card. First find this node's parent.
67*12054SStephen.Hanson@Sun.COM  * If it is a pciexfn node and it has dev=2 and node 6 levels further up
68*12054SStephen.Hanson@Sun.COM  * from it has a physlot then return true.
69*12054SStephen.Hanson@Sun.COM  */
70*12054SStephen.Hanson@Sun.COM int
ba_is_2(topo_mod_t * mod,did_t * dp)71*12054SStephen.Hanson@Sun.COM ba_is_2(topo_mod_t *mod, did_t *dp)
72*12054SStephen.Hanson@Sun.COM {
73*12054SStephen.Hanson@Sun.COM 	tnode_t *ptp;
74*12054SStephen.Hanson@Sun.COM 	did_t *pdp;
75*12054SStephen.Hanson@Sun.COM 	int i, d;
76*12054SStephen.Hanson@Sun.COM 
77*12054SStephen.Hanson@Sun.COM 	ptp = did_gettnode(dp);
78*12054SStephen.Hanson@Sun.COM 	if (strcmp(topo_node_name(ptp), PCIEX_FUNCTION) != 0)
79*12054SStephen.Hanson@Sun.COM 		return (0);
80*12054SStephen.Hanson@Sun.COM 	pdp = did_find(mod, topo_node_getspecific(ptp));
81*12054SStephen.Hanson@Sun.COM 	if (!pdp)
82*12054SStephen.Hanson@Sun.COM 		return (0);
83*12054SStephen.Hanson@Sun.COM 	did_BDF(pdp, NULL, &d, NULL);
84*12054SStephen.Hanson@Sun.COM 	if (d != 2)
85*12054SStephen.Hanson@Sun.COM 		return (0);
86*12054SStephen.Hanson@Sun.COM 
87*12054SStephen.Hanson@Sun.COM 	for (i = 0; i < 6; i++)
88*12054SStephen.Hanson@Sun.COM 		if ((ptp = topo_node_parent(ptp)) == NULL)
89*12054SStephen.Hanson@Sun.COM 			return (0);
90*12054SStephen.Hanson@Sun.COM 	pdp = did_find(mod, topo_node_getspecific(ptp));
91*12054SStephen.Hanson@Sun.COM 	return (pdp && did_physlot_exists(pdp));
92*12054SStephen.Hanson@Sun.COM }
93*12054SStephen.Hanson@Sun.COM 
94*12054SStephen.Hanson@Sun.COM /*
95*12054SStephen.Hanson@Sun.COM  * Look for down-stream switch "4" on riser card. First find this node's parent.
96*12054SStephen.Hanson@Sun.COM  * If it is a pciexfn node and it has dev=4 and node 6 levels further up
97*12054SStephen.Hanson@Sun.COM  * from it has a physlot then return true.
98*12054SStephen.Hanson@Sun.COM  */
99*12054SStephen.Hanson@Sun.COM int
ba_is_4(topo_mod_t * mod,did_t * dp)100*12054SStephen.Hanson@Sun.COM ba_is_4(topo_mod_t *mod, did_t *dp)
101*12054SStephen.Hanson@Sun.COM {
102*12054SStephen.Hanson@Sun.COM 	tnode_t *ptp;
103*12054SStephen.Hanson@Sun.COM 	did_t *pdp;
104*12054SStephen.Hanson@Sun.COM 	int i, d;
105*12054SStephen.Hanson@Sun.COM 
106*12054SStephen.Hanson@Sun.COM 	ptp = did_gettnode(dp);
107*12054SStephen.Hanson@Sun.COM 	if (strcmp(topo_node_name(ptp), PCIEX_FUNCTION) != 0)
108*12054SStephen.Hanson@Sun.COM 		return (0);
109*12054SStephen.Hanson@Sun.COM 	pdp = did_find(mod, topo_node_getspecific(ptp));
110*12054SStephen.Hanson@Sun.COM 	if (!pdp)
111*12054SStephen.Hanson@Sun.COM 		return (0);
112*12054SStephen.Hanson@Sun.COM 	did_BDF(pdp, NULL, &d, NULL);
113*12054SStephen.Hanson@Sun.COM 	if (d != 4)
114*12054SStephen.Hanson@Sun.COM 		return (0);
115*12054SStephen.Hanson@Sun.COM 
116*12054SStephen.Hanson@Sun.COM 	for (i = 0; i < 6; i++)
117*12054SStephen.Hanson@Sun.COM 		if ((ptp = topo_node_parent(ptp)) == NULL)
118*12054SStephen.Hanson@Sun.COM 			return (0);
119*12054SStephen.Hanson@Sun.COM 	pdp = did_find(mod, topo_node_getspecific(ptp));
120*12054SStephen.Hanson@Sun.COM 	return (pdp && did_physlot_exists(pdp));
121*12054SStephen.Hanson@Sun.COM }
122