kernel tree reorganization stage 1: Major cvs repository work (not logged as
[dragonfly.git] / sys / dev / atm / hea / eni_intr.c
1 /*
2  *
3  * ===================================
4  * HARP  |  Host ATM Research Platform
5  * ===================================
6  *
7  *
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.
12  *
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.
20  *
21  * Copyright 1994-1998 Network Computing Services, Inc.
22  *
23  * Copies of this Software may be made, however, the above copyright
24  * notice must be reproduced on all copies.
25  *
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.3 2003/08/07 21:16:49 dillon Exp $
28  */
29
30 /*
31  * Efficient ENI Adapter Support
32  * -----------------------------
33  *
34  * Interrupt processing
35  *
36  */
37
38 #include <netatm/kern_include.h>
39
40 #include "eni_stats.h"
41 #include "eni.h"
42 #include "eni_suni.h"
43 #include "eni_var.h"
44
45 static void     eni_suni_intr __P((Eni_unit *));
46
47 /*
48  * SUNI Interrupt processing
49  *
50  * Currently, we don't do anything more then clear the interrupt
51  * for the SUNI chip.
52  *
53  * Arguments:
54  *      eup             pointer to device unit structure
55  *
56  * Returns:
57  *      none
58  *
59  */
60 static void
61 eni_suni_intr ( eup )
62         Eni_unit *eup;
63 {
64         int     SuniInt;
65         int     val;
66
67         SuniInt = eup->eu_suni[SUNI_IS_REG];
68         
69         /* RSOPI */
70         if ( SuniInt & SUNI_RSOPI )
71                 val = eup->eu_suni[SUNI_RSOP_REG];
72
73         /* RLOPI */
74         if ( SuniInt & SUNI_RLOPI )
75                 val = eup->eu_suni[SUNI_RLOP_REG];
76
77         /* RPOPI */
78         if ( SuniInt & SUNI_RPOPI )
79                 val = eup->eu_suni[SUNI_RPOP_IS_REG];
80
81         /* RACPI */
82         if ( SuniInt & SUNI_RACPI )
83                 val = eup->eu_suni[SUNI_RACP_REG];
84
85         /* TACPI */
86         if ( SuniInt & SUNI_TACPI )
87                 val = eup->eu_suni[SUNI_TACP_REG];
88
89         /* TROOLI */
90         if ( SuniInt & SUNI_TROOLI )
91                 val = eup->eu_suni[SUNI_CLOCK_REG];
92
93         /* LCDI */
94                 /* Cleared when reading Master Interrupt Status Reg */
95
96         /* RDOOLI */
97         if ( SuniInt & SUNI_RDOOLI )
98                 val = eup->eu_suni[SUNI_CLOCK_REG];
99
100         return;
101 }
102
103 /*
104  * Device interrupt routine
105  *
106  * Service an interrupt from this device
107  *
108  * Arguments:
109  *      eup             pointer to device unit structure
110  *
111  * Returns:
112  *      none
113  *
114  */
115 #if defined(BSD) && BSD < 199506
116 int
117 #else
118 void
119 #endif
120 eni_intr ( arg )
121         void *arg;
122 {
123         Eni_unit        *eup = (Eni_unit *)arg;
124 #if defined(BSD) && BSD < 199506
125         int             serviced = 1;
126 #endif  /* BSD < 199506 */
127
128         /*
129          * Read and acknowledge any interrupts
130          */
131         u_long  mask = eup->eu_midway[MIDWAY_ISA];
132         /*
133          * Read the error statistics counter
134          */
135         u_long  sval = eup->eu_midway[MIDWAY_STAT];
136
137         /*
138          * Update statistics from adapter
139          */
140         eup->eu_trash += ( sval >> 16 );
141         eup->eu_ovfl += ( sval & 0xffff );
142
143         /*
144          * We handle any DMA completes first so
145          * that we can free resources for use
146          * during transmit and especially receive
147          */
148         /*
149          * Handle RX DMA Complete
150          */
151         if ( mask & ENI_INT_RX_DMA ) {
152                 eni_recv_drain ( eup );
153         }
154
155         /*
156          * Handle TX DMA Complete
157          */
158         if ( mask & ENI_INT_TX_DMA ) {
159                 eni_xmit_drain ( eup );
160         }
161
162         /*
163          * Look for any PDUs in service list
164          */
165         if ( mask & ENI_INT_SERVICE ) {
166                 eni_do_service ( eup );
167         }
168
169         /*
170          * Handle miscelaneous interrupts
171          */
172         if ( mask & ENI_INT_STAT ) {                    /* STAT_OVFL */
173                 log ( LOG_INFO, "eni_intr: stat_ovfl: 0x%lx\n", sval );
174         }
175         if ( mask & ENI_INT_SUNI ) {                    /* SUNI_INTR */
176                 eni_suni_intr ( eup );
177         }
178         if ( mask & ENI_INT_DMA_ERR ) {                 /* DMA Error */
179                 log ( LOG_ERR,
180                         "eni_intr: DMA Error\n" );
181                 /*
182                  * We don't know how to recover from DMA errors
183                  * yet. The adapter has disabled any further
184                  * processing and we're going to leave it like
185                  * that.
186                  */
187 #if defined(BSD) && BSD < 199506
188                 return serviced;                        /* Leave now */
189 #else
190                 return;                                 /* Leave now */
191 #endif
192         }
193         if ( mask & ENI_INT_IDEN ) {
194                 log ( LOG_ERR,
195                         "eni_intr: TX DMA Ident mismatch\n" );
196                 /*
197                  * Something in the TX buffer has really gotten messed
198                  * up. Since this is most likely a driver bug, and
199                  * the adapter has shut everything down, leave it
200                  * like that.
201                  */
202 #if BSD < 199506
203                 return 0;                               /* Leave now */
204 #else
205                 return;                                 /* Leave now */
206 #endif
207         }
208         if ( mask & ENI_INT_DMA_OVFL )
209                 eup->eu_stats.eni_st_drv.drv_xm_dmaovfl++;
210         if ( mask & ENI_INT_DMA_LERR ) {
211                 log ( LOG_ERR,
212                         "eni_intr: DMA LERR\n" );
213 #if BSD < 199506
214                 return 0;
215 #else
216                 return;
217 #endif
218         }
219
220 #if BSD < 199506
221         return 0;
222 #else
223         return;
224 #endif
225 }
226