1122780Salc/*-
2137372Salc * Copyright (c) 2003-2004 Alan L. Cox <alc@cs.rice.edu>
3122780Salc * All rights reserved.
4122780Salc *
5122780Salc * Redistribution and use in source and binary forms, with or without
6122780Salc * modification, are permitted provided that the following conditions
7122780Salc * are met:
8122780Salc * 1. Redistributions of source code must retain the above copyright
9122780Salc *    notice, this list of conditions and the following disclaimer.
10122780Salc * 2. Redistributions in binary form must reproduce the above copyright
11122780Salc *    notice, this list of conditions and the following disclaimer in the
12122780Salc *    documentation and/or other materials provided with the distribution.
13122780Salc *
14122780Salc * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15122780Salc * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16122780Salc * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17122780Salc * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18122780Salc * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19122780Salc * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20122780Salc * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21122780Salc * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22122780Salc * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23122780Salc * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24122780Salc * SUCH DAMAGE.
25122780Salc *
26122780Salc * $FreeBSD$
27122780Salc */
28122780Salc
29122780Salc#ifndef _SYS_SF_BUF_H_
30122780Salc#define _SYS_SF_BUF_H_
31122780Salc
32137372Salc/*
33137372Salc * Options to sf_buf_alloc() are specified through its flags argument.  This
34137372Salc * argument's value should be the result of a bitwise or'ing of one or more
35137372Salc * of the following values.
36137372Salc */
37137372Salc#define	SFB_CATCH	1		/* Check signals if the allocation
38137372Salc					   sleeps. */
39137372Salc#define	SFB_CPUPRIVATE	2		/* Create a CPU private mapping. */
40137372Salc#define	SFB_DEFAULT	0
41137372Salc#define	SFB_NOWAIT	4		/* Return NULL if all bufs are used. */
42137372Salc
43122780Salcstruct vm_page;
44122780Salc
45253351Saestruct sfstat {				/* sendfile statistics */
46253351Sae	uint64_t	sf_iocnt;	/* times sendfile had to do disk I/O */
47253351Sae	uint64_t	sf_allocfail;	/* times sfbuf allocation failed */
48253351Sae	uint64_t	sf_allocwait;	/* times sfbuf allocation had to wait */
49253351Sae};
50253351Sae
51253351Sae#ifdef _KERNEL
52253351Sae#include <machine/sf_buf.h>
53255246Sglebius#include <sys/systm.h>
54253351Sae#include <sys/counter.h>
55254799Sandrestruct mbuf;	/* for sf_buf_mext() */
56253351Sae
57253351Saeextern counter_u64_t sfstat[sizeof(struct sfstat) / sizeof(uint64_t)];
58253351Sae#define	SFSTAT_ADD(name, val)	\
59253351Sae    counter_u64_add(sfstat[offsetof(struct sfstat, name) / sizeof(uint64_t)],\
60253351Sae	(val))
61253351Sae#define	SFSTAT_INC(name)	SFSTAT_ADD(name, 1)
62253351Sae#endif /* _KERNEL */
63253351Sae
64254842Sandreint	sf_buf_mext(struct mbuf *mb, void *addr, void *args);
65122780Salc
66122780Salc#endif /* !_SYS_SF_BUF_H_ */
67