xref: /illumos-gate/usr/src/uts/intel/io/intel_nb5000/nb_log.h (revision 8b80e8cb6855118d46f605e91b5ed4ce83417395)
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 _NB_LOG_H
28 #define	_NB_LOG_H
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 #include <sys/cpu_module.h>
35 #include "nb5000.h"
36 
37 #define	NB_MAX_ERRORS	4
38 
39 /* North Bridge front side bus error registers */
40 
41 typedef struct nb_fsb_regs {
42 	uint8_t	fsb;		/* cpu slot */
43 	uint8_t ferr_fat_fsb;
44 	uint8_t nerr_fat_fsb;
45 	uint8_t ferr_nf_fsb;
46 	uint8_t nerr_nf_fsb;
47 	uint64_t nrecfsb_addr;
48 	uint32_t nrecfsb;
49 	uint32_t recfsb;
50 } nb_fsb_regs_t;
51 
52 /* PCI express ESI (South Bridge) error registers */
53 
54 typedef struct nb_pex_regs {
55 	uint8_t pex;		/* pci express slot */
56 	uint32_t pex_fat_ferr;
57 	uint32_t pex_fat_nerr;
58 	uint32_t pex_nf_corr_ferr;
59 	uint32_t pex_nf_corr_nerr;
60 	uint32_t uncerrsev;		/* uncorrectable error severity */
61 	uint32_t rperrsts;		/* root error status */
62 	uint32_t rperrsid;		/* error source identification */
63 	uint32_t uncerrsts;		/* uncorrectable error status */
64 	uint32_t aerrcapctrl;	/* advanced error capabilities and control */
65 	uint32_t corerrsts;	/* correctable error status */
66 	uint16_t pexdevsts;	/* pci express device status */
67 } nb_pex_regs_t;
68 
69 /* North Bridge memory controller hub internal error registers */
70 
71 typedef struct nb_int {
72 	uint16_t ferr_fat_int;	/* first fatal error */
73 	uint16_t ferr_nf_int;	/* first non-fatal error */
74 	uint16_t nerr_fat_int;	/* next fatal error */
75 	uint16_t nerr_nf_int;	/* next non-fatal error */
76 	uint32_t nrecint;	/* non recoverable error log */
77 	uint32_t recint;	/* recoverable error log */
78 	uint64_t nrecsf;	/* non recoverable control information */
79 	uint64_t recsf;		/* recoverable control information */
80 } nb_int_t;
81 
82 /* memory errors */
83 
84 typedef struct nb_fat_fbd {
85 	uint32_t ferr_fat_fbd;	/* fb-dimm first fatal error */
86 	uint32_t nerr_fat_fbd;	/* fb-dimm next fatal error */
87 	uint32_t nrecmema;	/* non recoverable memory error log */
88 	uint32_t nrecmemb;	/* non recoverable memory error log */
89 	uint32_t nrecfglog;	/* non recoverable dimm configuration */
90 	uint32_t nrecfbda;	/* non recoverable dimm log A */
91 	uint32_t nrecfbdb;	/* non recoverable dimm log B */
92 	uint32_t nrecfbdc;	/* non recoverable dimm log C */
93 	uint32_t nrecfbdd;	/* non recoverable dimm log D */
94 	uint32_t nrecfbde;	/* non recoverable dimm log E */
95 	uint32_t nrecfbdf;	/* non recoverable dimm log F */
96 	uint32_t spcpc;		/* spare copy control */
97 	uint8_t spcps;		/* spare copy status */
98 	uint32_t uerrcnt;	/* uncorrectable error count */
99 	uint32_t uerrcnt_last;	/* saved copy of uncorrectable error count */
100 	uint32_t badrama;	/* bad dram marker A */
101 	uint16_t badramb;	/* bad dram marker B */
102 	uint32_t badcnt;	/* bad dram counter */
103 } nb_fat_fbd_t;
104 
105 typedef struct nb_nf_fbd {
106 	uint32_t ferr_nf_fbd;	/* fb-dimm first non-fatal error */
107 	uint32_t nerr_nf_fbd;	/* fb-dimm next non-fatal error */
108 	uint32_t redmemb;	/* recoverable dimm data error log */
109 	uint32_t recmema;	/* recoverable memory error log A */
110 	uint32_t recmemb;	/* recoverable memory error log B */
111 	uint32_t recfglog;	/* recoverable dimm configuration */
112 	uint32_t recfbda;	/* recoverable dimm log A */
113 	uint32_t recfbdb;	/* recoverable dimm log B */
114 	uint32_t recfbdc;	/* recoverable dimm log C */
115 	uint32_t recfbdd;	/* recoverable dimm log D */
116 	uint32_t recfbde;	/* recoverable dimm log E */
117 	uint32_t recfbdf;	/* recoverable dimm log F */
118 	uint32_t spcpc;		/* spare copy control */
119 	uint8_t spcps;		/* spare copy status */
120 	uint32_t cerrcnta;	/* correctable error count A */
121 	uint32_t cerrcntb;	/* correctable error count B */
122 	uint32_t cerrcntc;	/* correctable error count C */
123 	uint32_t cerrcntd;	/* correctable error count D */
124 	uint32_t cerrcnta_last;	/* saved copy of correctable error count A */
125 	uint32_t cerrcntb_last;	/* saved copy of correctable error count B */
126 	uint32_t cerrcntc_last;	/* saved copy of correctable error count C */
127 	uint32_t cerrcntd_last;	/* saved copy of correctable error count D */
128 	uint32_t badrama;	/* bad dram marker A */
129 	uint16_t badramb;	/* bad dram marker B */
130 	uint32_t badcnt;	/* bad dram counter */
131 } nb_nf_fbd_t;
132 
133 typedef struct nb_dma {
134 	uint16_t pcists;
135 	uint16_t pexdevsts;
136 } nb_dma_t;
137 
138 typedef struct nb_thr {
139 	uint8_t ferr_fat_thr;
140 	uint8_t ferr_nf_thr;
141 	uint8_t nerr_fat_thr;
142 	uint8_t nerr_nf_thr;
143 	uint8_t ctsts;
144 	uint16_t thrtsts;
145 } nb_thr_t;
146 
147 typedef struct nb_regs {
148 	int flag;
149 	uint32_t chipset;
150 	uint64_t ferr;
151 	uint32_t nerr;
152 	union {
153 		nb_fsb_regs_t fsb_regs;
154 		nb_pex_regs_t pex_regs;
155 		nb_int_t int_regs;
156 		nb_fat_fbd_t fat_fbd_regs;
157 		nb_nf_fbd_t nf_fbd_regs;
158 		nb_dma_t dma_regs;
159 		nb_thr_t thr_regs;
160 	} nb;
161 } nb_regs_t;
162 
163 #define	NB_REG_LOG_FREE		0
164 #define	NB_REG_LOG_FSB		1
165 #define	NB_REG_LOG_PEX		2
166 #define	NB_REG_LOG_INT		3
167 #define	NB_REG_LOG_FAT_FBD	4
168 #define	NB_REG_LOG_NF_FBD	5
169 #define	NB_REG_LOG_DMA		6
170 #define	NB_REG_LOG_THR		7
171 
172 typedef struct nb_logout {
173 	uint64_t acl_timestamp;
174 	char *type;
175 	nb_regs_t nb_regs;
176 } nb_logout_t;
177 
178 typedef struct nb_mem_scatchpad {
179 	int intel_error_list;		/* error number in Chipset Error List */
180 	int branch;
181 	int channel;
182 	int rank;
183 	int dimm;
184 	int bank;
185 	int cas;
186 	int ras;
187 	uint64_t offset;
188 	uint64_t pa;
189 } nb_mem_scatchpad_t;
190 
191 typedef union nb_scatchpad {
192 	nb_mem_scatchpad_t ms;
193 	int intel_error_list;		/* error number in Chipset Error List */
194 } nb_scatchpad_t;
195 
196 typedef struct nb_dimm {
197 	uint64_t dimm_size;
198 	uint8_t mtr_present;
199 	uint8_t nranks;
200 	uint8_t nbanks;
201 	uint8_t ncolumn;
202 	uint8_t nrow;
203 	uint8_t width;
204 	uint8_t manufacture_location;
205 	uint8_t manufacture_week;
206 	uint8_t manufacture_year;	/* years from 2000 */
207 	uint16_t manufacture_id;
208 	uint32_t serial_number;
209 	char part_number[16];
210 	char revision[2];
211 	char label[64];
212 } nb_dimm_t;
213 
214 typedef struct bank_select {
215 	uint64_t base;
216 	uint64_t limit;
217 	uint8_t	way[2];
218 } bank_select_t;
219 
220 typedef struct rank_select {
221 	uint64_t base;
222 	uint64_t limit;
223 	uint32_t hole_base;
224 	uint32_t hole_size;
225 	uint8_t	rank[4];
226 	uint8_t interleave;
227 	uint8_t branch_interleave;
228 } rank_select_t;
229 
230 enum nb_memory_mode { NB_MEMORY_SINGLE_CHANNEL, NB_MEMORY_NORMAL,
231     NB_MEMORY_SPARE_RANK, NB_MEMORY_MIRROR };
232 
233 extern int nb_5000_memory_controller;
234 extern int nb_number_memory_controllers;
235 extern int nb_dimms_per_channel;
236 
237 extern nb_dimm_t **nb_dimms;
238 extern uint32_t nb_chipset;
239 
240 extern int nb_init(void);
241 extern int nb_dev_init(void);
242 extern void nb_dev_reinit(void);
243 extern void nb_unload(void);
244 extern void nb_dev_unload(void);
245 extern uint32_t top_of_low_memory;
246 extern bank_select_t nb_banks[NB_MAX_MEM_BRANCH_SELECT];
247 extern rank_select_t nb_ranks[NB_5000_MAX_MEM_CONTROLLERS]
248 	[NB_MAX_MEM_RANK_SELECT];
249 extern uint8_t spare_rank[NB_5000_MAX_MEM_CONTROLLERS];
250 extern enum nb_memory_mode nb_mode;
251 
252 extern int inb_mc_register(cmi_hdl_t, void *, void *, void *);
253 extern void nb_scrubber_enable(void);
254 extern void nb_error_trap(cmi_hdl_t, boolean_t, boolean_t);
255 
256 extern void nb_pci_cfg_setup(dev_info_t *);
257 extern void nb_pci_cfg_free(void);
258 
259 extern void *ras_regs;
260 
261 extern uint8_t nb_pci_getb(int, int, int, int, int *);
262 extern uint16_t nb_pci_getw(int, int, int, int, int *);
263 extern uint32_t nb_pci_getl(int, int, int, int, int *);
264 extern void nb_pci_putb(int, int, int, int, uint8_t);
265 extern void nb_pci_putw(int, int, int, int, uint16_t);
266 extern void nb_pci_putl(int, int, int, int, uint32_t);
267 
268 extern void nb_fsb_mask_mc(int, uint16_t);
269 extern void nb_fbd_mask_mc(uint32_t);
270 extern void nb_int_mask_mc(uint32_t);
271 extern void nb_thr_mask_mc(uint16_t);
272 extern void nb_mask_mc_reset(void);
273 
274 extern int nb_mask_mc_set;
275 
276 extern errorq_t *nb_queue;
277 extern kmutex_t nb_mutex;
278 
279 extern void nb_drain(void *, const void *, const errorq_elem_t *);
280 extern void nb_used_spare_rank(int, int);
281 
282 extern uint_t nb_config_gen;
283 
284 #ifdef __cplusplus
285 }
286 #endif
287 
288 #endif /* _NB_LOG_H */
289