DPDK patches and discussions
 help / color / mirror / Atom feed
From: Chengwen Feng <fengchengwen@huawei.com>
To: <thomas@monjalon.net>, <ferruh.yigit@intel.com>
Cc: <dev@dpdk.org>, <nipun.gupta@nxp.com>, <hemant.agrawal@nxp.com>,
	<maxime.coquelin@redhat.com>, <honnappa.nagarahalli@arm.com>,
	<jerinj@marvell.com>, <david.marchand@redhat.com>,
	<bruce.richardson@intel.com>, <jerinjacobk@gmail.com>
Subject: [dpdk-dev] [RFC PATCH] dmadev: introduce DMA device library
Date: Tue, 15 Jun 2021 21:22:07 +0800	[thread overview]
Message-ID: <1623763327-30987-1-git-send-email-fengchengwen@huawei.com> (raw)

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 <fengchengwen@huawei.com>
---
 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 <rte_common.h>
+#include <rte_memory.h>
+#include <rte_errno.h>
+#include <rte_compat.h>
+
+/**
+ * @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 <string.h>
+
+#include <rte_dev.h>
+#include <rte_common.h>
+
+#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_ */
-- 
2.8.1


             reply	other threads:[~2021-06-15 13:25 UTC|newest]

Thread overview: 79+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-15 13:22 Chengwen Feng [this message]
2021-06-15 16:38 ` Bruce Richardson
2021-06-16  7:09   ` Morten Brørup
2021-06-16 10:17     ` fengchengwen
2021-06-16 12:09       ` Morten Brørup
2021-06-16 13:06       ` Bruce Richardson
2021-06-16 14:37       ` Jerin Jacob
2021-06-17  9:15         ` Bruce Richardson
2021-06-18  5:52           ` Jerin Jacob
2021-06-18  9:41             ` fengchengwen
2021-06-22 17:25               ` Jerin Jacob
2021-06-23  3:30                 ` fengchengwen
2021-06-23  7:21                   ` Jerin Jacob
2021-06-23  9:37                     ` Bruce Richardson
2021-06-23 11:40                       ` Jerin Jacob
2021-06-23 14:19                         ` Bruce Richardson
2021-06-24  6:49                           ` Jerin Jacob
2021-06-23  9:41                 ` Bruce Richardson
2021-06-23 10:10                   ` Morten Brørup
2021-06-23 11:46                   ` Jerin Jacob
2021-06-23 14:22                     ` Bruce Richardson
2021-06-18  9:55             ` Bruce Richardson
2021-06-22 17:31               ` Jerin Jacob
2021-06-22 19:17                 ` Bruce Richardson
2021-06-23  7:00                   ` Jerin Jacob
2021-06-16  9:41   ` fengchengwen
2021-06-16 17:31     ` Bruce Richardson
2021-06-16 18:08       ` Jerin Jacob
2021-06-16 19:13         ` Bruce Richardson
2021-06-17  7:42           ` Jerin Jacob
2021-06-17  8:00             ` Bruce Richardson
2021-06-18  5:16               ` Jerin Jacob
2021-06-18 10:03                 ` Bruce Richardson
2021-06-22 17:36                   ` Jerin Jacob
2021-06-17  9:48       ` fengchengwen
2021-06-17 11:02         ` Bruce Richardson
2021-06-17 14:18           ` Bruce Richardson
2021-06-18  8:52             ` fengchengwen
2021-06-18  9:30               ` Bruce Richardson
2021-06-22 17:51               ` Jerin Jacob
2021-06-23  3:50                 ` fengchengwen
2021-06-23 11:00                   ` Jerin Jacob
2021-06-23 14:56                   ` Bruce Richardson
2021-06-24 12:19                     ` fengchengwen
2021-06-26  3:59                       ` [dpdk-dev] dmadev discussion summary fengchengwen
2021-06-28 10:00                         ` Bruce Richardson
2021-06-28 11:14                           ` Ananyev, Konstantin
2021-06-28 12:53                             ` Bruce Richardson
2021-07-02 13:31                           ` fengchengwen
2021-07-01 15:01                         ` Jerin Jacob
2021-07-01 16:33                           ` Bruce Richardson
2021-07-02  7:39                             ` Morten Brørup
2021-07-02 10:05                               ` Bruce Richardson
2021-07-02 13:45                           ` fengchengwen
2021-07-02 14:57                             ` Morten Brørup
2021-07-03  0:32                               ` fengchengwen
2021-07-03  8:53                                 ` Morten Brørup
2021-07-03  9:08                                   ` Jerin Jacob
2021-07-03 12:24                                     ` Morten Brørup
2021-07-04  7:43                                       ` Jerin Jacob
2021-07-05 10:28                                         ` Morten Brørup
2021-07-06  7:11                                           ` fengchengwen
2021-07-03  9:45                                   ` fengchengwen
2021-07-03 12:00                                     ` Morten Brørup
2021-07-04  7:34                                       ` Jerin Jacob
2021-07-02  7:07                         ` Liang Ma
2021-07-02 13:59                           ` fengchengwen
2021-06-24  7:03                   ` [dpdk-dev] [RFC PATCH] dmadev: introduce DMA device library Jerin Jacob
2021-06-24  7:59                     ` Morten Brørup
2021-06-24  8:05                       ` Jerin Jacob
2021-06-23  5:34       ` Hu, Jiayu
2021-06-23 11:07         ` Jerin Jacob
2021-06-16  2:17 ` Wang, Haiyue
2021-06-16  8:04   ` Bruce Richardson
2021-06-16  8:16     ` Wang, Haiyue
2021-06-16 12:14 ` David Marchand
2021-06-16 13:11   ` Bruce Richardson
2021-06-16 16:48     ` Honnappa Nagarahalli
2021-06-16 19:10       ` Bruce Richardson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1623763327-30987-1-git-send-email-fengchengwen@huawei.com \
    --to=fengchengwen@huawei.com \
    --cc=bruce.richardson@intel.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=hemant.agrawal@nxp.com \
    --cc=honnappa.nagarahalli@arm.com \
    --cc=jerinj@marvell.com \
    --cc=jerinjacobk@gmail.com \
    --cc=maxime.coquelin@redhat.com \
    --cc=nipun.gupta@nxp.com \
    --cc=thomas@monjalon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).