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