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 A3168A0540; Mon, 30 May 2022 20:24:51 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C71F540E78; Mon, 30 May 2022 20:24:50 +0200 (CEST) Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) by mails.dpdk.org (Postfix) with ESMTP id CF26E400D6 for ; Mon, 30 May 2022 20:24:46 +0200 (CEST) Received: by mail-lf1-f44.google.com with SMTP id u30so17921024lfm.9 for ; Mon, 30 May 2022 11:24:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=14c3KJ4IJfF1PNTl+QVXJy/Xsp3AwEHttVhlWsVoYFY=; b=aeXi+zHrClr7MKWqtj7pOUAFe2Sn4aEcjPnhgk6qXkShjGI8unlpWOal4WAUXe6dpc W8rhpXFEuekVp2sumZoGQASiKDZwgrrDdvCTDQiJu1Vzdbosn8ad4wLeu+wC3pk08HUI 5Y9xa5UuZq4hOiRjbjXHnPSIQ5yymaNgBcvZOdO8NSwYQLAPLlTX57GmYavbSxpwEUTg xr7KTmpjFan8HQI27qbemDvlU34f91X2+HGTFVT8VdcIbVRf0nGaTIzu1RXeNT1ePlzA f4SLttoRDYYLSkcOM/eV9jKOgDyOHRJ+GT5M5z67jWbYyX3VcXj4U44mrYEeA5tXCf2P 8feg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=14c3KJ4IJfF1PNTl+QVXJy/Xsp3AwEHttVhlWsVoYFY=; b=q+Ix5pJL353OIGw5BnoQAmqcxgFSKfBp5BqbgPvwFjhiKtQbwHab0s6nOZ1dNfF6BJ fhOcl8xm25lWKrVARbHrCWJdmrZ7a1hYHZzRVyA8aqbFxxkH3hTO6LA/44fGNux8cVcx fqF8Puc2pufMtzHDNrjP6fcTFZdlTNu6+TUxOnqKCoSD9wIyvB4qOLpScyjNkK8fFXQc pSGfk9d3nIPjvkKazP5uHuIVLOqj9fNCtAJmxZi5zNdj566NQsJ2qAS/Rjq/oGIf33D/ dXtki5zbL+61sbXJpDSz0+/6V5N6u4yKARe5ncJxLFem1TF9qc8EDu/1BvgOj200ComR oRCQ== X-Gm-Message-State: AOAM530U4aBJ0ARoIq9sNlAnxKT2MjnhmYBey0kvXXJqBuwzZOzH78Bn TItF9Tc5XrhKUgzAl+ZcwzbdoHi+ilg3JK/b X-Google-Smtp-Source: ABdhPJxKnHyQQJ6+3KUzYJYKYZIiGEXuuBKmUM28jd9vJ0i5tdeTM3CzsG8Fiq4F8aob4ziaBR+Vlw== X-Received: by 2002:a05:6512:118a:b0:478:a8b3:e1ee with SMTP id g10-20020a056512118a00b00478a8b3e1eemr19510392lfr.391.1653935086450; Mon, 30 May 2022 11:24:46 -0700 (PDT) Received: from localhost.localdomain (89-73-146-138.dynamic.chello.pl. [89.73.146.138]) by smtp.gmail.com with ESMTPSA id p16-20020a2eb990000000b00253d431466asm2665972ljp.96.2022.05.30.11.24.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 May 2022 11:24:45 -0700 (PDT) From: Stanislaw Kardach To: Vladimir Medvedkin Cc: Michal Mazurek , dev@dpdk.org, Frank Zhao , Sam Grove , mw@semihalf.com, upstream@semihalf.com, Stanislaw Kardach Subject: [PATCH v3 2/2] lpm: add a scalar version of lookupx4 function Date: Mon, 30 May 2022 20:24:37 +0200 Message-Id: <20220530182437.56853-2-kda@semihalf.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220530182437.56853-1-kda@semihalf.com> References: <20220527181822.716758-1-kda@semihalf.com> <20220530182437.56853-1-kda@semihalf.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 From: Michal Mazurek Add an implementation of the rte_lpm_lookupx4() function for platforms without support for vector operations. This will be useful in the upcoming RISC-V port as well as any platform which may want to start with a basic level of LPM support. Signed-off-by: Michal Mazurek Signed-off-by: Stanislaw Kardach --- doc/guides/rel_notes/release_22_07.rst | 5 ++++ lib/lpm/meson.build | 1 + lib/lpm/rte_lpm.h | 4 ++- lib/lpm/rte_lpm_scalar.h | 40 ++++++++++++++++++++++++++ 4 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 lib/lpm/rte_lpm_scalar.h diff --git a/doc/guides/rel_notes/release_22_07.rst b/doc/guides/rel_notes/release_22_07.rst index e49cacecef..0cf3f71269 100644 --- a/doc/guides/rel_notes/release_22_07.rst +++ b/doc/guides/rel_notes/release_22_07.rst @@ -104,6 +104,11 @@ New Features * ``RTE_EVENT_QUEUE_ATTR_WEIGHT`` * ``RTE_EVENT_QUEUE_ATTR_AFFINITY`` +* **Added scalar version of the LPM library.** + + * Added scalar implementation of ``rte_lpm_lookupx4``. This is a fall-back + implementation for platforms that don't support vector operations. + Removed Items ------------- diff --git a/lib/lpm/meson.build b/lib/lpm/meson.build index 78d91d3421..6b47361fce 100644 --- a/lib/lpm/meson.build +++ b/lib/lpm/meson.build @@ -14,6 +14,7 @@ headers = files('rte_lpm.h', 'rte_lpm6.h') indirect_headers += files( 'rte_lpm_altivec.h', 'rte_lpm_neon.h', + 'rte_lpm_scalar.h', 'rte_lpm_sse.h', 'rte_lpm_sve.h', ) diff --git a/lib/lpm/rte_lpm.h b/lib/lpm/rte_lpm.h index 1cf863a146..4f38864fde 100644 --- a/lib/lpm/rte_lpm.h +++ b/lib/lpm/rte_lpm.h @@ -405,8 +405,10 @@ rte_lpm_lookupx4(const struct rte_lpm *lpm, xmm_t ip, uint32_t hop[4], #endif #elif defined(RTE_ARCH_PPC_64) #include "rte_lpm_altivec.h" -#else +#elif defined(RTE_ARCH_X86) #include "rte_lpm_sse.h" +#else +#include "rte_lpm_scalar.h" #endif #ifdef __cplusplus diff --git a/lib/lpm/rte_lpm_scalar.h b/lib/lpm/rte_lpm_scalar.h new file mode 100644 index 0000000000..4ae1b6f0b8 --- /dev/null +++ b/lib/lpm/rte_lpm_scalar.h @@ -0,0 +1,40 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2022 StarFive + * Copyright(c) 2022 SiFive + * Copyright(c) 2022 Semihalf + */ + +#ifndef _RTE_LPM_SCALAR_H_ +#define _RTE_LPM_SCALAR_H_ + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +static inline void +rte_lpm_lookupx4(const struct rte_lpm *lpm, xmm_t ip, uint32_t hop[4], + uint32_t defv) +{ + uint32_t nh; + int ret; + + ret = rte_lpm_lookup(lpm, ((rte_xmm_t)ip).u32[0], &nh); + hop[0] = (ret == 0) ? nh : defv; + ret = rte_lpm_lookup(lpm, ((rte_xmm_t)ip).u32[1], &nh); + hop[1] = (ret == 0) ? nh : defv; + ret = rte_lpm_lookup(lpm, ((rte_xmm_t)ip).u32[2], &nh); + hop[2] = (ret == 0) ? nh : defv; + ret = rte_lpm_lookup(lpm, ((rte_xmm_t)ip).u32[3], &nh); + hop[3] = (ret == 0) ? nh : defv; +} + +#ifdef __cplusplus +} +#endif + +#endif /* _RTE_LPM_SCALAR_H_ */ -- 2.30.2