aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/lpfc/lpfc_debugfs.c
diff options
context:
space:
mode:
authorJames Smart <James.Smart@Emulex.Com>2007-08-02 11:09:43 -0400
committerJames Bottomley <jejb@mulgrave.localdomain>2007-08-01 13:17:30 -0400
commita58cbd5212fff2d4bba0bf58e778f02069597294 (patch)
treea2f773026934e3c2dad7642089b96ea48ea00db3 /drivers/scsi/lpfc/lpfc_debugfs.c
parentc000c43cf12090972fad0fbb621d78c2100d0373 (diff)
[SCSI] lpfc 8.2.2 : Error messages and debugfs updates
Error messages and debugfs updates: - Fix up GID_FT error messages - Enhance debugfs with slow_ring_trace, dumpslim and nodelist information - Add log type (and messages) for vport state changes - Enhance log messages when retries ELS fail Signed-off-by: James Smart <James.Smart@emulex.com> Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers/scsi/lpfc/lpfc_debugfs.c')
-rw-r--r--drivers/scsi/lpfc/lpfc_debugfs.c443
1 files changed, 398 insertions, 45 deletions
diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
index 673cfe11cc2b..2310a2d1d8ce 100644
--- a/drivers/scsi/lpfc/lpfc_debugfs.c
+++ b/drivers/scsi/lpfc/lpfc_debugfs.c
@@ -75,11 +75,18 @@ static int lpfc_debugfs_enable = 0;
75module_param(lpfc_debugfs_enable, int, 0); 75module_param(lpfc_debugfs_enable, int, 0);
76MODULE_PARM_DESC(lpfc_debugfs_enable, "Enable debugfs services"); 76MODULE_PARM_DESC(lpfc_debugfs_enable, "Enable debugfs services");
77 77
78static int lpfc_debugfs_max_disc_trc = 0; /* This MUST be a power of 2 */ 78/* This MUST be a power of 2 */
79static int lpfc_debugfs_max_disc_trc = 0;
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
84/* This MUST be a power of 2 */
85static int lpfc_debugfs_max_slow_ring_trc = 0;
86module_param(lpfc_debugfs_max_slow_ring_trc, int, 0);
87MODULE_PARM_DESC(lpfc_debugfs_max_slow_ring_trc,
88 "Set debugfs slow ring trace depth");
89
83static int lpfc_debugfs_mask_disc_trc = 0; 90static int lpfc_debugfs_mask_disc_trc = 0;
84module_param(lpfc_debugfs_mask_disc_trc, int, 0); 91module_param(lpfc_debugfs_mask_disc_trc, int, 0);
85MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc, 92MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc,
@@ -87,19 +94,22 @@ MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc,
87 94
88#include <linux/debugfs.h> 95#include <linux/debugfs.h>
89 96
90/* size of discovery_trace output line */ 97/* size of output line, for discovery_trace and slow_ring_trace */
91#define LPFC_DISC_TRC_ENTRY_SIZE 80 98#define LPFC_DEBUG_TRC_ENTRY_SIZE 100
92 99
93/* nodelist output buffer size */ 100/* nodelist output buffer size */
94#define LPFC_NODELIST_SIZE 8192 101#define LPFC_NODELIST_SIZE 8192
95#define LPFC_NODELIST_ENTRY_SIZE 120 102#define LPFC_NODELIST_ENTRY_SIZE 120
96 103
104/* dump_slim output buffer size */
105#define LPFC_DUMPSLIM_SIZE 4096
106
97struct lpfc_debug { 107struct lpfc_debug {
98 char *buffer; 108 char *buffer;
99 int len; 109 int len;
100}; 110};
101 111
102atomic_t lpfc_debugfs_disc_trc_cnt = ATOMIC_INIT(0); 112atomic_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
103unsigned long lpfc_debugfs_start_time = 0L; 113unsigned long lpfc_debugfs_start_time = 0L;
104 114
105static int 115static int
@@ -107,8 +117,8 @@ lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size)
107{ 117{
108 int i, index, len, enable; 118 int i, index, len, enable;
109 uint32_t ms; 119 uint32_t ms;
110 struct lpfc_disc_trc *dtp; 120 struct lpfc_debugfs_trc *dtp;
111 char buffer[80]; 121 char buffer[LPFC_DEBUG_TRC_ENTRY_SIZE];
112 122
113 123
114 enable = lpfc_debugfs_enable; 124 enable = lpfc_debugfs_enable;
@@ -122,7 +132,8 @@ lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size)
122 if (!dtp->fmt) 132 if (!dtp->fmt)
123 continue; 133 continue;
124 ms = jiffies_to_msecs(dtp->jif - lpfc_debugfs_start_time); 134 ms = jiffies_to_msecs(dtp->jif - lpfc_debugfs_start_time);
125 snprintf(buffer, 80, "%010d:%010d ms:%s\n", 135 snprintf(buffer,
136 LPFC_DEBUG_TRC_ENTRY_SIZE, "%010d:%010d ms:%s\n",
126 dtp->seq_cnt, ms, dtp->fmt); 137 dtp->seq_cnt, ms, dtp->fmt);
127 len += snprintf(buf+len, size-len, buffer, 138 len += snprintf(buf+len, size-len, buffer,
128 dtp->data1, dtp->data2, dtp->data3); 139 dtp->data1, dtp->data2, dtp->data3);
@@ -132,7 +143,50 @@ lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size)
132 if (!dtp->fmt) 143 if (!dtp->fmt)
133 continue; 144 continue;
134 ms = jiffies_to_msecs(dtp->jif - lpfc_debugfs_start_time); 145 ms = jiffies_to_msecs(dtp->jif - lpfc_debugfs_start_time);
135 snprintf(buffer, 80, "%010d:%010d ms:%s\n", 146 snprintf(buffer,
147 LPFC_DEBUG_TRC_ENTRY_SIZE, "%010d:%010d ms:%s\n",
148 dtp->seq_cnt, ms, dtp->fmt);
149 len += snprintf(buf+len, size-len, buffer,
150 dtp->data1, dtp->data2, dtp->data3);
151 }
152
153 lpfc_debugfs_enable = enable;
154 return len;
155}
156
157static int
158lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba *phba, char *buf, int size)
159{
160 int i, index, len, enable;
161 uint32_t ms;
162 struct lpfc_debugfs_trc *dtp;
163 char buffer[LPFC_DEBUG_TRC_ENTRY_SIZE];
164
165
166 enable = lpfc_debugfs_enable;
167 lpfc_debugfs_enable = 0;
168
169 len = 0;
170 index = (atomic_read(&phba->slow_ring_trc_cnt) + 1) &
171 (lpfc_debugfs_max_slow_ring_trc - 1);
172 for (i = index; i < lpfc_debugfs_max_slow_ring_trc; i++) {
173 dtp = phba->slow_ring_trc + i;
174 if (!dtp->fmt)
175 continue;
176 ms = jiffies_to_msecs(dtp->jif - lpfc_debugfs_start_time);
177 snprintf(buffer,
178 LPFC_DEBUG_TRC_ENTRY_SIZE, "%010d:%010d ms:%s\n",
179 dtp->seq_cnt, ms, dtp->fmt);
180 len += snprintf(buf+len, size-len, buffer,
181 dtp->data1, dtp->data2, dtp->data3);
182 }
183 for (i = 0; i < index; i++) {
184 dtp = phba->slow_ring_trc + i;
185 if (!dtp->fmt)
186 continue;
187 ms = jiffies_to_msecs(dtp->jif - lpfc_debugfs_start_time);
188 snprintf(buffer,
189 LPFC_DEBUG_TRC_ENTRY_SIZE, "%010d:%010d ms:%s\n",
136 dtp->seq_cnt, ms, dtp->fmt); 190 dtp->seq_cnt, ms, dtp->fmt);
137 len += snprintf(buf+len, size-len, buffer, 191 len += snprintf(buf+len, size-len, buffer,
138 dtp->data1, dtp->data2, dtp->data3); 192 dtp->data1, dtp->data2, dtp->data3);
@@ -143,6 +197,95 @@ lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size)
143} 197}
144 198
145static int 199static int
200lpfc_debugfs_dumpslim_data(struct lpfc_hba *phba, char *buf, int size)
201{
202 int len = 0;
203 int cnt, i, off;
204 uint32_t word0, word1, word2, word3;
205 uint32_t *ptr;
206 struct lpfc_pgp *pgpp;
207 struct lpfc_sli *psli = &phba->sli;
208 struct lpfc_sli_ring *pring;
209
210 cnt = LPFC_DUMPSLIM_SIZE;
211 off = 0;
212 spin_lock_irq(&phba->hbalock);
213
214 len += snprintf(buf+len, size-len, "SLIM Mailbox\n");
215 ptr = (uint32_t *)phba->slim2p;
216 i = sizeof(MAILBOX_t);
217 while (i > 0) {
218 len += snprintf(buf+len, size-len,
219 "%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n",
220 off, *ptr, *(ptr+1), *(ptr+2), *(ptr+3), *(ptr+4),
221 *(ptr+5), *(ptr+6), *(ptr+7));
222 ptr += 8;
223 i -= (8 * sizeof(uint32_t));
224 off += (8 * sizeof(uint32_t));
225 }
226
227 len += snprintf(buf+len, size-len, "SLIM PCB\n");
228 ptr = (uint32_t *)&phba->slim2p->pcb;
229 i = sizeof(PCB_t);
230 while (i > 0) {
231 len += snprintf(buf+len, size-len,
232 "%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n",
233 off, *ptr, *(ptr+1), *(ptr+2), *(ptr+3), *(ptr+4),
234 *(ptr+5), *(ptr+6), *(ptr+7));
235 ptr += 8;
236 i -= (8 * sizeof(uint32_t));
237 off += (8 * sizeof(uint32_t));
238 }
239
240 pgpp = (struct lpfc_pgp *)&phba->slim2p->mbx.us.s3_pgp.port;
241 pring = &psli->ring[0];
242 len += snprintf(buf+len, size-len,
243 "Ring 0: CMD GetInx:%d (Max:%d Next:%d Local:%d flg:x%x) "
244 "RSP PutInx:%d Max:%d\n",
245 pgpp->cmdGetInx, pring->numCiocb,
246 pring->next_cmdidx, pring->local_getidx, pring->flag,
247 pgpp->rspPutInx, pring->numRiocb);
248 pgpp++;
249
250 pring = &psli->ring[1];
251 len += snprintf(buf+len, size-len,
252 "Ring 1: CMD GetInx:%d (Max:%d Next:%d Local:%d flg:x%x) "
253 "RSP PutInx:%d Max:%d\n",
254 pgpp->cmdGetInx, pring->numCiocb,
255 pring->next_cmdidx, pring->local_getidx, pring->flag,
256 pgpp->rspPutInx, pring->numRiocb);
257 pgpp++;
258
259 pring = &psli->ring[2];
260 len += snprintf(buf+len, size-len,
261 "Ring 2: CMD GetInx:%d (Max:%d Next:%d Local:%d flg:x%x) "
262 "RSP PutInx:%d Max:%d\n",
263 pgpp->cmdGetInx, pring->numCiocb,
264 pring->next_cmdidx, pring->local_getidx, pring->flag,
265 pgpp->rspPutInx, pring->numRiocb);
266 pgpp++;
267
268 pring = &psli->ring[3];
269 len += snprintf(buf+len, size-len,
270 "Ring 3: CMD GetInx:%d (Max:%d Next:%d Local:%d flg:x%x) "
271 "RSP PutInx:%d Max:%d\n",
272 pgpp->cmdGetInx, pring->numCiocb,
273 pring->next_cmdidx, pring->local_getidx, pring->flag,
274 pgpp->rspPutInx, pring->numRiocb);
275
276
277 ptr = (uint32_t *)&phba->slim2p->mbx.us.s3_pgp.hbq_get;
278 word0 = readl(phba->HAregaddr);
279 word1 = readl(phba->CAregaddr);
280 word2 = readl(phba->HSregaddr);
281 word3 = readl(phba->HCregaddr);
282 len += snprintf(buf+len, size-len, "HA:%08x CA:%08x HS:%08x HC:%08x\n",
283 word0, word1, word2, word3);
284 spin_unlock_irq(&phba->hbalock);
285 return len;
286}
287
288static int
146lpfc_debugfs_nodelist_data(struct lpfc_vport *vport, char *buf, int size) 289lpfc_debugfs_nodelist_data(struct lpfc_vport *vport, char *buf, int size)
147{ 290{
148 int len = 0; 291 int len = 0;
@@ -204,7 +347,7 @@ lpfc_debugfs_nodelist_data(struct lpfc_vport *vport, char *buf, int size)
204 len += snprintf(buf+len, size-len, "RPI:%03d flag:x%08x ", 347 len += snprintf(buf+len, size-len, "RPI:%03d flag:x%08x ",
205 ndlp->nlp_rpi, ndlp->nlp_flag); 348 ndlp->nlp_rpi, ndlp->nlp_flag);
206 if (!ndlp->nlp_type) 349 if (!ndlp->nlp_type)
207 len += snprintf(buf+len, size-len, "UNKNOWN_TYPE"); 350 len += snprintf(buf+len, size-len, "UNKNOWN_TYPE ");
208 if (ndlp->nlp_type & NLP_FC_NODE) 351 if (ndlp->nlp_type & NLP_FC_NODE)
209 len += snprintf(buf+len, size-len, "FC_NODE "); 352 len += snprintf(buf+len, size-len, "FC_NODE ");
210 if (ndlp->nlp_type & NLP_FABRIC) 353 if (ndlp->nlp_type & NLP_FABRIC)
@@ -213,7 +356,9 @@ lpfc_debugfs_nodelist_data(struct lpfc_vport *vport, char *buf, int size)
213 len += snprintf(buf+len, size-len, "FCP_TGT sid:%d ", 356 len += snprintf(buf+len, size-len, "FCP_TGT sid:%d ",
214 ndlp->nlp_sid); 357 ndlp->nlp_sid);
215 if (ndlp->nlp_type & NLP_FCP_INITIATOR) 358 if (ndlp->nlp_type & NLP_FCP_INITIATOR)
216 len += snprintf(buf+len, size-len, "FCP_INITIATOR"); 359 len += snprintf(buf+len, size-len, "FCP_INITIATOR ");
360 len += snprintf(buf+len, size-len, "refcnt:%x",
361 atomic_read(&ndlp->kref.refcount));
217 len += snprintf(buf+len, size-len, "\n"); 362 len += snprintf(buf+len, size-len, "\n");
218 } 363 }
219 spin_unlock_irq(shost->host_lock); 364 spin_unlock_irq(shost->host_lock);
@@ -227,7 +372,7 @@ lpfc_debugfs_disc_trc(struct lpfc_vport *vport, int mask, char *fmt,
227 uint32_t data1, uint32_t data2, uint32_t data3) 372 uint32_t data1, uint32_t data2, uint32_t data3)
228{ 373{
229#ifdef CONFIG_LPFC_DEBUG_FS 374#ifdef CONFIG_LPFC_DEBUG_FS
230 struct lpfc_disc_trc *dtp; 375 struct lpfc_debugfs_trc *dtp;
231 int index; 376 int index;
232 377
233 if (!(lpfc_debugfs_mask_disc_trc & mask)) 378 if (!(lpfc_debugfs_mask_disc_trc & mask))
@@ -244,7 +389,32 @@ lpfc_debugfs_disc_trc(struct lpfc_vport *vport, int mask, char *fmt,
244 dtp->data1 = data1; 389 dtp->data1 = data1;
245 dtp->data2 = data2; 390 dtp->data2 = data2;
246 dtp->data3 = data3; 391 dtp->data3 = data3;
247 dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_disc_trc_cnt); 392 dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
393 dtp->jif = jiffies;
394#endif
395 return;
396}
397
398inline void
399lpfc_debugfs_slow_ring_trc(struct lpfc_hba *phba, char *fmt,
400 uint32_t data1, uint32_t data2, uint32_t data3)
401{
402#ifdef CONFIG_LPFC_DEBUG_FS
403 struct lpfc_debugfs_trc *dtp;
404 int index;
405
406 if (!lpfc_debugfs_enable || !lpfc_debugfs_max_slow_ring_trc ||
407 !phba || !phba->slow_ring_trc)
408 return;
409
410 index = atomic_inc_return(&phba->slow_ring_trc_cnt) &
411 (lpfc_debugfs_max_slow_ring_trc - 1);
412 dtp = phba->slow_ring_trc + index;
413 dtp->fmt = fmt;
414 dtp->data1 = data1;
415 dtp->data2 = data2;
416 dtp->data3 = data3;
417 dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
248 dtp->jif = jiffies; 418 dtp->jif = jiffies;
249#endif 419#endif
250 return; 420 return;
@@ -269,7 +439,7 @@ lpfc_debugfs_disc_trc_open(struct inode *inode, struct file *file)
269 goto out; 439 goto out;
270 440
271 /* Round to page boundry */ 441 /* Round to page boundry */
272 size = (lpfc_debugfs_max_disc_trc * LPFC_DISC_TRC_ENTRY_SIZE); 442 size = (lpfc_debugfs_max_disc_trc * LPFC_DEBUG_TRC_ENTRY_SIZE);
273 size = PAGE_ALIGN(size); 443 size = PAGE_ALIGN(size);
274 444
275 debug->buffer = kmalloc(size, GFP_KERNEL); 445 debug->buffer = kmalloc(size, GFP_KERNEL);
@@ -287,6 +457,68 @@ out:
287} 457}
288 458
289static int 459static int
460lpfc_debugfs_slow_ring_trc_open(struct inode *inode, struct file *file)
461{
462 struct lpfc_hba *phba = inode->i_private;
463 struct lpfc_debug *debug;
464 int size;
465 int rc = -ENOMEM;
466
467 if (!lpfc_debugfs_max_slow_ring_trc) {
468 rc = -ENOSPC;
469 goto out;
470 }
471
472 debug = kmalloc(sizeof(*debug), GFP_KERNEL);
473 if (!debug)
474 goto out;
475
476 /* Round to page boundry */
477 size = (lpfc_debugfs_max_slow_ring_trc * LPFC_DEBUG_TRC_ENTRY_SIZE);
478 size = PAGE_ALIGN(size);
479
480 debug->buffer = kmalloc(size, GFP_KERNEL);
481 if (!debug->buffer) {
482 kfree(debug);
483 goto out;
484 }
485
486 debug->len = lpfc_debugfs_slow_ring_trc_data(phba, debug->buffer, size);
487 file->private_data = debug;
488
489 rc = 0;
490out:
491 return rc;
492}
493
494static int
495lpfc_debugfs_dumpslim_open(struct inode *inode, struct file *file)
496{
497 struct lpfc_hba *phba = inode->i_private;
498 struct lpfc_debug *debug;
499 int rc = -ENOMEM;
500
501 debug = kmalloc(sizeof(*debug), GFP_KERNEL);
502 if (!debug)
503 goto out;
504
505 /* Round to page boundry */
506 debug->buffer = kmalloc(LPFC_DUMPSLIM_SIZE, GFP_KERNEL);
507 if (!debug->buffer) {
508 kfree(debug);
509 goto out;
510 }
511
512 debug->len = lpfc_debugfs_dumpslim_data(phba, debug->buffer,
513 LPFC_DUMPSLIM_SIZE);
514 file->private_data = debug;
515
516 rc = 0;
517out:
518 return rc;
519}
520
521static int
290lpfc_debugfs_nodelist_open(struct inode *inode, struct file *file) 522lpfc_debugfs_nodelist_open(struct inode *inode, struct file *file)
291{ 523{
292 struct lpfc_vport *vport = inode->i_private; 524 struct lpfc_vport *vport = inode->i_private;
@@ -372,6 +604,24 @@ static struct file_operations lpfc_debugfs_op_nodelist = {
372 .release = lpfc_debugfs_release, 604 .release = lpfc_debugfs_release,
373}; 605};
374 606
607#undef lpfc_debugfs_op_dumpslim
608static struct file_operations lpfc_debugfs_op_dumpslim = {
609 .owner = THIS_MODULE,
610 .open = lpfc_debugfs_dumpslim_open,
611 .llseek = lpfc_debugfs_lseek,
612 .read = lpfc_debugfs_read,
613 .release = lpfc_debugfs_release,
614};
615
616#undef lpfc_debugfs_op_slow_ring_trc
617static struct file_operations lpfc_debugfs_op_slow_ring_trc = {
618 .owner = THIS_MODULE,
619 .open = lpfc_debugfs_slow_ring_trc_open,
620 .llseek = lpfc_debugfs_lseek,
621 .read = lpfc_debugfs_read,
622 .release = lpfc_debugfs_release,
623};
624
375static struct dentry *lpfc_debugfs_root = NULL; 625static struct dentry *lpfc_debugfs_root = NULL;
376static atomic_t lpfc_debugfs_hba_count; 626static atomic_t lpfc_debugfs_hba_count;
377#endif 627#endif
@@ -387,60 +637,142 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
387 if (!lpfc_debugfs_enable) 637 if (!lpfc_debugfs_enable)
388 return; 638 return;
389 639
390 if (lpfc_debugfs_max_disc_trc) { 640 /* Setup lpfc root directory */
391 num = lpfc_debugfs_max_disc_trc - 1;
392 if (num & lpfc_debugfs_max_disc_trc) {
393 /* Change to be a power of 2 */
394 num = lpfc_debugfs_max_disc_trc;
395 i = 0;
396 while (num > 1) {
397 num = num >> 1;
398 i++;
399 }
400 lpfc_debugfs_max_disc_trc = (1 << i);
401 printk(KERN_ERR
402 "lpfc_debugfs_max_disc_trc changed to %d\n",
403 lpfc_debugfs_max_disc_trc);
404 }
405 }
406
407 if (!lpfc_debugfs_root) { 641 if (!lpfc_debugfs_root) {
408 lpfc_debugfs_root = debugfs_create_dir("lpfc", NULL); 642 lpfc_debugfs_root = debugfs_create_dir("lpfc", NULL);
409 atomic_set(&lpfc_debugfs_hba_count, 0); 643 atomic_set(&lpfc_debugfs_hba_count, 0);
410 if (!lpfc_debugfs_root) 644 if (!lpfc_debugfs_root) {
645 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
646 "%d:0409 Cannot create debugfs root (lpfc)",
647 phba->brd_no);
411 goto debug_failed; 648 goto debug_failed;
649 }
412 } 650 }
413 651
652 if (!lpfc_debugfs_start_time)
653 lpfc_debugfs_start_time = jiffies;
654
655 /* Setup lpfcX directory for specific HBA */
414 snprintf(name, sizeof(name), "lpfc%d", phba->brd_no); 656 snprintf(name, sizeof(name), "lpfc%d", phba->brd_no);
415 if (!phba->hba_debugfs_root) { 657 if (!phba->hba_debugfs_root) {
416 phba->hba_debugfs_root = 658 phba->hba_debugfs_root =
417 debugfs_create_dir(name, lpfc_debugfs_root); 659 debugfs_create_dir(name, lpfc_debugfs_root);
418 if (!phba->hba_debugfs_root) 660 if (!phba->hba_debugfs_root) {
661 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
662 "%d:0409 Cannot create debugfs hba (lpfc%d)",
663 phba->brd_no, phba->brd_no);
419 goto debug_failed; 664 goto debug_failed;
665 }
420 atomic_inc(&lpfc_debugfs_hba_count); 666 atomic_inc(&lpfc_debugfs_hba_count);
421 atomic_set(&phba->debugfs_vport_count, 0); 667 atomic_set(&phba->debugfs_vport_count, 0);
668
669 /* Setup dumpslim */
670 snprintf(name, sizeof(name), "dumpslim");
671 phba->debug_dumpslim =
672 debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
673 phba->hba_debugfs_root,
674 phba, &lpfc_debugfs_op_dumpslim);
675 if (!phba->debug_dumpslim) {
676 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
677 "%d:0409 Cannot create debugfs dumpslim (lpfc%d)",
678 phba->brd_no, phba->brd_no);
679 goto debug_failed;
680 }
681
682 /* Setup slow ring trace */
683 if (lpfc_debugfs_max_slow_ring_trc) {
684 num = lpfc_debugfs_max_slow_ring_trc - 1;
685 if (num & lpfc_debugfs_max_slow_ring_trc) {
686 /* Change to be a power of 2 */
687 num = lpfc_debugfs_max_slow_ring_trc;
688 i = 0;
689 while (num > 1) {
690 num = num >> 1;
691 i++;
692 }
693 lpfc_debugfs_max_slow_ring_trc = (1 << i);
694 printk(KERN_ERR
695 "lpfc_debugfs_max_slow_ring_trc change to %d\n",
696 lpfc_debugfs_max_slow_ring_trc);
697 }
698 }
699
700
701 snprintf(name, sizeof(name), "slow_ring_trace");
702 phba->debug_slow_ring_trc =
703 debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
704 phba->hba_debugfs_root,
705 phba, &lpfc_debugfs_op_slow_ring_trc);
706 if (!phba->debug_slow_ring_trc) {
707 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
708 "%d:0409 Cannot create debugfs "
709 "slow_ring_trace (lpfc%d)",
710 phba->brd_no, phba->brd_no);
711 goto debug_failed;
712 }
713 if (!phba->slow_ring_trc) {
714 phba->slow_ring_trc = kmalloc(
715 (sizeof(struct lpfc_debugfs_trc) *
716 lpfc_debugfs_max_slow_ring_trc),
717 GFP_KERNEL);
718 if (!phba->slow_ring_trc) {
719 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
720 "%d:0409 Cannot create debugfs "
721 "slow_ring buffer (lpfc%d)",
722 phba->brd_no, phba->brd_no);
723 goto debug_failed;
724 }
725 atomic_set(&phba->slow_ring_trc_cnt, 0);
726 memset(phba->slow_ring_trc, 0,
727 (sizeof(struct lpfc_debugfs_trc) *
728 lpfc_debugfs_max_slow_ring_trc));
729 }
422 } 730 }
423 731
424 snprintf(name, sizeof(name), "vport%d", vport->vpi); 732 snprintf(name, sizeof(name), "vport%d", vport->vpi);
425 if (!vport->vport_debugfs_root) { 733 if (!vport->vport_debugfs_root) {
426 vport->vport_debugfs_root = 734 vport->vport_debugfs_root =
427 debugfs_create_dir(name, phba->hba_debugfs_root); 735 debugfs_create_dir(name, phba->hba_debugfs_root);
428 if (!vport->vport_debugfs_root) 736 if (!vport->vport_debugfs_root) {
737 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
738 "%d:0409 Cant create debugfs vport%d (lpfc%d)",
739 phba->brd_no, vport->vpi, phba->brd_no);
429 goto debug_failed; 740 goto debug_failed;
741 }
430 atomic_inc(&phba->debugfs_vport_count); 742 atomic_inc(&phba->debugfs_vport_count);
431 } 743 }
432 744
433 if (!lpfc_debugfs_start_time) 745 if (lpfc_debugfs_max_disc_trc) {
434 lpfc_debugfs_start_time = jiffies; 746 num = lpfc_debugfs_max_disc_trc - 1;
747 if (num & lpfc_debugfs_max_disc_trc) {
748 /* Change to be a power of 2 */
749 num = lpfc_debugfs_max_disc_trc;
750 i = 0;
751 while (num > 1) {
752 num = num >> 1;
753 i++;
754 }
755 lpfc_debugfs_max_disc_trc = (1 << i);
756 printk(KERN_ERR
757 "lpfc_debugfs_max_disc_trc changed to %d\n",
758 lpfc_debugfs_max_disc_trc);
759 }
760 }
435 761
436 vport->disc_trc = kmalloc( 762 vport->disc_trc = kmalloc(
437 (sizeof(struct lpfc_disc_trc) * lpfc_debugfs_max_disc_trc), 763 (sizeof(struct lpfc_debugfs_trc) * lpfc_debugfs_max_disc_trc),
438 GFP_KERNEL); 764 GFP_KERNEL);
439 765
440 if (!vport->disc_trc) 766 if (!vport->disc_trc) {
767 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
768 "%d:0409 Cannot create debugfs "
769 "vport%d disc trace buffer (lpfc%d)",
770 phba->brd_no, vport->vpi, phba->brd_no);
441 goto debug_failed; 771 goto debug_failed;
772 }
773 atomic_set(&vport->disc_trc_cnt, 0);
442 memset(vport->disc_trc, 0, 774 memset(vport->disc_trc, 0,
443 (sizeof(struct lpfc_disc_trc) * lpfc_debugfs_max_disc_trc)); 775 (sizeof(struct lpfc_debugfs_trc) * lpfc_debugfs_max_disc_trc));
444 776
445 snprintf(name, sizeof(name), "discovery_trace"); 777 snprintf(name, sizeof(name), "discovery_trace");
446 vport->debug_disc_trc = 778 vport->debug_disc_trc =
@@ -449,8 +781,9 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
449 vport, &lpfc_debugfs_op_disc_trc); 781 vport, &lpfc_debugfs_op_disc_trc);
450 if (!vport->debug_disc_trc) { 782 if (!vport->debug_disc_trc) {
451 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 783 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
452 "%d:0409 Cannot create debugfs", 784 "%d:0409 Cannot create debugfs "
453 phba->brd_no); 785 "vport%d discovery_trace (lpfc%d)",
786 phba->brd_no, vport->vpi, phba->brd_no);
454 goto debug_failed; 787 goto debug_failed;
455 } 788 }
456 snprintf(name, sizeof(name), "nodelist"); 789 snprintf(name, sizeof(name), "nodelist");
@@ -460,8 +793,8 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
460 vport, &lpfc_debugfs_op_nodelist); 793 vport, &lpfc_debugfs_op_nodelist);
461 if (!vport->debug_nodelist) { 794 if (!vport->debug_nodelist) {
462 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 795 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
463 "%d:0409 Cannot create debugfs", 796 "%d:0409 Cant create debugfs vport%d nodelist (lpfc%d)",
464 phba->brd_no); 797 phba->brd_no, vport->vpi, phba->brd_no);
465 goto debug_failed; 798 goto debug_failed;
466 } 799 }
467debug_failed: 800debug_failed:
@@ -488,21 +821,41 @@ lpfc_debugfs_terminate(struct lpfc_vport *vport)
488 debugfs_remove(vport->debug_nodelist); /* nodelist */ 821 debugfs_remove(vport->debug_nodelist); /* nodelist */
489 vport->debug_nodelist = NULL; 822 vport->debug_nodelist = NULL;
490 } 823 }
824
491 if (vport->vport_debugfs_root) { 825 if (vport->vport_debugfs_root) {
492 debugfs_remove(vport->vport_debugfs_root); /* vportX */ 826 debugfs_remove(vport->vport_debugfs_root); /* vportX */
493 vport->vport_debugfs_root = NULL; 827 vport->vport_debugfs_root = NULL;
494 atomic_dec(&phba->debugfs_vport_count); 828 atomic_dec(&phba->debugfs_vport_count);
495 } 829 }
496 if (atomic_read(&phba->debugfs_vport_count) == 0) { 830 if (atomic_read(&phba->debugfs_vport_count) == 0) {
497 debugfs_remove(vport->phba->hba_debugfs_root); /* lpfcX */ 831
498 vport->phba->hba_debugfs_root = NULL; 832 if (phba->debug_dumpslim) {
499 atomic_dec(&lpfc_debugfs_hba_count); 833 debugfs_remove(phba->debug_dumpslim); /* dumpslim */
834 phba->debug_dumpslim = NULL;
835 }
836 if (phba->slow_ring_trc) {
837 kfree(phba->slow_ring_trc);
838 phba->slow_ring_trc = NULL;
839 }
840 if (phba->debug_slow_ring_trc) {
841 /* slow_ring_trace */
842 debugfs_remove(phba->debug_slow_ring_trc);
843 phba->debug_slow_ring_trc = NULL;
844 }
845
846 if (phba->hba_debugfs_root) {
847 debugfs_remove(phba->hba_debugfs_root); /* lpfcX */
848 phba->hba_debugfs_root = NULL;
849 atomic_dec(&lpfc_debugfs_hba_count);
850 }
851
500 if (atomic_read(&lpfc_debugfs_hba_count) == 0) { 852 if (atomic_read(&lpfc_debugfs_hba_count) == 0) {
501 debugfs_remove(lpfc_debugfs_root); /* lpfc */ 853 debugfs_remove(lpfc_debugfs_root); /* lpfc */
502 lpfc_debugfs_root = NULL; 854 lpfc_debugfs_root = NULL;
503 } 855 }
504 } 856 }
505#endif 857#endif
858 return;
506} 859}
507 860
508 861