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