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