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 2007 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #ifndef _DID_IMPL_H 28 #define _DID_IMPL_H 29 30 #pragma ident "%Z%%M% %I% %E% SMI" 31 32 #include <sys/pci.h> 33 #include <fm/libtopo.h> 34 #include <libdevinfo.h> 35 #include <libnvpair.h> 36 #include <did.h> 37 38 #ifdef __cplusplus 39 extern "C" { 40 #endif 41 42 #define REC_HASHLEN 253 43 44 /* 45 * Slot name info is attached to devinfo nodes, compressed inside of 46 * a "slot-names" property. When we dig this out we store each name 47 * as an FMRI, along with the device number to which it applies. 48 */ 49 typedef struct slotnm { 50 topo_mod_t *snm_mod; /* module that allocated the slot name */ 51 struct slotnm *snm_next; 52 int snm_dev; /* device on the bus that implements the slot */ 53 char *snm_label; /* label describing the slot */ 54 } slotnm_t; 55 56 typedef struct did_hash did_hash_t; 57 58 /* 59 * Private data stored with a tnode_t. We collect slot-name info from 60 * di_nodes that describe buses, but then don't use it until we get to 61 * a tnode_t actually describing a function of a device. We also use 62 * this struct to pass around bus, dev, function info so that doesn't 63 * have to be re-computed. 64 */ 65 struct did { 66 struct did *dp_next; /* for chaining in a hash bucket */ 67 struct did *dp_link; /* for chaining to related did_t */ 68 struct did *dp_chain; /* for chaining to another chain of did_ts */ 69 did_hash_t *dp_hash; /* the hash table where we reside */ 70 topo_mod_t *dp_mod; /* module that allocated the did private data */ 71 di_node_t dp_src; /* di_node_t from which the info was derived */ 72 int dp_refcnt; /* multiple nodes allowed to point at a did_t */ 73 uint_t dp_excap; /* PCI-Express capabilities */ 74 int dp_physlot; /* PCI-Express physical slot # */ 75 char *dp_physlot_label; /* PCI-Express slot implemented */ 76 int dp_class; /* PCI class */ 77 int dp_subclass; /* PCI subclass */ 78 int dp_board; /* Board number */ 79 int dp_bridge; /* Bridge number */ 80 int dp_rc; /* Root Complex number */ 81 int dp_bus; /* PCI bus number */ 82 int dp_dev; /* PCI device number on the above bus */ 83 int dp_fn; /* PCI function number of the above device */ 84 int dp_bdf; /* PCI "real" bdf */ 85 /* 86 * There may be some slot name info on devinfo node for a bus or 87 * hostbridge. We'll copy or reference it for child nodes of that 88 * bus or hostbridge. 89 */ 90 int dp_nslots; /* number of slots actually described */ 91 slotnm_t *dp_slotnames; /* the slot names as labels */ 92 tnode_t *dp_tnode; /* the parent tnode */ 93 }; 94 95 struct did_hash { 96 did_t **dph_hash; /* hash bucket array */ 97 uint_t dph_hashlen; /* size of hash bucket array */ 98 uint_t dph_nelems; /* number of elements in the hash */ 99 topo_mod_t *dph_mod; /* module that allocated the hash table */ 100 }; 101 102 #ifdef __cplusplus 103 } 104 #endif 105 106 #endif /* _DID_IMPL_H */ 107