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 2009 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #ifndef _PI_IMPL_H 28 #define _PI_IMPL_H 29 30 /* 31 * SUN4V Platform Independent Enumerator private interfaces 32 */ 33 34 #ifdef __cplusplus 35 extern "C" { 36 #endif 37 38 #include <sys/types.h> 39 #include <pthread.h> 40 #include <libuutil.h> 41 #include <sys/mdesc.h> 42 #include <sys/fm/ldom.h> 43 #include <fm/topo_mod.h> 44 #include <fm/topo_hc.h> 45 46 /* Definitions used when registering the enumerator with libtopo */ 47 #define SUN4VPI_DESC "SUN4V Platform independent topology enumerator" 48 #define SUN4VPI_SCHEME "hc" 49 #define SUN4VPI_VERSION TOPO_VERSION 50 51 /* Flags used by pi_enum_generic_impl */ 52 #define SUN4VPI_ENUM_ADD_SERIAL 1 /* Add serial to resource */ 53 54 /* Definitions used when working with PRI machine description nodes */ 55 #define MD_STR_BACK "back" 56 #define MD_STR_CFG_HANDLE "cfg-handle" /* FWARC/2008/300 */ 57 #define MD_STR_CHIP "chip" 58 #define MD_STR_COMPONENT "component" /* FWARC/2006/700 */ 59 #define MD_STR_CHASSIS "chassis" 60 #define MD_STR_COMPONENTS "components" /* FWARC/2006/700 */ 61 #define MD_STR_DASH_NUMBER "dash_number" /* FWARC/2006/700 */ 62 #define MD_STR_FRU "fru" /* FWARC/2006/700 */ 63 #define MD_STR_FWD "fwd" 64 #define MD_STR_ID "id" /* FWARC/2008/300 */ 65 #define MD_STR_NAC "nac" /* FWARC/2008/300 */ 66 #define MD_STR_NAME "name" 67 #define MD_STR_PART_NUMBER "part_number" /* FWARC/2008/300 */ 68 #define MD_STR_PATH "path" 69 #define MD_STR_PLATFORM "platform" 70 #define MD_STR_PRODUCT "product" /* FWARC/2009/390 */ 71 #define MD_STR_REVISION_NUMBER "rev_number" /* FWARC/2008/300 */ 72 #define MD_STR_SERIAL_NUMBER "serial_number" /* FWARC/2008/300 */ 73 #define MD_STR_TOPO_HC_NAME "topo-hc-name" /* FWARC/2008/300 */ 74 #define MD_STR_TOPO_SKIP "topo-skip" /* FWARC/2008/300 */ 75 #define MD_STR_TYPE "type" 76 77 78 /* 79 * The enumerator needs to pass some state in to the function that walks 80 * the PRI graph. This structure contains the necessary information. 81 */ 82 struct pi_enum_s { 83 topo_mod_t *mod; /* Topo module handle */ 84 85 ldom_hdl_t *ldomp; /* LDOM connection handle */ 86 uint64_t *ldom_bufp; /* LDOM connection data */ 87 ssize_t ldom_bufsize; /* LDOM connection data size */ 88 89 md_t *mdp; /* Machine Description handle */ 90 int md_nodes; /* Number of md nodes */ 91 92 void *wp; /* Walker private data */ 93 }; 94 typedef struct pi_enum_s pi_enum_t; 95 96 97 /* 98 * Some node types require custom functions to create their topology nodes. 99 * This function prototype defines the interface to these functions. 100 */ 101 typedef int pi_enum_fn_t(topo_mod_t *, md_t *, mde_cookie_t, topo_instance_t, 102 tnode_t *, const char *, tnode_t **); 103 104 pi_enum_fn_t pi_enum_cpu; /* Enumerate a CHIP/CORE/CPU node */ 105 pi_enum_fn_t pi_enum_mem; /* Enumerate a DIMM node */ 106 pi_enum_fn_t pi_enum_generic; /* Enumerate a generic PRI node */ 107 pi_enum_fn_t pi_enum_niu; /* Enumerate an NIU node */ 108 pi_enum_fn_t pi_enum_hostbridge; /* Enumerate a hostbridge node */ 109 pi_enum_fn_t pi_enum_pciexrc; /* Enumerate a PCIEX root complex */ 110 pi_enum_fn_t pi_enum_top; /* Enumerate a top-level PRI node */ 111 112 int pi_enum_generic_impl(topo_mod_t *, md_t *, mde_cookie_t, topo_instance_t, 113 tnode_t *, tnode_t *, const char *, const char *, tnode_t **, int flag); 114 115 116 /* 117 * Some enumeration functions may need to defer execution until after the 118 * entire PRI graph has been walked for some nodes. This interface is 119 * provided to allow for the registration of routines to execute after the 120 * entire graph has been walked (for example, to execute sub-enumerators). 121 */ 122 typedef int pi_deferenum_fn_t(topo_mod_t *, md_t *, mde_cookie_t, 123 topo_instance_t, tnode_t *, const char *, tnode_t *, void *); 124 125 int pi_defer_add(topo_mod_t *, mde_cookie_t, tnode_t *, tnode_t *, 126 pi_deferenum_fn_t, void *); 127 int pi_defer_exec(topo_mod_t *, md_t *); 128 129 /* Decorate a PCI-E node. */ 130 int pi_enum_update(topo_mod_t *, md_t *, mde_cookie_t, tnode_t *, tnode_t *, 131 const char *); 132 133 /* Functions to handle LDOM PRI sessions */ 134 int pi_ldompri_open(topo_mod_t *, pi_enum_t *); 135 void pi_ldompri_close(topo_mod_t *, pi_enum_t *); 136 137 138 /* Walk the PRI and create a topology starting at a particular PRI node */ 139 int pi_walker(pi_enum_t *, tnode_t *, const char *, mde_cookie_t, 140 mde_str_cookie_t, mde_str_cookie_t); 141 int pi_walker_init(topo_mod_t *); 142 void pi_walker_fini(topo_mod_t *); 143 144 /* PRI machine description node data access routines */ 145 int pi_find_mdenodes(topo_mod_t *, md_t *, mde_cookie_t, char *, char *, 146 mde_cookie_t **, size_t *); 147 int pi_skip_node(topo_mod_t *, md_t *, mde_cookie_t); 148 char *pi_get_productsn(topo_mod_t *, md_t *, mde_cookie_t); 149 char *pi_get_chassisid(topo_mod_t *, md_t *, mde_cookie_t); 150 char *pi_get_topo_hc_name(topo_mod_t *, md_t *, mde_cookie_t); 151 int pi_get_instance(topo_mod_t *, md_t *, mde_cookie_t, topo_instance_t *); 152 char *pi_get_part(topo_mod_t *, md_t *, mde_cookie_t); 153 char *pi_get_path(topo_mod_t *, md_t *, mde_cookie_t); 154 char *pi_get_productid(topo_mod_t *, md_t *); 155 char *pi_get_revision(topo_mod_t *, md_t *, mde_cookie_t); 156 char *pi_get_serial(topo_mod_t *, md_t *, mde_cookie_t); 157 char *pi_get_serverid(topo_mod_t *); 158 int pi_get_fru(topo_mod_t *, md_t *, mde_cookie_t, int *); 159 char *pi_get_label(topo_mod_t *, md_t *, mde_cookie_t); 160 161 int pi_set_auth(topo_mod_t *, md_t *, mde_cookie_t, tnode_t *, tnode_t *); 162 int pi_set_frufmri(topo_mod_t *, md_t *, mde_cookie_t, const char *, 163 topo_instance_t, tnode_t *, tnode_t *); 164 int pi_set_label(topo_mod_t *, md_t *, mde_cookie_t, tnode_t *); 165 int pi_set_system(topo_mod_t *, tnode_t *); 166 167 tnode_t *pi_node_bind(topo_mod_t *, md_t *, mde_cookie_t, tnode_t *, 168 const char *, topo_instance_t, nvlist_t *); 169 170 #ifdef __cplusplus 171 } 172 #endif 173 174 #endif /* _PI_IMPL_H */ 175