@@ -527,183 +527,79 @@ void zfcp_dbf_rec_run(char *tag, struct zfcp_erp_action *erp)
527527 spin_unlock_irqrestore (& dbf -> rec_lock , flags );
528528}
529529
530- /**
531- * zfcp_dbf_san_ct_request - trace event for issued CT request
532- * @fsf_req: request containing issued CT data
533- * @d_id: destination id where ct request is sent to
534- */
535- void zfcp_dbf_san_ct_request (struct zfcp_fsf_req * fsf_req , u32 d_id )
536- {
537- struct zfcp_fsf_ct_els * ct = (struct zfcp_fsf_ct_els * )fsf_req -> data ;
538- struct zfcp_adapter * adapter = fsf_req -> adapter ;
539- struct zfcp_dbf * dbf = adapter -> dbf ;
540- struct fc_ct_hdr * hdr = sg_virt (ct -> req );
541- struct zfcp_dbf_san_record * r = & dbf -> san_buf ;
542- struct zfcp_dbf_san_record_ct_request * oct = & r -> u .ct_req ;
543- int level = 3 ;
544- unsigned long flags ;
545-
546- spin_lock_irqsave (& dbf -> san_lock , flags );
547- memset (r , 0 , sizeof (* r ));
548- strncpy (r -> tag , "octc" , ZFCP_DBF_TAG_SIZE );
549- r -> fsf_reqid = fsf_req -> req_id ;
550- r -> fsf_seqno = fsf_req -> seq_no ;
551- oct -> d_id = d_id ;
552- oct -> cmd_req_code = hdr -> ct_cmd ;
553- oct -> revision = hdr -> ct_rev ;
554- oct -> gs_type = hdr -> ct_fs_type ;
555- oct -> gs_subtype = hdr -> ct_fs_subtype ;
556- oct -> options = hdr -> ct_options ;
557- oct -> max_res_size = hdr -> ct_mr_size ;
558- oct -> len = min ((int )ct -> req -> length - (int )sizeof (struct fc_ct_hdr ),
559- ZFCP_DBF_SAN_MAX_PAYLOAD );
560- debug_event (dbf -> san , level , r , sizeof (* r ));
561- zfcp_dbf_hexdump (dbf -> san , r , sizeof (* r ), level ,
562- (void * )hdr + sizeof (struct fc_ct_hdr ), oct -> len );
563- spin_unlock_irqrestore (& dbf -> san_lock , flags );
564- }
565-
566- /**
567- * zfcp_dbf_san_ct_response - trace event for completion of CT request
568- * @fsf_req: request containing CT response
569- */
570- void zfcp_dbf_san_ct_response (struct zfcp_fsf_req * fsf_req )
530+ static inline
531+ void zfcp_dbf_san (char * tag , struct zfcp_dbf * dbf , void * data , u8 id , u16 len ,
532+ u64 req_id , u32 d_id )
571533{
572- struct zfcp_fsf_ct_els * ct = (struct zfcp_fsf_ct_els * )fsf_req -> data ;
573- struct zfcp_adapter * adapter = fsf_req -> adapter ;
574- struct fc_ct_hdr * hdr = sg_virt (ct -> resp );
575- struct zfcp_dbf * dbf = adapter -> dbf ;
576- struct zfcp_dbf_san_record * r = & dbf -> san_buf ;
577- struct zfcp_dbf_san_record_ct_response * rct = & r -> u .ct_resp ;
578- int level = 3 ;
534+ struct zfcp_dbf_san * rec = & dbf -> san_buf ;
535+ u16 rec_len ;
579536 unsigned long flags ;
580537
581538 spin_lock_irqsave (& dbf -> san_lock , flags );
582- memset (r , 0 , sizeof (* r ));
583- strncpy (r -> tag , "rctc" , ZFCP_DBF_TAG_SIZE );
584- r -> fsf_reqid = fsf_req -> req_id ;
585- r -> fsf_seqno = fsf_req -> seq_no ;
586- rct -> cmd_rsp_code = hdr -> ct_cmd ;
587- rct -> revision = hdr -> ct_rev ;
588- rct -> reason_code = hdr -> ct_reason ;
589- rct -> expl = hdr -> ct_explan ;
590- rct -> vendor_unique = hdr -> ct_vendor ;
591- rct -> max_res_size = hdr -> ct_mr_size ;
592- rct -> len = min ((int )ct -> resp -> length - (int )sizeof (struct fc_ct_hdr ),
593- ZFCP_DBF_SAN_MAX_PAYLOAD );
594- debug_event (dbf -> san , level , r , sizeof (* r ));
595- zfcp_dbf_hexdump (dbf -> san , r , sizeof (* r ), level ,
596- (void * )hdr + sizeof (struct fc_ct_hdr ), rct -> len );
597- spin_unlock_irqrestore (& dbf -> san_lock , flags );
598- }
539+ memset (rec , 0 , sizeof (* rec ));
599540
600- static void zfcp_dbf_san_els (const char * tag , int level ,
601- struct zfcp_fsf_req * fsf_req , u32 d_id ,
602- void * buffer , int buflen )
603- {
604- struct zfcp_adapter * adapter = fsf_req -> adapter ;
605- struct zfcp_dbf * dbf = adapter -> dbf ;
606- struct zfcp_dbf_san_record * rec = & dbf -> san_buf ;
607- unsigned long flags ;
541+ rec -> id = id ;
542+ rec -> fsf_req_id = req_id ;
543+ rec -> d_id = d_id ;
544+ rec_len = min (len , (u16 )ZFCP_DBF_SAN_MAX_PAYLOAD );
545+ memcpy (rec -> payload , data , rec_len );
546+ memcpy (rec -> tag , tag , ZFCP_DBF_TAG_LEN );
608547
609- spin_lock_irqsave (& dbf -> san_lock , flags );
610- memset (rec , 0 , sizeof (* rec ));
611- strncpy (rec -> tag , tag , ZFCP_DBF_TAG_SIZE );
612- rec -> fsf_reqid = fsf_req -> req_id ;
613- rec -> fsf_seqno = fsf_req -> seq_no ;
614- rec -> u .els .d_id = d_id ;
615- debug_event (dbf -> san , level , rec , sizeof (* rec ));
616- zfcp_dbf_hexdump (dbf -> san , rec , sizeof (* rec ), level ,
617- buffer , min (buflen , ZFCP_DBF_SAN_MAX_PAYLOAD ));
548+ debug_event (dbf -> san , 1 , rec , sizeof (* rec ));
618549 spin_unlock_irqrestore (& dbf -> san_lock , flags );
619550}
620551
621552/**
622- * zfcp_dbf_san_els_request - trace event for issued ELS
623- * @fsf_req: request containing issued ELS
553+ * zfcp_dbf_san_req - trace event for issued SAN request
554+ * @tag: indentifier for event
555+ * @fsf_req: request containing issued CT data
556+ * d_id: destination ID
624557 */
625- void zfcp_dbf_san_els_request ( struct zfcp_fsf_req * fsf_req )
558+ void zfcp_dbf_san_req ( char * tag , struct zfcp_fsf_req * fsf , u32 d_id )
626559{
627- struct zfcp_fsf_ct_els * els = (struct zfcp_fsf_ct_els * )fsf_req -> data ;
628- u32 d_id = ntoh24 (fsf_req -> qtcb -> bottom .support .d_id );
560+ struct zfcp_dbf * dbf = fsf -> adapter -> dbf ;
561+ struct zfcp_fsf_ct_els * ct_els = fsf -> data ;
562+ u16 length ;
629563
630- zfcp_dbf_san_els ("oels" , 2 , fsf_req , d_id ,
631- sg_virt (els -> req ), els -> req -> length );
564+ length = (u16 )(ct_els -> req -> length + FC_CT_HDR_LEN );
565+ zfcp_dbf_san (tag , dbf , sg_virt (ct_els -> req ), ZFCP_DBF_SAN_REQ , length ,
566+ fsf -> req_id , d_id );
632567}
633568
634569/**
635- * zfcp_dbf_san_els_response - trace event for completed ELS
636- * @fsf_req: request containing ELS response
570+ * zfcp_dbf_san_res - trace event for received SAN request
571+ * @tag: indentifier for event
572+ * @fsf_req: request containing issued CT data
637573 */
638- void zfcp_dbf_san_els_response ( struct zfcp_fsf_req * fsf_req )
574+ void zfcp_dbf_san_res ( char * tag , struct zfcp_fsf_req * fsf )
639575{
640- struct zfcp_fsf_ct_els * els = (struct zfcp_fsf_ct_els * )fsf_req -> data ;
641- u32 d_id = ntoh24 (fsf_req -> qtcb -> bottom .support .d_id );
576+ struct zfcp_dbf * dbf = fsf -> adapter -> dbf ;
577+ struct zfcp_fsf_ct_els * ct_els = fsf -> data ;
578+ u16 length ;
642579
643- zfcp_dbf_san_els ("rels" , 2 , fsf_req , d_id ,
644- sg_virt (els -> resp ), els -> resp -> length );
580+ length = (u16 )(ct_els -> resp -> length + FC_CT_HDR_LEN );
581+ zfcp_dbf_san (tag , dbf , sg_virt (ct_els -> resp ), ZFCP_DBF_SAN_RES , length ,
582+ fsf -> req_id , 0 );
645583}
646584
647585/**
648- * zfcp_dbf_san_incoming_els - trace event for incomig ELS
649- * @fsf_req: request containing unsolicited status buffer with incoming ELS
586+ * zfcp_dbf_san_in_els - trace event for incoming ELS
587+ * @tag: indentifier for event
588+ * @fsf_req: request containing issued CT data
650589 */
651- void zfcp_dbf_san_incoming_els (struct zfcp_fsf_req * fsf_req )
652- {
653- struct fsf_status_read_buffer * buf =
654- (struct fsf_status_read_buffer * )fsf_req -> data ;
655- int length = (int )buf -> length -
656- (int )((void * )& buf -> payload - (void * )buf );
657-
658- zfcp_dbf_san_els ("iels" , 1 , fsf_req , ntoh24 (buf -> d_id ),
659- (void * )buf -> payload .data , length );
660- }
661-
662- static int zfcp_dbf_san_view_format (debug_info_t * id , struct debug_view * view ,
663- char * out_buf , const char * in_buf )
590+ void zfcp_dbf_san_in_els (char * tag , struct zfcp_fsf_req * fsf )
664591{
665- struct zfcp_dbf_san_record * r = (struct zfcp_dbf_san_record * )in_buf ;
666- char * p = out_buf ;
667-
668- if (strncmp (r -> tag , "dump" , ZFCP_DBF_TAG_SIZE ) == 0 )
669- return 0 ;
670-
671- zfcp_dbf_tag (& p , "tag" , r -> tag );
672- zfcp_dbf_out (& p , "fsf_reqid" , "0x%0Lx" , r -> fsf_reqid );
673- zfcp_dbf_out (& p , "fsf_seqno" , "0x%08x" , r -> fsf_seqno );
674-
675- if (strncmp (r -> tag , "octc" , ZFCP_DBF_TAG_SIZE ) == 0 ) {
676- struct zfcp_dbf_san_record_ct_request * ct = & r -> u .ct_req ;
677- zfcp_dbf_out (& p , "d_id" , "0x%06x" , ct -> d_id );
678- zfcp_dbf_out (& p , "cmd_req_code" , "0x%04x" , ct -> cmd_req_code );
679- zfcp_dbf_out (& p , "revision" , "0x%02x" , ct -> revision );
680- zfcp_dbf_out (& p , "gs_type" , "0x%02x" , ct -> gs_type );
681- zfcp_dbf_out (& p , "gs_subtype" , "0x%02x" , ct -> gs_subtype );
682- zfcp_dbf_out (& p , "options" , "0x%02x" , ct -> options );
683- zfcp_dbf_out (& p , "max_res_size" , "0x%04x" , ct -> max_res_size );
684- } else if (strncmp (r -> tag , "rctc" , ZFCP_DBF_TAG_SIZE ) == 0 ) {
685- struct zfcp_dbf_san_record_ct_response * ct = & r -> u .ct_resp ;
686- zfcp_dbf_out (& p , "cmd_rsp_code" , "0x%04x" , ct -> cmd_rsp_code );
687- zfcp_dbf_out (& p , "revision" , "0x%02x" , ct -> revision );
688- zfcp_dbf_out (& p , "reason_code" , "0x%02x" , ct -> reason_code );
689- zfcp_dbf_out (& p , "reason_code_expl" , "0x%02x" , ct -> expl );
690- zfcp_dbf_out (& p , "vendor_unique" , "0x%02x" , ct -> vendor_unique );
691- zfcp_dbf_out (& p , "max_res_size" , "0x%04x" , ct -> max_res_size );
692- } else if (strncmp (r -> tag , "oels" , ZFCP_DBF_TAG_SIZE ) == 0 ||
693- strncmp (r -> tag , "rels" , ZFCP_DBF_TAG_SIZE ) == 0 ||
694- strncmp (r -> tag , "iels" , ZFCP_DBF_TAG_SIZE ) == 0 ) {
695- struct zfcp_dbf_san_record_els * els = & r -> u .els ;
696- zfcp_dbf_out (& p , "d_id" , "0x%06x" , els -> d_id );
697- }
698- return p - out_buf ;
592+ struct zfcp_dbf * dbf = fsf -> adapter -> dbf ;
593+ struct fsf_status_read_buffer * srb =
594+ (struct fsf_status_read_buffer * ) fsf -> data ;
595+ u16 length ;
596+
597+ length = (u16 )(srb -> length -
598+ offsetof(struct fsf_status_read_buffer , payload ));
599+ zfcp_dbf_san (tag , dbf , srb -> payload .data , ZFCP_DBF_SAN_ELS , length ,
600+ fsf -> req_id , ntoh24 (srb -> d_id ));
699601}
700602
701- static struct debug_view zfcp_dbf_san_view = {
702- .name = "structured" ,
703- .header_proc = zfcp_dbf_view_header ,
704- .format_proc = zfcp_dbf_san_view_format ,
705- };
706-
707603void _zfcp_dbf_scsi (const char * tag , const char * tag2 , int level ,
708604 struct zfcp_dbf * dbf , struct scsi_cmnd * scsi_cmnd ,
709605 struct zfcp_fsf_req * fsf_req , unsigned long old_req_id )
@@ -882,8 +778,7 @@ int zfcp_dbf_adapter_register(struct zfcp_adapter *adapter)
882778
883779 /* debug feature area which records SAN command failures and recovery */
884780 sprintf (dbf_name , "zfcp_%s_san" , dev_name (& adapter -> ccw_device -> dev ));
885- dbf -> san = zfcp_dbf_reg (dbf_name , 6 , & zfcp_dbf_san_view ,
886- sizeof (struct zfcp_dbf_san_record ));
781+ dbf -> san = zfcp_dbf_reg (dbf_name , 3 , NULL , sizeof (struct zfcp_dbf_san ));
887782 if (!dbf -> san )
888783 goto err_out ;
889784
0 commit comments