add dmadev driver for idxd devices
Subsystems (3)
PATCH v6 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.
Documentation is also updated to add device configuration usage info.
---
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
v6:
- update doc to reference library documentation to remove duplication
- remove nb_vchans from info_get() since the lib fills it
- add error handling capability flag to info_get
--- doc/guides/dmadevs/idxd.rst | 19 +++++++++ doc/guides/prog_guide/dmadev.rst | 4 ++ drivers/dma/idxd/idxd_bus.c | 3 ++ drivers/dma/idxd/idxd_common.c | 71 ++++++++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 6 +++ drivers/dma/idxd/idxd_pci.c | 3 ++ 6 files changed, 106 insertions(+)
doc/guides/dmadevs/idxd.rst +19 -0
@@ -120,3 +120,22 @@ 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. + +Device Configuration +~~~~~~~~~~~~~~~~~~~~~ + +Refer to the :ref:`Device Configuration <dmadev_device_configuration>` and +:ref:`Configuration of Virtual DMA Channels <dmadev_vchan_configuration>` sections +of the dmadev library documentation for details on device configuration API usage. + +IDXD configuration requirements: + +* ``ring_size`` must be a power of two, between 64 and 4096. +* Only one ``vchan`` is supported per device (work queue). +* IDXD devices do not support silent mode. +* The transfer direction must be set to ``RTE_DMA_DIR_MEM_TO_MEM`` to copy from memory to memory.
doc/guides/prog_guide/dmadev.rst +4 -0
@@ -63,6 +63,8 @@ identifiers: - A device name used to designate the DMA device in console messages, for administration or debugging purposes. +.. _dmadev_device_configuration: + Device Configuration ~~~~~~~~~~~~~~~~~~~~
@@ -79,6 +81,8 @@ for the DMA device for example the number of virtual DMA channels to set up, indication of whether to enable silent mode. +.. _dmadev_vchan_configuration: + Configuration of Virtual DMA Channels ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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 +71 -0
77 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
@@ -84,6 +84,9 @@ 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, + .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 v6 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.
---
v6: fix return values of start and stop functions
--- doc/guides/dmadevs/idxd.rst | 3 +++ drivers/dma/idxd/idxd_pci.c | 51 +++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+)
doc/guides/dmadevs/idxd.rst +3 -0
@@ -139,3 +139,6 @@ IDXD configuration requirements: * Only one ``vchan`` is supported per device (work queue). * IDXD devices do not support silent mode. * The transfer direction must be set to ``RTE_DMA_DIR_MEM_TO_MEM`` to copy from memory to memory. + +Once configured, the device can then be made ready for use by calling the +``rte_dma_start()`` API.
drivers/dma/idxd/idxd_pci.c +51 -0
63 lines not on this page · raw message
Signature · 1 line
2.30.2
PATCH v6 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.
Documentation updates are included for dmadev library and IDXD driver docs as appropriate.
---
v6:
- add references to dmadev lib docs for generic info
- fix return values in "__idxd_write_desc()"
--- doc/guides/dmadevs/idxd.rst | 9 ++ doc/guides/prog_guide/dmadev.rst | 19 +++++ drivers/dma/idxd/idxd_common.c | 136 +++++++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 5 ++ drivers/dma/idxd/meson.build | 1 + 5 files changed, 170 insertions(+)
doc/guides/dmadevs/idxd.rst +9 -0
@@ -142,3 +142,12 @@ IDXD configuration requirements: Once configured, the device can then be made ready for use by calling the ``rte_dma_start()`` API. + +Performing Data Copies +~~~~~~~~~~~~~~~~~~~~~~~ + +Refer to the :ref:`Enqueue / Dequeue APIs <dmadev_enqueue_dequeue>` section of the dmadev library +documentation for details on operation enqueue and submission API usage. + +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.
doc/guides/prog_guide/dmadev.rst +19 -0
@@ -108,6 +108,8 @@ can be used to get the device info and supported features. Silent mode is a special device capability which does not require the application to invoke dequeue APIs. +.. _dmadev_enqueue_dequeue: + Enqueue / Dequeue APIs ~~~~~~~~~~~~~~~~~~~~~~
@@ -121,6 +123,23 @@ The ``rte_dma_submit`` API is used to issue doorbell to hardware. Alternatively the ``RTE_DMA_OP_FLAG_SUBMIT`` flag can be passed to the enqueue APIs to also issue the doorbell to hardware. +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[DMA_BURST_SZ], *dsts[DMA_BURST_SZ]; + unsigned int i; + + for (i = 0; i < RTE_DIM(srcs); i++) { + if (rte_dma_copy(dev_id, vchan, rte_pktmbuf_iova(srcs), + rte_pktmbuf_iova(dsts), COPY_LEN, 0) < 0) { + PRINT_ERR("Error with rte_dma_copy for buffer %u\n", i); + return -1; + } + } + rte_dma_submit(dev_id, vchan); + There are two dequeue APIs ``rte_dma_completed`` and ``rte_dma_completed_status``, these are used to obtain the results of the enqueue requests. ``rte_dma_completed`` will return the number of successfully
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 v6 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
v6:
- update documentation to reduce duplication
--- doc/guides/dmadevs/idxd.rst | 32 ++++- drivers/dma/idxd/idxd_common.c | 235 +++++++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 5 + 3 files changed, 271 insertions(+), 1 deletion(-)
doc/guides/dmadevs/idxd.rst +31 -1
@@ -147,7 +147,37 @@ Performing Data Copies ~~~~~~~~~~~~~~~~~~~~~~~ Refer to the :ref:`Enqueue / Dequeue APIs <dmadev_enqueue_dequeue>` section of the dmadev library -documentation for details on operation enqueue and submission API usage. +documentation for details on operation enqueue, submission and completion API usage. 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. + +When gathering completions, ``rte_dma_completed()`` should be used, up until the point an error +occurs in an operation. 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); + }
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 v6 11/16 dma/idxd: add operation statistic tracking
In reply to Kevin LaatzAdd statistic tracking for DSA devices.
The dmadev library documentation is also updated to add a generic section for using the library's statistics APIs.
---
v6: move doc update to dmadev library doC
--- doc/guides/prog_guide/dmadev.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/prog_guide/dmadev.rst +11 -0
@@ -148,3 +148,14 @@ completed operations along with the status of each operation (filled into the ``status`` array passed by user). These two APIs can also return the last completed operation's ``ring_idx`` which could help user track operations within their own application-defined rings. + + +Querying Device Statistics +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The statistics from a dmadev device can be got via the statistics functions, +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
@@ -136,6 +136,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 v6 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,uint16_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
@@ -140,6 +140,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 v6 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).
---
v6: updates for burst capacity api moving to fastpath
--- drivers/dma/idxd/idxd_common.c | 21 +++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 1 + drivers/dma/idxd/idxd_pci.c | 1 + 3 files changed, 23 insertions(+)
drivers/dma/idxd/idxd_common.c +21 -0
@@ -468,6 +468,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)
@@ -553,6 +573,7 @@ idxd_dmadev_create(const char *name, struct rte_device *dev, dmadev->submit = idxd_submit; dmadev->completed = idxd_completed; dmadev->completed_status = idxd_completed_status; + dmadev->burst_capacity = idxd_burst_capacity; idxd = dmadev->dev_private; *idxd = *base_idxd;/* copy over the main fields already passed in */
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 +1 -0
@@ -254,6 +254,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 v6 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 v6 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.
---
v6: remove purely cosmetic change from patch
--- usertools/dpdk-devbind.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
usertools/dpdk-devbind.py +7 -1
@@ -69,6 +69,7 @@ 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]
@@ -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 v6 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,12 +69,12 @@ 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, +misc_devices = [cnxk_bphy, cnxk_bphy_cgx, intel_ioat_bdw, intel_ioat_skx, intel_ioat_icx, intel_ntb_skx, intel_ntb_icx, octeontx2_dma]
Signature · 1 line
2.30.2
v7 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:
- v26 of the dmadev lib set [1]
- v7 of the dmadev test suite [2]
[1] http://patches.dpdk.org/project/dpdk/list/?series=19594
[2] http://patches.dpdk.org/project/dpdk/list/?series=19599
v7:
* rebase on above patchsets
* add meson reason for rawdev build
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 | 179 ++++++++ doc/guides/dmadevs/index.rst | 2 + doc/guides/prog_guide/dmadev.rst | 30 ++ 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 | 612 +++++++++++++++++++++++++ drivers/dma/idxd/idxd_hw_defs.h | 131 ++++++ drivers/dma/idxd/idxd_internal.h | 108 +++++ drivers/dma/idxd/idxd_pci.c | 386 ++++++++++++++++ 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 | 24 +- usertools/dpdk-devbind.py | 10 +- 19 files changed, 2016 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 v7 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.
---
v7: add meson reason for not building rawdev
--- doc/guides/rawdevs/ioat.rst | 8 ++++++++ drivers/meson.build | 4 ++-- drivers/raw/ioat/meson.build | 24 +++++++++++++++++++++--- 3 files changed, 31 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 +21 -3
@@ -2,14 +2,32 @@ # 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 + reason = 'replaced by dmadev drivers' + 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 v7 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/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
@@ -80,6 +80,11 @@ New Features operations. * Added 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. + * **Updated af_packet ethdev driver.** * Default VLAN strip behavior was changed. VLAN tag won't be stripped
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 v7 02/16] dma/idxd: add skeleton for VFIO based DSA device
13/10/2021 18:30, Kevin Laatz:
Quoted 3 lines
Add the basic device probe/remove skeleton code for DSA device bound to the vfio pci driver. Relevant documentation and
MAINTAINERSupdate also included.
It seems there is a compilation issue with this patch:
undefined reference to `idxd_pmd_logtype'
Please check compilation per-patch.
Re: [dpdk-dev] [PATCH v7 02/16] dma/idxd: add skeleton for VFIO based DSA device
Quoted 9 lines · Thomas Monjalon
13/10/2021 18:30, Kevin Laatz:
Quoted 3 lines
Add the basic device probe/remove skeleton code for DSA device bound to the vfio pci driver. Relevant documentation and
MAINTAINERSupdate also included.It seems there is a compilation issue with this patch:
undefined reference to `idxd_pmd_logtype'Please check compilation per-patch.
I'll take a look and fix, thanks!
/Kevin
PATCH v7 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.
--- 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 v7 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.
--- drivers/dma/idxd/idxd_bus.c | 19 +++++++++ drivers/dma/idxd/idxd_common.c | 72 ++++++++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 40 ++++++++++++++++++ drivers/dma/idxd/meson.build | 1 + 4 files changed, 132 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 +72 -0
72 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 v7 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.
--- 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 v7 6/16 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 | 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->fp_obj->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
PATCH v7 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.
Documentation is also updated to add device configuration usage info.
---
v7: remove invalid doc references after rebase
--- doc/guides/dmadevs/idxd.rst | 15 +++++++ drivers/dma/idxd/idxd_bus.c | 3 ++ drivers/dma/idxd/idxd_common.c | 71 ++++++++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 6 +++ drivers/dma/idxd/idxd_pci.c | 3 ++ 5 files changed, 98 insertions(+)
doc/guides/dmadevs/idxd.rst +15 -0
@@ -120,3 +120,18 @@ 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. + +Device Configuration +~~~~~~~~~~~~~~~~~~~~~ + +IDXD configuration requirements: + +* ``ring_size`` must be a power of two, between 64 and 4096. +* Only one ``vchan`` is supported per device (work queue). +* IDXD devices do not support silent mode. +* The transfer direction must be set to ``RTE_DMA_DIR_MEM_TO_MEM`` to copy from memory to memory.
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 +71 -0
77 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
@@ -84,6 +84,9 @@ 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, + .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 v7 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 | 51 +++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+)
doc/guides/dmadevs/idxd.rst +3 -0
@@ -135,3 +135,6 @@ IDXD configuration requirements: * Only one ``vchan`` is supported per device (work queue). * IDXD devices do not support silent mode. * The transfer direction must be set to ``RTE_DMA_DIR_MEM_TO_MEM`` to copy from memory to memory. + +Once configured, the device can then be made ready for use by calling the +``rte_dma_start()`` API.
drivers/dma/idxd/idxd_pci.c +51 -0
63 lines not on this page · raw message
Signature · 1 line
2.30.2
PATCH v7 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.
Documentation updates are included for dmadev library and IDXD driver docs as appropriate.
--- doc/guides/dmadevs/idxd.rst | 9 ++ doc/guides/prog_guide/dmadev.rst | 19 +++++ drivers/dma/idxd/idxd_common.c | 137 +++++++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 5 ++ drivers/dma/idxd/meson.build | 1 + 5 files changed, 171 insertions(+)
doc/guides/dmadevs/idxd.rst +9 -0
@@ -138,3 +138,12 @@ IDXD configuration requirements: Once configured, the device can then be made ready for use by calling the ``rte_dma_start()`` API. + +Performing Data Copies +~~~~~~~~~~~~~~~~~~~~~~~ + +Refer to the :ref:`Enqueue / Dequeue APIs <dmadev_enqueue_dequeue>` section of the dmadev library +documentation for details on operation enqueue and submission API usage. + +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.
doc/guides/prog_guide/dmadev.rst +19 -0
@@ -67,6 +67,8 @@ can be used to get the device info and supported features. Silent mode is a special device capability which does not require the application to invoke dequeue APIs. +.. _dmadev_enqueue_dequeue: + Enqueue / Dequeue APIs ~~~~~~~~~~~~~~~~~~~~~~
@@ -80,6 +82,23 @@ The ``rte_dma_submit`` API is used to issue doorbell to hardware. Alternatively the ``RTE_DMA_OP_FLAG_SUBMIT`` flag can be passed to the enqueue APIs to also issue the doorbell to hardware. +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[DMA_BURST_SZ], *dsts[DMA_BURST_SZ]; + unsigned int i; + + for (i = 0; i < RTE_DIM(srcs); i++) { + if (rte_dma_copy(dev_id, vchan, rte_pktmbuf_iova(srcs), + rte_pktmbuf_iova(dsts), COPY_LEN, 0) < 0) { + PRINT_ERR("Error with rte_dma_copy for buffer %u\n", i); + return -1; + } + } + rte_dma_submit(dev_id, vchan); + There are two dequeue APIs ``rte_dma_completed`` and ``rte_dma_completed_status``, these are used to obtain the results of the enqueue requests. ``rte_dma_completed`` will return the number of successfully
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_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 (void *dev_private,uint16_t qid,rte_iova_t src, +rte_iova_t dst,unsigned int length,uint64_t flags); +int idxd_enqueue_fill (void *dev_private,uint16_t qid,uint64_t pattern, +rte_iova_t dst,unsigned int length,uint64_t flags); +int idxd_submit (void *dev_private,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 v7 10/16 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 | 32 ++++- drivers/dma/idxd/idxd_common.c | 234 +++++++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 5 + 3 files changed, 270 insertions(+), 1 deletion(-)
doc/guides/dmadevs/idxd.rst +31 -1
@@ -143,7 +143,37 @@ Performing Data Copies ~~~~~~~~~~~~~~~~~~~~~~~ Refer to the :ref:`Enqueue / Dequeue APIs <dmadev_enqueue_dequeue>` section of the dmadev library -documentation for details on operation enqueue and submission API usage. +documentation for details on operation enqueue, submission and completion API usage. 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. + +When gathering completions, ``rte_dma_completed()`` should be used, up until the point an error +occurs in an operation. 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); + }
drivers/dma/idxd/idxd_common.c +234 -0
240 lines not on this page · raw message
drivers/dma/idxd/idxd_internal.h +5 -0
@@ -93,5 +93,10 @@ int idxd_enqueue_copy(void *dev_private, uint16_t qid, rte_iova_t src,int idxd_enqueue_fill (void *dev_private,uint16_t qid,uint64_t pattern,rte_iova_t dst,unsigned int length,uint64_t flags);int idxd_submit (void *dev_private,uint16_t qid); +uint16_t idxd_completed (void *dev_private,uint16_t qid,uint16_t max_ops, +uint16_t *last_idx,bool *has_error); +uint16_t idxd_completed_status(void *dev_private, 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 v7 11/16 dma/idxd: add operation statistic tracking
In reply to Kevin LaatzAdd statistic tracking for DSA devices.
The dmadev library documentation is also updated to add a generic section for using the library's statistics APIs.
--- doc/guides/prog_guide/dmadev.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/prog_guide/dmadev.rst +11 -0
@@ -107,3 +107,14 @@ completed operations along with the status of each operation (filled into the ``status`` array passed by user). These two APIs can also return the last completed operation's ``ring_idx`` which could help user track operations within their own application-defined rings. + + +Querying Device Statistics +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The statistics from a dmadev device can be got via the statistics functions, +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;
@@ -276,6 +278,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;
@@ -297,6 +301,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;
@@ -355,6 +361,7 @@ idxd_completed(void *dev_private, uint16_t qid __rte_unused, uint16_t max_ops, 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(void *dev_private, uint16_t qid __rte_unused, uint16_t max 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->fp_obj->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->fp_obj->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(void *dev_private, uint16_t qid, uint16_t max_ops, uint16_t idxd_completed_status(void *dev_private, 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
@@ -136,6 +136,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 v7 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.
--- 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
@@ -163,6 +163,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->fp_obj->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,uint16_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(void *dev_private, uint16_t qid __rte_unused,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); +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
@@ -140,6 +140,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 v7 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_common.c | 21 +++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 1 + drivers/dma/idxd/idxd_pci.c | 1 + 3 files changed, 23 insertions(+)
drivers/dma/idxd/idxd_common.c +21 -0
@@ -468,6 +468,26 @@ idxd_info_get(const struct rte_dma_dev *dev, struct rte_dma_info *info, uint32_treturn 0 ; } +uint16_t +idxd_burst_capacity(const void *dev_private, uint16_t vchan __rte_unused) +{ +const struct idxd_dmadev *idxd = 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)
@@ -553,6 +573,7 @@ idxd_dmadev_create(const char *name, struct rte_device *dev, dmadev->fp_obj->submit = idxd_submit; dmadev->fp_obj->completed = idxd_completed; dmadev->fp_obj->completed_status = idxd_completed_status; + dmadev->fp_obj->burst_capacity = idxd_burst_capacity; idxd = dmadev->data->dev_private; *idxd = *base_idxd;/* copy over the main fields already passed in */
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 void *dev_private,uint16_t vchan);#endif /* _IDXD_INTERNAL_H_ */
drivers/dma/idxd/idxd_pci.c +1 -0
@@ -254,6 +254,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 v7 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 v7 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 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
usertools/dpdk-devbind.py +7 -1
@@ -71,6 +71,7 @@ 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]
@@ -585,6 +586,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")
@@ -653,7 +657,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(
@@ -734,6 +738,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)
@@ -756,6 +761,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 v7 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
@@ -71,13 +71,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, cnxk_inl_dev, intel_ioat_bdw, - intel_ioat_skx, intel_ioat_icx, intel_idxd_spr, intel_ntb_skx, + intel_ioat_skx, 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
v8 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.
v8:
* fix compilation issues of individual patches
v7:
* rebase on above patchsets
* add meson reason for rawdev build
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 | 179 ++++++++ doc/guides/dmadevs/index.rst | 2 + doc/guides/prog_guide/dmadev.rst | 30 ++ 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 | 612 +++++++++++++++++++++++++ drivers/dma/idxd/idxd_hw_defs.h | 131 ++++++ drivers/dma/idxd/idxd_internal.h | 109 +++++ drivers/dma/idxd/idxd_pci.c | 368 +++++++++++++++ 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 | 24 +- lib/dmadev/rte_dmadev.h | 1 + usertools/dpdk-devbind.py | 10 +- 20 files changed, 2000 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 v8 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.
--- doc/guides/rawdevs/ioat.rst | 8 ++++++++ drivers/meson.build | 4 ++-- drivers/raw/ioat/meson.build | 24 +++++++++++++++++++++--- 3 files changed, 31 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 +21 -3
@@ -2,14 +2,32 @@ # 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 + reason = 'replaced by dmadev drivers' + 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 v8 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.
---
v8: fix compile issue
--- 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_common.c | 11 +++++ drivers/dma/idxd/idxd_internal.h | 27 ++++++++++++ drivers/dma/idxd/idxd_pci.c | 55 ++++++++++++++++++++++++ drivers/dma/idxd/meson.build | 12 ++++++ drivers/dma/idxd/version.map | 3 ++ drivers/dma/meson.build | 2 + 10 files changed, 185 insertions(+) create mode 100644 doc/guides/dmadevs/idxd.rst create mode 100644 drivers/dma/idxd/idxd_common.c 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
@@ -75,6 +75,11 @@ New Features operations. * Added 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. + * **Added new RSS offload types for IPv4/L4 checksum in RSS flow.** Added macros ETH_RSS_IPV4_CHKSUM and ETH_RSS_L4_CHKSUM, now IPv4 and
drivers/dma/idxd/idxd_common.c new file +11 -0
@@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright 2021 Intel Corporation +*/ + +#include <rte_log.h> + +#include "idxd_internal.h" + +int idxd_pmd_logtype; + +RTE_LOG_REGISTER_DEFAULT (idxd_pmd_logtype,WARNING );
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 +12 -0
@@ -0,0 +1,12 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2021 Intel Corporation + +if is_windows + subdir_done() +endif + +deps += ['bus_pci'] +sources = files( + 'idxd_common.c', + '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 v8 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.
--- doc/guides/dmadevs/idxd.rst | 64 ++++++ drivers/dma/idxd/idxd_bus.c | 351 +++++++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 34 +++ drivers/dma/idxd/meson.build | 1 + lib/dmadev/rte_dmadev.h | 1 + 5 files changed, 451 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/idxd_internal.h +34 -0
@@ -24,4 +24,38 @@ 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 */ + +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; +uint8_t sva_support; +uint8_t qid; + +union { +struct { +unsigned int dsa_id; + } bus; + } u; +}; +#endif /* _IDXD_INTERNAL_H_ */
drivers/dma/idxd/meson.build +1 -0
@@ -7,6 +7,7 @@ endif deps += ['bus_pci'] sources = files( + 'idxd_bus.c', 'idxd_common.c', 'idxd_pci.c' )
lib/dmadev/rte_dmadev.h +1 -0
@@ -149,6 +149,7 @@#include <rte_bitops.h> #include <rte_common.h> #include <rte_compat.h> +#include <rte_eal.h> #include <rte_dev.h> #ifdef __cplusplus
Signature · 1 line
2.30.2
PATCH v8 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.
--- drivers/dma/idxd/idxd_bus.c | 19 ++++++++++ drivers/dma/idxd/idxd_common.c | 61 ++++++++++++++++++++++++++++++++ drivers/dma/idxd/idxd_hw_defs.h | 27 ++++++++++++++ drivers/dma/idxd/idxd_internal.h | 7 ++++ 4 files changed, 114 insertions(+) create mode 100644 drivers/dma/idxd/idxd_hw_defs.h
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 +61 -0
71 lines not on this page · raw message
drivers/dma/idxd/idxd_hw_defs.h new file +27 -0
@@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright 2021 Intel Corporation +*/ + +#ifndef _IDXD_HW_DEFS_H_ +#define _IDXD_HW_DEFS_H_ + +#define IDXD_COMP_STATUS_INCOMPLETE 0 +#define IDXD_COMP_STATUS_SUCCESS 1 +#define IDXD_COMP_STATUS_INVALID_OPCODE 0x10 +#define IDXD_COMP_STATUS_INVALID_SIZE 0x13 +#define IDXD_COMP_STATUS_SKIPPED 0xFF/* not official IDXD error, needed as placeholder */ + +/** +* Completion record structure written back by DSA +*/ +struct idxd_completion { +uint8_t status; +uint8_t result; +/* 16-bits pad here */ +uint32_t completed_size;/* data length, or descriptors for batch */ + +rte_iova_t fault_address; +uint32_t invalid_flags; +} __rte_aligned(32); + +#endif
drivers/dma/idxd/idxd_internal.h +7 -0
@@ -5,6 +5,10 @@#ifndef _IDXD_INTERNAL_H_#define _IDXD_INTERNAL_H_ +#include <rte_dmadev_pmd.h> + +#include "idxd_hw_defs.h" +/** * @file idxd_internal.h *
@@ -58,4 +62,7 @@ struct idxd_dmadev { } 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_ */
Signature · 1 line
2.30.2
PATCH v8 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.
--- drivers/dma/idxd/idxd_hw_defs.h | 63 ++++++++ drivers/dma/idxd/idxd_internal.h | 13 ++ drivers/dma/idxd/idxd_pci.c | 259 ++++++++++++++++++++++++++++++- 3 files changed, 332 insertions(+), 3 deletions(-)
drivers/dma/idxd/idxd_hw_defs.h +63 -0
@@ -24,4 +24,67 @@ struct idxd_completion {uint32_t invalid_flags; } __rte_aligned(32); +/*** 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 +13 -0
@@ -6,6 +6,7 @@#define _IDXD_INTERNAL_H_#include <rte_dmadev_pmd.h> +#include <rte_spinlock.h> #include "idxd_hw_defs.h"
@@ -28,6 +29,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;
@@ -59,6 +70,8 @@ struct idxd_dmadev {struct {unsigned int dsa_id; } bus; + +struct idxd_pci_common *pci; } u; };
drivers/dma/idxd/idxd_pci.c +256 -3
286 lines not on this page · raw message
Signature · 1 line
2.30.2
PATCH v8 6/16 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 | 41 ++++++++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 4 ++++ drivers/dma/idxd/idxd_pci.c | 2 ++ 5 files changed, 81 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->fp_obj->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 +41 -0
47 lines not on this page · raw message
drivers/dma/idxd/idxd_internal.h +4 -0
@@ -40,6 +40,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;
@@ -63,6 +65,7 @@ struct idxd_dmadev {unsigned short max_batch_size;struct rte_dma_dev *dmadev; +struct rte_dma_vchan_conf qcfg;uint8_t sva_support;uint8_t qid;
@@ -77,5 +80,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 +2 -0
@@ -76,12 +76,14 @@ idxd_pci_dev_close(struct rte_dma_dev *dev)/* free device memory */ IDXD_PMD_DEBUG ("Freeing device driver memory" );rte_free (idxd->batch_idx_ring); +rte_free (idxd->desc_ring);return 0 ; }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
PATCH v8 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.
Documentation is also updated to add device configuration usage info.
--- doc/guides/dmadevs/idxd.rst | 15 +++++++ drivers/dma/idxd/idxd_bus.c | 3 ++ drivers/dma/idxd/idxd_common.c | 71 ++++++++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 6 +++ drivers/dma/idxd/idxd_pci.c | 3 ++ 5 files changed, 98 insertions(+)
doc/guides/dmadevs/idxd.rst +15 -0
@@ -120,3 +120,18 @@ 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. + +Device Configuration +~~~~~~~~~~~~~~~~~~~~~ + +IDXD configuration requirements: + +* ``ring_size`` must be a power of two, between 64 and 4096. +* Only one ``vchan`` is supported per device (work queue). +* IDXD devices do not support silent mode. +* The transfer direction must be set to ``RTE_DMA_DIR_MEM_TO_MEM`` to copy from memory to memory.
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 +71 -0
77 lines not on this page · raw message
drivers/dma/idxd/idxd_internal.h +6 -0
@@ -81,5 +81,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
@@ -84,6 +84,9 @@ 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, + .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 v8 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 | 51 +++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+)
doc/guides/dmadevs/idxd.rst +3 -0
@@ -135,3 +135,6 @@ IDXD configuration requirements: * Only one ``vchan`` is supported per device (work queue). * IDXD devices do not support silent mode. * The transfer direction must be set to ``RTE_DMA_DIR_MEM_TO_MEM`` to copy from memory to memory. + +Once configured, the device can then be made ready for use by calling the +``rte_dma_start()`` API.
drivers/dma/idxd/idxd_pci.c +51 -0
63 lines not on this page · raw message
Signature · 1 line
2.30.2
PATCH v8 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.
Documentation updates are included for dmadev library and IDXD driver docs as appropriate.
--- doc/guides/dmadevs/idxd.rst | 9 +++ doc/guides/prog_guide/dmadev.rst | 19 +++++ drivers/dma/idxd/idxd_common.c | 135 +++++++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 5 ++ drivers/dma/idxd/meson.build | 1 + 5 files changed, 169 insertions(+)
doc/guides/dmadevs/idxd.rst +9 -0
@@ -138,3 +138,12 @@ IDXD configuration requirements: Once configured, the device can then be made ready for use by calling the ``rte_dma_start()`` API. + +Performing Data Copies +~~~~~~~~~~~~~~~~~~~~~~~ + +Refer to the :ref:`Enqueue / Dequeue APIs <dmadev_enqueue_dequeue>` section of the dmadev library +documentation for details on operation enqueue and submission API usage. + +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.
doc/guides/prog_guide/dmadev.rst +19 -0
@@ -67,6 +67,8 @@ can be used to get the device info and supported features. Silent mode is a special device capability which does not require the application to invoke dequeue APIs. +.. _dmadev_enqueue_dequeue: + Enqueue / Dequeue APIs ~~~~~~~~~~~~~~~~~~~~~~
@@ -80,6 +82,23 @@ The ``rte_dma_submit`` API is used to issue doorbell to hardware. Alternatively the ``RTE_DMA_OP_FLAG_SUBMIT`` flag can be passed to the enqueue APIs to also issue the doorbell to hardware. +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[DMA_BURST_SZ], *dsts[DMA_BURST_SZ]; + unsigned int i; + + for (i = 0; i < RTE_DIM(srcs); i++) { + if (rte_dma_copy(dev_id, vchan, rte_pktmbuf_iova(srcs), + rte_pktmbuf_iova(dsts), COPY_LEN, 0) < 0) { + PRINT_ERR("Error with rte_dma_copy for buffer %u\n", i); + return -1; + } + } + rte_dma_submit(dev_id, vchan); + There are two dequeue APIs ``rte_dma_completed`` and ``rte_dma_completed_status``, these are used to obtain the results of the enqueue requests. ``rte_dma_completed`` will return the number of successfully
drivers/dma/idxd/idxd_common.c +135 -0
155 lines not on this page · raw message
drivers/dma/idxd/idxd_internal.h +5 -0
@@ -87,5 +87,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 (void *dev_private,uint16_t qid,rte_iova_t src, +rte_iova_t dst,unsigned int length,uint64_t flags); +int idxd_enqueue_fill (void *dev_private,uint16_t qid,uint64_t pattern, +rte_iova_t dst,unsigned int length,uint64_t flags); +int idxd_submit (void *dev_private,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 v8 09/16] dma/idxd: add data-path job submission functions
18/10/2021 14:28, Kevin Laatz:
drivers/dma/idxd/meson.build if is_windows · line 9
Quoted 3 lines
drivers/dma/idxd/meson.build +1
-0+cflags += '-mavx2' # all platforms with idxd HW support AVX
It would work only if the driver was disabled on non-x86 targets. For now it produces:
aarch64-linux-gnu-gcc: error: unrecognized command-line option '-mavx2'
PATCH v8 10/16 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 | 32 ++++- drivers/dma/idxd/idxd_common.c | 236 +++++++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 5 + 3 files changed, 272 insertions(+), 1 deletion(-)
doc/guides/dmadevs/idxd.rst +31 -1
@@ -143,7 +143,37 @@ Performing Data Copies ~~~~~~~~~~~~~~~~~~~~~~~ Refer to the :ref:`Enqueue / Dequeue APIs <dmadev_enqueue_dequeue>` section of the dmadev library -documentation for details on operation enqueue and submission API usage. +documentation for details on operation enqueue, submission and completion API usage. 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. + +When gathering completions, ``rte_dma_completed()`` should be used, up until the point an error +occurs in an operation. 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); + }
drivers/dma/idxd/idxd_common.c +236 -0
248 lines not on this page · raw message
drivers/dma/idxd/idxd_internal.h +5 -0
@@ -92,5 +92,10 @@ int idxd_enqueue_copy(void *dev_private, uint16_t qid, rte_iova_t src,int idxd_enqueue_fill (void *dev_private,uint16_t qid,uint64_t pattern,rte_iova_t dst,unsigned int length,uint64_t flags);int idxd_submit (void *dev_private,uint16_t qid); +uint16_t idxd_completed (void *dev_private,uint16_t qid,uint16_t max_ops, +uint16_t *last_idx,bool *has_error); +uint16_t idxd_completed_status(void *dev_private, 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 v8 11/16 dma/idxd: add operation statistic tracking
In reply to Kevin LaatzAdd statistic tracking for DSA devices.
The dmadev library documentation is also updated to add a generic section for using the library's statistics APIs.
--- doc/guides/prog_guide/dmadev.rst | 11 +++++++++++ drivers/dma/idxd/idxd_bus.c | 2 ++ drivers/dma/idxd/idxd_common.c | 27 +++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 5 +++++ drivers/dma/idxd/idxd_pci.c | 2 ++ 5 files changed, 47 insertions(+)
doc/guides/prog_guide/dmadev.rst +11 -0
@@ -107,3 +107,14 @@ completed operations along with the status of each operation (filled into the ``status`` array passed by user). These two APIs can also return the last completed operation's ``ring_idx`` which could help user track operations within their own application-defined rings. + + +Querying Device Statistics +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The statistics from a dmadev device can be got via the statistics functions, +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;
@@ -276,6 +278,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;
@@ -297,6 +301,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;
@@ -355,6 +361,7 @@ idxd_completed(void *dev_private, uint16_t qid __rte_unused, uint16_t max_ops, 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(void *dev_private, uint16_t qid __rte_unused, uint16_t max 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->fp_obj->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->fp_obj->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 +5 -0
@@ -59,6 +59,8 @@ struct idxd_dmadev {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 */
@@ -97,5 +99,8 @@ uint16_t idxd_completed(void *dev_private, uint16_t qid, uint16_t max_ops, uint16_t idxd_completed_status(void *dev_private, 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
@@ -136,6 +136,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 v8 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.
--- 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
@@ -163,6 +163,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->fp_obj->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,uint16_t max_ops,enum rte_dma_status_code *status) {
drivers/dma/idxd/idxd_internal.h +2 -0
@@ -102,5 +102,7 @@ uint16_t idxd_completed_status(void *dev_private, uint16_t qid __rte_unused,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); +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
@@ -140,6 +140,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 v8 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_common.c | 21 +++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 1 + drivers/dma/idxd/idxd_pci.c | 1 + 3 files changed, 23 insertions(+)
drivers/dma/idxd/idxd_common.c +21 -0
@@ -468,6 +468,26 @@ idxd_info_get(const struct rte_dma_dev *dev, struct rte_dma_info *info, uint32_treturn 0 ; } +uint16_t +idxd_burst_capacity(const void *dev_private, uint16_t vchan __rte_unused) +{ +const struct idxd_dmadev *idxd = 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)
@@ -553,6 +573,7 @@ idxd_dmadev_create(const char *name, struct rte_device *dev, dmadev->fp_obj->submit = idxd_submit; dmadev->fp_obj->completed = idxd_completed; dmadev->fp_obj->completed_status = idxd_completed_status; + dmadev->fp_obj->burst_capacity = idxd_burst_capacity; idxd = dmadev->data->dev_private; *idxd = *base_idxd;/* copy over the main fields already passed in */
drivers/dma/idxd/idxd_internal.h +1 -0
@@ -104,5 +104,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 void *dev_private,uint16_t vchan);#endif /* _IDXD_INTERNAL_H_ */
drivers/dma/idxd/idxd_pci.c +1 -0
@@ -254,6 +254,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 v8 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 v8 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 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
usertools/dpdk-devbind.py +7 -1
@@ -71,6 +71,7 @@ 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]
@@ -585,6 +586,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")
@@ -653,7 +657,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(
@@ -734,6 +738,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)
@@ -756,6 +761,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 v8 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
@@ -71,13 +71,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, cnxk_inl_dev, intel_ioat_bdw, - intel_ioat_skx, intel_ioat_icx, intel_idxd_spr, intel_ntb_skx, + intel_ioat_skx, 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
v9 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.
v9:
* add missing meson check for x86
v8:
* fix compilation issues of individual patches
v7:
* rebase on above patchsets
* add meson reason for rawdev build
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 | 179 ++++++++ doc/guides/dmadevs/index.rst | 2 + doc/guides/prog_guide/dmadev.rst | 30 ++ 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 | 612 +++++++++++++++++++++++++ drivers/dma/idxd/idxd_hw_defs.h | 131 ++++++ drivers/dma/idxd/idxd_internal.h | 109 +++++ drivers/dma/idxd/idxd_pci.c | 368 +++++++++++++++ drivers/dma/idxd/meson.build | 17 + 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 | 24 +- lib/dmadev/rte_dmadev.h | 1 + usertools/dpdk-devbind.py | 10 +- 20 files changed, 2003 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 v9 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.
--- doc/guides/rawdevs/ioat.rst | 8 ++++++++ drivers/meson.build | 4 ++-- drivers/raw/ioat/meson.build | 24 +++++++++++++++++++++--- 3 files changed, 31 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 +21 -3
@@ -2,14 +2,32 @@ # 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 + reason = 'replaced by dmadev drivers' + 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 v9 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.
---
v8: fix compile issue
v9: add meson check for x86
--- 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_common.c | 11 +++++ drivers/dma/idxd/idxd_internal.h | 27 ++++++++++++ drivers/dma/idxd/idxd_pci.c | 55 ++++++++++++++++++++++++ drivers/dma/idxd/meson.build | 15 +++++++ drivers/dma/idxd/version.map | 3 ++ drivers/dma/meson.build | 2 + 10 files changed, 188 insertions(+) create mode 100644 doc/guides/dmadevs/idxd.rst create mode 100644 drivers/dma/idxd/idxd_common.c 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
@@ -75,6 +75,11 @@ New Features operations. * Added 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. + * **Added new RSS offload types for IPv4/L4 checksum in RSS flow.** Added macros ETH_RSS_IPV4_CHKSUM and ETH_RSS_L4_CHKSUM, now IPv4 and
drivers/dma/idxd/idxd_common.c new file +11 -0
@@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright 2021 Intel Corporation +*/ + +#include <rte_log.h> + +#include "idxd_internal.h" + +int idxd_pmd_logtype; + +RTE_LOG_REGISTER_DEFAULT (idxd_pmd_logtype,WARNING );
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 +15 -0
@@ -0,0 +1,15 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2021 Intel Corporation + +build = dpdk_conf.has('RTE_ARCH_X86') +reason = 'only supported on x86' + +if is_windows + subdir_done() +endif + +deps += ['bus_pci'] +sources = files( + 'idxd_common.c', + '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 v9 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.
--- doc/guides/dmadevs/idxd.rst | 64 ++++++ drivers/dma/idxd/idxd_bus.c | 351 +++++++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 34 +++ drivers/dma/idxd/meson.build | 1 + lib/dmadev/rte_dmadev.h | 1 + 5 files changed, 451 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/idxd_internal.h +34 -0
@@ -24,4 +24,38 @@ 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 */ + +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; +uint8_t sva_support; +uint8_t qid; + +union { +struct { +unsigned int dsa_id; + } bus; + } u; +}; +#endif /* _IDXD_INTERNAL_H_ */
drivers/dma/idxd/meson.build +1 -0
@@ -10,6 +10,7 @@ endif deps += ['bus_pci'] sources = files( + 'idxd_bus.c', 'idxd_common.c', 'idxd_pci.c' )
lib/dmadev/rte_dmadev.h +1 -0
@@ -149,6 +149,7 @@#include <rte_bitops.h> #include <rte_common.h> #include <rte_compat.h> +#include <rte_eal.h> #include <rte_dev.h> #ifdef __cplusplus
Signature · 1 line
2.30.2
PATCH v9 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.
--- drivers/dma/idxd/idxd_bus.c | 19 ++++++++++ drivers/dma/idxd/idxd_common.c | 61 ++++++++++++++++++++++++++++++++ drivers/dma/idxd/idxd_hw_defs.h | 27 ++++++++++++++ drivers/dma/idxd/idxd_internal.h | 7 ++++ 4 files changed, 114 insertions(+) create mode 100644 drivers/dma/idxd/idxd_hw_defs.h
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 +61 -0
71 lines not on this page · raw message
drivers/dma/idxd/idxd_hw_defs.h new file +27 -0
@@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright 2021 Intel Corporation +*/ + +#ifndef _IDXD_HW_DEFS_H_ +#define _IDXD_HW_DEFS_H_ + +#define IDXD_COMP_STATUS_INCOMPLETE 0 +#define IDXD_COMP_STATUS_SUCCESS 1 +#define IDXD_COMP_STATUS_INVALID_OPCODE 0x10 +#define IDXD_COMP_STATUS_INVALID_SIZE 0x13 +#define IDXD_COMP_STATUS_SKIPPED 0xFF/* not official IDXD error, needed as placeholder */ + +/** +* Completion record structure written back by DSA +*/ +struct idxd_completion { +uint8_t status; +uint8_t result; +/* 16-bits pad here */ +uint32_t completed_size;/* data length, or descriptors for batch */ + +rte_iova_t fault_address; +uint32_t invalid_flags; +} __rte_aligned(32); + +#endif
drivers/dma/idxd/idxd_internal.h +7 -0
@@ -5,6 +5,10 @@#ifndef _IDXD_INTERNAL_H_#define _IDXD_INTERNAL_H_ +#include <rte_dmadev_pmd.h> + +#include "idxd_hw_defs.h" +/** * @file idxd_internal.h *
@@ -58,4 +62,7 @@ struct idxd_dmadev { } 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_ */
Signature · 1 line
2.30.2
PATCH v9 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.
--- drivers/dma/idxd/idxd_hw_defs.h | 63 ++++++++ drivers/dma/idxd/idxd_internal.h | 13 ++ drivers/dma/idxd/idxd_pci.c | 259 ++++++++++++++++++++++++++++++- 3 files changed, 332 insertions(+), 3 deletions(-)
drivers/dma/idxd/idxd_hw_defs.h +63 -0
@@ -24,4 +24,67 @@ struct idxd_completion {uint32_t invalid_flags; } __rte_aligned(32); +/*** 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 +13 -0
@@ -6,6 +6,7 @@#define _IDXD_INTERNAL_H_#include <rte_dmadev_pmd.h> +#include <rte_spinlock.h> #include "idxd_hw_defs.h"
@@ -28,6 +29,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;
@@ -59,6 +70,8 @@ struct idxd_dmadev {struct {unsigned int dsa_id; } bus; + +struct idxd_pci_common *pci; } u; };
drivers/dma/idxd/idxd_pci.c +256 -3
286 lines not on this page · raw message
Signature · 1 line
2.30.2
PATCH v9 6/16 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 | 41 ++++++++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 4 ++++ drivers/dma/idxd/idxd_pci.c | 2 ++ 5 files changed, 81 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->fp_obj->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 +41 -0
47 lines not on this page · raw message
drivers/dma/idxd/idxd_internal.h +4 -0
@@ -40,6 +40,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;
@@ -63,6 +65,7 @@ struct idxd_dmadev {unsigned short max_batch_size;struct rte_dma_dev *dmadev; +struct rte_dma_vchan_conf qcfg;uint8_t sva_support;uint8_t qid;
@@ -77,5 +80,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 +2 -0
@@ -76,12 +76,14 @@ idxd_pci_dev_close(struct rte_dma_dev *dev)/* free device memory */ IDXD_PMD_DEBUG ("Freeing device driver memory" );rte_free (idxd->batch_idx_ring); +rte_free (idxd->desc_ring);return 0 ; }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
PATCH v9 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.
Documentation is also updated to add device configuration usage info.
--- doc/guides/dmadevs/idxd.rst | 15 +++++++ drivers/dma/idxd/idxd_bus.c | 3 ++ drivers/dma/idxd/idxd_common.c | 71 ++++++++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 6 +++ drivers/dma/idxd/idxd_pci.c | 3 ++ 5 files changed, 98 insertions(+)
doc/guides/dmadevs/idxd.rst +15 -0
@@ -120,3 +120,18 @@ 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. + +Device Configuration +~~~~~~~~~~~~~~~~~~~~~ + +IDXD configuration requirements: + +* ``ring_size`` must be a power of two, between 64 and 4096. +* Only one ``vchan`` is supported per device (work queue). +* IDXD devices do not support silent mode. +* The transfer direction must be set to ``RTE_DMA_DIR_MEM_TO_MEM`` to copy from memory to memory.
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 +71 -0
77 lines not on this page · raw message
drivers/dma/idxd/idxd_internal.h +6 -0
@@ -81,5 +81,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
@@ -84,6 +84,9 @@ 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, + .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 v9 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 | 51 +++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+)
doc/guides/dmadevs/idxd.rst +3 -0
@@ -135,3 +135,6 @@ IDXD configuration requirements: * Only one ``vchan`` is supported per device (work queue). * IDXD devices do not support silent mode. * The transfer direction must be set to ``RTE_DMA_DIR_MEM_TO_MEM`` to copy from memory to memory. + +Once configured, the device can then be made ready for use by calling the +``rte_dma_start()`` API.
drivers/dma/idxd/idxd_pci.c +51 -0
63 lines not on this page · raw message
Signature · 1 line
2.30.2
PATCH v9 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.
Documentation updates are included for dmadev library and IDXD driver docs as appropriate.
--- doc/guides/dmadevs/idxd.rst | 9 +++ doc/guides/prog_guide/dmadev.rst | 19 +++++ drivers/dma/idxd/idxd_common.c | 135 +++++++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 5 ++ drivers/dma/idxd/meson.build | 1 + 5 files changed, 169 insertions(+)
doc/guides/dmadevs/idxd.rst +9 -0
@@ -138,3 +138,12 @@ IDXD configuration requirements: Once configured, the device can then be made ready for use by calling the ``rte_dma_start()`` API. + +Performing Data Copies +~~~~~~~~~~~~~~~~~~~~~~~ + +Refer to the :ref:`Enqueue / Dequeue APIs <dmadev_enqueue_dequeue>` section of the dmadev library +documentation for details on operation enqueue and submission API usage. + +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.
doc/guides/prog_guide/dmadev.rst +19 -0
@@ -67,6 +67,8 @@ can be used to get the device info and supported features. Silent mode is a special device capability which does not require the application to invoke dequeue APIs. +.. _dmadev_enqueue_dequeue: + Enqueue / Dequeue APIs ~~~~~~~~~~~~~~~~~~~~~~
@@ -80,6 +82,23 @@ The ``rte_dma_submit`` API is used to issue doorbell to hardware. Alternatively the ``RTE_DMA_OP_FLAG_SUBMIT`` flag can be passed to the enqueue APIs to also issue the doorbell to hardware. +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[DMA_BURST_SZ], *dsts[DMA_BURST_SZ]; + unsigned int i; + + for (i = 0; i < RTE_DIM(srcs); i++) { + if (rte_dma_copy(dev_id, vchan, rte_pktmbuf_iova(srcs), + rte_pktmbuf_iova(dsts), COPY_LEN, 0) < 0) { + PRINT_ERR("Error with rte_dma_copy for buffer %u\n", i); + return -1; + } + } + rte_dma_submit(dev_id, vchan); + There are two dequeue APIs ``rte_dma_completed`` and ``rte_dma_completed_status``, these are used to obtain the results of the enqueue requests. ``rte_dma_completed`` will return the number of successfully
drivers/dma/idxd/idxd_common.c +135 -0
155 lines not on this page · raw message
drivers/dma/idxd/idxd_internal.h +5 -0
@@ -87,5 +87,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 (void *dev_private,uint16_t qid,rte_iova_t src, +rte_iova_t dst,unsigned int length,uint64_t flags); +int idxd_enqueue_fill (void *dev_private,uint16_t qid,uint64_t pattern, +rte_iova_t dst,unsigned int length,uint64_t flags); +int idxd_submit (void *dev_private,uint16_t qid);#endif /* _IDXD_INTERNAL_H_ */
drivers/dma/idxd/meson.build +1 -0
@@ -9,6 +9,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 v9 10/16 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 | 32 ++++- drivers/dma/idxd/idxd_common.c | 236 +++++++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 5 + 3 files changed, 272 insertions(+), 1 deletion(-)
doc/guides/dmadevs/idxd.rst +31 -1
@@ -143,7 +143,37 @@ Performing Data Copies ~~~~~~~~~~~~~~~~~~~~~~~ Refer to the :ref:`Enqueue / Dequeue APIs <dmadev_enqueue_dequeue>` section of the dmadev library -documentation for details on operation enqueue and submission API usage. +documentation for details on operation enqueue, submission and completion API usage. 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. + +When gathering completions, ``rte_dma_completed()`` should be used, up until the point an error +occurs in an operation. 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); + }
drivers/dma/idxd/idxd_common.c +236 -0
248 lines not on this page · raw message
drivers/dma/idxd/idxd_internal.h +5 -0
@@ -92,5 +92,10 @@ int idxd_enqueue_copy(void *dev_private, uint16_t qid, rte_iova_t src,int idxd_enqueue_fill (void *dev_private,uint16_t qid,uint64_t pattern,rte_iova_t dst,unsigned int length,uint64_t flags);int idxd_submit (void *dev_private,uint16_t qid); +uint16_t idxd_completed (void *dev_private,uint16_t qid,uint16_t max_ops, +uint16_t *last_idx,bool *has_error); +uint16_t idxd_completed_status(void *dev_private, 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 v9 11/16 dma/idxd: add operation statistic tracking
In reply to Kevin LaatzAdd statistic tracking for DSA devices.
The dmadev library documentation is also updated to add a generic section for using the library's statistics APIs.
--- doc/guides/prog_guide/dmadev.rst | 11 +++++++++++ drivers/dma/idxd/idxd_bus.c | 2 ++ drivers/dma/idxd/idxd_common.c | 27 +++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 5 +++++ drivers/dma/idxd/idxd_pci.c | 2 ++ 5 files changed, 47 insertions(+)
doc/guides/prog_guide/dmadev.rst +11 -0
@@ -107,3 +107,14 @@ completed operations along with the status of each operation (filled into the ``status`` array passed by user). These two APIs can also return the last completed operation's ``ring_idx`` which could help user track operations within their own application-defined rings. + + +Querying Device Statistics +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The statistics from a dmadev device can be got via the statistics functions, +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;
@@ -276,6 +278,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;
@@ -297,6 +301,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;
@@ -355,6 +361,7 @@ idxd_completed(void *dev_private, uint16_t qid __rte_unused, uint16_t max_ops, 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(void *dev_private, uint16_t qid __rte_unused, uint16_t max 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->fp_obj->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->fp_obj->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 +5 -0
@@ -59,6 +59,8 @@ struct idxd_dmadev {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 */
@@ -97,5 +99,8 @@ uint16_t idxd_completed(void *dev_private, uint16_t qid, uint16_t max_ops, uint16_t idxd_completed_status(void *dev_private, 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
@@ -136,6 +136,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 v9 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.
--- 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
@@ -163,6 +163,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->fp_obj->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,uint16_t max_ops,enum rte_dma_status_code *status) {
drivers/dma/idxd/idxd_internal.h +2 -0
@@ -102,5 +102,7 @@ uint16_t idxd_completed_status(void *dev_private, uint16_t qid __rte_unused,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); +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
@@ -140,6 +140,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 v9 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_common.c | 21 +++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 1 + drivers/dma/idxd/idxd_pci.c | 1 + 3 files changed, 23 insertions(+)
drivers/dma/idxd/idxd_common.c +21 -0
@@ -468,6 +468,26 @@ idxd_info_get(const struct rte_dma_dev *dev, struct rte_dma_info *info, uint32_treturn 0 ; } +uint16_t +idxd_burst_capacity(const void *dev_private, uint16_t vchan __rte_unused) +{ +const struct idxd_dmadev *idxd = 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)
@@ -553,6 +573,7 @@ idxd_dmadev_create(const char *name, struct rte_device *dev, dmadev->fp_obj->submit = idxd_submit; dmadev->fp_obj->completed = idxd_completed; dmadev->fp_obj->completed_status = idxd_completed_status; + dmadev->fp_obj->burst_capacity = idxd_burst_capacity; idxd = dmadev->data->dev_private; *idxd = *base_idxd;/* copy over the main fields already passed in */
drivers/dma/idxd/idxd_internal.h +1 -0
@@ -104,5 +104,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 void *dev_private,uint16_t vchan);#endif /* _IDXD_INTERNAL_H_ */
drivers/dma/idxd/idxd_pci.c +1 -0
@@ -254,6 +254,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 v9 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 v9 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 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
usertools/dpdk-devbind.py +7 -1
@@ -71,6 +71,7 @@ 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]
@@ -585,6 +586,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")
@@ -653,7 +657,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(
@@ -734,6 +738,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)
@@ -756,6 +761,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 v9 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
@@ -71,13 +71,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, cnxk_inl_dev, intel_ioat_bdw, - intel_ioat_skx, intel_ioat_icx, intel_idxd_spr, intel_ntb_skx, + intel_ioat_skx, 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
v10 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.
v10:
* meson fix to ensure Windows and BSD builds compile
v9:
* add missing meson check for x86
v8:
* fix compilation issues of individual patches
v7:
* rebase on above patchsets
* add meson reason for rawdev build
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 | 179 ++++++++ doc/guides/dmadevs/index.rst | 2 + doc/guides/prog_guide/dmadev.rst | 30 ++ 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 | 612 +++++++++++++++++++++++++ drivers/dma/idxd/idxd_hw_defs.h | 131 ++++++ drivers/dma/idxd/idxd_internal.h | 109 +++++ drivers/dma/idxd/idxd_pci.c | 368 +++++++++++++++ drivers/dma/idxd/meson.build | 16 + 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 | 24 +- lib/dmadev/rte_dmadev.h | 1 + usertools/dpdk-devbind.py | 10 +- 20 files changed, 2002 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 v10 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.
--- doc/guides/rawdevs/ioat.rst | 8 ++++++++ drivers/meson.build | 4 ++-- drivers/raw/ioat/meson.build | 24 +++++++++++++++++++++--- 3 files changed, 31 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 +21 -3
@@ -2,14 +2,32 @@ # 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 + reason = 'replaced by dmadev drivers' + 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 v10 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.
---
v8: fix compile issue
v9: add meson check for x86
--- 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_common.c | 11 +++++ 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 + 10 files changed, 184 insertions(+) create mode 100644 doc/guides/dmadevs/idxd.rst create mode 100644 drivers/dma/idxd/idxd_common.c 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
@@ -75,6 +75,11 @@ New Features operations. * Added 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. + * **Added new RSS offload types for IPv4/L4 checksum in RSS flow.** Added macros ETH_RSS_IPV4_CHKSUM and ETH_RSS_L4_CHKSUM, now IPv4 and
drivers/dma/idxd/idxd_common.c new file +11 -0
@@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright 2021 Intel Corporation +*/ + +#include <rte_log.h> + +#include "idxd_internal.h" + +int idxd_pmd_logtype; + +RTE_LOG_REGISTER_DEFAULT (idxd_pmd_logtype,WARNING );
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 + +build = dpdk_conf.has('RTE_ARCH_X86') +reason = 'only supported on x86' + +deps += ['bus_pci'] +sources = files( + 'idxd_common.c', + '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 v10 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.
--- doc/guides/dmadevs/idxd.rst | 64 ++++++ drivers/dma/idxd/idxd_bus.c | 351 +++++++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 34 +++ drivers/dma/idxd/meson.build | 4 + lib/dmadev/rte_dmadev.h | 1 + 5 files changed, 454 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/idxd_internal.h +34 -0
@@ -24,4 +24,38 @@ 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 */ + +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; +uint8_t sva_support; +uint8_t qid; + +union { +struct { +unsigned int dsa_id; + } bus; + } u; +}; +#endif /* _IDXD_INTERNAL_H_ */
drivers/dma/idxd/meson.build +4 -0
@@ -9,3 +9,7 @@ sources = files( 'idxd_common.c', 'idxd_pci.c' ) + +if is_linux + sources += files('idxd_bus.c') +endif
lib/dmadev/rte_dmadev.h +1 -0
@@ -149,6 +149,7 @@#include <rte_bitops.h> #include <rte_common.h> #include <rte_compat.h> +#include <rte_eal.h> #include <rte_dev.h> #ifdef __cplusplus
Signature · 1 line
2.30.2
Re: [dpdk-dev] [PATCH v10 03/16] dma/idxd: add bus device probing
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.
[snip]
lib/dmadev/rte_dmadev.h line 152
Quoted 9 lines
lib/dmadev/rte_dmadev.h +1
-0@@ -149,6 +149,7 @@#include <rte_bitops.h> #include <rte_common.h> #include <rte_compat.h> +#include <rte_eal.h>
Why add rte_eal.h to rte_dmadev.h, just use rte_eal_get_runtime_dir() ? Suggest add rte_eal.h in the PMD's C files.
Quoted 4 lines
lib/dmadev/rte_dmadev.h +0
-0#include <rte_dev.h> #ifdef __cplusplus
PATCH v10 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.
--- drivers/dma/idxd/idxd_bus.c | 19 ++++++++++ drivers/dma/idxd/idxd_common.c | 61 ++++++++++++++++++++++++++++++++ drivers/dma/idxd/idxd_hw_defs.h | 27 ++++++++++++++ drivers/dma/idxd/idxd_internal.h | 7 ++++ 4 files changed, 114 insertions(+) create mode 100644 drivers/dma/idxd/idxd_hw_defs.h
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 +61 -0
71 lines not on this page · raw message
drivers/dma/idxd/idxd_hw_defs.h new file +27 -0
@@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright 2021 Intel Corporation +*/ + +#ifndef _IDXD_HW_DEFS_H_ +#define _IDXD_HW_DEFS_H_ + +#define IDXD_COMP_STATUS_INCOMPLETE 0 +#define IDXD_COMP_STATUS_SUCCESS 1 +#define IDXD_COMP_STATUS_INVALID_OPCODE 0x10 +#define IDXD_COMP_STATUS_INVALID_SIZE 0x13 +#define IDXD_COMP_STATUS_SKIPPED 0xFF/* not official IDXD error, needed as placeholder */ + +/** +* Completion record structure written back by DSA +*/ +struct idxd_completion { +uint8_t status; +uint8_t result; +/* 16-bits pad here */ +uint32_t completed_size;/* data length, or descriptors for batch */ + +rte_iova_t fault_address; +uint32_t invalid_flags; +} __rte_aligned(32); + +#endif
drivers/dma/idxd/idxd_internal.h +7 -0
@@ -5,6 +5,10 @@#ifndef _IDXD_INTERNAL_H_#define _IDXD_INTERNAL_H_ +#include <rte_dmadev_pmd.h> + +#include "idxd_hw_defs.h" +/** * @file idxd_internal.h *
@@ -58,4 +62,7 @@ struct idxd_dmadev { } 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_ */
Signature · 1 line
2.30.2
Re: [dpdk-dev] [PATCH v10 04/16] dma/idxd: create dmadev instances on bus probe
Quoted 4 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.
[snip]
Quoted 12 lines
static void *
idxd_bus_mmap_wq(struct rte_dsa_device *dev)
{drivers/dma/idxd/idxd_bus.c +1
-0@@ -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);
drivers/dma/idxd/idxd_bus.c idxd_probe_dsa(struct rte_dsa_device *dev) · line 232
Quoted 6 lines
drivers/dma/idxd/idxd_bus.c +3
-0@@ -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);
rawdev -> dmadev
Quoted 31 lines
drivers/dma/idxd/idxd_bus.c +3
-0+return ret; + } +return 0 ; }drivers/dma/idxd/idxd_common.c +13
-0@@ -2,10 +2,71 @@* Copyright 2021 Intel Corporation */ +#include <rte_malloc.h> +#include <rte_common.h> #include <rte_log.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 =NULL ; +struct rte_dma_dev *dmadev =NULL ; +int ret =0 ; +
drivers/dma/idxd/idxd_common.c line 31
Quoted 10 lines
drivers/dma/idxd/idxd_common.c +10
-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 (struct idxd_dmadev )); +if (dmadev ==NULL ) { +IDXD_PMD_ERR ("Unable to allocate raw device" );
raw -> dma
Better check the 'raw' keyword in the patch set.
Quoted 7 lines
drivers/dma/idxd/idxd_common.c +7
-0+ ret = -ENOMEM ; + goto cleanup; + } + dmadev->dev_ops = ops; + dmadev->device = dev; + + idxd = dmadev->data->dev_private;
drivers/dma/idxd/idxd_common.c line 48
Quoted 10 lines
drivers/dma/idxd/idxd_common.c +10
-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 ]) + +sizeof (idxd->batch_comp_ring[0 ])) * (idxd->max_batches +1 ), +sizeof (idxd->batch_comp_ring[0 ]));
infer the batch_comp_ring will access by hardware, maybe better use rte_zmalloc_socket() because rte_zmalloc will use rte_socket_id() and it may at diff socket when call.
Quoted 4 lines
drivers/dma/idxd/idxd_common.c +3
-0+if (idxd->batch_comp_ring ==NULL ) { +IDXD_PMD_ERR ("Unable to reserve memory for batch data\n" ); + ret = -ENOMEM ;
[snip]
PATCH v10 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.
--- drivers/dma/idxd/idxd_hw_defs.h | 63 ++++++++ drivers/dma/idxd/idxd_internal.h | 13 ++ drivers/dma/idxd/idxd_pci.c | 259 ++++++++++++++++++++++++++++++- 3 files changed, 332 insertions(+), 3 deletions(-)
drivers/dma/idxd/idxd_hw_defs.h +63 -0
@@ -24,4 +24,67 @@ struct idxd_completion {uint32_t invalid_flags; } __rte_aligned(32); +/*** 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 +13 -0
@@ -6,6 +6,7 @@#define _IDXD_INTERNAL_H_#include <rte_dmadev_pmd.h> +#include <rte_spinlock.h> #include "idxd_hw_defs.h"
@@ -28,6 +29,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;
@@ -59,6 +70,8 @@ struct idxd_dmadev {struct {unsigned int dsa_id; } bus; + +struct idxd_pci_common *pci; } u; };
drivers/dma/idxd/idxd_pci.c +256 -3
286 lines not on this page · raw message
Signature · 1 line
2.30.2
Re: [dpdk-dev] [PATCH v10 05/16] dma/idxd: create dmadev instances on pci probe
Quoted 7 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]>---
[snip]
Quoted 12 lines
drivers/dma/idxd/idxd_pci.c +11
-0+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;
drivers/dma/idxd/idxd_pci.c const struct rte_pci_id pci_id_idxd_map[] = { · line 42
Quoted 10 lines
drivers/dma/idxd/idxd_pci.c +10
-0+ +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 );
why not while (err_code & CMDSTATUS_ACTIVE_MASK) ?
the cmdstatus reg may change in load to err_code and while judge, so suggest always use err_code.
Quoted 151 lines
drivers/dma/idxd/idxd_pci.c +151
-0+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 int +idxd_pci_dev_close (struct rte_dma_dev *dev) +{ +struct idxd_dmadev *idxd = dev->fp_obj->dev_private; +uint8_t err_code; + +/* 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" ); + +/* free device memory */ +IDXD_PMD_DEBUG ("Freeing device driver memory" ); +rte_free (idxd->batch_idx_ring); + +return 0 ; +} + +static const struct rte_dma_dev_ops idxd_pci_ops = { + .dev_close = idxd_pci_dev_close, +}; + +/* 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);
drivers/dma/idxd/idxd_pci.c const struct rte_pci_id pci_id_idxd_map[] = { · line 203
Quoted 10 lines
drivers/dma/idxd/idxd_pci.c +10
-0+ } + + 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;
1. the err_code come from idxd->u.pci->regs->cmdstatus which may >0, I think it better use negative explicit.
2. suggest use goto err which also free pci memory.
Quoted 32 lines
drivers/dma/idxd/idxd_pci.c +21
-2+ } +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 ;
drivers/dma/idxd/idxd_pci.c const struct rte_pci_id pci_id_idxd_map[] = { · line 243
Quoted 10 lines
drivers/dma/idxd/idxd_pci.c +10
-0+ } + } + + 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" );
need free idxd.u.pci's memory.
Quoted 43 lines
drivers/dma/idxd/idxd_pci.c +39
-0+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; + +/* 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
drivers/dma/idxd/idxd_pci.c idxd_dmadev_remove_pci(struct rte_pci_device *dev) · line 295
Quoted 5 lines
drivers/dma/idxd/idxd_pci.c +1
-1@@ -39,7 +292,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);
The name should be 'snprintf(qname, sizeof(qname), "%s-q%d", name, qid)', and also free auxiliary memory like idxd.u.pci
Quoted 4 lines
drivers/dma/idxd/idxd_pci.c +0
-0}struct rte_pci_driver idxd_pmd_drv_pci = {
PATCH v10 6/16 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 | 41 ++++++++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 4 ++++ drivers/dma/idxd/idxd_pci.c | 2 ++ 5 files changed, 81 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->fp_obj->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 +41 -0
47 lines not on this page · raw message
drivers/dma/idxd/idxd_internal.h +4 -0
@@ -40,6 +40,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;
@@ -63,6 +65,7 @@ struct idxd_dmadev {unsigned short max_batch_size;struct rte_dma_dev *dmadev; +struct rte_dma_vchan_conf qcfg;uint8_t sva_support;uint8_t qid;
@@ -77,5 +80,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 +2 -0
@@ -76,12 +76,14 @@ idxd_pci_dev_close(struct rte_dma_dev *dev)/* free device memory */ IDXD_PMD_DEBUG ("Freeing device driver memory" );rte_free (idxd->batch_idx_ring); +rte_free (idxd->desc_ring);return 0 ; }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
Re: [dpdk-dev] [PATCH v10 06/16] dma/idxd: add datapath structures
Quoted 12 lines · Kevin Laatz
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]>Reviewed-by Conor Walsh <[email protected]>--- drivers/dma/idxd/idxd_bus.c | 1 + drivers/dma/idxd/idxd_common.c | 33 +++++++++++++++++++++++++ drivers/dma/idxd/idxd_hw_defs.h | 41 ++++++++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 4 ++++ drivers/dma/idxd/idxd_pci.c | 2 ++ 5 files changed, 81 insertions(+)
[snip]
Quoted 12 lines
drivers/dma/idxd/idxd_hw_defs.h +12
-0+/** +* Hardware descriptor used by DSA hardware, for both bursts and +* for individual operations. +*/ +struct idxd_hw_desc { + uint32_t pasid; + uint32_t op_flags; + rte_iova_t completion; + + RTE_STD_C11 + union { + rte_iova_t src; /* source address for copy ops etc. */
drivers/dma/idxd/idxd_hw_defs.h line 46
Quoted 10 lines
drivers/dma/idxd/idxd_hw_defs.h +10
-0+rte_iova_t desc_addr;/* descriptor pointer for batch */ + }; +rte_iova_t dst; + +uint32_t size;/* length of data for op, or batch size */ + +uint16_t intr_handle;/* completion interrupt handle */ + +/* remaining 26 bytes are reserved */ +uint16_t __reserved[13 ];
The non-reserved take about 30+B, and the struct align 64, so the __reserved[13] could delete.
It's a minor problem, so:
Quoted 11 lines
drivers/dma/idxd/idxd_hw_defs.h +2
-0+}__rte_aligned (64 ); +#define IDXD_COMP_STATUS_INCOMPLETE 0#define IDXD_COMP_STATUS_SUCCESS 1#define IDXD_COMP_STATUS_INVALID_OPCODE 0x10drivers/dma/idxd/idxd_internal.h +0
-0@@ -40,6 +40,8 @@ struct idxd_pci_common { };
[snip]
Re: [dpdk-dev] [PATCH v10 06/16] dma/idxd: add datapath structures
Quoted 41 lines · fengchengwen
Quoted 12 lines · Kevin Laatz
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]>Reviewed-by Conor Walsh <[email protected]>--- drivers/dma/idxd/idxd_bus.c | 1 + drivers/dma/idxd/idxd_common.c | 33 +++++++++++++++++++++++++ drivers/dma/idxd/idxd_hw_defs.h | 41 ++++++++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 4 ++++ drivers/dma/idxd/idxd_pci.c | 2 ++ 5 files changed, 81 insertions(+)[snip]
Quoted 12 lines
drivers/dma/idxd/idxd_hw_defs.h +12
-0+/** +* Hardware descriptor used by DSA hardware, for both bursts and +* for individual operations. +*/ +struct idxd_hw_desc { + uint32_t pasid; + uint32_t op_flags; + rte_iova_t completion; + + RTE_STD_C11 + union { + rte_iova_t src; /* source address for copy ops etc. */drivers/dma/idxd/idxd_hw_defs.h line 46
Quoted 10 lines
drivers/dma/idxd/idxd_hw_defs.h +10
-0+rte_iova_t desc_addr;/* descriptor pointer for batch */ + }; +rte_iova_t dst; + +uint32_t size;/* length of data for op, or batch size */ + +uint16_t intr_handle;/* completion interrupt handle */ + +/* remaining 26 bytes are reserved */ +uint16_t __reserved[13 ];The non-reserved take about 30+B, and the struct align 64, so the __reserved[13] could delete.
Quoted 3 lines
It's a minor problem, so:
Reviewed-by Chengwen Feng <[email protected]>
There are actually cases where that reserved field makes a difference. If we go to initialize a descriptor as a local variable the compiler is required to initialize all unspecified fields to 0, which means that if we don't explicitly put in place those reserved fields those bytes will be uninitialized. Since the hardware requires all unused fields to be zero, we need to keep this field in place to simplify the code and save us having to do extra memsets to zero the unused space.
PATCH v10 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.
Documentation is also updated to add device configuration usage info.
--- doc/guides/dmadevs/idxd.rst | 15 +++++++ drivers/dma/idxd/idxd_bus.c | 3 ++ drivers/dma/idxd/idxd_common.c | 71 ++++++++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 6 +++ drivers/dma/idxd/idxd_pci.c | 3 ++ 5 files changed, 98 insertions(+)
doc/guides/dmadevs/idxd.rst +15 -0
@@ -120,3 +120,18 @@ 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. + +Device Configuration +~~~~~~~~~~~~~~~~~~~~~ + +IDXD configuration requirements: + +* ``ring_size`` must be a power of two, between 64 and 4096. +* Only one ``vchan`` is supported per device (work queue). +* IDXD devices do not support silent mode. +* The transfer direction must be set to ``RTE_DMA_DIR_MEM_TO_MEM`` to copy from memory to memory.
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 +71 -0
77 lines not on this page · raw message
drivers/dma/idxd/idxd_internal.h +6 -0
@@ -81,5 +81,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
@@ -84,6 +84,9 @@ 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, + .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 v10 07/16] dma/idxd: add configure and info_get functions
Quoted 9 lines · Kevin Laatz
Add functions for device configuration. The
info_getfunction is included here since it can be useful for checking successful configuration.Documentation is also updated to add device configuration usage info.
Signed-off-by Bruce Richardson <[email protected]>Signed-off-by Kevin Laatz <[email protected]>Reviewed-by Conor Walsh <[email protected]>---
[snip]
PATCH v10 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 | 51 +++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+)
doc/guides/dmadevs/idxd.rst +3 -0
@@ -135,3 +135,6 @@ IDXD configuration requirements: * Only one ``vchan`` is supported per device (work queue). * IDXD devices do not support silent mode. * The transfer direction must be set to ``RTE_DMA_DIR_MEM_TO_MEM`` to copy from memory to memory. + +Once configured, the device can then be made ready for use by calling the +``rte_dma_start()`` API.
drivers/dma/idxd/idxd_pci.c +51 -0
63 lines not on this page · raw message
Signature · 1 line
2.30.2
Re: [dpdk-dev] [PATCH v10 08/16] dma/idxd: add start and stop functions for pci devices
Quoted 8 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]>---
[snip]
drivers/dma/idxd/idxd_pci.c idxd_is_wq_enabled(struct idxd_dmadev *idxd) · line 70
Quoted 10 lines
drivers/dma/idxd/idxd_pci.c +9
-0+static int +idxd_pci_dev_stop (struct rte_dma_dev *dev) +{ +struct idxd_dmadev *idxd = dev->fp_obj->dev_private; +uint8_t err_code; + +if (!idxd_is_wq_enabled (idxd)) { +IDXD_PMD_ERR ("Work queue %d already disabled" , idxd->qid); +return -EALREADY ;
suggest return 0.
Quoted 53 lines
drivers/dma/idxd/idxd_pci.c +42
-0+ } + + 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 ==0 ?-1 : -err_code; + } +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->fp_obj->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 int idxd_pci_dev_close (struct rte_dma_dev *dev) {@@ -87,6 +136,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, + .dev_start = idxd_pci_dev_start, + .dev_stop = idxd_pci_dev_stop, };/* each portal uses 4 x 4k pages */
PATCH v10 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.
Documentation updates are included for dmadev library and IDXD driver docs as appropriate.
--- doc/guides/dmadevs/idxd.rst | 9 +++ doc/guides/prog_guide/dmadev.rst | 19 +++++ drivers/dma/idxd/idxd_common.c | 135 +++++++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 5 ++ drivers/dma/idxd/meson.build | 1 + 5 files changed, 169 insertions(+)
doc/guides/dmadevs/idxd.rst +9 -0
@@ -138,3 +138,12 @@ IDXD configuration requirements: Once configured, the device can then be made ready for use by calling the ``rte_dma_start()`` API. + +Performing Data Copies +~~~~~~~~~~~~~~~~~~~~~~~ + +Refer to the :ref:`Enqueue / Dequeue APIs <dmadev_enqueue_dequeue>` section of the dmadev library +documentation for details on operation enqueue and submission API usage. + +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.
doc/guides/prog_guide/dmadev.rst +19 -0
@@ -67,6 +67,8 @@ can be used to get the device info and supported features. Silent mode is a special device capability which does not require the application to invoke dequeue APIs. +.. _dmadev_enqueue_dequeue: + Enqueue / Dequeue APIs ~~~~~~~~~~~~~~~~~~~~~~
@@ -80,6 +82,23 @@ The ``rte_dma_submit`` API is used to issue doorbell to hardware. Alternatively the ``RTE_DMA_OP_FLAG_SUBMIT`` flag can be passed to the enqueue APIs to also issue the doorbell to hardware. +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[DMA_BURST_SZ], *dsts[DMA_BURST_SZ]; + unsigned int i; + + for (i = 0; i < RTE_DIM(srcs); i++) { + if (rte_dma_copy(dev_id, vchan, rte_pktmbuf_iova(srcs), + rte_pktmbuf_iova(dsts), COPY_LEN, 0) < 0) { + PRINT_ERR("Error with rte_dma_copy for buffer %u\n", i); + return -1; + } + } + rte_dma_submit(dev_id, vchan); + There are two dequeue APIs ``rte_dma_completed`` and ``rte_dma_completed_status``, these are used to obtain the results of the enqueue requests. ``rte_dma_completed`` will return the number of successfully
drivers/dma/idxd/idxd_common.c +135 -0
155 lines not on this page · raw message
drivers/dma/idxd/idxd_internal.h +5 -0
@@ -87,5 +87,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 (void *dev_private,uint16_t qid,rte_iova_t src, +rte_iova_t dst,unsigned int length,uint64_t flags); +int idxd_enqueue_fill (void *dev_private,uint16_t qid,uint64_t pattern, +rte_iova_t dst,unsigned int length,uint64_t flags); +int idxd_submit (void *dev_private,uint16_t qid);#endif /* _IDXD_INTERNAL_H_ */
drivers/dma/idxd/meson.build +1 -0
@@ -5,6 +5,7 @@ build = dpdk_conf.has('RTE_ARCH_X86') reason = 'only supported on x86' deps += ['bus_pci'] +cflags += '-mavx2' # all platforms with idxd HW support AVX sources = files( 'idxd_common.c', 'idxd_pci.c'
Signature · 1 line
2.30.2
Re: [dpdk-dev] [PATCH v10 09/16] dma/idxd: add data-path job submission functions
Quoted 52 lines · Kevin Laatz
Add data path functions for enqueuing and submitting operations to DSA devices.
Documentation updates are included for dmadev library and IDXD driver docs as appropriate.
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 | 9 +++ doc/guides/prog_guide/dmadev.rst | 19 +++++ drivers/dma/idxd/idxd_common.c | 135 +++++++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 5 ++ drivers/dma/idxd/meson.build | 1 + 5 files changed, 169 insertions(+)doc/guides/dmadevs/idxd.rst +9
-0@@ -138,3 +138,12 @@ IDXD configuration requirements: Once configured, the device can then be made ready for use by calling the ``rte_dma_start()`` API. + +Performing Data Copies +~~~~~~~~~~~~~~~~~~~~~~~ + +Refer to the :ref:`Enqueue / Dequeue APIs <dmadev_enqueue_dequeue>` section of the dmadev library +documentation for details on operation enqueue and submission API usage. + +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.doc/guides/prog_guide/dmadev.rst +3
-0@@ -67,6 +67,8 @@ can be used to get the device info and supported features. Silent mode is a special device capability which does not require the application to invoke dequeue APIs. +.. _dmadev_enqueue_dequeue: + Enqueue / Dequeue APIs ~~~~~~~~~~~~~~~~~~~~~~@@ -80,6 +82,23 @@ The ``rte_dma_submit`` API is used to issue doorbell to hardware. Alternatively the ``RTE_DMA_OP_FLAG_SUBMIT`` flag can be passed to the enqueue APIs to also issue the doorbell to hardware. +The following code demonstrates how to enqueue a burst of copies to the
doc/guides/prog_guide/dmadev.rst The ``rte_dma_submit`` API is used to issue doorbell to hardware. · line 95
Quoted 10 lines
doc/guides/prog_guide/dmadev.rst +10
-0+device and start the hardware processing of them: + +.. code-block:: C + + struct rte_mbuf *srcs[DMA_BURST_SZ], *dsts[DMA_BURST_SZ]; + unsigned int i; + + for (i = 0; i < RTE_DIM(srcs); i++) { + if (rte_dma_copy(dev_id, vchan, rte_pktmbuf_iova(srcs), + rte_pktmbuf_iova(dsts), COPY_LEN, 0) < 0) {
srcs->srcs[i]
dsts->dsts[i]
could add my reviewed-by after fix it, thanks.
Quoted 17 lines
doc/guides/prog_guide/dmadev.rst +6
-0+ PRINT_ERR("Error with rte_dma_copy for buffer %u\n", i); + return -1; + } + } + rte_dma_submit(dev_id, vchan); + There are two dequeue APIs ``rte_dma_completed`` and ``rte_dma_completed_status``, these are used to obtain the results of the enqueue requests. ``rte_dma_completed`` will return the number of successfullydrivers/dma/idxd/idxd_common.c +0
-0@@ -2,14 +2,145 @@* Copyright 2021 Intel Corporation */
[snip]
PATCH v10 10/16 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 | 32 ++++- drivers/dma/idxd/idxd_common.c | 236 +++++++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 5 + 3 files changed, 272 insertions(+), 1 deletion(-)
doc/guides/dmadevs/idxd.rst +31 -1
@@ -143,7 +143,37 @@ Performing Data Copies ~~~~~~~~~~~~~~~~~~~~~~~ Refer to the :ref:`Enqueue / Dequeue APIs <dmadev_enqueue_dequeue>` section of the dmadev library -documentation for details on operation enqueue and submission API usage. +documentation for details on operation enqueue, submission and completion API usage. 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. + +When gathering completions, ``rte_dma_completed()`` should be used, up until the point an error +occurs in an operation. 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); + }
drivers/dma/idxd/idxd_common.c +236 -0
248 lines not on this page · raw message
drivers/dma/idxd/idxd_internal.h +5 -0
@@ -92,5 +92,10 @@ int idxd_enqueue_copy(void *dev_private, uint16_t qid, rte_iova_t src,int idxd_enqueue_fill (void *dev_private,uint16_t qid,uint64_t pattern,rte_iova_t dst,unsigned int length,uint64_t flags);int idxd_submit (void *dev_private,uint16_t qid); +uint16_t idxd_completed (void *dev_private,uint16_t qid,uint16_t max_ops, +uint16_t *last_idx,bool *has_error); +uint16_t idxd_completed_status(void *dev_private, 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 v10 11/16 dma/idxd: add operation statistic tracking
In reply to Kevin LaatzAdd statistic tracking for DSA devices.
The dmadev library documentation is also updated to add a generic section for using the library's statistics APIs.
--- doc/guides/prog_guide/dmadev.rst | 11 +++++++++++ drivers/dma/idxd/idxd_bus.c | 2 ++ drivers/dma/idxd/idxd_common.c | 27 +++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 5 +++++ drivers/dma/idxd/idxd_pci.c | 2 ++ 5 files changed, 47 insertions(+)
doc/guides/prog_guide/dmadev.rst +11 -0
@@ -107,3 +107,14 @@ completed operations along with the status of each operation (filled into the ``status`` array passed by user). These two APIs can also return the last completed operation's ``ring_idx`` which could help user track operations within their own application-defined rings. + + +Querying Device Statistics +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The statistics from a dmadev device can be got via the statistics functions, +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;
@@ -276,6 +278,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;
@@ -297,6 +301,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;
@@ -355,6 +361,7 @@ idxd_completed(void *dev_private, uint16_t qid __rte_unused, uint16_t max_ops, 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(void *dev_private, uint16_t qid __rte_unused, uint16_t max 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->fp_obj->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->fp_obj->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 +5 -0
@@ -59,6 +59,8 @@ struct idxd_dmadev {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 */
@@ -97,5 +99,8 @@ uint16_t idxd_completed(void *dev_private, uint16_t qid, uint16_t max_ops, uint16_t idxd_completed_status(void *dev_private, 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
@@ -136,6 +136,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 v10 11/16] dma/idxd: add operation statistic tracking
Quoted 22 lines · Kevin Laatz
Add statistic tracking for DSA devices.
The dmadev library documentation is also updated to add a generic section for using the library's statistics APIs.
Signed-off-by Bruce Richardson <[email protected]>Signed-off-by Kevin Laatz <[email protected]>Reviewed-by Conor Walsh <[email protected]>Reviewed-by Chengwen Feng <[email protected]>--- doc/guides/prog_guide/dmadev.rst | 11 +++++++++++ drivers/dma/idxd/idxd_bus.c | 2 ++ drivers/dma/idxd/idxd_common.c | 27 +++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 5 +++++ drivers/dma/idxd/idxd_pci.c | 2 ++ 5 files changed, 47 insertions(+)doc/guides/prog_guide/dmadev.rst +0
-0
doc/guides/prog_guide/dmadev.rst completed operations along with the status of each operation (filled into the · line 113
Quoted 7 lines
doc/guides/prog_guide/dmadev.rst +4
-0@@ -107,3 +107,14 @@ completed operations along with the status of each operation (filled into the ``status`` array passed by user). These two APIs can also return the last completed operation's ``ring_idx`` which could help user track operations within their own application-defined rings. + + +Querying Device Statistics +~~~~~~~~~~~~~~~~~~~~~~~~~~~
could remove last ~
anyway,
Quoted 19 lines
doc/guides/prog_guide/dmadev.rst +7
-0+ +The statistics from a dmadev device can be got via the statistics functions, +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, };
[snip]
Quoted 1 line
PATCH v10 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.
--- 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
@@ -163,6 +163,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->fp_obj->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,uint16_t max_ops,enum rte_dma_status_code *status) {
drivers/dma/idxd/idxd_internal.h +2 -0
@@ -102,5 +102,7 @@ uint16_t idxd_completed_status(void *dev_private, uint16_t qid __rte_unused,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); +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
@@ -140,6 +140,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
Re: [dpdk-dev] [PATCH v10 12/16] dma/idxd: add vchan status function
Quoted 36 lines · Kevin Laatz
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]>Reviewed-by Conor Walsh <[email protected]>--- 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 +3
-0@@ -163,6 +163,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)
drivers/dma/idxd/idxd_common.c get_comp_status(struct idxd_completion *c) · line 178
Quoted 10 lines
drivers/dma/idxd/idxd_common.c +10
-0+{ +struct idxd_dmadev *idxd = dev->fp_obj->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 ;
why not use stats.submitted and completed ? or I miss some thing about this API?
does this api must called after rte_dma_submit() ? If not the following seq will function fail:
enqueue multiple copy request
submit to hardware
enqueue multiple copy request
invoke rte_dma_vchan_status to query status --because the copy requests not submit, the last comp will be non-zero, so it will return IDLE.
Quoted 32 lines
drivers/dma/idxd/idxd_common.c +4
-0+ +return 0 ; +} + static __rte_always_inline intbatch_ok (struct idxd_dmadev *idxd,uint16_t max_ops,enum rte_dma_status_code *status) {drivers/dma/idxd/idxd_internal.h +2
-0@@ -102,5 +102,7 @@ uint16_t idxd_completed_status(void *dev_private, uint16_t qid __rte_unused,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); +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@@ -140,6 +140,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 */
Re: [dpdk-dev] [PATCH v10 12/16] dma/idxd: add vchan status function
Quoted 50 lines · fengchengwen
Quoted 36 lines · Kevin Laatz
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]>Reviewed-by Conor Walsh <[email protected]>--- 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 +3
-0@@ -163,6 +163,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)drivers/dma/idxd/idxd_common.c get_comp_status(struct idxd_completion *c) · line 178
Quoted 10 lines
drivers/dma/idxd/idxd_common.c +10
-0+{ +struct idxd_dmadev *idxd = dev->fp_obj->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 ;why not use stats.submitted and completed ? or I miss some thing about this API?
Quoted 6 lines
does this api must called after
rte_dma_submit()? If not the following seq will function fail:
enqueue multiple copy request
submit to hardware
enqueue multiple copy request
invokerte_dma_vchan_statusto query status --because the copy requests not submit, the last comp will be non-zero, so it will return IDLE.
That is correct. Until the jobs are submitted the device HW is idle as it is not processing any job. This API is to return the HW state, because that is the key concern here, whether the HW is in the process of doing DMA or not, since that is what can cause race conditions. The timing of sending down jobs to the device is under app control.
PATCH v10 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_common.c | 21 +++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 1 + drivers/dma/idxd/idxd_pci.c | 1 + 3 files changed, 23 insertions(+)
drivers/dma/idxd/idxd_common.c +21 -0
@@ -468,6 +468,26 @@ idxd_info_get(const struct rte_dma_dev *dev, struct rte_dma_info *info, uint32_treturn 0 ; } +uint16_t +idxd_burst_capacity(const void *dev_private, uint16_t vchan __rte_unused) +{ +const struct idxd_dmadev *idxd = 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)
@@ -553,6 +573,7 @@ idxd_dmadev_create(const char *name, struct rte_device *dev, dmadev->fp_obj->submit = idxd_submit; dmadev->fp_obj->completed = idxd_completed; dmadev->fp_obj->completed_status = idxd_completed_status; + dmadev->fp_obj->burst_capacity = idxd_burst_capacity; idxd = dmadev->data->dev_private; *idxd = *base_idxd;/* copy over the main fields already passed in */
drivers/dma/idxd/idxd_internal.h +1 -0
@@ -104,5 +104,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 void *dev_private,uint16_t vchan);#endif /* _IDXD_INTERNAL_H_ */
drivers/dma/idxd/idxd_pci.c +1 -0
@@ -254,6 +254,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 v10 13/16] dma/idxd: add burst capacity API
Quoted 21 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]>Reviewed-by Bruce Richardson <[email protected]>--- drivers/dma/idxd/idxd_common.c | 21 +++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 1 + drivers/dma/idxd/idxd_pci.c | 1 + 3 files changed, 23 insertions(+)drivers/dma/idxd/idxd_common.c +0
-0@@ -468,6 +468,26 @@ idxd_info_get(const struct rte_dma_dev *dev, struct rte_dma_info *info, uint32_treturn 0 ; }
[snip]
PATCH v10 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 v10 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 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
usertools/dpdk-devbind.py +7 -1
@@ -71,6 +71,7 @@ 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]
@@ -585,6 +586,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")
@@ -653,7 +657,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(
@@ -734,6 +738,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)
@@ -756,6 +761,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 v10 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
@@ -71,13 +71,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, cnxk_inl_dev, intel_ioat_bdw, - intel_ioat_skx, intel_ioat_icx, intel_idxd_spr, intel_ntb_skx, + intel_ioat_skx, 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
v11 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.
v11:
* addressed ML feedback from Chengwen
v10:
* meson fix to ensure Windows and BSD builds compile
v9:
* add missing meson check for x86
v8:
* fix compilation issues of individual patches
v7:
* rebase on above patchsets
* add meson reason for rawdev build
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 | 179 ++++++++ doc/guides/dmadevs/index.rst | 2 + doc/guides/prog_guide/dmadev.rst | 30 ++ 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 | 378 +++++++++++++++ drivers/dma/idxd/idxd_common.c | 612 +++++++++++++++++++++++++ drivers/dma/idxd/idxd_hw_defs.h | 131 ++++++ drivers/dma/idxd/idxd_internal.h | 109 +++++ drivers/dma/idxd/idxd_pci.c | 380 +++++++++++++++ drivers/dma/idxd/meson.build | 16 + 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 | 24 +- usertools/dpdk-devbind.py | 10 +- 19 files changed, 2014 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 v11 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.
--- doc/guides/rawdevs/ioat.rst | 8 ++++++++ drivers/meson.build | 4 ++-- drivers/raw/ioat/meson.build | 24 +++++++++++++++++++++--- 3 files changed, 31 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 +21 -3
@@ -2,14 +2,32 @@ # 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 + reason = 'replaced by dmadev drivers' + 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 v11 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.
---
v8: fix compile issue
v9: add meson check for x86
--- 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_common.c | 11 +++++ 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 + 10 files changed, 184 insertions(+) create mode 100644 doc/guides/dmadevs/idxd.rst create mode 100644 drivers/dma/idxd/idxd_common.c 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
@@ -75,6 +75,11 @@ New Features operations. * Added 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. + * **Added new RSS offload types for IPv4/L4 checksum in RSS flow.** Added macros ETH_RSS_IPV4_CHKSUM and ETH_RSS_L4_CHKSUM, now IPv4 and
drivers/dma/idxd/idxd_common.c new file +11 -0
@@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright 2021 Intel Corporation +*/ + +#include <rte_log.h> + +#include "idxd_internal.h" + +int idxd_pmd_logtype; + +RTE_LOG_REGISTER_DEFAULT (idxd_pmd_logtype,WARNING );
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 + +build = dpdk_conf.has('RTE_ARCH_X86') +reason = 'only supported on x86' + +deps += ['bus_pci'] +sources = files( + 'idxd_common.c', + '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 v11 02/16] dma/idxd: add skeleton for VFIO based DSA device
20/10/2021 18:29, Kevin Laatz:
drivers/dma/idxd/version.map line 3
Quoted 6 lines
drivers/dma/idxd/version.map new file +3
-0@@ -0,0 +1,3 @@ +DPDK_21 { + local: *; +};
Should be DPDK_22
Will fix while merging.
PATCH v11 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.
--- doc/guides/dmadevs/idxd.rst | 64 ++++++ drivers/dma/idxd/idxd_bus.c | 352 +++++++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 34 +++ drivers/dma/idxd/meson.build | 4 + 4 files changed, 454 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/idxd_internal.h +34 -0
@@ -24,4 +24,38 @@ 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 */ + +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; +uint8_t sva_support; +uint8_t qid; + +union { +struct { +unsigned int dsa_id; + } bus; + } u; +}; +#endif /* _IDXD_INTERNAL_H_ */
drivers/dma/idxd/meson.build +4 -0
@@ -9,3 +9,7 @@ sources = files( 'idxd_common.c', 'idxd_pci.c' ) + +if is_linux + sources += files('idxd_bus.c') +endif
Signature · 1 line
2.30.2
PATCH v11 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.
--- drivers/dma/idxd/idxd_bus.c | 19 ++++++++++ drivers/dma/idxd/idxd_common.c | 61 ++++++++++++++++++++++++++++++++ drivers/dma/idxd/idxd_hw_defs.h | 27 ++++++++++++++ drivers/dma/idxd/idxd_internal.h | 7 ++++ 4 files changed, 114 insertions(+) create mode 100644 drivers/dma/idxd/idxd_hw_defs.h
drivers/dma/idxd/idxd_bus.c +19 -0
@@ -86,6 +86,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) {
@@ -207,6 +219,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);
@@ -215,6 +228,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 dmadev %s" , dev->wq_name); +return ret; + } +return 0 ; }
drivers/dma/idxd/idxd_common.c +61 -0
71 lines not on this page · raw message
drivers/dma/idxd/idxd_hw_defs.h new file +27 -0
@@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright 2021 Intel Corporation +*/ + +#ifndef _IDXD_HW_DEFS_H_ +#define _IDXD_HW_DEFS_H_ + +#define IDXD_COMP_STATUS_INCOMPLETE 0 +#define IDXD_COMP_STATUS_SUCCESS 1 +#define IDXD_COMP_STATUS_INVALID_OPCODE 0x10 +#define IDXD_COMP_STATUS_INVALID_SIZE 0x13 +#define IDXD_COMP_STATUS_SKIPPED 0xFF/* not official IDXD error, needed as placeholder */ + +/** +* Completion record structure written back by DSA +*/ +struct idxd_completion { +uint8_t status; +uint8_t result; +/* 16-bits pad here */ +uint32_t completed_size;/* data length, or descriptors for batch */ + +rte_iova_t fault_address; +uint32_t invalid_flags; +} __rte_aligned(32); + +#endif
drivers/dma/idxd/idxd_internal.h +7 -0
@@ -5,6 +5,10 @@#ifndef _IDXD_INTERNAL_H_#define _IDXD_INTERNAL_H_ +#include <rte_dmadev_pmd.h> + +#include "idxd_hw_defs.h" +/** * @file idxd_internal.h *
@@ -58,4 +62,7 @@ struct idxd_dmadev { } 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_ */
Signature · 1 line
2.30.2
PATCH v11 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.
---
v11: fix destroy
--- drivers/dma/idxd/idxd_hw_defs.h | 63 +++++++ drivers/dma/idxd/idxd_internal.h | 13 ++ drivers/dma/idxd/idxd_pci.c | 271 ++++++++++++++++++++++++++++++- 3 files changed, 344 insertions(+), 3 deletions(-)
drivers/dma/idxd/idxd_hw_defs.h +63 -0
@@ -24,4 +24,67 @@ struct idxd_completion {uint32_t invalid_flags; } __rte_aligned(32); +/*** 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 +13 -0
@@ -6,6 +6,7 @@#define _IDXD_INTERNAL_H_#include <rte_dmadev_pmd.h> +#include <rte_spinlock.h> #include "idxd_hw_defs.h"
@@ -28,6 +29,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;
@@ -59,6 +70,8 @@ struct idxd_dmadev {struct {unsigned int dsa_id; } bus; + +struct idxd_pci_common *pci; } u; };
drivers/dma/idxd/idxd_pci.c +268 -3
302 lines not on this page · raw message
Signature · 1 line
2.30.2
PATCH v11 6/16 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 | 41 ++++++++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 4 ++++ drivers/dma/idxd/idxd_pci.c | 2 ++ 5 files changed, 81 insertions(+)
drivers/dma/idxd/idxd_bus.c +1 -0
@@ -96,6 +96,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->fp_obj->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 +41 -0
47 lines not on this page · raw message
drivers/dma/idxd/idxd_internal.h +4 -0
@@ -40,6 +40,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;
@@ -63,6 +65,7 @@ struct idxd_dmadev {unsigned short max_batch_size;struct rte_dma_dev *dmadev; +struct rte_dma_vchan_conf qcfg;uint8_t sva_support;uint8_t qid;
@@ -77,5 +80,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 +2 -0
@@ -77,12 +77,14 @@ idxd_pci_dev_close(struct rte_dma_dev *dev)/* free device memory */ IDXD_PMD_DEBUG ("Freeing device driver memory" );rte_free (idxd->batch_idx_ring); +rte_free (idxd->desc_ring);return 0 ; }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
PATCH v11 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.
Documentation is also updated to add device configuration usage info.
--- doc/guides/dmadevs/idxd.rst | 15 +++++++ drivers/dma/idxd/idxd_bus.c | 3 ++ drivers/dma/idxd/idxd_common.c | 71 ++++++++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 6 +++ drivers/dma/idxd/idxd_pci.c | 3 ++ 5 files changed, 98 insertions(+)
doc/guides/dmadevs/idxd.rst +15 -0
@@ -120,3 +120,18 @@ 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. + +Device Configuration +~~~~~~~~~~~~~~~~~~~~~ + +IDXD configuration requirements: + +* ``ring_size`` must be a power of two, between 64 and 4096. +* Only one ``vchan`` is supported per device (work queue). +* IDXD devices do not support silent mode. +* The transfer direction must be set to ``RTE_DMA_DIR_MEM_TO_MEM`` to copy from memory to memory.
drivers/dma/idxd/idxd_bus.c +3 -0
@@ -97,6 +97,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 +71 -0
77 lines not on this page · raw message
drivers/dma/idxd/idxd_internal.h +6 -0
@@ -81,5 +81,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
@@ -85,6 +85,9 @@ 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, + .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 v11 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 | 51 +++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+)
doc/guides/dmadevs/idxd.rst +3 -0
@@ -135,3 +135,6 @@ IDXD configuration requirements: * Only one ``vchan`` is supported per device (work queue). * IDXD devices do not support silent mode. * The transfer direction must be set to ``RTE_DMA_DIR_MEM_TO_MEM`` to copy from memory to memory. + +Once configured, the device can then be made ready for use by calling the +``rte_dma_start()`` API.
drivers/dma/idxd/idxd_pci.c +51 -0
63 lines not on this page · raw message
Signature · 1 line
2.30.2
PATCH v11 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.
Documentation updates are included for dmadev library and IDXD driver docs as appropriate.
--- doc/guides/dmadevs/idxd.rst | 9 +++ doc/guides/prog_guide/dmadev.rst | 19 +++++ drivers/dma/idxd/idxd_common.c | 135 +++++++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 5 ++ drivers/dma/idxd/meson.build | 1 + 5 files changed, 169 insertions(+)
doc/guides/dmadevs/idxd.rst +9 -0
@@ -138,3 +138,12 @@ IDXD configuration requirements: Once configured, the device can then be made ready for use by calling the ``rte_dma_start()`` API. + +Performing Data Copies +~~~~~~~~~~~~~~~~~~~~~~~ + +Refer to the :ref:`Enqueue / Dequeue APIs <dmadev_enqueue_dequeue>` section of the dmadev library +documentation for details on operation enqueue and submission API usage. + +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.
doc/guides/prog_guide/dmadev.rst +19 -0
@@ -67,6 +67,8 @@ can be used to get the device info and supported features. Silent mode is a special device capability which does not require the application to invoke dequeue APIs. +.. _dmadev_enqueue_dequeue: + Enqueue / Dequeue APIs ~~~~~~~~~~~~~~~~~~~~~~
@@ -80,6 +82,23 @@ The ``rte_dma_submit`` API is used to issue doorbell to hardware. Alternatively the ``RTE_DMA_OP_FLAG_SUBMIT`` flag can be passed to the enqueue APIs to also issue the doorbell to hardware. +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[DMA_BURST_SZ], *dsts[DMA_BURST_SZ]; + unsigned int i; + + for (i = 0; i < RTE_DIM(srcs); i++) { + if (rte_dma_copy(dev_id, vchan, rte_pktmbuf_iova(srcs[i]), + rte_pktmbuf_iova(dsts[i]), COPY_LEN, 0) < 0) { + PRINT_ERR("Error with rte_dma_copy for buffer %u\n", i); + return -1; + } + } + rte_dma_submit(dev_id, vchan); + There are two dequeue APIs ``rte_dma_completed`` and ``rte_dma_completed_status``, these are used to obtain the results of the enqueue requests. ``rte_dma_completed`` will return the number of successfully
drivers/dma/idxd/idxd_common.c +135 -0
155 lines not on this page · raw message
drivers/dma/idxd/idxd_internal.h +5 -0
@@ -87,5 +87,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 (void *dev_private,uint16_t qid,rte_iova_t src, +rte_iova_t dst,unsigned int length,uint64_t flags); +int idxd_enqueue_fill (void *dev_private,uint16_t qid,uint64_t pattern, +rte_iova_t dst,unsigned int length,uint64_t flags); +int idxd_submit (void *dev_private,uint16_t qid);#endif /* _IDXD_INTERNAL_H_ */
drivers/dma/idxd/meson.build +1 -0
@@ -5,6 +5,7 @@ build = dpdk_conf.has('RTE_ARCH_X86') reason = 'only supported on x86' deps += ['bus_pci'] +cflags += '-mavx2' # all platforms with idxd HW support AVX sources = files( 'idxd_common.c', 'idxd_pci.c'
Signature · 1 line
2.30.2
PATCH v11 10/16 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 | 32 ++++- drivers/dma/idxd/idxd_common.c | 236 +++++++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 5 + 3 files changed, 272 insertions(+), 1 deletion(-)
doc/guides/dmadevs/idxd.rst +31 -1
@@ -143,7 +143,37 @@ Performing Data Copies ~~~~~~~~~~~~~~~~~~~~~~~ Refer to the :ref:`Enqueue / Dequeue APIs <dmadev_enqueue_dequeue>` section of the dmadev library -documentation for details on operation enqueue and submission API usage. +documentation for details on operation enqueue, submission and completion API usage. 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. + +When gathering completions, ``rte_dma_completed()`` should be used, up until the point an error +occurs in an operation. 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); + }
drivers/dma/idxd/idxd_common.c +236 -0
248 lines not on this page · raw message
drivers/dma/idxd/idxd_internal.h +5 -0
@@ -92,5 +92,10 @@ int idxd_enqueue_copy(void *dev_private, uint16_t qid, rte_iova_t src,int idxd_enqueue_fill (void *dev_private,uint16_t qid,uint64_t pattern,rte_iova_t dst,unsigned int length,uint64_t flags);int idxd_submit (void *dev_private,uint16_t qid); +uint16_t idxd_completed (void *dev_private,uint16_t qid,uint16_t max_ops, +uint16_t *last_idx,bool *has_error); +uint16_t idxd_completed_status(void *dev_private, 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 v11 11/16 dma/idxd: add operation statistic tracking
In reply to Kevin LaatzAdd statistic tracking for DSA devices.
The dmadev library documentation is also updated to add a generic section for using the library's statistics APIs.
--- doc/guides/prog_guide/dmadev.rst | 11 +++++++++++ drivers/dma/idxd/idxd_bus.c | 2 ++ drivers/dma/idxd/idxd_common.c | 27 +++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 5 +++++ drivers/dma/idxd/idxd_pci.c | 2 ++ 5 files changed, 47 insertions(+)
doc/guides/prog_guide/dmadev.rst +11 -0
@@ -107,3 +107,14 @@ completed operations along with the status of each operation (filled into the ``status`` array passed by user). These two APIs can also return the last completed operation's ``ring_idx`` which could help user track operations within their own application-defined rings. + + +Querying Device Statistics +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The statistics from a dmadev device can be got via the statistics functions, +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
@@ -100,6 +100,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;
@@ -276,6 +278,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;
@@ -297,6 +301,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;
@@ -355,6 +361,7 @@ idxd_completed(void *dev_private, uint16_t qid __rte_unused, uint16_t max_ops, 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(void *dev_private, uint16_t qid __rte_unused, uint16_t max 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->fp_obj->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->fp_obj->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 +5 -0
@@ -59,6 +59,8 @@ struct idxd_dmadev {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 */
@@ -97,5 +99,8 @@ uint16_t idxd_completed(void *dev_private, uint16_t qid, uint16_t max_ops, uint16_t idxd_completed_status(void *dev_private, 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
@@ -137,6 +137,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 v11 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.
--- 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
@@ -102,6 +102,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
@@ -163,6 +163,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->fp_obj->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,uint16_t max_ops,enum rte_dma_status_code *status) {
drivers/dma/idxd/idxd_internal.h +2 -0
@@ -102,5 +102,7 @@ uint16_t idxd_completed_status(void *dev_private, uint16_t qid __rte_unused,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); +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
@@ -141,6 +141,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 v11 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_common.c | 21 +++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 1 + drivers/dma/idxd/idxd_pci.c | 1 + 3 files changed, 23 insertions(+)
drivers/dma/idxd/idxd_common.c +21 -0
@@ -468,6 +468,26 @@ idxd_info_get(const struct rte_dma_dev *dev, struct rte_dma_info *info, uint32_treturn 0 ; } +uint16_t +idxd_burst_capacity(const void *dev_private, uint16_t vchan __rte_unused) +{ +const struct idxd_dmadev *idxd = 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)
@@ -553,6 +573,7 @@ idxd_dmadev_create(const char *name, struct rte_device *dev, dmadev->fp_obj->submit = idxd_submit; dmadev->fp_obj->completed = idxd_completed; dmadev->fp_obj->completed_status = idxd_completed_status; + dmadev->fp_obj->burst_capacity = idxd_burst_capacity; idxd = dmadev->data->dev_private; *idxd = *base_idxd;/* copy over the main fields already passed in */
drivers/dma/idxd/idxd_internal.h +1 -0
@@ -104,5 +104,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 void *dev_private,uint16_t vchan);#endif /* _IDXD_INTERNAL_H_ */
drivers/dma/idxd/idxd_pci.c +1 -0
@@ -258,6 +258,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 v11 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 v11 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 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
usertools/dpdk-devbind.py +7 -1
@@ -71,6 +71,7 @@ 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]
@@ -585,6 +586,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")
@@ -653,7 +657,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(
@@ -734,6 +738,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)
@@ -756,6 +761,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 v11 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
@@ -71,13 +71,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, cnxk_inl_dev, intel_ioat_bdw, - intel_ioat_skx, intel_ioat_icx, intel_idxd_spr, intel_ntb_skx, + intel_ioat_skx, 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
20/10/2021 18:29, Kevin Laatz:
Quoted 3 lines
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.
Applied (with notified fix), thanks.
Quoted 7 lines · Thomas Monjalon
20/10/2021 18:29, Kevin Laatz:
Quoted 3 lines
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.
Applied (with notified fix), thanks.
Something is wrong in main branch with Windows compilation. It was not caught before, since this series crossed the road while Windows compilation on dma drivers passed.
I am not entirely sure on the fix, I'll post a patch to see if CI agrees. (I still wonder how stdint.h gets included for uintX definitions, but that's either "include luck" or my lack of coffee).
Signature · 1 line
David Marchand