From: Andrew Rybchenko <arybchenko@solarflare.com>
To: <dev@dpdk.org>
Cc: Ferruh Yigit <ferruh.yigit@intel.com>,
Ivan Malov <ivan.malov@oktetlabs.ru>
Subject: [dpdk-dev] [PATCH v3 2/6] net/sfc: add support for driver-wide dynamic logging
Date: Wed, 21 Mar 2018 11:28:17 +0000 [thread overview]
Message-ID: <1521631701-11282-3-git-send-email-arybchenko@solarflare.com> (raw)
In-Reply-To: <1521631701-11282-1-git-send-email-arybchenko@solarflare.com>
From: Ivan Malov <ivan.malov@oktetlabs.ru>
Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Andy Moreton <amoreton@solarflare.com>
---
doc/guides/nics/sfc_efx.rst | 19 +++++++++++++++++++
drivers/net/sfc/efsys.h | 3 ++-
drivers/net/sfc/sfc_dp.c | 5 +++--
drivers/net/sfc/sfc_dp.h | 6 ++++--
drivers/net/sfc/sfc_ef10_rx.c | 4 ++--
drivers/net/sfc/sfc_ethdev.c | 13 +++++++++++++
drivers/net/sfc/sfc_log.h | 12 ++++++++++++
7 files changed, 55 insertions(+), 7 deletions(-)
diff --git a/doc/guides/nics/sfc_efx.rst b/doc/guides/nics/sfc_efx.rst
index 36e98d3..7162ffd 100644
--- a/doc/guides/nics/sfc_efx.rst
+++ b/doc/guides/nics/sfc_efx.rst
@@ -339,3 +339,22 @@ boolean parameters value.
only possible to set an arbitrary value on SFN8xxx provided that
firmware version is 6.2.1.1033 or higher, otherwise any positive
value will select a fixed update period of **1000** milliseconds
+
+
+Dynamic Logging Parameters
+~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+One may leverage EAL option "--log-level" to change default levels
+for the log types supported by the driver. The option is used with
+an argument typically consisting of two parts separated by a comma.
+
+Level value is the last part which takes an integer greater than 0.
+Log type is the former part which may contain a regular expression.
+Depending on the choice of the expression, the given log level may
+be used either for some specific log type or for a subset of types.
+
+SFC EFX PMD provides the following log types available for control:
+
+- ``pmd.net.sfc.driver`` (default level is **6** - ``RTE_LOG_NOTICE``)
+
+ Affects driver-wide messages unrelated to any particular devices.
diff --git a/drivers/net/sfc/efsys.h b/drivers/net/sfc/efsys.h
index f20b667..d5b03a8 100644
--- a/drivers/net/sfc/efsys.h
+++ b/drivers/net/sfc/efsys.h
@@ -26,6 +26,7 @@
#include <rte_io.h>
#include "sfc_debug.h"
+#include "sfc_log.h"
#ifdef __cplusplus
extern "C" {
@@ -729,7 +730,7 @@ typedef uint64_t efsys_stat_t;
#define EFSYS_ERR(_esip, _code, _dword0, _dword1) \
do { \
(void)(_esip); \
- RTE_LOG(ERR, PMD, "FATAL ERROR #%u (0x%08x%08x)\n", \
+ SFC_GENERIC_LOG(ERR, "FATAL ERROR #%u (0x%08x%08x)", \
(_code), (_dword0), (_dword1)); \
_NOTE(CONSTANTCONDITION); \
} while (B_FALSE)
diff --git a/drivers/net/sfc/sfc_dp.c b/drivers/net/sfc/sfc_dp.c
index 9a5ca20..b121dc0 100644
--- a/drivers/net/sfc/sfc_dp.c
+++ b/drivers/net/sfc/sfc_dp.c
@@ -14,6 +14,7 @@
#include <rte_log.h>
#include "sfc_dp.h"
+#include "sfc_log.h"
void
sfc_dp_queue_init(struct sfc_dp_queue *dpq, uint16_t port_id, uint16_t queue_id,
@@ -63,8 +64,8 @@ int
sfc_dp_register(struct sfc_dp_list *head, struct sfc_dp *entry)
{
if (sfc_dp_find_by_name(head, entry->type, entry->name) != NULL) {
- rte_log(RTE_LOG_ERR, RTE_LOGTYPE_PMD,
- "sfc %s dapapath '%s' already registered\n",
+ SFC_GENERIC_LOG(ERR,
+ "sfc %s dapapath '%s' already registered",
entry->type == SFC_DP_RX ? "Rx" :
entry->type == SFC_DP_TX ? "Tx" :
"unknown",
diff --git a/drivers/net/sfc/sfc_dp.h b/drivers/net/sfc/sfc_dp.h
index b142532..26e7195 100644
--- a/drivers/net/sfc/sfc_dp.h
+++ b/drivers/net/sfc/sfc_dp.h
@@ -15,6 +15,8 @@
#include <rte_pci.h>
+#include "sfc_log.h"
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -58,10 +60,10 @@ void sfc_dp_queue_init(struct sfc_dp_queue *dpq,
const struct sfc_dp_queue *_dpq = (dpq); \
const struct rte_pci_addr *_addr = &(_dpq)->pci_addr; \
\
- RTE_LOG(level, PMD, \
+ SFC_GENERIC_LOG(level, \
RTE_FMT("%s " PCI_PRI_FMT \
" #%" PRIu16 ".%" PRIu16 ": " \
- RTE_FMT_HEAD(__VA_ARGS__,) "\n", \
+ RTE_FMT_HEAD(__VA_ARGS__ ,), \
dp_name, \
_addr->domain, _addr->bus, \
_addr->devid, _addr->function, \
diff --git a/drivers/net/sfc/sfc_ef10_rx.c b/drivers/net/sfc/sfc_ef10_rx.c
index f31a7e0..ad98727 100644
--- a/drivers/net/sfc/sfc_ef10_rx.c
+++ b/drivers/net/sfc/sfc_ef10_rx.c
@@ -597,8 +597,8 @@ sfc_ef10_supported_ptypes_get(uint32_t tunnel_encaps)
1u << EFX_TUNNEL_PROTOCOL_NVGRE):
return ef10_overlay_ptypes;
default:
- RTE_LOG(ERR, PMD,
- "Unexpected set of supported tunnel encapsulations: %#x\n",
+ SFC_GENERIC_LOG(ERR,
+ "Unexpected set of supported tunnel encapsulations: %#x",
tunnel_encaps);
/* FALLTHROUGH */
case 0:
diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c
index 7d51db9..341fa46 100644
--- a/drivers/net/sfc/sfc_ethdev.c
+++ b/drivers/net/sfc/sfc_ethdev.c
@@ -27,6 +27,8 @@
#include "sfc_dp.h"
#include "sfc_dp_rx.h"
+uint32_t sfc_logtype_driver;
+
static struct sfc_dp_list sfc_dp_head =
TAILQ_HEAD_INITIALIZER(sfc_dp_head);
@@ -2068,3 +2070,14 @@ RTE_PMD_REGISTER_PARAM_STRING(net_sfc_efx,
SFC_KVARG_STATS_UPDATE_PERIOD_MS "=<long> "
SFC_KVARG_MCDI_LOGGING "=" SFC_KVARG_VALUES_BOOL " "
SFC_KVARG_DEBUG_INIT "=" SFC_KVARG_VALUES_BOOL);
+
+RTE_INIT(sfc_driver_register_logtype);
+static void
+sfc_driver_register_logtype(void)
+{
+ int ret;
+
+ ret = rte_log_register_type_and_pick_level(SFC_LOGTYPE_PREFIX "driver",
+ RTE_LOG_NOTICE);
+ sfc_logtype_driver = (ret < 0) ? RTE_LOGTYPE_PMD : ret;
+}
diff --git a/drivers/net/sfc/sfc_log.h b/drivers/net/sfc/sfc_log.h
index a18191e..ecafffc 100644
--- a/drivers/net/sfc/sfc_log.h
+++ b/drivers/net/sfc/sfc_log.h
@@ -10,6 +10,18 @@
#ifndef _SFC_LOG_H_
#define _SFC_LOG_H_
+/** Generic driver log type */
+extern uint32_t sfc_logtype_driver;
+
+/** Common log type name prefix */
+#define SFC_LOGTYPE_PREFIX "pmd.net.sfc."
+
+/** Log PMD generic message, add a prefix and a line break */
+#define SFC_GENERIC_LOG(level, ...) \
+ rte_log(RTE_LOG_ ## level, sfc_logtype_driver, \
+ RTE_FMT("PMD: " RTE_FMT_HEAD(__VA_ARGS__ ,) "\n", \
+ RTE_FMT_TAIL(__VA_ARGS__ ,)))
+
/* Log PMD message, automatically add prefix and \n */
#define SFC_LOG(sa, level, ...) \
do { \
--
2.7.4
next prev parent reply other threads:[~2018-03-21 11:28 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-25 17:00 [dpdk-dev] [PATCH 0/6] net/sfc: implement " Andrew Rybchenko
2018-01-25 17:00 ` [dpdk-dev] [PATCH 1/6] eal: register log type and pick level from EAL args Andrew Rybchenko
2018-01-25 17:00 ` [dpdk-dev] [PATCH 2/6] net/sfc: add support for driver-wide dynamic logging Andrew Rybchenko
2018-01-25 18:42 ` Stephen Hemminger
2018-01-26 6:51 ` Andrew Rybchenko
2018-03-05 14:59 ` Ferruh Yigit
2018-03-06 14:45 ` Andrew Rybchenko
2018-03-06 14:56 ` Andrew Rybchenko
2018-03-06 15:26 ` Ferruh Yigit
2018-01-25 17:00 ` [dpdk-dev] [PATCH 3/6] net/sfc: add support for per-port " Andrew Rybchenko
2018-03-15 15:45 ` Ferruh Yigit
2018-01-25 17:00 ` [dpdk-dev] [PATCH 4/6] net/sfc: prepare to merge init logs with main log type Andrew Rybchenko
2018-01-25 17:00 ` [dpdk-dev] [PATCH 5/6] net/sfc: remove dedicated init log parameter Andrew Rybchenko
2018-01-25 17:00 ` [dpdk-dev] [PATCH 6/6] net/sfc: add dynamic log level for MCDI messages Andrew Rybchenko
2018-01-25 21:38 ` [dpdk-dev] [PATCH 0/6] net/sfc: implement dynamic logging Thomas Monjalon
2018-01-26 5:59 ` Andrew Rybchenko
2018-01-26 7:44 ` Thomas Monjalon
2018-02-15 11:35 ` [dpdk-dev] [PATCH v2] eal: register log type and pick level from EAL args Andrew Rybchenko
2018-03-05 15:00 ` [dpdk-dev] [PATCH 0/6] net/sfc: implement dynamic logging Ferruh Yigit
2018-03-21 11:28 ` [dpdk-dev] [PATCH v3 " Andrew Rybchenko
2018-03-21 11:28 ` [dpdk-dev] [PATCH v3 1/6] eal: register log type and pick level from EAL args Andrew Rybchenko
2018-03-22 10:21 ` Ferruh Yigit
2018-03-21 11:28 ` Andrew Rybchenko [this message]
2018-03-21 11:28 ` [dpdk-dev] [PATCH v3 3/6] net/sfc: add support for per-port dynamic logging Andrew Rybchenko
2018-03-21 11:28 ` [dpdk-dev] [PATCH v3 4/6] net/sfc: prepare to merge init logs with main log type Andrew Rybchenko
2018-03-21 11:28 ` [dpdk-dev] [PATCH v3 5/6] net/sfc: remove dedicated init log parameter Andrew Rybchenko
2018-03-21 11:28 ` [dpdk-dev] [PATCH v3 6/6] net/sfc: add dynamic log level for MCDI messages Andrew Rybchenko
2018-03-22 10:22 ` [dpdk-dev] [PATCH v3 0/6] net/sfc: implement dynamic logging Ferruh Yigit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1521631701-11282-3-git-send-email-arybchenko@solarflare.com \
--to=arybchenko@solarflare.com \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@intel.com \
--cc=ivan.malov@oktetlabs.ru \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).