net/sfc: support driver-wide dynamic logging
authorIvan Malov <ivan.malov@oktetlabs.ru>
Wed, 21 Mar 2018 11:28:17 +0000 (11:28 +0000)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 30 Mar 2018 12:08:44 +0000 (14:08 +0200)
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
drivers/net/sfc/efsys.h
drivers/net/sfc/sfc_dp.c
drivers/net/sfc/sfc_dp.h
drivers/net/sfc/sfc_ef10_rx.c
drivers/net/sfc/sfc_ethdev.c
drivers/net/sfc/sfc_log.h

index 36e98d3..7162ffd 100644 (file)
@@ -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.
index f20b667..d5b03a8 100644 (file)
@@ -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)
index 9a5ca20..b121dc0 100644 (file)
@@ -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",
index b142532..26e7195 100644 (file)
@@ -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,          \
index f31a7e0..ad98727 100644 (file)
@@ -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:
index 7d51db9..341fa46 100644 (file)
@@ -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;
+}
index a18191e..ecafffc 100644 (file)
 #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 {                                                            \