From patchwork Thu Nov 12 13:47:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jiang, Cheng1" X-Patchwork-Id: 84060 X-Patchwork-Delegate: maxime.coquelin@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 5354AA09D3; Thu, 12 Nov 2020 14:56:49 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 362DB56A3; Thu, 12 Nov 2020 14:56:48 +0100 (CET) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id DBCA44CA6 for ; Thu, 12 Nov 2020 14:56:45 +0100 (CET) IronPort-SDR: i+Ap3Yu6IDjF41At4/ZTYWfto+epalc6CNWacC1lfSe3/C6A9KU1EPzgf1p6zU3HDxvVCzlL/T C2fvLikKUf9Q== X-IronPort-AV: E=McAfee;i="6000,8403,9802"; a="169523771" X-IronPort-AV: E=Sophos;i="5.77,472,1596524400"; d="scan'208";a="169523771" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Nov 2020 05:56:43 -0800 IronPort-SDR: 1kbShqS6KVPR1pUQWuQDQrBW4VIR5l+Ae+/nQ32V4TC/PDxJXZ8wWEEACBxclxqU18qUdQde3l 4I//mO/qDeug== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,472,1596524400"; d="scan'208";a="309227224" Received: from dpdk_jiangcheng.sh.intel.com ([10.67.119.112]) by fmsmga007.fm.intel.com with ESMTP; 12 Nov 2020 05:56:40 -0800 From: Cheng Jiang 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, bruce.richardson@intel.com, Jiayu.Hu@intel.com, Cheng Jiang Date: Thu, 12 Nov 2020 13:47:54 +0000 Message-Id: <20201112134754.96530-1-Cheng1.jiang@intel.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201111111957.46090-1-Cheng1.jiang@intel.com> References: <20201111111957.46090-1-Cheng1.jiang@intel.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v4] examples/vhost: fix ioat dependency issue X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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") Signed-off-by: Cheng Jiang Acked-by: Bruce Richardson --- v4: * Use macros in ioat.c for conditional compilation instead of changing Makefile. v3: * Added fixes lines in commit log. 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 | 2 +- examples/vhost/ioat.c | 6 ++++++ examples/vhost/ioat.h | 32 +++++++++++++++++++++++++------- examples/vhost/main.c | 22 +++++++++++----------- examples/vhost/meson.build | 2 +- 5 files changed, 44 insertions(+), 20 deletions(-) -- 2.29.2 diff --git a/examples/vhost/Makefile b/examples/vhost/Makefile index cec59d0e0..8c969caaa 100644 --- a/examples/vhost/Makefile +++ b/examples/vhost/Makefile @@ -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) diff --git a/examples/vhost/ioat.c b/examples/vhost/ioat.c index b2c74f653..6f87d7bba 100644 --- a/examples/vhost/ioat.c +++ b/examples/vhost/ioat.c @@ -1,13 +1,17 @@ /* SPDX-License-Identifier: BSD-3-Clause * Copyright(c) 2010-2020 Intel Corporation */ +#ifdef RTE_RAW_IOAT #include #include +#endif /* RTE_RAW_IOAT */ #include #include "ioat.h" #include "main.h" +#ifdef RTE_RAW_IOAT + struct dma_for_vhost dma_bind[MAX_VHOST_DEVICE]; struct packet_tracker { @@ -199,3 +203,5 @@ ioat_check_completed_copies_cb(int vid, uint16_t queue_id, /* Opaque data is not supported */ return -1; } + +#endif /* RTE_RAW_IOAT */ 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