1 /*******************************************************************
2 * This file is part of the Emulex Linux Device Driver for *
3 * Fibre Channel Host Bus Adapters. *
4 * Copyright (C) 2007-2008 Emulex. All rights reserved. *
5 * EMULEX and SLI are trademarks of Emulex. *
8 * This program is free software; you can redistribute it and/or *
9 * modify it under the terms of version 2 of the GNU General *
10 * Public License as published by the Free Software Foundation. *
11 * This program is distributed in the hope that it will be useful. *
12 * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND *
13 * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, *
14 * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE *
15 * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD *
16 * TO BE LEGALLY INVALID. See the GNU General Public License for *
17 * more details, a copy of which can be found in the file COPYING *
18 * included with this package. *
19 *******************************************************************/
21 #include <linux/blkdev.h>
22 #include <linux/delay.h>
23 #include <linux/dma-mapping.h>
24 #include <linux/idr.h>
25 #include <linux/interrupt.h>
26 #include <linux/kthread.h>
27 #include <linux/pci.h>
28 #include <linux/spinlock.h>
29 #include <linux/ctype.h>
31 #include <scsi/scsi.h>
32 #include <scsi/scsi_device.h>
33 #include <scsi/scsi_host.h>
34 #include <scsi/scsi_transport_fc.h>
39 #include "lpfc_disc.h"
40 #include "lpfc_scsi.h"
42 #include "lpfc_logmsg.h"
43 #include "lpfc_crtn.h"
44 #include "lpfc_vport.h"
45 #include "lpfc_version.h"
46 #include "lpfc_compat.h"
47 #include "lpfc_debugfs.h"
49 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
53 * To access this interface the user should:
55 * # mount -t debugfs none /debug
57 * The lpfc debugfs directory hierarchy is:
59 * where X is the lpfc hba unique_id
60 * where Y is the vport VPI on that hba
62 * Debugging services available per vport:
64 * This is an ACSII readable file that contains a trace of the last
65 * lpfc_debugfs_max_disc_trc events that happened on a specific vport.
66 * See lpfc_debugfs.h for different categories of discovery events.
67 * To enable the discovery trace, the following module parameters must be set:
68 * lpfc_debugfs_enable=1 Turns on lpfc debugfs filesystem support
69 * lpfc_debugfs_max_disc_trc=X Where X is the event trace depth for
70 * EACH vport. X MUST also be a power of 2.
71 * lpfc_debugfs_mask_disc_trc=Y Where Y is an event mask as defined in
75 * This is an ACSII readable file that contains a trace of the last
76 * lpfc_debugfs_max_slow_ring_trc events that happened on a specific HBA.
77 * To enable the slow ring trace, the following module parameters must be set:
78 * lpfc_debugfs_enable=1 Turns on lpfc debugfs filesystem support
79 * lpfc_debugfs_max_slow_ring_trc=X Where X is the event trace depth for
80 * the HBA. X MUST also be a power of 2.
82 static int lpfc_debugfs_enable = 1;
83 module_param(lpfc_debugfs_enable, int, 0);
84 MODULE_PARM_DESC(lpfc_debugfs_enable, "Enable debugfs services");
86 /* This MUST be a power of 2 */
87 static int lpfc_debugfs_max_disc_trc;
88 module_param(lpfc_debugfs_max_disc_trc, int, 0);
89 MODULE_PARM_DESC(lpfc_debugfs_max_disc_trc,
90 "Set debugfs discovery trace depth");
92 /* This MUST be a power of 2 */
93 static int lpfc_debugfs_max_slow_ring_trc;
94 module_param(lpfc_debugfs_max_slow_ring_trc, int, 0);
95 MODULE_PARM_DESC(lpfc_debugfs_max_slow_ring_trc,
96 "Set debugfs slow ring trace depth");
98 int lpfc_debugfs_mask_disc_trc;
99 module_param(lpfc_debugfs_mask_disc_trc, int, 0);
100 MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc,
101 "Set debugfs discovery trace mask");
103 #include <linux/debugfs.h>
105 /* size of output line, for discovery_trace and slow_ring_trace */
106 #define LPFC_DEBUG_TRC_ENTRY_SIZE 100
108 /* nodelist output buffer size */
109 #define LPFC_NODELIST_SIZE 8192
110 #define LPFC_NODELIST_ENTRY_SIZE 120
112 /* dumpHBASlim output buffer size */
113 #define LPFC_DUMPHBASLIM_SIZE 4096
115 /* dumpHostSlim output buffer size */
116 #define LPFC_DUMPHOSTSLIM_SIZE 4096
118 /* hbqinfo output buffer size */
119 #define LPFC_HBQINFO_SIZE 8192
126 static atomic_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
127 static unsigned long lpfc_debugfs_start_time = 0L;
130 * lpfc_debugfs_disc_trc_data - Dump discovery logging to a buffer.
131 * @vport: The vport to gather the log info from.
132 * @buf: The buffer to dump log into.
133 * @size: The maximum amount of data to process.
136 * This routine gathers the lpfc discovery debugfs data from the @vport and
137 * dumps it to @buf up to @size number of bytes. It will start at the next entry
138 * in the log and process the log until the end of the buffer. Then it will
139 * gather from the beginning of the log and process until the current entry.
142 * Discovery logging will be disabled while while this routine dumps the log.
145 * This routine returns the amount of bytes that were dumped into @buf and will
149 lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size)
151 int i, index, len, enable;
153 struct lpfc_debugfs_trc *dtp;
154 char buffer[LPFC_DEBUG_TRC_ENTRY_SIZE];
156 enable = lpfc_debugfs_enable;
157 lpfc_debugfs_enable = 0;
160 index = (atomic_read(&vport->disc_trc_cnt) + 1) &
161 (lpfc_debugfs_max_disc_trc - 1);
162 for (i = index; i < lpfc_debugfs_max_disc_trc; i++) {
163 dtp = vport->disc_trc + i;
166 ms = jiffies_to_msecs(dtp->jif - lpfc_debugfs_start_time);
168 LPFC_DEBUG_TRC_ENTRY_SIZE, "%010d:%010d ms:%s\n",
169 dtp->seq_cnt, ms, dtp->fmt);
170 len += snprintf(buf+len, size-len, buffer,
171 dtp->data1, dtp->data2, dtp->data3);
173 for (i = 0; i < index; i++) {
174 dtp = vport->disc_trc + i;
177 ms = jiffies_to_msecs(dtp->jif - lpfc_debugfs_start_time);
179 LPFC_DEBUG_TRC_ENTRY_SIZE, "%010d:%010d ms:%s\n",
180 dtp->seq_cnt, ms, dtp->fmt);
181 len += snprintf(buf+len, size-len, buffer,
182 dtp->data1, dtp->data2, dtp->data3);
185 lpfc_debugfs_enable = enable;
190 * lpfc_debugfs_slow_ring_trc_data - Dump slow ring logging to a buffer.
191 * @phba: The HBA to gather the log info from.
192 * @buf: The buffer to dump log into.
193 * @size: The maximum amount of data to process.
196 * This routine gathers the lpfc slow ring debugfs data from the @phba and
197 * dumps it to @buf up to @size number of bytes. It will start at the next entry
198 * in the log and process the log until the end of the buffer. Then it will
199 * gather from the beginning of the log and process until the current entry.
202 * Slow ring logging will be disabled while while this routine dumps the log.
205 * This routine returns the amount of bytes that were dumped into @buf and will
209 lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba *phba, char *buf, int size)
211 int i, index, len, enable;
213 struct lpfc_debugfs_trc *dtp;
214 char buffer[LPFC_DEBUG_TRC_ENTRY_SIZE];
217 enable = lpfc_debugfs_enable;
218 lpfc_debugfs_enable = 0;
221 index = (atomic_read(&phba->slow_ring_trc_cnt) + 1) &
222 (lpfc_debugfs_max_slow_ring_trc - 1);
223 for (i = index; i < lpfc_debugfs_max_slow_ring_trc; i++) {
224 dtp = phba->slow_ring_trc + i;
227 ms = jiffies_to_msecs(dtp->jif - lpfc_debugfs_start_time);
229 LPFC_DEBUG_TRC_ENTRY_SIZE, "%010d:%010d ms:%s\n",
230 dtp->seq_cnt, ms, dtp->fmt);
231 len += snprintf(buf+len, size-len, buffer,
232 dtp->data1, dtp->data2, dtp->data3);
234 for (i = 0; i < index; i++) {
235 dtp = phba->slow_ring_trc + i;
238 ms = jiffies_to_msecs(dtp->jif - lpfc_debugfs_start_time);
240 LPFC_DEBUG_TRC_ENTRY_SIZE, "%010d:%010d ms:%s\n",
241 dtp->seq_cnt, ms, dtp->fmt);
242 len += snprintf(buf+len, size-len, buffer,
243 dtp->data1, dtp->data2, dtp->data3);
246 lpfc_debugfs_enable = enable;
250 static int lpfc_debugfs_last_hbq = -1;
253 * lpfc_debugfs_hbqinfo_data - Dump host buffer queue info to a buffer.
254 * @phba: The HBA to gather host buffer info from.
255 * @buf: The buffer to dump log into.
256 * @size: The maximum amount of data to process.
259 * This routine dumps the host buffer queue info from the @phba to @buf up to
260 * @size number of bytes. A header that describes the current hbq state will be
261 * dumped to @buf first and then info on each hbq entry will be dumped to @buf
262 * until @size bytes have been dumped or all the hbq info has been dumped.
265 * This routine will rotate through each configured HBQ each time called.
268 * This routine returns the amount of bytes that were dumped into @buf and will
272 lpfc_debugfs_hbqinfo_data(struct lpfc_hba *phba, char *buf, int size)
275 int cnt, i, j, found, posted, low;
276 uint32_t phys, raw_index, getidx;
277 struct lpfc_hbq_init *hip;
279 struct lpfc_hbq_entry *hbqe;
280 struct lpfc_dmabuf *d_buf;
281 struct hbq_dmabuf *hbq_buf;
283 cnt = LPFC_HBQINFO_SIZE;
284 spin_lock_irq(&phba->hbalock);
286 /* toggle between multiple hbqs, if any */
287 i = lpfc_sli_hbq_count();
289 lpfc_debugfs_last_hbq++;
290 if (lpfc_debugfs_last_hbq >= i)
291 lpfc_debugfs_last_hbq = 0;
294 lpfc_debugfs_last_hbq = 0;
296 i = lpfc_debugfs_last_hbq;
298 len += snprintf(buf+len, size-len, "HBQ %d Info\n", i);
300 hbqs = &phba->hbqs[i];
302 list_for_each_entry(d_buf, &hbqs->hbq_buffer_list, list)
305 hip = lpfc_hbq_defs[i];
306 len += snprintf(buf+len, size-len,
307 "idx:%d prof:%d rn:%d bufcnt:%d icnt:%d acnt:%d posted %d\n",
308 hip->hbq_index, hip->profile, hip->rn,
309 hip->buffer_count, hip->init_count, hip->add_count, posted);
311 raw_index = phba->hbq_get[i];
312 getidx = le32_to_cpu(raw_index);
313 len += snprintf(buf+len, size-len,
314 "entrys:%d bufcnt:%d Put:%d nPut:%d localGet:%d hbaGet:%d\n",
315 hbqs->entry_count, hbqs->buffer_count, hbqs->hbqPutIdx,
316 hbqs->next_hbqPutIdx, hbqs->local_hbqGetIdx, getidx);
318 hbqe = (struct lpfc_hbq_entry *) phba->hbqs[i].hbq_virt;
319 for (j=0; j<hbqs->entry_count; j++) {
320 len += snprintf(buf+len, size-len,
321 "%03d: %08x %04x %05x ", j,
322 le32_to_cpu(hbqe->bde.addrLow),
323 le32_to_cpu(hbqe->bde.tus.w),
324 le32_to_cpu(hbqe->buffer_tag));
328 /* First calculate if slot has an associated posted buffer */
329 low = hbqs->hbqPutIdx - posted;
331 if ((j >= hbqs->hbqPutIdx) || (j < low)) {
332 len += snprintf(buf+len, size-len, "Unused\n");
337 if ((j >= hbqs->hbqPutIdx) &&
338 (j < (hbqs->entry_count+low))) {
339 len += snprintf(buf+len, size-len, "Unused\n");
344 /* Get the Buffer info for the posted buffer */
345 list_for_each_entry(d_buf, &hbqs->hbq_buffer_list, list) {
346 hbq_buf = container_of(d_buf, struct hbq_dmabuf, dbuf);
347 phys = ((uint64_t)hbq_buf->dbuf.phys & 0xffffffff);
348 if (phys == le32_to_cpu(hbqe->bde.addrLow)) {
349 len += snprintf(buf+len, size-len,
350 "Buf%d: %p %06x\n", i,
351 hbq_buf->dbuf.virt, hbq_buf->tag);
358 len += snprintf(buf+len, size-len, "No DMAinfo?\n");
362 if (len > LPFC_HBQINFO_SIZE - 54)
365 spin_unlock_irq(&phba->hbalock);
369 static int lpfc_debugfs_last_hba_slim_off;
372 * lpfc_debugfs_dumpHBASlim_data - Dump HBA SLIM info to a buffer.
373 * @phba: The HBA to gather SLIM info from.
374 * @buf: The buffer to dump log into.
375 * @size: The maximum amount of data to process.
378 * This routine dumps the current contents of HBA SLIM for the HBA associated
379 * with @phba to @buf up to @size bytes of data. This is the raw HBA SLIM data.
382 * This routine will only dump up to 1024 bytes of data each time called and
383 * should be called multiple times to dump the entire HBA SLIM.
386 * This routine returns the amount of bytes that were dumped into @buf and will
390 lpfc_debugfs_dumpHBASlim_data(struct lpfc_hba *phba, char *buf, int size)
398 spin_lock_irq(&phba->hbalock);
400 len += snprintf(buf+len, size-len, "HBA SLIM\n");
401 lpfc_memcpy_from_slim(buffer,
402 ((uint8_t *)phba->MBslimaddr) + lpfc_debugfs_last_hba_slim_off,
405 ptr = (uint32_t *)&buffer[0];
406 off = lpfc_debugfs_last_hba_slim_off;
408 /* Set it up for the next time */
409 lpfc_debugfs_last_hba_slim_off += 1024;
410 if (lpfc_debugfs_last_hba_slim_off >= 4096)
411 lpfc_debugfs_last_hba_slim_off = 0;
415 len += snprintf(buf+len, size-len,
416 "%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n",
417 off, *ptr, *(ptr+1), *(ptr+2), *(ptr+3), *(ptr+4),
418 *(ptr+5), *(ptr+6), *(ptr+7));
420 i -= (8 * sizeof(uint32_t));
421 off += (8 * sizeof(uint32_t));
424 spin_unlock_irq(&phba->hbalock);
429 * lpfc_debugfs_dumpHostSlim_data - Dump host SLIM info to a buffer.
430 * @phba: The HBA to gather Host SLIM info from.
431 * @buf: The buffer to dump log into.
432 * @size: The maximum amount of data to process.
435 * This routine dumps the current contents of host SLIM for the host associated
436 * with @phba to @buf up to @size bytes of data. The dump will contain the
437 * Mailbox, PCB, Rings, and Registers that are located in host memory.
440 * This routine returns the amount of bytes that were dumped into @buf and will
444 lpfc_debugfs_dumpHostSlim_data(struct lpfc_hba *phba, char *buf, int size)
448 uint32_t word0, word1, word2, word3;
450 struct lpfc_pgp *pgpp;
451 struct lpfc_sli *psli = &phba->sli;
452 struct lpfc_sli_ring *pring;
455 spin_lock_irq(&phba->hbalock);
457 len += snprintf(buf+len, size-len, "SLIM Mailbox\n");
458 ptr = (uint32_t *)phba->slim2p.virt;
459 i = sizeof(MAILBOX_t);
461 len += snprintf(buf+len, size-len,
462 "%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n",
463 off, *ptr, *(ptr+1), *(ptr+2), *(ptr+3), *(ptr+4),
464 *(ptr+5), *(ptr+6), *(ptr+7));
466 i -= (8 * sizeof(uint32_t));
467 off += (8 * sizeof(uint32_t));
470 len += snprintf(buf+len, size-len, "SLIM PCB\n");
471 ptr = (uint32_t *)phba->pcb;
474 len += snprintf(buf+len, size-len,
475 "%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n",
476 off, *ptr, *(ptr+1), *(ptr+2), *(ptr+3), *(ptr+4),
477 *(ptr+5), *(ptr+6), *(ptr+7));
479 i -= (8 * sizeof(uint32_t));
480 off += (8 * sizeof(uint32_t));
483 for (i = 0; i < 4; i++) {
484 pgpp = &phba->port_gp[i];
485 pring = &psli->ring[i];
486 len += snprintf(buf+len, size-len,
487 "Ring %d: CMD GetInx:%d (Max:%d Next:%d "
488 "Local:%d flg:x%x) RSP PutInx:%d Max:%d\n",
489 i, pgpp->cmdGetInx, pring->numCiocb,
490 pring->next_cmdidx, pring->local_getidx,
491 pring->flag, pgpp->rspPutInx, pring->numRiocb);
493 word0 = readl(phba->HAregaddr);
494 word1 = readl(phba->CAregaddr);
495 word2 = readl(phba->HSregaddr);
496 word3 = readl(phba->HCregaddr);
497 len += snprintf(buf+len, size-len, "HA:%08x CA:%08x HS:%08x HC:%08x\n",
498 word0, word1, word2, word3);
499 spin_unlock_irq(&phba->hbalock);
504 * lpfc_debugfs_nodelist_data - Dump target node list to a buffer.
505 * @vport: The vport to gather target node info from.
506 * @buf: The buffer to dump log into.
507 * @size: The maximum amount of data to process.
510 * This routine dumps the current target node list associated with @vport to
511 * @buf up to @size bytes of data. Each node entry in the dump will contain a
512 * node state, DID, WWPN, WWNN, RPI, flags, type, and other useful fields.
515 * This routine returns the amount of bytes that were dumped into @buf and will
519 lpfc_debugfs_nodelist_data(struct lpfc_vport *vport, char *buf, int size)
523 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
524 struct lpfc_nodelist *ndlp;
525 unsigned char *statep, *name;
527 cnt = (LPFC_NODELIST_SIZE / LPFC_NODELIST_ENTRY_SIZE);
529 spin_lock_irq(shost->host_lock);
530 list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) {
532 len += snprintf(buf+len, size-len,
533 "Missing Nodelist Entries\n");
537 switch (ndlp->nlp_state) {
538 case NLP_STE_UNUSED_NODE:
541 case NLP_STE_PLOGI_ISSUE:
544 case NLP_STE_ADISC_ISSUE:
547 case NLP_STE_REG_LOGIN_ISSUE:
550 case NLP_STE_PRLI_ISSUE:
553 case NLP_STE_UNMAPPED_NODE:
556 case NLP_STE_MAPPED_NODE:
559 case NLP_STE_NPR_NODE:
565 len += snprintf(buf+len, size-len, "%s DID:x%06x ",
566 statep, ndlp->nlp_DID);
567 name = (unsigned char *)&ndlp->nlp_portname;
568 len += snprintf(buf+len, size-len,
569 "WWPN %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x ",
570 *name, *(name+1), *(name+2), *(name+3),
571 *(name+4), *(name+5), *(name+6), *(name+7));
572 name = (unsigned char *)&ndlp->nlp_nodename;
573 len += snprintf(buf+len, size-len,
574 "WWNN %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x ",
575 *name, *(name+1), *(name+2), *(name+3),
576 *(name+4), *(name+5), *(name+6), *(name+7));
577 len += snprintf(buf+len, size-len, "RPI:%03d flag:x%08x ",
578 ndlp->nlp_rpi, ndlp->nlp_flag);
580 len += snprintf(buf+len, size-len, "UNKNOWN_TYPE ");
581 if (ndlp->nlp_type & NLP_FC_NODE)
582 len += snprintf(buf+len, size-len, "FC_NODE ");
583 if (ndlp->nlp_type & NLP_FABRIC)
584 len += snprintf(buf+len, size-len, "FABRIC ");
585 if (ndlp->nlp_type & NLP_FCP_TARGET)
586 len += snprintf(buf+len, size-len, "FCP_TGT sid:%d ",
588 if (ndlp->nlp_type & NLP_FCP_INITIATOR)
589 len += snprintf(buf+len, size-len, "FCP_INITIATOR ");
590 len += snprintf(buf+len, size-len, "usgmap:%x ",
592 len += snprintf(buf+len, size-len, "refcnt:%x",
593 atomic_read(&ndlp->kref.refcount));
594 len += snprintf(buf+len, size-len, "\n");
596 spin_unlock_irq(shost->host_lock);
602 * lpfc_debugfs_disc_trc - Store discovery trace log.
603 * @vport: The vport to associate this trace string with for retrieval.
604 * @mask: Log entry classification.
605 * @fmt: Format string to be displayed when dumping the log.
606 * @data1: 1st data parameter to be applied to @fmt.
607 * @data2: 2nd data parameter to be applied to @fmt.
608 * @data3: 3rd data parameter to be applied to @fmt.
611 * This routine is used by the driver code to add a debugfs log entry to the
612 * discovery trace buffer associated with @vport. Only entries with a @mask that
613 * match the current debugfs discovery mask will be saved. Entries that do not
614 * match will be thrown away. @fmt, @data1, @data2, and @data3 are used like
615 * printf when displaying the log.
618 lpfc_debugfs_disc_trc(struct lpfc_vport *vport, int mask, char *fmt,
619 uint32_t data1, uint32_t data2, uint32_t data3)
621 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
622 struct lpfc_debugfs_trc *dtp;
625 if (!(lpfc_debugfs_mask_disc_trc & mask))
628 if (!lpfc_debugfs_enable || !lpfc_debugfs_max_disc_trc ||
629 !vport || !vport->disc_trc)
632 index = atomic_inc_return(&vport->disc_trc_cnt) &
633 (lpfc_debugfs_max_disc_trc - 1);
634 dtp = vport->disc_trc + index;
639 dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
646 * lpfc_debugfs_slow_ring_trc - Store slow ring trace log.
647 * @phba: The phba to associate this trace string with for retrieval.
648 * @fmt: Format string to be displayed when dumping the log.
649 * @data1: 1st data parameter to be applied to @fmt.
650 * @data2: 2nd data parameter to be applied to @fmt.
651 * @data3: 3rd data parameter to be applied to @fmt.
654 * This routine is used by the driver code to add a debugfs log entry to the
655 * discovery trace buffer associated with @vport. @fmt, @data1, @data2, and
656 * @data3 are used like printf when displaying the log.
659 lpfc_debugfs_slow_ring_trc(struct lpfc_hba *phba, char *fmt,
660 uint32_t data1, uint32_t data2, uint32_t data3)
662 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
663 struct lpfc_debugfs_trc *dtp;
666 if (!lpfc_debugfs_enable || !lpfc_debugfs_max_slow_ring_trc ||
667 !phba || !phba->slow_ring_trc)
670 index = atomic_inc_return(&phba->slow_ring_trc_cnt) &
671 (lpfc_debugfs_max_slow_ring_trc - 1);
672 dtp = phba->slow_ring_trc + index;
677 dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
683 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
685 * lpfc_debugfs_disc_trc_open - Open the discovery trace log.
686 * @inode: The inode pointer that contains a vport pointer.
687 * @file: The file pointer to attach the log output.
690 * This routine is the entry point for the debugfs open file operation. It gets
691 * the vport from the i_private field in @inode, allocates the necessary buffer
692 * for the log, fills the buffer from the in-memory log for this vport, and then
693 * returns a pointer to that log in the private_data field in @file.
696 * This function returns zero if successful. On error it will return an negative
700 lpfc_debugfs_disc_trc_open(struct inode *inode, struct file *file)
702 struct lpfc_vport *vport = inode->i_private;
703 struct lpfc_debug *debug;
707 if (!lpfc_debugfs_max_disc_trc) {
712 debug = kmalloc(sizeof(*debug), GFP_KERNEL);
716 /* Round to page boundary */
717 size = (lpfc_debugfs_max_disc_trc * LPFC_DEBUG_TRC_ENTRY_SIZE);
718 size = PAGE_ALIGN(size);
720 debug->buffer = kmalloc(size, GFP_KERNEL);
721 if (!debug->buffer) {
726 debug->len = lpfc_debugfs_disc_trc_data(vport, debug->buffer, size);
727 file->private_data = debug;
735 * lpfc_debugfs_slow_ring_trc_open - Open the Slow Ring trace log.
736 * @inode: The inode pointer that contains a vport pointer.
737 * @file: The file pointer to attach the log output.
740 * This routine is the entry point for the debugfs open file operation. It gets
741 * the vport from the i_private field in @inode, allocates the necessary buffer
742 * for the log, fills the buffer from the in-memory log for this vport, and then
743 * returns a pointer to that log in the private_data field in @file.
746 * This function returns zero if successful. On error it will return an negative
750 lpfc_debugfs_slow_ring_trc_open(struct inode *inode, struct file *file)
752 struct lpfc_hba *phba = inode->i_private;
753 struct lpfc_debug *debug;
757 if (!lpfc_debugfs_max_slow_ring_trc) {
762 debug = kmalloc(sizeof(*debug), GFP_KERNEL);
766 /* Round to page boundary */
767 size = (lpfc_debugfs_max_slow_ring_trc * LPFC_DEBUG_TRC_ENTRY_SIZE);
768 size = PAGE_ALIGN(size);
770 debug->buffer = kmalloc(size, GFP_KERNEL);
771 if (!debug->buffer) {
776 debug->len = lpfc_debugfs_slow_ring_trc_data(phba, debug->buffer, size);
777 file->private_data = debug;
785 * lpfc_debugfs_hbqinfo_open - Open the hbqinfo debugfs buffer.
786 * @inode: The inode pointer that contains a vport pointer.
787 * @file: The file pointer to attach the log output.
790 * This routine is the entry point for the debugfs open file operation. It gets
791 * the vport from the i_private field in @inode, allocates the necessary buffer
792 * for the log, fills the buffer from the in-memory log for this vport, and then
793 * returns a pointer to that log in the private_data field in @file.
796 * This function returns zero if successful. On error it will return an negative
800 lpfc_debugfs_hbqinfo_open(struct inode *inode, struct file *file)
802 struct lpfc_hba *phba = inode->i_private;
803 struct lpfc_debug *debug;
806 debug = kmalloc(sizeof(*debug), GFP_KERNEL);
810 /* Round to page boundary */
811 debug->buffer = kmalloc(LPFC_HBQINFO_SIZE, GFP_KERNEL);
812 if (!debug->buffer) {
817 debug->len = lpfc_debugfs_hbqinfo_data(phba, debug->buffer,
819 file->private_data = debug;
827 * lpfc_debugfs_dumpHBASlim_open - Open the Dump HBA SLIM debugfs buffer.
828 * @inode: The inode pointer that contains a vport pointer.
829 * @file: The file pointer to attach the log output.
832 * This routine is the entry point for the debugfs open file operation. It gets
833 * the vport from the i_private field in @inode, allocates the necessary buffer
834 * for the log, fills the buffer from the in-memory log for this vport, and then
835 * returns a pointer to that log in the private_data field in @file.
838 * This function returns zero if successful. On error it will return an negative
842 lpfc_debugfs_dumpHBASlim_open(struct inode *inode, struct file *file)
844 struct lpfc_hba *phba = inode->i_private;
845 struct lpfc_debug *debug;
848 debug = kmalloc(sizeof(*debug), GFP_KERNEL);
852 /* Round to page boundary */
853 debug->buffer = kmalloc(LPFC_DUMPHBASLIM_SIZE, GFP_KERNEL);
854 if (!debug->buffer) {
859 debug->len = lpfc_debugfs_dumpHBASlim_data(phba, debug->buffer,
860 LPFC_DUMPHBASLIM_SIZE);
861 file->private_data = debug;
869 * lpfc_debugfs_dumpHostSlim_open - Open the Dump Host SLIM debugfs buffer.
870 * @inode: The inode pointer that contains a vport pointer.
871 * @file: The file pointer to attach the log output.
874 * This routine is the entry point for the debugfs open file operation. It gets
875 * the vport from the i_private field in @inode, allocates the necessary buffer
876 * for the log, fills the buffer from the in-memory log for this vport, and then
877 * returns a pointer to that log in the private_data field in @file.
880 * This function returns zero if successful. On error it will return an negative
884 lpfc_debugfs_dumpHostSlim_open(struct inode *inode, struct file *file)
886 struct lpfc_hba *phba = inode->i_private;
887 struct lpfc_debug *debug;
890 debug = kmalloc(sizeof(*debug), GFP_KERNEL);
894 /* Round to page boundary */
895 debug->buffer = kmalloc(LPFC_DUMPHOSTSLIM_SIZE, GFP_KERNEL);
896 if (!debug->buffer) {
901 debug->len = lpfc_debugfs_dumpHostSlim_data(phba, debug->buffer,
902 LPFC_DUMPHOSTSLIM_SIZE);
903 file->private_data = debug;
911 lpfc_debugfs_dumpData_open(struct inode *inode, struct file *file)
913 struct lpfc_debug *debug;
919 debug = kmalloc(sizeof(*debug), GFP_KERNEL);
923 /* Round to page boundry */
924 printk(KERN_ERR "BLKGRD %s: _dump_buf_data=0x%p\n",
925 __func__, _dump_buf_data);
926 debug->buffer = _dump_buf_data;
927 if (!debug->buffer) {
932 debug->len = (1 << _dump_buf_data_order) << PAGE_SHIFT;
933 file->private_data = debug;
941 lpfc_debugfs_dumpDif_open(struct inode *inode, struct file *file)
943 struct lpfc_debug *debug;
949 debug = kmalloc(sizeof(*debug), GFP_KERNEL);
953 /* Round to page boundry */
954 printk(KERN_ERR "BLKGRD %s: _dump_buf_dif=0x%p file=%s\n", __func__,
955 _dump_buf_dif, file->f_dentry->d_name.name);
956 debug->buffer = _dump_buf_dif;
957 if (!debug->buffer) {
962 debug->len = (1 << _dump_buf_dif_order) << PAGE_SHIFT;
963 file->private_data = debug;
971 lpfc_debugfs_dumpDataDif_write(struct file *file, const char __user *buf,
972 size_t nbytes, loff_t *ppos)
975 * The Data/DIF buffers only save one failing IO
976 * The write op is used as a reset mechanism after an IO has
977 * already been saved to the next one can be saved
979 spin_lock(&_dump_buf_lock);
981 memset((void *)_dump_buf_data, 0,
982 ((1 << PAGE_SHIFT) << _dump_buf_data_order));
983 memset((void *)_dump_buf_dif, 0,
984 ((1 << PAGE_SHIFT) << _dump_buf_dif_order));
988 spin_unlock(&_dump_buf_lock);
996 * lpfc_debugfs_nodelist_open - Open the nodelist debugfs file.
997 * @inode: The inode pointer that contains a vport pointer.
998 * @file: The file pointer to attach the log output.
1001 * This routine is the entry point for the debugfs open file operation. It gets
1002 * the vport from the i_private field in @inode, allocates the necessary buffer
1003 * for the log, fills the buffer from the in-memory log for this vport, and then
1004 * returns a pointer to that log in the private_data field in @file.
1007 * This function returns zero if successful. On error it will return an negative
1011 lpfc_debugfs_nodelist_open(struct inode *inode, struct file *file)
1013 struct lpfc_vport *vport = inode->i_private;
1014 struct lpfc_debug *debug;
1017 debug = kmalloc(sizeof(*debug), GFP_KERNEL);
1021 /* Round to page boundary */
1022 debug->buffer = kmalloc(LPFC_NODELIST_SIZE, GFP_KERNEL);
1023 if (!debug->buffer) {
1028 debug->len = lpfc_debugfs_nodelist_data(vport, debug->buffer,
1029 LPFC_NODELIST_SIZE);
1030 file->private_data = debug;
1038 * lpfc_debugfs_lseek - Seek through a debugfs file.
1039 * @file: The file pointer to seek through.
1040 * @off: The offset to seek to or the amount to seek by.
1041 * @whence: Indicates how to seek.
1044 * This routine is the entry point for the debugfs lseek file operation. The
1045 * @whence parameter indicates whether @off is the offset to directly seek to,
1046 * or if it is a value to seek forward or reverse by. This function figures out
1047 * what the new offset of the debugfs file will be and assigns that value to the
1048 * f_pos field of @file.
1051 * This function returns the new offset if successful and returns a negative
1052 * error if unable to process the seek.
1055 lpfc_debugfs_lseek(struct file *file, loff_t off, int whence)
1057 struct lpfc_debug *debug;
1060 debug = file->private_data;
1067 pos = file->f_pos + off;
1070 pos = debug->len - off;
1072 return (pos < 0 || pos > debug->len) ? -EINVAL : (file->f_pos = pos);
1076 * lpfc_debugfs_read - Read a debugfs file.
1077 * @file: The file pointer to read from.
1078 * @buf: The buffer to copy the data to.
1079 * @nbytes: The number of bytes to read.
1080 * @ppos: The position in the file to start reading from.
1083 * This routine reads data from from the buffer indicated in the private_data
1084 * field of @file. It will start reading at @ppos and copy up to @nbytes of
1088 * This function returns the amount of data that was read (this could be less
1089 * than @nbytes if the end of the file was reached) or a negative error value.
1092 lpfc_debugfs_read(struct file *file, char __user *buf,
1093 size_t nbytes, loff_t *ppos)
1095 struct lpfc_debug *debug = file->private_data;
1096 return simple_read_from_buffer(buf, nbytes, ppos, debug->buffer,
1101 * lpfc_debugfs_release - Release the buffer used to store debugfs file data.
1102 * @inode: The inode pointer that contains a vport pointer. (unused)
1103 * @file: The file pointer that contains the buffer to release.
1106 * This routine frees the buffer that was allocated when the debugfs file was
1110 * This function returns zero.
1113 lpfc_debugfs_release(struct inode *inode, struct file *file)
1115 struct lpfc_debug *debug = file->private_data;
1117 kfree(debug->buffer);
1124 lpfc_debugfs_dumpDataDif_release(struct inode *inode, struct file *file)
1126 struct lpfc_debug *debug = file->private_data;
1128 debug->buffer = NULL;
1134 #undef lpfc_debugfs_op_disc_trc
1135 static const struct file_operations lpfc_debugfs_op_disc_trc = {
1136 .owner = THIS_MODULE,
1137 .open = lpfc_debugfs_disc_trc_open,
1138 .llseek = lpfc_debugfs_lseek,
1139 .read = lpfc_debugfs_read,
1140 .release = lpfc_debugfs_release,
1143 #undef lpfc_debugfs_op_nodelist
1144 static const struct file_operations lpfc_debugfs_op_nodelist = {
1145 .owner = THIS_MODULE,
1146 .open = lpfc_debugfs_nodelist_open,
1147 .llseek = lpfc_debugfs_lseek,
1148 .read = lpfc_debugfs_read,
1149 .release = lpfc_debugfs_release,
1152 #undef lpfc_debugfs_op_hbqinfo
1153 static const struct file_operations lpfc_debugfs_op_hbqinfo = {
1154 .owner = THIS_MODULE,
1155 .open = lpfc_debugfs_hbqinfo_open,
1156 .llseek = lpfc_debugfs_lseek,
1157 .read = lpfc_debugfs_read,
1158 .release = lpfc_debugfs_release,
1161 #undef lpfc_debugfs_op_dumpHBASlim
1162 static const struct file_operations lpfc_debugfs_op_dumpHBASlim = {
1163 .owner = THIS_MODULE,
1164 .open = lpfc_debugfs_dumpHBASlim_open,
1165 .llseek = lpfc_debugfs_lseek,
1166 .read = lpfc_debugfs_read,
1167 .release = lpfc_debugfs_release,
1170 #undef lpfc_debugfs_op_dumpHostSlim
1171 static const struct file_operations lpfc_debugfs_op_dumpHostSlim = {
1172 .owner = THIS_MODULE,
1173 .open = lpfc_debugfs_dumpHostSlim_open,
1174 .llseek = lpfc_debugfs_lseek,
1175 .read = lpfc_debugfs_read,
1176 .release = lpfc_debugfs_release,
1179 #undef lpfc_debugfs_op_dumpData
1180 static const struct file_operations lpfc_debugfs_op_dumpData = {
1181 .owner = THIS_MODULE,
1182 .open = lpfc_debugfs_dumpData_open,
1183 .llseek = lpfc_debugfs_lseek,
1184 .read = lpfc_debugfs_read,
1185 .write = lpfc_debugfs_dumpDataDif_write,
1186 .release = lpfc_debugfs_dumpDataDif_release,
1189 #undef lpfc_debugfs_op_dumpDif
1190 static const struct file_operations lpfc_debugfs_op_dumpDif = {
1191 .owner = THIS_MODULE,
1192 .open = lpfc_debugfs_dumpDif_open,
1193 .llseek = lpfc_debugfs_lseek,
1194 .read = lpfc_debugfs_read,
1195 .write = lpfc_debugfs_dumpDataDif_write,
1196 .release = lpfc_debugfs_dumpDataDif_release,
1199 #undef lpfc_debugfs_op_slow_ring_trc
1200 static const struct file_operations lpfc_debugfs_op_slow_ring_trc = {
1201 .owner = THIS_MODULE,
1202 .open = lpfc_debugfs_slow_ring_trc_open,
1203 .llseek = lpfc_debugfs_lseek,
1204 .read = lpfc_debugfs_read,
1205 .release = lpfc_debugfs_release,
1208 static struct dentry *lpfc_debugfs_root = NULL;
1209 static atomic_t lpfc_debugfs_hba_count;
1213 * lpfc_debugfs_initialize - Initialize debugfs for a vport.
1214 * @vport: The vport pointer to initialize.
1217 * When Debugfs is configured this routine sets up the lpfc debugfs file system.
1218 * If not already created, this routine will create the lpfc directory, and
1219 * lpfcX directory (for this HBA), and vportX directory for this vport. It will
1220 * also create each file used to access lpfc specific debugfs information.
1223 lpfc_debugfs_initialize(struct lpfc_vport *vport)
1225 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
1226 struct lpfc_hba *phba = vport->phba;
1230 if (!lpfc_debugfs_enable)
1233 /* Setup lpfc root directory */
1234 if (!lpfc_debugfs_root) {
1235 lpfc_debugfs_root = debugfs_create_dir("lpfc", NULL);
1236 atomic_set(&lpfc_debugfs_hba_count, 0);
1237 if (!lpfc_debugfs_root) {
1238 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
1239 "0408 Cannot create debugfs root\n");
1243 if (!lpfc_debugfs_start_time)
1244 lpfc_debugfs_start_time = jiffies;
1246 /* Setup lpfcX directory for specific HBA */
1247 snprintf(name, sizeof(name), "lpfc%d", phba->brd_no);
1248 if (!phba->hba_debugfs_root) {
1249 phba->hba_debugfs_root =
1250 debugfs_create_dir(name, lpfc_debugfs_root);
1251 if (!phba->hba_debugfs_root) {
1252 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
1253 "0412 Cannot create debugfs hba\n");
1256 atomic_inc(&lpfc_debugfs_hba_count);
1257 atomic_set(&phba->debugfs_vport_count, 0);
1260 snprintf(name, sizeof(name), "hbqinfo");
1261 phba->debug_hbqinfo =
1262 debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
1263 phba->hba_debugfs_root,
1264 phba, &lpfc_debugfs_op_hbqinfo);
1265 if (!phba->debug_hbqinfo) {
1266 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
1267 "0411 Cannot create debugfs hbqinfo\n");
1271 /* Setup dumpHBASlim */
1272 snprintf(name, sizeof(name), "dumpHBASlim");
1273 phba->debug_dumpHBASlim =
1274 debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
1275 phba->hba_debugfs_root,
1276 phba, &lpfc_debugfs_op_dumpHBASlim);
1277 if (!phba->debug_dumpHBASlim) {
1278 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
1279 "0413 Cannot create debugfs dumpHBASlim\n");
1283 /* Setup dumpHostSlim */
1284 snprintf(name, sizeof(name), "dumpHostSlim");
1285 phba->debug_dumpHostSlim =
1286 debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
1287 phba->hba_debugfs_root,
1288 phba, &lpfc_debugfs_op_dumpHostSlim);
1289 if (!phba->debug_dumpHostSlim) {
1290 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
1291 "0414 Cannot create debugfs dumpHostSlim\n");
1295 /* Setup dumpData */
1296 snprintf(name, sizeof(name), "dumpData");
1297 phba->debug_dumpData =
1298 debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
1299 phba->hba_debugfs_root,
1300 phba, &lpfc_debugfs_op_dumpData);
1301 if (!phba->debug_dumpData) {
1302 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
1303 "0800 Cannot create debugfs dumpData\n");
1308 snprintf(name, sizeof(name), "dumpDif");
1309 phba->debug_dumpDif =
1310 debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
1311 phba->hba_debugfs_root,
1312 phba, &lpfc_debugfs_op_dumpDif);
1313 if (!phba->debug_dumpDif) {
1314 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
1315 "0801 Cannot create debugfs dumpDif\n");
1321 /* Setup slow ring trace */
1322 if (lpfc_debugfs_max_slow_ring_trc) {
1323 num = lpfc_debugfs_max_slow_ring_trc - 1;
1324 if (num & lpfc_debugfs_max_slow_ring_trc) {
1325 /* Change to be a power of 2 */
1326 num = lpfc_debugfs_max_slow_ring_trc;
1332 lpfc_debugfs_max_slow_ring_trc = (1 << i);
1334 "lpfc_debugfs_max_disc_trc changed to "
1335 "%d\n", lpfc_debugfs_max_disc_trc);
1340 snprintf(name, sizeof(name), "slow_ring_trace");
1341 phba->debug_slow_ring_trc =
1342 debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
1343 phba->hba_debugfs_root,
1344 phba, &lpfc_debugfs_op_slow_ring_trc);
1345 if (!phba->debug_slow_ring_trc) {
1346 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
1347 "0415 Cannot create debugfs "
1348 "slow_ring_trace\n");
1351 if (!phba->slow_ring_trc) {
1352 phba->slow_ring_trc = kmalloc(
1353 (sizeof(struct lpfc_debugfs_trc) *
1354 lpfc_debugfs_max_slow_ring_trc),
1356 if (!phba->slow_ring_trc) {
1357 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
1358 "0416 Cannot create debugfs "
1359 "slow_ring buffer\n");
1362 atomic_set(&phba->slow_ring_trc_cnt, 0);
1363 memset(phba->slow_ring_trc, 0,
1364 (sizeof(struct lpfc_debugfs_trc) *
1365 lpfc_debugfs_max_slow_ring_trc));
1369 snprintf(name, sizeof(name), "vport%d", vport->vpi);
1370 if (!vport->vport_debugfs_root) {
1371 vport->vport_debugfs_root =
1372 debugfs_create_dir(name, phba->hba_debugfs_root);
1373 if (!vport->vport_debugfs_root) {
1374 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
1375 "0417 Cant create debugfs");
1378 atomic_inc(&phba->debugfs_vport_count);
1381 if (lpfc_debugfs_max_disc_trc) {
1382 num = lpfc_debugfs_max_disc_trc - 1;
1383 if (num & lpfc_debugfs_max_disc_trc) {
1384 /* Change to be a power of 2 */
1385 num = lpfc_debugfs_max_disc_trc;
1391 lpfc_debugfs_max_disc_trc = (1 << i);
1393 "lpfc_debugfs_max_disc_trc changed to %d\n",
1394 lpfc_debugfs_max_disc_trc);
1398 vport->disc_trc = kzalloc(
1399 (sizeof(struct lpfc_debugfs_trc) * lpfc_debugfs_max_disc_trc),
1402 if (!vport->disc_trc) {
1403 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
1404 "0418 Cannot create debugfs disc trace "
1408 atomic_set(&vport->disc_trc_cnt, 0);
1410 snprintf(name, sizeof(name), "discovery_trace");
1411 vport->debug_disc_trc =
1412 debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
1413 vport->vport_debugfs_root,
1414 vport, &lpfc_debugfs_op_disc_trc);
1415 if (!vport->debug_disc_trc) {
1416 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
1417 "0419 Cannot create debugfs "
1418 "discovery_trace\n");
1421 snprintf(name, sizeof(name), "nodelist");
1422 vport->debug_nodelist =
1423 debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
1424 vport->vport_debugfs_root,
1425 vport, &lpfc_debugfs_op_nodelist);
1426 if (!vport->debug_nodelist) {
1427 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
1428 "0409 Cant create debugfs nodelist");
1437 * lpfc_debugfs_terminate - Tear down debugfs infrastructure for this vport.
1438 * @vport: The vport pointer to remove from debugfs.
1441 * When Debugfs is configured this routine removes debugfs file system elements
1442 * that are specific to this vport. It also checks to see if there are any
1443 * users left for the debugfs directories associated with the HBA and driver. If
1444 * this is the last user of the HBA directory or driver directory then it will
1445 * remove those from the debugfs infrastructure as well.
1448 lpfc_debugfs_terminate(struct lpfc_vport *vport)
1450 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
1451 struct lpfc_hba *phba = vport->phba;
1453 if (vport->disc_trc) {
1454 kfree(vport->disc_trc);
1455 vport->disc_trc = NULL;
1457 if (vport->debug_disc_trc) {
1458 debugfs_remove(vport->debug_disc_trc); /* discovery_trace */
1459 vport->debug_disc_trc = NULL;
1461 if (vport->debug_nodelist) {
1462 debugfs_remove(vport->debug_nodelist); /* nodelist */
1463 vport->debug_nodelist = NULL;
1466 if (vport->vport_debugfs_root) {
1467 debugfs_remove(vport->vport_debugfs_root); /* vportX */
1468 vport->vport_debugfs_root = NULL;
1469 atomic_dec(&phba->debugfs_vport_count);
1471 if (atomic_read(&phba->debugfs_vport_count) == 0) {
1473 if (phba->debug_hbqinfo) {
1474 debugfs_remove(phba->debug_hbqinfo); /* hbqinfo */
1475 phba->debug_hbqinfo = NULL;
1477 if (phba->debug_dumpHBASlim) {
1478 debugfs_remove(phba->debug_dumpHBASlim); /* HBASlim */
1479 phba->debug_dumpHBASlim = NULL;
1481 if (phba->debug_dumpHostSlim) {
1482 debugfs_remove(phba->debug_dumpHostSlim); /* HostSlim */
1483 phba->debug_dumpHostSlim = NULL;
1485 if (phba->debug_dumpData) {
1486 debugfs_remove(phba->debug_dumpData); /* dumpData */
1487 phba->debug_dumpData = NULL;
1490 if (phba->debug_dumpDif) {
1491 debugfs_remove(phba->debug_dumpDif); /* dumpDif */
1492 phba->debug_dumpDif = NULL;
1495 if (phba->slow_ring_trc) {
1496 kfree(phba->slow_ring_trc);
1497 phba->slow_ring_trc = NULL;
1499 if (phba->debug_slow_ring_trc) {
1500 /* slow_ring_trace */
1501 debugfs_remove(phba->debug_slow_ring_trc);
1502 phba->debug_slow_ring_trc = NULL;
1505 if (phba->hba_debugfs_root) {
1506 debugfs_remove(phba->hba_debugfs_root); /* lpfcX */
1507 phba->hba_debugfs_root = NULL;
1508 atomic_dec(&lpfc_debugfs_hba_count);
1511 if (atomic_read(&lpfc_debugfs_hba_count) == 0) {
1512 debugfs_remove(lpfc_debugfs_root); /* lpfc */
1513 lpfc_debugfs_root = NULL;