From patchwork Tue Jun 15 13:22:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengwen Feng X-Patchwork-Id: 94250 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 78E26A0C47; Tue, 15 Jun 2021 15:25:40 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E56504067A; Tue, 15 Jun 2021 15:25:39 +0200 (CEST) Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by mails.dpdk.org (Postfix) with ESMTP id 7DDBE40140 for ; Tue, 15 Jun 2021 15:25:37 +0200 (CEST) Received: from dggemv704-chm.china.huawei.com (unknown [172.30.72.57]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4G487z1Rbpz1BMq3; Tue, 15 Jun 2021 21:20:31 +0800 (CST) Received: from dggpeml500024.china.huawei.com (7.185.36.10) by dggemv704-chm.china.huawei.com (10.3.19.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 15 Jun 2021 21:25:27 +0800 Received: from localhost.localdomain (10.67.165.24) by dggpeml500024.china.huawei.com (7.185.36.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 15 Jun 2021 21:25:26 +0800 From: Chengwen Feng To: , CC: , , , , , , , , Date: Tue, 15 Jun 2021 21:22:07 +0800 Message-ID: <1623763327-30987-1-git-send-email-fengchengwen@huawei.com> X-Mailer: git-send-email 2.8.1 MIME-Version: 1.0 X-Originating-IP: [10.67.165.24] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpeml500024.china.huawei.com (7.185.36.10) X-CFilter-Loop: Reflected Subject: [dpdk-dev] [RFC PATCH] dmadev: introduce DMA device library X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" This patch introduces 'dmadevice' which is a generic type of DMA device. The APIs of dmadev library exposes some generic operations which can enable configuration and I/O with the DMA devices. Signed-off-by: Chengwen Feng --- lib/dmadev/rte_dmadev.h | 531 ++++++++++++++++++++++++++++++++++++++++++++ lib/dmadev/rte_dmadev_pmd.h | 384 ++++++++++++++++++++++++++++++++ 2 files changed, 915 insertions(+) create mode 100644 lib/dmadev/rte_dmadev.h create mode 100644 lib/dmadev/rte_dmadev_pmd.h diff --git a/lib/dmadev/rte_dmadev.h b/lib/dmadev/rte_dmadev.h new file mode 100644 index 0000000..ca7c8a8 --- /dev/null +++ b/lib/dmadev/rte_dmadev.h @@ -0,0 +1,531 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright 2021 HiSilicon Limited. + */ + +#ifndef _RTE_DMADEV_H_ +#define _RTE_DMADEV_H_ + +/** + * @file rte_dmadev.h + * + * DMA (Direct Memory Access) device APIs. + * + * Defines RTE DMA Device APIs for DMA operations and its provisioning. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Get the total number of DMA devices that have been successfully + * initialised. + * + * @return + * The total number of usable DMA devices. + */ +__rte_experimental +uint16_t +rte_dmadev_count(void); + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Get the device identifier for the named DMA device. + * + * @param name + * DMA device name to select the DMA device identifier. + * + * @return + * Returns DMA device identifier on success. + * - <0: Failure to find named DMA device. + */ +__rte_experimental +int +rte_dmadev_get_dev_id(const char *name); + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Return the NUMA socket to which a device is connected. + * + * @param dev_id + * The identifier of the device. + * + * @return + * The NUMA socket id to which the device is connected or + * a default of zero if the socket could not be determined. + * - -EINVAL: dev_id value is out of range. + */ +__rte_experimental +int +rte_dmadev_socket_id(uint16_t dev_id); + +/** + * The capabilities of a DMA device. + */ +#define RTE_DMA_DEV_CAPA_FILL (1ull << 0) /**< Support fill ops */ +#define RTE_DMA_DEV_CAPA_FENCE (1ull << 1) /**< Support fence ops */ +#define RTE_DMA_DEV_CAPA_HANDLE (1ull << 2) /**< Support opaque handle */ + +/** + * DMA device information + */ +struct rte_dmadev_info { + const char *driver_name; /**< DMA driver name. */ + struct rte_device *device; /**< Device information. */ + uint64_t dev_capa; /**< Device capabilities (RTE_DMA_DEV_CAPA_). */ + uint16_t nb_max_desc; /**< Max allowed number of descriptors. */ + uint16_t nb_min_desc; /**< Min allowed number of descriptors. */ +}; + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Retrieve the contextual information of a DMA device. + * + * @param dev_id + * The identifier of the device. + * + * @param[out] dev_info + * A pointer to a structure of type *rte_dmadev_info* to be filled with the + * contextual information of the device. + * @return + * - 0: Success, driver updates the contextual information of the DMA device + * - <0: Error code returned by the driver info get function. + * + */ +__rte_experimental +int +rte_dmadev_info_get(uint16_t dev_id, struct rte_dmadev_info *dev_info); + +/** + * A structure used to configure a DMA device. + */ +struct rte_dmadev_conf { + uint16_t nb_desc; /**< The number of submission descriptor ring size */ + bool handle_enable; /**< if set, process user-supplied opaque handle */ +}; + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Configure a DMA device. + * + * This function must be invoked first before any other function in the + * API. This function can also be re-invoked when a device is in the + * stopped state. + * + * The caller may use rte_dmadev_info_get() to get the capability of each + * resources available for this DMA device. + * + * @param dev_id + * The identifier of the device to configure. + * @param dev_conf + * The DMA device configuration structure encapsulated into rte_dmadev_conf + * object. + * + * @return + * - 0: Success, device configured. + * - <0: Error code returned by the driver configuration function. + */ +__rte_experimental +int +rte_dmadev_configure(uint16_t dev_id, struct rte_dmadev_conf *dev_conf); + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Start a DMA device. + * + * The device start step is the last one and consists of setting the DMA + * to start accepting jobs (e.g. fill or copy). + * + * @param dev_id + * The identifier of the device. + * + * @return + * - 0: Success, device started. + * < 0: Error code returned by the driver start function. + */ +__rte_experimental +int +rte_dmadev_start(uint16_t dev_id); + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Stop a DMA device. The device can be restarted with a call to + * rte_dmadev_start() + * + * @param dev_id + * The identifier of the device. + * + * @return + * - 0: Success, device stopped. + * - <0: Error code returned by the driver stop function. + */ +__rte_experimental +int +rte_dmadev_stop(uint16_t dev_id); + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Close a DMA device. The device cannot be restarted after this call. + * + * @param dev_id + * The identifier of the device. + * + * @return + * - 0 on successfully closing device + * - <0 on failure to close device + */ +__rte_experimental +int +rte_dmadev_close(uint16_t dev_id); + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Reset a DMA device. + * This is different from cycle of rte_dmadev_start->rte_dmadev_stop in the + * sense similar to hard or soft reset. + * + * @param dev_id + * The identifier of the device. + * + * @return + * - 0 on successful reset device. + * - <0 on failure to reset device. + * - (-ENOTSUP) if the device doesn't support this function. + */ +__rte_experimental +int +rte_dmadev_reset(uint16_t dev_id); + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Enqueue a fill operation onto the DMA device + * + * This queues up a fill operation to be performed by hardware, but does not + * trigger hardware to begin that operation. + * + * @param dev_id + * The identifier of the device. + * @param pattern + * The pattern to populate the destination buffer with. + * @param dst + * The address of the destination buffer. + * @param len + * The length of the destination buffer. + * @param op_handle + * An opaque handle for this operation, may be returned when completed or + * completed_error. + * + * @return + * Number of operations enqueued, either 0 or 1 + */ +__rte_experimental +static inline int +rte_dmadev_fill(uint16_t dev_id, uint64_t pattern, rte_iova_t dst, + uint32_t len, uintptr_t op_handle); + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Enqueue a copy operation onto the DMA device. + * + * This queues up a copy operation to be performed by hardware, but does not + * trigger hardware to begin that operation. + * + * @param dev_id + * The identifier of the device. + * @param src + * The address of the source buffer. + * @param dst + * The address of the destination buffer. + * @param len + * The length of the data to be copied. + * @param op_handle + * An opaque handle for this operation, may be returned when completed or + * completed_error. + * + * @return + * Number of operations enqueued, either 0 or 1. + */ +__rte_experimental +static inline int +rte_dmadev_copy(uint16_t dev_id, rte_iova_t src, rte_iova_t dst, + uint32_t len, uintptr_t op_handle); + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Add a fence to force ordering between operations + * + * This adds a fence to a sequence of operations to enforce ordering, such that + * all operations enqueued before the fence must be completed before operations + * after the fence. + * NOTE: Since this fence may be added as a flag to the last operation enqueued, + * this API may not function correctly when called immediately after an + * "rte_dmadev_perform_ops" call i.e. before any new operations are enqueued. + * + * @param dev_id + * The identifier of the device. + * + * @return + * - 0: on successful add fence. + * - <0: on failure to add fence. + */ +__rte_experimental +static inline int +rte_dmadev_fence(uint16_t dev_id); + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Trigger hardware to begin performing enqueued operations + * + * This API is used to write the "doorbell" to the hardware to trigger it + * to begin the operations previously enqueued by rte_dmadev_enqueue_xxx() + * + * @param dev_id + * The identifier of the device. + * + * @return + * - 0: on successful trigger hardware. + * - <0: on failure to trigger hardware. + */ +__rte_experimental +static inline int +rte_dmadev_perform(uint16_t dev_id); + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Returns the number of operations that have been successful completed. + * + * @param dev_id + * The identifier of the device. + * @param op_handle + * Return the lastest completed operation's opaque handle which passed by fill + * or copy ops. + * NOTE: If handle_enable configuration option for the device was not set, + * this parameter is ignored, and may be NULL. + * + * @return + * -1 on device error, with rte_errno set appropriately and parameters + * unmodified. + * Otherwise number of successful completed operations. + */ +__rte_experimental +static inline int +rte_dmadev_completed(uint16_t dev_id, uintptr_t *op_handle); + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Returns the number of operations that failed to complete. + * NOTE: This API was used when rte_dmadev_completed return -1. + * + * @param dev_id + * The identifier of the device. + * @param op_handle + * Return the lastest failed operation's opaque handle which passed by fill + * or copy ops. + * NOTE: If handle_enable configuration option for the device was not set, + * this parameter is ignored, and may be NULL. + * + * @return + * The number of failed to complete operations (due to some error, e.g. + * hardware errors) + */ +__rte_experimental +static inline uint16_t +rte_dmadev_completed_error(uint16_t dev_id, uintptr_t *op_handle); + +/** Maximum name length for extended statistics counters */ +#define RTE_DMA_DEV_XSTATS_NAME_SIZE 64 + +/** + * A name-key lookup element for extended statistics. + * + * This structure is used to map between names and ID numbers + * for extended ethdev statistics. + */ +struct rte_dmadev_xstats_name { + char name[RTE_DMA_DEV_XSTATS_NAME_SIZE]; +}; + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Retrieve names of extended statistics of a DMA device. + * + * @param dev_id + * The identifier of the device. + * @param[out] xstats_names + * Block of memory to insert names into. Must be at least size in capacity. + * If set to NULL, function returns required capacity. + * @param size + * Capacity of xstats_names (number of names). + * @return + * - positive value lower or equal to size: success. The return value + * is the number of entries filled in the stats table. + * - positive value higher than size: error, the given statistics table + * is too small. The return value corresponds to the size that should + * be given to succeed. The entries in the table are not valid and + * shall not be used by the caller. + * - negative value on error: + * -ENODEV for invalid *dev_id* + * -ENOTSUP if the device doesn't support this function. + */ +int +rte_dmadev_xstats_names_get(uint16_t dev_id, + struct rte_dmadev_xstats_name *xstats_names, + unsigned int size); + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Retrieve extended statistics of a DMA device. + * + * @param dev_id + * The identifier of the device. + * @param ids + * The id numbers of the stats to get. The ids can be got from the stat + * position in the stat list from rte_dmadev_get_xstats_names(), or + * by using rte_dmadev_get_xstats_by_name() + * @param[out] values + * The values for each stats request by ID. + * @param n + * The number of stats requested + * @return + * - positive value: number of stat entries filled into the values array + * - negative value on error: + * -ENODEV for invalid *dev_id* + * -ENOTSUP if the device doesn't support this function. + */ +int +rte_dmadev_xstats_get(uint16_t dev_id, + const unsigned int ids[], + uint64_t values[], + unsigned int n); + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Reset the values of the xstats of the selected component in the device. + * + * @param dev_id + * The identifier of the device + * @param ids + * Selects specific statistics to be reset. When NULL, all statistics + * will be reset. If non-NULL, must point to array of at least + * *nb_ids* size. + * @param nb_ids + * The number of ids available from the *ids* array. Ignored when ids is NULL. + * @return + * - zero: successfully reset the statistics to zero + * - negative value on error: + * -EINVAL invalid parameters + * -ENOTSUP if not supported. + */ +int +rte_dmadev_xstats_reset(uint16_t dev_id, + const uint32_t ids[], + uint32_t nb_ids); + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Dump internal information about *dev_id* to the FILE* provided in *f*. + * + * @param dev_id + * The identifier of the device. + * + * @param f + * A pointer to a file for output. + * + * @return + * - 0: on successful dump device. + * - <0: on failure to dump device. + * - (-ENOTSUP) if the device doesn't support this function. + */ +__rte_experimental +int +rte_dmadev_dump(uint16_t dev_id, FILE *f); + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Trigger the dmadev self test. + * + * @param dev_id + * The identifier of the device. + * + * @return + * - 0: Selftest successful. + * - -ENOTSUP if the device doesn't support selftest + * - other values < 0 on failure. + */ +int +rte_dmadev_selftest(uint16_t dev_id); + + +struct rte_dmadev_ops; + +#define RTE_DMADEV_NAME_MAX_LEN (64) +/**< @internal Max length of name of DMA PMD */ + +/** @internal + * The data structure associated with each DMA device. + */ +struct rte_dmadev { + /**< Device ID for this instance */ + uint16_t dev_id; + /**< Functions exported by PMD */ + const struct rte_dmadev_ops *dev_ops; + /**< Device info. supplied during device initialization */ + struct rte_device *device; + /**< Driver info. supplied by probing */ + const char *driver_name; + + /**< Device name */ + char name[RTE_DMADEV_NAME_MAX_LEN]; +} __rte_cache_aligned; + +#ifdef __cplusplus +} +#endif + +#endif /* _RTE_DMADEV_H_ */ diff --git a/lib/dmadev/rte_dmadev_pmd.h b/lib/dmadev/rte_dmadev_pmd.h new file mode 100644 index 0000000..faa3909 --- /dev/null +++ b/lib/dmadev/rte_dmadev_pmd.h @@ -0,0 +1,384 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright 2021 HiSilicon Limited. + */ + +#ifndef _RTE_DMADEV_PMD_H_ +#define _RTE_DMADEV_PMD_H_ + +/** @file + * RTE DMA PMD APIs + * + * @note + * Driver facing APIs for a DMA device. These are not to be called directly by + * any application. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#include +#include + +#include "rte_dmadev.h" + +/** + * Get the rte_dmadev structure device pointer for the named device. + * + * @param name + * device name to select the device structure. + * + * @return + * - The rte_dmadev structure pointer for the given device name. + */ +struct rte_dmadev * +rte_dmadev_pmd_get_named_dev(const char *name); + +/** + * Definitions of all functions exported by a driver through the + * generic structure of type *dmadev_ops* supplied in the *rte_dmadev* + * structure associated with a device. + */ + +/** + * Get device information of a device. + * + * @param dev + * DMA device pointer + * @param dev_info + * DMA device information structure + * + * @return + * Returns 0 on success, negative error code on failure + */ +typedef int (*dmadev_info_get_t)(struct rte_dmadev *dev, + struct rte_dmadev_info *dev_info); + +/** + * Configure a device. + * + * @param dev + * DMA device pointer + * @param config + * DMA device configuration structure + * + * @return + * Returns 0 on success + */ +typedef int (*dmadev_configure_t)(const struct rte_dmadev *dev, + struct rte_dmadev_conf *config); + +/** + * Start a configured device. + * + * @param dev + * DMA device pointer + * + * @return + * Returns 0 on success + */ +typedef int (*dmadev_start_t)(struct rte_dmadev *dev); + +/** + * Stop a configured device. + * + * @param dev + * DMA device pointer + * + * @return + * Return 0 on success + */ +typedef int (*dmadev_stop_t)(struct rte_dmadev *dev); + +/** + * Close a configured device. + * + * @param dev + * DMA device pointer + * + * @return + * Return 0 on success + */ +typedef int (*dmadev_close_t)(struct rte_dmadev *dev); + +/** + * Reset a configured device. + * + * @param dev + * DMA device pointer + * + * @return + * 0 for success + * !0 for failure + */ +typedef int (*dmadev_reset_t)(struct rte_dmadev *dev); + +/** + * Enqueue a fill operation onto the DMA device + * + * This queues up a fill operation to be performed by hardware, but does not + * trigger hardware to begin that operation. + * + * @param dev + * DMA device pointer. + * @param pattern + * The pattern to populate the destination buffer with. + * @param dst + * The address of the destination buffer. + * @param len + * The length of the destination buffer. + * @param op_handle + * An opaque handle for this operation, may be returned when completed or + * completed_error. + * + * @return + * Number of operations enqueued, either 0 or 1 + */ +typedef int (*dmadev_fill_t)(struct rte_dmadev *dev, + uint64_t pattern, rte_iova_t dst, + uint32_t len, uintptr_t op_handle); + +/** + * Enqueue a copy operation onto the DMA device. + * + * This queues up a copy operation to be performed by hardware, but does not + * trigger hardware to begin that operation. + * + * @param dev + * DMA device pointer. + * @param src + * The address of the source buffer. + * @param dst + * The address of the destination buffer. + * @param len + * The length of the data to be copied. + * @param op_handle + * An opaque handle for this operation, may be returned when completed or + * completed_error. + * + * @return + * Number of operations enqueued, either 0 or 1. + */ +typedef int (*dmadev_copy_t)(struct rte_dmadev *dev, + rte_iova_t src, rte_iova_t dst, + uint32_t len, uintptr_t op_handle); + +/** + * Add a fence to force ordering between operations + * + * This adds a fence to a sequence of operations to enforce ordering, such that + * all operations enqueued before the fence must be completed before operations + * after the fence. + * NOTE: Since this fence may be added as a flag to the last operation enqueued, + * this API may not function correctly when called immediately after an + * "rte_dmadev_perform_ops" call i.e. before any new operations are enqueued. + * + * @param dev + * DMA device pointer. + * + * @return + * - 0: on successful add fence. + * - <0: on failure to add fence. + */ +typedef int (*dmadev_fence_t)(struct rte_dmadev *dev); + +/** + * Trigger hardware to begin performing enqueued operations + * + * This API is used to write the "doorbell" to the hardware to trigger it + * to begin the operations previously enqueued by rte_dmadev_enqueue_xxx() + * + * @param dev + * DMA device pointer. + * + * @return + * - 0: on successful trigger hardware. + * - <0: on failure to trigger hardware. + */ +typedef int (*dmadev_perform_t)(struct rte_dmadev *dev); + +/** + * Returns the number of operations that have been successful completed. + * + * @param dev + * DMA device pointer. + * @param op_handle + * Return the lastest completed operation's opaque handle which passed by fill + * or copy ops. + * NOTE: If handle_enable configuration option for the device was not set, + * this parameter is ignored, and may be NULL. + * + * @return + * -1 on device error, with rte_errno set appropriately and parameters + * unmodified. + * Otherwise number of successful completed operations. + */ +typedef int (*dmadev_completed_t)(struct rte_dmadev *dev, uintptr_t *op_handle); + +/** + * Returns the number of operations that failed to complete. + * + * @param dev_id + * The identifier of the device. + * @param op_handle + * Return the lastest failed operation's opaque handle which passed by fill + * or copy ops. + * NOTE: If handle_enable configuration option for the device was not set, + * this parameter is ignored, and may be NULL. + * + * @return + * The number of failed completed operations (due to some error, e.g. hardware + * errors) + */ +typedef int (*dmadev_completed_error_t)(struct rte_dmadev *dev, + uintptr_t *op_handle); + +/** + * Retrieve a set of statistics from device. + * Note: Being a DMA device, the stats are specific to the device being + * implemented thus represented as xstats. + * + * @param dev + * DMA device pointer + * @param ids + * The stat ids to retrieve + * @param values + * The returned stat values + * @param n + * The number of id values and entries in the values array + * + * @return + * The number of stat values successfully filled into the values array + */ +typedef int (*dmadev_xstats_get_t)(const struct rte_dmadev *dev, + const unsigned int ids[], uint64_t values[], unsigned int n); + +/** + * Resets the statistic values in xstats for the device. + */ +typedef int (*dmadev_xstats_reset_t)(struct rte_dmadev *dev, + const uint32_t ids[], + uint32_t nb_ids); + +/** + * Get names of extended stats of an DMA device + * + * @param dev + * DMA device pointer + * @param xstats_names + * Array of name values to be filled in + * @param size + * Number of values in the xstats_names array + * + * @return + * When size >= the number of stats, return the number of stat values filled + * into the array. + * When size < the number of available stats, return the number of stats + * values, and do not fill in any data into xstats_names. + */ +typedef int (*dmadev_xstats_get_names_t)(const struct rte_dmadev *dev, + struct rte_dmadev_xstats_name *xstats_names, + unsigned int size); + +/** + * Dump internal information + * + * @param dev + * DMA device pointer + * @param f + * A pointer to a file for output + * + * @return + * 0 for success, + * !0 Error + * + */ +typedef int (*dmadev_dump_t)(struct rte_dmadev *dev, FILE *f); + +/** + * Start dmadev selftest + * + * @param dev_id + * The identifier of the device. + * + * @return + * Return 0 on success + */ +typedef int (*dmadev_selftest_t)(uint16_t dev_id); + +/** Dmadevice operations function pointer table */ +struct rte_dmadev_ops { + /**< Get device info. */ + dmadev_info_get_t dev_info_get; + /**< Configure device. */ + dmadev_configure_t dev_configure; + /**< Start device. */ + dmadev_start_t dev_start; + /**< Stop device. */ + dmadev_stop_t dev_stop; + /**< Close device. */ + dmadev_close_t dev_close; + /**< Reset device. */ + dmadev_reset_t dev_reset; + + /**< Enqueue a fill operation onto the DMA device */ + dmadev_fill_t fill; + /**< Enqueue a copy operation onto the DMA device */ + dmadev_copy_t copy; + /**< Add a fence to force ordering between operations */ + dmadev_fence_t fence; + /**< Trigger hardware to begin performing enqueued operations */ + dmadev_perform_t perform; + /**< Returns the number of operations that successful completed */ + dmadev_completed_t completed; + /**< Returns the number of operations that failed to complete */ + dmadev_completed_error_t completed_error; + + /**< Get extended device statistics. */ + dmadev_xstats_get_t xstats_get; + /**< Get names of extended stats. */ + dmadev_xstats_get_names_t xstats_get_names; + /**< Reset the statistics values in xstats. */ + dmadev_xstats_reset_t xstats_reset; + + /* Dump internal information */ + dmadev_dump_t dump; + + /**< Device selftest function */ + dmadev_selftest_t dev_selftest; +}; + +/** + * Allocates a new dmadev slot for an DMA device and returns the pointer + * to that slot for the driver to use. + * + * @param name + * Unique identifier name for each device + * @param socket_id + * Socket to allocate resources on. + * + * @return + * - Slot in the rte_dev_devices array for a new device; + */ +struct rte_dmadev * +rte_dmadev_pmd_allocate(const char *name, int socket_id); + +/** + * Release the specified dmadev device. + * + * @param dev + * The *dmadev* pointer is the address of the *rte_dmadev* structure. + * + * @return + * - 0 on success, negative on error + */ +int +rte_dmadev_pmd_release(struct rte_dmadev *dev); + +#ifdef __cplusplus +} +#endif + +#endif /* _RTE_DMADEV_PMD_H_ */