1 /* 2 * This file and its contents are supplied under the terms of the 3 * Common Development and Distribution License ("CDDL"), version 1.0. 4 * You may only use this file in accordance with the terms of version 5 * 1.0 of the CDDL. 6 * 7 * A full copy of the text of the CDDL should have accompanied this 8 * source. A copy of the CDDL is also available via the Internet at 9 * http://www.illumos.org/license/CDDL. 10 */ 11 12 /* 13 * Copyright 2024 Oxide Computer company 14 */ 15 16 #ifndef _TOPO_ZEN_IMPL_H 17 #define _TOPO_ZEN_IMPL_H 18 19 /* 20 * Internal implementation details of the topo_zen module. 21 */ 22 23 #include <fm/topo_mod.h> 24 #include <amdzen_topo.h> 25 #include <fm/fmd_agent.h> 26 #include <libnvpair.h> 27 #include <kstat.h> 28 29 #include "topo_zen.h" 30 31 #ifdef __cplusplus 32 extern "C" { 33 #endif 34 /* 35 * Global data related to our module. 36 */ 37 typedef struct zen_topo { 38 int zt_fd; 39 amdzen_topo_base_t zt_base; 40 amdzen_topo_df_t *zt_dfs; 41 } zen_topo_t; 42 43 typedef struct zen_topo_enum_core { 44 tnode_t *ztcore_tn; 45 tnode_t *ztcore_l1i_tn; 46 tnode_t *ztcore_l1d_tn; 47 tnode_t *ztcore_l2_tn; 48 nvlist_t *ztcore_l1i; 49 nvlist_t *ztcore_l1d; 50 nvlist_t *ztcore_l2; 51 nvlist_t *ztcore_nvls[AMDZEN_TOPO_CORE_MAX_THREADS]; 52 tnode_t *ztcore_thr_tn[AMDZEN_TOPO_CORE_MAX_THREADS]; 53 } zen_topo_enum_core_t; 54 55 typedef struct zen_topo_enum_ccx { 56 tnode_t *ztccx_tn; 57 tnode_t *ztccx_l3_tn; 58 nvlist_t *ztccx_l3; 59 zen_topo_enum_core_t ztccx_core[AMDZEN_TOPO_CCX_MAX_CORES]; 60 } zen_topo_enum_ccx_t; 61 62 typedef struct zen_topo_enum_ccd { 63 tnode_t *ztccd_tn; 64 zen_topo_enum_ccx_t ztccd_ccx[AMDZEN_TOPO_CCD_MAX_CCX]; 65 } zen_topo_enum_ccd_t; 66 67 typedef struct zen_topo_enum_sock { 68 uint32_t ztes_sockid; 69 uint32_t ztes_nccd; 70 uint32_t ztes_nccd_valid; 71 const amdzen_topo_df_t *ztes_df; 72 amdzen_topo_ccd_t *ztes_ccd; 73 zen_topo_enum_ccd_t *ztes_tn_ccd; 74 fmd_agent_hdl_t *ztes_fm_agent; 75 kstat_ctl_t *ztes_kstat; 76 uint_t ztes_ncpus; 77 nvlist_t **ztes_cpus; 78 fmd_agent_cpu_cache_list_t ztes_cache; 79 tnode_t *ztes_tn; 80 /* 81 * These strings come from the CPU and kstat memory. Their lifetime 82 * cannot outlive that of our underlying data sources. 83 */ 84 const char *ztes_cpu_serial; 85 const char *ztes_cpu_rev; 86 const char *ztes_cpu_brand; 87 const char *ztes_cpu_sock; 88 int32_t ztes_cpu_fam; 89 int32_t ztes_cpu_model; 90 int32_t ztes_cpu_step; 91 } zen_topo_enum_sock_t; 92 93 extern int topo_zen_build_chip(topo_mod_t *, tnode_t *, topo_instance_t, 94 zen_topo_enum_sock_t *); 95 extern int topo_zen_create_tctl(topo_mod_t *, tnode_t *, 96 const amdzen_topo_df_t *); 97 extern int topo_zen_create_tdie(topo_mod_t *, tnode_t *, 98 const amdzen_topo_ccd_t *); 99 100 #ifdef __cplusplus 101 } 102 #endif 103 104 #endif /* _TOPO_ZEN_IMPL_H */ 105