From patchwork Thu Mar 2 11:16:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Maximets X-Patchwork-Id: 734567 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vYqWl6ZLPz9s7p for ; Thu, 2 Mar 2017 22:16:35 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 79D7DB35; Thu, 2 Mar 2017 11:16:33 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 5CD15982 for ; Thu, 2 Mar 2017 11:16:32 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mailout3.w1.samsung.com (mailout3.w1.samsung.com [210.118.77.13]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 7A343AB for ; Thu, 2 Mar 2017 11:16:29 +0000 (UTC) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout3.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OM60070UPZEUW10@mailout3.w1.samsung.com> for dev@openvswitch.org; Thu, 02 Mar 2017 11:16:26 +0000 (GMT) Received: from eusmges2.samsung.com (unknown [203.254.199.241]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20170302111625eucas1p1f3f2b45a2094466000426cf4f08d8bcd~oDHfb0SjV1916819168eucas1p1P; Thu, 2 Mar 2017 11:16:25 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2.samsung.com (EUCPMTA) with SMTP id 95.87.30614.90FF7B85; Thu, 2 Mar 2017 11:16:25 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20170302111625eucas1p1e3816908557764f938bfd06fd7ab20f5~oDHewKVKu3101231012eucas1p1U; Thu, 2 Mar 2017 11:16:25 +0000 (GMT) X-AuditID: cbfec7f1-f793f6d000007796-c5-58b7ff0908ae Received: from eusync2.samsung.com ( [203.254.199.212]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 3F.82.06687.46FF7B85; Thu, 2 Mar 2017 11:17:56 +0000 (GMT) Received: from imaximets.rnd.samsung.ru ([106.109.129.180]) by eusync2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OM600DX0PZ74D80@eusync2.samsung.com>; Thu, 02 Mar 2017 11:16:24 +0000 (GMT) From: Ilya Maximets To: dev@openvswitch.org, Daniele Di Proietto Date: Thu, 02 Mar 2017 14:16:07 +0300 Message-id: <1488453367-7202-1-git-send-email-i.maximets@samsung.com> X-Mailer: git-send-email 2.7.4 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrKIsWRmVeSWpSXmKPExsWy7djP87qc/7dHGDx/LW9x9PQeZou7P1Yw WUz7fJvd4kr7T3YHFo9nN/8zejy/1sPi0bdlFWMAcxSXTUpqTmZZapG+XQJXxtL1E9gLlklV fN77gL2BsV+4i5GTQ0LAROLOlJXsELaYxIV769m6GLk4hASWMkr0rd/DBOF8ZpToOneSCaZj 97+9UIlljBIzTzQzQzjNTBJnvq9lBqliE9CROLX6CCOILSLgJPFw9SoWEJtZIFhix/pjbCC2 MFB85YznYFNZBFQlNt3aB9bLK+AqcXrGN1aIbXISN891gi2QENjAJnGg4RfQIA4gR1Zi0wFm CNNFYtGPeIhyYYlXx7dAvSMj0dlxkAmitZlRomHVJUYIZwKjxJfm5V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HFZ74 Hoox+P28obE46PO36dI9F9LqLm3e/c2MbavQsYCLp+MbxMoKsl2KvDc/k/O67WIbrjPp1yfV e3d3x+k/tT6YvXxZiRJLcUaioRZzUXEiABrDbrBMAgAA X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20170302111625eucas1p1e3816908557764f938bfd06fd7ab20f5 X-Msg-Generator: CA X-Sender-IP: 182.198.249.179 X-Local-Sender: =?UTF-8?B?SWx5YSBNYXhpbWV0cxtTUlItVmlydHVhbGl6YXRpb24gTGFi?= =?UTF-8?B?G+yCvOyEseyghOyekBtMZWFkaW5nIEVuZ2luZWVy?= X-Global-Sender: =?UTF-8?B?SWx5YSBNYXhpbWV0cxtTUlItVmlydHVhbGl6YXRpb24gTGFi?= =?UTF-8?B?G1NhbXN1bmcgRWxlY3Ryb25pY3MbTGVhZGluZyBFbmdpbmVlcg==?= X-Sender-Code: =?UTF-8?B?QzEwG0NJU0hRG0MxMEdEMDFHRDAxMDE1NA==?= CMS-TYPE: 201P X-HopCount: 7 X-CMS-RootMailID: 20170302111625eucas1p1e3816908557764f938bfd06fd7ab20f5 X-RootMTR: 20170302111625eucas1p1e3816908557764f938bfd06fd7ab20f5 References: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: Ilya Maximets , Heetae Ahn Subject: [ovs-dev] [PATCH] dpdk: Redirect DPDK log to OVS logging subsystem. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org 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 --- NEWS | 5 +++++ lib/dpdk.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/NEWS b/NEWS index ce9fe88..8d4af9e 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 c1626e2..eb03ec9 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,45 @@ 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 = xmalloc(size + 1); + + strncpy(str, buf, size); + str[size] = '\0'; + + 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 +316,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)) {