Skip to content

Commit 1d9d5a9

Browse files
jsmart-ghmartinkpetersen
authored andcommitted
scsi: lpfc: refactor debugfs queue dump routines
Create common wq, cq, eq, rq dump functions Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com> Signed-off-by: James Smart <james.smart@broadcom.com> Reviewed-by: Hannes Reinecke <hare@suse.com> Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 07bcd98 commit 1d9d5a9

File tree

2 files changed

+101
-135
lines changed

2 files changed

+101
-135
lines changed

drivers/scsi/lpfc/lpfc_debugfs.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4555,31 +4555,31 @@ lpfc_debugfs_terminate(struct lpfc_vport *vport)
45554555
void
45564556
lpfc_debug_dump_all_queues(struct lpfc_hba *phba)
45574557
{
4558-
int fcp_wqidx;
4558+
int idx;
45594559

45604560
/*
45614561
* Dump Work Queues (WQs)
45624562
*/
4563-
lpfc_debug_dump_mbx_wq(phba);
4564-
lpfc_debug_dump_els_wq(phba);
4563+
lpfc_debug_dump_wq(phba, DUMP_MBX, 0);
4564+
lpfc_debug_dump_wq(phba, DUMP_ELS, 0);
45654565

4566-
for (fcp_wqidx = 0; fcp_wqidx < phba->cfg_fcp_io_channel; fcp_wqidx++)
4567-
lpfc_debug_dump_fcp_wq(phba, fcp_wqidx);
4566+
for (idx = 0; idx < phba->cfg_fcp_io_channel; idx++)
4567+
lpfc_debug_dump_wq(phba, DUMP_FCP, idx);
45684568

45694569
lpfc_debug_dump_hdr_rq(phba);
45704570
lpfc_debug_dump_dat_rq(phba);
45714571
/*
45724572
* Dump Complete Queues (CQs)
45734573
*/
4574-
lpfc_debug_dump_mbx_cq(phba);
4575-
lpfc_debug_dump_els_cq(phba);
4574+
lpfc_debug_dump_cq(phba, DUMP_MBX, 0);
4575+
lpfc_debug_dump_cq(phba, DUMP_ELS, 0);
45764576

4577-
for (fcp_wqidx = 0; fcp_wqidx < phba->cfg_fcp_io_channel; fcp_wqidx++)
4578-
lpfc_debug_dump_fcp_cq(phba, fcp_wqidx);
4577+
for (idx = 0; idx < phba->cfg_fcp_io_channel; idx++)
4578+
lpfc_debug_dump_cq(phba, DUMP_FCP, idx);
45794579

45804580
/*
45814581
* Dump Event Queues (EQs)
45824582
*/
4583-
for (fcp_wqidx = 0; fcp_wqidx < phba->cfg_fcp_io_channel; fcp_wqidx++)
4584-
lpfc_debug_dump_hba_eq(phba, fcp_wqidx);
4583+
for (idx = 0; idx < phba->cfg_fcp_io_channel; idx++)
4584+
lpfc_debug_dump_hba_eq(phba, idx);
45854585
}

drivers/scsi/lpfc/lpfc_debugfs.h

Lines changed: 90 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@
4242
/* hbqinfo output buffer size */
4343
#define LPFC_HBQINFO_SIZE 8192
4444

45+
enum {
46+
DUMP_FCP,
47+
DUMP_MBX,
48+
DUMP_ELS,
49+
};
50+
4551
/*
4652
* For SLI4 iDiag debugfs diagnostics tool
4753
*/
@@ -358,58 +364,97 @@ lpfc_debug_dump_q(struct lpfc_queue *q)
358364
}
359365

360366
/**
361-
* lpfc_debug_dump_fcp_wq - dump all entries from a fcp work queue
367+
* lpfc_debug_dump_wq - dump all entries from the fcp work queue
362368
* @phba: Pointer to HBA context object.
363-
* @fcp_wqidx: Index to a FCP work queue.
369+
* @wqidx: Index to a FCP work queue.
364370
*
365-
* This function dumps all entries from a FCP work queue specified by the
366-
* @fcp_wqidx.
371+
* This function dumps all entries from a FCP work queue specified
372+
* by the wqidx.
367373
**/
368374
static inline void
369-
lpfc_debug_dump_fcp_wq(struct lpfc_hba *phba, int fcp_wqidx)
375+
lpfc_debug_dump_wq(struct lpfc_hba *phba, int qtype, int wqidx)
370376
{
371-
/* sanity check */
372-
if (fcp_wqidx >= phba->cfg_fcp_io_channel)
377+
struct lpfc_queue *wq;
378+
char *qtypestr;
379+
380+
if (qtype == DUMP_FCP) {
381+
wq = phba->sli4_hba.fcp_wq[wqidx];
382+
qtypestr = "FCP";
383+
} else if (qtype == DUMP_MBX) {
384+
wq = phba->sli4_hba.mbx_wq;
385+
qtypestr = "MBX";
386+
} else if (qtype == DUMP_ELS) {
387+
wq = phba->sli4_hba.els_wq;
388+
qtypestr = "ELS";
389+
} else
373390
return;
374391

375-
printk(KERN_ERR "FCP WQ: WQ[Idx:%d|Qid:%d]\n",
376-
fcp_wqidx, phba->sli4_hba.fcp_wq[fcp_wqidx]->queue_id);
377-
lpfc_debug_dump_q(phba->sli4_hba.fcp_wq[fcp_wqidx]);
392+
if (qtype == DUMP_FCP)
393+
pr_err("%s WQ: WQ[Idx:%d|Qid:%d]\n",
394+
qtypestr, wqidx, wq->queue_id);
395+
else
396+
pr_err("%s WQ: WQ[Qid:%d]\n",
397+
qtypestr, wq->queue_id);
398+
399+
lpfc_debug_dump_q(wq);
378400
}
379401

380402
/**
381-
* lpfc_debug_dump_fcp_cq - dump all entries from a fcp work queue's cmpl queue
403+
* lpfc_debug_dump_cq - dump all entries from a fcp work queue's
404+
* cmpl queue
382405
* @phba: Pointer to HBA context object.
383-
* @fcp_wqidx: Index to a FCP work queue.
406+
* @wqidx: Index to a FCP work queue.
384407
*
385-
* This function dumps all entries from a FCP complete queue which is
386-
* associated to the FCP work queue specified by the @fcp_wqidx.
408+
* This function dumps all entries from a FCP completion queue
409+
* which is associated to the work queue specified by the @wqidx.
387410
**/
388411
static inline void
389-
lpfc_debug_dump_fcp_cq(struct lpfc_hba *phba, int fcp_wqidx)
412+
lpfc_debug_dump_cq(struct lpfc_hba *phba, int qtype, int wqidx)
390413
{
391-
int fcp_cqidx, fcp_cqid;
392-
393-
/* sanity check */
394-
if (fcp_wqidx >= phba->cfg_fcp_io_channel)
414+
struct lpfc_queue *wq, *cq, *eq;
415+
char *qtypestr;
416+
int eqidx;
417+
418+
/* fcp wq and cq are 1:1, thus same indexes */
419+
420+
if (qtype == DUMP_FCP) {
421+
wq = phba->sli4_hba.fcp_wq[wqidx];
422+
cq = phba->sli4_hba.fcp_cq[wqidx];
423+
qtypestr = "FCP";
424+
} else if (qtype == DUMP_MBX) {
425+
wq = phba->sli4_hba.mbx_wq;
426+
cq = phba->sli4_hba.mbx_cq;
427+
qtypestr = "MBX";
428+
} else if (qtype == DUMP_ELS) {
429+
wq = phba->sli4_hba.els_wq;
430+
cq = phba->sli4_hba.els_cq;
431+
qtypestr = "ELS";
432+
} else
395433
return;
396434

397-
fcp_cqid = phba->sli4_hba.fcp_wq[fcp_wqidx]->assoc_qid;
398-
for (fcp_cqidx = 0; fcp_cqidx < phba->cfg_fcp_io_channel; fcp_cqidx++)
399-
if (phba->sli4_hba.fcp_cq[fcp_cqidx]->queue_id == fcp_cqid)
435+
for (eqidx = 0; eqidx < phba->cfg_fcp_io_channel; eqidx++) {
436+
eq = phba->sli4_hba.hba_eq[eqidx];
437+
if (cq->assoc_qid == eq->queue_id)
400438
break;
401-
if (phba->intr_type == MSIX) {
402-
if (fcp_cqidx >= phba->cfg_fcp_io_channel)
403-
return;
404-
} else {
405-
if (fcp_cqidx > 0)
406-
return;
439+
}
440+
if (eqidx == phba->cfg_fcp_io_channel) {
441+
pr_err("Couldn't find EQ for CQ. Using EQ[0]\n");
442+
eqidx = 0;
443+
eq = phba->sli4_hba.hba_eq[0];
407444
}
408445

409-
printk(KERN_ERR "FCP CQ: WQ[Idx:%d|Qid%d]->CQ[Idx%d|Qid%d]:\n",
410-
fcp_wqidx, phba->sli4_hba.fcp_wq[fcp_wqidx]->queue_id,
411-
fcp_cqidx, fcp_cqid);
412-
lpfc_debug_dump_q(phba->sli4_hba.fcp_cq[fcp_cqidx]);
446+
if (qtype == DUMP_FCP)
447+
pr_err("%s CQ: WQ[Idx:%d|Qid%d]->CQ[Idx%d|Qid%d]"
448+
"->EQ[Idx:%d|Qid:%d]:\n",
449+
qtypestr, wqidx, wq->queue_id, wqidx, cq->queue_id,
450+
eqidx, eq->queue_id);
451+
else
452+
pr_err("%s CQ: WQ[Qid:%d]->CQ[Qid:%d]"
453+
"->EQ[Idx:%d|Qid:%d]:\n",
454+
qtypestr, wq->queue_id, cq->queue_id,
455+
eqidx, eq->queue_id);
456+
457+
lpfc_debug_dump_q(cq);
413458
}
414459

415460
/**
@@ -421,64 +466,15 @@ lpfc_debug_dump_fcp_cq(struct lpfc_hba *phba, int fcp_wqidx)
421466
* associated to the FCP work queue specified by the @fcp_wqidx.
422467
**/
423468
static inline void
424-
lpfc_debug_dump_hba_eq(struct lpfc_hba *phba, int fcp_wqidx)
469+
lpfc_debug_dump_hba_eq(struct lpfc_hba *phba, int qidx)
425470
{
426-
struct lpfc_queue *qdesc;
427-
int fcp_eqidx, fcp_eqid;
428-
int fcp_cqidx, fcp_cqid;
429-
430-
/* sanity check */
431-
if (fcp_wqidx >= phba->cfg_fcp_io_channel)
432-
return;
433-
fcp_cqid = phba->sli4_hba.fcp_wq[fcp_wqidx]->assoc_qid;
434-
for (fcp_cqidx = 0; fcp_cqidx < phba->cfg_fcp_io_channel; fcp_cqidx++)
435-
if (phba->sli4_hba.fcp_cq[fcp_cqidx]->queue_id == fcp_cqid)
436-
break;
437-
if (phba->intr_type == MSIX) {
438-
if (fcp_cqidx >= phba->cfg_fcp_io_channel)
439-
return;
440-
} else {
441-
if (fcp_cqidx > 0)
442-
return;
443-
}
471+
struct lpfc_queue *qp;
444472

445-
fcp_eqidx = fcp_cqidx;
446-
fcp_eqid = phba->sli4_hba.hba_eq[fcp_eqidx]->queue_id;
447-
qdesc = phba->sli4_hba.hba_eq[fcp_eqidx];
473+
qp = phba->sli4_hba.hba_eq[qidx];
448474

449-
printk(KERN_ERR "FCP EQ: WQ[Idx:%d|Qid:%d]->CQ[Idx:%d|Qid:%d]->"
450-
"EQ[Idx:%d|Qid:%d]\n",
451-
fcp_wqidx, phba->sli4_hba.fcp_wq[fcp_wqidx]->queue_id,
452-
fcp_cqidx, fcp_cqid, fcp_eqidx, fcp_eqid);
453-
lpfc_debug_dump_q(qdesc);
454-
}
475+
pr_err("EQ[Idx:%d|Qid:%d]\n", qidx, qp->queue_id);
455476

456-
/**
457-
* lpfc_debug_dump_els_wq - dump all entries from the els work queue
458-
* @phba: Pointer to HBA context object.
459-
*
460-
* This function dumps all entries from the ELS work queue.
461-
**/
462-
static inline void
463-
lpfc_debug_dump_els_wq(struct lpfc_hba *phba)
464-
{
465-
printk(KERN_ERR "ELS WQ: WQ[Qid:%d]:\n",
466-
phba->sli4_hba.els_wq->queue_id);
467-
lpfc_debug_dump_q(phba->sli4_hba.els_wq);
468-
}
469-
470-
/**
471-
* lpfc_debug_dump_mbx_wq - dump all entries from the mbox work queue
472-
* @phba: Pointer to HBA context object.
473-
*
474-
* This function dumps all entries from the MBOX work queue.
475-
**/
476-
static inline void
477-
lpfc_debug_dump_mbx_wq(struct lpfc_hba *phba)
478-
{
479-
printk(KERN_ERR "MBX WQ: WQ[Qid:%d]\n",
480-
phba->sli4_hba.mbx_wq->queue_id);
481-
lpfc_debug_dump_q(phba->sli4_hba.mbx_wq);
477+
lpfc_debug_dump_q(qp);
482478
}
483479

484480
/**
@@ -509,36 +505,6 @@ lpfc_debug_dump_hdr_rq(struct lpfc_hba *phba)
509505
lpfc_debug_dump_q(phba->sli4_hba.hdr_rq);
510506
}
511507

512-
/**
513-
* lpfc_debug_dump_els_cq - dump all entries from the els complete queue
514-
* @phba: Pointer to HBA context object.
515-
*
516-
* This function dumps all entries from the els complete queue.
517-
**/
518-
static inline void
519-
lpfc_debug_dump_els_cq(struct lpfc_hba *phba)
520-
{
521-
printk(KERN_ERR "ELS CQ: WQ[Qid:%d]->CQ[Qid:%d]\n",
522-
phba->sli4_hba.els_wq->queue_id,
523-
phba->sli4_hba.els_cq->queue_id);
524-
lpfc_debug_dump_q(phba->sli4_hba.els_cq);
525-
}
526-
527-
/**
528-
* lpfc_debug_dump_mbx_cq - dump all entries from the mbox complete queue
529-
* @phba: Pointer to HBA context object.
530-
*
531-
* This function dumps all entries from the mbox complete queue.
532-
**/
533-
static inline void
534-
lpfc_debug_dump_mbx_cq(struct lpfc_hba *phba)
535-
{
536-
printk(KERN_ERR "MBX CQ: WQ[Qid:%d]->CQ[Qid:%d]\n",
537-
phba->sli4_hba.mbx_wq->queue_id,
538-
phba->sli4_hba.mbx_cq->queue_id);
539-
lpfc_debug_dump_q(phba->sli4_hba.mbx_cq);
540-
}
541-
542508
/**
543509
* lpfc_debug_dump_wq_by_id - dump all entries from a work queue by queue id
544510
* @phba: Pointer to HBA context object.
@@ -556,14 +522,15 @@ lpfc_debug_dump_wq_by_id(struct lpfc_hba *phba, int qid)
556522
if (phba->sli4_hba.fcp_wq[wq_idx]->queue_id == qid)
557523
break;
558524
if (wq_idx < phba->cfg_fcp_io_channel) {
559-
printk(KERN_ERR "FCP WQ[Idx:%d|Qid:%d]\n", wq_idx, qid);
525+
pr_err("FCP WQ[Idx:%d|Qid:%d]\n", wq_idx, qid);
560526
lpfc_debug_dump_q(phba->sli4_hba.fcp_wq[wq_idx]);
561527
return;
562528
}
563529

564530
if (phba->sli4_hba.els_wq->queue_id == qid) {
565-
printk(KERN_ERR "ELS WQ[Qid:%d]\n", qid);
531+
pr_err("ELS WQ[Qid:%d]\n", qid);
566532
lpfc_debug_dump_q(phba->sli4_hba.els_wq);
533+
return;
567534
}
568535
}
569536

@@ -617,27 +584,26 @@ lpfc_debug_dump_rq_by_id(struct lpfc_hba *phba, int qid)
617584
static inline void
618585
lpfc_debug_dump_cq_by_id(struct lpfc_hba *phba, int qid)
619586
{
620-
int cq_idx = 0;
587+
int cq_idx;
621588

622-
do {
589+
for (cq_idx = 0; cq_idx < phba->cfg_fcp_io_channel; cq_idx++)
623590
if (phba->sli4_hba.fcp_cq[cq_idx]->queue_id == qid)
624591
break;
625-
} while (++cq_idx < phba->cfg_fcp_io_channel);
626592

627593
if (cq_idx < phba->cfg_fcp_io_channel) {
628-
printk(KERN_ERR "FCP CQ[Idx:%d|Qid:%d]\n", cq_idx, qid);
594+
pr_err("FCP CQ[Idx:%d|Qid:%d]\n", cq_idx, qid);
629595
lpfc_debug_dump_q(phba->sli4_hba.fcp_cq[cq_idx]);
630596
return;
631597
}
632598

633599
if (phba->sli4_hba.els_cq->queue_id == qid) {
634-
printk(KERN_ERR "ELS CQ[Qid:%d]\n", qid);
600+
pr_err("ELS CQ[Qid:%d]\n", qid);
635601
lpfc_debug_dump_q(phba->sli4_hba.els_cq);
636602
return;
637603
}
638604

639605
if (phba->sli4_hba.mbx_cq->queue_id == qid) {
640-
printk(KERN_ERR "MBX CQ[Qid:%d]\n", qid);
606+
pr_err("MBX CQ[Qid:%d]\n", qid);
641607
lpfc_debug_dump_q(phba->sli4_hba.mbx_cq);
642608
}
643609
}

0 commit comments

Comments
 (0)