2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-22 01:51:26 +00:00

dpdk: Redirect DPDK log to OVS logging subsystem.

This should be helpful for have all the logs in one place.
'ovs-appctl vlog' commands for 'dpdk' module can be used
to configure the log level. Lower bound for DPDK logging
(--log-level) still can be passed through 'dpdk-extra' field.

Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Acked-by: Aaron Conole <aconole@redhat.com>
Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
This commit is contained in:
Ilya Maximets 2017-03-06 09:49:11 +03:00 committed by Daniele Di Proietto
parent 96e9b168e0
commit 736ca516f3
2 changed files with 53 additions and 0 deletions

5
NEWS
View File

@ -5,6 +5,11 @@ Post-v2.7.0
`egress_pkt_mark` OVSDB option.
- EMC insertion probability is reduced to 1% and is configurable via
the new 'other_config:emc-insert-inv-prob' option.
- DPDK:
* DPDK log messages redirected to OVS logging subsystem.
Log level can be changed in a usual OVS way using
'ovs-appctl vlog' commands for 'dpdk' module. Lower bound
still can be configured via extra arguments for DPDK EAL.
v2.7.0 - xx xxx xxxx
---------------------

View File

@ -17,10 +17,12 @@
#include <config.h>
#include "dpdk.h"
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <getopt.h>
#include <rte_log.h>
#include <rte_memzone.h>
#ifdef DPDK_PDUMP
#include <rte_mempool.h>
@ -36,6 +38,8 @@
VLOG_DEFINE_THIS_MODULE(dpdk);
static FILE *log_stream = NULL; /* Stream for DPDK log redirection */
static char *vhost_sock_dir = NULL; /* Location of vhost-user sockets */
static int
@ -262,6 +266,42 @@ argv_release(char **dpdk_argv, char **dpdk_argv_release, size_t dpdk_argc)
free(dpdk_argv);
}
static ssize_t
dpdk_log_write(void *c OVS_UNUSED, const char *buf, size_t size)
{
char *str = xmemdup0(buf, size);
switch (rte_log_cur_msg_loglevel()) {
case RTE_LOG_DEBUG:
VLOG_DBG("%s", str);
break;
case RTE_LOG_INFO:
case RTE_LOG_NOTICE:
VLOG_INFO("%s", str);
break;
case RTE_LOG_WARNING:
VLOG_WARN("%s", str);
break;
case RTE_LOG_ERR:
VLOG_ERR("%s", str);
break;
case RTE_LOG_CRIT:
case RTE_LOG_ALERT:
case RTE_LOG_EMERG:
VLOG_EMER("%s", str);
break;
default:
OVS_NOT_REACHED();
}
free(str);
return size;
}
static cookie_io_functions_t dpdk_log_func = {
.write = dpdk_log_write,
};
static void
dpdk_init__(const struct smap *ovs_other_config)
{
@ -273,6 +313,14 @@ dpdk_init__(const struct smap *ovs_other_config)
cpu_set_t cpuset;
char *sock_dir_subcomponent;
log_stream = fopencookie(NULL, "w+", dpdk_log_func);
if (log_stream == NULL) {
VLOG_ERR("Can't redirect DPDK log: %s.", ovs_strerror(errno));
} else {
setbuf(log_stream, NULL);
rte_openlog_stream(log_stream);
}
if (process_vhost_flags("vhost-sock-dir", ovs_rundir(),
NAME_MAX, ovs_other_config,
&sock_dir_subcomponent)) {