xref: /freebsd/share/man/man4/ioat.4 (revision fa9896e082a1046ff4fbc75fcba4d18d1f2efc19)
1e974f91cSConrad Meyer.\" Copyright (c) 2015 EMC / Isilon Storage Division
2e974f91cSConrad Meyer.\" All rights reserved.
3e974f91cSConrad Meyer.\"
4e974f91cSConrad Meyer.\" Redistribution and use in source and binary forms, with or without
5e974f91cSConrad Meyer.\" modification, are permitted provided that the following conditions
6e974f91cSConrad Meyer.\" are met:
7e974f91cSConrad Meyer.\" 1. Redistributions of source code must retain the above copyright
8e974f91cSConrad Meyer.\"    notice, this list of conditions and the following disclaimer.
9e974f91cSConrad Meyer.\" 2. Redistributions in binary form must reproduce the above copyright
10e974f91cSConrad Meyer.\"    notice, this list of conditions and the following disclaimer in the
11e974f91cSConrad Meyer.\"    documentation and/or other materials provided with the distribution.
12e974f91cSConrad Meyer.\"
13e974f91cSConrad Meyer.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
14e974f91cSConrad Meyer.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15e974f91cSConrad Meyer.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16e974f91cSConrad Meyer.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
17e974f91cSConrad Meyer.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18e974f91cSConrad Meyer.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19e974f91cSConrad Meyer.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20e974f91cSConrad Meyer.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21e974f91cSConrad Meyer.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22e974f91cSConrad Meyer.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23e974f91cSConrad Meyer.\" SUCH DAMAGE.
24e974f91cSConrad Meyer.\"
25*bec7ff79SConrad Meyer.Dd May 3, 2016
26e974f91cSConrad Meyer.Dt IOAT 4
27e974f91cSConrad Meyer.Os
28e974f91cSConrad Meyer.Sh NAME
29e974f91cSConrad Meyer.Nm I/OAT
30e974f91cSConrad Meyer.Nd Intel I/O Acceleration Technology
31e974f91cSConrad Meyer.Sh SYNOPSIS
32faefad9cSConrad MeyerTo compile this driver into your kernel,
33faefad9cSConrad Meyerplace the following line in your kernel configuration file:
34faefad9cSConrad Meyer.Bd -ragged -offset indent
35e974f91cSConrad Meyer.Cd "device ioat"
36faefad9cSConrad Meyer.Ed
37faefad9cSConrad Meyer.Pp
38faefad9cSConrad MeyerOr, to load the driver as a module at boot, place the following line in
39faefad9cSConrad Meyer.Xr loader.conf 5 :
40faefad9cSConrad Meyer.Bd -literal -offset indent
41faefad9cSConrad Meyerioat_load="YES"
42faefad9cSConrad Meyer.Ed
43faefad9cSConrad Meyer.Pp
44e974f91cSConrad MeyerIn
45e974f91cSConrad Meyer.Xr loader.conf 5 :
46e974f91cSConrad Meyer.Pp
47e974f91cSConrad Meyer.Cd hw.ioat.force_legacy_interrupts=0
48e974f91cSConrad Meyer.Pp
49e974f91cSConrad MeyerIn
50e974f91cSConrad Meyer.Xr loader.conf 5 or
51e974f91cSConrad Meyer.Xr sysctl.conf 5 :
52e974f91cSConrad Meyer.Pp
53e974f91cSConrad Meyer.Cd hw.ioat.enable_ioat_test=0
54e974f91cSConrad Meyer.Cd hw.ioat.debug_level=0
55e974f91cSConrad Meyer(only critical errors; maximum of 3)
56e974f91cSConrad Meyer.Pp
57e974f91cSConrad Meyer.Ft typedef void
58faefad9cSConrad Meyer.Fn (*bus_dmaengine_callback_t) "void *arg" "int error"
59e974f91cSConrad Meyer.Pp
60e974f91cSConrad Meyer.Ft bus_dmaengine_t
61e974f91cSConrad Meyer.Fn ioat_get_dmaengine "uint32_t channel_index"
62e974f91cSConrad Meyer.Ft void
63faefad9cSConrad Meyer.Fn ioat_put_dmaengine "bus_dmaengine_t dmaengine"
645ca9fc2aSConrad Meyer.Ft int
6531bf2875SConrad Meyer.Fn ioat_get_hwversion "bus_dmaengine_t dmaengine"
66bd81fe68SConrad Meyer.Ft size_t
67bd81fe68SConrad Meyer.Fn ioat_get_max_io_size "bus_dmaengine_t dmaengine"
6831bf2875SConrad Meyer.Ft int
695ca9fc2aSConrad Meyer.Fn ioat_set_interrupt_coalesce "bus_dmaengine_t dmaengine" "uint16_t delay"
705ca9fc2aSConrad Meyer.Ft uint16_t
715ca9fc2aSConrad Meyer.Fn ioat_get_max_coalesce_period "bus_dmaengine_t dmaengine"
72faefad9cSConrad Meyer.Ft void
73e974f91cSConrad Meyer.Fn ioat_acquire "bus_dmaengine_t dmaengine"
741502e363SConrad Meyer.Ft int
751502e363SConrad Meyer.Fn ioat_acquire_reserve "bus_dmaengine_t dmaengine" "uint32_t n" "int mflags"
76e974f91cSConrad Meyer.Ft void
77e974f91cSConrad Meyer.Fn ioat_release "bus_dmaengine_t dmaengine"
78e974f91cSConrad Meyer.Ft struct bus_dmadesc *
79e974f91cSConrad Meyer.Fo ioat_copy
80e974f91cSConrad Meyer.Fa "bus_dmaengine_t dmaengine"
81e974f91cSConrad Meyer.Fa "bus_addr_t dst"
82e974f91cSConrad Meyer.Fa "bus_addr_t src"
83e974f91cSConrad Meyer.Fa "bus_size_t len"
84e974f91cSConrad Meyer.Fa "bus_dmaengine_callback_t callback_fn"
85e974f91cSConrad Meyer.Fa "void *callback_arg"
86e974f91cSConrad Meyer.Fa "uint32_t flags"
87e974f91cSConrad Meyer.Fc
88e974f91cSConrad Meyer.Ft struct bus_dmadesc *
899950fde0SConrad Meyer.Fo ioat_copy_8k_aligned
909950fde0SConrad Meyer.Fa "bus_dmaengine_t dmaengine"
919950fde0SConrad Meyer.Fa "bus_addr_t dst1"
929950fde0SConrad Meyer.Fa "bus_addr_t dst2"
939950fde0SConrad Meyer.Fa "bus_addr_t src1"
949950fde0SConrad Meyer.Fa "bus_addr_t src2"
959950fde0SConrad Meyer.Fa "bus_dmaengine_callback_t callback_fn"
969950fde0SConrad Meyer.Fa "void *callback_arg"
979950fde0SConrad Meyer.Fa "uint32_t flags"
989950fde0SConrad Meyer.Fc
999950fde0SConrad Meyer.Ft struct bus_dmadesc *
100*bec7ff79SConrad Meyer.Fo ioat_copy_crc
101*bec7ff79SConrad Meyer.Fa "bus_dmaengine_t dmaengine"
102*bec7ff79SConrad Meyer.Fa "bus_addr_t dst"
103*bec7ff79SConrad Meyer.Fa "bus_addr_t src"
104*bec7ff79SConrad Meyer.Fa "bus_size_t len"
105*bec7ff79SConrad Meyer.Fa "uint32_t *initialseed"
106*bec7ff79SConrad Meyer.Fa "bus_addr_t crcptr"
107*bec7ff79SConrad Meyer.Fa "bus_dmaengine_callback_t callback_fn"
108*bec7ff79SConrad Meyer.Fa "void *callback_arg"
109*bec7ff79SConrad Meyer.Fa "uint32_t flags"
110*bec7ff79SConrad Meyer.Fc
111*bec7ff79SConrad Meyer.Ft struct bus_dmadesc *
112*bec7ff79SConrad Meyer.Fo ioat_crc
113*bec7ff79SConrad Meyer.Fa "bus_dmaengine_t dmaengine"
114*bec7ff79SConrad Meyer.Fa "bus_addr_t src"
115*bec7ff79SConrad Meyer.Fa "bus_size_t len"
116*bec7ff79SConrad Meyer.Fa "uint32_t *initialseed"
117*bec7ff79SConrad Meyer.Fa "bus_addr_t crcptr"
118*bec7ff79SConrad Meyer.Fa "bus_dmaengine_callback_t callback_fn"
119*bec7ff79SConrad Meyer.Fa "void *callback_arg"
120*bec7ff79SConrad Meyer.Fa "uint32_t flags"
121*bec7ff79SConrad Meyer.Fc
122*bec7ff79SConrad Meyer.Ft struct bus_dmadesc *
123faefad9cSConrad Meyer.Fo ioat_blockfill
124faefad9cSConrad Meyer.Fa "bus_dmaengine_t dmaengine"
125faefad9cSConrad Meyer.Fa "bus_addr_t dst"
126faefad9cSConrad Meyer.Fa "uint64_t fillpattern"
127faefad9cSConrad Meyer.Fa "bus_size_t len"
128faefad9cSConrad Meyer.Fa "bus_dmaengine_callback_t callback_fn"
129faefad9cSConrad Meyer.Fa "void *callback_arg"
130faefad9cSConrad Meyer.Fa "uint32_t flags"
131faefad9cSConrad Meyer.Fc
132faefad9cSConrad Meyer.Ft struct bus_dmadesc *
133e974f91cSConrad Meyer.Fo ioat_null
134e974f91cSConrad Meyer.Fa "bus_dmaengine_t dmaengine"
135e974f91cSConrad Meyer.Fa "bus_dmaengine_callback_t callback_fn"
136e974f91cSConrad Meyer.Fa "void *callback_arg"
137e974f91cSConrad Meyer.Fa "uint32_t flags"
138e974f91cSConrad Meyer.Fc
139e974f91cSConrad Meyer.Sh DESCRIPTION
140e974f91cSConrad MeyerThe
141e974f91cSConrad Meyer.Nm
142e974f91cSConrad Meyerdriver provides a kernel API to a variety of DMA engines on some Intel server
143e974f91cSConrad Meyerplatforms.
144e974f91cSConrad Meyer.Pp
145e974f91cSConrad MeyerThere is a number of DMA channels per CPU package.
146e974f91cSConrad Meyer(Typically 4 or 8.)
147e974f91cSConrad MeyerEach may be used independently.
148e974f91cSConrad MeyerOperations on a single channel proceed sequentially.
149e974f91cSConrad Meyer.Pp
150faefad9cSConrad MeyerBlockfill operations can be used to write a 64-bit pattern to memory.
151faefad9cSConrad Meyer.Pp
152faefad9cSConrad MeyerCopy operations can be used to offload memory copies to the DMA engines.
153e974f91cSConrad Meyer.Pp
154e974f91cSConrad MeyerNull operations do nothing, but may be used to test the interrupt and callback
155e974f91cSConrad Meyermechanism.
156e974f91cSConrad Meyer.Pp
157e974f91cSConrad MeyerAll operations can optionally trigger an interrupt at completion with the
1586ca07079SConrad Meyer.Ar DMA_INT_EN
159e974f91cSConrad Meyerflag.
160e974f91cSConrad MeyerFor example, a user might submit multiple operations to the same channel and
161e974f91cSConrad Meyeronly enable an interrupt and callback for the last operation.
162faefad9cSConrad Meyer.Pp
1635ca9fc2aSConrad MeyerThe hardware can delay and coalesce interrupts on a given channel for a
1645ca9fc2aSConrad Meyerconfigurable period of time, in microseconds.
1655ca9fc2aSConrad MeyerThis may be desired to reduce the processing and interrupt overhead per
1665ca9fc2aSConrad Meyerdescriptor, especially for workflows consisting of many small operations.
1675ca9fc2aSConrad MeyerSoftware can control this on a per-channel basis with the
1685ca9fc2aSConrad Meyer.Fn ioat_set_interrupt_coalesce
1695ca9fc2aSConrad MeyerAPI.
1705ca9fc2aSConrad MeyerThe
1715ca9fc2aSConrad Meyer.Fn ioat_get_max_coalesce_period
1725ca9fc2aSConrad MeyerAPI can be used to determine the maximum coalescing period supported by the
1735ca9fc2aSConrad Meyerhardware, in microseconds.
1745ca9fc2aSConrad MeyerCurrent platforms support up to a 16.383 millisecond coalescing period.
1755ca9fc2aSConrad MeyerOptimal configuration will vary by workflow and desired operation latency.
1765ca9fc2aSConrad Meyer.Pp
177faefad9cSConrad MeyerAll operations are safe to use in a non-blocking context with the
178faefad9cSConrad Meyer.Ar DMA_NO_WAIT
179faefad9cSConrad Meyerflag.
180faefad9cSConrad Meyer(Of course, allocations may fail and operations requested with
181faefad9cSConrad Meyer.Ar DMA_NO_WAIT
182faefad9cSConrad Meyermay return NULL.)
183faefad9cSConrad Meyer.Pp
1846ca07079SConrad MeyerOperations that depend on the result of prior operations should use
1856ca07079SConrad Meyer.Ar DMA_FENCE .
1866ca07079SConrad MeyerFor example, such a scenario can happen when two related DMA operations are
1876ca07079SConrad Meyerqueued.
1886ca07079SConrad MeyerFirst, a DMA copy to one location (A), followed directly by a DMA copy
1896ca07079SConrad Meyerfrom A to B.
1906ca07079SConrad MeyerIn this scenario, some classes of I/OAT hardware may prefetch A for the second
1916ca07079SConrad Meyeroperation before it is written by the first operation.
1926ca07079SConrad MeyerTo avoid reading a stale value in sequences of dependent operations, use
1936ca07079SConrad Meyer.Ar DMA_FENCE .
1946ca07079SConrad Meyer.Pp
195faefad9cSConrad MeyerAll operations, as well as
196faefad9cSConrad Meyer.Fn ioat_get_dmaengine ,
197faefad9cSConrad Meyercan return NULL in special circumstances.
198faefad9cSConrad MeyerFor example, if the
199faefad9cSConrad Meyer.Nm
200faefad9cSConrad Meyerdriver is being unloaded, or the administrator has induced a hardware reset, or
201faefad9cSConrad Meyera usage error has resulted in a hardware error state that needs to be recovered
202faefad9cSConrad Meyerfrom.
203faefad9cSConrad Meyer.Pp
204faefad9cSConrad MeyerIt is invalid to attempt to submit new DMA operations in a
205faefad9cSConrad Meyer.Fa bus_dmaengine_callback_t
206faefad9cSConrad Meyercontext.
207*bec7ff79SConrad Meyer.Pp
208*bec7ff79SConrad MeyerThe CRC operations have three distinct modes.
209*bec7ff79SConrad MeyerThe default mode is to accumulate.
210*bec7ff79SConrad MeyerBy accumulating over multiple descriptors, a user may gather a CRC over several
211*bec7ff79SConrad Meyerchunks of memory and only write out the result once.
212*bec7ff79SConrad Meyer.Pp
213*bec7ff79SConrad MeyerThe
214*bec7ff79SConrad Meyer.Ar DMA_CRC_STORE
215*bec7ff79SConrad Meyerflag causes the operation to emit the CRC32C result.
216*bec7ff79SConrad MeyerIf
217*bec7ff79SConrad Meyer.Ar DMA_CRC_INLINE
218*bec7ff79SConrad Meyeris set, the result is written inline with the destination data (or source in
219*bec7ff79SConrad Meyer.Fn ioat_crc
220*bec7ff79SConrad Meyermode).
221*bec7ff79SConrad MeyerIf
222*bec7ff79SConrad Meyer.Ar DMA_CRC_INLINE
223*bec7ff79SConrad Meyeris not set, the result is written to the provided
224*bec7ff79SConrad Meyer.Fa crcptr .
225*bec7ff79SConrad Meyer.Pp
226*bec7ff79SConrad MeyerSimilarly, the
227*bec7ff79SConrad Meyer.Ar DMA_CRC_TEST
228*bec7ff79SConrad Meyerflag causes the operation to compare the CRC32C result to an existing checksum.
229*bec7ff79SConrad MeyerIf
230*bec7ff79SConrad Meyer.Ar DMA_CRC_INLINE
231*bec7ff79SConrad Meyeris set, the result is compared against the inline four bytes trailing the
232*bec7ff79SConrad Meyersource data.
233*bec7ff79SConrad MeyerIf it is not set, the result is compared against the value pointed to by
234*bec7ff79SConrad Meyer.Fa crcptr .
235*bec7ff79SConrad Meyer.Pp
236*bec7ff79SConrad Meyer.Fn ioat_copy_crc
237*bec7ff79SConrad Meyercalculates a CRC32C while copying data.
238*bec7ff79SConrad Meyer.Fn ioat_crc
239*bec7ff79SConrad Meyeronly computes a CRC32C of some data.
240*bec7ff79SConrad MeyerIf the
241*bec7ff79SConrad Meyer.Fa initialseed
242*bec7ff79SConrad Meyerargument to either routine is non-NULL, the CRC32C engine is initialized with
243*bec7ff79SConrad Meyerthe value it points to.
244e974f91cSConrad Meyer.Sh USAGE
245e974f91cSConrad MeyerA typical user will lookup the DMA engine object for a given channel with
246e974f91cSConrad Meyer.Fn ioat_get_dmaengine .
247e974f91cSConrad MeyerWhen the user wants to offload a copy, they will first
248e974f91cSConrad Meyer.Fn ioat_acquire
249e974f91cSConrad Meyerthe
250e974f91cSConrad Meyer.Ar bus_dmaengine_t
251e974f91cSConrad Meyerobject for exclusive access to enqueue operations on that channel.
2521502e363SConrad MeyerOptionally, the user can reserve space by using
2531502e363SConrad Meyer.Fn ioat_acquire_reserve
2541502e363SConrad Meyerinstead.
2551502e363SConrad MeyerIf
2561502e363SConrad Meyer.Fn ioat_acquire_reserve
2571502e363SConrad Meyersucceeds, there is guaranteed to be room for
2581502e363SConrad Meyer.Fa N
2591502e363SConrad Meyernew operations in the internal ring buffer.
260*bec7ff79SConrad Meyer.Pp
261e974f91cSConrad MeyerThen, they will submit one or more operations using
262faefad9cSConrad Meyer.Fn ioat_blockfill ,
263faefad9cSConrad Meyer.Fn ioat_copy ,
264*bec7ff79SConrad Meyer.Fn ioat_copy_8k_aligned ,
265*bec7ff79SConrad Meyer.Fn ioat_copy_crc ,
266*bec7ff79SConrad Meyer.Fn ioat_crc ,
267e974f91cSConrad Meyeror
268e974f91cSConrad Meyer.Fn ioat_null .
2699950fde0SConrad MeyerAfter queuing one or more individual DMA operations, they will
270e974f91cSConrad Meyer.Fn ioat_release
271e974f91cSConrad Meyerthe
272e974f91cSConrad Meyer.Ar bus_dmaengine_t
273e974f91cSConrad Meyerto drop their exclusive access to the channel.
274e974f91cSConrad MeyerThe routine they provided for the
275e974f91cSConrad Meyer.Fa callback_fn
276e974f91cSConrad Meyerargument will be invoked with the provided
277e974f91cSConrad Meyer.Fa callback_arg
278e974f91cSConrad Meyerwhen the operation is complete.
279faefad9cSConrad MeyerWhen they are finished with the
280faefad9cSConrad Meyer.Ar bus_dmaengine_t ,
281faefad9cSConrad Meyerthe user should
282faefad9cSConrad Meyer.Fn ioat_put_dmaengine .
283faefad9cSConrad Meyer.Pp
284faefad9cSConrad MeyerUsers MUST NOT block between
285faefad9cSConrad Meyer.Fn ioat_acquire
286faefad9cSConrad Meyerand
287faefad9cSConrad Meyer.Fn ioat_release .
288faefad9cSConrad MeyerUsers SHOULD NOT hold
289faefad9cSConrad Meyer.Ar bus_dmaengine_t
290faefad9cSConrad Meyerreferences for a very long time to enable fault recovery and kernel module
291faefad9cSConrad Meyerunload.
292e974f91cSConrad Meyer.Pp
293e974f91cSConrad MeyerFor an example of usage, see
294e974f91cSConrad Meyer.Pa src/sys/dev/ioat/ioat_test.c .
295e974f91cSConrad Meyer.Sh FILES
296280186c7SChristian Brueffer.Bl -tag
297e974f91cSConrad Meyer.It Pa /dev/ioat_test
298e974f91cSConrad Meyertest device for
299e974f91cSConrad Meyer.Xr ioatcontrol 8
300e974f91cSConrad Meyer.El
301e974f91cSConrad Meyer.Sh SEE ALSO
302e974f91cSConrad Meyer.Xr ioatcontrol 8
303e974f91cSConrad Meyer.Sh HISTORY
304e974f91cSConrad MeyerThe
305e974f91cSConrad Meyer.Nm
306e974f91cSConrad Meyerdriver first appeared in
307e974f91cSConrad Meyer.Fx 11.0 .
308e974f91cSConrad Meyer.Sh AUTHORS
309e974f91cSConrad MeyerThe
310e974f91cSConrad Meyer.Nm
311e974f91cSConrad Meyerdriver was developed by
312e974f91cSConrad Meyer.An \&Jim Harris Aq Mt jimharris@FreeBSD.org ,
313faefad9cSConrad Meyer.An \&Carl Delsey Aq Mt carl.r.delsey@intel.com ,
314e974f91cSConrad Meyerand
315faefad9cSConrad Meyer.An \&Conrad Meyer Aq Mt cem@FreeBSD.org .
316e974f91cSConrad MeyerThis manual page was written by
317e974f91cSConrad Meyer.An \&Conrad Meyer Aq Mt cem@FreeBSD.org .
318e974f91cSConrad Meyer.Sh CAVEATS
319e974f91cSConrad MeyerCopy operation takes bus addresses as parameters, not virtual addresses.
320e974f91cSConrad Meyer.Pp
321faefad9cSConrad MeyerBuffers for individual copy operations must be physically contiguous.
322faefad9cSConrad Meyer.Pp
323faefad9cSConrad MeyerCopies larger than max transfer size (1MB, but may vary by hardware) are not
324faefad9cSConrad Meyersupported.
325e974f91cSConrad MeyerFuture versions will likely support this by breaking up the transfer into
326e974f91cSConrad Meyersmaller sizes.
327e974f91cSConrad Meyer.Sh BUGS
328e974f91cSConrad MeyerThe
329e974f91cSConrad Meyer.Nm
330faefad9cSConrad Meyerdriver only supports blockfill, copy, and null operations at this time.
331e974f91cSConrad MeyerThe driver does not yet support advanced DMA modes, such as XOR, that some
332e974f91cSConrad MeyerI/OAT devices support.
333