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 75C9CA0548; Wed, 1 Jun 2022 13:15:58 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 20E9E4281E; Wed, 1 Jun 2022 13:15:54 +0200 (CEST) Received: from mail-lj1-f181.google.com (mail-lj1-f181.google.com [209.85.208.181]) by mails.dpdk.org (Postfix) with ESMTP id 723384003F for ; Wed, 1 Jun 2022 13:15:52 +0200 (CEST) Received: by mail-lj1-f181.google.com with SMTP id e4so1580293ljb.13 for ; Wed, 01 Jun 2022 04:15:52 -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=sxOey0Yawo14jIKgVDt8IIcj/Ws0M9z6h5/62MV0dMk=; b=rNgv86uL5RN1IvlXf9Ri8qfJvvfasGpIlI0HrK4aFmOUY3B3HViNPduqJfDNFktrBQ NIxmv+V81BBa1me3ET4J6ax5HvX37j0zF7uaLd97PLAkP0swMUG5uJdGgchIiRHoPKqD 6T7Cn8NEPLL2DsnNaMoIZsHbZxh6Nx+QEnJrMnhpCdBKsrwkG9KN3Gwa6nFn/4juLYQB VyRpB7V8nYrb6qEB/sWO1RLrsrxKs9XC7ukW+4DgE+alD6RTBiC89jW6U50EtWp2N5sV N+ZSHLZz1eMm5XH3Ax2xskFAxtAuXOedd0oSeO7mZ6FRoAmN+w2y4cAJj73PV+W5v4O+ Ud9A== 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=sxOey0Yawo14jIKgVDt8IIcj/Ws0M9z6h5/62MV0dMk=; b=hsXKptHCL+Cu9TuX1cfe51whFoLZ1aa0s9vEpPQfOm34UAebqAATLHSnAA+dE9JJKw oL3vvhFW5prsluOB+UT3p6cKczR2Vp6D15XUFtTOaSSfo6ZR8iIPJiubizwNJ3qYhnUg i7fQfiuE6VXL1QaJJxd5xGh2zQe+EykNniiuUhoTHSJPZT2lyjNaRvnT0wdnvFEAB1Fz Owdf4xBM8++Q/5UvJuRXz3AIxGbM016Qt86ZV39C+Y9Pu8lWvhSyZXEVhnBQgY6OiUEj 7QutEoRfoYqBs5D2skXCm8Q0/6v9qk31iE52TYbHhpJ1XQGbq0YRSepOrT7Ncu0XYXWd VqDA== X-Gm-Message-State: AOAM530Ciosu8nu1fNVXnpLjKY2woW+qOnskkbT87GqHkYQOnXwHzDdV OOotBqrrOgLVJ25wrsN6GLcpLg== X-Google-Smtp-Source: ABdhPJyT1PqkC2catmpyP5tjc3M7J/O9Wppn1W8vdefr3R0sMAzbFGDZ11KzEGTt1YZqxcaJzGMTpA== X-Received: by 2002:a2e:95d7:0:b0:249:7117:b7ad with SMTP id y23-20020a2e95d7000000b002497117b7admr26642028ljh.85.1654082152009; Wed, 01 Jun 2022 04:15:52 -0700 (PDT) Received: from toster.semihalf.net (89-73-146-138.dynamic.chello.pl. [89.73.146.138]) by smtp.gmail.com with ESMTPSA id h16-20020a2e5310000000b0024f3d1dae87sm268553ljb.15.2022.06.01.04.15.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jun 2022 04:15:51 -0700 (PDT) From: Stanislaw Kardach To: Vladimir Medvedkin Cc: Michal Mazurek , dev@dpdk.org, Frank Zhao , Sam Grove , upstream@semihalf.com, Stanislaw Kardach Subject: [PATCH v4 2/2] lpm: add a scalar version of lookupx4 function Date: Wed, 1 Jun 2022 13:15:42 +0200 Message-Id: <20220601111542.401360-2-kda@semihalf.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220601111542.401360-1-kda@semihalf.com> References: <20220601111542.401360-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 | 37 ++++++++++++++++++++++++++ 4 files changed, 46 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..f0d9f37894 --- /dev/null +++ b/lib/lpm/rte_lpm_scalar.h @@ -0,0 +1,37 @@ +/* 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 + +#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