aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Smart <James.Smart@Emulex.Com>2008-01-11 01:53:23 -0500
committerJames Bottomley <James.Bottomley@HansenPartnership.com>2008-01-23 12:29:23 -0500
commitc95d6c6c2b0a303a113fd468efce7430d5b20eac (patch)
treecc4ebba08495c50433a62430002432b3061789de
parent9c2face68782d5b7a322df6aade0512b47d29f10 (diff)
[SCSI] lpfc 8.2.4 : Enhance debugfs use
Enhance debugfs to dump HBA SLIM as well as Host SLIM Signed-off-by: James Smart <James.Smart@emulex.com> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
-rw-r--r--drivers/scsi/lpfc/lpfc.h3
-rw-r--r--drivers/scsi/lpfc/lpfc_debugfs.c144
2 files changed, 122 insertions, 25 deletions
diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
index 80719bb3511e..f26b9538affe 100644
--- a/drivers/scsi/lpfc/lpfc.h
+++ b/drivers/scsi/lpfc/lpfc.h
@@ -578,7 +578,8 @@ struct lpfc_hba {
578 struct dentry *hba_debugfs_root; 578 struct dentry *hba_debugfs_root;
579 atomic_t debugfs_vport_count; 579 atomic_t debugfs_vport_count;
580 struct dentry *debug_hbqinfo; 580 struct dentry *debug_hbqinfo;
581 struct dentry *debug_dumpslim; 581 struct dentry *debug_dumpHostSlim;
582 struct dentry *debug_dumpHBASlim;
582 struct dentry *debug_slow_ring_trc; 583 struct dentry *debug_slow_ring_trc;
583 struct lpfc_debugfs_trc *slow_ring_trc; 584 struct lpfc_debugfs_trc *slow_ring_trc;
584 atomic_t slow_ring_trc_cnt; 585 atomic_t slow_ring_trc_cnt;
diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
index da607c775cfc..783d1eea13ef 100644
--- a/drivers/scsi/lpfc/lpfc_debugfs.c
+++ b/drivers/scsi/lpfc/lpfc_debugfs.c
@@ -43,6 +43,7 @@
43#include "lpfc_crtn.h" 43#include "lpfc_crtn.h"
44#include "lpfc_vport.h" 44#include "lpfc_vport.h"
45#include "lpfc_version.h" 45#include "lpfc_version.h"
46#include "lpfc_compat.h"
46#include "lpfc_debugfs.h" 47#include "lpfc_debugfs.h"
47 48
48#ifdef CONFIG_LPFC_DEBUG_FS 49#ifdef CONFIG_LPFC_DEBUG_FS
@@ -75,18 +76,18 @@ module_param(lpfc_debugfs_enable, int, 0);
75MODULE_PARM_DESC(lpfc_debugfs_enable, "Enable debugfs services"); 76MODULE_PARM_DESC(lpfc_debugfs_enable, "Enable debugfs services");
76 77
77/* This MUST be a power of 2 */ 78/* This MUST be a power of 2 */
78static int lpfc_debugfs_max_disc_trc = 0; 79static int lpfc_debugfs_max_disc_trc;
79module_param(lpfc_debugfs_max_disc_trc, int, 0); 80module_param(lpfc_debugfs_max_disc_trc, int, 0);
80MODULE_PARM_DESC(lpfc_debugfs_max_disc_trc, 81MODULE_PARM_DESC(lpfc_debugfs_max_disc_trc,
81 "Set debugfs discovery trace depth"); 82 "Set debugfs discovery trace depth");
82 83
83/* This MUST be a power of 2 */ 84/* This MUST be a power of 2 */
84static int lpfc_debugfs_max_slow_ring_trc = 0; 85static int lpfc_debugfs_max_slow_ring_trc;
85module_param(lpfc_debugfs_max_slow_ring_trc, int, 0); 86module_param(lpfc_debugfs_max_slow_ring_trc, int, 0);
86MODULE_PARM_DESC(lpfc_debugfs_max_slow_ring_trc, 87MODULE_PARM_DESC(lpfc_debugfs_max_slow_ring_trc,
87 "Set debugfs slow ring trace depth"); 88 "Set debugfs slow ring trace depth");
88 89
89static int lpfc_debugfs_mask_disc_trc = 0; 90int lpfc_debugfs_mask_disc_trc;
90module_param(lpfc_debugfs_mask_disc_trc, int, 0); 91module_param(lpfc_debugfs_mask_disc_trc, int, 0);
91MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc, 92MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc,
92 "Set debugfs discovery trace mask"); 93 "Set debugfs discovery trace mask");
@@ -100,8 +101,11 @@ MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc,
100#define LPFC_NODELIST_SIZE 8192 101#define LPFC_NODELIST_SIZE 8192
101#define LPFC_NODELIST_ENTRY_SIZE 120 102#define LPFC_NODELIST_ENTRY_SIZE 120
102 103
103/* dumpslim output buffer size */ 104/* dumpHBASlim output buffer size */
104#define LPFC_DUMPSLIM_SIZE 4096 105#define LPFC_DUMPHBASLIM_SIZE 4096
106
107/* dumpHostSlim output buffer size */
108#define LPFC_DUMPHOSTSLIM_SIZE 4096
105 109
106/* hbqinfo output buffer size */ 110/* hbqinfo output buffer size */
107#define LPFC_HBQINFO_SIZE 8192 111#define LPFC_HBQINFO_SIZE 8192
@@ -298,18 +302,58 @@ skipit:
298 return len; 302 return len;
299} 303}
300 304
305static int lpfc_debugfs_last_hba_slim_off;
306
307static int
308lpfc_debugfs_dumpHBASlim_data(struct lpfc_hba *phba, char *buf, int size)
309{
310 int len = 0;
311 int i, off;
312 uint32_t *ptr;
313 char buffer[1024];
314
315 off = 0;
316 spin_lock_irq(&phba->hbalock);
317
318 len += snprintf(buf+len, size-len, "HBA SLIM\n");
319 lpfc_memcpy_from_slim(buffer,
320 ((uint8_t *)phba->MBslimaddr) + lpfc_debugfs_last_hba_slim_off,
321 1024);
322
323 ptr = (uint32_t *)&buffer[0];
324 off = lpfc_debugfs_last_hba_slim_off;
325
326 /* Set it up for the next time */
327 lpfc_debugfs_last_hba_slim_off += 1024;
328 if (lpfc_debugfs_last_hba_slim_off >= 4096)
329 lpfc_debugfs_last_hba_slim_off = 0;
330
331 i = 1024;
332 while (i > 0) {
333 len += snprintf(buf+len, size-len,
334 "%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n",
335 off, *ptr, *(ptr+1), *(ptr+2), *(ptr+3), *(ptr+4),
336 *(ptr+5), *(ptr+6), *(ptr+7));
337 ptr += 8;
338 i -= (8 * sizeof(uint32_t));
339 off += (8 * sizeof(uint32_t));
340 }
341
342 spin_unlock_irq(&phba->hbalock);
343 return len;
344}
345
301static int 346static int
302lpfc_debugfs_dumpslim_data(struct lpfc_hba *phba, char *buf, int size) 347lpfc_debugfs_dumpHostSlim_data(struct lpfc_hba *phba, char *buf, int size)
303{ 348{
304 int len = 0; 349 int len = 0;
305 int cnt, i, off; 350 int i, off;
306 uint32_t word0, word1, word2, word3; 351 uint32_t word0, word1, word2, word3;
307 uint32_t *ptr; 352 uint32_t *ptr;
308 struct lpfc_pgp *pgpp; 353 struct lpfc_pgp *pgpp;
309 struct lpfc_sli *psli = &phba->sli; 354 struct lpfc_sli *psli = &phba->sli;
310 struct lpfc_sli_ring *pring; 355 struct lpfc_sli_ring *pring;
311 356
312 cnt = LPFC_DUMPSLIM_SIZE;
313 off = 0; 357 off = 0;
314 spin_lock_irq(&phba->hbalock); 358 spin_lock_irq(&phba->hbalock);
315 359
@@ -621,7 +665,7 @@ out:
621} 665}
622 666
623static int 667static int
624lpfc_debugfs_dumpslim_open(struct inode *inode, struct file *file) 668lpfc_debugfs_dumpHBASlim_open(struct inode *inode, struct file *file)
625{ 669{
626 struct lpfc_hba *phba = inode->i_private; 670 struct lpfc_hba *phba = inode->i_private;
627 struct lpfc_debug *debug; 671 struct lpfc_debug *debug;
@@ -632,14 +676,41 @@ lpfc_debugfs_dumpslim_open(struct inode *inode, struct file *file)
632 goto out; 676 goto out;
633 677
634 /* Round to page boundry */ 678 /* Round to page boundry */
635 debug->buffer = kmalloc(LPFC_DUMPSLIM_SIZE, GFP_KERNEL); 679 debug->buffer = kmalloc(LPFC_DUMPHBASLIM_SIZE, GFP_KERNEL);
636 if (!debug->buffer) { 680 if (!debug->buffer) {
637 kfree(debug); 681 kfree(debug);
638 goto out; 682 goto out;
639 } 683 }
640 684
641 debug->len = lpfc_debugfs_dumpslim_data(phba, debug->buffer, 685 debug->len = lpfc_debugfs_dumpHBASlim_data(phba, debug->buffer,
642 LPFC_DUMPSLIM_SIZE); 686 LPFC_DUMPHBASLIM_SIZE);
687 file->private_data = debug;
688
689 rc = 0;
690out:
691 return rc;
692}
693
694static int
695lpfc_debugfs_dumpHostSlim_open(struct inode *inode, struct file *file)
696{
697 struct lpfc_hba *phba = inode->i_private;
698 struct lpfc_debug *debug;
699 int rc = -ENOMEM;
700
701 debug = kmalloc(sizeof(*debug), GFP_KERNEL);
702 if (!debug)
703 goto out;
704
705 /* Round to page boundry */
706 debug->buffer = kmalloc(LPFC_DUMPHOSTSLIM_SIZE, GFP_KERNEL);
707 if (!debug->buffer) {
708 kfree(debug);
709 goto out;
710 }
711
712 debug->len = lpfc_debugfs_dumpHostSlim_data(phba, debug->buffer,
713 LPFC_DUMPHOSTSLIM_SIZE);
643 file->private_data = debug; 714 file->private_data = debug;
644 715
645 rc = 0; 716 rc = 0;
@@ -742,10 +813,19 @@ static struct file_operations lpfc_debugfs_op_hbqinfo = {
742 .release = lpfc_debugfs_release, 813 .release = lpfc_debugfs_release,
743}; 814};
744 815
745#undef lpfc_debugfs_op_dumpslim 816#undef lpfc_debugfs_op_dumpHBASlim
746static struct file_operations lpfc_debugfs_op_dumpslim = { 817static struct file_operations lpfc_debugfs_op_dumpHBASlim = {
818 .owner = THIS_MODULE,
819 .open = lpfc_debugfs_dumpHBASlim_open,
820 .llseek = lpfc_debugfs_lseek,
821 .read = lpfc_debugfs_read,
822 .release = lpfc_debugfs_release,
823};
824
825#undef lpfc_debugfs_op_dumpHostSlim
826static struct file_operations lpfc_debugfs_op_dumpHostSlim = {
747 .owner = THIS_MODULE, 827 .owner = THIS_MODULE,
748 .open = lpfc_debugfs_dumpslim_open, 828 .open = lpfc_debugfs_dumpHostSlim_open,
749 .llseek = lpfc_debugfs_lseek, 829 .llseek = lpfc_debugfs_lseek,
750 .read = lpfc_debugfs_read, 830 .read = lpfc_debugfs_read,
751 .release = lpfc_debugfs_release, 831 .release = lpfc_debugfs_release,
@@ -813,15 +893,27 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
813 goto debug_failed; 893 goto debug_failed;
814 } 894 }
815 895
816 /* Setup dumpslim */ 896 /* Setup dumpHBASlim */
817 snprintf(name, sizeof(name), "dumpslim"); 897 snprintf(name, sizeof(name), "dumpHBASlim");
818 phba->debug_dumpslim = 898 phba->debug_dumpHBASlim =
819 debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR, 899 debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
820 phba->hba_debugfs_root, 900 phba->hba_debugfs_root,
821 phba, &lpfc_debugfs_op_dumpslim); 901 phba, &lpfc_debugfs_op_dumpHBASlim);
822 if (!phba->debug_dumpslim) { 902 if (!phba->debug_dumpHBASlim) {
823 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, 903 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
824 "0409 Cannot create debugfs dumpslim\n"); 904 "0409 Cannot create debugfs dumpHBASlim\n");
905 goto debug_failed;
906 }
907
908 /* Setup dumpHostSlim */
909 snprintf(name, sizeof(name), "dumpHostSlim");
910 phba->debug_dumpHostSlim =
911 debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
912 phba->hba_debugfs_root,
913 phba, &lpfc_debugfs_op_dumpHostSlim);
914 if (!phba->debug_dumpHostSlim) {
915 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
916 "0409 Cannot create debugfs dumpHostSlim\n");
825 goto debug_failed; 917 goto debug_failed;
826 } 918 }
827 919
@@ -971,9 +1063,13 @@ lpfc_debugfs_terminate(struct lpfc_vport *vport)
971 debugfs_remove(phba->debug_hbqinfo); /* hbqinfo */ 1063 debugfs_remove(phba->debug_hbqinfo); /* hbqinfo */
972 phba->debug_hbqinfo = NULL; 1064 phba->debug_hbqinfo = NULL;
973 } 1065 }
974 if (phba->debug_dumpslim) { 1066 if (phba->debug_dumpHBASlim) {
975 debugfs_remove(phba->debug_dumpslim); /* dumpslim */ 1067 debugfs_remove(phba->debug_dumpHBASlim); /* HBASlim */
976 phba->debug_dumpslim = NULL; 1068 phba->debug_dumpHBASlim = NULL;
1069 }
1070 if (phba->debug_dumpHostSlim) {
1071 debugfs_remove(phba->debug_dumpHostSlim); /* HostSlim */
1072 phba->debug_dumpHostSlim = NULL;
977 } 1073 }
978 if (phba->slow_ring_trc) { 1074 if (phba->slow_ring_trc) {
979 kfree(phba->slow_ring_trc); 1075 kfree(phba->slow_ring_trc);