]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - include/linux/netpoll.h
netfilter: nat: fix src map lookup
[mirror_ubuntu-artful-kernel.git] / include / linux / netpoll.h
CommitLineData
1da177e4
LT
1/*
2 * Common code for low-level network console, dump, and debugger code
3 *
4 * Derived from netconsole, kgdb-over-ethernet, and netdump patches
5 */
6
7#ifndef _LINUX_NETPOLL_H
8#define _LINUX_NETPOLL_H
9
10#include <linux/netdevice.h>
11#include <linux/interrupt.h>
53fb95d3 12#include <linux/rcupdate.h>
1da177e4 13#include <linux/list.h>
433cea4d 14#include <linux/refcount.h>
1da177e4 15
b7394d24
CW
16union inet_addr {
17 __u32 all[4];
18 __be32 ip;
19 __be32 ip6[4];
20 struct in_addr in;
21 struct in6_addr in6;
22};
23
1da177e4
LT
24struct netpoll {
25 struct net_device *dev;
bf6bce71
SH
26 char dev_name[IFNAMSIZ];
27 const char *name;
5de4a473 28
b7394d24
CW
29 union inet_addr local_ip, remote_ip;
30 bool ipv6;
1da177e4 31 u16 local_port, remote_port;
09538641 32 u8 remote_mac[ETH_ALEN];
508e14b4 33
2cde6acd 34 struct work_struct cleanup_work;
115c1d6e
JM
35};
36
37struct netpoll_info {
433cea4d 38 refcount_t refcnt;
508e14b4 39
bd7c4b60 40 struct semaphore dev_lock;
508e14b4 41
b6cd27ed 42 struct sk_buff_head txq;
508e14b4 43
6d5aefb8 44 struct delayed_work tx_work;
0e34e931
WC
45
46 struct netpoll *netpoll;
38e6bc18 47 struct rcu_head rcu;
1da177e4
LT
48};
49
ca99ca14 50#ifdef CONFIG_NETPOLL
66b5552f
EB
51extern void netpoll_poll_disable(struct net_device *dev);
52extern void netpoll_poll_enable(struct net_device *dev);
ca99ca14 53#else
66b5552f
EB
54static inline void netpoll_poll_disable(struct net_device *dev) { return; }
55static inline void netpoll_poll_enable(struct net_device *dev) { return; }
ca99ca14
NH
56#endif
57
1da177e4 58void netpoll_send_udp(struct netpoll *np, const char *msg, int len);
0bcc1816 59void netpoll_print_options(struct netpoll *np);
1da177e4 60int netpoll_parse_options(struct netpoll *np, char *opt);
a8779ec1 61int __netpoll_setup(struct netpoll *np, struct net_device *ndev);
1da177e4 62int netpoll_setup(struct netpoll *np);
8fdd95ec 63void __netpoll_cleanup(struct netpoll *np);
2cde6acd 64void __netpoll_free_async(struct netpoll *np);
1da177e4 65void netpoll_cleanup(struct netpoll *np);
c2355e1a
NH
66void netpoll_send_skb_on_dev(struct netpoll *np, struct sk_buff *skb,
67 struct net_device *dev);
68static inline void netpoll_send_skb(struct netpoll *np, struct sk_buff *skb)
69{
2899656b
AW
70 unsigned long flags;
71 local_irq_save(flags);
c2355e1a 72 netpoll_send_skb_on_dev(np, skb, np->dev);
2899656b 73 local_irq_restore(flags);
c2355e1a
NH
74}
75
e1bd4d3d 76#ifdef CONFIG_NETPOLL
bea3348e
SH
77static inline void *netpoll_poll_lock(struct napi_struct *napi)
78{
79 struct net_device *dev = napi->dev;
80
bea3348e 81 if (dev && dev->npinfo) {
89c4b442
ED
82 int owner = smp_processor_id();
83
84 while (cmpxchg(&napi->poll_owner, -1, owner) != -1)
85 cpu_relax();
86
bea3348e 87 return napi;
1da177e4 88 }
53fb95d3 89 return NULL;
1da177e4
LT
90}
91
53fb95d3 92static inline void netpoll_poll_unlock(void *have)
1da177e4 93{
bea3348e 94 struct napi_struct *napi = have;
53fb95d3 95
89c4b442
ED
96 if (napi)
97 smp_store_release(&napi->poll_owner, -1);
1da177e4
LT
98}
99
77ab8a54 100static inline bool netpoll_tx_running(struct net_device *dev)
c18370f5
HX
101{
102 return irqs_disabled();
103}
104
1da177e4 105#else
bea3348e
SH
106static inline void *netpoll_poll_lock(struct napi_struct *napi)
107{
108 return NULL;
109}
110static inline void netpoll_poll_unlock(void *have)
111{
112}
113static inline void netpoll_netdev_init(struct net_device *dev)
114{
115}
77ab8a54 116static inline bool netpoll_tx_running(struct net_device *dev)
c18370f5 117{
77ab8a54 118 return false;
c18370f5 119}
1da177e4
LT
120#endif
121
122#endif