diff --git a/.gitignore b/.gitignore index 3f64ac4b5..f4defeed1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ # build directories **/build/** **/x86_64-native-linuxapp-gcc/** +/build # dpdk built target dpdk-1.8.0/x86_64-native-linuxapp-gcc/* @@ -49,3 +50,16 @@ _preinstall # Debug files *.dSYM/ + +# Python virtual environment +env + +# Meson artifacts +/insstall +**/insstall/** + +# Submodules +/subprojects/dpdk-kmods/* + +# Output directories +/bin \ No newline at end of file diff --git a/.gitmodules b/.gitmodules index f6cce7efa..868901118 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,11 +1,13 @@ -[submodule "dpdk-1.8.0"] - path = dpdk - url = https://dpdk.org/git/dpdk - branch = master - commit = 0da7f445df445630c794897347ee360d6fe6348b [submodule "tools/Pktgen/pktgen-dpdk"] path = tools/Pktgen/pktgen-dpdk url = http://dpdk.org/git/apps/pktgen-dpdk branch = master commit = 807b4d2cfcc8ded46ece85353cefe5d655674de3 +[submodule "dpdk"] + path = subprojects/dpdk + url = https://github.com/DPDK/dpdk.git +[submodule "subprojects/dpdk-kmods"] + path = subprojects/dpdk-kmods + url = https://dpdk.org/git/dpdk-kmods + ignore = all diff --git a/Makefile b/Makefile deleted file mode 100644 index 2ba3d95ac..000000000 --- a/Makefile +++ /dev/null @@ -1,55 +0,0 @@ -# openNetVM -# https://github.com/sdnfv/openNetVM -# -# BSD LICENSE -# -# Copyright(c) -# 2015-2017 George Washington University -# 2015-2017 University of California Riverside -# 2016-2017 Hewlett Packard Enterprise Development LP -# 2010-2014 Intel Corporation. -# 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 ($(ONVM_HOME),) -$(error "Please define ONVM_HOME environment variable") -endif - -ifeq ($(RTE_SDK),) -$(error "Please define RTE_SDK environment variable") -endif - -all: - # cd $(ONVM_HOME)/dpdk && make - cd $(ONVM_HOME)/onvm && make - cd $(ONVM_HOME)/examples && make - -.PHONY: tags - -tags: - ctags -R . diff --git a/README.md b/README.md index 7b0524601..7306deb1a 100644 --- a/README.md +++ b/README.md @@ -1,81 +1,89 @@ -[openNetVM][onvm] -== +# [openNetVM][onvm] -_Please let us know if you use OpenNetVM in your research by [emailing us](mailto:timwood@gwu.edu) or completing this [short survey](https://goo.gl/forms/oxcnGO45Kxq1Zyyi2)._ +> _Please let us know if you use OpenNetVM in your research by [emailing us](mailto:timwood@gwu.edu) or completing this [short survey](https://goo.gl/forms/oxcnGO45Kxq1Zyyi2)._ -_Want to get started quickly?_ Try using our NSF CloudLab profile: https://www.cloudlab.us/p/GWCloudLab/onvm +> _Want to get started quickly?_ Try using our NSF CloudLab profile: +openNetVM is a high performance NFV platform based on [DPDK][dpdk] and [Docker][docker] containers. openNetVM provides a flexible framework for deploying network functions and interconnecting them to build service chains. + +openNetVM is an open source version of the NetVM platform described in our [NSDI 2014][nsdi14] and [HotMiddlebox 2016][hotmiddlebox16] papers, released under the [BSD][license] license. + +The [develop][dev] branch tracks experimental builds (active development) whereas the [master][mast] branch tracks verified stable releases. Please read our [releases][rels] document for more information about our releases and release cycle. + +You can find information about research projects building on [OpenNetVM][onvm] at the [UCR/GW SDNFV project site][sdnfv]. OpenNetVM is supported in part by NSF grants CNS-1422362 and CNS-1522546. -Notes --- +## Getting Started -We have updated our DPDK submodule to point to a new version, v20.05. If you have already cloned this repository, please update your DPDK submodule by running: +We've provided two scripts to install required dependencies, and configure your machine to run OpenNetVM. Required dependencies are installed by [`scripts/install.sh`](/scripts/install.sh), and configuration is done by [`scripts/setup_runtime.sh`](/scripts/setup_runtime.sh). +From the `openNetVM` folder, run the following two commands: + +```text +sudo ./scripts/install.sh ``` -git submodule sync -git submodule update --init + +```text +sudo ./scripts/setup_runtime.sh ``` -And then rebuild DPDK using the [install guide][install] or running these commands: +### Building +OpenNetVM uses the [Meson][meson] build system to compile all components, including dpdk. From the `openNetVM` parent folder run the following to setup build: + +```text +./scripts/build.sh ``` -cd dpdk -make config T=$RTE_TARGET -make T=$RTE_TARGET -j 8 -make install T=$RTE_TARGET -j 8 + +This will take care of the Meson build setup, compilation, and installation of onvm shared libriaries. + +Afterwards you may need to run the following comand to update the linker. + +```text +ldconfig ``` -The current OpenNetVM version is 20.10. Please see our [release](docs/Releases.md) document for more information. +### Running onvm_mgr -About --- -openNetVM is a high performance NFV platform based on [DPDK][dpdk] and [Docker][docker] containers. openNetVM provides a flexible framework for deploying network functions and interconnecting them to build service chains. +You can use our provided startup script to launch onvm_mgr. This scripts assumes the `openNetVM` folder is your working directory. -openNetVM is an open source version of the NetVM platform described in our [NSDI 2014][nsdi14] and [HotMiddlebox 2016][hotmiddlebox16] papers, released under the [BSD][license] license. +```text +./scripts/startup.sh +``` -The [develop][dev] branch tracks experimental builds (active development) whereas the [master][mast] branch tracks verified stable releases. Please read our [releases][rels] document for more information about our releases and release cycle. +## Usage Guide -You can find information about research projects building on [OpenNetVM][onvm] at the [UCR/GW SDNFV project site][sdnfv]. OpenNetVM is supported in part by NSF grants CNS-1422362 and CNS-1522546. +### Sample NFs -Installing --- -To install openNetVM, please see the [openNetVM Installation][install] guide for a thorough walkthrough. +openNetVM comes with several sample NFs. To get started with these, check out the [examples guide][examples]. -Using openNetVM --- -openNetVM comes with several sample network functions. To get started with some examples, please see the [Example Uses][examples] guide +### Creating NFs -Creating NFs --- -The [NF Development][nfs] guide will provide what you need to start creating your own NFs. +We have created an [NF development guide][nfs] to provide you with steps to create your first NF. + +### Containerizing NFs -Dockerize NFs --- NFs can be run inside docker containers, with the NF being automatically or hand started. For more informations, see our [Docker guide][docker-nf]. -TCP Stack --- +### mTCP apps as NFs + openNetVM can run mTCP applications as NFs. For more information, visit [mTCP][mtcp]. -Citing OpenNetVM --- +## Citing + If you use OpenNetVM in your work, please cite our paper: -``` + +```text @inproceedings{zhang_opennetvm:_2016, - title = {{OpenNetVM}: {A} {Platform} for {High} {Performance} {Network} {Service} {Chains}}, - booktitle = {Proceedings of the 2016 {ACM} {SIGCOMM} {Workshop} on {Hot} {Topics} in {Middleboxes} and {Network} {Function} {Virtualization}}, - publisher = {ACM}, - author = {Zhang, Wei and Liu, Guyue and Zhang, Wenhui and Shah, Neel and Lopreiato, Phillip and Todeschi, Gregoire and Ramakrishnan, K.K. and Wood, Timothy}, - month = aug, - year = {2016}, + title = {{OpenNetVM}: {A} {Platform} for {High} {Performance} {Network} {Service} {Chains}}, + booktitle = {Proceedings of the 2016 {ACM} {SIGCOMM} {Workshop} on {Hot} {Topics} in {Middleboxes} and {Network} {Function} {Virtualization}}, + publisher = {ACM}, + author = {Zhang, Wei and Liu, Guyue and Zhang, Wenhui and Shah, Neel and Lopreiato, Phillip and Todeschi, Gregoire and Ramakrishnan, K.K. and Wood, Timothy}, + month = aug, + year = {2016}, } ``` -_Please let us know if you use OpenNetVM in your research by [emailing us](mailto:timwood@gwu.edu) or completing this [short survey](https://goo.gl/forms/oxcnGO45Kxq1Zyyi2)._ - - - - +>_Please let us know if you use OpenNetVM in your research by [emailing us](mailto:timwood@gwu.edu) or completing this [short survey](https://goo.gl/forms/oxcnGO45Kxq1Zyyi2)._ [onvm]: http://sdnfv.github.io/onvm/ [sdnfv]: http://sdnfv.github.io/ @@ -84,11 +92,11 @@ _Please let us know if you use OpenNetVM in your research by [emailing us](mailt [docker]: https://www.docker.com/ [nsdi14]: http://faculty.cs.gwu.edu/timwood/papers/14-NSDI-netvm.pdf [hotmiddlebox16]: http://faculty.cs.gwu.edu/timwood/papers/16-HotMiddlebox-onvm.pdf -[install]: docs/Install.md -[examples]: docs/Examples.md -[nfs]: docs/NF_Dev.md -[docker-nf]: docs/Docker.md +[examples]: https://opennetvm.readthedocs.io/en/develop/examples/index.html +[nfs]: https://opennetvm.readthedocs.io/en/develop/nfdev/index.html +[docker-nf]: https://opennetvm.readthedocs.io/en/develop/docker/index.html [dev]: https://github.com/sdnfv/openNetVM/tree/develop [mast]: https://github.com/sdnfv/openNetVM/tree/master [rels]: docs/Releases.md [mtcp]: https://github.com/eunyoung14/mtcp +[meson]: https://mesonbuild.com/ diff --git a/dpdk b/dpdk deleted file mode 160000 index e2a234488..000000000 --- a/dpdk +++ /dev/null @@ -1 +0,0 @@ -Subproject commit e2a234488854fdeee267a2aa582aa082fce01d6e diff --git a/examples/Makefile b/examples/Makefile deleted file mode 100644 index e064ccd51..000000000 --- a/examples/Makefile +++ /dev/null @@ -1,64 +0,0 @@ -# openNetVM -# https://github.com/sdnfv/openNetVM -# -# BSD LICENSE -# -# Copyright(c) -# 2015-2017 George Washington University -# 2015-2017 University of California Riverside -# 2016-2017 Hewlett Packard Enterprise Development LP -# 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 - -# 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 test_messaging l3fwd fair_queue skeleton - - -ifeq ($(NDPI_HOME),) -$(warning "Skipping ndpi_stats NF as NDPI_HOME is not set") -else -examples +=ndpi_stats -endif - -clean_examples=$(addprefix clean_,$(examples)) - -.PHONY: $(examples) $(clean_examples) - -all : $(examples) -clean: $(clean_examples) - -$(examples): - cd $@ && $(MAKE) - -$(clean_examples): - cd $(patsubst clean_%,%,$@) && $(MAKE) clean diff --git a/examples/aes_decrypt/Makefile b/examples/aes_decrypt/Makefile deleted file mode 100644 index 01670a76a..000000000 --- a/examples/aes_decrypt/Makefile +++ /dev/null @@ -1,69 +0,0 @@ -# openNetVM -# https://github.com/sdnfv/openNetVM -# -# BSD LICENSE -# -# Copyright(c) -# 2015-2017 George Washington University -# 2015-2017 University of California Riverside -# 2016-2017 Hewlett Packard Enterprise Development LP -# 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 - -RTE_TARGET ?= x86_64-native-linuxapp-gcc - -# Default target, can be overriden by command line or environment -include $(RTE_SDK)/mk/rte.vars.mk - -# binary name -APP = aes_decrypt - -# all source are stored in SRCS-y -SRCS-y := aesdecrypt.c aes.c - -# OpenNetVM path -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/aes_decrypt/meson.build b/examples/aes_decrypt/meson.build new file mode 100644 index 000000000..0033f3ed6 --- /dev/null +++ b/examples/aes_decrypt/meson.build @@ -0,0 +1,4 @@ +sources = files( + 'aes.c', + 'aesdecrypt.c' +) \ No newline at end of file diff --git a/examples/aes_encrypt/Makefile b/examples/aes_encrypt/Makefile deleted file mode 100644 index 0ad2e8310..000000000 --- a/examples/aes_encrypt/Makefile +++ /dev/null @@ -1,69 +0,0 @@ -# openNetVM -# https://github.com/sdnfv/openNetVM -# -# BSD LICENSE -# -# Copyright(c) -# 2015-2017 George Washington University -# 2015-2017 University of California Riverside -# 2016-2017 Hewlett Packard Enterprise Development LP -# 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 - -RTE_TARGET ?= x86_64-native-linuxapp-gcc - -# Default target, can be overriden by command line or environment -include $(RTE_SDK)/mk/rte.vars.mk - -# binary name -APP = aes_encrypt - -# all source are stored in SRCS-y -SRCS-y := aesencrypt.c aes.c - -# OpenNetVM path -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/aes_encrypt/meson.build b/examples/aes_encrypt/meson.build new file mode 100644 index 000000000..220536ac4 --- /dev/null +++ b/examples/aes_encrypt/meson.build @@ -0,0 +1,4 @@ +sources = files( + 'aes.c', + 'aesencrypt.c' +) \ No newline at end of file diff --git a/examples/arp_response/Makefile b/examples/arp_response/Makefile deleted file mode 100644 index 9ebdda51a..000000000 --- a/examples/arp_response/Makefile +++ /dev/null @@ -1,62 +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 - -RTE_TARGET ?= $(RTE_TARGET) - -# Default target, can be overriden by command line or environment -include $(RTE_SDK)/mk/rte.vars.mk - -# binary name -APP = arp_response - -# all source are stored in SRCS-y -SRCS-y := arp_response.c - -# OpenNetVM path -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 - -include $(RTE_SDK)/mk/rte.extapp.mk diff --git a/examples/arp_response/arp_response.c b/examples/arp_response/arp_response.c index 6b23a0009..c083df871 100644 --- a/examples/arp_response/arp_response.c +++ b/examples/arp_response/arp_response.c @@ -235,9 +235,9 @@ send_arp_reply(int port, struct rte_ether_addr *tha, uint32_t tip, struct onvm_n // SET ETHER HEADER INFO eth_hdr = onvm_pkt_ether_hdr(out_pkt); - rte_ether_addr_copy(&ports->mac[port], ð_hdr->s_addr); + rte_ether_addr_copy(&ports->mac[port], ð_hdr->src_addr); eth_hdr->ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_ARP); - rte_ether_addr_copy(tha, ð_hdr->d_addr); + rte_ether_addr_copy(tha, ð_hdr->dst_addr); // SET ARP HDR INFO out_arp_hdr = rte_pktmbuf_mtod_offset(out_pkt, struct rte_arp_hdr *, sizeof(struct rte_ether_hdr)); @@ -255,7 +255,7 @@ send_arp_reply(int port, struct rte_ether_addr *tha, uint32_t tip, struct onvm_n rte_ether_addr_copy(tha, &out_arp_hdr->arp_data.arp_tha); // SEND PACKET OUT/SET METAINFO - pmeta = onvm_get_pkt_meta(out_pkt); + pmeta = onvm_get_pkt_meta(out_pkt, nf->dynfield_offset); pmeta->destination = port; pmeta->action = ONVM_NF_ACTION_OUT; @@ -282,7 +282,7 @@ packet_handler(struct rte_mbuf *pkt, struct onvm_pkt_meta *meta, case RTE_ARP_OP_REQUEST: if (rte_be_to_cpu_32(in_arp_hdr->arp_data.arp_tip) == state_info->source_ips[ports->id[pkt->port]]) { - result = send_arp_reply(pkt->port, ð_hdr->s_addr, + result = send_arp_reply(pkt->port, ð_hdr->src_addr, in_arp_hdr->arp_data.arp_sip, nf_local_ctx->nf); if (state_info->print_flag) { printf("ARP Reply From Port %d (ID %d): %d\n", pkt->port, diff --git a/examples/arp_response/meson.build b/examples/arp_response/meson.build new file mode 100644 index 000000000..69c10224d --- /dev/null +++ b/examples/arp_response/meson.build @@ -0,0 +1,3 @@ +sources = files( + 'arp_response.c' +) \ No newline at end of file diff --git a/examples/basic_monitor/Makefile b/examples/basic_monitor/Makefile deleted file mode 100644 index aff1328c3..000000000 --- a/examples/basic_monitor/Makefile +++ /dev/null @@ -1,62 +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 - -RTE_TARGET ?= $(RTE_TARGET) - -# Default target, can be overriden by command line or environment -include $(RTE_SDK)/mk/rte.vars.mk - -# binary name -APP = basic_monitor - -# all source are stored in SRCS-y -SRCS-y := monitor.c - -# OpenNetVM path -ONVM= $(SRCDIR)/../../onvm - -CFLAGS += $(WERROR_FLAGS) -O3 -g - -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 - -include $(RTE_SDK)/mk/rte.extapp.mk diff --git a/examples/basic_monitor/meson.build b/examples/basic_monitor/meson.build new file mode 100644 index 000000000..0b72baff0 --- /dev/null +++ b/examples/basic_monitor/meson.build @@ -0,0 +1,3 @@ +sources = files( + 'monitor.c' +) \ No newline at end of file diff --git a/examples/bridge/Makefile b/examples/bridge/Makefile deleted file mode 100644 index 9ed3370af..000000000 --- a/examples/bridge/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 = bridge - -# all source are stored in SRCS-y -SRCS-y := bridge.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/bridge/meson.build b/examples/bridge/meson.build new file mode 100644 index 000000000..4057708fb --- /dev/null +++ b/examples/bridge/meson.build @@ -0,0 +1,3 @@ +sources = files( + 'bridge.c' +) \ No newline at end of file diff --git a/examples/fair_queue/Makefile b/examples/fair_queue/Makefile deleted file mode 100644 index da97b989e..000000000 --- a/examples/fair_queue/Makefile +++ /dev/null @@ -1,68 +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 - -RTE_TARGET ?= x86_64-native-linuxapp-gcc - -# Default target, can be overriden by command line or environment -include $(RTE_SDK)/mk/rte.vars.mk - -# binary name -APP = fair_queue - -# all source are stored in SRCS-y -SRCS-y := fair_queue.c - -# OpenNetVM path -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/fair_queue/fair_queue.c b/examples/fair_queue/fair_queue.c index 4803caab9..50323a060 100644 --- a/examples/fair_queue/fair_queue.c +++ b/examples/fair_queue/fair_queue.c @@ -268,7 +268,7 @@ tx_loop(struct onvm_nf_local_ctx *nf_local_ctx) { continue; } - meta = onvm_get_pkt_meta((struct rte_mbuf *)pkt); + meta = onvm_get_pkt_meta((struct rte_mbuf *)pkt, nf_local_ctx->nf->dynfield_offset); meta->action = ONVM_NF_ACTION_TONF; meta->destination = destination; pktsTX[tx_batch_size++] = pkt; @@ -327,7 +327,7 @@ rx_loop(struct onvm_nf_local_ctx *nf_local_ctx) { for (i = 0; i < nb_pkts; i++) { if (fairqueue_enqueue(fair_queue, pkts[i]) == -1) { - meta = onvm_get_pkt_meta((struct rte_mbuf *)pkts[i]); + meta = onvm_get_pkt_meta((struct rte_mbuf *)pkts[i], nf_local_ctx->nf->dynfield_offset); meta->action = ONVM_NF_ACTION_DROP; meta->destination = destination; pktsDrop[tx_batch_size++] = pkts[i]; diff --git a/examples/fair_queue/meson.build b/examples/fair_queue/meson.build new file mode 100644 index 000000000..59b5c51e1 --- /dev/null +++ b/examples/fair_queue/meson.build @@ -0,0 +1,3 @@ +sources = files( + 'fair_queue.c' +) \ No newline at end of file diff --git a/examples/firewall/Makefile b/examples/firewall/Makefile deleted file mode 100755 index 02a6e4e28..000000000 --- a/examples/firewall/Makefile +++ /dev/null @@ -1,62 +0,0 @@ -# openNetVM -# https://github.com/sdnfv/openNetVM -# -# BSD LICENSE -# -# Copyright(c) -# 2015-2016 George Washington University -# 2015-2016 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 - -RTE_TARGET ?= $(RTE_TARGET) - -# Default target, can be overriden by command line or environment -include $(RTE_SDK)/mk/rte.vars.mk - -# binary name -APP = firewall - -# all source are stored in SRCS-y -SRCS-y := firewall.c - -# OpenNetVM path -ONVM= $(SRCDIR)/../../onvm - -CFLAGS += -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 - -include $(RTE_SDK)/mk/rte.extapp.mk diff --git a/examples/firewall/meson.build b/examples/firewall/meson.build new file mode 100644 index 000000000..d596df23e --- /dev/null +++ b/examples/firewall/meson.build @@ -0,0 +1,3 @@ +sources = files( + 'firewall.c' +) \ No newline at end of file diff --git a/examples/flow_table/Makefile b/examples/flow_table/Makefile deleted file mode 100644 index 479f816c5..000000000 --- a/examples/flow_table/Makefile +++ /dev/null @@ -1,68 +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 - -RTE_TARGET ?= x86_64-native-linuxapp-gcc - -# Default target, can be overriden by command line or environment -include $(RTE_SDK)/mk/rte.vars.mk - -# binary name -APP = flow_table - -# all source are stored in SRCS-y -SRCS-y := flow_table.c sdn.c setupconn.c msgbuf.c - -# OpenNetVM path -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/flow_table/meson.build b/examples/flow_table/meson.build new file mode 100644 index 000000000..2d7bf8311 --- /dev/null +++ b/examples/flow_table/meson.build @@ -0,0 +1,6 @@ +sources = files( + 'flow_table.c', + 'msgbuf.c', + 'sdn.c', + 'setupconn.c' +) \ No newline at end of file diff --git a/examples/flow_tracker/Makefile b/examples/flow_tracker/Makefile deleted file mode 100644 index 0a6adc616..000000000 --- a/examples/flow_tracker/Makefile +++ /dev/null @@ -1,60 +0,0 @@ -# openNetVM -# https://github.com/sdnfv/openNetVM -# -# BSD LICENSE -# -# Copyright(c) -# 2015-2016 George Washington University -# 2015-2016 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 - -RTE_TARGET ?= $(RTE_TARGET) - -# Default target, can be overridden by the command line or environment -include $(RTE_SDK)/mk/rte.vars.mk -# Binary name -APP = flow_tracker - -# all sources are stored in SRCS-y -SRCS-y := flow_tracker.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 - -include $(RTE_SDK)/mk/rte.extapp.mk diff --git a/examples/flow_tracker/meson.build b/examples/flow_tracker/meson.build new file mode 100644 index 000000000..3a52e57ed --- /dev/null +++ b/examples/flow_tracker/meson.build @@ -0,0 +1,3 @@ +sources = files( + 'flow_tracker.c' +) \ No newline at end of file diff --git a/examples/l2fwd/Makefile b/examples/l2fwd/Makefile deleted file mode 100755 index d79041bd3..000000000 --- a/examples/l2fwd/Makefile +++ /dev/null @@ -1,62 +0,0 @@ -# openNetVM -# https://github.com/sdnfv/openNetVM -# -# BSD LICENSE -# -# Copyright(c) -# 2015-2020 George Washington University -# 2015-2020 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 - -RTE_TARGET ?= $(RTE_TARGET) - -# Default target, can be overriden by command line or environment -include $(RTE_SDK)/mk/rte.vars.mk - -# binary name -APP = l2fwd - -# all source are stored in SRCS-y -SRCS-y := l2fwd.c - -# OpenNetVM path -ONVM= $(SRCDIR)/../../onvm - -CFLAGS += -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 - -include $(RTE_SDK)/mk/rte.extapp.mk diff --git a/examples/l2fwd/l2fwd.c b/examples/l2fwd/l2fwd.c index 4cf3c8280..c648086bc 100755 --- a/examples/l2fwd/l2fwd.c +++ b/examples/l2fwd/l2fwd.c @@ -209,18 +209,18 @@ l2fwd_mac_updating(struct rte_mbuf *pkt, unsigned dest_portid, struct state_info eth = rte_pktmbuf_mtod(pkt, struct rte_ether_hdr *); /* 02:00:00:00:00:xx */ - tmp = ð->d_addr.addr_bytes[0]; + tmp = ð->dst_addr.addr_bytes[0]; *((uint64_t *)tmp) = 0x000000000002 + ((uint64_t)dest_portid << 40); - rte_ether_addr_copy(tmp, ð->s_addr); + rte_ether_addr_copy(tmp, ð->src_addr); if (stats->print_mac) { printf("Packet updated MAC address: %02X:%02X:%02X:%02X:%02X:%02X\n\n", - eth->s_addr.addr_bytes[0], - eth->s_addr.addr_bytes[1], - eth->s_addr.addr_bytes[2], - eth->s_addr.addr_bytes[3], - eth->s_addr.addr_bytes[4], - eth->s_addr.addr_bytes[5]); + eth->src_addr.addr_bytes[0], + eth->src_addr.addr_bytes[1], + eth->src_addr.addr_bytes[2], + eth->src_addr.addr_bytes[3], + eth->src_addr.addr_bytes[4], + eth->src_addr.addr_bytes[5]); } } diff --git a/examples/l2fwd/meson.build b/examples/l2fwd/meson.build new file mode 100644 index 000000000..4ebb166db --- /dev/null +++ b/examples/l2fwd/meson.build @@ -0,0 +1,3 @@ +sources = files( + 'l2fwd.c' +) \ No newline at end of file diff --git a/examples/l3fwd/Makefile b/examples/l3fwd/Makefile deleted file mode 100755 index d7a09a633..000000000 --- a/examples/l3fwd/Makefile +++ /dev/null @@ -1,62 +0,0 @@ -# openNetVM -# https://github.com/sdnfv/openNetVM -# -# BSD LICENSE -# -# Copyright(c) -# 2015-2020 George Washington University -# 2015-2020 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 - -RTE_TARGET ?= $(RTE_TARGET) - -# Default target, can be overriden by command line or environment -include $(RTE_SDK)/mk/rte.vars.mk - -# binary name -APP = l3fwd - -# all source are stored in SRCS-y -SRCS-y := l3fwd.c l3fwd_lpm.c l3fwd_em.c - -# OpenNetVM path -ONVM= $(SRCDIR)/../../onvm - -CFLAGS += -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 - -include $(RTE_SDK)/mk/rte.extapp.mk diff --git a/examples/l3fwd/l3fwd.c b/examples/l3fwd/l3fwd.c index 3cf6a92b3..fe72dba9f 100755 --- a/examples/l3fwd/l3fwd.c +++ b/examples/l3fwd/l3fwd.c @@ -196,10 +196,10 @@ packet_handler(struct rte_mbuf *pkt, struct onvm_pkt_meta *meta, ++(ipv4_hdr->hdr_checksum); #endif /* dst addr */ - *(uint64_t *)ð_hdr->d_addr = stats->dest_eth_addr[dst_port]; + *(uint64_t *)ð_hdr->dst_addr = stats->dest_eth_addr[dst_port]; /* src addr */ - rte_ether_addr_copy(&stats->ports_eth_addr[dst_port], ð_hdr->s_addr); + rte_ether_addr_copy(&stats->ports_eth_addr[dst_port], ð_hdr->src_addr); meta->destination = dst_port; stats->port_statistics[dst_port]++; diff --git a/examples/l3fwd/meson.build b/examples/l3fwd/meson.build new file mode 100644 index 000000000..1c8bedf00 --- /dev/null +++ b/examples/l3fwd/meson.build @@ -0,0 +1,5 @@ +sources = files( + 'l3fwd_em.c', + 'l3fwd_lpm.c', + 'l3fwd.c' +) \ No newline at end of file diff --git a/examples/load_balancer/Makefile b/examples/load_balancer/Makefile deleted file mode 100644 index 9757b5a53..000000000 --- a/examples/load_balancer/Makefile +++ /dev/null @@ -1,69 +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 - -RTE_TARGET ?= x86_64-native-linuxapp-gcc - -# Default target, can be overriden by command line or environment -include $(RTE_SDK)/mk/rte.vars.mk - -# binary name -APP = load_balancer - -# all source are stored in SRCS-y -SRCS-y := load_balancer.c - -# OpenNetVM path -ONVM= $(SRCDIR)/../../onvm - -#CFLAGS += $(USER_FLAGS) -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/load_balancer/load_balancer.c b/examples/load_balancer/load_balancer.c index f8611879f..401b32ede 100644 --- a/examples/load_balancer/load_balancer.c +++ b/examples/load_balancer/load_balancer.c @@ -599,26 +599,26 @@ packet_handler(struct rte_mbuf *pkt, struct onvm_pkt_meta *meta, if (flow_info->is_active == 0) { flow_info->is_active = 1; for (i = 0; i < RTE_ETHER_ADDR_LEN; i++) { - flow_info->s_addr_bytes[i] = ehdr->s_addr.addr_bytes[i]; + flow_info->s_addr_bytes[i] = ehdr->src_addr.addr_bytes[i]; } } if (pkt->port == lb->server_port) { - if (onvm_get_macaddr(lb->client_port, &ehdr->s_addr) == -1) { + if (onvm_get_macaddr(lb->client_port, &ehdr->src_addr) == -1) { rte_exit(EXIT_FAILURE, "Failed to obtain MAC address\n"); } for (i = 0; i < RTE_ETHER_ADDR_LEN; i++) { - ehdr->d_addr.addr_bytes[i] = flow_info->s_addr_bytes[i]; + ehdr->dst_addr.addr_bytes[i] = flow_info->s_addr_bytes[i]; } ip->src_addr = lb->ip_lb_client; meta->destination = lb->client_port; } else { - if (onvm_get_macaddr(lb->server_port, &ehdr->s_addr) == -1) { + if (onvm_get_macaddr(lb->server_port, &ehdr->src_addr) == -1) { rte_exit(EXIT_FAILURE, "Failed to obtain MAC address\n"); } for (i = 0; i < RTE_ETHER_ADDR_LEN; i++) { - ehdr->d_addr.addr_bytes[i] = lb->server[flow_info->dest].d_addr_bytes[i]; + ehdr->dst_addr.addr_bytes[i] = lb->server[flow_info->dest].d_addr_bytes[i]; } ip->dst_addr = rte_cpu_to_be_32(lb->server[flow_info->dest].d_ip); diff --git a/examples/load_balancer/meson.build b/examples/load_balancer/meson.build new file mode 100644 index 000000000..a114c76a9 --- /dev/null +++ b/examples/load_balancer/meson.build @@ -0,0 +1,3 @@ +sources = files( + 'load_balancer.c' +) \ No newline at end of file diff --git a/examples/load_generator/Makefile b/examples/load_generator/Makefile deleted file mode 100644 index 6f2bcf0e8..000000000 --- a/examples/load_generator/Makefile +++ /dev/null @@ -1,62 +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 - -RTE_TARGET ?= $(RTE_TARGET) - -# Default target, can be overriden by command line or environment -include $(RTE_SDK)/mk/rte.vars.mk - -# binary name -APP = load_generator - -# all source are stored in SRCS-y -SRCS-y := load_generator.c - -# OpenNetVM path -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 - -include $(RTE_SDK)/mk/rte.extapp.mk diff --git a/examples/load_generator/load_generator.c b/examples/load_generator/load_generator.c index a662a0463..39bc26ac5 100644 --- a/examples/load_generator/load_generator.c +++ b/examples/load_generator/load_generator.c @@ -274,7 +274,7 @@ callback_handler(__attribute__((unused)) struct onvm_nf_local_ctx *nf_local_ctx) pkt_ehdr = (struct rte_ether_hdr *)rte_pktmbuf_append(pkt, packet_size); rte_memcpy(pkt_ehdr, ehdr, sizeof(struct rte_ether_hdr)); - struct onvm_pkt_meta *pmeta = onvm_get_pkt_meta(pkt); + struct onvm_pkt_meta *pmeta = onvm_get_pkt_meta(pkt, nf_local_ctx->nf->dynfield_offset); pmeta->destination = destination; pmeta->flags |= ONVM_SET_BIT(0, LOAD_GEN_BIT); if (action_out) { @@ -327,12 +327,12 @@ nf_setup(struct onvm_nf_local_ctx *nf_local_ctx) { rte_exit(EXIT_FAILURE, "Failed to allocate common ehdr\n"); } - if (onvm_get_macaddr(0, &ehdr->s_addr) == -1) { + if (onvm_get_macaddr(0, &ehdr->src_addr) == -1) { RTE_LOG(INFO, APP, "Using fake MAC address\n"); - onvm_get_fake_macaddr(&ehdr->s_addr); + onvm_get_fake_macaddr(&ehdr->src_addr); } for (j = 0; j < RTE_ETHER_ADDR_LEN; ++j) { - ehdr->d_addr.addr_bytes[j] = d_addr_bytes[j]; + ehdr->dst_addr.addr_bytes[j] = d_addr_bytes[j]; } ehdr->ether_type = rte_cpu_to_be_16(LOCAL_EXPERIMENTAL_ETHER); } diff --git a/examples/load_generator/meson.build b/examples/load_generator/meson.build new file mode 100644 index 000000000..54802a796 --- /dev/null +++ b/examples/load_generator/meson.build @@ -0,0 +1,3 @@ +sources = files( + 'load_generator.c' +) \ No newline at end of file diff --git a/examples/meson.build b/examples/meson.build new file mode 100644 index 000000000..40e4e6328 --- /dev/null +++ b/examples/meson.build @@ -0,0 +1,45 @@ +# List of all the onvm example apps +onvm_examples = [ + 'aes_decrypt', + 'aes_encrypt', + 'arp_response', + 'basic_monitor', + 'bridge', + 'fair_queue', + 'firewall', + # 'flow_table', + 'flow_tracker', + 'l2fwd', + 'l3fwd', + 'load_balancer', + 'load_generator', + # 'ndpi_stats', + 'nf_router', + # 'NFD', + 'payload_scan', + 'scaling_example', + 'simple_forward', + 'simple_fwd_tb', + 'skeleton', + 'speed_tester', + 'test_flow_dir', + 'test_messaging' +] + +foreach example : onvm_examples + name = 'onvm_' + example + sources = [] + includes = [include_directories(example), onvm_includes] + + subdir(example) + + executable( + name, + sources, + include_directories: includes, + dependencies: [onvm_dpdk_dep, onvm_nflib_dep], + install: true, + install_tag: 'onvm', + install_dir: onvm_output_dir + '/nf/' + example + ) +endforeach diff --git a/examples/nf_router/Makefile b/examples/nf_router/Makefile deleted file mode 100644 index f7ae6b684..000000000 --- a/examples/nf_router/Makefile +++ /dev/null @@ -1,68 +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 - -RTE_TARGET ?= x86_64-native-linuxapp-gcc - -# Default target, can be overriden by command line or environment -include $(RTE_SDK)/mk/rte.vars.mk - -# binary name -APP = nf_router - -# all source are stored in SRCS-y -SRCS-y := nf_router.c - -# OpenNetVM path -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/nf_router/meson.build b/examples/nf_router/meson.build new file mode 100644 index 000000000..8b005c2e8 --- /dev/null +++ b/examples/nf_router/meson.build @@ -0,0 +1,3 @@ +sources = files( + 'nf_router.c' +) \ No newline at end of file diff --git a/examples/payload_scan/Makefile b/examples/payload_scan/Makefile deleted file mode 100644 index 76abccbee..000000000 --- a/examples/payload_scan/Makefile +++ /dev/null @@ -1,62 +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 - -RTE_TARGET ?= $(RTE_TARGET) - -# Default target, can be overriden by command line or environment -include $(RTE_SDK)/mk/rte.vars.mk - -# binary name -APP = payload_scan - -# all source are stored in SRCS-y -SRCS-y := payload_scan.c - -# OpenNetVM path -ONVM= $(SRCDIR)/../../onvm - -CFLAGS += $(WERROR_FLAGS) -O3 -g - -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 - -include $(RTE_SDK)/mk/rte.extapp.mk diff --git a/examples/payload_scan/meson.build b/examples/payload_scan/meson.build new file mode 100644 index 000000000..8be5be4c4 --- /dev/null +++ b/examples/payload_scan/meson.build @@ -0,0 +1,3 @@ +sources = files( + 'payload_scan.c' +) \ No newline at end of file diff --git a/examples/scaling_example/Makefile b/examples/scaling_example/Makefile deleted file mode 100644 index 58e4b1394..000000000 --- a/examples/scaling_example/Makefile +++ /dev/null @@ -1,68 +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 - -RTE_TARGET ?= x86_64-native-linuxapp-gcc - -# Default target, can be overriden by command line or environment -include $(RTE_SDK)/mk/rte.vars.mk - -# binary name -APP = scaling_example - -# all source are stored in SRCS-y -SRCS-y := scaling.c - -# OpenNetVM path -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/scaling_example/meson.build b/examples/scaling_example/meson.build new file mode 100644 index 000000000..8da0def45 --- /dev/null +++ b/examples/scaling_example/meson.build @@ -0,0 +1,3 @@ +sources = files( + 'scaling.c' +) \ No newline at end of file diff --git a/examples/scaling_example/scaling.c b/examples/scaling_example/scaling.c index a30c8769d..5887ba583 100644 --- a/examples/scaling_example/scaling.c +++ b/examples/scaling_example/scaling.c @@ -184,15 +184,15 @@ nf_setup(__attribute__((unused)) struct onvm_nf_local_ctx *nf_local_ctx) { ehdr = (struct rte_ether_hdr *)rte_pktmbuf_append(pkt, packet_size); /* Using manager mac addr for source*/ - if (onvm_get_macaddr(0, &ehdr->s_addr) == -1) { - onvm_get_fake_macaddr(&ehdr->s_addr); + if (onvm_get_macaddr(0, &ehdr->src_addr) == -1) { + onvm_get_fake_macaddr(&ehdr->src_addr); } for (j = 0; j < RTE_ETHER_ADDR_LEN; ++j) { - ehdr->d_addr.addr_bytes[j] = d_addr_bytes[j]; + ehdr->dst_addr.addr_bytes[j] = d_addr_bytes[j]; } ehdr->ether_type = LOCAL_EXPERIMENTAL_ETHER; - pmeta = onvm_get_pkt_meta(pkt); + pmeta = onvm_get_pkt_meta(pkt, nf_local_ctx->nf->dynfield_offset); pmeta->destination = destination; pmeta->action = ONVM_NF_ACTION_TONF; pkt->hash.rss = i; @@ -367,12 +367,12 @@ thread_main_loop(struct onvm_nf_local_ctx *nf_local_ctx) { } /* Process all the packets */ for (i = 0; i < nb_pkts; i++) { - meta = onvm_get_pkt_meta((struct rte_mbuf *)pkts[i]); + meta = onvm_get_pkt_meta((struct rte_mbuf *)pkts[i], nf->dynfield_offset); packet_handler_fwd((struct rte_mbuf *)pkts[i], meta, nf_local_ctx); pktsTX[tx_batch_size++] = pkts[i]; } /* Process all packet actions */ - onvm_pkt_process_tx_batch(nf->nf_tx_mgr, pktsTX, tx_batch_size, nf); + onvm_pkt_process_tx_batch(nf->nf_tx_mgr, pktsTX, nf->dynfield_offset, tx_batch_size, nf); if (tx_batch_size < PACKET_READ_SIZE) { onvm_pkt_flush_all_nfs(nf->nf_tx_mgr, nf); } diff --git a/examples/simple_forward/Makefile b/examples/simple_forward/Makefile deleted file mode 100644 index bdcc8e94c..000000000 --- a/examples/simple_forward/Makefile +++ /dev/null @@ -1,68 +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 - -RTE_TARGET ?= x86_64-native-linuxapp-gcc - -# Default target, can be overriden by command line or environment -include $(RTE_SDK)/mk/rte.vars.mk - -# binary name -APP = simple_forward - -# all source are stored in SRCS-y -SRCS-y := forward.c - -# OpenNetVM path -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/simple_forward/meson.build b/examples/simple_forward/meson.build new file mode 100644 index 000000000..e66c8302d --- /dev/null +++ b/examples/simple_forward/meson.build @@ -0,0 +1,3 @@ +sources = files( + 'forward.c' +) \ No newline at end of file diff --git a/examples/simple_fwd_tb/Makefile b/examples/simple_fwd_tb/Makefile deleted file mode 100644 index d89e1a6e9..000000000 --- a/examples/simple_fwd_tb/Makefile +++ /dev/null @@ -1,68 +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 - -RTE_TARGET ?= x86_64-native-linuxapp-gcc - -# Default target, can be overriden by command line or environment -include $(RTE_SDK)/mk/rte.vars.mk - -# binary name -APP = simple_fwd_tb - -# all source are stored in SRCS-y -SRCS-y := forward_tb.c - -# OpenNetVM path -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/simple_fwd_tb/forward_tb.c b/examples/simple_fwd_tb/forward_tb.c index ed353ca20..1abd0798b 100644 --- a/examples/simple_fwd_tb/forward_tb.c +++ b/examples/simple_fwd_tb/forward_tb.c @@ -310,12 +310,12 @@ thread_main_loop(struct onvm_nf_local_ctx *nf_local_ctx) { /* Process all the dequeued packets */ for (i = 0; i < nb_pkts; i++) { - meta = onvm_get_pkt_meta((struct rte_mbuf *)pkts[i]); + meta = onvm_get_pkt_meta((struct rte_mbuf *)pkts[i], nf->dynfield_offset); packet_handler_tb((struct rte_mbuf *)pkts[i], meta, nf_local_ctx); pktsTX[tx_batch_size++] = pkts[i]; } - onvm_pkt_process_tx_batch(nf->nf_tx_mgr, pktsTX, tx_batch_size, nf); + onvm_pkt_process_tx_batch(nf->nf_tx_mgr, pktsTX, nf->dynfield_offset, tx_batch_size, nf); if (tx_batch_size < PACKET_READ_SIZE) { onvm_pkt_flush_all_nfs(nf->nf_tx_mgr, nf); } diff --git a/examples/simple_fwd_tb/meson.build b/examples/simple_fwd_tb/meson.build new file mode 100644 index 000000000..504a7a01c --- /dev/null +++ b/examples/simple_fwd_tb/meson.build @@ -0,0 +1,3 @@ +sources = files( + 'forward_tb.c' +) \ No newline at end of file diff --git a/examples/skeleton/Makefile b/examples/skeleton/Makefile deleted file mode 100644 index 6505a1485..000000000 --- a/examples/skeleton/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 [EDIT & ADD NF TAG TO "examples" VARIABLE WITHIN MAKEFILE OF EXAMPLES DIRECTORY] -APP = skeleton - -# all source are stored in SRCS-y -SRCS-y := skeleton.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/skeleton/meson.build b/examples/skeleton/meson.build new file mode 100644 index 000000000..185d428b6 --- /dev/null +++ b/examples/skeleton/meson.build @@ -0,0 +1,3 @@ +sources = files( + 'skeleton.c' +) \ No newline at end of file diff --git a/examples/speed_tester/Makefile b/examples/speed_tester/Makefile deleted file mode 100644 index 49e81b4a5..000000000 --- a/examples/speed_tester/Makefile +++ /dev/null @@ -1,76 +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. - -#Set this to 1 if libpcap is installed to use pcap replay -ENABLE_PCAP=0 - -ifeq ($(RTE_SDK),) -$(error "Please define RTE_SDK environment variable") -endif - -RTE_TARGET ?= x86_64-native-linuxapp-gcc - -# Default target, can be overriden by command line or environment -include $(RTE_SDK)/mk/rte.vars.mk - -# binary name -APP = speed_tester - -# all source are stored in SRCS-y -SRCS-y := speed_tester.c - -# OpenNetVM path -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 - -ifeq ($(ENABLE_PCAP), 1) -LDFLAGS += -lpcap -CFLAGS +=-D LIBPCAP -endif - -# 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/speed_tester/meson.build b/examples/speed_tester/meson.build new file mode 100644 index 000000000..bd39a56c4 --- /dev/null +++ b/examples/speed_tester/meson.build @@ -0,0 +1,3 @@ +sources = files( + 'speed_tester.c' +) \ No newline at end of file diff --git a/examples/speed_tester/speed_tester.c b/examples/speed_tester/speed_tester.c index 361d3d23c..816cd8656 100644 --- a/examples/speed_tester/speed_tester.c +++ b/examples/speed_tester/speed_tester.c @@ -393,16 +393,16 @@ nf_setup(struct onvm_nf_local_ctx *nf_local_ctx) { /*using manager mac addr for source *using input string for dest addr */ - if (onvm_get_macaddr(0, &ehdr->s_addr) == -1) { + if (onvm_get_macaddr(0, &ehdr->src_addr) == -1) { RTE_LOG(INFO, APP, "Using fake MAC address\n"); - onvm_get_fake_macaddr(&ehdr->s_addr); + onvm_get_fake_macaddr(&ehdr->src_addr); } for (j = 0; j < RTE_ETHER_ADDR_LEN; ++j) { - ehdr->d_addr.addr_bytes[j] = d_addr_bytes[j]; + ehdr->dst_addr.addr_bytes[j] = d_addr_bytes[j]; } ehdr->ether_type = LOCAL_EXPERIMENTAL_ETHER; - pmeta = onvm_get_pkt_meta(pkt); + pmeta = onvm_get_pkt_meta(pkt, nf_local_ctx->nf->dynfield_offset); pmeta->destination = destination; pmeta->action = ONVM_NF_ACTION_TONF; pmeta->flags = ONVM_SET_BIT(0, SPEED_TESTER_BIT); diff --git a/examples/test_flow_dir/Makefile b/examples/test_flow_dir/Makefile deleted file mode 100644 index 1edd6386c..000000000 --- a/examples/test_flow_dir/Makefile +++ /dev/null @@ -1,68 +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 - -RTE_TARGET ?= x86_64-native-linuxapp-gcc - -# Default target, can be overriden by command line or environment -include $(RTE_SDK)/mk/rte.vars.mk - -# binary name -APP = test_flow_dir - -# all source are stored in SRCS-y -SRCS-y := test_flow_dir.c - -# OpenNetVM path -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_flow_dir/meson.build b/examples/test_flow_dir/meson.build new file mode 100644 index 000000000..aa22362a1 --- /dev/null +++ b/examples/test_flow_dir/meson.build @@ -0,0 +1,3 @@ +sources = files( + 'test_flow_dir.c' +) \ No newline at end of file diff --git a/examples/test_messaging/Makefile b/examples/test_messaging/Makefile deleted file mode 100644 index ffb501a59..000000000 --- a/examples/test_messaging/Makefile +++ /dev/null @@ -1,67 +0,0 @@ -# openNetVM -# https://github.com/sdnfv/openNetVM -# -# BSD LICENSE -# -# Copyright(c) -# 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 -# 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/meson.build b/examples/test_messaging/meson.build new file mode 100644 index 000000000..846b353fb --- /dev/null +++ b/examples/test_messaging/meson.build @@ -0,0 +1,3 @@ +sources = files( + 'test_messaging.c' +) \ No newline at end of file diff --git a/meson.build b/meson.build new file mode 100644 index 000000000..e7aa13706 --- /dev/null +++ b/meson.build @@ -0,0 +1,32 @@ +project('openNetVM', 'c') + +add_global_arguments('-msse4', language : 'c') + +cc = meson.get_compiler('c') +onvm_source = meson.current_source_dir() + +# Output directory that executables are installed into +onvm_output_dir = meson.current_source_dir() + '/bin' + +# ONVM configurations +onvm_mgr_app_name = 'onvm_mgr' + +# DPDK dependencies +onvm_dpdk_dep = dependency('libdpdk') + +# ONVM dependencies +onvm_nflib_dep = [] +onvm_math_dep = cc.find_library('m') +onvm_thread_dep = dependency('threads') +onvm_systemd_dep = cc.find_library('systemd') + +# Include directories to be used when building components and examples +onvm_includes = include_directories('onvm/', + 'onvm/onvm_nflib', + 'onvm/onvm_mgr') + +# Build the ONVM components (onvm_mgr, nflib, lib) +subdir('onvm') + +# Build the ONVM example apps +subdir('examples') \ No newline at end of file diff --git a/onvm/Makefile b/onvm/Makefile deleted file mode 100644 index eaaf3c316..000000000 --- a/onvm/Makefile +++ /dev/null @@ -1,52 +0,0 @@ -# openNetVM -# https://github.com/sdnfv/openNetVM -# -# BSD LICENSE -# -# Copyright(c) -# 2015-2017 George Washington University -# 2015-2017 University of California Riverside -# 2010-2014 Intel Corporation. -# 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 -RTE_TARGET ?= x86_64-native-linuxapp-gcc - -include $(RTE_SDK)/mk/rte.vars.mk - -DIRS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += lib -DIRS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += onvm_nflib -DIRS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += onvm_mgr - -include $(RTE_SDK)/mk/rte.extsubdir.mk diff --git a/onvm/lib/Makefile b/onvm/lib/Makefile deleted file mode 100644 index e9828ea12..000000000 --- a/onvm/lib/Makefile +++ /dev/null @@ -1,56 +0,0 @@ -# openNetVM -# https://github.com/sdnfv/openNetVM -# -# BSD LICENSE -# -# Copyright(c) -# 2015-2017 George Washington University -# 2015-2017 University of California Riverside -# 2010-2014 Intel Corporation. -# 2016-2017 Hewlett Packard Enterprise Development LP -# 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 -LIB = libonvmhelper.a - -# all source are stored in SRCS-y -SRCS-y := cJSON.c - -CFLAGS += $(WERROR_FLAGS) -O3 $(USER_FLAGS) - -include $(RTE_SDK)/mk/rte.extlib.mk diff --git a/onvm/lib/meson.build b/onvm/lib/meson.build new file mode 100644 index 000000000..f09d96b36 --- /dev/null +++ b/onvm/lib/meson.build @@ -0,0 +1,16 @@ +sources = files('cJSON.c') + +libonvmhelper_includes = include_directories('.') + +libonvmhelper = library( + 'libonvmhelper', + sources, + include_directories : libonvmhelper_includes, + install: true, + install_tag: 'onvm' +) + +libonvmhelper_dep = declare_dependency( + link_with : libonvmhelper, + include_directories: libonvmhelper_includes +) \ No newline at end of file diff --git a/onvm/meson.build b/onvm/meson.build new file mode 100644 index 000000000..7626742af --- /dev/null +++ b/onvm/meson.build @@ -0,0 +1,3 @@ +subdir('lib') +subdir('onvm_nflib') +subdir('onvm_mgr') \ No newline at end of file diff --git a/onvm/onvm_mgr/Makefile b/onvm/onvm_mgr/Makefile deleted file mode 100644 index 90cda1fa2..000000000 --- a/onvm/onvm_mgr/Makefile +++ /dev/null @@ -1,76 +0,0 @@ -# openNetVM -# https://github.com/sdnfv/openNetVM -# -# BSD LICENSE -# -# Copyright(c) -# 2015-2017 George Washington University -# 2015-2017 University of California Riverside -# 2010-2014 Intel Corporation. -# 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. - -# set this to 0 to disable flow table lookup for incoming packets -ENABLE_FLOW_LOOKUP=1 - -ifeq ($(RTE_SDK),) -$(error "Please define RTE_SDK environment variable") -endif - -# Default target, can be overriden by command line or environment -RTE_TARGET ?= x86_64-native-linuxapp-gcc - -include $(RTE_SDK)/mk/rte.vars.mk - -ifneq ($(CONFIG_RTE_EXEC_ENV),"linuxapp") -$(error This application can only operate in a linuxapp environment, \ -please change the definition of the RTE_TARGET environment variable) -endif - -# binary name -APP = onvm_mgr - -# all source are stored in SRCS-y -SRCS-y := main.c onvm_init.c onvm_args.c onvm_stats.c onvm_pkt.c onvm_nf.c - -INC := onvm_mgr.h onvm_init.h onvm_args.h onvm_stats.h onvm_nf.h onvm_pkt.h - -CFLAGS += $(WERROR_FLAGS) -O3 $(USER_FLAGS) -CFLAGS += -I$(SRCDIR)/../ -I$(SRCDIR)/../onvm_nflib/ -I$(SRCDIR)/../lib/ -LDFLAGS += $(SRCDIR)/../lib/$(RTE_TARGET)/libonvmhelper.a -LDFLAGS += $(SRCDIR)/../onvm_nflib/$(RTE_TARGET)/libonvm.a - -ifeq ($(ENABLE_FLOW_LOOKUP), 1) -CFLAGS +=-D FLOW_LOOKUP -endif - -# for newer gcc, e.g. 4.4, no-strict-aliasing may not be necessary -# and so the next line can be removed in those cases. -EXTRA_CFLAGS += -fno-strict-aliasing - -include $(RTE_SDK)/mk/rte.extapp.mk diff --git a/onvm/onvm_mgr/main.c b/onvm/onvm_mgr/main.c index 99dee45af..38913af48 100644 --- a/onvm/onvm_mgr/main.c +++ b/onvm/onvm_mgr/main.c @@ -239,7 +239,7 @@ tx_thread_main(void *arg) { /* Now process the Client packets read */ if (likely(tx_count > 0)) { - onvm_pkt_process_tx_batch(tx_mgr, pkts, tx_count, nf); + onvm_pkt_process_tx_batch(tx_mgr, pkts, onvm_config->dynfield_offset, tx_count, nf); } } diff --git a/onvm/onvm_mgr/meson.build b/onvm/onvm_mgr/meson.build new file mode 100644 index 000000000..dd15464c2 --- /dev/null +++ b/onvm/onvm_mgr/meson.build @@ -0,0 +1,19 @@ +sources = files( + 'main.c', + 'onvm_args.c', + 'onvm_init.c', + 'onvm_nf.c', + 'onvm_pkt.c', + 'onvm_stats.c' +) + +onvm_mgr_include = include_directories('.') + +executable(onvm_mgr_app_name, + sources, + include_directories: [onvm_mgr_include, onvm_includes], + dependencies: [onvm_dpdk_dep, onvm_thread_dep, libonvm_dep, libonvmhelper_dep, onvm_math_dep], + install: true, + install_tag: 'onvm', + install_dir: onvm_output_dir, +) \ No newline at end of file diff --git a/onvm/onvm_mgr/onvm_init.c b/onvm/onvm_mgr/onvm_init.c index 25884dc96..86d49eb2d 100644 --- a/onvm/onvm_mgr/onvm_init.c +++ b/onvm/onvm_mgr/onvm_init.c @@ -115,18 +115,17 @@ check_all_ports_link_status(uint8_t port_num, uint32_t port_mask); static const struct rte_eth_conf port_conf = { .rxmode = { - .mq_mode = ETH_MQ_RX_RSS, - .max_rx_pkt_len = RTE_ETHER_MAX_LEN, - .split_hdr_size = 0, - .offloads = DEV_RX_OFFLOAD_CHECKSUM, + .mq_mode = RTE_ETH_MQ_RX_RSS, + .mtu = RTE_ETHER_MAX_LEN, + .offloads = RTE_ETH_RX_OFFLOAD_CHECKSUM, }, .rx_adv_conf = { .rss_conf = { - .rss_key = rss_symmetric_key, .rss_hf = ETH_RSS_IP | ETH_RSS_UDP | ETH_RSS_TCP | ETH_RSS_L2_PAYLOAD, + .rss_key = rss_symmetric_key, .rss_hf = RTE_ETH_RSS_IP | RTE_ETH_RSS_UDP | RTE_ETH_RSS_TCP | RTE_ETH_RSS_L2_PAYLOAD, }, }, - .txmode = {.mq_mode = ETH_MQ_TX_NONE, - .offloads = (DEV_TX_OFFLOAD_IPV4_CKSUM | DEV_TX_OFFLOAD_UDP_CKSUM | DEV_TX_OFFLOAD_TCP_CKSUM)}, + .txmode = {.mq_mode = RTE_ETH_MQ_TX_NONE, + .offloads = (RTE_ETH_TX_OFFLOAD_IPV4_CKSUM | RTE_ETH_TX_OFFLOAD_UDP_CKSUM | RTE_ETH_TX_OFFLOAD_TCP_CKSUM)}, }; /*********************************Interfaces**********************************/ @@ -207,6 +206,13 @@ init(int argc, char *argv[]) { if (retval != 0) return -1; + /* register onvm_pkt_meta dynfield with DPDK (must be done before init_mbuf_pools) */ + static const struct rte_mbuf_dynfield onvm_pkt_meta_dynfield_desc = { + .name = "onvm_pkt_meta_dynfield", + .size = sizeof(onvm_pkt_meta_t), + .align = alignof(onvm_pkt_meta_t) + }; + /* initialise mbuf pools */ retval = init_mbuf_pools(); if (retval != 0) @@ -224,6 +230,11 @@ init(int argc, char *argv[]) { rte_exit(EXIT_FAILURE, "Cannot create nf message pool: %s\n", rte_strerror(rte_errno)); } + /* initialize onvm_pkt_meta dynfield offset, and load to onvm_config */ + onvm_config->dynfield_offset = rte_mbuf_dynfield_register(&onvm_pkt_meta_dynfield_desc); + if(onvm_config->dynfield_offset < 0) + rte_exit(EXIT_FAILURE, "Cannot register onvm_pkt_meta mbuf field\n"); + /* now initialise the ports we will use */ for (i = 0; i < ports->num_ports; i++) { port_id = ports->id[i]; @@ -275,6 +286,7 @@ init(int argc, char *argv[]) { static void set_default_config(struct onvm_configuration *config) { config->flags.ONVM_NF_SHARE_CORES = ONVM_NF_SHARE_CORES_DEFAULT; + config->dynfield_offset = -1; } /** @@ -360,8 +372,8 @@ init_port(uint8_t port_num) { /* Standard DPDK port initialisation - config port, then set up * rx and tx rings */ rte_eth_dev_info_get(port_num, &dev_info); - if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE) - local_port_conf.txmode.offloads |= DEV_TX_OFFLOAD_MBUF_FAST_FREE; + if (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE) + local_port_conf.txmode.offloads |= RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE; local_port_conf.rx_adv_conf.rss_conf.rss_hf &= dev_info.flow_type_rss_offloads; if (local_port_conf.rx_adv_conf.rss_conf.rss_hf != port_conf.rx_adv_conf.rss_conf.rss_hf) { printf( @@ -371,8 +383,7 @@ init_port(uint8_t port_num) { } if (ONVM_USE_JUMBO_FRAMES) { - local_port_conf.rxmode.max_rx_pkt_len = 9600 + RTE_ETHER_CRC_LEN + RTE_ETHER_HDR_LEN; - local_port_conf.rxmode.offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME; + local_port_conf.rxmode.mtu = MAX_MTU; } if ((retval = rte_eth_dev_configure(port_num, rx_rings, tx_rings, &local_port_conf)) != 0) @@ -496,7 +507,7 @@ check_all_ports_link_status(uint8_t port_num, uint32_t port_mask) { "Port %d Link Up - speed %u " "Mbps - %s\n", ports->id[portid], (unsigned)link.link_speed, - (link.link_duplex == ETH_LINK_FULL_DUPLEX) ? ("full-duplex") + (link.link_duplex == RTE_ETH_LINK_FULL_DUPLEX) ? ("full-duplex") : ("half-duplex\n")); else printf("Port %d Link Down\n", (uint8_t)ports->id[portid]); diff --git a/onvm/onvm_mgr/onvm_init.h b/onvm/onvm_mgr/onvm_init.h index 85d11e9c8..84a8d6c93 100644 --- a/onvm/onvm_mgr/onvm_init.h +++ b/onvm/onvm_mgr/onvm_init.h @@ -59,6 +59,7 @@ #include #include #include +#include #ifdef RTE_LIBRTE_PDUMP #include #endif diff --git a/onvm/onvm_mgr/onvm_pkt.c b/onvm/onvm_mgr/onvm_pkt.c index 9e6076e87..96ba60376 100644 --- a/onvm/onvm_mgr/onvm_pkt.c +++ b/onvm/onvm_mgr/onvm_pkt.c @@ -67,19 +67,19 @@ onvm_pkt_process_rx_batch(struct queue_mgr *rx_mgr, struct rte_mbuf *pkts[], uin return; for (i = 0; i < rx_count; i++) { - meta = (struct onvm_pkt_meta *)&(((struct rte_mbuf *)pkts[i])->udata64); + meta = onvm_get_pkt_meta(pkts[i], onvm_config->dynfield_offset); meta->src = 0; meta->chain_index = 0; #ifdef FLOW_LOOKUP ret = onvm_flow_dir_get_pkt(pkts[i], &flow_entry); if (ret >= 0) { sc = flow_entry->sc; - meta->action = onvm_sc_next_action(sc, pkts[i]); - meta->destination = onvm_sc_next_destination(sc, pkts[i]); + meta->action = onvm_sc_next_action(sc, pkts[i], onvm_config->dynfield_offset); + meta->destination = onvm_sc_next_destination(sc, pkts[i], onvm_config->dynfield_offset); } else { #endif - meta->action = onvm_sc_next_action(default_chain, pkts[i]); - meta->destination = onvm_sc_next_destination(default_chain, pkts[i]); + meta->action = onvm_sc_next_action(default_chain, pkts[i], onvm_config->dynfield_offset); + meta->destination = onvm_sc_next_destination(default_chain, pkts[i], onvm_config->dynfield_offset); #ifdef FLOW_LOOKUP } #endif diff --git a/onvm/onvm_mgr/onvm_stats.c b/onvm/onvm_mgr/onvm_stats.c index 8d0863d55..325bf2acf 100644 --- a/onvm/onvm_mgr/onvm_stats.c +++ b/onvm/onvm_mgr/onvm_stats.c @@ -125,6 +125,13 @@ static FILE *json_events_out; /* Holds current timestamp, might want to make this not global */ char buffer[20]; +cJSON* onvm_json_root; +cJSON* onvm_json_port_stats_obj; +cJSON* onvm_json_nf_stats_obj; +cJSON* onvm_json_port_stats[RTE_MAX_ETHPORTS]; +cJSON* onvm_json_nf_stats[MAX_NFS]; +cJSON* onvm_json_events_arr; + /****************************Interfaces***************************************/ void diff --git a/onvm/onvm_mgr/onvm_stats.h b/onvm/onvm_mgr/onvm_stats.h index b6e337282..9c5ba1fff 100644 --- a/onvm/onvm_mgr/onvm_stats.h +++ b/onvm/onvm_mgr/onvm_stats.h @@ -138,12 +138,14 @@ struct onvm_event { void *data; }; -cJSON* onvm_json_root; -cJSON* onvm_json_port_stats_obj; -cJSON* onvm_json_nf_stats_obj; -cJSON* onvm_json_port_stats[RTE_MAX_ETHPORTS]; -cJSON* onvm_json_nf_stats[MAX_NFS]; -cJSON* onvm_json_events_arr; +/****************************Global variables***************************************/ + +extern cJSON* onvm_json_root; +extern cJSON* onvm_json_port_stats_obj; +extern cJSON* onvm_json_nf_stats_obj; +extern cJSON* onvm_json_port_stats[RTE_MAX_ETHPORTS]; +extern cJSON* onvm_json_nf_stats[MAX_NFS]; +extern cJSON* onvm_json_events_arr; /*********************************Interfaces**********************************/ diff --git a/onvm/onvm_nflib/Makefile b/onvm/onvm_nflib/Makefile deleted file mode 100644 index 69d9f2864..000000000 --- a/onvm/onvm_nflib/Makefile +++ /dev/null @@ -1,61 +0,0 @@ -# openNetVM -# https://github.com/sdnfv/openNetVM -# -# BSD LICENSE -# -# Copyright(c) -# 2015-2017 George Washington University -# 2015-2017 University of California Riverside -# 2010-2014 Intel Corporation. -# 2016-2017 Hewlett Packard Enterprise Development LP -# 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 - -ifeq ($(ONVM_HOME),) -$(error "Please define the ONVM_HOME 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 -LIB = libonvm.a - -# all source are stored in SRCS-y -SRCS-y := onvm_pkt_helper.c onvm_sc_common.c onvm_sc_mgr.c onvm_flow_table.c onvm_flow_dir.c onvm_nflib.c onvm_pkt_common.c onvm_config_common.c onvm_threading.c - -CFLAGS += $(WERROR_FLAGS) -O3 $(USER_FLAGS) -CFLAGS += -I$(ONVM_HOME)/onvm/lib - -include $(RTE_SDK)/mk/rte.extlib.mk diff --git a/onvm/onvm_nflib/meson.build b/onvm/onvm_nflib/meson.build new file mode 100644 index 000000000..e0154ac46 --- /dev/null +++ b/onvm/onvm_nflib/meson.build @@ -0,0 +1,34 @@ +sources = files( + 'onvm_config_common.c', + 'onvm_flow_dir.c', + 'onvm_flow_table.c', + 'onvm_nflib.c', + 'onvm_pkt_common.c', + 'onvm_pkt_helper.c', + 'onvm_sc_common.c', + 'onvm_sc_mgr.c', + 'onvm_threading.c' +) + +libonvm_includes = include_directories('.') + +libonvm_deps = [ + onvm_dpdk_dep, + onvm_thread_dep, + libonvmhelper_dep +] + +libonvm = library( + 'libonvm', + sources, + include_directories : libonvm_includes, + dependencies : libonvm_deps, + pic: true, + install: true, + install_tag: 'onvm') + +libonvm_dep = declare_dependency( + link_with: libonvm, + dependencies: libonvm_deps) + +onvm_nflib_dep += libonvm_dep \ No newline at end of file diff --git a/onvm/onvm_nflib/onvm_common.h b/onvm/onvm_nflib/onvm_common.h index e2b8adcc1..b50aecd96 100755 --- a/onvm/onvm_nflib/onvm_common.h +++ b/onvm/onvm_nflib/onvm_common.h @@ -59,6 +59,9 @@ #include "onvm_config_common.h" #include "onvm_msg_common.h" +#define JUMBO_FRAME_MAX_SIZE 0x2600 +#define MAX_MTU (JUMBO_FRAME_MAX_SIZE - (RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN)) + #define ONVM_NF_HANDLE_TX 1 // should be true if NFs primarily pass packets to each other #define ONVM_NF_SHUTDOWN_CORE_REASSIGNMENT 0 // should be true if on NF shutdown onvm_mgr tries to reallocate cores @@ -114,16 +117,16 @@ struct onvm_pkt_meta { uint8_t chain_index; /*index of the current step in the service chain*/ uint8_t flags; /* bits for custom NF data. Use with caution to prevent collisions from different NFs. */ }; +typedef struct onvm_pkt_meta onvm_pkt_meta_t; static inline struct onvm_pkt_meta * -onvm_get_pkt_meta(struct rte_mbuf *pkt) { - return (struct onvm_pkt_meta *)&pkt->udata64; +onvm_get_pkt_meta(struct rte_mbuf *pkt, int pkt_meta_offset) { + return RTE_MBUF_DYNFIELD(pkt, pkt_meta_offset, struct onvm_pkt_meta *); } static inline uint8_t -onvm_get_pkt_chain_index(struct rte_mbuf *pkt) { - struct onvm_pkt_meta* pkt_meta = (struct onvm_pkt_meta*) &pkt->udata64; - return pkt_meta->chain_index; +onvm_get_pkt_chain_index(struct rte_mbuf *pkt, int pkt_meta_offset) { + return (onvm_get_pkt_meta(pkt, pkt_meta_offset))->chain_index; } /* @@ -210,6 +213,7 @@ struct onvm_configuration { struct { uint8_t ONVM_NF_SHARE_CORES; } flags; + int dynfield_offset; }; struct core_status { @@ -324,6 +328,9 @@ struct onvm_nf { /* Mutex for NF sem_wait */ sem_t *nf_mutex; } shared_core; + + /** Used by RTE_MBUF_DYNFIELD to access ovnm pkt meta*/ + int dynfield_offset; }; /* diff --git a/onvm/onvm_nflib/onvm_nflib.c b/onvm/onvm_nflib/onvm_nflib.c index 4e95ed2a2..b2b75f68e 100644 --- a/onvm/onvm_nflib/onvm_nflib.c +++ b/onvm/onvm_nflib/onvm_nflib.c @@ -147,7 +147,7 @@ onvm_nflib_parse_args(int argc, char *argv[], struct onvm_nf_init_cfg *nf_init_c */ static inline uint16_t onvm_nflib_dequeue_packets(void **pkts, struct onvm_nf_local_ctx *nf_local_ctx, - nf_pkt_handler_fn handler) __attribute__((always_inline)); + nf_pkt_handler_fn handler, int pkt_meta_offset) __attribute__((always_inline)); /* * Check if there is a message available for this NF and process it @@ -601,10 +601,10 @@ onvm_nflib_thread_main_loop(void *arg) { } nb_pkts_added = - onvm_nflib_dequeue_packets((void **)pkts, nf_local_ctx, nf->function_table->pkt_handler); + onvm_nflib_dequeue_packets((void **)pkts, nf_local_ctx, nf->function_table->pkt_handler, onvm_config->dynfield_offset); if (likely(nb_pkts_added > 0)) { - onvm_pkt_process_tx_batch(nf->nf_tx_mgr, pkts, nb_pkts_added, nf); + onvm_pkt_process_tx_batch(nf->nf_tx_mgr, pkts, onvm_config->dynfield_offset, nb_pkts_added, nf); } /* Flush the packet buffers */ @@ -965,7 +965,7 @@ onvm_nflib_parse_config(struct onvm_configuration *config) { } static inline uint16_t -onvm_nflib_dequeue_packets(void **pkts, struct onvm_nf_local_ctx *nf_local_ctx, nf_pkt_handler_fn handler) { +onvm_nflib_dequeue_packets(void **pkts, struct onvm_nf_local_ctx *nf_local_ctx, nf_pkt_handler_fn handler, int pkt_meta_offset) { struct onvm_nf *nf; struct onvm_pkt_meta *meta; uint16_t i, nb_pkts; @@ -985,7 +985,7 @@ onvm_nflib_dequeue_packets(void **pkts, struct onvm_nf_local_ctx *nf_local_ctx, /* Give each packet to the user proccessing function */ for (i = 0; i < nb_pkts; i++) { - meta = onvm_get_pkt_meta((struct rte_mbuf *)pkts[i]); + meta = onvm_get_pkt_meta((struct rte_mbuf *)pkts[i], pkt_meta_offset); ret_act = (*handler)((struct rte_mbuf *)pkts[i], meta, nf_local_ctx); /* NF returns 0 to return packets or 1 to buffer */ if (likely(ret_act == 0)) { diff --git a/onvm/onvm_nflib/onvm_pkt_common.c b/onvm/onvm_nflib/onvm_pkt_common.c index 2a6d88c90..a543b2993 100644 --- a/onvm/onvm_nflib/onvm_pkt_common.c +++ b/onvm/onvm_nflib/onvm_pkt_common.c @@ -70,7 +70,7 @@ onvm_pkt_enqueue_port(struct queue_mgr *tx_mgr, uint16_t port, struct rte_mbuf * * */ static inline void -onvm_pkt_process_next_action(struct queue_mgr *tx_mgr, struct rte_mbuf *pkt, struct onvm_nf *nf); +onvm_pkt_process_next_action(struct queue_mgr *tx_mgr, struct rte_mbuf *pkt, int pkt_meta_offset, struct onvm_nf *nf); /* * Helper function to drop a packet. @@ -86,7 +86,7 @@ onvm_pkt_drop(struct rte_mbuf *pkt); /**********************************Interfaces*********************************/ void -onvm_pkt_process_tx_batch(struct queue_mgr *tx_mgr, struct rte_mbuf *pkts[], uint16_t tx_count, struct onvm_nf *nf) { +onvm_pkt_process_tx_batch(struct queue_mgr *tx_mgr, struct rte_mbuf *pkts[], int pkt_meta_offset, uint16_t tx_count, struct onvm_nf *nf) { uint16_t i; struct onvm_pkt_meta *meta; struct packet_buf *out_buf; @@ -95,7 +95,7 @@ onvm_pkt_process_tx_batch(struct queue_mgr *tx_mgr, struct rte_mbuf *pkts[], uin return; for (i = 0; i < tx_count; i++) { - meta = (struct onvm_pkt_meta *)&(((struct rte_mbuf *)pkts[i])->udata64); + meta = onvm_get_pkt_meta(pkts[i], pkt_meta_offset); meta->src = nf->instance_id; if (meta->action == ONVM_NF_ACTION_DROP) { // if the packet is drop, then is 0 @@ -106,7 +106,7 @@ onvm_pkt_process_tx_batch(struct queue_mgr *tx_mgr, struct rte_mbuf *pkts[], uin /* TODO: Here we drop the packet : there will be a flow table in the future to know what to do with the packet next */ nf->stats.act_next++; - onvm_pkt_process_next_action(tx_mgr, pkts[i], nf); + onvm_pkt_process_next_action(tx_mgr, pkts[i], pkt_meta_offset, nf); } else if (meta->action == ONVM_NF_ACTION_TONF) { nf->stats.act_tonf++; onvm_pkt_enqueue_nf(tx_mgr, meta->destination, pkts[i], nf); @@ -271,23 +271,23 @@ onvm_pkt_enqueue_port(struct queue_mgr *tx_mgr, uint16_t port, struct rte_mbuf * } inline static void -onvm_pkt_process_next_action(struct queue_mgr *tx_mgr, struct rte_mbuf *pkt, struct onvm_nf *nf) { +onvm_pkt_process_next_action(struct queue_mgr *tx_mgr, struct rte_mbuf *pkt, int pkt_meta_offset, struct onvm_nf *nf) { if (tx_mgr == NULL || pkt == NULL || nf == NULL) return; struct onvm_flow_entry *flow_entry; struct onvm_service_chain *sc; - struct onvm_pkt_meta *meta = onvm_get_pkt_meta(pkt); + struct onvm_pkt_meta *meta = onvm_get_pkt_meta(pkt, pkt_meta_offset); int ret; ret = onvm_flow_dir_get_pkt(pkt, &flow_entry); if (ret >= 0) { sc = flow_entry->sc; - meta->action = onvm_sc_next_action(sc, pkt); - meta->destination = onvm_sc_next_destination(sc, pkt); + meta->action = onvm_sc_next_action(sc, pkt, pkt_meta_offset); + meta->destination = onvm_sc_next_destination(sc, pkt, pkt_meta_offset); } else { - meta->action = onvm_sc_next_action(default_chain, pkt); - meta->destination = onvm_sc_next_destination(default_chain, pkt); + meta->action = onvm_sc_next_action(default_chain, pkt, pkt_meta_offset); + meta->destination = onvm_sc_next_destination(default_chain, pkt, pkt_meta_offset); } switch (meta->action) { diff --git a/onvm/onvm_nflib/onvm_pkt_common.h b/onvm/onvm_nflib/onvm_pkt_common.h index 3a320c796..ede76d463 100644 --- a/onvm/onvm_nflib/onvm_pkt_common.h +++ b/onvm/onvm_nflib/onvm_pkt_common.h @@ -72,7 +72,7 @@ extern struct onvm_service_chain *default_chain; * */ void -onvm_pkt_process_tx_batch(struct queue_mgr *tx_mgr, struct rte_mbuf *pkts[], uint16_t tx_count, struct onvm_nf *nf); +onvm_pkt_process_tx_batch(struct queue_mgr *tx_mgr, struct rte_mbuf *pkts[], int pkt_meta_offset, uint16_t tx_count, struct onvm_nf *nf); /* * Interface to send packets to all NFs after processing them. diff --git a/onvm/onvm_nflib/onvm_pkt_helper.c b/onvm/onvm_nflib/onvm_pkt_helper.c index 4b2f133da..00abcb4ff 100644 --- a/onvm/onvm_nflib/onvm_pkt_helper.c +++ b/onvm/onvm_nflib/onvm_pkt_helper.c @@ -73,8 +73,8 @@ onvm_pkt_set_mac_addr(struct rte_mbuf* pkt, unsigned src_port_id, unsigned dst_p * Get the MAC addresses of the src and destination NIC ports, * and set the ethernet header's fields to them. */ - rte_ether_addr_copy(&ports->mac[src_port_id], ð->s_addr); - rte_ether_addr_copy(&ports->mac[dst_port_id], ð->d_addr); + rte_ether_addr_copy(&ports->mac[src_port_id], ð->src_addr); + rte_ether_addr_copy(&ports->mac[dst_port_id], ð->dst_addr); return 0; } @@ -95,13 +95,13 @@ onvm_pkt_swap_src_mac_addr(struct rte_mbuf* pkt, unsigned dst_port_id, struct po /* * Copy the source mac address to the destination field. */ - rte_ether_addr_copy(ð->s_addr, ð->d_addr); + rte_ether_addr_copy(ð->src_addr, ð->dst_addr); /* * Get the mac address of the specified destination port id * and set the source field to it. */ - rte_ether_addr_copy(&ports->mac[dst_port_id], ð->s_addr); + rte_ether_addr_copy(&ports->mac[dst_port_id], ð->src_addr); return 0; } @@ -122,13 +122,13 @@ onvm_pkt_swap_dst_mac_addr(struct rte_mbuf* pkt, unsigned src_port_id, struct po /* * Copy the destination mac address to the source field. */ - rte_ether_addr_copy(ð->d_addr, ð->s_addr); + rte_ether_addr_copy(ð->dst_addr, ð->src_addr); /* * Get the mac address of specified source port id * and set the destination field to it. */ - rte_ether_addr_copy(&ports->mac[src_port_id], ð->d_addr); + rte_ether_addr_copy(&ports->mac[src_port_id], ð->dst_addr); return 0; } @@ -322,12 +322,12 @@ onvm_pkt_print_ether(struct rte_ether_hdr* hdr) { if (unlikely(hdr == NULL)) { return; } - printf("Source MAC: %02x:%02x:%02x:%02x:%02x:%02x\n", hdr->s_addr.addr_bytes[0], hdr->s_addr.addr_bytes[1], - hdr->s_addr.addr_bytes[2], hdr->s_addr.addr_bytes[3], hdr->s_addr.addr_bytes[4], - hdr->s_addr.addr_bytes[5]); - printf("Dest MAC: %02x:%02x:%02x:%02x:%02x:%02x\n", hdr->d_addr.addr_bytes[0], hdr->d_addr.addr_bytes[1], - hdr->d_addr.addr_bytes[2], hdr->d_addr.addr_bytes[3], hdr->d_addr.addr_bytes[4], - hdr->d_addr.addr_bytes[5]); + printf("Source MAC: %02x:%02x:%02x:%02x:%02x:%02x\n", hdr->src_addr.addr_bytes[0], hdr->src_addr.addr_bytes[1], + hdr->src_addr.addr_bytes[2], hdr->src_addr.addr_bytes[3], hdr->src_addr.addr_bytes[4], + hdr->src_addr.addr_bytes[5]); + printf("Dest MAC: %02x:%02x:%02x:%02x:%02x:%02x\n", hdr->dst_addr.addr_bytes[0], hdr->dst_addr.addr_bytes[1], + hdr->dst_addr.addr_bytes[2], hdr->dst_addr.addr_bytes[3], hdr->dst_addr.addr_bytes[4], + hdr->dst_addr.addr_bytes[5]); switch (hdr->ether_type) { case RTE_ETHER_TYPE_IPV4: type = "IPv4"; @@ -410,13 +410,13 @@ onvm_pkt_get_checksum_offload_flags(uint8_t port_id) { rte_eth_dev_info_get(port_id, &dev_info); - if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) { + if (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) { hw_offload_flags |= SUPPORTS_IPV4_CHECKSUM_OFFLOAD; } - if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) { + if (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) { hw_offload_flags |= SUPPORTS_TCP_CHECKSUM_OFFLOAD; } - if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) { + if (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) { hw_offload_flags |= SUPPORTS_UDP_CHECKSUM_OFFLOAD; } return hw_offload_flags; @@ -480,7 +480,7 @@ onvm_pkt_set_checksums(struct rte_mbuf* pkt) { ip->hdr_checksum = 0; pkt->l2_len = sizeof(struct rte_ether_hdr); pkt->l3_len = (ip->version_ihl & 0b1111) * 4; - pkt->ol_flags |= PKT_TX_IPV4; + pkt->ol_flags |= RTE_MBUF_F_TX_IPV4; if (tcp != NULL) { tcp->cksum = 0; @@ -488,7 +488,7 @@ onvm_pkt_set_checksums(struct rte_mbuf* pkt) { if (hw_cksum_support & SUPPORTS_TCP_CHECKSUM_OFFLOAD) { tcp->cksum = rte_ipv4_phdr_cksum(ip, pkt->ol_flags); - pkt->ol_flags |= PKT_TX_TCP_CKSUM; + pkt->ol_flags |= RTE_MBUF_F_TX_TCP_CKSUM; } else { /* software TCP checksumming */ tcp->cksum = calculate_tcpudp_cksum(ip, tcp, pkt->l3_len, IP_PROTOCOL_TCP); @@ -501,7 +501,7 @@ onvm_pkt_set_checksums(struct rte_mbuf* pkt) { if (hw_cksum_support & SUPPORTS_UDP_CHECKSUM_OFFLOAD) { udp->dgram_cksum = rte_ipv4_phdr_cksum(ip, pkt->ol_flags); - pkt->ol_flags |= PKT_TX_UDP_CKSUM; + pkt->ol_flags |= RTE_MBUF_F_TX_UDP_CKSUM; } else { /* software UDP checksumming */ udp->dgram_cksum = calculate_tcpudp_cksum(ip, udp, pkt->l3_len, IP_PROTOCOL_UDP); @@ -509,7 +509,7 @@ onvm_pkt_set_checksums(struct rte_mbuf* pkt) { } if (hw_cksum_support & SUPPORTS_IPV4_CHECKSUM_OFFLOAD) { - pkt->ol_flags |= PKT_TX_IP_CKSUM; + pkt->ol_flags |= RTE_MBUF_F_TX_IP_CKSUM; } else { /* software IP checksumming */ ip->hdr_checksum = calculate_ip_cksum(ip, pkt->l3_len); @@ -523,12 +523,12 @@ onvm_pkt_swap_ether_hdr(struct rte_ether_hdr* ether_hdr) { struct rte_ether_addr temp_ether_addr; for (i = 0; i < RTE_ETHER_ADDR_LEN; ++i) { - temp_ether_addr.addr_bytes[i] = ether_hdr->s_addr.addr_bytes[i]; - ether_hdr->s_addr.addr_bytes[i] = ether_hdr->d_addr.addr_bytes[i]; + temp_ether_addr.addr_bytes[i] = ether_hdr->src_addr.addr_bytes[i]; + ether_hdr->src_addr.addr_bytes[i] = ether_hdr->dst_addr.addr_bytes[i]; } for (i = 0; i < RTE_ETHER_ADDR_LEN; ++i) { - ether_hdr->d_addr.addr_bytes[i] = temp_ether_addr.addr_bytes[i]; + ether_hdr->dst_addr.addr_bytes[i] = temp_ether_addr.addr_bytes[i]; } return 0; @@ -574,7 +574,7 @@ onvm_pkt_generate_tcp(struct rte_mempool* pktmbuf_pool, struct rte_tcp_hdr* tcp_ return NULL; } - pkt->ol_flags = PKT_TX_IP_CKSUM | PKT_TX_IPV4 | PKT_TX_TCP_CKSUM; + pkt->ol_flags = RTE_MBUF_F_TX_IP_CKSUM | RTE_MBUF_F_TX_IPV4 | RTE_MBUF_F_TX_TCP_CKSUM; pkt->l2_len = sizeof(struct rte_ether_hdr); pkt->l3_len = sizeof(struct rte_ipv4_hdr); @@ -664,17 +664,17 @@ onvm_pkt_fill_ether(struct rte_ether_hdr* eth_hdr, int port, struct rte_ether_ad int i; /* Set ether header */ - rte_ether_addr_copy(&ports->mac[port], ð_hdr->s_addr); + rte_ether_addr_copy(&ports->mac[port], ð_hdr->src_addr); eth_hdr->ether_type = rte_be_to_cpu_16(RTE_ETHER_TYPE_IPV4); for (i = 0; i < RTE_ETHER_ADDR_LEN; ++i) { - eth_hdr->d_addr.addr_bytes[i] = dst_mac_addr->addr_bytes[i]; + eth_hdr->dst_addr.addr_bytes[i] = dst_mac_addr->addr_bytes[i]; } return 0; } struct rte_mbuf* -onvm_pkt_generate_udp_sample(struct rte_mempool* pktmbuf_pool) { +onvm_pkt_generate_udp_sample(struct rte_mempool* pktmbuf_pool, int pkt_meta_offset) { struct onvm_pkt_meta* pmeta = NULL; struct rte_mbuf* pkt; struct rte_udp_hdr udp_hdr; @@ -694,7 +694,7 @@ onvm_pkt_generate_udp_sample(struct rte_mempool* pktmbuf_pool) { } /* Set packet dest */ - pmeta = onvm_get_pkt_meta(pkt); + pmeta = onvm_get_pkt_meta(pkt, pkt_meta_offset); pmeta->destination = SAMPLE_NIC_PORT; pmeta->action = ONVM_NF_ACTION_OUT; @@ -715,7 +715,7 @@ onvm_pkt_generate_udp(struct rte_mempool* pktmbuf_pool, struct rte_udp_hdr* udp_ return NULL; } - pkt->ol_flags = PKT_TX_IP_CKSUM | PKT_TX_IPV4 | PKT_TX_UDP_CKSUM; + pkt->ol_flags = RTE_MBUF_F_TX_IP_CKSUM | RTE_MBUF_F_TX_IPV4 | RTE_MBUF_F_TX_UDP_CKSUM; pkt->l2_len = sizeof(struct rte_ether_hdr); pkt->l3_len = sizeof(struct rte_ipv4_hdr); diff --git a/onvm/onvm_nflib/onvm_pkt_helper.h b/onvm/onvm_nflib/onvm_pkt_helper.h index de62defa6..af9168ae1 100644 --- a/onvm/onvm_nflib/onvm_pkt_helper.h +++ b/onvm/onvm_nflib/onvm_pkt_helper.h @@ -230,6 +230,6 @@ onvm_pkt_generate_udp(struct rte_mempool* pktmbuf_pool, struct rte_udp_hdr* udp_ * Generates a sample UDP packet */ struct rte_mbuf* -onvm_pkt_generate_udp_sample(struct rte_mempool* pktmbuf_pool); +onvm_pkt_generate_udp_sample(struct rte_mempool* pktmbuf_pool, int pkt_meta_offset); #endif // _ONVM_PKT_HELPER_H_" diff --git a/onvm/onvm_nflib/onvm_sc_mgr.h b/onvm/onvm_nflib/onvm_sc_mgr.h index 57d1a1380..9927726ca 100644 --- a/onvm/onvm_nflib/onvm_sc_mgr.h +++ b/onvm/onvm_nflib/onvm_sc_mgr.h @@ -53,8 +53,8 @@ onvm_next_action(struct onvm_service_chain* chain, uint16_t cur_nf) { } static inline uint8_t -onvm_sc_next_action(struct onvm_service_chain* chain, struct rte_mbuf* pkt) { - return onvm_next_action(chain, onvm_get_pkt_chain_index(pkt)); +onvm_sc_next_action(struct onvm_service_chain* chain, struct rte_mbuf* pkt, int pkt_meta_offset) { + return onvm_next_action(chain, onvm_get_pkt_chain_index(pkt, pkt_meta_offset)); } static inline uint16_t @@ -66,8 +66,8 @@ onvm_next_destination(struct onvm_service_chain* chain, uint16_t cur_nf) { } static inline uint16_t -onvm_sc_next_destination(struct onvm_service_chain* chain, struct rte_mbuf* pkt) { - return onvm_next_destination(chain, onvm_get_pkt_chain_index(pkt)); +onvm_sc_next_destination(struct onvm_service_chain* chain, struct rte_mbuf* pkt, int pkt_meta_offset) { + return onvm_next_destination(chain, onvm_get_pkt_chain_index(pkt, pkt_meta_offset)); } /*get service chain*/ diff --git a/scripts/build.sh b/scripts/build.sh new file mode 100755 index 000000000..c71b84317 --- /dev/null +++ b/scripts/build.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +meson build +ninja -C build +meson install -C build --tags=onvm \ No newline at end of file diff --git a/scripts/install.sh b/scripts/install.sh index c87b457cb..a55ab5922 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -6,7 +6,7 @@ # OpenNetVM is distributed under the following BSD LICENSE: # # Copyright(c) -# 2015-2017 George Washington University +# 2015-2024 George Washington University # 2015-2017 University of California Riverside # All rights reserved. # @@ -35,103 +35,90 @@ # 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. - -set -e - -# A script to configure openNetVM -# Expected to be run as scripts/install.sh -# CONFIGURATION (via environment variable): -# - Make sure $RTE_TARGET and $RTE_SDK are correct (see install docs) -# - Set $ONVM_NUM_HUGEPAGES to control the number of pages created -# - Set $ONVM_SKIP_FSTAB to not add huge fs to /etc/fstab - -#Print a table with enviromental variable locations -echo "----------------------------------------" -echo "ONVM Environment Variables:" -echo "----------------------------------------" -echo "RTE_SDK: $RTE_SDK" -echo "RTE_TARGET: $RTE_TARGET" -echo "ONVM_NUM_HUGEPAGES: $ONVM_NUM_HUGEPAGES" -echo "ONVM_SKIP_HUGEPAGES: $ONVM_SKIP_HUGEPAGES" -echo "ONVM_SKIP_FSTAB: $ONVM_SKIP_FSTAB" -echo "----------------------------------------" - -if [ -z "$RTE_TARGET" ]; then - echo "Please export \$RTE_TARGET. Or try running this without sudo." - exit 1 -fi - -if [ -z "$RTE_SDK" ]; then - echo "Please export \$RTE_SDK" - exit 1 -fi - -# Validate sudo access -sudo -v - +# +# A script to install required linux packages and perform initial developer +# environment setup actions. + +packages=("build-essential" \ + "python3" \ + "python3-pip" \ + "python3-setuptools" \ + "python3-wheel" \ + "python3-venv" \ + "ninja-build" \ + "pkg-config" \ + "libnuma-dev" \ + "libpcap-dev" \ + "libsystemd-dev") +install_packages=true + +pypackages=("meson" \ + "pyelftools") +pyenv="env" + +# Check the passed arguments, and set the appropriate flags if a +# particular argument is detected +for arg in "$@" +do + if [[ $arg == "--noinstall" ]]; then + install_packages=false + break + fi +done + +# Check to make sure this script is running in the correct working +# directory. # Ensure we're working relative to the onvm root directory -if [ "$(basename "$(pwd)")" == "scripts" ]; then - cd .. +if [ "$(basename "$(pwd)")" != "openNetVM" ]; then + echo "Please run the installation script from the parent openNetVM directory" fi -# Set state variables -start_dir=$(pwd) -if [ -z "$ONVM_HOME" ]; then - echo "Please export \$ONVM_HOME and set it to $start_dir" - exit 1 -fi - -# Source DPDK helper functions -. "$ONVM_HOME"/scripts/dpdk_helper_scripts.sh - -set +e -remove_igb_uio_module -set -e - -# Compile dpdk -cd "$RTE_SDK" -echo "Compiling and installing dpdk in $RTE_SDK" +# (1) +# Install required packages for development +required=$(IFS=' '; echo "${packages[*]}") -# Adding ldflags.txt output for mTCP compatibility -if grep "ldflags.txt" "$RTE_SDK"/mk/rte.app.mk > /dev/null -then - : +echo "- Installing required packages" +if [ "$install_packages" = true ]; then + echo " - installing: $required" + sudo apt-get update + sudo apt-get install $required -y else - # want to use single quotes for sed operation - # shellcheck disable=SC2016 - sed -i -e 's/O_TO_EXE_STR =/\$(shell if [ \! -d \${RTE_SDK}\/\${RTE_TARGET}\/lib ]\; then mkdir -p \${RTE_SDK}\/\${RTE_TARGET}\/lib\; fi)\nLINKER_FLAGS = \$(call linkerprefix,\$(LDLIBS))\n\$(shell echo \${LINKER_FLAGS} \> \${RTE_SDK}\/\${RTE_TARGET}\/lib\/ldflags\.txt)\nO_TO_EXE_STR =/g' "$RTE_SDK"/mk/rte.app.mk + echo " - skipping due to --noinstall flag" fi -sed -i 's/CONFIG_RTE_EAL_IGB_UIO=n/CONFIG_RTE_EAL_IGB_UIO=y/g' "$RTE_SDK"/config/common_base -sleep 1 -make config T="$RTE_TARGET" -make T="$RTE_TARGET" -j 8 -make install T="$RTE_TARGET" -j 8 +# (2) +# Initialize the Git submodules (dpdk & pkt_gen) +echo "- Initializing Git submodules" -# Refresh sudo -sudo -v +git submodule update --init -cd "$start_dir" -# Setup/Check for free HugePages if the user wants to -if [ -z "$ONVM_SKIP_HUGEPAGES" ]; then - set_numa_pages -fi +# (3) +# Create the Python environment (this will be used for compiling onvm) +pyrequired=$(IFS=' '; echo "${pypackages[*]}") -grep -m 1 "huge" /etc/fstab | cat -# Only add to /etc/fstab if user wants it -if [ "${PIPESTATUS[0]}" != 0 ] && [ -z "$ONVM_SKIP_FSTAB" ]; then - echo "Adding huge fs to /etc/fstab" - sleep 1 - sudo sh -c "echo \"huge /mnt/huge hugetlbfs defaults 0 0\" >> /etc/fstab" -fi +echo "- Setup Python environment" +echo " - installing $pyrequired" + +python3 -m venv $pyenv +source env/bin/activate +pip3 install $pyrequired -# Configure local environment -echo "Configuring environment" -sleep 1 -scripts/setup_environment.sh -echo "ONVM INSTALL COMPLETED SUCCESSFULLY" +# (4) +# Build the dpdk-kmods uio kernel module +echo "- Building the dpdk-kmods uio kernel module" +cd subprojects/dpdk-kmods/linux/igb_uio +make +cd - +# (5) +# Install dpdk +echo "- Installing dpdk" +cd subprojects/dpdk +meson build +ninja -C build +ninja -C build install +sudo ldconfig diff --git a/scripts/install_old.sh b/scripts/install_old.sh new file mode 100755 index 000000000..c87b457cb --- /dev/null +++ b/scripts/install_old.sh @@ -0,0 +1,137 @@ +#! /bin/bash + +# openNetVM +# https://sdnfv.github.io +# +# OpenNetVM is distributed under the following 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. + +set -e + +# A script to configure openNetVM +# Expected to be run as scripts/install.sh +# CONFIGURATION (via environment variable): +# - Make sure $RTE_TARGET and $RTE_SDK are correct (see install docs) +# - Set $ONVM_NUM_HUGEPAGES to control the number of pages created +# - Set $ONVM_SKIP_FSTAB to not add huge fs to /etc/fstab + +#Print a table with enviromental variable locations +echo "----------------------------------------" +echo "ONVM Environment Variables:" +echo "----------------------------------------" +echo "RTE_SDK: $RTE_SDK" +echo "RTE_TARGET: $RTE_TARGET" +echo "ONVM_NUM_HUGEPAGES: $ONVM_NUM_HUGEPAGES" +echo "ONVM_SKIP_HUGEPAGES: $ONVM_SKIP_HUGEPAGES" +echo "ONVM_SKIP_FSTAB: $ONVM_SKIP_FSTAB" +echo "----------------------------------------" + +if [ -z "$RTE_TARGET" ]; then + echo "Please export \$RTE_TARGET. Or try running this without sudo." + exit 1 +fi + +if [ -z "$RTE_SDK" ]; then + echo "Please export \$RTE_SDK" + exit 1 +fi + +# Validate sudo access +sudo -v + +# Ensure we're working relative to the onvm root directory +if [ "$(basename "$(pwd)")" == "scripts" ]; then + cd .. +fi + +# Set state variables +start_dir=$(pwd) + +if [ -z "$ONVM_HOME" ]; then + echo "Please export \$ONVM_HOME and set it to $start_dir" + exit 1 +fi + +# Source DPDK helper functions +. "$ONVM_HOME"/scripts/dpdk_helper_scripts.sh + +set +e +remove_igb_uio_module +set -e + +# Compile dpdk +cd "$RTE_SDK" +echo "Compiling and installing dpdk in $RTE_SDK" + +# Adding ldflags.txt output for mTCP compatibility +if grep "ldflags.txt" "$RTE_SDK"/mk/rte.app.mk > /dev/null +then + : +else + # want to use single quotes for sed operation + # shellcheck disable=SC2016 + sed -i -e 's/O_TO_EXE_STR =/\$(shell if [ \! -d \${RTE_SDK}\/\${RTE_TARGET}\/lib ]\; then mkdir -p \${RTE_SDK}\/\${RTE_TARGET}\/lib\; fi)\nLINKER_FLAGS = \$(call linkerprefix,\$(LDLIBS))\n\$(shell echo \${LINKER_FLAGS} \> \${RTE_SDK}\/\${RTE_TARGET}\/lib\/ldflags\.txt)\nO_TO_EXE_STR =/g' "$RTE_SDK"/mk/rte.app.mk +fi + +sed -i 's/CONFIG_RTE_EAL_IGB_UIO=n/CONFIG_RTE_EAL_IGB_UIO=y/g' "$RTE_SDK"/config/common_base + +sleep 1 +make config T="$RTE_TARGET" +make T="$RTE_TARGET" -j 8 +make install T="$RTE_TARGET" -j 8 + +# Refresh sudo +sudo -v + +cd "$start_dir" + +# Setup/Check for free HugePages if the user wants to +if [ -z "$ONVM_SKIP_HUGEPAGES" ]; then + set_numa_pages +fi + +grep -m 1 "huge" /etc/fstab | cat +# Only add to /etc/fstab if user wants it +if [ "${PIPESTATUS[0]}" != 0 ] && [ -z "$ONVM_SKIP_FSTAB" ]; then + echo "Adding huge fs to /etc/fstab" + sleep 1 + sudo sh -c "echo \"huge /mnt/huge hugetlbfs defaults 0 0\" >> /etc/fstab" +fi + +# Configure local environment +echo "Configuring environment" +sleep 1 +scripts/setup_environment.sh + +echo "ONVM INSTALL COMPLETED SUCCESSFULLY" + diff --git a/scripts/setup_cloudlab.sh b/scripts/setup_cloudlab.sh deleted file mode 100755 index 13fa79618..000000000 --- a/scripts/setup_cloudlab.sh +++ /dev/null @@ -1,56 +0,0 @@ -#! /bin/bash - -# openNetVM -# https://sdnfv.github.io -# -# OpenNetVM is distributed under the following 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. -# -# A script to configure dpdk environment variables on the cloudlab server - -ONVM_PATH=/local/onvm/openNetVM -DPDK_PATH=/local/onvm/openNetVM/dpdk - -if [ -z "$RTE_TARGET" ]; then - export RTE_TARGET=x86_64-native-linuxapp-gcc -fi - -if [ -z "$RTE_SDK" ]; then - export RTE_SDK=$DPDK_PATH -fi - -if [ -z "$ONVM_HOME" ]; then - export ONVM_HOME=$ONVM_PATH -fi - -bash "$ONVM_HOME"/scripts/setup_environment.sh diff --git a/scripts/setup_runtime.sh b/scripts/setup_runtime.sh new file mode 100755 index 000000000..9fe7565fd --- /dev/null +++ b/scripts/setup_runtime.sh @@ -0,0 +1,106 @@ +#! /bin/bash + +# openNetVM +# https://sdnfv.github.io +# +# OpenNetVM is distributed under the following BSD LICENSE: +# +# Copyright(c) +# 2015-2024 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. +# +# Sets configuration items on the host system required to run openNetVM + +arg_hugepages=true + +# Basic check to make sure this script is running in the correct working +# directory. +if [ "$(basename "$(pwd)")" != "openNetVM" ]; then + echo "Please run the installation script from the parent openNetVM directory" +fi + +# Parse the passed arguments, and set the appropriate flags if a +# particular argument is detected +for arg in "$@" +do + if [[ $arg == "--nohugepages" ]]; then + arg_hugepages=false + break + fi +done + +# Check sudo privileges +sudo -v + + +# (1) +# Disable address space layout randomization (ASLR) +echo "- Disabling ASLR" +sudo sh -c "echo 0 > /proc/sys/kernel/randomize_va_space" + + +# (2) +# Disable hyperthreading +echo "- Disabling hyperthreading" + +CPUS_TO_SKIP=" $(cat /sys/devices/system/cpu/cpu*/topology/thread_siblings_list | sed 's/[^0-9].*//' | sort | uniq | tr "\r\n" " ") " +for CPU_PATH in /sys/devices/system/cpu/cpu[0-9]*; do + CPU="$(echo "$CPU_PATH" | tr -cd "0-9")" + echo "$CPUS_TO_SKIP" | grep " $CPU " > /dev/null + if [ $? -ne 0 ]; then + echo 0 > "$CPU_PATH"/online + fi +done + +lscpu | grep -i -E "^CPU\(s\):|core|socket" + + +# (3) +# Load the uio kernel module from dpdk-kmods +grep -m 1 "igb_uio" /proc/modules | cat +if [ "${PIPESTATUS[0]}" != 0 ]; then + echo "- Loading uio kernel module" + sudo modprobe uio + sudo insmod ./subprojects/dpdk-kmods/linux/igb_uio/igb_uio.ko +else + echo "- uio kernel module already loaded" +fi + + +# (4) +# Setup hugepages. +# This will be skipped if --nohugepages is passed in. +if [ "$arg_hugepages" = true ]; then + echo "- Configuring hugepages" + . ./scripts/dpdk_helper_scripts.sh + set_numa_pages "$hp_count" +else + echo "- Skipping hugepages" +fi \ No newline at end of file diff --git a/scripts/start.sh b/scripts/start.sh new file mode 100755 index 000000000..c7c724899 --- /dev/null +++ b/scripts/start.sh @@ -0,0 +1,282 @@ +#!/bin/bash + +function usage { + echo "$0 -k PORTMASK -n NF-COREMASK [-m MANAGER CORES] [-r NUM-SERVICES] [-d DEFAULT-SERVICE] [-s STATS-OUTPUT] [-p WEB-PORT-NUMBER] [-z STATS-SLEEP-TIME]" + # this works well on our 2x6-core nodes + echo "$0 -k 3 -n 0xF0 --> cores 0,1,2, with ports 0 and 1, with NFs running on cores 4,5,6,7" + echo -e "\tBy default, cores will be used as follows in numerical order:" + echo -e "\t\tRX thread, TX thread, ..., TX thread for last NF, Stats thread" + echo -e "$0 -k 3 -n 0xF0 -m 2,3,4" + echo -e "\tRuns ONVM the same way as above, but manually configures cores 2, 3 and 4 to be used as stated" + echo -e "$0 -k 3 -n 0xF0 -m 2,3,4 -s web" + echo -e "\tRuns ONVM the same way as above, but prints statistics to the web browser" + echo -e "$0 -k 3 -n 0xF0 -m 2,3,4 -s web -p 9000" + echo -e "\tRuns OVNM the same as above, but runs the web stats on port 9000 instead of defaulting to 8080" + echo -e "$0 -k 3 -n 0xF0 -m 2,3,4 -s stdout" + echo -e "\tRuns ONVM the same way as above, but prints statistics to stdout" + echo -e "$0 -k 3 -n 0xF0 -m 2,3,4 -s stdout -c" + echo -e "\tRuns ONVM the same way as above, but enables shared cpu support" + echo -e "$0 -k 3 -n 0xF0 -m 2,3,4 -s stdout -c -j" + echo -e "\tRuns ONVM the same way as above, but allows ports to send and receive jumbo frames" + echo -e "$0 -k 3 -n 0xF0 -m 2,3,4 -s stdout -t 42" + echo -e "\tRuns ONVM the same way as above, but shuts down after 42 seconds" + echo -e "$0 -k 3 -n 0xF0 -m 2,3,4 -s stdout -l 64" + echo -e "\tRuns ONVM the same way as above, but shuts down after receiving 64 million packets" + echo -e "$0 -k 3 -n 0xF0 -m 2,3,4 -s stdout -v" + echo -e "\tRuns ONVM the same way as above, but prints statistics to stdout in extra verbose mode" + echo -e "$0 -k 3 -n 0xF0 -m 2,3,4 -s stdout -vv" + echo -e "\tRuns ONVM the same way as above, but prints statistics to stdout in raw data dump mode" + echo -e "$0 -k 3 -n 0xF0 -m 2,3,4 -a 0x7f000000000 -s stdout" + echo -e "\tRuns ONVM the same way as above, but adds a --base-virtaddr dpdk parameter to overwrite default address" + echo -e "$0 -k 3 -n 0xF0 -m 2,3,4 -r 10 -d 2" + echo -e "\tRuns ONVM the same way as above, but limits max service IDs to 10 and uses service ID 2 as the default" + exit 1 +} + +# User can still use legacy syntax for backwards compatibility. Check syntax of input +# Check validity of core input +core_check="^([0-8]+,){2}([0-8]+)(,[0-8]+)*$" +port_check="^[0-9]+$" +nf_check="^0x[0-9A-F]+$" +flag_check="^-[a-z]$" +# Check for argument matches +[[ $1 =~ $core_check ]] +if [[ -n ${BASH_REMATCH[0]} ]] +then + core_match=true +else + core_match=false +fi +[[ $2 =~ $port_check ]] +if [[ -n ${BASH_REMATCH[0]} ]] +then + port_match=true +else + port_match=false +fi +[[ $3 =~ $nf_check ]] +if [[ -n ${BASH_REMATCH[0]} ]] +then + nf_match=true +else + nf_match=false +fi + +# Make sure someone isn't inputting the cores incorrectly and they are using legacy syntax +# The flag regex check ensures that the user is trying to input a flag, which is an indicator that they are using the new syntax +if [[ ! $1 =~ $flag_check ]] && (! $core_match || ! $port_match || ! $nf_match) +then + if ( ! $core_match && ( $port_match || $nf_match )) + then + # This verifies that the user actually tried to input the cores but did so incorrectly + echo "Error: Invalid Manager Cores. Proper syntax: $0 [OPTIONS]" + echo "Example: $0 0,1,2 1 0xF8 -s stdout" + exit 1 + elif ( ! $port_match && ( $core_match || $nf_match )) + then + # This verifies that the user actually tried to input the port mask but did so incorrectly + echo "Error: Invalid Port Mask. Proper syntax: $0 [OPTIONS]" + echo "Example: $0 0,1,2 1 0xF8 -s stdout" + exit 1 + elif ( ! $nf_match && ($core_match || $port_match )) + then + # This verifies that the user actually tried to input the NF core mask but did so incorrectly + echo "Error: Invalid NF Core Mask. Proper syntax: $0 [OPTIONS]" + echo "Example: $0 0,1,2 1 0xF8 -s stdout" + exit 1 + # We should never get here, but just a catch-all situation + else + echo "Error: Invalid input." + echo "" + usage + fi +elif $core_match && $port_match && $nf_match +then + script_name=$0 + cpu=$1 + ports=$2 + nf_cores=$3 + shift 3 +fi + +SCRIPT=$(readlink -f "$0") +SCRIPTPATH=$(dirname "$SCRIPT") +verbosity=1 +# Initialize base virtual address to empty. +virt_addr="" + +# only check for duplicate manager if not in Docker container +if [[ -n $(pgrep -u root -f "/onvm_mgr/.*/onvm_mgr") ]] && ! grep -q "docker" /proc/1/cgroup +then + echo "Manager cannot be started while another is running" + exit 1 +fi + +while getopts "a:r:d:s:t:l:p:z:cvm:k:n:j" opt; do + case $opt in + a) virt_addr="--base-virtaddr=$OPTARG";; + r) num_srvc="-r $OPTARG";; + d) def_srvc="-d $OPTARG";; + s) stats="-s $OPTARG";; + t) ttl="-t $OPTARG";; + l) packet_limit="-l $OPTARG";; + p) web_port="$OPTARG";; + z) stats_sleep_time="-z $OPTARG";; + c) shared_cpu_flag="-c";; + v) verbosity=$((verbosity+1));; + m) + # User is trying to set CPU cores but has already done so using legacy syntax + if [[ -n $cpu ]] + then + echo "Error: Cannot use manual manager core flag with legacy syntax. Proper syntax: $script_name [OPTIONS]" + echo "Example: $script_name 0,1,2 1 0xF8 -s stdout" + exit 1 + else + cpu=$OPTARG + fi;; + k) + # User is trying to set port mask but has already done so using legacy syntax + if [[ -n $ports ]] + then + echo "Error: Cannot use manual port mask flag with legacy syntax. Proper syntax: $script_name [OPTIONS]" + echo "Example: $script_name 0,1,2 1 0xF8 -s stdout" + exit 1 + else + ports=$OPTARG + fi;; + n) + # User is trying to set NF core mask but has already done so using legacy syntax + if [[ -n $nf_cores ]] + then + echo "Error: Cannot use manual NF core mask flag with legacy syntax. Proper syntax: $script_name [OPTIONS]" + echo "Example: $script_name 0,1,2 1 0xF8 -s stdout" + exit 1 + else + nf_cores=$OPTARG + fi;; + j) jumbo_frames_flag="-j";; + \?) echo "Unknown option -$OPTARG" && usage + ;; + esac +done + +# Verify that dependency bc is installed +if [[ -z $(command -v bc) ]] +then + echo "Error: bc is not installed. Install using:" + echo " sudo apt-get install bc" + echo "See dependencies for more information" + exit 1 +fi + +# Check for ports flag +if [ -z "$ports" ] +then + echo "Error: Port Mask not set. openNetVM requires that a Port Mask be set using -k using a hexadecimal number (without 0x)" + echo "" + usage +# Check port mask +elif [[ ! $ports =~ $port_check ]] +then + echo "Error: Invalid port mask. Check input and try again." + echo "" + usage +fi + +# Check for nf_cores flag +if [ -z "$nf_cores" ] +then + echo "Error: NF Core Mask not set. openNetVM requires that a NF Core Mask be set using -n using a hexadecimal number (starting with 0x)" + echo "" + usage +# Check NF core mask +elif [[ ! $nf_cores =~ $nf_check ]] +then + echo "Error: Invalid NF core mask. Check input and try again." + echo "" + usage +fi + +# Check for CPU core flag +if [ -z "$cpu" ] +then + echo "INFO: Using default CPU cores 0,1,2" + echo "" + cpu="0,1,2" +# Check CPU cores +elif [[ ! $cpu =~ $core_check ]] +then + echo "Error: Invalid CPU cores. openNetVM accepts 3 or more cores. Check input and try again." + echo "" + usage +fi + +if [ -z "$nf_cores" ] +then + usage +fi + +# Convert the port mask to binary +# Using bc where obase=2 indicates the output is base 2 and ibase=16 indicates the input is base 16 +ports_bin=$(echo "obase=2; ibase=16; $ports" | bc) +# Splice out the 0's from the binary numbers. The result is only 1's. Example: 1011001 -> 1111 +ports_bin="${ports_bin//0/}" +# The number of ports is the length of the string of 1's. Using above example: 1111 -> 4 +count_ports="${#ports_bin}" + +ports_detected=$(subprojects/dpdk/usertools/dpdk-devbind.py --status-dev net | sed '/Network devices using kernel driver/q' | grep -c "drv") +if [[ $ports_detected -lt $count_ports ]] +then + echo "Error: Invalid port mask. Insufficient NICs bound." + exit 1 +fi + +# Trim 0x from NF mask +nf_cores_trimmed=${nf_cores:2} +# Convert nf_cores to compare to cpu +nf_cores_trimmed=$(echo "obase=10; ibase=16; $nf_cores_trimmed" | bc) +# Convert cpu to separate +cpu_separated=$(echo $cpu | tr "," "\n") +for core in $cpu_separated +do + if (( nf_cores_trimmed & (1 << (core)) )) + then + echo "WARNING: Manager and NF cores overlap." + echo "" + break + fi +done + +verbosity_level="-v $verbosity" + +# If base virtual address has not been set by the user, set to default. +if [[ -z $virt_addr ]] +then + echo "Base virtual address set to default 0x7f000000000" + virt_addr="--base-virtaddr=0x7f000000000" +fi + +if [ "${stats}" = "-s web" ] +then + cd "$ONVM_HOME"/onvm_web/ || usage + if [ -n "${web_port}" ] + then + . start_web_console.sh -p "${web_port}" + else + . start_web_console.sh + fi + + cd "$ONVM_HOME"/onvm || usage +fi + +sudo rm -rf /mnt/huge/rtemap_* +# watch out for variable expansion +# shellcheck disable=SC2086 +sudo ./bin/onvm_mgr -l "$cpu" -n 4 --proc-type=primary ${virt_addr} -- -p ${ports} -n ${nf_cores} ${num_srvc} ${def_srvc} ${stats} ${stats_sleep_time} ${verbosity_level} ${ttl} ${packet_limit} ${shared_cpu_flag} ${jumbo_frames_flag} + +if [ "${stats}" = "-s web" ] +then + echo "Killing web stats running with PIDs: $ONVM_WEB_PID, $ONVM_WEB_PID2" + kill "$ONVM_WEB_PID" + kill "$ONVM_WEB_PID2" +fi diff --git a/subprojects/dpdk b/subprojects/dpdk new file mode 160000 index 000000000..80ecef6d1 --- /dev/null +++ b/subprojects/dpdk @@ -0,0 +1 @@ +Subproject commit 80ecef6d1f71fcebc0a51d7cabc51f73ee142ff2 diff --git a/subprojects/dpdk-kmods b/subprojects/dpdk-kmods new file mode 160000 index 000000000..e721c733c --- /dev/null +++ b/subprojects/dpdk-kmods @@ -0,0 +1 @@ +Subproject commit e721c733cd24206399bebb8f0751b0387c4c1595