From 10868439dbc010e534ac28616f00be3cc69fe018 Mon Sep 17 00:00:00 2001 From: NoahChinitzGWU Date: Fri, 18 Jun 2021 11:02:53 -0600 Subject: [PATCH 01/55] [Update] Fixed Issue #293 --- examples/basic_msg_test/Makefile | 67 ++++++++ examples/basic_msg_test/README.md | 31 ++++ examples/basic_msg_test/basic_msg_test.c | 195 +++++++++++++++++++++++ examples/basic_msg_test/go.sh | 20 +++ onvm/onvm_nflib/onvm_nflib.c | 11 +- 5 files changed, 323 insertions(+), 1 deletion(-) create mode 100644 examples/basic_msg_test/Makefile create mode 100644 examples/basic_msg_test/README.md create mode 100644 examples/basic_msg_test/basic_msg_test.c create mode 100644 examples/basic_msg_test/go.sh mode change 100755 => 100644 onvm/onvm_nflib/onvm_nflib.c diff --git a/examples/basic_msg_test/Makefile b/examples/basic_msg_test/Makefile new file mode 100644 index 000000000..b9daee0be --- /dev/null +++ b/examples/basic_msg_test/Makefile @@ -0,0 +1,67 @@ +# openNetVM +# https://github.com/sdnfv/openNetVM +# +# BSD LICENSE +# +# Copyright(c) +# 2015-2017 George Washington University +# 2015-2017 University of California Riverside +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# The name of the author may not be used to endorse or promote +# products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +ifeq ($(RTE_SDK),) +$(error "Please define RTE_SDK environment variable") +endif + + +# Default target, can be overriden by command line or environment +include $(RTE_SDK)/mk/rte.vars.mk +RTE_TARGET ?= x86_64-native-linuxapp-gcc + +# binary name +APP = basic_msg_test + +# all source are stored in SRCS-y +SRCS-y := basic_msg_test.c + +ONVM= $(SRCDIR)/../../onvm + +CFLAGS += $(WERROR_FLAGS) -O3 $(USER_FLAGS) + +CFLAGS += -I$(ONVM)/onvm_nflib +CFLAGS += -I$(ONVM)/lib +LDFLAGS += $(ONVM)/onvm_nflib/$(RTE_TARGET)/libonvm.a +LDFLAGS += $(ONVM)/lib/$(RTE_TARGET)/lib/libonvmhelper.a -lm + +# workaround for a gcc bug with noreturn attribute +# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12603 +ifeq ($(CONFIG_RTE_TOOLCHAIN_GCC),y) +CFLAGS_main.o += -Wno-return-type +endif + +include $(RTE_SDK)/mk/rte.extapp.mk diff --git a/examples/basic_msg_test/README.md b/examples/basic_msg_test/README.md new file mode 100644 index 000000000..5ae665e13 --- /dev/null +++ b/examples/basic_msg_test/README.md @@ -0,0 +1,31 @@ +Basic Message Test +== +This is an example NF that acts as a unit test for sending messsages from an NF to itself. + +Compilation and Execution +-- +``` +cd examples +make +cd basic_msg_test +./go.sh SERVICE_ID [PRINT_DELAY] + +OR + +./go.sh -F CONFIG_FILE -- -- [-p PRINT_DELAY] + +OR + +sudo ./build/basic_msg_test -l CORELIST -n 3 --proc-type=secondary -- -r SERVICE_ID -- [-p PRINT_DELAY] +``` + +App Specific Arguments +-- + - `-p `: number of packets between each print, e.g. `-p 1` prints every packet. + +Config File Support +-- +This NF supports the NF generating arguments from a config file. For +additional reading, see [Examples.md](../../docs/Examples.md) + +See `../example_config.json` for all possible options that can be set. \ No newline at end of file diff --git a/examples/basic_msg_test/basic_msg_test.c b/examples/basic_msg_test/basic_msg_test.c new file mode 100644 index 000000000..85a7261bd --- /dev/null +++ b/examples/basic_msg_test/basic_msg_test.c @@ -0,0 +1,195 @@ +/********************************************************************* + * openNetVM + * https://sdnfv.github.io + * + * BSD LICENSE + * + * Copyright(c) + * 2015-2019 George Washington University + * 2015-2019 University of California Riverside + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * basic_msg_test.c - unit test to ensure NFs can send messages to itself + ********************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "onvm_nflib.h" +#include "onvm_pkt_helper.h" + +#define NF_TAG "basic_msg_test" + +/* number of package between each print */ +static uint32_t print_delay = 1000000; + +static uint16_t destination; + +void +nf_setup(struct onvm_nf_local_ctx *nf_local_ctx); + +void +nf_msg_handler(void *msg_data, struct onvm_nf_local_ctx *nf_local_ctx); + +/* + * Print a usage message + */ +static void +usage(const char *progname) { + printf("Usage:\n"); + printf("%s [EAL args] -- [NF_LIB args] -- -p \n", progname); + printf("%s -F [EAL args] -- [NF_LIB args] -- [NF args]\n\n", progname); + printf("Flags:\n"); + printf(" - `-p `: number of packets between each print, e.g. `-p 1` prints every packets.\n"); +} + +/* + * Parse the application arguments. + */ +static int +parse_app_args(int argc, char *argv[], const char *progname) { + int c; + + while ((c = getopt(argc, argv, "p:")) != -1) { + switch (c) { + case 'p': + print_delay = strtoul(optarg, NULL, 10); + RTE_LOG(INFO, APP, "print_delay = %d\n", print_delay); + break; + case '?': + usage(progname); + if (optopt == 'p') + RTE_LOG(INFO, APP, "Option -%c requires an argument.\n", optopt); + else if (isprint(optopt)) + RTE_LOG(INFO, APP, "Unknown option `-%c'.\n", optopt); + else + RTE_LOG(INFO, APP, "Unknown option character `\\x%x'.\n", optopt); + return -1; + default: + usage(progname); + return -1; + } + } + return optind; +} + +void +nf_setup(__attribute__((unused)) struct onvm_nf_local_ctx *nf_local_ctx) { + // uint32_t i; + struct rte_mempool *pktmbuf_pool; + + pktmbuf_pool = rte_mempool_lookup(PKTMBUF_POOL_NAME); + if (pktmbuf_pool == NULL) { + onvm_nflib_stop(nf_local_ctx); + rte_exit(EXIT_FAILURE, "Cannot find mbuf pool!\n"); + } + + uint16_t address = 1; + + int ret = onvm_nflib_send_msg_to_nf(address, NULL); + printf("%d\n", ret); + +} + +void +nf_msg_handler(void *msg_data, __attribute__((unused)) struct onvm_nf_local_ctx *nf_local_ctx){ + + uint16_t address = 1; + + int ret = onvm_nflib_send_msg_to_nf(address, msg_data); + printf("%d\n", ret); + +} + +static int +packet_handler(struct rte_mbuf *pkt, struct onvm_pkt_meta *meta, + __attribute__((unused)) struct onvm_nf_local_ctx *nf_local_ctx) { + + (void)pkt; + meta->destination = destination; + meta->action = ONVM_NF_ACTION_TONF; + + return 0; +} + +int +main(int argc, char *argv[]) { + int arg_offset; + struct onvm_nf_local_ctx *nf_local_ctx; + struct onvm_nf_function_table *nf_function_table; + const char *progname = argv[0]; + + nf_local_ctx = onvm_nflib_init_nf_local_ctx(); + onvm_nflib_start_signal_handler(nf_local_ctx, NULL); + + nf_function_table = onvm_nflib_init_nf_function_table(); + nf_function_table->pkt_handler = &packet_handler; + nf_function_table->setup = &nf_setup; + nf_function_table->msg_handler = &nf_msg_handler; + + if ((arg_offset = onvm_nflib_init(argc, argv, NF_TAG, nf_local_ctx, nf_function_table)) < 0) { + onvm_nflib_stop(nf_local_ctx); + if (arg_offset == ONVM_SIGNAL_TERMINATION) { + printf("Exiting due to user termination\n"); + return 0; + } else { + rte_exit(EXIT_FAILURE, "Failed ONVM init\n"); + } + } + + argc -= arg_offset; + argv += arg_offset; + + if (parse_app_args(argc, argv, progname) < 0) { + onvm_nflib_stop(nf_local_ctx); + rte_exit(EXIT_FAILURE, "Invalid command-line arguments\n"); + } + + onvm_nflib_run(nf_local_ctx); + + onvm_nflib_stop(nf_local_ctx); + + printf("If we reach here, program is ending\n"); + return 0; +} \ No newline at end of file diff --git a/examples/basic_msg_test/go.sh b/examples/basic_msg_test/go.sh new file mode 100644 index 000000000..03fc3bb36 --- /dev/null +++ b/examples/basic_msg_test/go.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +#The go.sh script is a convinient way to run start_nf.sh without specifying NF_NAME + +NF_DIR=${PWD##*/} + +if [ ! -f ../start_nf.sh ]; then + echo "ERROR: The ./go.sh script can only be used from the NF folder" + echo "If running from other directory use examples/start_nf.sh" + exit 1 +fi + +# only check for running manager if not in Docker +if [[ -z $(pgrep -u root -f "/onvm/onvm_mgr/.*/onvm_mgr") ]] && ! grep -q "docker" /proc/1/cgroup +then + echo "NF cannot start without a running manager" + exit 1 +fi + +../start_nf.sh "$NF_DIR" "$@" diff --git a/onvm/onvm_nflib/onvm_nflib.c b/onvm/onvm_nflib/onvm_nflib.c old mode 100755 new mode 100644 index 2e5ecb33b..aab2c0773 --- a/onvm/onvm_nflib/onvm_nflib.c +++ b/onvm/onvm_nflib/onvm_nflib.c @@ -727,7 +727,16 @@ onvm_nflib_send_msg_to_nf(uint16_t dest, void *msg_data) { msg->msg_type = MSG_FROM_NF; msg->msg_data = msg_data; - return rte_ring_enqueue(nfs[dest].msg_q, (void*)msg); + ret = rte_ring_enqueue(nfs[dest].msg_q, (void*)msg); + if(ret != 0){ + RTE_LOG(INFO, APP, "Destination NF ring is full! Unable to enqueue msg to ring\n"); + rte_mempool_put(nf_msg_pool, (void*)msg); + return ret; + } + else{ + return rte_ring_enqueue(nfs[dest].msg_q, (void*)msg); + } + return 0; } void From 25650cca41db134986fd9dde81392f7d9185f8f6 Mon Sep 17 00:00:00 2001 From: NoahChinitzGWU Date: Fri, 18 Jun 2021 11:15:42 -0600 Subject: [PATCH 02/55] [Update] Deleted dead code --- examples/basic_msg_test/basic_msg_test.c | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/basic_msg_test/basic_msg_test.c b/examples/basic_msg_test/basic_msg_test.c index 85a7261bd..b0fd6ce00 100644 --- a/examples/basic_msg_test/basic_msg_test.c +++ b/examples/basic_msg_test/basic_msg_test.c @@ -116,7 +116,6 @@ parse_app_args(int argc, char *argv[], const char *progname) { void nf_setup(__attribute__((unused)) struct onvm_nf_local_ctx *nf_local_ctx) { - // uint32_t i; struct rte_mempool *pktmbuf_pool; pktmbuf_pool = rte_mempool_lookup(PKTMBUF_POOL_NAME); From 1a1b0b797b1bd79a43fca8fb4c8aa1f931263737 Mon Sep 17 00:00:00 2001 From: noahchin Date: Fri, 18 Jun 2021 14:02:22 -0600 Subject: [PATCH 03/55] [Update] Abstracted SID so that it works with whatever SID given --- examples/basic_msg_test/basic_msg_test.c | 7 +++---- examples/basic_msg_test/go.sh | 0 2 files changed, 3 insertions(+), 4 deletions(-) mode change 100644 => 100755 examples/basic_msg_test/go.sh diff --git a/examples/basic_msg_test/basic_msg_test.c b/examples/basic_msg_test/basic_msg_test.c index b0fd6ce00..780968d0d 100644 --- a/examples/basic_msg_test/basic_msg_test.c +++ b/examples/basic_msg_test/basic_msg_test.c @@ -124,7 +124,7 @@ nf_setup(__attribute__((unused)) struct onvm_nf_local_ctx *nf_local_ctx) { rte_exit(EXIT_FAILURE, "Cannot find mbuf pool!\n"); } - uint16_t address = 1; + uint16_t address = nf_local_ctx->nf->service_id; int ret = onvm_nflib_send_msg_to_nf(address, NULL); printf("%d\n", ret); @@ -134,7 +134,7 @@ nf_setup(__attribute__((unused)) struct onvm_nf_local_ctx *nf_local_ctx) { void nf_msg_handler(void *msg_data, __attribute__((unused)) struct onvm_nf_local_ctx *nf_local_ctx){ - uint16_t address = 1; + uint16_t address = nf_local_ctx->nf->service_id; int ret = onvm_nflib_send_msg_to_nf(address, msg_data); printf("%d\n", ret); @@ -142,10 +142,9 @@ nf_msg_handler(void *msg_data, __attribute__((unused)) struct onvm_nf_local_ctx } static int -packet_handler(struct rte_mbuf *pkt, struct onvm_pkt_meta *meta, +packet_handler(__attribute__((unused)) struct rte_mbuf *pkt, struct onvm_pkt_meta *meta, __attribute__((unused)) struct onvm_nf_local_ctx *nf_local_ctx) { - (void)pkt; meta->destination = destination; meta->action = ONVM_NF_ACTION_TONF; diff --git a/examples/basic_msg_test/go.sh b/examples/basic_msg_test/go.sh old mode 100644 new mode 100755 From 4bcb953bc25678bf8807380ca4eae8342fe6e968 Mon Sep 17 00:00:00 2001 From: noahchin Date: Mon, 21 Jun 2021 10:28:27 -0600 Subject: [PATCH 04/55] [Update] Changed name --- examples/basic_msg_test/{basic_msg_test.c => test_messaging.c} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename examples/basic_msg_test/{basic_msg_test.c => test_messaging.c} (100%) diff --git a/examples/basic_msg_test/basic_msg_test.c b/examples/basic_msg_test/test_messaging.c similarity index 100% rename from examples/basic_msg_test/basic_msg_test.c rename to examples/basic_msg_test/test_messaging.c From 0c6a4b2ba06a17d29a79d71d4bb770de9fcfbabf Mon Sep 17 00:00:00 2001 From: noahchin Date: Mon, 21 Jun 2021 10:29:15 -0600 Subject: [PATCH 05/55] [Update] Changed dir name --- examples/test_messaging/Makefile | 67 ++++++++ examples/test_messaging/README.md | 31 ++++ examples/test_messaging/go.sh | 20 +++ examples/test_messaging/test_messaging.c | 193 +++++++++++++++++++++++ 4 files changed, 311 insertions(+) create mode 100644 examples/test_messaging/Makefile create mode 100644 examples/test_messaging/README.md create mode 100755 examples/test_messaging/go.sh create mode 100644 examples/test_messaging/test_messaging.c diff --git a/examples/test_messaging/Makefile b/examples/test_messaging/Makefile new file mode 100644 index 000000000..d69f9959c --- /dev/null +++ b/examples/test_messaging/Makefile @@ -0,0 +1,67 @@ +# openNetVM +# https://github.com/sdnfv/openNetVM +# +# BSD LICENSE +# +# Copyright(c) +# 2015-2017 George Washington University +# 2015-2017 University of California Riverside +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# The name of the author may not be used to endorse or promote +# products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +ifeq ($(RTE_SDK),) +$(error "Please define RTE_SDK environment variable") +endif + + +# Default target, can be overriden by command line or environment +include $(RTE_SDK)/mk/rte.vars.mk +RTE_TARGET ?= x86_64-native-linuxapp-gcc + +# binary name +APP = test_messaging + +# all source are stored in SRCS-y +SRCS-y := test_messaging.c + +ONVM= $(SRCDIR)/../../onvm + +CFLAGS += $(WERROR_FLAGS) -O3 $(USER_FLAGS) + +CFLAGS += -I$(ONVM)/onvm_nflib +CFLAGS += -I$(ONVM)/lib +LDFLAGS += $(ONVM)/onvm_nflib/$(RTE_TARGET)/libonvm.a +LDFLAGS += $(ONVM)/lib/$(RTE_TARGET)/lib/libonvmhelper.a -lm + +# workaround for a gcc bug with noreturn attribute +# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12603 +ifeq ($(CONFIG_RTE_TOOLCHAIN_GCC),y) +CFLAGS_main.o += -Wno-return-type +endif + +include $(RTE_SDK)/mk/rte.extapp.mk diff --git a/examples/test_messaging/README.md b/examples/test_messaging/README.md new file mode 100644 index 000000000..5ae665e13 --- /dev/null +++ b/examples/test_messaging/README.md @@ -0,0 +1,31 @@ +Basic Message Test +== +This is an example NF that acts as a unit test for sending messsages from an NF to itself. + +Compilation and Execution +-- +``` +cd examples +make +cd basic_msg_test +./go.sh SERVICE_ID [PRINT_DELAY] + +OR + +./go.sh -F CONFIG_FILE -- -- [-p PRINT_DELAY] + +OR + +sudo ./build/basic_msg_test -l CORELIST -n 3 --proc-type=secondary -- -r SERVICE_ID -- [-p PRINT_DELAY] +``` + +App Specific Arguments +-- + - `-p `: number of packets between each print, e.g. `-p 1` prints every packet. + +Config File Support +-- +This NF supports the NF generating arguments from a config file. For +additional reading, see [Examples.md](../../docs/Examples.md) + +See `../example_config.json` for all possible options that can be set. \ No newline at end of file diff --git a/examples/test_messaging/go.sh b/examples/test_messaging/go.sh new file mode 100755 index 000000000..03fc3bb36 --- /dev/null +++ b/examples/test_messaging/go.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +#The go.sh script is a convinient way to run start_nf.sh without specifying NF_NAME + +NF_DIR=${PWD##*/} + +if [ ! -f ../start_nf.sh ]; then + echo "ERROR: The ./go.sh script can only be used from the NF folder" + echo "If running from other directory use examples/start_nf.sh" + exit 1 +fi + +# only check for running manager if not in Docker +if [[ -z $(pgrep -u root -f "/onvm/onvm_mgr/.*/onvm_mgr") ]] && ! grep -q "docker" /proc/1/cgroup +then + echo "NF cannot start without a running manager" + exit 1 +fi + +../start_nf.sh "$NF_DIR" "$@" diff --git a/examples/test_messaging/test_messaging.c b/examples/test_messaging/test_messaging.c new file mode 100644 index 000000000..6567c42d1 --- /dev/null +++ b/examples/test_messaging/test_messaging.c @@ -0,0 +1,193 @@ +/********************************************************************* + * openNetVM + * https://sdnfv.github.io + * + * BSD LICENSE + * + * Copyright(c) + * 2015-2019 George Washington University + * 2015-2019 University of California Riverside + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * test_messaging.c - unit test to ensure NFs can send messages to itself + ********************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "onvm_nflib.h" +#include "onvm_pkt_helper.h" + +#define NF_TAG "basic_msg_test" + +/* number of package between each print */ +static uint32_t print_delay = 1000000; + +static uint16_t destination; + +void +nf_setup(struct onvm_nf_local_ctx *nf_local_ctx); + +void +nf_msg_handler(void *msg_data, struct onvm_nf_local_ctx *nf_local_ctx); + +/* + * Print a usage message + */ +static void +usage(const char *progname) { + printf("Usage:\n"); + printf("%s [EAL args] -- [NF_LIB args] -- -p \n", progname); + printf("%s -F [EAL args] -- [NF_LIB args] -- [NF args]\n\n", progname); + printf("Flags:\n"); + printf(" - `-p `: number of packets between each print, e.g. `-p 1` prints every packets.\n"); +} + +/* + * Parse the application arguments. + */ +static int +parse_app_args(int argc, char *argv[], const char *progname) { + int c; + + while ((c = getopt(argc, argv, "p:")) != -1) { + switch (c) { + case 'p': + print_delay = strtoul(optarg, NULL, 10); + RTE_LOG(INFO, APP, "print_delay = %d\n", print_delay); + break; + case '?': + usage(progname); + if (optopt == 'p') + RTE_LOG(INFO, APP, "Option -%c requires an argument.\n", optopt); + else if (isprint(optopt)) + RTE_LOG(INFO, APP, "Unknown option `-%c'.\n", optopt); + else + RTE_LOG(INFO, APP, "Unknown option character `\\x%x'.\n", optopt); + return -1; + default: + usage(progname); + return -1; + } + } + return optind; +} + +void +nf_setup(__attribute__((unused)) struct onvm_nf_local_ctx *nf_local_ctx) { + struct rte_mempool *pktmbuf_pool; + + pktmbuf_pool = rte_mempool_lookup(PKTMBUF_POOL_NAME); + if (pktmbuf_pool == NULL) { + onvm_nflib_stop(nf_local_ctx); + rte_exit(EXIT_FAILURE, "Cannot find mbuf pool!\n"); + } + + uint16_t address = nf_local_ctx->nf->service_id; + + int ret = onvm_nflib_send_msg_to_nf(address, NULL); + printf("%d\n", ret); + +} + +void +nf_msg_handler(void *msg_data, __attribute__((unused)) struct onvm_nf_local_ctx *nf_local_ctx){ + + uint16_t address = nf_local_ctx->nf->service_id; + + int ret = onvm_nflib_send_msg_to_nf(address, msg_data); + printf("%d\n", ret); + +} + +static int +packet_handler(__attribute__((unused)) struct rte_mbuf *pkt, struct onvm_pkt_meta *meta, + __attribute__((unused)) struct onvm_nf_local_ctx *nf_local_ctx) { + + meta->destination = destination; + meta->action = ONVM_NF_ACTION_TONF; + + return 0; +} + +int +main(int argc, char *argv[]) { + int arg_offset; + struct onvm_nf_local_ctx *nf_local_ctx; + struct onvm_nf_function_table *nf_function_table; + const char *progname = argv[0]; + + nf_local_ctx = onvm_nflib_init_nf_local_ctx(); + onvm_nflib_start_signal_handler(nf_local_ctx, NULL); + + nf_function_table = onvm_nflib_init_nf_function_table(); + nf_function_table->pkt_handler = &packet_handler; + nf_function_table->setup = &nf_setup; + nf_function_table->msg_handler = &nf_msg_handler; + + if ((arg_offset = onvm_nflib_init(argc, argv, NF_TAG, nf_local_ctx, nf_function_table)) < 0) { + onvm_nflib_stop(nf_local_ctx); + if (arg_offset == ONVM_SIGNAL_TERMINATION) { + printf("Exiting due to user termination\n"); + return 0; + } else { + rte_exit(EXIT_FAILURE, "Failed ONVM init\n"); + } + } + + argc -= arg_offset; + argv += arg_offset; + + if (parse_app_args(argc, argv, progname) < 0) { + onvm_nflib_stop(nf_local_ctx); + rte_exit(EXIT_FAILURE, "Invalid command-line arguments\n"); + } + + onvm_nflib_run(nf_local_ctx); + + onvm_nflib_stop(nf_local_ctx); + + printf("If we reach here, program is ending\n"); + return 0; +} \ No newline at end of file From 9fbd366226ed28846897a4938984587ccbba8578 Mon Sep 17 00:00:00 2001 From: NoahChinitzGWU Date: Mon, 21 Jun 2021 10:42:44 -0600 Subject: [PATCH 06/55] [Update] Changed code in regards to PR #296 comments --- examples/test_messaging/README.md | 6 +++--- examples/test_messaging/test_messaging.c | 2 +- onvm/onvm_nflib/onvm_nflib.c | 5 +---- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/examples/test_messaging/README.md b/examples/test_messaging/README.md index 5ae665e13..1f6d5664d 100644 --- a/examples/test_messaging/README.md +++ b/examples/test_messaging/README.md @@ -1,4 +1,4 @@ -Basic Message Test +Test Messaging == This is an example NF that acts as a unit test for sending messsages from an NF to itself. @@ -7,7 +7,7 @@ Compilation and Execution ``` cd examples make -cd basic_msg_test +cd test_messaging ./go.sh SERVICE_ID [PRINT_DELAY] OR @@ -16,7 +16,7 @@ OR OR -sudo ./build/basic_msg_test -l CORELIST -n 3 --proc-type=secondary -- -r SERVICE_ID -- [-p PRINT_DELAY] +sudo ./build/test_messaging -l CORELIST -n 3 --proc-type=secondary -- -r SERVICE_ID -- [-p PRINT_DELAY] ``` App Specific Arguments diff --git a/examples/test_messaging/test_messaging.c b/examples/test_messaging/test_messaging.c index 6567c42d1..8642c17b7 100644 --- a/examples/test_messaging/test_messaging.c +++ b/examples/test_messaging/test_messaging.c @@ -59,7 +59,7 @@ #include "onvm_nflib.h" #include "onvm_pkt_helper.h" -#define NF_TAG "basic_msg_test" +#define NF_TAG "test_messaging" /* number of package between each print */ static uint32_t print_delay = 1000000; diff --git a/onvm/onvm_nflib/onvm_nflib.c b/onvm/onvm_nflib/onvm_nflib.c index aab2c0773..fd67153d0 100644 --- a/onvm/onvm_nflib/onvm_nflib.c +++ b/onvm/onvm_nflib/onvm_nflib.c @@ -729,13 +729,10 @@ onvm_nflib_send_msg_to_nf(uint16_t dest, void *msg_data) { ret = rte_ring_enqueue(nfs[dest].msg_q, (void*)msg); if(ret != 0){ - RTE_LOG(INFO, APP, "Destination NF ring is full! Unable to enqueue msg to ring\n"); + RTE_LOG(ERR, APP, "Destination NF ring is full! Unable to enqueue msg to ring\n"); rte_mempool_put(nf_msg_pool, (void*)msg); return ret; } - else{ - return rte_ring_enqueue(nfs[dest].msg_q, (void*)msg); - } return 0; } From 894811f023a8e17c545349f9a27cc38b585df79d Mon Sep 17 00:00:00 2001 From: NoahChinitzGWU Date: Mon, 21 Jun 2021 10:44:49 -0600 Subject: [PATCH 07/55] [Update] Drop packets --- examples/test_messaging/test_messaging.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/test_messaging/test_messaging.c b/examples/test_messaging/test_messaging.c index 8642c17b7..ea524111e 100644 --- a/examples/test_messaging/test_messaging.c +++ b/examples/test_messaging/test_messaging.c @@ -146,7 +146,7 @@ packet_handler(__attribute__((unused)) struct rte_mbuf *pkt, struct onvm_pkt_met __attribute__((unused)) struct onvm_nf_local_ctx *nf_local_ctx) { meta->destination = destination; - meta->action = ONVM_NF_ACTION_TONF; + meta->action = ONVM_NF_ACTION_DROP; return 0; } From def7da0d5526d94900eeaf045c3e647a823d444e Mon Sep 17 00:00:00 2001 From: noahchin Date: Tue, 22 Jun 2021 12:59:36 -0600 Subject: [PATCH 08/55] [Update] Sends more than one msg --- examples/test_messaging/test_messaging.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/examples/test_messaging/test_messaging.c b/examples/test_messaging/test_messaging.c index ea524111e..66cd13d1c 100644 --- a/examples/test_messaging/test_messaging.c +++ b/examples/test_messaging/test_messaging.c @@ -127,8 +127,8 @@ nf_setup(__attribute__((unused)) struct onvm_nf_local_ctx *nf_local_ctx) { uint16_t address = nf_local_ctx->nf->service_id; int ret = onvm_nflib_send_msg_to_nf(address, NULL); - printf("%d\n", ret); - + printf("Return: %d\n", ret); + } void @@ -136,8 +136,19 @@ nf_msg_handler(void *msg_data, __attribute__((unused)) struct onvm_nf_local_ctx uint16_t address = nf_local_ctx->nf->service_id; - int ret = onvm_nflib_send_msg_to_nf(address, msg_data); - printf("%d\n", ret); + for(int i = 0; i < 150; i++){ + int ret = onvm_nflib_send_msg_to_nf(address, msg_data); + + printf("Return: %d\n", ret); + printf("Iteration: %d\n", i); + printf("msg_data: %p\n", msg_data); + printf("SID: %i\n", address); + printf("Ring Count: %u\n", rte_ring_count(nf_local_ctx->nf->msg_q)); + + printf("---------------------------\n"); + + sleep(1); + } } From 7f772106d851ce641d3ecb06db6ac232e8848e48 Mon Sep 17 00:00:00 2001 From: noahchin Date: Tue, 22 Jun 2021 14:23:22 -0600 Subject: [PATCH 09/55] [Update] Working on making output cleaner as well as creating a struct to hold 'global data' --- examples/test_messaging/test_messaging.c | 45 +++++++++++++++++------- 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/examples/test_messaging/test_messaging.c b/examples/test_messaging/test_messaging.c index 66cd13d1c..3a95cc9db 100644 --- a/examples/test_messaging/test_messaging.c +++ b/examples/test_messaging/test_messaging.c @@ -58,6 +58,7 @@ #include "onvm_nflib.h" #include "onvm_pkt_helper.h" +#include "onvm_common.h" #define NF_TAG "test_messaging" @@ -66,6 +67,13 @@ static uint32_t print_delay = 1000000; static uint16_t destination; +struct test_msg_data{ + int tests_passed; + int tests_failed; + struct rte_mempool* msg_pool; + int test_phase; +}; + void nf_setup(struct onvm_nf_local_ctx *nf_local_ctx); @@ -126,29 +134,42 @@ nf_setup(__attribute__((unused)) struct onvm_nf_local_ctx *nf_local_ctx) { uint16_t address = nf_local_ctx->nf->service_id; - int ret = onvm_nflib_send_msg_to_nf(address, NULL); - printf("Return: %d\n", ret); - -} - -void -nf_msg_handler(void *msg_data, __attribute__((unused)) struct onvm_nf_local_ctx *nf_local_ctx){ + // lookup NF message pool and store pointer to it somewhere + /* Lookup mempool for NF messages */ + // nf_msg_pool = rte_mempool_lookup(_NF_MSG_POOL_NAME); + // if (nf_msg_pool == NULL) + // rte_exit(EXIT_FAILURE, "No NF Message mempool - bye\n"); - uint16_t address = nf_local_ctx->nf->service_id; + // send the numbers 1...10 and make sure we receive that correctly + int msg_ints[130]; - for(int i = 0; i < 150; i++){ - int ret = onvm_nflib_send_msg_to_nf(address, msg_data); + for(int i = 0; i < 130; i++){ + msg_ints[i] = i; + int ret = onvm_nflib_send_msg_to_nf(address, &msg_ints[i]); + printf("Sending message %d\n", i); printf("Return: %d\n", ret); printf("Iteration: %d\n", i); - printf("msg_data: %p\n", msg_data); printf("SID: %i\n", address); printf("Ring Count: %u\n", rte_ring_count(nf_local_ctx->nf->msg_q)); printf("---------------------------\n"); - sleep(1); } + + +} + +void +nf_msg_handler(void *msg_data, __attribute__((unused)) struct onvm_nf_local_ctx *nf_local_ctx){ + + // uint16_t address = nf_local_ctx->nf->service_id; + printf("Receive message\n"); + printf("msg_data: %d\n", *((int*) msg_data)); + printf("Ring Count: %u\n", rte_ring_count(nf_local_ctx->nf->msg_q)); + + printf("---------------------------\n"); + } From d296564fe1afcdba5345823dbcfe2c4b4a0a54e0 Mon Sep 17 00:00:00 2001 From: noahchin Date: Wed, 23 Jun 2021 12:20:33 -0600 Subject: [PATCH 10/55] [Update] Added checking of memory --- examples/test_messaging/test_messaging.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/examples/test_messaging/test_messaging.c b/examples/test_messaging/test_messaging.c index 3a95cc9db..4cf504651 100644 --- a/examples/test_messaging/test_messaging.c +++ b/examples/test_messaging/test_messaging.c @@ -152,7 +152,9 @@ nf_setup(__attribute__((unused)) struct onvm_nf_local_ctx *nf_local_ctx) { printf("Iteration: %d\n", i); printf("SID: %i\n", address); printf("Ring Count: %u\n", rte_ring_count(nf_local_ctx->nf->msg_q)); - + FILE *fp = fopen("/users/noahchin/openNetVM/examples/test_messaging/status.txt", "a+"); + rte_ring_dump(fp, nf_local_ctx->nf->msg_q); + fclose(fp); printf("---------------------------\n"); } @@ -167,10 +169,20 @@ nf_msg_handler(void *msg_data, __attribute__((unused)) struct onvm_nf_local_ctx printf("Receive message\n"); printf("msg_data: %d\n", *((int*) msg_data)); printf("Ring Count: %u\n", rte_ring_count(nf_local_ctx->nf->msg_q)); - + FILE *fp = fopen("/users/noahchin/openNetVM/examples/test_messaging/status.txt", "a+"); + rte_ring_dump(fp, nf_local_ctx->nf->msg_q); + fclose(fp); + int empty = rte_ring_empty(nf_local_ctx->nf->msg_q); + if(empty != 0){ + printf("Message Ring Empty\n"); + } + else{ + printf("Message Ring Not Empty\n"); + } printf("---------------------------\n"); + } static int From 23f30370198a2bc8aee82ab13bebac66dabaeb96 Mon Sep 17 00:00:00 2001 From: noahchin Date: Wed, 23 Jun 2021 13:43:37 -0600 Subject: [PATCH 11/55] [Update] Added working struct. Working on cleaner output and automation of test --- examples/test_messaging/test_messaging.c | 83 ++++++++++++++++++------ 1 file changed, 63 insertions(+), 20 deletions(-) diff --git a/examples/test_messaging/test_messaging.c b/examples/test_messaging/test_messaging.c index 4cf504651..c10afb39a 100644 --- a/examples/test_messaging/test_messaging.c +++ b/examples/test_messaging/test_messaging.c @@ -70,8 +70,11 @@ static uint16_t destination; struct test_msg_data{ int tests_passed; int tests_failed; - struct rte_mempool* msg_pool; int test_phase; + int ring_count; + uint16_t address; + struct rte_mempool* msg_pool; + struct rte_ring *msg_q; }; void @@ -96,8 +99,24 @@ usage(const char *progname) { * Parse the application arguments. */ static int -parse_app_args(int argc, char *argv[], const char *progname) { +parse_app_args(int argc, char *argv[], const char *progname, struct onvm_nf *nf) { int c; + struct test_msg_data *msg_params; + static struct rte_mempool *nf_msg_pool; + + nf_msg_pool = rte_mempool_lookup(_NF_MSG_POOL_NAME); + if (nf_msg_pool == NULL) + rte_exit(EXIT_FAILURE, "No NF Message mempool - bye\n"); + + msg_params = (struct test_msg_data *)rte_malloc(NULL, sizeof(struct test_msg_data), 0); + msg_params->tests_passed = 0; + msg_params->tests_failed = 0; + msg_params->test_phase = 1; + msg_params->ring_count = 0; + msg_params->address = nf->service_id; + msg_params->msg_pool = nf_msg_pool; + msg_params->msg_q = nf->msg_q; + nf->data = (void *)msg_params; while ((c = getopt(argc, argv, "p:")) != -1) { switch (c) { @@ -131,29 +150,39 @@ nf_setup(__attribute__((unused)) struct onvm_nf_local_ctx *nf_local_ctx) { onvm_nflib_stop(nf_local_ctx); rte_exit(EXIT_FAILURE, "Cannot find mbuf pool!\n"); } - - uint16_t address = nf_local_ctx->nf->service_id; - - // lookup NF message pool and store pointer to it somewhere - /* Lookup mempool for NF messages */ - // nf_msg_pool = rte_mempool_lookup(_NF_MSG_POOL_NAME); - // if (nf_msg_pool == NULL) - // rte_exit(EXIT_FAILURE, "No NF Message mempool - bye\n"); + // printf("TEST MESSAGING STARTED\n"); + // printf("---------------------------\n"); + // printf("TEST 1: Send/Receive One Message...\n"); + // printf("TEST 2: Send/Receive Multiple Messages...\n"); + // printf("TEST 3: Message Ring Overflow...\n"); + // int msg_tests_passed; + // int msg_tests_failed; + // int msg_test_phase; + // int msg_ring_count; + uint16_t msg_address; + struct test_msg_data *msg_params; + + msg_params = (struct test_msg_data *)nf_local_ctx->nf->data; + // msg_tests_passed = msg_params->tests_passed; + // msg_tests_failed = msg_params->tests_failed; + // msg_test_phase = msg_params->test_phase; + // msg_ring_count = msg_params->ring_count; + msg_address = msg_params->address; // send the numbers 1...10 and make sure we receive that correctly - int msg_ints[130]; + int msg_ints[10]; - for(int i = 0; i < 130; i++){ + for(int i = 0; i < 10; i++){ msg_ints[i] = i; - int ret = onvm_nflib_send_msg_to_nf(address, &msg_ints[i]); + int ret = onvm_nflib_send_msg_to_nf(msg_address, &msg_ints[i]); printf("Sending message %d\n", i); printf("Return: %d\n", ret); printf("Iteration: %d\n", i); - printf("SID: %i\n", address); - printf("Ring Count: %u\n", rte_ring_count(nf_local_ctx->nf->msg_q)); + printf("SID: %i\n", msg_address); + printf("Ring Count: %u\n", rte_ring_count(msg_params->msg_q)); FILE *fp = fopen("/users/noahchin/openNetVM/examples/test_messaging/status.txt", "a+"); - rte_ring_dump(fp, nf_local_ctx->nf->msg_q); + rte_ring_dump(fp, msg_params->msg_q); fclose(fp); printf("---------------------------\n"); @@ -165,14 +194,28 @@ nf_setup(__attribute__((unused)) struct onvm_nf_local_ctx *nf_local_ctx) { void nf_msg_handler(void *msg_data, __attribute__((unused)) struct onvm_nf_local_ctx *nf_local_ctx){ + // int msg_tests_passed; + // int msg_tests_failed; + // int msg_test_phase; + // int msg_ring_count; + // uint16_t msg_address; + struct test_msg_data *msg_params; + + msg_params = (struct test_msg_data *)nf_local_ctx->nf->data; + // msg_tests_passed = msg_params->tests_passed; + // msg_tests_failed = msg_params->tests_failed; + // msg_test_phase = msg_params->test_phase; + // msg_ring_count = msg_params->ring_count; + // msg_address = msg_params->address; + // uint16_t address = nf_local_ctx->nf->service_id; printf("Receive message\n"); printf("msg_data: %d\n", *((int*) msg_data)); - printf("Ring Count: %u\n", rte_ring_count(nf_local_ctx->nf->msg_q)); + printf("Ring Count: %u\n", rte_ring_count(msg_params->msg_q)); FILE *fp = fopen("/users/noahchin/openNetVM/examples/test_messaging/status.txt", "a+"); - rte_ring_dump(fp, nf_local_ctx->nf->msg_q); + rte_ring_dump(fp, msg_params->msg_q); fclose(fp); - int empty = rte_ring_empty(nf_local_ctx->nf->msg_q); + int empty = rte_ring_empty(msg_params->msg_q); if(empty != 0){ printf("Message Ring Empty\n"); } @@ -223,7 +266,7 @@ main(int argc, char *argv[]) { argc -= arg_offset; argv += arg_offset; - if (parse_app_args(argc, argv, progname) < 0) { + if (parse_app_args(argc, argv, progname, nf_local_ctx->nf) < 0) { onvm_nflib_stop(nf_local_ctx); rte_exit(EXIT_FAILURE, "Invalid command-line arguments\n"); } From b4dc99d5b6aa8636e244648ced80887f5e3372a2 Mon Sep 17 00:00:00 2001 From: NoahChinitzGWU Date: Thu, 24 Jun 2021 14:56:45 -0600 Subject: [PATCH 12/55] [Update] Added first Test --- examples/test_messaging/test_messaging.c | 69 ++++++++++++++---------- 1 file changed, 40 insertions(+), 29 deletions(-) diff --git a/examples/test_messaging/test_messaging.c b/examples/test_messaging/test_messaging.c index c10afb39a..e456ecb47 100644 --- a/examples/test_messaging/test_messaging.c +++ b/examples/test_messaging/test_messaging.c @@ -150,9 +150,10 @@ nf_setup(__attribute__((unused)) struct onvm_nf_local_ctx *nf_local_ctx) { onvm_nflib_stop(nf_local_ctx); rte_exit(EXIT_FAILURE, "Cannot find mbuf pool!\n"); } - // printf("TEST MESSAGING STARTED\n"); - // printf("---------------------------\n"); - // printf("TEST 1: Send/Receive One Message...\n"); + printf("TEST MESSAGING STARTED\n"); + printf("---------------------------\n"); + printf("TEST 1: Send/Receive One Message...\n"); + printf("---------------------------\n"); // printf("TEST 2: Send/Receive Multiple Messages...\n"); // printf("TEST 3: Message Ring Overflow...\n"); // int msg_tests_passed; @@ -169,24 +170,26 @@ nf_setup(__attribute__((unused)) struct onvm_nf_local_ctx *nf_local_ctx) { // msg_ring_count = msg_params->ring_count; msg_address = msg_params->address; - // send the numbers 1...10 and make sure we receive that correctly - int msg_ints[10]; - - for(int i = 0; i < 10; i++){ - msg_ints[i] = i; - int ret = onvm_nflib_send_msg_to_nf(msg_address, &msg_ints[i]); - - printf("Sending message %d\n", i); - printf("Return: %d\n", ret); - printf("Iteration: %d\n", i); - printf("SID: %i\n", msg_address); - printf("Ring Count: %u\n", rte_ring_count(msg_params->msg_q)); - FILE *fp = fopen("/users/noahchin/openNetVM/examples/test_messaging/status.txt", "a+"); - rte_ring_dump(fp, msg_params->msg_q); - fclose(fp); - printf("---------------------------\n"); - } + int *msg_ints; + + msg_ints = (int*)rte_malloc(NULL, sizeof(int*), 0); + + *msg_ints = 25; + + int ret = onvm_nflib_send_msg_to_nf(msg_address, msg_ints); + + printf("Sending message: %d\n", *msg_ints); + printf("Return: %d\n", ret); + printf("SID: %i\n", msg_address); + printf("Ring Count: %u\n", rte_ring_count(msg_params->msg_q)); + + // FILE *fp = fopen("/users/noahchin/openNetVM/examples/test_messaging/status.txt", "a+"); + // rte_ring_dump(fp, msg_params->msg_q); + // fclose(fp); + + printf("---------------------------\n"); + } @@ -197,7 +200,7 @@ nf_msg_handler(void *msg_data, __attribute__((unused)) struct onvm_nf_local_ctx // int msg_tests_passed; // int msg_tests_failed; // int msg_test_phase; - // int msg_ring_count; + int msg_ring_count; // uint16_t msg_address; struct test_msg_data *msg_params; @@ -205,16 +208,17 @@ nf_msg_handler(void *msg_data, __attribute__((unused)) struct onvm_nf_local_ctx // msg_tests_passed = msg_params->tests_passed; // msg_tests_failed = msg_params->tests_failed; // msg_test_phase = msg_params->test_phase; - // msg_ring_count = msg_params->ring_count; + msg_ring_count = rte_ring_count(msg_params->msg_q); // msg_address = msg_params->address; - // uint16_t address = nf_local_ctx->nf->service_id; printf("Receive message\n"); - printf("msg_data: %d\n", *((int*) msg_data)); - printf("Ring Count: %u\n", rte_ring_count(msg_params->msg_q)); - FILE *fp = fopen("/users/noahchin/openNetVM/examples/test_messaging/status.txt", "a+"); - rte_ring_dump(fp, msg_params->msg_q); - fclose(fp); + printf("msg_data: %d\n", *((int *)msg_data)); + printf("Ring Count: %u\n", msg_ring_count); + + // FILE *fp = fopen("/users/noahchin/openNetVM/examples/test_messaging/status.txt", "a+"); + // rte_ring_dump(fp, msg_params->msg_q); + // fclose(fp); + int empty = rte_ring_empty(msg_params->msg_q); if(empty != 0){ printf("Message Ring Empty\n"); @@ -223,8 +227,15 @@ nf_msg_handler(void *msg_data, __attribute__((unused)) struct onvm_nf_local_ctx printf("Message Ring Not Empty\n"); } printf("---------------------------\n"); + + if(*((int *)msg_data) == 25){ + printf("PASSED\n"); + } + else{ + printf("FAILED\n"); + } - + msg_params->ring_count = msg_ring_count; } From d27bf561c5c215a48df94b2457875cff593d7329 Mon Sep 17 00:00:00 2001 From: NoahChinitzGWU Date: Fri, 25 Jun 2021 14:59:45 -0600 Subject: [PATCH 13/55] [Update] Working on Unit Tests --- examples/test_messaging/test_messaging.c | 92 ++++++++++++------------ 1 file changed, 46 insertions(+), 46 deletions(-) diff --git a/examples/test_messaging/test_messaging.c b/examples/test_messaging/test_messaging.c index e456ecb47..90e9b425e 100644 --- a/examples/test_messaging/test_messaging.c +++ b/examples/test_messaging/test_messaging.c @@ -150,12 +150,10 @@ nf_setup(__attribute__((unused)) struct onvm_nf_local_ctx *nf_local_ctx) { onvm_nflib_stop(nf_local_ctx); rte_exit(EXIT_FAILURE, "Cannot find mbuf pool!\n"); } - printf("TEST MESSAGING STARTED\n"); - printf("---------------------------\n"); - printf("TEST 1: Send/Receive One Message...\n"); + + printf("\nTEST MESSAGING STARTED\n"); printf("---------------------------\n"); - // printf("TEST 2: Send/Receive Multiple Messages...\n"); - // printf("TEST 3: Message Ring Overflow...\n"); + // int msg_tests_passed; // int msg_tests_failed; // int msg_test_phase; @@ -170,27 +168,19 @@ nf_setup(__attribute__((unused)) struct onvm_nf_local_ctx *nf_local_ctx) { // msg_ring_count = msg_params->ring_count; msg_address = msg_params->address; - int *msg_ints; - msg_ints = (int*)rte_malloc(NULL, sizeof(int*), 0); - *msg_ints = 25; - - int ret = onvm_nflib_send_msg_to_nf(msg_address, msg_ints); - - printf("Sending message: %d\n", *msg_ints); - printf("Return: %d\n", ret); - printf("SID: %i\n", msg_address); - printf("Ring Count: %u\n", rte_ring_count(msg_params->msg_q)); - - // FILE *fp = fopen("/users/noahchin/openNetVM/examples/test_messaging/status.txt", "a+"); - // rte_ring_dump(fp, msg_params->msg_q); - // fclose(fp); - - printf("---------------------------\n"); + *msg_ints = 0; + onvm_nflib_send_msg_to_nf(msg_address, msg_ints); + // printf("Sending message: %d\n", *msg_ints); + // printf("Return: %d\n", ret); + // printf("SID: %i\n", msg_address); + // printf("Ring Count: %u\n", rte_ring_count(msg_params->msg_q)); + // printf("Test Phase: %d\n", msg_test_phase); + // printf("---------------------------\n"); } @@ -199,43 +189,53 @@ nf_msg_handler(void *msg_data, __attribute__((unused)) struct onvm_nf_local_ctx // int msg_tests_passed; // int msg_tests_failed; - // int msg_test_phase; + int msg_test_phase; int msg_ring_count; - // uint16_t msg_address; struct test_msg_data *msg_params; - - msg_params = (struct test_msg_data *)nf_local_ctx->nf->data; + msg_params = (struct test_msg_data *)nf_local_ctx->nf->data; // msg_tests_passed = msg_params->tests_passed; // msg_tests_failed = msg_params->tests_failed; - // msg_test_phase = msg_params->test_phase; + msg_test_phase = msg_params->test_phase; msg_ring_count = rte_ring_count(msg_params->msg_q); // msg_address = msg_params->address; - - printf("Receive message\n"); - printf("msg_data: %d\n", *((int *)msg_data)); - printf("Ring Count: %u\n", msg_ring_count); - - // FILE *fp = fopen("/users/noahchin/openNetVM/examples/test_messaging/status.txt", "a+"); - // rte_ring_dump(fp, msg_params->msg_q); - // fclose(fp); - - int empty = rte_ring_empty(msg_params->msg_q); - if(empty != 0){ - printf("Message Ring Empty\n"); + + + if(msg_test_phase == 1){ + if(*((int *)msg_data) == 0){ + printf("TEST 1: Send/Receive One Message...\n"); + printf("---------------------------\n"); + // printf("Receive message\n"); + // printf("msg_data: %d\n", *((int *)msg_data)); + // printf("Ring Count: %u\n", msg_ring_count); + printf("PASSED\n"); + + } + else{ + printf("FAILED\n"); + } + msg_test_phase++; + } + else if(msg_test_phase == 2){ + printf("TEST 2: Send/Receive Multiple Messages...\n"); + printf("---------------------------\n"); + printf("Receive message\n"); + printf("msg_data: %d\n", *((int *)msg_data)); + printf("Ring Count: %u\n", msg_ring_count); + msg_test_phase++; } - else{ - printf("Message Ring Not Empty\n"); + else if(msg_test_phase == 3){ + printf("TEST 3: Message Ring Overflow...\n"); + printf("---------------------------\n"); + printf("Receive message\n"); + printf("msg_data: %d\n", *((int *)msg_data)); + printf("Ring Count: %u\n", msg_ring_count); } printf("---------------------------\n"); - if(*((int *)msg_data) == 25){ - printf("PASSED\n"); - } - else{ - printf("FAILED\n"); - } + msg_params->ring_count = msg_ring_count; + msg_params->test_phase = msg_test_phase; } From 9a2730aa296607c1a34f432940e834577c8d7595 Mon Sep 17 00:00:00 2001 From: NoahChinitzGWU Date: Mon, 28 Jun 2021 13:36:45 -0600 Subject: [PATCH 14/55] [Update] Verson 1 of Tests. Looking at messaging code now --- examples/test_messaging/test_messaging.c | 120 ++++++++++++++--------- 1 file changed, 73 insertions(+), 47 deletions(-) diff --git a/examples/test_messaging/test_messaging.c b/examples/test_messaging/test_messaging.c index 90e9b425e..44a22aeb6 100644 --- a/examples/test_messaging/test_messaging.c +++ b/examples/test_messaging/test_messaging.c @@ -112,10 +112,10 @@ parse_app_args(int argc, char *argv[], const char *progname, struct onvm_nf *nf) msg_params->tests_passed = 0; msg_params->tests_failed = 0; msg_params->test_phase = 1; - msg_params->ring_count = 0; msg_params->address = nf->service_id; msg_params->msg_pool = nf_msg_pool; msg_params->msg_q = nf->msg_q; + msg_params->ring_count = 0; nf->data = (void *)msg_params; while ((c = getopt(argc, argv, "p:")) != -1) { @@ -154,88 +154,114 @@ nf_setup(__attribute__((unused)) struct onvm_nf_local_ctx *nf_local_ctx) { printf("\nTEST MESSAGING STARTED\n"); printf("---------------------------\n"); - // int msg_tests_passed; - // int msg_tests_failed; - // int msg_test_phase; - // int msg_ring_count; + int msg_tests_passed; + int msg_tests_failed; + int msg_test_phase; + int msg_ring_count; uint16_t msg_address; + struct rte_mempool *msg_pool; + struct rte_ring *msg_q; struct test_msg_data *msg_params; - msg_params = (struct test_msg_data *)nf_local_ctx->nf->data; - // msg_tests_passed = msg_params->tests_passed; - // msg_tests_failed = msg_params->tests_failed; - // msg_test_phase = msg_params->test_phase; - // msg_ring_count = msg_params->ring_count; + msg_params = (struct test_msg_data *)nf_local_ctx->nf->data; + msg_tests_passed = msg_params->tests_passed; + msg_tests_failed = msg_params->tests_failed; + msg_test_phase = msg_params->test_phase; + msg_ring_count = rte_ring_count(msg_params->msg_q); msg_address = msg_params->address; + msg_pool = msg_params->msg_pool; + msg_q = msg_params->msg_q; int *msg_ints; msg_ints = (int*)rte_malloc(NULL, sizeof(int*), 0); - *msg_ints = 0; - - onvm_nflib_send_msg_to_nf(msg_address, msg_ints); - - // printf("Sending message: %d\n", *msg_ints); - // printf("Return: %d\n", ret); - // printf("SID: %i\n", msg_address); - // printf("Ring Count: %u\n", rte_ring_count(msg_params->msg_q)); - // printf("Test Phase: %d\n", msg_test_phase); - // printf("---------------------------\n"); - + *msg_ints = 25; + + for(int i = 0; i < 130; i++){ + onvm_nflib_send_msg_to_nf(msg_address, msg_ints); + } + + msg_params->tests_passed = msg_tests_passed; + msg_params->tests_failed = msg_tests_failed; + msg_params->test_phase = msg_test_phase; + msg_params->ring_count = msg_ring_count; + msg_params->address = msg_address; + msg_params->msg_pool = msg_pool; + msg_params->msg_q = msg_q; + } void nf_msg_handler(void *msg_data, __attribute__((unused)) struct onvm_nf_local_ctx *nf_local_ctx){ - // int msg_tests_passed; - // int msg_tests_failed; + int msg_tests_passed; + int msg_tests_failed; int msg_test_phase; int msg_ring_count; + uint16_t msg_address; + struct rte_mempool *msg_pool; + struct rte_ring *msg_q; struct test_msg_data *msg_params; + msg_params = (struct test_msg_data *)nf_local_ctx->nf->data; - // msg_tests_passed = msg_params->tests_passed; - // msg_tests_failed = msg_params->tests_failed; + msg_tests_passed = msg_params->tests_passed; + msg_tests_failed = msg_params->tests_failed; msg_test_phase = msg_params->test_phase; msg_ring_count = rte_ring_count(msg_params->msg_q); - // msg_address = msg_params->address; - + msg_address = msg_params->address; + msg_pool = msg_params->msg_pool; + msg_q = msg_params->msg_q; if(msg_test_phase == 1){ - if(*((int *)msg_data) == 0){ + + if(*((int *)msg_data) == 25 && msg_ring_count == 126){ printf("TEST 1: Send/Receive One Message...\n"); printf("---------------------------\n"); - // printf("Receive message\n"); - // printf("msg_data: %d\n", *((int *)msg_data)); - // printf("Ring Count: %u\n", msg_ring_count); printf("PASSED\n"); - + msg_tests_passed++; + msg_test_phase++; } else{ - printf("FAILED\n"); + msg_tests_failed++; } - msg_test_phase++; } else if(msg_test_phase == 2){ - printf("TEST 2: Send/Receive Multiple Messages...\n"); - printf("---------------------------\n"); - printf("Receive message\n"); - printf("msg_data: %d\n", *((int *)msg_data)); - printf("Ring Count: %u\n", msg_ring_count); - msg_test_phase++; + + if(*((int *)msg_data) == 25 && msg_ring_count == 116){ + printf("TEST 2: Send/Receive Multiple Messages...\n"); + printf("---------------------------\n"); + printf("PASSED\n"); + msg_tests_passed++; + msg_test_phase++; + } + else{ + msg_tests_failed++; + } } else if(msg_test_phase == 3){ - printf("TEST 3: Message Ring Overflow...\n"); - printf("---------------------------\n"); - printf("Receive message\n"); - printf("msg_data: %d\n", *((int *)msg_data)); - printf("Ring Count: %u\n", msg_ring_count); + + if(*((int *)msg_data) == 25 && msg_ring_count == 0){ + printf("TEST 3: Message Ring Overflow...\n"); + printf("---------------------------\n"); + printf("PASSED\n"); + msg_tests_passed++; + }else{ + msg_tests_failed++; + } } printf("---------------------------\n"); + if(msg_ring_count == 0){ + printf("Passed %d/3 Tests\n", msg_tests_passed); + } - - msg_params->ring_count = msg_ring_count; + msg_params->tests_passed = msg_tests_passed; + msg_params->tests_failed = msg_tests_failed; msg_params->test_phase = msg_test_phase; + msg_params->ring_count = msg_ring_count; + msg_params->address = msg_address; + msg_params->msg_pool = msg_pool; + msg_params->msg_q = msg_q; } From 74350ec5a8b3ed9144238a2bfba9e4ffebce77a1 Mon Sep 17 00:00:00 2001 From: NoahChinitzGWU Date: Mon, 28 Jun 2021 13:55:38 -0600 Subject: [PATCH 15/55] [Update] Testing fixed. Changing Verbosity --- examples/test_messaging/test_messaging.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/examples/test_messaging/test_messaging.c b/examples/test_messaging/test_messaging.c index 44a22aeb6..5a81860b2 100644 --- a/examples/test_messaging/test_messaging.c +++ b/examples/test_messaging/test_messaging.c @@ -173,14 +173,20 @@ nf_setup(__attribute__((unused)) struct onvm_nf_local_ctx *nf_local_ctx) { msg_q = msg_params->msg_q; int *msg_ints; - msg_ints = (int*)rte_malloc(NULL, sizeof(int*), 0); - - *msg_ints = 25; + for(int i = 0; i < 130; i++){ - onvm_nflib_send_msg_to_nf(msg_address, msg_ints); + + msg_ints = (int*)rte_malloc(NULL, sizeof(int*), 0); + + *msg_ints = i; + + onvm_nflib_send_msg_to_nf(msg_address, msg_ints); + } - + + rte_free(msg_ints); + msg_params->tests_passed = msg_tests_passed; msg_params->tests_failed = msg_tests_failed; msg_params->test_phase = msg_test_phase; @@ -211,10 +217,10 @@ nf_msg_handler(void *msg_data, __attribute__((unused)) struct onvm_nf_local_ctx msg_address = msg_params->address; msg_pool = msg_params->msg_pool; msg_q = msg_params->msg_q; - + if(msg_test_phase == 1){ - if(*((int *)msg_data) == 25 && msg_ring_count == 126){ + if(*((int *)msg_data) == 0 && msg_ring_count == 126){ printf("TEST 1: Send/Receive One Message...\n"); printf("---------------------------\n"); printf("PASSED\n"); @@ -227,7 +233,7 @@ nf_msg_handler(void *msg_data, __attribute__((unused)) struct onvm_nf_local_ctx } else if(msg_test_phase == 2){ - if(*((int *)msg_data) == 25 && msg_ring_count == 116){ + if(*((int *)msg_data) == 10 && msg_ring_count == 116){ printf("TEST 2: Send/Receive Multiple Messages...\n"); printf("---------------------------\n"); printf("PASSED\n"); @@ -240,7 +246,7 @@ nf_msg_handler(void *msg_data, __attribute__((unused)) struct onvm_nf_local_ctx } else if(msg_test_phase == 3){ - if(*((int *)msg_data) == 25 && msg_ring_count == 0){ + if(*((int *)msg_data) == 126 && msg_ring_count == 0){ printf("TEST 3: Message Ring Overflow...\n"); printf("---------------------------\n"); printf("PASSED\n"); From 8183ad4b47b445f93bffa1164ec597afc37d1af4 Mon Sep 17 00:00:00 2001 From: Noah Chinitz <62520433+NoahChinitzGWU@users.noreply.github.com> Date: Mon, 28 Jun 2021 16:45:53 -0400 Subject: [PATCH 16/55] Delete Makefile --- examples/basic_msg_test/Makefile | 67 -------------------------------- 1 file changed, 67 deletions(-) delete mode 100644 examples/basic_msg_test/Makefile diff --git a/examples/basic_msg_test/Makefile b/examples/basic_msg_test/Makefile deleted file mode 100644 index b9daee0be..000000000 --- a/examples/basic_msg_test/Makefile +++ /dev/null @@ -1,67 +0,0 @@ -# openNetVM -# https://github.com/sdnfv/openNetVM -# -# BSD LICENSE -# -# Copyright(c) -# 2015-2017 George Washington University -# 2015-2017 University of California Riverside -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# The name of the author may not be used to endorse or promote -# products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -ifeq ($(RTE_SDK),) -$(error "Please define RTE_SDK environment variable") -endif - - -# Default target, can be overriden by command line or environment -include $(RTE_SDK)/mk/rte.vars.mk -RTE_TARGET ?= x86_64-native-linuxapp-gcc - -# binary name -APP = basic_msg_test - -# all source are stored in SRCS-y -SRCS-y := basic_msg_test.c - -ONVM= $(SRCDIR)/../../onvm - -CFLAGS += $(WERROR_FLAGS) -O3 $(USER_FLAGS) - -CFLAGS += -I$(ONVM)/onvm_nflib -CFLAGS += -I$(ONVM)/lib -LDFLAGS += $(ONVM)/onvm_nflib/$(RTE_TARGET)/libonvm.a -LDFLAGS += $(ONVM)/lib/$(RTE_TARGET)/lib/libonvmhelper.a -lm - -# workaround for a gcc bug with noreturn attribute -# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12603 -ifeq ($(CONFIG_RTE_TOOLCHAIN_GCC),y) -CFLAGS_main.o += -Wno-return-type -endif - -include $(RTE_SDK)/mk/rte.extapp.mk From f494289d165f2ebf0a8e39310381a5676049aa9c Mon Sep 17 00:00:00 2001 From: Noah Chinitz <62520433+NoahChinitzGWU@users.noreply.github.com> Date: Mon, 28 Jun 2021 16:46:21 -0400 Subject: [PATCH 17/55] Delete README.md --- examples/basic_msg_test/README.md | 31 ------------------------------- 1 file changed, 31 deletions(-) delete mode 100644 examples/basic_msg_test/README.md diff --git a/examples/basic_msg_test/README.md b/examples/basic_msg_test/README.md deleted file mode 100644 index 5ae665e13..000000000 --- a/examples/basic_msg_test/README.md +++ /dev/null @@ -1,31 +0,0 @@ -Basic Message Test -== -This is an example NF that acts as a unit test for sending messsages from an NF to itself. - -Compilation and Execution --- -``` -cd examples -make -cd basic_msg_test -./go.sh SERVICE_ID [PRINT_DELAY] - -OR - -./go.sh -F CONFIG_FILE -- -- [-p PRINT_DELAY] - -OR - -sudo ./build/basic_msg_test -l CORELIST -n 3 --proc-type=secondary -- -r SERVICE_ID -- [-p PRINT_DELAY] -``` - -App Specific Arguments --- - - `-p `: number of packets between each print, e.g. `-p 1` prints every packet. - -Config File Support --- -This NF supports the NF generating arguments from a config file. For -additional reading, see [Examples.md](../../docs/Examples.md) - -See `../example_config.json` for all possible options that can be set. \ No newline at end of file From 9f3f5574a42cee811cea17eff452c5a4386261d9 Mon Sep 17 00:00:00 2001 From: Noah Chinitz <62520433+NoahChinitzGWU@users.noreply.github.com> Date: Mon, 28 Jun 2021 16:46:29 -0400 Subject: [PATCH 18/55] Delete go.sh --- examples/basic_msg_test/go.sh | 20 -------------------- 1 file changed, 20 deletions(-) delete mode 100755 examples/basic_msg_test/go.sh diff --git a/examples/basic_msg_test/go.sh b/examples/basic_msg_test/go.sh deleted file mode 100755 index 03fc3bb36..000000000 --- a/examples/basic_msg_test/go.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash - -#The go.sh script is a convinient way to run start_nf.sh without specifying NF_NAME - -NF_DIR=${PWD##*/} - -if [ ! -f ../start_nf.sh ]; then - echo "ERROR: The ./go.sh script can only be used from the NF folder" - echo "If running from other directory use examples/start_nf.sh" - exit 1 -fi - -# only check for running manager if not in Docker -if [[ -z $(pgrep -u root -f "/onvm/onvm_mgr/.*/onvm_mgr") ]] && ! grep -q "docker" /proc/1/cgroup -then - echo "NF cannot start without a running manager" - exit 1 -fi - -../start_nf.sh "$NF_DIR" "$@" From 74eca8c3ae56d6abe544259e48dfbd6d96958f47 Mon Sep 17 00:00:00 2001 From: Noah Chinitz <62520433+NoahChinitzGWU@users.noreply.github.com> Date: Mon, 28 Jun 2021 16:46:36 -0400 Subject: [PATCH 19/55] Delete test_messaging.c --- examples/basic_msg_test/test_messaging.c | 193 ----------------------- 1 file changed, 193 deletions(-) delete mode 100644 examples/basic_msg_test/test_messaging.c diff --git a/examples/basic_msg_test/test_messaging.c b/examples/basic_msg_test/test_messaging.c deleted file mode 100644 index 780968d0d..000000000 --- a/examples/basic_msg_test/test_messaging.c +++ /dev/null @@ -1,193 +0,0 @@ -/********************************************************************* - * openNetVM - * https://sdnfv.github.io - * - * BSD LICENSE - * - * Copyright(c) - * 2015-2019 George Washington University - * 2015-2019 University of California Riverside - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * basic_msg_test.c - unit test to ensure NFs can send messages to itself - ********************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "onvm_nflib.h" -#include "onvm_pkt_helper.h" - -#define NF_TAG "basic_msg_test" - -/* number of package between each print */ -static uint32_t print_delay = 1000000; - -static uint16_t destination; - -void -nf_setup(struct onvm_nf_local_ctx *nf_local_ctx); - -void -nf_msg_handler(void *msg_data, struct onvm_nf_local_ctx *nf_local_ctx); - -/* - * Print a usage message - */ -static void -usage(const char *progname) { - printf("Usage:\n"); - printf("%s [EAL args] -- [NF_LIB args] -- -p \n", progname); - printf("%s -F [EAL args] -- [NF_LIB args] -- [NF args]\n\n", progname); - printf("Flags:\n"); - printf(" - `-p `: number of packets between each print, e.g. `-p 1` prints every packets.\n"); -} - -/* - * Parse the application arguments. - */ -static int -parse_app_args(int argc, char *argv[], const char *progname) { - int c; - - while ((c = getopt(argc, argv, "p:")) != -1) { - switch (c) { - case 'p': - print_delay = strtoul(optarg, NULL, 10); - RTE_LOG(INFO, APP, "print_delay = %d\n", print_delay); - break; - case '?': - usage(progname); - if (optopt == 'p') - RTE_LOG(INFO, APP, "Option -%c requires an argument.\n", optopt); - else if (isprint(optopt)) - RTE_LOG(INFO, APP, "Unknown option `-%c'.\n", optopt); - else - RTE_LOG(INFO, APP, "Unknown option character `\\x%x'.\n", optopt); - return -1; - default: - usage(progname); - return -1; - } - } - return optind; -} - -void -nf_setup(__attribute__((unused)) struct onvm_nf_local_ctx *nf_local_ctx) { - struct rte_mempool *pktmbuf_pool; - - pktmbuf_pool = rte_mempool_lookup(PKTMBUF_POOL_NAME); - if (pktmbuf_pool == NULL) { - onvm_nflib_stop(nf_local_ctx); - rte_exit(EXIT_FAILURE, "Cannot find mbuf pool!\n"); - } - - uint16_t address = nf_local_ctx->nf->service_id; - - int ret = onvm_nflib_send_msg_to_nf(address, NULL); - printf("%d\n", ret); - -} - -void -nf_msg_handler(void *msg_data, __attribute__((unused)) struct onvm_nf_local_ctx *nf_local_ctx){ - - uint16_t address = nf_local_ctx->nf->service_id; - - int ret = onvm_nflib_send_msg_to_nf(address, msg_data); - printf("%d\n", ret); - -} - -static int -packet_handler(__attribute__((unused)) struct rte_mbuf *pkt, struct onvm_pkt_meta *meta, - __attribute__((unused)) struct onvm_nf_local_ctx *nf_local_ctx) { - - meta->destination = destination; - meta->action = ONVM_NF_ACTION_TONF; - - return 0; -} - -int -main(int argc, char *argv[]) { - int arg_offset; - struct onvm_nf_local_ctx *nf_local_ctx; - struct onvm_nf_function_table *nf_function_table; - const char *progname = argv[0]; - - nf_local_ctx = onvm_nflib_init_nf_local_ctx(); - onvm_nflib_start_signal_handler(nf_local_ctx, NULL); - - nf_function_table = onvm_nflib_init_nf_function_table(); - nf_function_table->pkt_handler = &packet_handler; - nf_function_table->setup = &nf_setup; - nf_function_table->msg_handler = &nf_msg_handler; - - if ((arg_offset = onvm_nflib_init(argc, argv, NF_TAG, nf_local_ctx, nf_function_table)) < 0) { - onvm_nflib_stop(nf_local_ctx); - if (arg_offset == ONVM_SIGNAL_TERMINATION) { - printf("Exiting due to user termination\n"); - return 0; - } else { - rte_exit(EXIT_FAILURE, "Failed ONVM init\n"); - } - } - - argc -= arg_offset; - argv += arg_offset; - - if (parse_app_args(argc, argv, progname) < 0) { - onvm_nflib_stop(nf_local_ctx); - rte_exit(EXIT_FAILURE, "Invalid command-line arguments\n"); - } - - onvm_nflib_run(nf_local_ctx); - - onvm_nflib_stop(nf_local_ctx); - - printf("If we reach here, program is ending\n"); - return 0; -} \ No newline at end of file From 25fc0630b9b2e2c446a52cabd73c5251409ecd12 Mon Sep 17 00:00:00 2001 From: NoahChinitzGWU Date: Tue, 29 Jun 2021 10:35:42 -0600 Subject: [PATCH 20/55] [Update] Ready for Review. --- examples/test_messaging/README.md | 8 ----- examples/test_messaging/test_messaging.c | 39 +++++++++++++----------- 2 files changed, 22 insertions(+), 25 deletions(-) diff --git a/examples/test_messaging/README.md b/examples/test_messaging/README.md index 1f6d5664d..a20f58196 100644 --- a/examples/test_messaging/README.md +++ b/examples/test_messaging/README.md @@ -9,14 +9,6 @@ cd examples make cd test_messaging ./go.sh SERVICE_ID [PRINT_DELAY] - -OR - -./go.sh -F CONFIG_FILE -- -- [-p PRINT_DELAY] - -OR - -sudo ./build/test_messaging -l CORELIST -n 3 --proc-type=secondary -- -r SERVICE_ID -- [-p PRINT_DELAY] ``` App Specific Arguments diff --git a/examples/test_messaging/test_messaging.c b/examples/test_messaging/test_messaging.c index 5a81860b2..5c1095563 100644 --- a/examples/test_messaging/test_messaging.c +++ b/examples/test_messaging/test_messaging.c @@ -35,7 +35,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * test_messaging.c - unit test to ensure NFs can send messages to itself + * test_messaging.c - unit test to ensure NFs can send messages to themselves ********************************************************************/ #include @@ -62,11 +62,13 @@ #define NF_TAG "test_messaging" -/* number of package between each print */ static uint32_t print_delay = 1000000; static uint16_t destination; +/* num_msgs must be 128 or larger for all three tests to be ran and executed properly */ +static int num_msgs = 130; + struct test_msg_data{ int tests_passed; int tests_failed; @@ -141,6 +143,9 @@ parse_app_args(int argc, char *argv[], const char *progname, struct onvm_nf *nf) return optind; } +/* + * Sets up the NF. Initiates Unit Test + */ void nf_setup(__attribute__((unused)) struct onvm_nf_local_ctx *nf_local_ctx) { struct rte_mempool *pktmbuf_pool; @@ -173,9 +178,9 @@ nf_setup(__attribute__((unused)) struct onvm_nf_local_ctx *nf_local_ctx) { msg_q = msg_params->msg_q; int *msg_ints; - - for(int i = 0; i < 130; i++){ + /* num_msgs must be 128 or larger for all three tests to be ran and executed properly */ + for(int i = 0; i < num_msgs; i++){ msg_ints = (int*)rte_malloc(NULL, sizeof(int*), 0); @@ -196,7 +201,9 @@ nf_setup(__attribute__((unused)) struct onvm_nf_local_ctx *nf_local_ctx) { msg_params->msg_q = msg_q; } - +/* + * Runs logic for tests + */ void nf_msg_handler(void *msg_data, __attribute__((unused)) struct onvm_nf_local_ctx *nf_local_ctx){ @@ -219,41 +226,39 @@ nf_msg_handler(void *msg_data, __attribute__((unused)) struct onvm_nf_local_ctx msg_q = msg_params->msg_q; if(msg_test_phase == 1){ - - if(*((int *)msg_data) == 0 && msg_ring_count == 126){ + + /* Ensures that one message can be sent to itself */ + if(*((int *)msg_data) == (126 - msg_ring_count) && msg_ring_count == 126){ printf("TEST 1: Send/Receive One Message...\n"); printf("---------------------------\n"); printf("PASSED\n"); msg_tests_passed++; msg_test_phase++; } - else{ - msg_tests_failed++; - } + } else if(msg_test_phase == 2){ - if(*((int *)msg_data) == 10 && msg_ring_count == 116){ + /* Ensures that multiple messages can be sent to itself */ + if(*((int *)msg_data) == (126 - msg_ring_count) && msg_ring_count == 116){ printf("TEST 2: Send/Receive Multiple Messages...\n"); printf("---------------------------\n"); printf("PASSED\n"); msg_tests_passed++; msg_test_phase++; } - else{ - msg_tests_failed++; - } + } else if(msg_test_phase == 3){ - if(*((int *)msg_data) == 126 && msg_ring_count == 0){ + /* Ensures that even when the message ring overflows it can still process the messages */ + if(*((int *)msg_data) == (126 - msg_ring_count) && msg_ring_count == 0){ printf("TEST 3: Message Ring Overflow...\n"); printf("---------------------------\n"); printf("PASSED\n"); msg_tests_passed++; - }else{ - msg_tests_failed++; } + } printf("---------------------------\n"); From 2ae757f034445c74ca9a1e7c01e70fea2e9fc688 Mon Sep 17 00:00:00 2001 From: elliotthenne Date: Wed, 30 Jun 2021 14:14:02 -0700 Subject: [PATCH 21/55] debug files --- .vscode/launch.json | 29 +++++++++++++++++++++++++++++ .vscode/tasks.json | 27 +++++++++++++++++++++++++++ examples/gdb.sh | 1 + examples/go.sh | 2 +- 4 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 .vscode/launch.json create mode 100644 .vscode/tasks.json create mode 100644 examples/gdb.sh diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 000000000..6fdc4b269 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,29 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "gcc-9 - Build and debug speed tester", + "type": "cppdbg", + "request": "launch", + "program": "${workspaceFolder}/examples/speed_tester/build/app/speed_tester", + "args": ["-l", "0", "-n", "3", "--proc-type=secondary", "--", "-r", "1", "--", "-d", "1", "-c", "16000"], + "stopAtEntry": false, + "cwd": "${fileDirname}", + "environment": [], + "externalConsole": false, + "MIMode": "gdb", + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + } + ], + //"preLaunchTask": "C/C++: gcc-9 build active file", + "miDebuggerPath": "${workspaceFolder}/examples/gdb.sh" + } + ] +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 000000000..af54f1753 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,27 @@ +{ + "tasks": [ + { + "type": "cppbuild", + "label": "C/C++: gcc-9 build active file", + "command": "/usr/bin/gcc-9", + "args": [ + "-g", + "${file}", + "-o", + "${fileDirname}/${fileBasenameNoExtension}" + ], + "options": { + "cwd": "${fileDirname}" + }, + "problemMatcher": [ + "$gcc" + ], + "group": { + "kind": "build", + "isDefault": true + }, + "detail": "Task generated by Debugger." + } + ], + "version": "2.0.0" +} \ No newline at end of file diff --git a/examples/gdb.sh b/examples/gdb.sh new file mode 100644 index 000000000..1664fabeb --- /dev/null +++ b/examples/gdb.sh @@ -0,0 +1 @@ +pkexec /usr/bin/gdb "$@" diff --git a/examples/go.sh b/examples/go.sh index 8bcb99221..8c8fb6071 100755 --- a/examples/go.sh +++ b/examples/go.sh @@ -19,4 +19,4 @@ then exit 1 fi -../start_nf.sh $NF_DIR "$@" +bash -x ../start_nf.sh $NF_DIR "$@" From 23d7c550c038e29267ddc826eb3b3c3384aac21b Mon Sep 17 00:00:00 2001 From: NoahChinitzGWU Date: Wed, 30 Jun 2021 15:20:21 -0600 Subject: [PATCH 22/55] [Update] Test Version 3.0 --- examples/test_messaging/test_messaging.c | 214 +++++++++++++---------- 1 file changed, 123 insertions(+), 91 deletions(-) diff --git a/examples/test_messaging/test_messaging.c b/examples/test_messaging/test_messaging.c index 5c1095563..a11d89a85 100644 --- a/examples/test_messaging/test_messaging.c +++ b/examples/test_messaging/test_messaging.c @@ -61,18 +61,17 @@ #include "onvm_common.h" #define NF_TAG "test_messaging" +#define MAGIC_NUMBER 11 static uint32_t print_delay = 1000000; static uint16_t destination; -/* num_msgs must be 128 or larger for all three tests to be ran and executed properly */ -static int num_msgs = 130; - struct test_msg_data{ int tests_passed; int tests_failed; int test_phase; + int test_msg_count; int ring_count; uint16_t address; struct rte_mempool* msg_pool; @@ -118,6 +117,7 @@ parse_app_args(int argc, char *argv[], const char *progname, struct onvm_nf *nf) msg_params->msg_pool = nf_msg_pool; msg_params->msg_q = nf->msg_q; msg_params->ring_count = 0; + msg_params->test_msg_count = 0; nf->data = (void *)msg_params; while ((c = getopt(argc, argv, "p:")) != -1) { @@ -159,120 +159,150 @@ nf_setup(__attribute__((unused)) struct onvm_nf_local_ctx *nf_local_ctx) { printf("\nTEST MESSAGING STARTED\n"); printf("---------------------------\n"); - int msg_tests_passed; - int msg_tests_failed; - int msg_test_phase; - int msg_ring_count; - uint16_t msg_address; - struct rte_mempool *msg_pool; - struct rte_ring *msg_q; struct test_msg_data *msg_params; msg_params = (struct test_msg_data *)nf_local_ctx->nf->data; - msg_tests_passed = msg_params->tests_passed; - msg_tests_failed = msg_params->tests_failed; - msg_test_phase = msg_params->test_phase; - msg_ring_count = rte_ring_count(msg_params->msg_q); - msg_address = msg_params->address; - msg_pool = msg_params->msg_pool; - msg_q = msg_params->msg_q; - - int *msg_ints; - - /* num_msgs must be 128 or larger for all three tests to be ran and executed properly */ - for(int i = 0; i < num_msgs; i++){ - - msg_ints = (int*)rte_malloc(NULL, sizeof(int*), 0); - - *msg_ints = i; - onvm_nflib_send_msg_to_nf(msg_address, msg_ints); - - } - - rte_free(msg_ints); - - msg_params->tests_passed = msg_tests_passed; - msg_params->tests_failed = msg_tests_failed; - msg_params->test_phase = msg_test_phase; - msg_params->ring_count = msg_ring_count; - msg_params->address = msg_address; - msg_params->msg_pool = msg_pool; - msg_params->msg_q = msg_q; - + int *msg_int; + msg_int = (int*)rte_malloc(NULL, sizeof(int), 0); + *msg_int = MAGIC_NUMBER; + onvm_nflib_send_msg_to_nf(msg_params->address, msg_int); } + /* * Runs logic for tests */ void nf_msg_handler(void *msg_data, __attribute__((unused)) struct onvm_nf_local_ctx *nf_local_ctx){ - int msg_tests_passed; - int msg_tests_failed; - int msg_test_phase; - int msg_ring_count; - uint16_t msg_address; - struct rte_mempool *msg_pool; - struct rte_ring *msg_q; struct test_msg_data *msg_params; - msg_params = (struct test_msg_data *)nf_local_ctx->nf->data; - msg_tests_passed = msg_params->tests_passed; - msg_tests_failed = msg_params->tests_failed; - msg_test_phase = msg_params->test_phase; - msg_ring_count = rte_ring_count(msg_params->msg_q); - msg_address = msg_params->address; - msg_pool = msg_params->msg_pool; - msg_q = msg_params->msg_q; - - if(msg_test_phase == 1){ - - /* Ensures that one message can be sent to itself */ - if(*((int *)msg_data) == (126 - msg_ring_count) && msg_ring_count == 126){ - printf("TEST 1: Send/Receive One Message...\n"); - printf("---------------------------\n"); - printf("PASSED\n"); - msg_tests_passed++; - msg_test_phase++; + msg_params = (struct test_msg_data *)nf_local_ctx->nf->data; + + if(msg_params->test_phase == 1){ + + printf("TEST 1: Send/Receive One Message...\n"); + printf("---------------------------\n"); + + msg_params->test_msg_count++; + + if(1 == msg_params->test_msg_count){ + + if(rte_ring_count(msg_params->msg_q) != 0) { + printf("FAILED: Shouldn't be any messages left, but there are %d in the ring. This may cause future tests to fail.\n", rte_ring_count(msg_params->msg_q)); + msg_params->tests_failed++; + msg_params->test_phase++; + } + else { + if(*((int *)msg_data) == MAGIC_NUMBER){ + printf("PASSED\n"); + msg_params->tests_passed++; + msg_params->test_phase++; + } + else { + printf("FAILED: received %d instead of %d\n", *((int *)msg_data), MAGIC_NUMBER); + msg_params->tests_failed++; + msg_params->test_phase++; + } + } + + } + + rte_free(msg_data); + + msg_params->test_msg_count = 0; + // rte_ring_reset(msg_params->msg_q); + + // send messgaes for phase 2 here + printf("TEST 2: Send/Receive Multiple Messages...\n"); + printf("---------------------------\n"); + + for(int i = 0; i < 10; i++){ + int* msg_int = (int*)rte_malloc(NULL, sizeof(int), 0); + *msg_int = i; + onvm_nflib_send_msg_to_nf(msg_params->address, msg_int); } } - else if(msg_test_phase == 2){ + else if(msg_params->test_phase == 2){ + if(*((int *)msg_data) != msg_params->test_msg_count) { + printf("FAILED: received %d instead of %d\n", *((int *)msg_data), msg_params->test_msg_count); + msg_params->tests_failed++; + msg_params->test_phase++; + } + else { + msg_params->test_msg_count++; + } + + rte_free(msg_data); + /* Ensures that multiple messages can be sent to itself */ - if(*((int *)msg_data) == (126 - msg_ring_count) && msg_ring_count == 116){ - printf("TEST 2: Send/Receive Multiple Messages...\n"); - printf("---------------------------\n"); - printf("PASSED\n"); - msg_tests_passed++; - msg_test_phase++; + if(10 == msg_params->test_msg_count){ + + if(rte_ring_count(msg_params->msg_q) != 0) { + printf("FAILED: Shouldn't be any messages left, but there are %d in the ring. This may cause future tests to fail.\n", rte_ring_count(msg_params->msg_q)); + msg_params->tests_failed++; + msg_params->test_phase++; + } + else { + printf("PASSED\n"); + msg_params->tests_passed++; + msg_params->test_phase++; + } + + } + + msg_params->test_msg_count = 0; + // rte_ring_reset(msg_params->msg_q); + + printf("TEST 3: Message Ring Overflow...\n"); + printf("---------------------------\n"); + + for(int i = 0; i < 130; i++){ + int* msg_int = (int*)rte_malloc(NULL, sizeof(int), 0); + *msg_int = i; + onvm_nflib_send_msg_to_nf(msg_params->address, msg_int); } + // TODO: can we detect that we fail phase 2 from missing messages? + } - else if(msg_test_phase == 3){ + else if(msg_params->test_phase == 3){ - /* Ensures that even when the message ring overflows it can still process the messages */ - if(*((int *)msg_data) == (126 - msg_ring_count) && msg_ring_count == 0){ - printf("TEST 3: Message Ring Overflow...\n"); - printf("---------------------------\n"); - printf("PASSED\n"); - msg_tests_passed++; + if(*((int *)msg_data) != msg_params->test_msg_count) { + printf("FAILED: received %d instead of %d\n", *((int *)msg_data), msg_params->test_msg_count); + msg_params->tests_failed++; + msg_params->test_phase++; + } + else { + msg_params->test_msg_count++; + } + + rte_free(msg_data); + + /* Ensures that multiple messages can be sent to itself */ + if(126 == msg_params->test_msg_count){ + + if(rte_ring_count(msg_params->msg_q) != 0) { + printf("FAILED: Shouldn't be any messages left, but there are %d in the ring. This may cause future tests to fail.\n", rte_ring_count(msg_params->msg_q)); + msg_params->tests_failed++; + msg_params->test_phase++; + } + else { + printf("PASSED\n"); + msg_params->tests_passed++; + msg_params->test_phase++; + } + } } - printf("---------------------------\n"); + else if(msg_params->test_phase == 4){ + printf("Passed %d/3 Tests\n", msg_params->tests_passed); + } - if(msg_ring_count == 0){ - printf("Passed %d/3 Tests\n", msg_tests_passed); - } - - msg_params->tests_passed = msg_tests_passed; - msg_params->tests_failed = msg_tests_failed; - msg_params->test_phase = msg_test_phase; - msg_params->ring_count = msg_ring_count; - msg_params->address = msg_address; - msg_params->msg_pool = msg_pool; - msg_params->msg_q = msg_q; + printf("---------------------------\n"); } @@ -322,6 +352,8 @@ main(int argc, char *argv[]) { onvm_nflib_run(nf_local_ctx); onvm_nflib_stop(nf_local_ctx); + + rte_free(nf_local_ctx->nf->data); printf("If we reach here, program is ending\n"); return 0; From 85ecb0d118ff67c087f5b02a2ec65a650cec9bf7 Mon Sep 17 00:00:00 2001 From: elliotthenne Date: Wed, 30 Jun 2021 14:32:50 -0700 Subject: [PATCH 23/55] restored old go.sh file --- examples/go.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/go.sh b/examples/go.sh index 8c8fb6071..8bcb99221 100755 --- a/examples/go.sh +++ b/examples/go.sh @@ -19,4 +19,4 @@ then exit 1 fi -bash -x ../start_nf.sh $NF_DIR "$@" +../start_nf.sh $NF_DIR "$@" From 76e6be979c30c36974a9ae58ddd7dc7fd71faaf1 Mon Sep 17 00:00:00 2001 From: NoahChinitzGWU Date: Thu, 1 Jul 2021 12:45:26 -0600 Subject: [PATCH 24/55] [Update] Version 3.1 of Tests. Added destroy funciton --- examples/test_messaging/test_messaging.c | 80 +++++++++++++++--------- 1 file changed, 51 insertions(+), 29 deletions(-) diff --git a/examples/test_messaging/test_messaging.c b/examples/test_messaging/test_messaging.c index a11d89a85..e851f44c6 100644 --- a/examples/test_messaging/test_messaging.c +++ b/examples/test_messaging/test_messaging.c @@ -84,6 +84,19 @@ nf_setup(struct onvm_nf_local_ctx *nf_local_ctx); void nf_msg_handler(void *msg_data, struct onvm_nf_local_ctx *nf_local_ctx); +/* + * Frees memory allocated to the test_msg_data struct + */ +static int +destroy_test_msg_data(struct test_msg_data *test_msg_data){ + if(test_msg_data == NULL){ + return 0; + } + rte_free(test_msg_data); + return 0; + +} + /* * Print a usage message */ @@ -179,6 +192,7 @@ nf_msg_handler(void *msg_data, __attribute__((unused)) struct onvm_nf_local_ctx msg_params = (struct test_msg_data *)nf_local_ctx->nf->data; + // Tests if one message can be sent to itself if(msg_params->test_phase == 1){ printf("TEST 1: Send/Receive One Message...\n"); @@ -189,18 +203,21 @@ nf_msg_handler(void *msg_data, __attribute__((unused)) struct onvm_nf_local_ctx if(1 == msg_params->test_msg_count){ if(rte_ring_count(msg_params->msg_q) != 0) { - printf("FAILED: Shouldn't be any messages left, but there are %d in the ring. This may cause future tests to fail.\n", rte_ring_count(msg_params->msg_q)); + printf("FAILED TEST 1: Shouldn't be any messages left, but there are %d in the ring. This may cause future tests to fail.\n", rte_ring_count(msg_params->msg_q)); + printf("---------------------------\n"); msg_params->tests_failed++; msg_params->test_phase++; } else { if(*((int *)msg_data) == MAGIC_NUMBER){ - printf("PASSED\n"); + printf("PASSED TEST 1\n"); + printf("---------------------------\n"); msg_params->tests_passed++; msg_params->test_phase++; } else { - printf("FAILED: received %d instead of %d\n", *((int *)msg_data), MAGIC_NUMBER); + printf("FAILED TEST 1: received %d instead of %d\n", *((int *)msg_data), MAGIC_NUMBER); + printf("---------------------------\n"); msg_params->tests_failed++; msg_params->test_phase++; } @@ -211,9 +228,7 @@ nf_msg_handler(void *msg_data, __attribute__((unused)) struct onvm_nf_local_ctx rte_free(msg_data); msg_params->test_msg_count = 0; - // rte_ring_reset(msg_params->msg_q); - - // send messgaes for phase 2 here + printf("TEST 2: Send/Receive Multiple Messages...\n"); printf("---------------------------\n"); @@ -224,10 +239,12 @@ nf_msg_handler(void *msg_data, __attribute__((unused)) struct onvm_nf_local_ctx } } + //Tests if multiple messages can be sent to itself else if(msg_params->test_phase == 2){ if(*((int *)msg_data) != msg_params->test_msg_count) { - printf("FAILED: received %d instead of %d\n", *((int *)msg_data), msg_params->test_msg_count); + printf("FAILED TEST 2: received %d instead of %d\n", *((int *)msg_data), msg_params->test_msg_count); + printf("---------------------------\n"); msg_params->tests_failed++; msg_params->test_phase++; } @@ -237,41 +254,43 @@ nf_msg_handler(void *msg_data, __attribute__((unused)) struct onvm_nf_local_ctx rte_free(msg_data); - /* Ensures that multiple messages can be sent to itself */ if(10 == msg_params->test_msg_count){ if(rte_ring_count(msg_params->msg_q) != 0) { - printf("FAILED: Shouldn't be any messages left, but there are %d in the ring. This may cause future tests to fail.\n", rte_ring_count(msg_params->msg_q)); + printf("FAILED TEST 2: Shouldn't be any messages left, but there are %d in the ring. This may cause future tests to fail.\n", rte_ring_count(msg_params->msg_q)); + printf("---------------------------\n"); msg_params->tests_failed++; msg_params->test_phase++; } else { - printf("PASSED\n"); + printf("PASSED TEST 2\n"); + printf("---------------------------\n"); msg_params->tests_passed++; msg_params->test_phase++; + msg_params->test_msg_count = 0; } } - - msg_params->test_msg_count = 0; - // rte_ring_reset(msg_params->msg_q); - printf("TEST 3: Message Ring Overflow...\n"); - printf("---------------------------\n"); - - for(int i = 0; i < 130; i++){ - int* msg_int = (int*)rte_malloc(NULL, sizeof(int), 0); - *msg_int = i; - onvm_nflib_send_msg_to_nf(msg_params->address, msg_int); + if(msg_params->test_msg_count == 0){ + printf("TEST 3: Message Ring Overflow...\n"); + printf("---------------------------\n"); + for(int i = 0; i < 130; i++){ + int* msg_int = (int*)rte_malloc(NULL, sizeof(int), 0); + *msg_int = i; + onvm_nflib_send_msg_to_nf(msg_params->address, msg_int); + } } // TODO: can we detect that we fail phase 2 from missing messages? } + //Tests to see if even with a ring overflow it can still handle the messages else if(msg_params->test_phase == 3){ if(*((int *)msg_data) != msg_params->test_msg_count) { - printf("FAILED: received %d instead of %d\n", *((int *)msg_data), msg_params->test_msg_count); + printf("FAILED TEST 3: received %d instead of %d\n", *((int *)msg_data), msg_params->test_msg_count); + printf("---------------------------\n"); msg_params->tests_failed++; msg_params->test_phase++; } @@ -280,17 +299,18 @@ nf_msg_handler(void *msg_data, __attribute__((unused)) struct onvm_nf_local_ctx } rte_free(msg_data); - - /* Ensures that multiple messages can be sent to itself */ - if(126 == msg_params->test_msg_count){ + + if(127 == msg_params->test_msg_count){ if(rte_ring_count(msg_params->msg_q) != 0) { - printf("FAILED: Shouldn't be any messages left, but there are %d in the ring. This may cause future tests to fail.\n", rte_ring_count(msg_params->msg_q)); + printf("FAILED TEST 3: Shouldn't be any messages left, but there are %d in the ring. This may cause future tests to fail.\n", rte_ring_count(msg_params->msg_q)); + printf("---------------------------\n"); msg_params->tests_failed++; msg_params->test_phase++; } else { - printf("PASSED\n"); + printf("PASSED TEST 3\n"); + printf("---------------------------\n"); msg_params->tests_passed++; msg_params->test_phase++; } @@ -298,7 +318,8 @@ nf_msg_handler(void *msg_data, __attribute__((unused)) struct onvm_nf_local_ctx } } - else if(msg_params->test_phase == 4){ + + if(msg_params->test_phase == 4){ printf("Passed %d/3 Tests\n", msg_params->tests_passed); } @@ -345,15 +366,16 @@ main(int argc, char *argv[]) { argv += arg_offset; if (parse_app_args(argc, argv, progname, nf_local_ctx->nf) < 0) { + destroy_test_msg_data(nf_local_ctx->nf->data); onvm_nflib_stop(nf_local_ctx); rte_exit(EXIT_FAILURE, "Invalid command-line arguments\n"); } onvm_nflib_run(nf_local_ctx); - onvm_nflib_stop(nf_local_ctx); + destroy_test_msg_data((struct test_msg_data*)&nf_local_ctx->nf->data); - rte_free(nf_local_ctx->nf->data); + onvm_nflib_stop(nf_local_ctx); printf("If we reach here, program is ending\n"); return 0; From 87cf62b3c639badaf42f6955e8b0f136ea01d3be Mon Sep 17 00:00:00 2001 From: NoahChinitzGWU Date: Tue, 6 Jul 2021 14:29:40 -0600 Subject: [PATCH 25/55] [Update] Fixed destroy function. Added NF to examples/Makefile. Still working on hanging execution. --- examples/Makefile | 2 +- examples/test_messaging/test_messaging.c | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/examples/Makefile b/examples/Makefile index 3ce592312..e997c7690 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -40,7 +40,7 @@ $(error "Please define RTE_SDK environment variable") endif # To add new examples, append the directory name to this variable -examples = bridge basic_monitor simple_forward speed_tester flow_table test_flow_dir aes_encrypt aes_decrypt flow_tracker load_balancer arp_response nf_router scaling_example load_generator payload_scan firewall simple_fwd_tb l2fwd +examples = bridge basic_monitor simple_forward speed_tester flow_table test_flow_dir aes_encrypt aes_decrypt flow_tracker load_balancer arp_response nf_router scaling_example load_generator payload_scan firewall simple_fwd_tb l2fwd test_messaging ifeq ($(NDPI_HOME),) $(warning "Skipping ndpi_stats NF as NDPI_HOME is not set") diff --git a/examples/test_messaging/test_messaging.c b/examples/test_messaging/test_messaging.c index e851f44c6..7caec6873 100644 --- a/examples/test_messaging/test_messaging.c +++ b/examples/test_messaging/test_messaging.c @@ -88,13 +88,13 @@ nf_msg_handler(void *msg_data, struct onvm_nf_local_ctx *nf_local_ctx); * Frees memory allocated to the test_msg_data struct */ static int -destroy_test_msg_data(struct test_msg_data *test_msg_data){ +destroy_test_msg_data(struct test_msg_data **test_msg_data){ if(test_msg_data == NULL){ return 0; } - rte_free(test_msg_data); + rte_free(*test_msg_data); + (*test_msg_data) = NULL; return 0; - } /* @@ -205,6 +205,9 @@ nf_msg_handler(void *msg_data, __attribute__((unused)) struct onvm_nf_local_ctx if(rte_ring_count(msg_params->msg_q) != 0) { printf("FAILED TEST 1: Shouldn't be any messages left, but there are %d in the ring. This may cause future tests to fail.\n", rte_ring_count(msg_params->msg_q)); printf("---------------------------\n"); + while(rte_ring_count(msg_params->msg_q) != 0){ + rte_ring_dequeue(msg_params->msg_q, msg_data); + } msg_params->tests_failed++; msg_params->test_phase++; } @@ -259,6 +262,9 @@ nf_msg_handler(void *msg_data, __attribute__((unused)) struct onvm_nf_local_ctx if(rte_ring_count(msg_params->msg_q) != 0) { printf("FAILED TEST 2: Shouldn't be any messages left, but there are %d in the ring. This may cause future tests to fail.\n", rte_ring_count(msg_params->msg_q)); printf("---------------------------\n"); + while(rte_ring_count(msg_params->msg_q) != 0){ + rte_ring_dequeue(msg_params->msg_q, msg_data); + } msg_params->tests_failed++; msg_params->test_phase++; } @@ -305,6 +311,9 @@ nf_msg_handler(void *msg_data, __attribute__((unused)) struct onvm_nf_local_ctx if(rte_ring_count(msg_params->msg_q) != 0) { printf("FAILED TEST 3: Shouldn't be any messages left, but there are %d in the ring. This may cause future tests to fail.\n", rte_ring_count(msg_params->msg_q)); printf("---------------------------\n"); + while(rte_ring_count(msg_params->msg_q) != 0){ + rte_ring_dequeue(msg_params->msg_q, msg_data); + } msg_params->tests_failed++; msg_params->test_phase++; } @@ -373,7 +382,7 @@ main(int argc, char *argv[]) { onvm_nflib_run(nf_local_ctx); - destroy_test_msg_data((struct test_msg_data*)&nf_local_ctx->nf->data); + destroy_test_msg_data((struct test_msg_data**)&nf_local_ctx->nf->data); onvm_nflib_stop(nf_local_ctx); From 438c88033a54b3ea2a669bec28b3e527526d4a8d Mon Sep 17 00:00:00 2001 From: NoahChinitzGWU Date: Tue, 6 Jul 2021 16:43:04 -0600 Subject: [PATCH 26/55] Hanging occurs when IID != SID --- examples/test_messaging/test_messaging.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/examples/test_messaging/test_messaging.c b/examples/test_messaging/test_messaging.c index 7caec6873..46fbeded3 100644 --- a/examples/test_messaging/test_messaging.c +++ b/examples/test_messaging/test_messaging.c @@ -178,8 +178,15 @@ nf_setup(__attribute__((unused)) struct onvm_nf_local_ctx *nf_local_ctx) { int *msg_int; msg_int = (int*)rte_malloc(NULL, sizeof(int), 0); + if(msg_int == NULL){ + printf("Message was not able to be malloc'd\n"); + } *msg_int = MAGIC_NUMBER; - onvm_nflib_send_msg_to_nf(msg_params->address, msg_int); + int ret = onvm_nflib_send_msg_to_nf(msg_params->address, msg_int); + if(ret != 0){ + printf("Message was unable to be sent\n"); + } + } /* From 7d4bc26b7e7cf089bc50949117c6f8f59bc5550b Mon Sep 17 00:00:00 2001 From: elliotthenne <63778310+elliotthenne@users.noreply.github.com> Date: Tue, 6 Jul 2021 16:39:15 -0700 Subject: [PATCH 27/55] Update launch.json --- .vscode/launch.json | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 6fdc4b269..1a354774b 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -5,7 +5,7 @@ "version": "0.2.0", "configurations": [ { - "name": "gcc-9 - Build and debug speed tester", + "name": "gcc-9 - Debug speed tester", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/examples/speed_tester/build/app/speed_tester", @@ -22,8 +22,7 @@ "ignoreFailures": true } ], - //"preLaunchTask": "C/C++: gcc-9 build active file", "miDebuggerPath": "${workspaceFolder}/examples/gdb.sh" } ] -} \ No newline at end of file +} From 5379bc031dbd6f6487d5ebf88d176a45f0240ac7 Mon Sep 17 00:00:00 2001 From: NoahChinitzGWU Date: Wed, 7 Jul 2021 11:37:16 -0600 Subject: [PATCH 28/55] - Added GDB configuration for VSCode. - Convert from service ID to instance ID when sending message in /examples/test_messaging - Add support to look up instance ID of a message by passing NULL for the packet --- .vscode/launch.json | 20 ++++++++++++++++++++ examples/gdb.sh | 2 +- onvm/onvm_nflib/onvm_nflib.c | 4 +++- onvm/onvm_nflib/onvm_sc_common.c | 7 +++++-- 4 files changed, 29 insertions(+), 4 deletions(-) mode change 100644 => 100755 examples/gdb.sh diff --git a/.vscode/launch.json b/.vscode/launch.json index 1a354774b..b7ff4ecbf 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -23,6 +23,26 @@ } ], "miDebuggerPath": "${workspaceFolder}/examples/gdb.sh" + }, + { + "name": "gcc-9 - Debug Message Tester", + "type": "cppdbg", + "request": "launch", + "program": "${workspaceFolder}/examples/test_messaging/build/app/test_messaging", + "args": ["-l", "0", "-n", "3", "--proc-type=secondary", "--", "-r", "1"], + "stopAtEntry": false, + "cwd": "${fileDirname}", + "environment": [], + "externalConsole": false, + "MIMode": "gdb", + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + } + ], + "miDebuggerPath": "${workspaceFolder}/examples/gdb.sh" } ] } diff --git a/examples/gdb.sh b/examples/gdb.sh old mode 100644 new mode 100755 index 1664fabeb..e087ff4ea --- a/examples/gdb.sh +++ b/examples/gdb.sh @@ -1 +1 @@ -pkexec /usr/bin/gdb "$@" +sudo /usr/bin/gdb "$@" diff --git a/onvm/onvm_nflib/onvm_nflib.c b/onvm/onvm_nflib/onvm_nflib.c index fd67153d0..10f5b03bb 100644 --- a/onvm/onvm_nflib/onvm_nflib.c +++ b/onvm/onvm_nflib/onvm_nflib.c @@ -727,7 +727,9 @@ onvm_nflib_send_msg_to_nf(uint16_t dest, void *msg_data) { msg->msg_type = MSG_FROM_NF; msg->msg_data = msg_data; - ret = rte_ring_enqueue(nfs[dest].msg_q, (void*)msg); + //need to convert from SID to IID + uint16_t instance_id = onvm_sc_service_to_nf_map(dest, NULL); + ret = rte_ring_enqueue(nfs[instance_id].msg_q, (void*)msg); if(ret != 0){ RTE_LOG(ERR, APP, "Destination NF ring is full! Unable to enqueue msg to ring\n"); rte_mempool_put(nf_msg_pool, (void*)msg); diff --git a/onvm/onvm_nflib/onvm_sc_common.c b/onvm/onvm_nflib/onvm_sc_common.c index 6dcd506c4..f43f34c61 100644 --- a/onvm/onvm_nflib/onvm_sc_common.c +++ b/onvm/onvm_nflib/onvm_sc_common.c @@ -55,8 +55,11 @@ onvm_sc_service_to_nf_map(uint16_t service_id, struct rte_mbuf *pkt) { if (num_nfs_available == 0) return 0; - if (pkt == NULL) - return 0; + if (pkt == NULL){ + uint16_t instance_id = services[service_id][0]; + return instance_id; + } + uint16_t instance_index = pkt->hash.rss % num_nfs_available; uint16_t instance_id = services[service_id][instance_index]; From d0b7a37502c71ce9fa72d42aa88cc85a076cd559 Mon Sep 17 00:00:00 2001 From: NoahChinitzGWU Date: Wed, 7 Jul 2021 12:21:28 -0600 Subject: [PATCH 29/55] Added function comments --- onvm/onvm_nflib/onvm_nflib.c | 2 +- onvm/onvm_nflib/onvm_nflib.h | 10 ++++++++++ onvm/onvm_nflib/onvm_sc_common.h | 6 ++++-- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/onvm/onvm_nflib/onvm_nflib.c b/onvm/onvm_nflib/onvm_nflib.c index 10f5b03bb..269e40422 100644 --- a/onvm/onvm_nflib/onvm_nflib.c +++ b/onvm/onvm_nflib/onvm_nflib.c @@ -727,8 +727,8 @@ onvm_nflib_send_msg_to_nf(uint16_t dest, void *msg_data) { msg->msg_type = MSG_FROM_NF; msg->msg_data = msg_data; - //need to convert from SID to IID uint16_t instance_id = onvm_sc_service_to_nf_map(dest, NULL); + ret = rte_ring_enqueue(nfs[instance_id].msg_q, (void*)msg); if(ret != 0){ RTE_LOG(ERR, APP, "Destination NF ring is full! Unable to enqueue msg to ring\n"); diff --git a/onvm/onvm_nflib/onvm_nflib.h b/onvm/onvm_nflib/onvm_nflib.h index 858f95e45..e83b0073c 100644 --- a/onvm/onvm_nflib/onvm_nflib.h +++ b/onvm/onvm_nflib/onvm_nflib.h @@ -188,6 +188,16 @@ onvm_nflib_start_nf(struct onvm_nf_local_ctx *nf_local_ctx, struct onvm_nf_init_ int onvm_nflib_handle_msg(struct onvm_nf_msg *msg, struct onvm_nf_local_ctx *nf_local_ctx); +/** + * Sends a message to another NF + * + * @param dest_nf + * The destination NF's service ID + * @param msg_data + * Pointer to the message that is sent + * @return + * 0 on success, or a negative value on error + */ int onvm_nflib_send_msg_to_nf(uint16_t dest_nf, void *msg_data); diff --git a/onvm/onvm_nflib/onvm_sc_common.h b/onvm/onvm_nflib/onvm_sc_common.h index d0ed4a032..84efbde75 100644 --- a/onvm/onvm_nflib/onvm_sc_common.h +++ b/onvm/onvm_nflib/onvm_sc_common.h @@ -51,10 +51,12 @@ extern uint16_t **services; extern uint16_t *nf_per_service_count; /********************************Interfaces***********************************/ - +/* Returns the instance ID associated with the given service ID and packet. + If using for a message, given packet is NULL and the function returns + the first instance ID associated with the given service ID for messaging */ uint16_t onvm_sc_service_to_nf_map(uint16_t service_id, - struct rte_mbuf *pkt); /*, uint16_t *nf_per_service_count, uint16_t **services);*/ + struct rte_mbuf *pkt); /* append a entry to serivce chain, 0 means appending successful, 1 means failed*/ int From 9582113365c6dfeb2db131faeef202c00691da55 Mon Sep 17 00:00:00 2001 From: Noah Chinitz Date: Tue, 27 Jul 2021 17:58:19 +0000 Subject: [PATCH 30/55] [Update] fixed file according to PR comments --- examples/test_messaging/test_messaging.c | 30 ++++++++++++++++++------ 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/examples/test_messaging/test_messaging.c b/examples/test_messaging/test_messaging.c index 46fbeded3..a155cdff5 100644 --- a/examples/test_messaging/test_messaging.c +++ b/examples/test_messaging/test_messaging.c @@ -73,6 +73,7 @@ struct test_msg_data{ int test_phase; int test_msg_count; int ring_count; + int mempool_count; uint16_t address; struct rte_mempool* msg_pool; struct rte_ring *msg_q; @@ -130,6 +131,7 @@ parse_app_args(int argc, char *argv[], const char *progname, struct onvm_nf *nf) msg_params->msg_pool = nf_msg_pool; msg_params->msg_q = nf->msg_q; msg_params->ring_count = 0; + msg_params->mempool_count = rte_mempool_avail_count(msg_params->msg_pool); msg_params->test_msg_count = 0; nf->data = (void *)msg_params; @@ -186,7 +188,6 @@ nf_setup(__attribute__((unused)) struct onvm_nf_local_ctx *nf_local_ctx) { if(ret != 0){ printf("Message was unable to be sent\n"); } - } /* @@ -200,7 +201,7 @@ nf_msg_handler(void *msg_data, __attribute__((unused)) struct onvm_nf_local_ctx msg_params = (struct test_msg_data *)nf_local_ctx->nf->data; // Tests if one message can be sent to itself - if(msg_params->test_phase == 1){ + if(1 == msg_params->test_phase){ printf("TEST 1: Send/Receive One Message...\n"); printf("---------------------------\n"); @@ -218,6 +219,11 @@ nf_msg_handler(void *msg_data, __attribute__((unused)) struct onvm_nf_local_ctx msg_params->tests_failed++; msg_params->test_phase++; } + if((int)rte_mempool_avail_count(msg_params->msg_pool) != msg_params->mempool_count - 1){ + printf("FAILED TEST 1: %d messages have not been deallocated from the memory pool. There is a memory leak somewhere.\n", rte_mempool_avail_count(msg_params->msg_pool)); + msg_params->tests_failed++; + msg_params->test_phase++; + } else { if(*((int *)msg_data) == MAGIC_NUMBER){ printf("PASSED TEST 1\n"); @@ -250,7 +256,7 @@ nf_msg_handler(void *msg_data, __attribute__((unused)) struct onvm_nf_local_ctx } //Tests if multiple messages can be sent to itself - else if(msg_params->test_phase == 2){ + else if(2 == msg_params->test_phase){ if(*((int *)msg_data) != msg_params->test_msg_count) { printf("FAILED TEST 2: received %d instead of %d\n", *((int *)msg_data), msg_params->test_msg_count); @@ -275,6 +281,11 @@ nf_msg_handler(void *msg_data, __attribute__((unused)) struct onvm_nf_local_ctx msg_params->tests_failed++; msg_params->test_phase++; } + if((int)rte_mempool_avail_count(msg_params->msg_pool) != msg_params->mempool_count - 1){ + printf("FAILED TEST 2: %d messages have not been deallocated from the memory pool. There is a memory leak somewhere.\n", rte_mempool_avail_count(msg_params->msg_pool)); + msg_params->tests_failed++; + msg_params->test_phase++; + } else { printf("PASSED TEST 2\n"); printf("---------------------------\n"); @@ -285,10 +296,10 @@ nf_msg_handler(void *msg_data, __attribute__((unused)) struct onvm_nf_local_ctx } - if(msg_params->test_msg_count == 0){ + if(0 == msg_params->test_msg_count){ printf("TEST 3: Message Ring Overflow...\n"); printf("---------------------------\n"); - for(int i = 0; i < 130; i++){ + for(int i = 0; i < (int)(rte_ring_get_size(msg_params->msg_q) + 2); i++){ int* msg_int = (int*)rte_malloc(NULL, sizeof(int), 0); *msg_int = i; onvm_nflib_send_msg_to_nf(msg_params->address, msg_int); @@ -313,7 +324,7 @@ nf_msg_handler(void *msg_data, __attribute__((unused)) struct onvm_nf_local_ctx rte_free(msg_data); - if(127 == msg_params->test_msg_count){ + if((int)(rte_ring_get_size(msg_params->msg_q) - 1) == msg_params->test_msg_count){ if(rte_ring_count(msg_params->msg_q) != 0) { printf("FAILED TEST 3: Shouldn't be any messages left, but there are %d in the ring. This may cause future tests to fail.\n", rte_ring_count(msg_params->msg_q)); @@ -324,6 +335,11 @@ nf_msg_handler(void *msg_data, __attribute__((unused)) struct onvm_nf_local_ctx msg_params->tests_failed++; msg_params->test_phase++; } + if((int)rte_mempool_avail_count(msg_params->msg_pool) != msg_params->mempool_count - 1){ + printf("FAILED TEST 3: %d messages have not been deallocated from the memory pool. There is a memory leak somewhere.\n", rte_mempool_avail_count(msg_params->msg_pool)); + msg_params->tests_failed++; + msg_params->test_phase++; + } else { printf("PASSED TEST 3\n"); printf("---------------------------\n"); @@ -335,7 +351,7 @@ nf_msg_handler(void *msg_data, __attribute__((unused)) struct onvm_nf_local_ctx } - if(msg_params->test_phase == 4){ + if(4 == msg_params->test_phase){ printf("Passed %d/3 Tests\n", msg_params->tests_passed); } From 4832b0f82746f61c07af8de71dede182e0ed836c Mon Sep 17 00:00:00 2001 From: Noah Chinitz <62520433+NoahChinitzGWU@users.noreply.github.com> Date: Tue, 27 Jul 2021 14:31:39 -0400 Subject: [PATCH 31/55] Delete launch.json --- .vscode/launch.json | 48 --------------------------------------------- 1 file changed, 48 deletions(-) delete mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index b7ff4ecbf..000000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,48 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": "gcc-9 - Debug speed tester", - "type": "cppdbg", - "request": "launch", - "program": "${workspaceFolder}/examples/speed_tester/build/app/speed_tester", - "args": ["-l", "0", "-n", "3", "--proc-type=secondary", "--", "-r", "1", "--", "-d", "1", "-c", "16000"], - "stopAtEntry": false, - "cwd": "${fileDirname}", - "environment": [], - "externalConsole": false, - "MIMode": "gdb", - "setupCommands": [ - { - "description": "Enable pretty-printing for gdb", - "text": "-enable-pretty-printing", - "ignoreFailures": true - } - ], - "miDebuggerPath": "${workspaceFolder}/examples/gdb.sh" - }, - { - "name": "gcc-9 - Debug Message Tester", - "type": "cppdbg", - "request": "launch", - "program": "${workspaceFolder}/examples/test_messaging/build/app/test_messaging", - "args": ["-l", "0", "-n", "3", "--proc-type=secondary", "--", "-r", "1"], - "stopAtEntry": false, - "cwd": "${fileDirname}", - "environment": [], - "externalConsole": false, - "MIMode": "gdb", - "setupCommands": [ - { - "description": "Enable pretty-printing for gdb", - "text": "-enable-pretty-printing", - "ignoreFailures": true - } - ], - "miDebuggerPath": "${workspaceFolder}/examples/gdb.sh" - } - ] -} From 5b9896e48cede0dc1c097f3c5eba797e68199e7e Mon Sep 17 00:00:00 2001 From: Noah Chinitz <62520433+NoahChinitzGWU@users.noreply.github.com> Date: Tue, 27 Jul 2021 14:31:49 -0400 Subject: [PATCH 32/55] Delete tasks.json --- .vscode/tasks.json | 27 --------------------------- 1 file changed, 27 deletions(-) delete mode 100644 .vscode/tasks.json diff --git a/.vscode/tasks.json b/.vscode/tasks.json deleted file mode 100644 index af54f1753..000000000 --- a/.vscode/tasks.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "tasks": [ - { - "type": "cppbuild", - "label": "C/C++: gcc-9 build active file", - "command": "/usr/bin/gcc-9", - "args": [ - "-g", - "${file}", - "-o", - "${fileDirname}/${fileBasenameNoExtension}" - ], - "options": { - "cwd": "${fileDirname}" - }, - "problemMatcher": [ - "$gcc" - ], - "group": { - "kind": "build", - "isDefault": true - }, - "detail": "Task generated by Debugger." - } - ], - "version": "2.0.0" -} \ No newline at end of file From 3018dbbb42bb74626268b86e82b5c6f978fb1d5d Mon Sep 17 00:00:00 2001 From: Noah Chinitz <62520433+NoahChinitzGWU@users.noreply.github.com> Date: Tue, 27 Jul 2021 14:32:00 -0400 Subject: [PATCH 33/55] Delete gdb.sh --- examples/gdb.sh | 1 - 1 file changed, 1 deletion(-) delete mode 100755 examples/gdb.sh diff --git a/examples/gdb.sh b/examples/gdb.sh deleted file mode 100755 index e087ff4ea..000000000 --- a/examples/gdb.sh +++ /dev/null @@ -1 +0,0 @@ -sudo /usr/bin/gdb "$@" From b648a1392f82470549b1cca7e9ec8e914033ca03 Mon Sep 17 00:00:00 2001 From: NoahChintzGWU Date: Tue, 27 Jul 2021 18:37:26 +0000 Subject: [PATCH 34/55] [Update] Deleted unnecessary files --- examples/test_messaging/test_messaging.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/examples/test_messaging/test_messaging.c b/examples/test_messaging/test_messaging.c index a155cdff5..89adfc071 100644 --- a/examples/test_messaging/test_messaging.c +++ b/examples/test_messaging/test_messaging.c @@ -180,11 +180,14 @@ nf_setup(__attribute__((unused)) struct onvm_nf_local_ctx *nf_local_ctx) { int *msg_int; msg_int = (int*)rte_malloc(NULL, sizeof(int), 0); + if(msg_int == NULL){ printf("Message was not able to be malloc'd\n"); } + *msg_int = MAGIC_NUMBER; int ret = onvm_nflib_send_msg_to_nf(msg_params->address, msg_int); + if(ret != 0){ printf("Message was unable to be sent\n"); } From 58243bfc01a5a7236fb252c16a580d415b161d73 Mon Sep 17 00:00:00 2001 From: NoahChinitzGWU Date: Tue, 17 Aug 2021 20:22:02 +0000 Subject: [PATCH 35/55] Changed test making sure all messages have been dequeued --- examples/test_messaging/test_messaging.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/examples/test_messaging/test_messaging.c b/examples/test_messaging/test_messaging.c index 89adfc071..fe59ea7a1 100644 --- a/examples/test_messaging/test_messaging.c +++ b/examples/test_messaging/test_messaging.c @@ -5,8 +5,8 @@ * BSD LICENSE * * Copyright(c) - * 2015-2019 George Washington University - * 2015-2019 University of California Riverside + * 2015-2021 George Washington University + * 2015-2021 University of California Riverside * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -190,7 +190,7 @@ nf_setup(__attribute__((unused)) struct onvm_nf_local_ctx *nf_local_ctx) { if(ret != 0){ printf("Message was unable to be sent\n"); - } + } } /* @@ -222,8 +222,8 @@ nf_msg_handler(void *msg_data, __attribute__((unused)) struct onvm_nf_local_ctx msg_params->tests_failed++; msg_params->test_phase++; } - if((int)rte_mempool_avail_count(msg_params->msg_pool) != msg_params->mempool_count - 1){ - printf("FAILED TEST 1: %d messages have not been deallocated from the memory pool. There is a memory leak somewhere.\n", rte_mempool_avail_count(msg_params->msg_pool)); + if((int)rte_mempool_avail_count(msg_params->msg_pool) != msg_params->mempool_count){ + printf("FAILED TEST 1: %d messages have not been deallocated back to the memory pool. There is a memory leak somewhere.\n", msg_params->mempool_count - rte_mempool_avail_count(msg_params->msg_pool)); msg_params->tests_failed++; msg_params->test_phase++; } @@ -284,8 +284,8 @@ nf_msg_handler(void *msg_data, __attribute__((unused)) struct onvm_nf_local_ctx msg_params->tests_failed++; msg_params->test_phase++; } - if((int)rte_mempool_avail_count(msg_params->msg_pool) != msg_params->mempool_count - 1){ - printf("FAILED TEST 2: %d messages have not been deallocated from the memory pool. There is a memory leak somewhere.\n", rte_mempool_avail_count(msg_params->msg_pool)); + if((int)rte_mempool_avail_count(msg_params->msg_pool) != msg_params->mempool_count){ + printf("FAILED TEST 2: %d messages have not been deallocated back to the memory pool. There is a memory leak somewhere.\n", msg_params->mempool_count - rte_mempool_avail_count(msg_params->msg_pool)); msg_params->tests_failed++; msg_params->test_phase++; } @@ -313,7 +313,7 @@ nf_msg_handler(void *msg_data, __attribute__((unused)) struct onvm_nf_local_ctx } //Tests to see if even with a ring overflow it can still handle the messages - else if(msg_params->test_phase == 3){ + else if(3 == msg_params->test_phase){ if(*((int *)msg_data) != msg_params->test_msg_count) { printf("FAILED TEST 3: received %d instead of %d\n", *((int *)msg_data), msg_params->test_msg_count); @@ -338,8 +338,8 @@ nf_msg_handler(void *msg_data, __attribute__((unused)) struct onvm_nf_local_ctx msg_params->tests_failed++; msg_params->test_phase++; } - if((int)rte_mempool_avail_count(msg_params->msg_pool) != msg_params->mempool_count - 1){ - printf("FAILED TEST 3: %d messages have not been deallocated from the memory pool. There is a memory leak somewhere.\n", rte_mempool_avail_count(msg_params->msg_pool)); + if((int)rte_mempool_avail_count(msg_params->msg_pool) != msg_params->mempool_count){ + printf("FAILED TEST 3: %d messages have not been deallocated back to the memory pool. There is a memory leak somewhere.\n", msg_params->mempool_count - rte_mempool_avail_count(msg_params->msg_pool)); msg_params->tests_failed++; msg_params->test_phase++; } @@ -353,7 +353,7 @@ nf_msg_handler(void *msg_data, __attribute__((unused)) struct onvm_nf_local_ctx } } - + if(4 == msg_params->test_phase){ printf("Passed %d/3 Tests\n", msg_params->tests_passed); } From fd0ded8053ef460aa05ace76270bd7c287f7d3aa Mon Sep 17 00:00:00 2001 From: NoahChinitzGWU Date: Wed, 18 Aug 2021 20:08:05 +0000 Subject: [PATCH 36/55] [Update] cleaned up the tests --- examples/test_messaging/test_messaging.c | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/examples/test_messaging/test_messaging.c b/examples/test_messaging/test_messaging.c index fe59ea7a1..e04b8a386 100644 --- a/examples/test_messaging/test_messaging.c +++ b/examples/test_messaging/test_messaging.c @@ -222,11 +222,6 @@ nf_msg_handler(void *msg_data, __attribute__((unused)) struct onvm_nf_local_ctx msg_params->tests_failed++; msg_params->test_phase++; } - if((int)rte_mempool_avail_count(msg_params->msg_pool) != msg_params->mempool_count){ - printf("FAILED TEST 1: %d messages have not been deallocated back to the memory pool. There is a memory leak somewhere.\n", msg_params->mempool_count - rte_mempool_avail_count(msg_params->msg_pool)); - msg_params->tests_failed++; - msg_params->test_phase++; - } else { if(*((int *)msg_data) == MAGIC_NUMBER){ printf("PASSED TEST 1\n"); @@ -284,11 +279,6 @@ nf_msg_handler(void *msg_data, __attribute__((unused)) struct onvm_nf_local_ctx msg_params->tests_failed++; msg_params->test_phase++; } - if((int)rte_mempool_avail_count(msg_params->msg_pool) != msg_params->mempool_count){ - printf("FAILED TEST 2: %d messages have not been deallocated back to the memory pool. There is a memory leak somewhere.\n", msg_params->mempool_count - rte_mempool_avail_count(msg_params->msg_pool)); - msg_params->tests_failed++; - msg_params->test_phase++; - } else { printf("PASSED TEST 2\n"); printf("---------------------------\n"); @@ -338,11 +328,6 @@ nf_msg_handler(void *msg_data, __attribute__((unused)) struct onvm_nf_local_ctx msg_params->tests_failed++; msg_params->test_phase++; } - if((int)rte_mempool_avail_count(msg_params->msg_pool) != msg_params->mempool_count){ - printf("FAILED TEST 3: %d messages have not been deallocated back to the memory pool. There is a memory leak somewhere.\n", msg_params->mempool_count - rte_mempool_avail_count(msg_params->msg_pool)); - msg_params->tests_failed++; - msg_params->test_phase++; - } else { printf("PASSED TEST 3\n"); printf("---------------------------\n"); @@ -354,8 +339,13 @@ nf_msg_handler(void *msg_data, __attribute__((unused)) struct onvm_nf_local_ctx } - if(4 == msg_params->test_phase){ - printf("Passed %d/3 Tests\n", msg_params->tests_passed); + if(0 == msg_params->test_msg_count){ + if((int)rte_mempool_avail_count(msg_params->msg_pool) == msg_params->mempool_count){ + printf("Passed %d/3 Tests\n", msg_params->tests_passed); + } + else{ + printf("%d messages have not been deallocated back to the memory pool.\n", msg_params->mempool_count - rte_mempool_avail_count(msg_params->msg_pool)); + } } printf("---------------------------\n"); From 6ad66aa7489476865bc2abf153f52da33e17f651 Mon Sep 17 00:00:00 2001 From: NoahChinitzGWU Date: Thu, 19 Aug 2021 16:22:35 +0000 Subject: [PATCH 37/55] [Update] Ran Linter and finalized tests --- examples/test_messaging/Makefile | 4 +- examples/test_messaging/test_messaging.c | 133 +++++++---------------- onvm/onvm_nflib/onvm_nflib.c | 3 +- onvm/onvm_nflib/onvm_sc_common.c | 3 +- 4 files changed, 43 insertions(+), 100 deletions(-) diff --git a/examples/test_messaging/Makefile b/examples/test_messaging/Makefile index d69f9959c..ffb501a59 100644 --- a/examples/test_messaging/Makefile +++ b/examples/test_messaging/Makefile @@ -4,8 +4,8 @@ # BSD LICENSE # # Copyright(c) -# 2015-2017 George Washington University -# 2015-2017 University of California Riverside +# 2015-2021 George Washington University +# 2015-2021 University of California Riverside # All rights reserved. # # Redistribution and use in source and binary forms, with or without diff --git a/examples/test_messaging/test_messaging.c b/examples/test_messaging/test_messaging.c index e04b8a386..f2e8d01d4 100644 --- a/examples/test_messaging/test_messaging.c +++ b/examples/test_messaging/test_messaging.c @@ -65,8 +65,6 @@ static uint32_t print_delay = 1000000; -static uint16_t destination; - struct test_msg_data{ int tests_passed; int tests_failed; @@ -89,8 +87,8 @@ nf_msg_handler(void *msg_data, struct onvm_nf_local_ctx *nf_local_ctx); * Frees memory allocated to the test_msg_data struct */ static int -destroy_test_msg_data(struct test_msg_data **test_msg_data){ - if(test_msg_data == NULL){ +destroy_test_msg_data(struct test_msg_data **test_msg_data) { + if (test_msg_data == NULL) { return 0; } rte_free(*test_msg_data); @@ -162,9 +160,8 @@ parse_app_args(int argc, char *argv[], const char *progname, struct onvm_nf *nf) * Sets up the NF. Initiates Unit Test */ void -nf_setup(__attribute__((unused)) struct onvm_nf_local_ctx *nf_local_ctx) { +nf_setup(struct onvm_nf_local_ctx *nf_local_ctx) { struct rte_mempool *pktmbuf_pool; - pktmbuf_pool = rte_mempool_lookup(PKTMBUF_POOL_NAME); if (pktmbuf_pool == NULL) { onvm_nflib_stop(nf_local_ctx); @@ -173,192 +170,142 @@ nf_setup(__attribute__((unused)) struct onvm_nf_local_ctx *nf_local_ctx) { printf("\nTEST MESSAGING STARTED\n"); printf("---------------------------\n"); - struct test_msg_data *msg_params; - - msg_params = (struct test_msg_data *)nf_local_ctx->nf->data; - + msg_params = (struct test_msg_data *)nf_local_ctx->nf->data; int *msg_int; msg_int = (int*)rte_malloc(NULL, sizeof(int), 0); - - if(msg_int == NULL){ + if (msg_int == NULL) { printf("Message was not able to be malloc'd\n"); } - *msg_int = MAGIC_NUMBER; int ret = onvm_nflib_send_msg_to_nf(msg_params->address, msg_int); - - if(ret != 0){ + if (ret != 0) { printf("Message was unable to be sent\n"); - } + } } /* * Runs logic for tests */ void -nf_msg_handler(void *msg_data, __attribute__((unused)) struct onvm_nf_local_ctx *nf_local_ctx){ - +nf_msg_handler(void *msg_data, struct onvm_nf_local_ctx *nf_local_ctx) { struct test_msg_data *msg_params; - msg_params = (struct test_msg_data *)nf_local_ctx->nf->data; - // Tests if one message can be sent to itself - if(1 == msg_params->test_phase){ - + if (1 == msg_params->test_phase) { printf("TEST 1: Send/Receive One Message...\n"); printf("---------------------------\n"); - msg_params->test_msg_count++; - - if(1 == msg_params->test_msg_count){ - - if(rte_ring_count(msg_params->msg_q) != 0) { + if (1 == msg_params->test_msg_count) { + if (rte_ring_count(msg_params->msg_q) != 0) { printf("FAILED TEST 1: Shouldn't be any messages left, but there are %d in the ring. This may cause future tests to fail.\n", rte_ring_count(msg_params->msg_q)); printf("---------------------------\n"); - while(rte_ring_count(msg_params->msg_q) != 0){ + while (rte_ring_count(msg_params->msg_q) != 0) { rte_ring_dequeue(msg_params->msg_q, msg_data); } msg_params->tests_failed++; msg_params->test_phase++; - } - else { - if(*((int *)msg_data) == MAGIC_NUMBER){ + } else { + if (*((int *)msg_data) == MAGIC_NUMBER) { printf("PASSED TEST 1\n"); printf("---------------------------\n"); msg_params->tests_passed++; msg_params->test_phase++; - } - else { + } else { printf("FAILED TEST 1: received %d instead of %d\n", *((int *)msg_data), MAGIC_NUMBER); printf("---------------------------\n"); msg_params->tests_failed++; msg_params->test_phase++; } } - } - rte_free(msg_data); - msg_params->test_msg_count = 0; - printf("TEST 2: Send/Receive Multiple Messages...\n"); printf("---------------------------\n"); - - for(int i = 0; i < 10; i++){ + for (int i = 0; i < 10; i++) { int* msg_int = (int*)rte_malloc(NULL, sizeof(int), 0); - *msg_int = i; + *msg_int = i; onvm_nflib_send_msg_to_nf(msg_params->address, msg_int); } - - } - //Tests if multiple messages can be sent to itself - else if(2 == msg_params->test_phase){ - - if(*((int *)msg_data) != msg_params->test_msg_count) { + } else if (2 == msg_params->test_phase) { // Tests if multiple messages can be sent to itself + if (*((int *)msg_data) != msg_params->test_msg_count) { printf("FAILED TEST 2: received %d instead of %d\n", *((int *)msg_data), msg_params->test_msg_count); printf("---------------------------\n"); msg_params->tests_failed++; msg_params->test_phase++; - } - else { + } else { msg_params->test_msg_count++; } - rte_free(msg_data); - - if(10 == msg_params->test_msg_count){ - - if(rte_ring_count(msg_params->msg_q) != 0) { + if (10 == msg_params->test_msg_count) { + if (rte_ring_count(msg_params->msg_q) != 0) { printf("FAILED TEST 2: Shouldn't be any messages left, but there are %d in the ring. This may cause future tests to fail.\n", rte_ring_count(msg_params->msg_q)); printf("---------------------------\n"); - while(rte_ring_count(msg_params->msg_q) != 0){ + while (rte_ring_count(msg_params->msg_q) != 0) { rte_ring_dequeue(msg_params->msg_q, msg_data); } msg_params->tests_failed++; msg_params->test_phase++; - } - else { + } else { printf("PASSED TEST 2\n"); printf("---------------------------\n"); msg_params->tests_passed++; msg_params->test_phase++; msg_params->test_msg_count = 0; } - } - - if(0 == msg_params->test_msg_count){ + if (0 == msg_params->test_msg_count) { printf("TEST 3: Message Ring Overflow...\n"); printf("---------------------------\n"); - for(int i = 0; i < (int)(rte_ring_get_size(msg_params->msg_q) + 2); i++){ + for (int i = 0; i < (int)(rte_ring_get_size(msg_params->msg_q) + 2); i++) { int* msg_int = (int*)rte_malloc(NULL, sizeof(int), 0); - *msg_int = i; + *msg_int = i; onvm_nflib_send_msg_to_nf(msg_params->address, msg_int); } } - // TODO: can we detect that we fail phase 2 from missing messages? - - } - //Tests to see if even with a ring overflow it can still handle the messages - else if(3 == msg_params->test_phase){ - - if(*((int *)msg_data) != msg_params->test_msg_count) { + } else if (3 == msg_params->test_phase) { // Tests to see if even with a ring overflow it can still handle the messages + if (*((int *)msg_data) != msg_params->test_msg_count) { printf("FAILED TEST 3: received %d instead of %d\n", *((int *)msg_data), msg_params->test_msg_count); printf("---------------------------\n"); msg_params->tests_failed++; msg_params->test_phase++; - } - else { + } else { msg_params->test_msg_count++; } - rte_free(msg_data); - - if((int)(rte_ring_get_size(msg_params->msg_q) - 1) == msg_params->test_msg_count){ - - if(rte_ring_count(msg_params->msg_q) != 0) { + if ((int)(rte_ring_get_size(msg_params->msg_q) - 1) == msg_params->test_msg_count) { + if (rte_ring_count(msg_params->msg_q) != 0) { printf("FAILED TEST 3: Shouldn't be any messages left, but there are %d in the ring. This may cause future tests to fail.\n", rte_ring_count(msg_params->msg_q)); printf("---------------------------\n"); - while(rte_ring_count(msg_params->msg_q) != 0){ + while (rte_ring_count(msg_params->msg_q) != 0) { rte_ring_dequeue(msg_params->msg_q, msg_data); } msg_params->tests_failed++; msg_params->test_phase++; - } - else { + } else { printf("PASSED TEST 3\n"); printf("---------------------------\n"); msg_params->tests_passed++; msg_params->test_phase++; } - } - } - - if(0 == msg_params->test_msg_count){ - if((int)rte_mempool_avail_count(msg_params->msg_pool) == msg_params->mempool_count){ + if (4 == msg_params->test_phase) { + if ((int)rte_mempool_avail_count(msg_params->msg_pool) == msg_params->mempool_count) { printf("Passed %d/3 Tests\n", msg_params->tests_passed); - } - else{ + } else { printf("%d messages have not been deallocated back to the memory pool.\n", msg_params->mempool_count - rte_mempool_avail_count(msg_params->msg_pool)); } } - printf("---------------------------\n"); - } static int packet_handler(__attribute__((unused)) struct rte_mbuf *pkt, struct onvm_pkt_meta *meta, __attribute__((unused)) struct onvm_nf_local_ctx *nf_local_ctx) { - - meta->destination = destination; meta->action = ONVM_NF_ACTION_DROP; - return 0; } @@ -397,11 +344,9 @@ main(int argc, char *argv[]) { } onvm_nflib_run(nf_local_ctx); - destroy_test_msg_data((struct test_msg_data**)&nf_local_ctx->nf->data); - onvm_nflib_stop(nf_local_ctx); - + printf("If we reach here, program is ending\n"); return 0; -} \ No newline at end of file +} diff --git a/onvm/onvm_nflib/onvm_nflib.c b/onvm/onvm_nflib/onvm_nflib.c index 269e40422..9bfaa0526 100644 --- a/onvm/onvm_nflib/onvm_nflib.c +++ b/onvm/onvm_nflib/onvm_nflib.c @@ -728,9 +728,8 @@ onvm_nflib_send_msg_to_nf(uint16_t dest, void *msg_data) { msg->msg_data = msg_data; uint16_t instance_id = onvm_sc_service_to_nf_map(dest, NULL); - ret = rte_ring_enqueue(nfs[instance_id].msg_q, (void*)msg); - if(ret != 0){ + if (ret != 0) { RTE_LOG(ERR, APP, "Destination NF ring is full! Unable to enqueue msg to ring\n"); rte_mempool_put(nf_msg_pool, (void*)msg); return ret; diff --git a/onvm/onvm_nflib/onvm_sc_common.c b/onvm/onvm_nflib/onvm_sc_common.c index f43f34c61..45370cd1e 100644 --- a/onvm/onvm_nflib/onvm_sc_common.c +++ b/onvm/onvm_nflib/onvm_sc_common.c @@ -55,11 +55,10 @@ onvm_sc_service_to_nf_map(uint16_t service_id, struct rte_mbuf *pkt) { if (num_nfs_available == 0) return 0; - if (pkt == NULL){ + if (pkt == NULL) { uint16_t instance_id = services[service_id][0]; return instance_id; } - uint16_t instance_index = pkt->hash.rss % num_nfs_available; uint16_t instance_id = services[service_id][instance_index]; From 8ac16b850477194d1394a6d154b620bca4bbcf65 Mon Sep 17 00:00:00 2001 From: NoahChinitzGWU Date: Thu, 19 Aug 2021 17:31:47 +0000 Subject: [PATCH 38/55] [Update] Print out socket ID information for manager and network functions --- onvm/onvm_mgr/main.c | 38 ++++++++++++++++++------------------ onvm/onvm_nflib/onvm_nflib.c | 6 ++++-- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/onvm/onvm_mgr/main.c b/onvm/onvm_mgr/main.c index 4c1bbd53d..913b35558 100644 --- a/onvm/onvm_mgr/main.c +++ b/onvm/onvm_mgr/main.c @@ -84,7 +84,7 @@ master_thread_main(void) { const uint64_t start_time = rte_get_tsc_cycles(); uint64_t total_rx_pkts; - RTE_LOG(INFO, APP, "Core %d: Running master thread\n", rte_lcore_id()); + RTE_LOG(INFO, APP, "Socket %d, Core %d: Running master thread\n", rte_socket_id(), rte_lcore_id()); if (stats_destination == ONVM_STATS_WEB) { RTE_LOG(INFO, APP, "ONVM stats can be viewed through the web console\n"); @@ -130,7 +130,7 @@ master_thread_main(void) { rte_pdump_uninit(); #endif - RTE_LOG(INFO, APP, "Core %d: Initiating shutdown sequence\n", rte_lcore_id()); + RTE_LOG(INFO, APP, "Socket %d, Core %d: Initiating shutdown sequence\n", rte_socket_id(), rte_lcore_id()); /* Stop all RX and TX threads */ worker_keep_running = 0; @@ -140,7 +140,7 @@ master_thread_main(void) { if (nfs[i].status != NF_RUNNING) continue; - RTE_LOG(INFO, APP, "Core %d: Notifying NF %" PRIu16 " to shut down\n", rte_lcore_id(), i); + RTE_LOG(INFO, APP, "Socket %d, Core %d: Notifying NF %" PRIu16 " to shut down\n", rte_socket_id(), rte_lcore_id(), i); onvm_nf_send_msg(i, MSG_STOP, NULL); /* If in shared core mode NFs might be sleeping */ @@ -154,13 +154,13 @@ master_thread_main(void) { /* Wait to process all exits */ for (shutdown_iter_count = 0; shutdown_iter_count < MAX_SHUTDOWN_ITERS && num_nfs > 0; shutdown_iter_count++) { onvm_nf_check_status(); - RTE_LOG(INFO, APP, "Core %d: Waiting for %" PRIu16 " NFs to exit\n", rte_lcore_id(), num_nfs); + RTE_LOG(INFO, APP, "Socket %d, Core %d: Waiting for %" PRIu16 " NFs to exit\n", rte_socket_id(), rte_lcore_id(), num_nfs); sleep(sleeptime); } if (num_nfs > 0) { - RTE_LOG(INFO, APP, "Core %d: Up to %" PRIu16 " NFs may still be running and must be killed manually\n", - rte_lcore_id(), num_nfs); + RTE_LOG(INFO, APP, "Socket %d, Core %d: Up to %" PRIu16 " NFs may still be running and must be killed manually\n", + rte_socket_id(), rte_lcore_id(), num_nfs); } /* Clean up the shared memory */ @@ -171,7 +171,7 @@ master_thread_main(void) { } } - RTE_LOG(INFO, APP, "Core %d: Master thread done\n", rte_lcore_id()); + RTE_LOG(INFO, APP, "Socket %d, Core %d: Master thread done\n", rte_socket_id(), rte_lcore_id()); } /* @@ -186,7 +186,7 @@ rx_thread_main(void *arg) { cur_lcore = rte_lcore_id(); onvm_stats_gen_event_info("Rx Start", ONVM_EVENT_WITH_CORE, &cur_lcore); - RTE_LOG(INFO, APP, "Core %d: Running RX thread for RX queue %d\n", cur_lcore, rx_mgr->id); + RTE_LOG(INFO, APP, "Socket %d, Core %d: Running RX thread for RX queue %d\n", rte_socket_id(), cur_lcore, rx_mgr->id); for (; worker_keep_running;) { /* Read ports */ @@ -206,7 +206,7 @@ rx_thread_main(void *arg) { } } - RTE_LOG(INFO, APP, "Core %d: RX thread done\n", rte_lcore_id()); + RTE_LOG(INFO, APP, "Socket %d, Core %d: RX thread done\n", rte_socket_id(), rte_lcore_id()); return 0; } @@ -220,10 +220,10 @@ tx_thread_main(void *arg) { onvm_stats_gen_event_info("Tx Start", ONVM_EVENT_WITH_CORE, &cur_lcore); if (tx_mgr->tx_thread_info->first_nf == tx_mgr->tx_thread_info->last_nf - 1) { - RTE_LOG(INFO, APP, "Core %d: Running TX thread for NF %d\n", cur_lcore, + RTE_LOG(INFO, APP, "Socket %d, Core %d: Running TX thread for NF %d\n", rte_socket_id(), cur_lcore, tx_mgr->tx_thread_info->first_nf); } else if (tx_mgr->tx_thread_info->first_nf < tx_mgr->tx_thread_info->last_nf) { - RTE_LOG(INFO, APP, "Core %d: Running TX thread for NFs %d to %d\n", cur_lcore, + RTE_LOG(INFO, APP, "Socket %d, Core %d: Running TX thread for NFs %d to %d\n", rte_socket_id(), cur_lcore, tx_mgr->tx_thread_info->first_nf, tx_mgr->tx_thread_info->last_nf - 1); } @@ -250,7 +250,7 @@ tx_thread_main(void *arg) { onvm_pkt_flush_all_nfs(tx_mgr, NULL); } - RTE_LOG(INFO, APP, "Core %d: TX thread done\n", rte_lcore_id()); + RTE_LOG(INFO, APP, "Socket %d, Core %d: TX thread done\n", rte_socket_id(), rte_lcore_id()); return 0; } @@ -276,10 +276,10 @@ wakeup_thread_main(void *arg) { struct wakeup_thread_context *wakeup_ctx = (struct wakeup_thread_context *)arg; if (wakeup_ctx->first_nf == wakeup_ctx->last_nf - 1) { - RTE_LOG(INFO, APP, "Core %d: Running Wakeup thread for NF %d\n", rte_lcore_id(), + RTE_LOG(INFO, APP, "Socket %d, Core %d: Running Wakeup thread for NF %d\n", rte_socket_id(), rte_lcore_id(), wakeup_ctx->first_nf); } else if (wakeup_ctx->first_nf < wakeup_ctx->last_nf) { - RTE_LOG(INFO, APP, "Core %d: Running Wakeup thread for NFs %d to %d\n", rte_lcore_id(), + RTE_LOG(INFO, APP, "Socket %d, Core %d: Running Wakeup thread for NFs %d to %d\n", rte_socket_id(), rte_lcore_id(), wakeup_ctx->first_nf, wakeup_ctx->last_nf - 1); } @@ -379,7 +379,7 @@ main(int argc, char *argv[]) { /* Offset cur_lcore to start assigning TX cores */ cur_lcore += (rx_lcores - 1); - RTE_LOG(INFO, APP, "%d cores available in total\n", rte_lcore_count()); + RTE_LOG(INFO, APP, "%d sockets and %d cores available in total\n", rte_socket_count(), rte_lcore_count()); RTE_LOG(INFO, APP, "%d cores available for handling manager RX queues\n", rx_lcores); RTE_LOG(INFO, APP, "%d cores available for handling TX queues\n", tx_lcores); if (ONVM_NF_SHARE_CORES) @@ -432,7 +432,7 @@ main(int argc, char *argv[]) { tx_mgr[i]->tx_thread_info->last_nf = RTE_MIN((i + 1) * nfs_per_tx + 1, (unsigned)MAX_NFS); cur_lcore = rte_get_next_lcore(cur_lcore, 1, 1); if (rte_eal_remote_launch(tx_thread_main, (void *)tx_mgr[i], cur_lcore) == -EBUSY) { - RTE_LOG(ERR, APP, "Core %d is already busy, can't use for nf %d TX\n", cur_lcore, + RTE_LOG(ERR, APP, "Socket %d, Core %d is already busy, can't use for nf %d TX\n", rte_socket_id(), cur_lcore, tx_mgr[i]->tx_thread_info->first_nf); onvm_main_free(tx_lcores,rx_lcores, tx_mgr, rx_mgr, wakeup_ctx); return -1; @@ -454,7 +454,7 @@ main(int argc, char *argv[]) { } cur_lcore = rte_get_next_lcore(cur_lcore, 1, 1); if (rte_eal_remote_launch(rx_thread_main, (void *)rx_mgr[i], cur_lcore) == -EBUSY) { - RTE_LOG(ERR, APP, "Core %d is already busy, can't use for RX queue id %d\n", cur_lcore, + RTE_LOG(ERR, APP, "Socket %d, Core %d is already busy, can't use for RX queue id %d\n", rte_socket_id(), cur_lcore, rx_mgr[i]->id); onvm_main_free(tx_lcores,rx_lcores, tx_mgr, rx_mgr, wakeup_ctx); return -1; @@ -472,8 +472,8 @@ main(int argc, char *argv[]) { wakeup_ctx[i]->last_nf = RTE_MIN((i + 1) * nfs_per_wakeup_thread + 1, (unsigned)MAX_NFS); cur_lcore = rte_get_next_lcore(cur_lcore, 1, 1); if (rte_eal_remote_launch(wakeup_thread_main, (void*)wakeup_ctx[i], cur_lcore) == -EBUSY) { - RTE_LOG(ERR, APP, "Core %d is already busy, can't use for nf %d wakeup thread\n", - cur_lcore, wakeup_ctx[i]->first_nf); + RTE_LOG(ERR, APP, "Socket %d, Core %d is already busy, can't use for nf %d wakeup thread\n", + rte_socket_id(), cur_lcore, wakeup_ctx[i]->first_nf); onvm_main_free(tx_lcores, rx_lcores, tx_mgr, rx_mgr, wakeup_ctx); return -1; } diff --git a/onvm/onvm_nflib/onvm_nflib.c b/onvm/onvm_nflib/onvm_nflib.c index 9bfaa0526..a4f73012f 100644 --- a/onvm/onvm_nflib/onvm_nflib.c +++ b/onvm/onvm_nflib/onvm_nflib.c @@ -533,7 +533,7 @@ onvm_nflib_start_nf(struct onvm_nf_local_ctx *nf_local_ctx, struct onvm_nf_init_ RTE_LOG(INFO, APP, "Using Instance ID %d\n", nf->instance_id); RTE_LOG(INFO, APP, "Using Service ID %d\n", nf->service_id); - RTE_LOG(INFO, APP, "Running on core %d\n", nf->thread_info.core); + RTE_LOG(INFO, APP, "Running on Socket %d, Core %d\n", rte_socket_id(), nf->thread_info.core); if (nf->flags.time_to_live) RTE_LOG(INFO, APP, "Time to live set to %u\n", nf->flags.time_to_live); @@ -1328,7 +1328,7 @@ onvm_nflib_stats_summary_output(uint16_t id) { const char clr[] = {27, '[', '2', 'J', '\0'}; const char topLeft[] = {27, '[', '1', ';', '1', 'H', '\0'}; const char *csv_suffix = "_stats.csv"; - const char *csv_stats_headers = "NF tag, NF instance ID, NF service ID, NF assigned core, RX total," + const char *csv_stats_headers = "NF tag, NF instance ID, NF service ID, NF assigned socket, NF assigned core, RX total," "RX total dropped, TX total, TX total dropped, NF sent out, NF sent to NF," "NF dropped, NF next, NF tx buffered, NF tx buffered, NF tx returned"; const uint64_t rx = nfs[id].stats.rx; @@ -1355,6 +1355,7 @@ onvm_nflib_stats_summary_output(uint16_t id) { printf("NF tag: %s\n", nf_tag); printf("NF instance ID: %d\n", instance_id); printf("NF service ID: %d\n", service_id); + printf("NF assigned socket: %d\n", rte_socket_id()); printf("NF assigned core: %d\n", core); printf("----------------------------------------------------\n"); printf("RX total: %ld\n", rx); @@ -1397,6 +1398,7 @@ onvm_nflib_stats_summary_output(uint16_t id) { fprintf(csv_fp, "\n%s", nf_tag); fprintf(csv_fp, ", %d", instance_id); fprintf(csv_fp, ", %d", service_id); + fprintf(csv_fp, ", %d", rte_socket_id()); fprintf(csv_fp, ", %d", core); fprintf(csv_fp, ", %ld", rx); fprintf(csv_fp, ", %ld", rx_drop); From be801389df6f47ab96d7893a15dd9c2dd24ec06b Mon Sep 17 00:00:00 2001 From: NoahChinitzGWU Date: Thu, 19 Aug 2021 17:35:21 +0000 Subject: [PATCH 39/55] Revert "[Update] Print out socket ID information for manager and network functions" This reverts commit 8ac16b850477194d1394a6d154b620bca4bbcf65. --- onvm/onvm_mgr/main.c | 38 ++++++++++++++++++------------------ onvm/onvm_nflib/onvm_nflib.c | 6 ++---- 2 files changed, 21 insertions(+), 23 deletions(-) diff --git a/onvm/onvm_mgr/main.c b/onvm/onvm_mgr/main.c index 913b35558..4c1bbd53d 100644 --- a/onvm/onvm_mgr/main.c +++ b/onvm/onvm_mgr/main.c @@ -84,7 +84,7 @@ master_thread_main(void) { const uint64_t start_time = rte_get_tsc_cycles(); uint64_t total_rx_pkts; - RTE_LOG(INFO, APP, "Socket %d, Core %d: Running master thread\n", rte_socket_id(), rte_lcore_id()); + RTE_LOG(INFO, APP, "Core %d: Running master thread\n", rte_lcore_id()); if (stats_destination == ONVM_STATS_WEB) { RTE_LOG(INFO, APP, "ONVM stats can be viewed through the web console\n"); @@ -130,7 +130,7 @@ master_thread_main(void) { rte_pdump_uninit(); #endif - RTE_LOG(INFO, APP, "Socket %d, Core %d: Initiating shutdown sequence\n", rte_socket_id(), rte_lcore_id()); + RTE_LOG(INFO, APP, "Core %d: Initiating shutdown sequence\n", rte_lcore_id()); /* Stop all RX and TX threads */ worker_keep_running = 0; @@ -140,7 +140,7 @@ master_thread_main(void) { if (nfs[i].status != NF_RUNNING) continue; - RTE_LOG(INFO, APP, "Socket %d, Core %d: Notifying NF %" PRIu16 " to shut down\n", rte_socket_id(), rte_lcore_id(), i); + RTE_LOG(INFO, APP, "Core %d: Notifying NF %" PRIu16 " to shut down\n", rte_lcore_id(), i); onvm_nf_send_msg(i, MSG_STOP, NULL); /* If in shared core mode NFs might be sleeping */ @@ -154,13 +154,13 @@ master_thread_main(void) { /* Wait to process all exits */ for (shutdown_iter_count = 0; shutdown_iter_count < MAX_SHUTDOWN_ITERS && num_nfs > 0; shutdown_iter_count++) { onvm_nf_check_status(); - RTE_LOG(INFO, APP, "Socket %d, Core %d: Waiting for %" PRIu16 " NFs to exit\n", rte_socket_id(), rte_lcore_id(), num_nfs); + RTE_LOG(INFO, APP, "Core %d: Waiting for %" PRIu16 " NFs to exit\n", rte_lcore_id(), num_nfs); sleep(sleeptime); } if (num_nfs > 0) { - RTE_LOG(INFO, APP, "Socket %d, Core %d: Up to %" PRIu16 " NFs may still be running and must be killed manually\n", - rte_socket_id(), rte_lcore_id(), num_nfs); + RTE_LOG(INFO, APP, "Core %d: Up to %" PRIu16 " NFs may still be running and must be killed manually\n", + rte_lcore_id(), num_nfs); } /* Clean up the shared memory */ @@ -171,7 +171,7 @@ master_thread_main(void) { } } - RTE_LOG(INFO, APP, "Socket %d, Core %d: Master thread done\n", rte_socket_id(), rte_lcore_id()); + RTE_LOG(INFO, APP, "Core %d: Master thread done\n", rte_lcore_id()); } /* @@ -186,7 +186,7 @@ rx_thread_main(void *arg) { cur_lcore = rte_lcore_id(); onvm_stats_gen_event_info("Rx Start", ONVM_EVENT_WITH_CORE, &cur_lcore); - RTE_LOG(INFO, APP, "Socket %d, Core %d: Running RX thread for RX queue %d\n", rte_socket_id(), cur_lcore, rx_mgr->id); + RTE_LOG(INFO, APP, "Core %d: Running RX thread for RX queue %d\n", cur_lcore, rx_mgr->id); for (; worker_keep_running;) { /* Read ports */ @@ -206,7 +206,7 @@ rx_thread_main(void *arg) { } } - RTE_LOG(INFO, APP, "Socket %d, Core %d: RX thread done\n", rte_socket_id(), rte_lcore_id()); + RTE_LOG(INFO, APP, "Core %d: RX thread done\n", rte_lcore_id()); return 0; } @@ -220,10 +220,10 @@ tx_thread_main(void *arg) { onvm_stats_gen_event_info("Tx Start", ONVM_EVENT_WITH_CORE, &cur_lcore); if (tx_mgr->tx_thread_info->first_nf == tx_mgr->tx_thread_info->last_nf - 1) { - RTE_LOG(INFO, APP, "Socket %d, Core %d: Running TX thread for NF %d\n", rte_socket_id(), cur_lcore, + RTE_LOG(INFO, APP, "Core %d: Running TX thread for NF %d\n", cur_lcore, tx_mgr->tx_thread_info->first_nf); } else if (tx_mgr->tx_thread_info->first_nf < tx_mgr->tx_thread_info->last_nf) { - RTE_LOG(INFO, APP, "Socket %d, Core %d: Running TX thread for NFs %d to %d\n", rte_socket_id(), cur_lcore, + RTE_LOG(INFO, APP, "Core %d: Running TX thread for NFs %d to %d\n", cur_lcore, tx_mgr->tx_thread_info->first_nf, tx_mgr->tx_thread_info->last_nf - 1); } @@ -250,7 +250,7 @@ tx_thread_main(void *arg) { onvm_pkt_flush_all_nfs(tx_mgr, NULL); } - RTE_LOG(INFO, APP, "Socket %d, Core %d: TX thread done\n", rte_socket_id(), rte_lcore_id()); + RTE_LOG(INFO, APP, "Core %d: TX thread done\n", rte_lcore_id()); return 0; } @@ -276,10 +276,10 @@ wakeup_thread_main(void *arg) { struct wakeup_thread_context *wakeup_ctx = (struct wakeup_thread_context *)arg; if (wakeup_ctx->first_nf == wakeup_ctx->last_nf - 1) { - RTE_LOG(INFO, APP, "Socket %d, Core %d: Running Wakeup thread for NF %d\n", rte_socket_id(), rte_lcore_id(), + RTE_LOG(INFO, APP, "Core %d: Running Wakeup thread for NF %d\n", rte_lcore_id(), wakeup_ctx->first_nf); } else if (wakeup_ctx->first_nf < wakeup_ctx->last_nf) { - RTE_LOG(INFO, APP, "Socket %d, Core %d: Running Wakeup thread for NFs %d to %d\n", rte_socket_id(), rte_lcore_id(), + RTE_LOG(INFO, APP, "Core %d: Running Wakeup thread for NFs %d to %d\n", rte_lcore_id(), wakeup_ctx->first_nf, wakeup_ctx->last_nf - 1); } @@ -379,7 +379,7 @@ main(int argc, char *argv[]) { /* Offset cur_lcore to start assigning TX cores */ cur_lcore += (rx_lcores - 1); - RTE_LOG(INFO, APP, "%d sockets and %d cores available in total\n", rte_socket_count(), rte_lcore_count()); + RTE_LOG(INFO, APP, "%d cores available in total\n", rte_lcore_count()); RTE_LOG(INFO, APP, "%d cores available for handling manager RX queues\n", rx_lcores); RTE_LOG(INFO, APP, "%d cores available for handling TX queues\n", tx_lcores); if (ONVM_NF_SHARE_CORES) @@ -432,7 +432,7 @@ main(int argc, char *argv[]) { tx_mgr[i]->tx_thread_info->last_nf = RTE_MIN((i + 1) * nfs_per_tx + 1, (unsigned)MAX_NFS); cur_lcore = rte_get_next_lcore(cur_lcore, 1, 1); if (rte_eal_remote_launch(tx_thread_main, (void *)tx_mgr[i], cur_lcore) == -EBUSY) { - RTE_LOG(ERR, APP, "Socket %d, Core %d is already busy, can't use for nf %d TX\n", rte_socket_id(), cur_lcore, + RTE_LOG(ERR, APP, "Core %d is already busy, can't use for nf %d TX\n", cur_lcore, tx_mgr[i]->tx_thread_info->first_nf); onvm_main_free(tx_lcores,rx_lcores, tx_mgr, rx_mgr, wakeup_ctx); return -1; @@ -454,7 +454,7 @@ main(int argc, char *argv[]) { } cur_lcore = rte_get_next_lcore(cur_lcore, 1, 1); if (rte_eal_remote_launch(rx_thread_main, (void *)rx_mgr[i], cur_lcore) == -EBUSY) { - RTE_LOG(ERR, APP, "Socket %d, Core %d is already busy, can't use for RX queue id %d\n", rte_socket_id(), cur_lcore, + RTE_LOG(ERR, APP, "Core %d is already busy, can't use for RX queue id %d\n", cur_lcore, rx_mgr[i]->id); onvm_main_free(tx_lcores,rx_lcores, tx_mgr, rx_mgr, wakeup_ctx); return -1; @@ -472,8 +472,8 @@ main(int argc, char *argv[]) { wakeup_ctx[i]->last_nf = RTE_MIN((i + 1) * nfs_per_wakeup_thread + 1, (unsigned)MAX_NFS); cur_lcore = rte_get_next_lcore(cur_lcore, 1, 1); if (rte_eal_remote_launch(wakeup_thread_main, (void*)wakeup_ctx[i], cur_lcore) == -EBUSY) { - RTE_LOG(ERR, APP, "Socket %d, Core %d is already busy, can't use for nf %d wakeup thread\n", - rte_socket_id(), cur_lcore, wakeup_ctx[i]->first_nf); + RTE_LOG(ERR, APP, "Core %d is already busy, can't use for nf %d wakeup thread\n", + cur_lcore, wakeup_ctx[i]->first_nf); onvm_main_free(tx_lcores, rx_lcores, tx_mgr, rx_mgr, wakeup_ctx); return -1; } diff --git a/onvm/onvm_nflib/onvm_nflib.c b/onvm/onvm_nflib/onvm_nflib.c index a4f73012f..9bfaa0526 100644 --- a/onvm/onvm_nflib/onvm_nflib.c +++ b/onvm/onvm_nflib/onvm_nflib.c @@ -533,7 +533,7 @@ onvm_nflib_start_nf(struct onvm_nf_local_ctx *nf_local_ctx, struct onvm_nf_init_ RTE_LOG(INFO, APP, "Using Instance ID %d\n", nf->instance_id); RTE_LOG(INFO, APP, "Using Service ID %d\n", nf->service_id); - RTE_LOG(INFO, APP, "Running on Socket %d, Core %d\n", rte_socket_id(), nf->thread_info.core); + RTE_LOG(INFO, APP, "Running on core %d\n", nf->thread_info.core); if (nf->flags.time_to_live) RTE_LOG(INFO, APP, "Time to live set to %u\n", nf->flags.time_to_live); @@ -1328,7 +1328,7 @@ onvm_nflib_stats_summary_output(uint16_t id) { const char clr[] = {27, '[', '2', 'J', '\0'}; const char topLeft[] = {27, '[', '1', ';', '1', 'H', '\0'}; const char *csv_suffix = "_stats.csv"; - const char *csv_stats_headers = "NF tag, NF instance ID, NF service ID, NF assigned socket, NF assigned core, RX total," + const char *csv_stats_headers = "NF tag, NF instance ID, NF service ID, NF assigned core, RX total," "RX total dropped, TX total, TX total dropped, NF sent out, NF sent to NF," "NF dropped, NF next, NF tx buffered, NF tx buffered, NF tx returned"; const uint64_t rx = nfs[id].stats.rx; @@ -1355,7 +1355,6 @@ onvm_nflib_stats_summary_output(uint16_t id) { printf("NF tag: %s\n", nf_tag); printf("NF instance ID: %d\n", instance_id); printf("NF service ID: %d\n", service_id); - printf("NF assigned socket: %d\n", rte_socket_id()); printf("NF assigned core: %d\n", core); printf("----------------------------------------------------\n"); printf("RX total: %ld\n", rx); @@ -1398,7 +1397,6 @@ onvm_nflib_stats_summary_output(uint16_t id) { fprintf(csv_fp, "\n%s", nf_tag); fprintf(csv_fp, ", %d", instance_id); fprintf(csv_fp, ", %d", service_id); - fprintf(csv_fp, ", %d", rte_socket_id()); fprintf(csv_fp, ", %d", core); fprintf(csv_fp, ", %ld", rx); fprintf(csv_fp, ", %ld", rx_drop); From f5213ff3228d3e3d5c90a30ad569b5b1f3ca4564 Mon Sep 17 00:00:00 2001 From: NoahChinitzGWU Date: Thu, 19 Aug 2021 17:41:42 +0000 Subject: [PATCH 40/55] [Update] Print out socket ID information for manager and network functions --- onvm/onvm_mgr/main.c | 40 +++++++++++++++++------------------- onvm/onvm_nflib/onvm_nflib.c | 11 ++++------ 2 files changed, 23 insertions(+), 28 deletions(-) diff --git a/onvm/onvm_mgr/main.c b/onvm/onvm_mgr/main.c index 4c1bbd53d..b159acf45 100644 --- a/onvm/onvm_mgr/main.c +++ b/onvm/onvm_mgr/main.c @@ -41,10 +41,8 @@ /****************************************************************************** main.c - File containing the main function of the manager and all its worker threads. - ******************************************************************************/ #include @@ -84,7 +82,7 @@ master_thread_main(void) { const uint64_t start_time = rte_get_tsc_cycles(); uint64_t total_rx_pkts; - RTE_LOG(INFO, APP, "Core %d: Running master thread\n", rte_lcore_id()); + RTE_LOG(INFO, APP, "Socket %d, Core %d: Running master thread\n", rte_socket_id(), rte_lcore_id()); if (stats_destination == ONVM_STATS_WEB) { RTE_LOG(INFO, APP, "ONVM stats can be viewed through the web console\n"); @@ -130,7 +128,7 @@ master_thread_main(void) { rte_pdump_uninit(); #endif - RTE_LOG(INFO, APP, "Core %d: Initiating shutdown sequence\n", rte_lcore_id()); + RTE_LOG(INFO, APP, "Socket %d, Core %d: Initiating shutdown sequence\n", rte_socket_id(), rte_lcore_id()); /* Stop all RX and TX threads */ worker_keep_running = 0; @@ -140,7 +138,7 @@ master_thread_main(void) { if (nfs[i].status != NF_RUNNING) continue; - RTE_LOG(INFO, APP, "Core %d: Notifying NF %" PRIu16 " to shut down\n", rte_lcore_id(), i); + RTE_LOG(INFO, APP, "Socket %d, Core %d: Notifying NF %" PRIu16 " to shut down\n", rte_socket_id(), rte_lcore_id(), i); onvm_nf_send_msg(i, MSG_STOP, NULL); /* If in shared core mode NFs might be sleeping */ @@ -154,13 +152,13 @@ master_thread_main(void) { /* Wait to process all exits */ for (shutdown_iter_count = 0; shutdown_iter_count < MAX_SHUTDOWN_ITERS && num_nfs > 0; shutdown_iter_count++) { onvm_nf_check_status(); - RTE_LOG(INFO, APP, "Core %d: Waiting for %" PRIu16 " NFs to exit\n", rte_lcore_id(), num_nfs); + RTE_LOG(INFO, APP, "Socket %d, Core %d: Waiting for %" PRIu16 " NFs to exit\n", rte_socket_id(), rte_lcore_id(), num_nfs); sleep(sleeptime); } if (num_nfs > 0) { - RTE_LOG(INFO, APP, "Core %d: Up to %" PRIu16 " NFs may still be running and must be killed manually\n", - rte_lcore_id(), num_nfs); + RTE_LOG(INFO, APP, "Socket %d, Core %d: Up to %" PRIu16 " NFs may still be running and must be killed manually\n", + rte_socket_id(), rte_lcore_id(), num_nfs); } /* Clean up the shared memory */ @@ -171,7 +169,7 @@ master_thread_main(void) { } } - RTE_LOG(INFO, APP, "Core %d: Master thread done\n", rte_lcore_id()); + RTE_LOG(INFO, APP, "Socket %d, Core %d: Master thread done\n", rte_socket_id(), rte_lcore_id()); } /* @@ -186,7 +184,7 @@ rx_thread_main(void *arg) { cur_lcore = rte_lcore_id(); onvm_stats_gen_event_info("Rx Start", ONVM_EVENT_WITH_CORE, &cur_lcore); - RTE_LOG(INFO, APP, "Core %d: Running RX thread for RX queue %d\n", cur_lcore, rx_mgr->id); + RTE_LOG(INFO, APP, "Socket %d, Core %d: Running RX thread for RX queue %d\n", rte_socket_id(), cur_lcore, rx_mgr->id); for (; worker_keep_running;) { /* Read ports */ @@ -206,7 +204,7 @@ rx_thread_main(void *arg) { } } - RTE_LOG(INFO, APP, "Core %d: RX thread done\n", rte_lcore_id()); + RTE_LOG(INFO, APP, "Socket %d, Core %d: RX thread done\n", rte_socket_id(), rte_lcore_id()); return 0; } @@ -220,10 +218,10 @@ tx_thread_main(void *arg) { onvm_stats_gen_event_info("Tx Start", ONVM_EVENT_WITH_CORE, &cur_lcore); if (tx_mgr->tx_thread_info->first_nf == tx_mgr->tx_thread_info->last_nf - 1) { - RTE_LOG(INFO, APP, "Core %d: Running TX thread for NF %d\n", cur_lcore, + RTE_LOG(INFO, APP, "Socket %d, Core %d: Running TX thread for NF %d\n", rte_socket_id(), cur_lcore, tx_mgr->tx_thread_info->first_nf); } else if (tx_mgr->tx_thread_info->first_nf < tx_mgr->tx_thread_info->last_nf) { - RTE_LOG(INFO, APP, "Core %d: Running TX thread for NFs %d to %d\n", cur_lcore, + RTE_LOG(INFO, APP, "Socket %d, Core %d: Running TX thread for NFs %d to %d\n", rte_socket_id(), cur_lcore, tx_mgr->tx_thread_info->first_nf, tx_mgr->tx_thread_info->last_nf - 1); } @@ -250,7 +248,7 @@ tx_thread_main(void *arg) { onvm_pkt_flush_all_nfs(tx_mgr, NULL); } - RTE_LOG(INFO, APP, "Core %d: TX thread done\n", rte_lcore_id()); + RTE_LOG(INFO, APP, "Socket %d, Core %d: TX thread done\n", rte_socket_id(), rte_lcore_id()); return 0; } @@ -276,10 +274,10 @@ wakeup_thread_main(void *arg) { struct wakeup_thread_context *wakeup_ctx = (struct wakeup_thread_context *)arg; if (wakeup_ctx->first_nf == wakeup_ctx->last_nf - 1) { - RTE_LOG(INFO, APP, "Core %d: Running Wakeup thread for NF %d\n", rte_lcore_id(), + RTE_LOG(INFO, APP, "Socket %d, Core %d: Running Wakeup thread for NF %d\n", rte_socket_id(), rte_lcore_id(), wakeup_ctx->first_nf); } else if (wakeup_ctx->first_nf < wakeup_ctx->last_nf) { - RTE_LOG(INFO, APP, "Core %d: Running Wakeup thread for NFs %d to %d\n", rte_lcore_id(), + RTE_LOG(INFO, APP, "Socket %d, Core %d: Running Wakeup thread for NFs %d to %d\n", rte_socket_id(), rte_lcore_id(), wakeup_ctx->first_nf, wakeup_ctx->last_nf - 1); } @@ -379,7 +377,7 @@ main(int argc, char *argv[]) { /* Offset cur_lcore to start assigning TX cores */ cur_lcore += (rx_lcores - 1); - RTE_LOG(INFO, APP, "%d cores available in total\n", rte_lcore_count()); + RTE_LOG(INFO, APP, "%d sockets and %d cores available in total\n", rte_socket_count(), rte_lcore_count()); RTE_LOG(INFO, APP, "%d cores available for handling manager RX queues\n", rx_lcores); RTE_LOG(INFO, APP, "%d cores available for handling TX queues\n", tx_lcores); if (ONVM_NF_SHARE_CORES) @@ -432,7 +430,7 @@ main(int argc, char *argv[]) { tx_mgr[i]->tx_thread_info->last_nf = RTE_MIN((i + 1) * nfs_per_tx + 1, (unsigned)MAX_NFS); cur_lcore = rte_get_next_lcore(cur_lcore, 1, 1); if (rte_eal_remote_launch(tx_thread_main, (void *)tx_mgr[i], cur_lcore) == -EBUSY) { - RTE_LOG(ERR, APP, "Core %d is already busy, can't use for nf %d TX\n", cur_lcore, + RTE_LOG(ERR, APP, "Socket %d, Core %d is already busy, can't use for nf %d TX\n", rte_socket_id(), cur_lcore, tx_mgr[i]->tx_thread_info->first_nf); onvm_main_free(tx_lcores,rx_lcores, tx_mgr, rx_mgr, wakeup_ctx); return -1; @@ -454,7 +452,7 @@ main(int argc, char *argv[]) { } cur_lcore = rte_get_next_lcore(cur_lcore, 1, 1); if (rte_eal_remote_launch(rx_thread_main, (void *)rx_mgr[i], cur_lcore) == -EBUSY) { - RTE_LOG(ERR, APP, "Core %d is already busy, can't use for RX queue id %d\n", cur_lcore, + RTE_LOG(ERR, APP, "Socket %d, Core %d is already busy, can't use for RX queue id %d\n", rte_socket_id(), cur_lcore, rx_mgr[i]->id); onvm_main_free(tx_lcores,rx_lcores, tx_mgr, rx_mgr, wakeup_ctx); return -1; @@ -472,8 +470,8 @@ main(int argc, char *argv[]) { wakeup_ctx[i]->last_nf = RTE_MIN((i + 1) * nfs_per_wakeup_thread + 1, (unsigned)MAX_NFS); cur_lcore = rte_get_next_lcore(cur_lcore, 1, 1); if (rte_eal_remote_launch(wakeup_thread_main, (void*)wakeup_ctx[i], cur_lcore) == -EBUSY) { - RTE_LOG(ERR, APP, "Core %d is already busy, can't use for nf %d wakeup thread\n", - cur_lcore, wakeup_ctx[i]->first_nf); + RTE_LOG(ERR, APP, "Socket %d, Core %d is already busy, can't use for nf %d wakeup thread\n", + rte_socket_id(), cur_lcore, wakeup_ctx[i]->first_nf); onvm_main_free(tx_lcores, rx_lcores, tx_mgr, rx_mgr, wakeup_ctx); return -1; } diff --git a/onvm/onvm_nflib/onvm_nflib.c b/onvm/onvm_nflib/onvm_nflib.c index 9bfaa0526..3544089e5 100644 --- a/onvm/onvm_nflib/onvm_nflib.c +++ b/onvm/onvm_nflib/onvm_nflib.c @@ -39,13 +39,8 @@ ********************************************************************/ /****************************************************************************** - onvm_nflib.c - - File containing all functions of the NF API - - ******************************************************************************/ /***************************Standard C library********************************/ @@ -533,7 +528,7 @@ onvm_nflib_start_nf(struct onvm_nf_local_ctx *nf_local_ctx, struct onvm_nf_init_ RTE_LOG(INFO, APP, "Using Instance ID %d\n", nf->instance_id); RTE_LOG(INFO, APP, "Using Service ID %d\n", nf->service_id); - RTE_LOG(INFO, APP, "Running on core %d\n", nf->thread_info.core); + RTE_LOG(INFO, APP, "Running on Socket %d, Core %d\n", rte_socket_id(), nf->thread_info.core); if (nf->flags.time_to_live) RTE_LOG(INFO, APP, "Time to live set to %u\n", nf->flags.time_to_live); @@ -1328,7 +1323,7 @@ onvm_nflib_stats_summary_output(uint16_t id) { const char clr[] = {27, '[', '2', 'J', '\0'}; const char topLeft[] = {27, '[', '1', ';', '1', 'H', '\0'}; const char *csv_suffix = "_stats.csv"; - const char *csv_stats_headers = "NF tag, NF instance ID, NF service ID, NF assigned core, RX total," + const char *csv_stats_headers = "NF tag, NF instance ID, NF service ID, NF assigned socket, NF assigned core, RX total," "RX total dropped, TX total, TX total dropped, NF sent out, NF sent to NF," "NF dropped, NF next, NF tx buffered, NF tx buffered, NF tx returned"; const uint64_t rx = nfs[id].stats.rx; @@ -1355,6 +1350,7 @@ onvm_nflib_stats_summary_output(uint16_t id) { printf("NF tag: %s\n", nf_tag); printf("NF instance ID: %d\n", instance_id); printf("NF service ID: %d\n", service_id); + printf("NF assigned socket: %d\n", rte_socket_id()); printf("NF assigned core: %d\n", core); printf("----------------------------------------------------\n"); printf("RX total: %ld\n", rx); @@ -1397,6 +1393,7 @@ onvm_nflib_stats_summary_output(uint16_t id) { fprintf(csv_fp, "\n%s", nf_tag); fprintf(csv_fp, ", %d", instance_id); fprintf(csv_fp, ", %d", service_id); + fprintf(csv_fp, ", %d", rte_socket_id()); fprintf(csv_fp, ", %d", core); fprintf(csv_fp, ", %ld", rx); fprintf(csv_fp, ", %ld", rx_drop); From b3381e872820b3568a92bfb81bdf3360dcbe250a Mon Sep 17 00:00:00 2001 From: NoahChinitzGWU Date: Thu, 19 Aug 2021 18:11:08 +0000 Subject: [PATCH 41/55] [Updated] Fixed tests --- examples/test_messaging/test_messaging.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/examples/test_messaging/test_messaging.c b/examples/test_messaging/test_messaging.c index f2e8d01d4..f3dcbaaeb 100644 --- a/examples/test_messaging/test_messaging.c +++ b/examples/test_messaging/test_messaging.c @@ -129,7 +129,7 @@ parse_app_args(int argc, char *argv[], const char *progname, struct onvm_nf *nf) msg_params->msg_pool = nf_msg_pool; msg_params->msg_q = nf->msg_q; msg_params->ring_count = 0; - msg_params->mempool_count = rte_mempool_avail_count(msg_params->msg_pool); + msg_params->mempool_count = 0; msg_params->test_msg_count = 0; nf->data = (void *)msg_params; @@ -172,6 +172,7 @@ nf_setup(struct onvm_nf_local_ctx *nf_local_ctx) { printf("---------------------------\n"); struct test_msg_data *msg_params; msg_params = (struct test_msg_data *)nf_local_ctx->nf->data; + msg_params->mempool_count = rte_mempool_avail_count(msg_params->msg_pool); int *msg_int; msg_int = (int*)rte_malloc(NULL, sizeof(int), 0); if (msg_int == NULL) { @@ -211,6 +212,7 @@ nf_msg_handler(void *msg_data, struct onvm_nf_local_ctx *nf_local_ctx) { printf("---------------------------\n"); msg_params->tests_passed++; msg_params->test_phase++; + msg_params->test_msg_count = 0; } else { printf("FAILED TEST 1: received %d instead of %d\n", *((int *)msg_data), MAGIC_NUMBER); printf("---------------------------\n"); @@ -220,7 +222,6 @@ nf_msg_handler(void *msg_data, struct onvm_nf_local_ctx *nf_local_ctx) { } } rte_free(msg_data); - msg_params->test_msg_count = 0; printf("TEST 2: Send/Receive Multiple Messages...\n"); printf("---------------------------\n"); for (int i = 0; i < 10; i++) { @@ -237,7 +238,6 @@ nf_msg_handler(void *msg_data, struct onvm_nf_local_ctx *nf_local_ctx) { } else { msg_params->test_msg_count++; } - rte_free(msg_data); if (10 == msg_params->test_msg_count) { if (rte_ring_count(msg_params->msg_q) != 0) { printf("FAILED TEST 2: Shouldn't be any messages left, but there are %d in the ring. This may cause future tests to fail.\n", rte_ring_count(msg_params->msg_q)); @@ -255,6 +255,7 @@ nf_msg_handler(void *msg_data, struct onvm_nf_local_ctx *nf_local_ctx) { msg_params->test_msg_count = 0; } } + rte_free(msg_data); if (0 == msg_params->test_msg_count) { printf("TEST 3: Message Ring Overflow...\n"); printf("---------------------------\n"); @@ -289,11 +290,12 @@ nf_msg_handler(void *msg_data, struct onvm_nf_local_ctx *nf_local_ctx) { printf("---------------------------\n"); msg_params->tests_passed++; msg_params->test_phase++; + msg_params->test_msg_count = 0; } } } if (4 == msg_params->test_phase) { - if ((int)rte_mempool_avail_count(msg_params->msg_pool) == msg_params->mempool_count) { + if ((int)rte_mempool_avail_count(msg_params->msg_pool) == msg_params->mempool_count - 1) { printf("Passed %d/3 Tests\n", msg_params->tests_passed); } else { printf("%d messages have not been deallocated back to the memory pool.\n", msg_params->mempool_count - rte_mempool_avail_count(msg_params->msg_pool)); From 46da274c5b6f4fb79540a2c3831bdfa4f6276be4 Mon Sep 17 00:00:00 2001 From: NoahChinitzGWU Date: Thu, 19 Aug 2021 20:11:14 +0000 Subject: [PATCH 42/55] [Update] added 4th test phase --- examples/test_messaging/test_messaging.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/examples/test_messaging/test_messaging.c b/examples/test_messaging/test_messaging.c index f3dcbaaeb..5d6fbc3ca 100644 --- a/examples/test_messaging/test_messaging.c +++ b/examples/test_messaging/test_messaging.c @@ -295,10 +295,20 @@ nf_msg_handler(void *msg_data, struct onvm_nf_local_ctx *nf_local_ctx) { } } if (4 == msg_params->test_phase) { + printf("TEST 4: Memory Deallocation...\n"); + printf("---------------------------\n"); + // Tests to make sure all messages have been deallocated back to the memory pool if ((int)rte_mempool_avail_count(msg_params->msg_pool) == msg_params->mempool_count - 1) { - printf("Passed %d/3 Tests\n", msg_params->tests_passed); + printf("PASSED TEST 4\n"); + printf("---------------------------\n"); + msg_params->tests_passed++; + printf("Passed %d/4 Tests\n", msg_params->tests_passed); } else { + printf("FAILED TEST 4\n"); + printf("---------------------------\n"); printf("%d messages have not been deallocated back to the memory pool.\n", msg_params->mempool_count - rte_mempool_avail_count(msg_params->msg_pool)); + msg_params->tests_failed++; + printf("Passed %d/4 Tests\n", msg_params->tests_passed); } } printf("---------------------------\n"); From 0ade1361769aa6d0ec48196f3fd810d3a92a54b4 Mon Sep 17 00:00:00 2001 From: Noah Chinitz <62520433+NoahChinitzGWU@users.noreply.github.com> Date: Thu, 19 Aug 2021 17:13:02 -0400 Subject: [PATCH 43/55] =?UTF-8?q?Revert=20"[Update]=20Print=20out=20socket?= =?UTF-8?q?=20ID=20information=20for=20manager=20and=20network=20func?= =?UTF-8?q?=E2=80=A6"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- onvm/onvm_mgr/main.c | 40 +++++++++++++++++++----------------- onvm/onvm_nflib/onvm_nflib.c | 11 ++++++---- 2 files changed, 28 insertions(+), 23 deletions(-) diff --git a/onvm/onvm_mgr/main.c b/onvm/onvm_mgr/main.c index b159acf45..4c1bbd53d 100644 --- a/onvm/onvm_mgr/main.c +++ b/onvm/onvm_mgr/main.c @@ -41,8 +41,10 @@ /****************************************************************************** main.c + File containing the main function of the manager and all its worker threads. + ******************************************************************************/ #include @@ -82,7 +84,7 @@ master_thread_main(void) { const uint64_t start_time = rte_get_tsc_cycles(); uint64_t total_rx_pkts; - RTE_LOG(INFO, APP, "Socket %d, Core %d: Running master thread\n", rte_socket_id(), rte_lcore_id()); + RTE_LOG(INFO, APP, "Core %d: Running master thread\n", rte_lcore_id()); if (stats_destination == ONVM_STATS_WEB) { RTE_LOG(INFO, APP, "ONVM stats can be viewed through the web console\n"); @@ -128,7 +130,7 @@ master_thread_main(void) { rte_pdump_uninit(); #endif - RTE_LOG(INFO, APP, "Socket %d, Core %d: Initiating shutdown sequence\n", rte_socket_id(), rte_lcore_id()); + RTE_LOG(INFO, APP, "Core %d: Initiating shutdown sequence\n", rte_lcore_id()); /* Stop all RX and TX threads */ worker_keep_running = 0; @@ -138,7 +140,7 @@ master_thread_main(void) { if (nfs[i].status != NF_RUNNING) continue; - RTE_LOG(INFO, APP, "Socket %d, Core %d: Notifying NF %" PRIu16 " to shut down\n", rte_socket_id(), rte_lcore_id(), i); + RTE_LOG(INFO, APP, "Core %d: Notifying NF %" PRIu16 " to shut down\n", rte_lcore_id(), i); onvm_nf_send_msg(i, MSG_STOP, NULL); /* If in shared core mode NFs might be sleeping */ @@ -152,13 +154,13 @@ master_thread_main(void) { /* Wait to process all exits */ for (shutdown_iter_count = 0; shutdown_iter_count < MAX_SHUTDOWN_ITERS && num_nfs > 0; shutdown_iter_count++) { onvm_nf_check_status(); - RTE_LOG(INFO, APP, "Socket %d, Core %d: Waiting for %" PRIu16 " NFs to exit\n", rte_socket_id(), rte_lcore_id(), num_nfs); + RTE_LOG(INFO, APP, "Core %d: Waiting for %" PRIu16 " NFs to exit\n", rte_lcore_id(), num_nfs); sleep(sleeptime); } if (num_nfs > 0) { - RTE_LOG(INFO, APP, "Socket %d, Core %d: Up to %" PRIu16 " NFs may still be running and must be killed manually\n", - rte_socket_id(), rte_lcore_id(), num_nfs); + RTE_LOG(INFO, APP, "Core %d: Up to %" PRIu16 " NFs may still be running and must be killed manually\n", + rte_lcore_id(), num_nfs); } /* Clean up the shared memory */ @@ -169,7 +171,7 @@ master_thread_main(void) { } } - RTE_LOG(INFO, APP, "Socket %d, Core %d: Master thread done\n", rte_socket_id(), rte_lcore_id()); + RTE_LOG(INFO, APP, "Core %d: Master thread done\n", rte_lcore_id()); } /* @@ -184,7 +186,7 @@ rx_thread_main(void *arg) { cur_lcore = rte_lcore_id(); onvm_stats_gen_event_info("Rx Start", ONVM_EVENT_WITH_CORE, &cur_lcore); - RTE_LOG(INFO, APP, "Socket %d, Core %d: Running RX thread for RX queue %d\n", rte_socket_id(), cur_lcore, rx_mgr->id); + RTE_LOG(INFO, APP, "Core %d: Running RX thread for RX queue %d\n", cur_lcore, rx_mgr->id); for (; worker_keep_running;) { /* Read ports */ @@ -204,7 +206,7 @@ rx_thread_main(void *arg) { } } - RTE_LOG(INFO, APP, "Socket %d, Core %d: RX thread done\n", rte_socket_id(), rte_lcore_id()); + RTE_LOG(INFO, APP, "Core %d: RX thread done\n", rte_lcore_id()); return 0; } @@ -218,10 +220,10 @@ tx_thread_main(void *arg) { onvm_stats_gen_event_info("Tx Start", ONVM_EVENT_WITH_CORE, &cur_lcore); if (tx_mgr->tx_thread_info->first_nf == tx_mgr->tx_thread_info->last_nf - 1) { - RTE_LOG(INFO, APP, "Socket %d, Core %d: Running TX thread for NF %d\n", rte_socket_id(), cur_lcore, + RTE_LOG(INFO, APP, "Core %d: Running TX thread for NF %d\n", cur_lcore, tx_mgr->tx_thread_info->first_nf); } else if (tx_mgr->tx_thread_info->first_nf < tx_mgr->tx_thread_info->last_nf) { - RTE_LOG(INFO, APP, "Socket %d, Core %d: Running TX thread for NFs %d to %d\n", rte_socket_id(), cur_lcore, + RTE_LOG(INFO, APP, "Core %d: Running TX thread for NFs %d to %d\n", cur_lcore, tx_mgr->tx_thread_info->first_nf, tx_mgr->tx_thread_info->last_nf - 1); } @@ -248,7 +250,7 @@ tx_thread_main(void *arg) { onvm_pkt_flush_all_nfs(tx_mgr, NULL); } - RTE_LOG(INFO, APP, "Socket %d, Core %d: TX thread done\n", rte_socket_id(), rte_lcore_id()); + RTE_LOG(INFO, APP, "Core %d: TX thread done\n", rte_lcore_id()); return 0; } @@ -274,10 +276,10 @@ wakeup_thread_main(void *arg) { struct wakeup_thread_context *wakeup_ctx = (struct wakeup_thread_context *)arg; if (wakeup_ctx->first_nf == wakeup_ctx->last_nf - 1) { - RTE_LOG(INFO, APP, "Socket %d, Core %d: Running Wakeup thread for NF %d\n", rte_socket_id(), rte_lcore_id(), + RTE_LOG(INFO, APP, "Core %d: Running Wakeup thread for NF %d\n", rte_lcore_id(), wakeup_ctx->first_nf); } else if (wakeup_ctx->first_nf < wakeup_ctx->last_nf) { - RTE_LOG(INFO, APP, "Socket %d, Core %d: Running Wakeup thread for NFs %d to %d\n", rte_socket_id(), rte_lcore_id(), + RTE_LOG(INFO, APP, "Core %d: Running Wakeup thread for NFs %d to %d\n", rte_lcore_id(), wakeup_ctx->first_nf, wakeup_ctx->last_nf - 1); } @@ -377,7 +379,7 @@ main(int argc, char *argv[]) { /* Offset cur_lcore to start assigning TX cores */ cur_lcore += (rx_lcores - 1); - RTE_LOG(INFO, APP, "%d sockets and %d cores available in total\n", rte_socket_count(), rte_lcore_count()); + RTE_LOG(INFO, APP, "%d cores available in total\n", rte_lcore_count()); RTE_LOG(INFO, APP, "%d cores available for handling manager RX queues\n", rx_lcores); RTE_LOG(INFO, APP, "%d cores available for handling TX queues\n", tx_lcores); if (ONVM_NF_SHARE_CORES) @@ -430,7 +432,7 @@ main(int argc, char *argv[]) { tx_mgr[i]->tx_thread_info->last_nf = RTE_MIN((i + 1) * nfs_per_tx + 1, (unsigned)MAX_NFS); cur_lcore = rte_get_next_lcore(cur_lcore, 1, 1); if (rte_eal_remote_launch(tx_thread_main, (void *)tx_mgr[i], cur_lcore) == -EBUSY) { - RTE_LOG(ERR, APP, "Socket %d, Core %d is already busy, can't use for nf %d TX\n", rte_socket_id(), cur_lcore, + RTE_LOG(ERR, APP, "Core %d is already busy, can't use for nf %d TX\n", cur_lcore, tx_mgr[i]->tx_thread_info->first_nf); onvm_main_free(tx_lcores,rx_lcores, tx_mgr, rx_mgr, wakeup_ctx); return -1; @@ -452,7 +454,7 @@ main(int argc, char *argv[]) { } cur_lcore = rte_get_next_lcore(cur_lcore, 1, 1); if (rte_eal_remote_launch(rx_thread_main, (void *)rx_mgr[i], cur_lcore) == -EBUSY) { - RTE_LOG(ERR, APP, "Socket %d, Core %d is already busy, can't use for RX queue id %d\n", rte_socket_id(), cur_lcore, + RTE_LOG(ERR, APP, "Core %d is already busy, can't use for RX queue id %d\n", cur_lcore, rx_mgr[i]->id); onvm_main_free(tx_lcores,rx_lcores, tx_mgr, rx_mgr, wakeup_ctx); return -1; @@ -470,8 +472,8 @@ main(int argc, char *argv[]) { wakeup_ctx[i]->last_nf = RTE_MIN((i + 1) * nfs_per_wakeup_thread + 1, (unsigned)MAX_NFS); cur_lcore = rte_get_next_lcore(cur_lcore, 1, 1); if (rte_eal_remote_launch(wakeup_thread_main, (void*)wakeup_ctx[i], cur_lcore) == -EBUSY) { - RTE_LOG(ERR, APP, "Socket %d, Core %d is already busy, can't use for nf %d wakeup thread\n", - rte_socket_id(), cur_lcore, wakeup_ctx[i]->first_nf); + RTE_LOG(ERR, APP, "Core %d is already busy, can't use for nf %d wakeup thread\n", + cur_lcore, wakeup_ctx[i]->first_nf); onvm_main_free(tx_lcores, rx_lcores, tx_mgr, rx_mgr, wakeup_ctx); return -1; } diff --git a/onvm/onvm_nflib/onvm_nflib.c b/onvm/onvm_nflib/onvm_nflib.c index 3544089e5..9bfaa0526 100644 --- a/onvm/onvm_nflib/onvm_nflib.c +++ b/onvm/onvm_nflib/onvm_nflib.c @@ -39,8 +39,13 @@ ********************************************************************/ /****************************************************************************** + onvm_nflib.c + + File containing all functions of the NF API + + ******************************************************************************/ /***************************Standard C library********************************/ @@ -528,7 +533,7 @@ onvm_nflib_start_nf(struct onvm_nf_local_ctx *nf_local_ctx, struct onvm_nf_init_ RTE_LOG(INFO, APP, "Using Instance ID %d\n", nf->instance_id); RTE_LOG(INFO, APP, "Using Service ID %d\n", nf->service_id); - RTE_LOG(INFO, APP, "Running on Socket %d, Core %d\n", rte_socket_id(), nf->thread_info.core); + RTE_LOG(INFO, APP, "Running on core %d\n", nf->thread_info.core); if (nf->flags.time_to_live) RTE_LOG(INFO, APP, "Time to live set to %u\n", nf->flags.time_to_live); @@ -1323,7 +1328,7 @@ onvm_nflib_stats_summary_output(uint16_t id) { const char clr[] = {27, '[', '2', 'J', '\0'}; const char topLeft[] = {27, '[', '1', ';', '1', 'H', '\0'}; const char *csv_suffix = "_stats.csv"; - const char *csv_stats_headers = "NF tag, NF instance ID, NF service ID, NF assigned socket, NF assigned core, RX total," + const char *csv_stats_headers = "NF tag, NF instance ID, NF service ID, NF assigned core, RX total," "RX total dropped, TX total, TX total dropped, NF sent out, NF sent to NF," "NF dropped, NF next, NF tx buffered, NF tx buffered, NF tx returned"; const uint64_t rx = nfs[id].stats.rx; @@ -1350,7 +1355,6 @@ onvm_nflib_stats_summary_output(uint16_t id) { printf("NF tag: %s\n", nf_tag); printf("NF instance ID: %d\n", instance_id); printf("NF service ID: %d\n", service_id); - printf("NF assigned socket: %d\n", rte_socket_id()); printf("NF assigned core: %d\n", core); printf("----------------------------------------------------\n"); printf("RX total: %ld\n", rx); @@ -1393,7 +1397,6 @@ onvm_nflib_stats_summary_output(uint16_t id) { fprintf(csv_fp, "\n%s", nf_tag); fprintf(csv_fp, ", %d", instance_id); fprintf(csv_fp, ", %d", service_id); - fprintf(csv_fp, ", %d", rte_socket_id()); fprintf(csv_fp, ", %d", core); fprintf(csv_fp, ", %ld", rx); fprintf(csv_fp, ", %ld", rx_drop); From b1df4b297878abbbe6ebb0f1a62e8425df69a2d3 Mon Sep 17 00:00:00 2001 From: NoahChinitzGWU Date: Fri, 20 Aug 2021 20:45:45 +0000 Subject: [PATCH 44/55] [Update] Changing Workflow --- examples/test_messaging/test_messaging.c | 315 ++++++++++++++--------- 1 file changed, 187 insertions(+), 128 deletions(-) diff --git a/examples/test_messaging/test_messaging.c b/examples/test_messaging/test_messaging.c index 5d6fbc3ca..a45291b04 100644 --- a/examples/test_messaging/test_messaging.c +++ b/examples/test_messaging/test_messaging.c @@ -63,6 +63,12 @@ #define NF_TAG "test_messaging" #define MAGIC_NUMBER 11 +#define TEST_FAILED -1 +#define TEST_INCOMPLETE 0 +#define TEST_PASSED 1 + +#define TEST_TIME_LIMIT 5 + static uint32_t print_delay = 1000000; struct test_msg_data{ @@ -75,6 +81,8 @@ struct test_msg_data{ uint16_t address; struct rte_mempool* msg_pool; struct rte_ring *msg_q; + int test_status[3]; + uint64_t start_time; }; void @@ -96,6 +104,14 @@ destroy_test_msg_data(struct test_msg_data **test_msg_data) { return 0; } +static void +clear_msg_queue(struct test_msg_data *test_state) { + void* msg; + while (rte_ring_count(test_state->msg_q) != 0) { + rte_ring_dequeue(test_state->msg_q, &msg); + } +} + /* * Print a usage message */ @@ -112,27 +128,8 @@ usage(const char *progname) { * Parse the application arguments. */ static int -parse_app_args(int argc, char *argv[], const char *progname, struct onvm_nf *nf) { +parse_app_args(int argc, char *argv[], const char *progname, __attribute__((unused)) struct onvm_nf *nf) { int c; - struct test_msg_data *msg_params; - static struct rte_mempool *nf_msg_pool; - - nf_msg_pool = rte_mempool_lookup(_NF_MSG_POOL_NAME); - if (nf_msg_pool == NULL) - rte_exit(EXIT_FAILURE, "No NF Message mempool - bye\n"); - - msg_params = (struct test_msg_data *)rte_malloc(NULL, sizeof(struct test_msg_data), 0); - msg_params->tests_passed = 0; - msg_params->tests_failed = 0; - msg_params->test_phase = 1; - msg_params->address = nf->service_id; - msg_params->msg_pool = nf_msg_pool; - msg_params->msg_q = nf->msg_q; - msg_params->ring_count = 0; - msg_params->mempool_count = 0; - msg_params->test_msg_count = 0; - nf->data = (void *)msg_params; - while ((c = getopt(argc, argv, "p:")) != -1) { switch (c) { case 'p': @@ -162,27 +159,132 @@ parse_app_args(int argc, char *argv[], const char *progname, struct onvm_nf *nf) void nf_setup(struct onvm_nf_local_ctx *nf_local_ctx) { struct rte_mempool *pktmbuf_pool; + struct test_msg_data *test_state; + static struct rte_mempool *nf_msg_pool; pktmbuf_pool = rte_mempool_lookup(PKTMBUF_POOL_NAME); if (pktmbuf_pool == NULL) { onvm_nflib_stop(nf_local_ctx); rte_exit(EXIT_FAILURE, "Cannot find mbuf pool!\n"); } + nf_msg_pool = rte_mempool_lookup(_NF_MSG_POOL_NAME); + if (nf_msg_pool == NULL) + rte_exit(EXIT_FAILURE, "No NF Message mempool - bye\n"); - printf("\nTEST MESSAGING STARTED\n"); - printf("---------------------------\n"); - struct test_msg_data *msg_params; - msg_params = (struct test_msg_data *)nf_local_ctx->nf->data; - msg_params->mempool_count = rte_mempool_avail_count(msg_params->msg_pool); - int *msg_int; - msg_int = (int*)rte_malloc(NULL, sizeof(int), 0); - if (msg_int == NULL) { - printf("Message was not able to be malloc'd\n"); + test_state = (struct test_msg_data *)rte_malloc(NULL, sizeof(struct test_msg_data), 0); + test_state->tests_passed = 0; + test_state->tests_failed = 0; + test_state->test_phase = 0; + test_state->address = nf_local_ctx->nf->service_id; + test_state->msg_pool = nf_msg_pool; + test_state->msg_q = nf_local_ctx->nf->msg_q; + test_state->ring_count = 0; + test_state->mempool_count = 0; + test_state->test_msg_count = 0; + test_state->start_time = rte_get_tsc_cycles(); + memset(test_state->test_status, TEST_INCOMPLETE, sizeof(int)*3); + nf_local_ctx->nf->data = (void *)test_state; + +} + +static int +test_handler(struct onvm_nf_local_ctx *nf_local_ctx) { + struct test_msg_data *test_state; + test_state = (struct test_msg_data *)nf_local_ctx->nf->data; + + if(( (rte_get_tsc_cycles() - test_state->start_time) / rte_get_timer_hz()) > TEST_TIME_LIMIT) { + // it took too long + // we failed this test + test_state->test_status[test_state->test_phase - 1] = TEST_FAILED; + // reset start time clock + test_state->start_time = rte_get_tsc_cycles(); + // clear ring and move on to next test + clear_msg_queue(test_state); + test_state->test_phase++; } - *msg_int = MAGIC_NUMBER; - int ret = onvm_nflib_send_msg_to_nf(msg_params->address, msg_int); - if (ret != 0) { - printf("Message was unable to be sent\n"); + + // If we haven't started any tests yet, start phase 1 + if (0 == test_state->test_phase) { + printf("\nTEST MESSAGING STARTED\n"); + printf("---------------------------\n"); + clear_msg_queue(test_state); + test_state->mempool_count = rte_mempool_avail_count(test_state->msg_pool); + int *msg_int; + msg_int = (int*)rte_malloc(NULL, sizeof(int), 0); + if (msg_int == NULL) { + printf("Message was not able to be malloc'd\n"); + } + *msg_int = MAGIC_NUMBER; + int ret = onvm_nflib_send_msg_to_nf(test_state->address, msg_int); + if (ret != 0) { + printf("Message was unable to be sent\n"); + } + test_state->test_phase++; } + else if (1 == test_state->test_phase) { + printf("TEST 1: Send/Receive One Message with correct data...\n"); + printf("---------------------------\n"); + if(TEST_PASSED == test_state->test_status[0]){ + printf("PASSED TEST 1\n"); + printf("---------------------------\n"); + } + else if (TEST_FAILED == test_state->test_status[0]) { + printf("FAILED TEST 1\n"); + printf("---------------------------\n"); + } + if(TEST_INCOMPLETE != test_state->test_status[0]) { + printf("TEST 2: Send/Receive Multiple Messages...\n"); + printf("---------------------------\n"); + clear_msg_queue(test_state); + for (int i = 0; i < 10; i++) { + int* msg_int = (int*)rte_malloc(NULL, sizeof(int), 0); + *msg_int = i; + onvm_nflib_send_msg_to_nf(test_state->address, msg_int); + } + test_state->test_phase++; + } + } + else if (2 == test_state->test_phase){ + if (TEST_PASSED == test_state->test_status[1]){ + printf("PASSED TEST 2\n"); + printf("---------------------------\n"); + + } + else if (TEST_FAILED == test_state->test_status[1]){ + printf("FAILED TEST 2\n"); + printf("---------------------------\n"); + } + if(TEST_INCOMPLETE != test_state->test_status[1]) { + printf("TEST 3: Message Ring Overflow...\n"); + printf("---------------------------\n"); + clear_msg_queue(test_state); + for (int i = 0; i < (int)(rte_ring_get_size(test_state->msg_q) + 2); i++) { + int* msg_int = (int*)rte_malloc(NULL, sizeof(int), 0); + *msg_int = i; + onvm_nflib_send_msg_to_nf(test_state->address, msg_int); + } + test_state->test_phase++; + } + } + else if (3 == test_state->test_phase){ + if(TEST_PASSED == test_state->test_status[2]){ + printf("PASSED TEST 3\n"); + printf("---------------------------\n"); + } + else if (TEST_FAILED == test_state->test_status[2]){ + printf("FAILED TEST 3\n"); + printf("---------------------------\n"); + } + if(TEST_INCOMPLETE != test_state->test_status[2]){ + clear_msg_queue(test_state); + test_state->test_phase++; + } + } + else if (4 == test_state->test_phase){ + printf("Passed %d/3 Tests\n", test_state->tests_passed); + sleep(8); + return 1; + } + return 0; } /* @@ -190,128 +292,84 @@ nf_setup(struct onvm_nf_local_ctx *nf_local_ctx) { */ void nf_msg_handler(void *msg_data, struct onvm_nf_local_ctx *nf_local_ctx) { - struct test_msg_data *msg_params; - msg_params = (struct test_msg_data *)nf_local_ctx->nf->data; + struct test_msg_data *test_state; + test_state = (struct test_msg_data *)nf_local_ctx->nf->data; // Tests if one message can be sent to itself - if (1 == msg_params->test_phase) { - printf("TEST 1: Send/Receive One Message...\n"); - printf("---------------------------\n"); - msg_params->test_msg_count++; - if (1 == msg_params->test_msg_count) { - if (rte_ring_count(msg_params->msg_q) != 0) { - printf("FAILED TEST 1: Shouldn't be any messages left, but there are %d in the ring. This may cause future tests to fail.\n", rte_ring_count(msg_params->msg_q)); + if (1 == test_state->test_phase) { + test_state->test_msg_count++; + if (1 == test_state->test_msg_count) { + if (rte_ring_count(test_state->msg_q) != 0) { + printf("FAILURE: Shouldn't be any messages left, but there are %d in the ring. This may cause future tests to fail.\n", rte_ring_count(test_state->msg_q)); printf("---------------------------\n"); - while (rte_ring_count(msg_params->msg_q) != 0) { - rte_ring_dequeue(msg_params->msg_q, msg_data); - } - msg_params->tests_failed++; - msg_params->test_phase++; + test_state->tests_failed++; + test_state->test_status[0] = TEST_FAILED; } else { + // *((int *)msg_data) = 45; // CAUSE A BUG if (*((int *)msg_data) == MAGIC_NUMBER) { - printf("PASSED TEST 1\n"); - printf("---------------------------\n"); - msg_params->tests_passed++; - msg_params->test_phase++; - msg_params->test_msg_count = 0; + test_state->tests_passed++; + test_state->test_status[0] = TEST_PASSED; + test_state->test_msg_count = 0; } else { - printf("FAILED TEST 1: received %d instead of %d\n", *((int *)msg_data), MAGIC_NUMBER); + printf("FAILURE: Received %d instead of %d\n", *((int *)msg_data), MAGIC_NUMBER); printf("---------------------------\n"); - msg_params->tests_failed++; - msg_params->test_phase++; + test_state->tests_failed++; + test_state->test_status[0] = TEST_FAILED; } } } - rte_free(msg_data); - printf("TEST 2: Send/Receive Multiple Messages...\n"); - printf("---------------------------\n"); - for (int i = 0; i < 10; i++) { - int* msg_int = (int*)rte_malloc(NULL, sizeof(int), 0); - *msg_int = i; - onvm_nflib_send_msg_to_nf(msg_params->address, msg_int); - } - } else if (2 == msg_params->test_phase) { // Tests if multiple messages can be sent to itself - if (*((int *)msg_data) != msg_params->test_msg_count) { - printf("FAILED TEST 2: received %d instead of %d\n", *((int *)msg_data), msg_params->test_msg_count); + } else if (2 == test_state->test_phase) { // Tests if multiple messages can be sent to itself + if (*((int *)msg_data) != test_state->test_msg_count) { + printf("FAILURE: Received %d instead of %d\n", *((int *)msg_data), test_state->test_msg_count); printf("---------------------------\n"); - msg_params->tests_failed++; - msg_params->test_phase++; + test_state->tests_failed++; + test_state->test_status[1] = TEST_FAILED; } else { - msg_params->test_msg_count++; + test_state->test_msg_count++; + // sleep(6); } - if (10 == msg_params->test_msg_count) { - if (rte_ring_count(msg_params->msg_q) != 0) { - printf("FAILED TEST 2: Shouldn't be any messages left, but there are %d in the ring. This may cause future tests to fail.\n", rte_ring_count(msg_params->msg_q)); + if (10 == test_state->test_msg_count) { + if (rte_ring_count(test_state->msg_q) != 0) { + printf("FAILURE: Shouldn't be any messages left, but there are %d in the ring. This may cause future tests to fail.\n", rte_ring_count(test_state->msg_q)); printf("---------------------------\n"); - while (rte_ring_count(msg_params->msg_q) != 0) { - rte_ring_dequeue(msg_params->msg_q, msg_data); - } - msg_params->tests_failed++; - msg_params->test_phase++; + test_state->tests_failed++; + test_state->test_status[1] = TEST_FAILED; } else { - printf("PASSED TEST 2\n"); - printf("---------------------------\n"); - msg_params->tests_passed++; - msg_params->test_phase++; - msg_params->test_msg_count = 0; - } - } - rte_free(msg_data); - if (0 == msg_params->test_msg_count) { - printf("TEST 3: Message Ring Overflow...\n"); - printf("---------------------------\n"); - for (int i = 0; i < (int)(rte_ring_get_size(msg_params->msg_q) + 2); i++) { - int* msg_int = (int*)rte_malloc(NULL, sizeof(int), 0); - *msg_int = i; - onvm_nflib_send_msg_to_nf(msg_params->address, msg_int); + test_state->tests_passed++; + test_state->test_status[1] = TEST_PASSED; + test_state->test_msg_count = 0; } } // TODO: can we detect that we fail phase 2 from missing messages? - } else if (3 == msg_params->test_phase) { // Tests to see if even with a ring overflow it can still handle the messages - if (*((int *)msg_data) != msg_params->test_msg_count) { - printf("FAILED TEST 3: received %d instead of %d\n", *((int *)msg_data), msg_params->test_msg_count); + } else if (3 == test_state->test_phase) { // Tests to see if even with a ring overflow it can still handle the messages + if (*((int *)msg_data) != test_state->test_msg_count) { + printf("FAILURE: Received %d instead of %d\n", *((int *)msg_data), test_state->test_msg_count); printf("---------------------------\n"); - msg_params->tests_failed++; - msg_params->test_phase++; + test_state->tests_failed++; + test_state->test_status[2] = TEST_FAILED; } else { - msg_params->test_msg_count++; + test_state->test_msg_count++; } - rte_free(msg_data); - if ((int)(rte_ring_get_size(msg_params->msg_q) - 1) == msg_params->test_msg_count) { - if (rte_ring_count(msg_params->msg_q) != 0) { - printf("FAILED TEST 3: Shouldn't be any messages left, but there are %d in the ring. This may cause future tests to fail.\n", rte_ring_count(msg_params->msg_q)); + if ((int)(rte_ring_get_size(test_state->msg_q) - 1) == test_state->test_msg_count) { + if (rte_ring_count(test_state->msg_q) != 0) { + printf("FAILURE: Shouldn't be any messages left, but there are %d in the ring. This may cause future tests to fail.\n", rte_ring_count(test_state->msg_q)); printf("---------------------------\n"); - while (rte_ring_count(msg_params->msg_q) != 0) { - rte_ring_dequeue(msg_params->msg_q, msg_data); - } - msg_params->tests_failed++; - msg_params->test_phase++; + test_state->tests_failed++; + test_state->test_status[2] = TEST_FAILED; + } else if ((int)rte_mempool_avail_count(test_state->msg_pool) == test_state->mempool_count - 1) { + // only pass if there wasn't a memory leak + test_state->tests_passed++; + test_state->test_status[2] = TEST_PASSED; + test_state->test_msg_count = 0; } else { - printf("PASSED TEST 3\n"); + printf("FAILURE: %d messages have not been deallocated back to the memory pool.\n", test_state->mempool_count - rte_mempool_avail_count(test_state->msg_pool)); printf("---------------------------\n"); - msg_params->tests_passed++; - msg_params->test_phase++; - msg_params->test_msg_count = 0; + test_state->tests_failed++; + test_state->test_status[2] = TEST_FAILED; } } } - if (4 == msg_params->test_phase) { - printf("TEST 4: Memory Deallocation...\n"); - printf("---------------------------\n"); - // Tests to make sure all messages have been deallocated back to the memory pool - if ((int)rte_mempool_avail_count(msg_params->msg_pool) == msg_params->mempool_count - 1) { - printf("PASSED TEST 4\n"); - printf("---------------------------\n"); - msg_params->tests_passed++; - printf("Passed %d/4 Tests\n", msg_params->tests_passed); - } else { - printf("FAILED TEST 4\n"); - printf("---------------------------\n"); - printf("%d messages have not been deallocated back to the memory pool.\n", msg_params->mempool_count - rte_mempool_avail_count(msg_params->msg_pool)); - msg_params->tests_failed++; - printf("Passed %d/4 Tests\n", msg_params->tests_passed); - } - } printf("---------------------------\n"); + rte_free(msg_data); } static int @@ -335,6 +393,7 @@ main(int argc, char *argv[]) { nf_function_table->pkt_handler = &packet_handler; nf_function_table->setup = &nf_setup; nf_function_table->msg_handler = &nf_msg_handler; + nf_function_table->user_actions = &test_handler; if ((arg_offset = onvm_nflib_init(argc, argv, NF_TAG, nf_local_ctx, nf_function_table)) < 0) { onvm_nflib_stop(nf_local_ctx); From 8b310473d685a3765a9c0409dbcf2472f44625c7 Mon Sep 17 00:00:00 2001 From: NoahChinitzGWU Date: Mon, 23 Aug 2021 19:44:05 +0000 Subject: [PATCH 45/55] [Update] Fixed Workflow to be cleaner and more organized --- examples/test_messaging/test_messaging.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/examples/test_messaging/test_messaging.c b/examples/test_messaging/test_messaging.c index a45291b04..3f0931081 100644 --- a/examples/test_messaging/test_messaging.c +++ b/examples/test_messaging/test_messaging.c @@ -104,6 +104,9 @@ destroy_test_msg_data(struct test_msg_data **test_msg_data) { return 0; } +/* + * Clears the message queues after each test + */ static void clear_msg_queue(struct test_msg_data *test_state) { void* msg; @@ -154,7 +157,7 @@ parse_app_args(int argc, char *argv[], const char *progname, __attribute__((unus } /* - * Sets up the NF. Initiates Unit Test + * Sets up the NF and state data */ void nf_setup(struct onvm_nf_local_ctx *nf_local_ctx) { @@ -186,6 +189,9 @@ nf_setup(struct onvm_nf_local_ctx *nf_local_ctx) { } +/* + * Initiates each test phase + */ static int test_handler(struct onvm_nf_local_ctx *nf_local_ctx) { struct test_msg_data *test_state; @@ -281,14 +287,13 @@ test_handler(struct onvm_nf_local_ctx *nf_local_ctx) { } else if (4 == test_state->test_phase){ printf("Passed %d/3 Tests\n", test_state->tests_passed); - sleep(8); return 1; } return 0; } /* - * Runs logic for tests + * Checks for test correctness */ void nf_msg_handler(void *msg_data, struct onvm_nf_local_ctx *nf_local_ctx) { @@ -304,7 +309,6 @@ nf_msg_handler(void *msg_data, struct onvm_nf_local_ctx *nf_local_ctx) { test_state->tests_failed++; test_state->test_status[0] = TEST_FAILED; } else { - // *((int *)msg_data) = 45; // CAUSE A BUG if (*((int *)msg_data) == MAGIC_NUMBER) { test_state->tests_passed++; test_state->test_status[0] = TEST_PASSED; @@ -325,7 +329,6 @@ nf_msg_handler(void *msg_data, struct onvm_nf_local_ctx *nf_local_ctx) { test_state->test_status[1] = TEST_FAILED; } else { test_state->test_msg_count++; - // sleep(6); } if (10 == test_state->test_msg_count) { if (rte_ring_count(test_state->msg_q) != 0) { @@ -339,7 +342,6 @@ nf_msg_handler(void *msg_data, struct onvm_nf_local_ctx *nf_local_ctx) { test_state->test_msg_count = 0; } } - // TODO: can we detect that we fail phase 2 from missing messages? } else if (3 == test_state->test_phase) { // Tests to see if even with a ring overflow it can still handle the messages if (*((int *)msg_data) != test_state->test_msg_count) { printf("FAILURE: Received %d instead of %d\n", *((int *)msg_data), test_state->test_msg_count); @@ -372,6 +374,9 @@ nf_msg_handler(void *msg_data, struct onvm_nf_local_ctx *nf_local_ctx) { rte_free(msg_data); } +/* + * Not concerned with packets, so they are dropped. + */ static int packet_handler(__attribute__((unused)) struct rte_mbuf *pkt, struct onvm_pkt_meta *meta, __attribute__((unused)) struct onvm_nf_local_ctx *nf_local_ctx) { @@ -379,6 +384,9 @@ packet_handler(__attribute__((unused)) struct rte_mbuf *pkt, struct onvm_pkt_met return 0; } +/* + * Creates function table and local context. Runs NF. + */ int main(int argc, char *argv[]) { int arg_offset; From ad23d44d39f3ceab174cb2a69af76900abeec44a Mon Sep 17 00:00:00 2001 From: Noah Chinitz <62520433+NoahChinitzGWU@users.noreply.github.com> Date: Tue, 24 Aug 2021 12:12:20 -0400 Subject: [PATCH 46/55] Update onvm/onvm_nflib/onvm_nflib.c Co-authored-by: Tim Wood --- onvm/onvm_nflib/onvm_nflib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/onvm/onvm_nflib/onvm_nflib.c b/onvm/onvm_nflib/onvm_nflib.c index 9bfaa0526..50f44320e 100644 --- a/onvm/onvm_nflib/onvm_nflib.c +++ b/onvm/onvm_nflib/onvm_nflib.c @@ -730,7 +730,7 @@ onvm_nflib_send_msg_to_nf(uint16_t dest, void *msg_data) { uint16_t instance_id = onvm_sc_service_to_nf_map(dest, NULL); ret = rte_ring_enqueue(nfs[instance_id].msg_q, (void*)msg); if (ret != 0) { - RTE_LOG(ERR, APP, "Destination NF ring is full! Unable to enqueue msg to ring\n"); + RTE_LOG(WARNING, APP, "Destination NF ring is full! Unable to enqueue msg to ring\n"); rte_mempool_put(nf_msg_pool, (void*)msg); return ret; } From 34c0d5cd81452fff002c1560f1af85e8b45b6399 Mon Sep 17 00:00:00 2001 From: Noah Chinitz <62520433+NoahChinitzGWU@users.noreply.github.com> Date: Tue, 24 Aug 2021 12:17:39 -0400 Subject: [PATCH 47/55] Update examples/test_messaging/test_messaging.c Co-authored-by: Tim Wood --- examples/test_messaging/test_messaging.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/test_messaging/test_messaging.c b/examples/test_messaging/test_messaging.c index 3f0931081..b551478b4 100644 --- a/examples/test_messaging/test_messaging.c +++ b/examples/test_messaging/test_messaging.c @@ -94,7 +94,7 @@ nf_msg_handler(void *msg_data, struct onvm_nf_local_ctx *nf_local_ctx); /* * Frees memory allocated to the test_msg_data struct */ -static int +static void destroy_test_msg_data(struct test_msg_data **test_msg_data) { if (test_msg_data == NULL) { return 0; From 20bf3517f024d74b94635fe798f44a36f9fb5e31 Mon Sep 17 00:00:00 2001 From: Noah Chinitz <62520433+NoahChinitzGWU@users.noreply.github.com> Date: Tue, 24 Aug 2021 12:17:50 -0400 Subject: [PATCH 48/55] Update examples/test_messaging/test_messaging.c Co-authored-by: Tim Wood --- examples/test_messaging/test_messaging.c | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/test_messaging/test_messaging.c b/examples/test_messaging/test_messaging.c index b551478b4..f09d7dd7b 100644 --- a/examples/test_messaging/test_messaging.c +++ b/examples/test_messaging/test_messaging.c @@ -426,6 +426,5 @@ main(int argc, char *argv[]) { destroy_test_msg_data((struct test_msg_data**)&nf_local_ctx->nf->data); onvm_nflib_stop(nf_local_ctx); - printf("If we reach here, program is ending\n"); return 0; } From 75045aa7057f79963e3775cf1d189da696d66314 Mon Sep 17 00:00:00 2001 From: Noah Chinitz <62520433+NoahChinitzGWU@users.noreply.github.com> Date: Tue, 24 Aug 2021 12:19:29 -0400 Subject: [PATCH 49/55] Update examples/test_messaging/test_messaging.c Co-authored-by: Tim Wood --- examples/test_messaging/test_messaging.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/test_messaging/test_messaging.c b/examples/test_messaging/test_messaging.c index f09d7dd7b..13f37b501 100644 --- a/examples/test_messaging/test_messaging.c +++ b/examples/test_messaging/test_messaging.c @@ -97,7 +97,7 @@ nf_msg_handler(void *msg_data, struct onvm_nf_local_ctx *nf_local_ctx); static void destroy_test_msg_data(struct test_msg_data **test_msg_data) { if (test_msg_data == NULL) { - return 0; + return; } rte_free(*test_msg_data); (*test_msg_data) = NULL; From f4160b97bacec724c57cb7656835c896da75d21b Mon Sep 17 00:00:00 2001 From: Noah Chinitz <62520433+NoahChinitzGWU@users.noreply.github.com> Date: Tue, 24 Aug 2021 12:20:30 -0400 Subject: [PATCH 50/55] Update examples/test_messaging/test_messaging.c Co-authored-by: Tim Wood --- examples/test_messaging/test_messaging.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/test_messaging/test_messaging.c b/examples/test_messaging/test_messaging.c index 13f37b501..9c2ea1c7f 100644 --- a/examples/test_messaging/test_messaging.c +++ b/examples/test_messaging/test_messaging.c @@ -101,7 +101,7 @@ destroy_test_msg_data(struct test_msg_data **test_msg_data) { } rte_free(*test_msg_data); (*test_msg_data) = NULL; - return 0; + return; } /* From 7f4f0c84fd0285b936a414d45da277aaf304c0f6 Mon Sep 17 00:00:00 2001 From: Noah Chinitz <62520433+NoahChinitzGWU@users.noreply.github.com> Date: Tue, 24 Aug 2021 12:20:40 -0400 Subject: [PATCH 51/55] Update examples/test_messaging/test_messaging.c Co-authored-by: Tim Wood --- examples/test_messaging/test_messaging.c | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/test_messaging/test_messaging.c b/examples/test_messaging/test_messaging.c index 9c2ea1c7f..51255d57a 100644 --- a/examples/test_messaging/test_messaging.c +++ b/examples/test_messaging/test_messaging.c @@ -73,7 +73,6 @@ static uint32_t print_delay = 1000000; struct test_msg_data{ int tests_passed; - int tests_failed; int test_phase; int test_msg_count; int ring_count; From d5bbf683da5ddf966852ad0bb11ab20708c4d908 Mon Sep 17 00:00:00 2001 From: NoahChinitzGWU Date: Wed, 25 Aug 2021 17:57:09 +0000 Subject: [PATCH 52/55] [Update] Small fixes for merge --- examples/test_messaging/README.md | 6 +-- examples/test_messaging/test_messaging.c | 62 ++++++++---------------- 2 files changed, 21 insertions(+), 47 deletions(-) diff --git a/examples/test_messaging/README.md b/examples/test_messaging/README.md index a20f58196..910e983b2 100644 --- a/examples/test_messaging/README.md +++ b/examples/test_messaging/README.md @@ -8,13 +8,9 @@ Compilation and Execution cd examples make cd test_messaging -./go.sh SERVICE_ID [PRINT_DELAY] +./go.sh SERVICE_ID ``` -App Specific Arguments --- - - `-p `: number of packets between each print, e.g. `-p 1` prints every packet. - Config File Support -- This NF supports the NF generating arguments from a config file. For diff --git a/examples/test_messaging/test_messaging.c b/examples/test_messaging/test_messaging.c index 51255d57a..5ac982a01 100644 --- a/examples/test_messaging/test_messaging.c +++ b/examples/test_messaging/test_messaging.c @@ -69,8 +69,6 @@ #define TEST_TIME_LIMIT 5 -static uint32_t print_delay = 1000000; - struct test_msg_data{ int tests_passed; int test_phase; @@ -80,7 +78,7 @@ struct test_msg_data{ uint16_t address; struct rte_mempool* msg_pool; struct rte_ring *msg_q; - int test_status[3]; + int test_status[3]; uint64_t start_time; }; @@ -108,10 +106,12 @@ destroy_test_msg_data(struct test_msg_data **test_msg_data) { */ static void clear_msg_queue(struct test_msg_data *test_state) { - void* msg; + void* msg = NULL; while (rte_ring_count(test_state->msg_q) != 0) { rte_ring_dequeue(test_state->msg_q, &msg); + rte_mempool_put(test_state->msg_pool, (void *)msg); } + rte_free(msg); } /* @@ -120,10 +120,7 @@ clear_msg_queue(struct test_msg_data *test_state) { static void usage(const char *progname) { printf("Usage:\n"); - printf("%s [EAL args] -- [NF_LIB args] -- -p \n", progname); - printf("%s -F [EAL args] -- [NF_LIB args] -- [NF args]\n\n", progname); - printf("Flags:\n"); - printf(" - `-p `: number of packets between each print, e.g. `-p 1` prints every packets.\n"); + printf("%s [EAL args] -- [NF_LIB args]\n", progname); } /* @@ -134,10 +131,6 @@ parse_app_args(int argc, char *argv[], const char *progname, __attribute__((unus int c; while ((c = getopt(argc, argv, "p:")) != -1) { switch (c) { - case 'p': - print_delay = strtoul(optarg, NULL, 10); - RTE_LOG(INFO, APP, "print_delay = %d\n", print_delay); - break; case '?': usage(progname); if (optopt == 'p') @@ -174,7 +167,6 @@ nf_setup(struct onvm_nf_local_ctx *nf_local_ctx) { test_state = (struct test_msg_data *)rte_malloc(NULL, sizeof(struct test_msg_data), 0); test_state->tests_passed = 0; - test_state->tests_failed = 0; test_state->test_phase = 0; test_state->address = nf_local_ctx->nf->service_id; test_state->msg_pool = nf_msg_pool; @@ -185,7 +177,6 @@ nf_setup(struct onvm_nf_local_ctx *nf_local_ctx) { test_state->start_time = rte_get_tsc_cycles(); memset(test_state->test_status, TEST_INCOMPLETE, sizeof(int)*3); nf_local_ctx->nf->data = (void *)test_state; - } /* @@ -196,7 +187,7 @@ test_handler(struct onvm_nf_local_ctx *nf_local_ctx) { struct test_msg_data *test_state; test_state = (struct test_msg_data *)nf_local_ctx->nf->data; - if(( (rte_get_tsc_cycles() - test_state->start_time) / rte_get_timer_hz()) > TEST_TIME_LIMIT) { + if (( (rte_get_tsc_cycles() - test_state->start_time) / rte_get_timer_hz()) > TEST_TIME_LIMIT) { // it took too long // we failed this test test_state->test_status[test_state->test_phase - 1] = TEST_FAILED; @@ -224,19 +215,17 @@ test_handler(struct onvm_nf_local_ctx *nf_local_ctx) { printf("Message was unable to be sent\n"); } test_state->test_phase++; - } - else if (1 == test_state->test_phase) { + } else if (1 == test_state->test_phase) { printf("TEST 1: Send/Receive One Message with correct data...\n"); printf("---------------------------\n"); - if(TEST_PASSED == test_state->test_status[0]){ + if (TEST_PASSED == test_state->test_status[0]) { printf("PASSED TEST 1\n"); printf("---------------------------\n"); - } - else if (TEST_FAILED == test_state->test_status[0]) { + } else if (TEST_FAILED == test_state->test_status[0]) { printf("FAILED TEST 1\n"); printf("---------------------------\n"); } - if(TEST_INCOMPLETE != test_state->test_status[0]) { + if (TEST_INCOMPLETE != test_state->test_status[0]) { printf("TEST 2: Send/Receive Multiple Messages...\n"); printf("---------------------------\n"); clear_msg_queue(test_state); @@ -247,18 +236,16 @@ test_handler(struct onvm_nf_local_ctx *nf_local_ctx) { } test_state->test_phase++; } - } - else if (2 == test_state->test_phase){ - if (TEST_PASSED == test_state->test_status[1]){ + } else if (2 == test_state->test_phase) { + if (TEST_PASSED == test_state->test_status[1]) { printf("PASSED TEST 2\n"); printf("---------------------------\n"); - } - else if (TEST_FAILED == test_state->test_status[1]){ + } else if (TEST_FAILED == test_state->test_status[1]) { printf("FAILED TEST 2\n"); printf("---------------------------\n"); } - if(TEST_INCOMPLETE != test_state->test_status[1]) { + if (TEST_INCOMPLETE != test_state->test_status[1]) { printf("TEST 3: Message Ring Overflow...\n"); printf("---------------------------\n"); clear_msg_queue(test_state); @@ -269,23 +256,21 @@ test_handler(struct onvm_nf_local_ctx *nf_local_ctx) { } test_state->test_phase++; } - } - else if (3 == test_state->test_phase){ - if(TEST_PASSED == test_state->test_status[2]){ + } else if (3 == test_state->test_phase) { + if (TEST_PASSED == test_state->test_status[2]) { printf("PASSED TEST 3\n"); printf("---------------------------\n"); - } - else if (TEST_FAILED == test_state->test_status[2]){ + } else if (TEST_FAILED == test_state->test_status[2]) { printf("FAILED TEST 3\n"); printf("---------------------------\n"); } - if(TEST_INCOMPLETE != test_state->test_status[2]){ + if (TEST_INCOMPLETE != test_state->test_status[2]) { clear_msg_queue(test_state); test_state->test_phase++; } - } - else if (4 == test_state->test_phase){ + } else if (4 == test_state->test_phase) { printf("Passed %d/3 Tests\n", test_state->tests_passed); + sleep(2); return 1; } return 0; @@ -305,7 +290,6 @@ nf_msg_handler(void *msg_data, struct onvm_nf_local_ctx *nf_local_ctx) { if (rte_ring_count(test_state->msg_q) != 0) { printf("FAILURE: Shouldn't be any messages left, but there are %d in the ring. This may cause future tests to fail.\n", rte_ring_count(test_state->msg_q)); printf("---------------------------\n"); - test_state->tests_failed++; test_state->test_status[0] = TEST_FAILED; } else { if (*((int *)msg_data) == MAGIC_NUMBER) { @@ -315,7 +299,6 @@ nf_msg_handler(void *msg_data, struct onvm_nf_local_ctx *nf_local_ctx) { } else { printf("FAILURE: Received %d instead of %d\n", *((int *)msg_data), MAGIC_NUMBER); printf("---------------------------\n"); - test_state->tests_failed++; test_state->test_status[0] = TEST_FAILED; } } @@ -324,7 +307,6 @@ nf_msg_handler(void *msg_data, struct onvm_nf_local_ctx *nf_local_ctx) { if (*((int *)msg_data) != test_state->test_msg_count) { printf("FAILURE: Received %d instead of %d\n", *((int *)msg_data), test_state->test_msg_count); printf("---------------------------\n"); - test_state->tests_failed++; test_state->test_status[1] = TEST_FAILED; } else { test_state->test_msg_count++; @@ -333,7 +315,6 @@ nf_msg_handler(void *msg_data, struct onvm_nf_local_ctx *nf_local_ctx) { if (rte_ring_count(test_state->msg_q) != 0) { printf("FAILURE: Shouldn't be any messages left, but there are %d in the ring. This may cause future tests to fail.\n", rte_ring_count(test_state->msg_q)); printf("---------------------------\n"); - test_state->tests_failed++; test_state->test_status[1] = TEST_FAILED; } else { test_state->tests_passed++; @@ -345,7 +326,6 @@ nf_msg_handler(void *msg_data, struct onvm_nf_local_ctx *nf_local_ctx) { if (*((int *)msg_data) != test_state->test_msg_count) { printf("FAILURE: Received %d instead of %d\n", *((int *)msg_data), test_state->test_msg_count); printf("---------------------------\n"); - test_state->tests_failed++; test_state->test_status[2] = TEST_FAILED; } else { test_state->test_msg_count++; @@ -354,7 +334,6 @@ nf_msg_handler(void *msg_data, struct onvm_nf_local_ctx *nf_local_ctx) { if (rte_ring_count(test_state->msg_q) != 0) { printf("FAILURE: Shouldn't be any messages left, but there are %d in the ring. This may cause future tests to fail.\n", rte_ring_count(test_state->msg_q)); printf("---------------------------\n"); - test_state->tests_failed++; test_state->test_status[2] = TEST_FAILED; } else if ((int)rte_mempool_avail_count(test_state->msg_pool) == test_state->mempool_count - 1) { // only pass if there wasn't a memory leak @@ -364,7 +343,6 @@ nf_msg_handler(void *msg_data, struct onvm_nf_local_ctx *nf_local_ctx) { } else { printf("FAILURE: %d messages have not been deallocated back to the memory pool.\n", test_state->mempool_count - rte_mempool_avail_count(test_state->msg_pool)); printf("---------------------------\n"); - test_state->tests_failed++; test_state->test_status[2] = TEST_FAILED; } } From 4aaeef6cf7b8f7530774de451d5775575e6de755 Mon Sep 17 00:00:00 2001 From: NoahChinitzGWU Date: Thu, 26 Aug 2021 15:16:20 +0000 Subject: [PATCH 53/55] deleted sleep call --- examples/test_messaging/test_messaging.c | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/test_messaging/test_messaging.c b/examples/test_messaging/test_messaging.c index 5ac982a01..6fbf4edba 100644 --- a/examples/test_messaging/test_messaging.c +++ b/examples/test_messaging/test_messaging.c @@ -270,7 +270,6 @@ test_handler(struct onvm_nf_local_ctx *nf_local_ctx) { } } else if (4 == test_state->test_phase) { printf("Passed %d/3 Tests\n", test_state->tests_passed); - sleep(2); return 1; } return 0; From 466aa9000a520d5058e4192d36f1ceced5277518 Mon Sep 17 00:00:00 2001 From: Noah Chinitz <62520433+NoahChinitzGWU@users.noreply.github.com> Date: Fri, 27 Aug 2021 12:28:49 -0400 Subject: [PATCH 54/55] Update examples/test_messaging/README.md Co-authored-by: Tim Wood --- examples/test_messaging/README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/examples/test_messaging/README.md b/examples/test_messaging/README.md index 910e983b2..cf02f444c 100644 --- a/examples/test_messaging/README.md +++ b/examples/test_messaging/README.md @@ -1,7 +1,13 @@ Test Messaging == This is an example NF that acts as a unit test for sending messsages from an NF to itself. +The NF runs the following unit tests: + 1. Send/Receive a single message and check for data correctness + 2. Send/Receive a batch of messages + 3. Send a batch of messages larger than the ring and verify there are no memory pool leaks + + Each test is allowed to run for a maximum of 5 seconds. Compilation and Execution -- ``` From 3f89851f36992c9d85295a4ebe59c6f47e2f8014 Mon Sep 17 00:00:00 2001 From: Tim Wood Date: Fri, 27 Aug 2021 12:31:45 -0400 Subject: [PATCH 55/55] Update examples/test_messaging/README.md --- examples/test_messaging/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/test_messaging/README.md b/examples/test_messaging/README.md index cf02f444c..4064dd115 100644 --- a/examples/test_messaging/README.md +++ b/examples/test_messaging/README.md @@ -8,6 +8,7 @@ The NF runs the following unit tests: 3. Send a batch of messages larger than the ring and verify there are no memory pool leaks Each test is allowed to run for a maximum of 5 seconds. + Compilation and Execution -- ```