aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/memif/private.h
diff options
context:
space:
mode:
authorJuraj Sloboda <jsloboda@cisco.com>2018-10-03 16:00:21 +0200
committerDamjan Marion <dmarion@me.com>2018-10-03 17:37:48 +0000
commit7a40133d3355463368085c14f9fc4b4fd22d549a (patch)
tree07e0c07cd41a09ddbecdf51323fc0acfedc02330 /src/plugins/memif/private.h
parent7cd368f7be4ff0eb06e0b4975e7c2695ad788b44 (diff)
memif: include interface name in logs
Change-Id: I67f58aa93c721dbd518cc2ddcea330006693662f Signed-off-by: Juraj Sloboda <jsloboda@cisco.com>
Diffstat (limited to 'src/plugins/memif/private.h')
-rw-r--r--src/plugins/memif/private.h42
1 files changed, 37 insertions, 5 deletions
diff --git a/src/plugins/memif/private.h b/src/plugins/memif/private.h
index 82056a1ecfb..0116de3f1c3 100644
--- a/src/plugins/memif/private.h
+++ b/src/plugins/memif/private.h
@@ -30,21 +30,52 @@
#define MEMIF_MAX_LOG2_RING_SIZE 14
+#define memif_log_debug(dev, f, ...) do { \
+ memif_if_t *_dev = (memif_if_t *) dev; \
+ if (_dev) \
+ vlib_log(VLIB_LOG_LEVEL_DEBUG, memif_main.log_class, "%U: " f, \
+ format_vnet_hw_if_index_name, vnet_get_main(), \
+ _dev->hw_if_index, ##__VA_ARGS__); \
+ else \
+ vlib_log(VLIB_LOG_LEVEL_DEBUG, memif_main.log_class, f, \
+ ##__VA_ARGS__); \
+} while (0)
+
+#define memif_log_warn(dev, f, ...) do { \
+ memif_if_t *_dev = (memif_if_t *) dev; \
+ if (_dev) \
+ vlib_log(VLIB_LOG_LEVEL_WARNING, memif_main.log_class, "%U: " f, \
+ format_vnet_hw_if_index_name, vnet_get_main(), \
+ _dev->hw_if_index, ##__VA_ARGS__); \
+ else \
+ vlib_log(VLIB_LOG_LEVEL_WARNING, memif_main.log_class, f, \
+ ##__VA_ARGS__); \
+} while (0)
+
+#define memif_log_err(dev, f, ...) do { \
+ memif_if_t *_dev = (memif_if_t *) dev; \
+ if (_dev) \
+ vlib_log(VLIB_LOG_LEVEL_ERR, memif_main.log_class, "%U: " f, \
+ format_vnet_hw_if_index_name, vnet_get_main(), \
+ _dev->hw_if_index, ##__VA_ARGS__); \
+ else \
+ vlib_log(VLIB_LOG_LEVEL_ERR, memif_main.log_class, f, \
+ ##__VA_ARGS__); \
+} while (0)
+
#define memif_file_add(a, b) do { \
*a = clib_file_add (&file_main, b); \
- vlib_log_warn ((&memif_main)->log_class, \
- "clib_file_add fd %d private_data %u idx %u", \
+ memif_log_warn (0, "clib_file_add fd %d private_data %u idx %u", \
(b)->file_descriptor, (b)->private_data, *a); \
} while (0)
#define memif_file_del(a) do { \
- vlib_log_warn ((&memif_main)->log_class, \
- "clib_file_del idx %u",a - file_main.file_pool); \
+ memif_log_warn (0, "clib_file_del idx %u", a - file_main.file_pool); \
clib_file_del (&file_main, a); \
} while (0)
#define memif_file_del_by_index(a) do { \
- vlib_log_warn ((&memif_main)->log_class, "clib_file_del idx %u", a); \
+ memif_log_warn (0, "clib_file_del idx %u", a); \
clib_file_del_by_index (&file_main, a); \
} while (0)
@@ -277,6 +308,7 @@ clib_error_t *memif_msg_send_disconnect (memif_if_t * mif,
clib_error_t * err);
u8 *format_memif_device_name (u8 * s, va_list * args);
+
/*
* fd.io coding-style-patch-verification: ON
*