netpoll.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. #ifndef _LINUX_NETPOLL_H
  7. #define _LINUX_NETPOLL_H
  8. #include <linux/netdevice.h>
  9. #include <linux/interrupt.h>
  10. #include <linux/list.h>
  11. struct netpoll;
  12. struct netpoll {
  13. struct net_device *dev;
  14. char dev_name[16], *name;
  15. int rx_flags;
  16. void (*rx_hook)(struct netpoll *, int, char *, int);
  17. void (*drop)(struct sk_buff *skb);
  18. u32 local_ip, remote_ip;
  19. u16 local_port, remote_port;
  20. unsigned char local_mac[6], remote_mac[6];
  21. spinlock_t poll_lock;
  22. int poll_owner;
  23. };
  24. void netpoll_poll(struct netpoll *np);
  25. void netpoll_send_udp(struct netpoll *np, const char *msg, int len);
  26. int netpoll_parse_options(struct netpoll *np, char *opt);
  27. int netpoll_setup(struct netpoll *np);
  28. int netpoll_trap(void);
  29. void netpoll_set_trap(int trap);
  30. void netpoll_cleanup(struct netpoll *np);
  31. int __netpoll_rx(struct sk_buff *skb);
  32. void netpoll_queue(struct sk_buff *skb);
  33. #ifdef CONFIG_NETPOLL
  34. static inline int netpoll_rx(struct sk_buff *skb)
  35. {
  36. return skb->dev->np && skb->dev->np->rx_flags && __netpoll_rx(skb);
  37. }
  38. static inline void netpoll_poll_lock(struct net_device *dev)
  39. {
  40. if (dev->np) {
  41. spin_lock(&dev->np->poll_lock);
  42. dev->np->poll_owner = smp_processor_id();
  43. }
  44. }
  45. static inline void netpoll_poll_unlock(struct net_device *dev)
  46. {
  47. if (dev->np) {
  48. spin_unlock(&dev->np->poll_lock);
  49. dev->np->poll_owner = -1;
  50. }
  51. }
  52. #else
  53. #define netpoll_rx(a) 0
  54. #define netpoll_poll_lock(a)
  55. #define netpoll_poll_unlock(a)
  56. #endif
  57. #endif