]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | /*- |
2 | * BSD LICENSE | |
3 | * | |
4 | * Copyright (c) Intel Corporation. | |
5 | * All rights reserved. | |
6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | |
10 | * | |
11 | * * Redistributions of source code must retain the above copyright | |
12 | * notice, this list of conditions and the following disclaimer. | |
13 | * * Redistributions in binary form must reproduce the above copyright | |
14 | * notice, this list of conditions and the following disclaimer in | |
15 | * the documentation and/or other materials provided with the | |
16 | * distribution. | |
17 | * * Neither the name of Intel Corporation nor the names of its | |
18 | * contributors may be used to endorse or promote products derived | |
19 | * from this software without specific prior written permission. | |
20 | * | |
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
24 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
25 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
26 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
27 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
32 | */ | |
33 | ||
34 | /** \file | |
35 | * I/OAT DMA engine driver public interface | |
36 | */ | |
37 | ||
38 | #ifndef SPDK_IOAT_H | |
39 | #define SPDK_IOAT_H | |
40 | ||
11fdf7f2 TL |
41 | #include "spdk/stdinc.h" |
42 | ||
7c673cae FG |
43 | #ifdef __cplusplus |
44 | extern "C" { | |
45 | #endif | |
46 | ||
7c673cae FG |
47 | #include "spdk/env.h" |
48 | ||
49 | /** | |
50 | * Opaque handle for a single I/OAT channel returned by \ref spdk_ioat_probe(). | |
51 | */ | |
52 | struct spdk_ioat_chan; | |
53 | ||
54 | /** | |
55 | * Signature for callback function invoked when a request is completed. | |
56 | * | |
11fdf7f2 TL |
57 | * \param arg User-specified opaque value corresponding to cb_arg from the |
58 | * request submission. | |
7c673cae FG |
59 | */ |
60 | typedef void (*spdk_ioat_req_cb)(void *arg); | |
61 | ||
62 | /** | |
63 | * Callback for spdk_ioat_probe() enumeration. | |
64 | * | |
65 | * \param cb_ctx User-specified opaque value corresponding to cb_ctx from spdk_ioat_probe(). | |
66 | * \param pci_dev PCI device that is being probed. | |
67 | * | |
68 | * \return true to attach to this device. | |
69 | */ | |
70 | typedef bool (*spdk_ioat_probe_cb)(void *cb_ctx, struct spdk_pci_device *pci_dev); | |
71 | ||
72 | /** | |
11fdf7f2 TL |
73 | * Callback for spdk_ioat_probe() to report a device that has been attached to |
74 | * the userspace I/OAT driver. | |
7c673cae FG |
75 | * |
76 | * \param cb_ctx User-specified opaque value corresponding to cb_ctx from spdk_ioat_probe(). | |
77 | * \param pci_dev PCI device that was attached to the driver. | |
78 | * \param ioat I/OAT channel that was attached to the driver. | |
79 | */ | |
80 | typedef void (*spdk_ioat_attach_cb)(void *cb_ctx, struct spdk_pci_device *pci_dev, | |
81 | struct spdk_ioat_chan *ioat); | |
82 | ||
83 | /** | |
11fdf7f2 TL |
84 | * Enumerate the I/OAT devices attached to the system and attach the userspace |
85 | * I/OAT driver to them if desired. | |
7c673cae | 86 | * |
11fdf7f2 TL |
87 | * If called more than once, only devices that are not already attached to the |
88 | * SPDK I/OAT driver will be reported. | |
89 | * | |
90 | * To stop using the controller and release its associated resources, call | |
91 | * spdk_ioat_detach() with the ioat_channel instance returned by this function. | |
7c673cae | 92 | * |
11fdf7f2 TL |
93 | * \param cb_ctx Opaque value which will be passed back in cb_ctx parameter of |
94 | * the callbacks. | |
95 | * \param probe_cb will be called once per I/OAT device found in the system. | |
96 | * \param attach_cb will be called for devices for which probe_cb returned true | |
97 | * once the I/OAT controller has been attached to the userspace driver. | |
7c673cae | 98 | * |
11fdf7f2 | 99 | * \return 0 on success, -1 on failure. |
7c673cae FG |
100 | */ |
101 | int spdk_ioat_probe(void *cb_ctx, spdk_ioat_probe_cb probe_cb, spdk_ioat_attach_cb attach_cb); | |
102 | ||
103 | /** | |
11fdf7f2 | 104 | * Detach specified device returned by spdk_ioat_probe() from the I/OAT driver. |
7c673cae FG |
105 | * |
106 | * \param ioat I/OAT channel to detach from the driver. | |
11fdf7f2 TL |
107 | */ |
108 | void spdk_ioat_detach(struct spdk_ioat_chan *ioat); | |
7c673cae FG |
109 | |
110 | /** | |
111 | * Submit a DMA engine memory copy request. | |
112 | * | |
113 | * \param chan I/OAT channel to submit request. | |
11fdf7f2 TL |
114 | * \param cb_arg Opaque value which will be passed back as the arg parameter in |
115 | * the completion callback. | |
7c673cae FG |
116 | * \param cb_fn Callback function which will be called when the request is complete. |
117 | * \param dst Destination virtual address. | |
118 | * \param src Source virtual address. | |
119 | * \param nbytes Number of bytes to copy. | |
11fdf7f2 TL |
120 | * |
121 | * \return 0 on success, negative errno on failure. | |
7c673cae | 122 | */ |
11fdf7f2 TL |
123 | int spdk_ioat_submit_copy(struct spdk_ioat_chan *chan, |
124 | void *cb_arg, spdk_ioat_req_cb cb_fn, | |
125 | void *dst, const void *src, uint64_t nbytes); | |
7c673cae FG |
126 | |
127 | /** | |
128 | * Submit a DMA engine memory fill request. | |
129 | * | |
130 | * \param chan I/OAT channel to submit request. | |
11fdf7f2 TL |
131 | * \param cb_arg Opaque value which will be passed back as the cb_arg parameter |
132 | * in the completion callback. | |
7c673cae FG |
133 | * \param cb_fn Callback function which will be called when the request is complete. |
134 | * \param dst Destination virtual address. | |
135 | * \param fill_pattern Repeating eight-byte pattern to use for memory fill. | |
136 | * \param nbytes Number of bytes to fill. | |
11fdf7f2 TL |
137 | * |
138 | * \return 0 on success, negative errno on failure. | |
7c673cae | 139 | */ |
11fdf7f2 TL |
140 | int spdk_ioat_submit_fill(struct spdk_ioat_chan *chan, |
141 | void *cb_arg, spdk_ioat_req_cb cb_fn, | |
142 | void *dst, uint64_t fill_pattern, uint64_t nbytes); | |
7c673cae FG |
143 | |
144 | /** | |
145 | * Check for completed requests on an I/OAT channel. | |
146 | * | |
147 | * \param chan I/OAT channel to check for completions. | |
148 | * | |
11fdf7f2 | 149 | * \return 0 on success, negative errno on failure. |
7c673cae FG |
150 | */ |
151 | int spdk_ioat_process_events(struct spdk_ioat_chan *chan); | |
152 | ||
153 | /** | |
154 | * DMA engine capability flags | |
155 | */ | |
156 | enum spdk_ioat_dma_capability_flags { | |
157 | SPDK_IOAT_ENGINE_COPY_SUPPORTED = 0x1, /**< The memory copy is supported */ | |
158 | SPDK_IOAT_ENGINE_FILL_SUPPORTED = 0x2, /**< The memory fill is supported */ | |
159 | }; | |
160 | ||
161 | /** | |
162 | * Get the DMA engine capabilities. | |
163 | * | |
164 | * \param chan I/OAT channel to query. | |
165 | * | |
11fdf7f2 | 166 | * \return a combination of flags from spdk_ioat_dma_capability_flags(). |
7c673cae FG |
167 | */ |
168 | uint32_t spdk_ioat_get_dma_capabilities(struct spdk_ioat_chan *chan); | |
169 | ||
170 | #ifdef __cplusplus | |
171 | } | |
172 | #endif | |
173 | ||
174 | #endif |