Skip to contentSkip to conversation

vhost-add-DMADEV-support-for-async-datapath

RFC PATCH In review Sunil Pai G 2 participants 5 messages Aug 23, 2021 – Sep 13, 2021 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

cover vhost-add-DMADEV-support-for-async-datapath

Note to the reader:
-------------------
The intent of this patch is to explore possible different approaches of async implementations.
Please consider this patch for discussions only and not for merge/upstream.

This patch simplifies the vhost async datapath usability by utilizing the generic DMADEV API's to perform packet copy.

Previously, it was required by the application to implement its own DMA enabling logic making it difficult to adopt this feature. Having a common implementation in vhost library allows for easier adoption.

The usability of async datapath is enhanced by extending the API's to include a DMADEV ID to be passed by the application. This provides flexibility to applications to decide which DMADEV to be used.

Sunil Pai G (1):
vhost: Add DMADEV support for async datapath.

 lib/vhost/meson.build       |   2 +-
 lib/vhost/rte_vhost_async.h |  55 +------
 lib/vhost/vhost.c           |  46 +++---
 lib/vhost/vhost.h           |  24 ++-
 lib/vhost/virtio_net.c      | 311 +++++++++++++++++++++++++++++++-----
 5 files changed, 316 insertions(+), 122 deletions(-)
Signature · 1 line
2.25.1
#1 lore raw

RFC PATCH 1/1 vhost: add DMADEV support for async datapath

This patch simplifies the async data path enablement for applications by allowing just the DMADEV ID to be passed as a parameter rather than having to implement its own logic to enable DMA offload.

Remove the callbacks transfer_data and check_completed_copies and utilize the generic DMADEV API's to perform packet copy for vhost async datapath.

---
 lib/vhost/meson.build       |   2 +-
 lib/vhost/rte_vhost_async.h |  55 +------
 lib/vhost/vhost.c           |  46 +++---
 lib/vhost/vhost.h           |  24 ++-
 lib/vhost/virtio_net.c      | 311 +++++++++++++++++++++++++++++++-----
 5 files changed, 316 insertions(+), 122 deletions(-)
lib/vhost/meson.build +1 -1
index 2d8fe0239f..bea17ed4f5 100644
@@ -34,4 +34,4 @@ headers = files(
         'rte_vhost_async.h',
         'rte_vhost_crypto.h',
 )
-deps += ['ethdev', 'cryptodev', 'hash', 'pci']
+deps += ['ethdev', 'cryptodev', 'hash', 'pci', 'dmadev']
lib/vhost/rte_vhost_async.h +7 -48

97 lines not on this page · raw message

lib/vhost/vhost.c +20 -26

116 lines not on this page · raw message

lib/vhost/vhost.h +21 -3
index a2309b06cd..2c996c4414 100644
@@ -120,6 +120,26 @@ struct vring_used_elem_packed {
 	uint32_t count;
 };
 
+
+/* vHost async DMADEV ring size. */
+#define VHOST_ASYNC_DMADEV_RING_SIZE 4096
+
+#define DMA_COMPLETION_RING_SIZE VHOST_ASYNC_DMADEV_RING_SIZE
+
+struct enq_info_t{
+    uint8_t pkt_rcvd; //Make this atomic
+};
+
+/* DMA completion tracking ring to reorder the packets.
+ * The write's to the enq_info array should be atomic
+ * to guarantee correct behaviour. */
+struct dma_completions_t {
+    struct enq_info_t enq_info[DMA_COMPLETION_RING_SIZE];
+    uint16_t count;
+    uint16_t read_idx;
+    uint16_t write_idx;
+};
+
 /**
  * Structure contains variables relevant to RX/TX virtqueues.
  */
@@ -194,9 +214,6 @@ struct vhost_virtqueue {
 	struct rte_vhost_resubmit_info *resubmit_inflight;
 	uint64_t		global_counter;
 
-	/* operation callbacks for async dma */
-	struct rte_vhost_async_channel_ops	async_ops;
-
 	struct rte_vhost_iov_iter *it_pool;
 	struct iovec *vec_pool;
 
@@ -221,6 +238,7 @@ struct vhost_virtqueue {
 	/* vq async features */
 	bool		async_registered;
 	uint32_t	async_threshold;
+	struct dma_completions_t *dma_completions;
 
 	int			notif_enable;
 #define VIRTIO_UNINITIALIZED_NOTIF	(-1)
lib/vhost/virtio_net.c +267 -44

502 lines not on this page · raw message

Signature · 1 line
2.25.1
#2 lore raw
In reply to Sunil Pai G

Hi Sunil,

Quoted 6 lines · Sunil Pai G

Note to the reader:
-------------------
The intent of this patch is to explore possible different approaches of async implementations.
Please consider this patch for discussions only and not for merge/upstream.

Thanks for sharing, that will indeed help to find the best solution. I'm just wondering if you have the vhost example part of this rework, so that we can understand what are the impacts on app side?

Quoted 23 lines

This patch simplifies the vhost async datapath usability by utilizing the generic DMADEV API's to perform packet copy.

Previously, it was required by the application to implement its own DMA enabling logic making it difficult to adopt this feature. Having a common implementation in vhost library allows for easier adoption.

The usability of async datapath is enhanced by extending the API's to include a DMADEV ID to be passed by the application. This provides flexibility to applications to decide which DMADEV to be used.

Sunil Pai G (1):
vhost: Add DMADEV support for async datapath.

 lib/vhost/meson.build       |   2 +-
 lib/vhost/rte_vhost_async.h |  55 +------
 lib/vhost/vhost.c           |  46 +++---
 lib/vhost/vhost.h           |  24 ++-
 lib/vhost/virtio_net.c      | 311 +++++++++++++++++++++++++++++++-----
 5 files changed, 316 insertions(+), 122 deletions(-)
#3 lore raw

Hi Maxime,

<snip>

Quoted 10 lines

Hi Sunil,

Quoted 6 lines · Sunil Pai G

Note to the reader:
-------------------
The intent of this patch is to explore possible different approaches of async implementations.
Please consider this patch for discussions only and not for merge/upstream.

Quoted 4 lines

Thanks for sharing, that will indeed help to find the best solution. I'm just wondering if you have the vhost example part of this rework, so that we can understand what are the impacts on app side?

I did some quick changes for the vhost sample app but only for the Northbound path.
https://patches.dpdk.org/project/dpdk/patch/[email protected]/

Please note that the patch is untested.
<snip>