did_impl.h revision 00d0963faf2e861a4aef6b1bf28f99a5b2b20755
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey/*
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey * CDDL HEADER START
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey *
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey * The contents of this file are subject to the terms of the
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey * Common Development and Distribution License (the "License").
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey * You may not use this file except in compliance with the License.
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey *
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey * or http://www.opensolaris.org/os/licensing.
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey * See the License for the specific language governing permissions
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey * and limitations under the License.
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey *
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey * When distributing Covered Code, include this CDDL HEADER in each
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey * If applicable, add the following below this CDDL HEADER, with the
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey * fields enclosed by brackets "[]" replaced with your own identifying
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey * information: Portions Copyright [yyyy] [name of copyright owner]
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey *
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey * CDDL HEADER END
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey */
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey/*
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey * Use is subject to license terms.
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey */
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey#ifndef _DID_IMPL_H
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey#define _DID_IMPL_H
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey#pragma ident "%Z%%M% %I% %E% SMI"
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey#include <sys/pci.h>
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey#include <fm/libtopo.h>
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey#include <libdevinfo.h>
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey#include <libnvpair.h>
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey#ifdef __cplusplus
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskeyextern "C" {
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey#endif
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey#define REC_HASHLEN 253
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskeystruct did_hash;
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey/*
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey * Slot name info is attached to devinfo nodes, compressed inside of
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey * a "slot-names" property. When we dig this out we store each name
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey * as an FMRI, along with the device number to which it applies.
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey */
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskeytypedef struct slotnm {
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey topo_mod_t *snm_mod; /* module that allocated the slot name */
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey struct slotnm *snm_next;
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey int snm_dev; /* device on the bus that implements the slot */
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey char *snm_label; /* label describing the slot */
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey} slotnm_t;
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey/*
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey * Private data stored with a tnode_t. We collect slot-name info from
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey * di_nodes that describe buses, but then don't use it until we get to
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey * a tnode_t actually describing a function of a device. We also use
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey * this struct to pass around bus, dev, function info so that doesn't
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey * have to be re-computed.
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey */
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskeytypedef struct did {
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey struct did *dp_next; /* for chaining in a hash bucket */
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey struct did *dp_link; /* for chaining to related did_t */
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey struct did *dp_chain; /* for chaining to another chain of did_ts */
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey struct did_hash *dp_hash; /* the hash table where we reside */
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey topo_mod_t *dp_mod; /* module that allocated the did private data */
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey di_node_t dp_src; /* di_node_t from which the info was derived */
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey int dp_refcnt; /* multiple nodes allowed to point at a did_t */
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey uint_t dp_excap; /* PCI-Express capabilities */
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey int dp_physlot; /* PCI-Express physical slot # */
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey char *dp_physlot_label; /* PCI-Express slot implemented */
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey int dp_class; /* PCI class */
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey int dp_subclass; /* PCI subclass */
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey int dp_board; /* Board number */
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey int dp_bridge; /* Bridge number */
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey int dp_rc; /* Root Complex number */
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey int dp_bus; /* PCI bus number */
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey int dp_dev; /* PCI device number on the above bus */
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey int dp_fn; /* PCI function number of the above device */
int dp_bdf; /* PCI "real" bdf */
/*
* There may be some slot name info on devinfo node for a bus or
* hostbridge. We'll copy or reference it for child nodes of that
* bus or hostbridge.
*/
int dp_nslots; /* number of slots actually described */
slotnm_t *dp_slotnames; /* the slot names as labels */
} did_t;
typedef struct did_hash {
did_t **dph_hash; /* hash bucket array */
uint_t dph_hashlen; /* size of hash bucket array */
uint_t dph_nelems; /* number of elements in the hash */
topo_mod_t *dph_mod; /* module that allocated the hash table */
} did_hash_t;
extern did_hash_t *did_hash_create(topo_mod_t *);
extern did_t *did_hash_lookup(did_hash_t *, di_node_t);
extern void did_hash_destroy(did_hash_t *);
extern void did_hash_insert(did_hash_t *, di_node_t, did_t *);
extern did_t *did_create(did_hash_t *, di_node_t, int, int, int, int);
extern void did_destroy(did_t *);
extern void did_hold(did_t *);
extern void did_rele(did_t *);
#ifdef __cplusplus
}
#endif
#endif /* _DID_IMPL_H */