summaryrefslogtreecommitdiffstats
path: root/src/plugins/dpdk/device/cli.c
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2018-04-18 17:00:18 +0200
committerFlorin Coras <florin.coras@gmail.com>2018-04-18 18:00:56 +0000
commit5b6ae8de4fd0d7855f8f38426dd4524ebcb15fee (patch)
tree98a8b6ad2dd5a5f4edfb828f4b07961cb4ac05c7 /src/plugins/dpdk/device/cli.c
parente78fab8f5b8afe5bb1b0a2003f1a2384b07ed87f (diff)
dpdk: improve logging
- use of vlib_log for non-dataplane logging - redirect of dpdk logs trough unix pipe into vlib_log - "show dpdk physmem" cli Change-Id: I5da70f9c130273072a8cc80d169df31fc216b2c2 Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/plugins/dpdk/device/cli.c')
-rw-r--r--src/plugins/dpdk/device/cli.c92
1 files changed, 91 insertions, 1 deletions
diff --git a/src/plugins/dpdk/device/cli.c b/src/plugins/dpdk/device/cli.c
index c9fcea5c8d5..2eaf17e55a5 100644
--- a/src/plugins/dpdk/device/cli.c
+++ b/src/plugins/dpdk/device/cli.c
@@ -12,11 +12,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
+#include <unistd.h>
+#include <fcntl.h>
+
#include <vnet/vnet.h>
#include <vppinfra/vec.h>
#include <vppinfra/error.h>
#include <vppinfra/format.h>
#include <vppinfra/xxhash.h>
+#include <vppinfra/linux/sysfs.c>
#include <vnet/ethernet/ethernet.h>
#include <dpdk/device/dpdk.h>
@@ -376,7 +381,7 @@ show_dpdk_buffer (vlib_main_t * vm, unformat_input_t * input,
* @cliexend
?*/
/* *INDENT-OFF* */
-VLIB_CLI_COMMAND (cmd_show_dpdk_bufferr,static) = {
+VLIB_CLI_COMMAND (cmd_show_dpdk_buffer,static) = {
.path = "show dpdk buffer",
.short_help = "show dpdk buffer",
.function = show_dpdk_buffer,
@@ -385,6 +390,91 @@ VLIB_CLI_COMMAND (cmd_show_dpdk_bufferr,static) = {
/* *INDENT-ON* */
static clib_error_t *
+show_dpdk_physmem (vlib_main_t * vm, unformat_input_t * input,
+ vlib_cli_command_t * cmd)
+{
+ clib_error_t *err = 0;
+ u32 pipe_max_size;
+ int fds[2];
+ u8 *s = 0;
+ int n, n_try;
+ FILE *f;
+
+ err = clib_sysfs_read ("/proc/sys/fs/pipe-max-size", "%u", &pipe_max_size);
+
+ if (err)
+ return err;
+
+ if (pipe (fds) == -1)
+ return clib_error_return_unix (0, "pipe");
+
+#ifndef F_SETPIPE_SZ
+#define F_SETPIPE_SZ (1024 + 7)
+#endif
+
+ if (fcntl (fds[1], F_SETPIPE_SZ, pipe_max_size) == -1)
+ {
+ err = clib_error_return_unix (0, "fcntl(F_SETPIPE_SZ)");
+ goto error;
+ }
+
+ if (fcntl (fds[0], F_SETFL, O_NONBLOCK) == -1)
+ {
+ err = clib_error_return_unix (0, "fcntl(F_SETFL)");
+ goto error;
+ }
+
+ if ((f = fdopen (fds[1], "a")) == 0)
+ {
+ err = clib_error_return_unix (0, "fdopen");
+ goto error;
+ }
+
+ rte_dump_physmem_layout (f);
+ fflush (f);
+
+ n = n_try = 4096;
+ while (n == n_try)
+ {
+ uword len = vec_len (s);
+ vec_resize (s, len + n_try);
+
+ n = read (fds[0], s + len, n_try);
+ if (n < 0 && errno != EAGAIN)
+ {
+ err = clib_error_return_unix (0, "read");
+ goto error;
+ }
+ _vec_len (s) = len + (n < 0 ? 0 : n);
+ }
+
+ vlib_cli_output (vm, "%v", s);
+
+error:
+ close (fds[0]);
+ close (fds[1]);
+ vec_free (s);
+ return err;
+}
+
+/*?
+ * This command displays DPDK physmem layout
+ *
+ * @cliexpar
+ * Example of how to display DPDK physmem layout:
+ * @cliexstart{show dpdk physmem}
+ * @cliexend
+?*/
+/* *INDENT-OFF* */
+VLIB_CLI_COMMAND (cmd_show_dpdk_physmem,static) = {
+ .path = "show dpdk physmem",
+ .short_help = "show dpdk physmem",
+ .function = show_dpdk_physmem,
+ .is_mp_safe = 1,
+};
+/* *INDENT-ON* */
+
+static clib_error_t *
test_dpdk_buffer (vlib_main_t * vm, unformat_input_t * input,
vlib_cli_command_t * cmd)
{