nataraid(4): Add devstat support.
[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
984263bc
MD
34/*
35 * Copyright (c) 1980, 1986, 1989, 1993
36 * The Regents of the University of California. All rights reserved.
37 *
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.
53 *
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.
65 *
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 */
69
70#ifndef _NET_NETISR_H_
71#define _NET_NETISR_H_
72
73/*
74 * The networking code runs off software interrupts.
75 *
76 * You can switch into the network by doing splnet() and return by splx().
77 * The software interrupt level for the network is higher than the software
78 * level for the clock (so you can enter the network in routines called
79 * at timeout time).
80 */
81
82/*
83 * Each ``pup-level-1'' input queue has a bit in a ``netisr'' status
84 * word which is used to de-multiplex a single software
85 * interrupt used for scheduling the network code to calls
86 * on the lowest level routine of each protocol.
87 */
35746821 88#define NETISR_RESERVED0 0 /* cannot be used */
984263bc
MD
89#define NETISR_IP 2 /* same as AF_INET */
90#define NETISR_NS 6 /* same as AF_NS */
984263bc 91#define NETISR_ARP 18 /* same as AF_LINK */
9b42cabe 92#define NETISR_MPLS 21 /* MPLS */
984263bc 93#define NETISR_IPX 23 /* same as AF_IPX */
8bde602d 94#define NETISR_USB 25 /* USB soft interrupt */
984263bc
MD
95#define NETISR_PPP 27 /* PPP soft interrupt */
96#define NETISR_IPV6 28 /* same as AF_INET6 */
97#define NETISR_NATM 29 /* same as AF_NATM */
98#define NETISR_NETGRAPH 30 /* same as AF_NETGRAPH */
0a9108eb 99#define NETISR_BLUETOOTH 31
984263bc 100
8bde602d 101#define NETISR_MAX 32
ef0fdad1 102
03d6a592 103#if defined(_KERNEL) || defined(_KERNEL_STRUCTURES)
984263bc 104
03d6a592
MD
105#ifndef _SYS_TYPES_H_
106#include <sys/types.h>
107#endif
108#ifndef _SYS_QUEUE_H_
109#include <sys/queue.h>
110#endif
111#ifndef _SYS_PROTOSW_H_
9eeaa8a9 112#include <sys/protosw.h>
03d6a592
MD
113#endif
114#ifndef _SYS_MSGPORT_H_
115#include <sys/msgport.h>
116#endif
4599cf19
MD
117#ifndef _NET_NETMSG_H_
118#include <net/netmsg.h>
119#endif
03d6a592 120
03d6a592
MD
121#endif
122
123#ifdef _KERNEL
124
4599cf19
MD
125void netmsg_so_notify(netmsg_t);
126void netmsg_so_notify_abort(netmsg_t);
127void netmsg_so_notify_doabort(lwkt_msg_t);
0ddb6032 128
03d6a592
MD
129#endif
130
131#if defined(_KERNEL) || defined(_KERNEL_STRUCTURES)
132
c3c96e44
MD
133/*
134 * Temporary pktinfo structure passed directly from the driver to
135 * ether_input_chain(), allows us to bypass numerous checks.
136 */
f92bfd8c
SZ
137struct pktinfo {
138 int pi_netisr; /* netisr index, e.g. NETISR_IP */
139 uint32_t pi_flags; /* PKTINFO_FLAG_ */
140 int pi_l3proto; /* layer3 protocol number */
f92bfd8c
SZ
141};
142
c3c96e44 143#define PKTINFO_FLAG_FRAG 0x1
8bde602d 144
c3c96e44
MD
145/*
146 * NETISR_xxx registrations
147 */
8bde602d 148struct netisr {
c3c96e44 149 netisr_fn_t ni_handler; /* packet handler function */
e6f77b88 150 netisr_hashck_t ni_hashck; /* hash check function */
c3c96e44 151 netisr_cpufn_t ni_cpufn; /* characterize pkt return cpu */
002c1265 152 struct netmsg_base ni_netmsg; /* for sched_netisr() (no-data) */
8bde602d
JH
153};
154
03d6a592
MD
155#endif
156
157#ifdef _KERNEL
158
92db3805
SZ
159#define NETMSG_SERVICE_ADAPTIVE 1
160#define NETMSG_SERVICE_MPSAFE 2
161
1630efc5 162extern lwkt_port netisr_adone_rport;
3f48f9c5 163extern lwkt_port netisr_afree_rport;
c3d495a1 164extern lwkt_port netisr_afree_free_so_rport;
ecd27a4c 165extern lwkt_port netisr_apanic_rport;
002c1265 166extern lwkt_port netisr_sync_port;
3f48f9c5 167
ecdefdda 168lwkt_port_t cpu_portfn(int cpu);
c244d613 169lwkt_port_t cur_netport(void);
f92bfd8c 170
c3c96e44 171void netisr_register(int, netisr_fn_t, netisr_cpufn_t);
e6f77b88 172void netisr_register_hashcheck(int, netisr_hashck_t);
c3c96e44
MD
173void netisr_register_rollup(netisr_ru_t ru_func);
174
175void netisr_characterize(int num, struct mbuf **mp, int hoff);
e6f77b88
SZ
176void netisr_hashcheck(int num, struct mbuf *m,
177 const struct pktinfo *pi);
bf82f9b7 178int netisr_queue(int, struct mbuf *);
ebe4c2ae 179int netisr_handle(int, struct mbuf *);
f92bfd8c 180
a91f9815
SZ
181struct netisr_barrier *netisr_barrier_create(void);
182void netisr_barrier_set(struct netisr_barrier *);
183void netisr_barrier_rem(struct netisr_barrier *);
184
5c703385 185void netmsg_service_port_init(lwkt_port_t);
5c703385 186void netmsg_service_sync(void);
79f504ca 187void netmsg_sync_handler(netmsg_t);
bf82f9b7 188void schednetisr(int);
984263bc 189
c244d613
SZ
190#define curnetport cur_netport()
191
03d6a592 192#endif /* _KERNEL */
984263bc 193
bf82f9b7 194#endif /* _NET_NETISR_H_ */