2 * This file is part of the zfcp device driver for
3 * FCP adapters for IBM System z9 and zSeries.
5 * (C) Copyright IBM Corp. 2002, 2006
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #include <linux/ctype.h>
23 #include <asm/debug.h>
26 static u32 dbfsize = 4;
28 module_param(dbfsize, uint, 0400);
29 MODULE_PARM_DESC(dbfsize,
30 "number of pages for each debug feature area (default 4)");
32 #define ZFCP_LOG_AREA ZFCP_LOG_AREA_OTHER
34 static void zfcp_dbf_hexdump(debug_info_t *dbf, void *to, int to_len,
35 int level, char *from, int from_len)
38 struct zfcp_dbf_dump *dump = to;
39 int room = to_len - sizeof(*dump);
41 for (offset = 0; offset < from_len; offset += dump->size) {
42 memset(to, 0, to_len);
43 strncpy(dump->tag, "dump", ZFCP_DBF_TAG_SIZE);
44 dump->total_size = from_len;
45 dump->offset = offset;
46 dump->size = min(from_len - offset, room);
47 memcpy(dump->data, from + offset, dump->size);
48 debug_event(dbf, level, dump, dump->size);
52 /* FIXME: this duplicate this code in s390 debug feature */
53 static void zfcp_dbf_timestamp(unsigned long long stck, struct timespec *time)
55 unsigned long long sec;
57 stck -= 0x8126d60e46000000LL - (0x3c26700LL * 1000000 * 4096);
61 stck -= (sec * 1000000) << 12;
62 time->tv_nsec = ((stck * 1000) >> 12);
65 static void zfcp_dbf_tag(char **p, const char *label, const char *tag)
69 *p += sprintf(*p, "%-24s", label);
70 for (i = 0; i < ZFCP_DBF_TAG_SIZE; i++)
71 *p += sprintf(*p, "%c", tag[i]);
72 *p += sprintf(*p, "\n");
75 static void zfcp_dbf_outs(char **buf, const char *s1, const char *s2)
77 *buf += sprintf(*buf, "%-24s%s\n", s1, s2);
80 static void zfcp_dbf_out(char **buf, const char *s, const char *format, ...)
84 *buf += sprintf(*buf, "%-24s", s);
85 va_start(arg, format);
86 *buf += vsprintf(*buf, format, arg);
88 *buf += sprintf(*buf, "\n");
91 static void zfcp_dbf_outd(char **p, const char *label, char *buffer,
92 int buflen, int offset, int total_size)
95 *p += sprintf(*p, "%-24s ", label);
98 if ((offset % 32) == 0)
99 *p += sprintf(*p, "\n%-24c ", ' ');
100 else if ((offset % 4) == 0)
101 *p += sprintf(*p, " ");
103 *p += sprintf(*p, "%02x", *buffer++);
104 if (++offset == total_size) {
105 *p += sprintf(*p, "\n");
110 *p += sprintf(*p, "\n");
114 zfcp_dbf_view_header(debug_info_t * id, struct debug_view *view, int area,
115 debug_entry_t * entry, char *out_buf)
117 struct zfcp_dbf_dump *dump = (struct zfcp_dbf_dump *)DEBUG_DATA(entry);
121 if (strncmp(dump->tag, "dump", ZFCP_DBF_TAG_SIZE) != 0) {
122 zfcp_dbf_timestamp(entry->id.stck, &t);
123 zfcp_dbf_out(&p, "timestamp", "%011lu:%06lu",
124 t.tv_sec, t.tv_nsec);
125 zfcp_dbf_out(&p, "cpu", "%02i", entry->id.fields.cpuid);
127 zfcp_dbf_outd(&p, NULL, dump->data, dump->size, dump->offset,
129 if ((dump->offset + dump->size) == dump->total_size)
130 p += sprintf(p, "\n");
135 void zfcp_hba_dbf_event_fsf_response(struct zfcp_fsf_req *fsf_req)
137 struct zfcp_adapter *adapter = fsf_req->adapter;
138 struct fsf_qtcb *qtcb = fsf_req->qtcb;
139 union fsf_prot_status_qual *prot_status_qual =
140 &qtcb->prefix.prot_status_qual;
141 union fsf_status_qual *fsf_status_qual = &qtcb->header.fsf_status_qual;
142 struct scsi_cmnd *scsi_cmnd;
143 struct zfcp_port *port;
144 struct zfcp_unit *unit;
145 struct zfcp_send_els *send_els;
146 struct zfcp_hba_dbf_record *rec = &adapter->hba_dbf_buf;
147 struct zfcp_hba_dbf_record_response *response = &rec->type.response;
151 spin_lock_irqsave(&adapter->hba_dbf_lock, flags);
152 memset(rec, 0, sizeof(struct zfcp_hba_dbf_record));
153 strncpy(rec->tag, "resp", ZFCP_DBF_TAG_SIZE);
155 if ((qtcb->prefix.prot_status != FSF_PROT_GOOD) &&
156 (qtcb->prefix.prot_status != FSF_PROT_FSF_STATUS_PRESENTED)) {
157 strncpy(rec->tag2, "perr", ZFCP_DBF_TAG_SIZE);
159 } else if (qtcb->header.fsf_status != FSF_GOOD) {
160 strncpy(rec->tag2, "ferr", ZFCP_DBF_TAG_SIZE);
162 } else if ((fsf_req->fsf_command == FSF_QTCB_OPEN_PORT_WITH_DID) ||
163 (fsf_req->fsf_command == FSF_QTCB_OPEN_LUN)) {
164 strncpy(rec->tag2, "open", ZFCP_DBF_TAG_SIZE);
166 } else if (qtcb->header.log_length) {
167 strncpy(rec->tag2, "qtcb", ZFCP_DBF_TAG_SIZE);
170 strncpy(rec->tag2, "norm", ZFCP_DBF_TAG_SIZE);
174 response->fsf_command = fsf_req->fsf_command;
175 response->fsf_reqid = (unsigned long)fsf_req;
176 response->fsf_seqno = fsf_req->seq_no;
177 response->fsf_issued = fsf_req->issued;
178 response->fsf_prot_status = qtcb->prefix.prot_status;
179 response->fsf_status = qtcb->header.fsf_status;
180 memcpy(response->fsf_prot_status_qual,
181 prot_status_qual, FSF_PROT_STATUS_QUAL_SIZE);
182 memcpy(response->fsf_status_qual,
183 fsf_status_qual, FSF_STATUS_QUALIFIER_SIZE);
184 response->fsf_req_status = fsf_req->status;
185 response->sbal_first = fsf_req->sbal_first;
186 response->sbal_curr = fsf_req->sbal_curr;
187 response->sbal_last = fsf_req->sbal_last;
188 response->pool = fsf_req->pool != NULL;
189 response->erp_action = (unsigned long)fsf_req->erp_action;
191 switch (fsf_req->fsf_command) {
192 case FSF_QTCB_FCP_CMND:
193 if (fsf_req->status & ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT)
195 scsi_cmnd = (struct scsi_cmnd *)fsf_req->data;
196 if (scsi_cmnd != NULL) {
197 response->data.send_fcp.scsi_cmnd
198 = (unsigned long)scsi_cmnd;
199 response->data.send_fcp.scsi_serial
200 = scsi_cmnd->serial_number;
204 case FSF_QTCB_OPEN_PORT_WITH_DID:
205 case FSF_QTCB_CLOSE_PORT:
206 case FSF_QTCB_CLOSE_PHYSICAL_PORT:
207 port = (struct zfcp_port *)fsf_req->data;
208 response->data.port.wwpn = port->wwpn;
209 response->data.port.d_id = port->d_id;
210 response->data.port.port_handle = qtcb->header.port_handle;
213 case FSF_QTCB_OPEN_LUN:
214 case FSF_QTCB_CLOSE_LUN:
215 unit = (struct zfcp_unit *)fsf_req->data;
217 response->data.unit.wwpn = port->wwpn;
218 response->data.unit.fcp_lun = unit->fcp_lun;
219 response->data.unit.port_handle = qtcb->header.port_handle;
220 response->data.unit.lun_handle = qtcb->header.lun_handle;
223 case FSF_QTCB_SEND_ELS:
224 send_els = (struct zfcp_send_els *)fsf_req->data;
225 response->data.send_els.d_id = qtcb->bottom.support.d_id;
226 response->data.send_els.ls_code = send_els->ls_code >> 24;
229 case FSF_QTCB_ABORT_FCP_CMND:
230 case FSF_QTCB_SEND_GENERIC:
231 case FSF_QTCB_EXCHANGE_CONFIG_DATA:
232 case FSF_QTCB_EXCHANGE_PORT_DATA:
233 case FSF_QTCB_DOWNLOAD_CONTROL_FILE:
234 case FSF_QTCB_UPLOAD_CONTROL_FILE:
238 debug_event(adapter->hba_dbf, level,
239 rec, sizeof(struct zfcp_hba_dbf_record));
241 /* have fcp channel microcode fixed to use as little as possible */
242 if (fsf_req->fsf_command != FSF_QTCB_FCP_CMND) {
243 /* adjust length skipping trailing zeros */
244 char *buf = (char *)qtcb + qtcb->header.log_start;
245 int len = qtcb->header.log_length;
246 for (; len && !buf[len - 1]; len--);
247 zfcp_dbf_hexdump(adapter->hba_dbf, rec, sizeof(*rec), level,
251 spin_unlock_irqrestore(&adapter->hba_dbf_lock, flags);
255 zfcp_hba_dbf_event_fsf_unsol(const char *tag, struct zfcp_adapter *adapter,
256 struct fsf_status_read_buffer *status_buffer)
258 struct zfcp_hba_dbf_record *rec = &adapter->hba_dbf_buf;
261 spin_lock_irqsave(&adapter->hba_dbf_lock, flags);
262 memset(rec, 0, sizeof(struct zfcp_hba_dbf_record));
263 strncpy(rec->tag, "stat", ZFCP_DBF_TAG_SIZE);
264 strncpy(rec->tag2, tag, ZFCP_DBF_TAG_SIZE);
266 rec->type.status.failed = adapter->status_read_failed;
267 if (status_buffer != NULL) {
268 rec->type.status.status_type = status_buffer->status_type;
269 rec->type.status.status_subtype = status_buffer->status_subtype;
270 memcpy(&rec->type.status.queue_designator,
271 &status_buffer->queue_designator,
272 sizeof(struct fsf_queue_designator));
274 switch (status_buffer->status_type) {
275 case FSF_STATUS_READ_SENSE_DATA_AVAIL:
276 rec->type.status.payload_size =
277 ZFCP_DBF_UNSOL_PAYLOAD_SENSE_DATA_AVAIL;
280 case FSF_STATUS_READ_BIT_ERROR_THRESHOLD:
281 rec->type.status.payload_size =
282 ZFCP_DBF_UNSOL_PAYLOAD_BIT_ERROR_THRESHOLD;
285 case FSF_STATUS_READ_LINK_DOWN:
286 switch (status_buffer->status_subtype) {
287 case FSF_STATUS_READ_SUB_NO_PHYSICAL_LINK:
288 case FSF_STATUS_READ_SUB_FDISC_FAILED:
289 rec->type.status.payload_size =
290 sizeof(struct fsf_link_down_info);
294 case FSF_STATUS_READ_FEATURE_UPDATE_ALERT:
295 rec->type.status.payload_size =
296 ZFCP_DBF_UNSOL_PAYLOAD_FEATURE_UPDATE_ALERT;
299 memcpy(&rec->type.status.payload,
300 &status_buffer->payload, rec->type.status.payload_size);
303 debug_event(adapter->hba_dbf, 2,
304 rec, sizeof(struct zfcp_hba_dbf_record));
305 spin_unlock_irqrestore(&adapter->hba_dbf_lock, flags);
309 zfcp_hba_dbf_event_qdio(struct zfcp_adapter *adapter, unsigned int status,
310 unsigned int qdio_error, unsigned int siga_error,
311 int sbal_index, int sbal_count)
313 struct zfcp_hba_dbf_record *rec = &adapter->hba_dbf_buf;
316 spin_lock_irqsave(&adapter->hba_dbf_lock, flags);
317 memset(rec, 0, sizeof(struct zfcp_hba_dbf_record));
318 strncpy(rec->tag, "qdio", ZFCP_DBF_TAG_SIZE);
319 rec->type.qdio.status = status;
320 rec->type.qdio.qdio_error = qdio_error;
321 rec->type.qdio.siga_error = siga_error;
322 rec->type.qdio.sbal_index = sbal_index;
323 rec->type.qdio.sbal_count = sbal_count;
324 debug_event(adapter->hba_dbf, 0,
325 rec, sizeof(struct zfcp_hba_dbf_record));
326 spin_unlock_irqrestore(&adapter->hba_dbf_lock, flags);
329 static void zfcp_hba_dbf_view_response(char **p,
330 struct zfcp_hba_dbf_record_response *r)
334 zfcp_dbf_out(p, "fsf_command", "0x%08x", r->fsf_command);
335 zfcp_dbf_out(p, "fsf_reqid", "0x%0Lx", r->fsf_reqid);
336 zfcp_dbf_out(p, "fsf_seqno", "0x%08x", r->fsf_seqno);
337 zfcp_dbf_timestamp(r->fsf_issued, &t);
338 zfcp_dbf_out(p, "fsf_issued", "%011lu:%06lu", t.tv_sec, t.tv_nsec);
339 zfcp_dbf_out(p, "fsf_prot_status", "0x%08x", r->fsf_prot_status);
340 zfcp_dbf_out(p, "fsf_status", "0x%08x", r->fsf_status);
341 zfcp_dbf_outd(p, "fsf_prot_status_qual", r->fsf_prot_status_qual,
342 FSF_PROT_STATUS_QUAL_SIZE, 0, FSF_PROT_STATUS_QUAL_SIZE);
343 zfcp_dbf_outd(p, "fsf_status_qual", r->fsf_status_qual,
344 FSF_STATUS_QUALIFIER_SIZE, 0, FSF_STATUS_QUALIFIER_SIZE);
345 zfcp_dbf_out(p, "fsf_req_status", "0x%08x", r->fsf_req_status);
346 zfcp_dbf_out(p, "sbal_first", "0x%02x", r->sbal_first);
347 zfcp_dbf_out(p, "sbal_curr", "0x%02x", r->sbal_curr);
348 zfcp_dbf_out(p, "sbal_last", "0x%02x", r->sbal_last);
349 zfcp_dbf_out(p, "pool", "0x%02x", r->pool);
351 switch (r->fsf_command) {
352 case FSF_QTCB_FCP_CMND:
353 if (r->fsf_req_status & ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT)
355 zfcp_dbf_out(p, "scsi_cmnd", "0x%0Lx",
356 r->data.send_fcp.scsi_cmnd);
357 zfcp_dbf_out(p, "scsi_serial", "0x%016Lx",
358 r->data.send_fcp.scsi_serial);
361 case FSF_QTCB_OPEN_PORT_WITH_DID:
362 case FSF_QTCB_CLOSE_PORT:
363 case FSF_QTCB_CLOSE_PHYSICAL_PORT:
364 zfcp_dbf_out(p, "wwpn", "0x%016Lx", r->data.port.wwpn);
365 zfcp_dbf_out(p, "d_id", "0x%06x", r->data.port.d_id);
366 zfcp_dbf_out(p, "port_handle", "0x%08x",
367 r->data.port.port_handle);
370 case FSF_QTCB_OPEN_LUN:
371 case FSF_QTCB_CLOSE_LUN:
372 zfcp_dbf_out(p, "wwpn", "0x%016Lx", r->data.unit.wwpn);
373 zfcp_dbf_out(p, "fcp_lun", "0x%016Lx", r->data.unit.fcp_lun);
374 zfcp_dbf_out(p, "port_handle", "0x%08x",
375 r->data.unit.port_handle);
376 zfcp_dbf_out(p, "lun_handle", "0x%08x",
377 r->data.unit.lun_handle);
380 case FSF_QTCB_SEND_ELS:
381 zfcp_dbf_out(p, "d_id", "0x%06x", r->data.send_els.d_id);
382 zfcp_dbf_out(p, "ls_code", "0x%02x", r->data.send_els.ls_code);
385 case FSF_QTCB_ABORT_FCP_CMND:
386 case FSF_QTCB_SEND_GENERIC:
387 case FSF_QTCB_EXCHANGE_CONFIG_DATA:
388 case FSF_QTCB_EXCHANGE_PORT_DATA:
389 case FSF_QTCB_DOWNLOAD_CONTROL_FILE:
390 case FSF_QTCB_UPLOAD_CONTROL_FILE:
395 static void zfcp_hba_dbf_view_status(char **p,
396 struct zfcp_hba_dbf_record_status *r)
398 zfcp_dbf_out(p, "failed", "0x%02x", r->failed);
399 zfcp_dbf_out(p, "status_type", "0x%08x", r->status_type);
400 zfcp_dbf_out(p, "status_subtype", "0x%08x", r->status_subtype);
401 zfcp_dbf_outd(p, "queue_designator", (char *)&r->queue_designator,
402 sizeof(struct fsf_queue_designator), 0,
403 sizeof(struct fsf_queue_designator));
404 zfcp_dbf_outd(p, "payload", (char *)&r->payload, r->payload_size, 0,
408 static void zfcp_hba_dbf_view_qdio(char **p, struct zfcp_hba_dbf_record_qdio *r)
410 zfcp_dbf_out(p, "status", "0x%08x", r->status);
411 zfcp_dbf_out(p, "qdio_error", "0x%08x", r->qdio_error);
412 zfcp_dbf_out(p, "siga_error", "0x%08x", r->siga_error);
413 zfcp_dbf_out(p, "sbal_index", "0x%02x", r->sbal_index);
414 zfcp_dbf_out(p, "sbal_count", "0x%02x", r->sbal_count);
417 static int zfcp_hba_dbf_view_format(debug_info_t *id, struct debug_view *view,
418 char *out_buf, const char *in_buf)
420 struct zfcp_hba_dbf_record *r = (struct zfcp_hba_dbf_record *)in_buf;
423 if (strncmp(r->tag, "dump", ZFCP_DBF_TAG_SIZE) == 0)
426 zfcp_dbf_tag(&p, "tag", r->tag);
427 if (isalpha(r->tag2[0]))
428 zfcp_dbf_tag(&p, "tag2", r->tag2);
430 if (strncmp(r->tag, "resp", ZFCP_DBF_TAG_SIZE) == 0)
431 zfcp_hba_dbf_view_response(&p, &r->type.response);
432 else if (strncmp(r->tag, "stat", ZFCP_DBF_TAG_SIZE) == 0)
433 zfcp_hba_dbf_view_status(&p, &r->type.status);
434 else if (strncmp(r->tag, "qdio", ZFCP_DBF_TAG_SIZE) == 0)
435 zfcp_hba_dbf_view_qdio(&p, &r->type.qdio);
437 p += sprintf(p, "\n");
441 static struct debug_view zfcp_hba_dbf_view = {
444 &zfcp_dbf_view_header,
445 &zfcp_hba_dbf_view_format,
450 static const char *zfcp_rec_dbf_tags[] = {
451 [ZFCP_REC_DBF_ID_THREAD] = "thread",
452 [ZFCP_REC_DBF_ID_TARGET] = "target",
453 [ZFCP_REC_DBF_ID_TRIGGER] = "trigger",
454 [ZFCP_REC_DBF_ID_ACTION] = "action",
457 static const char *zfcp_rec_dbf_ids[] = {
463 [6] = "down sleep ecd",
464 [7] = "down wakeup ecd",
465 [8] = "down sleep epd",
466 [9] = "down wakeup epd",
468 [11] = "operational",
469 [12] = "scsi slave destroy",
470 [13] = "propagate failed adapter",
471 [14] = "propagate failed port",
472 [15] = "block adapter",
473 [16] = "unblock adapter",
475 [18] = "unblock port",
477 [20] = "unblock unit",
478 [21] = "unit recovery failed",
479 [22] = "port recovery failed",
480 [23] = "adapter recovery failed",
481 [24] = "qdio queues down",
483 [26] = "nameserver lookup failed",
484 [27] = "nameserver port failed",
487 [30] = "link up status read",
488 [31] = "open port failed",
489 [32] = "open port failed",
491 [34] = "open unit failed",
492 [35] = "exclusive open unit failed",
493 [36] = "shared open unit failed",
495 [38] = "link down status read no link",
496 [39] = "link down status read fdisc login",
497 [40] = "link down status read firmware update",
498 [41] = "link down status read unknown reason",
499 [42] = "link down ecd incomplete",
500 [43] = "link down epd incomplete",
501 [44] = "sysfs adapter recovery",
502 [45] = "sysfs port recovery",
503 [46] = "sysfs unit recovery",
504 [47] = "port boxed abort",
505 [48] = "unit boxed abort",
506 [49] = "port boxed ct",
507 [50] = "port boxed close physical",
508 [51] = "port boxed open unit",
509 [52] = "port boxed close unit",
510 [53] = "port boxed fcp",
511 [54] = "unit boxed fcp",
512 [55] = "port access denied ct",
513 [56] = "port access denied els",
514 [57] = "port access denied open port",
515 [58] = "port access denied close physical",
516 [59] = "unit access denied open unit",
517 [60] = "shared unit access denied open unit",
518 [61] = "unit access denied fcp",
519 [62] = "request timeout",
520 [63] = "adisc link test reject or timeout",
521 [64] = "adisc link test d_id changed",
522 [65] = "adisc link test failed",
523 [66] = "recovery out of memory",
524 [67] = "adapter recovery repeated after state change",
525 [68] = "port recovery repeated after state change",
526 [69] = "unit recovery repeated after state change",
527 [70] = "port recovery follow-up after successful adapter recovery",
528 [71] = "adapter recovery escalation after failed adapter recovery",
529 [72] = "port recovery follow-up after successful physical port "
531 [73] = "adapter recovery escalation after failed physical port "
533 [74] = "unit recovery follow-up after successful port recovery",
534 [75] = "physical port recovery escalation after failed port "
536 [76] = "port recovery escalation after failed unit recovery",
537 [77] = "recovery opening nameserver port",
538 [78] = "duplicate request id",
540 [80] = "exclusive read-only unit access unsupported",
541 [81] = "shared read-write unit access unsupported",
542 [82] = "incoming rscn",
543 [83] = "incoming plogi",
544 [84] = "incoming logo",
547 [87] = "ccw device gone",
548 [88] = "ccw device no path",
549 [89] = "ccw device operational",
550 [90] = "ccw device shutdown",
551 [91] = "sysfs port addition",
552 [92] = "sysfs port removal",
553 [93] = "sysfs adapter recovery",
554 [94] = "sysfs unit addition",
555 [95] = "sysfs unit removal",
556 [96] = "sysfs port recovery",
557 [97] = "sysfs unit recovery",
558 [98] = "sequence number mismatch",
560 [100] = "error state",
561 [101] = "status read physical port closed",
562 [102] = "link up status read",
563 [103] = "too many failed status read buffers",
564 [104] = "port handle not valid abort",
565 [105] = "lun handle not valid abort",
566 [106] = "port handle not valid ct",
567 [107] = "port handle not valid close port",
568 [108] = "port handle not valid close physical port",
569 [109] = "port handle not valid open unit",
570 [110] = "port handle not valid close unit",
571 [111] = "lun handle not valid close unit",
572 [112] = "port handle not valid fcp",
573 [113] = "lun handle not valid fcp",
574 [114] = "handle mismatch fcp",
575 [115] = "lun not valid fcp",
576 [116] = "qdio send failed",
577 [117] = "version mismatch",
578 [118] = "incompatible qtcb type",
579 [119] = "unknown protocol status",
580 [120] = "unknown fsf command",
581 [121] = "no recommendation for status qualifier",
582 [122] = "status read physical port closed in error",
583 [123] = "fc service class not supported ct",
584 [124] = "fc service class not supported els",
585 [125] = "need newer zfcp",
586 [126] = "need newer microcode",
587 [127] = "arbitrated loop not supported",
588 [128] = "unknown topology",
589 [129] = "qtcb size mismatch",
590 [130] = "unknown fsf status ecd",
591 [131] = "fcp request too big",
592 [132] = "fc service class not supported fcp",
593 [133] = "data direction not valid fcp",
594 [134] = "command length not valid fcp",
595 [135] = "status read act update",
596 [136] = "status read cfdc update",
597 [137] = "hbaapi port open",
598 [138] = "hbaapi unit open",
599 [139] = "hbaapi unit shutdown",
600 [140] = "qdio error",
601 [141] = "scsi host reset",
602 [142] = "dismissing fsf request for recovery action",
603 [143] = "recovery action timed out",
604 [144] = "recovery action gone",
605 [145] = "recovery action being processed",
606 [146] = "recovery action ready for next step",
609 static int zfcp_rec_dbf_view_format(debug_info_t *id, struct debug_view *view,
610 char *buf, const char *_rec)
612 struct zfcp_rec_dbf_record *r = (struct zfcp_rec_dbf_record *)_rec;
615 zfcp_dbf_outs(&p, "tag", zfcp_rec_dbf_tags[r->id]);
616 zfcp_dbf_outs(&p, "hint", zfcp_rec_dbf_ids[r->id2]);
617 zfcp_dbf_out(&p, "id", "%d", r->id2);
619 case ZFCP_REC_DBF_ID_THREAD:
620 zfcp_dbf_out(&p, "sema", "%d", r->u.thread.sema);
621 zfcp_dbf_out(&p, "total", "%d", r->u.thread.total);
622 zfcp_dbf_out(&p, "ready", "%d", r->u.thread.ready);
623 zfcp_dbf_out(&p, "running", "%d", r->u.thread.running);
625 case ZFCP_REC_DBF_ID_TARGET:
626 zfcp_dbf_out(&p, "reference", "0x%016Lx", r->u.target.ref);
627 zfcp_dbf_out(&p, "status", "0x%08x", r->u.target.status);
628 zfcp_dbf_out(&p, "erp_count", "%d", r->u.target.erp_count);
629 zfcp_dbf_out(&p, "d_id", "0x%06x", r->u.target.d_id);
630 zfcp_dbf_out(&p, "wwpn", "0x%016Lx", r->u.target.wwpn);
631 zfcp_dbf_out(&p, "fcp_lun", "0x%016Lx", r->u.target.fcp_lun);
633 case ZFCP_REC_DBF_ID_TRIGGER:
634 zfcp_dbf_out(&p, "reference", "0x%016Lx", r->u.trigger.ref);
635 zfcp_dbf_out(&p, "erp_action", "0x%016Lx", r->u.trigger.action);
636 zfcp_dbf_out(&p, "requested", "%d", r->u.trigger.want);
637 zfcp_dbf_out(&p, "executed", "%d", r->u.trigger.need);
638 zfcp_dbf_out(&p, "wwpn", "0x%016Lx", r->u.trigger.wwpn);
639 zfcp_dbf_out(&p, "fcp_lun", "0x%016Lx", r->u.trigger.fcp_lun);
640 zfcp_dbf_out(&p, "adapter_status", "0x%08x", r->u.trigger.as);
641 zfcp_dbf_out(&p, "port_status", "0x%08x", r->u.trigger.ps);
642 zfcp_dbf_out(&p, "unit_status", "0x%08x", r->u.trigger.us);
644 case ZFCP_REC_DBF_ID_ACTION:
645 zfcp_dbf_out(&p, "erp_action", "0x%016Lx", r->u.action.action);
646 zfcp_dbf_out(&p, "fsf_req", "0x%016Lx", r->u.action.fsf_req);
647 zfcp_dbf_out(&p, "status", "0x%08Lx", r->u.action.status);
648 zfcp_dbf_out(&p, "step", "0x%08Lx", r->u.action.step);
651 p += sprintf(p, "\n");
655 static struct debug_view zfcp_rec_dbf_view = {
658 &zfcp_dbf_view_header,
659 &zfcp_rec_dbf_view_format,
665 * zfcp_rec_dbf_event_thread - trace event related to recovery thread operation
666 * @id2: identifier for event
668 * @lock: non-zero value indicates that erp_lock has not yet been acquired
670 void zfcp_rec_dbf_event_thread(u8 id2, struct zfcp_adapter *adapter, int lock)
672 struct zfcp_rec_dbf_record *r = &adapter->rec_dbf_buf;
673 unsigned long flags = 0;
674 struct list_head *entry;
675 unsigned ready = 0, running = 0, total;
678 read_lock_irqsave(&adapter->erp_lock, flags);
679 list_for_each(entry, &adapter->erp_ready_head)
681 list_for_each(entry, &adapter->erp_running_head)
683 total = adapter->erp_total_count;
685 read_unlock_irqrestore(&adapter->erp_lock, flags);
687 spin_lock_irqsave(&adapter->rec_dbf_lock, flags);
688 memset(r, 0, sizeof(*r));
689 r->id = ZFCP_REC_DBF_ID_THREAD;
691 r->u.thread.sema = atomic_read(&adapter->erp_ready_sem.count);
692 r->u.thread.total = total;
693 r->u.thread.ready = ready;
694 r->u.thread.running = running;
695 debug_event(adapter->rec_dbf, 5, r, sizeof(*r));
696 spin_unlock_irqrestore(&adapter->rec_dbf_lock, flags);
699 static void zfcp_rec_dbf_event_target(u8 id2, u64 ref,
700 struct zfcp_adapter *adapter,
701 atomic_t *status, atomic_t *erp_count,
702 u64 wwpn, u32 d_id, u64 fcp_lun)
704 struct zfcp_rec_dbf_record *r = &adapter->rec_dbf_buf;
707 spin_lock_irqsave(&adapter->rec_dbf_lock, flags);
708 memset(r, 0, sizeof(*r));
709 r->id = ZFCP_REC_DBF_ID_TARGET;
711 r->u.target.ref = ref;
712 r->u.target.status = atomic_read(status);
713 r->u.target.wwpn = wwpn;
714 r->u.target.d_id = d_id;
715 r->u.target.fcp_lun = fcp_lun;
716 r->u.target.erp_count = atomic_read(erp_count);
717 debug_event(adapter->rec_dbf, 3, r, sizeof(*r));
718 spin_unlock_irqrestore(&adapter->rec_dbf_lock, flags);
722 * zfcp_rec_dbf_event_adapter - trace event for adapter state change
723 * @id: identifier for trigger of state change
724 * @ref: additional reference (e.g. request)
727 void zfcp_rec_dbf_event_adapter(u8 id, u64 ref, struct zfcp_adapter *adapter)
729 zfcp_rec_dbf_event_target(id, ref, adapter, &adapter->status,
730 &adapter->erp_counter, 0, 0, 0);
734 * zfcp_rec_dbf_event_port - trace event for port state change
735 * @id: identifier for trigger of state change
736 * @ref: additional reference (e.g. request)
739 void zfcp_rec_dbf_event_port(u8 id, u64 ref, struct zfcp_port *port)
741 struct zfcp_adapter *adapter = port->adapter;
743 zfcp_rec_dbf_event_target(id, ref, adapter, &port->status,
744 &port->erp_counter, port->wwpn, port->d_id,
749 * zfcp_rec_dbf_event_unit - trace event for unit state change
750 * @id: identifier for trigger of state change
751 * @ref: additional reference (e.g. request)
754 void zfcp_rec_dbf_event_unit(u8 id, u64 ref, struct zfcp_unit *unit)
756 struct zfcp_port *port = unit->port;
757 struct zfcp_adapter *adapter = port->adapter;
759 zfcp_rec_dbf_event_target(id, ref, adapter, &unit->status,
760 &unit->erp_counter, port->wwpn, port->d_id,
765 * zfcp_rec_dbf_event_trigger - trace event for triggered error recovery
766 * @id2: identifier for error recovery trigger
767 * @ref: additional reference (e.g. request)
768 * @want: originally requested error recovery action
769 * @need: error recovery action actually initiated
770 * @action: address of error recovery action struct
775 void zfcp_rec_dbf_event_trigger(u8 id2, u64 ref, u8 want, u8 need, u64 action,
776 struct zfcp_adapter *adapter,
777 struct zfcp_port *port, struct zfcp_unit *unit)
779 struct zfcp_rec_dbf_record *r = &adapter->rec_dbf_buf;
782 spin_lock_irqsave(&adapter->rec_dbf_lock, flags);
783 memset(r, 0, sizeof(*r));
784 r->id = ZFCP_REC_DBF_ID_TRIGGER;
786 r->u.trigger.ref = ref;
787 r->u.trigger.want = want;
788 r->u.trigger.need = need;
789 r->u.trigger.action = action;
790 r->u.trigger.as = atomic_read(&adapter->status);
792 r->u.trigger.ps = atomic_read(&port->status);
793 r->u.trigger.wwpn = port->wwpn;
796 r->u.trigger.us = atomic_read(&unit->status);
797 r->u.trigger.fcp_lun = unit->fcp_lun;
799 debug_event(adapter->rec_dbf, action ? 1 : 4, r, sizeof(*r));
800 spin_unlock_irqrestore(&adapter->rec_dbf_lock, flags);
804 * zfcp_rec_dbf_event_action - trace event showing progress of recovery action
806 * @erp_action: error recovery action struct pointer
808 void zfcp_rec_dbf_event_action(u8 id2, struct zfcp_erp_action *erp_action)
810 struct zfcp_adapter *adapter = erp_action->adapter;
811 struct zfcp_rec_dbf_record *r = &adapter->rec_dbf_buf;
814 spin_lock_irqsave(&adapter->rec_dbf_lock, flags);
815 memset(r, 0, sizeof(*r));
816 r->id = ZFCP_REC_DBF_ID_ACTION;
818 r->u.action.action = (u64)erp_action;
819 r->u.action.status = erp_action->status;
820 r->u.action.step = erp_action->step;
821 r->u.action.fsf_req = (u64)erp_action->fsf_req;
822 debug_event(adapter->rec_dbf, 4, r, sizeof(*r));
823 spin_unlock_irqrestore(&adapter->rec_dbf_lock, flags);
827 _zfcp_san_dbf_event_common_ct(const char *tag, struct zfcp_fsf_req *fsf_req,
828 u32 s_id, u32 d_id, void *buffer, int buflen)
830 struct zfcp_send_ct *send_ct = (struct zfcp_send_ct *)fsf_req->data;
831 struct zfcp_port *port = send_ct->port;
832 struct zfcp_adapter *adapter = port->adapter;
833 struct ct_hdr *header = (struct ct_hdr *)buffer;
834 struct zfcp_san_dbf_record *rec = &adapter->san_dbf_buf;
835 struct zfcp_san_dbf_record_ct *ct = &rec->type.ct;
838 spin_lock_irqsave(&adapter->san_dbf_lock, flags);
839 memset(rec, 0, sizeof(struct zfcp_san_dbf_record));
840 strncpy(rec->tag, tag, ZFCP_DBF_TAG_SIZE);
841 rec->fsf_reqid = (unsigned long)fsf_req;
842 rec->fsf_seqno = fsf_req->seq_no;
845 if (strncmp(tag, "octc", ZFCP_DBF_TAG_SIZE) == 0) {
846 ct->type.request.cmd_req_code = header->cmd_rsp_code;
847 ct->type.request.revision = header->revision;
848 ct->type.request.gs_type = header->gs_type;
849 ct->type.request.gs_subtype = header->gs_subtype;
850 ct->type.request.options = header->options;
851 ct->type.request.max_res_size = header->max_res_size;
852 } else if (strncmp(tag, "rctc", ZFCP_DBF_TAG_SIZE) == 0) {
853 ct->type.response.cmd_rsp_code = header->cmd_rsp_code;
854 ct->type.response.revision = header->revision;
855 ct->type.response.reason_code = header->reason_code;
856 ct->type.response.reason_code_expl = header->reason_code_expl;
857 ct->type.response.vendor_unique = header->vendor_unique;
860 min(buflen - (int)sizeof(struct ct_hdr), ZFCP_DBF_CT_PAYLOAD);
861 memcpy(ct->payload, buffer + sizeof(struct ct_hdr), ct->payload_size);
862 debug_event(adapter->san_dbf, 3,
863 rec, sizeof(struct zfcp_san_dbf_record));
864 spin_unlock_irqrestore(&adapter->san_dbf_lock, flags);
867 void zfcp_san_dbf_event_ct_request(struct zfcp_fsf_req *fsf_req)
869 struct zfcp_send_ct *ct = (struct zfcp_send_ct *)fsf_req->data;
870 struct zfcp_port *port = ct->port;
871 struct zfcp_adapter *adapter = port->adapter;
873 _zfcp_san_dbf_event_common_ct("octc", fsf_req,
874 fc_host_port_id(adapter->scsi_host),
875 port->d_id, zfcp_sg_to_address(ct->req),
879 void zfcp_san_dbf_event_ct_response(struct zfcp_fsf_req *fsf_req)
881 struct zfcp_send_ct *ct = (struct zfcp_send_ct *)fsf_req->data;
882 struct zfcp_port *port = ct->port;
883 struct zfcp_adapter *adapter = port->adapter;
885 _zfcp_san_dbf_event_common_ct("rctc", fsf_req, port->d_id,
886 fc_host_port_id(adapter->scsi_host),
887 zfcp_sg_to_address(ct->resp),
892 _zfcp_san_dbf_event_common_els(const char *tag, int level,
893 struct zfcp_fsf_req *fsf_req, u32 s_id,
894 u32 d_id, u8 ls_code, void *buffer, int buflen)
896 struct zfcp_adapter *adapter = fsf_req->adapter;
897 struct zfcp_san_dbf_record *rec = &adapter->san_dbf_buf;
900 spin_lock_irqsave(&adapter->san_dbf_lock, flags);
901 memset(rec, 0, sizeof(struct zfcp_san_dbf_record));
902 strncpy(rec->tag, tag, ZFCP_DBF_TAG_SIZE);
903 rec->fsf_reqid = (unsigned long)fsf_req;
904 rec->fsf_seqno = fsf_req->seq_no;
907 rec->type.els.ls_code = ls_code;
908 debug_event(adapter->san_dbf, level, rec, sizeof(*rec));
909 zfcp_dbf_hexdump(adapter->san_dbf, rec, sizeof(*rec), level,
910 buffer, min(buflen, ZFCP_DBF_ELS_MAX_PAYLOAD));
911 spin_unlock_irqrestore(&adapter->san_dbf_lock, flags);
914 void zfcp_san_dbf_event_els_request(struct zfcp_fsf_req *fsf_req)
916 struct zfcp_send_els *els = (struct zfcp_send_els *)fsf_req->data;
918 _zfcp_san_dbf_event_common_els("oels", 2, fsf_req,
919 fc_host_port_id(els->adapter->scsi_host),
921 *(u8 *) zfcp_sg_to_address(els->req),
922 zfcp_sg_to_address(els->req),
926 void zfcp_san_dbf_event_els_response(struct zfcp_fsf_req *fsf_req)
928 struct zfcp_send_els *els = (struct zfcp_send_els *)fsf_req->data;
930 _zfcp_san_dbf_event_common_els("rels", 2, fsf_req, els->d_id,
931 fc_host_port_id(els->adapter->scsi_host),
932 *(u8 *) zfcp_sg_to_address(els->req),
933 zfcp_sg_to_address(els->resp),
937 void zfcp_san_dbf_event_incoming_els(struct zfcp_fsf_req *fsf_req)
939 struct zfcp_adapter *adapter = fsf_req->adapter;
940 struct fsf_status_read_buffer *status_buffer =
941 (struct fsf_status_read_buffer *)fsf_req->data;
942 int length = (int)status_buffer->length -
943 (int)((void *)&status_buffer->payload - (void *)status_buffer);
945 _zfcp_san_dbf_event_common_els("iels", 1, fsf_req, status_buffer->d_id,
946 fc_host_port_id(adapter->scsi_host),
947 *(u8 *) status_buffer->payload,
948 (void *)status_buffer->payload, length);
952 zfcp_san_dbf_view_format(debug_info_t * id, struct debug_view *view,
953 char *out_buf, const char *in_buf)
955 struct zfcp_san_dbf_record *r = (struct zfcp_san_dbf_record *)in_buf;
957 int buflen = 0, total = 0;
960 if (strncmp(r->tag, "dump", ZFCP_DBF_TAG_SIZE) == 0)
963 zfcp_dbf_tag(&p, "tag", r->tag);
964 zfcp_dbf_out(&p, "fsf_reqid", "0x%0Lx", r->fsf_reqid);
965 zfcp_dbf_out(&p, "fsf_seqno", "0x%08x", r->fsf_seqno);
966 zfcp_dbf_out(&p, "s_id", "0x%06x", r->s_id);
967 zfcp_dbf_out(&p, "d_id", "0x%06x", r->d_id);
969 if (strncmp(r->tag, "octc", ZFCP_DBF_TAG_SIZE) == 0) {
970 /* FIXME: struct zfcp_dbf_ct_req *ct = ...; */
971 zfcp_dbf_out(&p, "cmd_req_code", "0x%04x",
972 r->type.ct.type.request.cmd_req_code);
973 zfcp_dbf_out(&p, "revision", "0x%02x",
974 r->type.ct.type.request.revision);
975 zfcp_dbf_out(&p, "gs_type", "0x%02x",
976 r->type.ct.type.request.gs_type);
977 zfcp_dbf_out(&p, "gs_subtype", "0x%02x",
978 r->type.ct.type.request.gs_subtype);
979 zfcp_dbf_out(&p, "options", "0x%02x",
980 r->type.ct.type.request.options);
981 zfcp_dbf_out(&p, "max_res_size", "0x%04x",
982 r->type.ct.type.request.max_res_size);
983 total = r->type.ct.payload_size;
984 buffer = r->type.ct.payload;
985 buflen = min(total, ZFCP_DBF_CT_PAYLOAD);
986 } else if (strncmp(r->tag, "rctc", ZFCP_DBF_TAG_SIZE) == 0) {
987 zfcp_dbf_out(&p, "cmd_rsp_code", "0x%04x",
988 r->type.ct.type.response.cmd_rsp_code);
989 zfcp_dbf_out(&p, "revision", "0x%02x",
990 r->type.ct.type.response.revision);
991 zfcp_dbf_out(&p, "reason_code", "0x%02x",
992 r->type.ct.type.response.reason_code);
993 zfcp_dbf_out(&p, "reason_code_expl", "0x%02x",
994 r->type.ct.type.response.reason_code_expl);
995 zfcp_dbf_out(&p, "vendor_unique", "0x%02x",
996 r->type.ct.type.response.vendor_unique);
997 total = r->type.ct.payload_size;
998 buffer = r->type.ct.payload;
999 buflen = min(total, ZFCP_DBF_CT_PAYLOAD);
1000 } else if (strncmp(r->tag, "oels", ZFCP_DBF_TAG_SIZE) == 0 ||
1001 strncmp(r->tag, "rels", ZFCP_DBF_TAG_SIZE) == 0 ||
1002 strncmp(r->tag, "iels", ZFCP_DBF_TAG_SIZE) == 0) {
1003 zfcp_dbf_out(&p, "ls_code", "0x%02x", r->type.els.ls_code);
1004 total = r->type.els.payload_size;
1005 buffer = r->type.els.payload;
1006 buflen = min(total, ZFCP_DBF_ELS_PAYLOAD);
1009 zfcp_dbf_outd(&p, "payload", buffer, buflen, 0, total);
1010 if (buflen == total)
1011 p += sprintf(p, "\n");
1016 static struct debug_view zfcp_san_dbf_view = {
1019 &zfcp_dbf_view_header,
1020 &zfcp_san_dbf_view_format,
1026 _zfcp_scsi_dbf_event_common(const char *tag, const char *tag2, int level,
1027 struct zfcp_adapter *adapter,
1028 struct scsi_cmnd *scsi_cmnd,
1029 struct zfcp_fsf_req *fsf_req,
1030 unsigned long old_req_id)
1032 struct zfcp_scsi_dbf_record *rec = &adapter->scsi_dbf_buf;
1033 struct zfcp_dbf_dump *dump = (struct zfcp_dbf_dump *)rec;
1034 unsigned long flags;
1035 struct fcp_rsp_iu *fcp_rsp;
1036 char *fcp_rsp_info = NULL, *fcp_sns_info = NULL;
1037 int offset = 0, buflen = 0;
1039 spin_lock_irqsave(&adapter->scsi_dbf_lock, flags);
1041 memset(rec, 0, sizeof(struct zfcp_scsi_dbf_record));
1043 strncpy(rec->tag, tag, ZFCP_DBF_TAG_SIZE);
1044 strncpy(rec->tag2, tag2, ZFCP_DBF_TAG_SIZE);
1045 if (scsi_cmnd != NULL) {
1046 if (scsi_cmnd->device) {
1047 rec->scsi_id = scsi_cmnd->device->id;
1048 rec->scsi_lun = scsi_cmnd->device->lun;
1050 rec->scsi_result = scsi_cmnd->result;
1051 rec->scsi_cmnd = (unsigned long)scsi_cmnd;
1052 rec->scsi_serial = scsi_cmnd->serial_number;
1053 memcpy(rec->scsi_opcode, &scsi_cmnd->cmnd,
1054 min((int)scsi_cmnd->cmd_len,
1055 ZFCP_DBF_SCSI_OPCODE));
1056 rec->scsi_retries = scsi_cmnd->retries;
1057 rec->scsi_allowed = scsi_cmnd->allowed;
1059 if (fsf_req != NULL) {
1060 fcp_rsp = (struct fcp_rsp_iu *)
1061 &(fsf_req->qtcb->bottom.io.fcp_rsp);
1063 zfcp_get_fcp_rsp_info_ptr(fcp_rsp);
1065 zfcp_get_fcp_sns_info_ptr(fcp_rsp);
1067 rec->type.fcp.rsp_validity =
1068 fcp_rsp->validity.value;
1069 rec->type.fcp.rsp_scsi_status =
1070 fcp_rsp->scsi_status;
1071 rec->type.fcp.rsp_resid = fcp_rsp->fcp_resid;
1072 if (fcp_rsp->validity.bits.fcp_rsp_len_valid)
1073 rec->type.fcp.rsp_code =
1074 *(fcp_rsp_info + 3);
1075 if (fcp_rsp->validity.bits.fcp_sns_len_valid) {
1076 buflen = min((int)fcp_rsp->fcp_sns_len,
1077 ZFCP_DBF_SCSI_MAX_FCP_SNS_INFO);
1078 rec->type.fcp.sns_info_len = buflen;
1079 memcpy(rec->type.fcp.sns_info,
1082 ZFCP_DBF_SCSI_FCP_SNS_INFO));
1083 offset += min(buflen,
1084 ZFCP_DBF_SCSI_FCP_SNS_INFO);
1087 rec->fsf_reqid = (unsigned long)fsf_req;
1088 rec->fsf_seqno = fsf_req->seq_no;
1089 rec->fsf_issued = fsf_req->issued;
1091 rec->type.old_fsf_reqid = old_req_id;
1093 strncpy(dump->tag, "dump", ZFCP_DBF_TAG_SIZE);
1094 dump->total_size = buflen;
1095 dump->offset = offset;
1096 dump->size = min(buflen - offset,
1098 zfcp_scsi_dbf_record) -
1099 (int)sizeof(struct zfcp_dbf_dump));
1100 memcpy(dump->data, fcp_sns_info + offset, dump->size);
1101 offset += dump->size;
1103 debug_event(adapter->scsi_dbf, level,
1104 rec, sizeof(struct zfcp_scsi_dbf_record));
1105 } while (offset < buflen);
1106 spin_unlock_irqrestore(&adapter->scsi_dbf_lock, flags);
1110 zfcp_scsi_dbf_event_result(const char *tag, int level,
1111 struct zfcp_adapter *adapter,
1112 struct scsi_cmnd *scsi_cmnd,
1113 struct zfcp_fsf_req *fsf_req)
1115 _zfcp_scsi_dbf_event_common("rslt", tag, level,
1116 adapter, scsi_cmnd, fsf_req, 0);
1120 zfcp_scsi_dbf_event_abort(const char *tag, struct zfcp_adapter *adapter,
1121 struct scsi_cmnd *scsi_cmnd,
1122 struct zfcp_fsf_req *new_fsf_req,
1123 unsigned long old_req_id)
1125 _zfcp_scsi_dbf_event_common("abrt", tag, 1,
1126 adapter, scsi_cmnd, new_fsf_req, old_req_id);
1130 zfcp_scsi_dbf_event_devreset(const char *tag, u8 flag, struct zfcp_unit *unit,
1131 struct scsi_cmnd *scsi_cmnd)
1133 struct zfcp_adapter *adapter = unit->port->adapter;
1135 _zfcp_scsi_dbf_event_common(flag == FCP_TARGET_RESET ? "trst" : "lrst",
1136 tag, 1, adapter, scsi_cmnd, NULL, 0);
1140 zfcp_scsi_dbf_view_format(debug_info_t * id, struct debug_view *view,
1141 char *out_buf, const char *in_buf)
1143 struct zfcp_scsi_dbf_record *r = (struct zfcp_scsi_dbf_record *)in_buf;
1147 if (strncmp(r->tag, "dump", ZFCP_DBF_TAG_SIZE) == 0)
1150 zfcp_dbf_tag(&p, "tag", r->tag);
1151 zfcp_dbf_tag(&p, "tag2", r->tag2);
1152 zfcp_dbf_out(&p, "scsi_id", "0x%08x", r->scsi_id);
1153 zfcp_dbf_out(&p, "scsi_lun", "0x%08x", r->scsi_lun);
1154 zfcp_dbf_out(&p, "scsi_result", "0x%08x", r->scsi_result);
1155 zfcp_dbf_out(&p, "scsi_cmnd", "0x%0Lx", r->scsi_cmnd);
1156 zfcp_dbf_out(&p, "scsi_serial", "0x%016Lx", r->scsi_serial);
1157 zfcp_dbf_outd(&p, "scsi_opcode", r->scsi_opcode, ZFCP_DBF_SCSI_OPCODE,
1158 0, ZFCP_DBF_SCSI_OPCODE);
1159 zfcp_dbf_out(&p, "scsi_retries", "0x%02x", r->scsi_retries);
1160 zfcp_dbf_out(&p, "scsi_allowed", "0x%02x", r->scsi_allowed);
1161 if (strncmp(r->tag, "abrt", ZFCP_DBF_TAG_SIZE) == 0)
1162 zfcp_dbf_out(&p, "old_fsf_reqid", "0x%0Lx",
1163 r->type.old_fsf_reqid);
1164 zfcp_dbf_out(&p, "fsf_reqid", "0x%0Lx", r->fsf_reqid);
1165 zfcp_dbf_out(&p, "fsf_seqno", "0x%08x", r->fsf_seqno);
1166 zfcp_dbf_timestamp(r->fsf_issued, &t);
1167 zfcp_dbf_out(&p, "fsf_issued", "%011lu:%06lu", t.tv_sec, t.tv_nsec);
1169 if (strncmp(r->tag, "rslt", ZFCP_DBF_TAG_SIZE) == 0) {
1170 zfcp_dbf_out(&p, "fcp_rsp_validity", "0x%02x",
1171 r->type.fcp.rsp_validity);
1172 zfcp_dbf_out(&p, "fcp_rsp_scsi_status",
1173 "0x%02x", r->type.fcp.rsp_scsi_status);
1174 zfcp_dbf_out(&p, "fcp_rsp_resid", "0x%08x",
1175 r->type.fcp.rsp_resid);
1176 zfcp_dbf_out(&p, "fcp_rsp_code", "0x%08x",
1177 r->type.fcp.rsp_code);
1178 zfcp_dbf_out(&p, "fcp_sns_info_len", "0x%08x",
1179 r->type.fcp.sns_info_len);
1180 zfcp_dbf_outd(&p, "fcp_sns_info", r->type.fcp.sns_info,
1181 min((int)r->type.fcp.sns_info_len,
1182 ZFCP_DBF_SCSI_FCP_SNS_INFO), 0,
1183 r->type.fcp.sns_info_len);
1185 p += sprintf(p, "\n");
1189 static struct debug_view zfcp_scsi_dbf_view = {
1192 &zfcp_dbf_view_header,
1193 &zfcp_scsi_dbf_view_format,
1199 * zfcp_adapter_debug_register - registers debug feature for an adapter
1200 * @adapter: pointer to adapter for which debug features should be registered
1201 * return: -ENOMEM on error, 0 otherwise
1203 int zfcp_adapter_debug_register(struct zfcp_adapter *adapter)
1205 char dbf_name[DEBUG_MAX_NAME_LEN];
1207 /* debug feature area which records recovery activity */
1208 sprintf(dbf_name, "zfcp_%s_rec", zfcp_get_busid_by_adapter(adapter));
1209 adapter->rec_dbf = debug_register(dbf_name, dbfsize, 1,
1210 sizeof(struct zfcp_rec_dbf_record));
1211 if (!adapter->rec_dbf)
1213 debug_register_view(adapter->rec_dbf, &debug_hex_ascii_view);
1214 debug_register_view(adapter->rec_dbf, &zfcp_rec_dbf_view);
1215 debug_set_level(adapter->rec_dbf, 3);
1217 /* debug feature area which records HBA (FSF and QDIO) conditions */
1218 sprintf(dbf_name, "zfcp_%s_hba", zfcp_get_busid_by_adapter(adapter));
1219 adapter->hba_dbf = debug_register(dbf_name, dbfsize, 1,
1220 sizeof(struct zfcp_hba_dbf_record));
1221 if (!adapter->hba_dbf)
1223 debug_register_view(adapter->hba_dbf, &debug_hex_ascii_view);
1224 debug_register_view(adapter->hba_dbf, &zfcp_hba_dbf_view);
1225 debug_set_level(adapter->hba_dbf, 3);
1227 /* debug feature area which records SAN command failures and recovery */
1228 sprintf(dbf_name, "zfcp_%s_san", zfcp_get_busid_by_adapter(adapter));
1229 adapter->san_dbf = debug_register(dbf_name, dbfsize, 1,
1230 sizeof(struct zfcp_san_dbf_record));
1231 if (!adapter->san_dbf)
1233 debug_register_view(adapter->san_dbf, &debug_hex_ascii_view);
1234 debug_register_view(adapter->san_dbf, &zfcp_san_dbf_view);
1235 debug_set_level(adapter->san_dbf, 6);
1237 /* debug feature area which records SCSI command failures and recovery */
1238 sprintf(dbf_name, "zfcp_%s_scsi", zfcp_get_busid_by_adapter(adapter));
1239 adapter->scsi_dbf = debug_register(dbf_name, dbfsize, 1,
1240 sizeof(struct zfcp_scsi_dbf_record));
1241 if (!adapter->scsi_dbf)
1243 debug_register_view(adapter->scsi_dbf, &debug_hex_ascii_view);
1244 debug_register_view(adapter->scsi_dbf, &zfcp_scsi_dbf_view);
1245 debug_set_level(adapter->scsi_dbf, 3);
1250 zfcp_adapter_debug_unregister(adapter);
1256 * zfcp_adapter_debug_unregister - unregisters debug feature for an adapter
1257 * @adapter: pointer to adapter for which debug features should be unregistered
1259 void zfcp_adapter_debug_unregister(struct zfcp_adapter *adapter)
1261 debug_unregister(adapter->scsi_dbf);
1262 debug_unregister(adapter->san_dbf);
1263 debug_unregister(adapter->hba_dbf);
1264 debug_unregister(adapter->rec_dbf);
1265 adapter->scsi_dbf = NULL;
1266 adapter->san_dbf = NULL;
1267 adapter->hba_dbf = NULL;
1268 adapter->rec_dbf = NULL;
1271 #undef ZFCP_LOG_AREA