summaryrefslogtreecommitdiff
path: root/usr/src/lib/fm/topo/modules/i86pc/pcibus/pci_i86pc.c
blob: 7fef097c1cb3748a5be6c385e9522ba0048457bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */

/*
 * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
 */

#include <fm/topo_mod.h>

#include "pcibus.h"
#include "pcibus_labels.h"
#include <string.h>
#include <strings.h>

/*
 * Including the following file gives us definitions of the three
 * global arrays used to adjust labels, Slot_Rewrites, Physlot_Names,
 * and Missing_Names.  With those defined we can use the common labeling
 * routines for pci.
 */
#include "pci_i86pc.h"

int
platform_pci_label(topo_mod_t *mod, tnode_t *node, nvlist_t *in,
    nvlist_t **out)
{
	return (pci_label_cmn(mod, node, in, out));
}
/*ARGSUSED*/
int
platform_pci_fru(topo_mod_t *mod, tnode_t *node, nvlist_t *in,
    nvlist_t **out)
{
	return (pci_fru_cmn(mod, node, in, out));
}

/*
 * return true if pciexbus node whose parent is a pciexrc node
 */
/*ARGSUSED*/
int
parent_is_rc(topo_mod_t *mod, did_t *dp)
{
	return (strcmp(topo_node_name(did_gettnode(dp)), PCIEX_ROOT) == 0);
}

/*
 * Look for down-stream switch "2" on riser card. First find this node's parent.
 * If it is a pciexfn node and it has dev=2 and node 6 levels further up
 * from it has a physlot then return true.
 */
int
ba_is_2(topo_mod_t *mod, did_t *dp)
{
	tnode_t *ptp;
	did_t *pdp;
	int i, d;

	ptp = did_gettnode(dp);
	if (strcmp(topo_node_name(ptp), PCIEX_FUNCTION) != 0)
		return (0);
	pdp = did_find(mod, topo_node_getspecific(ptp));
	if (!pdp)
		return (0);
	did_BDF(pdp, NULL, &d, NULL);
	if (d != 2)
		return (0);

	for (i = 0; i < 6; i++)
		if ((ptp = topo_node_parent(ptp)) == NULL)
			return (0);
	pdp = did_find(mod, topo_node_getspecific(ptp));
	return (pdp && did_physlot_exists(pdp));
}

/*
 * Look for down-stream switch "4" on riser card. First find this node's parent.
 * If it is a pciexfn node and it has dev=4 and node 6 levels further up
 * from it has a physlot then return true.
 */
int
ba_is_4(topo_mod_t *mod, did_t *dp)
{
	tnode_t *ptp;
	did_t *pdp;
	int i, d;

	ptp = did_gettnode(dp);
	if (strcmp(topo_node_name(ptp), PCIEX_FUNCTION) != 0)
		return (0);
	pdp = did_find(mod, topo_node_getspecific(ptp));
	if (!pdp)
		return (0);
	did_BDF(pdp, NULL, &d, NULL);
	if (d != 4)
		return (0);

	for (i = 0; i < 6; i++)
		if ((ptp = topo_node_parent(ptp)) == NULL)
			return (0);
	pdp = did_find(mod, topo_node_getspecific(ptp));
	return (pdp && did_physlot_exists(pdp));
}