Skip to content

Commit

Permalink
Refactored, cleaned up, and changed API (147)
Browse files Browse the repository at this point in the history
Refactoring to improve code organization

A big set of commits to clean the structure and simplify onvm source
code.

We separated all functions into the main.c of the manager into modules :
 - `onvm_stats` : functions displaying statistics
 - `onvm_pkt` : functions related to packet processing
 - `onvm_nf` : functions related to NFs management.

Each module comes with a header file with commented prototypes. And each
c and h file has been "cut" into parts :
 - interfaces, or functions called outside of the module
 - internal functions, the functions called only inside the module and
   doing all the work
 - helper functions, simple and short functions used many times through
   the module.

**API Changes:**
 - NFs now need to call functions like `onvm_nflib_*` instead of
   `onvm_nf_*`.  For example, `onvm_nflib_init` instead of
`onvm_nf_init`.  The example NFs have all been updated accordingly.
 - NF `Makefiles` need to be updated to find the path to `onvm_nflib`.
  • Loading branch information
Adam Shimi authored and nks5295 committed Aug 26, 2016
1 parent 75e0323 commit 75693ea
Show file tree
Hide file tree
Showing 33 changed files with 2,221 additions and 1,090 deletions.
21 changes: 21 additions & 0 deletions docs/Releases.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
## Release Notes

#### 8/25/16: Refactoring to improve code organization
A big set of commits to clean the structure and simplify onvm source code.
We separated all functions into the main.c of the manager into modules :
- `onvm_stats` : functions displaying statistics
- `onvm_pkt` : functions related to packet processing
- `onvm_nf` : functions related to NFs management.

Each module comes with a header file with commented prototypes. And each c and h file has been "cut" into parts :
- interfaces, or functions called outside of the module
- internal functions, the functions called only inside the module and doing all the work
- helper functions, simple and short functions used many times through the module.

**API Changes:**
- NFs now need to call functions like `onvm_nflib_*` instead of `onvm_nf_*`. For example, `onvm_nflib_init` instead of `onvm_nf_init`. The example NFs have all been updated accordingly.
- NF `Makefiles` need to be updated to find the path to `onvm_nflib`.


#### 4/24/16: Initial Release
Initial source code release.
4 changes: 2 additions & 2 deletions examples/basic_monitor/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ ONVM= $(SRCDIR)/../../onvm

CFLAGS += $(WERROR_FLAGS) -O3

CFLAGS += -I$(ONVM)/onvm_nf
CFLAGS += -I$(ONVM)/onvm_nflib
CFLAGS += -I$(ONVM)/shared
LDFLAGS += $(ONVM)/onvm_nf/onvm_nf/$(RTE_TARGET)/onvm_nflib.o
LDFLAGS += $(ONVM)/onvm_nflib/onvm_nflib/$(RTE_TARGET)/onvm_nflib.o
LDFLAGS += $(ONVM)/shared/shared/$(RTE_TARGET)/onvm_pkt_helper.o
LDFLAGS += $(ONVM)/shared/shared/$(RTE_TARGET)/onvm_sc_common.o

Expand Down
4 changes: 2 additions & 2 deletions examples/basic_monitor/monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,15 +159,15 @@ int main(int argc, char *argv[]) {

const char *progname = argv[0];

if ((arg_offset = onvm_nf_init(argc, argv, NF_TAG)) < 0)
if ((arg_offset = onvm_nflib_init(argc, argv, NF_TAG)) < 0)
return -1;
argc -= arg_offset;
argv += arg_offset;

if (parse_app_args(argc, argv, progname) < 0)
rte_exit(EXIT_FAILURE, "Invalid command-line arguments\n");

onvm_nf_run(nf_info, &packet_handler);
onvm_nflib_run(nf_info, &packet_handler);
printf("If we reach here, program is ending");
return 0;
}
4 changes: 2 additions & 2 deletions examples/bridge/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ ONVM= $(SRCDIR)/../../onvm

CFLAGS += $(WERROR_FLAGS) -O3 $(USER_FLAGS)

CFLAGS += -I$(ONVM)/onvm_nf
CFLAGS += -I$(ONVM)/onvm_nflib
CFLAGS += -I$(ONVM)/shared
LDFLAGS += $(ONVM)/onvm_nf/onvm_nf/$(RTE_TARGET)/onvm_nflib.o
LDFLAGS += $(ONVM)/onvm_nflib/onvm_nflib/$(RTE_TARGET)/onvm_nflib.o
LDFLAGS += $(ONVM)/shared/shared/$(RTE_TARGET)/onvm_pkt_helper.o
LDFLAGS += $(ONVM)/shared/shared/$(RTE_TARGET)/onvm_sc_common.o

Expand Down
4 changes: 2 additions & 2 deletions examples/bridge/bridge.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,15 +162,15 @@ int main(int argc, char *argv[]) {

const char *progname = argv[0];

if ((arg_offset = onvm_nf_init(argc, argv, NF_TAG)) < 0)
if ((arg_offset = onvm_nflib_init(argc, argv, NF_TAG)) < 0)
return -1;
argc -= arg_offset;
argv += arg_offset;

if (parse_app_args(argc, argv, progname) < 0)
rte_exit(EXIT_FAILURE, "Invalid command-line arguments\n");

onvm_nf_run(nf_info, &packet_handler);
onvm_nflib_run(nf_info, &packet_handler);
printf("If we reach here, program is ending");
return 0;
}
4 changes: 2 additions & 2 deletions examples/flow_table/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ ONVM ?= $(SRCDIR)/../../onvm

CFLAGS += $(WERROR_FLAGS) -O3 $(USER_FLAGS)

CFLAGS += -I$(ONVM)/onvm_nf
CFLAGS += -I$(ONVM)/onvm_nflib
CFLAGS += -I$(ONVM)/shared
LDFLAGS += $(ONVM)/onvm_nf/onvm_nf/x86_64-native-linuxapp-gcc/onvm_nflib.o
LDFLAGS += $(ONVM)/onvm_nflib/onvm_nflib/x86_64-native-linuxapp-gcc/onvm_nflib.o
LDFLAGS += $(ONVM)/shared/shared/x86_64-native-linuxapp-gcc/onvm_pkt_helper.o
LDFLAGS += $(ONVM)/shared/shared/x86_64-native-linuxapp-gcc/onvm_sc_common.o
LDFLAGS += $(ONVM)/shared/shared/x86_64-native-linuxapp-gcc/onvm_flow_table.o
Expand Down
4 changes: 2 additions & 2 deletions examples/flow_table/flow_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ int main(int argc, char *argv[]) {
int retval;
unsigned sdn_core = 0;

if ((retval = onvm_nf_init(argc, argv, NF_TAG)) < 0)
if ((retval = onvm_nflib_init(argc, argv, NF_TAG)) < 0)
return -1;
argc -= retval;
argv += retval;
Expand All @@ -271,7 +271,7 @@ int main(int argc, char *argv[]) {
/* Map sdn_ft table */
onvm_flow_dir_nf_init();
printf("Starting packet handler.\n");
onvm_nf_run(nf_info, &packet_handler);
onvm_nflib_run(nf_info, &packet_handler);
printf("NF exiting...");
cleanup();
return 0;
Expand Down
2 changes: 1 addition & 1 deletion examples/flow_table/sdn_pkt_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ sdn_pkt_list_flush(struct sdn_pkt_list* list) {
meta = onvm_get_pkt_meta(pkt);
meta->action = ONVM_NF_ACTION_NEXT;
meta->chain_index = 0;
onvm_nf_return_pkt(pkt);
onvm_nflib_return_pkt(pkt);
free(entry);
list->counter--;
}
Expand Down
4 changes: 2 additions & 2 deletions examples/simple_forward/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ ONVM= $(SRCDIR)/../../onvm

CFLAGS += $(WERROR_FLAGS) -O3 $(USER_FLAGS)

CFLAGS += -I$(ONVM)/onvm_nf
CFLAGS += -I$(ONVM)/onvm_nflib
CFLAGS += -I$(ONVM)/shared
LDFLAGS += $(ONVM)/onvm_nf/onvm_nf/x86_64-native-linuxapp-gcc/onvm_nflib.o
LDFLAGS += $(ONVM)/onvm_nflib/onvm_nflib/x86_64-native-linuxapp-gcc/onvm_nflib.o
LDFLAGS += $(ONVM)/shared/shared/x86_64-native-linuxapp-gcc/onvm_pkt_helper.o
LDFLAGS += $(ONVM)/shared/shared/$(RTE_TARGET)/onvm_sc_common.o

Expand Down
4 changes: 2 additions & 2 deletions examples/simple_forward/forward.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,15 +168,15 @@ int main(int argc, char *argv[]) {

const char *progname = argv[0];

if ((arg_offset = onvm_nf_init(argc, argv, NF_TAG)) < 0)
if ((arg_offset = onvm_nflib_init(argc, argv, NF_TAG)) < 0)
return -1;
argc -= arg_offset;
argv += arg_offset;

if (parse_app_args(argc, argv, progname) < 0)
rte_exit(EXIT_FAILURE, "Invalid command-line arguments\n");

onvm_nf_run(nf_info, &packet_handler);
onvm_nflib_run(nf_info, &packet_handler);
printf("If we reach here, program is ending");
return 0;
}
4 changes: 2 additions & 2 deletions examples/speed_tester/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ ONVM ?= $(SRCDIR)/../../onvm

CFLAGS += $(WERROR_FLAGS) -O3 $(USER_FLAGS)

CFLAGS += -I$(ONVM)/onvm_nf
CFLAGS += -I$(ONVM)/onvm_nflib
CFLAGS += -I$(ONVM)/shared
LDFLAGS += $(ONVM)/onvm_nf/onvm_nf/$(RTE_TARGET)/onvm_nflib.o
LDFLAGS += $(ONVM)/onvm_nflib/onvm_nflib/$(RTE_TARGET)/onvm_nflib.o
LDFLAGS += $(ONVM)/shared/shared/$(RTE_TARGET)/onvm_pkt_helper.o
LDFLAGS += $(ONVM)/shared/shared/$(RTE_TARGET)/onvm_sc_common.o

Expand Down
6 changes: 3 additions & 3 deletions examples/speed_tester/speed_tester.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ int main(int argc, char *argv[]) {

const char *progname = argv[0];

if ((arg_offset = onvm_nf_init(argc, argv, NF_TAG)) < 0)
if ((arg_offset = onvm_nflib_init(argc, argv, NF_TAG)) < 0)
return -1;
argc -= arg_offset;
argv += arg_offset;
Expand All @@ -204,10 +204,10 @@ int main(int argc, char *argv[]) {
pmeta->action = ONVM_NF_ACTION_TONF;
pkts[i]->port = 3;
pkts[i]->hash.rss = i;
onvm_nf_return_pkt(pkts[i]);
onvm_nflib_return_pkt(pkts[i]);
}

onvm_nf_run(nf_info, &packet_handler);
onvm_nflib_run(nf_info, &packet_handler);
printf("If we reach here, program is ending");
return 0;
}
4 changes: 2 additions & 2 deletions examples/test_flow_dir/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ ONVM= $(SRCDIR)/../../onvm

CFLAGS += $(WERROR_FLAGS) -O3 $(USER_FLAGS)

CFLAGS += -I$(ONVM)/onvm_nf
CFLAGS += -I$(ONVM)/onvm_nflib
CFLAGS += -I$(ONVM)/onvm_mgr
CFLAGS += -I$(ONVM)/shared
LDFLAGS += $(ONVM)/onvm_nf/onvm_nf/x86_64-native-linuxapp-gcc/onvm_nflib.o
LDFLAGS += $(ONVM)/onvm_nflib/onvm_nflib/x86_64-native-linuxapp-gcc/onvm_nflib.o
LDFLAGS += $(ONVM)/shared/shared/x86_64-native-linuxapp-gcc/onvm_pkt_helper.o
LDFLAGS += $(ONVM)/shared/shared/x86_64-native-linuxapp-gcc/onvm_sc_common.o
LDFLAGS += $(ONVM)/shared/shared/x86_64-native-linuxapp-gcc/onvm_sc_mgr.o
Expand Down
4 changes: 2 additions & 2 deletions examples/test_flow_dir/test_flow_dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ int main(int argc, char *argv[]) {

const char *progname = argv[0];

if ((arg_offset = onvm_nf_init(argc, argv, NF_TAG)) < 0)
if ((arg_offset = onvm_nflib_init(argc, argv, NF_TAG)) < 0)
return -1;
argc -= arg_offset;
argv += arg_offset;
Expand All @@ -200,7 +200,7 @@ int main(int argc, char *argv[]) {
/* Map the sdn_ft table */
onvm_flow_dir_nf_init();

onvm_nf_run(nf_info, &packet_handler);
onvm_nflib_run(nf_info, &packet_handler);
printf("If we reach here, program is ending");

return 0;
Expand Down
2 changes: 1 addition & 1 deletion onvm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ include $(RTE_SDK)/mk/rte.vars.mk

DIRS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += shared
DIRS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += onvm_mgr
DIRS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += onvm_nf
DIRS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += onvm_nflib

include $(RTE_SDK)/mk/rte.extsubdir.mk
4 changes: 2 additions & 2 deletions onvm/onvm_mgr/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ endif
APP = onvm_mgr

# all source are stored in SRCS-y
SRCS-y := main.c init.c args.c
SRCS-y := main.c onvm_init.c onvm_args.c onvm_stats.c onvm_pkt.c onvm_nf.c

INC := $(wildcard *.h)
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)/../
Expand Down
Loading

0 comments on commit 75693ea

Please sign in to comment.