/*
* 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
* 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
*/
/*
*/
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <alloca.h>
#include <libdevinfo.h>
#include <libnvpair.h>
#include <fm/topo_mod.h>
#include <hostbridge.h>
#include <pcibus.h>
#include <did.h>
#include <did_props.h>
#include <util.h>
extern txprop_t Bus_common_props[];
extern txprop_t Dev_common_props[];
extern txprop_t Fn_common_props[];
extern int Bus_propcnt;
extern int Dev_propcnt;
extern int Fn_propcnt;
nvlist_t **);
nvlist_t **);
topo_instance_t, void *, void *);
nvlist_t **);
nvlist_t **);
{ pci_enum, pci_release };
{ NULL }
};
int
{
/*
* Turn on module debugging output
*/
if (version != PCI_ENUMR_VERS)
return (-1);
}
return (0);
}
void
{
}
static int
{
if (version > TOPO_METH_LABEL_VERSION)
}
static int
{
}
static tnode_t *
{
return (NULL);
return (NULL);
}
return (ntn);
}
/*ARGSUSED*/
static int
{
return (-1);
return (-1);
}
return (0);
}
tnode_t *
{
/* We need the parent's dev info node for some of the info */
/* If this is the first child under root, get root's ptn */
return (NULL);
/* Get the required info to populate the excap */
/*
* Populate the excap with correct PCIe device type.
*
* Device Parent Device Parent Device
* excap device-type device-type excap Class Code
* -------------------------------------------------------------------
* PCI(default) pci N/A N/A != bridge
* PCIe pciex N/A N/A != bridge
* Root Port Defined in hostbridge
* Switch Up pciex pciex != up = bridge
* Switch Down pciex pciex = up = bridge
* PCIe-PCI pciex pci N/A = bridge
* PCI-PCIe pci pciex N/A = bridge
*/
if (pdev_is_pcie) {
if (dev_is_pcie) {
if (pexcap != PCIE_PCIECAP_DEV_TYPE_UP)
else
} else {
}
} else {
if (dev_is_pcie)
}
} else {
if (pdev_is_pcie)
}
return (NULL);
== NULL)
return (NULL);
return (NULL);
}
/*
* We may find pci-express buses or plain-pci buses beneath a function
*/
return (NULL);
}
return (NULL);
}
return (ntn);
}
tnode_t *
{
return (NULL);
return (NULL);
return (NULL);
}
/*
* We can expect to find pci-express functions beneath the device
*/
if (child_range_add(mod,
return (NULL);
}
return (ntn);
}
tnode_t *
{
return (NULL);
return (NULL);
return (NULL);
}
/*
* We can expect to find pci-express devices beneath the bus
*/
if (child_range_add(mod,
return (NULL);
}
return (ntn);
}
tnode_t *
{
return (NULL);
return (NULL);
return (NULL);
}
/*
* We may find pci buses beneath a function
*/
return (NULL);
}
return (ntn);
}
tnode_t *
{
return (NULL);
/* remember parent tnode */
return (NULL);
return (NULL);
}
/*
* We can expect to find pci functions beneath the device
*/
return (NULL);
}
return (ntn);
}
tnode_t *
{
int hbchild = 0;
return (NULL);
return (NULL);
/*
* If our devinfo node is lacking certain information of its
* own, and our parent topology node is a hostbridge, we may
* hostbridge node's private data.
*/
hbchild = 1;
return (NULL);
}
/*
* We can expect to find pci devices beneath the bus
*/
return (NULL);
}
/*
* On each bus child of the hostbridge, we represent the
* hostbridge as a device outside the range of legal device
* numbers.
*/
if (hbchild == 1) {
return (NULL);
}
}
return (ntn);
}
static int
{
int err;
char *devtyp;
/* Check if the children are PCI or PCIe */
else
return (err);
}
static void
{
char *propstr;
if (rc >= 0)
else
return;
++dcnt;
}
if (rc >= 0)
else
if (dcnt) {
}
return;
}
if (dcnt)
return;
}
/*
* This function may be a bridge. If not, check for a possible
* topology map file and kick off its enumeration of lower-level
* devices.
*/
depth);
}
/*
* Check for a Neptune-based NIC. This could either be a Neptune
* adapter card or an Neptune ASIC on a board (e.g. motherboard)
*
* For Netpune adapter cards, use xfp-hc-topology.xml to expand
* topology to include the XFP optical module, which is a FRU on
* the Neptune based 10giga fiber NICs.
*
* For Neptune ASICs, use the XAUI enumerator to expand topology.
* The 10giga ports are externalized by a XAUI cards, which
* are FRUs. The XAUI enumerator in turn instantiates the XFP
* optical module FRUs.
*/
else if (class == PCI_CLASS_NET &&
/*
* Is this an adapter card? Check the bus's physlot
*/
if (did_physlot(dp) >= 0) {
"xfp", FM_FMRI_SCHEME_HC);
} else {
NULL) {
"could not load xaui enum\n");
(void) topo_mod_seterrno(mod,
return;
} else {
XAUI, 0, 1) < 0) {
"child_range_add for "
"XAUI failed: %s\n",
topo_mod_errno(mod)));
return;
}
}
}
}
} else if (class == PCI_CLASS_MASS) {
int niports = 0;
di_node_t, int);
niports++;
}
if (niports > 0)
DI_RECEPTACLE_PHYMASK, &propstr)) > 0) {
rcnt) >= 0)
}
}
}
int
{
int b, d, f;
for (d = 0; d < MAX_PCIBUS_DEVS; d++)
for (f = 0; f < MAX_PCIDEV_FNS; f++)
/* start at the parent's first sibling */
while (sib != DI_NODE_NIL) {
return (-1);
if (pb < 0)
}
return (0);
if (rc >= 0)
else
return (-1);
if (pb < 0)
return (0);
for (d = 0; d < MAX_PCIBUS_DEVS; d++) {
for (f = 0; f < MAX_PCIDEV_FNS; f++) {
continue;
/*
* Try to enumerate as many devices and functions as
* possible. If we fail to declare a device, break
* out of the function loop.
*/
break;
}
}
return (0);
}
static int
{
int retval;
/*
* PCI-Express; parent node's private data is a simple di_node_t
* and we have to construct our own did hash and did_t.
*/
else
"Parent %s node missing private data.\n"
return (0);
}
if (did_hash_init(mp) != 0)
return (-1);
return (-1); /* errno already set */
return (retval);
}
static int
{
int retval;
/*
* XXTOPO: we should not be sharing private node data with another
* module. PCI Bus; Parent node's private data is a did_t. We'll
* use the did hash established by the parent.
*/
/*
* If we're looking for a specific bus-instance, find the right
* did_t in the chain, otherwise, there should be only one did_t.
*/
int b;
if (b == min)
break;
}
"Parent %s node missing private data related\n"
return (0);
}
} else {
}
return (retval);
}
/*ARGSUSED*/
static int
{
int retval;
char *pname;
"Currently only know how to enumerate %s or %s.\n",
return (0);
}
"Currently can only enumerate a %s or %s directly\n",
"descended from a %s or %s node.\n",
return (0);
}
} else {
"Currently only know how to enumerate %s or %s not %s.\n",
return (0);
}
return (retval);
}
/*ARGSUSED*/
static void
{
/*
* node private data (did_t) for this node is destroyed in
* did_hash_destroy()
*/
}