1 /*******************************************************************
2 * This file is part of the Emulex Linux Device Driver for *
3 * Fibre Channel Host Bus Adapters. *
4 * Copyright (C) 2007-2012 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/module.h>
24 #include <linux/dma-mapping.h>
25 #include <linux/idr.h>
26 #include <linux/interrupt.h>
27 #include <linux/kthread.h>
28 #include <linux/slab.h>
29 #include <linux/pci.h>
30 #include <linux/spinlock.h>
31 #include <linux/ctype.h>
33 #include <scsi/scsi.h>
34 #include <scsi/scsi_device.h>
35 #include <scsi/scsi_host.h>
36 #include <scsi/scsi_transport_fc.h>
41 #include "lpfc_sli4.h"
43 #include "lpfc_disc.h"
44 #include "lpfc_scsi.h"
46 #include "lpfc_logmsg.h"
47 #include "lpfc_crtn.h"
48 #include "lpfc_vport.h"
49 #include "lpfc_version.h"
50 #include "lpfc_compat.h"
51 #include "lpfc_debugfs.h"
54 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
58 * To access this interface the user should:
59 * # mount -t debugfs none /sys/kernel/debug
61 * The lpfc debugfs directory hierarchy is:
62 * /sys/kernel/debug/lpfc/fnX/vportY
63 * where X is the lpfc hba function unique_id
64 * where Y is the vport VPI on that hba
66 * Debugging services available per vport:
68 * This is an ACSII readable file that contains a trace of the last
69 * lpfc_debugfs_max_disc_trc events that happened on a specific vport.
70 * See lpfc_debugfs.h for different categories of discovery events.
71 * To enable the discovery trace, the following module parameters must be set:
72 * lpfc_debugfs_enable=1 Turns on lpfc debugfs filesystem support
73 * lpfc_debugfs_max_disc_trc=X Where X is the event trace depth for
74 * EACH vport. X MUST also be a power of 2.
75 * lpfc_debugfs_mask_disc_trc=Y Where Y is an event mask as defined in
79 * This is an ACSII readable file that contains a trace of the last
80 * lpfc_debugfs_max_slow_ring_trc events that happened on a specific HBA.
81 * To enable the slow ring trace, the following module parameters must be set:
82 * lpfc_debugfs_enable=1 Turns on lpfc debugfs filesystem support
83 * lpfc_debugfs_max_slow_ring_trc=X Where X is the event trace depth for
84 * the HBA. X MUST also be a power of 2.
86 static int lpfc_debugfs_enable
= 1;
87 module_param(lpfc_debugfs_enable
, int, S_IRUGO
);
88 MODULE_PARM_DESC(lpfc_debugfs_enable
, "Enable debugfs services");
90 /* This MUST be a power of 2 */
91 static int lpfc_debugfs_max_disc_trc
;
92 module_param(lpfc_debugfs_max_disc_trc
, int, S_IRUGO
);
93 MODULE_PARM_DESC(lpfc_debugfs_max_disc_trc
,
94 "Set debugfs discovery trace depth");
96 /* This MUST be a power of 2 */
97 static int lpfc_debugfs_max_slow_ring_trc
;
98 module_param(lpfc_debugfs_max_slow_ring_trc
, int, S_IRUGO
);
99 MODULE_PARM_DESC(lpfc_debugfs_max_slow_ring_trc
,
100 "Set debugfs slow ring trace depth");
102 static int lpfc_debugfs_mask_disc_trc
;
103 module_param(lpfc_debugfs_mask_disc_trc
, int, S_IRUGO
);
104 MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc
,
105 "Set debugfs discovery trace mask");
107 #include <linux/debugfs.h>
109 static atomic_t lpfc_debugfs_seq_trc_cnt
= ATOMIC_INIT(0);
110 static unsigned long lpfc_debugfs_start_time
= 0L;
113 static struct lpfc_idiag idiag
;
116 * lpfc_debugfs_disc_trc_data - Dump discovery logging to a buffer
117 * @vport: The vport to gather the log info from.
118 * @buf: The buffer to dump log into.
119 * @size: The maximum amount of data to process.
122 * This routine gathers the lpfc discovery debugfs data from the @vport and
123 * dumps it to @buf up to @size number of bytes. It will start at the next entry
124 * in the log and process the log until the end of the buffer. Then it will
125 * gather from the beginning of the log and process until the current entry.
128 * Discovery logging will be disabled while while this routine dumps the log.
131 * This routine returns the amount of bytes that were dumped into @buf and will
135 lpfc_debugfs_disc_trc_data(struct lpfc_vport
*vport
, char *buf
, int size
)
137 int i
, index
, len
, enable
;
139 struct lpfc_debugfs_trc
*dtp
;
142 buffer
= kmalloc(LPFC_DEBUG_TRC_ENTRY_SIZE
, GFP_KERNEL
);
146 enable
= lpfc_debugfs_enable
;
147 lpfc_debugfs_enable
= 0;
150 index
= (atomic_read(&vport
->disc_trc_cnt
) + 1) &
151 (lpfc_debugfs_max_disc_trc
- 1);
152 for (i
= index
; i
< lpfc_debugfs_max_disc_trc
; i
++) {
153 dtp
= vport
->disc_trc
+ i
;
156 ms
= jiffies_to_msecs(dtp
->jif
- lpfc_debugfs_start_time
);
158 LPFC_DEBUG_TRC_ENTRY_SIZE
, "%010d:%010d ms:%s\n",
159 dtp
->seq_cnt
, ms
, dtp
->fmt
);
160 len
+= snprintf(buf
+len
, size
-len
, buffer
,
161 dtp
->data1
, dtp
->data2
, dtp
->data3
);
163 for (i
= 0; i
< index
; i
++) {
164 dtp
= vport
->disc_trc
+ i
;
167 ms
= jiffies_to_msecs(dtp
->jif
- lpfc_debugfs_start_time
);
169 LPFC_DEBUG_TRC_ENTRY_SIZE
, "%010d:%010d ms:%s\n",
170 dtp
->seq_cnt
, ms
, dtp
->fmt
);
171 len
+= snprintf(buf
+len
, size
-len
, buffer
,
172 dtp
->data1
, dtp
->data2
, dtp
->data3
);
175 lpfc_debugfs_enable
= enable
;
182 * lpfc_debugfs_slow_ring_trc_data - Dump slow ring logging to a buffer
183 * @phba: The HBA to gather the log info from.
184 * @buf: The buffer to dump log into.
185 * @size: The maximum amount of data to process.
188 * This routine gathers the lpfc slow ring debugfs data from the @phba and
189 * dumps it to @buf up to @size number of bytes. It will start at the next entry
190 * in the log and process the log until the end of the buffer. Then it will
191 * gather from the beginning of the log and process until the current entry.
194 * Slow ring logging will be disabled while while this routine dumps the log.
197 * This routine returns the amount of bytes that were dumped into @buf and will
201 lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba
*phba
, char *buf
, int size
)
203 int i
, index
, len
, enable
;
205 struct lpfc_debugfs_trc
*dtp
;
208 buffer
= kmalloc(LPFC_DEBUG_TRC_ENTRY_SIZE
, GFP_KERNEL
);
212 enable
= lpfc_debugfs_enable
;
213 lpfc_debugfs_enable
= 0;
216 index
= (atomic_read(&phba
->slow_ring_trc_cnt
) + 1) &
217 (lpfc_debugfs_max_slow_ring_trc
- 1);
218 for (i
= index
; i
< lpfc_debugfs_max_slow_ring_trc
; i
++) {
219 dtp
= phba
->slow_ring_trc
+ i
;
222 ms
= jiffies_to_msecs(dtp
->jif
- lpfc_debugfs_start_time
);
224 LPFC_DEBUG_TRC_ENTRY_SIZE
, "%010d:%010d ms:%s\n",
225 dtp
->seq_cnt
, ms
, dtp
->fmt
);
226 len
+= snprintf(buf
+len
, size
-len
, buffer
,
227 dtp
->data1
, dtp
->data2
, dtp
->data3
);
229 for (i
= 0; i
< index
; i
++) {
230 dtp
= phba
->slow_ring_trc
+ i
;
233 ms
= jiffies_to_msecs(dtp
->jif
- lpfc_debugfs_start_time
);
235 LPFC_DEBUG_TRC_ENTRY_SIZE
, "%010d:%010d ms:%s\n",
236 dtp
->seq_cnt
, ms
, dtp
->fmt
);
237 len
+= snprintf(buf
+len
, size
-len
, buffer
,
238 dtp
->data1
, dtp
->data2
, dtp
->data3
);
241 lpfc_debugfs_enable
= enable
;
247 static int lpfc_debugfs_last_hbq
= -1;
250 * lpfc_debugfs_hbqinfo_data - Dump host buffer queue info to a buffer
251 * @phba: The HBA to gather host buffer info from.
252 * @buf: The buffer to dump log into.
253 * @size: The maximum amount of data to process.
256 * This routine dumps the host buffer queue info from the @phba to @buf up to
257 * @size number of bytes. A header that describes the current hbq state will be
258 * dumped to @buf first and then info on each hbq entry will be dumped to @buf
259 * until @size bytes have been dumped or all the hbq info has been dumped.
262 * This routine will rotate through each configured HBQ each time called.
265 * This routine returns the amount of bytes that were dumped into @buf and will
269 lpfc_debugfs_hbqinfo_data(struct lpfc_hba
*phba
, char *buf
, int size
)
272 int cnt
, i
, j
, found
, posted
, low
;
273 uint32_t phys
, raw_index
, getidx
;
274 struct lpfc_hbq_init
*hip
;
276 struct lpfc_hbq_entry
*hbqe
;
277 struct lpfc_dmabuf
*d_buf
;
278 struct hbq_dmabuf
*hbq_buf
;
280 if (phba
->sli_rev
!= 3)
282 cnt
= LPFC_HBQINFO_SIZE
;
283 spin_lock_irq(&phba
->hbalock
);
285 /* toggle between multiple hbqs, if any */
286 i
= lpfc_sli_hbq_count();
288 lpfc_debugfs_last_hbq
++;
289 if (lpfc_debugfs_last_hbq
>= i
)
290 lpfc_debugfs_last_hbq
= 0;
293 lpfc_debugfs_last_hbq
= 0;
295 i
= lpfc_debugfs_last_hbq
;
297 len
+= snprintf(buf
+len
, size
-len
, "HBQ %d Info\n", i
);
299 hbqs
= &phba
->hbqs
[i
];
301 list_for_each_entry(d_buf
, &hbqs
->hbq_buffer_list
, list
)
304 hip
= lpfc_hbq_defs
[i
];
305 len
+= snprintf(buf
+len
, size
-len
,
306 "idx:%d prof:%d rn:%d bufcnt:%d icnt:%d acnt:%d posted %d\n",
307 hip
->hbq_index
, hip
->profile
, hip
->rn
,
308 hip
->buffer_count
, hip
->init_count
, hip
->add_count
, posted
);
310 raw_index
= phba
->hbq_get
[i
];
311 getidx
= le32_to_cpu(raw_index
);
312 len
+= snprintf(buf
+len
, size
-len
,
313 "entrys:%d bufcnt:%d Put:%d nPut:%d localGet:%d hbaGet:%d\n",
314 hbqs
->entry_count
, hbqs
->buffer_count
, hbqs
->hbqPutIdx
,
315 hbqs
->next_hbqPutIdx
, hbqs
->local_hbqGetIdx
, getidx
);
317 hbqe
= (struct lpfc_hbq_entry
*) phba
->hbqs
[i
].hbq_virt
;
318 for (j
=0; j
<hbqs
->entry_count
; j
++) {
319 len
+= snprintf(buf
+len
, size
-len
,
320 "%03d: %08x %04x %05x ", j
,
321 le32_to_cpu(hbqe
->bde
.addrLow
),
322 le32_to_cpu(hbqe
->bde
.tus
.w
),
323 le32_to_cpu(hbqe
->buffer_tag
));
327 /* First calculate if slot has an associated posted buffer */
328 low
= hbqs
->hbqPutIdx
- posted
;
330 if ((j
>= hbqs
->hbqPutIdx
) || (j
< low
)) {
331 len
+= snprintf(buf
+len
, size
-len
, "Unused\n");
336 if ((j
>= hbqs
->hbqPutIdx
) &&
337 (j
< (hbqs
->entry_count
+low
))) {
338 len
+= snprintf(buf
+len
, size
-len
, "Unused\n");
343 /* Get the Buffer info for the posted buffer */
344 list_for_each_entry(d_buf
, &hbqs
->hbq_buffer_list
, list
) {
345 hbq_buf
= container_of(d_buf
, struct hbq_dmabuf
, dbuf
);
346 phys
= ((uint64_t)hbq_buf
->dbuf
.phys
& 0xffffffff);
347 if (phys
== le32_to_cpu(hbqe
->bde
.addrLow
)) {
348 len
+= snprintf(buf
+len
, size
-len
,
349 "Buf%d: %p %06x\n", i
,
350 hbq_buf
->dbuf
.virt
, hbq_buf
->tag
);
357 len
+= snprintf(buf
+len
, size
-len
, "No DMAinfo?\n");
361 if (len
> LPFC_HBQINFO_SIZE
- 54)
364 spin_unlock_irq(&phba
->hbalock
);
368 static int lpfc_debugfs_last_hba_slim_off
;
371 * lpfc_debugfs_dumpHBASlim_data - Dump HBA SLIM info to a buffer
372 * @phba: The HBA to gather SLIM info from.
373 * @buf: The buffer to dump log into.
374 * @size: The maximum amount of data to process.
377 * This routine dumps the current contents of HBA SLIM for the HBA associated
378 * with @phba to @buf up to @size bytes of data. This is the raw HBA SLIM data.
381 * This routine will only dump up to 1024 bytes of data each time called and
382 * should be called multiple times to dump the entire HBA SLIM.
385 * This routine returns the amount of bytes that were dumped into @buf and will
389 lpfc_debugfs_dumpHBASlim_data(struct lpfc_hba
*phba
, char *buf
, int size
)
396 buffer
= kmalloc(1024, GFP_KERNEL
);
401 spin_lock_irq(&phba
->hbalock
);
403 len
+= snprintf(buf
+len
, size
-len
, "HBA SLIM\n");
404 lpfc_memcpy_from_slim(buffer
,
405 phba
->MBslimaddr
+ lpfc_debugfs_last_hba_slim_off
, 1024);
407 ptr
= (uint32_t *)&buffer
[0];
408 off
= lpfc_debugfs_last_hba_slim_off
;
410 /* Set it up for the next time */
411 lpfc_debugfs_last_hba_slim_off
+= 1024;
412 if (lpfc_debugfs_last_hba_slim_off
>= 4096)
413 lpfc_debugfs_last_hba_slim_off
= 0;
417 len
+= snprintf(buf
+len
, size
-len
,
418 "%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n",
419 off
, *ptr
, *(ptr
+1), *(ptr
+2), *(ptr
+3), *(ptr
+4),
420 *(ptr
+5), *(ptr
+6), *(ptr
+7));
422 i
-= (8 * sizeof(uint32_t));
423 off
+= (8 * sizeof(uint32_t));
426 spin_unlock_irq(&phba
->hbalock
);
433 * lpfc_debugfs_dumpHostSlim_data - Dump host SLIM info to a buffer
434 * @phba: The HBA to gather Host SLIM info from.
435 * @buf: The buffer to dump log into.
436 * @size: The maximum amount of data to process.
439 * This routine dumps the current contents of host SLIM for the host associated
440 * with @phba to @buf up to @size bytes of data. The dump will contain the
441 * Mailbox, PCB, Rings, and Registers that are located in host memory.
444 * This routine returns the amount of bytes that were dumped into @buf and will
448 lpfc_debugfs_dumpHostSlim_data(struct lpfc_hba
*phba
, char *buf
, int size
)
452 uint32_t word0
, word1
, word2
, word3
;
454 struct lpfc_pgp
*pgpp
;
455 struct lpfc_sli
*psli
= &phba
->sli
;
456 struct lpfc_sli_ring
*pring
;
459 spin_lock_irq(&phba
->hbalock
);
461 len
+= snprintf(buf
+len
, size
-len
, "SLIM Mailbox\n");
462 ptr
= (uint32_t *)phba
->slim2p
.virt
;
463 i
= sizeof(MAILBOX_t
);
465 len
+= snprintf(buf
+len
, size
-len
,
466 "%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n",
467 off
, *ptr
, *(ptr
+1), *(ptr
+2), *(ptr
+3), *(ptr
+4),
468 *(ptr
+5), *(ptr
+6), *(ptr
+7));
470 i
-= (8 * sizeof(uint32_t));
471 off
+= (8 * sizeof(uint32_t));
474 len
+= snprintf(buf
+len
, size
-len
, "SLIM PCB\n");
475 ptr
= (uint32_t *)phba
->pcb
;
478 len
+= snprintf(buf
+len
, size
-len
,
479 "%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n",
480 off
, *ptr
, *(ptr
+1), *(ptr
+2), *(ptr
+3), *(ptr
+4),
481 *(ptr
+5), *(ptr
+6), *(ptr
+7));
483 i
-= (8 * sizeof(uint32_t));
484 off
+= (8 * sizeof(uint32_t));
487 for (i
= 0; i
< 4; i
++) {
488 pgpp
= &phba
->port_gp
[i
];
489 pring
= &psli
->ring
[i
];
490 len
+= snprintf(buf
+len
, size
-len
,
491 "Ring %d: CMD GetInx:%d (Max:%d Next:%d "
492 "Local:%d flg:x%x) RSP PutInx:%d Max:%d\n",
493 i
, pgpp
->cmdGetInx
, pring
->sli
.sli3
.numCiocb
,
494 pring
->sli
.sli3
.next_cmdidx
,
495 pring
->sli
.sli3
.local_getidx
,
496 pring
->flag
, pgpp
->rspPutInx
,
497 pring
->sli
.sli3
.numRiocb
);
500 if (phba
->sli_rev
<= LPFC_SLI_REV3
) {
501 word0
= readl(phba
->HAregaddr
);
502 word1
= readl(phba
->CAregaddr
);
503 word2
= readl(phba
->HSregaddr
);
504 word3
= readl(phba
->HCregaddr
);
505 len
+= snprintf(buf
+len
, size
-len
, "HA:%08x CA:%08x HS:%08x "
506 "HC:%08x\n", word0
, word1
, word2
, word3
);
508 spin_unlock_irq(&phba
->hbalock
);
513 * lpfc_debugfs_nodelist_data - Dump target node list to a buffer
514 * @vport: The vport to gather target node info from.
515 * @buf: The buffer to dump log into.
516 * @size: The maximum amount of data to process.
519 * This routine dumps the current target node list associated with @vport to
520 * @buf up to @size bytes of data. Each node entry in the dump will contain a
521 * node state, DID, WWPN, WWNN, RPI, flags, type, and other useful fields.
524 * This routine returns the amount of bytes that were dumped into @buf and will
528 lpfc_debugfs_nodelist_data(struct lpfc_vport
*vport
, char *buf
, int size
)
532 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
533 struct lpfc_nodelist
*ndlp
;
534 unsigned char *statep
, *name
;
536 cnt
= (LPFC_NODELIST_SIZE
/ LPFC_NODELIST_ENTRY_SIZE
);
538 spin_lock_irq(shost
->host_lock
);
539 list_for_each_entry(ndlp
, &vport
->fc_nodes
, nlp_listp
) {
541 len
+= snprintf(buf
+len
, size
-len
,
542 "Missing Nodelist Entries\n");
546 switch (ndlp
->nlp_state
) {
547 case NLP_STE_UNUSED_NODE
:
550 case NLP_STE_PLOGI_ISSUE
:
553 case NLP_STE_ADISC_ISSUE
:
556 case NLP_STE_REG_LOGIN_ISSUE
:
559 case NLP_STE_PRLI_ISSUE
:
562 case NLP_STE_LOGO_ISSUE
:
565 case NLP_STE_UNMAPPED_NODE
:
568 case NLP_STE_MAPPED_NODE
:
571 case NLP_STE_NPR_NODE
:
577 len
+= snprintf(buf
+len
, size
-len
, "%s DID:x%06x ",
578 statep
, ndlp
->nlp_DID
);
579 name
= (unsigned char *)&ndlp
->nlp_portname
;
580 len
+= snprintf(buf
+len
, size
-len
,
581 "WWPN %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x ",
582 *name
, *(name
+1), *(name
+2), *(name
+3),
583 *(name
+4), *(name
+5), *(name
+6), *(name
+7));
584 name
= (unsigned char *)&ndlp
->nlp_nodename
;
585 len
+= snprintf(buf
+len
, size
-len
,
586 "WWNN %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x ",
587 *name
, *(name
+1), *(name
+2), *(name
+3),
588 *(name
+4), *(name
+5), *(name
+6), *(name
+7));
589 if (ndlp
->nlp_flag
& NLP_RPI_REGISTERED
)
590 len
+= snprintf(buf
+len
, size
-len
, "RPI:%03d ",
593 len
+= snprintf(buf
+len
, size
-len
, "RPI:none ");
594 len
+= snprintf(buf
+len
, size
-len
, "flag:x%08x ",
597 len
+= snprintf(buf
+len
, size
-len
, "UNKNOWN_TYPE ");
598 if (ndlp
->nlp_type
& NLP_FC_NODE
)
599 len
+= snprintf(buf
+len
, size
-len
, "FC_NODE ");
600 if (ndlp
->nlp_type
& NLP_FABRIC
)
601 len
+= snprintf(buf
+len
, size
-len
, "FABRIC ");
602 if (ndlp
->nlp_type
& NLP_FCP_TARGET
)
603 len
+= snprintf(buf
+len
, size
-len
, "FCP_TGT sid:%d ",
605 if (ndlp
->nlp_type
& NLP_FCP_INITIATOR
)
606 len
+= snprintf(buf
+len
, size
-len
, "FCP_INITIATOR ");
607 len
+= snprintf(buf
+len
, size
-len
, "usgmap:%x ",
609 len
+= snprintf(buf
+len
, size
-len
, "refcnt:%x",
610 atomic_read(&ndlp
->kref
.refcount
));
611 len
+= snprintf(buf
+len
, size
-len
, "\n");
613 spin_unlock_irq(shost
->host_lock
);
619 * lpfc_debugfs_disc_trc - Store discovery trace log
620 * @vport: The vport to associate this trace string with for retrieval.
621 * @mask: Log entry classification.
622 * @fmt: Format string to be displayed when dumping the log.
623 * @data1: 1st data parameter to be applied to @fmt.
624 * @data2: 2nd data parameter to be applied to @fmt.
625 * @data3: 3rd data parameter to be applied to @fmt.
628 * This routine is used by the driver code to add a debugfs log entry to the
629 * discovery trace buffer associated with @vport. Only entries with a @mask that
630 * match the current debugfs discovery mask will be saved. Entries that do not
631 * match will be thrown away. @fmt, @data1, @data2, and @data3 are used like
632 * printf when displaying the log.
635 lpfc_debugfs_disc_trc(struct lpfc_vport
*vport
, int mask
, char *fmt
,
636 uint32_t data1
, uint32_t data2
, uint32_t data3
)
638 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
639 struct lpfc_debugfs_trc
*dtp
;
642 if (!(lpfc_debugfs_mask_disc_trc
& mask
))
645 if (!lpfc_debugfs_enable
|| !lpfc_debugfs_max_disc_trc
||
646 !vport
|| !vport
->disc_trc
)
649 index
= atomic_inc_return(&vport
->disc_trc_cnt
) &
650 (lpfc_debugfs_max_disc_trc
- 1);
651 dtp
= vport
->disc_trc
+ index
;
656 dtp
->seq_cnt
= atomic_inc_return(&lpfc_debugfs_seq_trc_cnt
);
663 * lpfc_debugfs_slow_ring_trc - Store slow ring trace log
664 * @phba: The phba to associate this trace string with for retrieval.
665 * @fmt: Format string to be displayed when dumping the log.
666 * @data1: 1st data parameter to be applied to @fmt.
667 * @data2: 2nd data parameter to be applied to @fmt.
668 * @data3: 3rd data parameter to be applied to @fmt.
671 * This routine is used by the driver code to add a debugfs log entry to the
672 * discovery trace buffer associated with @vport. @fmt, @data1, @data2, and
673 * @data3 are used like printf when displaying the log.
676 lpfc_debugfs_slow_ring_trc(struct lpfc_hba
*phba
, char *fmt
,
677 uint32_t data1
, uint32_t data2
, uint32_t data3
)
679 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
680 struct lpfc_debugfs_trc
*dtp
;
683 if (!lpfc_debugfs_enable
|| !lpfc_debugfs_max_slow_ring_trc
||
684 !phba
|| !phba
->slow_ring_trc
)
687 index
= atomic_inc_return(&phba
->slow_ring_trc_cnt
) &
688 (lpfc_debugfs_max_slow_ring_trc
- 1);
689 dtp
= phba
->slow_ring_trc
+ index
;
694 dtp
->seq_cnt
= atomic_inc_return(&lpfc_debugfs_seq_trc_cnt
);
700 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
702 * lpfc_debugfs_disc_trc_open - Open the discovery trace log
703 * @inode: The inode pointer that contains a vport pointer.
704 * @file: The file pointer to attach the log output.
707 * This routine is the entry point for the debugfs open file operation. It gets
708 * the vport from the i_private field in @inode, allocates the necessary buffer
709 * for the log, fills the buffer from the in-memory log for this vport, and then
710 * returns a pointer to that log in the private_data field in @file.
713 * This function returns zero if successful. On error it will return an negative
717 lpfc_debugfs_disc_trc_open(struct inode
*inode
, struct file
*file
)
719 struct lpfc_vport
*vport
= inode
->i_private
;
720 struct lpfc_debug
*debug
;
724 if (!lpfc_debugfs_max_disc_trc
) {
729 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
733 /* Round to page boundary */
734 size
= (lpfc_debugfs_max_disc_trc
* LPFC_DEBUG_TRC_ENTRY_SIZE
);
735 size
= PAGE_ALIGN(size
);
737 debug
->buffer
= kmalloc(size
, GFP_KERNEL
);
738 if (!debug
->buffer
) {
743 debug
->len
= lpfc_debugfs_disc_trc_data(vport
, debug
->buffer
, size
);
744 file
->private_data
= debug
;
752 * lpfc_debugfs_slow_ring_trc_open - Open the Slow Ring trace log
753 * @inode: The inode pointer that contains a vport pointer.
754 * @file: The file pointer to attach the log output.
757 * This routine is the entry point for the debugfs open file operation. It gets
758 * the vport from the i_private field in @inode, allocates the necessary buffer
759 * for the log, fills the buffer from the in-memory log for this vport, and then
760 * returns a pointer to that log in the private_data field in @file.
763 * This function returns zero if successful. On error it will return an negative
767 lpfc_debugfs_slow_ring_trc_open(struct inode
*inode
, struct file
*file
)
769 struct lpfc_hba
*phba
= inode
->i_private
;
770 struct lpfc_debug
*debug
;
774 if (!lpfc_debugfs_max_slow_ring_trc
) {
779 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
783 /* Round to page boundary */
784 size
= (lpfc_debugfs_max_slow_ring_trc
* LPFC_DEBUG_TRC_ENTRY_SIZE
);
785 size
= PAGE_ALIGN(size
);
787 debug
->buffer
= kmalloc(size
, GFP_KERNEL
);
788 if (!debug
->buffer
) {
793 debug
->len
= lpfc_debugfs_slow_ring_trc_data(phba
, debug
->buffer
, size
);
794 file
->private_data
= debug
;
802 * lpfc_debugfs_hbqinfo_open - Open the hbqinfo debugfs buffer
803 * @inode: The inode pointer that contains a vport pointer.
804 * @file: The file pointer to attach the log output.
807 * This routine is the entry point for the debugfs open file operation. It gets
808 * the vport from the i_private field in @inode, allocates the necessary buffer
809 * for the log, fills the buffer from the in-memory log for this vport, and then
810 * returns a pointer to that log in the private_data field in @file.
813 * This function returns zero if successful. On error it will return an negative
817 lpfc_debugfs_hbqinfo_open(struct inode
*inode
, struct file
*file
)
819 struct lpfc_hba
*phba
= inode
->i_private
;
820 struct lpfc_debug
*debug
;
823 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
827 /* Round to page boundary */
828 debug
->buffer
= kmalloc(LPFC_HBQINFO_SIZE
, GFP_KERNEL
);
829 if (!debug
->buffer
) {
834 debug
->len
= lpfc_debugfs_hbqinfo_data(phba
, debug
->buffer
,
836 file
->private_data
= debug
;
844 * lpfc_debugfs_dumpHBASlim_open - Open the Dump HBA SLIM debugfs buffer
845 * @inode: The inode pointer that contains a vport pointer.
846 * @file: The file pointer to attach the log output.
849 * This routine is the entry point for the debugfs open file operation. It gets
850 * the vport from the i_private field in @inode, allocates the necessary buffer
851 * for the log, fills the buffer from the in-memory log for this vport, and then
852 * returns a pointer to that log in the private_data field in @file.
855 * This function returns zero if successful. On error it will return an negative
859 lpfc_debugfs_dumpHBASlim_open(struct inode
*inode
, struct file
*file
)
861 struct lpfc_hba
*phba
= inode
->i_private
;
862 struct lpfc_debug
*debug
;
865 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
869 /* Round to page boundary */
870 debug
->buffer
= kmalloc(LPFC_DUMPHBASLIM_SIZE
, GFP_KERNEL
);
871 if (!debug
->buffer
) {
876 debug
->len
= lpfc_debugfs_dumpHBASlim_data(phba
, debug
->buffer
,
877 LPFC_DUMPHBASLIM_SIZE
);
878 file
->private_data
= debug
;
886 * lpfc_debugfs_dumpHostSlim_open - Open the Dump Host SLIM debugfs buffer
887 * @inode: The inode pointer that contains a vport pointer.
888 * @file: The file pointer to attach the log output.
891 * This routine is the entry point for the debugfs open file operation. It gets
892 * the vport from the i_private field in @inode, allocates the necessary buffer
893 * for the log, fills the buffer from the in-memory log for this vport, and then
894 * returns a pointer to that log in the private_data field in @file.
897 * This function returns zero if successful. On error it will return an negative
901 lpfc_debugfs_dumpHostSlim_open(struct inode
*inode
, struct file
*file
)
903 struct lpfc_hba
*phba
= inode
->i_private
;
904 struct lpfc_debug
*debug
;
907 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
911 /* Round to page boundary */
912 debug
->buffer
= kmalloc(LPFC_DUMPHOSTSLIM_SIZE
, GFP_KERNEL
);
913 if (!debug
->buffer
) {
918 debug
->len
= lpfc_debugfs_dumpHostSlim_data(phba
, debug
->buffer
,
919 LPFC_DUMPHOSTSLIM_SIZE
);
920 file
->private_data
= debug
;
928 lpfc_debugfs_dumpData_open(struct inode
*inode
, struct file
*file
)
930 struct lpfc_debug
*debug
;
936 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
940 /* Round to page boundary */
941 printk(KERN_ERR
"9059 BLKGRD: %s: _dump_buf_data=0x%p\n",
942 __func__
, _dump_buf_data
);
943 debug
->buffer
= _dump_buf_data
;
944 if (!debug
->buffer
) {
949 debug
->len
= (1 << _dump_buf_data_order
) << PAGE_SHIFT
;
950 file
->private_data
= debug
;
958 lpfc_debugfs_dumpDif_open(struct inode
*inode
, struct file
*file
)
960 struct lpfc_debug
*debug
;
966 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
970 /* Round to page boundary */
971 printk(KERN_ERR
"9060 BLKGRD: %s: _dump_buf_dif=0x%p file=%s\n",
972 __func__
, _dump_buf_dif
, file
->f_dentry
->d_name
.name
);
973 debug
->buffer
= _dump_buf_dif
;
974 if (!debug
->buffer
) {
979 debug
->len
= (1 << _dump_buf_dif_order
) << PAGE_SHIFT
;
980 file
->private_data
= debug
;
988 lpfc_debugfs_dumpDataDif_write(struct file
*file
, const char __user
*buf
,
989 size_t nbytes
, loff_t
*ppos
)
992 * The Data/DIF buffers only save one failing IO
993 * The write op is used as a reset mechanism after an IO has
994 * already been saved to the next one can be saved
996 spin_lock(&_dump_buf_lock
);
998 memset((void *)_dump_buf_data
, 0,
999 ((1 << PAGE_SHIFT
) << _dump_buf_data_order
));
1000 memset((void *)_dump_buf_dif
, 0,
1001 ((1 << PAGE_SHIFT
) << _dump_buf_dif_order
));
1005 spin_unlock(&_dump_buf_lock
);
1011 lpfc_debugfs_dif_err_read(struct file
*file
, char __user
*buf
,
1012 size_t nbytes
, loff_t
*ppos
)
1014 struct dentry
*dent
= file
->f_dentry
;
1015 struct lpfc_hba
*phba
= file
->private_data
;
1020 if (dent
== phba
->debug_writeGuard
)
1021 cnt
= snprintf(cbuf
, 32, "%u\n", phba
->lpfc_injerr_wgrd_cnt
);
1022 else if (dent
== phba
->debug_writeApp
)
1023 cnt
= snprintf(cbuf
, 32, "%u\n", phba
->lpfc_injerr_wapp_cnt
);
1024 else if (dent
== phba
->debug_writeRef
)
1025 cnt
= snprintf(cbuf
, 32, "%u\n", phba
->lpfc_injerr_wref_cnt
);
1026 else if (dent
== phba
->debug_readGuard
)
1027 cnt
= snprintf(cbuf
, 32, "%u\n", phba
->lpfc_injerr_rgrd_cnt
);
1028 else if (dent
== phba
->debug_readApp
)
1029 cnt
= snprintf(cbuf
, 32, "%u\n", phba
->lpfc_injerr_rapp_cnt
);
1030 else if (dent
== phba
->debug_readRef
)
1031 cnt
= snprintf(cbuf
, 32, "%u\n", phba
->lpfc_injerr_rref_cnt
);
1032 else if (dent
== phba
->debug_InjErrNPortID
)
1033 cnt
= snprintf(cbuf
, 32, "0x%06x\n", phba
->lpfc_injerr_nportid
);
1034 else if (dent
== phba
->debug_InjErrWWPN
) {
1035 memcpy(&tmp
, &phba
->lpfc_injerr_wwpn
, sizeof(struct lpfc_name
));
1036 tmp
= cpu_to_be64(tmp
);
1037 cnt
= snprintf(cbuf
, 32, "0x%016llx\n", tmp
);
1038 } else if (dent
== phba
->debug_InjErrLBA
) {
1039 if (phba
->lpfc_injerr_lba
== (sector_t
)(-1))
1040 cnt
= snprintf(cbuf
, 32, "off\n");
1042 cnt
= snprintf(cbuf
, 32, "0x%llx\n",
1043 (uint64_t) phba
->lpfc_injerr_lba
);
1045 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
1046 "0547 Unknown debugfs error injection entry\n");
1048 return simple_read_from_buffer(buf
, nbytes
, ppos
, &cbuf
, cnt
);
1052 lpfc_debugfs_dif_err_write(struct file
*file
, const char __user
*buf
,
1053 size_t nbytes
, loff_t
*ppos
)
1055 struct dentry
*dent
= file
->f_dentry
;
1056 struct lpfc_hba
*phba
= file
->private_data
;
1061 memset(dstbuf
, 0, 32);
1062 size
= (nbytes
< 32) ? nbytes
: 32;
1063 if (copy_from_user(dstbuf
, buf
, size
))
1066 if (dent
== phba
->debug_InjErrLBA
) {
1067 if ((buf
[0] == 'o') && (buf
[1] == 'f') && (buf
[2] == 'f'))
1068 tmp
= (uint64_t)(-1);
1071 if ((tmp
== 0) && (kstrtoull(dstbuf
, 0, &tmp
)))
1074 if (dent
== phba
->debug_writeGuard
)
1075 phba
->lpfc_injerr_wgrd_cnt
= (uint32_t)tmp
;
1076 else if (dent
== phba
->debug_writeApp
)
1077 phba
->lpfc_injerr_wapp_cnt
= (uint32_t)tmp
;
1078 else if (dent
== phba
->debug_writeRef
)
1079 phba
->lpfc_injerr_wref_cnt
= (uint32_t)tmp
;
1080 else if (dent
== phba
->debug_readGuard
)
1081 phba
->lpfc_injerr_rgrd_cnt
= (uint32_t)tmp
;
1082 else if (dent
== phba
->debug_readApp
)
1083 phba
->lpfc_injerr_rapp_cnt
= (uint32_t)tmp
;
1084 else if (dent
== phba
->debug_readRef
)
1085 phba
->lpfc_injerr_rref_cnt
= (uint32_t)tmp
;
1086 else if (dent
== phba
->debug_InjErrLBA
)
1087 phba
->lpfc_injerr_lba
= (sector_t
)tmp
;
1088 else if (dent
== phba
->debug_InjErrNPortID
)
1089 phba
->lpfc_injerr_nportid
= (uint32_t)(tmp
& Mask_DID
);
1090 else if (dent
== phba
->debug_InjErrWWPN
) {
1091 tmp
= cpu_to_be64(tmp
);
1092 memcpy(&phba
->lpfc_injerr_wwpn
, &tmp
, sizeof(struct lpfc_name
));
1094 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
1095 "0548 Unknown debugfs error injection entry\n");
1101 lpfc_debugfs_dif_err_release(struct inode
*inode
, struct file
*file
)
1107 * lpfc_debugfs_nodelist_open - Open the nodelist debugfs file
1108 * @inode: The inode pointer that contains a vport pointer.
1109 * @file: The file pointer to attach the log output.
1112 * This routine is the entry point for the debugfs open file operation. It gets
1113 * the vport from the i_private field in @inode, allocates the necessary buffer
1114 * for the log, fills the buffer from the in-memory log for this vport, and then
1115 * returns a pointer to that log in the private_data field in @file.
1118 * This function returns zero if successful. On error it will return an negative
1122 lpfc_debugfs_nodelist_open(struct inode
*inode
, struct file
*file
)
1124 struct lpfc_vport
*vport
= inode
->i_private
;
1125 struct lpfc_debug
*debug
;
1128 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
1132 /* Round to page boundary */
1133 debug
->buffer
= kmalloc(LPFC_NODELIST_SIZE
, GFP_KERNEL
);
1134 if (!debug
->buffer
) {
1139 debug
->len
= lpfc_debugfs_nodelist_data(vport
, debug
->buffer
,
1140 LPFC_NODELIST_SIZE
);
1141 file
->private_data
= debug
;
1149 * lpfc_debugfs_lseek - Seek through a debugfs file
1150 * @file: The file pointer to seek through.
1151 * @off: The offset to seek to or the amount to seek by.
1152 * @whence: Indicates how to seek.
1155 * This routine is the entry point for the debugfs lseek file operation. The
1156 * @whence parameter indicates whether @off is the offset to directly seek to,
1157 * or if it is a value to seek forward or reverse by. This function figures out
1158 * what the new offset of the debugfs file will be and assigns that value to the
1159 * f_pos field of @file.
1162 * This function returns the new offset if successful and returns a negative
1163 * error if unable to process the seek.
1166 lpfc_debugfs_lseek(struct file
*file
, loff_t off
, int whence
)
1168 struct lpfc_debug
*debug
= file
->private_data
;
1169 return fixed_size_llseek(file
, off
, whence
, debug
->len
);
1173 * lpfc_debugfs_read - Read a debugfs file
1174 * @file: The file pointer to read from.
1175 * @buf: The buffer to copy the data to.
1176 * @nbytes: The number of bytes to read.
1177 * @ppos: The position in the file to start reading from.
1180 * This routine reads data from from the buffer indicated in the private_data
1181 * field of @file. It will start reading at @ppos and copy up to @nbytes of
1185 * This function returns the amount of data that was read (this could be less
1186 * than @nbytes if the end of the file was reached) or a negative error value.
1189 lpfc_debugfs_read(struct file
*file
, char __user
*buf
,
1190 size_t nbytes
, loff_t
*ppos
)
1192 struct lpfc_debug
*debug
= file
->private_data
;
1194 return simple_read_from_buffer(buf
, nbytes
, ppos
, debug
->buffer
,
1199 * lpfc_debugfs_release - Release the buffer used to store debugfs file data
1200 * @inode: The inode pointer that contains a vport pointer. (unused)
1201 * @file: The file pointer that contains the buffer to release.
1204 * This routine frees the buffer that was allocated when the debugfs file was
1208 * This function returns zero.
1211 lpfc_debugfs_release(struct inode
*inode
, struct file
*file
)
1213 struct lpfc_debug
*debug
= file
->private_data
;
1215 kfree(debug
->buffer
);
1222 lpfc_debugfs_dumpDataDif_release(struct inode
*inode
, struct file
*file
)
1224 struct lpfc_debug
*debug
= file
->private_data
;
1226 debug
->buffer
= NULL
;
1233 * ---------------------------------
1234 * iDiag debugfs file access methods
1235 * ---------------------------------
1237 * All access methods are through the proper SLI4 PCI function's debugfs
1240 * /sys/kernel/debug/lpfc/fn<#>/iDiag
1244 * lpfc_idiag_cmd_get - Get and parse idiag debugfs comands from user space
1245 * @buf: The pointer to the user space buffer.
1246 * @nbytes: The number of bytes in the user space buffer.
1247 * @idiag_cmd: pointer to the idiag command struct.
1249 * This routine reads data from debugfs user space buffer and parses the
1250 * buffer for getting the idiag command and arguments. The while space in
1251 * between the set of data is used as the parsing separator.
1253 * This routine returns 0 when successful, it returns proper error code
1254 * back to the user space in error conditions.
1256 static int lpfc_idiag_cmd_get(const char __user
*buf
, size_t nbytes
,
1257 struct lpfc_idiag_cmd
*idiag_cmd
)
1260 char *pbuf
, *step_str
;
1264 /* Protect copy from user */
1265 if (!access_ok(VERIFY_READ
, buf
, nbytes
))
1268 memset(mybuf
, 0, sizeof(mybuf
));
1269 memset(idiag_cmd
, 0, sizeof(*idiag_cmd
));
1270 bsize
= min(nbytes
, (sizeof(mybuf
)-1));
1272 if (copy_from_user(mybuf
, buf
, bsize
))
1275 step_str
= strsep(&pbuf
, "\t ");
1277 /* The opcode must present */
1281 idiag_cmd
->opcode
= simple_strtol(step_str
, NULL
, 0);
1282 if (idiag_cmd
->opcode
== 0)
1285 for (i
= 0; i
< LPFC_IDIAG_CMD_DATA_SIZE
; i
++) {
1286 step_str
= strsep(&pbuf
, "\t ");
1289 idiag_cmd
->data
[i
] = simple_strtol(step_str
, NULL
, 0);
1295 * lpfc_idiag_open - idiag open debugfs
1296 * @inode: The inode pointer that contains a pointer to phba.
1297 * @file: The file pointer to attach the file operation.
1300 * This routine is the entry point for the debugfs open file operation. It
1301 * gets the reference to phba from the i_private field in @inode, it then
1302 * allocates buffer for the file operation, performs the necessary PCI config
1303 * space read into the allocated buffer according to the idiag user command
1304 * setup, and then returns a pointer to buffer in the private_data field in
1308 * This function returns zero if successful. On error it will return an
1309 * negative error value.
1312 lpfc_idiag_open(struct inode
*inode
, struct file
*file
)
1314 struct lpfc_debug
*debug
;
1316 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
1320 debug
->i_private
= inode
->i_private
;
1321 debug
->buffer
= NULL
;
1322 file
->private_data
= debug
;
1328 * lpfc_idiag_release - Release idiag access file operation
1329 * @inode: The inode pointer that contains a vport pointer. (unused)
1330 * @file: The file pointer that contains the buffer to release.
1333 * This routine is the generic release routine for the idiag access file
1334 * operation, it frees the buffer that was allocated when the debugfs file
1338 * This function returns zero.
1341 lpfc_idiag_release(struct inode
*inode
, struct file
*file
)
1343 struct lpfc_debug
*debug
= file
->private_data
;
1345 /* Free the buffers to the file operation */
1346 kfree(debug
->buffer
);
1353 * lpfc_idiag_cmd_release - Release idiag cmd access file operation
1354 * @inode: The inode pointer that contains a vport pointer. (unused)
1355 * @file: The file pointer that contains the buffer to release.
1358 * This routine frees the buffer that was allocated when the debugfs file
1359 * was opened. It also reset the fields in the idiag command struct in the
1360 * case of command for write operation.
1363 * This function returns zero.
1366 lpfc_idiag_cmd_release(struct inode
*inode
, struct file
*file
)
1368 struct lpfc_debug
*debug
= file
->private_data
;
1370 if (debug
->op
== LPFC_IDIAG_OP_WR
) {
1371 switch (idiag
.cmd
.opcode
) {
1372 case LPFC_IDIAG_CMD_PCICFG_WR
:
1373 case LPFC_IDIAG_CMD_PCICFG_ST
:
1374 case LPFC_IDIAG_CMD_PCICFG_CL
:
1375 case LPFC_IDIAG_CMD_QUEACC_WR
:
1376 case LPFC_IDIAG_CMD_QUEACC_ST
:
1377 case LPFC_IDIAG_CMD_QUEACC_CL
:
1378 memset(&idiag
, 0, sizeof(idiag
));
1385 /* Free the buffers to the file operation */
1386 kfree(debug
->buffer
);
1393 * lpfc_idiag_pcicfg_read - idiag debugfs read pcicfg
1394 * @file: The file pointer to read from.
1395 * @buf: The buffer to copy the data to.
1396 * @nbytes: The number of bytes to read.
1397 * @ppos: The position in the file to start reading from.
1400 * This routine reads data from the @phba pci config space according to the
1401 * idiag command, and copies to user @buf. Depending on the PCI config space
1402 * read command setup, it does either a single register read of a byte
1403 * (8 bits), a word (16 bits), or a dword (32 bits) or browsing through all
1404 * registers from the 4K extended PCI config space.
1407 * This function returns the amount of data that was read (this could be less
1408 * than @nbytes if the end of the file was reached) or a negative error value.
1411 lpfc_idiag_pcicfg_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
1414 struct lpfc_debug
*debug
= file
->private_data
;
1415 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
1416 int offset_label
, offset
, len
= 0, index
= LPFC_PCI_CFG_RD_SIZE
;
1419 struct pci_dev
*pdev
;
1424 pdev
= phba
->pcidev
;
1428 /* This is a user read operation */
1429 debug
->op
= LPFC_IDIAG_OP_RD
;
1432 debug
->buffer
= kmalloc(LPFC_PCI_CFG_SIZE
, GFP_KERNEL
);
1435 pbuffer
= debug
->buffer
;
1440 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_RD
) {
1441 where
= idiag
.cmd
.data
[IDIAG_PCICFG_WHERE_INDX
];
1442 count
= idiag
.cmd
.data
[IDIAG_PCICFG_COUNT_INDX
];
1446 /* Read single PCI config space register */
1448 case SIZE_U8
: /* byte (8 bits) */
1449 pci_read_config_byte(pdev
, where
, &u8val
);
1450 len
+= snprintf(pbuffer
+len
, LPFC_PCI_CFG_SIZE
-len
,
1451 "%03x: %02x\n", where
, u8val
);
1453 case SIZE_U16
: /* word (16 bits) */
1454 pci_read_config_word(pdev
, where
, &u16val
);
1455 len
+= snprintf(pbuffer
+len
, LPFC_PCI_CFG_SIZE
-len
,
1456 "%03x: %04x\n", where
, u16val
);
1458 case SIZE_U32
: /* double word (32 bits) */
1459 pci_read_config_dword(pdev
, where
, &u32val
);
1460 len
+= snprintf(pbuffer
+len
, LPFC_PCI_CFG_SIZE
-len
,
1461 "%03x: %08x\n", where
, u32val
);
1463 case LPFC_PCI_CFG_BROWSE
: /* browse all */
1471 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
1475 /* Browse all PCI config space registers */
1476 offset_label
= idiag
.offset
.last_rd
;
1477 offset
= offset_label
;
1479 /* Read PCI config space */
1480 len
+= snprintf(pbuffer
+len
, LPFC_PCI_CFG_SIZE
-len
,
1481 "%03x: ", offset_label
);
1483 pci_read_config_dword(pdev
, offset
, &u32val
);
1484 len
+= snprintf(pbuffer
+len
, LPFC_PCI_CFG_SIZE
-len
,
1486 offset
+= sizeof(uint32_t);
1487 if (offset
>= LPFC_PCI_CFG_SIZE
) {
1488 len
+= snprintf(pbuffer
+len
,
1489 LPFC_PCI_CFG_SIZE
-len
, "\n");
1492 index
-= sizeof(uint32_t);
1494 len
+= snprintf(pbuffer
+len
, LPFC_PCI_CFG_SIZE
-len
,
1496 else if (!(index
% (8 * sizeof(uint32_t)))) {
1497 offset_label
+= (8 * sizeof(uint32_t));
1498 len
+= snprintf(pbuffer
+len
, LPFC_PCI_CFG_SIZE
-len
,
1499 "\n%03x: ", offset_label
);
1503 /* Set up the offset for next portion of pci cfg read */
1505 idiag
.offset
.last_rd
+= LPFC_PCI_CFG_RD_SIZE
;
1506 if (idiag
.offset
.last_rd
>= LPFC_PCI_CFG_SIZE
)
1507 idiag
.offset
.last_rd
= 0;
1509 idiag
.offset
.last_rd
= 0;
1511 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
1515 * lpfc_idiag_pcicfg_write - Syntax check and set up idiag pcicfg commands
1516 * @file: The file pointer to read from.
1517 * @buf: The buffer to copy the user data from.
1518 * @nbytes: The number of bytes to get.
1519 * @ppos: The position in the file to start reading from.
1521 * This routine get the debugfs idiag command struct from user space and
1522 * then perform the syntax check for PCI config space read or write command
1523 * accordingly. In the case of PCI config space read command, it sets up
1524 * the command in the idiag command struct for the debugfs read operation.
1525 * In the case of PCI config space write operation, it executes the write
1526 * operation into the PCI config space accordingly.
1528 * It returns the @nbytges passing in from debugfs user space when successful.
1529 * In case of error conditions, it returns proper error code back to the user
1533 lpfc_idiag_pcicfg_write(struct file
*file
, const char __user
*buf
,
1534 size_t nbytes
, loff_t
*ppos
)
1536 struct lpfc_debug
*debug
= file
->private_data
;
1537 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
1538 uint32_t where
, value
, count
;
1542 struct pci_dev
*pdev
;
1545 pdev
= phba
->pcidev
;
1549 /* This is a user write operation */
1550 debug
->op
= LPFC_IDIAG_OP_WR
;
1552 rc
= lpfc_idiag_cmd_get(buf
, nbytes
, &idiag
.cmd
);
1556 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_RD
) {
1557 /* Sanity check on PCI config read command line arguments */
1558 if (rc
!= LPFC_PCI_CFG_RD_CMD_ARG
)
1560 /* Read command from PCI config space, set up command fields */
1561 where
= idiag
.cmd
.data
[IDIAG_PCICFG_WHERE_INDX
];
1562 count
= idiag
.cmd
.data
[IDIAG_PCICFG_COUNT_INDX
];
1563 if (count
== LPFC_PCI_CFG_BROWSE
) {
1564 if (where
% sizeof(uint32_t))
1566 /* Starting offset to browse */
1567 idiag
.offset
.last_rd
= where
;
1568 } else if ((count
!= sizeof(uint8_t)) &&
1569 (count
!= sizeof(uint16_t)) &&
1570 (count
!= sizeof(uint32_t)))
1572 if (count
== sizeof(uint8_t)) {
1573 if (where
> LPFC_PCI_CFG_SIZE
- sizeof(uint8_t))
1575 if (where
% sizeof(uint8_t))
1578 if (count
== sizeof(uint16_t)) {
1579 if (where
> LPFC_PCI_CFG_SIZE
- sizeof(uint16_t))
1581 if (where
% sizeof(uint16_t))
1584 if (count
== sizeof(uint32_t)) {
1585 if (where
> LPFC_PCI_CFG_SIZE
- sizeof(uint32_t))
1587 if (where
% sizeof(uint32_t))
1590 } else if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_WR
||
1591 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_ST
||
1592 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_CL
) {
1593 /* Sanity check on PCI config write command line arguments */
1594 if (rc
!= LPFC_PCI_CFG_WR_CMD_ARG
)
1596 /* Write command to PCI config space, read-modify-write */
1597 where
= idiag
.cmd
.data
[IDIAG_PCICFG_WHERE_INDX
];
1598 count
= idiag
.cmd
.data
[IDIAG_PCICFG_COUNT_INDX
];
1599 value
= idiag
.cmd
.data
[IDIAG_PCICFG_VALUE_INDX
];
1601 if ((count
!= sizeof(uint8_t)) &&
1602 (count
!= sizeof(uint16_t)) &&
1603 (count
!= sizeof(uint32_t)))
1605 if (count
== sizeof(uint8_t)) {
1606 if (where
> LPFC_PCI_CFG_SIZE
- sizeof(uint8_t))
1608 if (where
% sizeof(uint8_t))
1610 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_WR
)
1611 pci_write_config_byte(pdev
, where
,
1613 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_ST
) {
1614 rc
= pci_read_config_byte(pdev
, where
, &u8val
);
1616 u8val
|= (uint8_t)value
;
1617 pci_write_config_byte(pdev
, where
,
1621 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_CL
) {
1622 rc
= pci_read_config_byte(pdev
, where
, &u8val
);
1624 u8val
&= (uint8_t)(~value
);
1625 pci_write_config_byte(pdev
, where
,
1630 if (count
== sizeof(uint16_t)) {
1631 if (where
> LPFC_PCI_CFG_SIZE
- sizeof(uint16_t))
1633 if (where
% sizeof(uint16_t))
1635 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_WR
)
1636 pci_write_config_word(pdev
, where
,
1638 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_ST
) {
1639 rc
= pci_read_config_word(pdev
, where
, &u16val
);
1641 u16val
|= (uint16_t)value
;
1642 pci_write_config_word(pdev
, where
,
1646 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_CL
) {
1647 rc
= pci_read_config_word(pdev
, where
, &u16val
);
1649 u16val
&= (uint16_t)(~value
);
1650 pci_write_config_word(pdev
, where
,
1655 if (count
== sizeof(uint32_t)) {
1656 if (where
> LPFC_PCI_CFG_SIZE
- sizeof(uint32_t))
1658 if (where
% sizeof(uint32_t))
1660 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_WR
)
1661 pci_write_config_dword(pdev
, where
, value
);
1662 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_ST
) {
1663 rc
= pci_read_config_dword(pdev
, where
,
1667 pci_write_config_dword(pdev
, where
,
1671 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_CL
) {
1672 rc
= pci_read_config_dword(pdev
, where
,
1676 pci_write_config_dword(pdev
, where
,
1682 /* All other opecodes are illegal for now */
1687 memset(&idiag
, 0, sizeof(idiag
));
1692 * lpfc_idiag_baracc_read - idiag debugfs pci bar access read
1693 * @file: The file pointer to read from.
1694 * @buf: The buffer to copy the data to.
1695 * @nbytes: The number of bytes to read.
1696 * @ppos: The position in the file to start reading from.
1699 * This routine reads data from the @phba pci bar memory mapped space
1700 * according to the idiag command, and copies to user @buf.
1703 * This function returns the amount of data that was read (this could be less
1704 * than @nbytes if the end of the file was reached) or a negative error value.
1707 lpfc_idiag_baracc_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
1710 struct lpfc_debug
*debug
= file
->private_data
;
1711 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
1712 int offset_label
, offset
, offset_run
, len
= 0, index
;
1713 int bar_num
, acc_range
, bar_size
;
1715 void __iomem
*mem_mapped_bar
;
1717 struct pci_dev
*pdev
;
1720 pdev
= phba
->pcidev
;
1724 /* This is a user read operation */
1725 debug
->op
= LPFC_IDIAG_OP_RD
;
1728 debug
->buffer
= kmalloc(LPFC_PCI_BAR_RD_BUF_SIZE
, GFP_KERNEL
);
1731 pbuffer
= debug
->buffer
;
1736 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_RD
) {
1737 bar_num
= idiag
.cmd
.data
[IDIAG_BARACC_BAR_NUM_INDX
];
1738 offset
= idiag
.cmd
.data
[IDIAG_BARACC_OFF_SET_INDX
];
1739 acc_range
= idiag
.cmd
.data
[IDIAG_BARACC_ACC_MOD_INDX
];
1740 bar_size
= idiag
.cmd
.data
[IDIAG_BARACC_BAR_SZE_INDX
];
1747 if_type
= bf_get(lpfc_sli_intf_if_type
, &phba
->sli4_hba
.sli_intf
);
1748 if (if_type
== LPFC_SLI_INTF_IF_TYPE_0
) {
1749 if (bar_num
== IDIAG_BARACC_BAR_0
)
1750 mem_mapped_bar
= phba
->sli4_hba
.conf_regs_memmap_p
;
1751 else if (bar_num
== IDIAG_BARACC_BAR_1
)
1752 mem_mapped_bar
= phba
->sli4_hba
.ctrl_regs_memmap_p
;
1753 else if (bar_num
== IDIAG_BARACC_BAR_2
)
1754 mem_mapped_bar
= phba
->sli4_hba
.drbl_regs_memmap_p
;
1757 } else if (if_type
== LPFC_SLI_INTF_IF_TYPE_2
) {
1758 if (bar_num
== IDIAG_BARACC_BAR_0
)
1759 mem_mapped_bar
= phba
->sli4_hba
.conf_regs_memmap_p
;
1765 /* Read single PCI bar space register */
1766 if (acc_range
== SINGLE_WORD
) {
1767 offset_run
= offset
;
1768 u32val
= readl(mem_mapped_bar
+ offset_run
);
1769 len
+= snprintf(pbuffer
+len
, LPFC_PCI_BAR_RD_BUF_SIZE
-len
,
1770 "%05x: %08x\n", offset_run
, u32val
);
1774 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
1778 /* Browse all PCI bar space registers */
1779 offset_label
= idiag
.offset
.last_rd
;
1780 offset_run
= offset_label
;
1782 /* Read PCI bar memory mapped space */
1783 len
+= snprintf(pbuffer
+len
, LPFC_PCI_BAR_RD_BUF_SIZE
-len
,
1784 "%05x: ", offset_label
);
1785 index
= LPFC_PCI_BAR_RD_SIZE
;
1787 u32val
= readl(mem_mapped_bar
+ offset_run
);
1788 len
+= snprintf(pbuffer
+len
, LPFC_PCI_BAR_RD_BUF_SIZE
-len
,
1790 offset_run
+= sizeof(uint32_t);
1791 if (acc_range
== LPFC_PCI_BAR_BROWSE
) {
1792 if (offset_run
>= bar_size
) {
1793 len
+= snprintf(pbuffer
+len
,
1794 LPFC_PCI_BAR_RD_BUF_SIZE
-len
, "\n");
1798 if (offset_run
>= offset
+
1799 (acc_range
* sizeof(uint32_t))) {
1800 len
+= snprintf(pbuffer
+len
,
1801 LPFC_PCI_BAR_RD_BUF_SIZE
-len
, "\n");
1805 index
-= sizeof(uint32_t);
1807 len
+= snprintf(pbuffer
+len
,
1808 LPFC_PCI_BAR_RD_BUF_SIZE
-len
, "\n");
1809 else if (!(index
% (8 * sizeof(uint32_t)))) {
1810 offset_label
+= (8 * sizeof(uint32_t));
1811 len
+= snprintf(pbuffer
+len
,
1812 LPFC_PCI_BAR_RD_BUF_SIZE
-len
,
1813 "\n%05x: ", offset_label
);
1817 /* Set up the offset for next portion of pci bar read */
1819 idiag
.offset
.last_rd
+= LPFC_PCI_BAR_RD_SIZE
;
1820 if (acc_range
== LPFC_PCI_BAR_BROWSE
) {
1821 if (idiag
.offset
.last_rd
>= bar_size
)
1822 idiag
.offset
.last_rd
= 0;
1824 if (offset_run
>= offset
+
1825 (acc_range
* sizeof(uint32_t)))
1826 idiag
.offset
.last_rd
= offset
;
1829 if (acc_range
== LPFC_PCI_BAR_BROWSE
)
1830 idiag
.offset
.last_rd
= 0;
1832 idiag
.offset
.last_rd
= offset
;
1835 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
1839 * lpfc_idiag_baracc_write - Syntax check and set up idiag bar access commands
1840 * @file: The file pointer to read from.
1841 * @buf: The buffer to copy the user data from.
1842 * @nbytes: The number of bytes to get.
1843 * @ppos: The position in the file to start reading from.
1845 * This routine get the debugfs idiag command struct from user space and
1846 * then perform the syntax check for PCI bar memory mapped space read or
1847 * write command accordingly. In the case of PCI bar memory mapped space
1848 * read command, it sets up the command in the idiag command struct for
1849 * the debugfs read operation. In the case of PCI bar memorpy mapped space
1850 * write operation, it executes the write operation into the PCI bar memory
1851 * mapped space accordingly.
1853 * It returns the @nbytges passing in from debugfs user space when successful.
1854 * In case of error conditions, it returns proper error code back to the user
1858 lpfc_idiag_baracc_write(struct file
*file
, const char __user
*buf
,
1859 size_t nbytes
, loff_t
*ppos
)
1861 struct lpfc_debug
*debug
= file
->private_data
;
1862 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
1863 uint32_t bar_num
, bar_size
, offset
, value
, acc_range
;
1864 struct pci_dev
*pdev
;
1865 void __iomem
*mem_mapped_bar
;
1870 pdev
= phba
->pcidev
;
1874 /* This is a user write operation */
1875 debug
->op
= LPFC_IDIAG_OP_WR
;
1877 rc
= lpfc_idiag_cmd_get(buf
, nbytes
, &idiag
.cmd
);
1881 if_type
= bf_get(lpfc_sli_intf_if_type
, &phba
->sli4_hba
.sli_intf
);
1882 bar_num
= idiag
.cmd
.data
[IDIAG_BARACC_BAR_NUM_INDX
];
1884 if (if_type
== LPFC_SLI_INTF_IF_TYPE_0
) {
1885 if ((bar_num
!= IDIAG_BARACC_BAR_0
) &&
1886 (bar_num
!= IDIAG_BARACC_BAR_1
) &&
1887 (bar_num
!= IDIAG_BARACC_BAR_2
))
1889 } else if (if_type
== LPFC_SLI_INTF_IF_TYPE_2
) {
1890 if (bar_num
!= IDIAG_BARACC_BAR_0
)
1895 if (if_type
== LPFC_SLI_INTF_IF_TYPE_0
) {
1896 if (bar_num
== IDIAG_BARACC_BAR_0
) {
1897 idiag
.cmd
.data
[IDIAG_BARACC_BAR_SZE_INDX
] =
1898 LPFC_PCI_IF0_BAR0_SIZE
;
1899 mem_mapped_bar
= phba
->sli4_hba
.conf_regs_memmap_p
;
1900 } else if (bar_num
== IDIAG_BARACC_BAR_1
) {
1901 idiag
.cmd
.data
[IDIAG_BARACC_BAR_SZE_INDX
] =
1902 LPFC_PCI_IF0_BAR1_SIZE
;
1903 mem_mapped_bar
= phba
->sli4_hba
.ctrl_regs_memmap_p
;
1904 } else if (bar_num
== IDIAG_BARACC_BAR_2
) {
1905 idiag
.cmd
.data
[IDIAG_BARACC_BAR_SZE_INDX
] =
1906 LPFC_PCI_IF0_BAR2_SIZE
;
1907 mem_mapped_bar
= phba
->sli4_hba
.drbl_regs_memmap_p
;
1910 } else if (if_type
== LPFC_SLI_INTF_IF_TYPE_2
) {
1911 if (bar_num
== IDIAG_BARACC_BAR_0
) {
1912 idiag
.cmd
.data
[IDIAG_BARACC_BAR_SZE_INDX
] =
1913 LPFC_PCI_IF2_BAR0_SIZE
;
1914 mem_mapped_bar
= phba
->sli4_hba
.conf_regs_memmap_p
;
1920 offset
= idiag
.cmd
.data
[IDIAG_BARACC_OFF_SET_INDX
];
1921 if (offset
% sizeof(uint32_t))
1924 bar_size
= idiag
.cmd
.data
[IDIAG_BARACC_BAR_SZE_INDX
];
1925 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_RD
) {
1926 /* Sanity check on PCI config read command line arguments */
1927 if (rc
!= LPFC_PCI_BAR_RD_CMD_ARG
)
1929 acc_range
= idiag
.cmd
.data
[IDIAG_BARACC_ACC_MOD_INDX
];
1930 if (acc_range
== LPFC_PCI_BAR_BROWSE
) {
1931 if (offset
> bar_size
- sizeof(uint32_t))
1933 /* Starting offset to browse */
1934 idiag
.offset
.last_rd
= offset
;
1935 } else if (acc_range
> SINGLE_WORD
) {
1936 if (offset
+ acc_range
* sizeof(uint32_t) > bar_size
)
1938 /* Starting offset to browse */
1939 idiag
.offset
.last_rd
= offset
;
1940 } else if (acc_range
!= SINGLE_WORD
)
1942 } else if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_WR
||
1943 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_ST
||
1944 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_CL
) {
1945 /* Sanity check on PCI bar write command line arguments */
1946 if (rc
!= LPFC_PCI_BAR_WR_CMD_ARG
)
1948 /* Write command to PCI bar space, read-modify-write */
1949 acc_range
= SINGLE_WORD
;
1950 value
= idiag
.cmd
.data
[IDIAG_BARACC_REG_VAL_INDX
];
1951 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_WR
) {
1952 writel(value
, mem_mapped_bar
+ offset
);
1953 readl(mem_mapped_bar
+ offset
);
1955 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_ST
) {
1956 u32val
= readl(mem_mapped_bar
+ offset
);
1958 writel(u32val
, mem_mapped_bar
+ offset
);
1959 readl(mem_mapped_bar
+ offset
);
1961 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_CL
) {
1962 u32val
= readl(mem_mapped_bar
+ offset
);
1964 writel(u32val
, mem_mapped_bar
+ offset
);
1965 readl(mem_mapped_bar
+ offset
);
1968 /* All other opecodes are illegal for now */
1973 memset(&idiag
, 0, sizeof(idiag
));
1978 * lpfc_idiag_queinfo_read - idiag debugfs read queue information
1979 * @file: The file pointer to read from.
1980 * @buf: The buffer to copy the data to.
1981 * @nbytes: The number of bytes to read.
1982 * @ppos: The position in the file to start reading from.
1985 * This routine reads data from the @phba SLI4 PCI function queue information,
1986 * and copies to user @buf.
1989 * This function returns the amount of data that was read (this could be less
1990 * than @nbytes if the end of the file was reached) or a negative error value.
1993 lpfc_idiag_queinfo_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
1996 struct lpfc_debug
*debug
= file
->private_data
;
1997 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
2002 struct lpfc_queue
*qp
= NULL
;
2006 debug
->buffer
= kmalloc(LPFC_QUE_INFO_GET_BUF_SIZE
, GFP_KERNEL
);
2009 pbuffer
= debug
->buffer
;
2010 max_cnt
= LPFC_QUE_INFO_GET_BUF_SIZE
- 128;
2015 spin_lock_irq(&phba
->hbalock
);
2017 /* Fast-path event queue */
2018 if (phba
->sli4_hba
.hba_eq
&& phba
->cfg_fcp_io_channel
) {
2019 cnt
= phba
->cfg_fcp_io_channel
;
2021 for (x
= 0; x
< cnt
; x
++) {
2024 qp
= phba
->sli4_hba
.hba_eq
[x
];
2028 len
+= snprintf(pbuffer
+len
,
2029 LPFC_QUE_INFO_GET_BUF_SIZE
-len
,
2031 "EQ-STAT[max:x%x noE:x%x "
2032 "bs:x%x proc:x%llx]\n",
2033 qp
->q_cnt_1
, qp
->q_cnt_2
,
2034 qp
->q_cnt_3
, (unsigned long long)qp
->q_cnt_4
);
2036 len
+= snprintf(pbuffer
+len
,
2037 LPFC_QUE_INFO_GET_BUF_SIZE
-len
,
2039 "QE-CNT[%04d], QE-SIZE[%04d], "
2040 "HOST-IDX[%04d], PORT-IDX[%04d]",
2048 /* Reset max counter */
2051 len
+= snprintf(pbuffer
+len
,
2052 LPFC_QUE_INFO_GET_BUF_SIZE
-len
, "\n");
2056 /* Fast-path FCP CQ */
2057 qp
= phba
->sli4_hba
.fcp_cq
[x
];
2058 len
+= snprintf(pbuffer
+len
,
2059 LPFC_QUE_INFO_GET_BUF_SIZE
-len
,
2061 len
+= snprintf(pbuffer
+len
,
2062 LPFC_QUE_INFO_GET_BUF_SIZE
-len
,
2064 "CQ STAT[max:x%x relw:x%x "
2065 "xabt:x%x wq:x%llx]\n",
2067 qp
->q_cnt_1
, qp
->q_cnt_2
,
2068 qp
->q_cnt_3
, (unsigned long long)qp
->q_cnt_4
);
2069 len
+= snprintf(pbuffer
+len
,
2070 LPFC_QUE_INFO_GET_BUF_SIZE
-len
,
2072 "QE-CNT[%04d], QE-SIZE[%04d], "
2073 "HOST-IDX[%04d], PORT-IDX[%04d]",
2074 qp
->queue_id
, qp
->entry_count
,
2075 qp
->entry_size
, qp
->host_index
,
2079 /* Reset max counter */
2082 len
+= snprintf(pbuffer
+len
,
2083 LPFC_QUE_INFO_GET_BUF_SIZE
-len
, "\n");
2087 /* Fast-path FCP WQ */
2088 qp
= phba
->sli4_hba
.fcp_wq
[x
];
2090 len
+= snprintf(pbuffer
+len
,
2091 LPFC_QUE_INFO_GET_BUF_SIZE
-len
,
2092 "\t\tFCP WQ info: ");
2093 len
+= snprintf(pbuffer
+len
,
2094 LPFC_QUE_INFO_GET_BUF_SIZE
-len
,
2096 "WQ-STAT[oflow:x%x posted:x%llx]\n",
2098 qp
->q_cnt_1
, (unsigned long long)qp
->q_cnt_4
);
2099 len
+= snprintf(pbuffer
+len
,
2100 LPFC_QUE_INFO_GET_BUF_SIZE
-len
,
2102 "QE-CNT[%04d], QE-SIZE[%04d], "
2103 "HOST-IDX[%04d], PORT-IDX[%04d]",
2110 len
+= snprintf(pbuffer
+len
,
2111 LPFC_QUE_INFO_GET_BUF_SIZE
-len
, "\n");
2118 /* Only EQ 0 has slow path CQs configured */
2120 /* Slow-path mailbox CQ */
2121 qp
= phba
->sli4_hba
.mbx_cq
;
2123 len
+= snprintf(pbuffer
+len
,
2124 LPFC_QUE_INFO_GET_BUF_SIZE
-len
,
2126 len
+= snprintf(pbuffer
+len
,
2127 LPFC_QUE_INFO_GET_BUF_SIZE
-len
,
2129 "CQ-STAT[mbox:x%x relw:x%x "
2130 "xabt:x%x wq:x%llx]\n",
2132 qp
->q_cnt_1
, qp
->q_cnt_2
,
2134 (unsigned long long)qp
->q_cnt_4
);
2135 len
+= snprintf(pbuffer
+len
,
2136 LPFC_QUE_INFO_GET_BUF_SIZE
-len
,
2138 "QE-CNT[%04d], QE-SIZE[%04d], "
2139 "HOST-IDX[%04d], PORT-IDX[%04d]",
2140 qp
->queue_id
, qp
->entry_count
,
2141 qp
->entry_size
, qp
->host_index
,
2144 len
+= snprintf(pbuffer
+len
,
2145 LPFC_QUE_INFO_GET_BUF_SIZE
-len
, "\n");
2150 /* Slow-path MBOX MQ */
2151 qp
= phba
->sli4_hba
.mbx_wq
;
2153 len
+= snprintf(pbuffer
+len
,
2154 LPFC_QUE_INFO_GET_BUF_SIZE
-len
,
2155 "\t\tMBX MQ info: ");
2156 len
+= snprintf(pbuffer
+len
,
2157 LPFC_QUE_INFO_GET_BUF_SIZE
-len
,
2158 "AssocCQID[%02d]:\n",
2159 phba
->sli4_hba
.mbx_wq
->assoc_qid
);
2160 len
+= snprintf(pbuffer
+len
,
2161 LPFC_QUE_INFO_GET_BUF_SIZE
-len
,
2163 "QE-CNT[%04d], QE-SIZE[%04d], "
2164 "HOST-IDX[%04d], PORT-IDX[%04d]",
2165 qp
->queue_id
, qp
->entry_count
,
2166 qp
->entry_size
, qp
->host_index
,
2169 len
+= snprintf(pbuffer
+len
,
2170 LPFC_QUE_INFO_GET_BUF_SIZE
-len
, "\n");
2175 /* Slow-path ELS response CQ */
2176 qp
= phba
->sli4_hba
.els_cq
;
2178 len
+= snprintf(pbuffer
+len
,
2179 LPFC_QUE_INFO_GET_BUF_SIZE
-len
,
2181 len
+= snprintf(pbuffer
+len
,
2182 LPFC_QUE_INFO_GET_BUF_SIZE
-len
,
2184 "CQ-STAT[max:x%x relw:x%x "
2185 "xabt:x%x wq:x%llx]\n",
2187 qp
->q_cnt_1
, qp
->q_cnt_2
,
2189 (unsigned long long)qp
->q_cnt_4
);
2190 len
+= snprintf(pbuffer
+len
,
2191 LPFC_QUE_INFO_GET_BUF_SIZE
-len
,
2193 "QE-CNT[%04d], QE-SIZE[%04d], "
2194 "HOST-IDX[%04d], PORT-IDX[%04d]",
2195 qp
->queue_id
, qp
->entry_count
,
2196 qp
->entry_size
, qp
->host_index
,
2199 /* Reset max counter */
2202 len
+= snprintf(pbuffer
+len
,
2203 LPFC_QUE_INFO_GET_BUF_SIZE
-len
, "\n");
2208 /* Slow-path ELS WQ */
2209 qp
= phba
->sli4_hba
.els_wq
;
2211 len
+= snprintf(pbuffer
+len
,
2212 LPFC_QUE_INFO_GET_BUF_SIZE
-len
,
2213 "\t\tELS WQ info: ");
2214 len
+= snprintf(pbuffer
+len
,
2215 LPFC_QUE_INFO_GET_BUF_SIZE
-len
,
2217 " WQ-STAT[oflow:x%x "
2221 (unsigned long long)qp
->q_cnt_4
);
2222 len
+= snprintf(pbuffer
+len
,
2223 LPFC_QUE_INFO_GET_BUF_SIZE
-len
,
2225 "QE-CNT[%04d], QE-SIZE[%04d], "
2226 "HOST-IDX[%04d], PORT-IDX[%04d]",
2227 qp
->queue_id
, qp
->entry_count
,
2228 qp
->entry_size
, qp
->host_index
,
2231 len
+= snprintf(pbuffer
+len
,
2232 LPFC_QUE_INFO_GET_BUF_SIZE
-len
, "\n");
2237 if (phba
->sli4_hba
.hdr_rq
&& phba
->sli4_hba
.dat_rq
) {
2238 /* Slow-path RQ header */
2239 qp
= phba
->sli4_hba
.hdr_rq
;
2241 len
+= snprintf(pbuffer
+len
,
2242 LPFC_QUE_INFO_GET_BUF_SIZE
-len
,
2244 len
+= snprintf(pbuffer
+len
,
2245 LPFC_QUE_INFO_GET_BUF_SIZE
-len
,
2247 "RQ-STAT[nopost:x%x nobuf:x%x "
2248 "trunc:x%x rcv:x%llx]\n",
2250 qp
->q_cnt_1
, qp
->q_cnt_2
,
2252 (unsigned long long)qp
->q_cnt_4
);
2253 len
+= snprintf(pbuffer
+len
,
2254 LPFC_QUE_INFO_GET_BUF_SIZE
-len
,
2256 "QE-CNT[%04d], QE-SIZE[%04d], "
2257 "HOST-IDX[%04d], PORT-IDX[%04d]\n",
2264 /* Slow-path RQ data */
2265 qp
= phba
->sli4_hba
.dat_rq
;
2266 len
+= snprintf(pbuffer
+len
,
2267 LPFC_QUE_INFO_GET_BUF_SIZE
-len
,
2269 "QE-CNT[%04d], QE-SIZE[%04d], "
2270 "HOST-IDX[%04d], PORT-IDX[%04d]\n",
2277 len
+= snprintf(pbuffer
+len
,
2278 LPFC_QUE_INFO_GET_BUF_SIZE
-len
, "\n");
2283 spin_unlock_irq(&phba
->hbalock
);
2284 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
2287 len
+= snprintf(pbuffer
+len
,
2288 LPFC_QUE_INFO_GET_BUF_SIZE
-len
, "Truncated ...\n");
2289 spin_unlock_irq(&phba
->hbalock
);
2290 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
2294 * lpfc_idiag_que_param_check - queue access command parameter sanity check
2295 * @q: The pointer to queue structure.
2296 * @index: The index into a queue entry.
2297 * @count: The number of queue entries to access.
2300 * The routine performs sanity check on device queue access method commands.
2303 * This function returns -EINVAL when fails the sanity check, otherwise, it
2307 lpfc_idiag_que_param_check(struct lpfc_queue
*q
, int index
, int count
)
2309 /* Only support single entry read or browsing */
2310 if ((count
!= 1) && (count
!= LPFC_QUE_ACC_BROWSE
))
2312 if (index
> q
->entry_count
- 1)
2318 * lpfc_idiag_queacc_read_qe - read a single entry from the given queue index
2319 * @pbuffer: The pointer to buffer to copy the read data into.
2320 * @pque: The pointer to the queue to be read.
2321 * @index: The index into the queue entry.
2324 * This routine reads out a single entry from the given queue's index location
2325 * and copies it into the buffer provided.
2328 * This function returns 0 when it fails, otherwise, it returns the length of
2329 * the data read into the buffer provided.
2332 lpfc_idiag_queacc_read_qe(char *pbuffer
, int len
, struct lpfc_queue
*pque
,
2338 if (!pbuffer
|| !pque
)
2341 esize
= pque
->entry_size
;
2342 len
+= snprintf(pbuffer
+len
, LPFC_QUE_ACC_BUF_SIZE
-len
,
2343 "QE-INDEX[%04d]:\n", index
);
2346 pentry
= pque
->qe
[index
].address
;
2348 len
+= snprintf(pbuffer
+len
, LPFC_QUE_ACC_BUF_SIZE
-len
,
2351 offset
+= sizeof(uint32_t);
2352 esize
-= sizeof(uint32_t);
2353 if (esize
> 0 && !(offset
% (4 * sizeof(uint32_t))))
2354 len
+= snprintf(pbuffer
+len
,
2355 LPFC_QUE_ACC_BUF_SIZE
-len
, "\n");
2357 len
+= snprintf(pbuffer
+len
, LPFC_QUE_ACC_BUF_SIZE
-len
, "\n");
2363 * lpfc_idiag_queacc_read - idiag debugfs read port queue
2364 * @file: The file pointer to read from.
2365 * @buf: The buffer to copy the data to.
2366 * @nbytes: The number of bytes to read.
2367 * @ppos: The position in the file to start reading from.
2370 * This routine reads data from the @phba device queue memory according to the
2371 * idiag command, and copies to user @buf. Depending on the queue dump read
2372 * command setup, it does either a single queue entry read or browing through
2373 * all entries of the queue.
2376 * This function returns the amount of data that was read (this could be less
2377 * than @nbytes if the end of the file was reached) or a negative error value.
2380 lpfc_idiag_queacc_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
2383 struct lpfc_debug
*debug
= file
->private_data
;
2384 uint32_t last_index
, index
, count
;
2385 struct lpfc_queue
*pque
= NULL
;
2389 /* This is a user read operation */
2390 debug
->op
= LPFC_IDIAG_OP_RD
;
2393 debug
->buffer
= kmalloc(LPFC_QUE_ACC_BUF_SIZE
, GFP_KERNEL
);
2396 pbuffer
= debug
->buffer
;
2401 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_RD
) {
2402 index
= idiag
.cmd
.data
[IDIAG_QUEACC_INDEX_INDX
];
2403 count
= idiag
.cmd
.data
[IDIAG_QUEACC_COUNT_INDX
];
2404 pque
= (struct lpfc_queue
*)idiag
.ptr_private
;
2408 /* Browse the queue starting from index */
2409 if (count
== LPFC_QUE_ACC_BROWSE
)
2412 /* Read a single entry from the queue */
2413 len
= lpfc_idiag_queacc_read_qe(pbuffer
, len
, pque
, index
);
2415 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
2419 /* Browse all entries from the queue */
2420 last_index
= idiag
.offset
.last_rd
;
2423 while (len
< LPFC_QUE_ACC_SIZE
- pque
->entry_size
) {
2424 len
= lpfc_idiag_queacc_read_qe(pbuffer
, len
, pque
, index
);
2426 if (index
> pque
->entry_count
- 1)
2430 /* Set up the offset for next portion of pci cfg read */
2431 if (index
> pque
->entry_count
- 1)
2433 idiag
.offset
.last_rd
= index
;
2435 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
2439 * lpfc_idiag_queacc_write - Syntax check and set up idiag queacc commands
2440 * @file: The file pointer to read from.
2441 * @buf: The buffer to copy the user data from.
2442 * @nbytes: The number of bytes to get.
2443 * @ppos: The position in the file to start reading from.
2445 * This routine get the debugfs idiag command struct from user space and then
2446 * perform the syntax check for port queue read (dump) or write (set) command
2447 * accordingly. In the case of port queue read command, it sets up the command
2448 * in the idiag command struct for the following debugfs read operation. In
2449 * the case of port queue write operation, it executes the write operation
2450 * into the port queue entry accordingly.
2452 * It returns the @nbytges passing in from debugfs user space when successful.
2453 * In case of error conditions, it returns proper error code back to the user
2457 lpfc_idiag_queacc_write(struct file
*file
, const char __user
*buf
,
2458 size_t nbytes
, loff_t
*ppos
)
2460 struct lpfc_debug
*debug
= file
->private_data
;
2461 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
2462 uint32_t qidx
, quetp
, queid
, index
, count
, offset
, value
;
2464 struct lpfc_queue
*pque
;
2467 /* This is a user write operation */
2468 debug
->op
= LPFC_IDIAG_OP_WR
;
2470 rc
= lpfc_idiag_cmd_get(buf
, nbytes
, &idiag
.cmd
);
2474 /* Get and sanity check on command feilds */
2475 quetp
= idiag
.cmd
.data
[IDIAG_QUEACC_QUETP_INDX
];
2476 queid
= idiag
.cmd
.data
[IDIAG_QUEACC_QUEID_INDX
];
2477 index
= idiag
.cmd
.data
[IDIAG_QUEACC_INDEX_INDX
];
2478 count
= idiag
.cmd
.data
[IDIAG_QUEACC_COUNT_INDX
];
2479 offset
= idiag
.cmd
.data
[IDIAG_QUEACC_OFFST_INDX
];
2480 value
= idiag
.cmd
.data
[IDIAG_QUEACC_VALUE_INDX
];
2482 /* Sanity check on command line arguments */
2483 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_WR
||
2484 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_ST
||
2485 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_CL
) {
2486 if (rc
!= LPFC_QUE_ACC_WR_CMD_ARG
)
2490 } else if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_RD
) {
2491 if (rc
!= LPFC_QUE_ACC_RD_CMD_ARG
)
2498 /* HBA event queue */
2499 if (phba
->sli4_hba
.hba_eq
) {
2500 for (qidx
= 0; qidx
< phba
->cfg_fcp_io_channel
;
2502 if (phba
->sli4_hba
.hba_eq
[qidx
] &&
2503 phba
->sli4_hba
.hba_eq
[qidx
]->queue_id
==
2506 rc
= lpfc_idiag_que_param_check(
2507 phba
->sli4_hba
.hba_eq
[qidx
],
2512 phba
->sli4_hba
.hba_eq
[qidx
];
2520 /* MBX complete queue */
2521 if (phba
->sli4_hba
.mbx_cq
&&
2522 phba
->sli4_hba
.mbx_cq
->queue_id
== queid
) {
2524 rc
= lpfc_idiag_que_param_check(
2525 phba
->sli4_hba
.mbx_cq
, index
, count
);
2528 idiag
.ptr_private
= phba
->sli4_hba
.mbx_cq
;
2531 /* ELS complete queue */
2532 if (phba
->sli4_hba
.els_cq
&&
2533 phba
->sli4_hba
.els_cq
->queue_id
== queid
) {
2535 rc
= lpfc_idiag_que_param_check(
2536 phba
->sli4_hba
.els_cq
, index
, count
);
2539 idiag
.ptr_private
= phba
->sli4_hba
.els_cq
;
2542 /* FCP complete queue */
2543 if (phba
->sli4_hba
.fcp_cq
) {
2546 if (phba
->sli4_hba
.fcp_cq
[qidx
] &&
2547 phba
->sli4_hba
.fcp_cq
[qidx
]->queue_id
==
2550 rc
= lpfc_idiag_que_param_check(
2551 phba
->sli4_hba
.fcp_cq
[qidx
],
2556 phba
->sli4_hba
.fcp_cq
[qidx
];
2559 } while (++qidx
< phba
->cfg_fcp_io_channel
);
2564 /* MBX work queue */
2565 if (phba
->sli4_hba
.mbx_wq
&&
2566 phba
->sli4_hba
.mbx_wq
->queue_id
== queid
) {
2568 rc
= lpfc_idiag_que_param_check(
2569 phba
->sli4_hba
.mbx_wq
, index
, count
);
2572 idiag
.ptr_private
= phba
->sli4_hba
.mbx_wq
;
2578 /* ELS work queue */
2579 if (phba
->sli4_hba
.els_wq
&&
2580 phba
->sli4_hba
.els_wq
->queue_id
== queid
) {
2582 rc
= lpfc_idiag_que_param_check(
2583 phba
->sli4_hba
.els_wq
, index
, count
);
2586 idiag
.ptr_private
= phba
->sli4_hba
.els_wq
;
2589 /* FCP work queue */
2590 if (phba
->sli4_hba
.fcp_wq
) {
2591 for (qidx
= 0; qidx
< phba
->cfg_fcp_io_channel
;
2593 if (!phba
->sli4_hba
.fcp_wq
[qidx
])
2595 if (phba
->sli4_hba
.fcp_wq
[qidx
]->queue_id
==
2598 rc
= lpfc_idiag_que_param_check(
2599 phba
->sli4_hba
.fcp_wq
[qidx
],
2604 phba
->sli4_hba
.fcp_wq
[qidx
];
2613 if (phba
->sli4_hba
.hdr_rq
&&
2614 phba
->sli4_hba
.hdr_rq
->queue_id
== queid
) {
2616 rc
= lpfc_idiag_que_param_check(
2617 phba
->sli4_hba
.hdr_rq
, index
, count
);
2620 idiag
.ptr_private
= phba
->sli4_hba
.hdr_rq
;
2624 if (phba
->sli4_hba
.dat_rq
&&
2625 phba
->sli4_hba
.dat_rq
->queue_id
== queid
) {
2627 rc
= lpfc_idiag_que_param_check(
2628 phba
->sli4_hba
.dat_rq
, index
, count
);
2631 idiag
.ptr_private
= phba
->sli4_hba
.dat_rq
;
2643 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_RD
) {
2644 if (count
== LPFC_QUE_ACC_BROWSE
)
2645 idiag
.offset
.last_rd
= index
;
2648 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_WR
||
2649 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_ST
||
2650 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_CL
) {
2651 /* Additional sanity checks on write operation */
2652 pque
= (struct lpfc_queue
*)idiag
.ptr_private
;
2653 if (offset
> pque
->entry_size
/sizeof(uint32_t) - 1)
2655 pentry
= pque
->qe
[index
].address
;
2657 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_WR
)
2659 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_ST
)
2661 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_CL
)
2667 /* Clean out command structure on command error out */
2668 memset(&idiag
, 0, sizeof(idiag
));
2673 * lpfc_idiag_drbacc_read_reg - idiag debugfs read a doorbell register
2674 * @phba: The pointer to hba structure.
2675 * @pbuffer: The pointer to the buffer to copy the data to.
2676 * @len: The lenght of bytes to copied.
2677 * @drbregid: The id to doorbell registers.
2680 * This routine reads a doorbell register and copies its content to the
2681 * user buffer pointed to by @pbuffer.
2684 * This function returns the amount of data that was copied into @pbuffer.
2687 lpfc_idiag_drbacc_read_reg(struct lpfc_hba
*phba
, char *pbuffer
,
2688 int len
, uint32_t drbregid
)
2696 len
+= snprintf(pbuffer
+len
, LPFC_DRB_ACC_BUF_SIZE
-len
,
2697 "EQCQ-DRB-REG: 0x%08x\n",
2698 readl(phba
->sli4_hba
.EQCQDBregaddr
));
2701 len
+= snprintf(pbuffer
+len
, LPFC_DRB_ACC_BUF_SIZE
-len
,
2702 "MQ-DRB-REG: 0x%08x\n",
2703 readl(phba
->sli4_hba
.MQDBregaddr
));
2706 len
+= snprintf(pbuffer
+len
, LPFC_DRB_ACC_BUF_SIZE
-len
,
2707 "WQ-DRB-REG: 0x%08x\n",
2708 readl(phba
->sli4_hba
.WQDBregaddr
));
2711 len
+= snprintf(pbuffer
+len
, LPFC_DRB_ACC_BUF_SIZE
-len
,
2712 "RQ-DRB-REG: 0x%08x\n",
2713 readl(phba
->sli4_hba
.RQDBregaddr
));
2723 * lpfc_idiag_drbacc_read - idiag debugfs read port doorbell
2724 * @file: The file pointer to read from.
2725 * @buf: The buffer to copy the data to.
2726 * @nbytes: The number of bytes to read.
2727 * @ppos: The position in the file to start reading from.
2730 * This routine reads data from the @phba device doorbell register according
2731 * to the idiag command, and copies to user @buf. Depending on the doorbell
2732 * register read command setup, it does either a single doorbell register
2733 * read or dump all doorbell registers.
2736 * This function returns the amount of data that was read (this could be less
2737 * than @nbytes if the end of the file was reached) or a negative error value.
2740 lpfc_idiag_drbacc_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
2743 struct lpfc_debug
*debug
= file
->private_data
;
2744 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
2745 uint32_t drb_reg_id
, i
;
2749 /* This is a user read operation */
2750 debug
->op
= LPFC_IDIAG_OP_RD
;
2753 debug
->buffer
= kmalloc(LPFC_DRB_ACC_BUF_SIZE
, GFP_KERNEL
);
2756 pbuffer
= debug
->buffer
;
2761 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_RD
)
2762 drb_reg_id
= idiag
.cmd
.data
[IDIAG_DRBACC_REGID_INDX
];
2766 if (drb_reg_id
== LPFC_DRB_ACC_ALL
)
2767 for (i
= 1; i
<= LPFC_DRB_MAX
; i
++)
2768 len
= lpfc_idiag_drbacc_read_reg(phba
,
2771 len
= lpfc_idiag_drbacc_read_reg(phba
,
2772 pbuffer
, len
, drb_reg_id
);
2774 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
2778 * lpfc_idiag_drbacc_write - Syntax check and set up idiag drbacc commands
2779 * @file: The file pointer to read from.
2780 * @buf: The buffer to copy the user data from.
2781 * @nbytes: The number of bytes to get.
2782 * @ppos: The position in the file to start reading from.
2784 * This routine get the debugfs idiag command struct from user space and then
2785 * perform the syntax check for port doorbell register read (dump) or write
2786 * (set) command accordingly. In the case of port queue read command, it sets
2787 * up the command in the idiag command struct for the following debugfs read
2788 * operation. In the case of port doorbell register write operation, it
2789 * executes the write operation into the port doorbell register accordingly.
2791 * It returns the @nbytges passing in from debugfs user space when successful.
2792 * In case of error conditions, it returns proper error code back to the user
2796 lpfc_idiag_drbacc_write(struct file
*file
, const char __user
*buf
,
2797 size_t nbytes
, loff_t
*ppos
)
2799 struct lpfc_debug
*debug
= file
->private_data
;
2800 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
2801 uint32_t drb_reg_id
, value
, reg_val
= 0;
2802 void __iomem
*drb_reg
;
2805 /* This is a user write operation */
2806 debug
->op
= LPFC_IDIAG_OP_WR
;
2808 rc
= lpfc_idiag_cmd_get(buf
, nbytes
, &idiag
.cmd
);
2812 /* Sanity check on command line arguments */
2813 drb_reg_id
= idiag
.cmd
.data
[IDIAG_DRBACC_REGID_INDX
];
2814 value
= idiag
.cmd
.data
[IDIAG_DRBACC_VALUE_INDX
];
2816 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_WR
||
2817 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_ST
||
2818 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_CL
) {
2819 if (rc
!= LPFC_DRB_ACC_WR_CMD_ARG
)
2821 if (drb_reg_id
> LPFC_DRB_MAX
)
2823 } else if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_RD
) {
2824 if (rc
!= LPFC_DRB_ACC_RD_CMD_ARG
)
2826 if ((drb_reg_id
> LPFC_DRB_MAX
) &&
2827 (drb_reg_id
!= LPFC_DRB_ACC_ALL
))
2832 /* Perform the write access operation */
2833 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_WR
||
2834 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_ST
||
2835 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_CL
) {
2836 switch (drb_reg_id
) {
2838 drb_reg
= phba
->sli4_hba
.EQCQDBregaddr
;
2841 drb_reg
= phba
->sli4_hba
.MQDBregaddr
;
2844 drb_reg
= phba
->sli4_hba
.WQDBregaddr
;
2847 drb_reg
= phba
->sli4_hba
.RQDBregaddr
;
2853 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_WR
)
2855 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_ST
) {
2856 reg_val
= readl(drb_reg
);
2859 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_CL
) {
2860 reg_val
= readl(drb_reg
);
2863 writel(reg_val
, drb_reg
);
2864 readl(drb_reg
); /* flush */
2869 /* Clean out command structure on command error out */
2870 memset(&idiag
, 0, sizeof(idiag
));
2875 * lpfc_idiag_ctlacc_read_reg - idiag debugfs read a control registers
2876 * @phba: The pointer to hba structure.
2877 * @pbuffer: The pointer to the buffer to copy the data to.
2878 * @len: The lenght of bytes to copied.
2879 * @drbregid: The id to doorbell registers.
2882 * This routine reads a control register and copies its content to the
2883 * user buffer pointed to by @pbuffer.
2886 * This function returns the amount of data that was copied into @pbuffer.
2889 lpfc_idiag_ctlacc_read_reg(struct lpfc_hba
*phba
, char *pbuffer
,
2890 int len
, uint32_t ctlregid
)
2897 case LPFC_CTL_PORT_SEM
:
2898 len
+= snprintf(pbuffer
+len
, LPFC_CTL_ACC_BUF_SIZE
-len
,
2899 "Port SemReg: 0x%08x\n",
2900 readl(phba
->sli4_hba
.conf_regs_memmap_p
+
2901 LPFC_CTL_PORT_SEM_OFFSET
));
2903 case LPFC_CTL_PORT_STA
:
2904 len
+= snprintf(pbuffer
+len
, LPFC_CTL_ACC_BUF_SIZE
-len
,
2905 "Port StaReg: 0x%08x\n",
2906 readl(phba
->sli4_hba
.conf_regs_memmap_p
+
2907 LPFC_CTL_PORT_STA_OFFSET
));
2909 case LPFC_CTL_PORT_CTL
:
2910 len
+= snprintf(pbuffer
+len
, LPFC_CTL_ACC_BUF_SIZE
-len
,
2911 "Port CtlReg: 0x%08x\n",
2912 readl(phba
->sli4_hba
.conf_regs_memmap_p
+
2913 LPFC_CTL_PORT_CTL_OFFSET
));
2915 case LPFC_CTL_PORT_ER1
:
2916 len
+= snprintf(pbuffer
+len
, LPFC_CTL_ACC_BUF_SIZE
-len
,
2917 "Port Er1Reg: 0x%08x\n",
2918 readl(phba
->sli4_hba
.conf_regs_memmap_p
+
2919 LPFC_CTL_PORT_ER1_OFFSET
));
2921 case LPFC_CTL_PORT_ER2
:
2922 len
+= snprintf(pbuffer
+len
, LPFC_CTL_ACC_BUF_SIZE
-len
,
2923 "Port Er2Reg: 0x%08x\n",
2924 readl(phba
->sli4_hba
.conf_regs_memmap_p
+
2925 LPFC_CTL_PORT_ER2_OFFSET
));
2927 case LPFC_CTL_PDEV_CTL
:
2928 len
+= snprintf(pbuffer
+len
, LPFC_CTL_ACC_BUF_SIZE
-len
,
2929 "PDev CtlReg: 0x%08x\n",
2930 readl(phba
->sli4_hba
.conf_regs_memmap_p
+
2931 LPFC_CTL_PDEV_CTL_OFFSET
));
2940 * lpfc_idiag_ctlacc_read - idiag debugfs read port and device control register
2941 * @file: The file pointer to read from.
2942 * @buf: The buffer to copy the data to.
2943 * @nbytes: The number of bytes to read.
2944 * @ppos: The position in the file to start reading from.
2947 * This routine reads data from the @phba port and device registers according
2948 * to the idiag command, and copies to user @buf.
2951 * This function returns the amount of data that was read (this could be less
2952 * than @nbytes if the end of the file was reached) or a negative error value.
2955 lpfc_idiag_ctlacc_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
2958 struct lpfc_debug
*debug
= file
->private_data
;
2959 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
2960 uint32_t ctl_reg_id
, i
;
2964 /* This is a user read operation */
2965 debug
->op
= LPFC_IDIAG_OP_RD
;
2968 debug
->buffer
= kmalloc(LPFC_CTL_ACC_BUF_SIZE
, GFP_KERNEL
);
2971 pbuffer
= debug
->buffer
;
2976 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_RD
)
2977 ctl_reg_id
= idiag
.cmd
.data
[IDIAG_CTLACC_REGID_INDX
];
2981 if (ctl_reg_id
== LPFC_CTL_ACC_ALL
)
2982 for (i
= 1; i
<= LPFC_CTL_MAX
; i
++)
2983 len
= lpfc_idiag_ctlacc_read_reg(phba
,
2986 len
= lpfc_idiag_ctlacc_read_reg(phba
,
2987 pbuffer
, len
, ctl_reg_id
);
2989 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
2993 * lpfc_idiag_ctlacc_write - Syntax check and set up idiag ctlacc commands
2994 * @file: The file pointer to read from.
2995 * @buf: The buffer to copy the user data from.
2996 * @nbytes: The number of bytes to get.
2997 * @ppos: The position in the file to start reading from.
2999 * This routine get the debugfs idiag command struct from user space and then
3000 * perform the syntax check for port and device control register read (dump)
3001 * or write (set) command accordingly.
3003 * It returns the @nbytges passing in from debugfs user space when successful.
3004 * In case of error conditions, it returns proper error code back to the user
3008 lpfc_idiag_ctlacc_write(struct file
*file
, const char __user
*buf
,
3009 size_t nbytes
, loff_t
*ppos
)
3011 struct lpfc_debug
*debug
= file
->private_data
;
3012 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
3013 uint32_t ctl_reg_id
, value
, reg_val
= 0;
3014 void __iomem
*ctl_reg
;
3017 /* This is a user write operation */
3018 debug
->op
= LPFC_IDIAG_OP_WR
;
3020 rc
= lpfc_idiag_cmd_get(buf
, nbytes
, &idiag
.cmd
);
3024 /* Sanity check on command line arguments */
3025 ctl_reg_id
= idiag
.cmd
.data
[IDIAG_CTLACC_REGID_INDX
];
3026 value
= idiag
.cmd
.data
[IDIAG_CTLACC_VALUE_INDX
];
3028 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_WR
||
3029 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_ST
||
3030 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_CL
) {
3031 if (rc
!= LPFC_CTL_ACC_WR_CMD_ARG
)
3033 if (ctl_reg_id
> LPFC_CTL_MAX
)
3035 } else if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_RD
) {
3036 if (rc
!= LPFC_CTL_ACC_RD_CMD_ARG
)
3038 if ((ctl_reg_id
> LPFC_CTL_MAX
) &&
3039 (ctl_reg_id
!= LPFC_CTL_ACC_ALL
))
3044 /* Perform the write access operation */
3045 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_WR
||
3046 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_ST
||
3047 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_CL
) {
3048 switch (ctl_reg_id
) {
3049 case LPFC_CTL_PORT_SEM
:
3050 ctl_reg
= phba
->sli4_hba
.conf_regs_memmap_p
+
3051 LPFC_CTL_PORT_SEM_OFFSET
;
3053 case LPFC_CTL_PORT_STA
:
3054 ctl_reg
= phba
->sli4_hba
.conf_regs_memmap_p
+
3055 LPFC_CTL_PORT_STA_OFFSET
;
3057 case LPFC_CTL_PORT_CTL
:
3058 ctl_reg
= phba
->sli4_hba
.conf_regs_memmap_p
+
3059 LPFC_CTL_PORT_CTL_OFFSET
;
3061 case LPFC_CTL_PORT_ER1
:
3062 ctl_reg
= phba
->sli4_hba
.conf_regs_memmap_p
+
3063 LPFC_CTL_PORT_ER1_OFFSET
;
3065 case LPFC_CTL_PORT_ER2
:
3066 ctl_reg
= phba
->sli4_hba
.conf_regs_memmap_p
+
3067 LPFC_CTL_PORT_ER2_OFFSET
;
3069 case LPFC_CTL_PDEV_CTL
:
3070 ctl_reg
= phba
->sli4_hba
.conf_regs_memmap_p
+
3071 LPFC_CTL_PDEV_CTL_OFFSET
;
3077 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_WR
)
3079 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_ST
) {
3080 reg_val
= readl(ctl_reg
);
3083 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_CL
) {
3084 reg_val
= readl(ctl_reg
);
3087 writel(reg_val
, ctl_reg
);
3088 readl(ctl_reg
); /* flush */
3093 /* Clean out command structure on command error out */
3094 memset(&idiag
, 0, sizeof(idiag
));
3099 * lpfc_idiag_mbxacc_get_setup - idiag debugfs get mailbox access setup
3100 * @phba: Pointer to HBA context object.
3101 * @pbuffer: Pointer to data buffer.
3104 * This routine gets the driver mailbox access debugfs setup information.
3107 * This function returns the amount of data that was read (this could be less
3108 * than @nbytes if the end of the file was reached) or a negative error value.
3111 lpfc_idiag_mbxacc_get_setup(struct lpfc_hba
*phba
, char *pbuffer
)
3113 uint32_t mbx_dump_map
, mbx_dump_cnt
, mbx_word_cnt
, mbx_mbox_cmd
;
3116 mbx_mbox_cmd
= idiag
.cmd
.data
[IDIAG_MBXACC_MBCMD_INDX
];
3117 mbx_dump_map
= idiag
.cmd
.data
[IDIAG_MBXACC_DPMAP_INDX
];
3118 mbx_dump_cnt
= idiag
.cmd
.data
[IDIAG_MBXACC_DPCNT_INDX
];
3119 mbx_word_cnt
= idiag
.cmd
.data
[IDIAG_MBXACC_WDCNT_INDX
];
3121 len
+= snprintf(pbuffer
+len
, LPFC_MBX_ACC_BUF_SIZE
-len
,
3122 "mbx_dump_map: 0x%08x\n", mbx_dump_map
);
3123 len
+= snprintf(pbuffer
+len
, LPFC_MBX_ACC_BUF_SIZE
-len
,
3124 "mbx_dump_cnt: %04d\n", mbx_dump_cnt
);
3125 len
+= snprintf(pbuffer
+len
, LPFC_MBX_ACC_BUF_SIZE
-len
,
3126 "mbx_word_cnt: %04d\n", mbx_word_cnt
);
3127 len
+= snprintf(pbuffer
+len
, LPFC_MBX_ACC_BUF_SIZE
-len
,
3128 "mbx_mbox_cmd: 0x%02x\n", mbx_mbox_cmd
);
3134 * lpfc_idiag_mbxacc_read - idiag debugfs read on mailbox access
3135 * @file: The file pointer to read from.
3136 * @buf: The buffer to copy the data to.
3137 * @nbytes: The number of bytes to read.
3138 * @ppos: The position in the file to start reading from.
3141 * This routine reads data from the @phba driver mailbox access debugfs setup
3145 * This function returns the amount of data that was read (this could be less
3146 * than @nbytes if the end of the file was reached) or a negative error value.
3149 lpfc_idiag_mbxacc_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
3152 struct lpfc_debug
*debug
= file
->private_data
;
3153 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
3157 /* This is a user read operation */
3158 debug
->op
= LPFC_IDIAG_OP_RD
;
3161 debug
->buffer
= kmalloc(LPFC_MBX_ACC_BUF_SIZE
, GFP_KERNEL
);
3164 pbuffer
= debug
->buffer
;
3169 if ((idiag
.cmd
.opcode
!= LPFC_IDIAG_CMD_MBXACC_DP
) &&
3170 (idiag
.cmd
.opcode
!= LPFC_IDIAG_BSG_MBXACC_DP
))
3173 len
= lpfc_idiag_mbxacc_get_setup(phba
, pbuffer
);
3175 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
3179 * lpfc_idiag_mbxacc_write - Syntax check and set up idiag mbxacc commands
3180 * @file: The file pointer to read from.
3181 * @buf: The buffer to copy the user data from.
3182 * @nbytes: The number of bytes to get.
3183 * @ppos: The position in the file to start reading from.
3185 * This routine get the debugfs idiag command struct from user space and then
3186 * perform the syntax check for driver mailbox command (dump) and sets up the
3187 * necessary states in the idiag command struct accordingly.
3189 * It returns the @nbytges passing in from debugfs user space when successful.
3190 * In case of error conditions, it returns proper error code back to the user
3194 lpfc_idiag_mbxacc_write(struct file
*file
, const char __user
*buf
,
3195 size_t nbytes
, loff_t
*ppos
)
3197 struct lpfc_debug
*debug
= file
->private_data
;
3198 uint32_t mbx_dump_map
, mbx_dump_cnt
, mbx_word_cnt
, mbx_mbox_cmd
;
3201 /* This is a user write operation */
3202 debug
->op
= LPFC_IDIAG_OP_WR
;
3204 rc
= lpfc_idiag_cmd_get(buf
, nbytes
, &idiag
.cmd
);
3208 /* Sanity check on command line arguments */
3209 mbx_mbox_cmd
= idiag
.cmd
.data
[IDIAG_MBXACC_MBCMD_INDX
];
3210 mbx_dump_map
= idiag
.cmd
.data
[IDIAG_MBXACC_DPMAP_INDX
];
3211 mbx_dump_cnt
= idiag
.cmd
.data
[IDIAG_MBXACC_DPCNT_INDX
];
3212 mbx_word_cnt
= idiag
.cmd
.data
[IDIAG_MBXACC_WDCNT_INDX
];
3214 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_MBXACC_DP
) {
3215 if (!(mbx_dump_map
& LPFC_MBX_DMP_MBX_ALL
))
3217 if ((mbx_dump_map
& ~LPFC_MBX_DMP_MBX_ALL
) &&
3218 (mbx_dump_map
!= LPFC_MBX_DMP_ALL
))
3220 if (mbx_word_cnt
> sizeof(MAILBOX_t
))
3222 } else if (idiag
.cmd
.opcode
== LPFC_IDIAG_BSG_MBXACC_DP
) {
3223 if (!(mbx_dump_map
& LPFC_BSG_DMP_MBX_ALL
))
3225 if ((mbx_dump_map
& ~LPFC_BSG_DMP_MBX_ALL
) &&
3226 (mbx_dump_map
!= LPFC_MBX_DMP_ALL
))
3228 if (mbx_word_cnt
> (BSG_MBOX_SIZE
)/4)
3230 if (mbx_mbox_cmd
!= 0x9b)
3235 if (mbx_word_cnt
== 0)
3237 if (rc
!= LPFC_MBX_DMP_ARG
)
3239 if (mbx_mbox_cmd
& ~0xff)
3242 /* condition for stop mailbox dump */
3243 if (mbx_dump_cnt
== 0)
3249 /* Clean out command structure on command error out */
3250 memset(&idiag
, 0, sizeof(idiag
));
3254 /* Clean out command structure on command error out */
3255 memset(&idiag
, 0, sizeof(idiag
));
3260 * lpfc_idiag_extacc_avail_get - get the available extents information
3261 * @phba: pointer to lpfc hba data structure.
3262 * @pbuffer: pointer to internal buffer.
3263 * @len: length into the internal buffer data has been copied.
3266 * This routine is to get the available extent information.
3269 * overall lenth of the data read into the internal buffer.
3272 lpfc_idiag_extacc_avail_get(struct lpfc_hba
*phba
, char *pbuffer
, int len
)
3274 uint16_t ext_cnt
, ext_size
;
3276 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
3277 "\nAvailable Extents Information:\n");
3279 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
3280 "\tPort Available VPI extents: ");
3281 lpfc_sli4_get_avail_extnt_rsrc(phba
, LPFC_RSC_TYPE_FCOE_VPI
,
3282 &ext_cnt
, &ext_size
);
3283 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
3284 "Count %3d, Size %3d\n", ext_cnt
, ext_size
);
3286 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
3287 "\tPort Available VFI extents: ");
3288 lpfc_sli4_get_avail_extnt_rsrc(phba
, LPFC_RSC_TYPE_FCOE_VFI
,
3289 &ext_cnt
, &ext_size
);
3290 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
3291 "Count %3d, Size %3d\n", ext_cnt
, ext_size
);
3293 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
3294 "\tPort Available RPI extents: ");
3295 lpfc_sli4_get_avail_extnt_rsrc(phba
, LPFC_RSC_TYPE_FCOE_RPI
,
3296 &ext_cnt
, &ext_size
);
3297 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
3298 "Count %3d, Size %3d\n", ext_cnt
, ext_size
);
3300 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
3301 "\tPort Available XRI extents: ");
3302 lpfc_sli4_get_avail_extnt_rsrc(phba
, LPFC_RSC_TYPE_FCOE_XRI
,
3303 &ext_cnt
, &ext_size
);
3304 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
3305 "Count %3d, Size %3d\n", ext_cnt
, ext_size
);
3311 * lpfc_idiag_extacc_alloc_get - get the allocated extents information
3312 * @phba: pointer to lpfc hba data structure.
3313 * @pbuffer: pointer to internal buffer.
3314 * @len: length into the internal buffer data has been copied.
3317 * This routine is to get the allocated extent information.
3320 * overall lenth of the data read into the internal buffer.
3323 lpfc_idiag_extacc_alloc_get(struct lpfc_hba
*phba
, char *pbuffer
, int len
)
3325 uint16_t ext_cnt
, ext_size
;
3328 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
3329 "\nAllocated Extents Information:\n");
3331 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
3332 "\tHost Allocated VPI extents: ");
3333 rc
= lpfc_sli4_get_allocated_extnts(phba
, LPFC_RSC_TYPE_FCOE_VPI
,
3334 &ext_cnt
, &ext_size
);
3336 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
3337 "Port %d Extent %3d, Size %3d\n",
3338 phba
->brd_no
, ext_cnt
, ext_size
);
3340 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
3343 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
3344 "\tHost Allocated VFI extents: ");
3345 rc
= lpfc_sli4_get_allocated_extnts(phba
, LPFC_RSC_TYPE_FCOE_VFI
,
3346 &ext_cnt
, &ext_size
);
3348 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
3349 "Port %d Extent %3d, Size %3d\n",
3350 phba
->brd_no
, ext_cnt
, ext_size
);
3352 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
3355 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
3356 "\tHost Allocated RPI extents: ");
3357 rc
= lpfc_sli4_get_allocated_extnts(phba
, LPFC_RSC_TYPE_FCOE_RPI
,
3358 &ext_cnt
, &ext_size
);
3360 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
3361 "Port %d Extent %3d, Size %3d\n",
3362 phba
->brd_no
, ext_cnt
, ext_size
);
3364 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
3367 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
3368 "\tHost Allocated XRI extents: ");
3369 rc
= lpfc_sli4_get_allocated_extnts(phba
, LPFC_RSC_TYPE_FCOE_XRI
,
3370 &ext_cnt
, &ext_size
);
3372 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
3373 "Port %d Extent %3d, Size %3d\n",
3374 phba
->brd_no
, ext_cnt
, ext_size
);
3376 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
3383 * lpfc_idiag_extacc_drivr_get - get driver extent information
3384 * @phba: pointer to lpfc hba data structure.
3385 * @pbuffer: pointer to internal buffer.
3386 * @len: length into the internal buffer data has been copied.
3389 * This routine is to get the driver extent information.
3392 * overall lenth of the data read into the internal buffer.
3395 lpfc_idiag_extacc_drivr_get(struct lpfc_hba
*phba
, char *pbuffer
, int len
)
3397 struct lpfc_rsrc_blks
*rsrc_blks
;
3400 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
3401 "\nDriver Extents Information:\n");
3403 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
3404 "\tVPI extents:\n");
3406 list_for_each_entry(rsrc_blks
, &phba
->lpfc_vpi_blk_list
, list
) {
3407 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
3408 "\t\tBlock %3d: Start %4d, Count %4d\n",
3409 index
, rsrc_blks
->rsrc_start
,
3410 rsrc_blks
->rsrc_size
);
3413 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
3414 "\tVFI extents:\n");
3416 list_for_each_entry(rsrc_blks
, &phba
->sli4_hba
.lpfc_vfi_blk_list
,
3418 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
3419 "\t\tBlock %3d: Start %4d, Count %4d\n",
3420 index
, rsrc_blks
->rsrc_start
,
3421 rsrc_blks
->rsrc_size
);
3425 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
3426 "\tRPI extents:\n");
3428 list_for_each_entry(rsrc_blks
, &phba
->sli4_hba
.lpfc_rpi_blk_list
,
3430 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
3431 "\t\tBlock %3d: Start %4d, Count %4d\n",
3432 index
, rsrc_blks
->rsrc_start
,
3433 rsrc_blks
->rsrc_size
);
3437 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
3438 "\tXRI extents:\n");
3440 list_for_each_entry(rsrc_blks
, &phba
->sli4_hba
.lpfc_xri_blk_list
,
3442 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
3443 "\t\tBlock %3d: Start %4d, Count %4d\n",
3444 index
, rsrc_blks
->rsrc_start
,
3445 rsrc_blks
->rsrc_size
);
3453 * lpfc_idiag_extacc_write - Syntax check and set up idiag extacc commands
3454 * @file: The file pointer to read from.
3455 * @buf: The buffer to copy the user data from.
3456 * @nbytes: The number of bytes to get.
3457 * @ppos: The position in the file to start reading from.
3459 * This routine get the debugfs idiag command struct from user space and then
3460 * perform the syntax check for extent information access commands and sets
3461 * up the necessary states in the idiag command struct accordingly.
3463 * It returns the @nbytges passing in from debugfs user space when successful.
3464 * In case of error conditions, it returns proper error code back to the user
3468 lpfc_idiag_extacc_write(struct file
*file
, const char __user
*buf
,
3469 size_t nbytes
, loff_t
*ppos
)
3471 struct lpfc_debug
*debug
= file
->private_data
;
3475 /* This is a user write operation */
3476 debug
->op
= LPFC_IDIAG_OP_WR
;
3478 rc
= lpfc_idiag_cmd_get(buf
, nbytes
, &idiag
.cmd
);
3482 ext_map
= idiag
.cmd
.data
[IDIAG_EXTACC_EXMAP_INDX
];
3484 if (idiag
.cmd
.opcode
!= LPFC_IDIAG_CMD_EXTACC_RD
)
3486 if (rc
!= LPFC_EXT_ACC_CMD_ARG
)
3488 if (!(ext_map
& LPFC_EXT_ACC_ALL
))
3493 /* Clean out command structure on command error out */
3494 memset(&idiag
, 0, sizeof(idiag
));
3499 * lpfc_idiag_extacc_read - idiag debugfs read access to extent information
3500 * @file: The file pointer to read from.
3501 * @buf: The buffer to copy the data to.
3502 * @nbytes: The number of bytes to read.
3503 * @ppos: The position in the file to start reading from.
3506 * This routine reads data from the proper extent information according to
3507 * the idiag command, and copies to user @buf.
3510 * This function returns the amount of data that was read (this could be less
3511 * than @nbytes if the end of the file was reached) or a negative error value.
3514 lpfc_idiag_extacc_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
3517 struct lpfc_debug
*debug
= file
->private_data
;
3518 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
3523 /* This is a user read operation */
3524 debug
->op
= LPFC_IDIAG_OP_RD
;
3527 debug
->buffer
= kmalloc(LPFC_EXT_ACC_BUF_SIZE
, GFP_KERNEL
);
3530 pbuffer
= debug
->buffer
;
3533 if (idiag
.cmd
.opcode
!= LPFC_IDIAG_CMD_EXTACC_RD
)
3536 ext_map
= idiag
.cmd
.data
[IDIAG_EXTACC_EXMAP_INDX
];
3537 if (ext_map
& LPFC_EXT_ACC_AVAIL
)
3538 len
= lpfc_idiag_extacc_avail_get(phba
, pbuffer
, len
);
3539 if (ext_map
& LPFC_EXT_ACC_ALLOC
)
3540 len
= lpfc_idiag_extacc_alloc_get(phba
, pbuffer
, len
);
3541 if (ext_map
& LPFC_EXT_ACC_DRIVR
)
3542 len
= lpfc_idiag_extacc_drivr_get(phba
, pbuffer
, len
);
3544 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
3547 #undef lpfc_debugfs_op_disc_trc
3548 static const struct file_operations lpfc_debugfs_op_disc_trc
= {
3549 .owner
= THIS_MODULE
,
3550 .open
= lpfc_debugfs_disc_trc_open
,
3551 .llseek
= lpfc_debugfs_lseek
,
3552 .read
= lpfc_debugfs_read
,
3553 .release
= lpfc_debugfs_release
,
3556 #undef lpfc_debugfs_op_nodelist
3557 static const struct file_operations lpfc_debugfs_op_nodelist
= {
3558 .owner
= THIS_MODULE
,
3559 .open
= lpfc_debugfs_nodelist_open
,
3560 .llseek
= lpfc_debugfs_lseek
,
3561 .read
= lpfc_debugfs_read
,
3562 .release
= lpfc_debugfs_release
,
3565 #undef lpfc_debugfs_op_hbqinfo
3566 static const struct file_operations lpfc_debugfs_op_hbqinfo
= {
3567 .owner
= THIS_MODULE
,
3568 .open
= lpfc_debugfs_hbqinfo_open
,
3569 .llseek
= lpfc_debugfs_lseek
,
3570 .read
= lpfc_debugfs_read
,
3571 .release
= lpfc_debugfs_release
,
3574 #undef lpfc_debugfs_op_dumpHBASlim
3575 static const struct file_operations lpfc_debugfs_op_dumpHBASlim
= {
3576 .owner
= THIS_MODULE
,
3577 .open
= lpfc_debugfs_dumpHBASlim_open
,
3578 .llseek
= lpfc_debugfs_lseek
,
3579 .read
= lpfc_debugfs_read
,
3580 .release
= lpfc_debugfs_release
,
3583 #undef lpfc_debugfs_op_dumpHostSlim
3584 static const struct file_operations lpfc_debugfs_op_dumpHostSlim
= {
3585 .owner
= THIS_MODULE
,
3586 .open
= lpfc_debugfs_dumpHostSlim_open
,
3587 .llseek
= lpfc_debugfs_lseek
,
3588 .read
= lpfc_debugfs_read
,
3589 .release
= lpfc_debugfs_release
,
3592 #undef lpfc_debugfs_op_dumpData
3593 static const struct file_operations lpfc_debugfs_op_dumpData
= {
3594 .owner
= THIS_MODULE
,
3595 .open
= lpfc_debugfs_dumpData_open
,
3596 .llseek
= lpfc_debugfs_lseek
,
3597 .read
= lpfc_debugfs_read
,
3598 .write
= lpfc_debugfs_dumpDataDif_write
,
3599 .release
= lpfc_debugfs_dumpDataDif_release
,
3602 #undef lpfc_debugfs_op_dumpDif
3603 static const struct file_operations lpfc_debugfs_op_dumpDif
= {
3604 .owner
= THIS_MODULE
,
3605 .open
= lpfc_debugfs_dumpDif_open
,
3606 .llseek
= lpfc_debugfs_lseek
,
3607 .read
= lpfc_debugfs_read
,
3608 .write
= lpfc_debugfs_dumpDataDif_write
,
3609 .release
= lpfc_debugfs_dumpDataDif_release
,
3612 #undef lpfc_debugfs_op_dif_err
3613 static const struct file_operations lpfc_debugfs_op_dif_err
= {
3614 .owner
= THIS_MODULE
,
3615 .open
= simple_open
,
3616 .llseek
= lpfc_debugfs_lseek
,
3617 .read
= lpfc_debugfs_dif_err_read
,
3618 .write
= lpfc_debugfs_dif_err_write
,
3619 .release
= lpfc_debugfs_dif_err_release
,
3622 #undef lpfc_debugfs_op_slow_ring_trc
3623 static const struct file_operations lpfc_debugfs_op_slow_ring_trc
= {
3624 .owner
= THIS_MODULE
,
3625 .open
= lpfc_debugfs_slow_ring_trc_open
,
3626 .llseek
= lpfc_debugfs_lseek
,
3627 .read
= lpfc_debugfs_read
,
3628 .release
= lpfc_debugfs_release
,
3631 static struct dentry
*lpfc_debugfs_root
= NULL
;
3632 static atomic_t lpfc_debugfs_hba_count
;
3635 * File operations for the iDiag debugfs
3637 #undef lpfc_idiag_op_pciCfg
3638 static const struct file_operations lpfc_idiag_op_pciCfg
= {
3639 .owner
= THIS_MODULE
,
3640 .open
= lpfc_idiag_open
,
3641 .llseek
= lpfc_debugfs_lseek
,
3642 .read
= lpfc_idiag_pcicfg_read
,
3643 .write
= lpfc_idiag_pcicfg_write
,
3644 .release
= lpfc_idiag_cmd_release
,
3647 #undef lpfc_idiag_op_barAcc
3648 static const struct file_operations lpfc_idiag_op_barAcc
= {
3649 .owner
= THIS_MODULE
,
3650 .open
= lpfc_idiag_open
,
3651 .llseek
= lpfc_debugfs_lseek
,
3652 .read
= lpfc_idiag_baracc_read
,
3653 .write
= lpfc_idiag_baracc_write
,
3654 .release
= lpfc_idiag_cmd_release
,
3657 #undef lpfc_idiag_op_queInfo
3658 static const struct file_operations lpfc_idiag_op_queInfo
= {
3659 .owner
= THIS_MODULE
,
3660 .open
= lpfc_idiag_open
,
3661 .read
= lpfc_idiag_queinfo_read
,
3662 .release
= lpfc_idiag_release
,
3665 #undef lpfc_idiag_op_queAcc
3666 static const struct file_operations lpfc_idiag_op_queAcc
= {
3667 .owner
= THIS_MODULE
,
3668 .open
= lpfc_idiag_open
,
3669 .llseek
= lpfc_debugfs_lseek
,
3670 .read
= lpfc_idiag_queacc_read
,
3671 .write
= lpfc_idiag_queacc_write
,
3672 .release
= lpfc_idiag_cmd_release
,
3675 #undef lpfc_idiag_op_drbAcc
3676 static const struct file_operations lpfc_idiag_op_drbAcc
= {
3677 .owner
= THIS_MODULE
,
3678 .open
= lpfc_idiag_open
,
3679 .llseek
= lpfc_debugfs_lseek
,
3680 .read
= lpfc_idiag_drbacc_read
,
3681 .write
= lpfc_idiag_drbacc_write
,
3682 .release
= lpfc_idiag_cmd_release
,
3685 #undef lpfc_idiag_op_ctlAcc
3686 static const struct file_operations lpfc_idiag_op_ctlAcc
= {
3687 .owner
= THIS_MODULE
,
3688 .open
= lpfc_idiag_open
,
3689 .llseek
= lpfc_debugfs_lseek
,
3690 .read
= lpfc_idiag_ctlacc_read
,
3691 .write
= lpfc_idiag_ctlacc_write
,
3692 .release
= lpfc_idiag_cmd_release
,
3695 #undef lpfc_idiag_op_mbxAcc
3696 static const struct file_operations lpfc_idiag_op_mbxAcc
= {
3697 .owner
= THIS_MODULE
,
3698 .open
= lpfc_idiag_open
,
3699 .llseek
= lpfc_debugfs_lseek
,
3700 .read
= lpfc_idiag_mbxacc_read
,
3701 .write
= lpfc_idiag_mbxacc_write
,
3702 .release
= lpfc_idiag_cmd_release
,
3705 #undef lpfc_idiag_op_extAcc
3706 static const struct file_operations lpfc_idiag_op_extAcc
= {
3707 .owner
= THIS_MODULE
,
3708 .open
= lpfc_idiag_open
,
3709 .llseek
= lpfc_debugfs_lseek
,
3710 .read
= lpfc_idiag_extacc_read
,
3711 .write
= lpfc_idiag_extacc_write
,
3712 .release
= lpfc_idiag_cmd_release
,
3717 /* lpfc_idiag_mbxacc_dump_bsg_mbox - idiag debugfs dump bsg mailbox command
3718 * @phba: Pointer to HBA context object.
3719 * @dmabuf: Pointer to a DMA buffer descriptor.
3722 * This routine dump a bsg pass-through non-embedded mailbox command with
3726 lpfc_idiag_mbxacc_dump_bsg_mbox(struct lpfc_hba
*phba
, enum nemb_type nemb_tp
,
3727 enum mbox_type mbox_tp
, enum dma_type dma_tp
,
3728 enum sta_type sta_tp
,
3729 struct lpfc_dmabuf
*dmabuf
, uint32_t ext_buf
)
3731 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
3732 uint32_t *mbx_mbox_cmd
, *mbx_dump_map
, *mbx_dump_cnt
, *mbx_word_cnt
;
3733 char line_buf
[LPFC_MBX_ACC_LBUF_SZ
];
3735 uint32_t do_dump
= 0;
3739 if (idiag
.cmd
.opcode
!= LPFC_IDIAG_BSG_MBXACC_DP
)
3742 mbx_mbox_cmd
= &idiag
.cmd
.data
[IDIAG_MBXACC_MBCMD_INDX
];
3743 mbx_dump_map
= &idiag
.cmd
.data
[IDIAG_MBXACC_DPMAP_INDX
];
3744 mbx_dump_cnt
= &idiag
.cmd
.data
[IDIAG_MBXACC_DPCNT_INDX
];
3745 mbx_word_cnt
= &idiag
.cmd
.data
[IDIAG_MBXACC_WDCNT_INDX
];
3747 if (!(*mbx_dump_map
& LPFC_MBX_DMP_ALL
) ||
3748 (*mbx_dump_cnt
== 0) ||
3749 (*mbx_word_cnt
== 0))
3752 if (*mbx_mbox_cmd
!= 0x9B)
3755 if ((mbox_tp
== mbox_rd
) && (dma_tp
== dma_mbox
)) {
3756 if (*mbx_dump_map
& LPFC_BSG_DMP_MBX_RD_MBX
) {
3757 do_dump
|= LPFC_BSG_DMP_MBX_RD_MBX
;
3758 printk(KERN_ERR
"\nRead mbox command (x%x), "
3759 "nemb:0x%x, extbuf_cnt:%d:\n",
3760 sta_tp
, nemb_tp
, ext_buf
);
3763 if ((mbox_tp
== mbox_rd
) && (dma_tp
== dma_ebuf
)) {
3764 if (*mbx_dump_map
& LPFC_BSG_DMP_MBX_RD_BUF
) {
3765 do_dump
|= LPFC_BSG_DMP_MBX_RD_BUF
;
3766 printk(KERN_ERR
"\nRead mbox buffer (x%x), "
3767 "nemb:0x%x, extbuf_seq:%d:\n",
3768 sta_tp
, nemb_tp
, ext_buf
);
3771 if ((mbox_tp
== mbox_wr
) && (dma_tp
== dma_mbox
)) {
3772 if (*mbx_dump_map
& LPFC_BSG_DMP_MBX_WR_MBX
) {
3773 do_dump
|= LPFC_BSG_DMP_MBX_WR_MBX
;
3774 printk(KERN_ERR
"\nWrite mbox command (x%x), "
3775 "nemb:0x%x, extbuf_cnt:%d:\n",
3776 sta_tp
, nemb_tp
, ext_buf
);
3779 if ((mbox_tp
== mbox_wr
) && (dma_tp
== dma_ebuf
)) {
3780 if (*mbx_dump_map
& LPFC_BSG_DMP_MBX_WR_BUF
) {
3781 do_dump
|= LPFC_BSG_DMP_MBX_WR_BUF
;
3782 printk(KERN_ERR
"\nWrite mbox buffer (x%x), "
3783 "nemb:0x%x, extbuf_seq:%d:\n",
3784 sta_tp
, nemb_tp
, ext_buf
);
3788 /* dump buffer content */
3790 pword
= (uint32_t *)dmabuf
->virt
;
3791 for (i
= 0; i
< *mbx_word_cnt
; i
++) {
3794 printk(KERN_ERR
"%s\n", line_buf
);
3796 len
+= snprintf(line_buf
+len
,
3797 LPFC_MBX_ACC_LBUF_SZ
-len
,
3800 len
+= snprintf(line_buf
+len
, LPFC_MBX_ACC_LBUF_SZ
-len
,
3801 "%08x ", (uint32_t)*pword
);
3805 printk(KERN_ERR
"%s\n", line_buf
);
3809 /* Clean out command structure on reaching dump count */
3810 if (*mbx_dump_cnt
== 0)
3811 memset(&idiag
, 0, sizeof(idiag
));
3816 /* lpfc_idiag_mbxacc_dump_issue_mbox - idiag debugfs dump issue mailbox command
3817 * @phba: Pointer to HBA context object.
3818 * @dmabuf: Pointer to a DMA buffer descriptor.
3821 * This routine dump a pass-through non-embedded mailbox command from issue
3825 lpfc_idiag_mbxacc_dump_issue_mbox(struct lpfc_hba
*phba
, MAILBOX_t
*pmbox
)
3827 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
3828 uint32_t *mbx_dump_map
, *mbx_dump_cnt
, *mbx_word_cnt
, *mbx_mbox_cmd
;
3829 char line_buf
[LPFC_MBX_ACC_LBUF_SZ
];
3835 if (idiag
.cmd
.opcode
!= LPFC_IDIAG_CMD_MBXACC_DP
)
3838 mbx_mbox_cmd
= &idiag
.cmd
.data
[IDIAG_MBXACC_MBCMD_INDX
];
3839 mbx_dump_map
= &idiag
.cmd
.data
[IDIAG_MBXACC_DPMAP_INDX
];
3840 mbx_dump_cnt
= &idiag
.cmd
.data
[IDIAG_MBXACC_DPCNT_INDX
];
3841 mbx_word_cnt
= &idiag
.cmd
.data
[IDIAG_MBXACC_WDCNT_INDX
];
3843 if (!(*mbx_dump_map
& LPFC_MBX_DMP_MBX_ALL
) ||
3844 (*mbx_dump_cnt
== 0) ||
3845 (*mbx_word_cnt
== 0))
3848 if ((*mbx_mbox_cmd
!= LPFC_MBX_ALL_CMD
) &&
3849 (*mbx_mbox_cmd
!= pmbox
->mbxCommand
))
3852 /* dump buffer content */
3853 if (*mbx_dump_map
& LPFC_MBX_DMP_MBX_WORD
) {
3854 printk(KERN_ERR
"Mailbox command:0x%x dump by word:\n",
3856 pword
= (uint32_t *)pmbox
;
3857 for (i
= 0; i
< *mbx_word_cnt
; i
++) {
3860 printk(KERN_ERR
"%s\n", line_buf
);
3862 memset(line_buf
, 0, LPFC_MBX_ACC_LBUF_SZ
);
3863 len
+= snprintf(line_buf
+len
,
3864 LPFC_MBX_ACC_LBUF_SZ
-len
,
3867 len
+= snprintf(line_buf
+len
, LPFC_MBX_ACC_LBUF_SZ
-len
,
3869 ((uint32_t)*pword
) & 0xffffffff);
3873 printk(KERN_ERR
"%s\n", line_buf
);
3874 printk(KERN_ERR
"\n");
3876 if (*mbx_dump_map
& LPFC_MBX_DMP_MBX_BYTE
) {
3877 printk(KERN_ERR
"Mailbox command:0x%x dump by byte:\n",
3879 pbyte
= (uint8_t *)pmbox
;
3880 for (i
= 0; i
< *mbx_word_cnt
; i
++) {
3883 printk(KERN_ERR
"%s\n", line_buf
);
3885 memset(line_buf
, 0, LPFC_MBX_ACC_LBUF_SZ
);
3886 len
+= snprintf(line_buf
+len
,
3887 LPFC_MBX_ACC_LBUF_SZ
-len
,
3890 for (j
= 0; j
< 4; j
++) {
3891 len
+= snprintf(line_buf
+len
,
3892 LPFC_MBX_ACC_LBUF_SZ
-len
,
3894 ((uint8_t)*pbyte
) & 0xff);
3897 len
+= snprintf(line_buf
+len
,
3898 LPFC_MBX_ACC_LBUF_SZ
-len
, " ");
3901 printk(KERN_ERR
"%s\n", line_buf
);
3902 printk(KERN_ERR
"\n");
3906 /* Clean out command structure on reaching dump count */
3907 if (*mbx_dump_cnt
== 0)
3908 memset(&idiag
, 0, sizeof(idiag
));
3914 * lpfc_debugfs_initialize - Initialize debugfs for a vport
3915 * @vport: The vport pointer to initialize.
3918 * When Debugfs is configured this routine sets up the lpfc debugfs file system.
3919 * If not already created, this routine will create the lpfc directory, and
3920 * lpfcX directory (for this HBA), and vportX directory for this vport. It will
3921 * also create each file used to access lpfc specific debugfs information.
3924 lpfc_debugfs_initialize(struct lpfc_vport
*vport
)
3926 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
3927 struct lpfc_hba
*phba
= vport
->phba
;
3931 if (!lpfc_debugfs_enable
)
3934 /* Setup lpfc root directory */
3935 if (!lpfc_debugfs_root
) {
3936 lpfc_debugfs_root
= debugfs_create_dir("lpfc", NULL
);
3937 atomic_set(&lpfc_debugfs_hba_count
, 0);
3938 if (!lpfc_debugfs_root
) {
3939 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3940 "0408 Cannot create debugfs root\n");
3944 if (!lpfc_debugfs_start_time
)
3945 lpfc_debugfs_start_time
= jiffies
;
3947 /* Setup funcX directory for specific HBA PCI function */
3948 snprintf(name
, sizeof(name
), "fn%d", phba
->brd_no
);
3949 if (!phba
->hba_debugfs_root
) {
3950 phba
->hba_debugfs_root
=
3951 debugfs_create_dir(name
, lpfc_debugfs_root
);
3952 if (!phba
->hba_debugfs_root
) {
3953 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3954 "0412 Cannot create debugfs hba\n");
3957 atomic_inc(&lpfc_debugfs_hba_count
);
3958 atomic_set(&phba
->debugfs_vport_count
, 0);
3961 snprintf(name
, sizeof(name
), "hbqinfo");
3962 phba
->debug_hbqinfo
=
3963 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
3964 phba
->hba_debugfs_root
,
3965 phba
, &lpfc_debugfs_op_hbqinfo
);
3966 if (!phba
->debug_hbqinfo
) {
3967 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3968 "0411 Cannot create debugfs hbqinfo\n");
3972 /* Setup dumpHBASlim */
3973 if (phba
->sli_rev
< LPFC_SLI_REV4
) {
3974 snprintf(name
, sizeof(name
), "dumpHBASlim");
3975 phba
->debug_dumpHBASlim
=
3976 debugfs_create_file(name
,
3977 S_IFREG
|S_IRUGO
|S_IWUSR
,
3978 phba
->hba_debugfs_root
,
3979 phba
, &lpfc_debugfs_op_dumpHBASlim
);
3980 if (!phba
->debug_dumpHBASlim
) {
3981 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3982 "0413 Cannot create debugfs "
3987 phba
->debug_dumpHBASlim
= NULL
;
3989 /* Setup dumpHostSlim */
3990 if (phba
->sli_rev
< LPFC_SLI_REV4
) {
3991 snprintf(name
, sizeof(name
), "dumpHostSlim");
3992 phba
->debug_dumpHostSlim
=
3993 debugfs_create_file(name
,
3994 S_IFREG
|S_IRUGO
|S_IWUSR
,
3995 phba
->hba_debugfs_root
,
3996 phba
, &lpfc_debugfs_op_dumpHostSlim
);
3997 if (!phba
->debug_dumpHostSlim
) {
3998 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3999 "0414 Cannot create debugfs "
4004 phba
->debug_dumpHBASlim
= NULL
;
4006 /* Setup dumpData */
4007 snprintf(name
, sizeof(name
), "dumpData");
4008 phba
->debug_dumpData
=
4009 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
4010 phba
->hba_debugfs_root
,
4011 phba
, &lpfc_debugfs_op_dumpData
);
4012 if (!phba
->debug_dumpData
) {
4013 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
4014 "0800 Cannot create debugfs dumpData\n");
4019 snprintf(name
, sizeof(name
), "dumpDif");
4020 phba
->debug_dumpDif
=
4021 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
4022 phba
->hba_debugfs_root
,
4023 phba
, &lpfc_debugfs_op_dumpDif
);
4024 if (!phba
->debug_dumpDif
) {
4025 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
4026 "0801 Cannot create debugfs dumpDif\n");
4030 /* Setup DIF Error Injections */
4031 snprintf(name
, sizeof(name
), "InjErrLBA");
4032 phba
->debug_InjErrLBA
=
4033 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
4034 phba
->hba_debugfs_root
,
4035 phba
, &lpfc_debugfs_op_dif_err
);
4036 if (!phba
->debug_InjErrLBA
) {
4037 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
4038 "0807 Cannot create debugfs InjErrLBA\n");
4041 phba
->lpfc_injerr_lba
= LPFC_INJERR_LBA_OFF
;
4043 snprintf(name
, sizeof(name
), "InjErrNPortID");
4044 phba
->debug_InjErrNPortID
=
4045 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
4046 phba
->hba_debugfs_root
,
4047 phba
, &lpfc_debugfs_op_dif_err
);
4048 if (!phba
->debug_InjErrNPortID
) {
4049 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
4050 "0809 Cannot create debugfs InjErrNPortID\n");
4054 snprintf(name
, sizeof(name
), "InjErrWWPN");
4055 phba
->debug_InjErrWWPN
=
4056 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
4057 phba
->hba_debugfs_root
,
4058 phba
, &lpfc_debugfs_op_dif_err
);
4059 if (!phba
->debug_InjErrWWPN
) {
4060 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
4061 "0810 Cannot create debugfs InjErrWWPN\n");
4065 snprintf(name
, sizeof(name
), "writeGuardInjErr");
4066 phba
->debug_writeGuard
=
4067 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
4068 phba
->hba_debugfs_root
,
4069 phba
, &lpfc_debugfs_op_dif_err
);
4070 if (!phba
->debug_writeGuard
) {
4071 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
4072 "0802 Cannot create debugfs writeGuard\n");
4076 snprintf(name
, sizeof(name
), "writeAppInjErr");
4077 phba
->debug_writeApp
=
4078 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
4079 phba
->hba_debugfs_root
,
4080 phba
, &lpfc_debugfs_op_dif_err
);
4081 if (!phba
->debug_writeApp
) {
4082 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
4083 "0803 Cannot create debugfs writeApp\n");
4087 snprintf(name
, sizeof(name
), "writeRefInjErr");
4088 phba
->debug_writeRef
=
4089 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
4090 phba
->hba_debugfs_root
,
4091 phba
, &lpfc_debugfs_op_dif_err
);
4092 if (!phba
->debug_writeRef
) {
4093 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
4094 "0804 Cannot create debugfs writeRef\n");
4098 snprintf(name
, sizeof(name
), "readGuardInjErr");
4099 phba
->debug_readGuard
=
4100 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
4101 phba
->hba_debugfs_root
,
4102 phba
, &lpfc_debugfs_op_dif_err
);
4103 if (!phba
->debug_readGuard
) {
4104 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
4105 "0808 Cannot create debugfs readGuard\n");
4109 snprintf(name
, sizeof(name
), "readAppInjErr");
4110 phba
->debug_readApp
=
4111 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
4112 phba
->hba_debugfs_root
,
4113 phba
, &lpfc_debugfs_op_dif_err
);
4114 if (!phba
->debug_readApp
) {
4115 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
4116 "0805 Cannot create debugfs readApp\n");
4120 snprintf(name
, sizeof(name
), "readRefInjErr");
4121 phba
->debug_readRef
=
4122 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
4123 phba
->hba_debugfs_root
,
4124 phba
, &lpfc_debugfs_op_dif_err
);
4125 if (!phba
->debug_readRef
) {
4126 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
4127 "0806 Cannot create debugfs readApp\n");
4131 /* Setup slow ring trace */
4132 if (lpfc_debugfs_max_slow_ring_trc
) {
4133 num
= lpfc_debugfs_max_slow_ring_trc
- 1;
4134 if (num
& lpfc_debugfs_max_slow_ring_trc
) {
4135 /* Change to be a power of 2 */
4136 num
= lpfc_debugfs_max_slow_ring_trc
;
4142 lpfc_debugfs_max_slow_ring_trc
= (1 << i
);
4144 "lpfc_debugfs_max_disc_trc changed to "
4145 "%d\n", lpfc_debugfs_max_disc_trc
);
4149 snprintf(name
, sizeof(name
), "slow_ring_trace");
4150 phba
->debug_slow_ring_trc
=
4151 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
4152 phba
->hba_debugfs_root
,
4153 phba
, &lpfc_debugfs_op_slow_ring_trc
);
4154 if (!phba
->debug_slow_ring_trc
) {
4155 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
4156 "0415 Cannot create debugfs "
4157 "slow_ring_trace\n");
4160 if (!phba
->slow_ring_trc
) {
4161 phba
->slow_ring_trc
= kmalloc(
4162 (sizeof(struct lpfc_debugfs_trc
) *
4163 lpfc_debugfs_max_slow_ring_trc
),
4165 if (!phba
->slow_ring_trc
) {
4166 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
4167 "0416 Cannot create debugfs "
4168 "slow_ring buffer\n");
4171 atomic_set(&phba
->slow_ring_trc_cnt
, 0);
4172 memset(phba
->slow_ring_trc
, 0,
4173 (sizeof(struct lpfc_debugfs_trc
) *
4174 lpfc_debugfs_max_slow_ring_trc
));
4178 snprintf(name
, sizeof(name
), "vport%d", vport
->vpi
);
4179 if (!vport
->vport_debugfs_root
) {
4180 vport
->vport_debugfs_root
=
4181 debugfs_create_dir(name
, phba
->hba_debugfs_root
);
4182 if (!vport
->vport_debugfs_root
) {
4183 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
4184 "0417 Can't create debugfs\n");
4187 atomic_inc(&phba
->debugfs_vport_count
);
4190 if (lpfc_debugfs_max_disc_trc
) {
4191 num
= lpfc_debugfs_max_disc_trc
- 1;
4192 if (num
& lpfc_debugfs_max_disc_trc
) {
4193 /* Change to be a power of 2 */
4194 num
= lpfc_debugfs_max_disc_trc
;
4200 lpfc_debugfs_max_disc_trc
= (1 << i
);
4202 "lpfc_debugfs_max_disc_trc changed to %d\n",
4203 lpfc_debugfs_max_disc_trc
);
4207 vport
->disc_trc
= kzalloc(
4208 (sizeof(struct lpfc_debugfs_trc
) * lpfc_debugfs_max_disc_trc
),
4211 if (!vport
->disc_trc
) {
4212 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
4213 "0418 Cannot create debugfs disc trace "
4217 atomic_set(&vport
->disc_trc_cnt
, 0);
4219 snprintf(name
, sizeof(name
), "discovery_trace");
4220 vport
->debug_disc_trc
=
4221 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
4222 vport
->vport_debugfs_root
,
4223 vport
, &lpfc_debugfs_op_disc_trc
);
4224 if (!vport
->debug_disc_trc
) {
4225 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
4226 "0419 Cannot create debugfs "
4227 "discovery_trace\n");
4230 snprintf(name
, sizeof(name
), "nodelist");
4231 vport
->debug_nodelist
=
4232 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
4233 vport
->vport_debugfs_root
,
4234 vport
, &lpfc_debugfs_op_nodelist
);
4235 if (!vport
->debug_nodelist
) {
4236 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
4237 "2985 Can't create debugfs nodelist\n");
4242 * iDiag debugfs root entry points for SLI4 device only
4244 if (phba
->sli_rev
< LPFC_SLI_REV4
)
4247 snprintf(name
, sizeof(name
), "iDiag");
4248 if (!phba
->idiag_root
) {
4250 debugfs_create_dir(name
, phba
->hba_debugfs_root
);
4251 if (!phba
->idiag_root
) {
4252 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
4253 "2922 Can't create idiag debugfs\n");
4256 /* Initialize iDiag data structure */
4257 memset(&idiag
, 0, sizeof(idiag
));
4260 /* iDiag read PCI config space */
4261 snprintf(name
, sizeof(name
), "pciCfg");
4262 if (!phba
->idiag_pci_cfg
) {
4263 phba
->idiag_pci_cfg
=
4264 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
4265 phba
->idiag_root
, phba
, &lpfc_idiag_op_pciCfg
);
4266 if (!phba
->idiag_pci_cfg
) {
4267 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
4268 "2923 Can't create idiag debugfs\n");
4271 idiag
.offset
.last_rd
= 0;
4274 /* iDiag PCI BAR access */
4275 snprintf(name
, sizeof(name
), "barAcc");
4276 if (!phba
->idiag_bar_acc
) {
4277 phba
->idiag_bar_acc
=
4278 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
4279 phba
->idiag_root
, phba
, &lpfc_idiag_op_barAcc
);
4280 if (!phba
->idiag_bar_acc
) {
4281 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
4282 "3056 Can't create idiag debugfs\n");
4285 idiag
.offset
.last_rd
= 0;
4288 /* iDiag get PCI function queue information */
4289 snprintf(name
, sizeof(name
), "queInfo");
4290 if (!phba
->idiag_que_info
) {
4291 phba
->idiag_que_info
=
4292 debugfs_create_file(name
, S_IFREG
|S_IRUGO
,
4293 phba
->idiag_root
, phba
, &lpfc_idiag_op_queInfo
);
4294 if (!phba
->idiag_que_info
) {
4295 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
4296 "2924 Can't create idiag debugfs\n");
4301 /* iDiag access PCI function queue */
4302 snprintf(name
, sizeof(name
), "queAcc");
4303 if (!phba
->idiag_que_acc
) {
4304 phba
->idiag_que_acc
=
4305 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
4306 phba
->idiag_root
, phba
, &lpfc_idiag_op_queAcc
);
4307 if (!phba
->idiag_que_acc
) {
4308 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
4309 "2926 Can't create idiag debugfs\n");
4314 /* iDiag access PCI function doorbell registers */
4315 snprintf(name
, sizeof(name
), "drbAcc");
4316 if (!phba
->idiag_drb_acc
) {
4317 phba
->idiag_drb_acc
=
4318 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
4319 phba
->idiag_root
, phba
, &lpfc_idiag_op_drbAcc
);
4320 if (!phba
->idiag_drb_acc
) {
4321 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
4322 "2927 Can't create idiag debugfs\n");
4327 /* iDiag access PCI function control registers */
4328 snprintf(name
, sizeof(name
), "ctlAcc");
4329 if (!phba
->idiag_ctl_acc
) {
4330 phba
->idiag_ctl_acc
=
4331 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
4332 phba
->idiag_root
, phba
, &lpfc_idiag_op_ctlAcc
);
4333 if (!phba
->idiag_ctl_acc
) {
4334 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
4335 "2981 Can't create idiag debugfs\n");
4340 /* iDiag access mbox commands */
4341 snprintf(name
, sizeof(name
), "mbxAcc");
4342 if (!phba
->idiag_mbx_acc
) {
4343 phba
->idiag_mbx_acc
=
4344 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
4345 phba
->idiag_root
, phba
, &lpfc_idiag_op_mbxAcc
);
4346 if (!phba
->idiag_mbx_acc
) {
4347 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
4348 "2980 Can't create idiag debugfs\n");
4353 /* iDiag extents access commands */
4354 if (phba
->sli4_hba
.extents_in_use
) {
4355 snprintf(name
, sizeof(name
), "extAcc");
4356 if (!phba
->idiag_ext_acc
) {
4357 phba
->idiag_ext_acc
=
4358 debugfs_create_file(name
,
4359 S_IFREG
|S_IRUGO
|S_IWUSR
,
4360 phba
->idiag_root
, phba
,
4361 &lpfc_idiag_op_extAcc
);
4362 if (!phba
->idiag_ext_acc
) {
4363 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
4377 * lpfc_debugfs_terminate - Tear down debugfs infrastructure for this vport
4378 * @vport: The vport pointer to remove from debugfs.
4381 * When Debugfs is configured this routine removes debugfs file system elements
4382 * that are specific to this vport. It also checks to see if there are any
4383 * users left for the debugfs directories associated with the HBA and driver. If
4384 * this is the last user of the HBA directory or driver directory then it will
4385 * remove those from the debugfs infrastructure as well.
4388 lpfc_debugfs_terminate(struct lpfc_vport
*vport
)
4390 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
4391 struct lpfc_hba
*phba
= vport
->phba
;
4393 if (vport
->disc_trc
) {
4394 kfree(vport
->disc_trc
);
4395 vport
->disc_trc
= NULL
;
4397 if (vport
->debug_disc_trc
) {
4398 debugfs_remove(vport
->debug_disc_trc
); /* discovery_trace */
4399 vport
->debug_disc_trc
= NULL
;
4401 if (vport
->debug_nodelist
) {
4402 debugfs_remove(vport
->debug_nodelist
); /* nodelist */
4403 vport
->debug_nodelist
= NULL
;
4405 if (vport
->vport_debugfs_root
) {
4406 debugfs_remove(vport
->vport_debugfs_root
); /* vportX */
4407 vport
->vport_debugfs_root
= NULL
;
4408 atomic_dec(&phba
->debugfs_vport_count
);
4410 if (atomic_read(&phba
->debugfs_vport_count
) == 0) {
4412 if (phba
->debug_hbqinfo
) {
4413 debugfs_remove(phba
->debug_hbqinfo
); /* hbqinfo */
4414 phba
->debug_hbqinfo
= NULL
;
4416 if (phba
->debug_dumpHBASlim
) {
4417 debugfs_remove(phba
->debug_dumpHBASlim
); /* HBASlim */
4418 phba
->debug_dumpHBASlim
= NULL
;
4420 if (phba
->debug_dumpHostSlim
) {
4421 debugfs_remove(phba
->debug_dumpHostSlim
); /* HostSlim */
4422 phba
->debug_dumpHostSlim
= NULL
;
4424 if (phba
->debug_dumpData
) {
4425 debugfs_remove(phba
->debug_dumpData
); /* dumpData */
4426 phba
->debug_dumpData
= NULL
;
4429 if (phba
->debug_dumpDif
) {
4430 debugfs_remove(phba
->debug_dumpDif
); /* dumpDif */
4431 phba
->debug_dumpDif
= NULL
;
4433 if (phba
->debug_InjErrLBA
) {
4434 debugfs_remove(phba
->debug_InjErrLBA
); /* InjErrLBA */
4435 phba
->debug_InjErrLBA
= NULL
;
4437 if (phba
->debug_InjErrNPortID
) { /* InjErrNPortID */
4438 debugfs_remove(phba
->debug_InjErrNPortID
);
4439 phba
->debug_InjErrNPortID
= NULL
;
4441 if (phba
->debug_InjErrWWPN
) {
4442 debugfs_remove(phba
->debug_InjErrWWPN
); /* InjErrWWPN */
4443 phba
->debug_InjErrWWPN
= NULL
;
4445 if (phba
->debug_writeGuard
) {
4446 debugfs_remove(phba
->debug_writeGuard
); /* writeGuard */
4447 phba
->debug_writeGuard
= NULL
;
4449 if (phba
->debug_writeApp
) {
4450 debugfs_remove(phba
->debug_writeApp
); /* writeApp */
4451 phba
->debug_writeApp
= NULL
;
4453 if (phba
->debug_writeRef
) {
4454 debugfs_remove(phba
->debug_writeRef
); /* writeRef */
4455 phba
->debug_writeRef
= NULL
;
4457 if (phba
->debug_readGuard
) {
4458 debugfs_remove(phba
->debug_readGuard
); /* readGuard */
4459 phba
->debug_readGuard
= NULL
;
4461 if (phba
->debug_readApp
) {
4462 debugfs_remove(phba
->debug_readApp
); /* readApp */
4463 phba
->debug_readApp
= NULL
;
4465 if (phba
->debug_readRef
) {
4466 debugfs_remove(phba
->debug_readRef
); /* readRef */
4467 phba
->debug_readRef
= NULL
;
4470 if (phba
->slow_ring_trc
) {
4471 kfree(phba
->slow_ring_trc
);
4472 phba
->slow_ring_trc
= NULL
;
4474 if (phba
->debug_slow_ring_trc
) {
4475 /* slow_ring_trace */
4476 debugfs_remove(phba
->debug_slow_ring_trc
);
4477 phba
->debug_slow_ring_trc
= NULL
;
4483 if (phba
->sli_rev
== LPFC_SLI_REV4
) {
4484 if (phba
->idiag_ext_acc
) {
4486 debugfs_remove(phba
->idiag_ext_acc
);
4487 phba
->idiag_ext_acc
= NULL
;
4489 if (phba
->idiag_mbx_acc
) {
4491 debugfs_remove(phba
->idiag_mbx_acc
);
4492 phba
->idiag_mbx_acc
= NULL
;
4494 if (phba
->idiag_ctl_acc
) {
4496 debugfs_remove(phba
->idiag_ctl_acc
);
4497 phba
->idiag_ctl_acc
= NULL
;
4499 if (phba
->idiag_drb_acc
) {
4501 debugfs_remove(phba
->idiag_drb_acc
);
4502 phba
->idiag_drb_acc
= NULL
;
4504 if (phba
->idiag_que_acc
) {
4506 debugfs_remove(phba
->idiag_que_acc
);
4507 phba
->idiag_que_acc
= NULL
;
4509 if (phba
->idiag_que_info
) {
4511 debugfs_remove(phba
->idiag_que_info
);
4512 phba
->idiag_que_info
= NULL
;
4514 if (phba
->idiag_bar_acc
) {
4516 debugfs_remove(phba
->idiag_bar_acc
);
4517 phba
->idiag_bar_acc
= NULL
;
4519 if (phba
->idiag_pci_cfg
) {
4521 debugfs_remove(phba
->idiag_pci_cfg
);
4522 phba
->idiag_pci_cfg
= NULL
;
4525 /* Finally remove the iDiag debugfs root */
4526 if (phba
->idiag_root
) {
4528 debugfs_remove(phba
->idiag_root
);
4529 phba
->idiag_root
= NULL
;
4533 if (phba
->hba_debugfs_root
) {
4534 debugfs_remove(phba
->hba_debugfs_root
); /* fnX */
4535 phba
->hba_debugfs_root
= NULL
;
4536 atomic_dec(&lpfc_debugfs_hba_count
);
4539 if (atomic_read(&lpfc_debugfs_hba_count
) == 0) {
4540 debugfs_remove(lpfc_debugfs_root
); /* lpfc */
4541 lpfc_debugfs_root
= NULL
;
4549 * Driver debug utility routines outside of debugfs. The debug utility
4550 * routines implemented here is intended to be used in the instrumented
4551 * debug driver for debugging host or port issues.
4555 * lpfc_debug_dump_all_queues - dump all the queues with a hba
4556 * @phba: Pointer to HBA context object.
4558 * This function dumps entries of all the queues asociated with the @phba.
4561 lpfc_debug_dump_all_queues(struct lpfc_hba
*phba
)
4566 * Dump Work Queues (WQs)
4568 lpfc_debug_dump_mbx_wq(phba
);
4569 lpfc_debug_dump_els_wq(phba
);
4571 for (fcp_wqidx
= 0; fcp_wqidx
< phba
->cfg_fcp_io_channel
; fcp_wqidx
++)
4572 lpfc_debug_dump_fcp_wq(phba
, fcp_wqidx
);
4574 lpfc_debug_dump_hdr_rq(phba
);
4575 lpfc_debug_dump_dat_rq(phba
);
4577 * Dump Complete Queues (CQs)
4579 lpfc_debug_dump_mbx_cq(phba
);
4580 lpfc_debug_dump_els_cq(phba
);
4582 for (fcp_wqidx
= 0; fcp_wqidx
< phba
->cfg_fcp_io_channel
; fcp_wqidx
++)
4583 lpfc_debug_dump_fcp_cq(phba
, fcp_wqidx
);
4586 * Dump Event Queues (EQs)
4588 for (fcp_wqidx
= 0; fcp_wqidx
< phba
->cfg_fcp_io_channel
; fcp_wqidx
++)
4589 lpfc_debug_dump_hba_eq(phba
, fcp_wqidx
);