From patchwork Fri May 27 18:18:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanislaw Kardach X-Patchwork-Id: 111988 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 02B43A0544; Fri, 27 May 2022 20:18:34 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DBBD1410DC; Fri, 27 May 2022 20:18:33 +0200 (CEST) Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com [209.85.167.41]) by mails.dpdk.org (Postfix) with ESMTP id 14CC740E78 for ; Fri, 27 May 2022 20:18:32 +0200 (CEST) Received: by mail-lf1-f41.google.com with SMTP id u23so8090987lfc.1 for ; Fri, 27 May 2022 11:18:32 -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=DUEGBou937xXZO2hVTTU9+mNu3KmWeD84Qaf9kgbcvI=; b=GMqJtRqzNDC7bUTP20Af43SMigyNP0/8O3CpuBENpXpSbgSrQPlb6peRG3TSVcTdzs K9zMZVzzYqaImKfUq9kibCtEWjBZ7U8rEsbaY4nvPDNwVlDk2HpbnJEMvBKGtmG8cDfp psBv39/yI/KElvUx81wWBZQP9gicNoxxe0F0yyjyEeDAD5cXz0gynmxX4HMmoNtiL5nB 4xLVFe4Nus9+7C7kxlaDUNYiGnrClRPHEHN6mXTbEbcu9rPFx6AENjaE9zG3/9dp61sB sKAFX/tbXfKSuNw4Vm6BdGR/10WwEANd74T9wGmv9W5rOsudTRpq6ScBmFeeKEWPPFMN 6q2Q== 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=DUEGBou937xXZO2hVTTU9+mNu3KmWeD84Qaf9kgbcvI=; b=o017YG3WGNEy+Ew2MqKEZHqucmPzmbPmrb7KT/P+swfRgh0XKeIcaY5qmHDNyM+LeV Wb1LqwKJCoPtkxiyRPnBWSf+qecZRcIaQ9lIjfw9WQChGU6eCAekB7RKU9RIQY/vYU+X nO/mQKm/k7Yx3VrOZNuJWI00Tz61cLnLelBSIiqKlX23q1Ya8X3iNGNcy2c5jUbK8UkT jxn5EJuJ4VXl8Lpl4oGHTNPhtEHbDVRiPHTtZpInP+z/1kVKQQwTIDoLDcmZ74ntw4qP m+SGD7feVok0F9FAAo0SBwI1qNSMAeXRLq1UjRo5nw1grdeOerGVJ5AhuUzFahoBXglw GBxw== X-Gm-Message-State: AOAM531qW/AoDdCphPv4IgiNxz02WXnI03dq9PUleGFQXNigY6OOj2yt RJAo6yjTWwY8//DKWfcw5oUqBA== X-Google-Smtp-Source: ABdhPJzXNM9RXCYzVnUTPeFC7vjrzaYFMLcJD6yMRmJhur632o63C4JIBBXLkJRrPR4s8WNX4JRG+g== X-Received: by 2002:a19:7617:0:b0:478:66a4:c61d with SMTP id c23-20020a197617000000b0047866a4c61dmr21491706lff.600.1653675511513; Fri, 27 May 2022 11:18:31 -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.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 May 2022 11:18:31 -0700 (PDT) From: Stanislaw Kardach To: Vladimir Medvedkin Cc: Stanislaw Kardach , dev@dpdk.org, Frank Zhao , Sam Grove , mw@semihalf.com, upstream@semihalf.com Subject: [PATCH v2 1/2] lpm: add const to lpm arg of rte_lpm_lookup Date: Fri, 27 May 2022 20:18:21 +0200 Message-Id: <20220527181822.716758-1-kda@semihalf.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220510115824.457885-1-kda@semihalf.com> References: <20220510115824.457885-1-kda@semihalf.com> MIME-Version: 1.0 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 All other rte_lpm_lookup* functions take lpm argument as a const. As the basic rte_lpm_lookup() performs the same function, it should also do that. As this function is inline, no API/ABI change happens. Signed-off-by: Stanislaw Kardach --- lib/lpm/rte_lpm.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/lpm/rte_lpm.h b/lib/lpm/rte_lpm.h index eb91960e81..1cf863a146 100644 --- a/lib/lpm/rte_lpm.h +++ b/lib/lpm/rte_lpm.h @@ -279,7 +279,7 @@ rte_lpm_delete_all(struct rte_lpm *lpm); * -EINVAL for incorrect arguments, -ENOENT on lookup miss, 0 on lookup hit */ static inline int -rte_lpm_lookup(struct rte_lpm *lpm, uint32_t ip, uint32_t *next_hop) +rte_lpm_lookup(const struct rte_lpm *lpm, uint32_t ip, uint32_t *next_hop) { unsigned tbl24_index = (ip >> 8); uint32_t tbl_entry; From patchwork Fri May 27 18:18:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanislaw Kardach X-Patchwork-Id: 111989 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org 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 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_ */