xref: /haiku/src/add-ons/kernel/busses/scsi/usb/tracing.h (revision f8da8f3477d3c18142e59d17d05a545982faa5a8)
1 /**
2  *
3  * TODO: description
4  *
5  * This file is a part of USB SCSI CAM for Haiku.
6  * May be used under terms of the MIT License
7  *
8  * Author(s):
9  * 	Siarzhuk Zharski <imker@gmx.li>
10  *
11  *
12  */
13 /** tracing support definitions */
14 
15 #ifndef _USB_SCSI_TRACING_H_
16 	#define _USB_SCSI_TRACING_H_
17 
18 #ifndef _SG_BUFFER_H_
19 	#include "sg_buffer.h"
20 #endif /*_SG_BUFFER_H_*/
21 
22 void load_log_settings(void *sh);
23 void create_log(void);
24 void usb_scsi_trace(bool b_force, const char *fmt, ...);
25 
26 /* non-switchable tracng functions */
27 void usb_scsi_trace_bytes(const char *prefix, const uint8 *bytes, size_t bytes_len);
28 void usb_scsi_trace_sgb(const char *prefix, sg_buffer *sgb);
29 void usb_scsi_trace_CCB_HEADER(const CCB_HEADER *ccb);
30 void usb_scsi_trace_CCB_SCSIIO(const CCB_SCSIIO *ccbio);
31 
32 /* ---------------------- Generic tracing --------------------------------------- */
33 /**
34 	\define:TRACE_ALWAYS
35 	trace always - used mainly for error messages
36 */
37 #define TRACE_ALWAYS(x...) \
38 		usb_scsi_trace(true, x)
39 /**
40 	\define:TRACE
41 	trace only if logging is activated
42 */
43 #define TRACE(x...) \
44 		usb_scsi_trace(false, x)
45 
46 /* ---------------------- SCSI commands tracing -------------------------------- */
47 extern bool b_log_scsi_cmd;
48 void usb_scsi_trace_command(bool b_hlight, const uint8 *cmd, size_t cmdlen);
49 /**
50 	\define:TRACE_SCSI_COMMAND
51 	trace SCSI command
52 */
53 #define TRACE_SCSI_COMMAND(cmd, cmdlen)\
54 		{ if(b_log_scsi_cmd) usb_scsi_trace_command(false, cmd, cmdlen); }
55 /**
56 	\define:TRACE_SCSI_COMMAND_HLIGHT
57 	trace SCSI command and prefixes it with special sign. Used for tracing
58 	commands internally converted by this module.
59 */
60 #define TRACE_SCSI_COMMAND_HLIGHT(cmd, cmdlen)\
61 		{ if(b_log_scsi_cmd) usb_scsi_trace_command(true, cmd, cmdlen); }
62 
63 /* ---------------------- USB callback tracing -------------------------------- */
64 /**
65 	\define:TRACE_BULK_CALLBACK
66 	trace the bulk_callback procedures data and status flow.
67 */
68 extern bool b_log_bulk_cb;
69 #define TRACE_BULK_CALLBACK(stat, len)\
70 		{ if(b_log_bulk_cb) TRACE("B_CB:status:%08x;length:%d\n", stat, len); }
71 
72 /* --------------- USB mass storage commands tracing --------------------------- */
73 extern bool b_log_protocol;
74 /* --------------------------- data i/o tracing -------------------------------- */
75 extern bool b_log_data_processing;
76 void usb_scsi_trace_SG(iovec *sg, int count);
77 /**
78 	\define:TRACE_DATA_IO
79 	trace the information about amount processed data and status of process.
80 */
81 #define TRACE_DATA_IO(x...)\
82 		{ if(b_log_data_processing) usb_scsi_trace(false, x); }
83 #define TRACE_DATA_IO_SG(sg, cnt)\
84 		{ if(b_log_data_processing) usb_scsi_trace_SG(sg, cnt); }
85 
86 extern bool b_log_sense_data;
87 /**
88 	\define:TRACE_SENSE_DATA
89 	trace the information REQUEST SENSE data.
90 */
91 #define TRACE_SENSE_DATA(data, len)\
92 		{ if(b_log_sense_data) usb_scsi_trace_bytes("SENSE:", data, len); }
93 #define TRACE_MODE_SENSE_DATA(prefix, data, len)\
94 		{ if(b_log_sense_data) usb_scsi_trace_bytes(prefix, data, len); }
95 #define TRACE_MODE_SENSE_SGB(prefix, data)\
96 		{ if(b_log_sense_data) usb_scsi_trace_sgb(prefix, data); }
97 
98 extern bool b_log_capacity;
99 #define TRACE_CAPACITY(prefix, data)\
100 		{ if(b_log_capacity) usb_scsi_trace_sgb(prefix, data); }
101 
102 #endif /*_USB_SCSI_TRACING_H_*/
103 
104