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 0E161A00C3; Tue, 14 Dec 2021 15:13:11 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8B4E841154; Tue, 14 Dec 2021 15:12:53 +0100 (CET) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mails.dpdk.org (Postfix) with ESMTP id F177341144 for ; Tue, 14 Dec 2021 15:12:50 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1639491171; x=1671027171; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=cRqIAjEh/bn9SIrN0q/HDxXwevFEETN9iAflOuH2jxM=; b=K4ue8ESfO2p+6reHJZ5+fnGGYSOM1pT0Qt5g9+RyWfOD7QOt0mwelyWu vJ0KaGwDqOeVuRiAZZXo5eS2mTPHvX+QoCHKMFHPEnQ5VD0s0F0//eZlN UtvcUsqBylX3LmcobTENW3nV3P8VHKHKc/uENnt4z4XlqA3FF9mhDKxXx b85NIIw1j/aNjKrCs8v7RiMfHCyN0hRmPd74tzOR4p2d851ZSfeqr+TIn pio5n7xcytPNGE2TW25zLc8uzvRVqe225LoO2iAjtG/lvcPakVPTzbq4i SCOP1S0Ga1ZOlEsSFVvRJz/eDYxn02tiSdk/Ny4hOowXoqtzAARXhVBCh g==; X-IronPort-AV: E=McAfee;i="6200,9189,10197"; a="302362306" X-IronPort-AV: E=Sophos;i="5.88,205,1635231600"; d="scan'208";a="302362306" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Dec 2021 06:12:50 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,205,1635231600"; d="scan'208";a="465104103" Received: from silpixa00401120.ir.intel.com ([10.55.129.95]) by orsmga006.jf.intel.com with ESMTP; 14 Dec 2021 06:12:49 -0800 From: Ronan Randles To: dev@dpdk.org Cc: harry.van.haaren@intel.com Subject: [PATCH 03/12] gen: add files for initial traffic generation library Date: Tue, 14 Dec 2021 14:12:33 +0000 Message-Id: <20211214141242.3383831-4-ronan.randles@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211214141242.3383831-1-ronan.randles@intel.com> References: <20211214141242.3383831-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 --- 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 4cf540fc74..0e4f3b810d 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 018976df17..5b28cd3a89 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