From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7DB35454AA; Wed, 19 Jun 2024 18:41:21 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1F231402C6; Wed, 19 Jun 2024 18:41:21 +0200 (CEST) Received: from mail-qk1-f172.google.com (mail-qk1-f172.google.com [209.85.222.172]) by mails.dpdk.org (Postfix) with ESMTP id 481C640289 for ; Wed, 19 Jun 2024 18:41:19 +0200 (CEST) Received: by mail-qk1-f172.google.com with SMTP id af79cd13be357-797a7f9b552so1522485a.0 for ; Wed, 19 Jun 2024 09:41:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1718815278; x=1719420078; darn=dpdk.org; h=user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:mail-followup-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=wXFGreIdgFzLLcC+xftNDO+d7yKRqdi24egdrOVpgvo=; b=Rn/g/uo+xG5i+GSpu5sDsPiMFJqdJY230YPITuShqFTFPgszsgjxyBkiZ00hfHdvy8 wj0Z5FNmRCjZ3/TGdPzpkcQOVvfhSvxS/jS+/qRyrUAWbBHTc++JhAFX9kRLX+KmJYYa bX+/0RKv/NvJQDHtBE9QRDgZooiHamx1EQpSeAuVzhHv0d3bznR23WcyR0YL7Dq7/2TV VS6+UkESxkSmu5JBPfQkp8n9xOxfSPUjRk5ZflUgGA1Iur7KdiTX7tt+I4J1IrnZix3T 7mTXvXQaQGlQM+ArB7VpLE39mCIlbNW1iTN4PxOTP1rhCoWkPQX2gnief7hcaTjFp7KJ W1ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718815278; x=1719420078; h=user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:mail-followup-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wXFGreIdgFzLLcC+xftNDO+d7yKRqdi24egdrOVpgvo=; b=ixw9D4kt8UUBMrG3y7pnu3Y5V3TDvfuKR33oMwjV7Zs2vceD5H5OogjPFByFAdytUL WseO3BhScecns87vRtw1+ZEZsCYtr92QfrhKdeqMLNyNMtdi++d/FXjrtWwQEgLQ0qJu dFGeoXU+KoUXGP/URBqaplLzb0OAk7qkfVwAkUbSC+YVfqmSPXFTjWaithiCuvmlzUEs LIizpxvf0BOatVhU2SIP5tI/DGwzkDzRX/u8eHtACl6sTzPqY+3b2tFabF4FVh+XK/ot J2ikzXbzJGuy8A8LG0TrgvQ0TUK3D5S6dkXNNsEMM80umov3FQhiKZkzS2STzQuk4gS7 Jdaw== X-Forwarded-Encrypted: i=1; AJvYcCU4pXs42fnfS3yN7nIo9CrdJb6YXfJyRHrKhn7lrwu93QL0NPYJQXG2cZb4kvrLF8Q8/LZs98w8dHUXj+Y= X-Gm-Message-State: AOJu0Yw88mTvZMDOCE3wfjpDnh5pOLpDQ4M+7R/+KHjCcwW44ImYa6S7 GVNBjrcFc3tQT1x0ANGa3Nl+Q14zz2GLWuqfow2ttGiydViwQH8REr4JBORw9dk= X-Google-Smtp-Source: AGHT+IH4uwpwi69NHz5++qGikKaVSUww4cDWNRnBhDM/2rqIPxGCZgPPskmjm2+m90PHCLDa8Rjt3w== X-Received: by 2002:a0c:e1c1:0:b0:6b4:f7b4:80c9 with SMTP id 6a1803df08f44-6b501eb4848mr33469676d6.52.1718815278353; Wed, 19 Jun 2024 09:41:18 -0700 (PDT) Received: from ste-uk-lab-gw ([79.173.157.19]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6b50c008816sm4082146d6.124.2024.06.19.09.41.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jun 2024 09:41:18 -0700 (PDT) Date: Wed, 19 Jun 2024 17:41:14 +0100 From: Daniel Gregory To: Morten =?utf-8?Q?Br=C3=B8rup?= , Stephen Hemminger Cc: Stanislaw Kardach , Bruce Richardson , dev@dpdk.org, Liang Ma , Punit Agrawal , Pengcheng Wang , Chunsong Feng Subject: RE: [PATCH 1/5] config/riscv: add flag for using Zbc extension Message-ID: <20240619164114.GA88106@ste-uk-lab-gw> Mail-Followup-To: Morten =?utf-8?Q?Br=C3=B8rup?= , Stephen Hemminger , Stanislaw Kardach , Bruce Richardson , dev@dpdk.org, Liang Ma , Punit Agrawal , Pengcheng Wang , Chunsong Feng References: <20240618174133.33457-1-daniel.gregory@bytedance.com> <20240618174133.33457-2-daniel.gregory@bytedance.com> <20240618130318.0efacceb@hermes.local> <98CBD80474FA8B44BF855DF32C47DC35E9F53C@smartserver.smartshare.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <98CBD80474FA8B44BF855DF32C47DC35E9F53C@smartserver.smartshare.dk> User-Agent: Mutt/1.10.1 (2018-07-13) X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On Wed, Jun 19, 2024 at 09:08:14AM +0200, Morten Brørup wrote: > > From: Stephen Hemminger [mailto:stephen@networkplumber.org] > 1/5] config/riscv: add flag for using Zbc extension > > > > On Tue, 18 Jun 2024 18:41:29 +0100 > > Daniel Gregory wrote: > > > > > diff --git a/config/riscv/meson.build b/config/riscv/meson.build > > > index 07d7d9da23..4bda4089bd 100644 > > > --- a/config/riscv/meson.build > > > +++ b/config/riscv/meson.build > > > @@ -26,6 +26,13 @@ flags_common = [ > > > # read from /proc/device-tree/cpus/timebase-frequency. This property is > > > # guaranteed on Linux, as riscv time_init() requires it. > > > ['RTE_RISCV_TIME_FREQ', 0], > > > + > > > + # Use RISC-V Carry-less multiplication extension (Zbc) for hardware > > > + # implementations of CRC-32C (lib/hash/rte_crc_riscv64.h), CRC-32 and > > CRC-16 > > > + # (lib/net/net_crc_zbc.c). Requires intrinsics available in GCC 14.1.0+ > > and > > > + # Clang 18.1.0+ > > > + # Make sure to add '_zbc' to your target's -march below > > > + ['RTE_RISCV_ZBC', false], > > > ] > > > > Please do not add more config options via compile flags. > > It makes it impossible for distros to ship one version. > > > > Instead, detect at compile or runtime > > Build time detection is not possible for cross builds. > How about build time detection based on the target's configured instruction set (either specified by cross-file or passed in through -Dinstruction_set)? We could have a map from extensions present in the ISA string to compile flags that should be enabled. I suggested this whilst discussing a previous patch adding support for the Zawrs extension, but haven't heard back from Stanisław yet: https://lore.kernel.org/dpdk-dev/20240520094854.GA3672529@ste-uk-lab-gw/ As for runtime detection, newer kernel versions have a hardware probing interface for detecting the presence of extensions, support could be added to rte_cpuflags.c? https://docs.kernel.org/arch/riscv/hwprobe.html In combination, distros on newer kernels could ship a version that has these optimisations baked in that falls back to a generic implementation when the extension is detected to not be present, and systems without the latest GCC/Clang can still compile by specifying a target ISA that doesn't include "_zbc".