Skip to content

Commit

Permalink
[UPDATE] Command-Line Argument Debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
jett committed Oct 29, 2021
1 parent 50a5524 commit ffe76d7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion examples/skeleton/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ OR
OR
sudo ./build/skeleton -l CORELIST -n 3 --proc-type=secondary -- -r SERVICE_ID -- [-p PRINT_DELAY]
sudo ./build/skeleton -l CORELIST -n 3 --proc-type=secondary -- -r SERVICE_ID -- [-p TIME_PRINT_DELAY | -v PACKET_PRINT_DELAY]
```

App Specific Arguments
Expand Down
19 changes: 17 additions & 2 deletions examples/skeleton/skeleton.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,26 @@ parse_app_args(int argc, char *argv[], const char *progname, struct skeleton_sta
switch (c) {
case 'p':
skeleton_data->delay = strtoul(optarg, NULL, 10);
if (skeleton_data->delay < 1) {
RTE_LOG(INFO, APP, "Option -%c requires an argument.\n", optopt);
return -1;
}
skeleton_data->displayType = 0; // displayType 0 = Time-Based Delays
break;
return optind;
case 'v':
skeleton_data->delay = strtoul(optarg, NULL, 10);
if (skeleton_data->delay < 1) {
RTE_LOG(INFO, APP, "Option -%c requires an argument.\n", optopt);
return -1;
}
skeleton_data->displayType = 1; // displayType 1 = Packet-Based Delays
break;
return optind;
case '?':
usage(progname);
if (optopt == 'p')
RTE_LOG(INFO, APP, "Option -%c requires an argument.\n", optopt);
else if (optopt == 'v')
RTE_LOG(INFO, APP, "Option -%c requires an argument.\n", optopt);
else if (isprint(optopt))
RTE_LOG(INFO, APP, "Unknown option `-%c'.\n", optopt);
else
Expand Down Expand Up @@ -206,7 +216,9 @@ action(struct onvm_nf_local_ctx *nf_local_ctx){
__uint64_t delay = skeleton_data->delay;
__uint64_t current_time = skeleton_data->current_time;
if ((time%delay == 0) && (time != current_time)) {
skeleton_data->current_time = time;
do_stats_display(skeleton_data);
return 0;
}
}

Expand All @@ -230,6 +242,9 @@ setup(struct onvm_nf_local_ctx *nf_local_ctx){
skeleton_data->start_time = rte_get_tsc_cycles();
skeleton_data->current_time = 0;
skeleton_data->packets_processed = 0;
if (skeleton_data->displayType > -1) {
do_stats_display(skeleton_data);
}
}

/*
Expand Down

0 comments on commit ffe76d7

Please sign in to comment.