2015-12-03 21:30:38 +00:00
|
|
|
/*-
|
|
|
|
* BSD LICENSE
|
|
|
|
*
|
2016-01-26 17:47:22 +00:00
|
|
|
* Copyright (c) Intel Corporation.
|
2015-12-03 21:30:38 +00:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
*
|
|
|
|
* * Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* * Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in
|
|
|
|
* the documentation and/or other materials provided with the
|
|
|
|
* distribution.
|
|
|
|
* * Neither the name of Intel Corporation nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** \file
|
2016-04-29 18:04:33 +00:00
|
|
|
* I/OAT DMA engine driver public interface
|
2015-12-03 21:30:38 +00:00
|
|
|
*/
|
|
|
|
|
2016-02-11 19:31:35 +00:00
|
|
|
#ifndef SPDK_IOAT_H
|
|
|
|
#define SPDK_IOAT_H
|
2015-12-03 21:30:38 +00:00
|
|
|
|
2017-05-01 20:22:48 +00:00
|
|
|
#include "spdk/stdinc.h"
|
|
|
|
|
2016-02-12 14:52:35 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2016-08-10 17:41:12 +00:00
|
|
|
#include "spdk/env.h"
|
2016-02-03 21:36:26 +00:00
|
|
|
|
2016-02-03 19:57:51 +00:00
|
|
|
/**
|
2016-02-11 19:31:35 +00:00
|
|
|
* Opaque handle for a single I/OAT channel returned by \ref spdk_ioat_probe().
|
2016-02-03 19:57:51 +00:00
|
|
|
*/
|
2016-02-11 19:31:35 +00:00
|
|
|
struct spdk_ioat_chan;
|
2016-02-03 19:57:51 +00:00
|
|
|
|
2015-12-03 21:30:38 +00:00
|
|
|
/**
|
|
|
|
* Signature for callback function invoked when a request is completed.
|
2016-03-29 18:20:45 +00:00
|
|
|
*
|
|
|
|
* \param arg User-specified opaque value corresponding to cb_arg from the request submission.
|
2015-12-03 21:30:38 +00:00
|
|
|
*/
|
2016-02-11 19:31:35 +00:00
|
|
|
typedef void (*spdk_ioat_req_cb)(void *arg);
|
2015-12-03 21:30:38 +00:00
|
|
|
|
|
|
|
/**
|
2016-02-11 19:31:35 +00:00
|
|
|
* Callback for spdk_ioat_probe() enumeration.
|
2016-02-03 19:57:51 +00:00
|
|
|
*
|
2016-03-29 18:20:45 +00:00
|
|
|
* \param cb_ctx User-specified opaque value corresponding to cb_ctx from spdk_ioat_probe().
|
|
|
|
* \param pci_dev PCI device that is being probed.
|
|
|
|
*
|
2016-02-03 19:57:51 +00:00
|
|
|
* \return true to attach to this device.
|
2015-12-03 21:30:38 +00:00
|
|
|
*/
|
2016-02-11 19:31:35 +00:00
|
|
|
typedef bool (*spdk_ioat_probe_cb)(void *cb_ctx, struct spdk_pci_device *pci_dev);
|
2015-12-03 21:30:38 +00:00
|
|
|
|
|
|
|
/**
|
2016-02-11 19:31:35 +00:00
|
|
|
* Callback for spdk_ioat_probe() to report a device that has been attached to the userspace I/OAT driver.
|
2016-03-29 18:20:45 +00:00
|
|
|
*
|
|
|
|
* \param cb_ctx User-specified opaque value corresponding to cb_ctx from spdk_ioat_probe().
|
|
|
|
* \param pci_dev PCI device that was attached to the driver.
|
|
|
|
* \param ioat I/OAT channel that was attached to the driver.
|
2016-02-03 19:57:51 +00:00
|
|
|
*/
|
2016-02-11 19:31:35 +00:00
|
|
|
typedef void (*spdk_ioat_attach_cb)(void *cb_ctx, struct spdk_pci_device *pci_dev,
|
|
|
|
struct spdk_ioat_chan *ioat);
|
2016-02-03 19:57:51 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Enumerate the I/OAT devices attached to the system and attach the userspace I/OAT driver
|
|
|
|
* to them if desired.
|
|
|
|
*
|
2016-03-29 18:20:45 +00:00
|
|
|
* \param cb_ctx Opaque value which will be passed back in cb_ctx parameter of the callbacks.
|
2016-02-03 19:57:51 +00:00
|
|
|
* \param probe_cb will be called once per I/OAT device found in the system.
|
|
|
|
* \param attach_cb will be called for devices for which probe_cb returned true once the I/OAT
|
|
|
|
* controller has been attached to the userspace driver.
|
|
|
|
*
|
|
|
|
* If called more than once, only devices that are not already attached to the SPDK I/OAT driver
|
|
|
|
* will be reported.
|
2015-12-03 21:30:38 +00:00
|
|
|
*
|
2016-02-03 19:57:51 +00:00
|
|
|
* To stop using the the controller and release its associated resources,
|
2016-02-11 19:31:35 +00:00
|
|
|
* call \ref spdk_ioat_detach with the ioat_channel instance returned by this function.
|
2015-12-03 21:30:38 +00:00
|
|
|
*/
|
2016-02-11 19:31:35 +00:00
|
|
|
int spdk_ioat_probe(void *cb_ctx, spdk_ioat_probe_cb probe_cb, spdk_ioat_attach_cb attach_cb);
|
2015-12-03 21:30:38 +00:00
|
|
|
|
|
|
|
/**
|
2016-02-11 19:31:35 +00:00
|
|
|
* Detaches specified device returned by \ref spdk_ioat_probe() from the I/OAT driver.
|
2016-03-29 18:20:45 +00:00
|
|
|
*
|
|
|
|
* \param ioat I/OAT channel to detach from the driver.
|
2015-12-03 21:30:38 +00:00
|
|
|
*/
|
2016-02-11 19:31:35 +00:00
|
|
|
int spdk_ioat_detach(struct spdk_ioat_chan *ioat);
|
2015-12-03 21:30:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Submit a DMA engine memory copy request.
|
2016-03-29 18:20:45 +00:00
|
|
|
*
|
|
|
|
* \param chan I/OAT channel to submit request.
|
|
|
|
* \param cb_arg Opaque value which will be passed back as the arg parameter in the completion callback.
|
|
|
|
* \param cb_fn Callback function which will be called when the request is complete.
|
|
|
|
* \param dst Destination virtual address.
|
|
|
|
* \param src Source virtual address.
|
|
|
|
* \param nbytes Number of bytes to copy.
|
2015-12-03 21:30:38 +00:00
|
|
|
*/
|
2017-09-16 00:17:57 +00:00
|
|
|
int spdk_ioat_submit_copy(struct spdk_ioat_chan *chan,
|
|
|
|
void *cb_arg, spdk_ioat_req_cb cb_fn,
|
|
|
|
void *dst, const void *src, uint64_t nbytes);
|
2015-12-03 21:30:38 +00:00
|
|
|
|
2016-01-29 08:01:43 +00:00
|
|
|
/**
|
|
|
|
* Submit a DMA engine memory fill request.
|
2016-03-29 18:20:45 +00:00
|
|
|
*
|
|
|
|
* \param chan I/OAT channel to submit request.
|
|
|
|
* \param cb_arg Opaque value which will be passed back as the cb_arg parameter in the completion callback.
|
|
|
|
* \param cb_fn Callback function which will be called when the request is complete.
|
|
|
|
* \param dst Destination virtual address.
|
|
|
|
* \param fill_pattern Repeating eight-byte pattern to use for memory fill.
|
|
|
|
* \param nbytes Number of bytes to fill.
|
2016-01-29 08:01:43 +00:00
|
|
|
*/
|
2017-09-16 00:17:57 +00:00
|
|
|
int spdk_ioat_submit_fill(struct spdk_ioat_chan *chan,
|
|
|
|
void *cb_arg, spdk_ioat_req_cb cb_fn,
|
|
|
|
void *dst, uint64_t fill_pattern, uint64_t nbytes);
|
2016-01-29 08:01:43 +00:00
|
|
|
|
2015-12-17 17:56:00 +00:00
|
|
|
/**
|
2016-03-10 18:07:32 +00:00
|
|
|
* Check for completed requests on an I/OAT channel.
|
2015-12-17 17:56:00 +00:00
|
|
|
*
|
2016-03-29 18:20:45 +00:00
|
|
|
* \param chan I/OAT channel to check for completions.
|
|
|
|
*
|
2015-12-17 17:56:00 +00:00
|
|
|
* \returns 0 on success or negative if something went wrong.
|
2015-12-03 21:30:38 +00:00
|
|
|
*/
|
2016-03-10 18:07:32 +00:00
|
|
|
int spdk_ioat_process_events(struct spdk_ioat_chan *chan);
|
2015-12-03 21:30:38 +00:00
|
|
|
|
2016-01-29 08:01:43 +00:00
|
|
|
/**
|
|
|
|
* DMA engine capability flags
|
|
|
|
*/
|
2016-02-11 19:31:35 +00:00
|
|
|
enum spdk_ioat_dma_capability_flags {
|
|
|
|
SPDK_IOAT_ENGINE_COPY_SUPPORTED = 0x1, /**< The memory copy is supported */
|
|
|
|
SPDK_IOAT_ENGINE_FILL_SUPPORTED = 0x2, /**< The memory fill is supported */
|
2016-01-29 08:01:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the DMA engine capabilities.
|
2016-03-29 18:20:45 +00:00
|
|
|
*
|
|
|
|
* \param chan I/OAT channel to query.
|
|
|
|
*
|
|
|
|
* \return A combination of flags from \ref spdk_ioat_dma_capability_flags.
|
2016-01-29 08:01:43 +00:00
|
|
|
*/
|
2016-03-10 18:07:32 +00:00
|
|
|
uint32_t spdk_ioat_get_dma_capabilities(struct spdk_ioat_chan *chan);
|
2016-01-29 08:01:43 +00:00
|
|
|
|
2016-02-12 14:52:35 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-12-03 21:30:38 +00:00
|
|
|
#endif
|