direct-io.hg

view xen/net/devinit.c @ 690:cf5bddb3603e

bitkeeper revision 1.404 (3f57607dkEm0-zZkL-qD7DTt8vKceQ)

apic.c:
Another bug fix for no-APIC systems.
author kaf24@scramble.cl.cam.ac.uk
date Thu Sep 04 15:55:41 2003 +0000 (2003-09-04)
parents 170eb7974e43
children 890460f07ddf
line source
1 /******************************************************************************
2 * devinit.c
3 *
4 * This is the watchdog timer routines, ripped from sch_generic.c
5 * Original copyright notice appears below.
6 *
7 */
9 /*
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version
13 * 2 of the License, or (at your option) any later version.
14 *
15 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
16 * Jamal Hadi Salim, <hadi@nortelnetworks.com> 990601
17 * - Ingress support
18 */
20 #include <asm/uaccess.h>
21 #include <asm/system.h>
22 #include <asm/bitops.h>
23 #include <linux/config.h>
24 #include <linux/types.h>
25 #include <linux/sched.h>
26 #include <linux/lib.h>
27 #include <linux/mm.h>
28 #include <linux/socket.h>
29 #include <linux/sockios.h>
30 #include <linux/errno.h>
31 #include <linux/interrupt.h>
32 #include <linux/netdevice.h>
33 #include <linux/skbuff.h>
34 #include <linux/init.h>
36 static void dev_watchdog(unsigned long arg)
37 {
38 struct net_device *dev = (struct net_device *)arg;
40 spin_lock(&dev->xmit_lock);
41 if (netif_device_present(dev) &&
42 netif_running(dev) &&
43 netif_carrier_ok(dev)) {
44 if (netif_queue_stopped(dev) &&
45 (jiffies - dev->trans_start) > dev->watchdog_timeo) {
46 printk(KERN_INFO "NETDEV WATCHDOG: %s: transmit timed out\n", dev->name);
47 dev->tx_timeout(dev);
48 }
49 if (!mod_timer(&dev->watchdog_timer, jiffies + dev->watchdog_timeo))
50 dev_hold(dev);
51 }
52 spin_unlock(&dev->xmit_lock);
54 dev_put(dev);
55 }
57 static void dev_watchdog_init(struct net_device *dev)
58 {
59 init_timer(&dev->watchdog_timer);
60 dev->watchdog_timer.data = (unsigned long)dev;
61 dev->watchdog_timer.function = dev_watchdog;
62 }
64 void __netdev_watchdog_up(struct net_device *dev)
65 {
66 if (dev->tx_timeout) {
67 if (dev->watchdog_timeo <= 0)
68 dev->watchdog_timeo = 5*HZ;
69 if (!mod_timer(&dev->watchdog_timer, jiffies + dev->watchdog_timeo))
70 dev_hold(dev);
71 }
72 }
74 static void dev_watchdog_up(struct net_device *dev)
75 {
76 spin_lock_bh(&dev->xmit_lock);
77 __netdev_watchdog_up(dev);
78 spin_unlock_bh(&dev->xmit_lock);
79 }
81 static void dev_watchdog_down(struct net_device *dev)
82 {
83 spin_lock_bh(&dev->xmit_lock);
84 if (del_timer(&dev->watchdog_timer))
85 __dev_put(dev);
86 spin_unlock_bh(&dev->xmit_lock);
87 }
89 void dev_activate(struct net_device *dev)
90 {
91 spin_lock_bh(&dev->queue_lock);
92 dev->trans_start = jiffies;
93 dev_watchdog_up(dev);
94 spin_unlock_bh(&dev->queue_lock);
95 }
97 void dev_deactivate(struct net_device *dev)
98 {
99 dev_watchdog_down(dev);
100 }
102 void dev_init_scheduler(struct net_device *dev)
103 {
104 dev_watchdog_init(dev);
105 }
107 void dev_shutdown(struct net_device *dev)
108 {
109 }