From patchwork Wed Aug 26 15:14:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Dumitrescu X-Patchwork-Id: 75996 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id F0E6AA04B4; Wed, 26 Aug 2020 17:15:12 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C18A41BE80; Wed, 26 Aug 2020 17:15:05 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id F3B36B62 for ; Wed, 26 Aug 2020 17:15:02 +0200 (CEST) IronPort-SDR: OxDKUKs2mIAcEgQSTFdx5dGSd+ewy/aI2bhBDTE/Hs/V0BU8GOrk/GYd4t3hW8nuGHRKkSSjPQ K+Gy+MJPRhpA== X-IronPort-AV: E=McAfee;i="6000,8403,9725"; a="153879477" X-IronPort-AV: E=Sophos;i="5.76,356,1592895600"; d="scan'208";a="153879477" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Aug 2020 08:14:48 -0700 IronPort-SDR: z1xrZjfxgr8yGw7NsY820B2H7MNYnLVbibmVSX+6a0y3fT8Mlgj/NtTPYI6pYOIr8xTc+2x9v2 Xl//ZjjY7ktQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,356,1592895600"; d="scan'208";a="444081252" Received: from silpixa00400573.ir.intel.com (HELO silpixa00400573.ger.corp.intel.com) ([10.237.223.107]) by orsmga004.jf.intel.com with ESMTP; 26 Aug 2020 08:14:47 -0700 From: Cristian Dumitrescu To: dev@dpdk.org Date: Wed, 26 Aug 2020 16:14:06 +0100 Message-Id: <20200826151445.51500-2-cristian.dumitrescu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200826151445.51500-1-cristian.dumitrescu@intel.com> References: <20200826151445.51500-1-cristian.dumitrescu@intel.com> Subject: [dpdk-dev] [PATCH 01/40] pipeline: add pipeline X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Add improved pipeline type that supports dynamically-defined packet headers, meta-data, actions and pipelines. Actions and pipelines are defined through instructions. Signed-off-by: Cristian Dumitrescu --- lib/librte_pipeline/Makefile | 2 + lib/librte_pipeline/meson.build | 10 ++- lib/librte_pipeline/rte_pipeline_version.map | 3 + lib/librte_pipeline/rte_swx_pipeline.c | 70 +++++++++++++++++ lib/librte_pipeline/rte_swx_pipeline.h | 79 ++++++++++++++++++++ 5 files changed, 162 insertions(+), 2 deletions(-) create mode 100644 lib/librte_pipeline/rte_swx_pipeline.c create mode 100644 lib/librte_pipeline/rte_swx_pipeline.h diff --git a/lib/librte_pipeline/Makefile b/lib/librte_pipeline/Makefile index cfbbd1828..32582db9e 100644 --- a/lib/librte_pipeline/Makefile +++ b/lib/librte_pipeline/Makefile @@ -21,8 +21,10 @@ EXPORT_MAP := rte_pipeline_version.map SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) := rte_pipeline.c SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += rte_port_in_action.c SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += rte_table_action.c +SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += rte_swx_pipeline.c # install includes SYMLINK-$(CONFIG_RTE_LIBRTE_PIPELINE)-include += rte_pipeline.h rte_port_in_action.h rte_table_action.h +SYMLINK-$(CONFIG_RTE_LIBRTE_PIPELINE)-include += rte_swx_pipeline.h include $(RTE_SDK)/mk/rte.lib.mk diff --git a/lib/librte_pipeline/meson.build b/lib/librte_pipeline/meson.build index d70b1a023..880c2b274 100644 --- a/lib/librte_pipeline/meson.build +++ b/lib/librte_pipeline/meson.build @@ -1,6 +1,12 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017 Intel Corporation -sources = files('rte_pipeline.c', 'rte_port_in_action.c', 'rte_table_action.c') -headers = files('rte_pipeline.h', 'rte_port_in_action.h', 'rte_table_action.h') +sources = files('rte_pipeline.c', + 'rte_port_in_action.c', + 'rte_table_action.c', + 'rte_swx_pipeline.c',) +headers = files('rte_pipeline.h', + 'rte_port_in_action.h', + 'rte_table_action.h', + 'rte_swx_pipeline.h',) deps += ['port', 'table', 'meter', 'sched', 'cryptodev'] diff --git a/lib/librte_pipeline/rte_pipeline_version.map b/lib/librte_pipeline/rte_pipeline_version.map index 9ed80eb04..39593f1ee 100644 --- a/lib/librte_pipeline/rte_pipeline_version.map +++ b/lib/librte_pipeline/rte_pipeline_version.map @@ -55,4 +55,7 @@ EXPERIMENTAL { rte_table_action_time_read; rte_table_action_ttl_read; rte_table_action_crypto_sym_session_get; + rte_swx_pipeline_config; + rte_swx_pipeline_build; + rte_swx_pipeline_free; }; diff --git a/lib/librte_pipeline/rte_swx_pipeline.c b/lib/librte_pipeline/rte_swx_pipeline.c new file mode 100644 index 000000000..2319d4570 --- /dev/null +++ b/lib/librte_pipeline/rte_swx_pipeline.c @@ -0,0 +1,70 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2020 Intel Corporation + */ +#include +#include +#include +#include + +#include + +#include "rte_swx_pipeline.h" + +#define CHECK(condition, err_code) \ +do { \ + if (!(condition)) \ + return -(err_code); \ +} while (0) + +#define CHECK_NAME(name, err_code) \ + CHECK((name) && (name)[0], err_code) + +/* + * Pipeline. + */ +struct rte_swx_pipeline { + int build_done; + int numa_node; +}; + + +/* + * Pipeline. + */ +int +rte_swx_pipeline_config(struct rte_swx_pipeline **p, int numa_node) +{ + struct rte_swx_pipeline *pipeline; + + /* Check input parameters. */ + CHECK(p, EINVAL); + + /* Memory allocation. */ + pipeline = calloc(1, sizeof(struct rte_swx_pipeline)); + CHECK(pipeline, ENOMEM); + + /* Initialization. */ + pipeline->numa_node = numa_node; + + *p = pipeline; + return 0; +} + +void +rte_swx_pipeline_free(struct rte_swx_pipeline *p) +{ + if (!p) + return; + + free(p); +} + +int +rte_swx_pipeline_build(struct rte_swx_pipeline *p) +{ + CHECK(p, EINVAL); + CHECK(p->build_done == 0, EEXIST); + + p->build_done = 1; + return 0; +} diff --git a/lib/librte_pipeline/rte_swx_pipeline.h b/lib/librte_pipeline/rte_swx_pipeline.h new file mode 100644 index 000000000..ded26a4e4 --- /dev/null +++ b/lib/librte_pipeline/rte_swx_pipeline.h @@ -0,0 +1,79 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2020 Intel Corporation + */ +#ifndef __INCLUDE_RTE_SWX_PIPELINE_H__ +#define __INCLUDE_RTE_SWX_PIPELINE_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @file + * RTE SWX Pipeline + */ + +#include +#include + +#include + +/* + * Pipeline setup and operation + */ + +/** Pipeline opaque data structure. */ +struct rte_swx_pipeline; + +/** + * Pipeline configure + * + * @param[out] p + * Pipeline handle. Must point to valid memory. Contains valid pipeline handle + * when the function returns successfully. + * @param[in] numa_node + * Non-Uniform Memory Access (NUMA) node. + * @return + * 0 on success or the following error codes otherwise: + * -EINVAL: Invalid argument; + * -ENOMEM: Not enough space/cannot allocate memory. + */ +__rte_experimental +int +rte_swx_pipeline_config(struct rte_swx_pipeline **p, + int numa_node); + +/** + * Pipeline build + * + * Once called, the pipeline build operation marks the end of pipeline + * configuration. At this point, all the internal data structures needed to run + * the pipeline are built. + * + * @param[in] p + * Pipeline handle. + * @return + * 0 on success or the following error codes otherwise: + * -EINVAL: Invalid argument; + * -ENOMEM: Not enough space/cannot allocate memory; + * -EEXIST: Pipeline was already built successfully. + */ +__rte_experimental +int +rte_swx_pipeline_build(struct rte_swx_pipeline *p); + +/** + * Pipeline free + * + * @param[in] p + * Pipeline handle. + */ +__rte_experimental +void +rte_swx_pipeline_free(struct rte_swx_pipeline *p); + +#ifdef __cplusplus +} +#endif + +#endif