- In bridge_enqueue(), dispatch the mbuf to the current cpu's netisr, instead
[dragonfly/port-amd64.git] / sys / net / netisr.h
blob2432e6fdcb857a3e4b4620b8a51bafde0788ba55
1 /*
2 * Copyright (c) 2004 Jeffrey M. Hsu. All rights reserved.
3 * Copyright (c) 2004 The DragonFly Project. All rights reserved.
4 *
5 * This code is derived from software contributed to The DragonFly Project
6 * by Jeffrey M. Hsu.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. Neither the name of The DragonFly Project nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific, prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
28 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
30 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
35 * Copyright (c) 1980, 1986, 1989, 1993
36 * The Regents of the University of California. All rights reserved.
38 * Redistribution and use in source and binary forms, with or without
39 * modification, are permitted provided that the following conditions
40 * are met:
41 * 1. Redistributions of source code must retain the above copyright
42 * notice, this list of conditions and the following disclaimer.
43 * 2. Redistributions in binary form must reproduce the above copyright
44 * notice, this list of conditions and the following disclaimer in the
45 * documentation and/or other materials provided with the distribution.
46 * 3. All advertising materials mentioning features or use of this software
47 * must display the following acknowledgement:
48 * This product includes software developed by the University of
49 * California, Berkeley and its contributors.
50 * 4. Neither the name of the University nor the names of its contributors
51 * may be used to endorse or promote products derived from this software
52 * without specific prior written permission.
54 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
55 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
56 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
57 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
58 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
59 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
60 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
61 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
62 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
63 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
64 * SUCH DAMAGE.
66 * @(#)netisr.h 8.1 (Berkeley) 6/10/93
67 * $FreeBSD: src/sys/net/netisr.h,v 1.21.2.5 2002/02/09 23:02:39 luigi Exp $
68 * $DragonFly: src/sys/net/netisr.h,v 1.27 2007/06/16 15:27:27 sephe Exp $
71 #ifndef _NET_NETISR_H_
72 #define _NET_NETISR_H_
75 * The networking code runs off software interrupts.
77 * You can switch into the network by doing splnet() and return by splx().
78 * The software interrupt level for the network is higher than the software
79 * level for the clock (so you can enter the network in routines called
80 * at timeout time).
84 * Each ``pup-level-1'' input queue has a bit in a ``netisr'' status
85 * word which is used to de-multiplex a single software
86 * interrupt used for scheduling the network code to calls
87 * on the lowest level routine of each protocol.
89 #define NETISR_RESERVED0 0 /* cannot be used */
90 #define NETISR_POLL 1 /* polling callback */
91 #define NETISR_IP 2 /* same as AF_INET */
92 #define NETISR_NS 6 /* same as AF_NS */
93 #define NETISR_AARP 15 /* Appletalk ARP */
94 #define NETISR_ATALK2 16 /* Appletalk phase 2 */
95 #define NETISR_ATALK1 17 /* Appletalk phase 1 */
96 #define NETISR_ARP 18 /* same as AF_LINK */
97 #define NETISR_IPX 23 /* same as AF_IPX */
98 #define NETISR_USB 25 /* USB soft interrupt */
99 #define NETISR_PPP 27 /* PPP soft interrupt */
100 #define NETISR_IPV6 28 /* same as AF_INET6 */
101 #define NETISR_NATM 29 /* same as AF_NATM */
102 #define NETISR_NETGRAPH 30 /* same as AF_NETGRAPH */
103 #define NETISR_POLLMORE 31 /* check if we need more polling */
105 #define NETISR_MAX 32
107 #if defined(_KERNEL) || defined(_KERNEL_STRUCTURES)
109 #ifndef _SYS_TYPES_H_
110 #include <sys/types.h>
111 #endif
112 #ifndef _SYS_QUEUE_H_
113 #include <sys/queue.h>
114 #endif
115 #ifndef _SYS_PROTOSW_H_
116 #include <sys/protosw.h>
117 #endif
118 #ifndef _SYS_MSGPORT_H_
119 #include <sys/msgport.h>
120 #endif
121 #ifndef _NET_NETMSG_H_
122 #include <net/netmsg.h>
123 #endif
125 TAILQ_HEAD(notifymsglist, netmsg_so_notify);
127 typedef __boolean_t (*msg_predicate_fn_t)(struct netmsg *);
130 * Base class. All net messages must start with the same fields.
133 struct netmsg_packet {
134 struct netmsg nm_netmsg;
135 struct mbuf *nm_packet;
138 struct netmsg_pr_ctloutput {
139 struct netmsg nm_netmsg;
140 int (*nm_prfn) (struct socket *, struct sockopt *);
141 struct socket *nm_so;
142 struct sockopt *nm_sopt;
145 struct netmsg_pr_timeout {
146 struct netmsg nm_netmsg;
147 int (*nm_prfn) (void);
150 struct netmsg_so_notify {
151 struct netmsg nm_netmsg;
152 msg_predicate_fn_t nm_predicate;
153 struct socket *nm_so;
154 int nm_fflags; /* flags e.g. FNONBLOCK */
155 int nm_etype; /* receive or send event */
156 TAILQ_ENTRY(netmsg_so_notify) nm_list;
159 struct netmsg_so_notify_abort {
160 struct netmsg nm_netmsg;
161 struct netmsg_so_notify *nm_notifymsg;
164 #define NM_REVENT 0x1 /* event on receive buffer */
165 #define NM_SEVENT 0x2 /* event on send buffer */
167 #endif
169 #ifdef _KERNEL
172 * for dispatching pr_ functions,
173 * until they can be converted to message-passing
175 void netmsg_pru_abort(netmsg_t);
176 void netmsg_pru_accept(netmsg_t);
177 void netmsg_pru_attach(netmsg_t);
178 void netmsg_pru_bind(netmsg_t);
179 void netmsg_pru_connect(netmsg_t);
180 void netmsg_pru_connect2(netmsg_t);
181 void netmsg_pru_control(netmsg_t);
182 void netmsg_pru_detach(netmsg_t);
183 void netmsg_pru_disconnect(netmsg_t);
184 void netmsg_pru_listen(netmsg_t);
185 void netmsg_pru_peeraddr(netmsg_t);
186 void netmsg_pru_rcvd(netmsg_t);
187 void netmsg_pru_rcvoob(netmsg_t);
188 void netmsg_pru_send(netmsg_t);
189 void netmsg_pru_sense(netmsg_t);
190 void netmsg_pru_shutdown(netmsg_t);
191 void netmsg_pru_sockaddr(netmsg_t);
193 void netmsg_pru_sopoll(netmsg_t);
195 void netmsg_pr_ctloutput(netmsg_t);
196 void netmsg_pr_timeout(netmsg_t);
198 void netmsg_so_notify(netmsg_t);
199 void netmsg_so_notify_abort(netmsg_t);
200 void netmsg_so_notify_doabort(lwkt_msg_t);
202 #endif
204 #if defined(_KERNEL) || defined(_KERNEL_STRUCTURES)
206 typedef lwkt_port_t (*lwkt_portfn_t)(struct mbuf **);
208 struct netisr {
209 lwkt_port ni_port; /* must be first */
210 lwkt_portfn_t ni_mport;
211 netisr_fn_t ni_handler;
212 struct netmsg ni_netmsg; /* for sched_netisr() (no-data) */
215 #endif
217 #ifdef _KERNEL
219 extern lwkt_port netisr_afree_rport;
220 extern lwkt_port netisr_apanic_rport;
222 lwkt_port_t cpu0_portfn(struct mbuf **mptr);
223 lwkt_port_t cpu_portfn(int cpu);
224 void netisr_dispatch(int, struct mbuf *);
225 int netisr_queue(int, struct mbuf *);
226 void netisr_register(int, lwkt_portfn_t, netisr_fn_t);
227 int netisr_unregister(int);
228 void netmsg_service_port_init(lwkt_port_t);
229 void netmsg_service_loop(void *arg);
230 void netmsg_service_sync(void);
231 void schednetisr(int);
233 #endif /* _KERNEL */
235 #endif /* _NET_NETISR_H_ */