2 * Copyright (c) 2004 Matthew Dillon <dillon@backplane.com>.
3 * Copyright (c) 2004 Hiten Pandya <hmp@backplane.com>.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
22 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23 * COPYRIGHT HOLDERS, CONTRIBUTORS OR VOICES IN THE AUTHOR'S HEAD
24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY
25 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
26 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
27 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
29 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 * The MSF_BUF API is an augmentation similar to the SFBUF APIs and uses XIO
33 * page array handling. The SFBUF API originally came from:
35 * Copyright (c) 2003 Alan L. Cox <alc@cs.rice.edu>. All rights reserved.
36 * Copyright (c) 1998 David Greenman. All rights reserved.
37 * src/sys/sys/sfbuf.h,v 1.4 2004/04/01 17:58:06 dillon
39 * $DragonFly: src/sys/sys/msfbuf.h,v 1.3 2004/06/08 02:41:41 hmp Exp $
41 #ifndef _SYS_MSFBUF_H_
42 #define _SYS_MSFBUF_H_
45 #include <sys/queue.h>
53 * MSF_BUFs are used for caching ephermal mappings that span more than
56 * The interface returns an msf_buf data structure which has information
57 * about managing the ephermal mapping, its KVA pointer and an embedded
58 * XIO structure which describes the mapping.
60 * The embedded XIO structure be passed around to the DEV system because
61 * it is ref-counted; thus making it perfectly usable by anything that
62 * can accept an XIO as a transfer unit, most notably the buffer-cache
68 LIST_ENTRY(msf_buf) active_list; /* active list of buffers */
69 TAILQ_ENTRY(msf_buf) free_list; /* free list of buffers */
70 vm_offset_t m_kva; /* KVA offset */
71 cpumask_t m_cpumask; /* CPU mask for synchronization */
72 struct xio m_xio; /* xio embedded */
73 int m_refcnt; /* map usage tracking */
74 int m_flags; /* control flags */
80 * Return a KVA offset to the client
84 msf_buf_kva(struct msf_buf *msf)
90 * Return a reference to the underlying pages of an MSF_BUF
94 msf_buf_pages(struct msf_buf *msf)
96 return (msf->m_xio.xio_pages);
99 /* API function prototypes */
100 struct msf_buf *msf_buf_alloc(vm_page_t *pg_ary, int npages, int flags);
101 void msf_buf_free(struct msf_buf *);
102 void msf_buf_ref(struct msf_buf *);