- Test m_pkthdr.fw_flags against DUMMYNET_MBUF_TAGGED before trying to locate
[dragonfly/netmp.git] / sys / sys / aio.h
blob30fa3e76b5fce4037a24f508c0f2e5bb4a971050
1 /*
2 * Copyright (c) 1997 John S. Dyson. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. John S. Dyson's name may not be used to endorse or promote products
10 * derived from this software without specific prior written permission.
12 * DISCLAIMER: This code isn't warranted to do anything useful. Anything
13 * bad that happens because of using this software isn't the responsibility
14 * of the author. This software is distributed AS-IS.
16 * $FreeBSD: src/sys/sys/aio.h,v 1.13.2.8 2002/08/31 03:18:23 alc Exp $
17 * $DragonFly: src/sys/sys/aio.h,v 1.5 2007/04/22 01:13:16 dillon Exp $
20 #ifndef _SYS_AIO_H_
21 #define _SYS_AIO_H_
23 #ifndef _SYS_TYPES_H_
24 #include <sys/types.h>
25 #endif
26 #ifndef _SYS_TIME_H_
27 #include <sys/time.h>
28 #endif
29 #ifndef _SYS_SIGNAL_H_
30 #include <sys/signal.h>
31 #endif
32 #ifndef _SYS_QUEUE_H_
33 #include <sys/queue.h>
34 #endif
35 #ifndef _SYS_CALLOUT_H_
36 #include <sys/callout.h>
37 #endif
38 #ifndef _SYS_EVENT_H_
39 #include <sys/event.h>
40 #endif
43 * Returned by aio_cancel:
45 #define AIO_CANCELED 0x1
46 #define AIO_NOTCANCELED 0x2
47 #define AIO_ALLDONE 0x3
50 * LIO opcodes
52 #define LIO_NOP 0x0
53 #define LIO_WRITE 0x1
54 #define LIO_READ 0x2
57 * LIO modes
59 #define LIO_NOWAIT 0x0
60 #define LIO_WAIT 0x1
63 * Maximum number of allowed LIO operations
65 #define AIO_LISTIO_MAX 16
68 * Private members for aiocb -- don't access
69 * directly.
71 struct __aiocb_private {
72 int status;
73 int error;
74 void *kernelinfo;
78 * I/O control block
80 typedef struct aiocb {
81 int aio_fildes; /* File descriptor */
82 off_t aio_offset; /* File offset for I/O */
83 volatile void *aio_buf; /* I/O buffer in process space */
84 size_t aio_nbytes; /* Number of bytes for I/O */
85 struct sigevent aio_sigevent; /* Signal to deliver */
86 int aio_lio_opcode; /* LIO opcode */
87 int aio_reqprio; /* Request priority -- ignored */
88 struct __aiocb_private _aiocb_private;
89 } aiocb_t;
91 #ifndef _KERNEL
93 __BEGIN_DECLS
95 * Asynchronously read from a file
97 int aio_read(struct aiocb *);
100 * Asynchronously write to file
102 int aio_write(struct aiocb *);
105 * List I/O Asynchronously/synchronously read/write to/from file
106 * "lio_mode" specifies whether or not the I/O is synchronous.
107 * "acb_list" is an array of "nacb_listent" I/O control blocks.
108 * when all I/Os are complete, the optional signal "sig" is sent.
110 int lio_listio(int, struct aiocb * const [], int, struct sigevent *);
113 * Get completion status
114 * returns EINPROGRESS until I/O is complete.
115 * this routine does not block.
117 int aio_error(const struct aiocb *);
120 * Finish up I/O, releasing I/O resources and returns the value
121 * that would have been associated with a synchronous I/O request.
122 * This routine must be called once and only once for each
123 * I/O control block who has had I/O associated with it.
125 ssize_t aio_return(struct aiocb *);
128 * Cancel I/O
130 int aio_cancel(int, struct aiocb *);
133 * Suspend until all specified I/O or timeout is complete.
135 int aio_suspend(const struct aiocb * const[], int, const struct timespec *);
137 int aio_waitcomplete(struct aiocb **, struct timespec *);
139 __END_DECLS
141 #else
143 * Job queue item
146 #define AIOCBLIST_RUNDOWN 0x4
147 #define AIOCBLIST_DONE 0x10
149 struct aiocblist {
150 TAILQ_ENTRY (aiocblist) list; /* List of jobs */
151 TAILQ_ENTRY (aiocblist) plist; /* List of jobs for proc */
152 int jobflags;
153 int jobstate;
154 int inputcharge, outputcharge;
155 struct callout timeout;
156 struct buf *bp; /* Buffer pointer */
157 struct proc *userproc; /* User process */
158 struct file *fd_file; /* Pointer to file structure */
159 struct aio_liojob *lio; /* Optional lio job */
160 struct aiocb *uuaiocb; /* Pointer in userspace of aiocb */
161 struct klist klist; /* list of knotes */
162 struct aiocb uaiocb; /* Kernel I/O control block */
165 /* Forward declarations for prototypes below. */
166 struct socket;
167 struct signalsockbuf;
169 void aio_proc_rundown(struct proc *p);
170 void aio_swake(struct socket *, struct signalsockbuf *);
172 #endif
174 #endif