diff options
author | Deepak S <deepak.s@linux.intel.com> | 2017-10-16 18:03:51 -0700 |
---|---|---|
committer | Deepak S <deepak.s@linux.intel.com> | 2017-10-16 18:03:51 -0700 |
commit | 2a738a1538bec699534c17d1801bd33f20dafda6 (patch) | |
tree | d6f23c023e43c1843e8501dc6204d88eef688b39 | |
parent | 039ac41531956a733ed96f7c715ed072e724e0df (diff) |
Adding app version display
Change-Id: I366d915a05f58c5653de89c1c59ebd180904e080
Signed-off-by: Deepak S <deepak.s@linux.intel.com>
-rw-r--r-- | VNFs/UDP_Replay/main.c | 26 | ||||
-rw-r--r-- | common/vnf_common/config_parse.c | 21 | ||||
-rw-r--r-- | common/vnf_common/version.h | 35 |
3 files changed, 72 insertions, 10 deletions
diff --git a/VNFs/UDP_Replay/main.c b/VNFs/UDP_Replay/main.c index 2830aa41..2e1638e4 100644 --- a/VNFs/UDP_Replay/main.c +++ b/VNFs/UDP_Replay/main.c @@ -88,6 +88,7 @@ performance of the solution should be sufficient for testing the UDP NAT perform #include <lib_arp.h> #include "l2_proto.h" #include "interface.h" +#include "version.h" #include "l3fwd_common.h" #include "l3fwd_lpm4.h" #include "l3fwd_lpm6.h" @@ -2121,6 +2122,7 @@ print_usage(const char *prgname) " [--enable-jumbo [--max-pkt-len PKTLEN]]\n" " -p PORTMASK: hexadecimal bitmask of ports to configure\n" " -P : enable promiscuous mode\n" + " -v version: display app version\n" " --config (port,queue,lcore): rx queues configuration\n" " --eth-dest=X,MM:MM:MM:MM:MM:MM: optional, ethernet destination for port X\n" " --no-numa: optional, disable numa awareness\n" @@ -2294,6 +2296,7 @@ parse_eth_dest(const char *optarg) #define CMD_LINE_OPT_NO_HW_CSUM "no-hw-csum" #define CMD_LINE_OPT_IPV6 "ipv6" #define CMD_LINE_OPT_ENABLE_JUMBO "enable-jumbo" +#define CMD_LINE_OPT_VERSION "version" #define CMD_LINE_OPT_HASH_ENTRY_NUM "hash-entry-num" /* Parse the argument given in the command line of the application */ @@ -2302,7 +2305,7 @@ parse_args(int argc, char **argv) { int opt, ret; char **argvopt; - int option_index; + int option_index, v_present = 0; char *prgname = argv[0]; static struct option lgopts[] = { {CMD_LINE_OPT_CONFIG, 1, 0, 0}, @@ -2311,13 +2314,14 @@ parse_args(int argc, char **argv) {CMD_LINE_OPT_NO_HW_CSUM, 0, 0, 0}, {CMD_LINE_OPT_IPV6, 0, 0, 0}, {CMD_LINE_OPT_ENABLE_JUMBO, 0, 0, 0}, + {CMD_LINE_OPT_VERSION, 0, 0, 0}, {CMD_LINE_OPT_HASH_ENTRY_NUM, 1, 0, 0}, {NULL, 0, 0, 0} }; argvopt = argv; - while ((opt = getopt_long(argc, argvopt, "s:p:P", + while ((opt = getopt_long(argc, argvopt, "v:s:p:P", lgopts, &option_index)) != EOF) { switch (opt) { @@ -2378,6 +2382,15 @@ parse_args(int argc, char **argv) } #endif + if (!strncmp(lgopts[option_index].name, CMD_LINE_OPT_VERSION, + sizeof (CMD_LINE_OPT_VERSION))) { + if (v_present) + rte_panic("Error: VERSION is provided more than once\n"); + v_present = 1; + printf("Version: %s\n", VERSION_STR); + exit(0); + } + if (!strncmp(lgopts[option_index].name, CMD_LINE_OPT_ENABLE_JUMBO, sizeof (CMD_LINE_OPT_ENABLE_JUMBO))) { struct option lenopts = {"max-pkt-len", required_argument, 0, 0}; @@ -2745,6 +2758,11 @@ main(int argc, char **argv) uint32_t size; struct pipeline_params *params; + /* parse application arguments (after the EAL ones) */ + ret = parse_args(argc, argv); + if (ret < 0) + rte_exit(EXIT_FAILURE, "Invalid UDP_Replay parameters\n"); + /* init EAL */ ret = rte_eal_init(argc, argv); if (ret < 0) @@ -2752,10 +2770,6 @@ main(int argc, char **argv) argc -= ret; argv += ret; timer_lcore = rte_lcore_id(); - /* parse application arguments (after the EAL ones) */ - ret = parse_args(argc, argv); - if (ret < 0) - rte_exit(EXIT_FAILURE, "Invalid UDP_Replay parameters\n"); if (check_lcore_params() < 0) rte_exit(EXIT_FAILURE, "check_lcore_params failed\n"); diff --git a/common/vnf_common/config_parse.c b/common/vnf_common/config_parse.c index eeb547e6..48921f46 100644 --- a/common/vnf_common/config_parse.c +++ b/common/vnf_common/config_parse.c @@ -30,6 +30,7 @@ #include <rte_string_fns.h> #include "app.h" +#include "version.h" #include "parser.h" /** @@ -201,8 +202,8 @@ struct app_pipeline_params default_pipeline_params = { }; static const char app_usage[] = - "Usage: %s [-f CONFIG_FILE] [-s SCRIPT_FILE] [-p PORT_MASK] " - "[-l LOG_LEVEL] [--preproc PREPROCESSOR] [--preproc-args ARGS]\n" + "Usage: %s [--version] [-f CONFIG_FILE] [-s SCRIPT_FILE] [-p PORT_MASK] " + "[-l LOG_LEVEL] [--disable-hw-csum] [--preproc PREPROCESSOR] [--preproc-args ARGS]\n" "\n" "Arguments:\n" "\t-f CONFIG_FILE: Default config file is %s\n" @@ -210,6 +211,7 @@ static const char app_usage[] = "config file when not provided)\n" "\t-s SCRIPT_FILE: No CLI script file is run when not specified\n" "\t-l LOG_LEVEL: 0 = NONE, 1 = HIGH PRIO (default), 2 = LOW PRIO\n" + "\t--version application version\n" "\t--disable-hw-csum Disable TCP/UDP HW checksum\n" "\t--preproc PREPROCESSOR: Configuration file pre-processor\n" "\t--preproc-args ARGS: Arguments to be passed to pre-processor\n" @@ -3231,7 +3233,7 @@ app_config_args(struct app_params *app, int argc, char **argv) { const char *optname; int opt, option_index; - int f_present, s_present, p_present, l_present; + int f_present, s_present, p_present, l_present, v_present; int preproc_present, preproc_params_present, disable_csum_present; int hwlb_present; int flow_dir_present; @@ -3243,6 +3245,7 @@ app_config_args(struct app_params *app, int argc, char **argv) { "preproc-args", 1, 0, 0 }, { "hwlb", 1, 0, 0 }, { "flow_dir", 0, 0, 0 }, + { "version", 0, 0, 0 }, { NULL, 0, 0, 0 } }; @@ -3252,6 +3255,7 @@ app_config_args(struct app_params *app, int argc, char **argv) f_present = 0; s_present = 0; p_present = 0; + v_present = 0; l_present = 0; disable_csum_present = 0; preproc_present = 0; @@ -3261,7 +3265,7 @@ app_config_args(struct app_params *app, int argc, char **argv) flow_dir_present = 0; - while ((opt = getopt_long(argc, argv, "f:s:p:l:", lgopts, + while ((opt = getopt_long(argc, argv, "f:v:s:p:l:", lgopts, &option_index)) != EOF) switch (opt) { case 'f': @@ -3332,6 +3336,15 @@ app_config_args(struct app_params *app, int argc, char **argv) case 0: optname = lgopts[option_index].name; + if (strcmp(optname, "version") == 0) { + if (v_present) + rte_panic("Error: VERSION is provided " + "more than once\n"); + v_present = 1; + printf("Version: %s\n", VERSION_STR); + exit(0); + } + if (strcmp(optname, "hwlb") == 0) { if (hwlb_present) rte_panic("Error: hwlb argument " diff --git a/common/vnf_common/version.h b/common/vnf_common/version.h new file mode 100644 index 00000000..00d8f458 --- /dev/null +++ b/common/vnf_common/version.h @@ -0,0 +1,35 @@ +/* +// Copyright (c) 2017 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +*/ + +#ifndef __INCLUDE_VER_H__ +#define __INCLUDE_VER_H__ + +#define STRINGIFY(s) #s +#define SSTR(s) STRINGIFY(s) + +/* PROGRAM_NAME defined through Makefile */ +#define VERSION_MAJOR 0 +#define VERSION_MINOR 39 +#define VERSION_REV 0 + +#if VERSION_REV > 0 +#define VERSION_STR "v" SSTR(VERSION_MAJOR) "." SSTR(VERSION_MINOR) "." SSTR(VERSION_REV) +#else +#define VERSION_STR "v" SSTR(VERSION_MAJOR) "." SSTR(VERSION_MINOR) +#endif + + +#endif |