From 4dc7ccf7e9d9bca1989b840be9e8e84911387cf2 Mon Sep 17 00:00:00 2001 From: Joe Eykholt Date: Fri, 12 Mar 2010 16:07:41 -0800 Subject: [SCSI] libfc: add definition for task attribute mask The FCP command header definition should define a mask for the task attribute field. This adds that #define. Signed-off-by: Joe Eykholt Signed-off-by: Robert Love Signed-off-by: James Bottomley --- include/scsi/fc/fc_fcp.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/scsi/fc/fc_fcp.h b/include/scsi/fc/fc_fcp.h index 747e2c7..8e9b222 100644 --- a/include/scsi/fc/fc_fcp.h +++ b/include/scsi/fc/fc_fcp.h @@ -76,6 +76,7 @@ struct fcp_cmnd32 { #define FCP_PTA_HEADQ 1 /* head of queue task attribute */ #define FCP_PTA_ORDERED 2 /* ordered task attribute */ #define FCP_PTA_ACA 4 /* auto. contigent allegiance */ +#define FCP_PTA_MASK 7 /* mask for task attribute field */ #define FCP_PRI_SHIFT 3 /* priority field starts in bit 3 */ #define FCP_PRI_RESVD_MASK 0x80 /* reserved bits in priority field */ -- cgit v1.1 From 4291365784c9622c9d643cf23421f9c7b9662d71 Mon Sep 17 00:00:00 2001 From: Joe Eykholt Date: Fri, 12 Mar 2010 16:08:23 -0800 Subject: [SCSI] libfcoe: eliminate unused link and last_link fields The link and last_link fields in the fcoe_ctlr struct are no longer useful, since they are always set to the same value, and FIP always calls libfc to pass link information to the lport. Eliminate those fields and rename link_work to timer_work, since it no longer has any link change work to do. Thanks to Brian Uchino for discovering this issue. Signed-off-by: Joe Eykholt Signed-off-by: Robert Love Signed-off-by: James Bottomley --- include/scsi/libfcoe.h | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/scsi/libfcoe.h b/include/scsi/libfcoe.h index c603f4a..868ed26 100644 --- a/include/scsi/libfcoe.h +++ b/include/scsi/libfcoe.h @@ -65,14 +65,12 @@ enum fip_state { * @port_ka_time: time of next port keep-alive. * @ctlr_ka_time: time of next controller keep-alive. * @timer: timer struct used for all delayed events. - * @link_work: &work_struct for doing FCF selection. + * @timer_work: &work_struct for doing keep-alives and resets. * @recv_work: &work_struct for receiving FIP frames. * @fip_recv_list: list of received FIP frames. * @user_mfs: configured maximum FC frame size, including FC header. * @flogi_oxid: exchange ID of most recent fabric login. * @flogi_count: number of FLOGI attempts in AUTO mode. - * @link: current link status for libfc. - * @last_link: last link state reported to libfc. * @map_dest: use the FC_MAP mode for destination MAC addresses. * @spma: supports SPMA server-provided MACs mode * @send_ctlr_ka: need to send controller keep alive @@ -100,14 +98,12 @@ struct fcoe_ctlr { unsigned long port_ka_time; unsigned long ctlr_ka_time; struct timer_list timer; - struct work_struct link_work; + struct work_struct timer_work; struct work_struct recv_work; struct sk_buff_head fip_recv_list; u16 user_mfs; u16 flogi_oxid; u8 flogi_count; - u8 link; - u8 last_link; u8 reset_req; u8 map_dest; u8 spma; -- cgit v1.1 From f018b73af6db4f330ad5da9ac53997a699c30c42 Mon Sep 17 00:00:00 2001 From: Joe Eykholt Date: Fri, 12 Mar 2010 16:08:55 -0800 Subject: [SCSI] libfc, libfcoe, fcoe: use smp_processor_id() only when preempt disabled When the kernel is configured for preemption, using smp_processor_id() when preemption is enabled causes a warning backtrace and is wrong since we could move off of that CPU as soon as we get the ID, and we would be referencing the wrong CPU, and possibly an invalid one if it could be hotswapped out. Remove the fc_lport_get_stats() function and explicitly use per_cpu_ptr() to get the statistics. Where preemption has been disabled by holding a _bh lock continue to use smp_processor_id(), but otherwise use get_cpu()/put_cpu(). In fcoe_recv_frame() also changed the cases where we return in the middle to do a goto to the code which bumps ErrorFrames and does a put_cpu(). Two of these cases didn't bump ErrorFrames before, but doing so is harmless because they "can't happen", due to prior length checks. Also rearranged code in fcoe_recv_frame() to have only one call to fc_exch_recv(). It's just as efficient and saves a call to put_cpu(). In fc_fcp.c, adjusted a FIXME comment for code which doesn't need fixing. Signed-off-by: Joe Eykholt Signed-off-by: Robert Love Signed-off-by: James Bottomley --- include/scsi/libfc.h | 9 --------- 1 file changed, 9 deletions(-) (limited to 'include') diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h index 4b912ee..8d0d1b2 100644 --- a/include/scsi/libfc.h +++ b/include/scsi/libfc.h @@ -918,15 +918,6 @@ static inline void fc_lport_free_stats(struct fc_lport *lport) } /** - * fc_lport_get_stats() - Get a local port's statistics - * @lport: The local port whose statistics are to be retreived - */ -static inline struct fcoe_dev_stats *fc_lport_get_stats(struct fc_lport *lport) -{ - return per_cpu_ptr(lport->dev_stats, smp_processor_id()); -} - -/** * lport_priv() - Return the private data from a local port * @lport: The local port whose private data is to be retreived */ -- cgit v1.1 From 2f2eb58762b4dcddfe25c90800323765c1257eca Mon Sep 17 00:00:00 2001 From: Christof Schmitt Date: Wed, 24 Mar 2010 16:50:30 +0100 Subject: [SCSI] Allow FC LLD to fast-fail scsi eh by introducing new eh return If the scsi eh is running and then a FC LLD calls fc_remote_port_delete, the SCSI commands sent from the eh will fail. To prevent this, a FC LLD can call fc_block_scsi_eh from the eh callback, blocking the eh thread until the dev_loss_tmo fires or the remote port is available again. If (e.g. for a multipathing setup) the dev_loss_tmo is set to a very large value, thus preventing the scsi device removal , the scsi eh can block for a long time. For multipathing, the fast_io_fail_tmo is then set to a low value to detect path problems sooner. This patch introduces a new return code FAST_IO_FAIL. The function fc_block_scsi_eh now returns FAST_IO_FAIL when the fast_io_fail_tmo fires. This indicates that the LLD terminated all pending I/O requests and there are no more pending SCSI commands for the scsi eh to wait for. This return code can be passed back to the scsi eh to stop the escalation and finish the recovery process for this device. Signed-off-by: Christof Schmitt Signed-off-by: James Bottomley --- include/scsi/scsi.h | 1 + include/scsi/scsi_transport_fc.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/scsi/scsi.h b/include/scsi/scsi.h index 8b4deca..832f41f 100644 --- a/include/scsi/scsi.h +++ b/include/scsi/scsi.h @@ -423,6 +423,7 @@ static inline int scsi_is_wlun(unsigned int lun) #define ADD_TO_MLQUEUE 0x2006 #define TIMEOUT_ERROR 0x2007 #define SCSI_RETURN_NOT_HANDLED 0x2008 +#define FAST_IO_FAIL 0x2009 /* * Midlevel queue return values. diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h index 8e86a94..87d81b3 100644 --- a/include/scsi/scsi_transport_fc.h +++ b/include/scsi/scsi_transport_fc.h @@ -807,6 +807,6 @@ void fc_host_post_vendor_event(struct Scsi_Host *shost, u32 event_number, struct fc_vport *fc_vport_create(struct Scsi_Host *shost, int channel, struct fc_vport_identifiers *); int fc_vport_terminate(struct fc_vport *vport); -void fc_block_scsi_eh(struct scsi_cmnd *cmnd); +int fc_block_scsi_eh(struct scsi_cmnd *cmnd); #endif /* SCSI_TRANSPORT_FC_H */ -- cgit v1.1 From 0b2f74a47f2b10bd4c70324820a93c070b3960a5 Mon Sep 17 00:00:00 2001 From: Joe Eykholt Date: Fri, 9 Apr 2010 14:22:39 -0700 Subject: [SCSI] libfc: fix hton24 macro to take expressions as args hton24(p + 3, value) would fail to compile because p + 3[0] is not a valid expression. Went ahead and converted hton24 and ntoh24 to inline functions, which is better because the parameters are evalutated only once. Signed-off-by: Joe Eykholt Signed-off-by: Robert Love Signed-off-by: James Bottomley --- include/scsi/libfc.h | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h index 8d0d1b2..a26bb50 100644 --- a/include/scsi/libfc.h +++ b/include/scsi/libfc.h @@ -47,13 +47,18 @@ #define ntohll(x) be64_to_cpu(x) #define htonll(x) cpu_to_be64(x) -#define ntoh24(p) (((p)[0] << 16) | ((p)[1] << 8) | ((p)[2])) -#define hton24(p, v) do { \ - p[0] = (((v) >> 16) & 0xFF); \ - p[1] = (((v) >> 8) & 0xFF); \ - p[2] = ((v) & 0xFF); \ - } while (0) +static inline u32 ntoh24(const u8 *p) +{ + return (p[0] << 16) | (p[1] << 8) | p[2]; +} + +static inline void hton24(u8 *p, u32 v) +{ + p[0] = (v >> 16) & 0xff; + p[1] = (v >> 8) & 0xff; + p[2] = v & 0xff; +} /** * enum fc_lport_state - Local port states -- cgit v1.1 From da87bfab8a7e6cfd0e1e5c5874d7fd4f7d11e64e Mon Sep 17 00:00:00 2001 From: Vasu Dev Date: Fri, 9 Apr 2010 14:22:59 -0700 Subject: [SCSI] fcoe, fnic, libfc: increased CDB size to 16 bytes for fcoe. No reason to restrict CDB size to 12 bytes in fcoe, so increased to 16 so that 16 bytes SCSI CDB doesn't fail. Uses common define to set max_cmd_len for fcoe and fnic, fnic is already setting max_cmd_len to 16. sg_readcap -l fails without this fix. Signed-off-by: Vasu Dev Signed-off-by: Robert Love Signed-off-by: James Bottomley --- include/scsi/libfcoe.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/scsi/libfcoe.h b/include/scsi/libfcoe.h index 868ed26..ec13f51 100644 --- a/include/scsi/libfcoe.h +++ b/include/scsi/libfcoe.h @@ -29,6 +29,8 @@ #include #include +#define FCOE_MAX_CMD_LEN 16 /* Supported CDB length */ + /* * FIP tunable parameters. */ -- cgit v1.1 From 59c31b69d278b760fb84266f99c1dcb0f73ec51d Mon Sep 17 00:00:00 2001 From: "Martin K. Petersen" Date: Tue, 23 Mar 2010 01:13:28 -0400 Subject: [SCSI] Add missing scsi command definitions Add definitions for VERIFY(12) and VERIFY(32). Signed-off-by: Martin K. Petersen Signed-off-by: James Bottomley --- include/scsi/scsi.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/scsi/scsi.h b/include/scsi/scsi.h index 832f41f..9ae5c61 100644 --- a/include/scsi/scsi.h +++ b/include/scsi/scsi.h @@ -114,6 +114,7 @@ struct scsi_cmnd; #define READ_12 0xa8 #define WRITE_12 0xaa #define WRITE_VERIFY_12 0xae +#define VERIFY_12 0xaf #define SEARCH_HIGH_12 0xb0 #define SEARCH_EQUAL_12 0xb1 #define SEARCH_LOW_12 0xb2 @@ -134,6 +135,7 @@ struct scsi_cmnd; #define MO_SET_TARGET_PGS 0x0a /* values for variable length command */ #define READ_32 0x09 +#define VERIFY_32 0x0a #define WRITE_32 0x0b #define WRITE_SAME_32 0x0d -- cgit v1.1 From 5a2e3995951176e1aaa63d17ae2e1d26ac99003d Mon Sep 17 00:00:00 2001 From: Kei Tokunaga Date: Thu, 1 Apr 2010 20:40:58 +0900 Subject: [SCSI] ftrace: add __print_hex() __print_hex() prints values in an array in hex (w/o '0x') (space separated) EX) 92 33 32 f3 ee 4d Signed-off-by: Li Zefan Signed-off-by: Tomohiro Kusumi Signed-off-by: Kei Tokunaga Acked-by: Steven Rostedt Signed-off-by: James Bottomley --- include/linux/ftrace_event.h | 3 +++ include/trace/ftrace.h | 3 +++ 2 files changed, 6 insertions(+) (limited to 'include') diff --git a/include/linux/ftrace_event.h b/include/linux/ftrace_event.h index c0f4b36..c3c5aaa 100644 --- a/include/linux/ftrace_event.h +++ b/include/linux/ftrace_event.h @@ -25,6 +25,9 @@ const char *ftrace_print_flags_seq(struct trace_seq *p, const char *delim, const char *ftrace_print_symbols_seq(struct trace_seq *p, unsigned long val, const struct trace_print_flags *symbol_array); +const char *ftrace_print_hex_seq(struct trace_seq *p, + const unsigned char *buf, int len); + /* * The trace entry - the most basic unit of tracing. This is what * is printed in the end as a single line in the trace output, such as: diff --git a/include/trace/ftrace.h b/include/trace/ftrace.h index ea6f9d4..c48320b 100644 --- a/include/trace/ftrace.h +++ b/include/trace/ftrace.h @@ -198,6 +198,9 @@ ftrace_print_symbols_seq(p, value, symbols); \ }) +#undef __print_hex +#define __print_hex(buf, buf_len) ftrace_print_hex_seq(p, buf, buf_len) + #undef DECLARE_EVENT_CLASS #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \ static notrace enum print_line_t \ -- cgit v1.1 From bf81623542332bc2cedf3db49cbb2edb724780d2 Mon Sep 17 00:00:00 2001 From: Kei Tokunaga Date: Thu, 1 Apr 2010 20:41:40 +0900 Subject: [SCSI] add scsi trace core functions and put trace points Signed-off-by: Xiao Guangrong Signed-off-by: Tomohiro Kusumi Signed-off-by: Kei Tokunaga Signed-off-by: James Bottomley --- include/trace/events/scsi.h | 328 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 328 insertions(+) create mode 100644 include/trace/events/scsi.h (limited to 'include') diff --git a/include/trace/events/scsi.h b/include/trace/events/scsi.h new file mode 100644 index 0000000..76cbf82 --- /dev/null +++ b/include/trace/events/scsi.h @@ -0,0 +1,328 @@ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM scsi + +#if !defined(_TRACE_SCSI_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_SCSI_H + +#include +#include +#include +#include + +#define scsi_opcode_name(opcode) { opcode, #opcode } +#define show_opcode_name(val) \ + __print_symbolic(val, \ + scsi_opcode_name(TEST_UNIT_READY), \ + scsi_opcode_name(REZERO_UNIT), \ + scsi_opcode_name(REQUEST_SENSE), \ + scsi_opcode_name(FORMAT_UNIT), \ + scsi_opcode_name(READ_BLOCK_LIMITS), \ + scsi_opcode_name(REASSIGN_BLOCKS), \ + scsi_opcode_name(INITIALIZE_ELEMENT_STATUS), \ + scsi_opcode_name(READ_6), \ + scsi_opcode_name(WRITE_6), \ + scsi_opcode_name(SEEK_6), \ + scsi_opcode_name(READ_REVERSE), \ + scsi_opcode_name(WRITE_FILEMARKS), \ + scsi_opcode_name(SPACE), \ + scsi_opcode_name(INQUIRY), \ + scsi_opcode_name(RECOVER_BUFFERED_DATA), \ + scsi_opcode_name(MODE_SELECT), \ + scsi_opcode_name(RESERVE), \ + scsi_opcode_name(RELEASE), \ + scsi_opcode_name(COPY), \ + scsi_opcode_name(ERASE), \ + scsi_opcode_name(MODE_SENSE), \ + scsi_opcode_name(START_STOP), \ + scsi_opcode_name(RECEIVE_DIAGNOSTIC), \ + scsi_opcode_name(SEND_DIAGNOSTIC), \ + scsi_opcode_name(ALLOW_MEDIUM_REMOVAL), \ + scsi_opcode_name(SET_WINDOW), \ + scsi_opcode_name(READ_CAPACITY), \ + scsi_opcode_name(READ_10), \ + scsi_opcode_name(WRITE_10), \ + scsi_opcode_name(SEEK_10), \ + scsi_opcode_name(POSITION_TO_ELEMENT), \ + scsi_opcode_name(WRITE_VERIFY), \ + scsi_opcode_name(VERIFY), \ + scsi_opcode_name(SEARCH_HIGH), \ + scsi_opcode_name(SEARCH_EQUAL), \ + scsi_opcode_name(SEARCH_LOW), \ + scsi_opcode_name(SET_LIMITS), \ + scsi_opcode_name(PRE_FETCH), \ + scsi_opcode_name(READ_POSITION), \ + scsi_opcode_name(SYNCHRONIZE_CACHE), \ + scsi_opcode_name(LOCK_UNLOCK_CACHE), \ + scsi_opcode_name(READ_DEFECT_DATA), \ + scsi_opcode_name(MEDIUM_SCAN), \ + scsi_opcode_name(COMPARE), \ + scsi_opcode_name(COPY_VERIFY), \ + scsi_opcode_name(WRITE_BUFFER), \ + scsi_opcode_name(READ_BUFFER), \ + scsi_opcode_name(UPDATE_BLOCK), \ + scsi_opcode_name(READ_LONG), \ + scsi_opcode_name(WRITE_LONG), \ + scsi_opcode_name(CHANGE_DEFINITION), \ + scsi_opcode_name(WRITE_SAME), \ + scsi_opcode_name(UNMAP), \ + scsi_opcode_name(READ_TOC), \ + scsi_opcode_name(LOG_SELECT), \ + scsi_opcode_name(LOG_SENSE), \ + scsi_opcode_name(XDWRITEREAD_10), \ + scsi_opcode_name(MODE_SELECT_10), \ + scsi_opcode_name(RESERVE_10), \ + scsi_opcode_name(RELEASE_10), \ + scsi_opcode_name(MODE_SENSE_10), \ + scsi_opcode_name(PERSISTENT_RESERVE_IN), \ + scsi_opcode_name(PERSISTENT_RESERVE_OUT), \ + scsi_opcode_name(VARIABLE_LENGTH_CMD), \ + scsi_opcode_name(REPORT_LUNS), \ + scsi_opcode_name(MAINTENANCE_IN), \ + scsi_opcode_name(MAINTENANCE_OUT), \ + scsi_opcode_name(MOVE_MEDIUM), \ + scsi_opcode_name(EXCHANGE_MEDIUM), \ + scsi_opcode_name(READ_12), \ + scsi_opcode_name(WRITE_12), \ + scsi_opcode_name(WRITE_VERIFY_12), \ + scsi_opcode_name(SEARCH_HIGH_12), \ + scsi_opcode_name(SEARCH_EQUAL_12), \ + scsi_opcode_name(SEARCH_LOW_12), \ + scsi_opcode_name(READ_ELEMENT_STATUS), \ + scsi_opcode_name(SEND_VOLUME_TAG), \ + scsi_opcode_name(WRITE_LONG_2), \ + scsi_opcode_name(READ_16), \ + scsi_opcode_name(WRITE_16), \ + scsi_opcode_name(VERIFY_16), \ + scsi_opcode_name(WRITE_SAME_16), \ + scsi_opcode_name(SERVICE_ACTION_IN), \ + scsi_opcode_name(SAI_READ_CAPACITY_16), \ + scsi_opcode_name(SAI_GET_LBA_STATUS), \ + scsi_opcode_name(MI_REPORT_TARGET_PGS), \ + scsi_opcode_name(MO_SET_TARGET_PGS), \ + scsi_opcode_name(READ_32), \ + scsi_opcode_name(WRITE_32), \ + scsi_opcode_name(WRITE_SAME_32), \ + scsi_opcode_name(ATA_16), \ + scsi_opcode_name(ATA_12)) + +#define scsi_hostbyte_name(result) { result, #result } +#define show_hostbyte_name(val) \ + __print_symbolic(val, \ + scsi_hostbyte_name(DID_OK), \ + scsi_hostbyte_name(DID_NO_CONNECT), \ + scsi_hostbyte_name(DID_BUS_BUSY), \ + scsi_hostbyte_name(DID_TIME_OUT), \ + scsi_hostbyte_name(DID_BAD_TARGET), \ + scsi_hostbyte_name(DID_ABORT), \ + scsi_hostbyte_name(DID_PARITY), \ + scsi_hostbyte_name(DID_ERROR), \ + scsi_hostbyte_name(DID_RESET), \ + scsi_hostbyte_name(DID_BAD_INTR), \ + scsi_hostbyte_name(DID_PASSTHROUGH), \ + scsi_hostbyte_name(DID_SOFT_ERROR), \ + scsi_hostbyte_name(DID_IMM_RETRY), \ + scsi_hostbyte_name(DID_REQUEUE), \ + scsi_hostbyte_name(DID_TRANSPORT_DISRUPTED), \ + scsi_hostbyte_name(DID_TRANSPORT_FAILFAST)) + +#define scsi_driverbyte_name(result) { result, #result } +#define show_driverbyte_name(val) \ + __print_symbolic(val, \ + scsi_driverbyte_name(DRIVER_OK), \ + scsi_driverbyte_name(DRIVER_BUSY), \ + scsi_driverbyte_name(DRIVER_SOFT), \ + scsi_driverbyte_name(DRIVER_MEDIA), \ + scsi_driverbyte_name(DRIVER_ERROR), \ + scsi_driverbyte_name(DRIVER_INVALID), \ + scsi_driverbyte_name(DRIVER_TIMEOUT), \ + scsi_driverbyte_name(DRIVER_HARD), \ + scsi_driverbyte_name(DRIVER_SENSE)) + +#define scsi_msgbyte_name(result) { result, #result } +#define show_msgbyte_name(val) \ + __print_symbolic(val, \ + scsi_msgbyte_name(COMMAND_COMPLETE), \ + scsi_msgbyte_name(EXTENDED_MESSAGE), \ + scsi_msgbyte_name(SAVE_POINTERS), \ + scsi_msgbyte_name(RESTORE_POINTERS), \ + scsi_msgbyte_name(DISCONNECT), \ + scsi_msgbyte_name(INITIATOR_ERROR), \ + scsi_msgbyte_name(ABORT_TASK_SET), \ + scsi_msgbyte_name(MESSAGE_REJECT), \ + scsi_msgbyte_name(NOP), \ + scsi_msgbyte_name(MSG_PARITY_ERROR), \ + scsi_msgbyte_name(LINKED_CMD_COMPLETE), \ + scsi_msgbyte_name(LINKED_FLG_CMD_COMPLETE), \ + scsi_msgbyte_name(TARGET_RESET), \ + scsi_msgbyte_name(ABORT_TASK), \ + scsi_msgbyte_name(CLEAR_TASK_SET), \ + scsi_msgbyte_name(INITIATE_RECOVERY), \ + scsi_msgbyte_name(RELEASE_RECOVERY), \ + scsi_msgbyte_name(CLEAR_ACA), \ + scsi_msgbyte_name(LOGICAL_UNIT_RESET), \ + scsi_msgbyte_name(SIMPLE_QUEUE_TAG), \ + scsi_msgbyte_name(HEAD_OF_QUEUE_TAG), \ + scsi_msgbyte_name(ORDERED_QUEUE_TAG), \ + scsi_msgbyte_name(IGNORE_WIDE_RESIDUE), \ + scsi_msgbyte_name(ACA), \ + scsi_msgbyte_name(QAS_REQUEST), \ + scsi_msgbyte_name(BUS_DEVICE_RESET), \ + scsi_msgbyte_name(ABORT)) + +#define scsi_statusbyte_name(result) { result, #result } +#define show_statusbyte_name(val) \ + __print_symbolic(val, \ + scsi_statusbyte_name(SAM_STAT_GOOD), \ + scsi_statusbyte_name(SAM_STAT_CHECK_CONDITION), \ + scsi_statusbyte_name(SAM_STAT_CONDITION_MET), \ + scsi_statusbyte_name(SAM_STAT_BUSY), \ + scsi_statusbyte_name(SAM_STAT_INTERMEDIATE), \ + scsi_statusbyte_name(SAM_STAT_INTERMEDIATE_CONDITION_MET), \ + scsi_statusbyte_name(SAM_STAT_RESERVATION_CONFLICT), \ + scsi_statusbyte_name(SAM_STAT_COMMAND_TERMINATED), \ + scsi_statusbyte_name(SAM_STAT_TASK_SET_FULL), \ + scsi_statusbyte_name(SAM_STAT_ACA_ACTIVE), \ + scsi_statusbyte_name(SAM_STAT_TASK_ABORTED)) + +const char *scsi_trace_parse_cdb(struct trace_seq*, unsigned char*, int); +#define __parse_cdb(cdb, len) scsi_trace_parse_cdb(p, cdb, len) + +TRACE_EVENT(scsi_dispatch_cmd_start, + + TP_PROTO(struct scsi_cmnd *cmd), + + TP_ARGS(cmd), + + TP_STRUCT__entry( + __field( unsigned int, host_no ) + __field( unsigned int, channel ) + __field( unsigned int, id ) + __field( unsigned int, lun ) + __field( unsigned int, opcode ) + __field( unsigned int, cmd_len ) + __dynamic_array(unsigned char, cmnd, cmd->cmd_len) + ), + + TP_fast_assign( + __entry->host_no = cmd->device->host->host_no; + __entry->channel = cmd->device->channel; + __entry->id = cmd->device->id; + __entry->lun = cmd->device->lun; + __entry->opcode = cmd->cmnd[0]; + __entry->cmd_len = cmd->cmd_len; + memcpy(__get_dynamic_array(cmnd), cmd->cmnd, cmd->cmd_len); + ), + + TP_printk("host_no=%u channel=%u id=%u lun=%u cmnd=(%s %s raw=%s)", + __entry->host_no, __entry->channel, __entry->id, + __entry->lun, show_opcode_name(__entry->opcode), + __parse_cdb(__get_dynamic_array(cmnd), __entry->cmd_len), + __print_hex(__get_dynamic_array(cmnd), __entry->cmd_len)) +); + +TRACE_EVENT(scsi_dispatch_cmd_error, + + TP_PROTO(struct scsi_cmnd *cmd, int rtn), + + TP_ARGS(cmd, rtn), + + TP_STRUCT__entry( + __field( unsigned int, host_no ) + __field( unsigned int, channel ) + __field( unsigned int, id ) + __field( unsigned int, lun ) + __field( int, rtn ) + __field( unsigned int, opcode ) + __field( unsigned int, cmd_len ) + __dynamic_array(unsigned char, cmnd, cmd->cmd_len) + ), + + TP_fast_assign( + __entry->host_no = cmd->device->host->host_no; + __entry->channel = cmd->device->channel; + __entry->id = cmd->device->id; + __entry->lun = cmd->device->lun; + __entry->rtn = rtn; + __entry->opcode = cmd->cmnd[0]; + __entry->cmd_len = cmd->cmd_len; + memcpy(__get_dynamic_array(cmnd), cmd->cmnd, cmd->cmd_len); + ), + + TP_printk("host_no=%u channel=%u id=%u lun=%u cmnd=(%s %s raw=%s)" + " rtn=%d", + __entry->host_no, __entry->channel, __entry->id, + __entry->lun, show_opcode_name(__entry->opcode), + __parse_cdb(__get_dynamic_array(cmnd), __entry->cmd_len), + __print_hex(__get_dynamic_array(cmnd), __entry->cmd_len), + __entry->rtn) +); + +DECLARE_EVENT_CLASS(scsi_cmd_done_timeout_template, + + TP_PROTO(struct scsi_cmnd *cmd), + + TP_ARGS(cmd), + + TP_STRUCT__entry( + __field( unsigned int, host_no ) + __field( unsigned int, channel ) + __field( unsigned int, id ) + __field( unsigned int, lun ) + __field( int, result ) + __field( unsigned int, opcode ) + __field( unsigned int, cmd_len ) + __dynamic_array(unsigned char, cmnd, cmd->cmd_len) + ), + + TP_fast_assign( + __entry->host_no = cmd->device->host->host_no; + __entry->channel = cmd->device->channel; + __entry->id = cmd->device->id; + __entry->lun = cmd->device->lun; + __entry->result = cmd->result; + __entry->opcode = cmd->cmnd[0]; + __entry->cmd_len = cmd->cmd_len; + memcpy(__get_dynamic_array(cmnd), cmd->cmnd, cmd->cmd_len); + ), + + TP_printk("host_no=%u channel=%u id=%u lun=%u cmnd=(%s %s raw=%s) " + "result=(driver=%s host=%s message=%s status=%s)", + __entry->host_no, __entry->channel, __entry->id, + __entry->lun, show_opcode_name(__entry->opcode), + __parse_cdb(__get_dynamic_array(cmnd), __entry->cmd_len), + __print_hex(__get_dynamic_array(cmnd), __entry->cmd_len), + show_driverbyte_name(((__entry->result) >> 24) & 0xff), + show_hostbyte_name(((__entry->result) >> 16) & 0xff), + show_msgbyte_name(((__entry->result) >> 8) & 0xff), + show_statusbyte_name(__entry->result & 0xff)) +); + +DEFINE_EVENT(scsi_cmd_done_timeout_template, scsi_dispatch_cmd_done, + TP_PROTO(struct scsi_cmnd *cmd), + TP_ARGS(cmd)); + +DEFINE_EVENT(scsi_cmd_done_timeout_template, scsi_dispatch_cmd_timeout, + TP_PROTO(struct scsi_cmnd *cmd), + TP_ARGS(cmd)); + +TRACE_EVENT(scsi_eh_wakeup, + + TP_PROTO(struct Scsi_Host *shost), + + TP_ARGS(shost), + + TP_STRUCT__entry( + __field( unsigned int, host_no ) + ), + + TP_fast_assign( + __entry->host_no = shost->host_no; + ), + + TP_printk("host_no=%u", __entry->host_no) +); + +#endif /* _TRACE_SCSI_H */ + +/* This part must be outside protection */ +#include -- cgit v1.1 From c446c1f9907e84d014edb0bf3501f30cb512e06a Mon Sep 17 00:00:00 2001 From: "Martin K. Petersen" Date: Tue, 23 Mar 2010 01:16:57 -0400 Subject: [SCSI] scsi_trace: Enhance SCSI command tracing Various SCSI trace enhancements: - Display data and protection information scatterlist lengths in the trace output - Add support for VERIFY and WRITE SAME commands and decode the UNMAP bit if applicable - Add decoding of the PROTECT field for READ/VERIFY/WRITE/WRITE SAME commands as well as the EXPECTED INITIAL REFERENCE TAG field for their 32-byte variants - Decode READ CAPACITY(16), GET LBA STATUS, and UNMAP Signed-off-by: Martin K. Petersen Signed-off-by: James Bottomley --- include/trace/events/scsi.h | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) (limited to 'include') diff --git a/include/trace/events/scsi.h b/include/trace/events/scsi.h index 76cbf82..25fbefd 100644 --- a/include/trace/events/scsi.h +++ b/include/trace/events/scsi.h @@ -200,6 +200,8 @@ TRACE_EVENT(scsi_dispatch_cmd_start, __field( unsigned int, lun ) __field( unsigned int, opcode ) __field( unsigned int, cmd_len ) + __field( unsigned int, data_sglen ) + __field( unsigned int, prot_sglen ) __dynamic_array(unsigned char, cmnd, cmd->cmd_len) ), @@ -210,12 +212,16 @@ TRACE_EVENT(scsi_dispatch_cmd_start, __entry->lun = cmd->device->lun; __entry->opcode = cmd->cmnd[0]; __entry->cmd_len = cmd->cmd_len; + __entry->data_sglen = scsi_sg_count(cmd); + __entry->prot_sglen = scsi_prot_sg_count(cmd); memcpy(__get_dynamic_array(cmnd), cmd->cmnd, cmd->cmd_len); ), - TP_printk("host_no=%u channel=%u id=%u lun=%u cmnd=(%s %s raw=%s)", + TP_printk("host_no=%u channel=%u id=%u lun=%u data_sgl=%u prot_sgl=%u" \ + " cmnd=(%s %s raw=%s)", __entry->host_no, __entry->channel, __entry->id, - __entry->lun, show_opcode_name(__entry->opcode), + __entry->lun, __entry->data_sglen, __entry->prot_sglen, + show_opcode_name(__entry->opcode), __parse_cdb(__get_dynamic_array(cmnd), __entry->cmd_len), __print_hex(__get_dynamic_array(cmnd), __entry->cmd_len)) ); @@ -234,6 +240,8 @@ TRACE_EVENT(scsi_dispatch_cmd_error, __field( int, rtn ) __field( unsigned int, opcode ) __field( unsigned int, cmd_len ) + __field( unsigned int, data_sglen ) + __field( unsigned int, prot_sglen ) __dynamic_array(unsigned char, cmnd, cmd->cmd_len) ), @@ -245,13 +253,16 @@ TRACE_EVENT(scsi_dispatch_cmd_error, __entry->rtn = rtn; __entry->opcode = cmd->cmnd[0]; __entry->cmd_len = cmd->cmd_len; + __entry->data_sglen = scsi_sg_count(cmd); + __entry->prot_sglen = scsi_prot_sg_count(cmd); memcpy(__get_dynamic_array(cmnd), cmd->cmnd, cmd->cmd_len); ), - TP_printk("host_no=%u channel=%u id=%u lun=%u cmnd=(%s %s raw=%s)" - " rtn=%d", + TP_printk("host_no=%u channel=%u id=%u lun=%u data_sgl=%u prot_sgl=%u" \ + " cmnd=(%s %s raw=%s) rtn=%d", __entry->host_no, __entry->channel, __entry->id, - __entry->lun, show_opcode_name(__entry->opcode), + __entry->lun, __entry->data_sglen, __entry->prot_sglen, + show_opcode_name(__entry->opcode), __parse_cdb(__get_dynamic_array(cmnd), __entry->cmd_len), __print_hex(__get_dynamic_array(cmnd), __entry->cmd_len), __entry->rtn) @@ -271,6 +282,8 @@ DECLARE_EVENT_CLASS(scsi_cmd_done_timeout_template, __field( int, result ) __field( unsigned int, opcode ) __field( unsigned int, cmd_len ) + __field( unsigned int, data_sglen ) + __field( unsigned int, prot_sglen ) __dynamic_array(unsigned char, cmnd, cmd->cmd_len) ), @@ -282,13 +295,17 @@ DECLARE_EVENT_CLASS(scsi_cmd_done_timeout_template, __entry->result = cmd->result; __entry->opcode = cmd->cmnd[0]; __entry->cmd_len = cmd->cmd_len; + __entry->data_sglen = scsi_sg_count(cmd); + __entry->prot_sglen = scsi_prot_sg_count(cmd); memcpy(__get_dynamic_array(cmnd), cmd->cmnd, cmd->cmd_len); ), - TP_printk("host_no=%u channel=%u id=%u lun=%u cmnd=(%s %s raw=%s) " - "result=(driver=%s host=%s message=%s status=%s)", + TP_printk("host_no=%u channel=%u id=%u lun=%u data_sgl=%u " \ + "prot_sgl=%u cmnd=(%s %s raw=%s) result=(driver=%s host=%s " \ + "message=%s status=%s)", __entry->host_no, __entry->channel, __entry->id, - __entry->lun, show_opcode_name(__entry->opcode), + __entry->lun, __entry->data_sglen, __entry->prot_sglen, + show_opcode_name(__entry->opcode), __parse_cdb(__get_dynamic_array(cmnd), __entry->cmd_len), __print_hex(__get_dynamic_array(cmnd), __entry->cmd_len), show_driverbyte_name(((__entry->result) >> 24) & 0xff), -- cgit v1.1 From 7407e5bba2cc821950344fd1391d9ad1b7e0b397 Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Tue, 27 Apr 2010 14:11:47 -0700 Subject: [SCSI] Unexport scsi/scsi.h from headers_install The scsi/scsi.h header is normally provided by the libc (and was not exported by the kernel since 2.6.24) and has been until it was re-exported with 2.6.31. The kernel version is not userspace clean and does not appear to provide anything useable in userland over the (e)glibc version. Signed-off-by: Tom Rini Signed-off-by: James Bottomley --- include/scsi/Kbuild | 1 - 1 file changed, 1 deletion(-) (limited to 'include') diff --git a/include/scsi/Kbuild b/include/scsi/Kbuild index b3a0ee6..f2b9491 100644 --- a/include/scsi/Kbuild +++ b/include/scsi/Kbuild @@ -1,4 +1,3 @@ -header-y += scsi.h header-y += scsi_netlink.h header-y += scsi_netlink_fc.h header-y += scsi_bsg_fc.h -- cgit v1.1 From 1b80e0f91c41db4633c0a61f727de169a9e9b275 Mon Sep 17 00:00:00 2001 From: Robert Love Date: Fri, 7 May 2010 15:18:24 -0700 Subject: [SCSI] libfc: Remove unused fc_get_host_port_type Remove this unused routine. Signed-off-by: Robert Love Signed-off-by: James Bottomley --- include/scsi/libfc.h | 1 - 1 file changed, 1 deletion(-) (limited to 'include') diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h index a26bb50..1755fa7 100644 --- a/include/scsi/libfc.h +++ b/include/scsi/libfc.h @@ -1049,7 +1049,6 @@ void fc_exch_mgr_reset(struct fc_lport *, u32 s_id, u32 d_id); * Functions for fc_functions_template */ void fc_get_host_speed(struct Scsi_Host *); -void fc_get_host_port_type(struct Scsi_Host *); void fc_get_host_port_state(struct Scsi_Host *); void fc_set_rport_loss_tmo(struct fc_rport *, u32 timeout); struct fc_host_statistics *fc_get_host_stats(struct Scsi_Host *); -- cgit v1.1 From 7b2787ec15b9d1c2f716da61b0eec21a3f5e6520 Mon Sep 17 00:00:00 2001 From: Robert Love Date: Fri, 7 May 2010 15:18:41 -0700 Subject: [SCSI] libfc: Move the port_id into lport This patch creates a port_id member in struct fc_lport. This allows libfc to just deal with fc_lport instances instead of calling into the fc_host to get the port_id. This change helps in only using symbols necessary for operation from the libfc structures. libfc still needs to change the fc_host_port_id() if the port_id changes so the presentation layer (scsi_transport_fc) can provide the user with the correct value, but libfc shouldn't rely on the presentation layer for operational values. Signed-off-by: Robert Love Signed-off-by: James Bottomley --- include/scsi/fc_encode.h | 18 +++++++----------- include/scsi/libfc.h | 2 ++ 2 files changed, 9 insertions(+), 11 deletions(-) (limited to 'include') diff --git a/include/scsi/fc_encode.h b/include/scsi/fc_encode.h index 8eb0a0f..9b4867c 100644 --- a/include/scsi/fc_encode.h +++ b/include/scsi/fc_encode.h @@ -74,7 +74,7 @@ static inline void fc_adisc_fill(struct fc_lport *lport, struct fc_frame *fp) adisc->adisc_cmd = ELS_ADISC; put_unaligned_be64(lport->wwpn, &adisc->adisc_wwpn); put_unaligned_be64(lport->wwnn, &adisc->adisc_wwnn); - hton24(adisc->adisc_port_id, fc_host_port_id(lport->host)); + hton24(adisc->adisc_port_id, lport->port_id); } /** @@ -127,15 +127,13 @@ static inline int fc_ct_fill(struct fc_lport *lport, case FC_NS_RFT_ID: ct = fc_ct_hdr_fill(fp, op, sizeof(struct fc_ns_rft)); - hton24(ct->payload.rft.fid.fp_fid, - fc_host_port_id(lport->host)); + hton24(ct->payload.rft.fid.fp_fid, lport->port_id); ct->payload.rft.fts = lport->fcts; break; case FC_NS_RFF_ID: ct = fc_ct_hdr_fill(fp, op, sizeof(struct fc_ns_rff_id)); - hton24(ct->payload.rff.fr_fid.fp_fid, - fc_host_port_id(lport->host)); + hton24(ct->payload.rff.fr_fid.fp_fid, lport->port_id); ct->payload.rff.fr_type = FC_TYPE_FCP; if (lport->service_params & FCP_SPPF_INIT_FCN) ct->payload.rff.fr_feat = FCP_FEAT_INIT; @@ -145,16 +143,14 @@ static inline int fc_ct_fill(struct fc_lport *lport, case FC_NS_RNN_ID: ct = fc_ct_hdr_fill(fp, op, sizeof(struct fc_ns_rn_id)); - hton24(ct->payload.rn.fr_fid.fp_fid, - fc_host_port_id(lport->host)); + hton24(ct->payload.rn.fr_fid.fp_fid, lport->port_id); put_unaligned_be64(lport->wwnn, &ct->payload.rn.fr_wwn); break; case FC_NS_RSPN_ID: len = strnlen(fc_host_symbolic_name(lport->host), 255); ct = fc_ct_hdr_fill(fp, op, sizeof(struct fc_ns_rspn) + len); - hton24(ct->payload.spn.fr_fid.fp_fid, - fc_host_port_id(lport->host)); + hton24(ct->payload.spn.fr_fid.fp_fid, lport->port_id); strncpy(ct->payload.spn.fr_name, fc_host_symbolic_name(lport->host), len); ct->payload.spn.fr_name_len = len; @@ -268,7 +264,7 @@ static inline void fc_logo_fill(struct fc_lport *lport, struct fc_frame *fp) logo = fc_frame_payload_get(fp, sizeof(*logo)); memset(logo, 0, sizeof(*logo)); logo->fl_cmd = ELS_LOGO; - hton24(logo->fl_n_port_id, fc_host_port_id(lport->host)); + hton24(logo->fl_n_port_id, lport->port_id); logo->fl_n_port_wwn = htonll(lport->wwpn); } @@ -295,7 +291,7 @@ static inline void fc_rec_fill(struct fc_lport *lport, struct fc_frame *fp) rec = fc_frame_payload_get(fp, sizeof(*rec)); memset(rec, 0, sizeof(*rec)); rec->rec_cmd = ELS_REC; - hton24(rec->rec_s_id, fc_host_port_id(lport->host)); + hton24(rec->rec_s_id, lport->port_id); rec->rec_ox_id = htons(ep->oxid); rec->rec_rx_id = htons(ep->rxid); } diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h index 1755fa7..7495c0b 100644 --- a/include/scsi/libfc.h +++ b/include/scsi/libfc.h @@ -780,6 +780,7 @@ struct fc_disc { * @dev_stats: FCoE device stats (TODO: libfc should not be * FCoE aware) * @retry_count: Number of retries in the current state + * @port_id: FC Port ID * @wwpn: World Wide Port Name * @wwnn: World Wide Node Name * @service_params: Common service parameters @@ -826,6 +827,7 @@ struct fc_lport { u8 retry_count; /* Fabric information */ + u32 port_id; u64 wwpn; u64 wwnn; unsigned int service_params; -- cgit v1.1