1*49ef7e06SGarrett D'Amore /*
2*49ef7e06SGarrett D'Amore  * Copyright (c) 2008-2016 Solarflare Communications Inc.
3*49ef7e06SGarrett D'Amore  * All rights reserved.
4*49ef7e06SGarrett D'Amore  *
5*49ef7e06SGarrett D'Amore  * Redistribution and use in source and binary forms, with or without
6*49ef7e06SGarrett D'Amore  * modification, are permitted provided that the following conditions are met:
7*49ef7e06SGarrett D'Amore  *
8*49ef7e06SGarrett D'Amore  * 1. Redistributions of source code must retain the above copyright notice,
9*49ef7e06SGarrett D'Amore  *    this list of conditions and the following disclaimer.
10*49ef7e06SGarrett D'Amore  * 2. Redistributions in binary form must reproduce the above copyright notice,
11*49ef7e06SGarrett D'Amore  *    this list of conditions and the following disclaimer in the documentation
12*49ef7e06SGarrett D'Amore  *    and/or other materials provided with the distribution.
13*49ef7e06SGarrett D'Amore  *
14*49ef7e06SGarrett D'Amore  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15*49ef7e06SGarrett D'Amore  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
16*49ef7e06SGarrett D'Amore  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17*49ef7e06SGarrett D'Amore  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
18*49ef7e06SGarrett D'Amore  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19*49ef7e06SGarrett D'Amore  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20*49ef7e06SGarrett D'Amore  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
21*49ef7e06SGarrett D'Amore  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
22*49ef7e06SGarrett D'Amore  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
23*49ef7e06SGarrett D'Amore  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
24*49ef7e06SGarrett D'Amore  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25*49ef7e06SGarrett D'Amore  *
26*49ef7e06SGarrett D'Amore  * The views and conclusions contained in the software and documentation are
27*49ef7e06SGarrett D'Amore  * those of the authors and should not be interpreted as representing official
28*49ef7e06SGarrett D'Amore  * policies, either expressed or implied, of the FreeBSD Project.
29*49ef7e06SGarrett D'Amore  */
30*49ef7e06SGarrett D'Amore 
31*49ef7e06SGarrett D'Amore #include <sys/types.h>
32*49ef7e06SGarrett D'Amore #include <sys/ddi.h>
33*49ef7e06SGarrett D'Amore #include <sys/sunddi.h>
34*49ef7e06SGarrett D'Amore 
35*49ef7e06SGarrett D'Amore #include "sfxge.h"
36*49ef7e06SGarrett D'Amore 
37*49ef7e06SGarrett D'Amore #include "efx.h"
38*49ef7e06SGarrett D'Amore 
39*49ef7e06SGarrett D'Amore static const char *__sfxge_err[] = {
40*49ef7e06SGarrett D'Amore 	"",
41*49ef7e06SGarrett D'Amore 	"SRAM out-of-bounds",
42*49ef7e06SGarrett D'Amore 	"Buffer ID out-of-bounds",
43*49ef7e06SGarrett D'Amore 	"Internal memory parity",
44*49ef7e06SGarrett D'Amore 	"Receive buffer ownership",
45*49ef7e06SGarrett D'Amore 	"Transmit buffer ownership",
46*49ef7e06SGarrett D'Amore 	"Receive descriptor ownership",
47*49ef7e06SGarrett D'Amore 	"Transmit descriptor ownership",
48*49ef7e06SGarrett D'Amore 	"Event queue ownership",
49*49ef7e06SGarrett D'Amore 	"Event queue FIFO overflow",
50*49ef7e06SGarrett D'Amore 	"Illegal address",
51*49ef7e06SGarrett D'Amore 	"SRAM parity"
52*49ef7e06SGarrett D'Amore };
53*49ef7e06SGarrett D'Amore 
54*49ef7e06SGarrett D'Amore void
sfxge_err(efsys_identifier_t * arg,unsigned int code,uint32_t dword0,uint32_t dword1)55*49ef7e06SGarrett D'Amore sfxge_err(efsys_identifier_t *arg, unsigned int code, uint32_t dword0,
56*49ef7e06SGarrett D'Amore     uint32_t dword1)
57*49ef7e06SGarrett D'Amore {
58*49ef7e06SGarrett D'Amore 	sfxge_t *sp = (sfxge_t *)arg;
59*49ef7e06SGarrett D'Amore 	dev_info_t *dip = sp->s_dip;
60*49ef7e06SGarrett D'Amore 
61*49ef7e06SGarrett D'Amore 	ASSERT3U(code, <, EFX_ERR_NCODES);
62*49ef7e06SGarrett D'Amore 
63*49ef7e06SGarrett D'Amore 	dev_err(dip, CE_WARN, SFXGE_CMN_ERR "FATAL ERROR: %s (0x%08x%08x)",
64*49ef7e06SGarrett D'Amore 	    __sfxge_err[code], dword1, dword0);
65*49ef7e06SGarrett D'Amore }
66*49ef7e06SGarrett D'Amore 
67*49ef7e06SGarrett D'Amore void
sfxge_intr_fatal(sfxge_t * sp)68*49ef7e06SGarrett D'Amore sfxge_intr_fatal(sfxge_t *sp)
69*49ef7e06SGarrett D'Amore {
70*49ef7e06SGarrett D'Amore 	efx_nic_t *enp = sp->s_enp;
71*49ef7e06SGarrett D'Amore 	int err;
72*49ef7e06SGarrett D'Amore 
73*49ef7e06SGarrett D'Amore 	efx_intr_disable(enp);
74*49ef7e06SGarrett D'Amore 	efx_intr_fatal(enp);
75*49ef7e06SGarrett D'Amore 
76*49ef7e06SGarrett D'Amore 	err = sfxge_restart_dispatch(sp, DDI_NOSLEEP, SFXGE_HW_ERR,
77*49ef7e06SGarrett D'Amore 	    "Fatal Interrupt", 0);
78*49ef7e06SGarrett D'Amore 	if (err != 0) {
79*49ef7e06SGarrett D'Amore 		dev_err(sp->s_dip, CE_WARN, SFXGE_CMN_ERR
80*49ef7e06SGarrett D'Amore 		    "UNRECOVERABLE ERROR:"
81*49ef7e06SGarrett D'Amore 		    " Could not schedule driver restart. err=%d",
82*49ef7e06SGarrett D'Amore 		    err);
83*49ef7e06SGarrett D'Amore 		ASSERT(B_FALSE);
84*49ef7e06SGarrett D'Amore 	}
85*49ef7e06SGarrett D'Amore }
86