aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/netpoll.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/netpoll.h')
-rw-r--r--include/linux/netpoll.h71
1 files changed, 5 insertions, 66 deletions
diff --git a/include/linux/netpoll.h b/include/linux/netpoll.h
index fbfdb9d8d3a7..b25ee9ffdbe6 100644
--- a/include/linux/netpoll.h
+++ b/include/linux/netpoll.h
@@ -24,27 +24,20 @@ struct netpoll {
24 struct net_device *dev; 24 struct net_device *dev;
25 char dev_name[IFNAMSIZ]; 25 char dev_name[IFNAMSIZ];
26 const char *name; 26 const char *name;
27 void (*rx_skb_hook)(struct netpoll *np, int source, struct sk_buff *skb,
28 int offset, int len);
29 27
30 union inet_addr local_ip, remote_ip; 28 union inet_addr local_ip, remote_ip;
31 bool ipv6; 29 bool ipv6;
32 u16 local_port, remote_port; 30 u16 local_port, remote_port;
33 u8 remote_mac[ETH_ALEN]; 31 u8 remote_mac[ETH_ALEN];
34 32
35 struct list_head rx; /* rx_np list element */
36 struct work_struct cleanup_work; 33 struct work_struct cleanup_work;
37}; 34};
38 35
39struct netpoll_info { 36struct netpoll_info {
40 atomic_t refcnt; 37 atomic_t refcnt;
41 38
42 unsigned long rx_flags;
43 spinlock_t rx_lock;
44 struct semaphore dev_lock; 39 struct semaphore dev_lock;
45 struct list_head rx_np; /* netpolls that registered an rx_skb_hook */
46 40
47 struct sk_buff_head neigh_tx; /* list of neigh requests to reply to */
48 struct sk_buff_head txq; 41 struct sk_buff_head txq;
49 42
50 struct delayed_work tx_work; 43 struct delayed_work tx_work;
@@ -54,24 +47,21 @@ struct netpoll_info {
54}; 47};
55 48
56#ifdef CONFIG_NETPOLL 49#ifdef CONFIG_NETPOLL
57extern void netpoll_rx_disable(struct net_device *dev); 50extern void netpoll_poll_disable(struct net_device *dev);
58extern void netpoll_rx_enable(struct net_device *dev); 51extern void netpoll_poll_enable(struct net_device *dev);
59#else 52#else
60static inline void netpoll_rx_disable(struct net_device *dev) { return; } 53static inline void netpoll_poll_disable(struct net_device *dev) { return; }
61static inline void netpoll_rx_enable(struct net_device *dev) { return; } 54static inline void netpoll_poll_enable(struct net_device *dev) { return; }
62#endif 55#endif
63 56
64void netpoll_send_udp(struct netpoll *np, const char *msg, int len); 57void netpoll_send_udp(struct netpoll *np, const char *msg, int len);
65void netpoll_print_options(struct netpoll *np); 58void netpoll_print_options(struct netpoll *np);
66int netpoll_parse_options(struct netpoll *np, char *opt); 59int netpoll_parse_options(struct netpoll *np, char *opt);
67int __netpoll_setup(struct netpoll *np, struct net_device *ndev, gfp_t gfp); 60int __netpoll_setup(struct netpoll *np, struct net_device *ndev);
68int netpoll_setup(struct netpoll *np); 61int netpoll_setup(struct netpoll *np);
69int netpoll_trap(void);
70void netpoll_set_trap(int trap);
71void __netpoll_cleanup(struct netpoll *np); 62void __netpoll_cleanup(struct netpoll *np);
72void __netpoll_free_async(struct netpoll *np); 63void __netpoll_free_async(struct netpoll *np);
73void netpoll_cleanup(struct netpoll *np); 64void netpoll_cleanup(struct netpoll *np);
74int __netpoll_rx(struct sk_buff *skb, struct netpoll_info *npinfo);
75void netpoll_send_skb_on_dev(struct netpoll *np, struct sk_buff *skb, 65void netpoll_send_skb_on_dev(struct netpoll *np, struct sk_buff *skb,
76 struct net_device *dev); 66 struct net_device *dev);
77static inline void netpoll_send_skb(struct netpoll *np, struct sk_buff *skb) 67static inline void netpoll_send_skb(struct netpoll *np, struct sk_buff *skb)
@@ -82,46 +72,7 @@ static inline void netpoll_send_skb(struct netpoll *np, struct sk_buff *skb)
82 local_irq_restore(flags); 72 local_irq_restore(flags);
83} 73}
84 74
85
86
87#ifdef CONFIG_NETPOLL 75#ifdef CONFIG_NETPOLL
88static inline bool netpoll_rx_on(struct sk_buff *skb)
89{
90 struct netpoll_info *npinfo = rcu_dereference_bh(skb->dev->npinfo);
91
92 return npinfo && (!list_empty(&npinfo->rx_np) || npinfo->rx_flags);
93}
94
95static inline bool netpoll_rx(struct sk_buff *skb)
96{
97 struct netpoll_info *npinfo;
98 unsigned long flags;
99 bool ret = false;
100
101 local_irq_save(flags);
102
103 if (!netpoll_rx_on(skb))
104 goto out;
105
106 npinfo = rcu_dereference_bh(skb->dev->npinfo);
107 spin_lock(&npinfo->rx_lock);
108 /* check rx_flags again with the lock held */
109 if (npinfo->rx_flags && __netpoll_rx(skb, npinfo))
110 ret = true;
111 spin_unlock(&npinfo->rx_lock);
112
113out:
114 local_irq_restore(flags);
115 return ret;
116}
117
118static inline int netpoll_receive_skb(struct sk_buff *skb)
119{
120 if (!list_empty(&skb->dev->napi_list))
121 return netpoll_rx(skb);
122 return 0;
123}
124
125static inline void *netpoll_poll_lock(struct napi_struct *napi) 76static inline void *netpoll_poll_lock(struct napi_struct *napi)
126{ 77{
127 struct net_device *dev = napi->dev; 78 struct net_device *dev = napi->dev;
@@ -150,18 +101,6 @@ static inline bool netpoll_tx_running(struct net_device *dev)
150} 101}
151 102
152#else 103#else
153static inline bool netpoll_rx(struct sk_buff *skb)
154{
155 return false;
156}
157static inline bool netpoll_rx_on(struct sk_buff *skb)
158{
159 return false;
160}
161static inline int netpoll_receive_skb(struct sk_buff *skb)
162{
163 return 0;
164}
165static inline void *netpoll_poll_lock(struct napi_struct *napi) 104static inline void *netpoll_poll_lock(struct napi_struct *napi)
166{ 105{
167 return NULL; 106 return NULL;