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-2013 Solarflare Communications Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  */
  26 
  27 #include <sys/types.h>
  28 #include <sys/ddi.h>
  29 #include <sys/sunddi.h>
  30 
  31 #include "sfxge.h"
  32 
  33 #include "efx.h"
  34 
  35 static const char *__sfxge_err[] = {
  36         "",
  37         "SRAM out-of-bounds",
  38         "Buffer ID out-of-bounds",
  39         "Internal memory parity",
  40         "Receive buffer ownership",
  41         "Transmit buffer ownership",
  42         "Receive descriptor ownership",
  43         "Transmit descriptor ownership",
  44         "Event queue ownership",
  45         "Event queue FIFO overflow",
  46         "Illegal address",
  47         "SRAM parity"
  48 };
  49 
  50 void
  51 sfxge_err(efsys_identifier_t *arg, unsigned int code, uint32_t dword0,
  52     uint32_t dword1)
  53 {
  54         sfxge_t *sp = (sfxge_t *)arg;
  55         dev_info_t *dip = sp->s_dip;
  56 
  57         ASSERT3U(code, <, EFX_ERR_NCODES);
  58 
  59         cmn_err(CE_WARN, SFXGE_CMN_ERR "[%s%d] FATAL ERROR: %s (0x%08x%08x)",
  60             ddi_driver_name(dip), ddi_get_instance(dip), __sfxge_err[code],
  61             dword1, dword0);
  62 }
  63 
  64 void
  65 sfxge_intr_fatal(sfxge_t *sp)
  66 {
  67         efx_nic_t *enp = sp->s_enp;
  68         int err;
  69 
  70         efx_intr_disable(enp);
  71         efx_intr_fatal(enp);
  72 
  73         err = sfxge_restart_dispatch(sp, DDI_NOSLEEP, SFXGE_HW_ERR,
  74             "Fatal Interrupt", 0);
  75         if (err != 0) {
  76                 cmn_err(CE_WARN, SFXGE_CMN_ERR
  77                             "[%s%d] UNRECOVERABLE ERROR:"
  78                             " Could not schedule driver restart."
  79                             " err=%d\n",
  80                             ddi_driver_name(sp->s_dip),
  81                             ddi_get_instance(sp->s_dip),
  82                             err);
  83                 ASSERT(B_FALSE);
  84         }
  85 }