On Thu, Dec 30, 2021 at 04:55:05PM -0500, Jiayu Hu wrote:
> Since dmadev is introduced in 21.11, to avoid the overhead of vhost DMA
> abstraction layer and simplify application logics, this patch integrates
> dmadev in asynchronous data path.
> 
> Signed-off-by: Jiayu Hu <jiayu...@intel.com>
> Signed-off-by: Sunil Pai G <sunil.pa...@intel.com>
> ---
>  doc/guides/prog_guide/vhost_lib.rst |  70 ++++-----
>  examples/vhost/Makefile             |   2 +-
>  examples/vhost/ioat.c               | 218 --------------------------
>  examples/vhost/ioat.h               |  63 --------
>  examples/vhost/main.c               | 230 +++++++++++++++++++++++-----
>  examples/vhost/main.h               |  11 ++
>  examples/vhost/meson.build          |   6 +-
>  lib/vhost/meson.build               |   3 +-
>  lib/vhost/rte_vhost_async.h         | 121 +++++----------
>  lib/vhost/version.map               |   3 +
>  lib/vhost/vhost.c                   | 130 +++++++++++-----
>  lib/vhost/vhost.h                   |  53 ++++++-
>  lib/vhost/virtio_net.c              | 206 +++++++++++++++++++------
>  13 files changed, 587 insertions(+), 529 deletions(-)
>  delete mode 100644 examples/vhost/ioat.c
>  delete mode 100644 examples/vhost/ioat.h
> 

> diff --git a/examples/vhost/main.c b/examples/vhost/main.c
> index 33d023aa39..44073499bc 100644
> --- a/examples/vhost/main.c
> +++ b/examples/vhost/main.c
> @@ -24,8 +24,9 @@
>  #include <rte_ip.h>
>  #include <rte_tcp.h>
>  #include <rte_pause.h>
> +#include <rte_dmadev.h>
> +#include <rte_vhost_async.h>
>  
> -#include "ioat.h"
>  #include "main.h"
>  
>  #ifndef MAX_QUEUES
> @@ -56,6 +57,14 @@
>  #define RTE_TEST_TX_DESC_DEFAULT 512
>  
>  #define INVALID_PORT_ID 0xFF
> +#define INVALID_DMA_ID -1
> +
> +#define MAX_VHOST_DEVICE 1024
> +#define DMA_RING_SIZE 4096
> +
> +struct dma_for_vhost dma_bind[MAX_VHOST_DEVICE];
> +struct rte_vhost_async_dma_info dma_config[RTE_DMADEV_DEFAULT_MAX];
> +static int dma_count;
>  
>  /* mask of enabled ports */
>  static uint32_t enabled_port_mask = 0;
> @@ -96,8 +105,6 @@ static int builtin_net_driver;
>  
>  static int async_vhost_driver;
>  
> -static char *dma_type;
> -
>  /* Specify timeout (in useconds) between retries on RX. */
>  static uint32_t burst_rx_delay_time = BURST_RX_WAIT_US;
>  /* Specify the number of retries on RX. */
> @@ -196,13 +203,134 @@ struct vhost_bufftable *vhost_txbuff[RTE_MAX_LCORE * 
> MAX_VHOST_DEVICE];
>  #define MBUF_TABLE_DRAIN_TSC ((rte_get_tsc_hz() + US_PER_S - 1) \
>                                / US_PER_S * BURST_TX_DRAIN_US)
>  
> +static inline bool
> +is_dma_configured(int16_t dev_id)
> +{
> +     int i;
> +
> +     for (i = 0; i < dma_count; i++) {
> +             if (dma_config[i].dev_id == dev_id) {
> +                     return true;
> +             }
> +     }
> +     return false;
> +}
> +
>  static inline int
>  open_dma(const char *value)
>  {
> -     if (dma_type != NULL && strncmp(dma_type, "ioat", 4) == 0)
> -             return open_ioat(value);
> +     struct dma_for_vhost *dma_info = dma_bind;
> +     char *input = strndup(value, strlen(value) + 1);
> +     char *addrs = input;
> +     char *ptrs[2];
> +     char *start, *end, *substr;
> +     int64_t vid, vring_id;
> +
> +     struct rte_dma_info info;
> +     struct rte_dma_conf dev_config = { .nb_vchans = 1 };
> +     struct rte_dma_vchan_conf qconf = {
> +             .direction = RTE_DMA_DIR_MEM_TO_MEM,
> +             .nb_desc = DMA_RING_SIZE
> +     };
> +
> +     int dev_id;
> +     int ret = 0;
> +     uint16_t i = 0;
> +     char *dma_arg[MAX_VHOST_DEVICE];
> +     int args_nr;
> +
> +     while (isblank(*addrs))
> +             addrs++;
> +     if (*addrs == '\0') {
> +             ret = -1;
> +             goto out;
> +     }
> +
> +     /* process DMA devices within bracket. */
> +     addrs++;
> +     substr = strtok(addrs, ";]");
> +     if (!substr) {
> +             ret = -1;
> +             goto out;
> +     }
> +
> +     args_nr = rte_strsplit(substr, strlen(substr),
> +                     dma_arg, MAX_VHOST_DEVICE, ',');
> +     if (args_nr <= 0) {
> +             ret = -1;
> +             goto out;
> +     }
> +
> +     while (i < args_nr) {
> +             char *arg_temp = dma_arg[i];
> +             uint8_t sub_nr;
> +
> +             sub_nr = rte_strsplit(arg_temp, strlen(arg_temp), ptrs, 2, '@');
> +             if (sub_nr != 2) {
> +                     ret = -1;
> +                     goto out;
> +             }
> +
> +             start = strstr(ptrs[0], "txd");
Hi JiaYu, 
    it looks the parameter checking ignore the "rxd" case ? I think if
    the patch enable enqueue/dequeue at same time. rxd is needed for
    DMAS parameters.
Regards
Liang
 

Reply via email to