net/failsafe: convert to dynamic logging
authorStephen Hemminger <stephen@networkplumber.org>
Wed, 25 Apr 2018 15:56:42 +0000 (08:56 -0700)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 27 Apr 2018 17:00:59 +0000 (18:00 +0100)
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
drivers/net/failsafe/failsafe.c
drivers/net/failsafe/failsafe_private.h

index dc9b0d0..5e7a8ba 100644 (file)
@@ -13,6 +13,8 @@
 
 #include "failsafe_private.h"
 
+int failsafe_logtype;
+
 const char pmd_failsafe_driver_name[] = FAILSAFE_DRIVER_NAME;
 static const struct rte_eth_link eth_link = {
        .link_speed = ETH_SPEED_NUM_10G,
@@ -304,7 +306,7 @@ rte_pmd_failsafe_probe(struct rte_vdev_device *vdev)
            strlen(rte_vdev_device_args(vdev)) == 0) {
                eth_dev = rte_eth_dev_attach_secondary(name);
                if (!eth_dev) {
-                       RTE_LOG(ERR, PMD, "Failed to probe %s\n", name);
+                       ERROR("Failed to probe %s", name);
                        return -1;
                }
                /* TODO: request info from primary to set up Rx and Tx */
@@ -332,3 +334,12 @@ static struct rte_vdev_driver failsafe_drv = {
 
 RTE_PMD_REGISTER_VDEV(net_failsafe, failsafe_drv);
 RTE_PMD_REGISTER_PARAM_STRING(net_failsafe, PMD_FAILSAFE_PARAM_STRING);
+
+RTE_INIT(failsafe_init_log);
+static void
+failsafe_init_log(void)
+{
+       failsafe_logtype = rte_log_register("pmd.net.failsafe");
+       if (failsafe_logtype >= 0)
+               rte_log_set_level(failsafe_logtype, RTE_LOG_NOTICE);
+}
index 7db9eeb..b54f8e3 100644 (file)
@@ -326,8 +326,12 @@ extern int mac_from_arg;
 #define FS_THREADID_FMT  "lu"
 #endif
 
-#define LOG__(level, m, ...) \
-       RTE_LOG(level, PMD, "net_failsafe: " m "%c", __VA_ARGS__)
+extern int failsafe_logtype;
+
+#define LOG__(l, m, ...) \
+       rte_log(RTE_LOG_ ## l, failsafe_logtype, \
+               "net_failsafe: " m "%c", __VA_ARGS__)
+
 #define LOG_(level, ...) LOG__(level, __VA_ARGS__, '\n')
 #define DEBUG(...) LOG_(DEBUG, __VA_ARGS__)
 #define INFO(...) LOG_(INFO, __VA_ARGS__)