4 * Debug traces for zfcp.
6 * Copyright IBM Corporation 2002, 2009
9 #define KMSG_COMPONENT "zfcp"
10 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
12 #include <linux/ctype.h>
13 #include <asm/debug.h>
17 static u32 dbfsize
= 4;
19 module_param(dbfsize
, uint
, 0400);
20 MODULE_PARM_DESC(dbfsize
,
21 "number of pages for each debug feature area (default 4)");
23 static void zfcp_dbf_hexdump(debug_info_t
*dbf
, void *to
, int to_len
,
24 int level
, char *from
, int from_len
)
27 struct zfcp_dbf_dump
*dump
= to
;
28 int room
= to_len
- sizeof(*dump
);
30 for (offset
= 0; offset
< from_len
; offset
+= dump
->size
) {
31 memset(to
, 0, to_len
);
32 strncpy(dump
->tag
, "dump", ZFCP_DBF_TAG_SIZE
);
33 dump
->total_size
= from_len
;
34 dump
->offset
= offset
;
35 dump
->size
= min(from_len
- offset
, room
);
36 memcpy(dump
->data
, from
+ offset
, dump
->size
);
37 debug_event(dbf
, level
, dump
, dump
->size
+ sizeof(*dump
));
41 /* FIXME: this duplicate this code in s390 debug feature */
42 static void zfcp_dbf_timestamp(unsigned long long stck
, struct timespec
*time
)
44 unsigned long long sec
;
46 stck
-= 0x8126d60e46000000LL
- (0x3c26700LL
* 1000000 * 4096);
50 stck
-= (sec
* 1000000) << 12;
51 time
->tv_nsec
= ((stck
* 1000) >> 12);
54 static void zfcp_dbf_tag(char **p
, const char *label
, const char *tag
)
58 *p
+= sprintf(*p
, "%-24s", label
);
59 for (i
= 0; i
< ZFCP_DBF_TAG_SIZE
; i
++)
60 *p
+= sprintf(*p
, "%c", tag
[i
]);
61 *p
+= sprintf(*p
, "\n");
64 static void zfcp_dbf_outs(char **buf
, const char *s1
, const char *s2
)
66 *buf
+= sprintf(*buf
, "%-24s%s\n", s1
, s2
);
69 static void zfcp_dbf_out(char **buf
, const char *s
, const char *format
, ...)
73 *buf
+= sprintf(*buf
, "%-24s", s
);
74 va_start(arg
, format
);
75 *buf
+= vsprintf(*buf
, format
, arg
);
77 *buf
+= sprintf(*buf
, "\n");
80 static void zfcp_dbf_outd(char **p
, const char *label
, char *buffer
,
81 int buflen
, int offset
, int total_size
)
84 *p
+= sprintf(*p
, "%-24s ", label
);
87 if ((offset
% 32) == 0)
88 *p
+= sprintf(*p
, "\n%-24c ", ' ');
89 else if ((offset
% 4) == 0)
90 *p
+= sprintf(*p
, " ");
92 *p
+= sprintf(*p
, "%02x", *buffer
++);
93 if (++offset
== total_size
) {
94 *p
+= sprintf(*p
, "\n");
99 *p
+= sprintf(*p
, "\n");
102 static int zfcp_dbf_view_header(debug_info_t
*id
, struct debug_view
*view
,
103 int area
, debug_entry_t
*entry
, char *out_buf
)
105 struct zfcp_dbf_dump
*dump
= (struct zfcp_dbf_dump
*)DEBUG_DATA(entry
);
109 if (strncmp(dump
->tag
, "dump", ZFCP_DBF_TAG_SIZE
) != 0) {
110 zfcp_dbf_timestamp(entry
->id
.stck
, &t
);
111 zfcp_dbf_out(&p
, "timestamp", "%011lu:%06lu",
112 t
.tv_sec
, t
.tv_nsec
);
113 zfcp_dbf_out(&p
, "cpu", "%02i", entry
->id
.fields
.cpuid
);
115 zfcp_dbf_outd(&p
, "", dump
->data
, dump
->size
, dump
->offset
,
117 if ((dump
->offset
+ dump
->size
) == dump
->total_size
)
118 p
+= sprintf(p
, "\n");
123 void _zfcp_dbf_hba_fsf_response(const char *tag2
, int level
,
124 struct zfcp_fsf_req
*fsf_req
,
125 struct zfcp_dbf
*dbf
)
127 struct fsf_qtcb
*qtcb
= fsf_req
->qtcb
;
128 union fsf_prot_status_qual
*prot_status_qual
=
129 &qtcb
->prefix
.prot_status_qual
;
130 union fsf_status_qual
*fsf_status_qual
= &qtcb
->header
.fsf_status_qual
;
131 struct scsi_cmnd
*scsi_cmnd
;
132 struct zfcp_port
*port
;
133 struct zfcp_unit
*unit
;
134 struct zfcp_send_els
*send_els
;
135 struct zfcp_dbf_hba_record
*rec
= &dbf
->hba_buf
;
136 struct zfcp_dbf_hba_record_response
*response
= &rec
->u
.response
;
139 spin_lock_irqsave(&dbf
->hba_lock
, flags
);
140 memset(rec
, 0, sizeof(*rec
));
141 strncpy(rec
->tag
, "resp", ZFCP_DBF_TAG_SIZE
);
142 strncpy(rec
->tag2
, tag2
, ZFCP_DBF_TAG_SIZE
);
144 response
->fsf_command
= fsf_req
->fsf_command
;
145 response
->fsf_reqid
= fsf_req
->req_id
;
146 response
->fsf_seqno
= fsf_req
->seq_no
;
147 response
->fsf_issued
= fsf_req
->issued
;
148 response
->fsf_prot_status
= qtcb
->prefix
.prot_status
;
149 response
->fsf_status
= qtcb
->header
.fsf_status
;
150 memcpy(response
->fsf_prot_status_qual
,
151 prot_status_qual
, FSF_PROT_STATUS_QUAL_SIZE
);
152 memcpy(response
->fsf_status_qual
,
153 fsf_status_qual
, FSF_STATUS_QUALIFIER_SIZE
);
154 response
->fsf_req_status
= fsf_req
->status
;
155 response
->sbal_first
= fsf_req
->queue_req
.sbal_first
;
156 response
->sbal_last
= fsf_req
->queue_req
.sbal_last
;
157 response
->sbal_response
= fsf_req
->queue_req
.sbal_response
;
158 response
->pool
= fsf_req
->pool
!= NULL
;
159 response
->erp_action
= (unsigned long)fsf_req
->erp_action
;
161 switch (fsf_req
->fsf_command
) {
162 case FSF_QTCB_FCP_CMND
:
163 if (fsf_req
->status
& ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT
)
165 scsi_cmnd
= (struct scsi_cmnd
*)fsf_req
->data
;
167 response
->u
.fcp
.cmnd
= (unsigned long)scsi_cmnd
;
168 response
->u
.fcp
.serial
= scsi_cmnd
->serial_number
;
172 case FSF_QTCB_OPEN_PORT_WITH_DID
:
173 case FSF_QTCB_CLOSE_PORT
:
174 case FSF_QTCB_CLOSE_PHYSICAL_PORT
:
175 port
= (struct zfcp_port
*)fsf_req
->data
;
176 response
->u
.port
.wwpn
= port
->wwpn
;
177 response
->u
.port
.d_id
= port
->d_id
;
178 response
->u
.port
.port_handle
= qtcb
->header
.port_handle
;
181 case FSF_QTCB_OPEN_LUN
:
182 case FSF_QTCB_CLOSE_LUN
:
183 unit
= (struct zfcp_unit
*)fsf_req
->data
;
185 response
->u
.unit
.wwpn
= port
->wwpn
;
186 response
->u
.unit
.fcp_lun
= unit
->fcp_lun
;
187 response
->u
.unit
.port_handle
= qtcb
->header
.port_handle
;
188 response
->u
.unit
.lun_handle
= qtcb
->header
.lun_handle
;
191 case FSF_QTCB_SEND_ELS
:
192 send_els
= (struct zfcp_send_els
*)fsf_req
->data
;
193 response
->u
.els
.d_id
= qtcb
->bottom
.support
.d_id
;
194 response
->u
.els
.ls_code
= send_els
->ls_code
>> 24;
197 case FSF_QTCB_ABORT_FCP_CMND
:
198 case FSF_QTCB_SEND_GENERIC
:
199 case FSF_QTCB_EXCHANGE_CONFIG_DATA
:
200 case FSF_QTCB_EXCHANGE_PORT_DATA
:
201 case FSF_QTCB_DOWNLOAD_CONTROL_FILE
:
202 case FSF_QTCB_UPLOAD_CONTROL_FILE
:
206 debug_event(dbf
->hba
, level
, rec
, sizeof(*rec
));
208 /* have fcp channel microcode fixed to use as little as possible */
209 if (fsf_req
->fsf_command
!= FSF_QTCB_FCP_CMND
) {
210 /* adjust length skipping trailing zeros */
211 char *buf
= (char *)qtcb
+ qtcb
->header
.log_start
;
212 int len
= qtcb
->header
.log_length
;
213 for (; len
&& !buf
[len
- 1]; len
--);
214 zfcp_dbf_hexdump(dbf
->hba
, rec
, sizeof(*rec
), level
, buf
,
218 spin_unlock_irqrestore(&dbf
->hba_lock
, flags
);
221 void _zfcp_dbf_hba_fsf_unsol(const char *tag
, int level
, struct zfcp_dbf
*dbf
,
222 struct fsf_status_read_buffer
*status_buffer
)
224 struct zfcp_dbf_hba_record
*rec
= &dbf
->hba_buf
;
227 spin_lock_irqsave(&dbf
->hba_lock
, flags
);
228 memset(rec
, 0, sizeof(*rec
));
229 strncpy(rec
->tag
, "stat", ZFCP_DBF_TAG_SIZE
);
230 strncpy(rec
->tag2
, tag
, ZFCP_DBF_TAG_SIZE
);
232 rec
->u
.status
.failed
= atomic_read(&dbf
->adapter
->stat_miss
);
233 if (status_buffer
!= NULL
) {
234 rec
->u
.status
.status_type
= status_buffer
->status_type
;
235 rec
->u
.status
.status_subtype
= status_buffer
->status_subtype
;
236 memcpy(&rec
->u
.status
.queue_designator
,
237 &status_buffer
->queue_designator
,
238 sizeof(struct fsf_queue_designator
));
240 switch (status_buffer
->status_type
) {
241 case FSF_STATUS_READ_SENSE_DATA_AVAIL
:
242 rec
->u
.status
.payload_size
=
243 ZFCP_DBF_UNSOL_PAYLOAD_SENSE_DATA_AVAIL
;
246 case FSF_STATUS_READ_BIT_ERROR_THRESHOLD
:
247 rec
->u
.status
.payload_size
=
248 ZFCP_DBF_UNSOL_PAYLOAD_BIT_ERROR_THRESHOLD
;
251 case FSF_STATUS_READ_LINK_DOWN
:
252 switch (status_buffer
->status_subtype
) {
253 case FSF_STATUS_READ_SUB_NO_PHYSICAL_LINK
:
254 case FSF_STATUS_READ_SUB_FDISC_FAILED
:
255 rec
->u
.status
.payload_size
=
256 sizeof(struct fsf_link_down_info
);
260 case FSF_STATUS_READ_FEATURE_UPDATE_ALERT
:
261 rec
->u
.status
.payload_size
=
262 ZFCP_DBF_UNSOL_PAYLOAD_FEATURE_UPDATE_ALERT
;
265 memcpy(&rec
->u
.status
.payload
,
266 &status_buffer
->payload
, rec
->u
.status
.payload_size
);
269 debug_event(dbf
->hba
, level
, rec
, sizeof(*rec
));
270 spin_unlock_irqrestore(&dbf
->hba_lock
, flags
);
274 * zfcp_dbf_hba_qdio - trace event for QDIO related failure
275 * @qdio: qdio structure affected by this QDIO related event
276 * @qdio_error: as passed by qdio module
277 * @sbal_index: first buffer with error condition, as passed by qdio module
278 * @sbal_count: number of buffers affected, as passed by qdio module
280 void zfcp_dbf_hba_qdio(struct zfcp_dbf
*dbf
, unsigned int qdio_error
,
281 int sbal_index
, int sbal_count
)
283 struct zfcp_dbf_hba_record
*r
= &dbf
->hba_buf
;
286 spin_lock_irqsave(&dbf
->hba_lock
, flags
);
287 memset(r
, 0, sizeof(*r
));
288 strncpy(r
->tag
, "qdio", ZFCP_DBF_TAG_SIZE
);
289 r
->u
.qdio
.qdio_error
= qdio_error
;
290 r
->u
.qdio
.sbal_index
= sbal_index
;
291 r
->u
.qdio
.sbal_count
= sbal_count
;
292 debug_event(dbf
->hba
, 0, r
, sizeof(*r
));
293 spin_unlock_irqrestore(&dbf
->hba_lock
, flags
);
297 * zfcp_dbf_hba_berr - trace event for bit error threshold
298 * @dbf: dbf structure affected by this QDIO related event
301 void zfcp_dbf_hba_berr(struct zfcp_dbf
*dbf
, struct zfcp_fsf_req
*req
)
303 struct zfcp_dbf_hba_record
*r
= &dbf
->hba_buf
;
304 struct fsf_status_read_buffer
*sr_buf
= req
->data
;
305 struct fsf_bit_error_payload
*err
= &sr_buf
->payload
.bit_error
;
308 spin_lock_irqsave(&dbf
->hba_lock
, flags
);
309 memset(r
, 0, sizeof(*r
));
310 strncpy(r
->tag
, "berr", ZFCP_DBF_TAG_SIZE
);
311 memcpy(&r
->u
.berr
, err
, sizeof(struct fsf_bit_error_payload
));
312 debug_event(dbf
->hba
, 0, r
, sizeof(*r
));
313 spin_unlock_irqrestore(&dbf
->hba_lock
, flags
);
315 static void zfcp_dbf_hba_view_response(char **p
,
316 struct zfcp_dbf_hba_record_response
*r
)
320 zfcp_dbf_out(p
, "fsf_command", "0x%08x", r
->fsf_command
);
321 zfcp_dbf_out(p
, "fsf_reqid", "0x%0Lx", r
->fsf_reqid
);
322 zfcp_dbf_out(p
, "fsf_seqno", "0x%08x", r
->fsf_seqno
);
323 zfcp_dbf_timestamp(r
->fsf_issued
, &t
);
324 zfcp_dbf_out(p
, "fsf_issued", "%011lu:%06lu", t
.tv_sec
, t
.tv_nsec
);
325 zfcp_dbf_out(p
, "fsf_prot_status", "0x%08x", r
->fsf_prot_status
);
326 zfcp_dbf_out(p
, "fsf_status", "0x%08x", r
->fsf_status
);
327 zfcp_dbf_outd(p
, "fsf_prot_status_qual", r
->fsf_prot_status_qual
,
328 FSF_PROT_STATUS_QUAL_SIZE
, 0, FSF_PROT_STATUS_QUAL_SIZE
);
329 zfcp_dbf_outd(p
, "fsf_status_qual", r
->fsf_status_qual
,
330 FSF_STATUS_QUALIFIER_SIZE
, 0, FSF_STATUS_QUALIFIER_SIZE
);
331 zfcp_dbf_out(p
, "fsf_req_status", "0x%08x", r
->fsf_req_status
);
332 zfcp_dbf_out(p
, "sbal_first", "0x%02x", r
->sbal_first
);
333 zfcp_dbf_out(p
, "sbal_last", "0x%02x", r
->sbal_last
);
334 zfcp_dbf_out(p
, "sbal_response", "0x%02x", r
->sbal_response
);
335 zfcp_dbf_out(p
, "pool", "0x%02x", r
->pool
);
337 switch (r
->fsf_command
) {
338 case FSF_QTCB_FCP_CMND
:
339 if (r
->fsf_req_status
& ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT
)
341 zfcp_dbf_out(p
, "scsi_cmnd", "0x%0Lx", r
->u
.fcp
.cmnd
);
342 zfcp_dbf_out(p
, "scsi_serial", "0x%016Lx", r
->u
.fcp
.serial
);
343 p
+= sprintf(*p
, "\n");
346 case FSF_QTCB_OPEN_PORT_WITH_DID
:
347 case FSF_QTCB_CLOSE_PORT
:
348 case FSF_QTCB_CLOSE_PHYSICAL_PORT
:
349 zfcp_dbf_out(p
, "wwpn", "0x%016Lx", r
->u
.port
.wwpn
);
350 zfcp_dbf_out(p
, "d_id", "0x%06x", r
->u
.port
.d_id
);
351 zfcp_dbf_out(p
, "port_handle", "0x%08x", r
->u
.port
.port_handle
);
354 case FSF_QTCB_OPEN_LUN
:
355 case FSF_QTCB_CLOSE_LUN
:
356 zfcp_dbf_out(p
, "wwpn", "0x%016Lx", r
->u
.unit
.wwpn
);
357 zfcp_dbf_out(p
, "fcp_lun", "0x%016Lx", r
->u
.unit
.fcp_lun
);
358 zfcp_dbf_out(p
, "port_handle", "0x%08x", r
->u
.unit
.port_handle
);
359 zfcp_dbf_out(p
, "lun_handle", "0x%08x", r
->u
.unit
.lun_handle
);
362 case FSF_QTCB_SEND_ELS
:
363 zfcp_dbf_out(p
, "d_id", "0x%06x", r
->u
.els
.d_id
);
364 zfcp_dbf_out(p
, "ls_code", "0x%02x", r
->u
.els
.ls_code
);
367 case FSF_QTCB_ABORT_FCP_CMND
:
368 case FSF_QTCB_SEND_GENERIC
:
369 case FSF_QTCB_EXCHANGE_CONFIG_DATA
:
370 case FSF_QTCB_EXCHANGE_PORT_DATA
:
371 case FSF_QTCB_DOWNLOAD_CONTROL_FILE
:
372 case FSF_QTCB_UPLOAD_CONTROL_FILE
:
377 static void zfcp_dbf_hba_view_status(char **p
,
378 struct zfcp_dbf_hba_record_status
*r
)
380 zfcp_dbf_out(p
, "failed", "0x%02x", r
->failed
);
381 zfcp_dbf_out(p
, "status_type", "0x%08x", r
->status_type
);
382 zfcp_dbf_out(p
, "status_subtype", "0x%08x", r
->status_subtype
);
383 zfcp_dbf_outd(p
, "queue_designator", (char *)&r
->queue_designator
,
384 sizeof(struct fsf_queue_designator
), 0,
385 sizeof(struct fsf_queue_designator
));
386 zfcp_dbf_outd(p
, "payload", (char *)&r
->payload
, r
->payload_size
, 0,
390 static void zfcp_dbf_hba_view_qdio(char **p
, struct zfcp_dbf_hba_record_qdio
*r
)
392 zfcp_dbf_out(p
, "qdio_error", "0x%08x", r
->qdio_error
);
393 zfcp_dbf_out(p
, "sbal_index", "0x%02x", r
->sbal_index
);
394 zfcp_dbf_out(p
, "sbal_count", "0x%02x", r
->sbal_count
);
397 static void zfcp_dbf_hba_view_berr(char **p
, struct fsf_bit_error_payload
*r
)
399 zfcp_dbf_out(p
, "link_failures", "%d", r
->link_failure_error_count
);
400 zfcp_dbf_out(p
, "loss_of_sync_err", "%d", r
->loss_of_sync_error_count
);
401 zfcp_dbf_out(p
, "loss_of_sig_err", "%d", r
->loss_of_signal_error_count
);
402 zfcp_dbf_out(p
, "prim_seq_err", "%d",
403 r
->primitive_sequence_error_count
);
404 zfcp_dbf_out(p
, "inval_trans_word_err", "%d",
405 r
->invalid_transmission_word_error_count
);
406 zfcp_dbf_out(p
, "CRC_errors", "%d", r
->crc_error_count
);
407 zfcp_dbf_out(p
, "prim_seq_event_to", "%d",
408 r
->primitive_sequence_event_timeout_count
);
409 zfcp_dbf_out(p
, "elast_buf_overrun_err", "%d",
410 r
->elastic_buffer_overrun_error_count
);
411 zfcp_dbf_out(p
, "adv_rec_buf2buf_cred", "%d",
412 r
->advertised_receive_b2b_credit
);
413 zfcp_dbf_out(p
, "curr_rec_buf2buf_cred", "%d",
414 r
->current_receive_b2b_credit
);
415 zfcp_dbf_out(p
, "adv_trans_buf2buf_cred", "%d",
416 r
->advertised_transmit_b2b_credit
);
417 zfcp_dbf_out(p
, "curr_trans_buf2buf_cred", "%d",
418 r
->current_transmit_b2b_credit
);
421 static int zfcp_dbf_hba_view_format(debug_info_t
*id
, struct debug_view
*view
,
422 char *out_buf
, const char *in_buf
)
424 struct zfcp_dbf_hba_record
*r
= (struct zfcp_dbf_hba_record
*)in_buf
;
427 if (strncmp(r
->tag
, "dump", ZFCP_DBF_TAG_SIZE
) == 0)
430 zfcp_dbf_tag(&p
, "tag", r
->tag
);
431 if (isalpha(r
->tag2
[0]))
432 zfcp_dbf_tag(&p
, "tag2", r
->tag2
);
434 if (strncmp(r
->tag
, "resp", ZFCP_DBF_TAG_SIZE
) == 0)
435 zfcp_dbf_hba_view_response(&p
, &r
->u
.response
);
436 else if (strncmp(r
->tag
, "stat", ZFCP_DBF_TAG_SIZE
) == 0)
437 zfcp_dbf_hba_view_status(&p
, &r
->u
.status
);
438 else if (strncmp(r
->tag
, "qdio", ZFCP_DBF_TAG_SIZE
) == 0)
439 zfcp_dbf_hba_view_qdio(&p
, &r
->u
.qdio
);
440 else if (strncmp(r
->tag
, "berr", ZFCP_DBF_TAG_SIZE
) == 0)
441 zfcp_dbf_hba_view_berr(&p
, &r
->u
.berr
);
443 if (strncmp(r
->tag
, "resp", ZFCP_DBF_TAG_SIZE
) != 0)
444 p
+= sprintf(p
, "\n");
448 static struct debug_view zfcp_dbf_hba_view
= {
449 .name
= "structured",
450 .header_proc
= zfcp_dbf_view_header
,
451 .format_proc
= zfcp_dbf_hba_view_format
,
454 static const char *zfcp_dbf_rec_tags
[] = {
455 [ZFCP_REC_DBF_ID_THREAD
] = "thread",
456 [ZFCP_REC_DBF_ID_TARGET
] = "target",
457 [ZFCP_REC_DBF_ID_TRIGGER
] = "trigger",
458 [ZFCP_REC_DBF_ID_ACTION
] = "action",
461 static int zfcp_dbf_rec_view_format(debug_info_t
*id
, struct debug_view
*view
,
462 char *buf
, const char *_rec
)
464 struct zfcp_dbf_rec_record
*r
= (struct zfcp_dbf_rec_record
*)_rec
;
466 char hint
[ZFCP_DBF_ID_SIZE
+ 1];
468 memcpy(hint
, r
->id2
, ZFCP_DBF_ID_SIZE
);
469 hint
[ZFCP_DBF_ID_SIZE
] = 0;
470 zfcp_dbf_outs(&p
, "tag", zfcp_dbf_rec_tags
[r
->id
]);
471 zfcp_dbf_outs(&p
, "hint", hint
);
473 case ZFCP_REC_DBF_ID_THREAD
:
474 zfcp_dbf_out(&p
, "total", "%d", r
->u
.thread
.total
);
475 zfcp_dbf_out(&p
, "ready", "%d", r
->u
.thread
.ready
);
476 zfcp_dbf_out(&p
, "running", "%d", r
->u
.thread
.running
);
478 case ZFCP_REC_DBF_ID_TARGET
:
479 zfcp_dbf_out(&p
, "reference", "0x%016Lx", r
->u
.target
.ref
);
480 zfcp_dbf_out(&p
, "status", "0x%08x", r
->u
.target
.status
);
481 zfcp_dbf_out(&p
, "erp_count", "%d", r
->u
.target
.erp_count
);
482 zfcp_dbf_out(&p
, "d_id", "0x%06x", r
->u
.target
.d_id
);
483 zfcp_dbf_out(&p
, "wwpn", "0x%016Lx", r
->u
.target
.wwpn
);
484 zfcp_dbf_out(&p
, "fcp_lun", "0x%016Lx", r
->u
.target
.fcp_lun
);
486 case ZFCP_REC_DBF_ID_TRIGGER
:
487 zfcp_dbf_out(&p
, "reference", "0x%016Lx", r
->u
.trigger
.ref
);
488 zfcp_dbf_out(&p
, "erp_action", "0x%016Lx", r
->u
.trigger
.action
);
489 zfcp_dbf_out(&p
, "requested", "%d", r
->u
.trigger
.want
);
490 zfcp_dbf_out(&p
, "executed", "%d", r
->u
.trigger
.need
);
491 zfcp_dbf_out(&p
, "wwpn", "0x%016Lx", r
->u
.trigger
.wwpn
);
492 zfcp_dbf_out(&p
, "fcp_lun", "0x%016Lx", r
->u
.trigger
.fcp_lun
);
493 zfcp_dbf_out(&p
, "adapter_status", "0x%08x", r
->u
.trigger
.as
);
494 zfcp_dbf_out(&p
, "port_status", "0x%08x", r
->u
.trigger
.ps
);
495 zfcp_dbf_out(&p
, "unit_status", "0x%08x", r
->u
.trigger
.us
);
497 case ZFCP_REC_DBF_ID_ACTION
:
498 zfcp_dbf_out(&p
, "erp_action", "0x%016Lx", r
->u
.action
.action
);
499 zfcp_dbf_out(&p
, "fsf_req", "0x%016Lx", r
->u
.action
.fsf_req
);
500 zfcp_dbf_out(&p
, "status", "0x%08Lx", r
->u
.action
.status
);
501 zfcp_dbf_out(&p
, "step", "0x%08Lx", r
->u
.action
.step
);
504 p
+= sprintf(p
, "\n");
508 static struct debug_view zfcp_dbf_rec_view
= {
509 .name
= "structured",
510 .header_proc
= zfcp_dbf_view_header
,
511 .format_proc
= zfcp_dbf_rec_view_format
,
515 * zfcp_dbf_rec_thread - trace event related to recovery thread operation
516 * @id2: identifier for event
517 * @dbf: reference to dbf structure
518 * This function assumes that the caller is holding erp_lock.
520 void zfcp_dbf_rec_thread(char *id2
, struct zfcp_dbf
*dbf
)
522 struct zfcp_adapter
*adapter
= dbf
->adapter
;
523 struct zfcp_dbf_rec_record
*r
= &dbf
->rec_buf
;
524 unsigned long flags
= 0;
525 struct list_head
*entry
;
526 unsigned ready
= 0, running
= 0, total
;
528 list_for_each(entry
, &adapter
->erp_ready_head
)
530 list_for_each(entry
, &adapter
->erp_running_head
)
532 total
= adapter
->erp_total_count
;
534 spin_lock_irqsave(&dbf
->rec_lock
, flags
);
535 memset(r
, 0, sizeof(*r
));
536 r
->id
= ZFCP_REC_DBF_ID_THREAD
;
537 memcpy(r
->id2
, id2
, ZFCP_DBF_ID_SIZE
);
538 r
->u
.thread
.total
= total
;
539 r
->u
.thread
.ready
= ready
;
540 r
->u
.thread
.running
= running
;
541 debug_event(dbf
->rec
, 6, r
, sizeof(*r
));
542 spin_unlock_irqrestore(&dbf
->rec_lock
, flags
);
546 * zfcp_dbf_rec_thread - trace event related to recovery thread operation
547 * @id2: identifier for event
549 * This function assumes that the caller does not hold erp_lock.
551 void zfcp_dbf_rec_thread_lock(char *id2
, struct zfcp_dbf
*dbf
)
553 struct zfcp_adapter
*adapter
= dbf
->adapter
;
556 read_lock_irqsave(&adapter
->erp_lock
, flags
);
557 zfcp_dbf_rec_thread(id2
, dbf
);
558 read_unlock_irqrestore(&adapter
->erp_lock
, flags
);
561 static void zfcp_dbf_rec_target(char *id2
, void *ref
, struct zfcp_dbf
*dbf
,
562 atomic_t
*status
, atomic_t
*erp_count
, u64 wwpn
,
563 u32 d_id
, u64 fcp_lun
)
565 struct zfcp_dbf_rec_record
*r
= &dbf
->rec_buf
;
568 spin_lock_irqsave(&dbf
->rec_lock
, flags
);
569 memset(r
, 0, sizeof(*r
));
570 r
->id
= ZFCP_REC_DBF_ID_TARGET
;
571 memcpy(r
->id2
, id2
, ZFCP_DBF_ID_SIZE
);
572 r
->u
.target
.ref
= (unsigned long)ref
;
573 r
->u
.target
.status
= atomic_read(status
);
574 r
->u
.target
.wwpn
= wwpn
;
575 r
->u
.target
.d_id
= d_id
;
576 r
->u
.target
.fcp_lun
= fcp_lun
;
577 r
->u
.target
.erp_count
= atomic_read(erp_count
);
578 debug_event(dbf
->rec
, 3, r
, sizeof(*r
));
579 spin_unlock_irqrestore(&dbf
->rec_lock
, flags
);
583 * zfcp_dbf_rec_adapter - trace event for adapter state change
584 * @id: identifier for trigger of state change
585 * @ref: additional reference (e.g. request)
586 * @dbf: reference to dbf structure
588 void zfcp_dbf_rec_adapter(char *id
, void *ref
, struct zfcp_dbf
*dbf
)
590 struct zfcp_adapter
*adapter
= dbf
->adapter
;
592 zfcp_dbf_rec_target(id
, ref
, dbf
, &adapter
->status
,
593 &adapter
->erp_counter
, 0, 0, 0);
597 * zfcp_dbf_rec_port - trace event for port state change
598 * @id: identifier for trigger of state change
599 * @ref: additional reference (e.g. request)
602 void zfcp_dbf_rec_port(char *id
, void *ref
, struct zfcp_port
*port
)
604 struct zfcp_dbf
*dbf
= port
->adapter
->dbf
;
606 zfcp_dbf_rec_target(id
, ref
, dbf
, &port
->status
,
607 &port
->erp_counter
, port
->wwpn
, port
->d_id
,
612 * zfcp_dbf_rec_unit - trace event for unit state change
613 * @id: identifier for trigger of state change
614 * @ref: additional reference (e.g. request)
617 void zfcp_dbf_rec_unit(char *id
, void *ref
, struct zfcp_unit
*unit
)
619 struct zfcp_port
*port
= unit
->port
;
620 struct zfcp_dbf
*dbf
= port
->adapter
->dbf
;
622 zfcp_dbf_rec_target(id
, ref
, dbf
, &unit
->status
,
623 &unit
->erp_counter
, port
->wwpn
, port
->d_id
,
628 * zfcp_dbf_rec_trigger - trace event for triggered error recovery
629 * @id2: identifier for error recovery trigger
630 * @ref: additional reference (e.g. request)
631 * @want: originally requested error recovery action
632 * @need: error recovery action actually initiated
633 * @action: address of error recovery action struct
638 void zfcp_dbf_rec_trigger(char *id2
, void *ref
, u8 want
, u8 need
, void *action
,
639 struct zfcp_adapter
*adapter
, struct zfcp_port
*port
,
640 struct zfcp_unit
*unit
)
642 struct zfcp_dbf
*dbf
= adapter
->dbf
;
643 struct zfcp_dbf_rec_record
*r
= &dbf
->rec_buf
;
646 spin_lock_irqsave(&dbf
->rec_lock
, flags
);
647 memset(r
, 0, sizeof(*r
));
648 r
->id
= ZFCP_REC_DBF_ID_TRIGGER
;
649 memcpy(r
->id2
, id2
, ZFCP_DBF_ID_SIZE
);
650 r
->u
.trigger
.ref
= (unsigned long)ref
;
651 r
->u
.trigger
.want
= want
;
652 r
->u
.trigger
.need
= need
;
653 r
->u
.trigger
.action
= (unsigned long)action
;
654 r
->u
.trigger
.as
= atomic_read(&adapter
->status
);
656 r
->u
.trigger
.ps
= atomic_read(&port
->status
);
657 r
->u
.trigger
.wwpn
= port
->wwpn
;
660 r
->u
.trigger
.us
= atomic_read(&unit
->status
);
661 r
->u
.trigger
.fcp_lun
= unit
->fcp_lun
;
663 debug_event(dbf
->rec
, action
? 1 : 4, r
, sizeof(*r
));
664 spin_unlock_irqrestore(&dbf
->rec_lock
, flags
);
668 * zfcp_dbf_rec_action - trace event showing progress of recovery action
670 * @erp_action: error recovery action struct pointer
672 void zfcp_dbf_rec_action(char *id2
, struct zfcp_erp_action
*erp_action
)
674 struct zfcp_dbf
*dbf
= erp_action
->adapter
->dbf
;
675 struct zfcp_dbf_rec_record
*r
= &dbf
->rec_buf
;
678 spin_lock_irqsave(&dbf
->rec_lock
, flags
);
679 memset(r
, 0, sizeof(*r
));
680 r
->id
= ZFCP_REC_DBF_ID_ACTION
;
681 memcpy(r
->id2
, id2
, ZFCP_DBF_ID_SIZE
);
682 r
->u
.action
.action
= (unsigned long)erp_action
;
683 r
->u
.action
.status
= erp_action
->status
;
684 r
->u
.action
.step
= erp_action
->step
;
685 r
->u
.action
.fsf_req
= (unsigned long)erp_action
->fsf_req
;
686 debug_event(dbf
->rec
, 5, r
, sizeof(*r
));
687 spin_unlock_irqrestore(&dbf
->rec_lock
, flags
);
691 * zfcp_dbf_san_ct_request - trace event for issued CT request
692 * @fsf_req: request containing issued CT data
694 void zfcp_dbf_san_ct_request(struct zfcp_fsf_req
*fsf_req
)
696 struct zfcp_send_ct
*ct
= (struct zfcp_send_ct
*)fsf_req
->data
;
697 struct zfcp_wka_port
*wka_port
= ct
->wka_port
;
698 struct zfcp_adapter
*adapter
= wka_port
->adapter
;
699 struct zfcp_dbf
*dbf
= adapter
->dbf
;
700 struct ct_hdr
*hdr
= sg_virt(ct
->req
);
701 struct zfcp_dbf_san_record
*r
= &dbf
->san_buf
;
702 struct zfcp_dbf_san_record_ct_request
*oct
= &r
->u
.ct_req
;
706 spin_lock_irqsave(&dbf
->san_lock
, flags
);
707 memset(r
, 0, sizeof(*r
));
708 strncpy(r
->tag
, "octc", ZFCP_DBF_TAG_SIZE
);
709 r
->fsf_reqid
= fsf_req
->req_id
;
710 r
->fsf_seqno
= fsf_req
->seq_no
;
711 r
->s_id
= fc_host_port_id(adapter
->scsi_host
);
712 r
->d_id
= wka_port
->d_id
;
713 oct
->cmd_req_code
= hdr
->cmd_rsp_code
;
714 oct
->revision
= hdr
->revision
;
715 oct
->gs_type
= hdr
->gs_type
;
716 oct
->gs_subtype
= hdr
->gs_subtype
;
717 oct
->options
= hdr
->options
;
718 oct
->max_res_size
= hdr
->max_res_size
;
719 oct
->len
= min((int)ct
->req
->length
- (int)sizeof(struct ct_hdr
),
720 ZFCP_DBF_SAN_MAX_PAYLOAD
);
721 debug_event(dbf
->san
, level
, r
, sizeof(*r
));
722 zfcp_dbf_hexdump(dbf
->san
, r
, sizeof(*r
), level
,
723 (void *)hdr
+ sizeof(struct ct_hdr
), oct
->len
);
724 spin_unlock_irqrestore(&dbf
->san_lock
, flags
);
728 * zfcp_dbf_san_ct_response - trace event for completion of CT request
729 * @fsf_req: request containing CT response
731 void zfcp_dbf_san_ct_response(struct zfcp_fsf_req
*fsf_req
)
733 struct zfcp_send_ct
*ct
= (struct zfcp_send_ct
*)fsf_req
->data
;
734 struct zfcp_wka_port
*wka_port
= ct
->wka_port
;
735 struct zfcp_adapter
*adapter
= wka_port
->adapter
;
736 struct ct_hdr
*hdr
= sg_virt(ct
->resp
);
737 struct zfcp_dbf
*dbf
= adapter
->dbf
;
738 struct zfcp_dbf_san_record
*r
= &dbf
->san_buf
;
739 struct zfcp_dbf_san_record_ct_response
*rct
= &r
->u
.ct_resp
;
743 spin_lock_irqsave(&dbf
->san_lock
, flags
);
744 memset(r
, 0, sizeof(*r
));
745 strncpy(r
->tag
, "rctc", ZFCP_DBF_TAG_SIZE
);
746 r
->fsf_reqid
= fsf_req
->req_id
;
747 r
->fsf_seqno
= fsf_req
->seq_no
;
748 r
->s_id
= wka_port
->d_id
;
749 r
->d_id
= fc_host_port_id(adapter
->scsi_host
);
750 rct
->cmd_rsp_code
= hdr
->cmd_rsp_code
;
751 rct
->revision
= hdr
->revision
;
752 rct
->reason_code
= hdr
->reason_code
;
753 rct
->expl
= hdr
->reason_code_expl
;
754 rct
->vendor_unique
= hdr
->vendor_unique
;
755 rct
->max_res_size
= hdr
->max_res_size
;
756 rct
->len
= min((int)ct
->resp
->length
- (int)sizeof(struct ct_hdr
),
757 ZFCP_DBF_SAN_MAX_PAYLOAD
);
758 debug_event(dbf
->san
, level
, r
, sizeof(*r
));
759 zfcp_dbf_hexdump(dbf
->san
, r
, sizeof(*r
), level
,
760 (void *)hdr
+ sizeof(struct ct_hdr
), rct
->len
);
761 spin_unlock_irqrestore(&dbf
->san_lock
, flags
);
764 static void zfcp_dbf_san_els(const char *tag
, int level
,
765 struct zfcp_fsf_req
*fsf_req
, u32 s_id
, u32 d_id
,
766 u8 ls_code
, void *buffer
, int buflen
)
768 struct zfcp_adapter
*adapter
= fsf_req
->adapter
;
769 struct zfcp_dbf
*dbf
= adapter
->dbf
;
770 struct zfcp_dbf_san_record
*rec
= &dbf
->san_buf
;
773 spin_lock_irqsave(&dbf
->san_lock
, flags
);
774 memset(rec
, 0, sizeof(*rec
));
775 strncpy(rec
->tag
, tag
, ZFCP_DBF_TAG_SIZE
);
776 rec
->fsf_reqid
= fsf_req
->req_id
;
777 rec
->fsf_seqno
= fsf_req
->seq_no
;
780 rec
->u
.els
.ls_code
= ls_code
;
781 debug_event(dbf
->san
, level
, rec
, sizeof(*rec
));
782 zfcp_dbf_hexdump(dbf
->san
, rec
, sizeof(*rec
), level
,
783 buffer
, min(buflen
, ZFCP_DBF_SAN_MAX_PAYLOAD
));
784 spin_unlock_irqrestore(&dbf
->san_lock
, flags
);
788 * zfcp_dbf_san_els_request - trace event for issued ELS
789 * @fsf_req: request containing issued ELS
791 void zfcp_dbf_san_els_request(struct zfcp_fsf_req
*fsf_req
)
793 struct zfcp_send_els
*els
= (struct zfcp_send_els
*)fsf_req
->data
;
795 zfcp_dbf_san_els("oels", 2, fsf_req
,
796 fc_host_port_id(els
->adapter
->scsi_host
),
797 els
->d_id
, *(u8
*) sg_virt(els
->req
),
798 sg_virt(els
->req
), els
->req
->length
);
802 * zfcp_dbf_san_els_response - trace event for completed ELS
803 * @fsf_req: request containing ELS response
805 void zfcp_dbf_san_els_response(struct zfcp_fsf_req
*fsf_req
)
807 struct zfcp_send_els
*els
= (struct zfcp_send_els
*)fsf_req
->data
;
809 zfcp_dbf_san_els("rels", 2, fsf_req
, els
->d_id
,
810 fc_host_port_id(els
->adapter
->scsi_host
),
811 *(u8
*)sg_virt(els
->req
), sg_virt(els
->resp
),
816 * zfcp_dbf_san_incoming_els - trace event for incomig ELS
817 * @fsf_req: request containing unsolicited status buffer with incoming ELS
819 void zfcp_dbf_san_incoming_els(struct zfcp_fsf_req
*fsf_req
)
821 struct zfcp_adapter
*adapter
= fsf_req
->adapter
;
822 struct fsf_status_read_buffer
*buf
=
823 (struct fsf_status_read_buffer
*)fsf_req
->data
;
824 int length
= (int)buf
->length
-
825 (int)((void *)&buf
->payload
- (void *)buf
);
827 zfcp_dbf_san_els("iels", 1, fsf_req
, buf
->d_id
,
828 fc_host_port_id(adapter
->scsi_host
),
829 buf
->payload
.data
[0], (void *)buf
->payload
.data
,
833 static int zfcp_dbf_san_view_format(debug_info_t
*id
, struct debug_view
*view
,
834 char *out_buf
, const char *in_buf
)
836 struct zfcp_dbf_san_record
*r
= (struct zfcp_dbf_san_record
*)in_buf
;
839 if (strncmp(r
->tag
, "dump", ZFCP_DBF_TAG_SIZE
) == 0)
842 zfcp_dbf_tag(&p
, "tag", r
->tag
);
843 zfcp_dbf_out(&p
, "fsf_reqid", "0x%0Lx", r
->fsf_reqid
);
844 zfcp_dbf_out(&p
, "fsf_seqno", "0x%08x", r
->fsf_seqno
);
845 zfcp_dbf_out(&p
, "s_id", "0x%06x", r
->s_id
);
846 zfcp_dbf_out(&p
, "d_id", "0x%06x", r
->d_id
);
848 if (strncmp(r
->tag
, "octc", ZFCP_DBF_TAG_SIZE
) == 0) {
849 struct zfcp_dbf_san_record_ct_request
*ct
= &r
->u
.ct_req
;
850 zfcp_dbf_out(&p
, "cmd_req_code", "0x%04x", ct
->cmd_req_code
);
851 zfcp_dbf_out(&p
, "revision", "0x%02x", ct
->revision
);
852 zfcp_dbf_out(&p
, "gs_type", "0x%02x", ct
->gs_type
);
853 zfcp_dbf_out(&p
, "gs_subtype", "0x%02x", ct
->gs_subtype
);
854 zfcp_dbf_out(&p
, "options", "0x%02x", ct
->options
);
855 zfcp_dbf_out(&p
, "max_res_size", "0x%04x", ct
->max_res_size
);
856 } else if (strncmp(r
->tag
, "rctc", ZFCP_DBF_TAG_SIZE
) == 0) {
857 struct zfcp_dbf_san_record_ct_response
*ct
= &r
->u
.ct_resp
;
858 zfcp_dbf_out(&p
, "cmd_rsp_code", "0x%04x", ct
->cmd_rsp_code
);
859 zfcp_dbf_out(&p
, "revision", "0x%02x", ct
->revision
);
860 zfcp_dbf_out(&p
, "reason_code", "0x%02x", ct
->reason_code
);
861 zfcp_dbf_out(&p
, "reason_code_expl", "0x%02x", ct
->expl
);
862 zfcp_dbf_out(&p
, "vendor_unique", "0x%02x", ct
->vendor_unique
);
863 zfcp_dbf_out(&p
, "max_res_size", "0x%04x", ct
->max_res_size
);
864 } else if (strncmp(r
->tag
, "oels", ZFCP_DBF_TAG_SIZE
) == 0 ||
865 strncmp(r
->tag
, "rels", ZFCP_DBF_TAG_SIZE
) == 0 ||
866 strncmp(r
->tag
, "iels", ZFCP_DBF_TAG_SIZE
) == 0) {
867 struct zfcp_dbf_san_record_els
*els
= &r
->u
.els
;
868 zfcp_dbf_out(&p
, "ls_code", "0x%02x", els
->ls_code
);
873 static struct debug_view zfcp_dbf_san_view
= {
874 .name
= "structured",
875 .header_proc
= zfcp_dbf_view_header
,
876 .format_proc
= zfcp_dbf_san_view_format
,
879 void _zfcp_dbf_scsi(const char *tag
, const char *tag2
, int level
,
880 struct zfcp_dbf
*dbf
, struct scsi_cmnd
*scsi_cmnd
,
881 struct zfcp_fsf_req
*fsf_req
, unsigned long old_req_id
)
883 struct zfcp_dbf_scsi_record
*rec
= &dbf
->scsi_buf
;
884 struct zfcp_dbf_dump
*dump
= (struct zfcp_dbf_dump
*)rec
;
886 struct fcp_rsp_iu
*fcp_rsp
;
887 char *fcp_rsp_info
= NULL
, *fcp_sns_info
= NULL
;
888 int offset
= 0, buflen
= 0;
890 spin_lock_irqsave(&dbf
->scsi_lock
, flags
);
892 memset(rec
, 0, sizeof(*rec
));
894 strncpy(rec
->tag
, tag
, ZFCP_DBF_TAG_SIZE
);
895 strncpy(rec
->tag2
, tag2
, ZFCP_DBF_TAG_SIZE
);
896 if (scsi_cmnd
!= NULL
) {
897 if (scsi_cmnd
->device
) {
898 rec
->scsi_id
= scsi_cmnd
->device
->id
;
899 rec
->scsi_lun
= scsi_cmnd
->device
->lun
;
901 rec
->scsi_result
= scsi_cmnd
->result
;
902 rec
->scsi_cmnd
= (unsigned long)scsi_cmnd
;
903 rec
->scsi_serial
= scsi_cmnd
->serial_number
;
904 memcpy(rec
->scsi_opcode
, scsi_cmnd
->cmnd
,
905 min((int)scsi_cmnd
->cmd_len
,
906 ZFCP_DBF_SCSI_OPCODE
));
907 rec
->scsi_retries
= scsi_cmnd
->retries
;
908 rec
->scsi_allowed
= scsi_cmnd
->allowed
;
910 if (fsf_req
!= NULL
) {
911 fcp_rsp
= (struct fcp_rsp_iu
*)
912 &(fsf_req
->qtcb
->bottom
.io
.fcp_rsp
);
913 fcp_rsp_info
= (unsigned char *) &fcp_rsp
[1];
915 zfcp_get_fcp_sns_info_ptr(fcp_rsp
);
917 rec
->rsp_validity
= fcp_rsp
->validity
.value
;
918 rec
->rsp_scsi_status
= fcp_rsp
->scsi_status
;
919 rec
->rsp_resid
= fcp_rsp
->fcp_resid
;
920 if (fcp_rsp
->validity
.bits
.fcp_rsp_len_valid
)
921 rec
->rsp_code
= *(fcp_rsp_info
+ 3);
922 if (fcp_rsp
->validity
.bits
.fcp_sns_len_valid
) {
923 buflen
= min((int)fcp_rsp
->fcp_sns_len
,
924 ZFCP_DBF_SCSI_MAX_FCP_SNS_INFO
);
925 rec
->sns_info_len
= buflen
;
926 memcpy(rec
->sns_info
, fcp_sns_info
,
928 ZFCP_DBF_SCSI_FCP_SNS_INFO
));
929 offset
+= min(buflen
,
930 ZFCP_DBF_SCSI_FCP_SNS_INFO
);
933 rec
->fsf_reqid
= fsf_req
->req_id
;
934 rec
->fsf_seqno
= fsf_req
->seq_no
;
935 rec
->fsf_issued
= fsf_req
->issued
;
937 rec
->old_fsf_reqid
= old_req_id
;
939 strncpy(dump
->tag
, "dump", ZFCP_DBF_TAG_SIZE
);
940 dump
->total_size
= buflen
;
941 dump
->offset
= offset
;
942 dump
->size
= min(buflen
- offset
,
944 zfcp_dbf_scsi_record
) -
945 (int)sizeof(struct zfcp_dbf_dump
));
946 memcpy(dump
->data
, fcp_sns_info
+ offset
, dump
->size
);
947 offset
+= dump
->size
;
949 debug_event(dbf
->scsi
, level
, rec
, sizeof(*rec
));
950 } while (offset
< buflen
);
951 spin_unlock_irqrestore(&dbf
->scsi_lock
, flags
);
954 static int zfcp_dbf_scsi_view_format(debug_info_t
*id
, struct debug_view
*view
,
955 char *out_buf
, const char *in_buf
)
957 struct zfcp_dbf_scsi_record
*r
= (struct zfcp_dbf_scsi_record
*)in_buf
;
961 if (strncmp(r
->tag
, "dump", ZFCP_DBF_TAG_SIZE
) == 0)
964 zfcp_dbf_tag(&p
, "tag", r
->tag
);
965 zfcp_dbf_tag(&p
, "tag2", r
->tag2
);
966 zfcp_dbf_out(&p
, "scsi_id", "0x%08x", r
->scsi_id
);
967 zfcp_dbf_out(&p
, "scsi_lun", "0x%08x", r
->scsi_lun
);
968 zfcp_dbf_out(&p
, "scsi_result", "0x%08x", r
->scsi_result
);
969 zfcp_dbf_out(&p
, "scsi_cmnd", "0x%0Lx", r
->scsi_cmnd
);
970 zfcp_dbf_out(&p
, "scsi_serial", "0x%016Lx", r
->scsi_serial
);
971 zfcp_dbf_outd(&p
, "scsi_opcode", r
->scsi_opcode
, ZFCP_DBF_SCSI_OPCODE
,
972 0, ZFCP_DBF_SCSI_OPCODE
);
973 zfcp_dbf_out(&p
, "scsi_retries", "0x%02x", r
->scsi_retries
);
974 zfcp_dbf_out(&p
, "scsi_allowed", "0x%02x", r
->scsi_allowed
);
975 if (strncmp(r
->tag
, "abrt", ZFCP_DBF_TAG_SIZE
) == 0)
976 zfcp_dbf_out(&p
, "old_fsf_reqid", "0x%0Lx", r
->old_fsf_reqid
);
977 zfcp_dbf_out(&p
, "fsf_reqid", "0x%0Lx", r
->fsf_reqid
);
978 zfcp_dbf_out(&p
, "fsf_seqno", "0x%08x", r
->fsf_seqno
);
979 zfcp_dbf_timestamp(r
->fsf_issued
, &t
);
980 zfcp_dbf_out(&p
, "fsf_issued", "%011lu:%06lu", t
.tv_sec
, t
.tv_nsec
);
982 if (strncmp(r
->tag
, "rslt", ZFCP_DBF_TAG_SIZE
) == 0) {
983 zfcp_dbf_out(&p
, "fcp_rsp_validity", "0x%02x", r
->rsp_validity
);
984 zfcp_dbf_out(&p
, "fcp_rsp_scsi_status", "0x%02x",
986 zfcp_dbf_out(&p
, "fcp_rsp_resid", "0x%08x", r
->rsp_resid
);
987 zfcp_dbf_out(&p
, "fcp_rsp_code", "0x%08x", r
->rsp_code
);
988 zfcp_dbf_out(&p
, "fcp_sns_info_len", "0x%08x", r
->sns_info_len
);
989 zfcp_dbf_outd(&p
, "fcp_sns_info", r
->sns_info
,
990 min((int)r
->sns_info_len
,
991 ZFCP_DBF_SCSI_FCP_SNS_INFO
), 0,
994 p
+= sprintf(p
, "\n");
998 static struct debug_view zfcp_dbf_scsi_view
= {
999 .name
= "structured",
1000 .header_proc
= zfcp_dbf_view_header
,
1001 .format_proc
= zfcp_dbf_scsi_view_format
,
1004 static debug_info_t
*zfcp_dbf_reg(const char *name
, int level
,
1005 struct debug_view
*view
, int size
)
1007 struct debug_info
*d
;
1009 d
= debug_register(name
, dbfsize
, level
, size
);
1013 debug_register_view(d
, &debug_hex_ascii_view
);
1014 debug_register_view(d
, view
);
1015 debug_set_level(d
, level
);
1021 * zfcp_adapter_debug_register - registers debug feature for an adapter
1022 * @adapter: pointer to adapter for which debug features should be registered
1023 * return: -ENOMEM on error, 0 otherwise
1025 int zfcp_dbf_adapter_register(struct zfcp_adapter
*adapter
)
1027 char dbf_name
[DEBUG_MAX_NAME_LEN
];
1028 struct zfcp_dbf
*dbf
;
1030 dbf
= kmalloc(sizeof(struct zfcp_dbf
), GFP_KERNEL
);
1034 dbf
->adapter
= adapter
;
1036 spin_lock_init(&dbf
->hba_lock
);
1037 spin_lock_init(&dbf
->san_lock
);
1038 spin_lock_init(&dbf
->scsi_lock
);
1039 spin_lock_init(&dbf
->rec_lock
);
1041 /* debug feature area which records recovery activity */
1042 sprintf(dbf_name
, "zfcp_%s_rec", dev_name(&adapter
->ccw_device
->dev
));
1043 dbf
->rec
= zfcp_dbf_reg(dbf_name
, 3, &zfcp_dbf_rec_view
,
1044 sizeof(struct zfcp_dbf_rec_record
));
1048 /* debug feature area which records HBA (FSF and QDIO) conditions */
1049 sprintf(dbf_name
, "zfcp_%s_hba", dev_name(&adapter
->ccw_device
->dev
));
1050 dbf
->hba
= zfcp_dbf_reg(dbf_name
, 3, &zfcp_dbf_hba_view
,
1051 sizeof(struct zfcp_dbf_hba_record
));
1055 /* debug feature area which records SAN command failures and recovery */
1056 sprintf(dbf_name
, "zfcp_%s_san", dev_name(&adapter
->ccw_device
->dev
));
1057 dbf
->san
= zfcp_dbf_reg(dbf_name
, 6, &zfcp_dbf_san_view
,
1058 sizeof(struct zfcp_dbf_san_record
));
1062 /* debug feature area which records SCSI command failures and recovery */
1063 sprintf(dbf_name
, "zfcp_%s_scsi", dev_name(&adapter
->ccw_device
->dev
));
1064 dbf
->scsi
= zfcp_dbf_reg(dbf_name
, 3, &zfcp_dbf_scsi_view
,
1065 sizeof(struct zfcp_dbf_scsi_record
));
1073 zfcp_dbf_adapter_unregister(dbf
);
1078 * zfcp_adapter_debug_unregister - unregisters debug feature for an adapter
1079 * @dbf: pointer to dbf for which debug features should be unregistered
1081 void zfcp_dbf_adapter_unregister(struct zfcp_dbf
*dbf
)
1083 debug_unregister(dbf
->scsi
);
1084 debug_unregister(dbf
->san
);
1085 debug_unregister(dbf
->hba
);
1086 debug_unregister(dbf
->rec
);
1087 dbf
->adapter
->dbf
= NULL
;