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 5DE59A034E; Fri, 21 Jan 2022 11:31:49 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9BA514274A; Fri, 21 Jan 2022 11:31:36 +0100 (CET) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mails.dpdk.org (Postfix) with ESMTP id D2E3842754 for ; Fri, 21 Jan 2022 11:31:34 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1642761095; x=1674297095; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=lNV9QpL3SR578dqpveeWbqTPOd45ffJo2QerlJZ5vuk=; b=O1EBs5OY8mgkZgw2GIjiQk0SzNcGsEKrC+khufPB/gu4sfGed90wxyon ZcSVeOxUbayhUYuHTbtSPXgLQUN7t00fH6G8DI0kU0KE3XF6H9m6BEfAn gKPVZMlE2jva4bPj5FVn62pV+wnnHotWAXS/uFcUhoeAxhs/j6RsHGoKZ 8kWS193eeHt/UQVaG7X33hpsP1Dn6zS4JMAS5XJN2hy7IRAgILLChsKMq iCTnzOzMI8/Or6veN/hX2KkKYh9V2tamW6nJgYwECrUWVfkLW8bnBbXlD yZaGTV+PH20Du72wHpsKb4eGzPFixYVoiZAQlfoxsfQA8Is7Rc2Z+wniq g==; X-IronPort-AV: E=McAfee;i="6200,9189,10233"; a="270045081" X-IronPort-AV: E=Sophos;i="5.88,304,1635231600"; d="scan'208";a="270045081" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jan 2022 02:31:33 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,304,1635231600"; d="scan'208";a="533222731" Received: from silpixa00401120.ir.intel.com ([10.55.128.255]) by orsmga008.jf.intel.com with ESMTP; 21 Jan 2022 02:31:32 -0800 From: Ronan Randles To: dev@dpdk.org Cc: Harry van Haaren , Ronan Randles Subject: [PATCH v2 03/15] gen: add files for initial traffic generation library Date: Fri, 21 Jan 2022 10:31:10 +0000 Message-Id: <20220121103122.2926856-4-ronan.randles@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220121103122.2926856-1-ronan.randles@intel.com> References: <20211214141242.3383831-1-ronan.randles@intel.com> <20220121103122.2926856-1-ronan.randles@intel.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: Harry van Haaren This commit adds empty files to the DPDK build for a traffic generation library, including the bare create and destroy functions. Unit testing infrastructure is added for the create function. Signed-off-by: Harry van Haaren Signed-off-by: Ronan Randles --- app/test/meson.build | 2 ++ app/test/test_gen.c | 55 +++++++++++++++++++++++++++++++++++++++ doc/api/doxy-api-index.md | 3 ++- doc/api/doxy-api.conf.in | 1 + lib/gen/meson.build | 5 ++++ lib/gen/rte_gen.c | 33 +++++++++++++++++++++++ lib/gen/rte_gen.h | 44 +++++++++++++++++++++++++++++++ lib/gen/version.map | 6 +++++ lib/meson.build | 1 + 9 files changed, 149 insertions(+), 1 deletion(-) create mode 100644 app/test/test_gen.c create mode 100644 lib/gen/meson.build create mode 100644 lib/gen/rte_gen.c create mode 100644 lib/gen/rte_gen.h create mode 100644 lib/gen/version.map diff --git a/app/test/meson.build b/app/test/meson.build index 8cdfb783a9..c282493d10 100644 --- a/app/test/meson.build +++ b/app/test/meson.build @@ -66,6 +66,7 @@ test_sources = files( 'test_fib6_perf.c', 'test_func_reentrancy.c', 'test_flow_classify.c', + 'test_gen.c', 'test_graph.c', 'test_graph_perf.c', 'test_hash.c', @@ -173,6 +174,7 @@ test_deps = [ 'eventdev', 'fib', 'flow_classify', + 'gen', 'graph', 'hash', 'ipsec', diff --git a/app/test/test_gen.c b/app/test/test_gen.c new file mode 100644 index 0000000000..f53f4a6608 --- /dev/null +++ b/app/test/test_gen.c @@ -0,0 +1,55 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2021 Intel Corporation + */ + +#include +#include +#include + +#include "test.h" + +static struct rte_mempool *mp; + +static int +testsuite_setup(void) +{ + if (!mp) { + mp = rte_pktmbuf_pool_create("test_gen_mp", 8192, 256, 0, 2048, + SOCKET_ID_ANY); + } + return mp ? TEST_SUCCESS : TEST_FAILED; +} + +static void +testsuite_teardown(void) +{ + rte_mempool_free(mp); +} + +static int +test_gen_create(void) +{ + struct rte_gen *gen = rte_gen_create(mp); + TEST_ASSERT_FAIL(gen, "Expected valid pointer after create()"); + + rte_gen_destroy(gen); + return 0; +} + +static struct unit_test_suite gen_suite = { + .suite_name = "gen: packet generator unit test suite", + .setup = testsuite_setup, + .teardown = testsuite_teardown, + .unit_test_cases = { + TEST_CASE_ST(NULL, NULL, test_gen_create), + TEST_CASES_END() /**< NULL terminate unit test array */ + } +}; + +static int +test_gen_suite(void) +{ + return unit_test_suite_runner(&gen_suite); +} + +REGISTER_TEST_COMMAND(gen_autotest, test_gen_suite); diff --git a/doc/api/doxy-api-index.md b/doc/api/doxy-api-index.md index 4245b9635c..f7ddadd21a 100644 --- a/doc/api/doxy-api-index.md +++ b/doc/api/doxy-api-index.md @@ -220,7 +220,8 @@ The public API headers are grouped by topics: [log] (@ref rte_log.h), [errno] (@ref rte_errno.h), [trace] (@ref rte_trace.h), - [trace_point] (@ref rte_trace_point.h) + [trace_point] (@ref rte_trace_point.h), + [gen] (@ref rte_gen.h) - **misc**: [EAL config] (@ref rte_eal.h), diff --git a/doc/api/doxy-api.conf.in b/doc/api/doxy-api.conf.in index db2ca9b6ed..6344e949d9 100644 --- a/doc/api/doxy-api.conf.in +++ b/doc/api/doxy-api.conf.in @@ -41,6 +41,7 @@ INPUT = @TOPDIR@/doc/api/doxy-api-index.md \ @TOPDIR@/lib/eventdev \ @TOPDIR@/lib/fib \ @TOPDIR@/lib/flow_classify \ + @TOPDIR@/lib/gen \ @TOPDIR@/lib/gpudev \ @TOPDIR@/lib/graph \ @TOPDIR@/lib/gro \ diff --git a/lib/gen/meson.build b/lib/gen/meson.build new file mode 100644 index 0000000000..3c5d854645 --- /dev/null +++ b/lib/gen/meson.build @@ -0,0 +1,5 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2021 Intel Corporation + +sources = files('rte_gen.c') +headers = files('rte_gen.h') diff --git a/lib/gen/rte_gen.c b/lib/gen/rte_gen.c new file mode 100644 index 0000000000..d993772422 --- /dev/null +++ b/lib/gen/rte_gen.c @@ -0,0 +1,33 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2021 Intel Corporation + */ + +#include "rte_gen.h" + +#include + +/** Structure that represents a traffic generator. */ +struct rte_gen { + /* Mempool that buffers are retrieved from. */ + struct rte_mempool *mp; +}; + +/* Allocate and initialize a traffic generator instance. */ +struct rte_gen * +rte_gen_create(struct rte_mempool *mempool) +{ + struct rte_gen *gen = rte_zmalloc(NULL, sizeof(*gen), 0); + if (gen == NULL) + return NULL; + + gen->mp = mempool; + + return gen; +} + +/* Free a traffic generator instance. */ +void +rte_gen_destroy(struct rte_gen *gen) +{ + rte_free(gen); +} diff --git a/lib/gen/rte_gen.h b/lib/gen/rte_gen.h new file mode 100644 index 0000000000..5b30430f9e --- /dev/null +++ b/lib/gen/rte_gen.h @@ -0,0 +1,44 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2021 Intel Corporation + */ + +#ifndef _RTE_GEN_H_ +#define _RTE_GEN_H_ + +/** + * @file + * RTE gen + * + * A library for the generation of packets, to allow easy generation + * of various flows of packets. + */ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +/** Structure that represents a logical traffic generator. */ +struct rte_gen; + +/* Forward declarations for DPDK componeents. */ +struct rte_mempool; + +/* Allocate and initialize a traffic generator instance. */ +__rte_experimental +struct rte_gen * +rte_gen_create(struct rte_mempool *mempool); + +/* Free a traffic generator instance. */ +__rte_experimental +void +rte_gen_destroy(struct rte_gen *gen); + +#ifdef __cplusplus +} +#endif + +#endif /* _RTE_GEN_H_ */ diff --git a/lib/gen/version.map b/lib/gen/version.map new file mode 100644 index 0000000000..d8a26eb53a --- /dev/null +++ b/lib/gen/version.map @@ -0,0 +1,6 @@ +EXPERIMENTAL { + global: + + rte_gen_create; + rte_gen_destroy; +}; diff --git a/lib/meson.build b/lib/meson.build index fbaa6ef7c2..bdddc059ca 100644 --- a/lib/meson.build +++ b/lib/meson.build @@ -35,6 +35,7 @@ libraries = [ 'efd', 'eventdev', 'gpudev', + 'gen', 'gro', 'gso', 'ip_frag', -- 2.25.1