examples/vhost: fix ioat dependency
authorCheng Jiang <cheng1.jiang@intel.com>
Thu, 12 Nov 2020 15:49:02 +0000 (15:49 +0000)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 13 Nov 2020 18:43:26 +0000 (19:43 +0100)
Fix vhost-switch compiling issue when ioat dependency is missing.
Change 'RTE_x86' check into 'RTE_RAW_IOAT' check in meson build file.
Use 'RTE_RAW_IOAT' to control conditional compiling in source file.
Clean some codes.

Fixes: abec60e7115d ("examples/vhost: support vhost async data path")
Fixes: 3a04ecb21420 ("examples/vhost: add async vhost args parsing")

Reported-by: David Marchand <david.marchand@redhat.com>
Signed-off-by: Cheng Jiang <cheng1.jiang@intel.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Tested-by: David Marchand <david.marchand@redhat.com>
examples/vhost/Makefile
examples/vhost/ioat.c
examples/vhost/ioat.h
examples/vhost/main.c
examples/vhost/meson.build

index cec59d0..8c969ca 100644 (file)
@@ -5,7 +5,7 @@
 APP = vhost-switch
 
 # all source are stored in SRCS-y
-SRCS-y := main.c virtio_net.c
+SRCS-y := main.c virtio_net.c ioat.c
 
 # Build using pkg-config variables if possible
 ifneq ($(shell pkg-config --exists libdpdk && echo 0),0)
index 720c0b0..71d8a1f 100644 (file)
@@ -1,9 +1,11 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  * Copyright(c) 2010-2020 Intel Corporation
  */
+
+#include <sys/uio.h>
+#ifdef RTE_RAW_IOAT
 #include <rte_rawdev.h>
 #include <rte_ioat_rawdev.h>
-#include <sys/uio.h>
 
 #include "ioat.h"
 #include "main.h"
@@ -208,3 +210,5 @@ ioat_check_completed_copies_cb(int vid, uint16_t queue_id,
        /* Opaque data is not supported */
        return -1;
 }
+
+#endif /* RTE_RAW_IOAT */
index 9664fcc..d6e1e2e 100644 (file)
@@ -24,14 +24,8 @@ struct dma_for_vhost {
        uint16_t nr;
 };
 
-#ifdef RTE_ARCH_X86
+#ifdef RTE_RAW_IOAT
 int open_ioat(const char *value);
-#else
-static int open_ioat(const char *value __rte_unused)
-{
-       return -1;
-}
-#endif
 
 uint32_t
 ioat_transfer_data_cb(int vid, uint16_t queue_id,
@@ -42,4 +36,28 @@ uint32_t
 ioat_check_completed_copies_cb(int vid, uint16_t queue_id,
                struct rte_vhost_async_status *opaque_data,
                uint16_t max_packets);
+#else
+static int open_ioat(const char *value __rte_unused)
+{
+       return -1;
+}
+
+static uint32_t
+ioat_transfer_data_cb(int vid __rte_unused, uint16_t queue_id __rte_unused,
+               struct rte_vhost_async_desc *descs __rte_unused,
+               struct rte_vhost_async_status *opaque_data __rte_unused,
+               uint16_t count __rte_unused)
+{
+       return -1;
+}
+
+static uint32_t
+ioat_check_completed_copies_cb(int vid __rte_unused,
+               uint16_t queue_id __rte_unused,
+               struct rte_vhost_async_status *opaque_data __rte_unused,
+               uint16_t max_packets __rte_unused)
+{
+       return -1;
+}
+#endif
 #endif /* _IOAT_H_ */
index ec88874..8d8c303 100644 (file)
@@ -1300,13 +1300,6 @@ new_device(int vid)
        int lcore, core_add = 0;
        uint32_t device_num_min = num_devices;
        struct vhost_dev *vdev;
-
-       struct rte_vhost_async_channel_ops channel_ops = {
-               .transfer_data = ioat_transfer_data_cb,
-               .check_completed_copies = ioat_check_completed_copies_cb
-       };
-       struct rte_vhost_async_features f;
-
        vdev = rte_zmalloc("vhost device", sizeof(*vdev), RTE_CACHE_LINE_SIZE);
        if (vdev == NULL) {
                RTE_LOG(INFO, VHOST_DATA,
@@ -1348,10 +1341,17 @@ new_device(int vid)
                vid, vdev->coreid);
 
        if (async_vhost_driver) {
-               f.async_inorder = 1;
-               f.async_threshold = 256;
-               return rte_vhost_async_channel_register(vid, VIRTIO_RXQ,
-                       f.intval, &channel_ops);
+               struct rte_vhost_async_features f;
+               struct rte_vhost_async_channel_ops channel_ops;
+               if (strncmp(dma_type, "ioat", 4) == 0) {
+                       channel_ops.transfer_data = ioat_transfer_data_cb;
+                       channel_ops.check_completed_copies =
+                               ioat_check_completed_copies_cb;
+                       f.async_inorder = 1;
+                       f.async_threshold = 256;
+                       return rte_vhost_async_channel_register(vid, VIRTIO_RXQ,
+                               f.intval, &channel_ops);
+               }
        }
 
        return 0;
index 7e5b9d9..9d9947c 100644 (file)
@@ -17,7 +17,7 @@ sources = files(
        'main.c', 'virtio_net.c'
 )
 
-if dpdk_conf.has('RTE_ARCH_X86')
+if dpdk_conf.has('RTE_RAW_IOAT')
        deps += 'raw_ioat'
        sources += files('ioat.c')
 endif