1 .\" $NetBSD: dmoverio.4,v 1.5 2003/04/16 13:35:17 wiz Exp $
3 .\" Copyright (c) 2002 Wasabi Systems, Inc.
4 .\" All rights reserved.
6 .\" Written by Jason R. Thorpe for Wasabi Systems, Inc.
8 .\" Redistribution and use in source and binary forms, with or without
9 .\" 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.
13 .\" 2. Redistributions in binary form must reproduce the above copyright
14 .\" notice, this list of conditions and the following disclaimer in the
15 .\" documentation and/or other materials provided with the distribution.
16 .\" 3. All advertising materials mentioning features or use of this software
17 .\" must display the following acknowledgement:
18 .\" This product includes software developed for the NetBSD Project by
19 .\" Wasabi Systems, Inc.
20 .\" 4. The name of Wasabi Systems, Inc. may not be used to endorse
21 .\" or promote products derived from this software without specific prior
22 .\" written permission.
24 .\" THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
25 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
26 .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
27 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
28 .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 .\" POSSIBILITY OF SUCH DAMAGE.
41 .Nd hardware-assisted data mover interface
43 .Cd pseudo-device dmoverio
45 .In dev/dmover/dmover_io.h
49 pseudo-device driver provides an interface to hardware-assisted
50 data movers, which the kernel supports using the
52 facility. This can be used to copy data from one location in
53 memory to another, clear a region of memory, fill a region of memory
54 with a pattern, and perform simple operations on multiple regions of
55 memory, such as an XOR, without intervention by the CPU.
59 function always has one output region. A function may have zero or more
60 input regions, or may use an immediate value as an input. For functions
61 which use input regions, the lengths of each input region and the output
62 region must be the same. All
64 functions with the same name will have the same number of and type inputs.
68 the client must first create a session. This is achieved by performing
72 Create a session handle by opening the
78 function using the DMIO_SETFUNC ioctl, which takes the following
80 .Bd -literal -offset indent
81 #define DMIO_MAX_FUNCNAME 64
83 char dsf_name[DMIO_MAX_FUNCNAME];
87 If the specified function is not available, the DMIO_SETFUNC ioctl
88 will fail with an error code of
92 To submit a request for processing the following steps must be
96 Fill in a request structure:
97 .Bd -literal -offset indent
99 struct iovec *dmbuf_iov;
105 dmio_buffer req_outbuf;
109 uint8_t _immediate[8];
113 #define req_immediate _req_inbuf_un._immediate
114 #define req_inbuf _req_inbuf_un._inbuf
116 uint32_t req_id; /* request ID; passed in response */
120 For functions which use an immediate value as an input, the
122 member is used to specify the value. Values smaller than 8 bytes should
123 use the least-significant bytes first. For example, a 32-bit integer
124 would occupy bytes 0, 1, 2, and 3.
126 For functions which use input regions,
128 should point to an array of
129 .Fa dmio_buffer Ns 's .
133 should be a unique value for each request submitted by the client. It
134 will be passed back unchanged in the response when processing of the
135 request has completed.
137 Write the request structure to the session handle using the
139 system call. Multiple requests may be written to the session in a
142 Read the response structure back from the session handle using the
144 system call. The response structure is defined as follows:
145 .Bd -literal -offset indent
146 struct dmio_usrresp {
158 contains 0 if the request succeeded or an
160 value indicating why the request failed. Multiple responses may
161 be read back in a single call. Note that responses may not be
162 received in the same order as requests were written.
165 When a client is finished using a
167 session, the session is destroyed by closing the session handle using
170 The following is an example of a client using
172 to zero-fill a region of memory. In this example, the application would
173 be able to perform other work while the hardware-assisted data mover clears
174 the specified block of memory.
177 hw_bzero(void *buf, size_t len)
179 static uint32_t reqid;
181 struct dmio_setfunc dsf;
183 struct dmio_usrreq req;
184 struct dmio_usrresp resp;
187 fd = open("/dev/dmoverio", O_RDWR, 0666);
191 strcpy(dsf.dsf_name, "zero");
193 if (ioctl(fd, DMIO_SETFUNC, &dsf) == -1) {
201 req.req_outbuf.dmbuf_iov = &iov;
202 req.req_outbuf.dmbuf_iovcnt = 1;
203 req.req_id = reqid++;
205 if (write(fd, &req, sizeof(req)) != sizeof(req)) {
210 /* Application can do other work here. */
212 if (read(fd, &resp, sizeof(resp)) != sizeof(resp)) {
217 if (resp.resp_id != req.req_id) {
222 if (resp.resp_error != 0) {
236 device first appeared in
241 device was designed and implemented by
243 .Aq thorpej@wasabisystems.com
244 and contributed by Wasabi Systems, Inc.