aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/s390/scsi/zfcp_dbf.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/s390/scsi/zfcp_dbf.c')
-rw-r--r--drivers/s390/scsi/zfcp_dbf.c408
1 files changed, 192 insertions, 216 deletions
diff --git a/drivers/s390/scsi/zfcp_dbf.c b/drivers/s390/scsi/zfcp_dbf.c
index 3179b08bda6a..c066428b2878 100644
--- a/drivers/s390/scsi/zfcp_dbf.c
+++ b/drivers/s390/scsi/zfcp_dbf.c
@@ -120,9 +120,9 @@ static int zfcp_dbf_view_header(debug_info_t *id, struct debug_view *view,
120 return p - out_buf; 120 return p - out_buf;
121} 121}
122 122
123void _zfcp_hba_dbf_event_fsf_response(const char *tag2, int level, 123void _zfcp_dbf_hba_fsf_response(const char *tag2, int level,
124 struct zfcp_fsf_req *fsf_req, 124 struct zfcp_fsf_req *fsf_req,
125 struct zfcp_dbf *dbf) 125 struct zfcp_dbf *dbf)
126{ 126{
127 struct fsf_qtcb *qtcb = fsf_req->qtcb; 127 struct fsf_qtcb *qtcb = fsf_req->qtcb;
128 union fsf_prot_status_qual *prot_status_qual = 128 union fsf_prot_status_qual *prot_status_qual =
@@ -132,11 +132,11 @@ void _zfcp_hba_dbf_event_fsf_response(const char *tag2, int level,
132 struct zfcp_port *port; 132 struct zfcp_port *port;
133 struct zfcp_unit *unit; 133 struct zfcp_unit *unit;
134 struct zfcp_send_els *send_els; 134 struct zfcp_send_els *send_els;
135 struct zfcp_hba_dbf_record *rec = &dbf->hba_dbf_buf; 135 struct zfcp_dbf_hba_record *rec = &dbf->hba_buf;
136 struct zfcp_hba_dbf_record_response *response = &rec->u.response; 136 struct zfcp_dbf_hba_record_response *response = &rec->u.response;
137 unsigned long flags; 137 unsigned long flags;
138 138
139 spin_lock_irqsave(&dbf->hba_dbf_lock, flags); 139 spin_lock_irqsave(&dbf->hba_lock, flags);
140 memset(rec, 0, sizeof(*rec)); 140 memset(rec, 0, sizeof(*rec));
141 strncpy(rec->tag, "resp", ZFCP_DBF_TAG_SIZE); 141 strncpy(rec->tag, "resp", ZFCP_DBF_TAG_SIZE);
142 strncpy(rec->tag2, tag2, ZFCP_DBF_TAG_SIZE); 142 strncpy(rec->tag2, tag2, ZFCP_DBF_TAG_SIZE);
@@ -203,7 +203,7 @@ void _zfcp_hba_dbf_event_fsf_response(const char *tag2, int level,
203 break; 203 break;
204 } 204 }
205 205
206 debug_event(dbf->hba_dbf, level, rec, sizeof(*rec)); 206 debug_event(dbf->hba, level, rec, sizeof(*rec));
207 207
208 /* have fcp channel microcode fixed to use as little as possible */ 208 /* have fcp channel microcode fixed to use as little as possible */
209 if (fsf_req->fsf_command != FSF_QTCB_FCP_CMND) { 209 if (fsf_req->fsf_command != FSF_QTCB_FCP_CMND) {
@@ -211,27 +211,25 @@ void _zfcp_hba_dbf_event_fsf_response(const char *tag2, int level,
211 char *buf = (char *)qtcb + qtcb->header.log_start; 211 char *buf = (char *)qtcb + qtcb->header.log_start;
212 int len = qtcb->header.log_length; 212 int len = qtcb->header.log_length;
213 for (; len && !buf[len - 1]; len--); 213 for (; len && !buf[len - 1]; len--);
214 zfcp_dbf_hexdump(dbf->hba_dbf, rec, sizeof(*rec), level, buf, 214 zfcp_dbf_hexdump(dbf->hba, rec, sizeof(*rec), level, buf,
215 len); 215 len);
216 } 216 }
217 217
218 spin_unlock_irqrestore(&dbf->hba_dbf_lock, flags); 218 spin_unlock_irqrestore(&dbf->hba_lock, flags);
219} 219}
220 220
221void _zfcp_hba_dbf_event_fsf_unsol(const char *tag, int level, 221void _zfcp_dbf_hba_fsf_unsol(const char *tag, int level, struct zfcp_dbf *dbf,
222 struct zfcp_adapter *adapter, 222 struct fsf_status_read_buffer *status_buffer)
223 struct fsf_status_read_buffer *status_buffer)
224{ 223{
225 struct zfcp_dbf *dbf = adapter->dbf; 224 struct zfcp_dbf_hba_record *rec = &dbf->hba_buf;
226 struct zfcp_hba_dbf_record *rec = &dbf->hba_dbf_buf;
227 unsigned long flags; 225 unsigned long flags;
228 226
229 spin_lock_irqsave(&dbf->hba_dbf_lock, flags); 227 spin_lock_irqsave(&dbf->hba_lock, flags);
230 memset(rec, 0, sizeof(*rec)); 228 memset(rec, 0, sizeof(*rec));
231 strncpy(rec->tag, "stat", ZFCP_DBF_TAG_SIZE); 229 strncpy(rec->tag, "stat", ZFCP_DBF_TAG_SIZE);
232 strncpy(rec->tag2, tag, ZFCP_DBF_TAG_SIZE); 230 strncpy(rec->tag2, tag, ZFCP_DBF_TAG_SIZE);
233 231
234 rec->u.status.failed = atomic_read(&adapter->stat_miss); 232 rec->u.status.failed = atomic_read(&dbf->adapter->stat_miss);
235 if (status_buffer != NULL) { 233 if (status_buffer != NULL) {
236 rec->u.status.status_type = status_buffer->status_type; 234 rec->u.status.status_type = status_buffer->status_type;
237 rec->u.status.status_subtype = status_buffer->status_subtype; 235 rec->u.status.status_subtype = status_buffer->status_subtype;
@@ -268,58 +266,54 @@ void _zfcp_hba_dbf_event_fsf_unsol(const char *tag, int level,
268 &status_buffer->payload, rec->u.status.payload_size); 266 &status_buffer->payload, rec->u.status.payload_size);
269 } 267 }
270 268
271 debug_event(dbf->hba_dbf, level, rec, sizeof(*rec)); 269 debug_event(dbf->hba, level, rec, sizeof(*rec));
272 spin_unlock_irqrestore(&dbf->hba_dbf_lock, flags); 270 spin_unlock_irqrestore(&dbf->hba_lock, flags);
273} 271}
274 272
275/** 273/**
276 * zfcp_hba_dbf_event_qdio - trace event for QDIO related failure 274 * zfcp_dbf_hba_qdio - trace event for QDIO related failure
277 * @qdio: qdio structure affected by this QDIO related event 275 * @qdio: qdio structure affected by this QDIO related event
278 * @qdio_error: as passed by qdio module 276 * @qdio_error: as passed by qdio module
279 * @sbal_index: first buffer with error condition, as passed by qdio module 277 * @sbal_index: first buffer with error condition, as passed by qdio module
280 * @sbal_count: number of buffers affected, as passed by qdio module 278 * @sbal_count: number of buffers affected, as passed by qdio module
281 */ 279 */
282void zfcp_hba_dbf_event_qdio(struct zfcp_qdio *qdio, 280void zfcp_dbf_hba_qdio(struct zfcp_dbf *dbf, unsigned int qdio_error,
283 unsigned int qdio_error, int sbal_index, 281 int sbal_index, int sbal_count)
284 int sbal_count)
285{ 282{
286 struct zfcp_dbf *dbf = qdio->adapter->dbf; 283 struct zfcp_dbf_hba_record *r = &dbf->hba_buf;
287 struct zfcp_hba_dbf_record *r = &dbf->hba_dbf_buf;
288 unsigned long flags; 284 unsigned long flags;
289 285
290 spin_lock_irqsave(&dbf->hba_dbf_lock, flags); 286 spin_lock_irqsave(&dbf->hba_lock, flags);
291 memset(r, 0, sizeof(*r)); 287 memset(r, 0, sizeof(*r));
292 strncpy(r->tag, "qdio", ZFCP_DBF_TAG_SIZE); 288 strncpy(r->tag, "qdio", ZFCP_DBF_TAG_SIZE);
293 r->u.qdio.qdio_error = qdio_error; 289 r->u.qdio.qdio_error = qdio_error;
294 r->u.qdio.sbal_index = sbal_index; 290 r->u.qdio.sbal_index = sbal_index;
295 r->u.qdio.sbal_count = sbal_count; 291 r->u.qdio.sbal_count = sbal_count;
296 debug_event(dbf->hba_dbf, 0, r, sizeof(*r)); 292 debug_event(dbf->hba, 0, r, sizeof(*r));
297 spin_unlock_irqrestore(&dbf->hba_dbf_lock, flags); 293 spin_unlock_irqrestore(&dbf->hba_lock, flags);
298} 294}
299 295
300/** 296/**
301 * zfcp_hba_dbf_event_berr - trace event for bit error threshold 297 * zfcp_dbf_hba_berr - trace event for bit error threshold
302 * @adapter: adapter affected by this QDIO related event 298 * @dbf: dbf structure affected by this QDIO related event
303 * @req: fsf request 299 * @req: fsf request
304 */ 300 */
305void zfcp_hba_dbf_event_berr(struct zfcp_adapter *adapter, 301void zfcp_dbf_hba_berr(struct zfcp_dbf *dbf, struct zfcp_fsf_req *req)
306 struct zfcp_fsf_req *req)
307{ 302{
308 struct zfcp_dbf *dbf = adapter->dbf; 303 struct zfcp_dbf_hba_record *r = &dbf->hba_buf;
309 struct zfcp_hba_dbf_record *r = &dbf->hba_dbf_buf;
310 struct fsf_status_read_buffer *sr_buf = req->data; 304 struct fsf_status_read_buffer *sr_buf = req->data;
311 struct fsf_bit_error_payload *err = &sr_buf->payload.bit_error; 305 struct fsf_bit_error_payload *err = &sr_buf->payload.bit_error;
312 unsigned long flags; 306 unsigned long flags;
313 307
314 spin_lock_irqsave(&dbf->hba_dbf_lock, flags); 308 spin_lock_irqsave(&dbf->hba_lock, flags);
315 memset(r, 0, sizeof(*r)); 309 memset(r, 0, sizeof(*r));
316 strncpy(r->tag, "berr", ZFCP_DBF_TAG_SIZE); 310 strncpy(r->tag, "berr", ZFCP_DBF_TAG_SIZE);
317 memcpy(&r->u.berr, err, sizeof(struct fsf_bit_error_payload)); 311 memcpy(&r->u.berr, err, sizeof(struct fsf_bit_error_payload));
318 debug_event(dbf->hba_dbf, 0, r, sizeof(*r)); 312 debug_event(dbf->hba, 0, r, sizeof(*r));
319 spin_unlock_irqrestore(&dbf->hba_dbf_lock, flags); 313 spin_unlock_irqrestore(&dbf->hba_lock, flags);
320} 314}
321static void zfcp_hba_dbf_view_response(char **p, 315static void zfcp_dbf_hba_view_response(char **p,
322 struct zfcp_hba_dbf_record_response *r) 316 struct zfcp_dbf_hba_record_response *r)
323{ 317{
324 struct timespec t; 318 struct timespec t;
325 319
@@ -380,8 +374,8 @@ static void zfcp_hba_dbf_view_response(char **p,
380 } 374 }
381} 375}
382 376
383static void zfcp_hba_dbf_view_status(char **p, 377static void zfcp_dbf_hba_view_status(char **p,
384 struct zfcp_hba_dbf_record_status *r) 378 struct zfcp_dbf_hba_record_status *r)
385{ 379{
386 zfcp_dbf_out(p, "failed", "0x%02x", r->failed); 380 zfcp_dbf_out(p, "failed", "0x%02x", r->failed);
387 zfcp_dbf_out(p, "status_type", "0x%08x", r->status_type); 381 zfcp_dbf_out(p, "status_type", "0x%08x", r->status_type);
@@ -393,14 +387,14 @@ static void zfcp_hba_dbf_view_status(char **p,
393 r->payload_size); 387 r->payload_size);
394} 388}
395 389
396static void zfcp_hba_dbf_view_qdio(char **p, struct zfcp_hba_dbf_record_qdio *r) 390static void zfcp_dbf_hba_view_qdio(char **p, struct zfcp_dbf_hba_record_qdio *r)
397{ 391{
398 zfcp_dbf_out(p, "qdio_error", "0x%08x", r->qdio_error); 392 zfcp_dbf_out(p, "qdio_error", "0x%08x", r->qdio_error);
399 zfcp_dbf_out(p, "sbal_index", "0x%02x", r->sbal_index); 393 zfcp_dbf_out(p, "sbal_index", "0x%02x", r->sbal_index);
400 zfcp_dbf_out(p, "sbal_count", "0x%02x", r->sbal_count); 394 zfcp_dbf_out(p, "sbal_count", "0x%02x", r->sbal_count);
401} 395}
402 396
403static void zfcp_hba_dbf_view_berr(char **p, struct fsf_bit_error_payload *r) 397static void zfcp_dbf_hba_view_berr(char **p, struct fsf_bit_error_payload *r)
404{ 398{
405 zfcp_dbf_out(p, "link_failures", "%d", r->link_failure_error_count); 399 zfcp_dbf_out(p, "link_failures", "%d", r->link_failure_error_count);
406 zfcp_dbf_out(p, "loss_of_sync_err", "%d", r->loss_of_sync_error_count); 400 zfcp_dbf_out(p, "loss_of_sync_err", "%d", r->loss_of_sync_error_count);
@@ -424,10 +418,10 @@ static void zfcp_hba_dbf_view_berr(char **p, struct fsf_bit_error_payload *r)
424 r->current_transmit_b2b_credit); 418 r->current_transmit_b2b_credit);
425} 419}
426 420
427static int zfcp_hba_dbf_view_format(debug_info_t *id, struct debug_view *view, 421static int zfcp_dbf_hba_view_format(debug_info_t *id, struct debug_view *view,
428 char *out_buf, const char *in_buf) 422 char *out_buf, const char *in_buf)
429{ 423{
430 struct zfcp_hba_dbf_record *r = (struct zfcp_hba_dbf_record *)in_buf; 424 struct zfcp_dbf_hba_record *r = (struct zfcp_dbf_hba_record *)in_buf;
431 char *p = out_buf; 425 char *p = out_buf;
432 426
433 if (strncmp(r->tag, "dump", ZFCP_DBF_TAG_SIZE) == 0) 427 if (strncmp(r->tag, "dump", ZFCP_DBF_TAG_SIZE) == 0)
@@ -438,45 +432,42 @@ static int zfcp_hba_dbf_view_format(debug_info_t *id, struct debug_view *view,
438 zfcp_dbf_tag(&p, "tag2", r->tag2); 432 zfcp_dbf_tag(&p, "tag2", r->tag2);
439 433
440 if (strncmp(r->tag, "resp", ZFCP_DBF_TAG_SIZE) == 0) 434 if (strncmp(r->tag, "resp", ZFCP_DBF_TAG_SIZE) == 0)
441 zfcp_hba_dbf_view_response(&p, &r->u.response); 435 zfcp_dbf_hba_view_response(&p, &r->u.response);
442 else if (strncmp(r->tag, "stat", ZFCP_DBF_TAG_SIZE) == 0) 436 else if (strncmp(r->tag, "stat", ZFCP_DBF_TAG_SIZE) == 0)
443 zfcp_hba_dbf_view_status(&p, &r->u.status); 437 zfcp_dbf_hba_view_status(&p, &r->u.status);
444 else if (strncmp(r->tag, "qdio", ZFCP_DBF_TAG_SIZE) == 0) 438 else if (strncmp(r->tag, "qdio", ZFCP_DBF_TAG_SIZE) == 0)
445 zfcp_hba_dbf_view_qdio(&p, &r->u.qdio); 439 zfcp_dbf_hba_view_qdio(&p, &r->u.qdio);
446 else if (strncmp(r->tag, "berr", ZFCP_DBF_TAG_SIZE) == 0) 440 else if (strncmp(r->tag, "berr", ZFCP_DBF_TAG_SIZE) == 0)
447 zfcp_hba_dbf_view_berr(&p, &r->u.berr); 441 zfcp_dbf_hba_view_berr(&p, &r->u.berr);
448 442
449 if (strncmp(r->tag, "resp", ZFCP_DBF_TAG_SIZE) != 0) 443 if (strncmp(r->tag, "resp", ZFCP_DBF_TAG_SIZE) != 0)
450 p += sprintf(p, "\n"); 444 p += sprintf(p, "\n");
451 return p - out_buf; 445 return p - out_buf;
452} 446}
453 447
454static struct debug_view zfcp_hba_dbf_view = { 448static struct debug_view zfcp_dbf_hba_view = {
455 "structured", 449 .name = "structured",
456 NULL, 450 .header_proc = zfcp_dbf_view_header,
457 &zfcp_dbf_view_header, 451 .format_proc = zfcp_dbf_hba_view_format,
458 &zfcp_hba_dbf_view_format,
459 NULL,
460 NULL
461}; 452};
462 453
463static const char *zfcp_rec_dbf_tags[] = { 454static const char *zfcp_dbf_rec_tags[] = {
464 [ZFCP_REC_DBF_ID_THREAD] = "thread", 455 [ZFCP_REC_DBF_ID_THREAD] = "thread",
465 [ZFCP_REC_DBF_ID_TARGET] = "target", 456 [ZFCP_REC_DBF_ID_TARGET] = "target",
466 [ZFCP_REC_DBF_ID_TRIGGER] = "trigger", 457 [ZFCP_REC_DBF_ID_TRIGGER] = "trigger",
467 [ZFCP_REC_DBF_ID_ACTION] = "action", 458 [ZFCP_REC_DBF_ID_ACTION] = "action",
468}; 459};
469 460
470static int zfcp_rec_dbf_view_format(debug_info_t *id, struct debug_view *view, 461static int zfcp_dbf_rec_view_format(debug_info_t *id, struct debug_view *view,
471 char *buf, const char *_rec) 462 char *buf, const char *_rec)
472{ 463{
473 struct zfcp_rec_dbf_record *r = (struct zfcp_rec_dbf_record *)_rec; 464 struct zfcp_dbf_rec_record *r = (struct zfcp_dbf_rec_record *)_rec;
474 char *p = buf; 465 char *p = buf;
475 char hint[ZFCP_DBF_ID_SIZE + 1]; 466 char hint[ZFCP_DBF_ID_SIZE + 1];
476 467
477 memcpy(hint, r->id2, ZFCP_DBF_ID_SIZE); 468 memcpy(hint, r->id2, ZFCP_DBF_ID_SIZE);
478 hint[ZFCP_DBF_ID_SIZE] = 0; 469 hint[ZFCP_DBF_ID_SIZE] = 0;
479 zfcp_dbf_outs(&p, "tag", zfcp_rec_dbf_tags[r->id]); 470 zfcp_dbf_outs(&p, "tag", zfcp_dbf_rec_tags[r->id]);
480 zfcp_dbf_outs(&p, "hint", hint); 471 zfcp_dbf_outs(&p, "hint", hint);
481 switch (r->id) { 472 switch (r->id) {
482 case ZFCP_REC_DBF_ID_THREAD: 473 case ZFCP_REC_DBF_ID_THREAD:
@@ -514,25 +505,22 @@ static int zfcp_rec_dbf_view_format(debug_info_t *id, struct debug_view *view,
514 return p - buf; 505 return p - buf;
515} 506}
516 507
517static struct debug_view zfcp_rec_dbf_view = { 508static struct debug_view zfcp_dbf_rec_view = {
518 "structured", 509 .name = "structured",
519 NULL, 510 .header_proc = zfcp_dbf_view_header,
520 &zfcp_dbf_view_header, 511 .format_proc = zfcp_dbf_rec_view_format,
521 &zfcp_rec_dbf_view_format,
522 NULL,
523 NULL
524}; 512};
525 513
526/** 514/**
527 * zfcp_rec_dbf_event_thread - trace event related to recovery thread operation 515 * zfcp_dbf_rec_thread - trace event related to recovery thread operation
528 * @id2: identifier for event 516 * @id2: identifier for event
529 * @adapter: adapter 517 * @dbf: reference to dbf structure
530 * This function assumes that the caller is holding erp_lock. 518 * This function assumes that the caller is holding erp_lock.
531 */ 519 */
532void zfcp_rec_dbf_event_thread(char *id2, struct zfcp_adapter *adapter) 520void zfcp_dbf_rec_thread(char *id2, struct zfcp_dbf *dbf)
533{ 521{
534 struct zfcp_dbf *dbf = adapter->dbf; 522 struct zfcp_adapter *adapter = dbf->adapter;
535 struct zfcp_rec_dbf_record *r = &dbf->rec_dbf_buf; 523 struct zfcp_dbf_rec_record *r = &dbf->rec_buf;
536 unsigned long flags = 0; 524 unsigned long flags = 0;
537 struct list_head *entry; 525 struct list_head *entry;
538 unsigned ready = 0, running = 0, total; 526 unsigned ready = 0, running = 0, total;
@@ -543,42 +531,41 @@ void zfcp_rec_dbf_event_thread(char *id2, struct zfcp_adapter *adapter)
543 running++; 531 running++;
544 total = adapter->erp_total_count; 532 total = adapter->erp_total_count;
545 533
546 spin_lock_irqsave(&dbf->rec_dbf_lock, flags); 534 spin_lock_irqsave(&dbf->rec_lock, flags);
547 memset(r, 0, sizeof(*r)); 535 memset(r, 0, sizeof(*r));
548 r->id = ZFCP_REC_DBF_ID_THREAD; 536 r->id = ZFCP_REC_DBF_ID_THREAD;
549 memcpy(r->id2, id2, ZFCP_DBF_ID_SIZE); 537 memcpy(r->id2, id2, ZFCP_DBF_ID_SIZE);
550 r->u.thread.total = total; 538 r->u.thread.total = total;
551 r->u.thread.ready = ready; 539 r->u.thread.ready = ready;
552 r->u.thread.running = running; 540 r->u.thread.running = running;
553 debug_event(dbf->rec_dbf, 6, r, sizeof(*r)); 541 debug_event(dbf->rec, 6, r, sizeof(*r));
554 spin_unlock_irqrestore(&dbf->rec_dbf_lock, flags); 542 spin_unlock_irqrestore(&dbf->rec_lock, flags);
555} 543}
556 544
557/** 545/**
558 * zfcp_rec_dbf_event_thread - trace event related to recovery thread operation 546 * zfcp_dbf_rec_thread - trace event related to recovery thread operation
559 * @id2: identifier for event 547 * @id2: identifier for event
560 * @adapter: adapter 548 * @adapter: adapter
561 * This function assumes that the caller does not hold erp_lock. 549 * This function assumes that the caller does not hold erp_lock.
562 */ 550 */
563void zfcp_rec_dbf_event_thread_lock(char *id2, struct zfcp_adapter *adapter) 551void zfcp_dbf_rec_thread_lock(char *id2, struct zfcp_dbf *dbf)
564{ 552{
553 struct zfcp_adapter *adapter = dbf->adapter;
565 unsigned long flags; 554 unsigned long flags;
566 555
567 read_lock_irqsave(&adapter->erp_lock, flags); 556 read_lock_irqsave(&adapter->erp_lock, flags);
568 zfcp_rec_dbf_event_thread(id2, adapter); 557 zfcp_dbf_rec_thread(id2, dbf);
569 read_unlock_irqrestore(&adapter->erp_lock, flags); 558 read_unlock_irqrestore(&adapter->erp_lock, flags);
570} 559}
571 560
572static void zfcp_rec_dbf_event_target(char *id2, void *ref, 561static void zfcp_dbf_rec_target(char *id2, void *ref, struct zfcp_dbf *dbf,
573 struct zfcp_adapter *adapter, 562 atomic_t *status, atomic_t *erp_count, u64 wwpn,
574 atomic_t *status, atomic_t *erp_count, 563 u32 d_id, u64 fcp_lun)
575 u64 wwpn, u32 d_id, u64 fcp_lun)
576{ 564{
577 struct zfcp_dbf *dbf = adapter->dbf; 565 struct zfcp_dbf_rec_record *r = &dbf->rec_buf;
578 struct zfcp_rec_dbf_record *r = &dbf->rec_dbf_buf;
579 unsigned long flags; 566 unsigned long flags;
580 567
581 spin_lock_irqsave(&dbf->rec_dbf_lock, flags); 568 spin_lock_irqsave(&dbf->rec_lock, flags);
582 memset(r, 0, sizeof(*r)); 569 memset(r, 0, sizeof(*r));
583 r->id = ZFCP_REC_DBF_ID_TARGET; 570 r->id = ZFCP_REC_DBF_ID_TARGET;
584 memcpy(r->id2, id2, ZFCP_DBF_ID_SIZE); 571 memcpy(r->id2, id2, ZFCP_DBF_ID_SIZE);
@@ -588,56 +575,57 @@ static void zfcp_rec_dbf_event_target(char *id2, void *ref,
588 r->u.target.d_id = d_id; 575 r->u.target.d_id = d_id;
589 r->u.target.fcp_lun = fcp_lun; 576 r->u.target.fcp_lun = fcp_lun;
590 r->u.target.erp_count = atomic_read(erp_count); 577 r->u.target.erp_count = atomic_read(erp_count);
591 debug_event(dbf->rec_dbf, 3, r, sizeof(*r)); 578 debug_event(dbf->rec, 3, r, sizeof(*r));
592 spin_unlock_irqrestore(&dbf->rec_dbf_lock, flags); 579 spin_unlock_irqrestore(&dbf->rec_lock, flags);
593} 580}
594 581
595/** 582/**
596 * zfcp_rec_dbf_event_adapter - trace event for adapter state change 583 * zfcp_dbf_rec_adapter - trace event for adapter state change
597 * @id: identifier for trigger of state change 584 * @id: identifier for trigger of state change
598 * @ref: additional reference (e.g. request) 585 * @ref: additional reference (e.g. request)
599 * @adapter: adapter 586 * @dbf: reference to dbf structure
600 */ 587 */
601void zfcp_rec_dbf_event_adapter(char *id, void *ref, 588void zfcp_dbf_rec_adapter(char *id, void *ref, struct zfcp_dbf *dbf)
602 struct zfcp_adapter *adapter)
603{ 589{
604 zfcp_rec_dbf_event_target(id, ref, adapter, &adapter->status, 590 struct zfcp_adapter *adapter = dbf->adapter;
591
592 zfcp_dbf_rec_target(id, ref, dbf, &adapter->status,
605 &adapter->erp_counter, 0, 0, 0); 593 &adapter->erp_counter, 0, 0, 0);
606} 594}
607 595
608/** 596/**
609 * zfcp_rec_dbf_event_port - trace event for port state change 597 * zfcp_dbf_rec_port - trace event for port state change
610 * @id: identifier for trigger of state change 598 * @id: identifier for trigger of state change
611 * @ref: additional reference (e.g. request) 599 * @ref: additional reference (e.g. request)
612 * @port: port 600 * @port: port
613 */ 601 */
614void zfcp_rec_dbf_event_port(char *id, void *ref, struct zfcp_port *port) 602void zfcp_dbf_rec_port(char *id, void *ref, struct zfcp_port *port)
615{ 603{
616 struct zfcp_adapter *adapter = port->adapter; 604 struct zfcp_dbf *dbf = port->adapter->dbf;
617 605
618 zfcp_rec_dbf_event_target(id, ref, adapter, &port->status, 606 zfcp_dbf_rec_target(id, ref, dbf, &port->status,
619 &port->erp_counter, port->wwpn, port->d_id, 607 &port->erp_counter, port->wwpn, port->d_id,
620 0); 608 0);
621} 609}
622 610
623/** 611/**
624 * zfcp_rec_dbf_event_unit - trace event for unit state change 612 * zfcp_dbf_rec_unit - trace event for unit state change
625 * @id: identifier for trigger of state change 613 * @id: identifier for trigger of state change
626 * @ref: additional reference (e.g. request) 614 * @ref: additional reference (e.g. request)
627 * @unit: unit 615 * @unit: unit
628 */ 616 */
629void zfcp_rec_dbf_event_unit(char *id, void *ref, struct zfcp_unit *unit) 617void zfcp_dbf_rec_unit(char *id, void *ref, struct zfcp_unit *unit)
630{ 618{
631 struct zfcp_port *port = unit->port; 619 struct zfcp_port *port = unit->port;
632 struct zfcp_adapter *adapter = port->adapter; 620 struct zfcp_dbf *dbf = port->adapter->dbf;
633 621
634 zfcp_rec_dbf_event_target(id, ref, adapter, &unit->status, 622 zfcp_dbf_rec_target(id, ref, dbf, &unit->status,
635 &unit->erp_counter, port->wwpn, port->d_id, 623 &unit->erp_counter, port->wwpn, port->d_id,
636 unit->fcp_lun); 624 unit->fcp_lun);
637} 625}
638 626
639/** 627/**
640 * zfcp_rec_dbf_event_trigger - trace event for triggered error recovery 628 * zfcp_dbf_rec_trigger - trace event for triggered error recovery
641 * @id2: identifier for error recovery trigger 629 * @id2: identifier for error recovery trigger
642 * @ref: additional reference (e.g. request) 630 * @ref: additional reference (e.g. request)
643 * @want: originally requested error recovery action 631 * @want: originally requested error recovery action
@@ -647,15 +635,15 @@ void zfcp_rec_dbf_event_unit(char *id, void *ref, struct zfcp_unit *unit)
647 * @port: port 635 * @port: port
648 * @unit: unit 636 * @unit: unit
649 */ 637 */
650void zfcp_rec_dbf_event_trigger(char *id2, void *ref, u8 want, u8 need, 638void zfcp_dbf_rec_trigger(char *id2, void *ref, u8 want, u8 need, void *action,
651 void *action, struct zfcp_adapter *adapter, 639 struct zfcp_adapter *adapter, struct zfcp_port *port,
652 struct zfcp_port *port, struct zfcp_unit *unit) 640 struct zfcp_unit *unit)
653{ 641{
654 struct zfcp_dbf *dbf = adapter->dbf; 642 struct zfcp_dbf *dbf = adapter->dbf;
655 struct zfcp_rec_dbf_record *r = &dbf->rec_dbf_buf; 643 struct zfcp_dbf_rec_record *r = &dbf->rec_buf;
656 unsigned long flags; 644 unsigned long flags;
657 645
658 spin_lock_irqsave(&dbf->rec_dbf_lock, flags); 646 spin_lock_irqsave(&dbf->rec_lock, flags);
659 memset(r, 0, sizeof(*r)); 647 memset(r, 0, sizeof(*r));
660 r->id = ZFCP_REC_DBF_ID_TRIGGER; 648 r->id = ZFCP_REC_DBF_ID_TRIGGER;
661 memcpy(r->id2, id2, ZFCP_DBF_ID_SIZE); 649 memcpy(r->id2, id2, ZFCP_DBF_ID_SIZE);
@@ -672,23 +660,22 @@ void zfcp_rec_dbf_event_trigger(char *id2, void *ref, u8 want, u8 need,
672 r->u.trigger.us = atomic_read(&unit->status); 660 r->u.trigger.us = atomic_read(&unit->status);
673 r->u.trigger.fcp_lun = unit->fcp_lun; 661 r->u.trigger.fcp_lun = unit->fcp_lun;
674 } 662 }
675 debug_event(dbf->rec_dbf, action ? 1 : 4, r, sizeof(*r)); 663 debug_event(dbf->rec, action ? 1 : 4, r, sizeof(*r));
676 spin_unlock_irqrestore(&dbf->rec_dbf_lock, flags); 664 spin_unlock_irqrestore(&dbf->rec_lock, flags);
677} 665}
678 666
679/** 667/**
680 * zfcp_rec_dbf_event_action - trace event showing progress of recovery action 668 * zfcp_dbf_rec_action - trace event showing progress of recovery action
681 * @id2: identifier 669 * @id2: identifier
682 * @erp_action: error recovery action struct pointer 670 * @erp_action: error recovery action struct pointer
683 */ 671 */
684void zfcp_rec_dbf_event_action(char *id2, struct zfcp_erp_action *erp_action) 672void zfcp_dbf_rec_action(char *id2, struct zfcp_erp_action *erp_action)
685{ 673{
686 struct zfcp_adapter *adapter = erp_action->adapter; 674 struct zfcp_dbf *dbf = erp_action->adapter->dbf;
687 struct zfcp_dbf *dbf = adapter->dbf; 675 struct zfcp_dbf_rec_record *r = &dbf->rec_buf;
688 struct zfcp_rec_dbf_record *r = &dbf->rec_dbf_buf;
689 unsigned long flags; 676 unsigned long flags;
690 677
691 spin_lock_irqsave(&dbf->rec_dbf_lock, flags); 678 spin_lock_irqsave(&dbf->rec_lock, flags);
692 memset(r, 0, sizeof(*r)); 679 memset(r, 0, sizeof(*r));
693 r->id = ZFCP_REC_DBF_ID_ACTION; 680 r->id = ZFCP_REC_DBF_ID_ACTION;
694 memcpy(r->id2, id2, ZFCP_DBF_ID_SIZE); 681 memcpy(r->id2, id2, ZFCP_DBF_ID_SIZE);
@@ -696,27 +683,27 @@ void zfcp_rec_dbf_event_action(char *id2, struct zfcp_erp_action *erp_action)
696 r->u.action.status = erp_action->status; 683 r->u.action.status = erp_action->status;
697 r->u.action.step = erp_action->step; 684 r->u.action.step = erp_action->step;
698 r->u.action.fsf_req = (unsigned long)erp_action->fsf_req; 685 r->u.action.fsf_req = (unsigned long)erp_action->fsf_req;
699 debug_event(dbf->rec_dbf, 5, r, sizeof(*r)); 686 debug_event(dbf->rec, 5, r, sizeof(*r));
700 spin_unlock_irqrestore(&dbf->rec_dbf_lock, flags); 687 spin_unlock_irqrestore(&dbf->rec_lock, flags);
701} 688}
702 689
703/** 690/**
704 * zfcp_san_dbf_event_ct_request - trace event for issued CT request 691 * zfcp_dbf_san_ct_request - trace event for issued CT request
705 * @fsf_req: request containing issued CT data 692 * @fsf_req: request containing issued CT data
706 */ 693 */
707void zfcp_san_dbf_event_ct_request(struct zfcp_fsf_req *fsf_req) 694void zfcp_dbf_san_ct_request(struct zfcp_fsf_req *fsf_req)
708{ 695{
709 struct zfcp_send_ct *ct = (struct zfcp_send_ct *)fsf_req->data; 696 struct zfcp_send_ct *ct = (struct zfcp_send_ct *)fsf_req->data;
710 struct zfcp_wka_port *wka_port = ct->wka_port; 697 struct zfcp_wka_port *wka_port = ct->wka_port;
711 struct zfcp_adapter *adapter = wka_port->adapter; 698 struct zfcp_adapter *adapter = wka_port->adapter;
712 struct zfcp_dbf *dbf = adapter->dbf; 699 struct zfcp_dbf *dbf = adapter->dbf;
713 struct ct_hdr *hdr = sg_virt(ct->req); 700 struct ct_hdr *hdr = sg_virt(ct->req);
714 struct zfcp_san_dbf_record *r = &dbf->san_dbf_buf; 701 struct zfcp_dbf_san_record *r = &dbf->san_buf;
715 struct zfcp_san_dbf_record_ct_request *oct = &r->u.ct_req; 702 struct zfcp_dbf_san_record_ct_request *oct = &r->u.ct_req;
716 int level = 3; 703 int level = 3;
717 unsigned long flags; 704 unsigned long flags;
718 705
719 spin_lock_irqsave(&dbf->san_dbf_lock, flags); 706 spin_lock_irqsave(&dbf->san_lock, flags);
720 memset(r, 0, sizeof(*r)); 707 memset(r, 0, sizeof(*r));
721 strncpy(r->tag, "octc", ZFCP_DBF_TAG_SIZE); 708 strncpy(r->tag, "octc", ZFCP_DBF_TAG_SIZE);
722 r->fsf_reqid = fsf_req->req_id; 709 r->fsf_reqid = fsf_req->req_id;
@@ -731,29 +718,29 @@ void zfcp_san_dbf_event_ct_request(struct zfcp_fsf_req *fsf_req)
731 oct->max_res_size = hdr->max_res_size; 718 oct->max_res_size = hdr->max_res_size;
732 oct->len = min((int)ct->req->length - (int)sizeof(struct ct_hdr), 719 oct->len = min((int)ct->req->length - (int)sizeof(struct ct_hdr),
733 ZFCP_DBF_SAN_MAX_PAYLOAD); 720 ZFCP_DBF_SAN_MAX_PAYLOAD);
734 debug_event(dbf->san_dbf, level, r, sizeof(*r)); 721 debug_event(dbf->san, level, r, sizeof(*r));
735 zfcp_dbf_hexdump(dbf->san_dbf, r, sizeof(*r), level, 722 zfcp_dbf_hexdump(dbf->san, r, sizeof(*r), level,
736 (void *)hdr + sizeof(struct ct_hdr), oct->len); 723 (void *)hdr + sizeof(struct ct_hdr), oct->len);
737 spin_unlock_irqrestore(&dbf->san_dbf_lock, flags); 724 spin_unlock_irqrestore(&dbf->san_lock, flags);
738} 725}
739 726
740/** 727/**
741 * zfcp_san_dbf_event_ct_response - trace event for completion of CT request 728 * zfcp_dbf_san_ct_response - trace event for completion of CT request
742 * @fsf_req: request containing CT response 729 * @fsf_req: request containing CT response
743 */ 730 */
744void zfcp_san_dbf_event_ct_response(struct zfcp_fsf_req *fsf_req) 731void zfcp_dbf_san_ct_response(struct zfcp_fsf_req *fsf_req)
745{ 732{
746 struct zfcp_send_ct *ct = (struct zfcp_send_ct *)fsf_req->data; 733 struct zfcp_send_ct *ct = (struct zfcp_send_ct *)fsf_req->data;
747 struct zfcp_wka_port *wka_port = ct->wka_port; 734 struct zfcp_wka_port *wka_port = ct->wka_port;
748 struct zfcp_adapter *adapter = wka_port->adapter; 735 struct zfcp_adapter *adapter = wka_port->adapter;
749 struct ct_hdr *hdr = sg_virt(ct->resp); 736 struct ct_hdr *hdr = sg_virt(ct->resp);
750 struct zfcp_dbf *dbf = adapter->dbf; 737 struct zfcp_dbf *dbf = adapter->dbf;
751 struct zfcp_san_dbf_record *r = &dbf->san_dbf_buf; 738 struct zfcp_dbf_san_record *r = &dbf->san_buf;
752 struct zfcp_san_dbf_record_ct_response *rct = &r->u.ct_resp; 739 struct zfcp_dbf_san_record_ct_response *rct = &r->u.ct_resp;
753 int level = 3; 740 int level = 3;
754 unsigned long flags; 741 unsigned long flags;
755 742
756 spin_lock_irqsave(&dbf->san_dbf_lock, flags); 743 spin_lock_irqsave(&dbf->san_lock, flags);
757 memset(r, 0, sizeof(*r)); 744 memset(r, 0, sizeof(*r));
758 strncpy(r->tag, "rctc", ZFCP_DBF_TAG_SIZE); 745 strncpy(r->tag, "rctc", ZFCP_DBF_TAG_SIZE);
759 r->fsf_reqid = fsf_req->req_id; 746 r->fsf_reqid = fsf_req->req_id;
@@ -768,23 +755,22 @@ void zfcp_san_dbf_event_ct_response(struct zfcp_fsf_req *fsf_req)
768 rct->max_res_size = hdr->max_res_size; 755 rct->max_res_size = hdr->max_res_size;
769 rct->len = min((int)ct->resp->length - (int)sizeof(struct ct_hdr), 756 rct->len = min((int)ct->resp->length - (int)sizeof(struct ct_hdr),
770 ZFCP_DBF_SAN_MAX_PAYLOAD); 757 ZFCP_DBF_SAN_MAX_PAYLOAD);
771 debug_event(dbf->san_dbf, level, r, sizeof(*r)); 758 debug_event(dbf->san, level, r, sizeof(*r));
772 zfcp_dbf_hexdump(dbf->san_dbf, r, sizeof(*r), level, 759 zfcp_dbf_hexdump(dbf->san, r, sizeof(*r), level,
773 (void *)hdr + sizeof(struct ct_hdr), rct->len); 760 (void *)hdr + sizeof(struct ct_hdr), rct->len);
774 spin_unlock_irqrestore(&dbf->san_dbf_lock, flags); 761 spin_unlock_irqrestore(&dbf->san_lock, flags);
775} 762}
776 763
777static void zfcp_san_dbf_event_els(const char *tag, int level, 764static void zfcp_dbf_san_els(const char *tag, int level,
778 struct zfcp_fsf_req *fsf_req, u32 s_id, 765 struct zfcp_fsf_req *fsf_req, u32 s_id, u32 d_id,
779 u32 d_id, u8 ls_code, void *buffer, 766 u8 ls_code, void *buffer, int buflen)
780 int buflen)
781{ 767{
782 struct zfcp_adapter *adapter = fsf_req->adapter; 768 struct zfcp_adapter *adapter = fsf_req->adapter;
783 struct zfcp_dbf *dbf = adapter->dbf; 769 struct zfcp_dbf *dbf = adapter->dbf;
784 struct zfcp_san_dbf_record *rec = &dbf->san_dbf_buf; 770 struct zfcp_dbf_san_record *rec = &dbf->san_buf;
785 unsigned long flags; 771 unsigned long flags;
786 772
787 spin_lock_irqsave(&dbf->san_dbf_lock, flags); 773 spin_lock_irqsave(&dbf->san_lock, flags);
788 memset(rec, 0, sizeof(*rec)); 774 memset(rec, 0, sizeof(*rec));
789 strncpy(rec->tag, tag, ZFCP_DBF_TAG_SIZE); 775 strncpy(rec->tag, tag, ZFCP_DBF_TAG_SIZE);
790 rec->fsf_reqid = fsf_req->req_id; 776 rec->fsf_reqid = fsf_req->req_id;
@@ -792,45 +778,45 @@ static void zfcp_san_dbf_event_els(const char *tag, int level,
792 rec->s_id = s_id; 778 rec->s_id = s_id;
793 rec->d_id = d_id; 779 rec->d_id = d_id;
794 rec->u.els.ls_code = ls_code; 780 rec->u.els.ls_code = ls_code;
795 debug_event(dbf->san_dbf, level, rec, sizeof(*rec)); 781 debug_event(dbf->san, level, rec, sizeof(*rec));
796 zfcp_dbf_hexdump(dbf->san_dbf, rec, sizeof(*rec), level, 782 zfcp_dbf_hexdump(dbf->san, rec, sizeof(*rec), level,
797 buffer, min(buflen, ZFCP_DBF_SAN_MAX_PAYLOAD)); 783 buffer, min(buflen, ZFCP_DBF_SAN_MAX_PAYLOAD));
798 spin_unlock_irqrestore(&dbf->san_dbf_lock, flags); 784 spin_unlock_irqrestore(&dbf->san_lock, flags);
799} 785}
800 786
801/** 787/**
802 * zfcp_san_dbf_event_els_request - trace event for issued ELS 788 * zfcp_dbf_san_els_request - trace event for issued ELS
803 * @fsf_req: request containing issued ELS 789 * @fsf_req: request containing issued ELS
804 */ 790 */
805void zfcp_san_dbf_event_els_request(struct zfcp_fsf_req *fsf_req) 791void zfcp_dbf_san_els_request(struct zfcp_fsf_req *fsf_req)
806{ 792{
807 struct zfcp_send_els *els = (struct zfcp_send_els *)fsf_req->data; 793 struct zfcp_send_els *els = (struct zfcp_send_els *)fsf_req->data;
808 794
809 zfcp_san_dbf_event_els("oels", 2, fsf_req, 795 zfcp_dbf_san_els("oels", 2, fsf_req,
810 fc_host_port_id(els->adapter->scsi_host), 796 fc_host_port_id(els->adapter->scsi_host),
811 els->d_id, *(u8 *) sg_virt(els->req), 797 els->d_id, *(u8 *) sg_virt(els->req),
812 sg_virt(els->req), els->req->length); 798 sg_virt(els->req), els->req->length);
813} 799}
814 800
815/** 801/**
816 * zfcp_san_dbf_event_els_response - trace event for completed ELS 802 * zfcp_dbf_san_els_response - trace event for completed ELS
817 * @fsf_req: request containing ELS response 803 * @fsf_req: request containing ELS response
818 */ 804 */
819void zfcp_san_dbf_event_els_response(struct zfcp_fsf_req *fsf_req) 805void zfcp_dbf_san_els_response(struct zfcp_fsf_req *fsf_req)
820{ 806{
821 struct zfcp_send_els *els = (struct zfcp_send_els *)fsf_req->data; 807 struct zfcp_send_els *els = (struct zfcp_send_els *)fsf_req->data;
822 808
823 zfcp_san_dbf_event_els("rels", 2, fsf_req, els->d_id, 809 zfcp_dbf_san_els("rels", 2, fsf_req, els->d_id,
824 fc_host_port_id(els->adapter->scsi_host), 810 fc_host_port_id(els->adapter->scsi_host),
825 *(u8 *)sg_virt(els->req), sg_virt(els->resp), 811 *(u8 *)sg_virt(els->req), sg_virt(els->resp),
826 els->resp->length); 812 els->resp->length);
827} 813}
828 814
829/** 815/**
830 * zfcp_san_dbf_event_incoming_els - trace event for incomig ELS 816 * zfcp_dbf_san_incoming_els - trace event for incomig ELS
831 * @fsf_req: request containing unsolicited status buffer with incoming ELS 817 * @fsf_req: request containing unsolicited status buffer with incoming ELS
832 */ 818 */
833void zfcp_san_dbf_event_incoming_els(struct zfcp_fsf_req *fsf_req) 819void zfcp_dbf_san_incoming_els(struct zfcp_fsf_req *fsf_req)
834{ 820{
835 struct zfcp_adapter *adapter = fsf_req->adapter; 821 struct zfcp_adapter *adapter = fsf_req->adapter;
836 struct fsf_status_read_buffer *buf = 822 struct fsf_status_read_buffer *buf =
@@ -838,16 +824,16 @@ void zfcp_san_dbf_event_incoming_els(struct zfcp_fsf_req *fsf_req)
838 int length = (int)buf->length - 824 int length = (int)buf->length -
839 (int)((void *)&buf->payload - (void *)buf); 825 (int)((void *)&buf->payload - (void *)buf);
840 826
841 zfcp_san_dbf_event_els("iels", 1, fsf_req, buf->d_id, 827 zfcp_dbf_san_els("iels", 1, fsf_req, buf->d_id,
842 fc_host_port_id(adapter->scsi_host), 828 fc_host_port_id(adapter->scsi_host),
843 buf->payload.data[0], (void *)buf->payload.data, 829 buf->payload.data[0], (void *)buf->payload.data,
844 length); 830 length);
845} 831}
846 832
847static int zfcp_san_dbf_view_format(debug_info_t *id, struct debug_view *view, 833static int zfcp_dbf_san_view_format(debug_info_t *id, struct debug_view *view,
848 char *out_buf, const char *in_buf) 834 char *out_buf, const char *in_buf)
849{ 835{
850 struct zfcp_san_dbf_record *r = (struct zfcp_san_dbf_record *)in_buf; 836 struct zfcp_dbf_san_record *r = (struct zfcp_dbf_san_record *)in_buf;
851 char *p = out_buf; 837 char *p = out_buf;
852 838
853 if (strncmp(r->tag, "dump", ZFCP_DBF_TAG_SIZE) == 0) 839 if (strncmp(r->tag, "dump", ZFCP_DBF_TAG_SIZE) == 0)
@@ -860,7 +846,7 @@ static int zfcp_san_dbf_view_format(debug_info_t *id, struct debug_view *view,
860 zfcp_dbf_out(&p, "d_id", "0x%06x", r->d_id); 846 zfcp_dbf_out(&p, "d_id", "0x%06x", r->d_id);
861 847
862 if (strncmp(r->tag, "octc", ZFCP_DBF_TAG_SIZE) == 0) { 848 if (strncmp(r->tag, "octc", ZFCP_DBF_TAG_SIZE) == 0) {
863 struct zfcp_san_dbf_record_ct_request *ct = &r->u.ct_req; 849 struct zfcp_dbf_san_record_ct_request *ct = &r->u.ct_req;
864 zfcp_dbf_out(&p, "cmd_req_code", "0x%04x", ct->cmd_req_code); 850 zfcp_dbf_out(&p, "cmd_req_code", "0x%04x", ct->cmd_req_code);
865 zfcp_dbf_out(&p, "revision", "0x%02x", ct->revision); 851 zfcp_dbf_out(&p, "revision", "0x%02x", ct->revision);
866 zfcp_dbf_out(&p, "gs_type", "0x%02x", ct->gs_type); 852 zfcp_dbf_out(&p, "gs_type", "0x%02x", ct->gs_type);
@@ -868,7 +854,7 @@ static int zfcp_san_dbf_view_format(debug_info_t *id, struct debug_view *view,
868 zfcp_dbf_out(&p, "options", "0x%02x", ct->options); 854 zfcp_dbf_out(&p, "options", "0x%02x", ct->options);
869 zfcp_dbf_out(&p, "max_res_size", "0x%04x", ct->max_res_size); 855 zfcp_dbf_out(&p, "max_res_size", "0x%04x", ct->max_res_size);
870 } else if (strncmp(r->tag, "rctc", ZFCP_DBF_TAG_SIZE) == 0) { 856 } else if (strncmp(r->tag, "rctc", ZFCP_DBF_TAG_SIZE) == 0) {
871 struct zfcp_san_dbf_record_ct_response *ct = &r->u.ct_resp; 857 struct zfcp_dbf_san_record_ct_response *ct = &r->u.ct_resp;
872 zfcp_dbf_out(&p, "cmd_rsp_code", "0x%04x", ct->cmd_rsp_code); 858 zfcp_dbf_out(&p, "cmd_rsp_code", "0x%04x", ct->cmd_rsp_code);
873 zfcp_dbf_out(&p, "revision", "0x%02x", ct->revision); 859 zfcp_dbf_out(&p, "revision", "0x%02x", ct->revision);
874 zfcp_dbf_out(&p, "reason_code", "0x%02x", ct->reason_code); 860 zfcp_dbf_out(&p, "reason_code", "0x%02x", ct->reason_code);
@@ -878,34 +864,30 @@ static int zfcp_san_dbf_view_format(debug_info_t *id, struct debug_view *view,
878 } else if (strncmp(r->tag, "oels", ZFCP_DBF_TAG_SIZE) == 0 || 864 } else if (strncmp(r->tag, "oels", ZFCP_DBF_TAG_SIZE) == 0 ||
879 strncmp(r->tag, "rels", ZFCP_DBF_TAG_SIZE) == 0 || 865 strncmp(r->tag, "rels", ZFCP_DBF_TAG_SIZE) == 0 ||
880 strncmp(r->tag, "iels", ZFCP_DBF_TAG_SIZE) == 0) { 866 strncmp(r->tag, "iels", ZFCP_DBF_TAG_SIZE) == 0) {
881 struct zfcp_san_dbf_record_els *els = &r->u.els; 867 struct zfcp_dbf_san_record_els *els = &r->u.els;
882 zfcp_dbf_out(&p, "ls_code", "0x%02x", els->ls_code); 868 zfcp_dbf_out(&p, "ls_code", "0x%02x", els->ls_code);
883 } 869 }
884 return p - out_buf; 870 return p - out_buf;
885} 871}
886 872
887static struct debug_view zfcp_san_dbf_view = { 873static struct debug_view zfcp_dbf_san_view = {
888 "structured", 874 .name = "structured",
889 NULL, 875 .header_proc = zfcp_dbf_view_header,
890 &zfcp_dbf_view_header, 876 .format_proc = zfcp_dbf_san_view_format,
891 &zfcp_san_dbf_view_format,
892 NULL,
893 NULL
894}; 877};
895 878
896void _zfcp_scsi_dbf_event(const char *tag, const char *tag2, int level, 879void _zfcp_dbf_scsi(const char *tag, const char *tag2, int level,
897 struct zfcp_dbf *dbf, struct scsi_cmnd *scsi_cmnd, 880 struct zfcp_dbf *dbf, struct scsi_cmnd *scsi_cmnd,
898 struct zfcp_fsf_req *fsf_req, 881 struct zfcp_fsf_req *fsf_req, unsigned long old_req_id)
899 unsigned long old_req_id)
900{ 882{
901 struct zfcp_scsi_dbf_record *rec = &dbf->scsi_dbf_buf; 883 struct zfcp_dbf_scsi_record *rec = &dbf->scsi_buf;
902 struct zfcp_dbf_dump *dump = (struct zfcp_dbf_dump *)rec; 884 struct zfcp_dbf_dump *dump = (struct zfcp_dbf_dump *)rec;
903 unsigned long flags; 885 unsigned long flags;
904 struct fcp_rsp_iu *fcp_rsp; 886 struct fcp_rsp_iu *fcp_rsp;
905 char *fcp_rsp_info = NULL, *fcp_sns_info = NULL; 887 char *fcp_rsp_info = NULL, *fcp_sns_info = NULL;
906 int offset = 0, buflen = 0; 888 int offset = 0, buflen = 0;
907 889
908 spin_lock_irqsave(&dbf->scsi_dbf_lock, flags); 890 spin_lock_irqsave(&dbf->scsi_lock, flags);
909 do { 891 do {
910 memset(rec, 0, sizeof(*rec)); 892 memset(rec, 0, sizeof(*rec));
911 if (offset == 0) { 893 if (offset == 0) {
@@ -959,20 +941,20 @@ void _zfcp_scsi_dbf_event(const char *tag, const char *tag2, int level,
959 dump->offset = offset; 941 dump->offset = offset;
960 dump->size = min(buflen - offset, 942 dump->size = min(buflen - offset,
961 (int)sizeof(struct 943 (int)sizeof(struct
962 zfcp_scsi_dbf_record) - 944 zfcp_dbf_scsi_record) -
963 (int)sizeof(struct zfcp_dbf_dump)); 945 (int)sizeof(struct zfcp_dbf_dump));
964 memcpy(dump->data, fcp_sns_info + offset, dump->size); 946 memcpy(dump->data, fcp_sns_info + offset, dump->size);
965 offset += dump->size; 947 offset += dump->size;
966 } 948 }
967 debug_event(dbf->scsi_dbf, level, rec, sizeof(*rec)); 949 debug_event(dbf->scsi, level, rec, sizeof(*rec));
968 } while (offset < buflen); 950 } while (offset < buflen);
969 spin_unlock_irqrestore(&dbf->scsi_dbf_lock, flags); 951 spin_unlock_irqrestore(&dbf->scsi_lock, flags);
970} 952}
971 953
972static int zfcp_scsi_dbf_view_format(debug_info_t *id, struct debug_view *view, 954static int zfcp_dbf_scsi_view_format(debug_info_t *id, struct debug_view *view,
973 char *out_buf, const char *in_buf) 955 char *out_buf, const char *in_buf)
974{ 956{
975 struct zfcp_scsi_dbf_record *r = (struct zfcp_scsi_dbf_record *)in_buf; 957 struct zfcp_dbf_scsi_record *r = (struct zfcp_dbf_scsi_record *)in_buf;
976 struct timespec t; 958 struct timespec t;
977 char *p = out_buf; 959 char *p = out_buf;
978 960
@@ -1013,13 +995,10 @@ static int zfcp_scsi_dbf_view_format(debug_info_t *id, struct debug_view *view,
1013 return p - out_buf; 995 return p - out_buf;
1014} 996}
1015 997
1016static struct debug_view zfcp_scsi_dbf_view = { 998static struct debug_view zfcp_dbf_scsi_view = {
1017 "structured", 999 .name = "structured",
1018 NULL, 1000 .header_proc = zfcp_dbf_view_header,
1019 &zfcp_dbf_view_header, 1001 .format_proc = zfcp_dbf_scsi_view_format,
1020 &zfcp_scsi_dbf_view_format,
1021 NULL,
1022 NULL
1023}; 1002};
1024 1003
1025static debug_info_t *zfcp_dbf_reg(const char *name, int level, 1004static debug_info_t *zfcp_dbf_reg(const char *name, int level,
@@ -1043,7 +1022,7 @@ static debug_info_t *zfcp_dbf_reg(const char *name, int level,
1043 * @adapter: pointer to adapter for which debug features should be registered 1022 * @adapter: pointer to adapter for which debug features should be registered
1044 * return: -ENOMEM on error, 0 otherwise 1023 * return: -ENOMEM on error, 0 otherwise
1045 */ 1024 */
1046int zfcp_adapter_debug_register(struct zfcp_adapter *adapter) 1025int zfcp_dbf_adapter_register(struct zfcp_adapter *adapter)
1047{ 1026{
1048 char dbf_name[DEBUG_MAX_NAME_LEN]; 1027 char dbf_name[DEBUG_MAX_NAME_LEN];
1049 struct zfcp_dbf *dbf; 1028 struct zfcp_dbf *dbf;
@@ -1052,63 +1031,60 @@ int zfcp_adapter_debug_register(struct zfcp_adapter *adapter)
1052 if (!dbf) 1031 if (!dbf)
1053 return -ENOMEM; 1032 return -ENOMEM;
1054 1033
1055 spin_lock_init(&dbf->hba_dbf_lock); 1034 dbf->adapter = adapter;
1056 spin_lock_init(&dbf->san_dbf_lock); 1035
1057 spin_lock_init(&dbf->scsi_dbf_lock); 1036 spin_lock_init(&dbf->hba_lock);
1058 spin_lock_init(&dbf->rec_dbf_lock); 1037 spin_lock_init(&dbf->san_lock);
1038 spin_lock_init(&dbf->scsi_lock);
1039 spin_lock_init(&dbf->rec_lock);
1059 1040
1060 /* debug feature area which records recovery activity */ 1041 /* debug feature area which records recovery activity */
1061 sprintf(dbf_name, "zfcp_%s_rec", dev_name(&adapter->ccw_device->dev)); 1042 sprintf(dbf_name, "zfcp_%s_rec", dev_name(&adapter->ccw_device->dev));
1062 dbf->rec_dbf = zfcp_dbf_reg(dbf_name, 3, &zfcp_rec_dbf_view, 1043 dbf->rec = zfcp_dbf_reg(dbf_name, 3, &zfcp_dbf_rec_view,
1063 sizeof(struct zfcp_rec_dbf_record)); 1044 sizeof(struct zfcp_dbf_rec_record));
1064 if (!dbf->rec_dbf) 1045 if (!dbf->rec)
1065 goto fail_rec; 1046 goto err_out;
1066 1047
1067 /* debug feature area which records HBA (FSF and QDIO) conditions */ 1048 /* debug feature area which records HBA (FSF and QDIO) conditions */
1068 sprintf(dbf_name, "zfcp_%s_hba", dev_name(&adapter->ccw_device->dev)); 1049 sprintf(dbf_name, "zfcp_%s_hba", dev_name(&adapter->ccw_device->dev));
1069 dbf->hba_dbf = zfcp_dbf_reg(dbf_name, 3, &zfcp_hba_dbf_view, 1050 dbf->hba = zfcp_dbf_reg(dbf_name, 3, &zfcp_dbf_hba_view,
1070 sizeof(struct zfcp_hba_dbf_record)); 1051 sizeof(struct zfcp_dbf_hba_record));
1071 if (!dbf->hba_dbf) 1052 if (!dbf->hba)
1072 goto fail_hba; 1053 goto err_out;
1073 1054
1074 /* debug feature area which records SAN command failures and recovery */ 1055 /* debug feature area which records SAN command failures and recovery */
1075 sprintf(dbf_name, "zfcp_%s_san", dev_name(&adapter->ccw_device->dev)); 1056 sprintf(dbf_name, "zfcp_%s_san", dev_name(&adapter->ccw_device->dev));
1076 dbf->san_dbf = zfcp_dbf_reg(dbf_name, 6, &zfcp_san_dbf_view, 1057 dbf->san = zfcp_dbf_reg(dbf_name, 6, &zfcp_dbf_san_view,
1077 sizeof(struct zfcp_san_dbf_record)); 1058 sizeof(struct zfcp_dbf_san_record));
1078 if (!dbf->san_dbf) 1059 if (!dbf->san)
1079 goto fail_san; 1060 goto err_out;
1080 1061
1081 /* debug feature area which records SCSI command failures and recovery */ 1062 /* debug feature area which records SCSI command failures and recovery */
1082 sprintf(dbf_name, "zfcp_%s_scsi", dev_name(&adapter->ccw_device->dev)); 1063 sprintf(dbf_name, "zfcp_%s_scsi", dev_name(&adapter->ccw_device->dev));
1083 dbf->scsi_dbf = zfcp_dbf_reg(dbf_name, 3, &zfcp_scsi_dbf_view, 1064 dbf->scsi = zfcp_dbf_reg(dbf_name, 3, &zfcp_dbf_scsi_view,
1084 sizeof(struct zfcp_scsi_dbf_record)); 1065 sizeof(struct zfcp_dbf_scsi_record));
1085 if (!dbf->scsi_dbf) 1066 if (!dbf->scsi)
1086 goto fail_scsi; 1067 goto err_out;
1087 1068
1088 adapter->dbf = dbf; 1069 adapter->dbf = dbf;
1089 return 0; 1070 return 0;
1090 1071
1091fail_scsi: 1072err_out:
1092 debug_unregister(dbf->san_dbf); 1073 zfcp_dbf_adapter_unregister(dbf);
1093fail_san:
1094 debug_unregister(dbf->hba_dbf);
1095fail_hba:
1096 debug_unregister(dbf->rec_dbf);
1097fail_rec:
1098 kfree(dbf);
1099 return -ENOMEM; 1074 return -ENOMEM;
1100} 1075}
1101 1076
1102/** 1077/**
1103 * zfcp_adapter_debug_unregister - unregisters debug feature for an adapter 1078 * zfcp_adapter_debug_unregister - unregisters debug feature for an adapter
1104 * @adapter: pointer to adapter for which debug features should be unregistered 1079 * @dbf: pointer to dbf for which debug features should be unregistered
1105 */ 1080 */
1106void zfcp_adapter_debug_unregister(struct zfcp_adapter *adapter) 1081void zfcp_dbf_adapter_unregister(struct zfcp_dbf *dbf)
1107{ 1082{
1108 debug_unregister(adapter->dbf->scsi_dbf); 1083 debug_unregister(dbf->scsi);
1109 debug_unregister(adapter->dbf->san_dbf); 1084 debug_unregister(dbf->san);
1110 debug_unregister(adapter->dbf->hba_dbf); 1085 debug_unregister(dbf->hba);
1111 debug_unregister(adapter->dbf->rec_dbf); 1086 debug_unregister(dbf->rec);
1112 kfree(adapter->dbf); 1087 dbf->adapter->dbf = NULL;
1113 adapter->dbf = NULL; 1088 kfree(dbf);
1114} 1089}
1090