A little script that runs through all the header files and checks that
[dragonfly.git] / sys / net / netisr.h
CommitLineData
66d6c637
JH
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.
19 *
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.
32 */
33
34/*
35 * Copyright (c) 2004 Jeffrey M. Hsu. All rights reserved.
36 *
37 * License terms: all terms for the DragonFly license above plus the following:
38 *
39 * 4. All advertising materials mentioning features or use of this software
40 * must display the following acknowledgement:
41 *
42 * This product includes software developed by Jeffrey M. Hsu
43 * for the DragonFly Project.
44 *
45 * This requirement may be waived with permission from Jeffrey Hsu.
46 * This requirement will sunset and may be removed on July 8 2005,
47 * after which the standard DragonFly license (as shown above) will
48 * apply.
49 */
50
984263bc
MD
51/*
52 * Copyright (c) 1980, 1986, 1989, 1993
53 * The Regents of the University of California. All rights reserved.
54 *
55 * Redistribution and use in source and binary forms, with or without
56 * modification, are permitted provided that the following conditions
57 * are met:
58 * 1. Redistributions of source code must retain the above copyright
59 * notice, this list of conditions and the following disclaimer.
60 * 2. Redistributions in binary form must reproduce the above copyright
61 * notice, this list of conditions and the following disclaimer in the
62 * documentation and/or other materials provided with the distribution.
63 * 3. All advertising materials mentioning features or use of this software
64 * must display the following acknowledgement:
65 * This product includes software developed by the University of
66 * California, Berkeley and its contributors.
67 * 4. Neither the name of the University nor the names of its contributors
68 * may be used to endorse or promote products derived from this software
69 * without specific prior written permission.
70 *
71 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
72 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
73 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
74 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
75 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
76 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
77 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
78 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
79 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
80 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
81 * SUCH DAMAGE.
82 *
83 * @(#)netisr.h 8.1 (Berkeley) 6/10/93
84 * $FreeBSD: src/sys/net/netisr.h,v 1.21.2.5 2002/02/09 23:02:39 luigi Exp $
ecdefdda 85 * $DragonFly: src/sys/net/netisr.h,v 1.22 2006/01/31 19:05:35 dillon Exp $
984263bc
MD
86 */
87
88#ifndef _NET_NETISR_H_
89#define _NET_NETISR_H_
90
bf82f9b7
MD
91#include <sys/msgport.h>
92
984263bc
MD
93/*
94 * The networking code runs off software interrupts.
95 *
96 * You can switch into the network by doing splnet() and return by splx().
97 * The software interrupt level for the network is higher than the software
98 * level for the clock (so you can enter the network in routines called
99 * at timeout time).
100 */
101
102/*
103 * Each ``pup-level-1'' input queue has a bit in a ``netisr'' status
104 * word which is used to de-multiplex a single software
105 * interrupt used for scheduling the network code to calls
106 * on the lowest level routine of each protocol.
107 */
35746821
MD
108#define NETISR_RESERVED0 0 /* cannot be used */
109#define NETISR_POLL 1 /* polling callback */
984263bc
MD
110#define NETISR_IP 2 /* same as AF_INET */
111#define NETISR_NS 6 /* same as AF_NS */
8bde602d
JH
112#define NETISR_AARP 15 /* Appletalk ARP */
113#define NETISR_ATALK2 16 /* Appletalk phase 2 */
114#define NETISR_ATALK1 17 /* Appletalk phase 1 */
984263bc
MD
115#define NETISR_ARP 18 /* same as AF_LINK */
116#define NETISR_IPX 23 /* same as AF_IPX */
8bde602d 117#define NETISR_USB 25 /* USB soft interrupt */
984263bc
MD
118#define NETISR_PPP 27 /* PPP soft interrupt */
119#define NETISR_IPV6 28 /* same as AF_INET6 */
120#define NETISR_NATM 29 /* same as AF_NATM */
121#define NETISR_NETGRAPH 30 /* same as AF_NETGRAPH */
122#define NETISR_POLLMORE 31 /* check if we need more polling */
123
8bde602d 124#define NETISR_MAX 32
ef0fdad1 125
b6e58eb0
JH
126TAILQ_HEAD(notifymsglist, netmsg_so_notify);
127
984263bc 128#ifdef _KERNEL
984263bc 129
9eeaa8a9
JH
130#include <sys/protosw.h>
131
132struct netmsg;
133
b76bed62 134typedef int (*netisr_fn_t)(struct netmsg *);
c1d0003c 135typedef boolean_t (*msg_predicate_fn_t)(struct netmsg *);
9eeaa8a9
JH
136
137/*
138 * Base class. All net messages must start with the same fields.
139 */
140struct netmsg {
141 struct lwkt_msg nm_lmsg;
9eeaa8a9
JH
142};
143
144struct netmsg_packet {
145 struct lwkt_msg nm_lmsg;
9eeaa8a9
JH
146 struct mbuf *nm_packet;
147};
148
149struct netmsg_pr_ctloutput {
150 struct lwkt_msg nm_lmsg;
9eeaa8a9
JH
151 int (*nm_prfn) (struct socket *, struct sockopt *);
152 struct socket *nm_so;
153 struct sockopt *nm_sopt;
154};
155
156struct netmsg_pr_timeout {
157 struct lwkt_msg nm_lmsg;
b44419cb 158 int (*nm_prfn) (void);
9eeaa8a9
JH
159};
160
c1d0003c
JH
161struct netmsg_so_notify {
162 struct lwkt_msg nm_lmsg;
c1d0003c
JH
163 msg_predicate_fn_t nm_predicate;
164 struct socket *nm_so;
165 int nm_etype; /* receive or send event */
166 TAILQ_ENTRY(netmsg_so_notify) nm_list;
167};
168
169#define NM_REVENT 0x1 /* event on receive buffer */
170#define NM_SEVENT 0x2 /* event on send buffer */
171
9eeaa8a9
JH
172/*
173 * for dispatching pr_ functions,
174 * until they can be converted to message-passing
175 */
b44419cb
MD
176int netmsg_pru_abort(lwkt_msg_t);
177int netmsg_pru_accept(lwkt_msg_t);
178int netmsg_pru_attach(lwkt_msg_t);
179int netmsg_pru_bind(lwkt_msg_t);
180int netmsg_pru_connect(lwkt_msg_t);
181int netmsg_pru_connect2(lwkt_msg_t);
182int netmsg_pru_control(lwkt_msg_t);
183int netmsg_pru_detach(lwkt_msg_t);
184int netmsg_pru_disconnect(lwkt_msg_t);
185int netmsg_pru_listen(lwkt_msg_t);
186int netmsg_pru_peeraddr(lwkt_msg_t);
187int netmsg_pru_rcvd(lwkt_msg_t);
188int netmsg_pru_rcvoob(lwkt_msg_t);
189int netmsg_pru_send(lwkt_msg_t);
190int netmsg_pru_sense(lwkt_msg_t);
191int netmsg_pru_shutdown(lwkt_msg_t);
192int netmsg_pru_sockaddr(lwkt_msg_t);
193
194int netmsg_pru_sopoll(lwkt_msg_t);
195
196int netmsg_pr_ctloutput(lwkt_msg_t);
197int netmsg_pr_timeout(lwkt_msg_t);
198
199int netmsg_so_notify(lwkt_msg_t);
200int netmsg_so_notify_abort(lwkt_msg_t);
0ddb6032 201
b01ae44a 202typedef lwkt_port_t (*lwkt_portfn_t)(struct mbuf **);
8bde602d 203
8bde602d 204struct netisr {
a29576fc 205 lwkt_port ni_port; /* must be first */
bf82f9b7 206 lwkt_portfn_t ni_mport;
8bde602d 207 netisr_fn_t ni_handler;
a29576fc 208 struct netmsg ni_netmsg; /* for sched_netisr() (no-data) */
8bde602d
JH
209};
210
3f48f9c5
JH
211extern lwkt_port netisr_afree_rport;
212
b01ae44a 213lwkt_port_t cpu0_portfn(struct mbuf **mptr);
ecdefdda 214lwkt_port_t cpu_portfn(int cpu);
bf82f9b7
MD
215void netisr_dispatch(int, struct mbuf *);
216int netisr_queue(int, struct mbuf *);
217void netisr_register(int, lwkt_portfn_t, netisr_fn_t);
218int netisr_unregister(int);
5c703385 219void netmsg_service_port_init(lwkt_port_t);
bf82f9b7 220void netmsg_service_loop(void *arg);
5c703385 221void netmsg_service_sync(void);
bf82f9b7 222void schednetisr(int);
984263bc 223
9eeaa8a9 224#endif /* KERNEL */
984263bc 225
bf82f9b7 226#endif /* _NET_NETISR_H_ */