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