Skip to content

Commit 2c55b75

Browse files
sswenJames Bottomley
authored andcommitted
[SCSI] zfcp: Redesign of the debug tracing for SAN records.
This patch is the continuation to redesign the zfcp tracing to a more straight-forward and easy to extend scheme. This patch deals with all trace records of the zfcp SAN area. Signed-off-by: Swen Schillig <swen@vnet.ibm.com> Signed-off-by: Christof Schmitt <christof.schmitt@de.ibm.com> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
1 parent ae0904f commit 2c55b75

File tree

5 files changed

+85
-202
lines changed

5 files changed

+85
-202
lines changed

drivers/s390/scsi/zfcp_dbf.c

Lines changed: 48 additions & 153 deletions
Original file line numberDiff line numberDiff line change
@@ -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-
707603
void _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

drivers/s390/scsi/zfcp_dbf.h

Lines changed: 29 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,34 @@ struct zfcp_dbf_rec {
108108
} u;
109109
} __packed;
110110

111+
/**
112+
* enum zfcp_dbf_san_id - SAN trace record identifier
113+
* @ZFCP_DBF_SAN_REQ: request trace record id
114+
* @ZFCP_DBF_SAN_RES: response trace record id
115+
* @ZFCP_DBF_SAN_ELS: extended link service record id
116+
*/
117+
enum zfcp_dbf_san_id {
118+
ZFCP_DBF_SAN_REQ = 1,
119+
ZFCP_DBF_SAN_RES = 2,
120+
ZFCP_DBF_SAN_ELS = 3,
121+
};
122+
123+
/** struct zfcp_dbf_san - trace record for SAN requests and responses
124+
* @id: unique number of recovery record type
125+
* @tag: identifier string specifying the location of initiation
126+
* @fsf_req_id: request id for fsf requests
127+
* @payload: unformatted information related to request/response
128+
* @d_id: destination id
129+
*/
130+
struct zfcp_dbf_san {
131+
u8 id;
132+
char tag[ZFCP_DBF_TAG_LEN];
133+
u64 fsf_req_id;
134+
u32 d_id;
135+
#define ZFCP_DBF_SAN_MAX_PAYLOAD (FC_CT_HDR_LEN + 32)
136+
char payload[ZFCP_DBF_SAN_MAX_PAYLOAD];
137+
} __packed;
138+
111139
struct zfcp_dbf_hba_record_response {
112140
u32 fsf_command;
113141
u64 fsf_reqid;
@@ -176,44 +204,6 @@ struct zfcp_dbf_hba_record {
176204
} u;
177205
} __attribute__ ((packed));
178206

179-
struct zfcp_dbf_san_record_ct_request {
180-
u16 cmd_req_code;
181-
u8 revision;
182-
u8 gs_type;
183-
u8 gs_subtype;
184-
u8 options;
185-
u16 max_res_size;
186-
u32 len;
187-
u32 d_id;
188-
} __attribute__ ((packed));
189-
190-
struct zfcp_dbf_san_record_ct_response {
191-
u16 cmd_rsp_code;
192-
u8 revision;
193-
u8 reason_code;
194-
u8 expl;
195-
u8 vendor_unique;
196-
u16 max_res_size;
197-
u32 len;
198-
} __attribute__ ((packed));
199-
200-
struct zfcp_dbf_san_record_els {
201-
u32 d_id;
202-
} __attribute__ ((packed));
203-
204-
struct zfcp_dbf_san_record {
205-
u8 tag[ZFCP_DBF_TAG_SIZE];
206-
u64 fsf_reqid;
207-
u32 fsf_seqno;
208-
union {
209-
struct zfcp_dbf_san_record_ct_request ct_req;
210-
struct zfcp_dbf_san_record_ct_response ct_resp;
211-
struct zfcp_dbf_san_record_els els;
212-
} u;
213-
} __attribute__ ((packed));
214-
215-
#define ZFCP_DBF_SAN_MAX_PAYLOAD 1024
216-
217207
struct zfcp_dbf_scsi_record {
218208
u8 tag[ZFCP_DBF_TAG_SIZE];
219209
u8 tag2[ZFCP_DBF_TAG_SIZE];
@@ -250,7 +240,7 @@ struct zfcp_dbf {
250240
spinlock_t scsi_lock;
251241
struct zfcp_dbf_rec rec_buf;
252242
struct zfcp_dbf_hba_record hba_buf;
253-
struct zfcp_dbf_san_record san_buf;
243+
struct zfcp_dbf_san san_buf;
254244
struct zfcp_dbf_scsi_record scsi_buf;
255245
struct zfcp_adapter *adapter;
256246
};

drivers/s390/scsi/zfcp_ext.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,9 @@ extern void _zfcp_dbf_hba_fsf_unsol(const char *, int level, struct zfcp_dbf *,
5555
struct fsf_status_read_buffer *);
5656
extern void zfcp_dbf_hba_qdio(struct zfcp_dbf *, unsigned int, int, int);
5757
extern void zfcp_dbf_hba_berr(struct zfcp_dbf *, struct zfcp_fsf_req *);
58-
extern void zfcp_dbf_san_ct_request(struct zfcp_fsf_req *, u32);
59-
extern void zfcp_dbf_san_ct_response(struct zfcp_fsf_req *);
60-
extern void zfcp_dbf_san_els_request(struct zfcp_fsf_req *);
61-
extern void zfcp_dbf_san_els_response(struct zfcp_fsf_req *);
62-
extern void zfcp_dbf_san_incoming_els(struct zfcp_fsf_req *);
58+
extern void zfcp_dbf_san_req(char *, struct zfcp_fsf_req *, u32);
59+
extern void zfcp_dbf_san_res(char *, struct zfcp_fsf_req *);
60+
extern void zfcp_dbf_san_in_els(char *, struct zfcp_fsf_req *);
6361
extern void _zfcp_dbf_scsi(const char *, const char *, int, struct zfcp_dbf *,
6462
struct scsi_cmnd *, struct zfcp_fsf_req *,
6563
unsigned long);

drivers/s390/scsi/zfcp_fc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ void zfcp_fc_incoming_els(struct zfcp_fsf_req *fsf_req)
251251
(struct fsf_status_read_buffer *) fsf_req->data;
252252
unsigned int els_type = status_buffer->payload.data[0];
253253

254-
zfcp_dbf_san_incoming_els(fsf_req);
254+
zfcp_dbf_san_in_els("fciels1", fsf_req);
255255
if (els_type == ELS_PLOGI)
256256
zfcp_fc_incoming_plogi(fsf_req);
257257
else if (els_type == ELS_LOGO)

drivers/s390/scsi/zfcp_fsf.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -882,7 +882,7 @@ static void zfcp_fsf_send_ct_handler(struct zfcp_fsf_req *req)
882882

883883
switch (header->fsf_status) {
884884
case FSF_GOOD:
885-
zfcp_dbf_san_ct_response(req);
885+
zfcp_dbf_san_res("fsscth1", req);
886886
ct->status = 0;
887887
break;
888888
case FSF_SERVICE_CLASS_NOT_SUPPORTED:
@@ -1025,7 +1025,7 @@ int zfcp_fsf_send_ct(struct zfcp_fc_wka_port *wka_port,
10251025
req->qtcb->header.port_handle = wka_port->handle;
10261026
req->data = ct;
10271027

1028-
zfcp_dbf_san_ct_request(req, wka_port->d_id);
1028+
zfcp_dbf_san_req("fssct_1", req, wka_port->d_id);
10291029

10301030
ret = zfcp_fsf_req_send(req);
10311031
if (ret)
@@ -1053,7 +1053,7 @@ static void zfcp_fsf_send_els_handler(struct zfcp_fsf_req *req)
10531053

10541054
switch (header->fsf_status) {
10551055
case FSF_GOOD:
1056-
zfcp_dbf_san_els_response(req);
1056+
zfcp_dbf_san_res("fsselh1", req);
10571057
send_els->status = 0;
10581058
break;
10591059
case FSF_SERVICE_CLASS_NOT_SUPPORTED:
@@ -1127,7 +1127,7 @@ int zfcp_fsf_send_els(struct zfcp_adapter *adapter, u32 d_id,
11271127
req->handler = zfcp_fsf_send_els_handler;
11281128
req->data = els;
11291129

1130-
zfcp_dbf_san_els_request(req);
1130+
zfcp_dbf_san_req("fssels1", req, d_id);
11311131

11321132
ret = zfcp_fsf_req_send(req);
11331133
if (ret)

0 commit comments

Comments
 (0)