HAMMER 60I/Many: Mirroring
[dragonfly.git] / sys / dev / atm / hfa / fore_intr.c
blob74667034a804c010202a4051c390c84142a1755b
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/hfa/fore_intr.c,v 1.3 1999/08/28 00:41:50 peter Exp $
27 * @(#) $DragonFly: src/sys/dev/atm/hfa/fore_intr.c,v 1.6 2008/03/01 22:03:13 swildner Exp $
31 * FORE Systems 200-Series Adapter Support
32 * ---------------------------------------
34 * Interrupt processing
38 #include "fore_include.h"
41 * Device interrupt routine
43 * Called at interrupt level.
45 * Arguments:
46 * arg pointer to device unit structure
48 * Returns:
49 * 1 device interrupt was serviced
50 * 0 no interrupts serviced
53 void
54 fore_intr(void *arg)
56 Fore_unit *fup = arg;
57 Aali *aap;
60 * Try to prevent stuff happening after we've paniced
62 if (panicstr)
63 return;
66 * Get to the microcode shared memory interface
68 if ((aap = fup->fu_aali) == NULL)
69 return;
72 * Has this card issued an interrupt??
74 if (*fup->fu_psr) {
76 * Clear the device interrupt
78 switch (fup->fu_config.ac_device) {
80 case DEV_FORE_PCA200E:
81 PCA200E_HCR_SET(*fup->fu_ctlreg, PCA200E_CLR_HBUS_INT);
82 break;
83 default:
84 panic("fore_intr: unknown device type");
86 aap->aali_intr_sent = CP_WRITE(0);
89 * Reset the watchdog timer
91 fup->fu_timer = FORE_WATCHDOG;
94 * Device initialization handled separately
96 if ((fup->fu_flags & CUF_INITED) == 0) {
99 * We're just initializing device now, so see if
100 * the initialization command has completed
102 if (CP_READ(aap->aali_init.init_status) &
103 QSTAT_COMPLETED)
104 fore_initialize_complete(fup);
107 * If we're still not inited, none of the host
108 * queues are setup yet
110 if ((fup->fu_flags & CUF_INITED) == 0)
111 return;
115 * Drain the queues of completed work
117 fore_cmd_drain(fup);
118 fore_recv_drain(fup);
119 fore_xmit_drain(fup);
122 * Supply more buffers to the CP
124 fore_buf_supply(fup);
130 * Watchdog timeout routine
132 * Called when we haven't heard from the card in a while. Just in case
133 * we missed an interrupt, we'll drain the queues and try to resupply the
134 * CP with more receive buffers. If the CP is partially wedged, hopefully
135 * this will be enough to get it going again.
137 * Called with interrupts locked out.
139 * Arguments:
140 * fup pointer to device unit structure
142 * Returns:
143 * none
146 void
147 fore_watchdog(Fore_unit *fup)
150 * Try to prevent stuff happening after we've paniced
152 if (panicstr) {
153 return;
157 * Reset the watchdog timer
159 fup->fu_timer = FORE_WATCHDOG;
162 * If the device is initialized, nudge it (wink, wink)
164 if (fup->fu_flags & CUF_INITED) {
167 * Drain the queues of completed work
169 fore_cmd_drain(fup);
170 fore_recv_drain(fup);
171 fore_xmit_drain(fup);
174 * Supply more buffers to the CP
176 fore_buf_supply(fup);
179 return;