virtio: Add RX queue full statisitics
[vpp.git] / src / vpp / app / version.c
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 <vpp/app/version.h>
18
19 /** \file
20     Display image version information
21 */
22
23 /*? %%clicmd:group_label Image Version Information %% ?*/
24
25 /*
26  * Version variables are static to ensure that they're visible in core
27  * dumps, i.e., not in the rodata segment
28  */
29
30 /** The image version string */
31 char *vpe_version_string =
32   "vpp v" VPP_BUILD_VER
33   " built by " VPP_BUILD_USER " on " VPP_BUILD_HOST " at " VPP_BUILD_DATE;
34
35 /** The name of the compiler */
36 static char *vpe_compiler =
37 #if defined(__INTEL_COMPILER)
38 #define __(x) #x
39 #define _(x) __(x)
40   "icc " _(__INTEL_COMPILER) " (" __VERSION__ ")";
41 #undef _
42 #undef __
43 #elif defined(__clang__)
44   "Clang/LLVM " __clang_version__;
45 #elif defined (__GNUC__)
46   "GCC " __VERSION__;
47 #else
48   "unknown compiler";
49 #endif
50
51 /** \brief Display image version info, a debug CLI command function
52  */
53 static clib_error_t *
54 show_vpe_version_command_fn (vlib_main_t * vm,
55                              unformat_input_t * input,
56                              vlib_cli_command_t * cmd)
57 {
58   int i;
59   int verbose = 0;
60   int cmdline = 0;
61   int indent = 2;
62   vlib_global_main_t *vgm = vlib_get_global_main ();
63   char **argv = (char **) vgm->argv;
64
65   while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
66     {
67       if (unformat (input, "verbose %=", &verbose, 1))
68         ;
69       else if (unformat (input, "cmdline %=", &cmdline, 1))
70         ;
71       else
72         break;
73     }
74
75   if (verbose)
76     {
77 #define _(a,b,c) vlib_cli_output (vm, "%-25s " b, a ":", c);
78       _("Version", "%s", "v" VPP_BUILD_VER);
79       _("Compiled by", "%s", VPP_BUILD_USER);
80       _("Compile host", "%s", VPP_BUILD_HOST);
81       _("Compile date", "%s", VPP_BUILD_DATE);
82       _("Compile location", "%s", VPP_BUILD_TOPDIR);
83       _("Compiler", "%s", vpe_compiler);
84       _("Current PID", "%d", getpid ());
85 #undef _
86     }
87   if (cmdline)
88     {
89       vlib_cli_output (vm, "%-25s", "Command line arguments:");
90
91       for (i = 0; argv[i]; i++)
92         {
93           if (strstr (argv[i], "{"))
94             indent += 2;
95           vlib_cli_output (vm, "%U%s", format_white_space, indent, argv[i]);
96           if (strstr (argv[i], "}"))
97             indent -= 2;
98         }
99     }
100   if ((verbose + cmdline) == 0)
101     vlib_cli_output (vm, "%s", vpe_version_string);
102   return 0;
103 }
104
105 /*?
106  * This command displays image version and command line arguments
107  *
108  * @cliexpar
109  * How to display the image version string:
110  * @cliexstart{show version}
111  * vpp v18.07-rc0~509-gb9124828 built by vppuser on vppbuild at date
112  * @cliexend
113  *
114  * @cliexpar
115  * How to display verbose image version information:
116  * @cliexstart{show version verbose}
117  * Version:                  v18.07-rc0~509-gb9124828
118  * Compiled by:              vppuser
119  * Compile host:             vppbuild
120  * Compile date:             Fri Jul 13 09:05:37 EDT 2018
121  * Compile location:         /scratch/vpp-showversion
122  * Compiler:                 GCC 7.3.0
123  * Current PID:              5334
124  * @cliexend
125  *
126  * @cliexpar
127  * How to display the vpp command line arguments:
128  * @cliexstart{show version cmdline}
129  * vpp# show version cmdline
130  * Command line arguments:
131  *   /scratch/vpp-showversion/build-root/install-vpp_debug-native/vpp/bin/vpp
132  *   unix
133  *   interactive
134  * @cliexend
135 ?*/
136
137 VLIB_CLI_COMMAND (show_vpe_version_command, static) = {
138   .path = "show version",
139   .short_help = "show version [verbose] [cmdline]",
140   .function = show_vpe_version_command_fn,
141   .is_mp_safe = 1,
142 };
143
144 /** Return the image build directory name */
145 char *
146 vpe_api_get_build_directory (void)
147 {
148   return VPP_BUILD_TOPDIR;
149 }
150
151 /** Return the image version string */
152 char *
153 vpe_api_get_version (void)
154 {
155   return VPP_BUILD_VER;
156 }
157
158 /** return the build date */
159 char *
160 vpe_api_get_build_date (void)
161 {
162   return VPP_BUILD_DATE;
163 }
164
165 /*
166  * fd.io coding-style-patch-verification: ON
167  *
168  * Local Variables:
169  * eval: (c-set-style "gnu")
170  * End:
171  */