diff options
| author | Jake Burkholder <jake@FreeBSD.org> | 2002-09-22 05:56:41 +0000 |
|---|---|---|
| committer | Jake Burkholder <jake@FreeBSD.org> | 2002-09-22 05:56:41 +0000 |
| commit | e3b6e33c07b11798e5e24baaa7d596902debdcba (patch) | |
| tree | da1088de2fb25dba3e43139bc803c958f4ba8778 | |
| parent | 0e7fe4f6c052e29ad6a8d4be15f5bd8007a38af8 (diff) | |
Notes
| -rw-r--r-- | sys/conf/files | 1 | ||||
| -rw-r--r-- | sys/kern/kern_intr.c | 80 | ||||
| -rw-r--r-- | sys/net/netisr.c | 116 |
3 files changed, 118 insertions, 79 deletions
diff --git a/sys/conf/files b/sys/conf/files index 8eccf4c5261e..6d12865e8836 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -1071,6 +1071,7 @@ net/if_tap.c optional tap net/if_vlan.c optional vlan net/intrq.c standard net/net_osdep.c standard +net/netisr.c standard net/ppp_deflate.c optional ppp_deflate net/ppp_tty.c optional ppp net/pfil.c optional pfil_hooks diff --git a/sys/kern/kern_intr.c b/sys/kern/kern_intr.c index 4eb5c1f6bd5f..af6e59b30420 100644 --- a/sys/kern/kern_intr.c +++ b/sys/kern/kern_intr.c @@ -57,7 +57,6 @@ struct int_entropy { int vector; }; -void *net_ih; void *vm_ih; void *softclock_ih; struct ithd *clk_ithd; @@ -68,7 +67,6 @@ static MALLOC_DEFINE(M_ITHREAD, "ithread", "Interrupt Threads"); static void ithread_update(struct ithd *); static void ithread_loop(void *); static void start_softintr(void *); -static void swi_net(void *); u_char ithread_priority(enum intr_type flags) @@ -571,8 +569,7 @@ static void start_softintr(void *dummy) { - if (swi_add(NULL, "net", swi_net, NULL, SWI_NET, 0, &net_ih) || - swi_add(&clk_ithd, "clock", softclock, NULL, SWI_CLOCK, + if (swi_add(&clk_ithd, "clock", softclock, NULL, SWI_CLOCK, INTR_MPSAFE, &softclock_ih) || swi_add(NULL, "vm", swi_vm, NULL, SWI_VM, 0, &vm_ih)) panic("died while creating standard software ithreads"); @@ -583,81 +580,6 @@ start_softintr(void *dummy) } SYSINIT(start_softintr, SI_SUB_SOFTINTR, SI_ORDER_FIRST, start_softintr, NULL) -void -legacy_setsoftnet(void) -{ - swi_sched(net_ih, 0); -} - -/* - * XXX: This should really be in the network code somewhere and installed - * via a SI_SUB_SOFINTR, SI_ORDER_MIDDLE sysinit. - */ -void (*netisrs[32])(void); -volatile unsigned int netisr; /* scheduling bits for network */ - -int -register_netisr(num, handler) - int num; - netisr_t *handler; -{ - - if (num < 0 || num >= (sizeof(netisrs)/sizeof(*netisrs)) ) { - printf("register_netisr: bad isr number: %d\n", num); - return (EINVAL); - } - netisrs[num] = handler; - return (0); -} - -int -unregister_netisr(num) - int num; -{ - - if (num < 0 || num >= (sizeof(netisrs)/sizeof(*netisrs)) ) { - printf("unregister_netisr: bad isr number: %d\n", num); - return (EINVAL); - } - netisrs[num] = NULL; - return (0); -} - -#ifdef DEVICE_POLLING - void netisr_pollmore(void); -#endif - -static void -swi_net(void *dummy) -{ - u_int bits; - int i; - -#ifdef DEVICE_POLLING - for (;;) { - int pollmore; -#endif - bits = atomic_readandclear_int(&netisr); -#ifdef DEVICE_POLLING - if (bits == 0) - return; - pollmore = bits & (1 << NETISR_POLL); -#endif - while ((i = ffs(bits)) != 0) { - i--; - if (netisrs[i] != NULL) - netisrs[i](); - else - printf("swi_net: unregistered isr number: %d.\n", i); - bits &= ~(1 << i); - } -#ifdef DEVICE_POLLING - if (pollmore) - netisr_pollmore(); - } -#endif -} - /* * Sysctls used by systat and others: hw.intrnames and hw.intrcnt. * The data for this machine dependent, and the declarations are in machine diff --git a/sys/net/netisr.c b/sys/net/netisr.c new file mode 100644 index 000000000000..cb7bc3222891 --- /dev/null +++ b/sys/net/netisr.c @@ -0,0 +1,116 @@ +/* + * Copyright (c) 1997, Stefan Esser <se@freebsd.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/bus.h> +#include <sys/proc.h> +#include <sys/interrupt.h> +#include <sys/kernel.h> + +#include <net/netisr.h> + +static void swi_net(void *); + +void *net_ih; +volatile unsigned int netisr; +void (*netisrs[32])(void); + +void +legacy_setsoftnet(void) +{ + swi_sched(net_ih, 0); +} + +int +register_netisr(int num, netisr_t *handler) +{ + + if (num < 0 || num >= (sizeof(netisrs)/sizeof(*netisrs)) ) { + printf("register_netisr: bad isr number: %d\n", num); + return (EINVAL); + } + netisrs[num] = handler; + return (0); +} + +int +unregister_netisr(int num) +{ + + if (num < 0 || num >= (sizeof(netisrs)/sizeof(*netisrs)) ) { + printf("unregister_netisr: bad isr number: %d\n", num); + return (EINVAL); + } + netisrs[num] = NULL; + return (0); +} + +#ifdef DEVICE_POLLING +void netisr_pollmore(void); +#endif + +static void +swi_net(void *dummy) +{ + u_int bits; + int i; + +#ifdef DEVICE_POLLING + for (;;) { + int pollmore; +#endif + bits = atomic_readandclear_int(&netisr); +#ifdef DEVICE_POLLING + if (bits == 0) + return; + pollmore = bits & (1 << NETISR_POLL); +#endif + while ((i = ffs(bits)) != 0) { + i--; + if (netisrs[i] != NULL) + netisrs[i](); + else + printf("swi_net: unregistered isr number: %d.\n", i); + bits &= ~(1 << i); + } +#ifdef DEVICE_POLLING + if (pollmore) + netisr_pollmore(); + } +#endif +} + +static void +start_netisr(void *dummy) +{ + + if (swi_add(NULL, "net", swi_net, NULL, SWI_NET, 0, &net_ih)) + panic("start_netisr"); +} +SYSINIT(start_netisr, SI_SUB_SOFTINTR, SI_ORDER_FIRST, start_netisr, NULL) |
