@@ -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',
new file mode 100644
@@ -0,0 +1,55 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2021 Intel Corporation
+ */
+
+#include <rte_common.h>
+#include <rte_gen.h>
+#include <rte_mbuf.h>
+
+#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);
@@ -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),
@@ -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 \
new file mode 100644
@@ -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')
new file mode 100644
@@ -0,0 +1,33 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2021 Intel Corporation
+ */
+
+#include "rte_gen.h"
+
+#include <rte_malloc.h>
+
+/** 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);
+}
new file mode 100644
@@ -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 <stdint.h>
+#include <rte_compat.h>
+
+#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_ */
new file mode 100644
@@ -0,0 +1,6 @@
+EXPERIMENTAL {
+ global:
+
+ rte_gen_create;
+ rte_gen_destroy;
+};
@@ -35,6 +35,7 @@ libraries = [
'efd',
'eventdev',
'gpudev',
+ 'gen',
'gro',
'gso',
'ip_frag',