ext2fs - A few bug fixes and syntax adjustments.
[dragonfly.git] / sys / dev / atm / hea / eni_intr.c
blob873b15ac6904d055de93315cc47612d4f33de250
1 /*
3 * ===================================
4 * HARP | Host ATM Research Platform
5 * ===================================
8 * This Host ATM Research Platform ("HARP") file (the "Software") is
9 * made available by Network Computing Services, Inc. ("NetworkCS")
10 * "AS IS". NetworkCS does not provide maintenance, improvements or
11 * support of any kind.
13 * NETWORKCS MAKES NO WARRANTIES OR REPRESENTATIONS, EXPRESS OR IMPLIED,
14 * INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY
15 * AND FITNESS FOR A PARTICULAR PURPOSE, AS TO ANY ELEMENT OF THE
16 * SOFTWARE OR ANY SUPPORT PROVIDED IN CONNECTION WITH THIS SOFTWARE.
17 * In no event shall NetworkCS be responsible for any damages, including
18 * but not limited to consequential damages, arising from or relating to
19 * any use of the Software or related support.
21 * Copyright 1994-1998 Network Computing Services, Inc.
23 * Copies of this Software may be made, however, the above copyright
24 * notice must be reproduced on all copies.
26 * @(#) $FreeBSD: src/sys/dev/hea/eni_intr.c,v 1.4 1999/08/28 00:41:44 peter Exp $
27 * @(#) $DragonFly: src/sys/dev/atm/hea/eni_intr.c,v 1.7 2008/03/01 22:03:13 swildner Exp $
31 * Efficient ENI Adapter Support
32 * -----------------------------
34 * Interrupt processing
38 #include <netproto/atm/kern_include.h>
40 #include "eni_stats.h"
41 #include "eni.h"
42 #include "eni_suni.h"
43 #include "eni_var.h"
45 static void eni_suni_intr (Eni_unit *);
48 * SUNI Interrupt processing
50 * Currently, we don't do anything more then clear the interrupt
51 * for the SUNI chip.
53 * Arguments:
54 * eup pointer to device unit structure
56 * Returns:
57 * none
60 static void
61 eni_suni_intr(Eni_unit *eup)
63 int SuniInt;
64 int val;
66 SuniInt = eup->eu_suni[SUNI_IS_REG];
68 /* RSOPI */
69 if ( SuniInt & SUNI_RSOPI )
70 val = eup->eu_suni[SUNI_RSOP_REG];
72 /* RLOPI */
73 if ( SuniInt & SUNI_RLOPI )
74 val = eup->eu_suni[SUNI_RLOP_REG];
76 /* RPOPI */
77 if ( SuniInt & SUNI_RPOPI )
78 val = eup->eu_suni[SUNI_RPOP_IS_REG];
80 /* RACPI */
81 if ( SuniInt & SUNI_RACPI )
82 val = eup->eu_suni[SUNI_RACP_REG];
84 /* TACPI */
85 if ( SuniInt & SUNI_TACPI )
86 val = eup->eu_suni[SUNI_TACP_REG];
88 /* TROOLI */
89 if ( SuniInt & SUNI_TROOLI )
90 val = eup->eu_suni[SUNI_CLOCK_REG];
92 /* LCDI */
93 /* Cleared when reading Master Interrupt Status Reg */
95 /* RDOOLI */
96 if ( SuniInt & SUNI_RDOOLI )
97 val = eup->eu_suni[SUNI_CLOCK_REG];
99 return;
103 * Device interrupt routine
105 * Service an interrupt from this device
107 * Arguments:
108 * eup pointer to device unit structure
110 * Returns:
111 * none
114 void
115 eni_intr(void *arg)
117 Eni_unit *eup = (Eni_unit *)arg;
120 * Read and acknowledge any interrupts
122 u_long mask = eup->eu_midway[MIDWAY_ISA];
124 * Read the error statistics counter
126 u_long sval = eup->eu_midway[MIDWAY_STAT];
129 * Update statistics from adapter
131 eup->eu_trash += ( sval >> 16 );
132 eup->eu_ovfl += ( sval & 0xffff );
135 * We handle any DMA completes first so
136 * that we can free resources for use
137 * during transmit and especially receive
140 * Handle RX DMA Complete
142 if ( mask & ENI_INT_RX_DMA ) {
143 eni_recv_drain ( eup );
147 * Handle TX DMA Complete
149 if ( mask & ENI_INT_TX_DMA ) {
150 eni_xmit_drain ( eup );
154 * Look for any PDUs in service list
156 if ( mask & ENI_INT_SERVICE ) {
157 eni_do_service ( eup );
161 * Handle miscelaneous interrupts
163 if ( mask & ENI_INT_STAT ) { /* STAT_OVFL */
164 log ( LOG_INFO, "eni_intr: stat_ovfl: 0x%lx\n", sval );
166 if ( mask & ENI_INT_SUNI ) { /* SUNI_INTR */
167 eni_suni_intr ( eup );
169 if ( mask & ENI_INT_DMA_ERR ) { /* DMA Error */
170 log ( LOG_ERR,
171 "eni_intr: DMA Error\n" );
173 * We don't know how to recover from DMA errors
174 * yet. The adapter has disabled any further
175 * processing and we're going to leave it like
176 * that.
178 return; /* Leave now */
180 if ( mask & ENI_INT_IDEN ) {
181 log ( LOG_ERR,
182 "eni_intr: TX DMA Ident mismatch\n" );
184 * Something in the TX buffer has really gotten messed
185 * up. Since this is most likely a driver bug, and
186 * the adapter has shut everything down, leave it
187 * like that.
189 return; /* Leave now */
191 if ( mask & ENI_INT_DMA_OVFL )
192 eup->eu_stats.eni_st_drv.drv_xm_dmaovfl++;
193 if ( mask & ENI_INT_DMA_LERR ) {
194 log ( LOG_ERR,
195 "eni_intr: DMA LERR\n" );
196 return;