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 C88F2A0544; Fri, 27 May 2022 20:18:38 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C2DC1427F5; Fri, 27 May 2022 20:18:37 +0200 (CEST) Received: from mail-lj1-f182.google.com (mail-lj1-f182.google.com [209.85.208.182]) by mails.dpdk.org (Postfix) with ESMTP id 0AE0F40E78 for ; Fri, 27 May 2022 20:18:33 +0200 (CEST) Received: by mail-lj1-f182.google.com with SMTP id t13so3350269ljd.6 for ; Fri, 27 May 2022 11:18:33 -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=mQm9/psUBbj3VA+ThTxPoL6xSV4DAJMQOjGqgw2fCm4=; b=0ed8pSL34PtAI2XZXb4vnvCpNhAW1pCu539vpQ8Det3lbRlYnQCdpK7ITqvQ/AOWUk N8mqhJkm98Hqxf3XIlrs/AZ3pFwe/QPKu5k+DZSx/No4BbI4rh1VH3ZVrHjFJMV7ABYn siaWtYSCNFjysA73eKdPFCOCjXDV4Kp+M5heKqmsb37C+Yx8mYuKt0YPdTWlJ9FOx3PN JUvmG5ygccTPzj2OsPvETmJenzJ/5oe8zX4n0HbXj2n9N8i1Gr3U7dvOn/7pvdkKZRjt 6W6hgc0K+qr38natVbQxDse5CD3mrjcKO4jT/g+ALJSmj0seIe3ghANni0xNcq4RhJoz oDsw== 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=mQm9/psUBbj3VA+ThTxPoL6xSV4DAJMQOjGqgw2fCm4=; b=H0ws0V35cYZstIEIILohBIoELK+72YIs5DgdK08oOSE5TeBbqCyLp1fLr6JfoS13eK fKcHYdIx41VMIKZ2kvk9XmmIfXSMe6G8kF8gEDB7C/zPytdRQb2PNlavYjrzSsOHJtgx op5WUbeRBwmeN2Kl5+oZQu1yuYTxkUhOwx4EpmApXmL15fa5YJRoN+/wAp/XFK+NoWgY eli9BhEVW9JKxWd3mdTZP57X1IWclGRsnjvfZzpvYgrArmhBDoJ0bjfnKonIwjXZOU3l NV83CTwacrkMG6tjsQwvrIoPCYMP0H57goyVDOAcoljq4PlRjdW0Gj8Z1XWALIkAH0RM w1Gg== X-Gm-Message-State: AOAM530eRNSaI2fOvuMtz/wF/t0AYLLBprAdRIqcnSAMtVITPuE/g3/w /3Dik8kKJTa3zVfJQKOFiMt0dQ== X-Google-Smtp-Source: ABdhPJz5p/q4b5zt8DP9Ap539zV/zaY207y6ZcqOHAI7vsDrFXw2RJpZAT0LBbBRxYbo0v9VBAQIIg== X-Received: by 2002:a05:651c:b29:b0:255:3725:3c36 with SMTP id b41-20020a05651c0b2900b0025537253c36mr2996459ljr.226.1653675512541; Fri, 27 May 2022 11:18:32 -0700 (PDT) Received: from localhost.localdomain (89-73-146-138.dynamic.chello.pl. [89.73.146.138]) by smtp.gmail.com with ESMTPSA id f17-20020a193811000000b0047255d211a5sm958545lfa.212.2022.05.27.11.18.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 May 2022 11:18:32 -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 v2 2/2] lpm: add a scalar version of lookupx4 function Date: Fri, 27 May 2022 20:18:22 +0200 Message-Id: <20220527181822.716758-2-kda@semihalf.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220527181822.716758-1-kda@semihalf.com> References: <20220510115824.457885-1-kda@semihalf.com> <20220527181822.716758-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 | 36 ++++++++++++++++++++++++++ 4 files changed, 45 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..2fc0e19161 --- /dev/null +++ b/lib/lpm/rte_lpm_scalar.h @@ -0,0 +1,36 @@ +/* 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 i, ret; + + for (i = 0; i < 4; i++) { + ret = rte_lpm_lookup(lpm, ((rte_xmm_t)ip).u32[i], &nh); + hop[i] = (ret == 0) ? nh : defv; + } +} + +#ifdef __cplusplus +} +#endif + +#endif /* _RTE_LPM_SCALAR_H_ */ -- 2.30.2