diff --git a/NEWS b/NEWS index ce9fe8803..8d4af9ead 100644 --- a/NEWS +++ b/NEWS @@ -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 --------------------- diff --git a/lib/dpdk.c b/lib/dpdk.c index 9e873617e..8da6c3244 100644 --- a/lib/dpdk.c +++ b/lib/dpdk.c @@ -17,10 +17,12 @@ #include #include "dpdk.h" +#include #include #include #include +#include #include #ifdef DPDK_PDUMP #include @@ -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)) {