FD.io VPP  v16.12-rc0-308-g931be3a
Vector Packet Processing
version.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #include <vlib/vlib.h>
16 #include <vppinfra/cpu.h>
17 #include <app/version.h>
18 
19 #if DPDK > 0
20 #include <rte_version.h>
21 #include <vnet/vnet.h>
22 #include <vnet/devices/dpdk/dpdk.h>
23 #endif /* DPDK */
24 
25 static char *vpe_version_string =
26  "vpp v" VPP_BUILD_VER
27  " built by " VPP_BUILD_USER " on " VPP_BUILD_HOST " at " VPP_BUILD_DATE;
28 
29 static char *vpe_compiler =
30 #if defined(__INTEL_COMPILER)
31 #define __(x) #x
32 #define _(x) __(x)
33  "icc " _(__INTEL_COMPILER) " (" __VERSION__ ")";
34 #undef _
35 #undef __
36 #elif defined(__clang__)
37  "Clang/LLVM " __clang_version__;
38 #elif defined (__GNUC__)
39  "GCC " __VERSION__;
40 #else
41  "unknown compiler";
42 #endif
43 
44 static clib_error_t *
46  unformat_input_t * input,
47  vlib_cli_command_t * cmd)
48 {
49  if (unformat (input, "verbose"))
50  {
51 #define _(a,b,c) vlib_cli_output (vm, "%-25s " b, a ":", c);
52  _("Version", "%s", "v" VPP_BUILD_VER);
53  _("Compiled by", "%s", VPP_BUILD_USER);
54  _("Compile host", "%s", VPP_BUILD_HOST);
55  _("Compile date", "%s", VPP_BUILD_DATE);
56  _("Compile location", "%s", VPP_BUILD_TOPDIR);
57  _("Compiler", "%s", vpe_compiler);
58  _("CPU model name", "%U", format_cpu_model_name);
59  _("CPU microarchitecture", "%U", format_cpu_uarch);
60  _("CPU flags", "%U", format_cpu_flags);
61  _("Current PID", "%d", getpid ());
62 #if DPDK > 0
63  _("DPDK Version", "%s", rte_version ());
64  _("DPDK EAL init args", "%s", dpdk_config_main.eal_init_args_str);
65 #endif
66 #undef _
67  }
68  else
70  return 0;
71 }
72 
73 /* *INDENT-OFF* */
74 VLIB_CLI_COMMAND (show_vpe_version_command, static) = {
75  .path = "show version",
76  .short_help = "show version information",
77  .function = show_vpe_version_command_fn,
78 };
79 /* *INDENT-ON* */
80 
81 char *
83 {
84  return VPP_BUILD_TOPDIR;
85 }
86 
87 char *
89 {
90  return VPP_BUILD_VER;
91 }
92 
93 char *
95 {
96  return VPP_BUILD_DATE;
97 }
98 
99 /*
100  * fd.io coding-style-patch-verification: ON
101  *
102  * Local Variables:
103  * eval: (c-set-style "gnu")
104  * End:
105  */
uword unformat(unformat_input_t *i, char *fmt,...)
Definition: unformat.c:966
foreach_x86_64_flags format_function_t format_cpu_uarch
Definition: cpu.h:93
u8 * eal_init_args_str
Definition: dpdk.h:374
static char * vpe_compiler
Definition: version.c:29
static char * vpe_version_string
Definition: version.c:25
format_function_t format_cpu_flags
Definition: cpu.h:95
dpdk_config_main_t dpdk_config_main
Definition: dpdk.h:400
char * vpe_api_get_version(void)
Definition: version.c:88
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:575
static clib_error_t * show_vpe_version_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: version.c:45
char * vpe_api_get_build_directory(void)
Definition: version.c:82
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:154
char * vpe_api_get_build_date(void)
Definition: version.c:94
struct _unformat_input_t unformat_input_t
format_function_t format_cpu_model_name
Definition: cpu.h:94