Merge from vendor branch LIBARCHIVE:
[dragonfly.git] / sys / dev / atm / hfa / fore_timer.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/hfa/fore_timer.c,v 1.3 1999/08/28 00:41:52 peter Exp $
27  *      @(#) $DragonFly: src/sys/dev/atm/hfa/fore_timer.c,v 1.3 2003/08/07 21:16:49 dillon Exp $
28  */
29
30 /*
31  * FORE Systems 200-Series Adapter Support
32  * ---------------------------------------
33  *
34  * Timer processing
35  *
36  */
37
38 #include "fore_include.h"
39
40 /*
41  * Process a Fore timer tick
42  * 
43  * This function is called every FORE_TIME_TICK seconds in order to update
44  * all of the unit watchdog timers.  
45  *
46  * Called at splnet.
47  *
48  * Arguments:
49  *      tip     pointer to fore timer control block
50  *
51  * Returns:
52  *      none
53  *
54  */
55 void
56 fore_timeout(tip)
57         struct atm_time *tip;
58 {
59         Fore_unit       *fup;
60         int             i;
61
62
63         /*
64          * Schedule next timeout
65          */
66         atm_timeout(&fore_timer, ATM_HZ * FORE_TIME_TICK, fore_timeout);
67
68         /*
69          * Run through all units, updating each active timer.
70          * If an expired timer is found, notify that unit.
71          */
72         for (i = 0; i < fore_nunits; i++) {
73
74                 if ((fup = fore_units[i]) == NULL)
75                         continue;
76
77                 /*
78                  * Decrement timer, if it's active
79                  */
80                 if (fup->fu_timer && (--fup->fu_timer == 0)) {
81
82                         /*
83                          * Timeout occurred - go check out the queues
84                          */
85                         ATM_DEBUG0("fore_timeout\n");
86                         DEVICE_LOCK((Cmn_unit *)fup);
87                         fore_watchdog(fup);
88                         DEVICE_UNLOCK((Cmn_unit *)fup);
89                 }
90         }
91 }
92