xref: /freebsd/sys/dev/ioat/ioat.h (revision bf8553ea3853b2d67d361c308e56365bc5b72d42)
1e974f91cSConrad Meyer /*-
2e974f91cSConrad Meyer  * Copyright (C) 2012 Intel Corporation
3e974f91cSConrad Meyer  * All rights reserved.
4e974f91cSConrad Meyer  *
5e974f91cSConrad Meyer  * Redistribution and use in source and binary forms, with or without
6e974f91cSConrad Meyer  * modification, are permitted provided that the following conditions
7e974f91cSConrad Meyer  * are met:
8e974f91cSConrad Meyer  * 1. Redistributions of source code must retain the above copyright
9e974f91cSConrad Meyer  *    notice, this list of conditions and the following disclaimer.
10e974f91cSConrad Meyer  * 2. Redistributions in binary form must reproduce the above copyright
11e974f91cSConrad Meyer  *    notice, this list of conditions and the following disclaimer in the
12e974f91cSConrad Meyer  *    documentation and/or other materials provided with the distribution.
13e974f91cSConrad Meyer  *
14e974f91cSConrad Meyer  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15e974f91cSConrad Meyer  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16e974f91cSConrad Meyer  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17e974f91cSConrad Meyer  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18e974f91cSConrad Meyer  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19e974f91cSConrad Meyer  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20e974f91cSConrad Meyer  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21e974f91cSConrad Meyer  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22e974f91cSConrad Meyer  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23e974f91cSConrad Meyer  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24e974f91cSConrad Meyer  * SUCH DAMAGE.
25e974f91cSConrad Meyer  */
26e974f91cSConrad Meyer 
27e974f91cSConrad Meyer __FBSDID("$FreeBSD$");
28e974f91cSConrad Meyer 
29e974f91cSConrad Meyer #ifndef __IOAT_H__
30e974f91cSConrad Meyer #define __IOAT_H__
31e974f91cSConrad Meyer 
32e974f91cSConrad Meyer #include <sys/param.h>
33e974f91cSConrad Meyer #include <machine/bus.h>
34e974f91cSConrad Meyer 
35e974f91cSConrad Meyer /*
36e974f91cSConrad Meyer  * This file defines the public interface to the IOAT driver.
37e974f91cSConrad Meyer  */
38e974f91cSConrad Meyer 
39e974f91cSConrad Meyer /*
40e974f91cSConrad Meyer  * Enables an interrupt for this operation. Typically, you would only enable
41e974f91cSConrad Meyer  * this on the last operation in a group
42e974f91cSConrad Meyer  */
43e974f91cSConrad Meyer #define	DMA_INT_EN	0x1
44*bf8553eaSConrad Meyer /*
45*bf8553eaSConrad Meyer  * Like M_NOWAIT.  Operations will return NULL if they cannot allocate a
46*bf8553eaSConrad Meyer  * descriptor without blocking.
47*bf8553eaSConrad Meyer  */
48*bf8553eaSConrad Meyer #define	DMA_NO_WAIT	0x2
49*bf8553eaSConrad Meyer #define	DMA_ALL_FLAGS	(DMA_INT_EN | DMA_NO_WAIT)
50e974f91cSConrad Meyer 
51e974f91cSConrad Meyer typedef void *bus_dmaengine_t;
52e974f91cSConrad Meyer struct bus_dmadesc;
53e974f91cSConrad Meyer typedef void (*bus_dmaengine_callback_t)(void *arg);
54e974f91cSConrad Meyer 
55e974f91cSConrad Meyer /*
56e974f91cSConrad Meyer  * Called first to acquire a reference to the DMA channel
57e974f91cSConrad Meyer  */
58e974f91cSConrad Meyer bus_dmaengine_t ioat_get_dmaengine(uint32_t channel_index);
59e974f91cSConrad Meyer 
60466b3540SConrad Meyer /* Release the DMA channel */
61466b3540SConrad Meyer void ioat_put_dmaengine(bus_dmaengine_t dmaengine);
62466b3540SConrad Meyer 
63e974f91cSConrad Meyer /*
64e974f91cSConrad Meyer  * Acquire must be called before issuing an operation to perform. Release is
65e974f91cSConrad Meyer  * called after. Multiple operations can be issued within the context of one
66e974f91cSConrad Meyer  * acquire and release
67e974f91cSConrad Meyer  */
68e974f91cSConrad Meyer void ioat_acquire(bus_dmaengine_t dmaengine);
69e974f91cSConrad Meyer void ioat_release(bus_dmaengine_t dmaengine);
70e974f91cSConrad Meyer 
71e974f91cSConrad Meyer /* Issues the copy data operation */
72e974f91cSConrad Meyer struct bus_dmadesc *ioat_copy(bus_dmaengine_t dmaengine, bus_addr_t dst,
73e974f91cSConrad Meyer     bus_addr_t src, bus_size_t len, bus_dmaengine_callback_t callback_fn,
74e974f91cSConrad Meyer     void *callback_arg, uint32_t flags);
75e974f91cSConrad Meyer 
76e974f91cSConrad Meyer /*
77e974f91cSConrad Meyer  * Issues a null operation. This issues the operation to the hardware, but the
78e974f91cSConrad Meyer  * hardware doesn't do anything with it.
79e974f91cSConrad Meyer  */
80e974f91cSConrad Meyer struct bus_dmadesc *ioat_null(bus_dmaengine_t dmaengine,
81e974f91cSConrad Meyer     bus_dmaengine_callback_t callback_fn, void *callback_arg, uint32_t flags);
82e974f91cSConrad Meyer 
83e974f91cSConrad Meyer 
84e974f91cSConrad Meyer #endif /* __IOAT_H__ */
85e974f91cSConrad Meyer 
86