/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Support routines for managing per-CPU state.
*/
#include <cmd_cpu.h>
#include <cmd_mem.h>
#include <cmd.h>
#include <stdio.h>
#include <string.h>
#include <strings.h>
#include <errno.h>
#include <kstat.h>
#include <sys/niagararegs.h>
#include <cmd_hc_sun4v.h>
static int
{
if (CMD_ERRCL_ISMISCREGS(clcode))
return (MISCREGS_ERR);
else if (CMD_ERRCL_ISL2XXCU(clcode))
return (L2_ERR);
else if (CMD_ERRCL_ISL2ND(clcode))
return (L2ND_ERR);
else if (CMD_ERRCL_ISMEM(clcode))
return (MEM_ERR);
else if (CMD_ERRCL_ISDCDP(clcode))
return (DCDP_ERR);
else if (CMD_ERRCL_ISICDP(clcode))
return (ICDP_ERR);
else if (CMD_ERRCL_REMOTEL2(clcode))
return (REMOTE_L2ERR);
else
return (UNKNOWN_ERR);
}
void
{
int err_type;
switch (err_type) {
case MISCREGS_ERR:
*ed = &miscregsdata;
break;
case L2_ERR:
case REMOTE_L2ERR:
*ed = &n1l2errdata;
} else {
if (CMD_ERRCL_ISL2CE(clcode)) {
*ed = &n2ce_l2errdata;
} else {
*ed = &n2ue_l2errdata;
}
}
break;
case DCDP_ERR:
*ed = &dcachedata;
break;
case ICDP_ERR:
*ed = &icachedata;
break;
/*
* When an error goes through the train, it requires
* to have cmd_case_t & errdata_t structures even it is not
* diagnosed when the error is resolved. Sun4v does
* does not have a L3 error, but the L3 cpu case was defined,
* so its data structures are used for the default cases.
*/
default:
break;
}
}
int
{
/*
* There is no L2 data for a remote write back
* cache error in the ereport, so skip the status check
*/
if (clcode == CMD_ERRCL_WBUE)
return (0);
if (afar_status == AFLT_STAT_VALID)
return (0);
return (-1);
}
/*
* Search for the entry that matches the ena and the AFAR
* if we have a valid AFAR, otherwise search for the entry
* that its's ena is < delta ENA.
*/
/*ARGSUSED*/
{
int i;
if (afar_status == AFLT_STAT_VALID) {
for (i = 0; i < cmd.cmd_xxcu_ntrw; i++) {
cmd.cmd_delta_ena) &&
return (&cmd.cmd_xxcu_trw[i]);
}
}
}
for (i = 0; i < cmd.cmd_xxcu_ntrw; i++) {
< cmd.cmd_delta_ena)
return (&cmd.cmd_xxcu_trw[i]);
}
}
return (NULL);
}
{
int i;
for (i = 0; i < 64; i++) {
tmp = (0x0000000000000001ULL << i);
break;
}
}
return (tmp_mask);
}
/*
* For a resolved error, its error code will be paired with
* each error code in the train mask and compared against the
* pre-defined trains in the cmd_cpu.c to determine if the error
* is in the train.
*/
{
while (error_mask) {
if (tmp_mask == 0)
break;
if (cause) {
return (cause);
}
}
return (0);
}
{
}
int
{
int errtype;
/*
* skip the fill data for the errors which is not L2 errors.
*/
errtype);
return (0);
}
&niagara_l2_afsr) != 0 &&
&niagara_l2_afsr) != 0) {
return (-1);
}
return (-1);
}
/* Niagara-2 doesn't provide separate (redundant) l2-synd */
}
&xr->xr_synd_status) != 0) {
return (-1);
}
return (0);
}
int
{
int i;
/*
* Niagara L2 fetches from a memory location containing a UE
* are given a poison syndrome in one or more 7 bit subsyndromes
* each covering one of 4 4 byte checkwords.
*
* 0 is an invalid syndrome because it denotes no error, but
* is associated with an ereport -- meaning there WAS an error.
*/
/*
* HW does not store the syndrome value for write-back cache
* error, so skip the synd check for L2 write-back error
*/
return (0);
if (synd == 0)
return (-1);
for (i = 0; i < 4; i++) {
if (((synd >> i*NI_L2_POISON_SYND_SIZE) &
return (-1);
}
return (0);
}
int
{
/*
* Set Niagara afar and synd validity.
* For a given set of error registers, the payload value is valid iff
* no higher priority error status bit is set. See niagararegs.h
* for error status bit values and priority settings.
*/
switch (clcode) {
case CMD_ERRCL_LDAU:
case CMD_ERRCL_LDSU:
case CMD_ERRCL_DL2U:
case CMD_ERRCL_IL2U:
*stat_val =
((afsr & NI_L2AFSR_P02) == 0) ?
break;
case CMD_ERRCL_LDWU:
*stat_val =
((afsr & NI_L2AFSR_P03) == 0) ?
break;
case CMD_ERRCL_LDRU:
*stat_val =
((afsr & NI_L2AFSR_P04) == 0) ?
break;
case CMD_ERRCL_LDAC:
case CMD_ERRCL_LDSC:
*stat_val =
((afsr & NI_L2AFSR_P08) == 0) ?
break;
case CMD_ERRCL_LDWC:
*stat_val =
((afsr & NI_L2AFSR_P09) == 0) ?
break;
case CMD_ERRCL_LDRC:
*stat_val =
((afsr & NI_L2AFSR_P10) == 0) ?
break;
default:
return (-1);
}
return (0);
}
int
{
/*
* In Niagara-1, we carried forward the register names afsr and afar
* in ereports from sun4u, even though the hardware registers were
* named esr and ear respectively. In Niagara-2 we decided to conform
* to the hardware names.
*/
&niagara_l2_afsr) != 0 &&
&niagara_l2_afsr) != 0)
return (-1);
return (-1);
if (stat_val == AFLT_STAT_VALID) {
if (nvlist_lookup_uint64(nvl,
FM_EREPORT_PAYLOAD_NAME_L2_AFAR, afar) == 0 ||
FM_EREPORT_PAYLOAD_NAME_L2_EAR, afar) == 0)
return (0);
}
return (-1);
}
/*
* sun4v cmd_cpu_get_frustr expects a 'cpufru' element in 'detector' FMRI
* of ereport (which is stored as 'asru' of cmd_cpu_t). For early sun4v,
* this was mistakenly spec'ed as "hc://MB" instead of "hc:///component=MB",
* so this situation must be remediated when found.
*/
char *
{
char *frustr;
sizeof (CPU_FRU_FMRI) -1) == 0)
else {
"cmd_cpu_getfrustr: no cpufru");
return (NULL);
}
return (s1);
}
}
(void) cmd_set_errno(ENOENT);
return (NULL);
}
char *
char *partstr;
else
return (NULL);
}
char *
char *serialstr;
else
return (NULL);
}
nvlist_t *
{
return (NULL);
return (fru);
}