add dmadev driver for idxd devices
Subsystems (3)
cover add dmadev driver for idxd devices
This patchset adds a dmadev driver and associated documentation to support Intel Data Streaming Accelerator devices. This driver is intended to ultimately replace the current IDXD part of the IOAT rawdev driver.
NOTE: This patchset has several dependencies:
- v16 of the dmadev set [1]
- rfc of the dmadev test suite [2]
[1] http://patches.dpdk.org/project/dpdk/list/?series=18391
[2] http://patches.dpdk.org/project/dpdk/list/?series=18477
Bruce Richardson (1):
raw/ioat: only build if dmadev not present
Conor Walsh (1):
dma/idxd: move dpdk_idxd_cfg.py from raw to dma
Kevin Laatz (11):
doc: initial commit for dmadevs section dma/idxd: add skeleton for VFIO based DSA device dma/idxd: add bus device probing
dma/idxd: create dmadev instances on bus probe dma/idxd: create dmadev instances on pci probe dma/idxd: add datapath structures
dma/idxd: add configure and info_get functions dma/idxd: add start and stop functions for pci devices dma/idxd: add data-path job submission functions dma/idxd: add data-path job completion functions dma/idxd: add operation statistic tracking
MAINTAINERS | 10 + doc/guides/dmadevs/idxd.rst | 255 +++++++++++ doc/guides/dmadevs/index.rst | 14 + doc/guides/index.rst | 1 + doc/guides/rel_notes/release_21_11.rst | 5 + drivers/dma/idxd/dpdk_idxd_cfg.py | 117 +++++ drivers/dma/idxd/idxd_bus.c | 375 ++++++++++++++++ drivers/dma/idxd/idxd_common.c | 571 +++++++++++++++++++++++++ drivers/dma/idxd/idxd_hw_defs.h | 130 ++++++ drivers/dma/idxd/idxd_internal.h | 102 +++++ drivers/dma/idxd/idxd_pci.c | 372 ++++++++++++++++ drivers/dma/idxd/meson.build | 10 + drivers/dma/idxd/version.map | 3 + drivers/dma/meson.build | 1 + drivers/raw/ioat/dpdk_idxd_cfg.py | 118 +---- drivers/raw/ioat/meson.build | 23 +- 16 files changed, 1987 insertions(+), 120 deletions(-) create mode 100644 doc/guides/dmadevs/idxd.rst create mode 100644 doc/guides/dmadevs/index.rst create mode 100755 drivers/dma/idxd/dpdk_idxd_cfg.py create mode 100644 drivers/dma/idxd/idxd_bus.c create mode 100644 drivers/dma/idxd/idxd_common.c create mode 100644 drivers/dma/idxd/idxd_hw_defs.h create mode 100644 drivers/dma/idxd/idxd_internal.h create mode 100644 drivers/dma/idxd/idxd_pci.c create mode 100644 drivers/dma/idxd/meson.build create mode 100644 drivers/dma/idxd/version.map mode change 100755 => 120000 drivers/raw/ioat/dpdk_idxd_cfg.py
Signature · 1 line
2.30.2
PATCH 1/13 raw/ioat: only build if dmadev not present
From: Bruce Richardson <[email protected]>
Only build the rawdev IDXD/IOAT drivers if the dmadev drivers are not present.
--- drivers/raw/ioat/meson.build | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-)
drivers/raw/ioat/meson.build +20 -3
@@ -2,14 +2,31 @@ # Copyright 2019 Intel Corporation build = dpdk_conf.has('RTE_ARCH_X86') +# only use ioat rawdev driver if we don't have the equivalent dmadev ones +if not dpdk_conf.has('RTE_DMA_IDXD') and not dpdk_conf.has('RTE_DMA_IOAT') + build = false + subdir_done() +endif + reason = 'only supported on x86' sources = files( - 'idxd_bus.c', - 'idxd_pci.c', 'ioat_common.c', - 'ioat_rawdev.c', 'ioat_rawdev_test.c', ) + +if not dpdk_conf.has('RTE_DMA_IDXD') + sources += files( + 'idxd_bus.c', + 'idxd_pci.c', + ) +endif + +if not dpdk_conf.has('RTE_DMA_IOAT') + sources += files ( + 'ioat_rawdev.c', + ) +endif + deps += ['bus_pci', 'mbuf', 'rawdev'] headers = files( 'rte_ioat_rawdev.h',
Signature · 1 line
2.30.2
PATCH 2/13 doc: initial commit for dmadevs section
In reply to Kevin LaatzAdd new section to the programmer's guide for dmadev devices.
--- doc/guides/dmadevs/index.rst | 14 ++++++++++++++ doc/guides/index.rst | 1 + 2 files changed, 15 insertions(+) create mode 100644 doc/guides/dmadevs/index.rst
doc/guides/dmadevs/index.rst new file +14 -0
@@ -0,0 +1,14 @@ +.. SPDX-License-Identifier: BSD-3-Clause + Copyright(c) 2021 Intel Corporation. + +DMA Device Drivers +================== + +The following are a list of DMA device PMDs, which can be used from an +application through DMAdev API. + +.. toctree:: + :maxdepth: 2 + :numbered: + + idxd
doc/guides/index.rst +1 -0
@@ -19,6 +19,7 @@ DPDK documentation bbdevs/index cryptodevs/index compressdevs/index + dmadevs/index vdpadevs/index regexdevs/index eventdevs/index
Signature · 1 line
2.30.2
PATCH 3/13 dma/idxd: add skeleton for VFIO based DSA device
In reply to Kevin LaatzAdd the basic device probe/remove skeleton code for DSA device bound to the vfio pci driver. Relevant documentation and MAINTAINERS update also included.
--- MAINTAINERS | 10 +++++ doc/guides/dmadevs/idxd.rst | 58 ++++++++++++++++++++++++++ doc/guides/rel_notes/release_21_11.rst | 5 +++ drivers/dma/idxd/idxd_internal.h | 27 ++++++++++++ drivers/dma/idxd/idxd_pci.c | 55 ++++++++++++++++++++++++ drivers/dma/idxd/meson.build | 7 ++++ drivers/dma/idxd/version.map | 3 ++ drivers/dma/meson.build | 1 + 8 files changed, 166 insertions(+) create mode 100644 doc/guides/dmadevs/idxd.rst create mode 100644 drivers/dma/idxd/idxd_internal.h create mode 100644 drivers/dma/idxd/idxd_pci.c create mode 100644 drivers/dma/idxd/meson.build create mode 100644 drivers/dma/idxd/version.map
MAINTAINERS +10 -0
@@ -1199,6 +1199,16 @@ F: doc/guides/compressdevs/zlib.rst F: doc/guides/compressdevs/features/zlib.ini +DMAdev Drivers +-------------- + +Intel IDXD - EXPERIMENTAL +M: Bruce Richardson <[email protected]> +M: Kevin Laatz <[email protected]> +F: drivers/dma/idxd/ +F: doc/guides/dmadevs/idxd.rst + + RegEx Drivers -------------
doc/guides/dmadevs/idxd.rst new file +58 -0
58 lines not on this page · raw message
doc/guides/rel_notes/release_21_11.rst +5 -0
@@ -61,6 +61,11 @@ New Features provisioning of hardware and software DMA poll mode drivers, defining generic APIs which support a number of different DMA operations. +* **Added IDXD dmadev driver implementation.** + + The IDXD dmadev driver provide device drivers for the Intel DSA devices. + This device driver can be used through the generic dmadev API. + Removed Items -------------
drivers/dma/idxd/idxd_internal.h new file +27 -0
@@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright 2021 Intel Corporation +*/ + +#ifndef _IDXD_INTERNAL_H_ +#define _IDXD_INTERNAL_H_ + +/** +* @file idxd_internal.h +* +* Internal data structures for the idxd/DSA driver for dmadev +* +* @warning +* @b EXPERIMENTAL: these structures and APIs may change without prior notice +*/ + +extern int idxd_pmd_logtype; + +#define IDXD_PMD_LOG(level, fmt, args...) rte_log(RTE_LOG_ ## level, \ + idxd_pmd_logtype, "IDXD: %s(): " fmt "\n", __func__, ##args) + +#define IDXD_PMD_DEBUG(fmt, args...) IDXD_PMD_LOG(DEBUG, fmt, ## args) +#define IDXD_PMD_INFO(fmt, args...) IDXD_PMD_LOG(INFO, fmt, ## args) +#define IDXD_PMD_ERR(fmt, args...) IDXD_PMD_LOG(ERR, fmt, ## args) +#define IDXD_PMD_WARN(fmt, args...) IDXD_PMD_LOG(WARNING, fmt, ## args) + +#endif /* _IDXD_INTERNAL_H_ */
drivers/dma/idxd/idxd_pci.c new file +55 -0
55 lines not on this page · raw message
drivers/dma/idxd/meson.build new file +7 -0
@@ -0,0 +1,7 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2021 Intel Corporation + +deps += ['bus_pci'] +sources = files( + 'idxd_pci.c' +)
drivers/dma/idxd/version.map new file +3 -0
@@ -0,0 +1,3 @@ +DPDK_21 { + local: *; +};
drivers/dma/meson.build +1 -0
@@ -6,6 +6,7 @@ if is_windows endif drivers = [ + 'idxd', 'skeleton', ] std_deps = ['dmadev']
Signature · 1 line
2.30.2
PATCH 4/13 dma/idxd: add bus device probing
In reply to Kevin LaatzAdd the basic device probing for DSA devices bound to the IDXD kernel driver. These devices can be configured via sysfs and made available to DPDK if they are found during bus scan. Relevant documentation is included.
--- doc/guides/dmadevs/idxd.rst | 64 +++++++ drivers/dma/idxd/idxd_bus.c | 351 +++++++++++++++++++++++++++++++++++ drivers/dma/idxd/meson.build | 1 + 3 files changed, 416 insertions(+) create mode 100644 drivers/dma/idxd/idxd_bus.c
doc/guides/dmadevs/idxd.rst +64 -0
@@ -32,6 +32,56 @@ target platform is x86-based. No additional compilation steps are necessary. Device Setup ------------- +Intel\ |reg| DSA devices can use the IDXD kernel driver or DPDK-supported drivers, +such as ``vfio-pci``. Both are supported by the IDXD PMD. + +Intel\ |reg| DSA devices using IDXD kernel driver +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +To use an Intel\ |reg| DSA device bound to the IDXD kernel driver, the device must first be configured. +The `accel-config <https://github.com/intel/idxd-config>`_ utility library can be used for configuration. + +.. note:: + The device configuration can also be done by directly interacting with the sysfs nodes. + An example of how this may be done can be seen in the script ``dpdk_idxd_cfg.py`` + included in the driver source directory. + +There are some mandatory configuration steps before being able to use a device with an application. +The internal engines, which do the copies or other operations, +and the work-queues, which are used by applications to assign work to the device, +need to be assigned to groups, and the various other configuration options, +such as priority or queue depth, need to be set for each queue. + +To assign an engine to a group:: + + $ accel-config config-engine dsa0/engine0.0 --group-id=0 + $ accel-config config-engine dsa0/engine0.1 --group-id=1 + +To assign work queues to groups for passing descriptors to the engines a similar accel-config command can be used. +However, the work queues also need to be configured depending on the use case. +Some configuration options include: + +* mode (Dedicated/Shared): Indicates whether a WQ may accept jobs from multiple queues simultaneously. +* priority: WQ priority between 1 and 15. Larger value means higher priority. +* wq-size: the size of the WQ. Sum of all WQ sizes must be less that the total-size defined by the device. +* type: WQ type (kernel/mdev/user). Determines how the device is presented. +* name: identifier given to the WQ. + +Example configuration for a work queue:: + + $ accel-config config-wq dsa0/wq0.0 --group-id=0 \ + --mode=dedicated --priority=10 --wq-size=8 \ + --type=user --name=dpdk_app1 + +Once the devices have been configured, they need to be enabled:: + + $ accel-config enable-device dsa0 + $ accel-config enable-wq dsa0/wq0.0 + +Check the device configuration:: + + $ accel-config list + Devices using VFIO/UIO drivers ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -56,3 +106,17 @@ If fewer workqueues are required, then the ``max_queues`` parameter may be passe the device driver on the EAL commandline, via the ``allowlist`` or ``-a`` flag e.g.:: $ dpdk-test -a <b:d:f>,max_queues=4 + +For devices bound to the IDXD kernel driver, +the DPDK IDXD driver will automatically perform a scan for available workqueues +to use. Any workqueues found listed in ``/dev/dsa`` on the system will be checked +in ``/sys``, and any which have ``dpdk_`` prefix in their name will be automatically +probed by the driver to make them available to the application. +Alternatively, to support use by multiple DPDK processes simultaneously, +the value used as the DPDK ``--file-prefix`` parameter may be used as a workqueue +name prefix, instead of ``dpdk_``, allowing each DPDK application instance to only +use a subset of configured queues. + +Once probed successfully, irrespective of kernel driver, the device will appear as a ``dmadev``, +that is a "DMA device type" inside DPDK, and can be accessed using APIs from the +``rte_dmadev`` library.
drivers/dma/idxd/idxd_bus.c new file +351 -0
351 lines not on this page · raw message
drivers/dma/idxd/meson.build +1 -0
@@ -3,5 +3,6 @@ deps += ['bus_pci'] sources = files( + 'idxd_bus.c', 'idxd_pci.c' )
Signature · 1 line
2.30.2
PATCH 5/13 dma/idxd: create dmadev instances on bus probe
In reply to Kevin LaatzWhen a suitable device is found during the bus scan/probe, create a dmadev instance for each HW queue. Internal structures required for device creation are also added.
--- drivers/dma/idxd/idxd_bus.c | 20 ++++++++- drivers/dma/idxd/idxd_common.c | 75 ++++++++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 40 +++++++++++++++++ drivers/dma/idxd/meson.build | 1 + 4 files changed, 135 insertions(+), 1 deletion(-) create mode 100644 drivers/dma/idxd/idxd_common.c
drivers/dma/idxd/idxd_bus.c +19 -1
@@ -84,6 +84,18 @@ dsa_get_sysfs_path(void)return path ? path :DSA_SYSFS_PATH ; } +static int +idxd_dev_close (struct rte_dmadev *dev) +{ +struct idxd_dmadev *idxd = dev->data->dev_private; +munmap (idxd->portal,0x1000 ); +return 0 ; +} + +static const struct rte_dmadev_ops idxd_vdev_ops = { + .dev_close = idxd_dev_close, +}; +static void *idxd_vdev_mmap_wq (struct rte_dsa_device *dev) {
@@ -205,7 +217,7 @@ idxd_probe_dsa(struct rte_dsa_device *dev)return -1 ; idxd.max_batch_size = ret; idxd.qid = dev->addr.wq_id; - idxd.u.vdev.dsa_id = dev->addr.device_id; + idxd.u.bus.dsa_id = dev->addr.device_id; idxd.sva_support =1 ; idxd.portal =idxd_vdev_mmap_wq (dev);
@@ -214,6 +226,12 @@ idxd_probe_dsa(struct rte_dsa_device *dev)return -ENOENT ; } + ret =idxd_dmadev_create (dev->wq_name, &dev->device, &idxd, &idxd_vdev_ops); +if (ret) { +IDXD_PMD_ERR ("Failed to create rawdev %s" , dev->wq_name); +return ret; + } +return 0 ; }
drivers/dma/idxd/idxd_common.c new file +75 -0
75 lines not on this page · raw message
drivers/dma/idxd/idxd_internal.h +40 -0
@@ -24,4 +24,44 @@ extern int idxd_pmd_logtype; #define IDXD_PMD_ERR(fmt, args...) IDXD_PMD_LOG(ERR, fmt, ## args) #define IDXD_PMD_WARN(fmt, args...) IDXD_PMD_LOG(WARNING, fmt, ## args) +struct idxd_dmadev { +/* counters to track the batches */ +unsigned short max_batches; +unsigned short batch_idx_read; +unsigned short batch_idx_write; + +/* track descriptors and handles */ +unsigned short desc_ring_mask; +unsigned short ids_avail;/* handles for ops completed */ +unsigned short ids_returned;/* the read pointer for hdls/desc rings */ +unsigned short batch_start;/* start+size == write pointer for hdls/desc */ +unsigned short batch_size; + +void *portal;/* address to write the batch descriptor */ + +struct idxd_completion *batch_comp_ring; +unsigned short *batch_idx_ring;/* store where each batch ends */ + +struct rte_dmadev_stats stats; + +rte_iova_t batch_iova;/* base address of the batch comp ring */ +rte_iova_t desc_iova;/* base address of desc ring, needed for completions */ + +unsigned short max_batch_size; + +struct rte_dmadev *dmadev; +struct rte_dmadev_vchan_conf qcfg; +uint8_t sva_support; +uint8_t qid; + +union { +struct { +unsigned int dsa_id; + } bus; + } u; +}; + +int idxd_dmadev_create (const char *name,struct rte_device *dev, +const struct idxd_dmadev *base_idxd,const struct rte_dmadev_ops *ops); +#endif /* _IDXD_INTERNAL_H_ */
drivers/dma/idxd/meson.build +1 -0
@@ -4,5 +4,6 @@ deps += ['bus_pci'] sources = files( 'idxd_bus.c', + 'idxd_common.c', 'idxd_pci.c' )
Signature · 1 line
2.30.2
PATCH 6/13 dma/idxd: create dmadev instances on pci probe
In reply to Kevin LaatzWhen a suitable device is found during the PCI probe, create a dmadev instance for each HW queue. HW definitions required are also included.
--- drivers/dma/idxd/idxd_hw_defs.h | 71 ++++++++ drivers/dma/idxd/idxd_internal.h | 14 ++ drivers/dma/idxd/idxd_pci.c | 268 ++++++++++++++++++++++++++++++- 3 files changed, 350 insertions(+), 3 deletions(-) create mode 100644 drivers/dma/idxd/idxd_hw_defs.h
drivers/dma/idxd/idxd_hw_defs.h new file +71 -0
@@ -0,0 +1,71 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright 2021 Intel Corporation +*/ + +#ifndef _IDXD_HW_DEFS_H_ +#define _IDXD_HW_DEFS_H_ + +/*** Definitions for Intel(R) Data Streaming Accelerator ***/ + +#define IDXD_CMD_SHIFT 20 +enum rte_idxd_cmds { + idxd_enable_dev =1 , + idxd_disable_dev, + idxd_drain_all, + idxd_abort_all, + idxd_reset_device, + idxd_enable_wq, + idxd_disable_wq, + idxd_drain_wq, + idxd_abort_wq, + idxd_reset_wq, +}; + +/* General bar0 registers */ +struct rte_idxd_bar0 { + uint32_t __rte_cache_aligned version; /* offset 0x00 */ + uint64_t __rte_aligned(0x10) gencap; /* offset 0x10 */ + uint64_t __rte_aligned(0x10) wqcap; /* offset 0x20 */ + uint64_t __rte_aligned(0x10) grpcap; /* offset 0x30 */ + uint64_t __rte_aligned(0x08) engcap; /* offset 0x38 */ + uint64_t __rte_aligned(0x10) opcap; /* offset 0x40 */ + uint64_t __rte_aligned(0x20) offsets[2]; /* offset 0x60 */ + uint32_t __rte_aligned(0x20) gencfg; /* offset 0x80 */ + uint32_t __rte_aligned(0x08) genctrl; /* offset 0x88 */ + uint32_t __rte_aligned(0x10) gensts; /* offset 0x90 */ + uint32_t __rte_aligned(0x08) intcause; /* offset 0x98 */ + uint32_t __rte_aligned(0x10) cmd; /* offset 0xA0 */ + uint32_t __rte_aligned(0x08) cmdstatus; /* offset 0xA8 */ + uint64_t __rte_aligned(0x20) swerror[4]; /* offset 0xC0 */ +}; + +/* workqueue config is provided by array of uint32_t. */ +enum rte_idxd_wqcfg { + wq_size_idx,/* size is in first 32-bit value */ + wq_threshold_idx,/* WQ threshold second 32-bits */ + wq_mode_idx,/* WQ mode and other flags */ + wq_sizes_idx,/* WQ transfer and batch sizes */ + wq_occ_int_idx,/* WQ occupancy interrupt handle */ + wq_occ_limit_idx,/* WQ occupancy limit */ + wq_state_idx,/* WQ state and occupancy state */ +}; + +#define WQ_MODE_SHARED 0 +#define WQ_MODE_DEDICATED 1 +#define WQ_PRIORITY_SHIFT 4 +#define WQ_BATCH_SZ_SHIFT 5 +#define WQ_STATE_SHIFT 30 +#define WQ_STATE_MASK 0x3 + +struct rte_idxd_grpcfg { + uint64_t grpwqcfg[4] __rte_cache_aligned; /* 64-byte register set */ +uint64_t grpengcfg;/* offset 32 */ +uint32_t grpflags;/* offset 40 */ +}; + +#define GENSTS_DEV_STATE_MASK 0x03 +#define CMDSTATUS_ACTIVE_SHIFT 31 +#define CMDSTATUS_ACTIVE_MASK (1 << 31) +#define CMDSTATUS_ERR_MASK 0xFF + +#endif
drivers/dma/idxd/idxd_internal.h +14 -0
@@ -5,6 +5,8 @@#ifndef _IDXD_INTERNAL_H_#define _IDXD_INTERNAL_H_ +#include "idxd_hw_defs.h" +/** * @file idxd_internal.h *
@@ -24,6 +26,16 @@ extern int idxd_pmd_logtype; #define IDXD_PMD_ERR(fmt, args...) IDXD_PMD_LOG(ERR, fmt, ## args) #define IDXD_PMD_WARN(fmt, args...) IDXD_PMD_LOG(WARNING, fmt, ## args) +struct idxd_pci_common { +rte_spinlock_t lk; + +uint8_t wq_cfg_sz; +volatile struct rte_idxd_bar0 *regs; +volatile uint32_t *wq_regs_base; +volatile struct rte_idxd_grpcfg *grp_regs; +volatile void *portals; +}; +struct idxd_dmadev {/* counters to track the batches */ unsigned short max_batches;
@@ -58,6 +70,8 @@ struct idxd_dmadev {struct {unsigned int dsa_id; } bus; + +struct idxd_pci_common *pci; } u; };
drivers/dma/idxd/idxd_pci.c +265 -3
295 lines not on this page · raw message
Signature · 1 line
2.30.2
PATCH 7/13 dma/idxd: add datapath structures
In reply to Kevin LaatzAdd data structures required for the data path for IDXD devices.
--- drivers/dma/idxd/idxd_bus.c | 1 + drivers/dma/idxd/idxd_common.c | 33 ++++++++++++++++++ drivers/dma/idxd/idxd_hw_defs.h | 59 ++++++++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 3 ++ drivers/dma/idxd/idxd_pci.c | 2 +- 5 files changed, 97 insertions(+), 1 deletion(-)
drivers/dma/idxd/idxd_bus.c +1 -0
@@ -94,6 +94,7 @@ idxd_dev_close(struct rte_dmadev *dev)static const struct rte_dmadev_ops idxd_vdev_ops = { .dev_close = idxd_dev_close, + .dev_dump = idxd_dump, }; static void *
drivers/dma/idxd/idxd_common.c +33 -0
@@ -10,6 +10,35 @@#define IDXD_PMD_NAME_STR "dmadev_idxd" +int +idxd_dump (const struct rte_dmadev *dev,FILE *f) +{ +struct idxd_dmadev *idxd = dev->dev_private; +unsigned int i; + +fprintf (f,"== Private Data ==\n" ); +fprintf (f," Portal: %p\n" , idxd->portal); +fprintf (f," Config: { ring_size: %u }\n" , + idxd->qcfg.nb_desc); +fprintf (f," Batch ring (sz = %u, max_batches = %u):\n\t" , + idxd->max_batches +1 , idxd->max_batches); +for (i =0 ; i <= idxd->max_batches; i++) { +fprintf (f," %u " , idxd->batch_idx_ring[i]); +if (i == idxd->batch_idx_read && i == idxd->batch_idx_write) +fprintf (f,"[rd ptr, wr ptr] " ); +else if (i == idxd->batch_idx_read) +fprintf (f,"[rd ptr] " ); +else if (i == idxd->batch_idx_write) +fprintf (f,"[wr ptr] " ); +if (i == idxd->max_batches) +fprintf (f,"\n" ); + } + +fprintf (f," Curr batch: start = %u, size = %u\n" , idxd->batch_start, idxd->batch_size); +fprintf (f," IDS: avail = %u, returned: %u\n" , idxd->ids_avail, idxd->ids_returned); +return 0 ; +} + int idxd_dmadev_create(const char *name, struct rte_device *dev, const struct idxd_dmadev *base_idxd,
@@ -19,6 +48,10 @@ idxd_dmadev_create(const char *name, struct rte_device *dev,struct rte_dmadev *dmadev =NULL ;int ret =0 ; +RTE_BUILD_BUG_ON (sizeof (struct idxd_hw_desc ) !=64 ); +RTE_BUILD_BUG_ON (offsetof(struct idxd_hw_desc , size) !=32 ); +RTE_BUILD_BUG_ON (sizeof (struct idxd_completion ) !=32 ); +if (!name) {IDXD_PMD_ERR ("Invalid name of the device!" ); ret = -EINVAL ;
drivers/dma/idxd/idxd_hw_defs.h +59 -0
65 lines not on this page · raw message
drivers/dma/idxd/idxd_internal.h +3 -0
@@ -37,6 +37,8 @@ struct idxd_pci_common { };struct idxd_dmadev { +struct idxd_hw_desc *desc_ring; +/* counters to track the batches */ unsigned short max_batches;unsigned short batch_idx_read;
@@ -77,5 +79,6 @@ struct idxd_dmadev {int idxd_dmadev_create (const char *name,struct rte_device *dev,const struct idxd_dmadev *base_idxd,const struct rte_dmadev_ops *ops); +int idxd_dump (const struct rte_dmadev *dev,FILE *f);#endif /* _IDXD_INTERNAL_H_ */
drivers/dma/idxd/idxd_pci.c +1 -1
@@ -60,7 +60,7 @@ idxd_is_wq_enabled(struct idxd_dmadev *idxd) }static const struct rte_dmadev_ops idxd_pci_ops = { - + .dev_dump = idxd_dump, };/* each portal uses 4 x 4k pages */
Signature · 1 line
2.30.2
PATCH 8/13 dma/idxd: add configure and info_get functions
In reply to Kevin LaatzAdd functions for device configuration. The info_get function is included here since it can be useful for checking successful configuration.
--- doc/guides/dmadevs/idxd.rst | 33 ++++++++++++++++ drivers/dma/idxd/idxd_bus.c | 3 ++ drivers/dma/idxd/idxd_common.c | 67 ++++++++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 5 +++ drivers/dma/idxd/idxd_pci.c | 3 ++ 5 files changed, 111 insertions(+)
doc/guides/dmadevs/idxd.rst +33 -0
@@ -120,3 +120,36 @@ use a subset of configured queues. Once probed successfully, irrespective of kernel driver, the device will appear as a ``dmadev``, that is a "DMA device type" inside DPDK, and can be accessed using APIs from the ``rte_dmadev`` library. + +Using IDXD DMAdev Devices +-------------------------- + +To use the devices from an application, the dmadev API can be used. + +Getting Device Information +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Basic information about each dmadev device can be queried using the +``rte_dmadev_info_get()`` API. This will return basic device information such as +the ``rte_device`` structure, device capabilities and other device specific values. + +Device Configuration +~~~~~~~~~~~~~~~~~~~~~ + +Configuring an IDXD dmadev device is done using the ``rte_dmadev_configure()`` and +``rte_dmadev_vchan_setup`` APIs. The configurations are passed to these APIs using +the ``rte_dmadev_conf`` and ``rte_dmadev_vchan_conf`` structures, respectively. For +example, these can be used to configure the number of ``vchans`` per device, the +ring size, etc. The ring size must be a power of two, between 64 and 4096. + +The following code shows how the device is configured in +``test_dmadev.c``: + +.. literalinclude:: ../../../app/test/test_dmadev.c + :language: c + :start-after: Setup of the dmadev device. 8< + :end-before: >8 End of setup of the dmadev device. + :dedent: 1 + +Once configured, the device can then be made ready for use by calling the +``rte_dmadev_start()`` API.
drivers/dma/idxd/idxd_bus.c +3 -0
@@ -95,6 +95,9 @@ idxd_dev_close(struct rte_dmadev *dev)static const struct rte_dmadev_ops idxd_vdev_ops = { .dev_close = idxd_dev_close, .dev_dump = idxd_dump, + .dev_configure = idxd_configure, + .vchan_setup = idxd_vchan_setup, + .dev_info_get = idxd_info_get, }; static void *
drivers/dma/idxd/idxd_common.c +67 -0
73 lines not on this page · raw message
drivers/dma/idxd/idxd_internal.h +5 -0
@@ -80,5 +80,10 @@ struct idxd_dmadev {int idxd_dmadev_create (const char *name,struct rte_device *dev,const struct idxd_dmadev *base_idxd,const struct rte_dmadev_ops *ops);int idxd_dump (const struct rte_dmadev *dev,FILE *f); +int idxd_configure (struct rte_dmadev *dev,const struct rte_dmadev_conf *dev_conf); +int idxd_vchan_setup (struct rte_dmadev *dev,uint16_t vchan, +const struct rte_dmadev_vchan_conf *qconf); +int idxd_info_get (const struct rte_dmadev *dev,struct rte_dmadev_info *dev_info, +uint32_t size);#endif /* _IDXD_INTERNAL_H_ */
drivers/dma/idxd/idxd_pci.c +3 -0
@@ -61,6 +61,9 @@ idxd_is_wq_enabled(struct idxd_dmadev *idxd)static const struct rte_dmadev_ops idxd_pci_ops = { .dev_dump = idxd_dump, + .dev_configure = idxd_configure, + .vchan_setup = idxd_vchan_setup, + .dev_info_get = idxd_info_get, };/* each portal uses 4 x 4k pages */
Signature · 1 line
2.30.2
PATCH 9/13 dma/idxd: add start and stop functions for pci devices
In reply to Kevin LaatzAdd device start/stop functions for DSA devices bound to vfio. For devices bound to the IDXD kernel driver, these are not required since the IDXD kernel driver takes care of this.
--- drivers/dma/idxd/idxd_pci.c | 52 +++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+)
drivers/dma/idxd/idxd_pci.c +52 -0
@@ -59,11 +59,63 @@ idxd_is_wq_enabled(struct idxd_dmadev *idxd)return ((state >>WQ_STATE_SHIFT ) &WQ_STATE_MASK ) ==0x1 ; } +static int +idxd_pci_dev_stop (struct rte_dmadev *dev) +{ +struct idxd_dmadev *idxd = dev->dev_private; +uint8_t err_code; + +if (!idxd_is_wq_enabled (idxd)) { +IDXD_PMD_ERR ("Work queue %d already disabled" , idxd->qid); +return -EALREADY ; + } + + err_code =idxd_pci_dev_command (idxd, idxd_disable_wq); +if (err_code ||idxd_is_wq_enabled (idxd)) { +IDXD_PMD_ERR ("Failed disabling work queue %d, error code: %#x" , + idxd->qid, err_code); +return -err_code; + } +IDXD_PMD_DEBUG ("Work queue %d disabled OK" , idxd->qid); + +return 0 ; +} + +static int +idxd_pci_dev_start (struct rte_dmadev *dev) +{ +struct idxd_dmadev *idxd = dev->dev_private; +uint8_t err_code; + +if (idxd_is_wq_enabled (idxd)) { +IDXD_PMD_WARN ("WQ %d already enabled" , idxd->qid); +return 0 ; + } + +if (idxd->desc_ring ==NULL ) { +IDXD_PMD_ERR ("WQ %d has not been fully configured" , idxd->qid); +return -EINVAL ; + } + + err_code =idxd_pci_dev_command (idxd, idxd_enable_wq); +if (err_code || !idxd_is_wq_enabled (idxd)) { +IDXD_PMD_ERR ("Failed enabling work queue %d, error code: %#x" , + idxd->qid, err_code); +return err_code ==0 ?-1 : err_code; + } + +IDXD_PMD_DEBUG ("Work queue %d enabled OK" , idxd->qid); + +return 0 ; +} +static const struct rte_dmadev_ops idxd_pci_ops = { .dev_dump = idxd_dump, .dev_configure = idxd_configure, .vchan_setup = idxd_vchan_setup, .dev_info_get = idxd_info_get, + .dev_start = idxd_pci_dev_start, + .dev_stop = idxd_pci_dev_stop, };/* each portal uses 4 x 4k pages */
Signature · 1 line
2.30.2
PATCH 10/13 dma/idxd: add data-path job submission functions
In reply to Kevin LaatzAdd data path functions for enqueuing and submitting operations to DSA devices.
--- doc/guides/dmadevs/idxd.rst | 64 ++++++++++++++ drivers/dma/idxd/idxd_common.c | 138 +++++++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 5 ++ drivers/dma/idxd/meson.build | 1 + 4 files changed, 208 insertions(+)
doc/guides/dmadevs/idxd.rst +64 -0
@@ -153,3 +153,67 @@ The following code shows how the device is configured in Once configured, the device can then be made ready for use by calling the ``rte_dmadev_start()`` API. + +Performing Data Copies +~~~~~~~~~~~~~~~~~~~~~~~ + +To perform data copies using IDXD dmadev devices, descriptors should be enqueued +using the ``rte_dmadev_copy()`` API. The HW can be triggered to perform the copy +in two ways, either via a ``RTE_DMA_OP_FLAG_SUBMIT`` flag or by calling +``rte_dmadev_submit()``. Once copies have been completed, the completion will +be reported back when the application calls ``rte_dmadev_completed()`` or +``rte_dmadev_completed_status()``. The latter will also report the status of each +completed operation. + +The ``rte_dmadev_copy()`` function enqueues a single copy to the device ring for +copying at a later point. The parameters to that function include the IOVA addresses +of both the source and destination buffers, as well as the length of the copy. + +The ``rte_dmadev_copy()`` function enqueues a copy operation on the device ring. +If the ``RTE_DMA_OP_FLAG_SUBMIT`` flag is set when calling ``rte_dmadev_copy()``, +the device hardware will be informed of the elements. Alternatively, if the flag +is not set, the application need to call the ``rte_dmadev_submit()`` function to +notify the device hardware. Once the device hardware is informed of the elements +enqueued on the ring, and the device will begin to process them. It is expected +that, for efficiency reasons, a burst of operations will be enqueued to the +device via multiple enqueue calls between calls to the ``rte_dmadev_submit()`` +function. + +The following code from demonstrates how to enqueue a burst of copies to the +device and start the hardware processing of them: + +.. code-block:: C + + struct rte_mbuf *srcs[COMP_BURST_SZ], *dsts[COMP_BURST_SZ]; + unsigned int i; + + for (i = 0; i < RTE_DIM(srcs); i++) { + uint64_t *src_data; + + srcs[i] = rte_pktmbuf_alloc(pool); + dsts[i] = rte_pktmbuf_alloc(pool); + src_data = rte_pktmbuf_mtod(srcs[i], uint64_t *); + if (srcs[i] == NULL || dsts[i] == NULL) { + PRINT_ERR("Error allocating buffers\n"); + return -1; + } + + for (j = 0; j < COPY_LEN/sizeof(uint64_t); j++) + src_data[j] = rte_rand(); + + if (rte_dmadev_copy(dev_id, vchan, srcs[i]->buf_iova + srcs[i]->data_off, + dsts[i]->buf_iova + dsts[i]->data_off, COPY_LEN, 0) < 0) { + PRINT_ERR("Error with rte_dmadev_copy for buffer %u\n", i); + return -1; + } + } + rte_dmadev_submit(dev_id, vchan); + +Filling an Area of Memory +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The IDXD driver also has support for the ``fill`` operation, where an area +of memory is overwritten, or filled, with a short pattern of data. +Fill operations can be performed in much the same was as copy operations +described above, just using the ``rte_dmadev_fill()`` function rather than the +``rte_dmadev_copy()`` function.
drivers/dma/idxd/idxd_common.c +138 -0
158 lines not on this page · raw message
drivers/dma/idxd/idxd_internal.h +5 -0
@@ -85,5 +85,10 @@ int idxd_vchan_setup(struct rte_dmadev *dev, uint16_t vchan, const struct rte_dmadev_vchan_conf *qconf);int idxd_info_get (const struct rte_dmadev *dev,struct rte_dmadev_info *dev_info,uint32_t size); +int idxd_enqueue_copy (struct rte_dmadev *dev,uint16_t qid,rte_iova_t src, +rte_iova_t dst,unsigned int length,uint64_t flags); +int idxd_enqueue_fill (struct rte_dmadev *dev,uint16_t qid,uint64_t pattern, +rte_iova_t dst,unsigned int length,uint64_t flags); +int idxd_submit (struct rte_dmadev *dev,uint16_t qid);#endif /* _IDXD_INTERNAL_H_ */
drivers/dma/idxd/meson.build +1 -0
@@ -2,6 +2,7 @@ # Copyright(c) 2021 Intel Corporation deps += ['bus_pci'] +cflags += '-mavx2' # all platforms with idxd HW support AVX sources = files( 'idxd_bus.c', 'idxd_common.c',
Signature · 1 line
2.30.2
PATCH 11/13 dma/idxd: add data-path job completion functions
In reply to Kevin LaatzAdd the data path functions for gathering completed operations.
--- doc/guides/dmadevs/idxd.rst | 25 ++++ drivers/dma/idxd/idxd_common.c | 235 +++++++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 5 + 3 files changed, 265 insertions(+)
doc/guides/dmadevs/idxd.rst +25 -0
@@ -209,6 +209,31 @@ device and start the hardware processing of them: } rte_dmadev_submit(dev_id, vchan); +To retrieve information about completed copies, ``rte_dmadev_completed()`` and +``rte_dmadev_completed_status()`` APIs should be used. ``rte_dmadev_completed()`` +will return the number of completed operations, along with the index of the last +successful completed operation and whether or not an error was encountered. If an +error was encounted, ``rte_dmadev_completed_status()`` must be used to kick the +device off to continue processing operations and also to gather the status of each +individual operations which is filled in to the ``status`` array provided as +parameter by the application. + +The following code shows how to retrieve the number of successfully completed +copies within a burst and then using ``rte_dmadev_completed_status()`` to check +which operation failed and kick off the device to continue processing operations: + +.. code-block:: C + + enum rte_dma_status_code status[COMP_BURST_SZ]; + uint16_t count, idx, status_count; + bool error = 0; + + count = rte_dmadev_completed(dev_id, vchan, COMP_BURST_SZ, &idx, &error); + + if (error){ + status_count = rte_dmadev_completed_status(dev_id, vchan, COMP_BURST_SZ, &idx, status); + } + Filling an Area of Memory ~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/dma/idxd/idxd_common.c +235 -0
247 lines not on this page · raw message
drivers/dma/idxd/idxd_internal.h +5 -0
@@ -90,5 +90,10 @@ int idxd_enqueue_copy(struct rte_dmadev *dev, uint16_t qid, rte_iova_t src,int idxd_enqueue_fill (struct rte_dmadev *dev,uint16_t qid,uint64_t pattern,rte_iova_t dst,unsigned int length,uint64_t flags);int idxd_submit (struct rte_dmadev *dev,uint16_t qid); +uint16_t idxd_completed (struct rte_dmadev *dev,uint16_t qid,uint16_t max_ops, +uint16_t *last_idx,bool *has_error); +uint16_t idxd_completed_status(struct rte_dmadev *dev, uint16_t qid __rte_unused, +uint16_t max_ops,uint16_t *last_idx, +enum rte_dma_status_code *status);#endif /* _IDXD_INTERNAL_H_ */
Signature · 1 line
2.30.2
PATCH 12/13 dma/idxd: add operation statistic tracking
In reply to Kevin LaatzAdd statistic tracking for DSA devices.
--- doc/guides/dmadevs/idxd.rst | 11 +++++++++++ drivers/dma/idxd/idxd_bus.c | 2 ++ drivers/dma/idxd/idxd_common.c | 23 +++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 3 +++ 4 files changed, 39 insertions(+)
doc/guides/dmadevs/idxd.rst +11 -0
@@ -242,3 +242,14 @@ of memory is overwritten, or filled, with a short pattern of data. Fill operations can be performed in much the same was as copy operations described above, just using the ``rte_dmadev_fill()`` function rather than the ``rte_dmadev_copy()`` function. + +Querying Device Statistics +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The statistics from the IDXD dmadev device can be got via the stats functions in +the ``rte_dmadev`` library, i.e. ``rte_dmadev_stats_get()``. The statistics +returned for each device instance are: + +* ``submitted_count`` +* ``completed_fail_count`` +* ``completed_count``
drivers/dma/idxd/idxd_bus.c +2 -0
@@ -98,6 +98,8 @@ static const struct rte_dmadev_ops idxd_vdev_ops = { .dev_configure = idxd_configure, .vchan_setup = idxd_vchan_setup, .dev_info_get = idxd_info_get, + .stats_get = idxd_stats_get, + .stats_reset = idxd_stats_reset, }; static void *
drivers/dma/idxd/idxd_common.c +23 -0
@@ -66,6 +66,8 @@ __submit(struct idxd_dmadev *idxd)if (++idxd->batch_idx_write > idxd->max_batches) idxd->batch_idx_write =0 ; + idxd->stats.submitted += idxd->batch_size; + idxd->batch_start += idxd->batch_size; idxd->batch_size =0 ; idxd->batch_idx_ring[idxd->batch_idx_write] = idxd->batch_start;
@@ -356,6 +358,7 @@ idxd_completed(struct rte_dmadev *dev, uint16_t qid __rte_unused, uint16_t max_o ret += batch; }while (batch >0 && *has_error == false); + idxd->stats.completed += ret; *last_idx = idxd->ids_returned -1 ;return ret; }
@@ -373,6 +376,7 @@ idxd_completed_status(struct rte_dmadev *dev, uint16_t qid __rte_unused, uint16_ ret += batch; }while (batch >0 ); + idxd->stats.completed += ret; *last_idx = idxd->ids_returned -1 ;return ret; }
@@ -406,6 +410,25 @@ idxd_dump(const struct rte_dmadev *dev, FILE *f)return 0 ; } +int +idxd_stats_get(const struct rte_dmadev *dev, uint16_t vchan __rte_unused, +struct rte_dmadev_stats *stats,uint32_t stats_sz) +{ +struct idxd_dmadev *idxd = dev->dev_private; +if (stats_sz <sizeof (*stats)) +return -EINVAL ; + *stats = idxd->stats; +return 0 ; +} + +int +idxd_stats_reset(struct rte_dmadev *dev, uint16_t vchan __rte_unused) +{ +struct idxd_dmadev *idxd = dev->dev_private; + idxd->stats = (struct rte_dmadev_stats ){0 }; +return 0 ; +} +int idxd_info_get (const struct rte_dmadev *dev,struct rte_dmadev_info *info,uint32_t size) {
drivers/dma/idxd/idxd_internal.h +3 -0
@@ -95,5 +95,8 @@ uint16_t idxd_completed(struct rte_dmadev *dev, uint16_t qid, uint16_t max_ops, uint16_t idxd_completed_status(struct rte_dmadev *dev, uint16_t qid __rte_unused,uint16_t max_ops,uint16_t *last_idx,enum rte_dma_status_code *status); +int idxd_stats_get (const struct rte_dmadev *dev,uint16_t vchan, +struct rte_dmadev_stats *stats,uint32_t stats_sz); +int idxd_stats_reset (struct rte_dmadev *dev,uint16_t vchan);#endif /* _IDXD_INTERNAL_H_ */
Signature · 1 line
2.30.2
PATCH 13/13 dma/idxd: move dpdk_idxd_cfg.py from raw to dma
In reply to Kevin LaatzFrom: Conor Walsh <[email protected]>
Move the example script for configuring IDXD devices bound to the IDXD kernel driver from raw to dma, and create a symlink to still allow use from raw.
--- drivers/dma/idxd/dpdk_idxd_cfg.py | 117 +++++++++++++++++++++++++++++ drivers/raw/ioat/dpdk_idxd_cfg.py | 118 +----------------------------- 2 files changed, 118 insertions(+), 117 deletions(-) create mode 100755 drivers/dma/idxd/dpdk_idxd_cfg.py mode change 100755 => 120000 drivers/raw/ioat/dpdk_idxd_cfg.py
drivers/dma/idxd/dpdk_idxd_cfg.py new file +117 -0
@@ -0,0 +1,117 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2020 Intel Corporation + +""" +Configure an entire Intel DSA instance, using idxd kernel driver, for DPDK use +""" + +import sys +import argparse +import os +import os.path + + +class SysfsDir: + "Used to read/write paths in a sysfs directory" + def __init__(self, path): + self.path = path + + def read_int(self, filename): + "Return a value from sysfs file" + with open(os.path.join(self.path, filename)) as f: + return int(f.readline()) + + def write_values(self, values): + "write dictionary, where key is filename and value is value to write" + for filename, contents in values.items(): + with open(os.path.join(self.path, filename), "w") as f: + f.write(str(contents)) + + +def reset_device(dsa_id): + "Reset the DSA device and all its queues" + drv_dir = SysfsDir("/sys/bus/dsa/drivers/dsa") + drv_dir.write_values({"unbind": f"dsa{dsa_id}"}) + + +def get_pci_dir(pci): + "Search for the sysfs directory of the PCI device" + base_dir = '/sys/bus/pci/devices/' + for path, dirs, files in os.walk(base_dir): + for dir in dirs: + if pci in dir: + return os.path.join(base_dir, dir) + sys.exit(f"Could not find sysfs directory for device {pci}") + + +def get_dsa_id(pci): + "Get the DSA instance ID using the PCI address of the device" + pci_dir = get_pci_dir(pci) + for path, dirs, files in os.walk(pci_dir): + for dir in dirs: + if dir.startswith('dsa') and 'wq' not in dir: + return int(dir[3:]) + sys.exit(f"Could not get device ID for device {pci}") + + +def configure_dsa(dsa_id, queues, prefix): + "Configure the DSA instance with appropriate number of queues" + dsa_dir = SysfsDir(f"/sys/bus/dsa/devices/dsa{dsa_id}") + drv_dir = SysfsDir("/sys/bus/dsa/drivers/dsa") + + max_groups = dsa_dir.read_int("max_groups") + max_engines = dsa_dir.read_int("max_engines") + max_queues = dsa_dir.read_int("max_work_queues") + max_work_queues_size = dsa_dir.read_int("max_work_queues_size") + + nb_queues = min(queues, max_queues) + if queues > nb_queues: + print(f"Setting number of queues to max supported value: {max_queues}") + + # we want one engine per group, and no more engines than queues + nb_groups = min(max_engines, max_groups, nb_queues) + for grp in range(nb_groups): + dsa_dir.write_values({f"engine{dsa_id}.{grp}/group_id": grp}) + + # configure each queue + for q in range(nb_queues): + wq_dir = SysfsDir(os.path.join(dsa_dir.path, f"wq{dsa_id}.{q}")) + wq_dir.write_values({"group_id": q % nb_groups, + "type": "user", + "mode": "dedicated", + "name": f"{prefix}_wq{dsa_id}.{q}", + "priority": 1, + "size": int(max_work_queues_size / nb_queues)}) + + # enable device and then queues + drv_dir.write_values({"bind": f"dsa{dsa_id}"}) + for q in range(nb_queues): + drv_dir.write_values({"bind": f"wq{dsa_id}.{q}"}) + + +def main(args): + "Main function, does arg parsing and calls config function" + arg_p = argparse.ArgumentParser( + description="Configure whole DSA device instance for DPDK use") + arg_p.add_argument('dsa_id', + help="Specify DSA instance either via DSA instance number or PCI address") + arg_p.add_argument('-q', metavar='queues', type=int, default=255, + help="Number of queues to set up") + arg_p.add_argument('--name-prefix', metavar='prefix', dest='prefix', + default="dpdk", + help="Prefix for workqueue name to mark for DPDK use [default: 'dpdk']") + arg_p.add_argument('--reset', action='store_true', + help="Reset DSA device and its queues") + parsed_args = arg_p.parse_args(args[1:]) + + dsa_id = parsed_args.dsa_id + dsa_id = get_dsa_id(dsa_id) if ':' in dsa_id else dsa_id + if parsed_args.reset: + reset_device(dsa_id) + else: + configure_dsa(dsa_id, parsed_args.q, parsed_args.prefix) + + +if __name__ == "__main__": + main(sys.argv)
drivers/raw/ioat/dpdk_idxd_cfg.py deleted +0 -117
117 lines not on this page · raw message
drivers/raw/ioat/dpdk_idxd_cfg.py new file +1 -0
@@ -0,0 +1 @@ +../../dma/idxd/dpdk_idxd_cfg.py
Signature · 1 line
2.30.2
v2 cover add dmadev driver for idxd devices
In reply to Kevin LaatzThis patchset adds a dmadev driver and associated documentation to support Intel Data Streaming Accelerator devices. This driver is intended to ultimately replace the current IDXD part of the IOAT rawdev driver.
NOTE: This patchset has several dependencies:
- v19 of the dmadev set [1]
- v2 of the dmadev test suite [2]
[1] http://patches.dpdk.org/project/dpdk/list/?series=18629
[2] http://patches.dpdk.org/project/dpdk/list/?series=18607
v2:
* rebased on above patchsets
* added API to check for device being idle
* added devbind updates for DMA devices
* fixed issue identified by internal coverity scan
* other minor miscellaneous changes and fixes
Bruce Richardson (1):
raw/ioat: only build if dmadev not present
Conor Walsh (1):
dma/idxd: move dpdk_idxd_cfg.py from raw to dma
Kevin Laatz (14):
doc: initial commit for dmadevs section dma/idxd: add skeleton for VFIO based DSA device dma/idxd: add bus device probing
dma/idxd: create dmadev instances on bus probe dma/idxd: create dmadev instances on pci probe dma/idxd: add datapath structures
dma/idxd: add configure and info_get functions dma/idxd: add start and stop functions for pci devices dma/idxd: add data-path job submission functions dma/idxd: add data-path job completion functions dma/idxd: add operation statistic tracking dma/idxd: add vchan idle function
devbind: add dma device class
devbind: move idxd device ID to dmadev class
MAINTAINERS | 10 + app/test/test_dmadev.c | 3 +- doc/guides/dmadevs/idxd.rst | 255 +++++++++++ doc/guides/dmadevs/index.rst | 14 + doc/guides/index.rst | 1 + doc/guides/rel_notes/release_21_11.rst | 5 + drivers/dma/idxd/dpdk_idxd_cfg.py | 117 +++++ drivers/dma/idxd/idxd_bus.c | 376 ++++++++++++++++ drivers/dma/idxd/idxd_common.c | 585 +++++++++++++++++++++++++ drivers/dma/idxd/idxd_hw_defs.h | 131 ++++++ drivers/dma/idxd/idxd_internal.h | 103 +++++ drivers/dma/idxd/idxd_pci.c | 379 ++++++++++++++++ drivers/dma/idxd/meson.build | 10 + drivers/dma/idxd/version.map | 3 + drivers/dma/meson.build | 1 + drivers/raw/ioat/dpdk_idxd_cfg.py | 118 +---- drivers/raw/ioat/meson.build | 23 +- usertools/dpdk-devbind.py | 12 +- 18 files changed, 2022 insertions(+), 124 deletions(-) create mode 100644 doc/guides/dmadevs/idxd.rst create mode 100644 doc/guides/dmadevs/index.rst create mode 100755 drivers/dma/idxd/dpdk_idxd_cfg.py create mode 100644 drivers/dma/idxd/idxd_bus.c create mode 100644 drivers/dma/idxd/idxd_common.c create mode 100644 drivers/dma/idxd/idxd_hw_defs.h create mode 100644 drivers/dma/idxd/idxd_internal.h create mode 100644 drivers/dma/idxd/idxd_pci.c create mode 100644 drivers/dma/idxd/meson.build create mode 100644 drivers/dma/idxd/version.map mode change 100755 => 120000 drivers/raw/ioat/dpdk_idxd_cfg.py
Signature · 1 line
2.30.2
PATCH v2 1/16 raw/ioat: only build if dmadev not present
From: Bruce Richardson <[email protected]>
Only build the rawdev IDXD/IOAT drivers if the dmadev drivers are not present.
--- drivers/raw/ioat/meson.build | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-)
drivers/raw/ioat/meson.build +20 -3
@@ -2,14 +2,31 @@ # Copyright 2019 Intel Corporation build = dpdk_conf.has('RTE_ARCH_X86') +# only use ioat rawdev driver if we don't have the equivalent dmadev ones +if not dpdk_conf.has('RTE_DMA_IDXD') and not dpdk_conf.has('RTE_DMA_IOAT') + build = false + subdir_done() +endif + reason = 'only supported on x86' sources = files( - 'idxd_bus.c', - 'idxd_pci.c', 'ioat_common.c', - 'ioat_rawdev.c', 'ioat_rawdev_test.c', ) + +if not dpdk_conf.has('RTE_DMA_IDXD') + sources += files( + 'idxd_bus.c', + 'idxd_pci.c', + ) +endif + +if not dpdk_conf.has('RTE_DMA_IOAT') + sources += files ( + 'ioat_rawdev.c', + ) +endif + deps += ['bus_pci', 'mbuf', 'rawdev'] headers = files( 'rte_ioat_rawdev.h',
Signature · 1 line
2.30.2
PATCH v2 2/16 doc: initial commit for dmadevs section
In reply to Kevin LaatzAdd new section to the programmer's guide for dmadev devices.
--- doc/guides/dmadevs/index.rst | 14 ++++++++++++++ doc/guides/index.rst | 1 + 2 files changed, 15 insertions(+) create mode 100644 doc/guides/dmadevs/index.rst
doc/guides/dmadevs/index.rst new file +14 -0
@@ -0,0 +1,14 @@ +.. SPDX-License-Identifier: BSD-3-Clause + Copyright(c) 2021 Intel Corporation. + +DMA Device Drivers +================== + +The following are a list of DMA device PMDs, which can be used from an +application through DMAdev API. + +.. toctree:: + :maxdepth: 2 + :numbered: + + idxd
doc/guides/index.rst +1 -0
@@ -19,6 +19,7 @@ DPDK documentation bbdevs/index cryptodevs/index compressdevs/index + dmadevs/index vdpadevs/index regexdevs/index eventdevs/index
Signature · 1 line
2.30.2
Re: [dpdk-dev] [PATCH v2 02/16] doc: initial commit for dmadevs section
Quoted 4 lines · Kevin Laatz
Add new section to the programmer's guide for dmadev devices.
Signed-off-by Kevin Laatz <[email protected]>---
PATCH v2 3/16 dma/idxd: add skeleton for VFIO based DSA device
In reply to Kevin LaatzAdd the basic device probe/remove skeleton code for DSA device bound to the vfio pci driver. Relevant documentation and MAINTAINERS update also included.
--- MAINTAINERS | 10 +++++ doc/guides/dmadevs/idxd.rst | 58 ++++++++++++++++++++++++++ doc/guides/rel_notes/release_21_11.rst | 5 +++ drivers/dma/idxd/idxd_internal.h | 27 ++++++++++++ drivers/dma/idxd/idxd_pci.c | 55 ++++++++++++++++++++++++ drivers/dma/idxd/meson.build | 7 ++++ drivers/dma/idxd/version.map | 3 ++ drivers/dma/meson.build | 1 + 8 files changed, 166 insertions(+) create mode 100644 doc/guides/dmadevs/idxd.rst create mode 100644 drivers/dma/idxd/idxd_internal.h create mode 100644 drivers/dma/idxd/idxd_pci.c create mode 100644 drivers/dma/idxd/meson.build create mode 100644 drivers/dma/idxd/version.map
MAINTAINERS +10 -0
@@ -1199,6 +1199,16 @@ F: doc/guides/compressdevs/zlib.rst F: doc/guides/compressdevs/features/zlib.ini +DMAdev Drivers +-------------- + +Intel IDXD - EXPERIMENTAL +M: Bruce Richardson <[email protected]> +M: Kevin Laatz <[email protected]> +F: drivers/dma/idxd/ +F: doc/guides/dmadevs/idxd.rst + + RegEx Drivers -------------
doc/guides/dmadevs/idxd.rst new file +58 -0
58 lines not on this page · raw message
doc/guides/rel_notes/release_21_11.rst +5 -0
@@ -60,6 +60,11 @@ New Features The dmadev library provides a DMA device framework for management and provision of hardware and software DMA devices. +* **Added IDXD dmadev driver implementation.** + + The IDXD dmadev driver provide device drivers for the Intel DSA devices. + This device driver can be used through the generic dmadev API. + Removed Items -------------
drivers/dma/idxd/idxd_internal.h new file +27 -0
@@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright 2021 Intel Corporation +*/ + +#ifndef _IDXD_INTERNAL_H_ +#define _IDXD_INTERNAL_H_ + +/** +* @file idxd_internal.h +* +* Internal data structures for the idxd/DSA driver for dmadev +* +* @warning +* @b EXPERIMENTAL: these structures and APIs may change without prior notice +*/ + +extern int idxd_pmd_logtype; + +#define IDXD_PMD_LOG(level, fmt, args...) rte_log(RTE_LOG_ ## level, \ + idxd_pmd_logtype, "IDXD: %s(): " fmt "\n", __func__, ##args) + +#define IDXD_PMD_DEBUG(fmt, args...) IDXD_PMD_LOG(DEBUG, fmt, ## args) +#define IDXD_PMD_INFO(fmt, args...) IDXD_PMD_LOG(INFO, fmt, ## args) +#define IDXD_PMD_ERR(fmt, args...) IDXD_PMD_LOG(ERR, fmt, ## args) +#define IDXD_PMD_WARN(fmt, args...) IDXD_PMD_LOG(WARNING, fmt, ## args) + +#endif /* _IDXD_INTERNAL_H_ */
drivers/dma/idxd/idxd_pci.c new file +55 -0
55 lines not on this page · raw message
drivers/dma/idxd/meson.build new file +7 -0
@@ -0,0 +1,7 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2021 Intel Corporation + +deps += ['bus_pci'] +sources = files( + 'idxd_pci.c' +)
drivers/dma/idxd/version.map new file +3 -0
@@ -0,0 +1,3 @@ +DPDK_21 { + local: *; +};
drivers/dma/meson.build +1 -0
@@ -6,6 +6,7 @@ if is_windows endif drivers = [ + 'idxd', 'skeleton', ] std_deps = ['dmadev']
Signature · 1 line
2.30.2
PATCH v2 4/16 dma/idxd: add bus device probing
In reply to Kevin LaatzAdd the basic device probing for DSA devices bound to the IDXD kernel driver. These devices can be configured via sysfs and made available to DPDK if they are found during bus scan. Relevant documentation is included.
--- doc/guides/dmadevs/idxd.rst | 64 +++++++ drivers/dma/idxd/idxd_bus.c | 351 +++++++++++++++++++++++++++++++++++ drivers/dma/idxd/meson.build | 1 + 3 files changed, 416 insertions(+) create mode 100644 drivers/dma/idxd/idxd_bus.c
doc/guides/dmadevs/idxd.rst +64 -0
@@ -32,6 +32,56 @@ target platform is x86-based. No additional compilation steps are necessary. Device Setup ------------- +Intel\ |reg| DSA devices can use the IDXD kernel driver or DPDK-supported drivers, +such as ``vfio-pci``. Both are supported by the IDXD PMD. + +Intel\ |reg| DSA devices using IDXD kernel driver +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +To use an Intel\ |reg| DSA device bound to the IDXD kernel driver, the device must first be configured. +The `accel-config <https://github.com/intel/idxd-config>`_ utility library can be used for configuration. + +.. note:: + The device configuration can also be done by directly interacting with the sysfs nodes. + An example of how this may be done can be seen in the script ``dpdk_idxd_cfg.py`` + included in the driver source directory. + +There are some mandatory configuration steps before being able to use a device with an application. +The internal engines, which do the copies or other operations, +and the work-queues, which are used by applications to assign work to the device, +need to be assigned to groups, and the various other configuration options, +such as priority or queue depth, need to be set for each queue. + +To assign an engine to a group:: + + $ accel-config config-engine dsa0/engine0.0 --group-id=0 + $ accel-config config-engine dsa0/engine0.1 --group-id=1 + +To assign work queues to groups for passing descriptors to the engines a similar accel-config command can be used. +However, the work queues also need to be configured depending on the use case. +Some configuration options include: + +* mode (Dedicated/Shared): Indicates whether a WQ may accept jobs from multiple queues simultaneously. +* priority: WQ priority between 1 and 15. Larger value means higher priority. +* wq-size: the size of the WQ. Sum of all WQ sizes must be less that the total-size defined by the device. +* type: WQ type (kernel/mdev/user). Determines how the device is presented. +* name: identifier given to the WQ. + +Example configuration for a work queue:: + + $ accel-config config-wq dsa0/wq0.0 --group-id=0 \ + --mode=dedicated --priority=10 --wq-size=8 \ + --type=user --name=dpdk_app1 + +Once the devices have been configured, they need to be enabled:: + + $ accel-config enable-device dsa0 + $ accel-config enable-wq dsa0/wq0.0 + +Check the device configuration:: + + $ accel-config list + Devices using VFIO/UIO drivers ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -56,3 +106,17 @@ If fewer workqueues are required, then the ``max_queues`` parameter may be passe the device driver on the EAL commandline, via the ``allowlist`` or ``-a`` flag e.g.:: $ dpdk-test -a <b:d:f>,max_queues=4 + +For devices bound to the IDXD kernel driver, +the DPDK IDXD driver will automatically perform a scan for available workqueues +to use. Any workqueues found listed in ``/dev/dsa`` on the system will be checked +in ``/sys``, and any which have ``dpdk_`` prefix in their name will be automatically +probed by the driver to make them available to the application. +Alternatively, to support use by multiple DPDK processes simultaneously, +the value used as the DPDK ``--file-prefix`` parameter may be used as a workqueue +name prefix, instead of ``dpdk_``, allowing each DPDK application instance to only +use a subset of configured queues. + +Once probed successfully, irrespective of kernel driver, the device will appear as a ``dmadev``, +that is a "DMA device type" inside DPDK, and can be accessed using APIs from the +``rte_dmadev`` library.
drivers/dma/idxd/idxd_bus.c new file +351 -0
351 lines not on this page · raw message
drivers/dma/idxd/meson.build +1 -0
@@ -3,5 +3,6 @@ deps += ['bus_pci'] sources = files( + 'idxd_bus.c', 'idxd_pci.c' )
Signature · 1 line
2.30.2
PATCH v2 5/16 dma/idxd: create dmadev instances on bus probe
In reply to Kevin LaatzWhen a suitable device is found during the bus scan/probe, create a dmadev instance for each HW queue. Internal structures required for device creation are also added.
--- drivers/dma/idxd/idxd_bus.c | 20 ++++++++- drivers/dma/idxd/idxd_common.c | 75 ++++++++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 40 +++++++++++++++++ drivers/dma/idxd/meson.build | 1 + 4 files changed, 135 insertions(+), 1 deletion(-) create mode 100644 drivers/dma/idxd/idxd_common.c
drivers/dma/idxd/idxd_bus.c +19 -1
@@ -84,6 +84,18 @@ dsa_get_sysfs_path(void)return path ? path :DSA_SYSFS_PATH ; } +static int +idxd_dev_close (struct rte_dmadev *dev) +{ +struct idxd_dmadev *idxd = dev->data->dev_private; +munmap (idxd->portal,0x1000 ); +return 0 ; +} + +static const struct rte_dmadev_ops idxd_vdev_ops = { + .dev_close = idxd_dev_close, +}; +static void *idxd_vdev_mmap_wq (struct rte_dsa_device *dev) {
@@ -205,7 +217,7 @@ idxd_probe_dsa(struct rte_dsa_device *dev)return -1 ; idxd.max_batch_size = ret; idxd.qid = dev->addr.wq_id; - idxd.u.vdev.dsa_id = dev->addr.device_id; + idxd.u.bus.dsa_id = dev->addr.device_id; idxd.sva_support =1 ; idxd.portal =idxd_vdev_mmap_wq (dev);
@@ -214,6 +226,12 @@ idxd_probe_dsa(struct rte_dsa_device *dev)return -ENOENT ; } + ret =idxd_dmadev_create (dev->wq_name, &dev->device, &idxd, &idxd_vdev_ops); +if (ret) { +IDXD_PMD_ERR ("Failed to create rawdev %s" , dev->wq_name); +return ret; + } +return 0 ; }
drivers/dma/idxd/idxd_common.c new file +75 -0
75 lines not on this page · raw message
drivers/dma/idxd/idxd_internal.h +40 -0
@@ -24,4 +24,44 @@ extern int idxd_pmd_logtype; #define IDXD_PMD_ERR(fmt, args...) IDXD_PMD_LOG(ERR, fmt, ## args) #define IDXD_PMD_WARN(fmt, args...) IDXD_PMD_LOG(WARNING, fmt, ## args) +struct idxd_dmadev { +/* counters to track the batches */ +unsigned short max_batches; +unsigned short batch_idx_read; +unsigned short batch_idx_write; + +/* track descriptors and handles */ +unsigned short desc_ring_mask; +unsigned short ids_avail;/* handles for ops completed */ +unsigned short ids_returned;/* the read pointer for hdls/desc rings */ +unsigned short batch_start;/* start+size == write pointer for hdls/desc */ +unsigned short batch_size; + +void *portal;/* address to write the batch descriptor */ + +struct idxd_completion *batch_comp_ring; +unsigned short *batch_idx_ring;/* store where each batch ends */ + +struct rte_dmadev_stats stats; + +rte_iova_t batch_iova;/* base address of the batch comp ring */ +rte_iova_t desc_iova;/* base address of desc ring, needed for completions */ + +unsigned short max_batch_size; + +struct rte_dmadev *dmadev; +struct rte_dmadev_vchan_conf qcfg; +uint8_t sva_support; +uint8_t qid; + +union { +struct { +unsigned int dsa_id; + } bus; + } u; +}; + +int idxd_dmadev_create (const char *name,struct rte_device *dev, +const struct idxd_dmadev *base_idxd,const struct rte_dmadev_ops *ops); +#endif /* _IDXD_INTERNAL_H_ */
drivers/dma/idxd/meson.build +1 -0
@@ -4,5 +4,6 @@ deps += ['bus_pci'] sources = files( 'idxd_bus.c', + 'idxd_common.c', 'idxd_pci.c' )
Signature · 1 line
2.30.2
PATCH v2 6/16 dma/idxd: create dmadev instances on pci probe
In reply to Kevin LaatzWhen a suitable device is found during the PCI probe, create a dmadev instance for each HW queue. HW definitions required are also included.
--- drivers/dma/idxd/idxd_hw_defs.h | 71 ++++++++ drivers/dma/idxd/idxd_internal.h | 14 ++ drivers/dma/idxd/idxd_pci.c | 272 ++++++++++++++++++++++++++++++- 3 files changed, 354 insertions(+), 3 deletions(-) create mode 100644 drivers/dma/idxd/idxd_hw_defs.h
drivers/dma/idxd/idxd_hw_defs.h new file +71 -0
@@ -0,0 +1,71 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright 2021 Intel Corporation +*/ + +#ifndef _IDXD_HW_DEFS_H_ +#define _IDXD_HW_DEFS_H_ + +/*** Definitions for Intel(R) Data Streaming Accelerator ***/ + +#define IDXD_CMD_SHIFT 20 +enum rte_idxd_cmds { + idxd_enable_dev =1 , + idxd_disable_dev, + idxd_drain_all, + idxd_abort_all, + idxd_reset_device, + idxd_enable_wq, + idxd_disable_wq, + idxd_drain_wq, + idxd_abort_wq, + idxd_reset_wq, +}; + +/* General bar0 registers */ +struct rte_idxd_bar0 { + uint32_t __rte_cache_aligned version; /* offset 0x00 */ + uint64_t __rte_aligned(0x10) gencap; /* offset 0x10 */ + uint64_t __rte_aligned(0x10) wqcap; /* offset 0x20 */ + uint64_t __rte_aligned(0x10) grpcap; /* offset 0x30 */ + uint64_t __rte_aligned(0x08) engcap; /* offset 0x38 */ + uint64_t __rte_aligned(0x10) opcap; /* offset 0x40 */ + uint64_t __rte_aligned(0x20) offsets[2]; /* offset 0x60 */ + uint32_t __rte_aligned(0x20) gencfg; /* offset 0x80 */ + uint32_t __rte_aligned(0x08) genctrl; /* offset 0x88 */ + uint32_t __rte_aligned(0x10) gensts; /* offset 0x90 */ + uint32_t __rte_aligned(0x08) intcause; /* offset 0x98 */ + uint32_t __rte_aligned(0x10) cmd; /* offset 0xA0 */ + uint32_t __rte_aligned(0x08) cmdstatus; /* offset 0xA8 */ + uint64_t __rte_aligned(0x20) swerror[4]; /* offset 0xC0 */ +}; + +/* workqueue config is provided by array of uint32_t. */ +enum rte_idxd_wqcfg { + wq_size_idx,/* size is in first 32-bit value */ + wq_threshold_idx,/* WQ threshold second 32-bits */ + wq_mode_idx,/* WQ mode and other flags */ + wq_sizes_idx,/* WQ transfer and batch sizes */ + wq_occ_int_idx,/* WQ occupancy interrupt handle */ + wq_occ_limit_idx,/* WQ occupancy limit */ + wq_state_idx,/* WQ state and occupancy state */ +}; + +#define WQ_MODE_SHARED 0 +#define WQ_MODE_DEDICATED 1 +#define WQ_PRIORITY_SHIFT 4 +#define WQ_BATCH_SZ_SHIFT 5 +#define WQ_STATE_SHIFT 30 +#define WQ_STATE_MASK 0x3 + +struct rte_idxd_grpcfg { + uint64_t grpwqcfg[4] __rte_cache_aligned; /* 64-byte register set */ +uint64_t grpengcfg;/* offset 32 */ +uint32_t grpflags;/* offset 40 */ +}; + +#define GENSTS_DEV_STATE_MASK 0x03 +#define CMDSTATUS_ACTIVE_SHIFT 31 +#define CMDSTATUS_ACTIVE_MASK (1 << 31) +#define CMDSTATUS_ERR_MASK 0xFF + +#endif
drivers/dma/idxd/idxd_internal.h +14 -0
@@ -5,6 +5,8 @@#ifndef _IDXD_INTERNAL_H_#define _IDXD_INTERNAL_H_ +#include "idxd_hw_defs.h" +/** * @file idxd_internal.h *
@@ -24,6 +26,16 @@ extern int idxd_pmd_logtype; #define IDXD_PMD_ERR(fmt, args...) IDXD_PMD_LOG(ERR, fmt, ## args) #define IDXD_PMD_WARN(fmt, args...) IDXD_PMD_LOG(WARNING, fmt, ## args) +struct idxd_pci_common { +rte_spinlock_t lk; + +uint8_t wq_cfg_sz; +volatile struct rte_idxd_bar0 *regs; +volatile uint32_t *wq_regs_base; +volatile struct rte_idxd_grpcfg *grp_regs; +volatile void *portals; +}; +struct idxd_dmadev {/* counters to track the batches */ unsigned short max_batches;
@@ -58,6 +70,8 @@ struct idxd_dmadev {struct {unsigned int dsa_id; } bus; + +struct idxd_pci_common *pci; } u; };
drivers/dma/idxd/idxd_pci.c +269 -3
299 lines not on this page · raw message
Signature · 1 line
2.30.2
PATCH v2 7/16 dma/idxd: add datapath structures
In reply to Kevin LaatzAdd data structures required for the data path for IDXD devices.
---
v2: add completion status for invalid opcode
--- drivers/dma/idxd/idxd_bus.c | 1 + drivers/dma/idxd/idxd_common.c | 33 ++++++++++++++++++ drivers/dma/idxd/idxd_hw_defs.h | 60 ++++++++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 3 ++ drivers/dma/idxd/idxd_pci.c | 2 +- 5 files changed, 98 insertions(+), 1 deletion(-)
drivers/dma/idxd/idxd_bus.c +1 -0
@@ -94,6 +94,7 @@ idxd_dev_close(struct rte_dmadev *dev)static const struct rte_dmadev_ops idxd_vdev_ops = { .dev_close = idxd_dev_close, + .dev_dump = idxd_dump, }; static void *
drivers/dma/idxd/idxd_common.c +33 -0
@@ -10,6 +10,35 @@#define IDXD_PMD_NAME_STR "dmadev_idxd" +int +idxd_dump (const struct rte_dmadev *dev,FILE *f) +{ +struct idxd_dmadev *idxd = dev->dev_private; +unsigned int i; + +fprintf (f,"== Private Data ==\n" ); +fprintf (f," Portal: %p\n" , idxd->portal); +fprintf (f," Config: { ring_size: %u }\n" , + idxd->qcfg.nb_desc); +fprintf (f," Batch ring (sz = %u, max_batches = %u):\n\t" , + idxd->max_batches +1 , idxd->max_batches); +for (i =0 ; i <= idxd->max_batches; i++) { +fprintf (f," %u " , idxd->batch_idx_ring[i]); +if (i == idxd->batch_idx_read && i == idxd->batch_idx_write) +fprintf (f,"[rd ptr, wr ptr] " ); +else if (i == idxd->batch_idx_read) +fprintf (f,"[rd ptr] " ); +else if (i == idxd->batch_idx_write) +fprintf (f,"[wr ptr] " ); +if (i == idxd->max_batches) +fprintf (f,"\n" ); + } + +fprintf (f," Curr batch: start = %u, size = %u\n" , idxd->batch_start, idxd->batch_size); +fprintf (f," IDS: avail = %u, returned: %u\n" , idxd->ids_avail, idxd->ids_returned); +return 0 ; +} + int idxd_dmadev_create(const char *name, struct rte_device *dev, const struct idxd_dmadev *base_idxd,
@@ -19,6 +48,10 @@ idxd_dmadev_create(const char *name, struct rte_device *dev,struct rte_dmadev *dmadev =NULL ;int ret =0 ; +RTE_BUILD_BUG_ON (sizeof (struct idxd_hw_desc ) !=64 ); +RTE_BUILD_BUG_ON (offsetof(struct idxd_hw_desc , size) !=32 ); +RTE_BUILD_BUG_ON (sizeof (struct idxd_completion ) !=32 ); +if (!name) {IDXD_PMD_ERR ("Invalid name of the device!" ); ret = -EINVAL ;
drivers/dma/idxd/idxd_hw_defs.h +60 -0
66 lines not on this page · raw message
drivers/dma/idxd/idxd_internal.h +3 -0
@@ -37,6 +37,8 @@ struct idxd_pci_common { };struct idxd_dmadev { +struct idxd_hw_desc *desc_ring; +/* counters to track the batches */ unsigned short max_batches;unsigned short batch_idx_read;
@@ -77,5 +79,6 @@ struct idxd_dmadev {int idxd_dmadev_create (const char *name,struct rte_device *dev,const struct idxd_dmadev *base_idxd,const struct rte_dmadev_ops *ops); +int idxd_dump (const struct rte_dmadev *dev,FILE *f);#endif /* _IDXD_INTERNAL_H_ */
drivers/dma/idxd/idxd_pci.c +1 -1
@@ -60,7 +60,7 @@ idxd_is_wq_enabled(struct idxd_dmadev *idxd) }static const struct rte_dmadev_ops idxd_pci_ops = { - + .dev_dump = idxd_dump, };/* each portal uses 4 x 4k pages */
Signature · 1 line
2.30.2
PATCH v2 8/16 dma/idxd: add configure and info_get functions
In reply to Kevin LaatzAdd functions for device configuration. The info_get function is included here since it can be useful for checking successful configuration.
---
v2:
- fix reconfigure bug in idxd_vchan_setup()
- add literal include comment for the docs to pick up
--- app/test/test_dmadev.c | 3 +- doc/guides/dmadevs/idxd.rst | 33 ++++++++++++++++ drivers/dma/idxd/idxd_bus.c | 3 ++ drivers/dma/idxd/idxd_common.c | 66 ++++++++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 5 +++ drivers/dma/idxd/idxd_pci.c | 3 ++ 6 files changed, 112 insertions(+), 1 deletion(-)
app/test/test_dmadev.c +2 -1
@@ -770,6 +770,7 @@ static int test_dmadev_instance(uint16_t dev_id) {#define TEST_RINGSIZE 512 +/* Setup of the dmadev device. 8< */ struct rte_dmadev_stats stats;struct rte_dmadev_info info;const struct rte_dmadev_conf conf = { .nb_vchans =1 };
@@ -795,7 +796,7 @@ test_dmadev_instance(uint16_t dev_id)PRINT_ERR ("Error with queue configuration\n" );return -1 ; } - +/* >8 End of setup of the dmadev device. */ rte_dmadev_info_get (dev_id, &info);if (info.nb_vchans !=1 ) {PRINT_ERR ("Error, no configured queues reported on device id %u\n" , dev_id);
doc/guides/dmadevs/idxd.rst +33 -0
@@ -120,3 +120,36 @@ use a subset of configured queues. Once probed successfully, irrespective of kernel driver, the device will appear as a ``dmadev``, that is a "DMA device type" inside DPDK, and can be accessed using APIs from the ``rte_dmadev`` library. + +Using IDXD DMAdev Devices +-------------------------- + +To use the devices from an application, the dmadev API can be used. + +Getting Device Information +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Basic information about each dmadev device can be queried using the +``rte_dmadev_info_get()`` API. This will return basic device information such as +the ``rte_device`` structure, device capabilities and other device specific values. + +Device Configuration +~~~~~~~~~~~~~~~~~~~~~ + +Configuring an IDXD dmadev device is done using the ``rte_dmadev_configure()`` and +``rte_dmadev_vchan_setup`` APIs. The configurations are passed to these APIs using +the ``rte_dmadev_conf`` and ``rte_dmadev_vchan_conf`` structures, respectively. For +example, these can be used to configure the number of ``vchans`` per device, the +ring size, etc. The ring size must be a power of two, between 64 and 4096. + +The following code shows how the device is configured in +``test_dmadev.c``: + +.. literalinclude:: ../../../app/test/test_dmadev.c + :language: c + :start-after: Setup of the dmadev device. 8< + :end-before: >8 End of setup of the dmadev device. + :dedent: 1 + +Once configured, the device can then be made ready for use by calling the +``rte_dmadev_start()`` API.
drivers/dma/idxd/idxd_bus.c +3 -0
@@ -95,6 +95,9 @@ idxd_dev_close(struct rte_dmadev *dev)static const struct rte_dmadev_ops idxd_vdev_ops = { .dev_close = idxd_dev_close, .dev_dump = idxd_dump, + .dev_configure = idxd_configure, + .vchan_setup = idxd_vchan_setup, + .dev_info_get = idxd_info_get, }; static void *
drivers/dma/idxd/idxd_common.c +66 -0
72 lines not on this page · raw message
drivers/dma/idxd/idxd_internal.h +5 -0
@@ -80,5 +80,10 @@ struct idxd_dmadev {int idxd_dmadev_create (const char *name,struct rte_device *dev,const struct idxd_dmadev *base_idxd,const struct rte_dmadev_ops *ops);int idxd_dump (const struct rte_dmadev *dev,FILE *f); +int idxd_configure (struct rte_dmadev *dev,const struct rte_dmadev_conf *dev_conf); +int idxd_vchan_setup (struct rte_dmadev *dev,uint16_t vchan, +const struct rte_dmadev_vchan_conf *qconf); +int idxd_info_get (const struct rte_dmadev *dev,struct rte_dmadev_info *dev_info, +uint32_t size);#endif /* _IDXD_INTERNAL_H_ */
drivers/dma/idxd/idxd_pci.c +3 -0
@@ -61,6 +61,9 @@ idxd_is_wq_enabled(struct idxd_dmadev *idxd)static const struct rte_dmadev_ops idxd_pci_ops = { .dev_dump = idxd_dump, + .dev_configure = idxd_configure, + .vchan_setup = idxd_vchan_setup, + .dev_info_get = idxd_info_get, };/* each portal uses 4 x 4k pages */
Signature · 1 line
2.30.2
PATCH v2 9/16 dma/idxd: add start and stop functions for pci devices
In reply to Kevin LaatzAdd device start/stop functions for DSA devices bound to vfio. For devices bound to the IDXD kernel driver, these are not required since the IDXD kernel driver takes care of this.
--- drivers/dma/idxd/idxd_pci.c | 52 +++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+)
drivers/dma/idxd/idxd_pci.c +52 -0
@@ -59,11 +59,63 @@ idxd_is_wq_enabled(struct idxd_dmadev *idxd)return ((state >>WQ_STATE_SHIFT ) &WQ_STATE_MASK ) ==0x1 ; } +static int +idxd_pci_dev_stop (struct rte_dmadev *dev) +{ +struct idxd_dmadev *idxd = dev->dev_private; +uint8_t err_code; + +if (!idxd_is_wq_enabled (idxd)) { +IDXD_PMD_ERR ("Work queue %d already disabled" , idxd->qid); +return -EALREADY ; + } + + err_code =idxd_pci_dev_command (idxd, idxd_disable_wq); +if (err_code ||idxd_is_wq_enabled (idxd)) { +IDXD_PMD_ERR ("Failed disabling work queue %d, error code: %#x" , + idxd->qid, err_code); +return -err_code; + } +IDXD_PMD_DEBUG ("Work queue %d disabled OK" , idxd->qid); + +return 0 ; +} + +static int +idxd_pci_dev_start (struct rte_dmadev *dev) +{ +struct idxd_dmadev *idxd = dev->dev_private; +uint8_t err_code; + +if (idxd_is_wq_enabled (idxd)) { +IDXD_PMD_WARN ("WQ %d already enabled" , idxd->qid); +return 0 ; + } + +if (idxd->desc_ring ==NULL ) { +IDXD_PMD_ERR ("WQ %d has not been fully configured" , idxd->qid); +return -EINVAL ; + } + + err_code =idxd_pci_dev_command (idxd, idxd_enable_wq); +if (err_code || !idxd_is_wq_enabled (idxd)) { +IDXD_PMD_ERR ("Failed enabling work queue %d, error code: %#x" , + idxd->qid, err_code); +return err_code ==0 ?-1 : err_code; + } + +IDXD_PMD_DEBUG ("Work queue %d enabled OK" , idxd->qid); + +return 0 ; +} +static const struct rte_dmadev_ops idxd_pci_ops = { .dev_dump = idxd_dump, .dev_configure = idxd_configure, .vchan_setup = idxd_vchan_setup, .dev_info_get = idxd_info_get, + .dev_start = idxd_pci_dev_start, + .dev_stop = idxd_pci_dev_stop, };/* each portal uses 4 x 4k pages */
Signature · 1 line
2.30.2
PATCH v2 10/16 dma/idxd: add data-path job submission functions
In reply to Kevin LaatzAdd data path functions for enqueuing and submitting operations to DSA devices.
--- doc/guides/dmadevs/idxd.rst | 64 +++++++++++++++ drivers/dma/idxd/idxd_common.c | 137 +++++++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 5 ++ drivers/dma/idxd/meson.build | 1 + 4 files changed, 207 insertions(+)
doc/guides/dmadevs/idxd.rst +64 -0
@@ -153,3 +153,67 @@ The following code shows how the device is configured in Once configured, the device can then be made ready for use by calling the ``rte_dmadev_start()`` API. + +Performing Data Copies +~~~~~~~~~~~~~~~~~~~~~~~ + +To perform data copies using IDXD dmadev devices, descriptors should be enqueued +using the ``rte_dmadev_copy()`` API. The HW can be triggered to perform the copy +in two ways, either via a ``RTE_DMA_OP_FLAG_SUBMIT`` flag or by calling +``rte_dmadev_submit()``. Once copies have been completed, the completion will +be reported back when the application calls ``rte_dmadev_completed()`` or +``rte_dmadev_completed_status()``. The latter will also report the status of each +completed operation. + +The ``rte_dmadev_copy()`` function enqueues a single copy to the device ring for +copying at a later point. The parameters to that function include the IOVA addresses +of both the source and destination buffers, as well as the length of the copy. + +The ``rte_dmadev_copy()`` function enqueues a copy operation on the device ring. +If the ``RTE_DMA_OP_FLAG_SUBMIT`` flag is set when calling ``rte_dmadev_copy()``, +the device hardware will be informed of the elements. Alternatively, if the flag +is not set, the application need to call the ``rte_dmadev_submit()`` function to +notify the device hardware. Once the device hardware is informed of the elements +enqueued on the ring, and the device will begin to process them. It is expected +that, for efficiency reasons, a burst of operations will be enqueued to the +device via multiple enqueue calls between calls to the ``rte_dmadev_submit()`` +function. + +The following code from demonstrates how to enqueue a burst of copies to the +device and start the hardware processing of them: + +.. code-block:: C + + struct rte_mbuf *srcs[COMP_BURST_SZ], *dsts[COMP_BURST_SZ]; + unsigned int i; + + for (i = 0; i < RTE_DIM(srcs); i++) { + uint64_t *src_data; + + srcs[i] = rte_pktmbuf_alloc(pool); + dsts[i] = rte_pktmbuf_alloc(pool); + src_data = rte_pktmbuf_mtod(srcs[i], uint64_t *); + if (srcs[i] == NULL || dsts[i] == NULL) { + PRINT_ERR("Error allocating buffers\n"); + return -1; + } + + for (j = 0; j < COPY_LEN/sizeof(uint64_t); j++) + src_data[j] = rte_rand(); + + if (rte_dmadev_copy(dev_id, vchan, srcs[i]->buf_iova + srcs[i]->data_off, + dsts[i]->buf_iova + dsts[i]->data_off, COPY_LEN, 0) < 0) { + PRINT_ERR("Error with rte_dmadev_copy for buffer %u\n", i); + return -1; + } + } + rte_dmadev_submit(dev_id, vchan); + +Filling an Area of Memory +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The IDXD driver also has support for the ``fill`` operation, where an area +of memory is overwritten, or filled, with a short pattern of data. +Fill operations can be performed in much the same was as copy operations +described above, just using the ``rte_dmadev_fill()`` function rather than the +``rte_dmadev_copy()`` function.
drivers/dma/idxd/idxd_common.c +137 -0
157 lines not on this page · raw message
drivers/dma/idxd/idxd_internal.h +5 -0
@@ -85,5 +85,10 @@ int idxd_vchan_setup(struct rte_dmadev *dev, uint16_t vchan, const struct rte_dmadev_vchan_conf *qconf);int idxd_info_get (const struct rte_dmadev *dev,struct rte_dmadev_info *dev_info,uint32_t size); +int idxd_enqueue_copy (struct rte_dmadev *dev,uint16_t qid,rte_iova_t src, +rte_iova_t dst,unsigned int length,uint64_t flags); +int idxd_enqueue_fill (struct rte_dmadev *dev,uint16_t qid,uint64_t pattern, +rte_iova_t dst,unsigned int length,uint64_t flags); +int idxd_submit (struct rte_dmadev *dev,uint16_t qid);#endif /* _IDXD_INTERNAL_H_ */
drivers/dma/idxd/meson.build +1 -0
@@ -2,6 +2,7 @@ # Copyright(c) 2021 Intel Corporation deps += ['bus_pci'] +cflags += '-mavx2' # all platforms with idxd HW support AVX sources = files( 'idxd_bus.c', 'idxd_common.c',
Signature · 1 line
2.30.2
PATCH v2 11/16 dma/idxd: add data-path job completion functions
In reply to Kevin LaatzAdd the data path functions for gathering completed operations.
---
v2:
- fixed typo in docs
- add completion status for invalid opcode
--- doc/guides/dmadevs/idxd.rst | 25 ++++ drivers/dma/idxd/idxd_common.c | 237 +++++++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 5 + 3 files changed, 267 insertions(+)
doc/guides/dmadevs/idxd.rst +25 -0
@@ -209,6 +209,31 @@ device and start the hardware processing of them: } rte_dmadev_submit(dev_id, vchan); +To retrieve information about completed copies, ``rte_dmadev_completed()`` and +``rte_dmadev_completed_status()`` APIs should be used. ``rte_dmadev_completed()`` +will return the number of completed operations, along with the index of the last +successful completed operation and whether or not an error was encountered. If an +error was encountered, ``rte_dmadev_completed_status()`` must be used to kick the +device off to continue processing operations and also to gather the status of each +individual operations which is filled in to the ``status`` array provided as +parameter by the application. + +The following code shows how to retrieve the number of successfully completed +copies within a burst and then using ``rte_dmadev_completed_status()`` to check +which operation failed and kick off the device to continue processing operations: + +.. code-block:: C + + enum rte_dma_status_code status[COMP_BURST_SZ]; + uint16_t count, idx, status_count; + bool error = 0; + + count = rte_dmadev_completed(dev_id, vchan, COMP_BURST_SZ, &idx, &error); + + if (error){ + status_count = rte_dmadev_completed_status(dev_id, vchan, COMP_BURST_SZ, &idx, status); + } + Filling an Area of Memory ~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/dma/idxd/idxd_common.c +237 -0
249 lines not on this page · raw message
drivers/dma/idxd/idxd_internal.h +5 -0
@@ -90,5 +90,10 @@ int idxd_enqueue_copy(struct rte_dmadev *dev, uint16_t qid, rte_iova_t src,int idxd_enqueue_fill (struct rte_dmadev *dev,uint16_t qid,uint64_t pattern,rte_iova_t dst,unsigned int length,uint64_t flags);int idxd_submit (struct rte_dmadev *dev,uint16_t qid); +uint16_t idxd_completed (struct rte_dmadev *dev,uint16_t qid,uint16_t max_ops, +uint16_t *last_idx,bool *has_error); +uint16_t idxd_completed_status(struct rte_dmadev *dev, uint16_t qid __rte_unused, +uint16_t max_ops,uint16_t *last_idx, +enum rte_dma_status_code *status);#endif /* _IDXD_INTERNAL_H_ */
Signature · 1 line
2.30.2
PATCH v2 12/16 dma/idxd: add operation statistic tracking
In reply to Kevin LaatzAdd statistic tracking for DSA devices.
--- doc/guides/dmadevs/idxd.rst | 11 +++++++++++ drivers/dma/idxd/idxd_bus.c | 2 ++ drivers/dma/idxd/idxd_common.c | 27 +++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 3 +++ drivers/dma/idxd/idxd_pci.c | 2 ++ 5 files changed, 45 insertions(+)
doc/guides/dmadevs/idxd.rst +11 -0
@@ -242,3 +242,14 @@ of memory is overwritten, or filled, with a short pattern of data. Fill operations can be performed in much the same was as copy operations described above, just using the ``rte_dmadev_fill()`` function rather than the ``rte_dmadev_copy()`` function. + +Querying Device Statistics +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The statistics from the IDXD dmadev device can be got via the stats functions in +the ``rte_dmadev`` library, i.e. ``rte_dmadev_stats_get()``. The statistics +returned for each device instance are: + +* ``submitted`` +* ``completed`` +* ``errors``
drivers/dma/idxd/idxd_bus.c +2 -0
@@ -98,6 +98,8 @@ static const struct rte_dmadev_ops idxd_vdev_ops = { .dev_configure = idxd_configure, .vchan_setup = idxd_vchan_setup, .dev_info_get = idxd_info_get, + .stats_get = idxd_stats_get, + .stats_reset = idxd_stats_reset, }; static void *
drivers/dma/idxd/idxd_common.c +27 -0
@@ -65,6 +65,8 @@ __submit(struct idxd_dmadev *idxd)if (++idxd->batch_idx_write > idxd->max_batches) idxd->batch_idx_write =0 ; + idxd->stats.submitted += idxd->batch_size; + idxd->batch_start += idxd->batch_size; idxd->batch_size =0 ; idxd->batch_idx_ring[idxd->batch_idx_write] = idxd->batch_start;
@@ -278,6 +280,8 @@ batch_completed_status(struct idxd_dmadev *idxd, uint16_t max_ops, enum rte_dma_const uint16_t b_len = b_end - b_start;if (b_len ==1 ) {/* not a batch */ *status =get_comp_status (&idxd->batch_comp_ring[idxd->batch_idx_read]); +if (status !=RTE_DMA_STATUS_SUCCESSFUL ) + idxd->stats.errors++; idxd->ids_avail++; idxd->ids_returned++; idxd->batch_idx_read = next_batch;
@@ -299,6 +303,8 @@ batch_completed_status(struct idxd_dmadev *idxd, uint16_t max_ops, enum rte_dma_struct idxd_completion *c = (void *) &idxd->desc_ring[(b_start + ret) & idxd->desc_ring_mask]; status[ret] = (ret < bcount) ?get_comp_status (c) :RTE_DMA_STATUS_NOT_ATTEMPTED ; +if (status[ret] !=RTE_DMA_STATUS_SUCCESSFUL ) + idxd->stats.errors++; } idxd->ids_avail = idxd->ids_returned += ret;
@@ -357,6 +363,7 @@ idxd_completed(struct rte_dmadev *dev, uint16_t qid __rte_unused, uint16_t max_o ret += batch; }while (batch >0 && *has_error == false); + idxd->stats.completed += ret; *last_idx = idxd->ids_returned -1 ;return ret; }
@@ -374,6 +381,7 @@ idxd_completed_status(struct rte_dmadev *dev, uint16_t qid __rte_unused, uint16_ ret += batch; }while (batch >0 ); + idxd->stats.completed += ret; *last_idx = idxd->ids_returned -1 ;return ret; }
@@ -407,6 +415,25 @@ idxd_dump(const struct rte_dmadev *dev, FILE *f)return 0 ; } +int +idxd_stats_get(const struct rte_dmadev *dev, uint16_t vchan __rte_unused, +struct rte_dmadev_stats *stats,uint32_t stats_sz) +{ +struct idxd_dmadev *idxd = dev->dev_private; +if (stats_sz <sizeof (*stats)) +return -EINVAL ; + *stats = idxd->stats; +return 0 ; +} + +int +idxd_stats_reset(struct rte_dmadev *dev, uint16_t vchan __rte_unused) +{ +struct idxd_dmadev *idxd = dev->dev_private; + idxd->stats = (struct rte_dmadev_stats ){0 }; +return 0 ; +} +int idxd_info_get (const struct rte_dmadev *dev,struct rte_dmadev_info *info,uint32_t size) {
drivers/dma/idxd/idxd_internal.h +3 -0
@@ -95,5 +95,8 @@ uint16_t idxd_completed(struct rte_dmadev *dev, uint16_t qid, uint16_t max_ops, uint16_t idxd_completed_status(struct rte_dmadev *dev, uint16_t qid __rte_unused,uint16_t max_ops,uint16_t *last_idx,enum rte_dma_status_code *status); +int idxd_stats_get (const struct rte_dmadev *dev,uint16_t vchan, +struct rte_dmadev_stats *stats,uint32_t stats_sz); +int idxd_stats_reset (struct rte_dmadev *dev,uint16_t vchan);#endif /* _IDXD_INTERNAL_H_ */
drivers/dma/idxd/idxd_pci.c +2 -0
@@ -114,6 +114,8 @@ static const struct rte_dmadev_ops idxd_pci_ops = { .dev_configure = idxd_configure, .vchan_setup = idxd_vchan_setup, .dev_info_get = idxd_info_get, + .stats_get = idxd_stats_get, + .stats_reset = idxd_stats_reset, .dev_start = idxd_pci_dev_start, .dev_stop = idxd_pci_dev_stop, };
Signature · 1 line
2.30.2
PATCH v2 13/16 dma/idxd: add vchan idle function
In reply to Kevin LaatzWhen testing dmadev drivers, it is useful to have the HW device in a known state. This patch adds the implementation of the function which will wait for the device to be idle (all jobs completed) before proceeding.
--- drivers/dma/idxd/idxd_bus.c | 1 + drivers/dma/idxd/idxd_common.c | 10 ++++++++++ drivers/dma/idxd/idxd_internal.h | 1 + drivers/dma/idxd/idxd_pci.c | 1 + 4 files changed, 13 insertions(+)
drivers/dma/idxd/idxd_bus.c +1 -0
@@ -100,6 +100,7 @@ static const struct rte_dmadev_ops idxd_vdev_ops = { .dev_info_get = idxd_info_get, .stats_get = idxd_stats_get, .stats_reset = idxd_stats_reset, + .vchan_idle = idxd_vchan_idle, }; static void *
drivers/dma/idxd/idxd_common.c +10 -0
@@ -165,6 +165,16 @@ get_comp_status(struct idxd_completion *c) } } +int +idxd_vchan_idle(const struct rte_dmadev *dev, uint16_t vchan __rte_unused) +{ +struct idxd_dmadev *idxd = dev->dev_private; +uint16_t last_batch_write = idxd->batch_idx_write ==0 ? idxd->max_batches : + idxd->batch_idx_write -1 ; + +return (idxd->batch_comp_ring[last_batch_write].status !=0 ); +} + static __rte_always_inline intbatch_ok (struct idxd_dmadev *idxd,uint8_t max_ops,enum rte_dma_status_code *status) {
drivers/dma/idxd/idxd_internal.h +1 -0
@@ -98,5 +98,6 @@ uint16_t idxd_completed_status(struct rte_dmadev *dev, uint16_t qid __rte_unusedint idxd_stats_get (const struct rte_dmadev *dev,uint16_t vchan,struct rte_dmadev_stats *stats,uint32_t stats_sz);int idxd_stats_reset (struct rte_dmadev *dev,uint16_t vchan); +int idxd_vchan_idle (const struct rte_dmadev *dev,uint16_t vchan);#endif /* _IDXD_INTERNAL_H_ */
drivers/dma/idxd/idxd_pci.c +1 -0
@@ -118,6 +118,7 @@ static const struct rte_dmadev_ops idxd_pci_ops = { .stats_reset = idxd_stats_reset, .dev_start = idxd_pci_dev_start, .dev_stop = idxd_pci_dev_stop, + .vchan_idle = idxd_vchan_idle, };/* each portal uses 4 x 4k pages */
Signature · 1 line
2.30.2
PATCH v2 14/16 dma/idxd: move dpdk_idxd_cfg.py from raw to dma
In reply to Kevin LaatzFrom: Conor Walsh <[email protected]>
Move the example script for configuring IDXD devices bound to the IDXD kernel driver from raw to dma, and create a symlink to still allow use from raw.
--- drivers/dma/idxd/dpdk_idxd_cfg.py | 117 +++++++++++++++++++++++++++++ drivers/raw/ioat/dpdk_idxd_cfg.py | 118 +----------------------------- 2 files changed, 118 insertions(+), 117 deletions(-) create mode 100755 drivers/dma/idxd/dpdk_idxd_cfg.py mode change 100755 => 120000 drivers/raw/ioat/dpdk_idxd_cfg.py
drivers/dma/idxd/dpdk_idxd_cfg.py new file +117 -0
@@ -0,0 +1,117 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2020 Intel Corporation + +""" +Configure an entire Intel DSA instance, using idxd kernel driver, for DPDK use +""" + +import sys +import argparse +import os +import os.path + + +class SysfsDir: + "Used to read/write paths in a sysfs directory" + def __init__(self, path): + self.path = path + + def read_int(self, filename): + "Return a value from sysfs file" + with open(os.path.join(self.path, filename)) as f: + return int(f.readline()) + + def write_values(self, values): + "write dictionary, where key is filename and value is value to write" + for filename, contents in values.items(): + with open(os.path.join(self.path, filename), "w") as f: + f.write(str(contents)) + + +def reset_device(dsa_id): + "Reset the DSA device and all its queues" + drv_dir = SysfsDir("/sys/bus/dsa/drivers/dsa") + drv_dir.write_values({"unbind": f"dsa{dsa_id}"}) + + +def get_pci_dir(pci): + "Search for the sysfs directory of the PCI device" + base_dir = '/sys/bus/pci/devices/' + for path, dirs, files in os.walk(base_dir): + for dir in dirs: + if pci in dir: + return os.path.join(base_dir, dir) + sys.exit(f"Could not find sysfs directory for device {pci}") + + +def get_dsa_id(pci): + "Get the DSA instance ID using the PCI address of the device" + pci_dir = get_pci_dir(pci) + for path, dirs, files in os.walk(pci_dir): + for dir in dirs: + if dir.startswith('dsa') and 'wq' not in dir: + return int(dir[3:]) + sys.exit(f"Could not get device ID for device {pci}") + + +def configure_dsa(dsa_id, queues, prefix): + "Configure the DSA instance with appropriate number of queues" + dsa_dir = SysfsDir(f"/sys/bus/dsa/devices/dsa{dsa_id}") + drv_dir = SysfsDir("/sys/bus/dsa/drivers/dsa") + + max_groups = dsa_dir.read_int("max_groups") + max_engines = dsa_dir.read_int("max_engines") + max_queues = dsa_dir.read_int("max_work_queues") + max_work_queues_size = dsa_dir.read_int("max_work_queues_size") + + nb_queues = min(queues, max_queues) + if queues > nb_queues: + print(f"Setting number of queues to max supported value: {max_queues}") + + # we want one engine per group, and no more engines than queues + nb_groups = min(max_engines, max_groups, nb_queues) + for grp in range(nb_groups): + dsa_dir.write_values({f"engine{dsa_id}.{grp}/group_id": grp}) + + # configure each queue + for q in range(nb_queues): + wq_dir = SysfsDir(os.path.join(dsa_dir.path, f"wq{dsa_id}.{q}")) + wq_dir.write_values({"group_id": q % nb_groups, + "type": "user", + "mode": "dedicated", + "name": f"{prefix}_wq{dsa_id}.{q}", + "priority": 1, + "size": int(max_work_queues_size / nb_queues)}) + + # enable device and then queues + drv_dir.write_values({"bind": f"dsa{dsa_id}"}) + for q in range(nb_queues): + drv_dir.write_values({"bind": f"wq{dsa_id}.{q}"}) + + +def main(args): + "Main function, does arg parsing and calls config function" + arg_p = argparse.ArgumentParser( + description="Configure whole DSA device instance for DPDK use") + arg_p.add_argument('dsa_id', + help="Specify DSA instance either via DSA instance number or PCI address") + arg_p.add_argument('-q', metavar='queues', type=int, default=255, + help="Number of queues to set up") + arg_p.add_argument('--name-prefix', metavar='prefix', dest='prefix', + default="dpdk", + help="Prefix for workqueue name to mark for DPDK use [default: 'dpdk']") + arg_p.add_argument('--reset', action='store_true', + help="Reset DSA device and its queues") + parsed_args = arg_p.parse_args(args[1:]) + + dsa_id = parsed_args.dsa_id + dsa_id = get_dsa_id(dsa_id) if ':' in dsa_id else dsa_id + if parsed_args.reset: + reset_device(dsa_id) + else: + configure_dsa(dsa_id, parsed_args.q, parsed_args.prefix) + + +if __name__ == "__main__": + main(sys.argv)
drivers/raw/ioat/dpdk_idxd_cfg.py deleted +0 -117
117 lines not on this page · raw message
drivers/raw/ioat/dpdk_idxd_cfg.py new file +1 -0
@@ -0,0 +1 @@ +../../dma/idxd/dpdk_idxd_cfg.py
Signature · 1 line
2.30.2
PATCH v2 15/16 devbind: add dma device class
In reply to Kevin LaatzAdd a new class for DMA devices. Devices listed under the DMA class are to be used with the dmadev library.
--- usertools/dpdk-devbind.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
usertools/dpdk-devbind.py +9 -3
@@ -69,12 +69,13 @@ network_devices = [network_class, cavium_pkx, avp_vnic, ifpga_class] baseband_devices = [acceleration_class] crypto_devices = [encryption_class, intel_processor_class] +dma_devices = [] eventdev_devices = [cavium_sso, cavium_tim, intel_dlb, octeontx2_sso] mempool_devices = [cavium_fpa, octeontx2_npa] compress_devices = [cavium_zip] regex_devices = [octeontx2_ree] -misc_devices = [cnxk_bphy, cnxk_bphy_cgx, intel_ioat_bdw, intel_ioat_skx, intel_ioat_icx, intel_idxd_spr, - intel_ntb_skx, intel_ntb_icx, +misc_devices = [cnxk_bphy, cnxk_bphy_cgx, intel_ioat_bdw, intel_ioat_skx, + intel_ioat_icx, intel_idxd_spr, intel_ntb_skx, intel_ntb_icx, octeontx2_dma] # global dict ethernet devices present. Dictionary indexed by PCI address.
@@ -583,6 +584,9 @@ def show_status(): if status_dev in ["crypto", "all"]: show_device_status(crypto_devices, "Crypto") + if status_dev in ["dma", "all"]: + show_device_status(dma_devices, "DMA") + if status_dev in ["event", "all"]: show_device_status(eventdev_devices, "Eventdev")
@@ -651,7 +655,7 @@ def parse_args(): parser.add_argument( '--status-dev', help="Print the status of given device group.", - choices=['baseband', 'compress', 'crypto', 'event', + choices=['baseband', 'compress', 'crypto', 'dma', 'event', 'mempool', 'misc', 'net', 'regex']) bind_group = parser.add_mutually_exclusive_group() bind_group.add_argument(
@@ -732,6 +736,7 @@ def do_arg_actions(): get_device_details(network_devices) get_device_details(baseband_devices) get_device_details(crypto_devices) + get_device_details(dma_devices) get_device_details(eventdev_devices) get_device_details(mempool_devices) get_device_details(compress_devices)
@@ -754,6 +759,7 @@ def main(): get_device_details(network_devices) get_device_details(baseband_devices) get_device_details(crypto_devices) + get_device_details(dma_devices) get_device_details(eventdev_devices) get_device_details(mempool_devices) get_device_details(compress_devices)
Signature · 1 line
2.30.2
PATCH v2 16/16 devbind: move idxd device ID to dmadev class
In reply to Kevin LaatzThe dmadev library is the preferred abstraction for using IDXD devices and will replace the rawdev implementation in future. This patch moves the IDXD device ID to the dmadev class.
--- usertools/dpdk-devbind.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
usertools/dpdk-devbind.py +2 -2
@@ -69,13 +69,13 @@ network_devices = [network_class, cavium_pkx, avp_vnic, ifpga_class] baseband_devices = [acceleration_class] crypto_devices = [encryption_class, intel_processor_class] -dma_devices = [] +dma_devices = [intel_idxd_spr] eventdev_devices = [cavium_sso, cavium_tim, intel_dlb, octeontx2_sso] mempool_devices = [cavium_fpa, octeontx2_npa] compress_devices = [cavium_zip] regex_devices = [octeontx2_ree] misc_devices = [cnxk_bphy, cnxk_bphy_cgx, intel_ioat_bdw, intel_ioat_skx, - intel_ioat_icx, intel_idxd_spr, intel_ntb_skx, intel_ntb_icx, + intel_ioat_icx, intel_ntb_skx, intel_ntb_icx, octeontx2_dma] # global dict ethernet devices present. Dictionary indexed by PCI address.
Signature · 1 line
2.30.2
v3 cover add dmadev driver for idxd devices
In reply to Kevin LaatzThis patchset adds a dmadev driver and associated documentation to support Intel Data Streaming Accelerator devices. This driver is intended to ultimately replace the current IDXD part of the IOAT rawdev driver.
NOTE: This patchset has several dependencies:
- v21 of the dmadev lib set [1]
- v3 of the dmadev test suite [2]
[1] http://patches.dpdk.org/project/dpdk/list/?series=18738
[2] http://patches.dpdk.org/project/dpdk/list/?series=18744
v3:
* rebased on above patchsets
* added burst capacity API
v2:
* rebased on above patchsets
* added API to check for device being idle
* added devbind updates for DMA devices
* fixed issue identified by internal coverity scan
* other minor miscellaneous changes and fixes
Bruce Richardson (1):
raw/ioat: only build if dmadev not present
Conor Walsh (1):
dma/idxd: move dpdk_idxd_cfg.py from raw to dma
Kevin Laatz (15):
doc: initial commit for dmadevs section dma/idxd: add skeleton for VFIO based DSA device dma/idxd: add bus device probing
dma/idxd: create dmadev instances on bus probe dma/idxd: create dmadev instances on pci probe dma/idxd: add datapath structures
dma/idxd: add configure and info_get functions dma/idxd: add start and stop functions for pci devices dma/idxd: add data-path job submission functions dma/idxd: add data-path job completion functions dma/idxd: add operation statistic tracking dma/idxd: add vchan status function
dma/idxd: add burst capacity API
devbind: add dma device class
devbind: move idxd device ID to dmadev class
MAINTAINERS | 10 + app/test/test_dmadev.c | 2 + doc/guides/dmadevs/idxd.rst | 255 ++++++++++ doc/guides/dmadevs/index.rst | 14 + doc/guides/index.rst | 1 + doc/guides/rel_notes/release_21_11.rst | 5 + drivers/dma/idxd/dpdk_idxd_cfg.py | 117 +++++ drivers/dma/idxd/idxd_bus.c | 378 +++++++++++++++ drivers/dma/idxd/idxd_common.c | 616 +++++++++++++++++++++++++ drivers/dma/idxd/idxd_hw_defs.h | 131 ++++++ drivers/dma/idxd/idxd_internal.h | 108 +++++ drivers/dma/idxd/idxd_pci.c | 381 +++++++++++++++ drivers/dma/idxd/meson.build | 10 + drivers/dma/idxd/version.map | 3 + drivers/dma/meson.build | 1 + drivers/raw/ioat/dpdk_idxd_cfg.py | 118 +---- drivers/raw/ioat/meson.build | 23 +- usertools/dpdk-devbind.py | 12 +- 18 files changed, 2062 insertions(+), 123 deletions(-) create mode 100644 doc/guides/dmadevs/idxd.rst create mode 100644 doc/guides/dmadevs/index.rst create mode 100755 drivers/dma/idxd/dpdk_idxd_cfg.py create mode 100644 drivers/dma/idxd/idxd_bus.c create mode 100644 drivers/dma/idxd/idxd_common.c create mode 100644 drivers/dma/idxd/idxd_hw_defs.h create mode 100644 drivers/dma/idxd/idxd_internal.h create mode 100644 drivers/dma/idxd/idxd_pci.c create mode 100644 drivers/dma/idxd/meson.build create mode 100644 drivers/dma/idxd/version.map mode change 100755 => 120000 drivers/raw/ioat/dpdk_idxd_cfg.py
Signature · 1 line
2.30.2
PATCH v3 1/17 raw/ioat: only build if dmadev not present
From: Bruce Richardson <[email protected]>
Only build the rawdev IDXD/IOAT drivers if the dmadev drivers are not present.
--- drivers/raw/ioat/meson.build | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-)
drivers/raw/ioat/meson.build +20 -3
@@ -2,14 +2,31 @@ # Copyright 2019 Intel Corporation build = dpdk_conf.has('RTE_ARCH_X86') +# only use ioat rawdev driver if we don't have the equivalent dmadev ones +if not dpdk_conf.has('RTE_DMA_IDXD') and not dpdk_conf.has('RTE_DMA_IOAT') + build = false + subdir_done() +endif + reason = 'only supported on x86' sources = files( - 'idxd_bus.c', - 'idxd_pci.c', 'ioat_common.c', - 'ioat_rawdev.c', 'ioat_rawdev_test.c', ) + +if not dpdk_conf.has('RTE_DMA_IDXD') + sources += files( + 'idxd_bus.c', + 'idxd_pci.c', + ) +endif + +if not dpdk_conf.has('RTE_DMA_IOAT') + sources += files ( + 'ioat_rawdev.c', + ) +endif + deps += ['bus_pci', 'mbuf', 'rawdev'] headers = files( 'rte_ioat_rawdev.h',
Signature · 1 line
2.30.2
Re: [dpdk-dev] [PATCH v3 01/17] raw/ioat: only build if dmadev not present
Quoted 16 lines
From: Bruce Richardson <[email protected]>
Only build the rawdev IDXD/IOAT drivers if the dmadev drivers are not present.
Signed-off-by Bruce Richardson <[email protected]>--- drivers/raw/ioat/meson.build | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-)drivers/raw/ioat/meson.build +0
-0
drivers/raw/ioat/meson.build line 2
Quoted 1 line
drivers/raw/ioat/meson.build +0
-0@@ -2,14 +2,31 @@ # Copyright 2019 Intel Corporation
Minor nit the copyright should be updated to 2019-2021
drivers/raw/ioat/meson.build line 6
Quoted 3 lines
drivers/raw/ioat/meson.build +2
-0build = dpdk_conf.has('RTE_ARCH_X86') +# only use ioat rawdev driver if we don't have the equivalent dmadev ones +if not dpdk_conf.has('RTE_DMA_IDXD') and not dpdk_conf.has('RTE_DMA_IOAT')
When disabling the dmadev drivers using -Ddisable_drivers=dma/* the rawdev driver isnt available to use for dma devices.
The way this is ATM if dmadev is disabled it doesnt build rawdev.
The logic should be - if dpdk_conf.has('RTE_DMA_IDXD') and dpdk_conf.has('RTE_DMA_IOAT')
<snip>
Re: [dpdk-dev] [PATCH v3 01/17] raw/ioat: only build if dmadev not present
Quoted 26 lines · Conor Walsh
Quoted 16 lines
From: Bruce Richardson <[email protected]>
Only build the rawdev IDXD/IOAT drivers if the dmadev drivers are not present.
Signed-off-by Bruce Richardson <[email protected]>---
drivers/raw/ioat/meson.build| 23 ++++++++++++++++++++---1 file changed, 20 insertions(+), 3 deletions(-)drivers/raw/ioat/meson.build +0
-0drivers/raw/ioat/meson.build line 2
Quoted 1 line
drivers/raw/ioat/meson.build +0
-0@@ -2,14 +2,31 @@ # Copyright 2019 Intel CorporationMinor nit the copyright should be updated to 2019-2021
Quoted 5 lines
drivers/raw/ioat/meson.build +1
-0build = dpdk_conf.has('RTE_ARCH_X86') +# only use ioat rawdev driver if we don't have the equivalent dmadevones
+if notdpdk_conf.has('RTE_DMA_IDXD')and notdpdk_conf.has('RTE_DMA_IOAT')When disabling the dmadev drivers using -Ddisable_drivers=dma/* the rawdev driver isnt available to use for dma devices.
Quoted 4 lines
The way this is ATM if dmadev is disabled it doesnt build rawdev.
The logic should be - if
dpdk_conf.has('RTE_DMA_IDXD')anddpdk_conf.has('RTE_DMA_IOAT')
Will fix this in v4, thanks!
PATCH v3 2/17 doc: initial commit for dmadevs section
In reply to Kevin LaatzAdd new section to the programmer's guide for dmadev devices.
--- doc/guides/dmadevs/index.rst | 14 ++++++++++++++ doc/guides/index.rst | 1 + 2 files changed, 15 insertions(+) create mode 100644 doc/guides/dmadevs/index.rst
doc/guides/dmadevs/index.rst new file +14 -0
@@ -0,0 +1,14 @@ +.. SPDX-License-Identifier: BSD-3-Clause + Copyright(c) 2021 Intel Corporation. + +DMA Device Drivers +================== + +The following are a list of DMA device PMDs, which can be used from an +application through DMAdev API. + +.. toctree:: + :maxdepth: 2 + :numbered: + + idxd
doc/guides/index.rst +1 -0
@@ -19,6 +19,7 @@ DPDK documentation bbdevs/index cryptodevs/index compressdevs/index + dmadevs/index vdpadevs/index regexdevs/index eventdevs/index
Signature · 1 line
2.30.2
Re: [dpdk-dev] [PATCH v3 02/17] doc: initial commit for dmadevs section
Quoted 5 lines
Add new section to the programmer's guide for dmadev devices.
Signed-off-by Kevin Laatz <[email protected]>Acked-by Bruce Richardson <[email protected]>
<snip>
PATCH v3 3/17 dma/idxd: add skeleton for VFIO based DSA device
In reply to Kevin LaatzAdd the basic device probe/remove skeleton code for DSA device bound to the vfio pci driver. Relevant documentation and MAINTAINERS update also included.
--- MAINTAINERS | 10 +++++ doc/guides/dmadevs/idxd.rst | 58 ++++++++++++++++++++++++++ doc/guides/rel_notes/release_21_11.rst | 5 +++ drivers/dma/idxd/idxd_internal.h | 27 ++++++++++++ drivers/dma/idxd/idxd_pci.c | 55 ++++++++++++++++++++++++ drivers/dma/idxd/meson.build | 7 ++++ drivers/dma/idxd/version.map | 3 ++ drivers/dma/meson.build | 1 + 8 files changed, 166 insertions(+) create mode 100644 doc/guides/dmadevs/idxd.rst create mode 100644 drivers/dma/idxd/idxd_internal.h create mode 100644 drivers/dma/idxd/idxd_pci.c create mode 100644 drivers/dma/idxd/meson.build create mode 100644 drivers/dma/idxd/version.map
MAINTAINERS +10 -0
@@ -1199,6 +1199,16 @@ F: doc/guides/compressdevs/zlib.rst F: doc/guides/compressdevs/features/zlib.ini +DMAdev Drivers +-------------- + +Intel IDXD - EXPERIMENTAL +M: Bruce Richardson <[email protected]> +M: Kevin Laatz <[email protected]> +F: drivers/dma/idxd/ +F: doc/guides/dmadevs/idxd.rst + + RegEx Drivers -------------
doc/guides/dmadevs/idxd.rst new file +58 -0
58 lines not on this page · raw message
doc/guides/rel_notes/release_21_11.rst +5 -0
@@ -67,6 +67,11 @@ New Features The dmadev library provides a DMA device framework for management and provision of hardware and software DMA devices. +* **Added IDXD dmadev driver implementation.** + + The IDXD dmadev driver provide device drivers for the Intel DSA devices. + This device driver can be used through the generic dmadev API. + Removed Items -------------
drivers/dma/idxd/idxd_internal.h new file +27 -0
@@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright 2021 Intel Corporation +*/ + +#ifndef _IDXD_INTERNAL_H_ +#define _IDXD_INTERNAL_H_ + +/** +* @file idxd_internal.h +* +* Internal data structures for the idxd/DSA driver for dmadev +* +* @warning +* @b EXPERIMENTAL: these structures and APIs may change without prior notice +*/ + +extern int idxd_pmd_logtype; + +#define IDXD_PMD_LOG(level, fmt, args...) rte_log(RTE_LOG_ ## level, \ + idxd_pmd_logtype, "IDXD: %s(): " fmt "\n", __func__, ##args) + +#define IDXD_PMD_DEBUG(fmt, args...) IDXD_PMD_LOG(DEBUG, fmt, ## args) +#define IDXD_PMD_INFO(fmt, args...) IDXD_PMD_LOG(INFO, fmt, ## args) +#define IDXD_PMD_ERR(fmt, args...) IDXD_PMD_LOG(ERR, fmt, ## args) +#define IDXD_PMD_WARN(fmt, args...) IDXD_PMD_LOG(WARNING, fmt, ## args) + +#endif /* _IDXD_INTERNAL_H_ */
drivers/dma/idxd/idxd_pci.c new file +55 -0
55 lines not on this page · raw message
drivers/dma/idxd/meson.build new file +7 -0
@@ -0,0 +1,7 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2021 Intel Corporation + +deps += ['bus_pci'] +sources = files( + 'idxd_pci.c' +)
drivers/dma/idxd/version.map new file +3 -0
@@ -0,0 +1,3 @@ +DPDK_21 { + local: *; +};
drivers/dma/meson.build +1 -0
@@ -6,6 +6,7 @@ if is_windows endif drivers = [ + 'idxd', 'skeleton', ] std_deps = ['dmadev']
Signature · 1 line
2.30.2
Re: [dpdk-dev] [PATCH v3 03/17] dma/idxd: add skeleton for VFIO based DSA device
Quoted 6 lines · Kevin Laatz
Add the basic device probe/remove skeleton code for DSA device bound to the vfio pci driver. Relevant documentation and
MAINTAINERSupdate also included.Signed-off-by Bruce Richardson <[email protected]>Signed-off-by Kevin Laatz <[email protected]>
<snip>
PATCH v3 4/17 dma/idxd: add bus device probing
In reply to Kevin LaatzAdd the basic device probing for DSA devices bound to the IDXD kernel driver. These devices can be configured via sysfs and made available to DPDK if they are found during bus scan. Relevant documentation is included.
--- doc/guides/dmadevs/idxd.rst | 64 +++++++ drivers/dma/idxd/idxd_bus.c | 352 +++++++++++++++++++++++++++++++++++ drivers/dma/idxd/meson.build | 1 + 3 files changed, 417 insertions(+) create mode 100644 drivers/dma/idxd/idxd_bus.c
doc/guides/dmadevs/idxd.rst +64 -0
@@ -32,6 +32,56 @@ target platform is x86-based. No additional compilation steps are necessary. Device Setup ------------- +Intel\ |reg| DSA devices can use the IDXD kernel driver or DPDK-supported drivers, +such as ``vfio-pci``. Both are supported by the IDXD PMD. + +Intel\ |reg| DSA devices using IDXD kernel driver +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +To use an Intel\ |reg| DSA device bound to the IDXD kernel driver, the device must first be configured. +The `accel-config <https://github.com/intel/idxd-config>`_ utility library can be used for configuration. + +.. note:: + The device configuration can also be done by directly interacting with the sysfs nodes. + An example of how this may be done can be seen in the script ``dpdk_idxd_cfg.py`` + included in the driver source directory. + +There are some mandatory configuration steps before being able to use a device with an application. +The internal engines, which do the copies or other operations, +and the work-queues, which are used by applications to assign work to the device, +need to be assigned to groups, and the various other configuration options, +such as priority or queue depth, need to be set for each queue. + +To assign an engine to a group:: + + $ accel-config config-engine dsa0/engine0.0 --group-id=0 + $ accel-config config-engine dsa0/engine0.1 --group-id=1 + +To assign work queues to groups for passing descriptors to the engines a similar accel-config command can be used. +However, the work queues also need to be configured depending on the use case. +Some configuration options include: + +* mode (Dedicated/Shared): Indicates whether a WQ may accept jobs from multiple queues simultaneously. +* priority: WQ priority between 1 and 15. Larger value means higher priority. +* wq-size: the size of the WQ. Sum of all WQ sizes must be less that the total-size defined by the device. +* type: WQ type (kernel/mdev/user). Determines how the device is presented. +* name: identifier given to the WQ. + +Example configuration for a work queue:: + + $ accel-config config-wq dsa0/wq0.0 --group-id=0 \ + --mode=dedicated --priority=10 --wq-size=8 \ + --type=user --name=dpdk_app1 + +Once the devices have been configured, they need to be enabled:: + + $ accel-config enable-device dsa0 + $ accel-config enable-wq dsa0/wq0.0 + +Check the device configuration:: + + $ accel-config list + Devices using VFIO/UIO drivers ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -56,3 +106,17 @@ If fewer workqueues are required, then the ``max_queues`` parameter may be passe the device driver on the EAL commandline, via the ``allowlist`` or ``-a`` flag e.g.:: $ dpdk-test -a <b:d:f>,max_queues=4 + +For devices bound to the IDXD kernel driver, +the DPDK IDXD driver will automatically perform a scan for available workqueues +to use. Any workqueues found listed in ``/dev/dsa`` on the system will be checked +in ``/sys``, and any which have ``dpdk_`` prefix in their name will be automatically +probed by the driver to make them available to the application. +Alternatively, to support use by multiple DPDK processes simultaneously, +the value used as the DPDK ``--file-prefix`` parameter may be used as a workqueue +name prefix, instead of ``dpdk_``, allowing each DPDK application instance to only +use a subset of configured queues. + +Once probed successfully, irrespective of kernel driver, the device will appear as a ``dmadev``, +that is a "DMA device type" inside DPDK, and can be accessed using APIs from the +``rte_dmadev`` library.
drivers/dma/idxd/idxd_bus.c new file +352 -0
352 lines not on this page · raw message
drivers/dma/idxd/meson.build +1 -0
@@ -3,5 +3,6 @@ deps += ['bus_pci'] sources = files( + 'idxd_bus.c', 'idxd_pci.c' )
Signature · 1 line
2.30.2
Re: [dpdk-dev] [PATCH v3 04/17] dma/idxd: add bus device probing
<snip>
drivers/dma/idxd/idxd_bus.c line 89
Quoted 2 lines
drivers/dma/idxd/idxd_bus.c new file +2
-0+static void * +idxd_vdev_mmap_wq (struct rte_dsa_device *dev)
Some inconsistent naming between vdev and bus in some of these functions the above should be idxd_bus_mmap_wq for example.
Quoted 11 lines
drivers/dma/idxd/idxd_bus.c new file +11
-0+{ +void *addr; +char path[PATH_MAX ]; +int fd; + +snprintf (path,sizeof (path),"%s/%s" ,dsa_get_dev_path (), dev->wq_name); + fd =open (path,O_RDWR ); +if (fd <0 ) { +IDXD_PMD_ERR ("Failed to open device path: %s" , path); +return NULL ; + }
drivers/dma/idxd/idxd_bus.c line 110
Quoted 10 lines
drivers/dma/idxd/idxd_bus.c new file +10
-0+ + addr =mmap (NULL ,0x1000 ,PROT_WRITE ,MAP_SHARED , fd,0 ); +close (fd); +if (addr ==MAP_FAILED ) { +IDXD_PMD_ERR ("Failed to mmap device %s" , path); +return NULL ; + } + +return addr; +}
Re: [dpdk-dev] [PATCH v3 04/17] dma/idxd: add bus device probing
Quoted 7 lines · Conor Walsh
<snip>
drivers/dma/idxd/idxd_bus.c line 89
Quoted 2 lines
drivers/dma/idxd/idxd_bus.c new file +2
-0+static void * +idxd_vdev_mmap_wq (struct rte_dsa_device *dev)Some inconsistent naming between vdev and bus in some of these functions the above should be
idxd_bus_mmap_wqfor example.
Will fix in v4, thanks.
Quoted 2 lines
Re: [dpdk-dev] [PATCH v3 04/17] dma/idxd: add bus device probing
In reply to Kevin LaatzHi Kevin,
Quoted 4 lines · Kevin Laatz
Add the basic device probing for DSA devices bound to the IDXD kernel driver. These devices can be configured via sysfs and made available to DPDK if they are found during bus scan. Relevant documentation is included.
Quoted 9 lines
Signed-off-by Bruce Richardson <[email protected]>Signed-off-by Kevin Laatz <[email protected]>--- doc/guides/dmadevs/idxd.rst | 64 +++++++ drivers/dma/idxd/idxd_bus.c | 352 +++++++++++++++++++++++++++++++++++ drivers/dma/idxd/meson.build | 1 + 3 files changed, 417 insertions(+) create mode 100644 drivers/dma/idxd/idxd_bus.c
Sorry if it has been asked before, but what is the reason this DSA bus driver is not in drivers/bus/?
Re: [dpdk-dev] [PATCH v3 04/17] dma/idxd: add bus device probing
Quoted 17 lines · Maxime Coquelin
Hi Kevin,
Quoted 4 lines · Kevin Laatz
Add the basic device probing for DSA devices bound to the IDXD kernel driver. These devices can be configured via sysfs and made available to DPDK if they are found during bus scan. Relevant documentation is included.
Quoted 9 lines
Signed-off-by Bruce Richardson <[email protected]>Signed-off-by Kevin Laatz <[email protected]>--- doc/guides/dmadevs/idxd.rst | 64 +++++++ drivers/dma/idxd/idxd_bus.c | 352 +++++++++++++++++++++++++++++++++++ drivers/dma/idxd/meson.build | 1 + 3 files changed, 417 insertions(+) create mode 100644 drivers/dma/idxd/idxd_bus.c
Quoted 3 lines
Sorry if it has been asked before, but what is the reason this DSA bus driver is not in
drivers/bus/?
This bus-driver solution came out of discussion previously when we were looking to add DSA support to the ioat driver. Individual device drivers of any class cannot themselves do any probing to discover devices, but only bus drivers can do that. Therefore, to enable discovery of DSA devices used by the kernel driver, a custom bus driver is necessary. Since this bus driver only supports discovery of DSA devices using a single driver type behind the scenes (referred to in previous discussions as a "singleton" bus driver), it's kept in with the rest of the DSA driver code. It's not a full bus driver, more a minimal driver whose job it is to scan /dev/dsa and initialise the proper DSA/idxd driver.
So we could move it to /dev/bus, but I think it would lead to overall higher maintenance and I fail to see any real benefits.
/Bruce
PATCH v3 5/17 dma/idxd: create dmadev instances on bus probe
In reply to Kevin LaatzWhen a suitable device is found during the bus scan/probe, create a dmadev instance for each HW queue. Internal structures required for device creation are also added.
--- drivers/dma/idxd/idxd_bus.c | 20 ++++++++- drivers/dma/idxd/idxd_common.c | 75 ++++++++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 40 +++++++++++++++++ drivers/dma/idxd/meson.build | 1 + 4 files changed, 135 insertions(+), 1 deletion(-) create mode 100644 drivers/dma/idxd/idxd_common.c
drivers/dma/idxd/idxd_bus.c +19 -1
@@ -85,6 +85,18 @@ dsa_get_sysfs_path(void)return path ? path :DSA_SYSFS_PATH ; } +static int +idxd_dev_close (struct rte_dmadev *dev) +{ +struct idxd_dmadev *idxd = dev->data->dev_private; +munmap (idxd->portal,0x1000 ); +return 0 ; +} + +static const struct rte_dmadev_ops idxd_vdev_ops = { + .dev_close = idxd_dev_close, +}; +static void *idxd_vdev_mmap_wq (struct rte_dsa_device *dev) {
@@ -206,7 +218,7 @@ idxd_probe_dsa(struct rte_dsa_device *dev)return -1 ; idxd.max_batch_size = ret; idxd.qid = dev->addr.wq_id; - idxd.u.vdev.dsa_id = dev->addr.device_id; + idxd.u.bus.dsa_id = dev->addr.device_id; idxd.sva_support =1 ; idxd.portal =idxd_vdev_mmap_wq (dev);
@@ -215,6 +227,12 @@ idxd_probe_dsa(struct rte_dsa_device *dev)return -ENOENT ; } + ret =idxd_dmadev_create (dev->wq_name, &dev->device, &idxd, &idxd_vdev_ops); +if (ret) { +IDXD_PMD_ERR ("Failed to create rawdev %s" , dev->wq_name); +return ret; + } +return 0 ; }
drivers/dma/idxd/idxd_common.c new file +75 -0
75 lines not on this page · raw message
drivers/dma/idxd/idxd_internal.h +40 -0
@@ -24,4 +24,44 @@ extern int idxd_pmd_logtype; #define IDXD_PMD_ERR(fmt, args...) IDXD_PMD_LOG(ERR, fmt, ## args) #define IDXD_PMD_WARN(fmt, args...) IDXD_PMD_LOG(WARNING, fmt, ## args) +struct idxd_dmadev { +/* counters to track the batches */ +unsigned short max_batches; +unsigned short batch_idx_read; +unsigned short batch_idx_write; + +/* track descriptors and handles */ +unsigned short desc_ring_mask; +unsigned short ids_avail;/* handles for ops completed */ +unsigned short ids_returned;/* the read pointer for hdls/desc rings */ +unsigned short batch_start;/* start+size == write pointer for hdls/desc */ +unsigned short batch_size; + +void *portal;/* address to write the batch descriptor */ + +struct idxd_completion *batch_comp_ring; +unsigned short *batch_idx_ring;/* store where each batch ends */ + +struct rte_dmadev_stats stats; + +rte_iova_t batch_iova;/* base address of the batch comp ring */ +rte_iova_t desc_iova;/* base address of desc ring, needed for completions */ + +unsigned short max_batch_size; + +struct rte_dmadev *dmadev; +struct rte_dmadev_vchan_conf qcfg; +uint8_t sva_support; +uint8_t qid; + +union { +struct { +unsigned int dsa_id; + } bus; + } u; +}; + +int idxd_dmadev_create (const char *name,struct rte_device *dev, +const struct idxd_dmadev *base_idxd,const struct rte_dmadev_ops *ops); +#endif /* _IDXD_INTERNAL_H_ */
drivers/dma/idxd/meson.build +1 -0
@@ -4,5 +4,6 @@ deps += ['bus_pci'] sources = files( 'idxd_bus.c', + 'idxd_common.c', 'idxd_pci.c' )
Signature · 1 line
2.30.2
Re: [dpdk-dev] [PATCH v3 05/17] dma/idxd: create dmadev instances on bus probe
<snip>
drivers/dma/idxd/idxd_bus.c idxd_probe_dsa(struct rte_dsa_device *dev) · line 221
Quoted 3 lines
idxd.qid = dev->addr.wq_id;drivers/dma/idxd/idxd_bus.c +1
-1- idxd.u.vdev.dsa_id = dev->addr.device_id; + idxd.u.bus.dsa_id = dev->addr.device_id;
This should be done in previous patch.
PATCH v3 6/17 dma/idxd: create dmadev instances on pci probe
In reply to Kevin LaatzWhen a suitable device is found during the PCI probe, create a dmadev instance for each HW queue. HW definitions required are also included.
--- drivers/dma/idxd/idxd_hw_defs.h | 71 ++++++++ drivers/dma/idxd/idxd_internal.h | 16 ++ drivers/dma/idxd/idxd_pci.c | 272 ++++++++++++++++++++++++++++++- 3 files changed, 356 insertions(+), 3 deletions(-) create mode 100644 drivers/dma/idxd/idxd_hw_defs.h
drivers/dma/idxd/idxd_hw_defs.h new file +71 -0
@@ -0,0 +1,71 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright 2021 Intel Corporation +*/ + +#ifndef _IDXD_HW_DEFS_H_ +#define _IDXD_HW_DEFS_H_ + +/*** Definitions for Intel(R) Data Streaming Accelerator ***/ + +#define IDXD_CMD_SHIFT 20 +enum rte_idxd_cmds { + idxd_enable_dev =1 , + idxd_disable_dev, + idxd_drain_all, + idxd_abort_all, + idxd_reset_device, + idxd_enable_wq, + idxd_disable_wq, + idxd_drain_wq, + idxd_abort_wq, + idxd_reset_wq, +}; + +/* General bar0 registers */ +struct rte_idxd_bar0 { + uint32_t __rte_cache_aligned version; /* offset 0x00 */ + uint64_t __rte_aligned(0x10) gencap; /* offset 0x10 */ + uint64_t __rte_aligned(0x10) wqcap; /* offset 0x20 */ + uint64_t __rte_aligned(0x10) grpcap; /* offset 0x30 */ + uint64_t __rte_aligned(0x08) engcap; /* offset 0x38 */ + uint64_t __rte_aligned(0x10) opcap; /* offset 0x40 */ + uint64_t __rte_aligned(0x20) offsets[2]; /* offset 0x60 */ + uint32_t __rte_aligned(0x20) gencfg; /* offset 0x80 */ + uint32_t __rte_aligned(0x08) genctrl; /* offset 0x88 */ + uint32_t __rte_aligned(0x10) gensts; /* offset 0x90 */ + uint32_t __rte_aligned(0x08) intcause; /* offset 0x98 */ + uint32_t __rte_aligned(0x10) cmd; /* offset 0xA0 */ + uint32_t __rte_aligned(0x08) cmdstatus; /* offset 0xA8 */ + uint64_t __rte_aligned(0x20) swerror[4]; /* offset 0xC0 */ +}; + +/* workqueue config is provided by array of uint32_t. */ +enum rte_idxd_wqcfg { + wq_size_idx,/* size is in first 32-bit value */ + wq_threshold_idx,/* WQ threshold second 32-bits */ + wq_mode_idx,/* WQ mode and other flags */ + wq_sizes_idx,/* WQ transfer and batch sizes */ + wq_occ_int_idx,/* WQ occupancy interrupt handle */ + wq_occ_limit_idx,/* WQ occupancy limit */ + wq_state_idx,/* WQ state and occupancy state */ +}; + +#define WQ_MODE_SHARED 0 +#define WQ_MODE_DEDICATED 1 +#define WQ_PRIORITY_SHIFT 4 +#define WQ_BATCH_SZ_SHIFT 5 +#define WQ_STATE_SHIFT 30 +#define WQ_STATE_MASK 0x3 + +struct rte_idxd_grpcfg { + uint64_t grpwqcfg[4] __rte_cache_aligned; /* 64-byte register set */ +uint64_t grpengcfg;/* offset 32 */ +uint32_t grpflags;/* offset 40 */ +}; + +#define GENSTS_DEV_STATE_MASK 0x03 +#define CMDSTATUS_ACTIVE_SHIFT 31 +#define CMDSTATUS_ACTIVE_MASK (1 << 31) +#define CMDSTATUS_ERR_MASK 0xFF + +#endif
drivers/dma/idxd/idxd_internal.h +16 -0
@@ -5,6 +5,10 @@#ifndef _IDXD_INTERNAL_H_#define _IDXD_INTERNAL_H_ +#include <rte_spinlock.h> + +#include "idxd_hw_defs.h" +/** * @file idxd_internal.h *
@@ -24,6 +28,16 @@ extern int idxd_pmd_logtype; #define IDXD_PMD_ERR(fmt, args...) IDXD_PMD_LOG(ERR, fmt, ## args) #define IDXD_PMD_WARN(fmt, args...) IDXD_PMD_LOG(WARNING, fmt, ## args) +struct idxd_pci_common { +rte_spinlock_t lk; + +uint8_t wq_cfg_sz; +volatile struct rte_idxd_bar0 *regs; +volatile uint32_t *wq_regs_base; +volatile struct rte_idxd_grpcfg *grp_regs; +volatile void *portals; +}; +struct idxd_dmadev {/* counters to track the batches */ unsigned short max_batches;
@@ -58,6 +72,8 @@ struct idxd_dmadev {struct {unsigned int dsa_id; } bus; + +struct idxd_pci_common *pci; } u; };
drivers/dma/idxd/idxd_pci.c +269 -3
299 lines not on this page · raw message
Signature · 1 line
2.30.2
Re: [dpdk-dev] [PATCH v3 06/17] dma/idxd: create dmadev instances on pci probe
Quoted 6 lines
When a suitable device is found during the PCI probe, create a dmadev instance for each HW queue. HW definitions required are also included.
Signed-off-by Bruce Richardson <[email protected]>Signed-off-by Kevin Laatz <[email protected]>
<snip>
PATCH v3 7/17 dma/idxd: add datapath structures
In reply to Kevin LaatzAdd data structures required for the data path for IDXD devices.
---
v2: add completion status for invalid opcode
--- drivers/dma/idxd/idxd_bus.c | 1 + drivers/dma/idxd/idxd_common.c | 33 ++++++++++++++++++ drivers/dma/idxd/idxd_hw_defs.h | 60 ++++++++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 3 ++ drivers/dma/idxd/idxd_pci.c | 2 +- 5 files changed, 98 insertions(+), 1 deletion(-)
drivers/dma/idxd/idxd_bus.c +1 -0
@@ -95,6 +95,7 @@ idxd_dev_close(struct rte_dmadev *dev)static const struct rte_dmadev_ops idxd_vdev_ops = { .dev_close = idxd_dev_close, + .dev_dump = idxd_dump, }; static void *
drivers/dma/idxd/idxd_common.c +33 -0
@@ -10,6 +10,35 @@#define IDXD_PMD_NAME_STR "dmadev_idxd" +int +idxd_dump (const struct rte_dmadev *dev,FILE *f) +{ +struct idxd_dmadev *idxd = dev->dev_private; +unsigned int i; + +fprintf (f,"== Private Data ==\n" ); +fprintf (f," Portal: %p\n" , idxd->portal); +fprintf (f," Config: { ring_size: %u }\n" , + idxd->qcfg.nb_desc); +fprintf (f," Batch ring (sz = %u, max_batches = %u):\n\t" , + idxd->max_batches +1 , idxd->max_batches); +for (i =0 ; i <= idxd->max_batches; i++) { +fprintf (f," %u " , idxd->batch_idx_ring[i]); +if (i == idxd->batch_idx_read && i == idxd->batch_idx_write) +fprintf (f,"[rd ptr, wr ptr] " ); +else if (i == idxd->batch_idx_read) +fprintf (f,"[rd ptr] " ); +else if (i == idxd->batch_idx_write) +fprintf (f,"[wr ptr] " ); +if (i == idxd->max_batches) +fprintf (f,"\n" ); + } + +fprintf (f," Curr batch: start = %u, size = %u\n" , idxd->batch_start, idxd->batch_size); +fprintf (f," IDS: avail = %u, returned: %u\n" , idxd->ids_avail, idxd->ids_returned); +return 0 ; +} + int idxd_dmadev_create(const char *name, struct rte_device *dev, const struct idxd_dmadev *base_idxd,
@@ -19,6 +48,10 @@ idxd_dmadev_create(const char *name, struct rte_device *dev,struct rte_dmadev *dmadev =NULL ;int ret =0 ; +RTE_BUILD_BUG_ON (sizeof (struct idxd_hw_desc ) !=64 ); +RTE_BUILD_BUG_ON (offsetof(struct idxd_hw_desc , size) !=32 ); +RTE_BUILD_BUG_ON (sizeof (struct idxd_completion ) !=32 ); +if (!name) {IDXD_PMD_ERR ("Invalid name of the device!" ); ret = -EINVAL ;
drivers/dma/idxd/idxd_hw_defs.h +60 -0
66 lines not on this page · raw message
drivers/dma/idxd/idxd_internal.h +3 -0
@@ -39,6 +39,8 @@ struct idxd_pci_common { };struct idxd_dmadev { +struct idxd_hw_desc *desc_ring; +/* counters to track the batches */ unsigned short max_batches;unsigned short batch_idx_read;
@@ -79,5 +81,6 @@ struct idxd_dmadev {int idxd_dmadev_create (const char *name,struct rte_device *dev,const struct idxd_dmadev *base_idxd,const struct rte_dmadev_ops *ops); +int idxd_dump (const struct rte_dmadev *dev,FILE *f);#endif /* _IDXD_INTERNAL_H_ */
drivers/dma/idxd/idxd_pci.c +1 -1
@@ -60,7 +60,7 @@ idxd_is_wq_enabled(struct idxd_dmadev *idxd) }static const struct rte_dmadev_ops idxd_pci_ops = { - + .dev_dump = idxd_dump, };/* each portal uses 4 x 4k pages */
Signature · 1 line
2.30.2
Re: [dpdk-dev] [PATCH v3 07/17] dma/idxd: add datapath structures
Quoted 5 lines
Add data structures required for the data path for IDXD devices.
Signed-off-by Bruce Richardson <[email protected]>Signed-off-by Kevin Laatz <[email protected]>
<snip>
drivers/dma/idxd/idxd_common.c line 19
Quoted 7 lines
drivers/dma/idxd/idxd_common.c +7
-0+int +idxd_dump (const struct rte_dmadev *dev,FILE *f) +{ +struct idxd_dmadev *idxd = dev->dev_private; +unsigned int i; + +fprintf (f,"== Private Data ==\n" );
Minor nit could you call out IDXD somewhere here just to make it clear which driver is being used?
It may be helpful for debugging just to quickly see if the correct driver was used.
Quoted 11 lines
drivers/dma/idxd/idxd_common.c +11
-0+fprintf (f," Portal: %p\n" , idxd->portal); +fprintf (f," Config: { ring_size: %u }\n" , + idxd->qcfg.nb_desc); +fprintf (f," Batch ring (sz = %u, max_batches = %u):\n\t" , + idxd->max_batches +1 , idxd->max_batches); +for (i =0 ; i <= idxd->max_batches; i++) { +fprintf (f," %u " , idxd->batch_idx_ring[i]); +if (i == idxd->batch_idx_read && i == idxd->batch_idx_write) +fprintf (f,"[rd ptr, wr ptr] " ); +else if (i == idxd->batch_idx_read) +fprintf (f,"[rd ptr] " );
drivers/dma/idxd/idxd_common.c line 40
Quoted 10 lines
drivers/dma/idxd/idxd_common.c +10
-0+else if (i == idxd->batch_idx_write) +fprintf (f,"[wr ptr] " ); +if (i == idxd->max_batches) +fprintf (f,"\n" ); + } + +fprintf (f," Curr batch: start = %u, size = %u\n" , idxd->batch_start, idxd->batch_size); +fprintf (f," IDS: avail = %u, returned: %u\n" , idxd->ids_avail, idxd->ids_returned); +return 0 ; +}
<snip>
PATCH v3 8/17 dma/idxd: add configure and info_get functions
In reply to Kevin LaatzAdd functions for device configuration. The info_get function is included here since it can be useful for checking successful configuration.
---
v2:
- fix reconfigure bug in idxd_vchan_setup()
- add literal include comment for the docs to pick up
v3:
- fixes needed after changes from rebasing
--- app/test/test_dmadev.c | 2 + doc/guides/dmadevs/idxd.rst | 33 +++++++++++++++ drivers/dma/idxd/idxd_bus.c | 3 ++ drivers/dma/idxd/idxd_common.c | 73 ++++++++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 6 +++ drivers/dma/idxd/idxd_pci.c | 3 ++ 6 files changed, 120 insertions(+)
app/test/test_dmadev.c +2 -0
@@ -739,6 +739,7 @@ test_dmadev_instance(uint16_t dev_id) {#define TEST_RINGSIZE 512#define CHECK_ERRS true +/* Setup of the dmadev device. 8< */ struct rte_dmadev_stats stats;struct rte_dmadev_info info;const struct rte_dmadev_conf conf = { .nb_vchans =1 };
@@ -759,6 +760,7 @@ test_dmadev_instance(uint16_t dev_id)if (rte_dmadev_vchan_setup (dev_id, vchan, &qconf) <0 )ERR_RETURN ("Error with queue configuration\n" ); +/* >8 End of setup of the dmadev device. */ rte_dmadev_info_get (dev_id, &info);if (info.nb_vchans !=1 )
doc/guides/dmadevs/idxd.rst +33 -0
@@ -120,3 +120,36 @@ use a subset of configured queues. Once probed successfully, irrespective of kernel driver, the device will appear as a ``dmadev``, that is a "DMA device type" inside DPDK, and can be accessed using APIs from the ``rte_dmadev`` library. + +Using IDXD DMAdev Devices +-------------------------- + +To use the devices from an application, the dmadev API can be used. + +Getting Device Information +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Basic information about each dmadev device can be queried using the +``rte_dmadev_info_get()`` API. This will return basic device information such as +the ``rte_device`` structure, device capabilities and other device specific values. + +Device Configuration +~~~~~~~~~~~~~~~~~~~~~ + +Configuring an IDXD dmadev device is done using the ``rte_dmadev_configure()`` and +``rte_dmadev_vchan_setup`` APIs. The configurations are passed to these APIs using +the ``rte_dmadev_conf`` and ``rte_dmadev_vchan_conf`` structures, respectively. For +example, these can be used to configure the number of ``vchans`` per device, the +ring size, etc. The ring size must be a power of two, between 64 and 4096. + +The following code shows how the device is configured in +``test_dmadev.c``: + +.. literalinclude:: ../../../app/test/test_dmadev.c + :language: c + :start-after: Setup of the dmadev device. 8< + :end-before: >8 End of setup of the dmadev device. + :dedent: 1 + +Once configured, the device can then be made ready for use by calling the +``rte_dmadev_start()`` API.
drivers/dma/idxd/idxd_bus.c +3 -0
@@ -96,6 +96,9 @@ idxd_dev_close(struct rte_dmadev *dev)static const struct rte_dmadev_ops idxd_vdev_ops = { .dev_close = idxd_dev_close, .dev_dump = idxd_dump, + .dev_configure = idxd_configure, + .vchan_setup = idxd_vchan_setup, + .dev_info_get = idxd_info_get, }; static void *
drivers/dma/idxd/idxd_common.c +73 -0
79 lines not on this page · raw message
drivers/dma/idxd/idxd_internal.h +6 -0
@@ -82,5 +82,11 @@ struct idxd_dmadev {int idxd_dmadev_create (const char *name,struct rte_device *dev,const struct idxd_dmadev *base_idxd,const struct rte_dmadev_ops *ops);int idxd_dump (const struct rte_dmadev *dev,FILE *f); +int idxd_configure (struct rte_dmadev *dev,const struct rte_dmadev_conf *dev_conf, +uint32_t conf_sz); +int idxd_vchan_setup (struct rte_dmadev *dev,uint16_t vchan, +const struct rte_dmadev_vchan_conf *qconf,uint32_t qconf_sz); +int idxd_info_get (const struct rte_dmadev *dev,struct rte_dmadev_info *dev_info, +uint32_t size);#endif /* _IDXD_INTERNAL_H_ */
drivers/dma/idxd/idxd_pci.c +3 -0
@@ -61,6 +61,9 @@ idxd_is_wq_enabled(struct idxd_dmadev *idxd)static const struct rte_dmadev_ops idxd_pci_ops = { .dev_dump = idxd_dump, + .dev_configure = idxd_configure, + .vchan_setup = idxd_vchan_setup, + .dev_info_get = idxd_info_get, };/* each portal uses 4 x 4k pages */
Signature · 1 line
2.30.2
Re: [dpdk-dev] [PATCH v3 08/17] dma/idxd: add configure and info_get functions
Quoted 6 lines
Add functions for device configuration. The
info_getfunction is included here since it can be useful for checking successful configuration.Signed-off-by Bruce Richardson <[email protected]>Signed-off-by Kevin Laatz <[email protected]>
<snip>
doc/guides/dmadevs/idxd.rst use a subset of configured queues. · line 155
Quoted 11 lines
doc/guides/dmadevs/idxd.rst +11
-0+The following code shows how the device is configured in +``test_dmadev.c``: + +.. literalinclude:: ../../../app/test/test_dmadev.c + :language: c + :start-after: Setup of the dmadev device. 8< + :end-before: >8 End of setup of the dmadev device. + :dedent: 1 + +Once configured, the device can then be made ready for use by calling the +``rte_dmadev_start()`` API.
Last line should be in the next patch, but it doesn't really matter.
PATCH v3 9/17 dma/idxd: add start and stop functions for pci devices
In reply to Kevin LaatzAdd device start/stop functions for DSA devices bound to vfio. For devices bound to the IDXD kernel driver, these are not required since the IDXD kernel driver takes care of this.
--- drivers/dma/idxd/idxd_pci.c | 52 +++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+)
drivers/dma/idxd/idxd_pci.c +52 -0
@@ -59,11 +59,63 @@ idxd_is_wq_enabled(struct idxd_dmadev *idxd)return ((state >>WQ_STATE_SHIFT ) &WQ_STATE_MASK ) ==0x1 ; } +static int +idxd_pci_dev_stop (struct rte_dmadev *dev) +{ +struct idxd_dmadev *idxd = dev->dev_private; +uint8_t err_code; + +if (!idxd_is_wq_enabled (idxd)) { +IDXD_PMD_ERR ("Work queue %d already disabled" , idxd->qid); +return -EALREADY ; + } + + err_code =idxd_pci_dev_command (idxd, idxd_disable_wq); +if (err_code ||idxd_is_wq_enabled (idxd)) { +IDXD_PMD_ERR ("Failed disabling work queue %d, error code: %#x" , + idxd->qid, err_code); +return -err_code; + } +IDXD_PMD_DEBUG ("Work queue %d disabled OK" , idxd->qid); + +return 0 ; +} + +static int +idxd_pci_dev_start (struct rte_dmadev *dev) +{ +struct idxd_dmadev *idxd = dev->dev_private; +uint8_t err_code; + +if (idxd_is_wq_enabled (idxd)) { +IDXD_PMD_WARN ("WQ %d already enabled" , idxd->qid); +return 0 ; + } + +if (idxd->desc_ring ==NULL ) { +IDXD_PMD_ERR ("WQ %d has not been fully configured" , idxd->qid); +return -EINVAL ; + } + + err_code =idxd_pci_dev_command (idxd, idxd_enable_wq); +if (err_code || !idxd_is_wq_enabled (idxd)) { +IDXD_PMD_ERR ("Failed enabling work queue %d, error code: %#x" , + idxd->qid, err_code); +return err_code ==0 ?-1 : err_code; + } + +IDXD_PMD_DEBUG ("Work queue %d enabled OK" , idxd->qid); + +return 0 ; +} +static const struct rte_dmadev_ops idxd_pci_ops = { .dev_dump = idxd_dump, .dev_configure = idxd_configure, .vchan_setup = idxd_vchan_setup, .dev_info_get = idxd_info_get, + .dev_start = idxd_pci_dev_start, + .dev_stop = idxd_pci_dev_stop, };/* each portal uses 4 x 4k pages */
Signature · 1 line
2.30.2
Re: [dpdk-dev] [PATCH v3 09/17] dma/idxd: add start and stop functions for pci devices
Quoted 7 lines
Add device start/stop functions for DSA devices bound to vfio. For devices bound to the IDXD kernel driver, these are not required since the IDXD kernel driver takes care of this.
Signed-off-by Bruce Richardson <[email protected]>Signed-off-by Kevin Laatz <[email protected]>
PATCH v3 10/17 dma/idxd: add data-path job submission functions
In reply to Kevin LaatzAdd data path functions for enqueuing and submitting operations to DSA devices.
--- doc/guides/dmadevs/idxd.rst | 64 +++++++++++++++ drivers/dma/idxd/idxd_common.c | 137 +++++++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 5 ++ drivers/dma/idxd/meson.build | 1 + 4 files changed, 207 insertions(+)
doc/guides/dmadevs/idxd.rst +64 -0
@@ -153,3 +153,67 @@ The following code shows how the device is configured in Once configured, the device can then be made ready for use by calling the ``rte_dmadev_start()`` API. + +Performing Data Copies +~~~~~~~~~~~~~~~~~~~~~~~ + +To perform data copies using IDXD dmadev devices, descriptors should be enqueued +using the ``rte_dmadev_copy()`` API. The HW can be triggered to perform the copy +in two ways, either via a ``RTE_DMA_OP_FLAG_SUBMIT`` flag or by calling +``rte_dmadev_submit()``. Once copies have been completed, the completion will +be reported back when the application calls ``rte_dmadev_completed()`` or +``rte_dmadev_completed_status()``. The latter will also report the status of each +completed operation. + +The ``rte_dmadev_copy()`` function enqueues a single copy to the device ring for +copying at a later point. The parameters to that function include the IOVA addresses +of both the source and destination buffers, as well as the length of the copy. + +The ``rte_dmadev_copy()`` function enqueues a copy operation on the device ring. +If the ``RTE_DMA_OP_FLAG_SUBMIT`` flag is set when calling ``rte_dmadev_copy()``, +the device hardware will be informed of the elements. Alternatively, if the flag +is not set, the application need to call the ``rte_dmadev_submit()`` function to +notify the device hardware. Once the device hardware is informed of the elements +enqueued on the ring, and the device will begin to process them. It is expected +that, for efficiency reasons, a burst of operations will be enqueued to the +device via multiple enqueue calls between calls to the ``rte_dmadev_submit()`` +function. + +The following code from demonstrates how to enqueue a burst of copies to the +device and start the hardware processing of them: + +.. code-block:: C + + struct rte_mbuf *srcs[COMP_BURST_SZ], *dsts[COMP_BURST_SZ]; + unsigned int i; + + for (i = 0; i < RTE_DIM(srcs); i++) { + uint64_t *src_data; + + srcs[i] = rte_pktmbuf_alloc(pool); + dsts[i] = rte_pktmbuf_alloc(pool); + src_data = rte_pktmbuf_mtod(srcs[i], uint64_t *); + if (srcs[i] == NULL || dsts[i] == NULL) { + PRINT_ERR("Error allocating buffers\n"); + return -1; + } + + for (j = 0; j < COPY_LEN/sizeof(uint64_t); j++) + src_data[j] = rte_rand(); + + if (rte_dmadev_copy(dev_id, vchan, srcs[i]->buf_iova + srcs[i]->data_off, + dsts[i]->buf_iova + dsts[i]->data_off, COPY_LEN, 0) < 0) { + PRINT_ERR("Error with rte_dmadev_copy for buffer %u\n", i); + return -1; + } + } + rte_dmadev_submit(dev_id, vchan); + +Filling an Area of Memory +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The IDXD driver also has support for the ``fill`` operation, where an area +of memory is overwritten, or filled, with a short pattern of data. +Fill operations can be performed in much the same was as copy operations +described above, just using the ``rte_dmadev_fill()`` function rather than the +``rte_dmadev_copy()`` function.
drivers/dma/idxd/idxd_common.c +137 -0
157 lines not on this page · raw message
drivers/dma/idxd/idxd_internal.h +5 -0
@@ -88,5 +88,10 @@ int idxd_vchan_setup(struct rte_dmadev *dev, uint16_t vchan, const struct rte_dmadev_vchan_conf *qconf, uint32_t qconf_sz);int idxd_info_get (const struct rte_dmadev *dev,struct rte_dmadev_info *dev_info,uint32_t size); +int idxd_enqueue_copy (struct rte_dmadev *dev,uint16_t qid,rte_iova_t src, +rte_iova_t dst,unsigned int length,uint64_t flags); +int idxd_enqueue_fill (struct rte_dmadev *dev,uint16_t qid,uint64_t pattern, +rte_iova_t dst,unsigned int length,uint64_t flags); +int idxd_submit (struct rte_dmadev *dev,uint16_t qid);#endif /* _IDXD_INTERNAL_H_ */
drivers/dma/idxd/meson.build +1 -0
@@ -2,6 +2,7 @@ # Copyright(c) 2021 Intel Corporation deps += ['bus_pci'] +cflags += '-mavx2' # all platforms with idxd HW support AVX sources = files( 'idxd_bus.c', 'idxd_common.c',
Signature · 1 line
2.30.2
Re: [dpdk-dev] [PATCH v3 10/17] dma/idxd: add data-path job submission functions
Quoted 6 lines
Add data path functions for enqueuing and submitting operations to DSA devices.
Signed-off-by Bruce Richardson <[email protected]>Signed-off-by Kevin Laatz <[email protected]>
<snip>
Quoted 31 lines
drivers/dma/idxd/idxd_common.c +31
-0+static __rte_always_inline int +__idxd_write_desc (struct rte_dmadev *dev, +const uint32_t op_flags, +const rte_iova_t src, +const rte_iova_t dst, +const uint32_t size, +const uint32_t flags) +{ +struct idxd_dmadev *idxd = dev->dev_private; +uint16_t mask = idxd->desc_ring_mask; +uint16_t job_id = idxd->batch_start + idxd->batch_size; +/* we never wrap batches, so we only mask the start and allow start+size to overflow */ +uint16_t write_idx = (idxd->batch_start & mask) + idxd->batch_size; + +/* first check batch ring space then desc ring space */ +if ((idxd->batch_idx_read ==0 && idxd->batch_idx_write == idxd->max_batches) || + idxd->batch_idx_write +1 == idxd->batch_idx_read) + goto failed; +if (((write_idx +1 ) & mask) == (idxd->ids_returned & mask)) + goto failed; + +/* write desc. Note: descriptors don't wrap, but the completion address does */ +const uint64_t op_flags64 = (uint64_t )(op_flags |IDXD_FLAG_COMPLETION_ADDR_VALID ) <<32 ; +const uint64_t comp_addr =__desc_idx_to_iova (idxd, write_idx & mask); +_mm256_store_si256 ((void *)&idxd->desc_ring[write_idx], +_mm256_set_epi64x (dst, src, comp_addr, op_flags64)); +_mm256_store_si256 ((void *)&idxd->desc_ring[write_idx].size, +_mm256_set_epi64x (0 ,0 ,0 , size)); + + idxd->batch_size++; +
drivers/dma/idxd/idxd_common.c line 115
Quoted 10 lines
drivers/dma/idxd/idxd_common.c +10
-0+rte_prefetch0_write (&idxd->desc_ring[write_idx +1 ]); + +if (flags &RTE_DMA_OP_FLAG_SUBMIT ) +__submit (idxd); + +return job_id; + +failed: +return -1 ; +}
If the failed goto just returns -1 it would probably be better to remove it and just return -1 in the 2 spots above.
PATCH v3 11/17 dma/idxd: add data-path job completion functions
In reply to Kevin LaatzAdd the data path functions for gathering completed operations.
---
v2:
- fixed typo in docs
- add completion status for invalid opcode
--- doc/guides/dmadevs/idxd.rst | 25 ++++ drivers/dma/idxd/idxd_common.c | 237 +++++++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 5 + 3 files changed, 267 insertions(+)
doc/guides/dmadevs/idxd.rst +25 -0
@@ -209,6 +209,31 @@ device and start the hardware processing of them: } rte_dmadev_submit(dev_id, vchan); +To retrieve information about completed copies, ``rte_dmadev_completed()`` and +``rte_dmadev_completed_status()`` APIs should be used. ``rte_dmadev_completed()`` +will return the number of completed operations, along with the index of the last +successful completed operation and whether or not an error was encountered. If an +error was encountered, ``rte_dmadev_completed_status()`` must be used to kick the +device off to continue processing operations and also to gather the status of each +individual operations which is filled in to the ``status`` array provided as +parameter by the application. + +The following code shows how to retrieve the number of successfully completed +copies within a burst and then using ``rte_dmadev_completed_status()`` to check +which operation failed and kick off the device to continue processing operations: + +.. code-block:: C + + enum rte_dma_status_code status[COMP_BURST_SZ]; + uint16_t count, idx, status_count; + bool error = 0; + + count = rte_dmadev_completed(dev_id, vchan, COMP_BURST_SZ, &idx, &error); + + if (error){ + status_count = rte_dmadev_completed_status(dev_id, vchan, COMP_BURST_SZ, &idx, status); + } + Filling an Area of Memory ~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/dma/idxd/idxd_common.c +237 -0
249 lines not on this page · raw message
drivers/dma/idxd/idxd_internal.h +5 -0
@@ -93,5 +93,10 @@ int idxd_enqueue_copy(struct rte_dmadev *dev, uint16_t qid, rte_iova_t src,int idxd_enqueue_fill (struct rte_dmadev *dev,uint16_t qid,uint64_t pattern,rte_iova_t dst,unsigned int length,uint64_t flags);int idxd_submit (struct rte_dmadev *dev,uint16_t qid); +uint16_t idxd_completed (struct rte_dmadev *dev,uint16_t qid,uint16_t max_ops, +uint16_t *last_idx,bool *has_error); +uint16_t idxd_completed_status(struct rte_dmadev *dev, uint16_t qid __rte_unused, +uint16_t max_ops,uint16_t *last_idx, +enum rte_dma_status_code *status);#endif /* _IDXD_INTERNAL_H_ */
Signature · 1 line
2.30.2
Re: [dpdk-dev] [PATCH v3 11/17] dma/idxd: add data-path job completion functions
Quoted 5 lines
Add the data path functions for gathering completed operations.
Signed-off-by Bruce Richardson <[email protected]>Signed-off-by Kevin Laatz <[email protected]>
PATCH v3 12/17 dma/idxd: add operation statistic tracking
In reply to Kevin LaatzAdd statistic tracking for DSA devices.
--- doc/guides/dmadevs/idxd.rst | 11 +++++++++++ drivers/dma/idxd/idxd_bus.c | 2 ++ drivers/dma/idxd/idxd_common.c | 27 +++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 3 +++ drivers/dma/idxd/idxd_pci.c | 2 ++ 5 files changed, 45 insertions(+)
doc/guides/dmadevs/idxd.rst +11 -0
@@ -242,3 +242,14 @@ of memory is overwritten, or filled, with a short pattern of data. Fill operations can be performed in much the same was as copy operations described above, just using the ``rte_dmadev_fill()`` function rather than the ``rte_dmadev_copy()`` function. + +Querying Device Statistics +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The statistics from the IDXD dmadev device can be got via the stats functions in +the ``rte_dmadev`` library, i.e. ``rte_dmadev_stats_get()``. The statistics +returned for each device instance are: + +* ``submitted`` +* ``completed`` +* ``errors``
drivers/dma/idxd/idxd_bus.c +2 -0
@@ -99,6 +99,8 @@ static const struct rte_dmadev_ops idxd_vdev_ops = { .dev_configure = idxd_configure, .vchan_setup = idxd_vchan_setup, .dev_info_get = idxd_info_get, + .stats_get = idxd_stats_get, + .stats_reset = idxd_stats_reset, }; static void *
drivers/dma/idxd/idxd_common.c +27 -0
@@ -65,6 +65,8 @@ __submit(struct idxd_dmadev *idxd)if (++idxd->batch_idx_write > idxd->max_batches) idxd->batch_idx_write =0 ; + idxd->stats.submitted += idxd->batch_size; + idxd->batch_start += idxd->batch_size; idxd->batch_size =0 ; idxd->batch_idx_ring[idxd->batch_idx_write] = idxd->batch_start;
@@ -278,6 +280,8 @@ batch_completed_status(struct idxd_dmadev *idxd, uint16_t max_ops, enum rte_dma_const uint16_t b_len = b_end - b_start;if (b_len ==1 ) {/* not a batch */ *status =get_comp_status (&idxd->batch_comp_ring[idxd->batch_idx_read]); +if (status !=RTE_DMA_STATUS_SUCCESSFUL ) + idxd->stats.errors++; idxd->ids_avail++; idxd->ids_returned++; idxd->batch_idx_read = next_batch;
@@ -299,6 +303,8 @@ batch_completed_status(struct idxd_dmadev *idxd, uint16_t max_ops, enum rte_dma_struct idxd_completion *c = (void *) &idxd->desc_ring[(b_start + ret) & idxd->desc_ring_mask]; status[ret] = (ret < bcount) ?get_comp_status (c) :RTE_DMA_STATUS_NOT_ATTEMPTED ; +if (status[ret] !=RTE_DMA_STATUS_SUCCESSFUL ) + idxd->stats.errors++; } idxd->ids_avail = idxd->ids_returned += ret;
@@ -357,6 +363,7 @@ idxd_completed(struct rte_dmadev *dev, uint16_t qid __rte_unused, uint16_t max_o ret += batch; }while (batch >0 && *has_error == false); + idxd->stats.completed += ret; *last_idx = idxd->ids_returned -1 ;return ret; }
@@ -374,6 +381,7 @@ idxd_completed_status(struct rte_dmadev *dev, uint16_t qid __rte_unused, uint16_ ret += batch; }while (batch >0 ); + idxd->stats.completed += ret; *last_idx = idxd->ids_returned -1 ;return ret; }
@@ -407,6 +415,25 @@ idxd_dump(const struct rte_dmadev *dev, FILE *f)return 0 ; } +int +idxd_stats_get(const struct rte_dmadev *dev, uint16_t vchan __rte_unused, +struct rte_dmadev_stats *stats,uint32_t stats_sz) +{ +struct idxd_dmadev *idxd = dev->dev_private; +if (stats_sz <sizeof (*stats)) +return -EINVAL ; + *stats = idxd->stats; +return 0 ; +} + +int +idxd_stats_reset(struct rte_dmadev *dev, uint16_t vchan __rte_unused) +{ +struct idxd_dmadev *idxd = dev->dev_private; + idxd->stats = (struct rte_dmadev_stats ){0 }; +return 0 ; +} +int idxd_info_get (const struct rte_dmadev *dev,struct rte_dmadev_info *info,uint32_t size) {
drivers/dma/idxd/idxd_internal.h +3 -0
@@ -98,5 +98,8 @@ uint16_t idxd_completed(struct rte_dmadev *dev, uint16_t qid, uint16_t max_ops, uint16_t idxd_completed_status(struct rte_dmadev *dev, uint16_t qid __rte_unused,uint16_t max_ops,uint16_t *last_idx,enum rte_dma_status_code *status); +int idxd_stats_get (const struct rte_dmadev *dev,uint16_t vchan, +struct rte_dmadev_stats *stats,uint32_t stats_sz); +int idxd_stats_reset (struct rte_dmadev *dev,uint16_t vchan);#endif /* _IDXD_INTERNAL_H_ */
drivers/dma/idxd/idxd_pci.c +2 -0
@@ -114,6 +114,8 @@ static const struct rte_dmadev_ops idxd_pci_ops = { .dev_configure = idxd_configure, .vchan_setup = idxd_vchan_setup, .dev_info_get = idxd_info_get, + .stats_get = idxd_stats_get, + .stats_reset = idxd_stats_reset, .dev_start = idxd_pci_dev_start, .dev_stop = idxd_pci_dev_stop, };
Signature · 1 line
2.30.2
Re: [dpdk-dev] [PATCH v3 12/17] dma/idxd: add operation statistic tracking
Quoted 5 lines
Add statistic tracking for DSA devices.
Signed-off-by Bruce Richardson <[email protected]>Signed-off-by Kevin Laatz <[email protected]>
PATCH v3 13/17 dma/idxd: add vchan status function
In reply to Kevin LaatzWhen testing dmadev drivers, it is useful to have the HW device in a known state. This patch adds the implementation of the function which will wait for the device to be idle (all jobs completed) before proceeding.
---
v3: update API name to vchan_status
--- drivers/dma/idxd/idxd_bus.c | 1 + drivers/dma/idxd/idxd_common.c | 14 ++++++++++++++ drivers/dma/idxd/idxd_internal.h | 2 ++ drivers/dma/idxd/idxd_pci.c | 1 + 4 files changed, 18 insertions(+)
drivers/dma/idxd/idxd_bus.c +1 -0
@@ -101,6 +101,7 @@ static const struct rte_dmadev_ops idxd_vdev_ops = { .dev_info_get = idxd_info_get, .stats_get = idxd_stats_get, .stats_reset = idxd_stats_reset, + .vchan_status = idxd_vchan_status, }; static void *
drivers/dma/idxd/idxd_common.c +14 -0
@@ -165,6 +165,20 @@ get_comp_status(struct idxd_completion *c) } } +int +idxd_vchan_status(const struct rte_dmadev *dev, uint16_t vchan __rte_unused, +enum rte_dmadev_vchan_status *status) +{ +struct idxd_dmadev *idxd = dev->dev_private; +uint16_t last_batch_write = idxd->batch_idx_write ==0 ? idxd->max_batches : + idxd->batch_idx_write -1 ; +uint8_t bstatus = (idxd->batch_comp_ring[last_batch_write].status !=0 ); + + *status = bstatus ?RTE_DMA_VCHAN_IDLE :RTE_DMA_VCHAN_ACTIVE ; + +return 0 ; +} + static __rte_always_inline intbatch_ok (struct idxd_dmadev *idxd,uint8_t max_ops,enum rte_dma_status_code *status) {
drivers/dma/idxd/idxd_internal.h +2 -0
@@ -101,5 +101,7 @@ uint16_t idxd_completed_status(struct rte_dmadev *dev, uint16_t qid __rte_unusedint idxd_stats_get (const struct rte_dmadev *dev,uint16_t vchan,struct rte_dmadev_stats *stats,uint32_t stats_sz);int idxd_stats_reset (struct rte_dmadev *dev,uint16_t vchan); +int idxd_vchan_status (const struct rte_dmadev *dev,uint16_t vchan, +enum rte_dmadev_vchan_status *status);#endif /* _IDXD_INTERNAL_H_ */
drivers/dma/idxd/idxd_pci.c +1 -0
@@ -118,6 +118,7 @@ static const struct rte_dmadev_ops idxd_pci_ops = { .stats_reset = idxd_stats_reset, .dev_start = idxd_pci_dev_start, .dev_stop = idxd_pci_dev_stop, + .vchan_status = idxd_vchan_status, };/* each portal uses 4 x 4k pages */
Signature · 1 line
2.30.2
Re: [dpdk-dev] [PATCH v3 13/17] dma/idxd: add vchan status function
Quoted 6 lines
When testing dmadev drivers, it is useful to have the HW device in a known state. This patch adds the implementation of the function which will wait for the device to be idle (all jobs completed) before proceeding.
Signed-off-by Kevin Laatz <[email protected]>
<snip>
drivers/dma/idxd/idxd_common.c get_comp_status(struct idxd_completion *c) · line 180
Quoted 13 lines
drivers/dma/idxd/idxd_common.c +13
-0+int +idxd_vchan_status(const struct rte_dmadev *dev, uint16_t vchan __rte_unused, +enum rte_dmadev_vchan_status *status) +{ +struct idxd_dmadev *idxd = dev->dev_private; +uint16_t last_batch_write = idxd->batch_idx_write ==0 ? idxd->max_batches : + idxd->batch_idx_write -1 ; +uint8_t bstatus = (idxd->batch_comp_ring[last_batch_write].status !=0 ); + + *status = bstatus ?RTE_DMA_VCHAN_IDLE :RTE_DMA_VCHAN_ACTIVE ; + +return 0 ; +}
Should there be a comment noting that RTE_DMA_VCHAN_HALTED_ERROR does not apply to IDXD?
PATCH v3 14/17 dma/idxd: add burst capacity API
In reply to Kevin LaatzAdd support for the burst capacity API. This API will provide the calling application with the remaining capacity of the current burst (limited by max HW batch size).
--- drivers/dma/idxd/idxd_bus.c | 1 + drivers/dma/idxd/idxd_common.c | 20 ++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 1 + drivers/dma/idxd/idxd_pci.c | 2 ++ 4 files changed, 24 insertions(+)
drivers/dma/idxd/idxd_bus.c +1 -0
@@ -102,6 +102,7 @@ static const struct rte_dmadev_ops idxd_vdev_ops = { .stats_get = idxd_stats_get, .stats_reset = idxd_stats_reset, .vchan_status = idxd_vchan_status, + .burst_capacity = idxd_burst_capacity, }; static void *
drivers/dma/idxd/idxd_common.c +20 -0
@@ -470,6 +470,26 @@ idxd_info_get(const struct rte_dmadev *dev, struct rte_dmadev_info *info, uint32return 0 ; } +uint16_t +idxd_burst_capacity(const struct rte_dmadev *dev, uint16_t vchan __rte_unused) +{ +struct idxd_dmadev *idxd = dev->dev_private; +uint16_t write_idx = idxd->batch_start + idxd->batch_size; +uint16_t used_space; + +/* Check for space in the batch ring */ +if ((idxd->batch_idx_read ==0 && idxd->batch_idx_write == idxd->max_batches) || + idxd->batch_idx_write +1 == idxd->batch_idx_read) +return 0 ; + +/* For descriptors, check for wrap-around on write but not read */ +if (idxd->ids_returned > write_idx) + write_idx += idxd->desc_ring_mask +1 ; + used_space = write_idx - idxd->ids_returned; + +return RTE_MIN ((idxd->desc_ring_mask - used_space), idxd->max_batch_size); +} +int idxd_configure(struct rte_dmadev *dev __rte_unused, const struct rte_dmadev_conf *dev_conf,uint32_t conf_sz)
drivers/dma/idxd/idxd_internal.h +1 -0
@@ -103,5 +103,6 @@ int idxd_stats_get(const struct rte_dmadev *dev, uint16_t vchan,int idxd_stats_reset (struct rte_dmadev *dev,uint16_t vchan);int idxd_vchan_status (const struct rte_dmadev *dev,uint16_t vchan,enum rte_dmadev_vchan_status *status); +uint16_t idxd_burst_capacity (const struct rte_dmadev *dev,uint16_t vchan);#endif /* _IDXD_INTERNAL_H_ */
drivers/dma/idxd/idxd_pci.c +2 -0
@@ -119,6 +119,7 @@ static const struct rte_dmadev_ops idxd_pci_ops = { .dev_start = idxd_pci_dev_start, .dev_stop = idxd_pci_dev_stop, .vchan_status = idxd_vchan_status, + .burst_capacity = idxd_burst_capacity, };/* each portal uses 4 x 4k pages */
@@ -232,6 +233,7 @@ init_pci_device(struct rte_pci_device *dev, struct idxd_dmadev *idxd, idxd->u.pci = pci; idxd->max_batches = wq_size; + idxd->max_batch_size =1 << lg2_max_batch;/* enable the device itself */ err_code =idxd_pci_dev_command (idxd, idxd_enable_dev);
Signature · 1 line
2.30.2
Re: [dpdk-dev] [PATCH v3 14/17] dma/idxd: add burst capacity API
Quoted 6 lines
Add support for the burst capacity API. This API will provide the calling application with the remaining capacity of the current burst (limited by max HW batch size).
Signed-off-by Kevin Laatz <[email protected]>
PATCH v3 15/17 dma/idxd: move dpdk_idxd_cfg.py from raw to dma
In reply to Kevin LaatzFrom: Conor Walsh <[email protected]>
Move the example script for configuring IDXD devices bound to the IDXD kernel driver from raw to dma, and create a symlink to still allow use from raw.
--- drivers/dma/idxd/dpdk_idxd_cfg.py | 117 +++++++++++++++++++++++++++++ drivers/raw/ioat/dpdk_idxd_cfg.py | 118 +----------------------------- 2 files changed, 118 insertions(+), 117 deletions(-) create mode 100755 drivers/dma/idxd/dpdk_idxd_cfg.py mode change 100755 => 120000 drivers/raw/ioat/dpdk_idxd_cfg.py
drivers/dma/idxd/dpdk_idxd_cfg.py new file +117 -0
@@ -0,0 +1,117 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2020 Intel Corporation + +""" +Configure an entire Intel DSA instance, using idxd kernel driver, for DPDK use +""" + +import sys +import argparse +import os +import os.path + + +class SysfsDir: + "Used to read/write paths in a sysfs directory" + def __init__(self, path): + self.path = path + + def read_int(self, filename): + "Return a value from sysfs file" + with open(os.path.join(self.path, filename)) as f: + return int(f.readline()) + + def write_values(self, values): + "write dictionary, where key is filename and value is value to write" + for filename, contents in values.items(): + with open(os.path.join(self.path, filename), "w") as f: + f.write(str(contents)) + + +def reset_device(dsa_id): + "Reset the DSA device and all its queues" + drv_dir = SysfsDir("/sys/bus/dsa/drivers/dsa") + drv_dir.write_values({"unbind": f"dsa{dsa_id}"}) + + +def get_pci_dir(pci): + "Search for the sysfs directory of the PCI device" + base_dir = '/sys/bus/pci/devices/' + for path, dirs, files in os.walk(base_dir): + for dir in dirs: + if pci in dir: + return os.path.join(base_dir, dir) + sys.exit(f"Could not find sysfs directory for device {pci}") + + +def get_dsa_id(pci): + "Get the DSA instance ID using the PCI address of the device" + pci_dir = get_pci_dir(pci) + for path, dirs, files in os.walk(pci_dir): + for dir in dirs: + if dir.startswith('dsa') and 'wq' not in dir: + return int(dir[3:]) + sys.exit(f"Could not get device ID for device {pci}") + + +def configure_dsa(dsa_id, queues, prefix): + "Configure the DSA instance with appropriate number of queues" + dsa_dir = SysfsDir(f"/sys/bus/dsa/devices/dsa{dsa_id}") + drv_dir = SysfsDir("/sys/bus/dsa/drivers/dsa") + + max_groups = dsa_dir.read_int("max_groups") + max_engines = dsa_dir.read_int("max_engines") + max_queues = dsa_dir.read_int("max_work_queues") + max_work_queues_size = dsa_dir.read_int("max_work_queues_size") + + nb_queues = min(queues, max_queues) + if queues > nb_queues: + print(f"Setting number of queues to max supported value: {max_queues}") + + # we want one engine per group, and no more engines than queues + nb_groups = min(max_engines, max_groups, nb_queues) + for grp in range(nb_groups): + dsa_dir.write_values({f"engine{dsa_id}.{grp}/group_id": grp}) + + # configure each queue + for q in range(nb_queues): + wq_dir = SysfsDir(os.path.join(dsa_dir.path, f"wq{dsa_id}.{q}")) + wq_dir.write_values({"group_id": q % nb_groups, + "type": "user", + "mode": "dedicated", + "name": f"{prefix}_wq{dsa_id}.{q}", + "priority": 1, + "size": int(max_work_queues_size / nb_queues)}) + + # enable device and then queues + drv_dir.write_values({"bind": f"dsa{dsa_id}"}) + for q in range(nb_queues): + drv_dir.write_values({"bind": f"wq{dsa_id}.{q}"}) + + +def main(args): + "Main function, does arg parsing and calls config function" + arg_p = argparse.ArgumentParser( + description="Configure whole DSA device instance for DPDK use") + arg_p.add_argument('dsa_id', + help="Specify DSA instance either via DSA instance number or PCI address") + arg_p.add_argument('-q', metavar='queues', type=int, default=255, + help="Number of queues to set up") + arg_p.add_argument('--name-prefix', metavar='prefix', dest='prefix', + default="dpdk", + help="Prefix for workqueue name to mark for DPDK use [default: 'dpdk']") + arg_p.add_argument('--reset', action='store_true', + help="Reset DSA device and its queues") + parsed_args = arg_p.parse_args(args[1:]) + + dsa_id = parsed_args.dsa_id + dsa_id = get_dsa_id(dsa_id) if ':' in dsa_id else dsa_id + if parsed_args.reset: + reset_device(dsa_id) + else: + configure_dsa(dsa_id, parsed_args.q, parsed_args.prefix) + + +if __name__ == "__main__": + main(sys.argv)
drivers/raw/ioat/dpdk_idxd_cfg.py deleted +0 -117
117 lines not on this page · raw message
drivers/raw/ioat/dpdk_idxd_cfg.py new file +1 -0
@@ -0,0 +1 @@ +../../dma/idxd/dpdk_idxd_cfg.py
Signature · 1 line
2.30.2
PATCH v3 16/17 devbind: add dma device class
In reply to Kevin LaatzAdd a new class for DMA devices. Devices listed under the DMA class are to be used with the dmadev library.
--- usertools/dpdk-devbind.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
usertools/dpdk-devbind.py +9 -3
@@ -69,12 +69,13 @@ network_devices = [network_class, cavium_pkx, avp_vnic, ifpga_class] baseband_devices = [acceleration_class] crypto_devices = [encryption_class, intel_processor_class] +dma_devices = [] eventdev_devices = [cavium_sso, cavium_tim, intel_dlb, octeontx2_sso] mempool_devices = [cavium_fpa, octeontx2_npa] compress_devices = [cavium_zip] regex_devices = [octeontx2_ree] -misc_devices = [cnxk_bphy, cnxk_bphy_cgx, intel_ioat_bdw, intel_ioat_skx, intel_ioat_icx, intel_idxd_spr, - intel_ntb_skx, intel_ntb_icx, +misc_devices = [cnxk_bphy, cnxk_bphy_cgx, intel_ioat_bdw, intel_ioat_skx, + intel_ioat_icx, intel_idxd_spr, intel_ntb_skx, intel_ntb_icx, octeontx2_dma] # global dict ethernet devices present. Dictionary indexed by PCI address.
@@ -583,6 +584,9 @@ def show_status(): if status_dev in ["crypto", "all"]: show_device_status(crypto_devices, "Crypto") + if status_dev in ["dma", "all"]: + show_device_status(dma_devices, "DMA") + if status_dev in ["event", "all"]: show_device_status(eventdev_devices, "Eventdev")
@@ -651,7 +655,7 @@ def parse_args(): parser.add_argument( '--status-dev', help="Print the status of given device group.", - choices=['baseband', 'compress', 'crypto', 'event', + choices=['baseband', 'compress', 'crypto', 'dma', 'event', 'mempool', 'misc', 'net', 'regex']) bind_group = parser.add_mutually_exclusive_group() bind_group.add_argument(
@@ -732,6 +736,7 @@ def do_arg_actions(): get_device_details(network_devices) get_device_details(baseband_devices) get_device_details(crypto_devices) + get_device_details(dma_devices) get_device_details(eventdev_devices) get_device_details(mempool_devices) get_device_details(compress_devices)
@@ -754,6 +759,7 @@ def main(): get_device_details(network_devices) get_device_details(baseband_devices) get_device_details(crypto_devices) + get_device_details(dma_devices) get_device_details(eventdev_devices) get_device_details(mempool_devices) get_device_details(compress_devices)
Signature · 1 line
2.30.2
Re: [dpdk-dev] [PATCH v3 16/17] devbind: add dma device class
Quoted 5 lines
Add a new class for DMA devices. Devices listed under the DMA class are to be used with the dmadev library.
Signed-off-by Kevin Laatz <[email protected]>
PATCH v3 17/17 devbind: move idxd device ID to dmadev class
In reply to Kevin LaatzThe dmadev library is the preferred abstraction for using IDXD devices and will replace the rawdev implementation in future. This patch moves the IDXD device ID to the dmadev class.
--- usertools/dpdk-devbind.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
usertools/dpdk-devbind.py +2 -2
@@ -69,13 +69,13 @@ network_devices = [network_class, cavium_pkx, avp_vnic, ifpga_class] baseband_devices = [acceleration_class] crypto_devices = [encryption_class, intel_processor_class] -dma_devices = [] +dma_devices = [intel_idxd_spr] eventdev_devices = [cavium_sso, cavium_tim, intel_dlb, octeontx2_sso] mempool_devices = [cavium_fpa, octeontx2_npa] compress_devices = [cavium_zip] regex_devices = [octeontx2_ree] misc_devices = [cnxk_bphy, cnxk_bphy_cgx, intel_ioat_bdw, intel_ioat_skx, - intel_ioat_icx, intel_idxd_spr, intel_ntb_skx, intel_ntb_icx, + intel_ioat_icx, intel_ntb_skx, intel_ntb_icx, octeontx2_dma] # global dict ethernet devices present. Dictionary indexed by PCI address.
Signature · 1 line
2.30.2
Re: [dpdk-dev] [PATCH v3 17/17] devbind: move idxd device ID to dmadev class
Quoted 6 lines
The dmadev library is the preferred abstraction for using IDXD devices and will replace the rawdev implementation in future. This patch moves the IDXD device ID to the dmadev class.
Signed-off-by Kevin Laatz <[email protected]>
v4 cover add dmadev driver for idxd devices
In reply to Kevin LaatzThis patchset adds a dmadev driver and associated documentation to support Intel Data Streaming Accelerator devices. This driver is intended to ultimately replace the current IDXD part of the IOAT rawdev driver.
NOTE: This patchset has several dependencies:
- v22 of the dmadev lib set [1]
- v5 of the dmadev test suite [2]
[1] http://patches.dpdk.org/project/dpdk/list/?series=18960
[2] http://patches.dpdk.org/project/dpdk/list/?series=19017
v4:
* rebased on above patchsets
* minor fixes based on review feedback
v3:
* rebased on above patchsets
* added burst capacity API
v2:
* rebased on above patchsets
* added API to check for device being idle
* added devbind updates for DMA devices
* fixed issue identified by internal coverity scan
* other minor miscellaneous changes and fixes
Bruce Richardson (1):
raw/ioat: only build if dmadev not present
Conor Walsh (1):
dma/idxd: move dpdk_idxd_cfg.py from raw to dma
Kevin Laatz (14):
dma/idxd: add skeleton for VFIO based DSA device dma/idxd: add bus device probing
dma/idxd: create dmadev instances on bus probe dma/idxd: create dmadev instances on pci probe dma/idxd: add datapath structures
dma/idxd: add configure and info_get functions dma/idxd: add start and stop functions for pci devices dma/idxd: add data-path job submission functions dma/idxd: add data-path job completion functions dma/idxd: add operation statistic tracking dma/idxd: add vchan status function
dma/idxd: add burst capacity API
devbind: add dma device class
devbind: move idxd device ID to dmadev class
MAINTAINERS | 10 + app/test/test_dmadev.c | 2 + doc/guides/dmadevs/idxd.rst | 262 +++++++++++ doc/guides/rawdevs/ioat.rst | 7 + doc/guides/rel_notes/release_21_11.rst | 5 + drivers/dma/idxd/dpdk_idxd_cfg.py | 117 +++++ drivers/dma/idxd/idxd_bus.c | 378 +++++++++++++++ drivers/dma/idxd/idxd_common.c | 616 +++++++++++++++++++++++++ drivers/dma/idxd/idxd_hw_defs.h | 131 ++++++ drivers/dma/idxd/idxd_internal.h | 108 +++++ drivers/dma/idxd/idxd_pci.c | 387 ++++++++++++++++ drivers/dma/idxd/meson.build | 14 + drivers/dma/idxd/version.map | 3 + drivers/dma/meson.build | 2 + drivers/meson.build | 2 +- drivers/raw/ioat/dpdk_idxd_cfg.py | 118 +---- drivers/raw/ioat/meson.build | 23 +- usertools/dpdk-devbind.py | 12 +- 18 files changed, 2073 insertions(+), 124 deletions(-) create mode 100644 doc/guides/dmadevs/idxd.rst create mode 100755 drivers/dma/idxd/dpdk_idxd_cfg.py create mode 100644 drivers/dma/idxd/idxd_bus.c create mode 100644 drivers/dma/idxd/idxd_common.c create mode 100644 drivers/dma/idxd/idxd_hw_defs.h create mode 100644 drivers/dma/idxd/idxd_internal.h create mode 100644 drivers/dma/idxd/idxd_pci.c create mode 100644 drivers/dma/idxd/meson.build create mode 100644 drivers/dma/idxd/version.map mode change 100755 => 120000 drivers/raw/ioat/dpdk_idxd_cfg.py
Signature · 1 line
2.30.2
PATCH v4 1/16 raw/ioat: only build if dmadev not present
From: Bruce Richardson <[email protected]>
Only build the rawdev IDXD/IOAT drivers if the dmadev drivers are not present.
A not is also added to the documentation to inform users of this change.
---
v4:
- Fix build issue
- Add note in raw documentation to outline this change
--- doc/guides/rawdevs/ioat.rst | 7 +++++++ drivers/meson.build | 2 +- drivers/raw/ioat/meson.build | 23 ++++++++++++++++++++--- 3 files changed, 28 insertions(+), 4 deletions(-)
doc/guides/rawdevs/ioat.rst +7 -0
@@ -34,6 +34,13 @@ Compilation For builds using ``meson`` and ``ninja``, the driver will be built when the target platform is x86-based. No additional compilation steps are necessary. +.. note:: + Since the addition of the DMAdev library, the ``ioat`` and ``idxd`` parts of this driver + will only be built if their ``DMAdev`` counterparts are not built. The following can be used + to disable the ``DMAdev`` drivers, if the raw drivers are to be used instead:: + + $ meson -Ddisable_drivers=dma/* <build_dir> + Device Setup -------------
drivers/meson.build +1 -1
@@ -10,6 +10,7 @@ subdirs = [ 'common/qat', # depends on bus. 'common/sfc_efx', # depends on bus. 'mempool', # depends on common and bus. + 'dma', # depends on common and bus. 'net', # depends on common, bus, mempool 'raw', # depends on common, bus and net. 'crypto', # depends on common, bus and mempool (net in future).
@@ -18,7 +19,6 @@ subdirs = [ 'vdpa', # depends on common, bus and mempool. 'event', # depends on common, bus, mempool and net. 'baseband', # depends on common and bus. - 'dma', # depends on common and bus. ] if meson.is_cross_build()
drivers/raw/ioat/meson.build +20 -3
@@ -2,14 +2,31 @@ # Copyright 2019 Intel Corporation build = dpdk_conf.has('RTE_ARCH_X86') +# only use ioat rawdev driver if we don't have the equivalent dmadev ones +if dpdk_conf.has('RTE_DMA_IDXD') and dpdk_conf.has('RTE_DMA_IOAT') + build = false + subdir_done() +endif + reason = 'only supported on x86' sources = files( - 'idxd_bus.c', - 'idxd_pci.c', 'ioat_common.c', - 'ioat_rawdev.c', 'ioat_rawdev_test.c', ) + +if not dpdk_conf.has('RTE_DMA_IDXD') + sources += files( + 'idxd_bus.c', + 'idxd_pci.c', + ) +endif + +if not dpdk_conf.has('RTE_DMA_IOAT') + sources += files ( + 'ioat_rawdev.c', + ) +endif + deps += ['bus_pci', 'mbuf', 'rawdev'] headers = files( 'rte_ioat_rawdev.h',
Signature · 1 line
2.30.2
PATCH v4 2/16 dma/idxd: add skeleton for VFIO based DSA device
In reply to Kevin LaatzAdd the basic device probe/remove skeleton code for DSA device bound to the vfio pci driver. Relevant documentation and MAINTAINERS update also included.
--- MAINTAINERS | 10 +++++ doc/guides/dmadevs/idxd.rst | 58 ++++++++++++++++++++++++++ doc/guides/rel_notes/release_21_11.rst | 5 +++ drivers/dma/idxd/idxd_internal.h | 27 ++++++++++++ drivers/dma/idxd/idxd_pci.c | 55 ++++++++++++++++++++++++ drivers/dma/idxd/meson.build | 11 +++++ drivers/dma/idxd/version.map | 3 ++ drivers/dma/meson.build | 2 + 8 files changed, 171 insertions(+) create mode 100644 doc/guides/dmadevs/idxd.rst create mode 100644 drivers/dma/idxd/idxd_internal.h create mode 100644 drivers/dma/idxd/idxd_pci.c create mode 100644 drivers/dma/idxd/meson.build create mode 100644 drivers/dma/idxd/version.map
MAINTAINERS +10 -0
@@ -1200,6 +1200,16 @@ F: doc/guides/compressdevs/zlib.rst F: doc/guides/compressdevs/features/zlib.ini +DMAdev Drivers +-------------- + +Intel IDXD - EXPERIMENTAL +M: Bruce Richardson <[email protected]> +M: Kevin Laatz <[email protected]> +F: drivers/dma/idxd/ +F: doc/guides/dmadevs/idxd.rst + + RegEx Drivers -------------
doc/guides/dmadevs/idxd.rst new file +58 -0
58 lines not on this page · raw message
doc/guides/rel_notes/release_21_11.rst +5 -0
@@ -92,6 +92,11 @@ New Features * Device allocation and it's multi-process support. * Control and data plane functions. +* **Added IDXD dmadev driver implementation.** + + The IDXD dmadev driver provide device drivers for the Intel DSA devices. + This device driver can be used through the generic dmadev API. + Removed Items -------------
drivers/dma/idxd/idxd_internal.h new file +27 -0
@@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright 2021 Intel Corporation +*/ + +#ifndef _IDXD_INTERNAL_H_ +#define _IDXD_INTERNAL_H_ + +/** +* @file idxd_internal.h +* +* Internal data structures for the idxd/DSA driver for dmadev +* +* @warning +* @b EXPERIMENTAL: these structures and APIs may change without prior notice +*/ + +extern int idxd_pmd_logtype; + +#define IDXD_PMD_LOG(level, fmt, args...) rte_log(RTE_LOG_ ## level, \ + idxd_pmd_logtype, "IDXD: %s(): " fmt "\n", __func__, ##args) + +#define IDXD_PMD_DEBUG(fmt, args...) IDXD_PMD_LOG(DEBUG, fmt, ## args) +#define IDXD_PMD_INFO(fmt, args...) IDXD_PMD_LOG(INFO, fmt, ## args) +#define IDXD_PMD_ERR(fmt, args...) IDXD_PMD_LOG(ERR, fmt, ## args) +#define IDXD_PMD_WARN(fmt, args...) IDXD_PMD_LOG(WARNING, fmt, ## args) + +#endif /* _IDXD_INTERNAL_H_ */
drivers/dma/idxd/idxd_pci.c new file +55 -0
55 lines not on this page · raw message
drivers/dma/idxd/meson.build new file +11 -0
@@ -0,0 +1,11 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2021 Intel Corporation + +if is_windows + subdir_done() +endif + +deps += ['bus_pci'] +sources = files( + 'idxd_pci.c' +)
drivers/dma/idxd/version.map new file +3 -0
@@ -0,0 +1,3 @@ +DPDK_21 { + local: *; +};
drivers/dma/meson.build +2 -0
@@ -2,5 +2,7 @@ # Copyright 2021 HiSilicon Limited drivers = [ + 'idxd', 'skeleton', ] +std_deps = ['dmadev']
Signature · 1 line
2.30.2
PATCH v4 3/16 dma/idxd: add bus device probing
In reply to Kevin LaatzAdd the basic device probing for DSA devices bound to the IDXD kernel driver. These devices can be configured via sysfs and made available to DPDK if they are found during bus scan. Relevant documentation is included.
---
v4: fix 'vdev' naming, changed to 'bus'
--- doc/guides/dmadevs/idxd.rst | 64 +++++++ drivers/dma/idxd/idxd_bus.c | 351 +++++++++++++++++++++++++++++++++++ drivers/dma/idxd/meson.build | 1 + 3 files changed, 416 insertions(+) create mode 100644 drivers/dma/idxd/idxd_bus.c
doc/guides/dmadevs/idxd.rst +64 -0
@@ -32,6 +32,56 @@ target platform is x86-based. No additional compilation steps are necessary. Device Setup ------------- +Intel\ |reg| DSA devices can use the IDXD kernel driver or DPDK-supported drivers, +such as ``vfio-pci``. Both are supported by the IDXD PMD. + +Intel\ |reg| DSA devices using IDXD kernel driver +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +To use an Intel\ |reg| DSA device bound to the IDXD kernel driver, the device must first be configured. +The `accel-config <https://github.com/intel/idxd-config>`_ utility library can be used for configuration. + +.. note:: + The device configuration can also be done by directly interacting with the sysfs nodes. + An example of how this may be done can be seen in the script ``dpdk_idxd_cfg.py`` + included in the driver source directory. + +There are some mandatory configuration steps before being able to use a device with an application. +The internal engines, which do the copies or other operations, +and the work-queues, which are used by applications to assign work to the device, +need to be assigned to groups, and the various other configuration options, +such as priority or queue depth, need to be set for each queue. + +To assign an engine to a group:: + + $ accel-config config-engine dsa0/engine0.0 --group-id=0 + $ accel-config config-engine dsa0/engine0.1 --group-id=1 + +To assign work queues to groups for passing descriptors to the engines a similar accel-config command can be used. +However, the work queues also need to be configured depending on the use case. +Some configuration options include: + +* mode (Dedicated/Shared): Indicates whether a WQ may accept jobs from multiple queues simultaneously. +* priority: WQ priority between 1 and 15. Larger value means higher priority. +* wq-size: the size of the WQ. Sum of all WQ sizes must be less that the total-size defined by the device. +* type: WQ type (kernel/mdev/user). Determines how the device is presented. +* name: identifier given to the WQ. + +Example configuration for a work queue:: + + $ accel-config config-wq dsa0/wq0.0 --group-id=0 \ + --mode=dedicated --priority=10 --wq-size=8 \ + --type=user --name=dpdk_app1 + +Once the devices have been configured, they need to be enabled:: + + $ accel-config enable-device dsa0 + $ accel-config enable-wq dsa0/wq0.0 + +Check the device configuration:: + + $ accel-config list + Devices using VFIO/UIO drivers ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -56,3 +106,17 @@ If fewer workqueues are required, then the ``max_queues`` parameter may be passe the device driver on the EAL commandline, via the ``allowlist`` or ``-a`` flag e.g.:: $ dpdk-test -a <b:d:f>,max_queues=4 + +For devices bound to the IDXD kernel driver, +the DPDK IDXD driver will automatically perform a scan for available workqueues +to use. Any workqueues found listed in ``/dev/dsa`` on the system will be checked +in ``/sys``, and any which have ``dpdk_`` prefix in their name will be automatically +probed by the driver to make them available to the application. +Alternatively, to support use by multiple DPDK processes simultaneously, +the value used as the DPDK ``--file-prefix`` parameter may be used as a workqueue +name prefix, instead of ``dpdk_``, allowing each DPDK application instance to only +use a subset of configured queues. + +Once probed successfully, irrespective of kernel driver, the device will appear as a ``dmadev``, +that is a "DMA device type" inside DPDK, and can be accessed using APIs from the +``rte_dmadev`` library.
drivers/dma/idxd/idxd_bus.c new file +351 -0
351 lines not on this page · raw message
drivers/dma/idxd/meson.build +1 -0
@@ -7,5 +7,6 @@ endif deps += ['bus_pci'] sources = files( + 'idxd_bus.c', 'idxd_pci.c' )
Signature · 1 line
2.30.2
PATCH v4 4/16 dma/idxd: create dmadev instances on bus probe
In reply to Kevin LaatzWhen a suitable device is found during the bus scan/probe, create a dmadev instance for each HW queue. Internal structures required for device creation are also added.
---
v4:
- fix 'vdev' naming, changed to 'bus'
- rebase changes
--- drivers/dma/idxd/idxd_bus.c | 19 ++++++++ drivers/dma/idxd/idxd_common.c | 76 ++++++++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 40 +++++++++++++++++ drivers/dma/idxd/meson.build | 1 + 4 files changed, 136 insertions(+) create mode 100644 drivers/dma/idxd/idxd_common.c
drivers/dma/idxd/idxd_bus.c +19 -0
@@ -85,6 +85,18 @@ dsa_get_sysfs_path(void)return path ? path :DSA_SYSFS_PATH ; } +static int +idxd_dev_close (struct rte_dma_dev *dev) +{ +struct idxd_dmadev *idxd = dev->data->dev_private; +munmap (idxd->portal,0x1000 ); +return 0 ; +} + +static const struct rte_dma_dev_ops idxd_bus_ops = { + .dev_close = idxd_dev_close, +}; +static void *idxd_bus_mmap_wq (struct rte_dsa_device *dev) {
@@ -206,6 +218,7 @@ idxd_probe_dsa(struct rte_dsa_device *dev)return -1 ; idxd.max_batch_size = ret; idxd.qid = dev->addr.wq_id; + idxd.u.bus.dsa_id = dev->addr.device_id; idxd.sva_support =1 ; idxd.portal =idxd_bus_mmap_wq (dev);
@@ -214,6 +227,12 @@ idxd_probe_dsa(struct rte_dsa_device *dev)return -ENOENT ; } + ret =idxd_dmadev_create (dev->wq_name, &dev->device, &idxd, &idxd_bus_ops); +if (ret) { +IDXD_PMD_ERR ("Failed to create rawdev %s" , dev->wq_name); +return ret; + } +return 0 ; }
drivers/dma/idxd/idxd_common.c new file +76 -0
76 lines not on this page · raw message
drivers/dma/idxd/idxd_internal.h +40 -0
@@ -24,4 +24,44 @@ extern int idxd_pmd_logtype; #define IDXD_PMD_ERR(fmt, args...) IDXD_PMD_LOG(ERR, fmt, ## args) #define IDXD_PMD_WARN(fmt, args...) IDXD_PMD_LOG(WARNING, fmt, ## args) +struct idxd_dmadev { +/* counters to track the batches */ +unsigned short max_batches; +unsigned short batch_idx_read; +unsigned short batch_idx_write; + +/* track descriptors and handles */ +unsigned short desc_ring_mask; +unsigned short ids_avail;/* handles for ops completed */ +unsigned short ids_returned;/* the read pointer for hdls/desc rings */ +unsigned short batch_start;/* start+size == write pointer for hdls/desc */ +unsigned short batch_size; + +void *portal;/* address to write the batch descriptor */ + +struct idxd_completion *batch_comp_ring; +unsigned short *batch_idx_ring;/* store where each batch ends */ + +struct rte_dma_stats stats; + +rte_iova_t batch_iova;/* base address of the batch comp ring */ +rte_iova_t desc_iova;/* base address of desc ring, needed for completions */ + +unsigned short max_batch_size; + +struct rte_dma_dev *dmadev; +struct rte_dma_vchan_conf qcfg; +uint8_t sva_support; +uint8_t qid; + +union { +struct { +unsigned int dsa_id; + } bus; + } u; +}; + +int idxd_dmadev_create (const char *name,struct rte_device *dev, +const struct idxd_dmadev *base_idxd,const struct rte_dma_dev_ops *ops); +#endif /* _IDXD_INTERNAL_H_ */
drivers/dma/idxd/meson.build +1 -0
@@ -8,5 +8,6 @@ endif deps += ['bus_pci'] sources = files( 'idxd_bus.c', + 'idxd_common.c', 'idxd_pci.c' )
Signature · 1 line
2.30.2
PATCH v4 5/16 dma/idxd: create dmadev instances on pci probe
In reply to Kevin LaatzWhen a suitable device is found during the PCI probe, create a dmadev instance for each HW queue. HW definitions required are also included.
---
v4: rebase changes
--- drivers/dma/idxd/idxd_hw_defs.h | 71 ++++++++ drivers/dma/idxd/idxd_internal.h | 16 ++ drivers/dma/idxd/idxd_pci.c | 278 ++++++++++++++++++++++++++++++- 3 files changed, 362 insertions(+), 3 deletions(-) create mode 100644 drivers/dma/idxd/idxd_hw_defs.h
drivers/dma/idxd/idxd_hw_defs.h new file +71 -0
@@ -0,0 +1,71 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright 2021 Intel Corporation +*/ + +#ifndef _IDXD_HW_DEFS_H_ +#define _IDXD_HW_DEFS_H_ + +/*** Definitions for Intel(R) Data Streaming Accelerator ***/ + +#define IDXD_CMD_SHIFT 20 +enum rte_idxd_cmds { + idxd_enable_dev =1 , + idxd_disable_dev, + idxd_drain_all, + idxd_abort_all, + idxd_reset_device, + idxd_enable_wq, + idxd_disable_wq, + idxd_drain_wq, + idxd_abort_wq, + idxd_reset_wq, +}; + +/* General bar0 registers */ +struct rte_idxd_bar0 { + uint32_t __rte_cache_aligned version; /* offset 0x00 */ + uint64_t __rte_aligned(0x10) gencap; /* offset 0x10 */ + uint64_t __rte_aligned(0x10) wqcap; /* offset 0x20 */ + uint64_t __rte_aligned(0x10) grpcap; /* offset 0x30 */ + uint64_t __rte_aligned(0x08) engcap; /* offset 0x38 */ + uint64_t __rte_aligned(0x10) opcap; /* offset 0x40 */ + uint64_t __rte_aligned(0x20) offsets[2]; /* offset 0x60 */ + uint32_t __rte_aligned(0x20) gencfg; /* offset 0x80 */ + uint32_t __rte_aligned(0x08) genctrl; /* offset 0x88 */ + uint32_t __rte_aligned(0x10) gensts; /* offset 0x90 */ + uint32_t __rte_aligned(0x08) intcause; /* offset 0x98 */ + uint32_t __rte_aligned(0x10) cmd; /* offset 0xA0 */ + uint32_t __rte_aligned(0x08) cmdstatus; /* offset 0xA8 */ + uint64_t __rte_aligned(0x20) swerror[4]; /* offset 0xC0 */ +}; + +/* workqueue config is provided by array of uint32_t. */ +enum rte_idxd_wqcfg { + wq_size_idx,/* size is in first 32-bit value */ + wq_threshold_idx,/* WQ threshold second 32-bits */ + wq_mode_idx,/* WQ mode and other flags */ + wq_sizes_idx,/* WQ transfer and batch sizes */ + wq_occ_int_idx,/* WQ occupancy interrupt handle */ + wq_occ_limit_idx,/* WQ occupancy limit */ + wq_state_idx,/* WQ state and occupancy state */ +}; + +#define WQ_MODE_SHARED 0 +#define WQ_MODE_DEDICATED 1 +#define WQ_PRIORITY_SHIFT 4 +#define WQ_BATCH_SZ_SHIFT 5 +#define WQ_STATE_SHIFT 30 +#define WQ_STATE_MASK 0x3 + +struct rte_idxd_grpcfg { + uint64_t grpwqcfg[4] __rte_cache_aligned; /* 64-byte register set */ +uint64_t grpengcfg;/* offset 32 */ +uint32_t grpflags;/* offset 40 */ +}; + +#define GENSTS_DEV_STATE_MASK 0x03 +#define CMDSTATUS_ACTIVE_SHIFT 31 +#define CMDSTATUS_ACTIVE_MASK (1 << 31) +#define CMDSTATUS_ERR_MASK 0xFF + +#endif
drivers/dma/idxd/idxd_internal.h +16 -0
@@ -5,6 +5,10 @@#ifndef _IDXD_INTERNAL_H_#define _IDXD_INTERNAL_H_ +#include <rte_spinlock.h> + +#include "idxd_hw_defs.h" +/** * @file idxd_internal.h *
@@ -24,6 +28,16 @@ extern int idxd_pmd_logtype; #define IDXD_PMD_ERR(fmt, args...) IDXD_PMD_LOG(ERR, fmt, ## args) #define IDXD_PMD_WARN(fmt, args...) IDXD_PMD_LOG(WARNING, fmt, ## args) +struct idxd_pci_common { +rte_spinlock_t lk; + +uint8_t wq_cfg_sz; +volatile struct rte_idxd_bar0 *regs; +volatile uint32_t *wq_regs_base; +volatile struct rte_idxd_grpcfg *grp_regs; +volatile void *portals; +}; +struct idxd_dmadev {/* counters to track the batches */ unsigned short max_batches;
@@ -58,6 +72,8 @@ struct idxd_dmadev {struct {unsigned int dsa_id; } bus; + +struct idxd_pci_common *pci; } u; };
drivers/dma/idxd/idxd_pci.c +275 -3
305 lines not on this page · raw message
Signature · 1 line
2.30.2
PATCH v4 6/16 dma/idxd: add datapath structures
In reply to Kevin LaatzAdd data structures required for the data path for IDXD devices.
---
v2: add completion status for invalid opcode
--- drivers/dma/idxd/idxd_bus.c | 1 + drivers/dma/idxd/idxd_common.c | 33 ++++++++++++++++++ drivers/dma/idxd/idxd_hw_defs.h | 60 ++++++++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 3 ++ drivers/dma/idxd/idxd_pci.c | 2 +- 5 files changed, 98 insertions(+), 1 deletion(-)
drivers/dma/idxd/idxd_bus.c +1 -0
@@ -95,6 +95,7 @@ idxd_dev_close(struct rte_dma_dev *dev)static const struct rte_dma_dev_ops idxd_bus_ops = { .dev_close = idxd_dev_close, + .dev_dump = idxd_dump, }; static void *
drivers/dma/idxd/idxd_common.c +33 -0
@@ -10,6 +10,35 @@#define IDXD_PMD_NAME_STR "dmadev_idxd" +int +idxd_dump (const struct rte_dma_dev *dev,FILE *f) +{ +struct idxd_dmadev *idxd = dev->dev_private; +unsigned int i; + +fprintf (f,"== IDXD Private Data ==\n" ); +fprintf (f," Portal: %p\n" , idxd->portal); +fprintf (f," Config: { ring_size: %u }\n" , + idxd->qcfg.nb_desc); +fprintf (f," Batch ring (sz = %u, max_batches = %u):\n\t" , + idxd->max_batches +1 , idxd->max_batches); +for (i =0 ; i <= idxd->max_batches; i++) { +fprintf (f," %u " , idxd->batch_idx_ring[i]); +if (i == idxd->batch_idx_read && i == idxd->batch_idx_write) +fprintf (f,"[rd ptr, wr ptr] " ); +else if (i == idxd->batch_idx_read) +fprintf (f,"[rd ptr] " ); +else if (i == idxd->batch_idx_write) +fprintf (f,"[wr ptr] " ); +if (i == idxd->max_batches) +fprintf (f,"\n" ); + } + +fprintf (f," Curr batch: start = %u, size = %u\n" , idxd->batch_start, idxd->batch_size); +fprintf (f," IDS: avail = %u, returned: %u\n" , idxd->ids_avail, idxd->ids_returned); +return 0 ; +} + int idxd_dmadev_create(const char *name, struct rte_device *dev, const struct idxd_dmadev *base_idxd,
@@ -19,6 +48,10 @@ idxd_dmadev_create(const char *name, struct rte_device *dev,struct rte_dma_dev *dmadev =NULL ;int ret =0 ; +RTE_BUILD_BUG_ON (sizeof (struct idxd_hw_desc ) !=64 ); +RTE_BUILD_BUG_ON (offsetof(struct idxd_hw_desc , size) !=32 ); +RTE_BUILD_BUG_ON (sizeof (struct idxd_completion ) !=32 ); +if (!name) {IDXD_PMD_ERR ("Invalid name of the device!" ); ret = -EINVAL ;
drivers/dma/idxd/idxd_hw_defs.h +60 -0
66 lines not on this page · raw message
drivers/dma/idxd/idxd_internal.h +3 -0
@@ -39,6 +39,8 @@ struct idxd_pci_common { };struct idxd_dmadev { +struct idxd_hw_desc *desc_ring; +/* counters to track the batches */ unsigned short max_batches;unsigned short batch_idx_read;
@@ -79,5 +81,6 @@ struct idxd_dmadev {int idxd_dmadev_create (const char *name,struct rte_device *dev,const struct idxd_dmadev *base_idxd,const struct rte_dma_dev_ops *ops); +int idxd_dump (const struct rte_dma_dev *dev,FILE *f);#endif /* _IDXD_INTERNAL_H_ */
drivers/dma/idxd/idxd_pci.c +1 -1
@@ -60,7 +60,7 @@ idxd_is_wq_enabled(struct idxd_dmadev *idxd) }static const struct rte_dma_dev_ops idxd_pci_ops = { - + .dev_dump = idxd_dump, };/* each portal uses 4 x 4k pages */
Signature · 1 line
2.30.2
PATCH v4 7/16 dma/idxd: add configure and info_get functions
In reply to Kevin LaatzAdd functions for device configuration. The info_get function is included here since it can be useful for checking successful configuration.
---
v2:
- fix reconfigure bug in idxd_vchan_setup()
- add literal include comment for the docs to pick up
v3:
- fixes needed after changes from rebasing
--- app/test/test_dmadev.c | 2 + doc/guides/dmadevs/idxd.rst | 30 +++++++++++++ drivers/dma/idxd/idxd_bus.c | 3 ++ drivers/dma/idxd/idxd_common.c | 72 ++++++++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 6 +++ drivers/dma/idxd/idxd_pci.c | 3 ++ 6 files changed, 116 insertions(+)
app/test/test_dmadev.c +2 -0
@@ -739,6 +739,7 @@ test_dmadev_instance(uint16_t dev_id) {#define TEST_RINGSIZE 512#define CHECK_ERRS true +/* Setup of the dmadev device. 8< */ struct rte_dma_stats stats;struct rte_dma_info info;const struct rte_dma_conf conf = { .nb_vchans =1 };
@@ -759,6 +760,7 @@ test_dmadev_instance(uint16_t dev_id)if (rte_dma_vchan_setup (dev_id, vchan, &qconf) <0 )ERR_RETURN ("Error with queue configuration\n" ); +/* >8 End of setup of the dmadev device. */ rte_dma_info_get (dev_id, &info);if (info.nb_vchans !=1 )
doc/guides/dmadevs/idxd.rst +30 -0
@@ -120,3 +120,33 @@ use a subset of configured queues. Once probed successfully, irrespective of kernel driver, the device will appear as a ``dmadev``, that is a "DMA device type" inside DPDK, and can be accessed using APIs from the ``rte_dmadev`` library. + +Using IDXD DMAdev Devices +-------------------------- + +To use the devices from an application, the dmadev API can be used. + +Getting Device Information +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Basic information about each dmadev device can be queried using the +``rte_dma_info_get()`` API. This will return basic device information such as +the ``rte_device`` structure, device capabilities and other device specific values. + +Device Configuration +~~~~~~~~~~~~~~~~~~~~~ + +Configuring an IDXD dmadev device is done using the ``rte_dma_configure()`` and +``rte_dma_vchan_setup`` APIs. The configurations are passed to these APIs using +the ``rte_dma_conf`` and ``rte_dma_vchan_conf`` structures, respectively. For +example, these can be used to configure the number of ``vchans`` per device, the +ring size, etc. The ring size must be a power of two, between 64 and 4096. + +The following code shows how the device is configured in +``test_dmadev.c``: + +.. literalinclude:: ../../../app/test/test_dmadev.c + :language: c + :start-after: Setup of the dmadev device. 8< + :end-before: >8 End of setup of the dmadev device. + :dedent: 1
drivers/dma/idxd/idxd_bus.c +3 -0
@@ -96,6 +96,9 @@ idxd_dev_close(struct rte_dma_dev *dev)static const struct rte_dma_dev_ops idxd_bus_ops = { .dev_close = idxd_dev_close, .dev_dump = idxd_dump, + .dev_configure = idxd_configure, + .vchan_setup = idxd_vchan_setup, + .dev_info_get = idxd_info_get, }; static void *
drivers/dma/idxd/idxd_common.c +72 -0
78 lines not on this page · raw message
drivers/dma/idxd/idxd_internal.h +6 -0
@@ -82,5 +82,11 @@ struct idxd_dmadev {int idxd_dmadev_create (const char *name,struct rte_device *dev,const struct idxd_dmadev *base_idxd,const struct rte_dma_dev_ops *ops);int idxd_dump (const struct rte_dma_dev *dev,FILE *f); +int idxd_configure (struct rte_dma_dev *dev,const struct rte_dma_conf *dev_conf, +uint32_t conf_sz); +int idxd_vchan_setup (struct rte_dma_dev *dev,uint16_t vchan, +const struct rte_dma_vchan_conf *qconf,uint32_t qconf_sz); +int idxd_info_get (const struct rte_dma_dev *dev,struct rte_dma_info *dev_info, +uint32_t size);#endif /* _IDXD_INTERNAL_H_ */
drivers/dma/idxd/idxd_pci.c +3 -0
@@ -61,6 +61,9 @@ idxd_is_wq_enabled(struct idxd_dmadev *idxd)static const struct rte_dma_dev_ops idxd_pci_ops = { .dev_dump = idxd_dump, + .dev_configure = idxd_configure, + .vchan_setup = idxd_vchan_setup, + .dev_info_get = idxd_info_get, };/* each portal uses 4 x 4k pages */
Signature · 1 line
2.30.2
PATCH v4 8/16 dma/idxd: add start and stop functions for pci devices
In reply to Kevin LaatzAdd device start/stop functions for DSA devices bound to vfio. For devices bound to the IDXD kernel driver, these are not required since the IDXD kernel driver takes care of this.
--- doc/guides/dmadevs/idxd.rst | 3 +++ drivers/dma/idxd/idxd_pci.c | 52 +++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+)
doc/guides/dmadevs/idxd.rst +3 -0
@@ -150,3 +150,6 @@ The following code shows how the device is configured in :start-after: Setup of the dmadev device. 8< :end-before: >8 End of setup of the dmadev device. :dedent: 1 + +Once configured, the device can then be made ready for use by calling the +``rte_dma_start()`` API.
drivers/dma/idxd/idxd_pci.c +52 -0
63 lines not on this page · raw message
Signature · 1 line
2.30.2
PATCH v4 9/16 dma/idxd: add data-path job submission functions
In reply to Kevin LaatzAdd data path functions for enqueuing and submitting operations to DSA devices.
--- doc/guides/dmadevs/idxd.rst | 64 +++++++++++++++ drivers/dma/idxd/idxd_common.c | 136 +++++++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 5 ++ drivers/dma/idxd/meson.build | 1 + 4 files changed, 206 insertions(+)
doc/guides/dmadevs/idxd.rst +64 -0
@@ -153,3 +153,67 @@ The following code shows how the device is configured in Once configured, the device can then be made ready for use by calling the ``rte_dma_start()`` API. + +Performing Data Copies +~~~~~~~~~~~~~~~~~~~~~~~ + +To perform data copies using IDXD dmadev devices, descriptors should be enqueued +using the ``rte_dma_copy()`` API. The HW can be triggered to perform the copy +in two ways, either via a ``RTE_DMA_OP_FLAG_SUBMIT`` flag or by calling +``rte_dma_submit()``. Once copies have been completed, the completion will +be reported back when the application calls ``rte_dma_completed()`` or +``rte_dma_completed_status()``. The latter will also report the status of each +completed operation. + +The ``rte_dma_copy()`` function enqueues a single copy to the device ring for +copying at a later point. The parameters to that function include the IOVA addresses +of both the source and destination buffers, as well as the length of the copy. + +The ``rte_dma_copy()`` function enqueues a copy operation on the device ring. +If the ``RTE_DMA_OP_FLAG_SUBMIT`` flag is set when calling ``rte_dma_copy()``, +the device hardware will be informed of the elements. Alternatively, if the flag +is not set, the application needs to call the ``rte_dma_submit()`` function to +notify the device hardware. Once the device hardware is informed of the elements +enqueued on the ring, the device will begin to process them. It is expected +that, for efficiency reasons, a burst of operations will be enqueued to the +device via multiple enqueue calls between calls to the ``rte_dma_submit()`` +function. + +The following code demonstrates how to enqueue a burst of copies to the +device and start the hardware processing of them: + +.. code-block:: C + + struct rte_mbuf *srcs[COMP_BURST_SZ], *dsts[COMP_BURST_SZ]; + unsigned int i; + + for (i = 0; i < RTE_DIM(srcs); i++) { + uint64_t *src_data; + + srcs[i] = rte_pktmbuf_alloc(pool); + dsts[i] = rte_pktmbuf_alloc(pool); + src_data = rte_pktmbuf_mtod(srcs[i], uint64_t *); + if (srcs[i] == NULL || dsts[i] == NULL) { + PRINT_ERR("Error allocating buffers\n"); + return -1; + } + + for (j = 0; j < COPY_LEN/sizeof(uint64_t); j++) + src_data[j] = rte_rand(); + + if (rte_dma_copy(dev_id, vchan, srcs[i]->buf_iova + srcs[i]->data_off, + dsts[i]->buf_iova + dsts[i]->data_off, COPY_LEN, 0) < 0) { + PRINT_ERR("Error with rte_dma_copy for buffer %u\n", i); + return -1; + } + } + rte_dma_submit(dev_id, vchan); + +Filling an Area of Memory +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The IDXD driver also has support for the ``fill`` operation, where an area +of memory is overwritten, or filled, with a short pattern of data. +Fill operations can be performed in much the same was as copy operations +described above, just using the ``rte_dma_fill()`` function rather than the +``rte_dma_copy()`` function.
drivers/dma/idxd/idxd_common.c +136 -0
156 lines not on this page · raw message
drivers/dma/idxd/idxd_internal.h +5 -0
@@ -88,5 +88,10 @@ int idxd_vchan_setup(struct rte_dma_dev *dev, uint16_t vchan, const struct rte_dma_vchan_conf *qconf, uint32_t qconf_sz);int idxd_info_get (const struct rte_dma_dev *dev,struct rte_dma_info *dev_info,uint32_t size); +int idxd_enqueue_copy (struct rte_dma_dev *dev,uint16_t qid,rte_iova_t src, +rte_iova_t dst,unsigned int length,uint64_t flags); +int idxd_enqueue_fill (struct rte_dma_dev *dev,uint16_t qid,uint64_t pattern, +rte_iova_t dst,unsigned int length,uint64_t flags); +int idxd_submit (struct rte_dma_dev *dev,uint16_t qid);#endif /* _IDXD_INTERNAL_H_ */
drivers/dma/idxd/meson.build +1 -0
@@ -6,6 +6,7 @@ if is_windows endif deps += ['bus_pci'] +cflags += '-mavx2' # all platforms with idxd HW support AVX sources = files( 'idxd_bus.c', 'idxd_common.c',
Signature · 1 line
2.30.2
PATCH v4 10/16 dma/idxd: add data-path job completion functions
In reply to Kevin LaatzAdd the data path functions for gathering completed operations.
---
v2:
- fixed typo in docs
- add completion status for invalid opcode
--- doc/guides/dmadevs/idxd.rst | 32 +++++ drivers/dma/idxd/idxd_common.c | 235 +++++++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 5 + 3 files changed, 272 insertions(+)
doc/guides/dmadevs/idxd.rst +32 -0
@@ -209,6 +209,38 @@ device and start the hardware processing of them: } rte_dma_submit(dev_id, vchan); +To retrieve information about completed copies, ``rte_dma_completed()`` and +``rte_dma_completed_status()`` APIs should be used. ``rte_dma_completed()`` +will return the number of completed operations, along with the index of the last +successful completed operation and whether or not an error was encountered. If an +error was encountered, ``rte_dma_completed_status()`` must be used to kick the +device off to continue processing operations and also to gather the status of each +individual operations which is filled in to the ``status`` array provided as +parameter by the application. + +The following status codes are supported by IDXD: +* ``RTE_DMA_STATUS_SUCCESSFUL``: The operation was successful. +* ``RTE_DMA_STATUS_INVALID_OPCODE``: The operation failed due to an invalid operation code. +* ``RTE_DMA_STATUS_INVALID_LENGTH``: The operation failed due to an invalid data length. +* ``RTE_DMA_STATUS_NOT_ATTEMPTED``: The operation was not attempted. +* ``RTE_DMA_STATUS_ERROR_UNKNOWN``: The operation failed due to an unspecified error. + +The following code shows how to retrieve the number of successfully completed +copies within a burst and then using ``rte_dma_completed_status()`` to check +which operation failed and kick off the device to continue processing operations: + +.. code-block:: C + + enum rte_dma_status_code status[COMP_BURST_SZ]; + uint16_t count, idx, status_count; + bool error = 0; + + count = rte_dma_completed(dev_id, vchan, COMP_BURST_SZ, &idx, &error); + + if (error){ + status_count = rte_dma_completed_status(dev_id, vchan, COMP_BURST_SZ, &idx, status); + } + Filling an Area of Memory ~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/dma/idxd/idxd_common.c +235 -0
241 lines not on this page · raw message
drivers/dma/idxd/idxd_internal.h +5 -0
@@ -93,5 +93,10 @@ int idxd_enqueue_copy(struct rte_dma_dev *dev, uint16_t qid, rte_iova_t src,int idxd_enqueue_fill (struct rte_dma_dev *dev,uint16_t qid,uint64_t pattern,rte_iova_t dst,unsigned int length,uint64_t flags);int idxd_submit (struct rte_dma_dev *dev,uint16_t qid); +uint16_t idxd_completed (struct rte_dma_dev *dev,uint16_t qid,uint16_t max_ops, +uint16_t *last_idx,bool *has_error); +uint16_t idxd_completed_status(struct rte_dma_dev *dev, uint16_t qid __rte_unused, +uint16_t max_ops,uint16_t *last_idx, +enum rte_dma_status_code *status);#endif /* _IDXD_INTERNAL_H_ */
Signature · 1 line
2.30.2
PATCH v4 11/16 dma/idxd: add operation statistic tracking
In reply to Kevin LaatzAdd statistic tracking for DSA devices.
--- doc/guides/dmadevs/idxd.rst | 11 +++++++++++ drivers/dma/idxd/idxd_bus.c | 2 ++ drivers/dma/idxd/idxd_common.c | 27 +++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 3 +++ drivers/dma/idxd/idxd_pci.c | 2 ++ 5 files changed, 45 insertions(+)
doc/guides/dmadevs/idxd.rst +11 -0
@@ -249,3 +249,14 @@ of memory is overwritten, or filled, with a short pattern of data. Fill operations can be performed in much the same was as copy operations described above, just using the ``rte_dma_fill()`` function rather than the ``rte_dma_copy()`` function. + +Querying Device Statistics +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The statistics from the IDXD dmadev device can be got via the stats functions in +the ``rte_dmadev`` library, i.e. ``rte_dma_stats_get()``. The statistics +returned for each device instance are: + +* ``submitted``: The number of operations submitted to the device. +* ``completed``: The number of operations which have completed (successful and failed). +* ``errors``: The number of operations that completed with error.
drivers/dma/idxd/idxd_bus.c +2 -0
@@ -99,6 +99,8 @@ static const struct rte_dma_dev_ops idxd_bus_ops = { .dev_configure = idxd_configure, .vchan_setup = idxd_vchan_setup, .dev_info_get = idxd_info_get, + .stats_get = idxd_stats_get, + .stats_reset = idxd_stats_reset, }; static void *
drivers/dma/idxd/idxd_common.c +27 -0
@@ -65,6 +65,8 @@ __submit(struct idxd_dmadev *idxd)if (++idxd->batch_idx_write > idxd->max_batches) idxd->batch_idx_write =0 ; + idxd->stats.submitted += idxd->batch_size; + idxd->batch_start += idxd->batch_size; idxd->batch_size =0 ; idxd->batch_idx_ring[idxd->batch_idx_write] = idxd->batch_start;
@@ -275,6 +277,8 @@ batch_completed_status(struct idxd_dmadev *idxd, uint16_t max_ops, enum rte_dma_const uint16_t b_len = b_end - b_start;if (b_len ==1 ) {/* not a batch */ *status =get_comp_status (&idxd->batch_comp_ring[idxd->batch_idx_read]); +if (status !=RTE_DMA_STATUS_SUCCESSFUL ) + idxd->stats.errors++; idxd->ids_avail++; idxd->ids_returned++; idxd->batch_idx_read = next_batch;
@@ -296,6 +300,8 @@ batch_completed_status(struct idxd_dmadev *idxd, uint16_t max_ops, enum rte_dma_struct idxd_completion *c = (void *) &idxd->desc_ring[(b_start + ret) & idxd->desc_ring_mask]; status[ret] = (ret < bcount) ?get_comp_status (c) :RTE_DMA_STATUS_NOT_ATTEMPTED ; +if (status[ret] !=RTE_DMA_STATUS_SUCCESSFUL ) + idxd->stats.errors++; } idxd->ids_avail = idxd->ids_returned += ret;
@@ -354,6 +360,7 @@ idxd_completed(struct rte_dma_dev *dev, uint16_t qid __rte_unused, uint16_t max_ ret += batch; }while (batch >0 && *has_error == false); + idxd->stats.completed += ret; *last_idx = idxd->ids_returned -1 ;return ret; }
@@ -371,6 +378,7 @@ idxd_completed_status(struct rte_dma_dev *dev, uint16_t qid __rte_unused, uint16 ret += batch; }while (batch >0 ); + idxd->stats.completed += ret; *last_idx = idxd->ids_returned -1 ;return ret; }
@@ -404,6 +412,25 @@ idxd_dump(const struct rte_dma_dev *dev, FILE *f)return 0 ; } +int +idxd_stats_get(const struct rte_dma_dev *dev, uint16_t vchan __rte_unused, +struct rte_dma_stats *stats,uint32_t stats_sz) +{ +struct idxd_dmadev *idxd = dev->dev_private; +if (stats_sz <sizeof (*stats)) +return -EINVAL ; + *stats = idxd->stats; +return 0 ; +} + +int +idxd_stats_reset(struct rte_dma_dev *dev, uint16_t vchan __rte_unused) +{ +struct idxd_dmadev *idxd = dev->dev_private; + idxd->stats = (struct rte_dma_stats ){0 }; +return 0 ; +} +int idxd_info_get (const struct rte_dma_dev *dev,struct rte_dma_info *info,uint32_t size) {
drivers/dma/idxd/idxd_internal.h +3 -0
@@ -98,5 +98,8 @@ uint16_t idxd_completed(struct rte_dma_dev *dev, uint16_t qid, uint16_t max_ops, uint16_t idxd_completed_status(struct rte_dma_dev *dev, uint16_t qid __rte_unused,uint16_t max_ops,uint16_t *last_idx,enum rte_dma_status_code *status); +int idxd_stats_get (const struct rte_dma_dev *dev,uint16_t vchan, +struct rte_dma_stats *stats,uint32_t stats_sz); +int idxd_stats_reset (struct rte_dma_dev *dev,uint16_t vchan);#endif /* _IDXD_INTERNAL_H_ */
drivers/dma/idxd/idxd_pci.c +2 -0
@@ -114,6 +114,8 @@ static const struct rte_dma_dev_ops idxd_pci_ops = { .dev_configure = idxd_configure, .vchan_setup = idxd_vchan_setup, .dev_info_get = idxd_info_get, + .stats_get = idxd_stats_get, + .stats_reset = idxd_stats_reset, .dev_start = idxd_pci_dev_start, .dev_stop = idxd_pci_dev_stop, };
Signature · 1 line
2.30.2
PATCH v4 12/16 dma/idxd: add vchan status function
In reply to Kevin LaatzWhen testing dmadev drivers, it is useful to have the HW device in a known state. This patch adds the implementation of the function which will wait for the device to be idle (all jobs completed) before proceeding.
---
v3: update API name to vchan_status
--- drivers/dma/idxd/idxd_bus.c | 1 + drivers/dma/idxd/idxd_common.c | 17 +++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 2 ++ drivers/dma/idxd/idxd_pci.c | 1 + 4 files changed, 21 insertions(+)
drivers/dma/idxd/idxd_bus.c +1 -0
@@ -101,6 +101,7 @@ static const struct rte_dma_dev_ops idxd_bus_ops = { .dev_info_get = idxd_info_get, .stats_get = idxd_stats_get, .stats_reset = idxd_stats_reset, + .vchan_status = idxd_vchan_status, }; static void *
drivers/dma/idxd/idxd_common.c +17 -0
@@ -162,6 +162,23 @@ get_comp_status(struct idxd_completion *c) } } +int +idxd_vchan_status(const struct rte_dma_dev *dev, uint16_t vchan __rte_unused, +enum rte_dma_vchan_status *status) +{ +struct idxd_dmadev *idxd = dev->dev_private; +uint16_t last_batch_write = idxd->batch_idx_write ==0 ? idxd->max_batches : + idxd->batch_idx_write -1 ; +uint8_t bstatus = (idxd->batch_comp_ring[last_batch_write].status !=0 ); + +/* An IDXD device will always be either active or idle. +* RTE_DMA_VCHAN_HALTED_ERROR is therefore not supported by IDXD. +*/ + *status = bstatus ?RTE_DMA_VCHAN_IDLE :RTE_DMA_VCHAN_ACTIVE ; + +return 0 ; +} + static __rte_always_inline intbatch_ok (struct idxd_dmadev *idxd,uint8_t max_ops,enum rte_dma_status_code *status) {
drivers/dma/idxd/idxd_internal.h +2 -0
@@ -101,5 +101,7 @@ uint16_t idxd_completed_status(struct rte_dma_dev *dev, uint16_t qid __rte_unuseint idxd_stats_get (const struct rte_dma_dev *dev,uint16_t vchan,struct rte_dma_stats *stats,uint32_t stats_sz);int idxd_stats_reset (struct rte_dma_dev *dev,uint16_t vchan); +int idxd_vchan_status (const struct rte_dma_dev *dev,uint16_t vchan, +enum rte_dma_vchan_status *status);#endif /* _IDXD_INTERNAL_H_ */
drivers/dma/idxd/idxd_pci.c +1 -0
@@ -118,6 +118,7 @@ static const struct rte_dma_dev_ops idxd_pci_ops = { .stats_reset = idxd_stats_reset, .dev_start = idxd_pci_dev_start, .dev_stop = idxd_pci_dev_stop, + .vchan_status = idxd_vchan_status, };/* each portal uses 4 x 4k pages */
Signature · 1 line
2.30.2
PATCH v4 13/16 dma/idxd: add burst capacity API
In reply to Kevin LaatzAdd support for the burst capacity API. This API will provide the calling application with the remaining capacity of the current burst (limited by max HW batch size).
--- drivers/dma/idxd/idxd_bus.c | 1 + drivers/dma/idxd/idxd_common.c | 20 ++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 1 + drivers/dma/idxd/idxd_pci.c | 2 ++ 4 files changed, 24 insertions(+)
drivers/dma/idxd/idxd_bus.c +1 -0
@@ -102,6 +102,7 @@ static const struct rte_dma_dev_ops idxd_bus_ops = { .stats_get = idxd_stats_get, .stats_reset = idxd_stats_reset, .vchan_status = idxd_vchan_status, + .burst_capacity = idxd_burst_capacity, }; static void *
drivers/dma/idxd/idxd_common.c +20 -0
@@ -469,6 +469,26 @@ idxd_info_get(const struct rte_dma_dev *dev, struct rte_dma_info *info, uint32_treturn 0 ; } +uint16_t +idxd_burst_capacity(const struct rte_dma_dev *dev, uint16_t vchan __rte_unused) +{ +struct idxd_dmadev *idxd = dev->dev_private; +uint16_t write_idx = idxd->batch_start + idxd->batch_size; +uint16_t used_space; + +/* Check for space in the batch ring */ +if ((idxd->batch_idx_read ==0 && idxd->batch_idx_write == idxd->max_batches) || + idxd->batch_idx_write +1 == idxd->batch_idx_read) +return 0 ; + +/* For descriptors, check for wrap-around on write but not read */ +if (idxd->ids_returned > write_idx) + write_idx += idxd->desc_ring_mask +1 ; + used_space = write_idx - idxd->ids_returned; + +return RTE_MIN ((idxd->desc_ring_mask - used_space), idxd->max_batch_size); +} +int idxd_configure(struct rte_dma_dev *dev __rte_unused, const struct rte_dma_conf *dev_conf,uint32_t conf_sz)
drivers/dma/idxd/idxd_internal.h +1 -0
@@ -103,5 +103,6 @@ int idxd_stats_get(const struct rte_dma_dev *dev, uint16_t vchan,int idxd_stats_reset (struct rte_dma_dev *dev,uint16_t vchan);int idxd_vchan_status (const struct rte_dma_dev *dev,uint16_t vchan,enum rte_dma_vchan_status *status); +uint16_t idxd_burst_capacity (const struct rte_dma_dev *dev,uint16_t vchan);#endif /* _IDXD_INTERNAL_H_ */
drivers/dma/idxd/idxd_pci.c +2 -0
@@ -119,6 +119,7 @@ static const struct rte_dma_dev_ops idxd_pci_ops = { .dev_start = idxd_pci_dev_start, .dev_stop = idxd_pci_dev_stop, .vchan_status = idxd_vchan_status, + .burst_capacity = idxd_burst_capacity, };/* each portal uses 4 x 4k pages */
@@ -232,6 +233,7 @@ init_pci_device(struct rte_pci_device *dev, struct idxd_dmadev *idxd, idxd->u.pci = pci; idxd->max_batches = wq_size; + idxd->max_batch_size =1 << lg2_max_batch;/* enable the device itself */ err_code =idxd_pci_dev_command (idxd, idxd_enable_dev);
Signature · 1 line
2.30.2
PATCH v4 14/16 dma/idxd: move dpdk_idxd_cfg.py from raw to dma
In reply to Kevin LaatzFrom: Conor Walsh <[email protected]>
Move the example script for configuring IDXD devices bound to the IDXD kernel driver from raw to dma, and create a symlink to still allow use from raw.
--- drivers/dma/idxd/dpdk_idxd_cfg.py | 117 +++++++++++++++++++++++++++++ drivers/raw/ioat/dpdk_idxd_cfg.py | 118 +----------------------------- 2 files changed, 118 insertions(+), 117 deletions(-) create mode 100755 drivers/dma/idxd/dpdk_idxd_cfg.py mode change 100755 => 120000 drivers/raw/ioat/dpdk_idxd_cfg.py
drivers/dma/idxd/dpdk_idxd_cfg.py new file +117 -0
@@ -0,0 +1,117 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2020 Intel Corporation + +""" +Configure an entire Intel DSA instance, using idxd kernel driver, for DPDK use +""" + +import sys +import argparse +import os +import os.path + + +class SysfsDir: + "Used to read/write paths in a sysfs directory" + def __init__(self, path): + self.path = path + + def read_int(self, filename): + "Return a value from sysfs file" + with open(os.path.join(self.path, filename)) as f: + return int(f.readline()) + + def write_values(self, values): + "write dictionary, where key is filename and value is value to write" + for filename, contents in values.items(): + with open(os.path.join(self.path, filename), "w") as f: + f.write(str(contents)) + + +def reset_device(dsa_id): + "Reset the DSA device and all its queues" + drv_dir = SysfsDir("/sys/bus/dsa/drivers/dsa") + drv_dir.write_values({"unbind": f"dsa{dsa_id}"}) + + +def get_pci_dir(pci): + "Search for the sysfs directory of the PCI device" + base_dir = '/sys/bus/pci/devices/' + for path, dirs, files in os.walk(base_dir): + for dir in dirs: + if pci in dir: + return os.path.join(base_dir, dir) + sys.exit(f"Could not find sysfs directory for device {pci}") + + +def get_dsa_id(pci): + "Get the DSA instance ID using the PCI address of the device" + pci_dir = get_pci_dir(pci) + for path, dirs, files in os.walk(pci_dir): + for dir in dirs: + if dir.startswith('dsa') and 'wq' not in dir: + return int(dir[3:]) + sys.exit(f"Could not get device ID for device {pci}") + + +def configure_dsa(dsa_id, queues, prefix): + "Configure the DSA instance with appropriate number of queues" + dsa_dir = SysfsDir(f"/sys/bus/dsa/devices/dsa{dsa_id}") + drv_dir = SysfsDir("/sys/bus/dsa/drivers/dsa") + + max_groups = dsa_dir.read_int("max_groups") + max_engines = dsa_dir.read_int("max_engines") + max_queues = dsa_dir.read_int("max_work_queues") + max_work_queues_size = dsa_dir.read_int("max_work_queues_size") + + nb_queues = min(queues, max_queues) + if queues > nb_queues: + print(f"Setting number of queues to max supported value: {max_queues}") + + # we want one engine per group, and no more engines than queues + nb_groups = min(max_engines, max_groups, nb_queues) + for grp in range(nb_groups): + dsa_dir.write_values({f"engine{dsa_id}.{grp}/group_id": grp}) + + # configure each queue + for q in range(nb_queues): + wq_dir = SysfsDir(os.path.join(dsa_dir.path, f"wq{dsa_id}.{q}")) + wq_dir.write_values({"group_id": q % nb_groups, + "type": "user", + "mode": "dedicated", + "name": f"{prefix}_wq{dsa_id}.{q}", + "priority": 1, + "size": int(max_work_queues_size / nb_queues)}) + + # enable device and then queues + drv_dir.write_values({"bind": f"dsa{dsa_id}"}) + for q in range(nb_queues): + drv_dir.write_values({"bind": f"wq{dsa_id}.{q}"}) + + +def main(args): + "Main function, does arg parsing and calls config function" + arg_p = argparse.ArgumentParser( + description="Configure whole DSA device instance for DPDK use") + arg_p.add_argument('dsa_id', + help="Specify DSA instance either via DSA instance number or PCI address") + arg_p.add_argument('-q', metavar='queues', type=int, default=255, + help="Number of queues to set up") + arg_p.add_argument('--name-prefix', metavar='prefix', dest='prefix', + default="dpdk", + help="Prefix for workqueue name to mark for DPDK use [default: 'dpdk']") + arg_p.add_argument('--reset', action='store_true', + help="Reset DSA device and its queues") + parsed_args = arg_p.parse_args(args[1:]) + + dsa_id = parsed_args.dsa_id + dsa_id = get_dsa_id(dsa_id) if ':' in dsa_id else dsa_id + if parsed_args.reset: + reset_device(dsa_id) + else: + configure_dsa(dsa_id, parsed_args.q, parsed_args.prefix) + + +if __name__ == "__main__": + main(sys.argv)
drivers/raw/ioat/dpdk_idxd_cfg.py deleted +0 -117
117 lines not on this page · raw message
drivers/raw/ioat/dpdk_idxd_cfg.py new file +1 -0
@@ -0,0 +1 @@ +../../dma/idxd/dpdk_idxd_cfg.py
Signature · 1 line
2.30.2
PATCH v4 15/16 devbind: add dma device class
In reply to Kevin LaatzAdd a new class for DMA devices. Devices listed under the DMA class are to be used with the dmadev library.
--- usertools/dpdk-devbind.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
usertools/dpdk-devbind.py +9 -3
@@ -69,12 +69,13 @@ network_devices = [network_class, cavium_pkx, avp_vnic, ifpga_class] baseband_devices = [acceleration_class] crypto_devices = [encryption_class, intel_processor_class] +dma_devices = [] eventdev_devices = [cavium_sso, cavium_tim, intel_dlb, octeontx2_sso] mempool_devices = [cavium_fpa, octeontx2_npa] compress_devices = [cavium_zip] regex_devices = [octeontx2_ree] -misc_devices = [cnxk_bphy, cnxk_bphy_cgx, intel_ioat_bdw, intel_ioat_skx, intel_ioat_icx, intel_idxd_spr, - intel_ntb_skx, intel_ntb_icx, +misc_devices = [cnxk_bphy, cnxk_bphy_cgx, intel_ioat_bdw, intel_ioat_skx, + intel_ioat_icx, intel_idxd_spr, intel_ntb_skx, intel_ntb_icx, octeontx2_dma] # global dict ethernet devices present. Dictionary indexed by PCI address.
@@ -583,6 +584,9 @@ def show_status(): if status_dev in ["crypto", "all"]: show_device_status(crypto_devices, "Crypto") + if status_dev in ["dma", "all"]: + show_device_status(dma_devices, "DMA") + if status_dev in ["event", "all"]: show_device_status(eventdev_devices, "Eventdev")
@@ -651,7 +655,7 @@ def parse_args(): parser.add_argument( '--status-dev', help="Print the status of given device group.", - choices=['baseband', 'compress', 'crypto', 'event', + choices=['baseband', 'compress', 'crypto', 'dma', 'event', 'mempool', 'misc', 'net', 'regex']) bind_group = parser.add_mutually_exclusive_group() bind_group.add_argument(
@@ -732,6 +736,7 @@ def do_arg_actions(): get_device_details(network_devices) get_device_details(baseband_devices) get_device_details(crypto_devices) + get_device_details(dma_devices) get_device_details(eventdev_devices) get_device_details(mempool_devices) get_device_details(compress_devices)
@@ -754,6 +759,7 @@ def main(): get_device_details(network_devices) get_device_details(baseband_devices) get_device_details(crypto_devices) + get_device_details(dma_devices) get_device_details(eventdev_devices) get_device_details(mempool_devices) get_device_details(compress_devices)
Signature · 1 line
2.30.2
PATCH v4 16/16 devbind: move idxd device ID to dmadev class
In reply to Kevin LaatzThe dmadev library is the preferred abstraction for using IDXD devices and will replace the rawdev implementation in future. This patch moves the IDXD device ID to the dmadev class.
--- usertools/dpdk-devbind.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
usertools/dpdk-devbind.py +2 -2
@@ -69,13 +69,13 @@ network_devices = [network_class, cavium_pkx, avp_vnic, ifpga_class] baseband_devices = [acceleration_class] crypto_devices = [encryption_class, intel_processor_class] -dma_devices = [] +dma_devices = [intel_idxd_spr] eventdev_devices = [cavium_sso, cavium_tim, intel_dlb, octeontx2_sso] mempool_devices = [cavium_fpa, octeontx2_npa] compress_devices = [cavium_zip] regex_devices = [octeontx2_ree] misc_devices = [cnxk_bphy, cnxk_bphy_cgx, intel_ioat_bdw, intel_ioat_skx, - intel_ioat_icx, intel_idxd_spr, intel_ntb_skx, intel_ntb_icx, + intel_ioat_icx, intel_ntb_skx, intel_ntb_icx, octeontx2_dma] # global dict ethernet devices present. Dictionary indexed by PCI address.
Signature · 1 line
2.30.2
v5 cover add dmadev driver for idxd devices
In reply to Kevin LaatzThis patchset adds a dmadev driver and associated documentation to support Intel Data Streaming Accelerator devices. This driver is intended to ultimately replace the current IDXD part of the IOAT rawdev driver.
NOTE: This patchset has several dependencies:
- v22 of the dmadev lib set [1]
- v5 of the dmadev test suite [2]
[1] http://patches.dpdk.org/project/dpdk/list/?series=18960
[2] http://patches.dpdk.org/project/dpdk/list/?series=19017
v5:
* add missing toctree entry for idxd driver
v4:
* rebased on above patchsets
* minor fixes based on review feedback
v3:
* rebased on above patchsets
* added burst capacity API
v2:
* rebased on above patchsets
* added API to check for device being idle
* added devbind updates for DMA devices
* fixed issue identified by internal coverity scan
* other minor miscellaneous changes and fixes
Bruce Richardson (1):
raw/ioat: only build if dmadev not present
Conor Walsh (1):
dma/idxd: move dpdk_idxd_cfg.py from raw to dma
Kevin Laatz (14):
dma/idxd: add skeleton for VFIO based DSA device dma/idxd: add bus device probing
dma/idxd: create dmadev instances on bus probe dma/idxd: create dmadev instances on pci probe dma/idxd: add datapath structures
dma/idxd: add configure and info_get functions dma/idxd: add start and stop functions for pci devices dma/idxd: add data-path job submission functions dma/idxd: add data-path job completion functions dma/idxd: add operation statistic tracking dma/idxd: add vchan status function
dma/idxd: add burst capacity API
devbind: add dma device class
devbind: move idxd device ID to dmadev class
MAINTAINERS | 10 + app/test/test_dmadev.c | 2 + doc/guides/dmadevs/idxd.rst | 262 +++++++++++ doc/guides/dmadevs/index.rst | 2 + doc/guides/rawdevs/ioat.rst | 7 + doc/guides/rel_notes/release_21_11.rst | 5 + drivers/dma/idxd/dpdk_idxd_cfg.py | 117 +++++ drivers/dma/idxd/idxd_bus.c | 378 +++++++++++++++ drivers/dma/idxd/idxd_common.c | 616 +++++++++++++++++++++++++ drivers/dma/idxd/idxd_hw_defs.h | 131 ++++++ drivers/dma/idxd/idxd_internal.h | 108 +++++ drivers/dma/idxd/idxd_pci.c | 387 ++++++++++++++++ drivers/dma/idxd/meson.build | 14 + drivers/dma/idxd/version.map | 3 + drivers/dma/meson.build | 2 + drivers/meson.build | 2 +- drivers/raw/ioat/dpdk_idxd_cfg.py | 118 +---- drivers/raw/ioat/meson.build | 23 +- usertools/dpdk-devbind.py | 12 +- 19 files changed, 2075 insertions(+), 124 deletions(-) create mode 100644 doc/guides/dmadevs/idxd.rst create mode 100755 drivers/dma/idxd/dpdk_idxd_cfg.py create mode 100644 drivers/dma/idxd/idxd_bus.c create mode 100644 drivers/dma/idxd/idxd_common.c create mode 100644 drivers/dma/idxd/idxd_hw_defs.h create mode 100644 drivers/dma/idxd/idxd_internal.h create mode 100644 drivers/dma/idxd/idxd_pci.c create mode 100644 drivers/dma/idxd/meson.build create mode 100644 drivers/dma/idxd/version.map mode change 100755 => 120000 drivers/raw/ioat/dpdk_idxd_cfg.py
Signature · 1 line
2.30.2
PATCH v5 1/16 raw/ioat: only build if dmadev not present
From: Bruce Richardson <[email protected]>
Only build the rawdev IDXD/IOAT drivers if the dmadev drivers are not present.
A not is also added to the documentation to inform users of this change.
---
v4:
- Fix build issue
- Add note in raw documentation to outline this change
--- doc/guides/rawdevs/ioat.rst | 7 +++++++ drivers/meson.build | 2 +- drivers/raw/ioat/meson.build | 23 ++++++++++++++++++++--- 3 files changed, 28 insertions(+), 4 deletions(-)
doc/guides/rawdevs/ioat.rst +7 -0
@@ -34,6 +34,13 @@ Compilation For builds using ``meson`` and ``ninja``, the driver will be built when the target platform is x86-based. No additional compilation steps are necessary. +.. note:: + Since the addition of the DMAdev library, the ``ioat`` and ``idxd`` parts of this driver + will only be built if their ``DMAdev`` counterparts are not built. The following can be used + to disable the ``DMAdev`` drivers, if the raw drivers are to be used instead:: + + $ meson -Ddisable_drivers=dma/* <build_dir> + Device Setup -------------
drivers/meson.build +1 -1
@@ -10,6 +10,7 @@ subdirs = [ 'common/qat', # depends on bus. 'common/sfc_efx', # depends on bus. 'mempool', # depends on common and bus. + 'dma', # depends on common and bus. 'net', # depends on common, bus, mempool 'raw', # depends on common, bus and net. 'crypto', # depends on common, bus and mempool (net in future).
@@ -18,7 +19,6 @@ subdirs = [ 'vdpa', # depends on common, bus and mempool. 'event', # depends on common, bus, mempool and net. 'baseband', # depends on common and bus. - 'dma', # depends on common and bus. ] if meson.is_cross_build()
drivers/raw/ioat/meson.build +20 -3
@@ -2,14 +2,31 @@ # Copyright 2019 Intel Corporation build = dpdk_conf.has('RTE_ARCH_X86') +# only use ioat rawdev driver if we don't have the equivalent dmadev ones +if dpdk_conf.has('RTE_DMA_IDXD') and dpdk_conf.has('RTE_DMA_IOAT') + build = false + subdir_done() +endif + reason = 'only supported on x86' sources = files( - 'idxd_bus.c', - 'idxd_pci.c', 'ioat_common.c', - 'ioat_rawdev.c', 'ioat_rawdev_test.c', ) + +if not dpdk_conf.has('RTE_DMA_IDXD') + sources += files( + 'idxd_bus.c', + 'idxd_pci.c', + ) +endif + +if not dpdk_conf.has('RTE_DMA_IOAT') + sources += files ( + 'ioat_rawdev.c', + ) +endif + deps += ['bus_pci', 'mbuf', 'rawdev'] headers = files( 'rte_ioat_rawdev.h',
Signature · 1 line
2.30.2
Re: [dpdk-dev] [PATCH v5 01/16] raw/ioat: only build if dmadev not present
Quoted 6 lines · Kevin Laatz
From: Bruce Richardson <[email protected]>
Only build the rawdev IDXD/IOAT drivers if the dmadev drivers are not present.
A not is also added to the documentation to inform users of this change.
typo: "note"
It would also be worthwhile mentioning in the commit log that the order of dependencies is changed so that dmadev comes before rawdev.
Quoted 20 lines
Signed-off-by Bruce Richardson <[email protected]>Signed-off-by Kevin Laatz <[email protected]>Reviewed-by Conor Walsh <[email protected]>---
v4:
- Fix build issue
- Add note in raw documentation to outline this change--- doc/guides/rawdevs/ioat.rst | 7 +++++++ drivers/meson.build | 2 +- drivers/raw/ioat/meson.build | 23 ++++++++++++++++++++--- 3 files changed, 28 insertions(+), 4 deletions(-)doc/guides/rawdevs/ioat.rst +0
-0
doc/guides/rawdevs/ioat.rst Compilation · line 41
Quoted 8 lines
doc/guides/rawdevs/ioat.rst +5
-0@@ -34,6 +34,13 @@ Compilation For builds using ``meson`` and ``ninja``, the driver will be built when the target platform is x86-based. No additional compilation steps are necessary. +.. note:: + Since the addition of the DMAdev library, the ``ioat`` and ``idxd`` parts of this driver + will only be built if their ``DMAdev`` counterparts are not built. The following can be used + to disable the ``DMAdev`` drivers, if the raw drivers are to be used instead:: +
Suggest where possible to split lines on punctuation. Put a line break after the "." at the end of the first sentence. Similarly if breaking lines, try and do so after commas.
Quoted 18 lines
doc/guides/rawdevs/ioat.rst +2
-0+ $ meson -Ddisable_drivers=dma/* <build_dir> + Device Setup -------------drivers/meson.build +1
-0@@ -10,6 +10,7 @@ subdirs = [ 'common/qat', # depends on bus. 'common/sfc_efx', # depends on bus. 'mempool', # depends on common and bus. + 'dma', # depends on common and bus. 'net', # depends on common, bus, mempool 'raw', # depends on common, bus and net. 'crypto', # depends on common, bus and mempool (net in future).
drivers/meson.build subdirs = [ · line 23
Quoted 6 lines
drivers/meson.build +0
-1@@ -18,7 +19,6 @@ subdirs = [ 'vdpa', # depends on common, bus and mempool. 'event', # depends on common, bus, mempool and net. 'baseband', # depends on common and bus. - 'dma', # depends on common and bus. ]
As stated above, I think the reason for this change should be noted in the commit log.
Quoted 43 lines
drivers/meson.build +0
-0if meson.is_cross_build()drivers/raw/ioat/meson.build +20
-3@@ -2,14 +2,31 @@ # Copyright 2019 Intel Corporation build = dpdk_conf.has('RTE_ARCH_X86') +# only use ioat rawdev driver if we don't have the equivalent dmadev ones +if dpdk_conf.has('RTE_DMA_IDXD') and dpdk_conf.has('RTE_DMA_IOAT') + build = false + subdir_done() +endif + reason = 'only supported on x86' sources = files( - 'idxd_bus.c', - 'idxd_pci.c', 'ioat_common.c', - 'ioat_rawdev.c', 'ioat_rawdev_test.c', ) + +if not dpdk_conf.has('RTE_DMA_IDXD') + sources += files( + 'idxd_bus.c', + 'idxd_pci.c', + ) +endif + +if not dpdk_conf.has('RTE_DMA_IOAT') + sources += files ( + 'ioat_rawdev.c', + ) +endif + deps += ['bus_pci', 'mbuf', 'rawdev'] headers = files( 'rte_ioat_rawdev.h',Signature · 1 line
2.30.2
PATCH v5 2/16 dma/idxd: add skeleton for VFIO based DSA device
In reply to Kevin LaatzAdd the basic device probe/remove skeleton code for DSA device bound to the vfio pci driver. Relevant documentation and MAINTAINERS update also included.
---
v5: add missing toctree entry for idxd driver
--- MAINTAINERS | 10 +++++ doc/guides/dmadevs/idxd.rst | 58 ++++++++++++++++++++++++++ doc/guides/dmadevs/index.rst | 2 + doc/guides/rel_notes/release_21_11.rst | 5 +++ drivers/dma/idxd/idxd_internal.h | 27 ++++++++++++ drivers/dma/idxd/idxd_pci.c | 55 ++++++++++++++++++++++++ drivers/dma/idxd/meson.build | 11 +++++ drivers/dma/idxd/version.map | 3 ++ drivers/dma/meson.build | 2 + 9 files changed, 173 insertions(+) create mode 100644 doc/guides/dmadevs/idxd.rst create mode 100644 drivers/dma/idxd/idxd_internal.h create mode 100644 drivers/dma/idxd/idxd_pci.c create mode 100644 drivers/dma/idxd/meson.build create mode 100644 drivers/dma/idxd/version.map
MAINTAINERS +10 -0
@@ -1200,6 +1200,16 @@ F: doc/guides/compressdevs/zlib.rst F: doc/guides/compressdevs/features/zlib.ini +DMAdev Drivers +-------------- + +Intel IDXD - EXPERIMENTAL +M: Bruce Richardson <[email protected]> +M: Kevin Laatz <[email protected]> +F: drivers/dma/idxd/ +F: doc/guides/dmadevs/idxd.rst + + RegEx Drivers -------------
doc/guides/dmadevs/idxd.rst new file +58 -0
58 lines not on this page · raw message
doc/guides/dmadevs/index.rst +2 -0
@@ -10,3 +10,5 @@ an application through DMA API. .. toctree:: :maxdepth: 2 :numbered: + + idxd
doc/guides/rel_notes/release_21_11.rst +5 -0
@@ -92,6 +92,11 @@ New Features * Device allocation and it's multi-process support. * Control and data plane functions. +* **Added IDXD dmadev driver implementation.** + + The IDXD dmadev driver provide device drivers for the Intel DSA devices. + This device driver can be used through the generic dmadev API. + Removed Items -------------
drivers/dma/idxd/idxd_internal.h new file +27 -0
@@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright 2021 Intel Corporation +*/ + +#ifndef _IDXD_INTERNAL_H_ +#define _IDXD_INTERNAL_H_ + +/** +* @file idxd_internal.h +* +* Internal data structures for the idxd/DSA driver for dmadev +* +* @warning +* @b EXPERIMENTAL: these structures and APIs may change without prior notice +*/ + +extern int idxd_pmd_logtype; + +#define IDXD_PMD_LOG(level, fmt, args...) rte_log(RTE_LOG_ ## level, \ + idxd_pmd_logtype, "IDXD: %s(): " fmt "\n", __func__, ##args) + +#define IDXD_PMD_DEBUG(fmt, args...) IDXD_PMD_LOG(DEBUG, fmt, ## args) +#define IDXD_PMD_INFO(fmt, args...) IDXD_PMD_LOG(INFO, fmt, ## args) +#define IDXD_PMD_ERR(fmt, args...) IDXD_PMD_LOG(ERR, fmt, ## args) +#define IDXD_PMD_WARN(fmt, args...) IDXD_PMD_LOG(WARNING, fmt, ## args) + +#endif /* _IDXD_INTERNAL_H_ */
drivers/dma/idxd/idxd_pci.c new file +55 -0
55 lines not on this page · raw message
drivers/dma/idxd/meson.build new file +11 -0
@@ -0,0 +1,11 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2021 Intel Corporation + +if is_windows + subdir_done() +endif + +deps += ['bus_pci'] +sources = files( + 'idxd_pci.c' +)
drivers/dma/idxd/version.map new file +3 -0
@@ -0,0 +1,3 @@ +DPDK_21 { + local: *; +};
drivers/dma/meson.build +2 -0
@@ -2,5 +2,7 @@ # Copyright 2021 HiSilicon Limited drivers = [ + 'idxd', 'skeleton', ] +std_deps = ['dmadev']
Signature · 1 line
2.30.2
Re: [dpdk-dev] [PATCH v5 02/16] dma/idxd: add skeleton for VFIO based DSA device
Quoted 8 lines · Kevin Laatz
Add the basic device probe/remove skeleton code for DSA device bound to the vfio pci driver. Relevant documentation and
MAINTAINERSupdate also included.Signed-off-by Bruce Richardson <[email protected]>Signed-off-by Kevin Laatz <[email protected]>Reviewed-by Conor Walsh <[email protected]>
<snip>
Quoted 5 lines
drivers/dma/idxd/meson.build new file +2
-0@@ -0,0 +1,11 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2021 Intel Corporation
drivers/dma/idxd/meson.build line 11
Quoted 10 lines
drivers/dma/idxd/meson.build new file +9
-0+ +if is_windows + subdir_done() +endif + +deps += ['bus_pci'] +sources = files( + 'idxd_pci.c' +)
If doing a v6, this should be fixed to have a newline at end.
/Bruce
PATCH v5 3/16 dma/idxd: add bus device probing
In reply to Kevin LaatzAdd the basic device probing for DSA devices bound to the IDXD kernel driver. These devices can be configured via sysfs and made available to DPDK if they are found during bus scan. Relevant documentation is included.
---
v4: fix 'vdev' naming, changed to 'bus'
--- doc/guides/dmadevs/idxd.rst | 64 +++++++ drivers/dma/idxd/idxd_bus.c | 351 +++++++++++++++++++++++++++++++++++ drivers/dma/idxd/meson.build | 1 + 3 files changed, 416 insertions(+) create mode 100644 drivers/dma/idxd/idxd_bus.c
doc/guides/dmadevs/idxd.rst +64 -0
@@ -32,6 +32,56 @@ target platform is x86-based. No additional compilation steps are necessary. Device Setup ------------- +Intel\ |reg| DSA devices can use the IDXD kernel driver or DPDK-supported drivers, +such as ``vfio-pci``. Both are supported by the IDXD PMD. + +Intel\ |reg| DSA devices using IDXD kernel driver +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +To use an Intel\ |reg| DSA device bound to the IDXD kernel driver, the device must first be configured. +The `accel-config <https://github.com/intel/idxd-config>`_ utility library can be used for configuration. + +.. note:: + The device configuration can also be done by directly interacting with the sysfs nodes. + An example of how this may be done can be seen in the script ``dpdk_idxd_cfg.py`` + included in the driver source directory. + +There are some mandatory configuration steps before being able to use a device with an application. +The internal engines, which do the copies or other operations, +and the work-queues, which are used by applications to assign work to the device, +need to be assigned to groups, and the various other configuration options, +such as priority or queue depth, need to be set for each queue. + +To assign an engine to a group:: + + $ accel-config config-engine dsa0/engine0.0 --group-id=0 + $ accel-config config-engine dsa0/engine0.1 --group-id=1 + +To assign work queues to groups for passing descriptors to the engines a similar accel-config command can be used. +However, the work queues also need to be configured depending on the use case. +Some configuration options include: + +* mode (Dedicated/Shared): Indicates whether a WQ may accept jobs from multiple queues simultaneously. +* priority: WQ priority between 1 and 15. Larger value means higher priority. +* wq-size: the size of the WQ. Sum of all WQ sizes must be less that the total-size defined by the device. +* type: WQ type (kernel/mdev/user). Determines how the device is presented. +* name: identifier given to the WQ. + +Example configuration for a work queue:: + + $ accel-config config-wq dsa0/wq0.0 --group-id=0 \ + --mode=dedicated --priority=10 --wq-size=8 \ + --type=user --name=dpdk_app1 + +Once the devices have been configured, they need to be enabled:: + + $ accel-config enable-device dsa0 + $ accel-config enable-wq dsa0/wq0.0 + +Check the device configuration:: + + $ accel-config list + Devices using VFIO/UIO drivers ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -56,3 +106,17 @@ If fewer workqueues are required, then the ``max_queues`` parameter may be passe the device driver on the EAL commandline, via the ``allowlist`` or ``-a`` flag e.g.:: $ dpdk-test -a <b:d:f>,max_queues=4 + +For devices bound to the IDXD kernel driver, +the DPDK IDXD driver will automatically perform a scan for available workqueues +to use. Any workqueues found listed in ``/dev/dsa`` on the system will be checked +in ``/sys``, and any which have ``dpdk_`` prefix in their name will be automatically +probed by the driver to make them available to the application. +Alternatively, to support use by multiple DPDK processes simultaneously, +the value used as the DPDK ``--file-prefix`` parameter may be used as a workqueue +name prefix, instead of ``dpdk_``, allowing each DPDK application instance to only +use a subset of configured queues. + +Once probed successfully, irrespective of kernel driver, the device will appear as a ``dmadev``, +that is a "DMA device type" inside DPDK, and can be accessed using APIs from the +``rte_dmadev`` library.
drivers/dma/idxd/idxd_bus.c new file +351 -0
351 lines not on this page · raw message
drivers/dma/idxd/meson.build +1 -0
@@ -7,5 +7,6 @@ endif deps += ['bus_pci'] sources = files( + 'idxd_bus.c', 'idxd_pci.c' )
Signature · 1 line
2.30.2
PATCH v5 4/16 dma/idxd: create dmadev instances on bus probe
In reply to Kevin LaatzWhen a suitable device is found during the bus scan/probe, create a dmadev instance for each HW queue. Internal structures required for device creation are also added.
---
v4:
- fix 'vdev' naming, changed to 'bus'
- rebase changes
--- drivers/dma/idxd/idxd_bus.c | 19 ++++++++ drivers/dma/idxd/idxd_common.c | 76 ++++++++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 40 +++++++++++++++++ drivers/dma/idxd/meson.build | 1 + 4 files changed, 136 insertions(+) create mode 100644 drivers/dma/idxd/idxd_common.c
drivers/dma/idxd/idxd_bus.c +19 -0
@@ -85,6 +85,18 @@ dsa_get_sysfs_path(void)return path ? path :DSA_SYSFS_PATH ; } +static int +idxd_dev_close (struct rte_dma_dev *dev) +{ +struct idxd_dmadev *idxd = dev->data->dev_private; +munmap (idxd->portal,0x1000 ); +return 0 ; +} + +static const struct rte_dma_dev_ops idxd_bus_ops = { + .dev_close = idxd_dev_close, +}; +static void *idxd_bus_mmap_wq (struct rte_dsa_device *dev) {
@@ -206,6 +218,7 @@ idxd_probe_dsa(struct rte_dsa_device *dev)return -1 ; idxd.max_batch_size = ret; idxd.qid = dev->addr.wq_id; + idxd.u.bus.dsa_id = dev->addr.device_id; idxd.sva_support =1 ; idxd.portal =idxd_bus_mmap_wq (dev);
@@ -214,6 +227,12 @@ idxd_probe_dsa(struct rte_dsa_device *dev)return -ENOENT ; } + ret =idxd_dmadev_create (dev->wq_name, &dev->device, &idxd, &idxd_bus_ops); +if (ret) { +IDXD_PMD_ERR ("Failed to create rawdev %s" , dev->wq_name); +return ret; + } +return 0 ; }
drivers/dma/idxd/idxd_common.c new file +76 -0
76 lines not on this page · raw message
drivers/dma/idxd/idxd_internal.h +40 -0
@@ -24,4 +24,44 @@ extern int idxd_pmd_logtype; #define IDXD_PMD_ERR(fmt, args...) IDXD_PMD_LOG(ERR, fmt, ## args) #define IDXD_PMD_WARN(fmt, args...) IDXD_PMD_LOG(WARNING, fmt, ## args) +struct idxd_dmadev { +/* counters to track the batches */ +unsigned short max_batches; +unsigned short batch_idx_read; +unsigned short batch_idx_write; + +/* track descriptors and handles */ +unsigned short desc_ring_mask; +unsigned short ids_avail;/* handles for ops completed */ +unsigned short ids_returned;/* the read pointer for hdls/desc rings */ +unsigned short batch_start;/* start+size == write pointer for hdls/desc */ +unsigned short batch_size; + +void *portal;/* address to write the batch descriptor */ + +struct idxd_completion *batch_comp_ring; +unsigned short *batch_idx_ring;/* store where each batch ends */ + +struct rte_dma_stats stats; + +rte_iova_t batch_iova;/* base address of the batch comp ring */ +rte_iova_t desc_iova;/* base address of desc ring, needed for completions */ + +unsigned short max_batch_size; + +struct rte_dma_dev *dmadev; +struct rte_dma_vchan_conf qcfg; +uint8_t sva_support; +uint8_t qid; + +union { +struct { +unsigned int dsa_id; + } bus; + } u; +}; + +int idxd_dmadev_create (const char *name,struct rte_device *dev, +const struct idxd_dmadev *base_idxd,const struct rte_dma_dev_ops *ops); +#endif /* _IDXD_INTERNAL_H_ */
drivers/dma/idxd/meson.build +1 -0
@@ -8,5 +8,6 @@ endif deps += ['bus_pci'] sources = files( 'idxd_bus.c', + 'idxd_common.c', 'idxd_pci.c' )
Signature · 1 line
2.30.2
Re: [dpdk-dev] [PATCH v5 04/16] dma/idxd: create dmadev instances on bus probe
Quoted 106 lines · Kevin Laatz
When a suitable device is found during the bus scan/probe, create a dmadev instance for each HW queue. Internal structures required for device creation are also added.
Signed-off-by Bruce Richardson <[email protected]>Signed-off-by Kevin Laatz <[email protected]>Reviewed-by Conor Walsh <[email protected]>---
v4:
- fix 'vdev' naming, changed to 'bus'
- rebase changes--- drivers/dma/idxd/idxd_bus.c | 19 ++++++++ drivers/dma/idxd/idxd_common.c | 76 ++++++++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 40 +++++++++++++++++ drivers/dma/idxd/meson.build | 1 + 4 files changed, 136 insertions(+) create mode 100644 drivers/dma/idxd/idxd_common.cdrivers/dma/idxd/idxd_bus.c +19
-0@@ -85,6 +85,18 @@ dsa_get_sysfs_path(void)return path ? path :DSA_SYSFS_PATH ; } +static int +idxd_dev_close (struct rte_dma_dev *dev) +{ +struct idxd_dmadev *idxd = dev->data->dev_private; +munmap (idxd->portal,0x1000 ); +return 0 ; +} + +static const struct rte_dma_dev_ops idxd_bus_ops = { + .dev_close = idxd_dev_close, +}; +static void *idxd_bus_mmap_wq (struct rte_dsa_device *dev) {@@ -206,6 +218,7 @@ idxd_probe_dsa(struct rte_dsa_device *dev)return -1 ; idxd.max_batch_size = ret; idxd.qid = dev->addr.wq_id; + idxd.u.bus.dsa_id = dev->addr.device_id; idxd.sva_support =1 ; idxd.portal =idxd_bus_mmap_wq (dev);@@ -214,6 +227,12 @@ idxd_probe_dsa(struct rte_dsa_device *dev)return -ENOENT ; } + ret =idxd_dmadev_create (dev->wq_name, &dev->device, &idxd, &idxd_bus_ops); +if (ret) { +IDXD_PMD_ERR ("Failed to create rawdev %s" , dev->wq_name); +return ret; + } +return 0 ; }drivers/dma/idxd/idxd_common.c new file +36
-0@@ -0,0 +1,76 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright 2021 Intel Corporation +*/ + +#include <rte_dmadev_pmd.h> +#include <rte_malloc.h> +#include <rte_common.h> + +#include "idxd_internal.h" + +#define IDXD_PMD_NAME_STR "dmadev_idxd" + +int +idxd_dmadev_create (const char *name,struct rte_device *dev, +const struct idxd_dmadev *base_idxd, +const struct rte_dma_dev_ops *ops) +{ +struct idxd_dmadev *idxd; +struct rte_dma_dev *dmadev =NULL ; +int ret =0 ; + +if (!name) { +IDXD_PMD_ERR ("Invalid name of the device!" ); + ret = -EINVAL ; + goto cleanup; + } + +/* Allocate device structure */ + dmadev =rte_dma_pmd_allocate (name, dev->numa_node, +sizeof (dmadev->dev_private)); +if (dmadev ==NULL ) { +IDXD_PMD_ERR ("Unable to allocate raw device" ); + ret = -ENOMEM ; + goto cleanup; + } + dmadev->dev_ops = ops;
drivers/dma/idxd/idxd_common.c line 46
Quoted 10 lines
drivers/dma/idxd/idxd_common.c new file +10
-0+ dmadev->device = dev; + + idxd =rte_malloc_socket (NULL ,sizeof (struct idxd_dmadev ),0 , dev->numa_node); +if (idxd ==NULL ) { +IDXD_PMD_ERR ("Unable to allocate memory for device" ); + ret = -ENOMEM ; + goto cleanup; + } + dmadev->data->dev_private = idxd; + dmadev->dev_private = idxd;
The dmadev->dev_private and dmadev->data->dev_private already inited by rte_dma_pmd_allocate, and the driver only needs to pass in the correct parameters.
Recommended:
dmadev = rte_dma_pmd_allocate(name, dev->name, sizeof(struct idxd_dmadev));
Quoted 8 lines
drivers/dma/idxd/idxd_common.c new file +8
-0+ *idxd = *base_idxd;/* copy over the main fields already passed in */ + idxd->dmadev = dmadev; + +/* allocate batch index ring and completion ring. +* The +1 is because we can never fully use +* the ring, otherwise read == write means both full and empty. +*/ + idxd->batch_comp_ring = rte_zmalloc(NULL, (sizeof(idxd->batch_idx_ring[0]) +
drivers/dma/idxd/idxd_common.c line 64
Quoted 10 lines
drivers/dma/idxd/idxd_common.c new file +10
-0+ sizeof(idxd->batch_comp_ring[0])) * (idxd->max_batches + 1), + sizeof(idxd->batch_comp_ring[0])); +if (idxd->batch_comp_ring ==NULL ) { +IDXD_PMD_ERR ("Unable to reserve memory for batch data\n" ); + ret = -ENOMEM ; + goto cleanup; + } + idxd->batch_idx_ring = (void *)&idxd->batch_comp_ring[idxd->max_batches+1 ]; + idxd->batch_iova =rte_mem_virt2iova (idxd->batch_comp_ring); +
Once init one dmadev successful, driver need changes it's state to READY, like:
dmadev->state = RTE_DMA_DEV_READY;
This was useful when call rte_dma_pmd_release: if the state is ready, lib will call rte_dma_close() to release the dmadev, else it only clean the struct which lib holds.
Quoted 74 lines
drivers/dma/idxd/idxd_common.c new file +12
-0+return 0 ; + +cleanup: +if (dmadev) +rte_dma_pmd_release (name); + +return ret; +} + +int idxd_pmd_logtype; + +RTE_LOG_REGISTER_DEFAULT (idxd_pmd_logtype,WARNING );drivers/dma/idxd/idxd_internal.h +40
-0@@ -24,4 +24,44 @@ extern int idxd_pmd_logtype; #define IDXD_PMD_ERR(fmt, args...) IDXD_PMD_LOG(ERR, fmt, ## args) #define IDXD_PMD_WARN(fmt, args...) IDXD_PMD_LOG(WARNING, fmt, ## args) +struct idxd_dmadev { +/* counters to track the batches */ +unsigned short max_batches; +unsigned short batch_idx_read; +unsigned short batch_idx_write; + +/* track descriptors and handles */ +unsigned short desc_ring_mask; +unsigned short ids_avail;/* handles for ops completed */ +unsigned short ids_returned;/* the read pointer for hdls/desc rings */ +unsigned short batch_start;/* start+size == write pointer for hdls/desc */ +unsigned short batch_size; + +void *portal;/* address to write the batch descriptor */ + +struct idxd_completion *batch_comp_ring; +unsigned short *batch_idx_ring;/* store where each batch ends */ + +struct rte_dma_stats stats; + +rte_iova_t batch_iova;/* base address of the batch comp ring */ +rte_iova_t desc_iova;/* base address of desc ring, needed for completions */ + +unsigned short max_batch_size; + +struct rte_dma_dev *dmadev; +struct rte_dma_vchan_conf qcfg; +uint8_t sva_support; +uint8_t qid; + +union { +struct { +unsigned int dsa_id; + } bus; + } u; +}; + +int idxd_dmadev_create (const char *name,struct rte_device *dev, +const struct idxd_dmadev *base_idxd,const struct rte_dma_dev_ops *ops); +#endif /* _IDXD_INTERNAL_H_ */ drivers/dma/idxd/meson.build +1
-0@@ -8,5 +8,6 @@ endif deps += ['bus_pci'] sources = files( 'idxd_bus.c', + 'idxd_common.c', 'idxd_pci.c' )
Re: [dpdk-dev] [PATCH v5 04/16] dma/idxd: create dmadev instances on bus probe
Quoted 143 lines · fengchengwen
Quoted 106 lines · Kevin Laatz
When a suitable device is found during the bus scan/probe, create a dmadev instance for each HW queue. Internal structures required for device creation are also added.
Signed-off-by Bruce Richardson <[email protected]>Signed-off-by Kevin Laatz <[email protected]>Reviewed-by Conor Walsh <[email protected]>---
v4:
- fix 'vdev' naming, changed to 'bus'
- rebase changes--- drivers/dma/idxd/idxd_bus.c | 19 ++++++++ drivers/dma/idxd/idxd_common.c | 76 ++++++++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 40 +++++++++++++++++ drivers/dma/idxd/meson.build | 1 + 4 files changed, 136 insertions(+)create mode 100644
drivers/dma/idxd/idxd_common.cdrivers/dma/idxd/idxd_bus.c +19
-0@@ -85,6 +85,18 @@ dsa_get_sysfs_path(void)return path ? path :DSA_SYSFS_PATH ; } +static int +idxd_dev_close (struct rte_dma_dev *dev) +{ +struct idxd_dmadev *idxd = dev->data->dev_private; +munmap (idxd->portal,0x1000 ); +return 0 ; +} + +static const struct rte_dma_dev_ops idxd_bus_ops = { + .dev_close = idxd_dev_close, +}; +static void *idxd_bus_mmap_wq (struct rte_dsa_device *dev) {@@ -206,6 +218,7 @@ idxd_probe_dsa(struct rte_dsa_device *dev)return -1 ; idxd.max_batch_size = ret; idxd.qid = dev->addr.wq_id; + idxd.u.bus.dsa_id = dev->addr.device_id; idxd.sva_support =1 ; idxd.portal =idxd_bus_mmap_wq (dev);@@ -214,6 +227,12 @@ idxd_probe_dsa(struct rte_dsa_device *dev)return -ENOENT ; } + ret =idxd_dmadev_create (dev->wq_name, &dev->device, &idxd, &idxd_bus_ops); +if (ret) { +IDXD_PMD_ERR ("Failed to create rawdev %s" , dev->wq_name); +return ret; + } +return 0 ; }drivers/dma/idxd/idxd_common.c new file +36
-0@@ -0,0 +1,76 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright 2021 Intel Corporation +*/ + +#include <rte_dmadev_pmd.h> +#include <rte_malloc.h> +#include <rte_common.h> + +#include "idxd_internal.h" + +#define IDXD_PMD_NAME_STR "dmadev_idxd" + +int +idxd_dmadev_create (const char *name,struct rte_device *dev, +const struct idxd_dmadev *base_idxd, +const struct rte_dma_dev_ops *ops) +{ +struct idxd_dmadev *idxd; +struct rte_dma_dev *dmadev =NULL ; +int ret =0 ; + +if (!name) { +IDXD_PMD_ERR ("Invalid name of the device!" ); + ret = -EINVAL ; + goto cleanup; + } + +/* Allocate device structure */ + dmadev =rte_dma_pmd_allocate (name, dev->numa_node, +sizeof (dmadev->dev_private)); +if (dmadev ==NULL ) { +IDXD_PMD_ERR ("Unable to allocate raw device" ); + ret = -ENOMEM ; + goto cleanup; + } + dmadev->dev_ops = ops;drivers/dma/idxd/idxd_common.c line 46
Quoted 10 lines
drivers/dma/idxd/idxd_common.c new file +10
-0+ dmadev->device = dev; + + idxd =rte_malloc_socket (NULL ,sizeof (struct idxd_dmadev ),0 , dev->numa_node); +if (idxd ==NULL ) { +IDXD_PMD_ERR ("Unable to allocate memory for device" ); + ret = -ENOMEM ; + goto cleanup; + } + dmadev->data->dev_private = idxd; + dmadev->dev_private = idxd;The
dmadev->dev_privateanddmadev->data->dev_privatealready inited byrte_dma_pmd_allocate, and the driver only needs to pass in the correct parameters.Recommended:
dmadev = rte_dma_pmd_allocate(name, dev->name, sizeof(struct idxd_dmadev));Quoted 8 lines
drivers/dma/idxd/idxd_common.c new file +8
-0+ *idxd = *base_idxd;/* copy over the main fields already passed in */ + idxd->dmadev = dmadev; + +/* allocate batch index ring and completion ring. +* The +1 is because we can never fully use +* the ring, otherwise read == write means both full and empty. +*/ + idxd->batch_comp_ring = rte_zmalloc(NULL, (sizeof(idxd->batch_idx_ring[0]) +drivers/dma/idxd/idxd_common.c line 64
Quoted 10 lines
drivers/dma/idxd/idxd_common.c new file +10
-0+ sizeof(idxd->batch_comp_ring[0])) * (idxd->max_batches + 1), + sizeof(idxd->batch_comp_ring[0])); +if (idxd->batch_comp_ring ==NULL ) { +IDXD_PMD_ERR ("Unable to reserve memory for batch data\n" ); + ret = -ENOMEM ; + goto cleanup; + } + idxd->batch_idx_ring = (void *)&idxd->batch_comp_ring[idxd->max_batches+1 ]; + idxd->batch_iova =rte_mem_virt2iova (idxd->batch_comp_ring); +Once init one dmadev successful, driver need changes it's state to READY, like:
Quoted 3 lines
dmadev->state = RTE_DMA_DEV_READY;This was useful when call
rte_dma_pmd_release: if the state is ready, lib will callrte_dma_close()to release the dmadev, else it only clean the struct which lib holds.
Will make these changes in v6, thanks!
PATCH v5 5/16 dma/idxd: create dmadev instances on pci probe
In reply to Kevin LaatzWhen a suitable device is found during the PCI probe, create a dmadev instance for each HW queue. HW definitions required are also included.
---
v4: rebase changes
--- drivers/dma/idxd/idxd_hw_defs.h | 71 ++++++++ drivers/dma/idxd/idxd_internal.h | 16 ++ drivers/dma/idxd/idxd_pci.c | 278 ++++++++++++++++++++++++++++++- 3 files changed, 362 insertions(+), 3 deletions(-) create mode 100644 drivers/dma/idxd/idxd_hw_defs.h
drivers/dma/idxd/idxd_hw_defs.h new file +71 -0
@@ -0,0 +1,71 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright 2021 Intel Corporation +*/ + +#ifndef _IDXD_HW_DEFS_H_ +#define _IDXD_HW_DEFS_H_ + +/*** Definitions for Intel(R) Data Streaming Accelerator ***/ + +#define IDXD_CMD_SHIFT 20 +enum rte_idxd_cmds { + idxd_enable_dev =1 , + idxd_disable_dev, + idxd_drain_all, + idxd_abort_all, + idxd_reset_device, + idxd_enable_wq, + idxd_disable_wq, + idxd_drain_wq, + idxd_abort_wq, + idxd_reset_wq, +}; + +/* General bar0 registers */ +struct rte_idxd_bar0 { + uint32_t __rte_cache_aligned version; /* offset 0x00 */ + uint64_t __rte_aligned(0x10) gencap; /* offset 0x10 */ + uint64_t __rte_aligned(0x10) wqcap; /* offset 0x20 */ + uint64_t __rte_aligned(0x10) grpcap; /* offset 0x30 */ + uint64_t __rte_aligned(0x08) engcap; /* offset 0x38 */ + uint64_t __rte_aligned(0x10) opcap; /* offset 0x40 */ + uint64_t __rte_aligned(0x20) offsets[2]; /* offset 0x60 */ + uint32_t __rte_aligned(0x20) gencfg; /* offset 0x80 */ + uint32_t __rte_aligned(0x08) genctrl; /* offset 0x88 */ + uint32_t __rte_aligned(0x10) gensts; /* offset 0x90 */ + uint32_t __rte_aligned(0x08) intcause; /* offset 0x98 */ + uint32_t __rte_aligned(0x10) cmd; /* offset 0xA0 */ + uint32_t __rte_aligned(0x08) cmdstatus; /* offset 0xA8 */ + uint64_t __rte_aligned(0x20) swerror[4]; /* offset 0xC0 */ +}; + +/* workqueue config is provided by array of uint32_t. */ +enum rte_idxd_wqcfg { + wq_size_idx,/* size is in first 32-bit value */ + wq_threshold_idx,/* WQ threshold second 32-bits */ + wq_mode_idx,/* WQ mode and other flags */ + wq_sizes_idx,/* WQ transfer and batch sizes */ + wq_occ_int_idx,/* WQ occupancy interrupt handle */ + wq_occ_limit_idx,/* WQ occupancy limit */ + wq_state_idx,/* WQ state and occupancy state */ +}; + +#define WQ_MODE_SHARED 0 +#define WQ_MODE_DEDICATED 1 +#define WQ_PRIORITY_SHIFT 4 +#define WQ_BATCH_SZ_SHIFT 5 +#define WQ_STATE_SHIFT 30 +#define WQ_STATE_MASK 0x3 + +struct rte_idxd_grpcfg { + uint64_t grpwqcfg[4] __rte_cache_aligned; /* 64-byte register set */ +uint64_t grpengcfg;/* offset 32 */ +uint32_t grpflags;/* offset 40 */ +}; + +#define GENSTS_DEV_STATE_MASK 0x03 +#define CMDSTATUS_ACTIVE_SHIFT 31 +#define CMDSTATUS_ACTIVE_MASK (1 << 31) +#define CMDSTATUS_ERR_MASK 0xFF + +#endif
drivers/dma/idxd/idxd_internal.h +16 -0
@@ -5,6 +5,10 @@#ifndef _IDXD_INTERNAL_H_#define _IDXD_INTERNAL_H_ +#include <rte_spinlock.h> + +#include "idxd_hw_defs.h" +/** * @file idxd_internal.h *
@@ -24,6 +28,16 @@ extern int idxd_pmd_logtype; #define IDXD_PMD_ERR(fmt, args...) IDXD_PMD_LOG(ERR, fmt, ## args) #define IDXD_PMD_WARN(fmt, args...) IDXD_PMD_LOG(WARNING, fmt, ## args) +struct idxd_pci_common { +rte_spinlock_t lk; + +uint8_t wq_cfg_sz; +volatile struct rte_idxd_bar0 *regs; +volatile uint32_t *wq_regs_base; +volatile struct rte_idxd_grpcfg *grp_regs; +volatile void *portals; +}; +struct idxd_dmadev {/* counters to track the batches */ unsigned short max_batches;
@@ -58,6 +72,8 @@ struct idxd_dmadev {struct {unsigned int dsa_id; } bus; + +struct idxd_pci_common *pci; } u; };
drivers/dma/idxd/idxd_pci.c +275 -3
305 lines not on this page · raw message
Signature · 1 line
2.30.2
Re: [dpdk-dev] [PATCH v5 05/16] dma/idxd: create dmadev instances on pci probe
Quoted 411 lines · Kevin Laatz
When a suitable device is found during the PCI probe, create a dmadev instance for each HW queue. HW definitions required are also included.
Signed-off-by Bruce Richardson <[email protected]>Signed-off-by Kevin Laatz <[email protected]>Reviewed-by Conor Walsh <[email protected]>---
v4: rebase changes--- drivers/dma/idxd/idxd_hw_defs.h | 71 ++++++++ drivers/dma/idxd/idxd_internal.h | 16 ++ drivers/dma/idxd/idxd_pci.c | 278 ++++++++++++++++++++++++++++++- 3 files changed, 362 insertions(+), 3 deletions(-) create mode 100644 drivers/dma/idxd/idxd_hw_defs.hdrivers/dma/idxd/idxd_hw_defs.h new file +71
-0@@ -0,0 +1,71 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright 2021 Intel Corporation +*/ + +#ifndef _IDXD_HW_DEFS_H_ +#define _IDXD_HW_DEFS_H_ + +/*** Definitions for Intel(R) Data Streaming Accelerator ***/ + +#define IDXD_CMD_SHIFT 20 +enum rte_idxd_cmds { + idxd_enable_dev =1 , + idxd_disable_dev, + idxd_drain_all, + idxd_abort_all, + idxd_reset_device, + idxd_enable_wq, + idxd_disable_wq, + idxd_drain_wq, + idxd_abort_wq, + idxd_reset_wq, +}; + +/* General bar0 registers */ +struct rte_idxd_bar0 { + uint32_t __rte_cache_aligned version; /* offset 0x00 */ + uint64_t __rte_aligned(0x10) gencap; /* offset 0x10 */ + uint64_t __rte_aligned(0x10) wqcap; /* offset 0x20 */ + uint64_t __rte_aligned(0x10) grpcap; /* offset 0x30 */ + uint64_t __rte_aligned(0x08) engcap; /* offset 0x38 */ + uint64_t __rte_aligned(0x10) opcap; /* offset 0x40 */ + uint64_t __rte_aligned(0x20) offsets[2]; /* offset 0x60 */ + uint32_t __rte_aligned(0x20) gencfg; /* offset 0x80 */ + uint32_t __rte_aligned(0x08) genctrl; /* offset 0x88 */ + uint32_t __rte_aligned(0x10) gensts; /* offset 0x90 */ + uint32_t __rte_aligned(0x08) intcause; /* offset 0x98 */ + uint32_t __rte_aligned(0x10) cmd; /* offset 0xA0 */ + uint32_t __rte_aligned(0x08) cmdstatus; /* offset 0xA8 */ + uint64_t __rte_aligned(0x20) swerror[4]; /* offset 0xC0 */ +}; + +/* workqueue config is provided by array of uint32_t. */ +enum rte_idxd_wqcfg { + wq_size_idx,/* size is in first 32-bit value */ + wq_threshold_idx,/* WQ threshold second 32-bits */ + wq_mode_idx,/* WQ mode and other flags */ + wq_sizes_idx,/* WQ transfer and batch sizes */ + wq_occ_int_idx,/* WQ occupancy interrupt handle */ + wq_occ_limit_idx,/* WQ occupancy limit */ + wq_state_idx,/* WQ state and occupancy state */ +}; + +#define WQ_MODE_SHARED 0 +#define WQ_MODE_DEDICATED 1 +#define WQ_PRIORITY_SHIFT 4 +#define WQ_BATCH_SZ_SHIFT 5 +#define WQ_STATE_SHIFT 30 +#define WQ_STATE_MASK 0x3 + +struct rte_idxd_grpcfg { + uint64_t grpwqcfg[4] __rte_cache_aligned; /* 64-byte register set */ +uint64_t grpengcfg;/* offset 32 */ +uint32_t grpflags;/* offset 40 */ +}; + +#define GENSTS_DEV_STATE_MASK 0x03 +#define CMDSTATUS_ACTIVE_SHIFT 31 +#define CMDSTATUS_ACTIVE_MASK (1 << 31) +#define CMDSTATUS_ERR_MASK 0xFF + +#endif drivers/dma/idxd/idxd_internal.h +16
-0@@ -5,6 +5,10 @@#ifndef _IDXD_INTERNAL_H_#define _IDXD_INTERNAL_H_ +#include <rte_spinlock.h> + +#include "idxd_hw_defs.h" +/** * @file idxd_internal.h * @@ -24,6 +28,16 @@ extern int idxd_pmd_logtype; #define IDXD_PMD_ERR(fmt, args...) IDXD_PMD_LOG(ERR, fmt, ## args) #define IDXD_PMD_WARN(fmt, args...) IDXD_PMD_LOG(WARNING, fmt, ## args) +struct idxd_pci_common { +rte_spinlock_t lk; + +uint8_t wq_cfg_sz; +volatile struct rte_idxd_bar0 *regs; +volatile uint32_t *wq_regs_base; +volatile struct rte_idxd_grpcfg *grp_regs; +volatile void *portals; +}; +struct idxd_dmadev {/* counters to track the batches */ unsigned short max_batches;@@ -58,6 +72,8 @@ struct idxd_dmadev {struct {unsigned int dsa_id; } bus; + +struct idxd_pci_common *pci; } u; };drivers/dma/idxd/idxd_pci.c +251
-2@@ -3,6 +3,9 @@*/ #include <rte_bus_pci.h> +#include <rte_devargs.h> +#include <rte_dmadev_pmd.h> +#include <rte_malloc.h> #include "idxd_internal.h" @@ -16,17 +19,286 @@ const struct rte_pci_id pci_id_idxd_map[] = { { .vendor_id = 0, /* sentinel */ }, }; +static inline int +idxd_pci_dev_command (struct idxd_dmadev *idxd,enum rte_idxd_cmds command) +{ +uint8_t err_code; +uint16_t qid = idxd->qid; +int i =0 ; + +if (command >= idxd_disable_wq && command <= idxd_reset_wq) + qid = (1 << qid); +rte_spinlock_lock (&idxd->u.pci->lk); + idxd->u.pci->regs->cmd = (command <<IDXD_CMD_SHIFT ) | qid; + +do { +rte_pause (); + err_code = idxd->u.pci->regs->cmdstatus; +if (++i >=1000 ) { +IDXD_PMD_ERR ("Timeout waiting for command response from HW" ); +rte_spinlock_unlock (&idxd->u.pci->lk); +return err_code; + } + }while (idxd->u.pci->regs->cmdstatus &CMDSTATUS_ACTIVE_MASK ); +rte_spinlock_unlock (&idxd->u.pci->lk); + +return err_code &CMDSTATUS_ERR_MASK ; +} + +static uint32_t * +idxd_get_wq_cfg (struct idxd_pci_common *pci,uint8_t wq_idx) +{ +return RTE_PTR_ADD (pci->wq_regs_base, + (uintptr_t )wq_idx << (5 + pci->wq_cfg_sz)); +} + +static int +idxd_is_wq_enabled (struct idxd_dmadev *idxd) +{ +uint32_t state =idxd_get_wq_cfg (idxd->u.pci, idxd->qid)[wq_state_idx]; +return ((state >>WQ_STATE_SHIFT ) &WQ_STATE_MASK ) ==0x1 ; +} + +static const struct rte_dma_dev_ops idxd_pci_ops = { + +}; + +/* each portal uses 4 x 4k pages */ +#define IDXD_PORTAL_SIZE (4096 * 4) + +static int +init_pci_device (struct rte_pci_device *dev,struct idxd_dmadev *idxd, +unsigned int max_queues) +{ +struct idxd_pci_common *pci; +uint8_t nb_groups, nb_engines, nb_wqs; +uint16_t grp_offset, wq_offset;/* how far into bar0 the regs are */ +uint16_t wq_size, total_wq_size; +uint8_t lg2_max_batch, lg2_max_copy_size; +unsigned int i, err_code; + + pci =malloc (sizeof (*pci)); +if (pci ==NULL ) { +IDXD_PMD_ERR ("%s: Can't allocate memory" , __func__); + goto err; + } +rte_spinlock_init (&pci->lk); + +/* assign the bar registers, and then configure device */ + pci->regs = dev->mem_resource[0 ].addr; + grp_offset = (uint16_t )pci->regs->offsets[0 ]; + pci->grp_regs =RTE_PTR_ADD (pci->regs, grp_offset *0x100 ); + wq_offset = (uint16_t )(pci->regs->offsets[0 ] >>16 ); + pci->wq_regs_base =RTE_PTR_ADD (pci->regs, wq_offset *0x100 ); + pci->portals = dev->mem_resource[2 ].addr; + pci->wq_cfg_sz = (pci->regs->wqcap >>24 ) &0x0F ; + +/* sanity check device status */ +if (pci->regs->gensts &GENSTS_DEV_STATE_MASK ) { +/* need function-level-reset (FLR) or is enabled */ +IDXD_PMD_ERR ("Device status is not disabled, cannot init" ); + goto err; + } +if (pci->regs->cmdstatus &CMDSTATUS_ACTIVE_MASK ) { +/* command in progress */ +IDXD_PMD_ERR ("Device has a command in progress, cannot init" ); + goto err; + } + +/* read basic info about the hardware for use when configuring */ + nb_groups = (uint8_t )pci->regs->grpcap; + nb_engines = (uint8_t )pci->regs->engcap; + nb_wqs = (uint8_t )(pci->regs->wqcap >>16 ); + total_wq_size = (uint16_t )pci->regs->wqcap; + lg2_max_copy_size = (uint8_t )(pci->regs->gencap >>16 ) &0x1F ; + lg2_max_batch = (uint8_t )(pci->regs->gencap >>21 ) &0x0F ; + +IDXD_PMD_DEBUG ("nb_groups = %u, nb_engines = %u, nb_wqs = %u" , + nb_groups, nb_engines, nb_wqs); + +/* zero out any old config */ +for (i =0 ; i < nb_groups; i++) { + pci->grp_regs[i].grpengcfg =0 ; + pci->grp_regs[i].grpwqcfg[0 ] =0 ; + } +for (i =0 ; i < nb_wqs; i++) +idxd_get_wq_cfg (pci, i)[0 ] =0 ; + +/* limit queues if necessary */ +if (max_queues !=0 && nb_wqs > max_queues) { + nb_wqs = max_queues; +if (nb_engines > max_queues) + nb_engines = max_queues; +if (nb_groups > max_queues) + nb_engines = max_queues; +IDXD_PMD_DEBUG ("Limiting queues to %u" , nb_wqs); + } + +/* put each engine into a separate group to avoid reordering */ +if (nb_groups > nb_engines) + nb_groups = nb_engines; +if (nb_groups < nb_engines) + nb_engines = nb_groups; + +/* assign engines to groups, round-robin style */ +for (i =0 ; i < nb_engines; i++) { +IDXD_PMD_DEBUG ("Assigning engine %u to group %u" , + i, i % nb_groups); + pci->grp_regs[i % nb_groups].grpengcfg |= (1ULL << i); + } + +/* now do the same for queues and give work slots to each queue */ + wq_size = total_wq_size / nb_wqs; +IDXD_PMD_DEBUG ("Work queue size = %u, max batch = 2^%u, max copy = 2^%u" , + wq_size, lg2_max_batch, lg2_max_copy_size); +for (i =0 ; i < nb_wqs; i++) { +/* add engine "i" to a group */ +IDXD_PMD_DEBUG ("Assigning work queue %u to group %u" , + i, i % nb_groups); + pci->grp_regs[i % nb_groups].grpwqcfg[0 ] |= (1ULL << i); +/* now configure it, in terms of size, max batch, mode */ +idxd_get_wq_cfg (pci, i)[wq_size_idx] = wq_size; +idxd_get_wq_cfg (pci, i)[wq_mode_idx] = (1 <<WQ_PRIORITY_SHIFT ) | +WQ_MODE_DEDICATED ; +idxd_get_wq_cfg (pci, i)[wq_sizes_idx] = lg2_max_copy_size | + (lg2_max_batch <<WQ_BATCH_SZ_SHIFT ); + } + +/* dump the group configuration to output */ +for (i =0 ; i < nb_groups; i++) { +IDXD_PMD_DEBUG ("## Group %d" , i); +IDXD_PMD_DEBUG (" GRPWQCFG: %" PRIx64, pci->grp_regs[i].grpwqcfg[0 ]); +IDXD_PMD_DEBUG (" GRPENGCFG: %" PRIx64, pci->grp_regs[i].grpengcfg); +IDXD_PMD_DEBUG (" GRPFLAGS: %" PRIx32, pci->grp_regs[i].grpflags); + } + + idxd->u.pci = pci; + idxd->max_batches = wq_size; + +/* enable the device itself */ + err_code =idxd_pci_dev_command (idxd, idxd_enable_dev); +if (err_code) { +IDXD_PMD_ERR ("Error enabling device: code %#x" , err_code); +return err_code; + } +IDXD_PMD_DEBUG ("IDXD Device enabled OK" ); + +return nb_wqs; + +err: +free (pci); +return -1 ; +} +static int idxd_dmadev_probe_pci (struct rte_pci_driver *drv,struct rte_pci_device *dev) { -int ret =0 ; +struct idxd_dmadev idxd = {0 }; +uint8_t nb_wqs; +int qid, ret =0 ;char name[PCI_PRI_STR_SIZE ]; +unsigned int max_queues =0 ;rte_pci_device_name (&dev->addr, name,sizeof (name));IDXD_PMD_INFO ("Init %s on NUMA node %d" , name, dev->device.numa_node); dev->device.driver = &drv->driver; -return ret; +if (dev->device.devargs && dev->device.devargs->args[0 ] !='\0' ) { +/* if the number of devargs grows beyond just 1, use rte_kvargs */ +if (sscanf (dev->device.devargs->args, +"max_queues=%u" , &max_queues) !=1 ) { +IDXD_PMD_ERR ("Invalid device parameter: '%s'" , + dev->device.devargs->args); +return -1 ; + } + } + + ret =init_pci_device (dev, &idxd, max_queues); +if (ret <0 ) { +IDXD_PMD_ERR ("Error initializing PCI hardware" ); +return ret; + } +if (idxd.u.pci->portals ==NULL ) { +IDXD_PMD_ERR ("Error, invalid portal assigned during initialization\n" ); +return -EINVAL ; + } + nb_wqs = (uint8_t )ret; + +/* set up one device for each queue */ +for (qid =0 ; qid < nb_wqs; qid++) { +char qname[32 ]; + +/* add the queue number to each device name */ +snprintf (qname,sizeof (qname),"%s-q%d" , name, qid); + idxd.qid = qid; + idxd.portal =RTE_PTR_ADD (idxd.u.pci->portals, + qid *IDXD_PORTAL_SIZE ); +if (idxd_is_wq_enabled (&idxd)) +IDXD_PMD_ERR ("Error, WQ %u seems enabled" , qid); + ret =idxd_dmadev_create (qname, &dev->device, + &idxd, &idxd_pci_ops); +if (ret !=0 ) { +IDXD_PMD_ERR ("Failed to create dmadev %s" , name); +if (qid ==0 )/* if no devices using this, free pci */ +free (idxd.u.pci); +return ret; + } + } + +return 0 ; +} + +static int +idxd_dmadev_destroy (const char *name) +{ +int ret; +uint8_t err_code; +struct rte_dma_dev *dmadev; +struct idxd_dmadev *idxd; +int dev_id =rte_dma_get_dev_id (name); + +if (!name) { +IDXD_PMD_ERR ("Invalid device name" ); +return -EINVAL ; + } + +if (dev_id <0 ) { +IDXD_PMD_ERR ("Invalid device ID" ); +return -EINVAL ; + } + + dmadev = &rte_dma_devices[dev_id]; +if (!dmadev) { +IDXD_PMD_ERR ("Invalid device name (%s)" , name); +return -EINVAL ; + } + + idxd = dmadev->dev_private; +if (!idxd) { +IDXD_PMD_ERR ("Error getting dev_private" );
drivers/dma/idxd/idxd_pci.c const struct rte_pci_id pci_id_idxd_map[] = { · line 288
Quoted 10 lines
drivers/dma/idxd/idxd_pci.c +10
-0+return -EINVAL ; + } + +/* disable the device */ + err_code =idxd_pci_dev_command (idxd, idxd_disable_dev); +if (err_code) { +IDXD_PMD_ERR ("Error disabling device: code %#x" , err_code); +return err_code; + } +IDXD_PMD_DEBUG ("IDXD Device disabled OK" );
Recommended: move the above disable idxd device to rte_dma_close() ops. when create: mark state as READY
when destroy: direct call rte_dma_pmd_release(name), the lib will call rte_dma_close().
drivers/dma/idxd/idxd_pci.c const struct rte_pci_id pci_id_idxd_map[] = { · line 292
Quoted 4 lines
drivers/dma/idxd/idxd_pci.c +4
-0+ +/* free device memory */ +IDXD_PMD_DEBUG ("Freeing device driver memory" ); + dmadev->dev_private =NULL ;
The dmalib managed dev_private, so that driver could not do free again.
drivers/dma/idxd/idxd_pci.c const struct rte_pci_id pci_id_idxd_map[] = { · line 294
Quoted 2 lines
drivers/dma/idxd/idxd_pci.c +2
-0+rte_free (idxd->batch_idx_ring); +rte_free (idxd->desc_ring);
Please move above free ops to rte_dma_close() ops.
Quoted 20 lines
drivers/dma/idxd/idxd_pci.c +8
-1+ +/* rte_dma_close is called by pmd_release */ + ret =rte_dma_pmd_release (name); +if (ret) +IDXD_PMD_DEBUG ("Device cleanup failed" ); + +return 0 ; } static int@@ -39,7 +311,7 @@ idxd_dmadev_remove_pci(struct rte_pci_device *dev)IDXD_PMD_INFO ("Closing %s on NUMA node %d" , name, dev->device.numa_node); -return 0 ; +return idxd_dmadev_destroy (name); }struct rte_pci_driver idxd_pmd_drv_pci = {
Re: [dpdk-dev] [PATCH v5 05/16] dma/idxd: create dmadev instances on pci probe
Quoted 17 lines · fengchengwen
Quoted 16 lines · Kevin Laatz
When a suitable device is found during the PCI probe, create a dmadev instance for each HW queue. HW definitions required are also included.
Signed-off-by Bruce Richardson <[email protected]>Signed-off-by Kevin Laatz <[email protected]>Reviewed-by Conor Walsh <[email protected]>---
v4: rebase changes--- drivers/dma/idxd/idxd_hw_defs.h | 71 ++++++++ drivers/dma/idxd/idxd_internal.h | 16 ++ drivers/dma/idxd/idxd_pci.c | 278 ++++++++++++++++++++++++++++++- 3 files changed, 362 insertions(+), 3 deletions(-)create mode 100644
drivers/dma/idxd/idxd_hw_defs.h
[snip]
Quoted 49 lines
Quoted 29 lines
drivers/dma/idxd/idxd_pci.c +29
-0+ +static int +idxd_dmadev_destroy (const char *name) +{ +int ret; +uint8_t err_code; +struct rte_dma_dev *dmadev; +struct idxd_dmadev *idxd; +int dev_id =rte_dma_get_dev_id (name); + +if (!name) { +IDXD_PMD_ERR ("Invalid device name" ); +return -EINVAL ; + } + +if (dev_id <0 ) { +IDXD_PMD_ERR ("Invalid device ID" ); +return -EINVAL ; + } + + dmadev = &rte_dma_devices[dev_id]; +if (!dmadev) { +IDXD_PMD_ERR ("Invalid device name (%s)" , name); +return -EINVAL ; + } + + idxd = dmadev->dev_private; +if (!idxd) { +IDXD_PMD_ERR ("Error getting dev_private" );drivers/dma/idxd/idxd_pci.c const struct rte_pci_id pci_id_idxd_map[] = { · line 288
Quoted 10 lines
drivers/dma/idxd/idxd_pci.c +10
-0+return -EINVAL ; + } + +/* disable the device */ + err_code =idxd_pci_dev_command (idxd, idxd_disable_dev); +if (err_code) { +IDXD_PMD_ERR ("Error disabling device: code %#x" , err_code); +return err_code; + } +IDXD_PMD_DEBUG ("IDXD Device disabled OK" );Recommended: move the above disable idxd device to
rte_dma_close()ops. when create: mark state as READY
when destroy: direct callrte_dma_pmd_release(name), the lib will callrte_dma_close().drivers/dma/idxd/idxd_pci.c const struct rte_pci_id pci_id_idxd_map[] = { · line 292
Quoted 4 lines
drivers/dma/idxd/idxd_pci.c +4
-0+ +/* free device memory */ +IDXD_PMD_DEBUG ("Freeing device driver memory" ); + dmadev->dev_private =NULL ;The dmalib managed
dev_private, so that driver could not do free again.
Quoted 4 lines
drivers/dma/idxd/idxd_pci.c const struct rte_pci_id pci_id_idxd_map[] = { · line 294
Quoted 2 lines
drivers/dma/idxd/idxd_pci.c +2
-0+rte_free (idxd->batch_idx_ring); +rte_free (idxd->desc_ring);Please move above free ops to
rte_dma_close()ops.
Will fix, thanks
PATCH v5 6/16 dma/idxd: add datapath structures
In reply to Kevin LaatzAdd data structures required for the data path for IDXD devices.
---
v2: add completion status for invalid opcode
--- drivers/dma/idxd/idxd_bus.c | 1 + drivers/dma/idxd/idxd_common.c | 33 ++++++++++++++++++ drivers/dma/idxd/idxd_hw_defs.h | 60 ++++++++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 3 ++ drivers/dma/idxd/idxd_pci.c | 2 +- 5 files changed, 98 insertions(+), 1 deletion(-)
drivers/dma/idxd/idxd_bus.c +1 -0
@@ -95,6 +95,7 @@ idxd_dev_close(struct rte_dma_dev *dev)static const struct rte_dma_dev_ops idxd_bus_ops = { .dev_close = idxd_dev_close, + .dev_dump = idxd_dump, }; static void *
drivers/dma/idxd/idxd_common.c +33 -0
@@ -10,6 +10,35 @@#define IDXD_PMD_NAME_STR "dmadev_idxd" +int +idxd_dump (const struct rte_dma_dev *dev,FILE *f) +{ +struct idxd_dmadev *idxd = dev->dev_private; +unsigned int i; + +fprintf (f,"== IDXD Private Data ==\n" ); +fprintf (f," Portal: %p\n" , idxd->portal); +fprintf (f," Config: { ring_size: %u }\n" , + idxd->qcfg.nb_desc); +fprintf (f," Batch ring (sz = %u, max_batches = %u):\n\t" , + idxd->max_batches +1 , idxd->max_batches); +for (i =0 ; i <= idxd->max_batches; i++) { +fprintf (f," %u " , idxd->batch_idx_ring[i]); +if (i == idxd->batch_idx_read && i == idxd->batch_idx_write) +fprintf (f,"[rd ptr, wr ptr] " ); +else if (i == idxd->batch_idx_read) +fprintf (f,"[rd ptr] " ); +else if (i == idxd->batch_idx_write) +fprintf (f,"[wr ptr] " ); +if (i == idxd->max_batches) +fprintf (f,"\n" ); + } + +fprintf (f," Curr batch: start = %u, size = %u\n" , idxd->batch_start, idxd->batch_size); +fprintf (f," IDS: avail = %u, returned: %u\n" , idxd->ids_avail, idxd->ids_returned); +return 0 ; +} + int idxd_dmadev_create(const char *name, struct rte_device *dev, const struct idxd_dmadev *base_idxd,
@@ -19,6 +48,10 @@ idxd_dmadev_create(const char *name, struct rte_device *dev,struct rte_dma_dev *dmadev =NULL ;int ret =0 ; +RTE_BUILD_BUG_ON (sizeof (struct idxd_hw_desc ) !=64 ); +RTE_BUILD_BUG_ON (offsetof(struct idxd_hw_desc , size) !=32 ); +RTE_BUILD_BUG_ON (sizeof (struct idxd_completion ) !=32 ); +if (!name) {IDXD_PMD_ERR ("Invalid name of the device!" ); ret = -EINVAL ;
drivers/dma/idxd/idxd_hw_defs.h +60 -0
66 lines not on this page · raw message
drivers/dma/idxd/idxd_internal.h +3 -0
@@ -39,6 +39,8 @@ struct idxd_pci_common { };struct idxd_dmadev { +struct idxd_hw_desc *desc_ring; +/* counters to track the batches */ unsigned short max_batches;unsigned short batch_idx_read;
@@ -79,5 +81,6 @@ struct idxd_dmadev {int idxd_dmadev_create (const char *name,struct rte_device *dev,const struct idxd_dmadev *base_idxd,const struct rte_dma_dev_ops *ops); +int idxd_dump (const struct rte_dma_dev *dev,FILE *f);#endif /* _IDXD_INTERNAL_H_ */
drivers/dma/idxd/idxd_pci.c +1 -1
@@ -60,7 +60,7 @@ idxd_is_wq_enabled(struct idxd_dmadev *idxd) }static const struct rte_dma_dev_ops idxd_pci_ops = { - + .dev_dump = idxd_dump, };/* each portal uses 4 x 4k pages */
Signature · 1 line
2.30.2
PATCH v5 7/16 dma/idxd: add configure and info_get functions
In reply to Kevin LaatzAdd functions for device configuration. The info_get function is included here since it can be useful for checking successful configuration.
---
v2:
- fix reconfigure bug in idxd_vchan_setup()
- add literal include comment for the docs to pick up
v3:
- fixes needed after changes from rebasing
--- app/test/test_dmadev.c | 2 + doc/guides/dmadevs/idxd.rst | 30 +++++++++++++ drivers/dma/idxd/idxd_bus.c | 3 ++ drivers/dma/idxd/idxd_common.c | 72 ++++++++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 6 +++ drivers/dma/idxd/idxd_pci.c | 3 ++ 6 files changed, 116 insertions(+)
app/test/test_dmadev.c +2 -0
@@ -739,6 +739,7 @@ test_dmadev_instance(uint16_t dev_id) {#define TEST_RINGSIZE 512#define CHECK_ERRS true +/* Setup of the dmadev device. 8< */ struct rte_dma_stats stats;struct rte_dma_info info;const struct rte_dma_conf conf = { .nb_vchans =1 };
@@ -759,6 +760,7 @@ test_dmadev_instance(uint16_t dev_id)if (rte_dma_vchan_setup (dev_id, vchan, &qconf) <0 )ERR_RETURN ("Error with queue configuration\n" ); +/* >8 End of setup of the dmadev device. */ rte_dma_info_get (dev_id, &info);if (info.nb_vchans !=1 )
doc/guides/dmadevs/idxd.rst +30 -0
@@ -120,3 +120,33 @@ use a subset of configured queues. Once probed successfully, irrespective of kernel driver, the device will appear as a ``dmadev``, that is a "DMA device type" inside DPDK, and can be accessed using APIs from the ``rte_dmadev`` library. + +Using IDXD DMAdev Devices +-------------------------- + +To use the devices from an application, the dmadev API can be used. + +Getting Device Information +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Basic information about each dmadev device can be queried using the +``rte_dma_info_get()`` API. This will return basic device information such as +the ``rte_device`` structure, device capabilities and other device specific values. + +Device Configuration +~~~~~~~~~~~~~~~~~~~~~ + +Configuring an IDXD dmadev device is done using the ``rte_dma_configure()`` and +``rte_dma_vchan_setup`` APIs. The configurations are passed to these APIs using +the ``rte_dma_conf`` and ``rte_dma_vchan_conf`` structures, respectively. For +example, these can be used to configure the number of ``vchans`` per device, the +ring size, etc. The ring size must be a power of two, between 64 and 4096. + +The following code shows how the device is configured in +``test_dmadev.c``: + +.. literalinclude:: ../../../app/test/test_dmadev.c + :language: c + :start-after: Setup of the dmadev device. 8< + :end-before: >8 End of setup of the dmadev device. + :dedent: 1
drivers/dma/idxd/idxd_bus.c +3 -0
@@ -96,6 +96,9 @@ idxd_dev_close(struct rte_dma_dev *dev)static const struct rte_dma_dev_ops idxd_bus_ops = { .dev_close = idxd_dev_close, .dev_dump = idxd_dump, + .dev_configure = idxd_configure, + .vchan_setup = idxd_vchan_setup, + .dev_info_get = idxd_info_get, }; static void *
drivers/dma/idxd/idxd_common.c +72 -0
78 lines not on this page · raw message
drivers/dma/idxd/idxd_internal.h +6 -0
@@ -82,5 +82,11 @@ struct idxd_dmadev {int idxd_dmadev_create (const char *name,struct rte_device *dev,const struct idxd_dmadev *base_idxd,const struct rte_dma_dev_ops *ops);int idxd_dump (const struct rte_dma_dev *dev,FILE *f); +int idxd_configure (struct rte_dma_dev *dev,const struct rte_dma_conf *dev_conf, +uint32_t conf_sz); +int idxd_vchan_setup (struct rte_dma_dev *dev,uint16_t vchan, +const struct rte_dma_vchan_conf *qconf,uint32_t qconf_sz); +int idxd_info_get (const struct rte_dma_dev *dev,struct rte_dma_info *dev_info, +uint32_t size);#endif /* _IDXD_INTERNAL_H_ */
drivers/dma/idxd/idxd_pci.c +3 -0
@@ -61,6 +61,9 @@ idxd_is_wq_enabled(struct idxd_dmadev *idxd)static const struct rte_dma_dev_ops idxd_pci_ops = { .dev_dump = idxd_dump, + .dev_configure = idxd_configure, + .vchan_setup = idxd_vchan_setup, + .dev_info_get = idxd_info_get, };/* each portal uses 4 x 4k pages */
Signature · 1 line
2.30.2
Re: [dpdk-dev] [PATCH v5 07/16] dma/idxd: add configure and info_get functions
Quoted 3 lines · Kevin Laatz
Add functions for device configuration. The
info_getfunction is included here since it can be useful for checking successful configuration.
Since this patch makes a change in the test code to enable use in the docs, that should be called out here too, I think, for example: "When providing an example of the function's use in the documentation, use code snippet from the unit tests".
Re: [dpdk-dev] [PATCH v5 07/16] dma/idxd: add configure and info_get functions
In reply to Kevin LaatzQuoted 52 lines · Kevin Laatz
Add functions for device configuration. The
info_getfunction is included here since it can be useful for checking successful configuration.Signed-off-by Bruce Richardson <[email protected]>Signed-off-by Kevin Laatz <[email protected]>Reviewed-by Conor Walsh <[email protected]>---
v2:
- fix reconfigure bug inidxd_vchan_setup()
- add literal include comment for the docs to pick up
v3:
- fixes needed after changes from rebasing--- app/test/test_dmadev.c | 2 + doc/guides/dmadevs/idxd.rst | 30 +++++++++++++ drivers/dma/idxd/idxd_bus.c | 3 ++ drivers/dma/idxd/idxd_common.c | 72 ++++++++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 6 +++ drivers/dma/idxd/idxd_pci.c | 3 ++ 6 files changed, 116 insertions(+)app/test/test_dmadev.c +2
-0@@ -739,6 +739,7 @@ test_dmadev_instance(uint16_t dev_id) {#define TEST_RINGSIZE 512#define CHECK_ERRS true +/* Setup of the dmadev device. 8< */ struct rte_dma_stats stats;struct rte_dma_info info;const struct rte_dma_conf conf = { .nb_vchans =1 };@@ -759,6 +760,7 @@ test_dmadev_instance(uint16_t dev_id)if (rte_dma_vchan_setup (dev_id, vchan, &qconf) <0 )ERR_RETURN ("Error with queue configuration\n" ); +/* >8 End of setup of the dmadev device. */ rte_dma_info_get (dev_id, &info);if (info.nb_vchans !=1 )doc/guides/dmadevs/idxd.rst +2
-0@@ -120,3 +120,33 @@ use a subset of configured queues. Once probed successfully, irrespective of kernel driver, the device will appear as a ``dmadev``, that is a "DMA device type" inside DPDK, and can be accessed using APIs from the ``rte_dmadev`` library. + +Using IDXD DMAdev Devices
doc/guides/dmadevs/idxd.rst use a subset of configured queues. · line 134
Quoted 10 lines
doc/guides/dmadevs/idxd.rst +10
-0+-------------------------- + +To use the devices from an application, the dmadev API can be used. + +Getting Device Information +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Basic information about each dmadev device can be queried using the +``rte_dma_info_get()`` API. This will return basic device information such as +the ``rte_device`` structure, device capabilities and other device specific values.
The info_get cannot obtains 'rte_device' now.
Quoted 45 lines
doc/guides/dmadevs/idxd.rst +18
-0+ +Device Configuration +~~~~~~~~~~~~~~~~~~~~~ + +Configuring an IDXD dmadev device is done using the ``rte_dma_configure()`` and +``rte_dma_vchan_setup`` APIs. The configurations are passed to these APIs using +the ``rte_dma_conf`` and ``rte_dma_vchan_conf`` structures, respectively. For +example, these can be used to configure the number of ``vchans`` per device, the +ring size, etc. The ring size must be a power of two, between 64 and 4096. + +The following code shows how the device is configured in +``test_dmadev.c``: + +.. literalinclude:: ../../../app/test/test_dmadev.c + :language: c + :start-after: Setup of the dmadev device. 8< + :end-before: >8 End of setup of the dmadev device. + :dedent: 1drivers/dma/idxd/idxd_bus.c +3
-0@@ -96,6 +96,9 @@ idxd_dev_close(struct rte_dma_dev *dev)static const struct rte_dma_dev_ops idxd_bus_ops = { .dev_close = idxd_dev_close, .dev_dump = idxd_dump, + .dev_configure = idxd_configure, + .vchan_setup = idxd_vchan_setup, + .dev_info_get = idxd_info_get, }; static void *drivers/dma/idxd/idxd_common.c +5
-0@@ -39,6 +39,78 @@ idxd_dump(const struct rte_dma_dev *dev, FILE *f)return 0 ; } +int +idxd_info_get (const struct rte_dma_dev *dev,struct rte_dma_info *info,uint32_t size) +{ +struct idxd_dmadev *idxd = dev->dev_private; +
drivers/dma/idxd/idxd_common.c idxd_dump(const struct rte_dma_dev *dev, FILE *f) · line 56
Quoted 10 lines
drivers/dma/idxd/idxd_common.c +10
-0+if (size <sizeof (*info)) +return -EINVAL ; + + *info = (struct rte_dma_info ) { + .dev_capa =RTE_DMA_CAPA_MEM_TO_MEM | +RTE_DMA_CAPA_OPS_COPY |RTE_DMA_CAPA_OPS_FILL , + .max_vchans =1 , + .max_desc =4096 , + .min_desc =64 , + .nb_vchans = (idxd->desc_ring !=NULL ),/* returns 1 or 0 */
The nb_vchans field was filled by lib.
Quoted 91 lines
drivers/dma/idxd/idxd_common.c +57
-0+ }; +if (idxd->sva_support) + info->dev_capa |=RTE_DMA_CAPA_SVA ; +return 0 ; +} + +int +idxd_configure(struct rte_dma_dev *dev __rte_unused, const struct rte_dma_conf *dev_conf, +uint32_t conf_sz) +{ +if (sizeof (struct rte_dma_conf ) != conf_sz) +return -EINVAL ; + +if (dev_conf->nb_vchans !=1 ) +return -EINVAL ; +return 0 ; +} + +int +idxd_vchan_setup(struct rte_dma_dev *dev, uint16_t vchan __rte_unused, +const struct rte_dma_vchan_conf *qconf,uint32_t qconf_sz) +{ +struct idxd_dmadev *idxd = dev->dev_private; +uint16_t max_desc = qconf->nb_desc; + +if (sizeof (struct rte_dma_vchan_conf ) != qconf_sz) +return -EINVAL ; + + idxd->qcfg = *qconf; + +if (!rte_is_power_of_2 (max_desc)) + max_desc =rte_align32pow2 (max_desc); +IDXD_PMD_DEBUG ("DMA dev %u using %u descriptors" , dev->data->dev_id, max_desc); + idxd->desc_ring_mask = max_desc -1 ; + idxd->qcfg.nb_desc = max_desc; + +/* in case we are reconfiguring a device, free any existing memory */ +rte_free (idxd->desc_ring); + +/* allocate the descriptor ring at 2x size as batches can't wrap */ + idxd->desc_ring =rte_zmalloc (NULL ,sizeof (*idxd->desc_ring) * max_desc *2 ,0 ); +if (idxd->desc_ring ==NULL ) +return -ENOMEM ; + idxd->desc_iova =rte_mem_virt2iova (idxd->desc_ring); + + idxd->batch_idx_read =0 ; + idxd->batch_idx_write =0 ; + idxd->batch_start =0 ; + idxd->batch_size =0 ; + idxd->ids_returned =0 ; + idxd->ids_avail =0 ; + +memset (idxd->batch_comp_ring,0 ,sizeof (*idxd->batch_comp_ring) * + (idxd->max_batches +1 )); +return 0 ; +} + int idxd_dmadev_create(const char *name, struct rte_device *dev, const struct idxd_dmadev *base_idxd,drivers/dma/idxd/idxd_internal.h +6
-0@@ -82,5 +82,11 @@ struct idxd_dmadev {int idxd_dmadev_create (const char *name,struct rte_device *dev,const struct idxd_dmadev *base_idxd,const struct rte_dma_dev_ops *ops);int idxd_dump (const struct rte_dma_dev *dev,FILE *f); +int idxd_configure (struct rte_dma_dev *dev,const struct rte_dma_conf *dev_conf, +uint32_t conf_sz); +int idxd_vchan_setup (struct rte_dma_dev *dev,uint16_t vchan, +const struct rte_dma_vchan_conf *qconf,uint32_t qconf_sz); +int idxd_info_get (const struct rte_dma_dev *dev,struct rte_dma_info *dev_info, +uint32_t size);#endif /* _IDXD_INTERNAL_H_ */ drivers/dma/idxd/idxd_pci.c +3
-0@@ -61,6 +61,9 @@ idxd_is_wq_enabled(struct idxd_dmadev *idxd)static const struct rte_dma_dev_ops idxd_pci_ops = { .dev_dump = idxd_dump, + .dev_configure = idxd_configure, + .vchan_setup = idxd_vchan_setup, + .dev_info_get = idxd_info_get, };/* each portal uses 4 x 4k pages */
PATCH v5 8/16 dma/idxd: add start and stop functions for pci devices
In reply to Kevin LaatzAdd device start/stop functions for DSA devices bound to vfio. For devices bound to the IDXD kernel driver, these are not required since the IDXD kernel driver takes care of this.
--- doc/guides/dmadevs/idxd.rst | 3 +++ drivers/dma/idxd/idxd_pci.c | 52 +++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+)
doc/guides/dmadevs/idxd.rst +3 -0
@@ -150,3 +150,6 @@ The following code shows how the device is configured in :start-after: Setup of the dmadev device. 8< :end-before: >8 End of setup of the dmadev device. :dedent: 1 + +Once configured, the device can then be made ready for use by calling the +``rte_dma_start()`` API.
drivers/dma/idxd/idxd_pci.c +52 -0
63 lines not on this page · raw message
Signature · 1 line
2.30.2
Re: [dpdk-dev] [PATCH v5 08/16] dma/idxd: add start and stop functions for pci devices
Quoted 37 lines · Kevin Laatz
Add device start/stop functions for DSA devices bound to vfio. For devices bound to the IDXD kernel driver, these are not required since the IDXD kernel driver takes care of this.
Signed-off-by Bruce Richardson <[email protected]>Signed-off-by Kevin Laatz <[email protected]>Reviewed-by Conor Walsh <[email protected]>--- doc/guides/dmadevs/idxd.rst | 3 +++ drivers/dma/idxd/idxd_pci.c | 52 +++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+)doc/guides/dmadevs/idxd.rst +3
-0@@ -150,3 +150,6 @@ The following code shows how the device is configured in :start-after: Setup of the dmadev device. 8< :end-before: >8 End of setup of the dmadev device. :dedent: 1 + +Once configured, the device can then be made ready for use by calling the +``rte_dma_start()`` API.drivers/dma/idxd/idxd_pci.c +6
-0@@ -59,11 +59,63 @@ idxd_is_wq_enabled(struct idxd_dmadev *idxd)return ((state >>WQ_STATE_SHIFT ) &WQ_STATE_MASK ) ==0x1 ; } +static int +idxd_pci_dev_stop (struct rte_dma_dev *dev) +{ +struct idxd_dmadev *idxd = dev->dev_private; +uint8_t err_code; +
drivers/dma/idxd/idxd_pci.c idxd_is_wq_enabled(struct idxd_dmadev *idxd) · line 77
Quoted 10 lines
drivers/dma/idxd/idxd_pci.c +10
-0+if (!idxd_is_wq_enabled (idxd)) { +IDXD_PMD_ERR ("Work queue %d already disabled" , idxd->qid); +return -EALREADY ; + } + + err_code =idxd_pci_dev_command (idxd, idxd_disable_wq); +if (err_code ||idxd_is_wq_enabled (idxd)) { +IDXD_PMD_ERR ("Failed disabling work queue %d, error code: %#x" , + idxd->qid, err_code); +return -err_code;
The err_code may zero.
Quoted 17 lines
drivers/dma/idxd/idxd_pci.c +17
-0+ } +IDXD_PMD_DEBUG ("Work queue %d disabled OK" , idxd->qid); + +return 0 ; +} + +static int +idxd_pci_dev_start (struct rte_dma_dev *dev) +{ +struct idxd_dmadev *idxd = dev->dev_private; +uint8_t err_code; + +if (idxd_is_wq_enabled (idxd)) { +IDXD_PMD_WARN ("WQ %d already enabled" , idxd->qid); +return 0 ; + } +
drivers/dma/idxd/idxd_pci.c idxd_is_wq_enabled(struct idxd_dmadev *idxd) · line 104
Quoted 10 lines
drivers/dma/idxd/idxd_pci.c +10
-0+if (idxd->desc_ring ==NULL ) { +IDXD_PMD_ERR ("WQ %d has not been fully configured" , idxd->qid); +return -EINVAL ; + } + + err_code =idxd_pci_dev_command (idxd, idxd_enable_wq); +if (err_code || !idxd_is_wq_enabled (idxd)) { +IDXD_PMD_ERR ("Failed enabling work queue %d, error code: %#x" , + idxd->qid, err_code); +return err_code ==0 ?-1 : err_code;
The rte_dma_start specified that a negative number is returned for failure. Suggestions return err_code == 0 ? -1 : -err_code;
Quoted 18 lines
drivers/dma/idxd/idxd_pci.c +9
-0+ } + +IDXD_PMD_DEBUG ("Work queue %d enabled OK" , idxd->qid); + +return 0 ; +} +static const struct rte_dma_dev_ops idxd_pci_ops = { .dev_dump = idxd_dump, .dev_configure = idxd_configure, .vchan_setup = idxd_vchan_setup, .dev_info_get = idxd_info_get, + .dev_start = idxd_pci_dev_start, + .dev_stop = idxd_pci_dev_stop, };/* each portal uses 4 x 4k pages */
PATCH v5 9/16 dma/idxd: add data-path job submission functions
In reply to Kevin LaatzAdd data path functions for enqueuing and submitting operations to DSA devices.
--- doc/guides/dmadevs/idxd.rst | 64 +++++++++++++++ drivers/dma/idxd/idxd_common.c | 136 +++++++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 5 ++ drivers/dma/idxd/meson.build | 1 + 4 files changed, 206 insertions(+)
doc/guides/dmadevs/idxd.rst +64 -0
@@ -153,3 +153,67 @@ The following code shows how the device is configured in Once configured, the device can then be made ready for use by calling the ``rte_dma_start()`` API. + +Performing Data Copies +~~~~~~~~~~~~~~~~~~~~~~~ + +To perform data copies using IDXD dmadev devices, descriptors should be enqueued +using the ``rte_dma_copy()`` API. The HW can be triggered to perform the copy +in two ways, either via a ``RTE_DMA_OP_FLAG_SUBMIT`` flag or by calling +``rte_dma_submit()``. Once copies have been completed, the completion will +be reported back when the application calls ``rte_dma_completed()`` or +``rte_dma_completed_status()``. The latter will also report the status of each +completed operation. + +The ``rte_dma_copy()`` function enqueues a single copy to the device ring for +copying at a later point. The parameters to that function include the IOVA addresses +of both the source and destination buffers, as well as the length of the copy. + +The ``rte_dma_copy()`` function enqueues a copy operation on the device ring. +If the ``RTE_DMA_OP_FLAG_SUBMIT`` flag is set when calling ``rte_dma_copy()``, +the device hardware will be informed of the elements. Alternatively, if the flag +is not set, the application needs to call the ``rte_dma_submit()`` function to +notify the device hardware. Once the device hardware is informed of the elements +enqueued on the ring, the device will begin to process them. It is expected +that, for efficiency reasons, a burst of operations will be enqueued to the +device via multiple enqueue calls between calls to the ``rte_dma_submit()`` +function. + +The following code demonstrates how to enqueue a burst of copies to the +device and start the hardware processing of them: + +.. code-block:: C + + struct rte_mbuf *srcs[COMP_BURST_SZ], *dsts[COMP_BURST_SZ]; + unsigned int i; + + for (i = 0; i < RTE_DIM(srcs); i++) { + uint64_t *src_data; + + srcs[i] = rte_pktmbuf_alloc(pool); + dsts[i] = rte_pktmbuf_alloc(pool); + src_data = rte_pktmbuf_mtod(srcs[i], uint64_t *); + if (srcs[i] == NULL || dsts[i] == NULL) { + PRINT_ERR("Error allocating buffers\n"); + return -1; + } + + for (j = 0; j < COPY_LEN/sizeof(uint64_t); j++) + src_data[j] = rte_rand(); + + if (rte_dma_copy(dev_id, vchan, srcs[i]->buf_iova + srcs[i]->data_off, + dsts[i]->buf_iova + dsts[i]->data_off, COPY_LEN, 0) < 0) { + PRINT_ERR("Error with rte_dma_copy for buffer %u\n", i); + return -1; + } + } + rte_dma_submit(dev_id, vchan); + +Filling an Area of Memory +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The IDXD driver also has support for the ``fill`` operation, where an area +of memory is overwritten, or filled, with a short pattern of data. +Fill operations can be performed in much the same was as copy operations +described above, just using the ``rte_dma_fill()`` function rather than the +``rte_dma_copy()`` function.
drivers/dma/idxd/idxd_common.c +136 -0
156 lines not on this page · raw message
drivers/dma/idxd/idxd_internal.h +5 -0
@@ -88,5 +88,10 @@ int idxd_vchan_setup(struct rte_dma_dev *dev, uint16_t vchan, const struct rte_dma_vchan_conf *qconf, uint32_t qconf_sz);int idxd_info_get (const struct rte_dma_dev *dev,struct rte_dma_info *dev_info,uint32_t size); +int idxd_enqueue_copy (struct rte_dma_dev *dev,uint16_t qid,rte_iova_t src, +rte_iova_t dst,unsigned int length,uint64_t flags); +int idxd_enqueue_fill (struct rte_dma_dev *dev,uint16_t qid,uint64_t pattern, +rte_iova_t dst,unsigned int length,uint64_t flags); +int idxd_submit (struct rte_dma_dev *dev,uint16_t qid);#endif /* _IDXD_INTERNAL_H_ */
drivers/dma/idxd/meson.build +1 -0
@@ -6,6 +6,7 @@ if is_windows endif deps += ['bus_pci'] +cflags += '-mavx2' # all platforms with idxd HW support AVX sources = files( 'idxd_bus.c', 'idxd_common.c',
Signature · 1 line
2.30.2
Re: [dpdk-dev] [PATCH v5 09/16] dma/idxd: add data-path job submission functions
Quoted 67 lines · Kevin Laatz
Add data path functions for enqueuing and submitting operations to DSA devices.
Signed-off-by Bruce Richardson <[email protected]>Signed-off-by Kevin Laatz <[email protected]>Reviewed-by Conor Walsh <[email protected]>--- doc/guides/dmadevs/idxd.rst | 64 +++++++++++++++ drivers/dma/idxd/idxd_common.c | 136 +++++++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 5 ++ drivers/dma/idxd/meson.build | 1 + 4 files changed, 206 insertions(+)doc/guides/dmadevs/idxd.rst +46
-0@@ -153,3 +153,67 @@ The following code shows how the device is configured in Once configured, the device can then be made ready for use by calling the ``rte_dma_start()`` API. + +Performing Data Copies +~~~~~~~~~~~~~~~~~~~~~~~ + +To perform data copies using IDXD dmadev devices, descriptors should be enqueued +using the ``rte_dma_copy()`` API. The HW can be triggered to perform the copy +in two ways, either via a ``RTE_DMA_OP_FLAG_SUBMIT`` flag or by calling +``rte_dma_submit()``. Once copies have been completed, the completion will +be reported back when the application calls ``rte_dma_completed()`` or +``rte_dma_completed_status()``. The latter will also report the status of each +completed operation. + +The ``rte_dma_copy()`` function enqueues a single copy to the device ring for +copying at a later point. The parameters to that function include the IOVA addresses +of both the source and destination buffers, as well as the length of the copy. + +The ``rte_dma_copy()`` function enqueues a copy operation on the device ring. +If the ``RTE_DMA_OP_FLAG_SUBMIT`` flag is set when calling ``rte_dma_copy()``, +the device hardware will be informed of the elements. Alternatively, if the flag +is not set, the application needs to call the ``rte_dma_submit()`` function to +notify the device hardware. Once the device hardware is informed of the elements +enqueued on the ring, the device will begin to process them. It is expected +that, for efficiency reasons, a burst of operations will be enqueued to the +device via multiple enqueue calls between calls to the ``rte_dma_submit()`` +function. + +The following code demonstrates how to enqueue a burst of copies to the +device and start the hardware processing of them: + +.. code-block:: C + + struct rte_mbuf *srcs[COMP_BURST_SZ], *dsts[COMP_BURST_SZ]; + unsigned int i; + + for (i = 0; i < RTE_DIM(srcs); i++) { + uint64_t *src_data; + + srcs[i] = rte_pktmbuf_alloc(pool); + dsts[i] = rte_pktmbuf_alloc(pool); + src_data = rte_pktmbuf_mtod(srcs[i], uint64_t *); + if (srcs[i] == NULL || dsts[i] == NULL) { + PRINT_ERR("Error allocating buffers\n"); + return -1; + } + + for (j = 0; j < COPY_LEN/sizeof(uint64_t); j++)
doc/guides/dmadevs/idxd.rst The following code shows how the device is configured in · line 211
Quoted 10 lines
doc/guides/dmadevs/idxd.rst +10
-0+ src_data[j] = rte_rand(); + + if (rte_dma_copy(dev_id, vchan, srcs[i]->buf_iova + srcs[i]->data_off, + dsts[i]->buf_iova + dsts[i]->data_off, COPY_LEN, 0) < 0) { + PRINT_ERR("Error with rte_dma_copy for buffer %u\n", i); + return -1; + } + } + rte_dma_submit(dev_id, vchan); +
I think this code block is larger than necessary, because it shows buffer allocation and initialization rather than just the basics of copy() and submit() APIs. Furthermore, rather than calling out the generic API use in the idxd-specific docs, can we just include a reference to the dmadev documentation?
/Bruce
Re: [dpdk-dev] [PATCH v5 09/16] dma/idxd: add data-path job submission functions
In reply to Kevin LaatzQuoted 13 lines · Kevin Laatz
Add data path functions for enqueuing and submitting operations to DSA devices.
Signed-off-by Bruce Richardson <[email protected]>Signed-off-by Kevin Laatz <[email protected]>Reviewed-by Conor Walsh <[email protected]>--- doc/guides/dmadevs/idxd.rst | 64 +++++++++++++++ drivers/dma/idxd/idxd_common.c | 136 +++++++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 5 ++ drivers/dma/idxd/meson.build | 1 + 4 files changed, 206 insertions(+)
[snip]
Quoted 11 lines
drivers/dma/idxd/idxd_common.c +11
-0+ +static __rte_always_inline int +__idxd_write_desc (struct rte_dma_dev *dev, +const uint32_t op_flags, +const rte_iova_t src, +const rte_iova_t dst, +const uint32_t size, +const uint32_t flags) +{ +struct idxd_dmadev *idxd = dev->dev_private; +uint16_t mask = idxd->desc_ring_mask;
drivers/dma/idxd/idxd_common.c line 94
Quoted 10 lines
drivers/dma/idxd/idxd_common.c +10
-0+uint16_t job_id = idxd->batch_start + idxd->batch_size; +/* we never wrap batches, so we only mask the start and allow start+size to overflow */ +uint16_t write_idx = (idxd->batch_start & mask) + idxd->batch_size; + +/* first check batch ring space then desc ring space */ +if ((idxd->batch_idx_read ==0 && idxd->batch_idx_write == idxd->max_batches) || + idxd->batch_idx_write +1 == idxd->batch_idx_read) +return -1 ; +if (((write_idx +1 ) & mask) == (idxd->ids_returned & mask)) +return -1 ;
Please return -ENOSPC when the ring is full.
Quoted 32 lines
drivers/dma/idxd/idxd_common.c +32
-0+ +/* write desc. Note: descriptors don't wrap, but the completion address does */ +const uint64_t op_flags64 = (uint64_t )(op_flags |IDXD_FLAG_COMPLETION_ADDR_VALID ) <<32 ; +const uint64_t comp_addr =__desc_idx_to_iova (idxd, write_idx & mask); +_mm256_store_si256 ((void *)&idxd->desc_ring[write_idx], +_mm256_set_epi64x (dst, src, comp_addr, op_flags64)); +_mm256_store_si256 ((void *)&idxd->desc_ring[write_idx].size, +_mm256_set_epi64x (0 ,0 ,0 , size)); + + idxd->batch_size++; + +rte_prefetch0_write (&idxd->desc_ring[write_idx +1 ]); + +if (flags &RTE_DMA_OP_FLAG_SUBMIT ) +__submit (idxd); + +return job_id; +} + +int +idxd_enqueue_copy(struct rte_dma_dev *dev, uint16_t qid __rte_unused, rte_iova_t src, +rte_iova_t dst,unsigned int length,uint64_t flags) +{ +/* we can take advantage of the fact that the fence flag in dmadev and DSA are the same, +* but check it at compile time to be sure. +*/ +RTE_BUILD_BUG_ON (RTE_DMA_OP_FLAG_FENCE !=IDXD_FLAG_FENCE ); +uint32_t memmove = (idxd_op_memmove <<IDXD_CMD_OP_SHIFT ) | +IDXD_FLAG_CACHE_CONTROL | (flags &IDXD_FLAG_FENCE ); +return __idxd_write_desc (dev, memmove, src, dst, length, flags); +} +
[snip]
PATCH v5 10/16 dma/idxd: add data-path job completion functions
In reply to Kevin LaatzAdd the data path functions for gathering completed operations.
---
v2:
- fixed typo in docs
- add completion status for invalid opcode
--- doc/guides/dmadevs/idxd.rst | 32 +++++ drivers/dma/idxd/idxd_common.c | 235 +++++++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 5 + 3 files changed, 272 insertions(+)
doc/guides/dmadevs/idxd.rst +32 -0
@@ -209,6 +209,38 @@ device and start the hardware processing of them: } rte_dma_submit(dev_id, vchan); +To retrieve information about completed copies, ``rte_dma_completed()`` and +``rte_dma_completed_status()`` APIs should be used. ``rte_dma_completed()`` +will return the number of completed operations, along with the index of the last +successful completed operation and whether or not an error was encountered. If an +error was encountered, ``rte_dma_completed_status()`` must be used to kick the +device off to continue processing operations and also to gather the status of each +individual operations which is filled in to the ``status`` array provided as +parameter by the application. + +The following status codes are supported by IDXD: +* ``RTE_DMA_STATUS_SUCCESSFUL``: The operation was successful. +* ``RTE_DMA_STATUS_INVALID_OPCODE``: The operation failed due to an invalid operation code. +* ``RTE_DMA_STATUS_INVALID_LENGTH``: The operation failed due to an invalid data length. +* ``RTE_DMA_STATUS_NOT_ATTEMPTED``: The operation was not attempted. +* ``RTE_DMA_STATUS_ERROR_UNKNOWN``: The operation failed due to an unspecified error. + +The following code shows how to retrieve the number of successfully completed +copies within a burst and then using ``rte_dma_completed_status()`` to check +which operation failed and kick off the device to continue processing operations: + +.. code-block:: C + + enum rte_dma_status_code status[COMP_BURST_SZ]; + uint16_t count, idx, status_count; + bool error = 0; + + count = rte_dma_completed(dev_id, vchan, COMP_BURST_SZ, &idx, &error); + + if (error){ + status_count = rte_dma_completed_status(dev_id, vchan, COMP_BURST_SZ, &idx, status); + } + Filling an Area of Memory ~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/dma/idxd/idxd_common.c +235 -0
241 lines not on this page · raw message
drivers/dma/idxd/idxd_internal.h +5 -0
@@ -93,5 +93,10 @@ int idxd_enqueue_copy(struct rte_dma_dev *dev, uint16_t qid, rte_iova_t src,int idxd_enqueue_fill (struct rte_dma_dev *dev,uint16_t qid,uint64_t pattern,rte_iova_t dst,unsigned int length,uint64_t flags);int idxd_submit (struct rte_dma_dev *dev,uint16_t qid); +uint16_t idxd_completed (struct rte_dma_dev *dev,uint16_t qid,uint16_t max_ops, +uint16_t *last_idx,bool *has_error); +uint16_t idxd_completed_status(struct rte_dma_dev *dev, uint16_t qid __rte_unused, +uint16_t max_ops,uint16_t *last_idx, +enum rte_dma_status_code *status);#endif /* _IDXD_INTERNAL_H_ */
Signature · 1 line
2.30.2
Re: [dpdk-dev] [PATCH v5 10/16] dma/idxd: add data-path job completion functions
Quoted 46 lines · Kevin Laatz
Add the data path functions for gathering completed operations.
Signed-off-by Bruce Richardson <[email protected]>Signed-off-by Kevin Laatz <[email protected]>Reviewed-by Conor Walsh <[email protected]>---
v2:
- fixed typo in docs
- add completion status for invalid opcode--- doc/guides/dmadevs/idxd.rst | 32 +++++ drivers/dma/idxd/idxd_common.c | 235 +++++++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 5 + 3 files changed, 272 insertions(+)doc/guides/dmadevs/idxd.rst +22
-0@@ -209,6 +209,38 @@ device and start the hardware processing of them: } rte_dma_submit(dev_id, vchan); +To retrieve information about completed copies, ``rte_dma_completed()`` and +``rte_dma_completed_status()`` APIs should be used. ``rte_dma_completed()`` +will return the number of completed operations, along with the index of the last +successful completed operation and whether or not an error was encountered. If an +error was encountered, ``rte_dma_completed_status()`` must be used to kick the +device off to continue processing operations and also to gather the status of each +individual operations which is filled in to the ``status`` array provided as +parameter by the application. + +The following status codes are supported by IDXD: +* ``RTE_DMA_STATUS_SUCCESSFUL``: The operation was successful. +* ``RTE_DMA_STATUS_INVALID_OPCODE``: The operation failed due to an invalid operation code. +* ``RTE_DMA_STATUS_INVALID_LENGTH``: The operation failed due to an invalid data length. +* ``RTE_DMA_STATUS_NOT_ATTEMPTED``: The operation was not attempted. +* ``RTE_DMA_STATUS_ERROR_UNKNOWN``: The operation failed due to an unspecified error. + +The following code shows how to retrieve the number of successfully completed +copies within a burst and then using ``rte_dma_completed_status()`` to check +which operation failed and kick off the device to continue processing operations: + +.. code-block:: C +
doc/guides/dmadevs/idxd.rst device and start the hardware processing of them: · line 243
Quoted 10 lines
doc/guides/dmadevs/idxd.rst +10
-0+ enum rte_dma_status_code status[COMP_BURST_SZ]; + uint16_t count, idx, status_count; + bool error = 0; + + count = rte_dma_completed(dev_id, vchan, COMP_BURST_SZ, &idx, &error); + + if (error){ + status_count = rte_dma_completed_status(dev_id, vchan, COMP_BURST_SZ, &idx, status); + } +
As with some of the other documentation text, it should be checked for overlap with the dmadev documentation, and merged with that if appropriate.
/Bruce
Re: [dpdk-dev] [PATCH v5 10/16] dma/idxd: add data-path job completion functions
In reply to Kevin LaatzQuoted 45 lines · Kevin Laatz
Add the data path functions for gathering completed operations.
Signed-off-by Bruce Richardson <[email protected]>Signed-off-by Kevin Laatz <[email protected]>Reviewed-by Conor Walsh <[email protected]>---
v2:
- fixed typo in docs
- add completion status for invalid opcode--- doc/guides/dmadevs/idxd.rst | 32 +++++ drivers/dma/idxd/idxd_common.c | 235 +++++++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 5 + 3 files changed, 272 insertions(+)doc/guides/dmadevs/idxd.rst +21
-0@@ -209,6 +209,38 @@ device and start the hardware processing of them: } rte_dma_submit(dev_id, vchan); +To retrieve information about completed copies, ``rte_dma_completed()`` and +``rte_dma_completed_status()`` APIs should be used. ``rte_dma_completed()`` +will return the number of completed operations, along with the index of the last +successful completed operation and whether or not an error was encountered. If an +error was encountered, ``rte_dma_completed_status()`` must be used to kick the +device off to continue processing operations and also to gather the status of each +individual operations which is filled in to the ``status`` array provided as +parameter by the application. + +The following status codes are supported by IDXD: +* ``RTE_DMA_STATUS_SUCCESSFUL``: The operation was successful. +* ``RTE_DMA_STATUS_INVALID_OPCODE``: The operation failed due to an invalid operation code. +* ``RTE_DMA_STATUS_INVALID_LENGTH``: The operation failed due to an invalid data length. +* ``RTE_DMA_STATUS_NOT_ATTEMPTED``: The operation was not attempted. +* ``RTE_DMA_STATUS_ERROR_UNKNOWN``: The operation failed due to an unspecified error. + +The following code shows how to retrieve the number of successfully completed +copies within a burst and then using ``rte_dma_completed_status()`` to check +which operation failed and kick off the device to continue processing operations: + +.. code-block:: C
doc/guides/dmadevs/idxd.rst device and start the hardware processing of them: · line 242
Quoted 10 lines
doc/guides/dmadevs/idxd.rst +10
-0+ + enum rte_dma_status_code status[COMP_BURST_SZ]; + uint16_t count, idx, status_count; + bool error = 0; + + count = rte_dma_completed(dev_id, vchan, COMP_BURST_SZ, &idx, &error); + + if (error){ + status_count = rte_dma_completed_status(dev_id, vchan, COMP_BURST_SZ, &idx, status); + }
Because it's a sequential scan to get the completion status, so the count may >0 even error was true. e.g.
request 1 successful
request 2 successful
request 3 fail
so the rte_dma_completed(dev_id, vchan, 3, &idx, &error) will return 2 and error was mark with true. If return 0 and error with true in above situation, this means that the driver must scans all completions first. which will lead to low performance.
Therefore, the recommended handling method is as follows:
count = rte_dma_completed(dev_id, vchan, COMP_BURST_SZ, &idx, &error);
if (likely(count > 0)) {
// process success completed
}
if (unlikely(error)) {
//}
Quoted 24 lines
doc/guides/dmadevs/idxd.rst +1
-0+ Filling an Area of Memory ~~~~~~~~~~~~~~~~~~~~~~~~~~drivers/dma/idxd/idxd_common.c +12
-0@@ -140,6 +140,241 @@ idxd_submit(struct rte_dma_dev *dev, uint16_t qid __rte_unused)return 0 ; } +static enum rte_dma_status_code +get_comp_status (struct idxd_completion *c) +{ +uint8_t st = c->status; +switch (st) { +/* successful descriptors are not written back normally */ +case IDXD_COMP_STATUS_INCOMPLETE : +case IDXD_COMP_STATUS_SUCCESS : +return RTE_DMA_STATUS_SUCCESSFUL ; +case IDXD_COMP_STATUS_INVALID_OPCODE : +return RTE_DMA_STATUS_INVALID_OPCODE ; +case IDXD_COMP_STATUS_INVALID_SIZE :
drivers/dma/idxd/idxd_common.c idxd_submit(struct rte_dma_dev *dev, uint16_t qid __rte_unused) · line 164
Quoted 10 lines
drivers/dma/idxd/idxd_common.c +10
-0+return RTE_DMA_STATUS_INVALID_LENGTH ; +case IDXD_COMP_STATUS_SKIPPED : +return RTE_DMA_STATUS_NOT_ATTEMPTED ; +default : +return RTE_DMA_STATUS_ERROR_UNKNOWN ; + } +} + +static __rte_always_inline int +batch_ok (struct idxd_dmadev *idxd,uint8_t max_ops,enum rte_dma_status_code *status)
uint8_t max_ops -> uint16_t max_ops ?
Quoted 34 lines
drivers/dma/idxd/idxd_common.c +34
-0+{ +uint16_t ret; +uint8_t bstatus; + +if (max_ops ==0 ) +return 0 ; + +/* first check if there are any unreturned handles from last time */ +if (idxd->ids_avail != idxd->ids_returned) { + ret =RTE_MIN ((uint16_t )(idxd->ids_avail - idxd->ids_returned), max_ops); + idxd->ids_returned += ret; +if (status) +memset (status,RTE_DMA_STATUS_SUCCESSFUL , ret *sizeof (*status)); +return ret; + } + +if (idxd->batch_idx_read == idxd->batch_idx_write) +return 0 ; + + bstatus = idxd->batch_comp_ring[idxd->batch_idx_read].status; +/* now check if next batch is complete and successful */ +if (bstatus ==IDXD_COMP_STATUS_SUCCESS ) { +/* since the batch idx ring stores the start of each batch, pre-increment to lookup +* start of next batch. +*/ +if (++idxd->batch_idx_read > idxd->max_batches) + idxd->batch_idx_read =0 ; + idxd->ids_avail = idxd->batch_idx_ring[idxd->batch_idx_read]; + + ret =RTE_MIN ((uint16_t )(idxd->ids_avail - idxd->ids_returned), max_ops); + idxd->ids_returned += ret; +if (status) +memset (status,RTE_DMA_STATUS_SUCCESSFUL , ret *sizeof (*status)); +return ret;
drivers/dma/idxd/idxd_common.c idxd_submit(struct rte_dma_dev *dev, uint16_t qid __rte_unused) · line 208
Quoted 10 lines
drivers/dma/idxd/idxd_common.c +10
-0+ } +/* check if batch is incomplete */ +else if (bstatus ==IDXD_COMP_STATUS_INCOMPLETE ) +return 0 ; + +return -1 ;/* error case */ +} + +static inline uint16_t +batch_completed (struct idxd_dmadev *idxd,uint8_t max_ops,bool *has_error)
uint8_t max_ops -> uint16_t max_ops ?
Quoted 188 lines
drivers/dma/idxd/idxd_common.c +169
-0+{ +uint16_t i; +uint16_t b_start, b_end, next_batch; + +int ret =batch_ok (idxd, max_ops,NULL ); +if (ret >=0 ) +return ret; + +/* ERROR case, not successful, not incomplete */ +/* Get the batch size, and special case size 1. +* once we identify the actual failure job, return other jobs, then update +* the batch ring indexes to make it look like the first job of the batch has failed. +* Subsequent calls here will always return zero packets, and the error must be cleared by +* calling the completed_status() function. +*/ + next_batch = (idxd->batch_idx_read +1 ); +if (next_batch > idxd->max_batches) + next_batch =0 ; + b_start = idxd->batch_idx_ring[idxd->batch_idx_read]; + b_end = idxd->batch_idx_ring[next_batch]; + +if (b_end - b_start ==1 ) {/* not a batch */ + *has_error = true; +return 0 ; + } + +for (i = b_start; i < b_end; i++) { +struct idxd_completion *c = (void *)&idxd->desc_ring[i & idxd->desc_ring_mask]; +if (c->status >IDXD_COMP_STATUS_SUCCESS )/* ignore incomplete(0) and success(1) */ +break ; + } + ret =RTE_MIN ((uint16_t )(i - idxd->ids_returned), max_ops); +if (ret < max_ops) + *has_error = true;/* we got up to the point of error */ + idxd->ids_avail = idxd->ids_returned += ret; + +/* to ensure we can call twice and just return 0, set start of batch to where we finished */ + idxd->batch_comp_ring[idxd->batch_idx_read].completed_size -= ret; + idxd->batch_idx_ring[idxd->batch_idx_read] += ret; +if (idxd->batch_idx_ring[next_batch] - idxd->batch_idx_ring[idxd->batch_idx_read] ==1 ) { +/* copy over the descriptor status to the batch ring as if no batch */ +uint16_t d_idx = idxd->batch_idx_ring[idxd->batch_idx_read] & idxd->desc_ring_mask; +struct idxd_completion *desc_comp = (void *)&idxd->desc_ring[d_idx]; + idxd->batch_comp_ring[idxd->batch_idx_read].status = desc_comp->status; + } + +return ret; +} + +static uint16_t +batch_completed_status (struct idxd_dmadev *idxd,uint16_t max_ops,enum rte_dma_status_code *status) +{ +uint16_t next_batch; + +int ret =batch_ok (idxd, max_ops, status); +if (ret >=0 ) +return ret; + +/* ERROR case, not successful, not incomplete */ +/* Get the batch size, and special case size 1. +*/ + next_batch = (idxd->batch_idx_read +1 ); +if (next_batch > idxd->max_batches) + next_batch =0 ; +const uint16_t b_start = idxd->batch_idx_ring[idxd->batch_idx_read]; +const uint16_t b_end = idxd->batch_idx_ring[next_batch]; +const uint16_t b_len = b_end - b_start; +if (b_len ==1 ) {/* not a batch */ + *status =get_comp_status (&idxd->batch_comp_ring[idxd->batch_idx_read]); + idxd->ids_avail++; + idxd->ids_returned++; + idxd->batch_idx_read = next_batch; +return 1 ; + } + +/* not a single-element batch, need to process more. +* Scenarios: +* 1. max_ops >= batch_size - can fit everything, simple case +* - loop through completed ops and then add on any not-attempted ones +* 2. max_ops < batch_size - can't fit everything, more complex case +* - loop through completed/incomplete and stop when hit max_ops +* - adjust the batch descriptor to update where we stopped, with appropriate bcount +* - if bcount is to be exactly 1, update the batch descriptor as it will be treated as +* non-batch next time. +*/ +const uint16_t bcount = idxd->batch_comp_ring[idxd->batch_idx_read].completed_size; +for (ret =0 ; ret < b_len && ret < max_ops; ret++) { +struct idxd_completion *c = (void *) + &idxd->desc_ring[(b_start + ret) & idxd->desc_ring_mask]; + status[ret] = (ret < bcount) ?get_comp_status (c) :RTE_DMA_STATUS_NOT_ATTEMPTED ; + } + idxd->ids_avail = idxd->ids_returned += ret; + +/* everything fit */ +if (ret == b_len) { + idxd->batch_idx_read = next_batch; +return ret; + } + +/* set up for next time, update existing batch descriptor & start idx at batch_idx_read */ + idxd->batch_idx_ring[idxd->batch_idx_read] += ret; +if (ret > bcount) { +/* we have only incomplete ones - set batch completed size to 0 */ +struct idxd_completion *comp = &idxd->batch_comp_ring[idxd->batch_idx_read]; + comp->completed_size =0 ; +/* if there is only one descriptor left, job skipped so set flag appropriately */ +if (b_len - ret ==1 ) + comp->status =IDXD_COMP_STATUS_SKIPPED ; + }else { +struct idxd_completion *comp = &idxd->batch_comp_ring[idxd->batch_idx_read]; + comp->completed_size -= ret; +/* if there is only one descriptor left, copy status info straight to desc */ +if (comp->completed_size ==1 ) { +struct idxd_completion *c = (void *) + &idxd->desc_ring[(b_start + ret) & idxd->desc_ring_mask]; + comp->status = c->status; +/* individual descs can be ok without writeback, but not batches */ +if (comp->status ==IDXD_COMP_STATUS_INCOMPLETE ) + comp->status =IDXD_COMP_STATUS_SUCCESS ; + }else if (bcount == b_len) { +/* check if we still have an error, and clear flag if not */ +uint16_t i; +for (i = b_start + ret; i < b_end; i++) { +struct idxd_completion *c = (void *) + &idxd->desc_ring[i & idxd->desc_ring_mask]; +if (c->status >IDXD_COMP_STATUS_SUCCESS ) +break ; + } +if (i == b_end)/* no errors */ + comp->status =IDXD_COMP_STATUS_SUCCESS ; + } + } + +return ret; +} + +uint16_t +idxd_completed(struct rte_dma_dev *dev, uint16_t qid __rte_unused, uint16_t max_ops, +uint16_t *last_idx,bool *has_error) +{ +struct idxd_dmadev *idxd = dev->dev_private; +uint16_t batch, ret =0 ; + +do { + batch =batch_completed (idxd, max_ops - ret, has_error); + ret += batch; + }while (batch >0 && *has_error == false); + + *last_idx = idxd->ids_returned -1 ; +return ret; +} + +uint16_t +idxd_completed_status(struct rte_dma_dev *dev, uint16_t qid __rte_unused, uint16_t max_ops, +uint16_t *last_idx,enum rte_dma_status_code *status) +{ +struct idxd_dmadev *idxd = dev->dev_private; + +uint16_t batch, ret =0 ; + +do { + batch =batch_completed_status (idxd, max_ops - ret, &status[ret]); + ret += batch; + }while (batch >0 ); + + *last_idx = idxd->ids_returned -1 ; +return ret; +} +int idxd_dump (const struct rte_dma_dev *dev,FILE *f) {drivers/dma/idxd/idxd_internal.h +5
-0@@ -93,5 +93,10 @@ int idxd_enqueue_copy(struct rte_dma_dev *dev, uint16_t qid, rte_iova_t src,int idxd_enqueue_fill (struct rte_dma_dev *dev,uint16_t qid,uint64_t pattern,rte_iova_t dst,unsigned int length,uint64_t flags);int idxd_submit (struct rte_dma_dev *dev,uint16_t qid); +uint16_t idxd_completed (struct rte_dma_dev *dev,uint16_t qid,uint16_t max_ops, +uint16_t *last_idx,bool *has_error); +uint16_t idxd_completed_status(struct rte_dma_dev *dev, uint16_t qid __rte_unused, +uint16_t max_ops,uint16_t *last_idx, +enum rte_dma_status_code *status);#endif /* _IDXD_INTERNAL_H_ */
PATCH v5 11/16 dma/idxd: add operation statistic tracking
In reply to Kevin LaatzAdd statistic tracking for DSA devices.
--- doc/guides/dmadevs/idxd.rst | 11 +++++++++++ drivers/dma/idxd/idxd_bus.c | 2 ++ drivers/dma/idxd/idxd_common.c | 27 +++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 3 +++ drivers/dma/idxd/idxd_pci.c | 2 ++ 5 files changed, 45 insertions(+)
doc/guides/dmadevs/idxd.rst +11 -0
@@ -249,3 +249,14 @@ of memory is overwritten, or filled, with a short pattern of data. Fill operations can be performed in much the same was as copy operations described above, just using the ``rte_dma_fill()`` function rather than the ``rte_dma_copy()`` function. + +Querying Device Statistics +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The statistics from the IDXD dmadev device can be got via the stats functions in +the ``rte_dmadev`` library, i.e. ``rte_dma_stats_get()``. The statistics +returned for each device instance are: + +* ``submitted``: The number of operations submitted to the device. +* ``completed``: The number of operations which have completed (successful and failed). +* ``errors``: The number of operations that completed with error.
drivers/dma/idxd/idxd_bus.c +2 -0
@@ -99,6 +99,8 @@ static const struct rte_dma_dev_ops idxd_bus_ops = { .dev_configure = idxd_configure, .vchan_setup = idxd_vchan_setup, .dev_info_get = idxd_info_get, + .stats_get = idxd_stats_get, + .stats_reset = idxd_stats_reset, }; static void *
drivers/dma/idxd/idxd_common.c +27 -0
@@ -65,6 +65,8 @@ __submit(struct idxd_dmadev *idxd)if (++idxd->batch_idx_write > idxd->max_batches) idxd->batch_idx_write =0 ; + idxd->stats.submitted += idxd->batch_size; + idxd->batch_start += idxd->batch_size; idxd->batch_size =0 ; idxd->batch_idx_ring[idxd->batch_idx_write] = idxd->batch_start;
@@ -275,6 +277,8 @@ batch_completed_status(struct idxd_dmadev *idxd, uint16_t max_ops, enum rte_dma_const uint16_t b_len = b_end - b_start;if (b_len ==1 ) {/* not a batch */ *status =get_comp_status (&idxd->batch_comp_ring[idxd->batch_idx_read]); +if (status !=RTE_DMA_STATUS_SUCCESSFUL ) + idxd->stats.errors++; idxd->ids_avail++; idxd->ids_returned++; idxd->batch_idx_read = next_batch;
@@ -296,6 +300,8 @@ batch_completed_status(struct idxd_dmadev *idxd, uint16_t max_ops, enum rte_dma_struct idxd_completion *c = (void *) &idxd->desc_ring[(b_start + ret) & idxd->desc_ring_mask]; status[ret] = (ret < bcount) ?get_comp_status (c) :RTE_DMA_STATUS_NOT_ATTEMPTED ; +if (status[ret] !=RTE_DMA_STATUS_SUCCESSFUL ) + idxd->stats.errors++; } idxd->ids_avail = idxd->ids_returned += ret;
@@ -354,6 +360,7 @@ idxd_completed(struct rte_dma_dev *dev, uint16_t qid __rte_unused, uint16_t max_ ret += batch; }while (batch >0 && *has_error == false); + idxd->stats.completed += ret; *last_idx = idxd->ids_returned -1 ;return ret; }
@@ -371,6 +378,7 @@ idxd_completed_status(struct rte_dma_dev *dev, uint16_t qid __rte_unused, uint16 ret += batch; }while (batch >0 ); + idxd->stats.completed += ret; *last_idx = idxd->ids_returned -1 ;return ret; }
@@ -404,6 +412,25 @@ idxd_dump(const struct rte_dma_dev *dev, FILE *f)return 0 ; } +int +idxd_stats_get(const struct rte_dma_dev *dev, uint16_t vchan __rte_unused, +struct rte_dma_stats *stats,uint32_t stats_sz) +{ +struct idxd_dmadev *idxd = dev->dev_private; +if (stats_sz <sizeof (*stats)) +return -EINVAL ; + *stats = idxd->stats; +return 0 ; +} + +int +idxd_stats_reset(struct rte_dma_dev *dev, uint16_t vchan __rte_unused) +{ +struct idxd_dmadev *idxd = dev->dev_private; + idxd->stats = (struct rte_dma_stats ){0 }; +return 0 ; +} +int idxd_info_get (const struct rte_dma_dev *dev,struct rte_dma_info *info,uint32_t size) {
drivers/dma/idxd/idxd_internal.h +3 -0
@@ -98,5 +98,8 @@ uint16_t idxd_completed(struct rte_dma_dev *dev, uint16_t qid, uint16_t max_ops, uint16_t idxd_completed_status(struct rte_dma_dev *dev, uint16_t qid __rte_unused,uint16_t max_ops,uint16_t *last_idx,enum rte_dma_status_code *status); +int idxd_stats_get (const struct rte_dma_dev *dev,uint16_t vchan, +struct rte_dma_stats *stats,uint32_t stats_sz); +int idxd_stats_reset (struct rte_dma_dev *dev,uint16_t vchan);#endif /* _IDXD_INTERNAL_H_ */
drivers/dma/idxd/idxd_pci.c +2 -0
@@ -114,6 +114,8 @@ static const struct rte_dma_dev_ops idxd_pci_ops = { .dev_configure = idxd_configure, .vchan_setup = idxd_vchan_setup, .dev_info_get = idxd_info_get, + .stats_get = idxd_stats_get, + .stats_reset = idxd_stats_reset, .dev_start = idxd_pci_dev_start, .dev_stop = idxd_pci_dev_stop, };
Signature · 1 line
2.30.2
Re: [dpdk-dev] [PATCH v5 11/16] dma/idxd: add operation statistic tracking
Quoted 13 lines · Kevin Laatz
Add statistic tracking for DSA devices.
Signed-off-by Bruce Richardson <[email protected]>Signed-off-by Kevin Laatz <[email protected]>Reviewed-by Conor Walsh <[email protected]>--- doc/guides/dmadevs/idxd.rst | 11 +++++++++++ drivers/dma/idxd/idxd_bus.c | 2 ++ drivers/dma/idxd/idxd_common.c | 27 +++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 3 +++ drivers/dma/idxd/idxd_pci.c | 2 ++ 5 files changed, 45 insertions(+)
[snip]
PATCH v5 12/16 dma/idxd: add vchan status function
In reply to Kevin LaatzWhen testing dmadev drivers, it is useful to have the HW device in a known state. This patch adds the implementation of the function which will wait for the device to be idle (all jobs completed) before proceeding.
---
v3: update API name to vchan_status
--- drivers/dma/idxd/idxd_bus.c | 1 + drivers/dma/idxd/idxd_common.c | 17 +++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 2 ++ drivers/dma/idxd/idxd_pci.c | 1 + 4 files changed, 21 insertions(+)
drivers/dma/idxd/idxd_bus.c +1 -0
@@ -101,6 +101,7 @@ static const struct rte_dma_dev_ops idxd_bus_ops = { .dev_info_get = idxd_info_get, .stats_get = idxd_stats_get, .stats_reset = idxd_stats_reset, + .vchan_status = idxd_vchan_status, }; static void *
drivers/dma/idxd/idxd_common.c +17 -0
@@ -162,6 +162,23 @@ get_comp_status(struct idxd_completion *c) } } +int +idxd_vchan_status(const struct rte_dma_dev *dev, uint16_t vchan __rte_unused, +enum rte_dma_vchan_status *status) +{ +struct idxd_dmadev *idxd = dev->dev_private; +uint16_t last_batch_write = idxd->batch_idx_write ==0 ? idxd->max_batches : + idxd->batch_idx_write -1 ; +uint8_t bstatus = (idxd->batch_comp_ring[last_batch_write].status !=0 ); + +/* An IDXD device will always be either active or idle. +* RTE_DMA_VCHAN_HALTED_ERROR is therefore not supported by IDXD. +*/ + *status = bstatus ?RTE_DMA_VCHAN_IDLE :RTE_DMA_VCHAN_ACTIVE ; + +return 0 ; +} + static __rte_always_inline intbatch_ok (struct idxd_dmadev *idxd,uint8_t max_ops,enum rte_dma_status_code *status) {
drivers/dma/idxd/idxd_internal.h +2 -0
@@ -101,5 +101,7 @@ uint16_t idxd_completed_status(struct rte_dma_dev *dev, uint16_t qid __rte_unuseint idxd_stats_get (const struct rte_dma_dev *dev,uint16_t vchan,struct rte_dma_stats *stats,uint32_t stats_sz);int idxd_stats_reset (struct rte_dma_dev *dev,uint16_t vchan); +int idxd_vchan_status (const struct rte_dma_dev *dev,uint16_t vchan, +enum rte_dma_vchan_status *status);#endif /* _IDXD_INTERNAL_H_ */
drivers/dma/idxd/idxd_pci.c +1 -0
@@ -118,6 +118,7 @@ static const struct rte_dma_dev_ops idxd_pci_ops = { .stats_reset = idxd_stats_reset, .dev_start = idxd_pci_dev_start, .dev_stop = idxd_pci_dev_stop, + .vchan_status = idxd_vchan_status, };/* each portal uses 4 x 4k pages */
Signature · 1 line
2.30.2
PATCH v5 13/16 dma/idxd: add burst capacity API
In reply to Kevin LaatzAdd support for the burst capacity API. This API will provide the calling application with the remaining capacity of the current burst (limited by max HW batch size).
--- drivers/dma/idxd/idxd_bus.c | 1 + drivers/dma/idxd/idxd_common.c | 20 ++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 1 + drivers/dma/idxd/idxd_pci.c | 2 ++ 4 files changed, 24 insertions(+)
drivers/dma/idxd/idxd_bus.c +1 -0
@@ -102,6 +102,7 @@ static const struct rte_dma_dev_ops idxd_bus_ops = { .stats_get = idxd_stats_get, .stats_reset = idxd_stats_reset, .vchan_status = idxd_vchan_status, + .burst_capacity = idxd_burst_capacity, }; static void *
drivers/dma/idxd/idxd_common.c +20 -0
@@ -469,6 +469,26 @@ idxd_info_get(const struct rte_dma_dev *dev, struct rte_dma_info *info, uint32_treturn 0 ; } +uint16_t +idxd_burst_capacity(const struct rte_dma_dev *dev, uint16_t vchan __rte_unused) +{ +struct idxd_dmadev *idxd = dev->dev_private; +uint16_t write_idx = idxd->batch_start + idxd->batch_size; +uint16_t used_space; + +/* Check for space in the batch ring */ +if ((idxd->batch_idx_read ==0 && idxd->batch_idx_write == idxd->max_batches) || + idxd->batch_idx_write +1 == idxd->batch_idx_read) +return 0 ; + +/* For descriptors, check for wrap-around on write but not read */ +if (idxd->ids_returned > write_idx) + write_idx += idxd->desc_ring_mask +1 ; + used_space = write_idx - idxd->ids_returned; + +return RTE_MIN ((idxd->desc_ring_mask - used_space), idxd->max_batch_size); +} +int idxd_configure(struct rte_dma_dev *dev __rte_unused, const struct rte_dma_conf *dev_conf,uint32_t conf_sz)
drivers/dma/idxd/idxd_internal.h +1 -0
@@ -103,5 +103,6 @@ int idxd_stats_get(const struct rte_dma_dev *dev, uint16_t vchan,int idxd_stats_reset (struct rte_dma_dev *dev,uint16_t vchan);int idxd_vchan_status (const struct rte_dma_dev *dev,uint16_t vchan,enum rte_dma_vchan_status *status); +uint16_t idxd_burst_capacity (const struct rte_dma_dev *dev,uint16_t vchan);#endif /* _IDXD_INTERNAL_H_ */
drivers/dma/idxd/idxd_pci.c +2 -0
@@ -119,6 +119,7 @@ static const struct rte_dma_dev_ops idxd_pci_ops = { .dev_start = idxd_pci_dev_start, .dev_stop = idxd_pci_dev_stop, .vchan_status = idxd_vchan_status, + .burst_capacity = idxd_burst_capacity, };/* each portal uses 4 x 4k pages */
@@ -232,6 +233,7 @@ init_pci_device(struct rte_pci_device *dev, struct idxd_dmadev *idxd, idxd->u.pci = pci; idxd->max_batches = wq_size; + idxd->max_batch_size =1 << lg2_max_batch;/* enable the device itself */ err_code =idxd_pci_dev_command (idxd, idxd_enable_dev);
Signature · 1 line
2.30.2
Re: [dpdk-dev] [PATCH v5 13/16] dma/idxd: add burst capacity API
Quoted 7 lines · Kevin Laatz
Add support for the burst capacity API. This API will provide the calling application with the remaining capacity of the current burst (limited by max HW batch size).
Signed-off-by Kevin Laatz <[email protected]>Reviewed-by Conor Walsh <[email protected]>---
PATCH v5 14/16 dma/idxd: move dpdk_idxd_cfg.py from raw to dma
In reply to Kevin LaatzFrom: Conor Walsh <[email protected]>
Move the example script for configuring IDXD devices bound to the IDXD kernel driver from raw to dma, and create a symlink to still allow use from raw.
--- drivers/dma/idxd/dpdk_idxd_cfg.py | 117 +++++++++++++++++++++++++++++ drivers/raw/ioat/dpdk_idxd_cfg.py | 118 +----------------------------- 2 files changed, 118 insertions(+), 117 deletions(-) create mode 100755 drivers/dma/idxd/dpdk_idxd_cfg.py mode change 100755 => 120000 drivers/raw/ioat/dpdk_idxd_cfg.py
drivers/dma/idxd/dpdk_idxd_cfg.py new file +117 -0
@@ -0,0 +1,117 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2020 Intel Corporation + +""" +Configure an entire Intel DSA instance, using idxd kernel driver, for DPDK use +""" + +import sys +import argparse +import os +import os.path + + +class SysfsDir: + "Used to read/write paths in a sysfs directory" + def __init__(self, path): + self.path = path + + def read_int(self, filename): + "Return a value from sysfs file" + with open(os.path.join(self.path, filename)) as f: + return int(f.readline()) + + def write_values(self, values): + "write dictionary, where key is filename and value is value to write" + for filename, contents in values.items(): + with open(os.path.join(self.path, filename), "w") as f: + f.write(str(contents)) + + +def reset_device(dsa_id): + "Reset the DSA device and all its queues" + drv_dir = SysfsDir("/sys/bus/dsa/drivers/dsa") + drv_dir.write_values({"unbind": f"dsa{dsa_id}"}) + + +def get_pci_dir(pci): + "Search for the sysfs directory of the PCI device" + base_dir = '/sys/bus/pci/devices/' + for path, dirs, files in os.walk(base_dir): + for dir in dirs: + if pci in dir: + return os.path.join(base_dir, dir) + sys.exit(f"Could not find sysfs directory for device {pci}") + + +def get_dsa_id(pci): + "Get the DSA instance ID using the PCI address of the device" + pci_dir = get_pci_dir(pci) + for path, dirs, files in os.walk(pci_dir): + for dir in dirs: + if dir.startswith('dsa') and 'wq' not in dir: + return int(dir[3:]) + sys.exit(f"Could not get device ID for device {pci}") + + +def configure_dsa(dsa_id, queues, prefix): + "Configure the DSA instance with appropriate number of queues" + dsa_dir = SysfsDir(f"/sys/bus/dsa/devices/dsa{dsa_id}") + drv_dir = SysfsDir("/sys/bus/dsa/drivers/dsa") + + max_groups = dsa_dir.read_int("max_groups") + max_engines = dsa_dir.read_int("max_engines") + max_queues = dsa_dir.read_int("max_work_queues") + max_work_queues_size = dsa_dir.read_int("max_work_queues_size") + + nb_queues = min(queues, max_queues) + if queues > nb_queues: + print(f"Setting number of queues to max supported value: {max_queues}") + + # we want one engine per group, and no more engines than queues + nb_groups = min(max_engines, max_groups, nb_queues) + for grp in range(nb_groups): + dsa_dir.write_values({f"engine{dsa_id}.{grp}/group_id": grp}) + + # configure each queue + for q in range(nb_queues): + wq_dir = SysfsDir(os.path.join(dsa_dir.path, f"wq{dsa_id}.{q}")) + wq_dir.write_values({"group_id": q % nb_groups, + "type": "user", + "mode": "dedicated", + "name": f"{prefix}_wq{dsa_id}.{q}", + "priority": 1, + "size": int(max_work_queues_size / nb_queues)}) + + # enable device and then queues + drv_dir.write_values({"bind": f"dsa{dsa_id}"}) + for q in range(nb_queues): + drv_dir.write_values({"bind": f"wq{dsa_id}.{q}"}) + + +def main(args): + "Main function, does arg parsing and calls config function" + arg_p = argparse.ArgumentParser( + description="Configure whole DSA device instance for DPDK use") + arg_p.add_argument('dsa_id', + help="Specify DSA instance either via DSA instance number or PCI address") + arg_p.add_argument('-q', metavar='queues', type=int, default=255, + help="Number of queues to set up") + arg_p.add_argument('--name-prefix', metavar='prefix', dest='prefix', + default="dpdk", + help="Prefix for workqueue name to mark for DPDK use [default: 'dpdk']") + arg_p.add_argument('--reset', action='store_true', + help="Reset DSA device and its queues") + parsed_args = arg_p.parse_args(args[1:]) + + dsa_id = parsed_args.dsa_id + dsa_id = get_dsa_id(dsa_id) if ':' in dsa_id else dsa_id + if parsed_args.reset: + reset_device(dsa_id) + else: + configure_dsa(dsa_id, parsed_args.q, parsed_args.prefix) + + +if __name__ == "__main__": + main(sys.argv)
drivers/raw/ioat/dpdk_idxd_cfg.py deleted +0 -117
117 lines not on this page · raw message
drivers/raw/ioat/dpdk_idxd_cfg.py new file +1 -0
@@ -0,0 +1 @@ +../../dma/idxd/dpdk_idxd_cfg.py
Signature · 1 line
2.30.2
Re: [dpdk-dev] [PATCH v5 14/16] dma/idxd: move dpdk_idxd_cfg.py from raw to dma
Quoted 9 lines · Kevin Laatz
From: Conor Walsh <[email protected]>
Move the example script for configuring IDXD devices bound to the IDXD kernel driver from raw to dma, and create a symlink to still allow use from raw.
Signed-off-by Conor Walsh <[email protected]>Signed-off-by Kevin Laatz <[email protected]>---
PATCH v5 15/16 devbind: add dma device class
In reply to Kevin LaatzAdd a new class for DMA devices. Devices listed under the DMA class are to be used with the dmadev library.
--- usertools/dpdk-devbind.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
usertools/dpdk-devbind.py +9 -3
@@ -69,12 +69,13 @@ network_devices = [network_class, cavium_pkx, avp_vnic, ifpga_class] baseband_devices = [acceleration_class] crypto_devices = [encryption_class, intel_processor_class] +dma_devices = [] eventdev_devices = [cavium_sso, cavium_tim, intel_dlb, octeontx2_sso] mempool_devices = [cavium_fpa, octeontx2_npa] compress_devices = [cavium_zip] regex_devices = [octeontx2_ree] -misc_devices = [cnxk_bphy, cnxk_bphy_cgx, intel_ioat_bdw, intel_ioat_skx, intel_ioat_icx, intel_idxd_spr, - intel_ntb_skx, intel_ntb_icx, +misc_devices = [cnxk_bphy, cnxk_bphy_cgx, intel_ioat_bdw, intel_ioat_skx, + intel_ioat_icx, intel_idxd_spr, intel_ntb_skx, intel_ntb_icx, octeontx2_dma] # global dict ethernet devices present. Dictionary indexed by PCI address.
@@ -583,6 +584,9 @@ def show_status(): if status_dev in ["crypto", "all"]: show_device_status(crypto_devices, "Crypto") + if status_dev in ["dma", "all"]: + show_device_status(dma_devices, "DMA") + if status_dev in ["event", "all"]: show_device_status(eventdev_devices, "Eventdev")
@@ -651,7 +655,7 @@ def parse_args(): parser.add_argument( '--status-dev', help="Print the status of given device group.", - choices=['baseband', 'compress', 'crypto', 'event', + choices=['baseband', 'compress', 'crypto', 'dma', 'event', 'mempool', 'misc', 'net', 'regex']) bind_group = parser.add_mutually_exclusive_group() bind_group.add_argument(
@@ -732,6 +736,7 @@ def do_arg_actions(): get_device_details(network_devices) get_device_details(baseband_devices) get_device_details(crypto_devices) + get_device_details(dma_devices) get_device_details(eventdev_devices) get_device_details(mempool_devices) get_device_details(compress_devices)
@@ -754,6 +759,7 @@ def main(): get_device_details(network_devices) get_device_details(baseband_devices) get_device_details(crypto_devices) + get_device_details(dma_devices) get_device_details(eventdev_devices) get_device_details(mempool_devices) get_device_details(compress_devices)
Signature · 1 line
2.30.2
Re: [dpdk-dev] [PATCH v5 15/16] devbind: add dma device class
Quoted 6 lines · Kevin Laatz
Add a new class for DMA devices. Devices listed under the DMA class are to be used with the dmadev library.
Signed-off-by Kevin Laatz <[email protected]>Reviewed-by Conor Walsh <[email protected]>---
One small comment below to be fixed.
Quoted 10 lines
usertools/dpdk-devbind.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)usertools/dpdk-devbind.py +0
-0@@ -69,12 +69,13 @@ network_devices = [network_class, cavium_pkx, avp_vnic, ifpga_class] baseband_devices = [acceleration_class]
usertools/dpdk-devbind.py line 78
Quoted 10 lines
usertools/dpdk-devbind.py +3
-2crypto_devices = [encryption_class, intel_processor_class] +dma_devices = [] eventdev_devices = [cavium_sso, cavium_tim, intel_dlb, octeontx2_sso] mempool_devices = [cavium_fpa, octeontx2_npa] compress_devices = [cavium_zip] regex_devices = [octeontx2_ree] -misc_devices = [cnxk_bphy, cnxk_bphy_cgx, intel_ioat_bdw, intel_ioat_skx, intel_ioat_icx, intel_idxd_spr, - intel_ntb_skx, intel_ntb_icx, +misc_devices = [cnxk_bphy, cnxk_bphy_cgx, intel_ioat_bdw, intel_ioat_skx, + intel_ioat_icx, intel_idxd_spr, intel_ntb_skx, intel_ntb_icx,
This looks a purely cosmetic change, which doesn't really below in the patch - especially since a number of these entries are to move in later patches for 21.11.
/Bruce
Re: [dpdk-dev] [PATCH v5 15/16] devbind: add dma device class
In reply to Kevin LaatzQuoted 65 lines · Kevin Laatz
Add a new class for DMA devices. Devices listed under the DMA class are to be used with the dmadev library.
Signed-off-by Kevin Laatz <[email protected]>Reviewed-by Conor Walsh <[email protected]>--- usertools/dpdk-devbind.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)usertools/dpdk-devbind.py +9
-3@@ -69,12 +69,13 @@ network_devices = [network_class, cavium_pkx, avp_vnic, ifpga_class] baseband_devices = [acceleration_class] crypto_devices = [encryption_class, intel_processor_class] +dma_devices = [] eventdev_devices = [cavium_sso, cavium_tim, intel_dlb, octeontx2_sso] mempool_devices = [cavium_fpa, octeontx2_npa] compress_devices = [cavium_zip] regex_devices = [octeontx2_ree] -misc_devices = [cnxk_bphy, cnxk_bphy_cgx, intel_ioat_bdw, intel_ioat_skx, intel_ioat_icx, intel_idxd_spr, - intel_ntb_skx, intel_ntb_icx, +misc_devices = [cnxk_bphy, cnxk_bphy_cgx, intel_ioat_bdw, intel_ioat_skx, + intel_ioat_icx, intel_idxd_spr, intel_ntb_skx, intel_ntb_icx, octeontx2_dma] # global dict ethernet devices present. Dictionary indexed by PCI address.@@ -583,6 +584,9 @@ def show_status(): if status_dev in ["crypto", "all"]: show_device_status(crypto_devices, "Crypto") + if status_dev in ["dma", "all"]: + show_device_status(dma_devices, "DMA") + if status_dev in ["event", "all"]: show_device_status(eventdev_devices, "Eventdev")@@ -651,7 +655,7 @@ def parse_args(): parser.add_argument( '--status-dev', help="Print the status of given device group.", - choices=['baseband', 'compress', 'crypto', 'event', + choices=['baseband', 'compress', 'crypto', 'dma', 'event', 'mempool', 'misc', 'net', 'regex']) bind_group = parser.add_mutually_exclusive_group() bind_group.add_argument(@@ -732,6 +736,7 @@ def do_arg_actions(): get_device_details(network_devices) get_device_details(baseband_devices) get_device_details(crypto_devices) + get_device_details(dma_devices) get_device_details(eventdev_devices) get_device_details(mempool_devices) get_device_details(compress_devices)@@ -754,6 +759,7 @@ def main(): get_device_details(network_devices) get_device_details(baseband_devices) get_device_details(crypto_devices) + get_device_details(dma_devices) get_device_details(eventdev_devices) get_device_details(mempool_devices) get_device_details(compress_devices)
PATCH v5 16/16 devbind: move idxd device ID to dmadev class
In reply to Kevin LaatzThe dmadev library is the preferred abstraction for using IDXD devices and will replace the rawdev implementation in future. This patch moves the IDXD device ID to the dmadev class.
--- usertools/dpdk-devbind.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
usertools/dpdk-devbind.py +2 -2
@@ -69,13 +69,13 @@ network_devices = [network_class, cavium_pkx, avp_vnic, ifpga_class] baseband_devices = [acceleration_class] crypto_devices = [encryption_class, intel_processor_class] -dma_devices = [] +dma_devices = [intel_idxd_spr] eventdev_devices = [cavium_sso, cavium_tim, intel_dlb, octeontx2_sso] mempool_devices = [cavium_fpa, octeontx2_npa] compress_devices = [cavium_zip] regex_devices = [octeontx2_ree] misc_devices = [cnxk_bphy, cnxk_bphy_cgx, intel_ioat_bdw, intel_ioat_skx, - intel_ioat_icx, intel_idxd_spr, intel_ntb_skx, intel_ntb_icx, + intel_ioat_icx, intel_ntb_skx, intel_ntb_icx, octeontx2_dma] # global dict ethernet devices present. Dictionary indexed by PCI address.
Signature · 1 line
2.30.2
Re: [dpdk-dev] [PATCH v5 16/16] devbind: move idxd device ID to dmadev class
Quoted 7 lines · Kevin Laatz
The dmadev library is the preferred abstraction for using IDXD devices and will replace the rawdev implementation in future. This patch moves the IDXD device ID to the dmadev class.
Signed-off-by Kevin Laatz <[email protected]>Reviewed-by Conor Walsh <[email protected]>---
v6 cover add dmadev driver for idxd devices
In reply to Kevin LaatzThis patchset adds a dmadev driver and associated documentation to support Intel Data Streaming Accelerator devices. This driver is intended to ultimately replace the current IDXD part of the IOAT rawdev driver.
NOTE: This patchset has several dependencies:
- v23 of the dmadev lib set [1]
- v6 of the dmadev test suite [2]
[1] http://patches.dpdk.org/project/dpdk/list/?series=19140
[2] http://patches.dpdk.org/project/dpdk/list/?series=19138
v6:
* set state of device during create
* add dev_close function
* documentation updates - moved generic pieces from driver doc to lib doc
* other small miscellaneous fixes based on rebasing and ML feedback
v5:
* add missing toctree entry for idxd driver
v4:
* rebased on above patchsets
* minor fixes based on review feedback
v3:
* rebased on above patchsets
* added burst capacity API
v2:
* rebased on above patchsets
* added API to check for device being idle
* added devbind updates for DMA devices
* fixed issue identified by internal coverity scan
Bruce Richardson (1):
raw/ioat: only build if dmadev not present
Conor Walsh (1):
dma/idxd: move dpdk_idxd_cfg.py from raw to dma
Kevin Laatz (14):
dma/idxd: add skeleton for VFIO based DSA device dma/idxd: add bus device probing
dma/idxd: create dmadev instances on bus probe dma/idxd: create dmadev instances on pci probe dma/idxd: add datapath structures
dma/idxd: add configure and info_get functions dma/idxd: add start and stop functions for pci devices dma/idxd: add data-path job submission functions dma/idxd: add data-path job completion functions dma/idxd: add operation statistic tracking dma/idxd: add vchan status function
dma/idxd: add burst capacity API
devbind: add dma device class
devbind: move idxd device ID to dmadev class
MAINTAINERS | 10 + doc/guides/dmadevs/idxd.rst | 183 ++++++++ doc/guides/dmadevs/index.rst | 2 + doc/guides/prog_guide/dmadev.rst | 34 ++ doc/guides/rawdevs/ioat.rst | 8 + doc/guides/rel_notes/release_21_11.rst | 5 + drivers/dma/idxd/dpdk_idxd_cfg.py | 117 +++++ drivers/dma/idxd/idxd_bus.c | 377 +++++++++++++++ drivers/dma/idxd/idxd_common.c | 610 +++++++++++++++++++++++++ drivers/dma/idxd/idxd_hw_defs.h | 131 ++++++ drivers/dma/idxd/idxd_internal.h | 108 +++++ drivers/dma/idxd/idxd_pci.c | 393 ++++++++++++++++ drivers/dma/idxd/meson.build | 14 + drivers/dma/idxd/version.map | 3 + drivers/dma/meson.build | 2 + drivers/meson.build | 4 +- drivers/raw/ioat/dpdk_idxd_cfg.py | 118 +---- drivers/raw/ioat/meson.build | 23 +- usertools/dpdk-devbind.py | 10 +- 19 files changed, 2028 insertions(+), 124 deletions(-) create mode 100644 doc/guides/dmadevs/idxd.rst create mode 100755 drivers/dma/idxd/dpdk_idxd_cfg.py create mode 100644 drivers/dma/idxd/idxd_bus.c create mode 100644 drivers/dma/idxd/idxd_common.c create mode 100644 drivers/dma/idxd/idxd_hw_defs.h create mode 100644 drivers/dma/idxd/idxd_internal.h create mode 100644 drivers/dma/idxd/idxd_pci.c create mode 100644 drivers/dma/idxd/meson.build create mode 100644 drivers/dma/idxd/version.map mode change 100755 => 120000 drivers/raw/ioat/dpdk_idxd_cfg.py
Signature · 1 line
2.30.2
PATCH v6 1/16 raw/ioat: only build if dmadev not present
From: Bruce Richardson <[email protected]>
Only build the rawdev IDXD/IOAT drivers if the dmadev drivers are not present.
This change requires the dependencies to be reordered in drivers/meson.build so that rawdev can use the "RTE_DMA_* build macros to check for the presence of the equivalent dmadev driver.
A note is also added to the documentation to inform users of this change.
---
v4:
- Fix build issue
- Add note in raw documentation to outline this change
v5:
- Provide more detail in commit message
- Minor doc changes
--- doc/guides/rawdevs/ioat.rst | 8 ++++++++ drivers/meson.build | 4 ++-- drivers/raw/ioat/meson.build | 23 ++++++++++++++++++++--- 3 files changed, 30 insertions(+), 5 deletions(-)
doc/guides/rawdevs/ioat.rst +8 -0
@@ -34,6 +34,14 @@ Compilation For builds using ``meson`` and ``ninja``, the driver will be built when the target platform is x86-based. No additional compilation steps are necessary. +.. note:: + Since the addition of the dmadev library, the ``ioat`` and ``idxd`` parts of this driver + will only be built if their ``dmadev`` counterparts are not built. + The following can be used to disable the ``dmadev`` drivers, + if the raw drivers are to be used instead:: + + $ meson -Ddisable_drivers=dma/* <build_dir> + Device Setup -------------
drivers/meson.build +2 -2
@@ -10,15 +10,15 @@ subdirs = [ 'common/qat', # depends on bus. 'common/sfc_efx', # depends on bus. 'mempool', # depends on common and bus. + 'dma', # depends on common and bus. 'net', # depends on common, bus, mempool - 'raw', # depends on common, bus and net. + 'raw', # depends on common, bus, dma and net. 'crypto', # depends on common, bus and mempool (net in future). 'compress', # depends on common, bus, mempool. 'regex', # depends on common, bus, regexdev. 'vdpa', # depends on common, bus and mempool. 'event', # depends on common, bus, mempool and net. 'baseband', # depends on common and bus. - 'dma', # depends on common and bus. ] if meson.is_cross_build()
drivers/raw/ioat/meson.build +20 -3
@@ -2,14 +2,31 @@ # Copyright 2019 Intel Corporation build = dpdk_conf.has('RTE_ARCH_X86') +# only use ioat rawdev driver if we don't have the equivalent dmadev ones +if dpdk_conf.has('RTE_DMA_IDXD') and dpdk_conf.has('RTE_DMA_IOAT') + build = false + subdir_done() +endif + reason = 'only supported on x86' sources = files( - 'idxd_bus.c', - 'idxd_pci.c', 'ioat_common.c', - 'ioat_rawdev.c', 'ioat_rawdev_test.c', ) + +if not dpdk_conf.has('RTE_DMA_IDXD') + sources += files( + 'idxd_bus.c', + 'idxd_pci.c', + ) +endif + +if not dpdk_conf.has('RTE_DMA_IOAT') + sources += files ( + 'ioat_rawdev.c', + ) +endif + deps += ['bus_pci', 'mbuf', 'rawdev'] headers = files( 'rte_ioat_rawdev.h',
Signature · 1 line
2.30.2
PATCH v6 2/16 dma/idxd: add skeleton for VFIO based DSA device
In reply to Kevin LaatzAdd the basic device probe/remove skeleton code for DSA device bound to the vfio pci driver. Relevant documentation and MAINTAINERS update also included.
---
v5: add missing toctree entry for idxd driver
v6: add missing new line at end of meson file
--- MAINTAINERS | 10 +++++ doc/guides/dmadevs/idxd.rst | 58 ++++++++++++++++++++++++++ doc/guides/dmadevs/index.rst | 2 + doc/guides/rel_notes/release_21_11.rst | 5 +++ drivers/dma/idxd/idxd_internal.h | 27 ++++++++++++ drivers/dma/idxd/idxd_pci.c | 55 ++++++++++++++++++++++++ drivers/dma/idxd/meson.build | 11 +++++ drivers/dma/idxd/version.map | 3 ++ drivers/dma/meson.build | 2 + 9 files changed, 173 insertions(+) create mode 100644 doc/guides/dmadevs/idxd.rst create mode 100644 drivers/dma/idxd/idxd_internal.h create mode 100644 drivers/dma/idxd/idxd_pci.c create mode 100644 drivers/dma/idxd/meson.build create mode 100644 drivers/dma/idxd/version.map
MAINTAINERS +10 -0
@@ -1200,6 +1200,16 @@ F: doc/guides/compressdevs/zlib.rst F: doc/guides/compressdevs/features/zlib.ini +DMAdev Drivers +-------------- + +Intel IDXD - EXPERIMENTAL +M: Bruce Richardson <[email protected]> +M: Kevin Laatz <[email protected]> +F: drivers/dma/idxd/ +F: doc/guides/dmadevs/idxd.rst + + RegEx Drivers -------------
doc/guides/dmadevs/idxd.rst new file +58 -0
58 lines not on this page · raw message
doc/guides/dmadevs/index.rst +2 -0
@@ -10,3 +10,5 @@ an application through DMA API. .. toctree:: :maxdepth: 2 :numbered: + + idxd
doc/guides/rel_notes/release_21_11.rst +5 -0
@@ -98,6 +98,11 @@ New Features * Data plane APIs. * Multi-process support. +* **Added IDXD dmadev driver implementation.** + + The IDXD dmadev driver provide device drivers for the Intel DSA devices. + This device driver can be used through the generic dmadev API. + Removed Items -------------
drivers/dma/idxd/idxd_internal.h new file +27 -0
@@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright 2021 Intel Corporation +*/ + +#ifndef _IDXD_INTERNAL_H_ +#define _IDXD_INTERNAL_H_ + +/** +* @file idxd_internal.h +* +* Internal data structures for the idxd/DSA driver for dmadev +* +* @warning +* @b EXPERIMENTAL: these structures and APIs may change without prior notice +*/ + +extern int idxd_pmd_logtype; + +#define IDXD_PMD_LOG(level, fmt, args...) rte_log(RTE_LOG_ ## level, \ + idxd_pmd_logtype, "IDXD: %s(): " fmt "\n", __func__, ##args) + +#define IDXD_PMD_DEBUG(fmt, args...) IDXD_PMD_LOG(DEBUG, fmt, ## args) +#define IDXD_PMD_INFO(fmt, args...) IDXD_PMD_LOG(INFO, fmt, ## args) +#define IDXD_PMD_ERR(fmt, args...) IDXD_PMD_LOG(ERR, fmt, ## args) +#define IDXD_PMD_WARN(fmt, args...) IDXD_PMD_LOG(WARNING, fmt, ## args) + +#endif /* _IDXD_INTERNAL_H_ */
drivers/dma/idxd/idxd_pci.c new file +55 -0
55 lines not on this page · raw message
drivers/dma/idxd/meson.build new file +11 -0
@@ -0,0 +1,11 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2021 Intel Corporation + +if is_windows + subdir_done() +endif + +deps += ['bus_pci'] +sources = files( + 'idxd_pci.c' +)
drivers/dma/idxd/version.map new file +3 -0
@@ -0,0 +1,3 @@ +DPDK_21 { + local: *; +};
drivers/dma/meson.build +2 -0
@@ -2,5 +2,7 @@ # Copyright 2021 HiSilicon Limited drivers = [ + 'idxd', 'skeleton', ] +std_deps = ['dmadev']
Signature · 1 line
2.30.2
PATCH v6 3/16 dma/idxd: add bus device probing
In reply to Kevin LaatzAdd the basic device probing for DSA devices bound to the IDXD kernel driver. These devices can be configured via sysfs and made available to DPDK if they are found during bus scan. Relevant documentation is included.
---
v4: fix 'vdev' naming, changed to 'bus'
--- doc/guides/dmadevs/idxd.rst | 64 +++++++ drivers/dma/idxd/idxd_bus.c | 351 +++++++++++++++++++++++++++++++++++ drivers/dma/idxd/meson.build | 1 + 3 files changed, 416 insertions(+) create mode 100644 drivers/dma/idxd/idxd_bus.c
doc/guides/dmadevs/idxd.rst +64 -0
@@ -32,6 +32,56 @@ target platform is x86-based. No additional compilation steps are necessary. Device Setup ------------- +Intel\ |reg| DSA devices can use the IDXD kernel driver or DPDK-supported drivers, +such as ``vfio-pci``. Both are supported by the IDXD PMD. + +Intel\ |reg| DSA devices using IDXD kernel driver +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +To use an Intel\ |reg| DSA device bound to the IDXD kernel driver, the device must first be configured. +The `accel-config <https://github.com/intel/idxd-config>`_ utility library can be used for configuration. + +.. note:: + The device configuration can also be done by directly interacting with the sysfs nodes. + An example of how this may be done can be seen in the script ``dpdk_idxd_cfg.py`` + included in the driver source directory. + +There are some mandatory configuration steps before being able to use a device with an application. +The internal engines, which do the copies or other operations, +and the work-queues, which are used by applications to assign work to the device, +need to be assigned to groups, and the various other configuration options, +such as priority or queue depth, need to be set for each queue. + +To assign an engine to a group:: + + $ accel-config config-engine dsa0/engine0.0 --group-id=0 + $ accel-config config-engine dsa0/engine0.1 --group-id=1 + +To assign work queues to groups for passing descriptors to the engines a similar accel-config command can be used. +However, the work queues also need to be configured depending on the use case. +Some configuration options include: + +* mode (Dedicated/Shared): Indicates whether a WQ may accept jobs from multiple queues simultaneously. +* priority: WQ priority between 1 and 15. Larger value means higher priority. +* wq-size: the size of the WQ. Sum of all WQ sizes must be less that the total-size defined by the device. +* type: WQ type (kernel/mdev/user). Determines how the device is presented. +* name: identifier given to the WQ. + +Example configuration for a work queue:: + + $ accel-config config-wq dsa0/wq0.0 --group-id=0 \ + --mode=dedicated --priority=10 --wq-size=8 \ + --type=user --name=dpdk_app1 + +Once the devices have been configured, they need to be enabled:: + + $ accel-config enable-device dsa0 + $ accel-config enable-wq dsa0/wq0.0 + +Check the device configuration:: + + $ accel-config list + Devices using VFIO/UIO drivers ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -56,3 +106,17 @@ If fewer workqueues are required, then the ``max_queues`` parameter may be passe the device driver on the EAL commandline, via the ``allowlist`` or ``-a`` flag e.g.:: $ dpdk-test -a <b:d:f>,max_queues=4 + +For devices bound to the IDXD kernel driver, +the DPDK IDXD driver will automatically perform a scan for available workqueues +to use. Any workqueues found listed in ``/dev/dsa`` on the system will be checked +in ``/sys``, and any which have ``dpdk_`` prefix in their name will be automatically +probed by the driver to make them available to the application. +Alternatively, to support use by multiple DPDK processes simultaneously, +the value used as the DPDK ``--file-prefix`` parameter may be used as a workqueue +name prefix, instead of ``dpdk_``, allowing each DPDK application instance to only +use a subset of configured queues. + +Once probed successfully, irrespective of kernel driver, the device will appear as a ``dmadev``, +that is a "DMA device type" inside DPDK, and can be accessed using APIs from the +``rte_dmadev`` library.
drivers/dma/idxd/idxd_bus.c new file +351 -0
351 lines not on this page · raw message
drivers/dma/idxd/meson.build +1 -0
@@ -7,5 +7,6 @@ endif deps += ['bus_pci'] sources = files( + 'idxd_bus.c', 'idxd_pci.c' )
Signature · 1 line
2.30.2
PATCH v6 4/16 dma/idxd: create dmadev instances on bus probe
In reply to Kevin LaatzWhen a suitable device is found during the bus scan/probe, create a dmadev instance for each HW queue. Internal structures required for device creation are also added.
---
v4:
- fix 'vdev' naming, changed to 'bus'
- rebase changes
v6:
- remove redundant struct initialization in create
- set device state to ready at end of create
--- drivers/dma/idxd/idxd_bus.c | 19 +++++++++ drivers/dma/idxd/idxd_common.c | 70 ++++++++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 40 ++++++++++++++++++ drivers/dma/idxd/meson.build | 1 + 4 files changed, 130 insertions(+) create mode 100644 drivers/dma/idxd/idxd_common.c
drivers/dma/idxd/idxd_bus.c +19 -0
@@ -85,6 +85,18 @@ dsa_get_sysfs_path(void)return path ? path :DSA_SYSFS_PATH ; } +static int +idxd_dev_close (struct rte_dma_dev *dev) +{ +struct idxd_dmadev *idxd = dev->data->dev_private; +munmap (idxd->portal,0x1000 ); +return 0 ; +} + +static const struct rte_dma_dev_ops idxd_bus_ops = { + .dev_close = idxd_dev_close, +}; +static void *idxd_bus_mmap_wq (struct rte_dsa_device *dev) {
@@ -206,6 +218,7 @@ idxd_probe_dsa(struct rte_dsa_device *dev)return -1 ; idxd.max_batch_size = ret; idxd.qid = dev->addr.wq_id; + idxd.u.bus.dsa_id = dev->addr.device_id; idxd.sva_support =1 ; idxd.portal =idxd_bus_mmap_wq (dev);
@@ -214,6 +227,12 @@ idxd_probe_dsa(struct rte_dsa_device *dev)return -ENOENT ; } + ret =idxd_dmadev_create (dev->wq_name, &dev->device, &idxd, &idxd_bus_ops); +if (ret) { +IDXD_PMD_ERR ("Failed to create rawdev %s" , dev->wq_name); +return ret; + } +return 0 ; }
drivers/dma/idxd/idxd_common.c new file +70 -0
70 lines not on this page · raw message
drivers/dma/idxd/idxd_internal.h +40 -0
@@ -24,4 +24,44 @@ extern int idxd_pmd_logtype; #define IDXD_PMD_ERR(fmt, args...) IDXD_PMD_LOG(ERR, fmt, ## args) #define IDXD_PMD_WARN(fmt, args...) IDXD_PMD_LOG(WARNING, fmt, ## args) +struct idxd_dmadev { +/* counters to track the batches */ +unsigned short max_batches; +unsigned short batch_idx_read; +unsigned short batch_idx_write; + +/* track descriptors and handles */ +unsigned short desc_ring_mask; +unsigned short ids_avail;/* handles for ops completed */ +unsigned short ids_returned;/* the read pointer for hdls/desc rings */ +unsigned short batch_start;/* start+size == write pointer for hdls/desc */ +unsigned short batch_size; + +void *portal;/* address to write the batch descriptor */ + +struct idxd_completion *batch_comp_ring; +unsigned short *batch_idx_ring;/* store where each batch ends */ + +struct rte_dma_stats stats; + +rte_iova_t batch_iova;/* base address of the batch comp ring */ +rte_iova_t desc_iova;/* base address of desc ring, needed for completions */ + +unsigned short max_batch_size; + +struct rte_dma_dev *dmadev; +struct rte_dma_vchan_conf qcfg; +uint8_t sva_support; +uint8_t qid; + +union { +struct { +unsigned int dsa_id; + } bus; + } u; +}; + +int idxd_dmadev_create (const char *name,struct rte_device *dev, +const struct idxd_dmadev *base_idxd,const struct rte_dma_dev_ops *ops); +#endif /* _IDXD_INTERNAL_H_ */
drivers/dma/idxd/meson.build +1 -0
@@ -8,5 +8,6 @@ endif deps += ['bus_pci'] sources = files( 'idxd_bus.c', + 'idxd_common.c', 'idxd_pci.c' )
Signature · 1 line
2.30.2
PATCH v6 5/16 dma/idxd: create dmadev instances on pci probe
In reply to Kevin LaatzWhen a suitable device is found during the PCI probe, create a dmadev instance for each HW queue. HW definitions required are also included.
---
v4: rebase changes
v6: add close function for device destroy and cleanup
--- drivers/dma/idxd/idxd_hw_defs.h | 71 ++++++++ drivers/dma/idxd/idxd_internal.h | 16 ++ drivers/dma/idxd/idxd_pci.c | 285 ++++++++++++++++++++++++++++++- 3 files changed, 369 insertions(+), 3 deletions(-) create mode 100644 drivers/dma/idxd/idxd_hw_defs.h
drivers/dma/idxd/idxd_hw_defs.h new file +71 -0
@@ -0,0 +1,71 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright 2021 Intel Corporation +*/ + +#ifndef _IDXD_HW_DEFS_H_ +#define _IDXD_HW_DEFS_H_ + +/*** Definitions for Intel(R) Data Streaming Accelerator ***/ + +#define IDXD_CMD_SHIFT 20 +enum rte_idxd_cmds { + idxd_enable_dev =1 , + idxd_disable_dev, + idxd_drain_all, + idxd_abort_all, + idxd_reset_device, + idxd_enable_wq, + idxd_disable_wq, + idxd_drain_wq, + idxd_abort_wq, + idxd_reset_wq, +}; + +/* General bar0 registers */ +struct rte_idxd_bar0 { + uint32_t __rte_cache_aligned version; /* offset 0x00 */ + uint64_t __rte_aligned(0x10) gencap; /* offset 0x10 */ + uint64_t __rte_aligned(0x10) wqcap; /* offset 0x20 */ + uint64_t __rte_aligned(0x10) grpcap; /* offset 0x30 */ + uint64_t __rte_aligned(0x08) engcap; /* offset 0x38 */ + uint64_t __rte_aligned(0x10) opcap; /* offset 0x40 */ + uint64_t __rte_aligned(0x20) offsets[2]; /* offset 0x60 */ + uint32_t __rte_aligned(0x20) gencfg; /* offset 0x80 */ + uint32_t __rte_aligned(0x08) genctrl; /* offset 0x88 */ + uint32_t __rte_aligned(0x10) gensts; /* offset 0x90 */ + uint32_t __rte_aligned(0x08) intcause; /* offset 0x98 */ + uint32_t __rte_aligned(0x10) cmd; /* offset 0xA0 */ + uint32_t __rte_aligned(0x08) cmdstatus; /* offset 0xA8 */ + uint64_t __rte_aligned(0x20) swerror[4]; /* offset 0xC0 */ +}; + +/* workqueue config is provided by array of uint32_t. */ +enum rte_idxd_wqcfg { + wq_size_idx,/* size is in first 32-bit value */ + wq_threshold_idx,/* WQ threshold second 32-bits */ + wq_mode_idx,/* WQ mode and other flags */ + wq_sizes_idx,/* WQ transfer and batch sizes */ + wq_occ_int_idx,/* WQ occupancy interrupt handle */ + wq_occ_limit_idx,/* WQ occupancy limit */ + wq_state_idx,/* WQ state and occupancy state */ +}; + +#define WQ_MODE_SHARED 0 +#define WQ_MODE_DEDICATED 1 +#define WQ_PRIORITY_SHIFT 4 +#define WQ_BATCH_SZ_SHIFT 5 +#define WQ_STATE_SHIFT 30 +#define WQ_STATE_MASK 0x3 + +struct rte_idxd_grpcfg { + uint64_t grpwqcfg[4] __rte_cache_aligned; /* 64-byte register set */ +uint64_t grpengcfg;/* offset 32 */ +uint32_t grpflags;/* offset 40 */ +}; + +#define GENSTS_DEV_STATE_MASK 0x03 +#define CMDSTATUS_ACTIVE_SHIFT 31 +#define CMDSTATUS_ACTIVE_MASK (1 << 31) +#define CMDSTATUS_ERR_MASK 0xFF + +#endif
drivers/dma/idxd/idxd_internal.h +16 -0
@@ -5,6 +5,10 @@#ifndef _IDXD_INTERNAL_H_#define _IDXD_INTERNAL_H_ +#include <rte_spinlock.h> + +#include "idxd_hw_defs.h" +/** * @file idxd_internal.h *
@@ -24,6 +28,16 @@ extern int idxd_pmd_logtype; #define IDXD_PMD_ERR(fmt, args...) IDXD_PMD_LOG(ERR, fmt, ## args) #define IDXD_PMD_WARN(fmt, args...) IDXD_PMD_LOG(WARNING, fmt, ## args) +struct idxd_pci_common { +rte_spinlock_t lk; + +uint8_t wq_cfg_sz; +volatile struct rte_idxd_bar0 *regs; +volatile uint32_t *wq_regs_base; +volatile struct rte_idxd_grpcfg *grp_regs; +volatile void *portals; +}; +struct idxd_dmadev {/* counters to track the batches */ unsigned short max_batches;
@@ -58,6 +72,8 @@ struct idxd_dmadev {struct {unsigned int dsa_id; } bus; + +struct idxd_pci_common *pci; } u; };
drivers/dma/idxd/idxd_pci.c +282 -3
312 lines not on this page · raw message
Signature · 1 line
2.30.2
PATCH v6 6/16 dma/idxd: add datapath structures
In reply to Kevin LaatzAdd data structures required for the data path for IDXD devices.
---
v2: add completion status for invalid opcode
--- drivers/dma/idxd/idxd_bus.c | 1 + drivers/dma/idxd/idxd_common.c | 33 ++++++++++++++++++ drivers/dma/idxd/idxd_hw_defs.h | 60 ++++++++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 3 ++ drivers/dma/idxd/idxd_pci.c | 1 + 5 files changed, 98 insertions(+)
drivers/dma/idxd/idxd_bus.c +1 -0
@@ -95,6 +95,7 @@ idxd_dev_close(struct rte_dma_dev *dev)static const struct rte_dma_dev_ops idxd_bus_ops = { .dev_close = idxd_dev_close, + .dev_dump = idxd_dump, }; static void *
drivers/dma/idxd/idxd_common.c +33 -0
@@ -10,6 +10,35 @@#define IDXD_PMD_NAME_STR "dmadev_idxd" +int +idxd_dump (const struct rte_dma_dev *dev,FILE *f) +{ +struct idxd_dmadev *idxd = dev->dev_private; +unsigned int i; + +fprintf (f,"== IDXD Private Data ==\n" ); +fprintf (f," Portal: %p\n" , idxd->portal); +fprintf (f," Config: { ring_size: %u }\n" , + idxd->qcfg.nb_desc); +fprintf (f," Batch ring (sz = %u, max_batches = %u):\n\t" , + idxd->max_batches +1 , idxd->max_batches); +for (i =0 ; i <= idxd->max_batches; i++) { +fprintf (f," %u " , idxd->batch_idx_ring[i]); +if (i == idxd->batch_idx_read && i == idxd->batch_idx_write) +fprintf (f,"[rd ptr, wr ptr] " ); +else if (i == idxd->batch_idx_read) +fprintf (f,"[rd ptr] " ); +else if (i == idxd->batch_idx_write) +fprintf (f,"[wr ptr] " ); +if (i == idxd->max_batches) +fprintf (f,"\n" ); + } + +fprintf (f," Curr batch: start = %u, size = %u\n" , idxd->batch_start, idxd->batch_size); +fprintf (f," IDS: avail = %u, returned: %u\n" , idxd->ids_avail, idxd->ids_returned); +return 0 ; +} + int idxd_dmadev_create(const char *name, struct rte_device *dev, const struct idxd_dmadev *base_idxd,
@@ -19,6 +48,10 @@ idxd_dmadev_create(const char *name, struct rte_device *dev,struct rte_dma_dev *dmadev =NULL ;int ret =0 ; +RTE_BUILD_BUG_ON (sizeof (struct idxd_hw_desc ) !=64 ); +RTE_BUILD_BUG_ON (offsetof(struct idxd_hw_desc , size) !=32 ); +RTE_BUILD_BUG_ON (sizeof (struct idxd_completion ) !=32 ); +if (!name) {IDXD_PMD_ERR ("Invalid name of the device!" ); ret = -EINVAL ;
drivers/dma/idxd/idxd_hw_defs.h +60 -0
66 lines not on this page · raw message
drivers/dma/idxd/idxd_internal.h +3 -0
@@ -39,6 +39,8 @@ struct idxd_pci_common { };struct idxd_dmadev { +struct idxd_hw_desc *desc_ring; +/* counters to track the batches */ unsigned short max_batches;unsigned short batch_idx_read;
@@ -79,5 +81,6 @@ struct idxd_dmadev {int idxd_dmadev_create (const char *name,struct rte_device *dev,const struct idxd_dmadev *base_idxd,const struct rte_dma_dev_ops *ops); +int idxd_dump (const struct rte_dma_dev *dev,FILE *f);#endif /* _IDXD_INTERNAL_H_ */
drivers/dma/idxd/idxd_pci.c +1 -0
@@ -83,6 +83,7 @@ idxd_pci_dev_close(struct rte_dma_dev *dev)static const struct rte_dma_dev_ops idxd_pci_ops = { .dev_close = idxd_pci_dev_close, + .dev_dump = idxd_dump, };/* each portal uses 4 x 4k pages */
Signature · 1 line
2.30.2