From patchwork Mon May 11 18:48:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ferruh Yigit X-Patchwork-Id: 70092 X-Patchwork-Delegate: ferruh.yigit@amd.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 23266A0350; Mon, 11 May 2020 20:49:05 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 078DC1C19E; Mon, 11 May 2020 20:49:05 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id 227771C0DA for ; Mon, 11 May 2020 20:49:02 +0200 (CEST) IronPort-SDR: YZTcGDNS148sNt+eG7fjrYs0B8UaCZodun9lrRvTVKQ7N0tWFLvtuiIt1iGUZr2CDlV8qUe4kw q4jI2pZVR9DA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2020 11:49:01 -0700 IronPort-SDR: //WJIUJ6UerYcvY4TRkbPQGPDsJaRpEng0yzcGEJiLLLe1oWyfsSOM8f7rZsRGFKkzq2JJ8eHb NwMTcHtOBf1Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,381,1583222400"; d="scan'208";a="409015929" Received: from silpixa00399752.ir.intel.com (HELO silpixa00399752.ger.corp.intel.com) ([10.237.222.180]) by orsmga004.jf.intel.com with ESMTP; 11 May 2020 11:48:59 -0700 From: Ferruh Yigit To: Maxime Coquelin , Zhihong Wang , Xiaolong Ye , Marvin Liu Cc: dev@dpdk.org, Ferruh Yigit , Thomas Monjalon , David Marchand , Bruce Richardson , Radu Nicolau , Luca Boccassi Date: Mon, 11 May 2020 19:48:57 +0100 Message-Id: <20200511184857.614820-1-ferruh.yigit@intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200511144720.241224-1-maxime.coquelin@redhat.com> References: <20200511144720.241224-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2] net/virtio: fix AVX512 datapath selection 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" From: Maxime Coquelin The AVX512 packed ring datapath selection was only done at build time, but it should also be checked at runtime that the CPU supports it. This patch add a CPU flags check so that non-vectorized path is selected at runtime if AVX512 is not supported. Also in meson build enable vectorization only for relevant file, not for all driver. Fixes: ccb10995c2ad ("net/virtio: add election for vectorized path") Signed-off-by: Maxime Coquelin Signed-off-by: Ferruh Yigit Acked-by: Maxime Coquelin --- Cc: Bruce Richardson Cc: Radu Nicolau Cc: Luca Boccassi For meson I mainly adapted implementation from other driver, not able to test or verify myself. --- drivers/net/virtio/meson.build | 9 +++++++-- drivers/net/virtio/virtio_ethdev.c | 6 ++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/net/virtio/meson.build b/drivers/net/virtio/meson.build index 5cc529f6aa..3fd6051f4b 100644 --- a/drivers/net/virtio/meson.build +++ b/drivers/net/virtio/meson.build @@ -11,8 +11,14 @@ deps += ['kvargs', 'bus_pci'] if arch_subdir == 'x86' if not machine_args.contains('-mno-avx512f') if cc.has_argument('-mavx512f') and cc.has_argument('-mavx512vl') and cc.has_argument('-mavx512bw') - cflags += ['-mavx512f', '-mavx512bw', '-mavx512vl'] cflags += ['-DCC_AVX512_SUPPORT'] + virtio_avx512_lib = static_library('virtio_avx512_lib', + 'virtio_rxtx_packed_avx.c', + dependencies: [static_rte_ethdev, + static_rte_kvargs, static_rte_bus_pci], + include_directories: includes, + c_args: [cflags, '-mavx512f', '-mavx512bw', '-mavx512vl']) + objs += virtio_avx512_lib.extract_objects('virtio_rxtx_packed_avx.c') if (toolchain == 'gcc' and cc.version().version_compare('>=8.3.0')) cflags += '-DVHOST_GCC_UNROLL_PRAGMA' elif (toolchain == 'clang' and cc.version().version_compare('>=3.7.0')) @@ -20,7 +26,6 @@ if arch_subdir == 'x86' elif (toolchain == 'icc' and cc.version().version_compare('>=16.0.0')) cflags += '-DVHOST_ICC_UNROLL_PRAGMA' endif - sources += files('virtio_rxtx_packed_avx.c') endif endif sources += files('virtio_rxtx_simple_sse.c') diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index 312871cb48..49ccef12c7 100644 --- a/drivers/net/virtio/virtio_ethdev.c +++ b/drivers/net/virtio/virtio_ethdev.c @@ -1965,8 +1965,10 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev) PMD_DRV_LOG(INFO, "building environment do not support packed ring vectorized"); #else - hw->use_vec_rx = 1; - hw->use_vec_tx = 1; + if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F)) { + hw->use_vec_rx = 1; + hw->use_vec_tx = 1; + } #endif } }