aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/netpoll.h
diff options
context:
space:
mode:
authorAndrea Bastoni <bastoni@cs.unc.edu>2010-10-23 01:01:49 -0400
committerAndrea Bastoni <bastoni@cs.unc.edu>2010-10-23 01:01:49 -0400
commit3dd41424090a0ca3a660218d06afe6ff4441bad3 (patch)
tree511ef1bb1799027fc5aad574adce49120ecadd87 /include/linux/netpoll.h
parent5c5456402d467969b217d7fdd6670f8c8600f5a8 (diff)
parentf6f94e2ab1b33f0082ac22d71f66385a60d8157f (diff)
Merge commit 'v2.6.36' into wip-merge-2.6.36
Conflicts: Makefile arch/x86/include/asm/unistd_32.h arch/x86/kernel/syscall_table_32.S kernel/sched.c kernel/time/tick-sched.c Relevant API and functions changes (solved in this commit): - (API) .enqueue_task() (enqueue_task_litmus), dequeue_task() (dequeue_task_litmus), [litmus/sched_litmus.c] - (API) .select_task_rq() (select_task_rq_litmus) [litmus/sched_litmus.c] - (API) sysrq_dump_trace_buffer() and sysrq_handle_kill_rt_tasks() [litmus/sched_trace.c] - struct kfifo internal buffer name changed (buffer -> buf) [litmus/sched_trace.c] - add_wait_queue_exclusive_locked -> __add_wait_queue_tail_exclusive [litmus/fmlp.c] - syscall numbers for both x86_32 and x86_64
Diffstat (limited to 'include/linux/netpoll.h')
-rw-r--r--include/linux/netpoll.h41
1 files changed, 30 insertions, 11 deletions
diff --git a/include/linux/netpoll.h b/include/linux/netpoll.h
index a765ea898549..50d8009be86c 100644
--- a/include/linux/netpoll.h
+++ b/include/linux/netpoll.h
@@ -14,6 +14,7 @@
14 14
15struct netpoll { 15struct netpoll {
16 struct net_device *dev; 16 struct net_device *dev;
17 struct net_device *real_dev;
17 char dev_name[IFNAMSIZ]; 18 char dev_name[IFNAMSIZ];
18 const char *name; 19 const char *name;
19 void (*rx_hook)(struct netpoll *, int, char *, int); 20 void (*rx_hook)(struct netpoll *, int, char *, int);
@@ -36,41 +37,52 @@ struct netpoll_info {
36 struct sk_buff_head txq; 37 struct sk_buff_head txq;
37 38
38 struct delayed_work tx_work; 39 struct delayed_work tx_work;
40
41 struct netpoll *netpoll;
39}; 42};
40 43
44void netpoll_poll_dev(struct net_device *dev);
41void netpoll_poll(struct netpoll *np); 45void netpoll_poll(struct netpoll *np);
42void netpoll_send_udp(struct netpoll *np, const char *msg, int len); 46void netpoll_send_udp(struct netpoll *np, const char *msg, int len);
43void netpoll_print_options(struct netpoll *np); 47void netpoll_print_options(struct netpoll *np);
44int netpoll_parse_options(struct netpoll *np, char *opt); 48int netpoll_parse_options(struct netpoll *np, char *opt);
49int __netpoll_setup(struct netpoll *np);
45int netpoll_setup(struct netpoll *np); 50int netpoll_setup(struct netpoll *np);
46int netpoll_trap(void); 51int netpoll_trap(void);
47void netpoll_set_trap(int trap); 52void netpoll_set_trap(int trap);
53void __netpoll_cleanup(struct netpoll *np);
48void netpoll_cleanup(struct netpoll *np); 54void netpoll_cleanup(struct netpoll *np);
49int __netpoll_rx(struct sk_buff *skb); 55int __netpoll_rx(struct sk_buff *skb);
56void netpoll_send_skb(struct netpoll *np, struct sk_buff *skb);
50 57
51 58
52#ifdef CONFIG_NETPOLL 59#ifdef CONFIG_NETPOLL
53static inline int netpoll_rx(struct sk_buff *skb) 60static inline bool netpoll_rx(struct sk_buff *skb)
54{ 61{
55 struct netpoll_info *npinfo = skb->dev->npinfo; 62 struct netpoll_info *npinfo;
56 unsigned long flags; 63 unsigned long flags;
57 int ret = 0; 64 bool ret = false;
65
66 local_irq_save(flags);
67 npinfo = rcu_dereference_bh(skb->dev->npinfo);
58 68
59 if (!npinfo || (list_empty(&npinfo->rx_np) && !npinfo->rx_flags)) 69 if (!npinfo || (list_empty(&npinfo->rx_np) && !npinfo->rx_flags))
60 return 0; 70 goto out;
61 71
62 spin_lock_irqsave(&npinfo->rx_lock, flags); 72 spin_lock(&npinfo->rx_lock);
63 /* check rx_flags again with the lock held */ 73 /* check rx_flags again with the lock held */
64 if (npinfo->rx_flags && __netpoll_rx(skb)) 74 if (npinfo->rx_flags && __netpoll_rx(skb))
65 ret = 1; 75 ret = true;
66 spin_unlock_irqrestore(&npinfo->rx_lock, flags); 76 spin_unlock(&npinfo->rx_lock);
67 77
78out:
79 local_irq_restore(flags);
68 return ret; 80 return ret;
69} 81}
70 82
71static inline int netpoll_rx_on(struct sk_buff *skb) 83static inline int netpoll_rx_on(struct sk_buff *skb)
72{ 84{
73 struct netpoll_info *npinfo = skb->dev->npinfo; 85 struct netpoll_info *npinfo = rcu_dereference_bh(skb->dev->npinfo);
74 86
75 return npinfo && (!list_empty(&npinfo->rx_np) || npinfo->rx_flags); 87 return npinfo && (!list_empty(&npinfo->rx_np) || npinfo->rx_flags);
76} 88}
@@ -86,7 +98,6 @@ static inline void *netpoll_poll_lock(struct napi_struct *napi)
86{ 98{
87 struct net_device *dev = napi->dev; 99 struct net_device *dev = napi->dev;
88 100
89 rcu_read_lock(); /* deal with race on ->npinfo */
90 if (dev && dev->npinfo) { 101 if (dev && dev->npinfo) {
91 spin_lock(&napi->poll_lock); 102 spin_lock(&napi->poll_lock);
92 napi->poll_owner = smp_processor_id(); 103 napi->poll_owner = smp_processor_id();
@@ -103,11 +114,15 @@ static inline void netpoll_poll_unlock(void *have)
103 napi->poll_owner = -1; 114 napi->poll_owner = -1;
104 spin_unlock(&napi->poll_lock); 115 spin_unlock(&napi->poll_lock);
105 } 116 }
106 rcu_read_unlock(); 117}
118
119static inline int netpoll_tx_running(struct net_device *dev)
120{
121 return irqs_disabled();
107} 122}
108 123
109#else 124#else
110static inline int netpoll_rx(struct sk_buff *skb) 125static inline bool netpoll_rx(struct sk_buff *skb)
111{ 126{
112 return 0; 127 return 0;
113} 128}
@@ -129,6 +144,10 @@ static inline void netpoll_poll_unlock(void *have)
129static inline void netpoll_netdev_init(struct net_device *dev) 144static inline void netpoll_netdev_init(struct net_device *dev)
130{ 145{
131} 146}
147static inline int netpoll_tx_running(struct net_device *dev)
148{
149 return 0;
150}
132#endif 151#endif
133 152
134#endif 153#endif