From: Ivan Malov Date: Wed, 21 Mar 2018 11:28:17 +0000 (+0000) Subject: net/sfc: support driver-wide dynamic logging X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=fdceb100c7ced8511ea0191cb084e38ee6c1162f;p=dpdk.git net/sfc: support driver-wide dynamic logging Signed-off-by: Ivan Malov Signed-off-by: Andrew Rybchenko Reviewed-by: Andy Moreton --- diff --git a/doc/guides/nics/sfc_efx.rst b/doc/guides/nics/sfc_efx.rst index 36e98d384d..7162ffd1cc 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 f20b667d8c..d5b03a884f 100644 --- a/drivers/net/sfc/efsys.h +++ b/drivers/net/sfc/efsys.h @@ -26,6 +26,7 @@ #include #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 9a5ca20b09..b121dc098e 100644 --- a/drivers/net/sfc/sfc_dp.c +++ b/drivers/net/sfc/sfc_dp.c @@ -14,6 +14,7 @@ #include #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 b142532d90..26e719545f 100644 --- a/drivers/net/sfc/sfc_dp.h +++ b/drivers/net/sfc/sfc_dp.h @@ -15,6 +15,8 @@ #include +#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 f31a7e0e08..ad9872729d 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 7d51db979a..341fa46b28 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 "= " 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 a18191eda0..ecafffc08b 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 { \