]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/sys/sf_sync.h
Add new a M_START() mbuf macro that returns a pointer to the start of
[FreeBSD/FreeBSD.git] / sys / sys / sf_sync.h
1 /*-
2  * Copyright (c) 2013 Adrian Chadd <adrian@FreeBSD.org>
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24  * SUCH DAMAGE.
25  *
26  * $FreeBSD$
27  */
28
29 #ifndef _SYS_SF_SYNC_H_
30 #define _SYS_SF_SYNC_H_
31
32 typedef enum {
33         SF_STATE_NONE,
34         SF_STATE_SETUP,
35         SF_STATE_RUNNING,
36         SF_STATE_COMPLETED,
37         SF_STATE_FREEING
38 } sendfile_sync_state_t;
39
40 struct sendfile_sync {
41         struct mtx      mtx;
42         struct cv       cv;
43         struct knlist   klist;
44         uint32_t        flags;
45         uint32_t        count;
46         int32_t         xerrno;         /* Completion errno, if retval < 0 */
47         off_t           retval;         /* Completion retval (eg written bytes) */
48         sendfile_sync_state_t   state;
49 };
50
51 /* XXX pollution */
52 struct sf_hdtr_kq;
53
54 extern  struct sendfile_sync * sf_sync_alloc(uint32_t flags);
55 extern  void sf_sync_syscall_wait(struct sendfile_sync *);
56 extern  void sf_sync_free(struct sendfile_sync *);
57 extern  void sf_sync_try_free(struct sendfile_sync *);
58 extern  void sf_sync_ref(struct sendfile_sync *);
59 extern  void sf_sync_deref(struct sendfile_sync *);
60 extern  int sf_sync_kqueue_setup(struct sendfile_sync *, struct sf_hdtr_kq *);
61 extern  void sf_sync_set_state(struct sendfile_sync *, sendfile_sync_state_t, int);
62 extern  void sf_sync_set_retval(struct sendfile_sync *, off_t, int);
63
64 #endif /* !_SYS_SF_BUF_H_ */