diff mbox series

[RFC,1/3] target: core: Initial work on improving SCSI target logs

Message ID 20230726115509.357-2-a.kovaleva@yadro.com (mailing list archive)
State New, archived
Headers show
Series SCSI target logs | expand

Commit Message

Anastasia Kovaleva July 26, 2023, 11:55 a.m. UTC
Introduce the new logging wrapper.

Signed-off-by: Anastasia Kovaleva <a.kovaleva@yadro.com>
---
 include/target/target_core_base.h | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
diff mbox series

Patch

diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
index 159567359bbb..ba8c05dc3d54 100644
--- a/include/target/target_core_base.h
+++ b/include/target/target_core_base.h
@@ -11,6 +11,31 @@ 
 
 #define TARGET_CORE_VERSION		"v5.0"
 
+/*
+ * Unified target core logs
+ */
+#define target_sess_log(lvl, sess, fmt, ...) pr_##lvl("target " TARGET_PREFIX " (%s -> %d): " fmt, \
+		(sess)->se_node_acl->initiatorname, (sess)->se_tpg->tpg_rtpi, ##__VA_ARGS__)
+#define target_cmd_log(lvl, cmd, fmt, ...) pr_##lvl("target " TARGET_PREFIX " (%s -> %d/%lld): " fmt, \
+		(cmd)->se_sess->se_node_acl->initiatorname, (cmd)->se_lun->lun_tpg->tpg_rtpi, \
+		(cmd)->orig_fe_lun, ##__VA_ARGS__)
+#define target_log(lvl, fmt, ...) pr_##lvl("target " TARGET_PREFIX ": " fmt, ##__VA_ARGS__)
+
+#define target_sess_debug(sess, fmt, ...) target_sess_log(debug, sess, fmt, ##__VA_ARGS__)
+#define target_sess_info(sess, fmt, ...)  target_sess_log(info, sess, fmt, ##__VA_ARGS__)
+#define target_sess_warn(sess, fmt, ...)  target_sess_log(warn, sess, fmt, ##__VA_ARGS__)
+#define target_sess_err(sess, fmt, ...)   target_sess_log(err, sess, fmt, ##__VA_ARGS__)
+
+#define target_cmd_debug(cmd, fmt, ...) target_cmd_log(debug, cmd, fmt, ##__VA_ARGS__)
+#define target_cmd_info(cmd, fmt, ...)  target_cmd_log(info, cmd, fmt, ##__VA_ARGS__)
+#define target_cmd_warn(cmd, fmt, ...)  target_cmd_log(warn, cmd, fmt, ##__VA_ARGS__)
+#define target_cmd_err(cmd, fmt, ...)   target_cmd_log(err, cmd, fmt, ##__VA_ARGS__)
+
+#define target_debug(fmt, ...) target_log(debug, fmt, ##__VA_ARGS__)
+#define target_info(fmt, ...)  target_log(info, fmt, ##__VA_ARGS__)
+#define target_warn(fmt, ...)  target_log(warn, fmt, ##__VA_ARGS__)
+#define target_err(fmt, ...)   target_log(err, fmt, ##__VA_ARGS__)
+
 /*
  * Maximum size of a CDB that can be stored in se_cmd without allocating
  * memory dynamically for the CDB.