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 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26 #ifndef _CMD_DIMM_H 27 #define _CMD_DIMM_H 28 29 /* 30 * Memory modules are described by the cmd_dimm general-purpose state structure. 31 * Whereas banks are primarily used to track UEs, this structure is used to 32 * track CEs, which can be associated with individual modules. Each memory 33 * module is part of a bank, and will have a link to the bank if the bank is 34 * known to the diagnosis engine. Banks will be known if UEs have occurred. 35 * 36 * Data structures: 37 * 38 * ,--------. ,--------. 39 * |dimm | <---- |case_ptr| (CMD_PTR_DIMM_CASE) 40 * | | `--------' 41 * |,-------| ,-------------. 42 * ,->||asru_t | ----> |packed nvlist| 43 * | |`-------| `-------------' 44 * `--| unum | 45 * | bank | ----> bank buffer 46 * `--------' 47 * 48 * Data structure P? Case? Notes 49 * ---------------- --- ----- ---------------------------------------------- 50 * cmd_dimm_t Yes No Name is derived from the unum ("dimm_%s") 51 * cmd_case_ptr_t Yes Yes Name is case's UUID 52 * dimm_asru Yes No Name is derived from the unum ("dimm_asru_%d") 53 * dimm_unum No No Pointer into ASRU - relinked during restore 54 * dimm_bank No No Recreated during restore 55 */ 56 57 #include <cmd_mem.h> 58 #include <values.h> 59 60 #ifdef __cplusplus 61 extern "C" { 62 #endif 63 64 /* 65 * CMD_MAX_CKWDS denotes the highest number, across all covered 66 * SPARC architectures, of checkwords per cache line. 67 */ 68 69 #define CMD_MAX_CKWDS 4 70 71 /* 72 * The DIMM structure started life without a version number. Making things more 73 * complicated, the version number in the new struct occupies the space used for 74 * the case pointer in the non-versioned struct. We therefore have to use 75 * somewhat unorthodox version numbers so as to allow us to easily tell the 76 * difference between a version number and a case pointer. Case pointers will 77 * be zero or (this being SPARC), a value with the bottom two bits clear. Our 78 * version numbers will begin with 0x11, and will increase by 0x10 each time. 79 */ 80 81 #define DIMM_MKVERSION(version) ((version) << 4 | 1) 82 83 #define CMD_DIMM_VERSION_1 DIMM_MKVERSION(1) /* 17 */ 84 #define CMD_DIMM_VERSION CMD_DIMM_VERSION_1 85 86 #define CMD_DIMM_VERSIONED(dimm) ((dimm)->dimm_version & 1) 87 88 #define CMD_DIMM_STAT_PREFIX "d" /* d = dimm */ 89 90 typedef struct cmd_dimm_0 { 91 cmd_header_t dimm0_header; /* Nodetype must be CMD_NT_DIMM */ 92 fmd_case_t *dimm0_case; /* Open CE case against this DIMM */ 93 cmd_fmri_t dimm0_asru; /* ASRU for this DIMM */ 94 const char *dimm0_unum; /* This DIMM's name */ 95 uint_t dimm0_wrnthresh; /* # of pages retired before warning */ 96 uint_t dimm0_nretired; /* # ret'd pages for CEs in DIMM */ 97 cmd_bank_t *dimm0_bank; /* This DIMM's bank (if discovered) */ 98 } cmd_dimm_0_t; 99 100 typedef struct cmd_dimm_pers { 101 cmd_header_t dimmp_header; /* Nodetype must be CMD_NT_DIMM */ 102 uint_t dimmp_version; 103 cmd_fmri_t dimmp_asru; /* ASRU for this DIMM */ 104 uint_t dimmp_flags; /* CMD_MEM_F_* */ 105 uint_t dimmp_nretired; /* # ret'd pages for CEs in DIMM */ 106 } cmd_dimm_pers_t; 107 108 /* 109 * Index block for MQSC rules 4A and 4B correlation of memory CEs 110 * on a single DIMM. "Unit Position" refers to bit or nibble depending 111 * on the memory ECC. This structure is not persisted. 112 */ 113 114 typedef struct cmd_mq { 115 cmd_list_t mq_l; /* pointers to prev and next */ 116 uint64_t mq_tstamp; /* timestamp of ereport in secs */ 117 uint16_t mq_ckwd; /* phys addr mod 64 */ 118 uint64_t mq_phys_addr; /* from ereport */ 119 uint16_t mq_unit_position; /* bit for sun4u, nibble for sun4v */ 120 int16_t mq_dram; /* by table lookup from unit pos */ 121 fmd_event_t *mq_ep; /* ereport - for potential fault */ 122 char *mq_serdnm; /* serd eng to retain CE events */ 123 } cmd_mq_t; 124 125 struct cmd_dimm { 126 cmd_dimm_pers_t dimm_pers; 127 cmd_bank_t *dimm_bank; /* This DIMM's bank (if discovered) */ 128 const char *dimm_unum; /* This DIMM's name */ 129 cmd_case_t dimm_case; /* Open CE case against this DIMM */ 130 fmd_stat_t dimm_retstat; /* retirement statistics, this DIMM */ 131 cmd_list_t 132 mq_root[CMD_MAX_CKWDS]; /* per-checkword CEs to correlate */ 133 }; 134 135 #define CMD_MQ_TIMELIM (72*60*60) /* 72 hours */ 136 #define CMD_MQ_SERDT MAXINT /* Never expected to fire */ 137 #define CMD_MQ_SERDN 2 /* Dup CEs not allowed */ 138 139 #define CMD_DIMM_MAXSIZE \ 140 MAX(sizeof (cmd_dimm_0_t), sizeof (cmd_dimm_pers_t)) 141 #define CMD_DIMM_MINSIZE \ 142 MIN(sizeof (cmd_dimm_0_t), sizeof (cmd_dimm_pers_t)) 143 144 #define dimm_header dimm_pers.dimmp_header 145 #define dimm_nodetype dimm_pers.dimmp_header.hdr_nodetype 146 #define dimm_bufname dimm_pers.dimmp_header.hdr_bufname 147 #define dimm_version dimm_pers.dimmp_version 148 #define dimm_asru dimm_pers.dimmp_asru 149 #define dimm_asru_nvl dimm_pers.dimmp_asru.fmri_nvl 150 #define dimm_flags dimm_pers.dimmp_flags 151 #define dimm_nretired dimm_pers.dimmp_nretired 152 153 extern cmd_dimm_t *cmd_dimm_lookup(fmd_hdl_t *, nvlist_t *); 154 extern cmd_dimm_t *cmd_dimm_create(fmd_hdl_t *, nvlist_t *); 155 156 extern nvlist_t *cmd_dimm_fru(cmd_dimm_t *); 157 extern nvlist_t *cmd_dimm_create_fault(fmd_hdl_t *, cmd_dimm_t *, const char *, 158 uint_t); 159 #ifdef sun4v 160 extern nvlist_t *cmd_mem2hc(fmd_hdl_t *, nvlist_t *); 161 #endif /* sun4v */ 162 163 extern nvlist_t *cmd_dimm_fmri_derive(fmd_hdl_t *, uint64_t, uint16_t, 164 uint64_t); 165 extern int cmd_dimm_thresh_reached(fmd_hdl_t *, cmd_dimm_t *, uint64_t, 166 uint16_t); 167 168 extern void cmd_dimm_dirty(fmd_hdl_t *, cmd_dimm_t *); 169 extern void *cmd_dimm_restore(fmd_hdl_t *, fmd_case_t *, cmd_case_ptr_t *); 170 extern void cmd_dimm_destroy(fmd_hdl_t *, cmd_dimm_t *); 171 extern void cmd_dimm_validate(fmd_hdl_t *); 172 extern void cmd_dimm_gc(fmd_hdl_t *); 173 extern void cmd_dimm_fini(fmd_hdl_t *); 174 175 extern void cmd_dimmlist_free(fmd_hdl_t *); 176 177 #ifdef __cplusplus 178 } 179 #endif 180 181 #endif /* _CMD_DIMM_H */ 182