Blame view

include/linux/netpoll.h 2.69 KB
b24413180   Greg Kroah-Hartman   License cleanup: ...
1
  /* SPDX-License-Identifier: GPL-2.0 */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2
3
4
5
6
7
8
9
10
11
12
  /*
   * Common code for low-level network console, dump, and debugger code
   *
   * Derived from netconsole, kgdb-over-ethernet, and netdump patches
   */
  
  #ifndef _LINUX_NETPOLL_H
  #define _LINUX_NETPOLL_H
  
  #include <linux/netdevice.h>
  #include <linux/interrupt.h>
53fb95d3c   Matt Mackall   [NETPOLL]: fix in...
13
  #include <linux/rcupdate.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
14
  #include <linux/list.h>
433cea4d9   Reshetova, Elena   net: convert netp...
15
  #include <linux/refcount.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
16

b7394d242   Cong Wang   netpoll: prepare ...
17
18
19
20
21
22
23
  union inet_addr {
  	__u32		all[4];
  	__be32		ip;
  	__be32		ip6[4];
  	struct in_addr	in;
  	struct in6_addr	in6;
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
24
25
  struct netpoll {
  	struct net_device *dev;
bf6bce71e   Stephen Hemminger   netpoll header cl...
26
27
  	char dev_name[IFNAMSIZ];
  	const char *name;
5de4a473b   Stephen Hemminger   netpoll queue cle...
28

b7394d242   Cong Wang   netpoll: prepare ...
29
30
  	union inet_addr local_ip, remote_ip;
  	bool ipv6;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
31
  	u16 local_port, remote_port;
095386416   Stephen Hemminger   [NETPOLL]: no nee...
32
  	u8 remote_mac[ETH_ALEN];
508e14b4a   Daniel Borkmann   netpoll: allow ex...
33

2cde6acd4   Neil Horman   netpoll: Fix __ne...
34
  	struct work_struct cleanup_work;
115c1d6e6   Jeff Moyer   [NETPOLL]: Introd...
35
36
37
  };
  
  struct netpoll_info {
433cea4d9   Reshetova, Elena   net: convert netp...
38
  	refcount_t refcnt;
508e14b4a   Daniel Borkmann   netpoll: allow ex...
39

bd7c4b604   Neil Horman   netpoll: convert ...
40
  	struct semaphore dev_lock;
508e14b4a   Daniel Borkmann   netpoll: allow ex...
41

b6cd27ed3   Stephen Hemminger   netpoll per devic...
42
  	struct sk_buff_head txq;
508e14b4a   Daniel Borkmann   netpoll: allow ex...
43

6d5aefb8e   David Howells   WorkQueue: Fix up...
44
  	struct delayed_work tx_work;
0e34e9317   WANG Cong   netpoll: add gene...
45
46
  
  	struct netpoll *netpoll;
38e6bc185   Amerigo Wang   netpoll: make __n...
47
  	struct rcu_head rcu;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
48
  };
ca99ca14c   Neil Horman   netpoll: protect ...
49
  #ifdef CONFIG_NETPOLL
66b5552fc   Eric W. Biederman   netpoll: Rename n...
50
51
  extern void netpoll_poll_disable(struct net_device *dev);
  extern void netpoll_poll_enable(struct net_device *dev);
ca99ca14c   Neil Horman   netpoll: protect ...
52
  #else
66b5552fc   Eric W. Biederman   netpoll: Rename n...
53
54
  static inline void netpoll_poll_disable(struct net_device *dev) { return; }
  static inline void netpoll_poll_enable(struct net_device *dev) { return; }
ca99ca14c   Neil Horman   netpoll: protect ...
55
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
56
  void netpoll_send_udp(struct netpoll *np, const char *msg, int len);
0bcc18161   Satyam Sharma   [NET] netconsole:...
57
  void netpoll_print_options(struct netpoll *np);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
58
  int netpoll_parse_options(struct netpoll *np, char *opt);
a8779ec1c   Eric W. Biederman   netpoll: Remove g...
59
  int __netpoll_setup(struct netpoll *np, struct net_device *ndev);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
60
  int netpoll_setup(struct netpoll *np);
8fdd95ec1   Herbert Xu   netpoll: Allow ne...
61
  void __netpoll_cleanup(struct netpoll *np);
2cde6acd4   Neil Horman   netpoll: Fix __ne...
62
  void __netpoll_free_async(struct netpoll *np);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
63
  void netpoll_cleanup(struct netpoll *np);
c2355e1ab   Neil Horman   bonding: Fix bond...
64
65
66
67
  void netpoll_send_skb_on_dev(struct netpoll *np, struct sk_buff *skb,
  			     struct net_device *dev);
  static inline void netpoll_send_skb(struct netpoll *np, struct sk_buff *skb)
  {
2899656b4   Amerigo Wang   netpoll: take rcu...
68
69
  	unsigned long flags;
  	local_irq_save(flags);
c2355e1ab   Neil Horman   bonding: Fix bond...
70
  	netpoll_send_skb_on_dev(np, skb, np->dev);
2899656b4   Amerigo Wang   netpoll: take rcu...
71
  	local_irq_restore(flags);
c2355e1ab   Neil Horman   bonding: Fix bond...
72
  }
e1bd4d3d7   Eric W. Biederman   netpoll: Move all...
73
  #ifdef CONFIG_NETPOLL
bea3348ee   Stephen Hemminger   [NET]: Make NAPI ...
74
75
76
  static inline void *netpoll_poll_lock(struct napi_struct *napi)
  {
  	struct net_device *dev = napi->dev;
bea3348ee   Stephen Hemminger   [NET]: Make NAPI ...
77
  	if (dev && dev->npinfo) {
89c4b442b   Eric Dumazet   netpoll: more eff...
78
79
80
81
  		int owner = smp_processor_id();
  
  		while (cmpxchg(&napi->poll_owner, -1, owner) != -1)
  			cpu_relax();
bea3348ee   Stephen Hemminger   [NET]: Make NAPI ...
82
  		return napi;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
83
  	}
53fb95d3c   Matt Mackall   [NETPOLL]: fix in...
84
  	return NULL;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
85
  }
53fb95d3c   Matt Mackall   [NETPOLL]: fix in...
86
  static inline void netpoll_poll_unlock(void *have)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
87
  {
bea3348ee   Stephen Hemminger   [NET]: Make NAPI ...
88
  	struct napi_struct *napi = have;
53fb95d3c   Matt Mackall   [NETPOLL]: fix in...
89

89c4b442b   Eric Dumazet   netpoll: more eff...
90
91
  	if (napi)
  		smp_store_release(&napi->poll_owner, -1);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
92
  }
77ab8a54d   Amerigo Wang   netpoll: convert ...
93
  static inline bool netpoll_tx_running(struct net_device *dev)
c18370f5b   Herbert Xu   netpoll: Add netp...
94
95
96
  {
  	return irqs_disabled();
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
97
  #else
bea3348ee   Stephen Hemminger   [NET]: Make NAPI ...
98
99
100
101
102
103
104
105
106
107
  static inline void *netpoll_poll_lock(struct napi_struct *napi)
  {
  	return NULL;
  }
  static inline void netpoll_poll_unlock(void *have)
  {
  }
  static inline void netpoll_netdev_init(struct net_device *dev)
  {
  }
77ab8a54d   Amerigo Wang   netpoll: convert ...
108
  static inline bool netpoll_tx_running(struct net_device *dev)
c18370f5b   Herbert Xu   netpoll: Add netp...
109
  {
77ab8a54d   Amerigo Wang   netpoll: convert ...
110
  	return false;
c18370f5b   Herbert Xu   netpoll: Add netp...
111
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
112
113
114
  #endif
  
  #endif