From patchwork Mon May 30 18:24:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanislaw Kardach X-Patchwork-Id: 112090 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 1994AA0540; Mon, 30 May 2022 20:24:47 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F1F2440689; Mon, 30 May 2022 20:24:46 +0200 (CEST) Received: from mail-lf1-f53.google.com (mail-lf1-f53.google.com [209.85.167.53]) by mails.dpdk.org (Postfix) with ESMTP id C0F98400D6 for ; Mon, 30 May 2022 20:24:45 +0200 (CEST) Received: by mail-lf1-f53.google.com with SMTP id u23so18016245lfc.1 for ; Mon, 30 May 2022 11:24:45 -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=58vPgQ/WtxHYosIEKZaI4ic7VbVZlZM9pWQ7lIzjfXYfBSbQ79WgjjrK2UotPxElYN EaUyQHVa0ATiWPGW/HLr5ahcJzcpcwUdftzMufVK2WeOMUwsj66eXcgIYaRHdAHp60/V X3QQmrTikN40SZIW9ZhtWdetCnl6qokh1nkNd7tSMgKSlMxbSkchJyJkQvB+ZHGI/Tsz GSbDjQG8ziWKF4grwgwYydjedNFodQqxtkdri2R7jVDSL6dZHo9xY9w0d2VvJwvHWw8K 8jsT43ZRmmwv4VAzuqhdrgoCSmMw4PG1+pThhUup2iWepE5pRLfOXDcZjAcVJfGfxBtH +hpw== 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=Z2n73l5GyX8mb/Vo1VU/5/eMr2Tvh3JKfOSlrUphAzaRHneZ8+bvHX2kYr+P0NDKSq xjd9e76laFUyGHr92uWQXdXvlTcTfAnFA5QKxl4zg9Wrvyt02vCT7vDb2OpMIVsX5Fjq Fsm4pCYTBX0J1bkvcHYMPY4ysSMO2hfdxLlWTDjdElzTlel4UwLmrHkUNkMaBhioRnhR wF4X/dJX/pvRFyU6M045qh4+eF+meS5Ga+Bee4DztK/euGPGf2O+tMi6RKERnTBOxHIc +JwTWy1yQFuELvlj+gKDdFiLQcvnBGsf9KV6QY+lh2Hy6ahLqF+Uvk038fp/GYJQYI7W qtwQ== X-Gm-Message-State: AOAM532CWUCGH4c33NnulPRCIFE60fr5hViGE+r/uGJMFV58LmZkv86o hESPT6lbcmfIyAilSHbilTeu5A== X-Google-Smtp-Source: ABdhPJwrbNPynrI3TlbOJSLLwcVUm73WIC6Y+NhAXlty9MMMFdXb/yOz3foY30KqtE8Qhf2gMeDQ6Q== X-Received: by 2002:a05:6512:1093:b0:478:9c38:a227 with SMTP id j19-20020a056512109300b004789c38a227mr21284948lfg.630.1653935085310; Mon, 30 May 2022 11:24:45 -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.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 May 2022 11:24:44 -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 v3 1/2] lpm: add const to lpm arg of rte_lpm_lookup Date: Mon, 30 May 2022 20:24:36 +0200 Message-Id: <20220530182437.56853-1-kda@semihalf.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220527181822.716758-1-kda@semihalf.com> References: <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 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 Acked-by: Stephen Hemminger Acked-by: Vladimir Medvedkin --- 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 Mon May 30 18:24:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanislaw Kardach X-Patchwork-Id: 112091 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 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 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 Acked-by: Vladimir Medvedkin --- 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_ */