From patchwork Wed Jun 1 11:15:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanislaw Kardach X-Patchwork-Id: 112224 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 9AFFCA0548; Wed, 1 Jun 2022 13:15:53 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 40EE140689; Wed, 1 Jun 2022 13:15:53 +0200 (CEST) Received: from mail-lj1-f176.google.com (mail-lj1-f176.google.com [209.85.208.176]) by mails.dpdk.org (Postfix) with ESMTP id 698894003F for ; Wed, 1 Jun 2022 13:15:51 +0200 (CEST) Received: by mail-lj1-f176.google.com with SMTP id 1so1606037ljp.8 for ; Wed, 01 Jun 2022 04:15:51 -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:mime-version :content-transfer-encoding; bh=wP7ttZT9Um0TPiISVA4+oTHyzspPKX95EJ/P1PjqSXo=; b=ILfUW6h9XHeDeQtmFt8azV4hxAxsbw+Dq+G0tLTJaNrdoJBMNUzKwzyQQsLVS18PQf F6RUri6XZl8xHUcsXx5jlPTDSwMtYu+VL3SLHwKaOk9UeJhE0fXZUCWgI+v8tsmqIV7s YELo+ASWr/++fXJqKOt7bAKXfqURW9CudegYzZOv4IarsVwHV5kZJ4VL/A4pbcWPDlif AIr4fHfQYF8qW9lqXSIiDNEr0jA1nUI80Csd71Whpb/dXTon2xXNgw0WJ1ouGH+awO3g HOqrDQ6Z0t/6g6JnMv9G8fHJ++zMaph8eRDfGNUy+r0xnmpjBKJSFaKKd8sqbMt+Lbcz q1+A== 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:mime-version :content-transfer-encoding; bh=wP7ttZT9Um0TPiISVA4+oTHyzspPKX95EJ/P1PjqSXo=; b=AVoaMkwDww31BV+NcjVHTPXXub5ZeJY6BzwZljWpGWmLunSSvqR285XY7g/13P9zX3 yu1bQBcxtzCTMAhZi2EIAPg+Da69m7uUTz9L0E0Wx8KZ5mL+MF7LIkbyZeGR7OZMAv0G q5AxRoldkLb962U1nMl0OBMCyQtpxgDGXN03HCiD0dOi3803O18ti3+RMHQl4SEdf+f1 PFUPZVFRccKVfrJ6vaiFq+DGt0ge8+1bb49P/ZRuQikVz5Gyiw5oogZcNjqFJTAq6N95 F6RN5/x2vitWgKP+mlb/uiljWylPZFxoEX+57zvnPMs4Nlww/Ao9QIhNxPwn7zj/FQJ1 wVQA== X-Gm-Message-State: AOAM532aZp9x0+j62QGe9I9apctdSutwE9X+HYsebRW022crn75XtM+m F08o+6bhF5Mz0859qhi7GcKXgw== X-Google-Smtp-Source: ABdhPJxQmeJapSh2+Tdk/VwyM98DBXdB8UrzPyQH27apadtSol50KiIkryOxob+UBo+uyfnVqvFi6A== X-Received: by 2002:a05:651c:233:b0:255:58b9:1f53 with SMTP id z19-20020a05651c023300b0025558b91f53mr6078950ljn.143.1654082150910; Wed, 01 Jun 2022 04:15:50 -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.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jun 2022 04:15:50 -0700 (PDT) From: Stanislaw Kardach To: Vladimir Medvedkin Cc: Stanislaw Kardach , dev@dpdk.org, Frank Zhao , Sam Grove , upstream@semihalf.com, Stephen Hemminger Subject: [PATCH v4 1/2] lpm: add const to lpm arg of rte_lpm_lookup Date: Wed, 1 Jun 2022 13:15:41 +0200 Message-Id: <20220601111542.401360-1-kda@semihalf.com> X-Mailer: git-send-email 2.30.2 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: Vladimir Medvedkin Acked-by: Stephen Hemminger --- 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 Wed Jun 1 11:15:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanislaw Kardach X-Patchwork-Id: 112225 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 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 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 | 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_ */