DPDK patches and discussions
 help / color / mirror / Atom feed
From: Cheng Jiang <Cheng1.jiang@intel.com>
To: maxime.coquelin@redhat.com, chenbo.xia@intel.com
Cc: dev@dpdk.org, patrick.fu@intel.com, YvonneX.Yang@intel.com,
	david.marchand@redhat.com, Jiayu.Hu@intel.com,
	Cheng Jiang <Cheng1.jiang@intel.com>
Subject: [dpdk-dev] [PATCH v2] examples/vhost: fix ioat dependency issue
Date: Thu, 12 Nov 2020 05:16:30 +0000
Message-ID: <20201112051630.983-1-Cheng1.jiang@intel.com> (raw)
In-Reply-To: <20201111111957.46090-1-Cheng1.jiang@intel.com>

Fix vhost-switch compiling issue when ioat dependency is missing.
Change 'RTE_x86' check into 'RTE_RAW_IOAT' check in meson build file
and update Makefile. Clean some codes.

Signed-off-by: Cheng Jiang <Cheng1.jiang@intel.com>
---
v2:
 * Cleaned some codes
 * Changed RTE_RAW_IOAT check method in Makefile
 * Added ioat function definition when RTE_RAW_IOAT is missing

 examples/vhost/Makefile    |  5 +++++
 examples/vhost/ioat.h      | 32 +++++++++++++++++++++++++-------
 examples/vhost/main.c      | 22 +++++++++++-----------
 examples/vhost/meson.build |  2 +-
 4 files changed, 42 insertions(+), 19 deletions(-)

diff --git a/examples/vhost/Makefile b/examples/vhost/Makefile
index cec59d0e0..cbe56f742 100644
--- a/examples/vhost/Makefile
+++ b/examples/vhost/Makefile
@@ -28,6 +28,11 @@ CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
 LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk)
 LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk)

+HAS_RAW_IOAT=$(shell echo RTE_RAW_IOAT | $(CPP) $(CFLAGS) -P - | tail -1)
+ifeq ($(HAS_RAW_IOAT), 1)
+SRCS-y += ioat.c
+endif
+
 CFLAGS += -DALLOW_EXPERIMENTAL_API

 build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
diff --git a/examples/vhost/ioat.h b/examples/vhost/ioat.h
index 9664fcc3a..d6e1e2e07 100644
--- a/examples/vhost/ioat.h
+++ b/examples/vhost/ioat.h
@@ -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_ */
diff --git a/examples/vhost/main.c b/examples/vhost/main.c
index 59a1aff07..4dc6102ab 100644
--- a/examples/vhost/main.c
+++ b/examples/vhost/main.c
@@ -1294,13 +1294,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,
@@ -1342,10 +1335,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;
diff --git a/examples/vhost/meson.build b/examples/vhost/meson.build
index 24f1f7131..d5388a795 100644
--- a/examples/vhost/meson.build
+++ b/examples/vhost/meson.build
@@ -15,7 +15,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
--
2.29.2


  parent reply	other threads:[~2020-11-12  5:25 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-11 11:19 [dpdk-dev] [PATCH v1] " Cheng Jiang
2020-11-11 14:36 ` David Marchand
2020-11-11 15:03   ` Bruce Richardson
2020-11-12  7:14   ` Jiang, Cheng1
2020-11-12  9:31     ` Bruce Richardson
2020-11-12  9:39       ` David Marchand
2020-11-12 10:22         ` Bruce Richardson
2020-11-12  5:16 ` Cheng Jiang [this message]
2020-11-12  7:21 ` [dpdk-dev] [PATCH v3] " Cheng Jiang
2020-11-12  9:36   ` David Marchand
2020-11-12 10:28     ` Bruce Richardson
2020-11-12 11:29       ` Jiang, Cheng1
2020-11-12 12:02         ` Bruce Richardson
2020-11-12 14:06           ` Jiang, Cheng1
2020-11-12 13:47 ` [dpdk-dev] [PATCH v4] " Cheng Jiang
2020-11-12 15:01   ` Bruce Richardson
2020-11-12 15:55     ` Jiang, Cheng1
2020-11-12 15:49 ` [dpdk-dev] [PATCH v5] " Cheng Jiang
2020-11-12 16:01   ` Bruce Richardson
2020-11-12 16:51   ` Maxime Coquelin
2020-11-12 18:18   ` David Marchand
2020-11-13  8:40   ` Maxime Coquelin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201112051630.983-1-Cheng1.jiang@intel.com \
    --to=cheng1.jiang@intel.com \
    --cc=Jiayu.Hu@intel.com \
    --cc=YvonneX.Yang@intel.com \
    --cc=chenbo.xia@intel.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=maxime.coquelin@redhat.com \
    --cc=patrick.fu@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git