FreeBSD/Linux Kernel Cross Reference
sys/device/net_io.h
1 /*
2 * Mach Operating System
3 * Copyright (c) 1993,1992,1991,1990,1989 Carnegie Mellon University
4 * All Rights Reserved.
5 *
6 * Permission to use, copy, modify and distribute this software and its
7 * documentation is hereby granted, provided that both the copyright
8 * notice and this permission notice appear in all copies of the
9 * software, derivative works or modified versions, and any portions
10 * thereof, and that both notices appear in supporting documentation.
11 *
12 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
13 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
14 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
15 *
16 * Carnegie Mellon requests users of this software to return to
17 *
18 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
19 * School of Computer Science
20 * Carnegie Mellon University
21 * Pittsburgh PA 15213-3890
22 *
23 * any improvements or extensions that they make and grant Carnegie Mellon
24 * the rights to redistribute these changes.
25 */
26 /*
27 * HISTORY
28 * $Log: net_io.h,v $
29 * Revision 2.9 93/11/17 16:34:24 dbg
30 * Added ANSI function prototypes.
31 * [93/01/08 dbg]
32 *
33 * Revision 2.8 91/05/14 15:59:55 mrt
34 * Correcting copyright
35 *
36 * Revision 2.7 91/03/16 14:43:26 rpd
37 * Added net_packet.
38 * [91/01/14 rpd]
39 *
40 * Revision 2.6 91/02/05 17:10:03 mrt
41 * Changed to new Mach copyright
42 * [91/01/31 17:30:15 mrt]
43 *
44 * Revision 2.5 91/01/08 15:09:56 rpd
45 * Replaced NET_KMSG_GET, NET_KMSG_FREE
46 * with net_kmsg_get, net_kmsg_put, net_kmsg_collect.
47 * [91/01/05 rpd]
48 *
49 * Revision 2.4 90/06/02 14:48:20 rpd
50 * Converted to new IPC.
51 * [90/03/26 21:58:23 rpd]
52 *
53 * Revision 2.3 90/02/22 20:02:26 dbg
54 * kmsg->queue_head becomds kmsg->chain.
55 * [90/01/25 dbg]
56 *
57 * Revision 2.2 90/01/11 11:42:26 dbg
58 * Make run in parallel.
59 * [89/11/27 dbg]
60 *
61 */
62 /*
63 * Author: David B. Golub, Carnegie Mellon University
64 * Date: ll/89
65 */
66
67 #ifndef _DEVICE_NET_IO_H_
68 #define _DEVICE_NET_IO_H_
69
70 /*
71 * Utilities for playing with network messages.
72 */
73
74 #include <mach/machine/vm_types.h>
75 #include <ipc/ipc_kmsg.h>
76
77 #include <kern/macro_help.h>
78 #include <kern/lock.h>
79 #include <kern/kalloc.h>
80
81 #include <device/net_status.h>
82 #include <device/if_hdr.h>
83 #include <device/io_req.h>
84
85 /*
86 * A network packet is wrapped in a kernel message while in
87 * the kernel.
88 */
89
90 #define net_kmsg(kmsg) ((net_rcv_msg_t)&(kmsg)->ikm_header)
91
92 /*
93 * Interrupt routines may allocate and free net_kmsgs with these
94 * functions. net_kmsg_get may return IKM_NULL.
95 */
96
97 extern ipc_kmsg_t net_kmsg_get(void);
98 extern void net_kmsg_put(ipc_kmsg_t);
99
100 /*
101 * Non-interrupt code may allocate and free net_kmsgs with these functions.
102 */
103
104 extern vm_size_t net_kmsg_size;
105
106 #define net_kmsg_alloc() ((ipc_kmsg_t) kalloc(net_kmsg_size))
107 #define net_kmsg_free(kmsg) kfree((vm_offset_t) (kmsg), net_kmsg_size)
108
109 /*
110 * This routine may be called to recycle unneeded net_kmsgs
111 * to the general message pool.
112 */
113 extern void net_kmsg_collect(void);
114
115 /*
116 * Network messages are sent to receive ports at AST time.
117 */
118 extern void net_ast(void);
119
120
121 /*
122 * Network utility routines.
123 */
124
125 extern void net_packet(
126 struct ifnet * ifp,
127 ipc_kmsg_t kmsg,
128 unsigned int count,
129 boolean_t priority);
130
131 extern void net_filter(
132 ipc_kmsg_t kmsg,
133 ipc_kmsg_queue_t send_list);
134
135 extern io_return_t net_getstat(
136 struct ifnet * ifp,
137 dev_flavor_t flavor,
138 dev_status_t status,
139 natural_t *count);
140
141 extern io_return_t net_write(
142 struct ifnet * ifp,
143 void (*start)(int),
144 io_req_t ior);
145
146 #endif /* _DEVICE_NET_IO_H_ */
Cache object: 5dc55ebf4574212bc9e5a45ba33d72f6
|