1*49ef7e06SGarrett D'Amore /*
2*49ef7e06SGarrett D'Amore  * Copyright (c) 2012-2015 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 "efx.h"
32*49ef7e06SGarrett D'Amore #include "efx_impl.h"
33*49ef7e06SGarrett D'Amore 
34*49ef7e06SGarrett D'Amore 
35*49ef7e06SGarrett D'Amore #if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD
36*49ef7e06SGarrett D'Amore 
37*49ef7e06SGarrett D'Amore 	__checkReturn	efx_rc_t
ef10_intr_init(__in efx_nic_t * enp,__in efx_intr_type_t type,__in efsys_mem_t * esmp)38*49ef7e06SGarrett D'Amore ef10_intr_init(
39*49ef7e06SGarrett D'Amore 	__in		efx_nic_t *enp,
40*49ef7e06SGarrett D'Amore 	__in		efx_intr_type_t type,
41*49ef7e06SGarrett D'Amore 	__in		efsys_mem_t *esmp)
42*49ef7e06SGarrett D'Amore {
43*49ef7e06SGarrett D'Amore 	_NOTE(ARGUNUSED(enp, type, esmp))
44*49ef7e06SGarrett D'Amore 	return (0);
45*49ef7e06SGarrett D'Amore }
46*49ef7e06SGarrett D'Amore 
47*49ef7e06SGarrett D'Amore 
48*49ef7e06SGarrett D'Amore 			void
ef10_intr_enable(__in efx_nic_t * enp)49*49ef7e06SGarrett D'Amore ef10_intr_enable(
50*49ef7e06SGarrett D'Amore 	__in		efx_nic_t *enp)
51*49ef7e06SGarrett D'Amore {
52*49ef7e06SGarrett D'Amore 	_NOTE(ARGUNUSED(enp))
53*49ef7e06SGarrett D'Amore }
54*49ef7e06SGarrett D'Amore 
55*49ef7e06SGarrett D'Amore 
56*49ef7e06SGarrett D'Amore 			void
ef10_intr_disable(__in efx_nic_t * enp)57*49ef7e06SGarrett D'Amore ef10_intr_disable(
58*49ef7e06SGarrett D'Amore 	__in		efx_nic_t *enp)
59*49ef7e06SGarrett D'Amore {
60*49ef7e06SGarrett D'Amore 	_NOTE(ARGUNUSED(enp))
61*49ef7e06SGarrett D'Amore }
62*49ef7e06SGarrett D'Amore 
63*49ef7e06SGarrett D'Amore 
64*49ef7e06SGarrett D'Amore 			void
ef10_intr_disable_unlocked(__in efx_nic_t * enp)65*49ef7e06SGarrett D'Amore ef10_intr_disable_unlocked(
66*49ef7e06SGarrett D'Amore 	__in		efx_nic_t *enp)
67*49ef7e06SGarrett D'Amore {
68*49ef7e06SGarrett D'Amore 	_NOTE(ARGUNUSED(enp))
69*49ef7e06SGarrett D'Amore }
70*49ef7e06SGarrett D'Amore 
71*49ef7e06SGarrett D'Amore 
72*49ef7e06SGarrett D'Amore static	__checkReturn	efx_rc_t
efx_mcdi_trigger_interrupt(__in efx_nic_t * enp,__in unsigned int level)73*49ef7e06SGarrett D'Amore efx_mcdi_trigger_interrupt(
74*49ef7e06SGarrett D'Amore 	__in		efx_nic_t *enp,
75*49ef7e06SGarrett D'Amore 	__in		unsigned int level)
76*49ef7e06SGarrett D'Amore {
77*49ef7e06SGarrett D'Amore 	efx_mcdi_req_t req;
78*49ef7e06SGarrett D'Amore 	uint8_t payload[MAX(MC_CMD_TRIGGER_INTERRUPT_IN_LEN,
79*49ef7e06SGarrett D'Amore 			    MC_CMD_TRIGGER_INTERRUPT_OUT_LEN)];
80*49ef7e06SGarrett D'Amore 	efx_rc_t rc;
81*49ef7e06SGarrett D'Amore 
82*49ef7e06SGarrett D'Amore 	EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
83*49ef7e06SGarrett D'Amore 		    enp->en_family == EFX_FAMILY_MEDFORD);
84*49ef7e06SGarrett D'Amore 
85*49ef7e06SGarrett D'Amore 	if (level >= enp->en_nic_cfg.enc_intr_limit) {
86*49ef7e06SGarrett D'Amore 		rc = EINVAL;
87*49ef7e06SGarrett D'Amore 		goto fail1;
88*49ef7e06SGarrett D'Amore 	}
89*49ef7e06SGarrett D'Amore 
90*49ef7e06SGarrett D'Amore 	(void) memset(payload, 0, sizeof (payload));
91*49ef7e06SGarrett D'Amore 	req.emr_cmd = MC_CMD_TRIGGER_INTERRUPT;
92*49ef7e06SGarrett D'Amore 	req.emr_in_buf = payload;
93*49ef7e06SGarrett D'Amore 	req.emr_in_length = MC_CMD_TRIGGER_INTERRUPT_IN_LEN;
94*49ef7e06SGarrett D'Amore 	req.emr_out_buf = payload;
95*49ef7e06SGarrett D'Amore 	req.emr_out_length = MC_CMD_TRIGGER_INTERRUPT_OUT_LEN;
96*49ef7e06SGarrett D'Amore 
97*49ef7e06SGarrett D'Amore 	MCDI_IN_SET_DWORD(req, TRIGGER_INTERRUPT_IN_INTR_LEVEL, level);
98*49ef7e06SGarrett D'Amore 
99*49ef7e06SGarrett D'Amore 	efx_mcdi_execute(enp, &req);
100*49ef7e06SGarrett D'Amore 
101*49ef7e06SGarrett D'Amore 	if (req.emr_rc != 0) {
102*49ef7e06SGarrett D'Amore 		rc = req.emr_rc;
103*49ef7e06SGarrett D'Amore 		goto fail2;
104*49ef7e06SGarrett D'Amore 	}
105*49ef7e06SGarrett D'Amore 
106*49ef7e06SGarrett D'Amore 	return (0);
107*49ef7e06SGarrett D'Amore 
108*49ef7e06SGarrett D'Amore fail2:
109*49ef7e06SGarrett D'Amore 	EFSYS_PROBE(fail2);
110*49ef7e06SGarrett D'Amore 
111*49ef7e06SGarrett D'Amore fail1:
112*49ef7e06SGarrett D'Amore 	EFSYS_PROBE1(fail1, efx_rc_t, rc);
113*49ef7e06SGarrett D'Amore 
114*49ef7e06SGarrett D'Amore 	return (rc);
115*49ef7e06SGarrett D'Amore }
116*49ef7e06SGarrett D'Amore 
117*49ef7e06SGarrett D'Amore 	__checkReturn	efx_rc_t
ef10_intr_trigger(__in efx_nic_t * enp,__in unsigned int level)118*49ef7e06SGarrett D'Amore ef10_intr_trigger(
119*49ef7e06SGarrett D'Amore 	__in		efx_nic_t *enp,
120*49ef7e06SGarrett D'Amore 	__in		unsigned int level)
121*49ef7e06SGarrett D'Amore {
122*49ef7e06SGarrett D'Amore 	efx_nic_cfg_t *encp = &(enp->en_nic_cfg);
123*49ef7e06SGarrett D'Amore 	efx_rc_t rc;
124*49ef7e06SGarrett D'Amore 
125*49ef7e06SGarrett D'Amore 	if (encp->enc_bug41750_workaround) {
126*49ef7e06SGarrett D'Amore 		/*
127*49ef7e06SGarrett D'Amore 		 * bug 41750: Test interrupts don't work on Greenport
128*49ef7e06SGarrett D'Amore 		 * bug 50084: Test interrupts don't work on VFs
129*49ef7e06SGarrett D'Amore 		 */
130*49ef7e06SGarrett D'Amore 		rc = ENOTSUP;
131*49ef7e06SGarrett D'Amore 		goto fail1;
132*49ef7e06SGarrett D'Amore 	}
133*49ef7e06SGarrett D'Amore 
134*49ef7e06SGarrett D'Amore 	if ((rc = efx_mcdi_trigger_interrupt(enp, level)) != 0)
135*49ef7e06SGarrett D'Amore 		goto fail2;
136*49ef7e06SGarrett D'Amore 
137*49ef7e06SGarrett D'Amore 	return (0);
138*49ef7e06SGarrett D'Amore 
139*49ef7e06SGarrett D'Amore fail2:
140*49ef7e06SGarrett D'Amore 	EFSYS_PROBE(fail2);
141*49ef7e06SGarrett D'Amore fail1:
142*49ef7e06SGarrett D'Amore 	EFSYS_PROBE1(fail1, efx_rc_t, rc);
143*49ef7e06SGarrett D'Amore 
144*49ef7e06SGarrett D'Amore 	return (rc);
145*49ef7e06SGarrett D'Amore }
146*49ef7e06SGarrett D'Amore 
147*49ef7e06SGarrett D'Amore 			void
ef10_intr_status_line(__in efx_nic_t * enp,__out boolean_t * fatalp,__out uint32_t * qmaskp)148*49ef7e06SGarrett D'Amore ef10_intr_status_line(
149*49ef7e06SGarrett D'Amore 	__in		efx_nic_t *enp,
150*49ef7e06SGarrett D'Amore 	__out		boolean_t *fatalp,
151*49ef7e06SGarrett D'Amore 	__out		uint32_t *qmaskp)
152*49ef7e06SGarrett D'Amore {
153*49ef7e06SGarrett D'Amore 	efx_dword_t dword;
154*49ef7e06SGarrett D'Amore 
155*49ef7e06SGarrett D'Amore 	EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
156*49ef7e06SGarrett D'Amore 		    enp->en_family == EFX_FAMILY_MEDFORD);
157*49ef7e06SGarrett D'Amore 
158*49ef7e06SGarrett D'Amore 	/* Read the queue mask and implicitly acknowledge the interrupt. */
159*49ef7e06SGarrett D'Amore 	EFX_BAR_READD(enp, ER_DZ_BIU_INT_ISR_REG, &dword, B_FALSE);
160*49ef7e06SGarrett D'Amore 	*qmaskp = EFX_DWORD_FIELD(dword, EFX_DWORD_0);
161*49ef7e06SGarrett D'Amore 
162*49ef7e06SGarrett D'Amore 	EFSYS_PROBE1(qmask, uint32_t, *qmaskp);
163*49ef7e06SGarrett D'Amore 
164*49ef7e06SGarrett D'Amore 	*fatalp = B_FALSE;
165*49ef7e06SGarrett D'Amore }
166*49ef7e06SGarrett D'Amore 
167*49ef7e06SGarrett D'Amore 			void
ef10_intr_status_message(__in efx_nic_t * enp,__in unsigned int message,__out boolean_t * fatalp)168*49ef7e06SGarrett D'Amore ef10_intr_status_message(
169*49ef7e06SGarrett D'Amore 	__in		efx_nic_t *enp,
170*49ef7e06SGarrett D'Amore 	__in		unsigned int message,
171*49ef7e06SGarrett D'Amore 	__out		boolean_t *fatalp)
172*49ef7e06SGarrett D'Amore {
173*49ef7e06SGarrett D'Amore 	EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
174*49ef7e06SGarrett D'Amore 		    enp->en_family == EFX_FAMILY_MEDFORD);
175*49ef7e06SGarrett D'Amore 
176*49ef7e06SGarrett D'Amore 	_NOTE(ARGUNUSED(enp, message))
177*49ef7e06SGarrett D'Amore 
178*49ef7e06SGarrett D'Amore 	/* EF10 fatal errors are reported via events */
179*49ef7e06SGarrett D'Amore 	*fatalp = B_FALSE;
180*49ef7e06SGarrett D'Amore }
181*49ef7e06SGarrett D'Amore 
182*49ef7e06SGarrett D'Amore 			void
ef10_intr_fatal(__in efx_nic_t * enp)183*49ef7e06SGarrett D'Amore ef10_intr_fatal(
184*49ef7e06SGarrett D'Amore 	__in		efx_nic_t *enp)
185*49ef7e06SGarrett D'Amore {
186*49ef7e06SGarrett D'Amore 	/* EF10 fatal errors are reported via events */
187*49ef7e06SGarrett D'Amore 	_NOTE(ARGUNUSED(enp))
188*49ef7e06SGarrett D'Amore }
189*49ef7e06SGarrett D'Amore 
190*49ef7e06SGarrett D'Amore 			void
ef10_intr_fini(__in efx_nic_t * enp)191*49ef7e06SGarrett D'Amore ef10_intr_fini(
192*49ef7e06SGarrett D'Amore 	__in		efx_nic_t *enp)
193*49ef7e06SGarrett D'Amore {
194*49ef7e06SGarrett D'Amore 	_NOTE(ARGUNUSED(enp))
195*49ef7e06SGarrett D'Amore }
196*49ef7e06SGarrett D'Amore 
197*49ef7e06SGarrett D'Amore #endif	/* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD */
198