netisr.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * Copyright (c) 2010 Owain G. Ainsworth <oga@openbsd.org>
  3. *
  4. * Permission to use, copy, modify, and distribute this software for any
  5. * purpose with or without fee is hereby granted, provided that the above
  6. * copyright notice and this permission notice appear in all copies.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  11. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  14. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #include <sys/param.h>
  17. #include <sys/systm.h>
  18. #include <net/netisr.h>
  19. #include <machine/intr.h>
  20. #include "ether.h"
  21. #include "ppp.h"
  22. #include "bridge.h"
  23. #include "pppoe.h"
  24. #include "pfsync.h"
  25. void netintr(void *);
  26. int netisr;
  27. void *netisr_intr;
  28. void
  29. netintr(void *unused) /* ARGSUSED */
  30. {
  31. int n, t = 0;
  32. while ((n = netisr) != 0) {
  33. atomic_clearbits_int(&netisr, n);
  34. #if NETHER > 0
  35. if (n & (1 << NETISR_ARP))
  36. arpintr();
  37. #endif
  38. if (n & (1 << NETISR_IP))
  39. ipintr();
  40. #ifdef INET6
  41. if (n & (1 << NETISR_IPV6))
  42. ip6intr();
  43. #endif
  44. #if NPPP > 0
  45. if (n & (1 << NETISR_PPP))
  46. pppintr();
  47. #endif
  48. #if NBRIDGE > 0
  49. if (n & (1 << NETISR_BRIDGE))
  50. bridgeintr();
  51. #endif
  52. #if NPPPOE > 0
  53. if (n & (1 << NETISR_PPPOE))
  54. pppoeintr();
  55. #endif
  56. t |= n;
  57. }
  58. #if NPFSYNC > 0
  59. if (t & (1 << NETISR_PFSYNC))
  60. pfsyncintr();
  61. #endif
  62. if (t & (1 << NETISR_TX))
  63. nettxintr();
  64. }
  65. void
  66. netisr_init(void)
  67. {
  68. netisr_intr = softintr_establish(IPL_SOFTNET, netintr, NULL);
  69. if (netisr_intr == NULL)
  70. panic("can't establish softnet handler");
  71. }