- Test m_pkthdr.fw_flags against DUMMYNET_MBUF_TAGGED before trying to locate
[dragonfly/netmp.git] / sys / sys / syslink.h
blob151a812d117c9e667c49a019b57bb005257453a0
1 /*
2 * Copyright (c) 2004-2007 The DragonFly Project. All rights reserved.
3 *
4 * This code is derived from software contributed to The DragonFly Project
5 * by Matthew Dillon <dillon@backplane.com>
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * 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
15 * the documentation and/or other materials provided with the
16 * distribution.
17 * 3. Neither the name of The DragonFly Project nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific, prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
31 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
34 * $DragonFly: src/sys/sys/syslink.h,v 1.13 2007/08/13 17:47:20 dillon Exp $
38 * The syslink infrastructure implements an optimized RPC mechanism across a
39 * communications link. RPC functions are grouped together into larger
40 * protocols. Prototypes are typically associated with system structures
41 * but do not have to be.
43 * syslink - Implements a communications end-point and protocol. A
44 * syslink is typically directly embedded in a related
45 * structure.
48 #ifndef _SYS_SYSLINK_H_
49 #define _SYS_SYSLINK_H_
51 #ifndef _SYS_TYPES_H_
52 #include <sys/types.h>
53 #endif
54 #ifndef _SYS_SYSID_H_
55 #include <sys/sysid.h>
56 #endif
57 #ifndef _SYS_TREE_H_
58 #include <sys/tree.h>
59 #endif
60 #ifndef _SYS_SYSLINK_MSG_H_
61 #include <sys/syslink_msg.h>
62 #endif
65 * Additional headers are required to support kernel-only
66 * data structures.
68 #if defined(_KERNEL) || defined(_KERNEL_STRUCTURES)
69 #ifndef _SYS_BUF_H_
70 #include <sys/buf.h>
71 #endif
72 #ifndef _SYS_BIO_H_
73 #include <sys/bio.h>
74 #endif
75 #ifndef _SYS_MSGPORT_H_
76 #include <sys/msgport.h>
77 #endif
78 #endif
80 /***************************************************************************
81 * PROTOCOL API/ABI *
82 ***************************************************************************
84 * These structures implement the programming interface for end-points and
85 * RPC calls.
88 struct syslink;
89 struct syslink_desc;
90 struct syslink_generic_args;
92 typedef int (*syslink_func_t)(struct syslink_generic_args *);
94 #define SYSLINK_CMD_NEW 0x00000001 /* create unassociated desc */
97 * Typically an extension of the syslink_info structure is passed
98 * to the kernel, or NULL for commands that do not need one.
100 struct syslink_info {
101 int version;
102 int wbflag;
103 int reserved[2];
106 #define SYSLINK_INFO_VERSION 1
109 * SYSLINK_CMD_NEW
111 * Create a pair of syslink descriptors representing a two-way
112 * communications channel.
114 struct syslink_info_new {
115 struct syslink_info head;
116 int fds[2];
119 union syslink_info_all {
120 struct syslink_info head;
121 struct syslink_info_new cmd_new;
125 * Kernel-only data structures.
127 #if defined(_KERNEL) || defined(_KERNEL_STRUCTURES)
130 * slmsg - internal kernel representation of a syslink message, organized
131 * as a LWKT message, out of band DMA buffer(s), and related memory.
132 * This structure is typically arranged via two object caches,
133 * one which maintains buffers for short syslink messages and one
134 * for long syslink messages.
136 TAILQ_HEAD(slmsgq,slmsg);
137 RB_HEAD(slmsg_rb_tree, slmsg);
138 RB_PROTOTYPE2(slmsg_rb_tree, slmsg, entry.rbnode, rb_slmsg_compare, sysid_t);
140 struct slmsg {
141 TAILQ_ENTRY(slmsg) tqnode; /* inq */
142 RB_ENTRY(slmsg) rbnode; /* held for reply matching */
143 int msgsize;
144 int maxsize;
145 int flags;
146 caddr_t vmbase; /* memory mapped */
147 size_t vmsize;
148 struct xio xio; /* restricted xio */
149 struct slmsg *rep; /* reply (kernel backend) */
150 struct objcache *oc;
151 struct syslink_msg *msg;
152 void (*callback_func)(struct slmsg *, void *, int);
153 void *callback_data;
156 #define SLMSGF_ONINQ 0x0001
157 #define SLMSGF_HASXIO 0x0002
158 #define SLMSGF_LINMAP 0x0004
160 #endif
162 #if defined(_KERNEL)
164 struct sldesc;
165 int syslink_ukbackend(int *fdp, struct sldesc **kslp);
166 struct slmsg *syslink_kallocmsg(void);
167 int syslink_kdomsg(struct sldesc *ksl, struct slmsg *msg);
168 int syslink_ksendmsg(struct sldesc *ksl, struct slmsg *msg,
169 void (*func)(struct slmsg *, void *, int), void *arg);
170 int syslink_kwaitmsg(struct sldesc *ksl, struct slmsg *msg);
171 void syslink_kfreemsg(struct sldesc *ksl, struct slmsg *msg);
172 void syslink_kshutdown(struct sldesc *ksl, int how);
173 void syslink_kclose(struct sldesc *ksl);
174 int syslink_kdmabuf_pages(struct slmsg *slmsg, struct vm_page **mbase, int npages);
175 int syslink_kdmabuf_data(struct slmsg *slmsg, char *base, int bytes);
179 #else
181 int syslink(int, struct syslink_info *, size_t);
183 #endif
185 #endif