1 /*******************************************************************
2 * This file is part of the Emulex Linux Device Driver for *
3 * Fibre Channel Host Bus Adapters. *
4 * Copyright (C) 2017-2018 Broadcom. All Rights Reserved. The term *
5 * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. *
6 * Copyright (C) 2007-2015 Emulex. All rights reserved. *
7 * EMULEX and SLI are trademarks of Emulex. *
10 * This program is free software; you can redistribute it and/or *
11 * modify it under the terms of version 2 of the GNU General *
12 * Public License as published by the Free Software Foundation. *
13 * This program is distributed in the hope that it will be useful. *
14 * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND *
15 * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, *
16 * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE *
17 * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD *
18 * TO BE LEGALLY INVALID. See the GNU General Public License for *
19 * more details, a copy of which can be found in the file COPYING *
20 * included with this package. *
21 *******************************************************************/
23 #include <linux/blkdev.h>
24 #include <linux/delay.h>
25 #include <linux/module.h>
26 #include <linux/dma-mapping.h>
27 #include <linux/idr.h>
28 #include <linux/interrupt.h>
29 #include <linux/kthread.h>
30 #include <linux/slab.h>
31 #include <linux/pci.h>
32 #include <linux/spinlock.h>
33 #include <linux/ctype.h>
35 #include <scsi/scsi.h>
36 #include <scsi/scsi_device.h>
37 #include <scsi/scsi_host.h>
38 #include <scsi/scsi_transport_fc.h>
39 #include <scsi/fc/fc_fs.h>
41 #include <linux/nvme-fc-driver.h>
46 #include "lpfc_sli4.h"
48 #include "lpfc_disc.h"
50 #include "lpfc_scsi.h"
51 #include "lpfc_nvme.h"
52 #include "lpfc_nvmet.h"
53 #include "lpfc_logmsg.h"
54 #include "lpfc_crtn.h"
55 #include "lpfc_vport.h"
56 #include "lpfc_version.h"
57 #include "lpfc_compat.h"
58 #include "lpfc_debugfs.h"
61 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
65 * To access this interface the user should:
66 * # mount -t debugfs none /sys/kernel/debug
68 * The lpfc debugfs directory hierarchy is:
69 * /sys/kernel/debug/lpfc/fnX/vportY
70 * where X is the lpfc hba function unique_id
71 * where Y is the vport VPI on that hba
73 * Debugging services available per vport:
75 * This is an ACSII readable file that contains a trace of the last
76 * lpfc_debugfs_max_disc_trc events that happened on a specific vport.
77 * See lpfc_debugfs.h for different categories of discovery events.
78 * To enable the discovery trace, the following module parameters must be set:
79 * lpfc_debugfs_enable=1 Turns on lpfc debugfs filesystem support
80 * lpfc_debugfs_max_disc_trc=X Where X is the event trace depth for
81 * EACH vport. X MUST also be a power of 2.
82 * lpfc_debugfs_mask_disc_trc=Y Where Y is an event mask as defined in
86 * This is an ACSII readable file that contains a trace of the last
87 * lpfc_debugfs_max_slow_ring_trc events that happened on a specific HBA.
88 * To enable the slow ring trace, the following module parameters must be set:
89 * lpfc_debugfs_enable=1 Turns on lpfc debugfs filesystem support
90 * lpfc_debugfs_max_slow_ring_trc=X Where X is the event trace depth for
91 * the HBA. X MUST also be a power of 2.
93 static int lpfc_debugfs_enable
= 1;
94 module_param(lpfc_debugfs_enable
, int, S_IRUGO
);
95 MODULE_PARM_DESC(lpfc_debugfs_enable
, "Enable debugfs services");
97 /* This MUST be a power of 2 */
98 static int lpfc_debugfs_max_disc_trc
;
99 module_param(lpfc_debugfs_max_disc_trc
, int, S_IRUGO
);
100 MODULE_PARM_DESC(lpfc_debugfs_max_disc_trc
,
101 "Set debugfs discovery trace depth");
103 /* This MUST be a power of 2 */
104 static int lpfc_debugfs_max_slow_ring_trc
;
105 module_param(lpfc_debugfs_max_slow_ring_trc
, int, S_IRUGO
);
106 MODULE_PARM_DESC(lpfc_debugfs_max_slow_ring_trc
,
107 "Set debugfs slow ring trace depth");
109 /* This MUST be a power of 2 */
110 static int lpfc_debugfs_max_nvmeio_trc
;
111 module_param(lpfc_debugfs_max_nvmeio_trc
, int, 0444);
112 MODULE_PARM_DESC(lpfc_debugfs_max_nvmeio_trc
,
113 "Set debugfs NVME IO trace depth");
115 static int lpfc_debugfs_mask_disc_trc
;
116 module_param(lpfc_debugfs_mask_disc_trc
, int, S_IRUGO
);
117 MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc
,
118 "Set debugfs discovery trace mask");
120 #include <linux/debugfs.h>
122 static atomic_t lpfc_debugfs_seq_trc_cnt
= ATOMIC_INIT(0);
123 static unsigned long lpfc_debugfs_start_time
= 0L;
126 static struct lpfc_idiag idiag
;
129 * lpfc_debugfs_disc_trc_data - Dump discovery logging to a buffer
130 * @vport: The vport to gather the log info from.
131 * @buf: The buffer to dump log into.
132 * @size: The maximum amount of data to process.
135 * This routine gathers the lpfc discovery debugfs data from the @vport and
136 * dumps it to @buf up to @size number of bytes. It will start at the next entry
137 * in the log and process the log until the end of the buffer. Then it will
138 * gather from the beginning of the log and process until the current entry.
141 * Discovery logging will be disabled while while this routine dumps the log.
144 * This routine returns the amount of bytes that were dumped into @buf and will
148 lpfc_debugfs_disc_trc_data(struct lpfc_vport
*vport
, char *buf
, int size
)
150 int i
, index
, len
, enable
;
152 struct lpfc_debugfs_trc
*dtp
;
155 buffer
= kmalloc(LPFC_DEBUG_TRC_ENTRY_SIZE
, GFP_KERNEL
);
159 enable
= lpfc_debugfs_enable
;
160 lpfc_debugfs_enable
= 0;
163 index
= (atomic_read(&vport
->disc_trc_cnt
) + 1) &
164 (lpfc_debugfs_max_disc_trc
- 1);
165 for (i
= index
; i
< lpfc_debugfs_max_disc_trc
; i
++) {
166 dtp
= vport
->disc_trc
+ i
;
169 ms
= jiffies_to_msecs(dtp
->jif
- lpfc_debugfs_start_time
);
171 LPFC_DEBUG_TRC_ENTRY_SIZE
, "%010d:%010d ms:%s\n",
172 dtp
->seq_cnt
, ms
, dtp
->fmt
);
173 len
+= scnprintf(buf
+len
, size
-len
, buffer
,
174 dtp
->data1
, dtp
->data2
, dtp
->data3
);
176 for (i
= 0; i
< index
; i
++) {
177 dtp
= vport
->disc_trc
+ i
;
180 ms
= jiffies_to_msecs(dtp
->jif
- lpfc_debugfs_start_time
);
182 LPFC_DEBUG_TRC_ENTRY_SIZE
, "%010d:%010d ms:%s\n",
183 dtp
->seq_cnt
, ms
, dtp
->fmt
);
184 len
+= scnprintf(buf
+len
, size
-len
, buffer
,
185 dtp
->data1
, dtp
->data2
, dtp
->data3
);
188 lpfc_debugfs_enable
= enable
;
195 * lpfc_debugfs_slow_ring_trc_data - Dump slow ring logging to a buffer
196 * @phba: The HBA to gather the log info from.
197 * @buf: The buffer to dump log into.
198 * @size: The maximum amount of data to process.
201 * This routine gathers the lpfc slow ring debugfs data from the @phba and
202 * dumps it to @buf up to @size number of bytes. It will start at the next entry
203 * in the log and process the log until the end of the buffer. Then it will
204 * gather from the beginning of the log and process until the current entry.
207 * Slow ring logging will be disabled while while this routine dumps the log.
210 * This routine returns the amount of bytes that were dumped into @buf and will
214 lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba
*phba
, char *buf
, int size
)
216 int i
, index
, len
, enable
;
218 struct lpfc_debugfs_trc
*dtp
;
221 buffer
= kmalloc(LPFC_DEBUG_TRC_ENTRY_SIZE
, GFP_KERNEL
);
225 enable
= lpfc_debugfs_enable
;
226 lpfc_debugfs_enable
= 0;
229 index
= (atomic_read(&phba
->slow_ring_trc_cnt
) + 1) &
230 (lpfc_debugfs_max_slow_ring_trc
- 1);
231 for (i
= index
; i
< lpfc_debugfs_max_slow_ring_trc
; i
++) {
232 dtp
= phba
->slow_ring_trc
+ i
;
235 ms
= jiffies_to_msecs(dtp
->jif
- lpfc_debugfs_start_time
);
237 LPFC_DEBUG_TRC_ENTRY_SIZE
, "%010d:%010d ms:%s\n",
238 dtp
->seq_cnt
, ms
, dtp
->fmt
);
239 len
+= scnprintf(buf
+len
, size
-len
, buffer
,
240 dtp
->data1
, dtp
->data2
, dtp
->data3
);
242 for (i
= 0; i
< index
; i
++) {
243 dtp
= phba
->slow_ring_trc
+ i
;
246 ms
= jiffies_to_msecs(dtp
->jif
- lpfc_debugfs_start_time
);
248 LPFC_DEBUG_TRC_ENTRY_SIZE
, "%010d:%010d ms:%s\n",
249 dtp
->seq_cnt
, ms
, dtp
->fmt
);
250 len
+= scnprintf(buf
+len
, size
-len
, buffer
,
251 dtp
->data1
, dtp
->data2
, dtp
->data3
);
254 lpfc_debugfs_enable
= enable
;
260 static int lpfc_debugfs_last_hbq
= -1;
263 * lpfc_debugfs_hbqinfo_data - Dump host buffer queue info to a buffer
264 * @phba: The HBA to gather host buffer info from.
265 * @buf: The buffer to dump log into.
266 * @size: The maximum amount of data to process.
269 * This routine dumps the host buffer queue info from the @phba to @buf up to
270 * @size number of bytes. A header that describes the current hbq state will be
271 * dumped to @buf first and then info on each hbq entry will be dumped to @buf
272 * until @size bytes have been dumped or all the hbq info has been dumped.
275 * This routine will rotate through each configured HBQ each time called.
278 * This routine returns the amount of bytes that were dumped into @buf and will
282 lpfc_debugfs_hbqinfo_data(struct lpfc_hba
*phba
, char *buf
, int size
)
285 int i
, j
, found
, posted
, low
;
286 uint32_t phys
, raw_index
, getidx
;
287 struct lpfc_hbq_init
*hip
;
289 struct lpfc_hbq_entry
*hbqe
;
290 struct lpfc_dmabuf
*d_buf
;
291 struct hbq_dmabuf
*hbq_buf
;
293 if (phba
->sli_rev
!= 3)
296 spin_lock_irq(&phba
->hbalock
);
298 /* toggle between multiple hbqs, if any */
299 i
= lpfc_sli_hbq_count();
301 lpfc_debugfs_last_hbq
++;
302 if (lpfc_debugfs_last_hbq
>= i
)
303 lpfc_debugfs_last_hbq
= 0;
306 lpfc_debugfs_last_hbq
= 0;
308 i
= lpfc_debugfs_last_hbq
;
310 len
+= scnprintf(buf
+len
, size
-len
, "HBQ %d Info\n", i
);
312 hbqs
= &phba
->hbqs
[i
];
314 list_for_each_entry(d_buf
, &hbqs
->hbq_buffer_list
, list
)
317 hip
= lpfc_hbq_defs
[i
];
318 len
+= scnprintf(buf
+len
, size
-len
,
319 "idx:%d prof:%d rn:%d bufcnt:%d icnt:%d acnt:%d posted %d\n",
320 hip
->hbq_index
, hip
->profile
, hip
->rn
,
321 hip
->buffer_count
, hip
->init_count
, hip
->add_count
, posted
);
323 raw_index
= phba
->hbq_get
[i
];
324 getidx
= le32_to_cpu(raw_index
);
325 len
+= scnprintf(buf
+len
, size
-len
,
326 "entries:%d bufcnt:%d Put:%d nPut:%d localGet:%d hbaGet:%d\n",
327 hbqs
->entry_count
, hbqs
->buffer_count
, hbqs
->hbqPutIdx
,
328 hbqs
->next_hbqPutIdx
, hbqs
->local_hbqGetIdx
, getidx
);
330 hbqe
= (struct lpfc_hbq_entry
*) phba
->hbqs
[i
].hbq_virt
;
331 for (j
=0; j
<hbqs
->entry_count
; j
++) {
332 len
+= scnprintf(buf
+len
, size
-len
,
333 "%03d: %08x %04x %05x ", j
,
334 le32_to_cpu(hbqe
->bde
.addrLow
),
335 le32_to_cpu(hbqe
->bde
.tus
.w
),
336 le32_to_cpu(hbqe
->buffer_tag
));
340 /* First calculate if slot has an associated posted buffer */
341 low
= hbqs
->hbqPutIdx
- posted
;
343 if ((j
>= hbqs
->hbqPutIdx
) || (j
< low
)) {
344 len
+= scnprintf(buf
+ len
, size
- len
,
350 if ((j
>= hbqs
->hbqPutIdx
) &&
351 (j
< (hbqs
->entry_count
+low
))) {
352 len
+= scnprintf(buf
+ len
, size
- len
,
358 /* Get the Buffer info for the posted buffer */
359 list_for_each_entry(d_buf
, &hbqs
->hbq_buffer_list
, list
) {
360 hbq_buf
= container_of(d_buf
, struct hbq_dmabuf
, dbuf
);
361 phys
= ((uint64_t)hbq_buf
->dbuf
.phys
& 0xffffffff);
362 if (phys
== le32_to_cpu(hbqe
->bde
.addrLow
)) {
363 len
+= scnprintf(buf
+len
, size
-len
,
364 "Buf%d: %p %06x\n", i
,
365 hbq_buf
->dbuf
.virt
, hbq_buf
->tag
);
372 len
+= scnprintf(buf
+len
, size
-len
, "No DMAinfo?\n");
376 if (len
> LPFC_HBQINFO_SIZE
- 54)
379 spin_unlock_irq(&phba
->hbalock
);
383 static int lpfc_debugfs_last_hba_slim_off
;
386 * lpfc_debugfs_dumpHBASlim_data - Dump HBA SLIM info to a buffer
387 * @phba: The HBA to gather SLIM info from.
388 * @buf: The buffer to dump log into.
389 * @size: The maximum amount of data to process.
392 * This routine dumps the current contents of HBA SLIM for the HBA associated
393 * with @phba to @buf up to @size bytes of data. This is the raw HBA SLIM data.
396 * This routine will only dump up to 1024 bytes of data each time called and
397 * should be called multiple times to dump the entire HBA SLIM.
400 * This routine returns the amount of bytes that were dumped into @buf and will
404 lpfc_debugfs_dumpHBASlim_data(struct lpfc_hba
*phba
, char *buf
, int size
)
411 buffer
= kmalloc(1024, GFP_KERNEL
);
416 spin_lock_irq(&phba
->hbalock
);
418 len
+= scnprintf(buf
+len
, size
-len
, "HBA SLIM\n");
419 lpfc_memcpy_from_slim(buffer
,
420 phba
->MBslimaddr
+ lpfc_debugfs_last_hba_slim_off
, 1024);
422 ptr
= (uint32_t *)&buffer
[0];
423 off
= lpfc_debugfs_last_hba_slim_off
;
425 /* Set it up for the next time */
426 lpfc_debugfs_last_hba_slim_off
+= 1024;
427 if (lpfc_debugfs_last_hba_slim_off
>= 4096)
428 lpfc_debugfs_last_hba_slim_off
= 0;
432 len
+= scnprintf(buf
+len
, size
-len
,
433 "%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n",
434 off
, *ptr
, *(ptr
+1), *(ptr
+2), *(ptr
+3), *(ptr
+4),
435 *(ptr
+5), *(ptr
+6), *(ptr
+7));
437 i
-= (8 * sizeof(uint32_t));
438 off
+= (8 * sizeof(uint32_t));
441 spin_unlock_irq(&phba
->hbalock
);
448 * lpfc_debugfs_dumpHostSlim_data - Dump host SLIM info to a buffer
449 * @phba: The HBA to gather Host SLIM info from.
450 * @buf: The buffer to dump log into.
451 * @size: The maximum amount of data to process.
454 * This routine dumps the current contents of host SLIM for the host associated
455 * with @phba to @buf up to @size bytes of data. The dump will contain the
456 * Mailbox, PCB, Rings, and Registers that are located in host memory.
459 * This routine returns the amount of bytes that were dumped into @buf and will
463 lpfc_debugfs_dumpHostSlim_data(struct lpfc_hba
*phba
, char *buf
, int size
)
467 uint32_t word0
, word1
, word2
, word3
;
469 struct lpfc_pgp
*pgpp
;
470 struct lpfc_sli
*psli
= &phba
->sli
;
471 struct lpfc_sli_ring
*pring
;
474 spin_lock_irq(&phba
->hbalock
);
476 len
+= scnprintf(buf
+len
, size
-len
, "SLIM Mailbox\n");
477 ptr
= (uint32_t *)phba
->slim2p
.virt
;
478 i
= sizeof(MAILBOX_t
);
480 len
+= scnprintf(buf
+len
, size
-len
,
481 "%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n",
482 off
, *ptr
, *(ptr
+1), *(ptr
+2), *(ptr
+3), *(ptr
+4),
483 *(ptr
+5), *(ptr
+6), *(ptr
+7));
485 i
-= (8 * sizeof(uint32_t));
486 off
+= (8 * sizeof(uint32_t));
489 len
+= scnprintf(buf
+len
, size
-len
, "SLIM PCB\n");
490 ptr
= (uint32_t *)phba
->pcb
;
493 len
+= scnprintf(buf
+len
, size
-len
,
494 "%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n",
495 off
, *ptr
, *(ptr
+1), *(ptr
+2), *(ptr
+3), *(ptr
+4),
496 *(ptr
+5), *(ptr
+6), *(ptr
+7));
498 i
-= (8 * sizeof(uint32_t));
499 off
+= (8 * sizeof(uint32_t));
502 if (phba
->sli_rev
<= LPFC_SLI_REV3
) {
503 for (i
= 0; i
< 4; i
++) {
504 pgpp
= &phba
->port_gp
[i
];
505 pring
= &psli
->sli3_ring
[i
];
506 len
+= scnprintf(buf
+len
, size
-len
,
507 "Ring %d: CMD GetInx:%d "
510 "RSP PutInx:%d Max:%d\n",
512 pring
->sli
.sli3
.numCiocb
,
513 pring
->sli
.sli3
.next_cmdidx
,
514 pring
->sli
.sli3
.local_getidx
,
515 pring
->flag
, pgpp
->rspPutInx
,
516 pring
->sli
.sli3
.numRiocb
);
519 word0
= readl(phba
->HAregaddr
);
520 word1
= readl(phba
->CAregaddr
);
521 word2
= readl(phba
->HSregaddr
);
522 word3
= readl(phba
->HCregaddr
);
523 len
+= scnprintf(buf
+len
, size
-len
, "HA:%08x CA:%08x HS:%08x "
524 "HC:%08x\n", word0
, word1
, word2
, word3
);
526 spin_unlock_irq(&phba
->hbalock
);
531 * lpfc_debugfs_nodelist_data - Dump target node list to a buffer
532 * @vport: The vport to gather target node info from.
533 * @buf: The buffer to dump log into.
534 * @size: The maximum amount of data to process.
537 * This routine dumps the current target node list associated with @vport to
538 * @buf up to @size bytes of data. Each node entry in the dump will contain a
539 * node state, DID, WWPN, WWNN, RPI, flags, type, and other useful fields.
542 * This routine returns the amount of bytes that were dumped into @buf and will
546 lpfc_debugfs_nodelist_data(struct lpfc_vport
*vport
, char *buf
, int size
)
549 int i
, iocnt
, outio
, cnt
;
550 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
551 struct lpfc_hba
*phba
= vport
->phba
;
552 struct lpfc_nodelist
*ndlp
;
553 unsigned char *statep
;
554 struct nvme_fc_local_port
*localport
;
555 struct lpfc_nvmet_tgtport
*tgtp
;
556 struct nvme_fc_remote_port
*nrport
= NULL
;
557 struct lpfc_nvme_rport
*rport
;
559 cnt
= (LPFC_NODELIST_SIZE
/ LPFC_NODELIST_ENTRY_SIZE
);
562 len
+= scnprintf(buf
+len
, size
-len
, "\nFCP Nodelist Entries ...\n");
563 spin_lock_irq(shost
->host_lock
);
564 list_for_each_entry(ndlp
, &vport
->fc_nodes
, nlp_listp
) {
567 len
+= scnprintf(buf
+len
, size
-len
,
568 "Missing Nodelist Entries\n");
572 switch (ndlp
->nlp_state
) {
573 case NLP_STE_UNUSED_NODE
:
576 case NLP_STE_PLOGI_ISSUE
:
579 case NLP_STE_ADISC_ISSUE
:
582 case NLP_STE_REG_LOGIN_ISSUE
:
585 case NLP_STE_PRLI_ISSUE
:
588 case NLP_STE_LOGO_ISSUE
:
591 case NLP_STE_UNMAPPED_NODE
:
595 case NLP_STE_MAPPED_NODE
:
599 case NLP_STE_NPR_NODE
:
605 len
+= scnprintf(buf
+len
, size
-len
, "%s DID:x%06x ",
606 statep
, ndlp
->nlp_DID
);
607 len
+= scnprintf(buf
+len
, size
-len
,
609 wwn_to_u64(ndlp
->nlp_portname
.u
.wwn
));
610 len
+= scnprintf(buf
+len
, size
-len
,
612 wwn_to_u64(ndlp
->nlp_nodename
.u
.wwn
));
613 if (ndlp
->nlp_flag
& NLP_RPI_REGISTERED
)
614 len
+= scnprintf(buf
+len
, size
-len
, "RPI:%03d ",
617 len
+= scnprintf(buf
+len
, size
-len
, "RPI:none ");
618 len
+= scnprintf(buf
+len
, size
-len
, "flag:x%08x ",
621 len
+= scnprintf(buf
+len
, size
-len
, "UNKNOWN_TYPE ");
622 if (ndlp
->nlp_type
& NLP_FC_NODE
)
623 len
+= scnprintf(buf
+len
, size
-len
, "FC_NODE ");
624 if (ndlp
->nlp_type
& NLP_FABRIC
) {
625 len
+= scnprintf(buf
+len
, size
-len
, "FABRIC ");
628 if (ndlp
->nlp_type
& NLP_FCP_TARGET
)
629 len
+= scnprintf(buf
+len
, size
-len
, "FCP_TGT sid:%d ",
631 if (ndlp
->nlp_type
& NLP_FCP_INITIATOR
)
632 len
+= scnprintf(buf
+len
, size
-len
, "FCP_INITIATOR ");
633 if (ndlp
->nlp_type
& NLP_NVME_TARGET
)
634 len
+= scnprintf(buf
+ len
,
635 size
- len
, "NVME_TGT sid:%d ",
637 if (ndlp
->nlp_type
& NLP_NVME_INITIATOR
)
638 len
+= scnprintf(buf
+ len
,
639 size
- len
, "NVME_INITIATOR ");
640 len
+= scnprintf(buf
+len
, size
-len
, "usgmap:%x ",
642 len
+= scnprintf(buf
+len
, size
-len
, "refcnt:%x",
643 kref_read(&ndlp
->kref
));
645 i
= atomic_read(&ndlp
->cmd_pending
);
646 len
+= scnprintf(buf
+ len
, size
- len
,
647 " OutIO:x%x Qdepth x%x",
648 i
, ndlp
->cmd_qdepth
);
651 len
+= scnprintf(buf
+len
, size
-len
, "\n");
653 spin_unlock_irq(shost
->host_lock
);
655 len
+= scnprintf(buf
+ len
, size
- len
,
656 "\nOutstanding IO x%x\n", outio
);
658 if (phba
->nvmet_support
&& phba
->targetport
&& (vport
== phba
->pport
)) {
659 tgtp
= (struct lpfc_nvmet_tgtport
*)phba
->targetport
->private;
660 len
+= scnprintf(buf
+ len
, size
- len
,
661 "\nNVME Targetport Entry ...\n");
663 /* Port state is only one of two values for now. */
664 if (phba
->targetport
->port_id
)
665 statep
= "REGISTERED";
668 len
+= scnprintf(buf
+ len
, size
- len
,
669 "TGT WWNN x%llx WWPN x%llx State %s\n",
670 wwn_to_u64(vport
->fc_nodename
.u
.wwn
),
671 wwn_to_u64(vport
->fc_portname
.u
.wwn
),
673 len
+= scnprintf(buf
+ len
, size
- len
,
674 " Targetport DID x%06x\n",
675 phba
->targetport
->port_id
);
679 len
+= scnprintf(buf
+ len
, size
- len
,
680 "\nNVME Lport/Rport Entries ...\n");
682 localport
= vport
->localport
;
686 spin_lock_irq(shost
->host_lock
);
688 /* Port state is only one of two values for now. */
689 if (localport
->port_id
)
694 len
+= scnprintf(buf
+ len
, size
- len
,
695 "Lport DID x%06x PortState %s\n",
696 localport
->port_id
, statep
);
698 len
+= scnprintf(buf
+ len
, size
- len
, "\tRport List:\n");
699 list_for_each_entry(ndlp
, &vport
->fc_nodes
, nlp_listp
) {
700 /* local short-hand pointer. */
701 spin_lock(&phba
->hbalock
);
702 rport
= lpfc_ndlp_get_nrport(ndlp
);
704 nrport
= rport
->remoteport
;
707 spin_unlock(&phba
->hbalock
);
711 /* Port state is only one of two values for now. */
712 switch (nrport
->port_state
) {
713 case FC_OBJSTATE_ONLINE
:
716 case FC_OBJSTATE_UNKNOWN
:
720 statep
= "UNSUPPORTED";
724 /* Tab in to show lport ownership. */
725 len
+= scnprintf(buf
+ len
, size
- len
,
726 "\t%s Port ID:x%06x ",
727 statep
, nrport
->port_id
);
728 len
+= scnprintf(buf
+ len
, size
- len
, "WWPN x%llx ",
730 len
+= scnprintf(buf
+ len
, size
- len
, "WWNN x%llx ",
733 /* An NVME rport can have multiple roles. */
734 if (nrport
->port_role
& FC_PORT_ROLE_NVME_INITIATOR
)
735 len
+= scnprintf(buf
+ len
, size
- len
,
737 if (nrport
->port_role
& FC_PORT_ROLE_NVME_TARGET
)
738 len
+= scnprintf(buf
+ len
, size
- len
,
740 if (nrport
->port_role
& FC_PORT_ROLE_NVME_DISCOVERY
)
741 len
+= scnprintf(buf
+ len
, size
- len
,
743 if (nrport
->port_role
& ~(FC_PORT_ROLE_NVME_INITIATOR
|
744 FC_PORT_ROLE_NVME_TARGET
|
745 FC_PORT_ROLE_NVME_DISCOVERY
))
746 len
+= scnprintf(buf
+ len
, size
- len
,
749 /* Terminate the string. */
750 len
+= scnprintf(buf
+ len
, size
- len
, "\n");
753 spin_unlock_irq(shost
->host_lock
);
759 * lpfc_debugfs_nvmestat_data - Dump target node list to a buffer
760 * @vport: The vport to gather target node info from.
761 * @buf: The buffer to dump log into.
762 * @size: The maximum amount of data to process.
765 * This routine dumps the NVME statistics associated with @vport
768 * This routine returns the amount of bytes that were dumped into @buf and will
772 lpfc_debugfs_nvmestat_data(struct lpfc_vport
*vport
, char *buf
, int size
)
774 struct lpfc_hba
*phba
= vport
->phba
;
775 struct lpfc_nvmet_tgtport
*tgtp
;
776 struct lpfc_nvmet_rcv_ctx
*ctxp
, *next_ctxp
;
777 struct nvme_fc_local_port
*localport
;
778 struct lpfc_nvme_ctrl_stat
*cstat
;
779 struct lpfc_nvme_lport
*lport
;
780 uint64_t data1
, data2
, data3
;
781 uint64_t tot
, totin
, totout
;
785 if (phba
->nvmet_support
) {
786 if (!phba
->targetport
)
788 tgtp
= (struct lpfc_nvmet_tgtport
*)phba
->targetport
->private;
789 len
+= scnprintf(buf
+ len
, size
- len
,
790 "\nNVME Targetport Statistics\n");
792 len
+= scnprintf(buf
+ len
, size
- len
,
793 "LS: Rcv %08x Drop %08x Abort %08x\n",
794 atomic_read(&tgtp
->rcv_ls_req_in
),
795 atomic_read(&tgtp
->rcv_ls_req_drop
),
796 atomic_read(&tgtp
->xmt_ls_abort
));
797 if (atomic_read(&tgtp
->rcv_ls_req_in
) !=
798 atomic_read(&tgtp
->rcv_ls_req_out
)) {
799 len
+= scnprintf(buf
+ len
, size
- len
,
800 "Rcv LS: in %08x != out %08x\n",
801 atomic_read(&tgtp
->rcv_ls_req_in
),
802 atomic_read(&tgtp
->rcv_ls_req_out
));
805 len
+= scnprintf(buf
+ len
, size
- len
,
806 "LS: Xmt %08x Drop %08x Cmpl %08x\n",
807 atomic_read(&tgtp
->xmt_ls_rsp
),
808 atomic_read(&tgtp
->xmt_ls_drop
),
809 atomic_read(&tgtp
->xmt_ls_rsp_cmpl
));
811 len
+= scnprintf(buf
+ len
, size
- len
,
812 "LS: RSP Abort %08x xb %08x Err %08x\n",
813 atomic_read(&tgtp
->xmt_ls_rsp_aborted
),
814 atomic_read(&tgtp
->xmt_ls_rsp_xb_set
),
815 atomic_read(&tgtp
->xmt_ls_rsp_error
));
817 len
+= scnprintf(buf
+ len
, size
- len
,
818 "FCP: Rcv %08x Defer %08x Release %08x "
820 atomic_read(&tgtp
->rcv_fcp_cmd_in
),
821 atomic_read(&tgtp
->rcv_fcp_cmd_defer
),
822 atomic_read(&tgtp
->xmt_fcp_release
),
823 atomic_read(&tgtp
->rcv_fcp_cmd_drop
));
825 if (atomic_read(&tgtp
->rcv_fcp_cmd_in
) !=
826 atomic_read(&tgtp
->rcv_fcp_cmd_out
)) {
827 len
+= scnprintf(buf
+ len
, size
- len
,
828 "Rcv FCP: in %08x != out %08x\n",
829 atomic_read(&tgtp
->rcv_fcp_cmd_in
),
830 atomic_read(&tgtp
->rcv_fcp_cmd_out
));
833 len
+= scnprintf(buf
+ len
, size
- len
,
834 "FCP Rsp: read %08x readrsp %08x "
835 "write %08x rsp %08x\n",
836 atomic_read(&tgtp
->xmt_fcp_read
),
837 atomic_read(&tgtp
->xmt_fcp_read_rsp
),
838 atomic_read(&tgtp
->xmt_fcp_write
),
839 atomic_read(&tgtp
->xmt_fcp_rsp
));
841 len
+= scnprintf(buf
+ len
, size
- len
,
842 "FCP Rsp Cmpl: %08x err %08x drop %08x\n",
843 atomic_read(&tgtp
->xmt_fcp_rsp_cmpl
),
844 atomic_read(&tgtp
->xmt_fcp_rsp_error
),
845 atomic_read(&tgtp
->xmt_fcp_rsp_drop
));
847 len
+= scnprintf(buf
+ len
, size
- len
,
848 "FCP Rsp Abort: %08x xb %08x xricqe %08x\n",
849 atomic_read(&tgtp
->xmt_fcp_rsp_aborted
),
850 atomic_read(&tgtp
->xmt_fcp_rsp_xb_set
),
851 atomic_read(&tgtp
->xmt_fcp_xri_abort_cqe
));
853 len
+= scnprintf(buf
+ len
, size
- len
,
854 "ABORT: Xmt %08x Cmpl %08x\n",
855 atomic_read(&tgtp
->xmt_fcp_abort
),
856 atomic_read(&tgtp
->xmt_fcp_abort_cmpl
));
858 len
+= scnprintf(buf
+ len
, size
- len
,
859 "ABORT: Sol %08x Usol %08x Err %08x Cmpl %08x",
860 atomic_read(&tgtp
->xmt_abort_sol
),
861 atomic_read(&tgtp
->xmt_abort_unsol
),
862 atomic_read(&tgtp
->xmt_abort_rsp
),
863 atomic_read(&tgtp
->xmt_abort_rsp_error
));
865 len
+= scnprintf(buf
+ len
, size
- len
, "\n");
868 spin_lock(&phba
->sli4_hba
.abts_nvme_buf_list_lock
);
869 list_for_each_entry_safe(ctxp
, next_ctxp
,
870 &phba
->sli4_hba
.lpfc_abts_nvmet_ctx_list
,
874 spin_unlock(&phba
->sli4_hba
.abts_nvme_buf_list_lock
);
876 len
+= scnprintf(buf
+ len
, size
- len
,
877 "ABORT: %d ctx entries\n", cnt
);
878 spin_lock(&phba
->sli4_hba
.abts_nvme_buf_list_lock
);
879 list_for_each_entry_safe(ctxp
, next_ctxp
,
880 &phba
->sli4_hba
.lpfc_abts_nvmet_ctx_list
,
882 if (len
>= (size
- LPFC_DEBUG_OUT_LINE_SZ
))
884 len
+= scnprintf(buf
+ len
, size
- len
,
885 "Entry: oxid %x state %x "
887 ctxp
->oxid
, ctxp
->state
,
890 spin_unlock(&phba
->sli4_hba
.abts_nvme_buf_list_lock
);
893 /* Calculate outstanding IOs */
894 tot
= atomic_read(&tgtp
->rcv_fcp_cmd_drop
);
895 tot
+= atomic_read(&tgtp
->xmt_fcp_release
);
896 tot
= atomic_read(&tgtp
->rcv_fcp_cmd_in
) - tot
;
898 len
+= scnprintf(buf
+ len
, size
- len
,
899 "IO_CTX: %08x WAIT: cur %08x tot %08x\n"
900 "CTX Outstanding %08llx\n",
901 phba
->sli4_hba
.nvmet_xri_cnt
,
902 phba
->sli4_hba
.nvmet_io_wait_cnt
,
903 phba
->sli4_hba
.nvmet_io_wait_total
,
906 if (!(phba
->cfg_enable_fc4_type
& LPFC_ENABLE_NVME
))
909 localport
= vport
->localport
;
912 lport
= (struct lpfc_nvme_lport
*)localport
->private;
916 len
+= scnprintf(buf
+ len
, size
- len
,
917 "\nNVME Lport Statistics\n");
919 len
+= scnprintf(buf
+ len
, size
- len
,
920 "LS: Xmt %016x Cmpl %016x\n",
921 atomic_read(&lport
->fc4NvmeLsRequests
),
922 atomic_read(&lport
->fc4NvmeLsCmpls
));
924 if (phba
->cfg_nvme_io_channel
< 32)
925 maxch
= phba
->cfg_nvme_io_channel
;
930 for (i
= 0; i
< phba
->cfg_nvme_io_channel
; i
++) {
931 cstat
= &lport
->cstat
[i
];
932 tot
= atomic_read(&cstat
->fc4NvmeIoCmpls
);
934 data1
= atomic_read(&cstat
->fc4NvmeInputRequests
);
935 data2
= atomic_read(&cstat
->fc4NvmeOutputRequests
);
936 data3
= atomic_read(&cstat
->fc4NvmeControlRequests
);
937 totout
+= (data1
+ data2
+ data3
);
939 /* Limit to 32, debugfs display buffer limitation */
943 len
+= scnprintf(buf
+ len
, PAGE_SIZE
- len
,
944 "FCP (%d): Rd %016llx Wr %016llx "
946 i
, data1
, data2
, data3
);
947 len
+= scnprintf(buf
+ len
, PAGE_SIZE
- len
,
948 "Cmpl %016llx OutIO %016llx\n",
949 tot
, ((data1
+ data2
+ data3
) - tot
));
951 len
+= scnprintf(buf
+ len
, PAGE_SIZE
- len
,
952 "Total FCP Cmpl %016llx Issue %016llx "
954 totin
, totout
, totout
- totin
);
956 len
+= scnprintf(buf
+ len
, size
- len
,
957 "LS Xmt Err: Abrt %08x Err %08x "
958 "Cmpl Err: xb %08x Err %08x\n",
959 atomic_read(&lport
->xmt_ls_abort
),
960 atomic_read(&lport
->xmt_ls_err
),
961 atomic_read(&lport
->cmpl_ls_xb
),
962 atomic_read(&lport
->cmpl_ls_err
));
964 len
+= scnprintf(buf
+ len
, size
- len
,
965 "FCP Xmt Err: noxri %06x nondlp %06x "
966 "qdepth %06x wqerr %06x err %06x Abrt %06x\n",
967 atomic_read(&lport
->xmt_fcp_noxri
),
968 atomic_read(&lport
->xmt_fcp_bad_ndlp
),
969 atomic_read(&lport
->xmt_fcp_qdepth
),
970 atomic_read(&lport
->xmt_fcp_wqerr
),
971 atomic_read(&lport
->xmt_fcp_err
),
972 atomic_read(&lport
->xmt_fcp_abort
));
974 len
+= scnprintf(buf
+ len
, size
- len
,
975 "FCP Cmpl Err: xb %08x Err %08x\n",
976 atomic_read(&lport
->cmpl_fcp_xb
),
977 atomic_read(&lport
->cmpl_fcp_err
));
986 * lpfc_debugfs_nvmektime_data - Dump target node list to a buffer
987 * @vport: The vport to gather target node info from.
988 * @buf: The buffer to dump log into.
989 * @size: The maximum amount of data to process.
992 * This routine dumps the NVME statistics associated with @vport
995 * This routine returns the amount of bytes that were dumped into @buf and will
999 lpfc_debugfs_nvmektime_data(struct lpfc_vport
*vport
, char *buf
, int size
)
1001 struct lpfc_hba
*phba
= vport
->phba
;
1004 if (phba
->nvmet_support
== 0) {
1005 /* NVME Initiator */
1006 len
+= scnprintf(buf
+ len
, PAGE_SIZE
- len
,
1007 "ktime %s: Total Samples: %lld\n",
1008 (phba
->ktime_on
? "Enabled" : "Disabled"),
1009 phba
->ktime_data_samples
);
1010 if (phba
->ktime_data_samples
== 0)
1014 buf
+ len
, PAGE_SIZE
- len
,
1015 "Segment 1: Last NVME Cmd cmpl "
1016 "done -to- Start of next NVME cnd (in driver)\n");
1018 buf
+ len
, PAGE_SIZE
- len
,
1019 "avg:%08lld min:%08lld max %08lld\n",
1020 div_u64(phba
->ktime_seg1_total
,
1021 phba
->ktime_data_samples
),
1022 phba
->ktime_seg1_min
,
1023 phba
->ktime_seg1_max
);
1025 buf
+ len
, PAGE_SIZE
- len
,
1026 "Segment 2: Driver start of NVME cmd "
1027 "-to- Firmware WQ doorbell\n");
1029 buf
+ len
, PAGE_SIZE
- len
,
1030 "avg:%08lld min:%08lld max %08lld\n",
1031 div_u64(phba
->ktime_seg2_total
,
1032 phba
->ktime_data_samples
),
1033 phba
->ktime_seg2_min
,
1034 phba
->ktime_seg2_max
);
1036 buf
+ len
, PAGE_SIZE
- len
,
1037 "Segment 3: Firmware WQ doorbell -to- "
1038 "MSI-X ISR cmpl\n");
1040 buf
+ len
, PAGE_SIZE
- len
,
1041 "avg:%08lld min:%08lld max %08lld\n",
1042 div_u64(phba
->ktime_seg3_total
,
1043 phba
->ktime_data_samples
),
1044 phba
->ktime_seg3_min
,
1045 phba
->ktime_seg3_max
);
1047 buf
+ len
, PAGE_SIZE
- len
,
1048 "Segment 4: MSI-X ISR cmpl -to- "
1049 "NVME cmpl done\n");
1051 buf
+ len
, PAGE_SIZE
- len
,
1052 "avg:%08lld min:%08lld max %08lld\n",
1053 div_u64(phba
->ktime_seg4_total
,
1054 phba
->ktime_data_samples
),
1055 phba
->ktime_seg4_min
,
1056 phba
->ktime_seg4_max
);
1058 buf
+ len
, PAGE_SIZE
- len
,
1059 "Total IO avg time: %08lld\n",
1060 div_u64(phba
->ktime_seg1_total
+
1061 phba
->ktime_seg2_total
+
1062 phba
->ktime_seg3_total
+
1063 phba
->ktime_seg4_total
,
1064 phba
->ktime_data_samples
));
1069 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
1070 "ktime %s: Total Samples: %lld %lld\n",
1071 (phba
->ktime_on
? "Enabled" : "Disabled"),
1072 phba
->ktime_data_samples
,
1073 phba
->ktime_status_samples
);
1074 if (phba
->ktime_data_samples
== 0)
1077 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
1078 "Segment 1: MSI-X ISR Rcv cmd -to- "
1079 "cmd pass to NVME Layer\n");
1080 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
1081 "avg:%08lld min:%08lld max %08lld\n",
1082 div_u64(phba
->ktime_seg1_total
,
1083 phba
->ktime_data_samples
),
1084 phba
->ktime_seg1_min
,
1085 phba
->ktime_seg1_max
);
1086 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
1087 "Segment 2: cmd pass to NVME Layer- "
1088 "-to- Driver rcv cmd OP (action)\n");
1089 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
1090 "avg:%08lld min:%08lld max %08lld\n",
1091 div_u64(phba
->ktime_seg2_total
,
1092 phba
->ktime_data_samples
),
1093 phba
->ktime_seg2_min
,
1094 phba
->ktime_seg2_max
);
1095 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
1096 "Segment 3: Driver rcv cmd OP -to- "
1097 "Firmware WQ doorbell: cmd\n");
1098 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
1099 "avg:%08lld min:%08lld max %08lld\n",
1100 div_u64(phba
->ktime_seg3_total
,
1101 phba
->ktime_data_samples
),
1102 phba
->ktime_seg3_min
,
1103 phba
->ktime_seg3_max
);
1104 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
1105 "Segment 4: Firmware WQ doorbell: cmd "
1106 "-to- MSI-X ISR for cmd cmpl\n");
1107 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
1108 "avg:%08lld min:%08lld max %08lld\n",
1109 div_u64(phba
->ktime_seg4_total
,
1110 phba
->ktime_data_samples
),
1111 phba
->ktime_seg4_min
,
1112 phba
->ktime_seg4_max
);
1113 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
1114 "Segment 5: MSI-X ISR for cmd cmpl "
1115 "-to- NVME layer passed cmd done\n");
1116 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
1117 "avg:%08lld min:%08lld max %08lld\n",
1118 div_u64(phba
->ktime_seg5_total
,
1119 phba
->ktime_data_samples
),
1120 phba
->ktime_seg5_min
,
1121 phba
->ktime_seg5_max
);
1123 if (phba
->ktime_status_samples
== 0) {
1124 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
1125 "Total: cmd received by MSI-X ISR "
1126 "-to- cmd completed on wire\n");
1127 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
1128 "avg:%08lld min:%08lld "
1130 div_u64(phba
->ktime_seg10_total
,
1131 phba
->ktime_data_samples
),
1132 phba
->ktime_seg10_min
,
1133 phba
->ktime_seg10_max
);
1137 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
1138 "Segment 6: NVME layer passed cmd done "
1139 "-to- Driver rcv rsp status OP\n");
1140 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
1141 "avg:%08lld min:%08lld max %08lld\n",
1142 div_u64(phba
->ktime_seg6_total
,
1143 phba
->ktime_status_samples
),
1144 phba
->ktime_seg6_min
,
1145 phba
->ktime_seg6_max
);
1146 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
1147 "Segment 7: Driver rcv rsp status OP "
1148 "-to- Firmware WQ doorbell: status\n");
1149 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
1150 "avg:%08lld min:%08lld max %08lld\n",
1151 div_u64(phba
->ktime_seg7_total
,
1152 phba
->ktime_status_samples
),
1153 phba
->ktime_seg7_min
,
1154 phba
->ktime_seg7_max
);
1155 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
1156 "Segment 8: Firmware WQ doorbell: status"
1157 " -to- MSI-X ISR for status cmpl\n");
1158 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
1159 "avg:%08lld min:%08lld max %08lld\n",
1160 div_u64(phba
->ktime_seg8_total
,
1161 phba
->ktime_status_samples
),
1162 phba
->ktime_seg8_min
,
1163 phba
->ktime_seg8_max
);
1164 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
1165 "Segment 9: MSI-X ISR for status cmpl "
1166 "-to- NVME layer passed status done\n");
1167 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
1168 "avg:%08lld min:%08lld max %08lld\n",
1169 div_u64(phba
->ktime_seg9_total
,
1170 phba
->ktime_status_samples
),
1171 phba
->ktime_seg9_min
,
1172 phba
->ktime_seg9_max
);
1173 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
1174 "Total: cmd received by MSI-X ISR -to- "
1175 "cmd completed on wire\n");
1176 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
1177 "avg:%08lld min:%08lld max %08lld\n",
1178 div_u64(phba
->ktime_seg10_total
,
1179 phba
->ktime_status_samples
),
1180 phba
->ktime_seg10_min
,
1181 phba
->ktime_seg10_max
);
1186 * lpfc_debugfs_nvmeio_trc_data - Dump NVME IO trace list to a buffer
1187 * @phba: The phba to gather target node info from.
1188 * @buf: The buffer to dump log into.
1189 * @size: The maximum amount of data to process.
1192 * This routine dumps the NVME IO trace associated with @phba
1195 * This routine returns the amount of bytes that were dumped into @buf and will
1199 lpfc_debugfs_nvmeio_trc_data(struct lpfc_hba
*phba
, char *buf
, int size
)
1201 struct lpfc_debugfs_nvmeio_trc
*dtp
;
1202 int i
, state
, index
, skip
;
1205 state
= phba
->nvmeio_trc_on
;
1207 index
= (atomic_read(&phba
->nvmeio_trc_cnt
) + 1) &
1208 (phba
->nvmeio_trc_size
- 1);
1209 skip
= phba
->nvmeio_trc_output_idx
;
1211 len
+= scnprintf(buf
+ len
, size
- len
,
1212 "%s IO Trace %s: next_idx %d skip %d size %d\n",
1213 (phba
->nvmet_support
? "NVME" : "NVMET"),
1214 (state
? "Enabled" : "Disabled"),
1215 index
, skip
, phba
->nvmeio_trc_size
);
1217 if (!phba
->nvmeio_trc
|| state
)
1220 /* trace MUST bhe off to continue */
1222 for (i
= index
; i
< phba
->nvmeio_trc_size
; i
++) {
1227 dtp
= phba
->nvmeio_trc
+ i
;
1228 phba
->nvmeio_trc_output_idx
++;
1233 len
+= scnprintf(buf
+ len
, size
- len
, dtp
->fmt
,
1234 dtp
->data1
, dtp
->data2
, dtp
->data3
);
1236 if (phba
->nvmeio_trc_output_idx
>= phba
->nvmeio_trc_size
) {
1237 phba
->nvmeio_trc_output_idx
= 0;
1238 len
+= scnprintf(buf
+ len
, size
- len
,
1239 "Trace Complete\n");
1243 if (len
>= (size
- LPFC_DEBUG_OUT_LINE_SZ
)) {
1244 len
+= scnprintf(buf
+ len
, size
- len
,
1245 "Trace Continue (%d of %d)\n",
1246 phba
->nvmeio_trc_output_idx
,
1247 phba
->nvmeio_trc_size
);
1251 for (i
= 0; i
< index
; i
++) {
1256 dtp
= phba
->nvmeio_trc
+ i
;
1257 phba
->nvmeio_trc_output_idx
++;
1262 len
+= scnprintf(buf
+ len
, size
- len
, dtp
->fmt
,
1263 dtp
->data1
, dtp
->data2
, dtp
->data3
);
1265 if (phba
->nvmeio_trc_output_idx
>= phba
->nvmeio_trc_size
) {
1266 phba
->nvmeio_trc_output_idx
= 0;
1267 len
+= scnprintf(buf
+ len
, size
- len
,
1268 "Trace Complete\n");
1272 if (len
>= (size
- LPFC_DEBUG_OUT_LINE_SZ
)) {
1273 len
+= scnprintf(buf
+ len
, size
- len
,
1274 "Trace Continue (%d of %d)\n",
1275 phba
->nvmeio_trc_output_idx
,
1276 phba
->nvmeio_trc_size
);
1281 len
+= scnprintf(buf
+ len
, size
- len
,
1288 * lpfc_debugfs_cpucheck_data - Dump target node list to a buffer
1289 * @vport: The vport to gather target node info from.
1290 * @buf: The buffer to dump log into.
1291 * @size: The maximum amount of data to process.
1294 * This routine dumps the NVME statistics associated with @vport
1297 * This routine returns the amount of bytes that were dumped into @buf and will
1301 lpfc_debugfs_cpucheck_data(struct lpfc_vport
*vport
, char *buf
, int size
)
1303 struct lpfc_hba
*phba
= vport
->phba
;
1306 uint32_t tot_xmt
= 0;
1307 uint32_t tot_rcv
= 0;
1308 uint32_t tot_cmpl
= 0;
1309 uint32_t tot_ccmpl
= 0;
1311 if (phba
->nvmet_support
== 0) {
1312 /* NVME Initiator */
1313 len
+= scnprintf(buf
+ len
, PAGE_SIZE
- len
,
1315 (phba
->cpucheck_on
& LPFC_CHECK_NVME_IO
?
1316 "Enabled" : "Disabled"));
1317 for (i
= 0; i
< phba
->sli4_hba
.num_present_cpu
; i
++) {
1318 if (i
>= LPFC_CHECK_CPU_CNT
)
1320 len
+= scnprintf(buf
+ len
, PAGE_SIZE
- len
,
1321 "%02d: xmit x%08x cmpl x%08x\n",
1322 i
, phba
->cpucheck_xmt_io
[i
],
1323 phba
->cpucheck_cmpl_io
[i
]);
1324 tot_xmt
+= phba
->cpucheck_xmt_io
[i
];
1325 tot_cmpl
+= phba
->cpucheck_cmpl_io
[i
];
1327 len
+= scnprintf(buf
+ len
, PAGE_SIZE
- len
,
1328 "tot:xmit x%08x cmpl x%08x\n",
1334 len
+= scnprintf(buf
+ len
, PAGE_SIZE
- len
,
1336 (phba
->cpucheck_on
& LPFC_CHECK_NVMET_IO
?
1337 "IO Enabled - " : "IO Disabled - "));
1338 len
+= scnprintf(buf
+ len
, PAGE_SIZE
- len
,
1340 (phba
->cpucheck_on
& LPFC_CHECK_NVMET_RCV
?
1341 "Rcv Enabled\n" : "Rcv Disabled\n"));
1342 for (i
= 0; i
< phba
->sli4_hba
.num_present_cpu
; i
++) {
1343 if (i
>= LPFC_CHECK_CPU_CNT
)
1345 len
+= scnprintf(buf
+ len
, PAGE_SIZE
- len
,
1346 "%02d: xmit x%08x ccmpl x%08x "
1347 "cmpl x%08x rcv x%08x\n",
1348 i
, phba
->cpucheck_xmt_io
[i
],
1349 phba
->cpucheck_ccmpl_io
[i
],
1350 phba
->cpucheck_cmpl_io
[i
],
1351 phba
->cpucheck_rcv_io
[i
]);
1352 tot_xmt
+= phba
->cpucheck_xmt_io
[i
];
1353 tot_rcv
+= phba
->cpucheck_rcv_io
[i
];
1354 tot_cmpl
+= phba
->cpucheck_cmpl_io
[i
];
1355 tot_ccmpl
+= phba
->cpucheck_ccmpl_io
[i
];
1357 len
+= scnprintf(buf
+ len
, PAGE_SIZE
- len
,
1358 "tot:xmit x%08x ccmpl x%08x cmpl x%08x rcv x%08x\n",
1359 tot_xmt
, tot_ccmpl
, tot_cmpl
, tot_rcv
);
1366 * lpfc_debugfs_disc_trc - Store discovery trace log
1367 * @vport: The vport to associate this trace string with for retrieval.
1368 * @mask: Log entry classification.
1369 * @fmt: Format string to be displayed when dumping the log.
1370 * @data1: 1st data parameter to be applied to @fmt.
1371 * @data2: 2nd data parameter to be applied to @fmt.
1372 * @data3: 3rd data parameter to be applied to @fmt.
1375 * This routine is used by the driver code to add a debugfs log entry to the
1376 * discovery trace buffer associated with @vport. Only entries with a @mask that
1377 * match the current debugfs discovery mask will be saved. Entries that do not
1378 * match will be thrown away. @fmt, @data1, @data2, and @data3 are used like
1379 * printf when displaying the log.
1382 lpfc_debugfs_disc_trc(struct lpfc_vport
*vport
, int mask
, char *fmt
,
1383 uint32_t data1
, uint32_t data2
, uint32_t data3
)
1385 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
1386 struct lpfc_debugfs_trc
*dtp
;
1389 if (!(lpfc_debugfs_mask_disc_trc
& mask
))
1392 if (!lpfc_debugfs_enable
|| !lpfc_debugfs_max_disc_trc
||
1393 !vport
|| !vport
->disc_trc
)
1396 index
= atomic_inc_return(&vport
->disc_trc_cnt
) &
1397 (lpfc_debugfs_max_disc_trc
- 1);
1398 dtp
= vport
->disc_trc
+ index
;
1403 dtp
->seq_cnt
= atomic_inc_return(&lpfc_debugfs_seq_trc_cnt
);
1410 * lpfc_debugfs_slow_ring_trc - Store slow ring trace log
1411 * @phba: The phba to associate this trace string with for retrieval.
1412 * @fmt: Format string to be displayed when dumping the log.
1413 * @data1: 1st data parameter to be applied to @fmt.
1414 * @data2: 2nd data parameter to be applied to @fmt.
1415 * @data3: 3rd data parameter to be applied to @fmt.
1418 * This routine is used by the driver code to add a debugfs log entry to the
1419 * discovery trace buffer associated with @vport. @fmt, @data1, @data2, and
1420 * @data3 are used like printf when displaying the log.
1423 lpfc_debugfs_slow_ring_trc(struct lpfc_hba
*phba
, char *fmt
,
1424 uint32_t data1
, uint32_t data2
, uint32_t data3
)
1426 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
1427 struct lpfc_debugfs_trc
*dtp
;
1430 if (!lpfc_debugfs_enable
|| !lpfc_debugfs_max_slow_ring_trc
||
1431 !phba
|| !phba
->slow_ring_trc
)
1434 index
= atomic_inc_return(&phba
->slow_ring_trc_cnt
) &
1435 (lpfc_debugfs_max_slow_ring_trc
- 1);
1436 dtp
= phba
->slow_ring_trc
+ index
;
1441 dtp
->seq_cnt
= atomic_inc_return(&lpfc_debugfs_seq_trc_cnt
);
1448 * lpfc_debugfs_nvme_trc - Store NVME/NVMET trace log
1449 * @phba: The phba to associate this trace string with for retrieval.
1450 * @fmt: Format string to be displayed when dumping the log.
1451 * @data1: 1st data parameter to be applied to @fmt.
1452 * @data2: 2nd data parameter to be applied to @fmt.
1453 * @data3: 3rd data parameter to be applied to @fmt.
1456 * This routine is used by the driver code to add a debugfs log entry to the
1457 * nvme trace buffer associated with @phba. @fmt, @data1, @data2, and
1458 * @data3 are used like printf when displaying the log.
1461 lpfc_debugfs_nvme_trc(struct lpfc_hba
*phba
, char *fmt
,
1462 uint16_t data1
, uint16_t data2
, uint32_t data3
)
1464 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
1465 struct lpfc_debugfs_nvmeio_trc
*dtp
;
1468 if (!phba
->nvmeio_trc_on
|| !phba
->nvmeio_trc
)
1471 index
= atomic_inc_return(&phba
->nvmeio_trc_cnt
) &
1472 (phba
->nvmeio_trc_size
- 1);
1473 dtp
= phba
->nvmeio_trc
+ index
;
1481 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
1483 * lpfc_debugfs_disc_trc_open - Open the discovery trace log
1484 * @inode: The inode pointer that contains a vport pointer.
1485 * @file: The file pointer to attach the log output.
1488 * This routine is the entry point for the debugfs open file operation. It gets
1489 * the vport from the i_private field in @inode, allocates the necessary buffer
1490 * for the log, fills the buffer from the in-memory log for this vport, and then
1491 * returns a pointer to that log in the private_data field in @file.
1494 * This function returns zero if successful. On error it will return a negative
1498 lpfc_debugfs_disc_trc_open(struct inode
*inode
, struct file
*file
)
1500 struct lpfc_vport
*vport
= inode
->i_private
;
1501 struct lpfc_debug
*debug
;
1505 if (!lpfc_debugfs_max_disc_trc
) {
1510 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
1514 /* Round to page boundary */
1515 size
= (lpfc_debugfs_max_disc_trc
* LPFC_DEBUG_TRC_ENTRY_SIZE
);
1516 size
= PAGE_ALIGN(size
);
1518 debug
->buffer
= kmalloc(size
, GFP_KERNEL
);
1519 if (!debug
->buffer
) {
1524 debug
->len
= lpfc_debugfs_disc_trc_data(vport
, debug
->buffer
, size
);
1525 file
->private_data
= debug
;
1533 * lpfc_debugfs_slow_ring_trc_open - Open the Slow Ring trace log
1534 * @inode: The inode pointer that contains a vport pointer.
1535 * @file: The file pointer to attach the log output.
1538 * This routine is the entry point for the debugfs open file operation. It gets
1539 * the vport from the i_private field in @inode, allocates the necessary buffer
1540 * for the log, fills the buffer from the in-memory log for this vport, and then
1541 * returns a pointer to that log in the private_data field in @file.
1544 * This function returns zero if successful. On error it will return a negative
1548 lpfc_debugfs_slow_ring_trc_open(struct inode
*inode
, struct file
*file
)
1550 struct lpfc_hba
*phba
= inode
->i_private
;
1551 struct lpfc_debug
*debug
;
1555 if (!lpfc_debugfs_max_slow_ring_trc
) {
1560 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
1564 /* Round to page boundary */
1565 size
= (lpfc_debugfs_max_slow_ring_trc
* LPFC_DEBUG_TRC_ENTRY_SIZE
);
1566 size
= PAGE_ALIGN(size
);
1568 debug
->buffer
= kmalloc(size
, GFP_KERNEL
);
1569 if (!debug
->buffer
) {
1574 debug
->len
= lpfc_debugfs_slow_ring_trc_data(phba
, debug
->buffer
, size
);
1575 file
->private_data
= debug
;
1583 * lpfc_debugfs_hbqinfo_open - Open the hbqinfo debugfs buffer
1584 * @inode: The inode pointer that contains a vport pointer.
1585 * @file: The file pointer to attach the log output.
1588 * This routine is the entry point for the debugfs open file operation. It gets
1589 * the vport from the i_private field in @inode, allocates the necessary buffer
1590 * for the log, fills the buffer from the in-memory log for this vport, and then
1591 * returns a pointer to that log in the private_data field in @file.
1594 * This function returns zero if successful. On error it will return a negative
1598 lpfc_debugfs_hbqinfo_open(struct inode
*inode
, struct file
*file
)
1600 struct lpfc_hba
*phba
= inode
->i_private
;
1601 struct lpfc_debug
*debug
;
1604 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
1608 /* Round to page boundary */
1609 debug
->buffer
= kmalloc(LPFC_HBQINFO_SIZE
, GFP_KERNEL
);
1610 if (!debug
->buffer
) {
1615 debug
->len
= lpfc_debugfs_hbqinfo_data(phba
, debug
->buffer
,
1617 file
->private_data
= debug
;
1625 * lpfc_debugfs_dumpHBASlim_open - Open the Dump HBA SLIM debugfs buffer
1626 * @inode: The inode pointer that contains a vport pointer.
1627 * @file: The file pointer to attach the log output.
1630 * This routine is the entry point for the debugfs open file operation. It gets
1631 * the vport from the i_private field in @inode, allocates the necessary buffer
1632 * for the log, fills the buffer from the in-memory log for this vport, and then
1633 * returns a pointer to that log in the private_data field in @file.
1636 * This function returns zero if successful. On error it will return a negative
1640 lpfc_debugfs_dumpHBASlim_open(struct inode
*inode
, struct file
*file
)
1642 struct lpfc_hba
*phba
= inode
->i_private
;
1643 struct lpfc_debug
*debug
;
1646 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
1650 /* Round to page boundary */
1651 debug
->buffer
= kmalloc(LPFC_DUMPHBASLIM_SIZE
, GFP_KERNEL
);
1652 if (!debug
->buffer
) {
1657 debug
->len
= lpfc_debugfs_dumpHBASlim_data(phba
, debug
->buffer
,
1658 LPFC_DUMPHBASLIM_SIZE
);
1659 file
->private_data
= debug
;
1667 * lpfc_debugfs_dumpHostSlim_open - Open the Dump Host SLIM debugfs buffer
1668 * @inode: The inode pointer that contains a vport pointer.
1669 * @file: The file pointer to attach the log output.
1672 * This routine is the entry point for the debugfs open file operation. It gets
1673 * the vport from the i_private field in @inode, allocates the necessary buffer
1674 * for the log, fills the buffer from the in-memory log for this vport, and then
1675 * returns a pointer to that log in the private_data field in @file.
1678 * This function returns zero if successful. On error it will return a negative
1682 lpfc_debugfs_dumpHostSlim_open(struct inode
*inode
, struct file
*file
)
1684 struct lpfc_hba
*phba
= inode
->i_private
;
1685 struct lpfc_debug
*debug
;
1688 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
1692 /* Round to page boundary */
1693 debug
->buffer
= kmalloc(LPFC_DUMPHOSTSLIM_SIZE
, GFP_KERNEL
);
1694 if (!debug
->buffer
) {
1699 debug
->len
= lpfc_debugfs_dumpHostSlim_data(phba
, debug
->buffer
,
1700 LPFC_DUMPHOSTSLIM_SIZE
);
1701 file
->private_data
= debug
;
1709 lpfc_debugfs_dumpData_open(struct inode
*inode
, struct file
*file
)
1711 struct lpfc_debug
*debug
;
1714 if (!_dump_buf_data
)
1717 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
1721 /* Round to page boundary */
1722 pr_err("9059 BLKGRD: %s: _dump_buf_data=0x%p\n",
1723 __func__
, _dump_buf_data
);
1724 debug
->buffer
= _dump_buf_data
;
1725 if (!debug
->buffer
) {
1730 debug
->len
= (1 << _dump_buf_data_order
) << PAGE_SHIFT
;
1731 file
->private_data
= debug
;
1739 lpfc_debugfs_dumpDif_open(struct inode
*inode
, struct file
*file
)
1741 struct lpfc_debug
*debug
;
1747 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
1751 /* Round to page boundary */
1752 pr_err("9060 BLKGRD: %s: _dump_buf_dif=0x%p file=%pD\n",
1753 __func__
, _dump_buf_dif
, file
);
1754 debug
->buffer
= _dump_buf_dif
;
1755 if (!debug
->buffer
) {
1760 debug
->len
= (1 << _dump_buf_dif_order
) << PAGE_SHIFT
;
1761 file
->private_data
= debug
;
1769 lpfc_debugfs_dumpDataDif_write(struct file
*file
, const char __user
*buf
,
1770 size_t nbytes
, loff_t
*ppos
)
1773 * The Data/DIF buffers only save one failing IO
1774 * The write op is used as a reset mechanism after an IO has
1775 * already been saved to the next one can be saved
1777 spin_lock(&_dump_buf_lock
);
1779 memset((void *)_dump_buf_data
, 0,
1780 ((1 << PAGE_SHIFT
) << _dump_buf_data_order
));
1781 memset((void *)_dump_buf_dif
, 0,
1782 ((1 << PAGE_SHIFT
) << _dump_buf_dif_order
));
1786 spin_unlock(&_dump_buf_lock
);
1792 lpfc_debugfs_dif_err_read(struct file
*file
, char __user
*buf
,
1793 size_t nbytes
, loff_t
*ppos
)
1795 struct dentry
*dent
= file
->f_path
.dentry
;
1796 struct lpfc_hba
*phba
= file
->private_data
;
1801 if (dent
== phba
->debug_writeGuard
)
1802 cnt
= scnprintf(cbuf
, 32, "%u\n", phba
->lpfc_injerr_wgrd_cnt
);
1803 else if (dent
== phba
->debug_writeApp
)
1804 cnt
= scnprintf(cbuf
, 32, "%u\n", phba
->lpfc_injerr_wapp_cnt
);
1805 else if (dent
== phba
->debug_writeRef
)
1806 cnt
= scnprintf(cbuf
, 32, "%u\n", phba
->lpfc_injerr_wref_cnt
);
1807 else if (dent
== phba
->debug_readGuard
)
1808 cnt
= scnprintf(cbuf
, 32, "%u\n", phba
->lpfc_injerr_rgrd_cnt
);
1809 else if (dent
== phba
->debug_readApp
)
1810 cnt
= scnprintf(cbuf
, 32, "%u\n", phba
->lpfc_injerr_rapp_cnt
);
1811 else if (dent
== phba
->debug_readRef
)
1812 cnt
= scnprintf(cbuf
, 32, "%u\n", phba
->lpfc_injerr_rref_cnt
);
1813 else if (dent
== phba
->debug_InjErrNPortID
)
1814 cnt
= scnprintf(cbuf
, 32, "0x%06x\n",
1815 phba
->lpfc_injerr_nportid
);
1816 else if (dent
== phba
->debug_InjErrWWPN
) {
1817 memcpy(&tmp
, &phba
->lpfc_injerr_wwpn
, sizeof(struct lpfc_name
));
1818 tmp
= cpu_to_be64(tmp
);
1819 cnt
= scnprintf(cbuf
, 32, "0x%016llx\n", tmp
);
1820 } else if (dent
== phba
->debug_InjErrLBA
) {
1821 if (phba
->lpfc_injerr_lba
== (sector_t
)(-1))
1822 cnt
= scnprintf(cbuf
, 32, "off\n");
1824 cnt
= scnprintf(cbuf
, 32, "0x%llx\n",
1825 (uint64_t) phba
->lpfc_injerr_lba
);
1827 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
1828 "0547 Unknown debugfs error injection entry\n");
1830 return simple_read_from_buffer(buf
, nbytes
, ppos
, &cbuf
, cnt
);
1834 lpfc_debugfs_dif_err_write(struct file
*file
, const char __user
*buf
,
1835 size_t nbytes
, loff_t
*ppos
)
1837 struct dentry
*dent
= file
->f_path
.dentry
;
1838 struct lpfc_hba
*phba
= file
->private_data
;
1843 memset(dstbuf
, 0, 33);
1844 size
= (nbytes
< 32) ? nbytes
: 32;
1845 if (copy_from_user(dstbuf
, buf
, size
))
1848 if (dent
== phba
->debug_InjErrLBA
) {
1849 if ((buf
[0] == 'o') && (buf
[1] == 'f') && (buf
[2] == 'f'))
1850 tmp
= (uint64_t)(-1);
1853 if ((tmp
== 0) && (kstrtoull(dstbuf
, 0, &tmp
)))
1856 if (dent
== phba
->debug_writeGuard
)
1857 phba
->lpfc_injerr_wgrd_cnt
= (uint32_t)tmp
;
1858 else if (dent
== phba
->debug_writeApp
)
1859 phba
->lpfc_injerr_wapp_cnt
= (uint32_t)tmp
;
1860 else if (dent
== phba
->debug_writeRef
)
1861 phba
->lpfc_injerr_wref_cnt
= (uint32_t)tmp
;
1862 else if (dent
== phba
->debug_readGuard
)
1863 phba
->lpfc_injerr_rgrd_cnt
= (uint32_t)tmp
;
1864 else if (dent
== phba
->debug_readApp
)
1865 phba
->lpfc_injerr_rapp_cnt
= (uint32_t)tmp
;
1866 else if (dent
== phba
->debug_readRef
)
1867 phba
->lpfc_injerr_rref_cnt
= (uint32_t)tmp
;
1868 else if (dent
== phba
->debug_InjErrLBA
)
1869 phba
->lpfc_injerr_lba
= (sector_t
)tmp
;
1870 else if (dent
== phba
->debug_InjErrNPortID
)
1871 phba
->lpfc_injerr_nportid
= (uint32_t)(tmp
& Mask_DID
);
1872 else if (dent
== phba
->debug_InjErrWWPN
) {
1873 tmp
= cpu_to_be64(tmp
);
1874 memcpy(&phba
->lpfc_injerr_wwpn
, &tmp
, sizeof(struct lpfc_name
));
1876 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
1877 "0548 Unknown debugfs error injection entry\n");
1883 lpfc_debugfs_dif_err_release(struct inode
*inode
, struct file
*file
)
1889 * lpfc_debugfs_nodelist_open - Open the nodelist debugfs file
1890 * @inode: The inode pointer that contains a vport pointer.
1891 * @file: The file pointer to attach the log output.
1894 * This routine is the entry point for the debugfs open file operation. It gets
1895 * the vport from the i_private field in @inode, allocates the necessary buffer
1896 * for the log, fills the buffer from the in-memory log for this vport, and then
1897 * returns a pointer to that log in the private_data field in @file.
1900 * This function returns zero if successful. On error it will return a negative
1904 lpfc_debugfs_nodelist_open(struct inode
*inode
, struct file
*file
)
1906 struct lpfc_vport
*vport
= inode
->i_private
;
1907 struct lpfc_debug
*debug
;
1910 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
1914 /* Round to page boundary */
1915 debug
->buffer
= kmalloc(LPFC_NODELIST_SIZE
, GFP_KERNEL
);
1916 if (!debug
->buffer
) {
1921 debug
->len
= lpfc_debugfs_nodelist_data(vport
, debug
->buffer
,
1922 LPFC_NODELIST_SIZE
);
1923 file
->private_data
= debug
;
1931 * lpfc_debugfs_lseek - Seek through a debugfs file
1932 * @file: The file pointer to seek through.
1933 * @off: The offset to seek to or the amount to seek by.
1934 * @whence: Indicates how to seek.
1937 * This routine is the entry point for the debugfs lseek file operation. The
1938 * @whence parameter indicates whether @off is the offset to directly seek to,
1939 * or if it is a value to seek forward or reverse by. This function figures out
1940 * what the new offset of the debugfs file will be and assigns that value to the
1941 * f_pos field of @file.
1944 * This function returns the new offset if successful and returns a negative
1945 * error if unable to process the seek.
1948 lpfc_debugfs_lseek(struct file
*file
, loff_t off
, int whence
)
1950 struct lpfc_debug
*debug
= file
->private_data
;
1951 return fixed_size_llseek(file
, off
, whence
, debug
->len
);
1955 * lpfc_debugfs_read - Read a debugfs file
1956 * @file: The file pointer to read from.
1957 * @buf: The buffer to copy the data to.
1958 * @nbytes: The number of bytes to read.
1959 * @ppos: The position in the file to start reading from.
1962 * This routine reads data from from the buffer indicated in the private_data
1963 * field of @file. It will start reading at @ppos and copy up to @nbytes of
1967 * This function returns the amount of data that was read (this could be less
1968 * than @nbytes if the end of the file was reached) or a negative error value.
1971 lpfc_debugfs_read(struct file
*file
, char __user
*buf
,
1972 size_t nbytes
, loff_t
*ppos
)
1974 struct lpfc_debug
*debug
= file
->private_data
;
1976 return simple_read_from_buffer(buf
, nbytes
, ppos
, debug
->buffer
,
1981 * lpfc_debugfs_release - Release the buffer used to store debugfs file data
1982 * @inode: The inode pointer that contains a vport pointer. (unused)
1983 * @file: The file pointer that contains the buffer to release.
1986 * This routine frees the buffer that was allocated when the debugfs file was
1990 * This function returns zero.
1993 lpfc_debugfs_release(struct inode
*inode
, struct file
*file
)
1995 struct lpfc_debug
*debug
= file
->private_data
;
1997 kfree(debug
->buffer
);
2004 lpfc_debugfs_dumpDataDif_release(struct inode
*inode
, struct file
*file
)
2006 struct lpfc_debug
*debug
= file
->private_data
;
2008 debug
->buffer
= NULL
;
2016 lpfc_debugfs_nvmestat_open(struct inode
*inode
, struct file
*file
)
2018 struct lpfc_vport
*vport
= inode
->i_private
;
2019 struct lpfc_debug
*debug
;
2022 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
2026 /* Round to page boundary */
2027 debug
->buffer
= kmalloc(LPFC_NVMESTAT_SIZE
, GFP_KERNEL
);
2028 if (!debug
->buffer
) {
2033 debug
->len
= lpfc_debugfs_nvmestat_data(vport
, debug
->buffer
,
2034 LPFC_NVMESTAT_SIZE
);
2036 debug
->i_private
= inode
->i_private
;
2037 file
->private_data
= debug
;
2045 lpfc_debugfs_nvmestat_write(struct file
*file
, const char __user
*buf
,
2046 size_t nbytes
, loff_t
*ppos
)
2048 struct lpfc_debug
*debug
= file
->private_data
;
2049 struct lpfc_vport
*vport
= (struct lpfc_vport
*)debug
->i_private
;
2050 struct lpfc_hba
*phba
= vport
->phba
;
2051 struct lpfc_nvmet_tgtport
*tgtp
;
2055 if (!phba
->targetport
)
2061 memset(mybuf
, 0, sizeof(mybuf
));
2063 if (copy_from_user(mybuf
, buf
, nbytes
))
2067 tgtp
= (struct lpfc_nvmet_tgtport
*)phba
->targetport
->private;
2068 if ((strncmp(pbuf
, "reset", strlen("reset")) == 0) ||
2069 (strncmp(pbuf
, "zero", strlen("zero")) == 0)) {
2070 atomic_set(&tgtp
->rcv_ls_req_in
, 0);
2071 atomic_set(&tgtp
->rcv_ls_req_out
, 0);
2072 atomic_set(&tgtp
->rcv_ls_req_drop
, 0);
2073 atomic_set(&tgtp
->xmt_ls_abort
, 0);
2074 atomic_set(&tgtp
->xmt_ls_abort_cmpl
, 0);
2075 atomic_set(&tgtp
->xmt_ls_rsp
, 0);
2076 atomic_set(&tgtp
->xmt_ls_drop
, 0);
2077 atomic_set(&tgtp
->xmt_ls_rsp_error
, 0);
2078 atomic_set(&tgtp
->xmt_ls_rsp_cmpl
, 0);
2080 atomic_set(&tgtp
->rcv_fcp_cmd_in
, 0);
2081 atomic_set(&tgtp
->rcv_fcp_cmd_out
, 0);
2082 atomic_set(&tgtp
->rcv_fcp_cmd_drop
, 0);
2083 atomic_set(&tgtp
->xmt_fcp_drop
, 0);
2084 atomic_set(&tgtp
->xmt_fcp_read_rsp
, 0);
2085 atomic_set(&tgtp
->xmt_fcp_read
, 0);
2086 atomic_set(&tgtp
->xmt_fcp_write
, 0);
2087 atomic_set(&tgtp
->xmt_fcp_rsp
, 0);
2088 atomic_set(&tgtp
->xmt_fcp_release
, 0);
2089 atomic_set(&tgtp
->xmt_fcp_rsp_cmpl
, 0);
2090 atomic_set(&tgtp
->xmt_fcp_rsp_error
, 0);
2091 atomic_set(&tgtp
->xmt_fcp_rsp_drop
, 0);
2093 atomic_set(&tgtp
->xmt_fcp_abort
, 0);
2094 atomic_set(&tgtp
->xmt_fcp_abort_cmpl
, 0);
2095 atomic_set(&tgtp
->xmt_abort_sol
, 0);
2096 atomic_set(&tgtp
->xmt_abort_unsol
, 0);
2097 atomic_set(&tgtp
->xmt_abort_rsp
, 0);
2098 atomic_set(&tgtp
->xmt_abort_rsp_error
, 0);
2104 lpfc_debugfs_nvmektime_open(struct inode
*inode
, struct file
*file
)
2106 struct lpfc_vport
*vport
= inode
->i_private
;
2107 struct lpfc_debug
*debug
;
2110 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
2114 /* Round to page boundary */
2115 debug
->buffer
= kmalloc(LPFC_NVMEKTIME_SIZE
, GFP_KERNEL
);
2116 if (!debug
->buffer
) {
2121 debug
->len
= lpfc_debugfs_nvmektime_data(vport
, debug
->buffer
,
2122 LPFC_NVMEKTIME_SIZE
);
2124 debug
->i_private
= inode
->i_private
;
2125 file
->private_data
= debug
;
2133 lpfc_debugfs_nvmektime_write(struct file
*file
, const char __user
*buf
,
2134 size_t nbytes
, loff_t
*ppos
)
2136 struct lpfc_debug
*debug
= file
->private_data
;
2137 struct lpfc_vport
*vport
= (struct lpfc_vport
*)debug
->i_private
;
2138 struct lpfc_hba
*phba
= vport
->phba
;
2145 memset(mybuf
, 0, sizeof(mybuf
));
2147 if (copy_from_user(mybuf
, buf
, nbytes
))
2151 if ((strncmp(pbuf
, "on", sizeof("on") - 1) == 0)) {
2152 phba
->ktime_data_samples
= 0;
2153 phba
->ktime_status_samples
= 0;
2154 phba
->ktime_seg1_total
= 0;
2155 phba
->ktime_seg1_max
= 0;
2156 phba
->ktime_seg1_min
= 0xffffffff;
2157 phba
->ktime_seg2_total
= 0;
2158 phba
->ktime_seg2_max
= 0;
2159 phba
->ktime_seg2_min
= 0xffffffff;
2160 phba
->ktime_seg3_total
= 0;
2161 phba
->ktime_seg3_max
= 0;
2162 phba
->ktime_seg3_min
= 0xffffffff;
2163 phba
->ktime_seg4_total
= 0;
2164 phba
->ktime_seg4_max
= 0;
2165 phba
->ktime_seg4_min
= 0xffffffff;
2166 phba
->ktime_seg5_total
= 0;
2167 phba
->ktime_seg5_max
= 0;
2168 phba
->ktime_seg5_min
= 0xffffffff;
2169 phba
->ktime_seg6_total
= 0;
2170 phba
->ktime_seg6_max
= 0;
2171 phba
->ktime_seg6_min
= 0xffffffff;
2172 phba
->ktime_seg7_total
= 0;
2173 phba
->ktime_seg7_max
= 0;
2174 phba
->ktime_seg7_min
= 0xffffffff;
2175 phba
->ktime_seg8_total
= 0;
2176 phba
->ktime_seg8_max
= 0;
2177 phba
->ktime_seg8_min
= 0xffffffff;
2178 phba
->ktime_seg9_total
= 0;
2179 phba
->ktime_seg9_max
= 0;
2180 phba
->ktime_seg9_min
= 0xffffffff;
2181 phba
->ktime_seg10_total
= 0;
2182 phba
->ktime_seg10_max
= 0;
2183 phba
->ktime_seg10_min
= 0xffffffff;
2186 return strlen(pbuf
);
2187 } else if ((strncmp(pbuf
, "off",
2188 sizeof("off") - 1) == 0)) {
2190 return strlen(pbuf
);
2191 } else if ((strncmp(pbuf
, "zero",
2192 sizeof("zero") - 1) == 0)) {
2193 phba
->ktime_data_samples
= 0;
2194 phba
->ktime_status_samples
= 0;
2195 phba
->ktime_seg1_total
= 0;
2196 phba
->ktime_seg1_max
= 0;
2197 phba
->ktime_seg1_min
= 0xffffffff;
2198 phba
->ktime_seg2_total
= 0;
2199 phba
->ktime_seg2_max
= 0;
2200 phba
->ktime_seg2_min
= 0xffffffff;
2201 phba
->ktime_seg3_total
= 0;
2202 phba
->ktime_seg3_max
= 0;
2203 phba
->ktime_seg3_min
= 0xffffffff;
2204 phba
->ktime_seg4_total
= 0;
2205 phba
->ktime_seg4_max
= 0;
2206 phba
->ktime_seg4_min
= 0xffffffff;
2207 phba
->ktime_seg5_total
= 0;
2208 phba
->ktime_seg5_max
= 0;
2209 phba
->ktime_seg5_min
= 0xffffffff;
2210 phba
->ktime_seg6_total
= 0;
2211 phba
->ktime_seg6_max
= 0;
2212 phba
->ktime_seg6_min
= 0xffffffff;
2213 phba
->ktime_seg7_total
= 0;
2214 phba
->ktime_seg7_max
= 0;
2215 phba
->ktime_seg7_min
= 0xffffffff;
2216 phba
->ktime_seg8_total
= 0;
2217 phba
->ktime_seg8_max
= 0;
2218 phba
->ktime_seg8_min
= 0xffffffff;
2219 phba
->ktime_seg9_total
= 0;
2220 phba
->ktime_seg9_max
= 0;
2221 phba
->ktime_seg9_min
= 0xffffffff;
2222 phba
->ktime_seg10_total
= 0;
2223 phba
->ktime_seg10_max
= 0;
2224 phba
->ktime_seg10_min
= 0xffffffff;
2225 return strlen(pbuf
);
2231 lpfc_debugfs_nvmeio_trc_open(struct inode
*inode
, struct file
*file
)
2233 struct lpfc_hba
*phba
= inode
->i_private
;
2234 struct lpfc_debug
*debug
;
2237 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
2241 /* Round to page boundary */
2242 debug
->buffer
= kmalloc(LPFC_NVMEIO_TRC_SIZE
, GFP_KERNEL
);
2243 if (!debug
->buffer
) {
2248 debug
->len
= lpfc_debugfs_nvmeio_trc_data(phba
, debug
->buffer
,
2249 LPFC_NVMEIO_TRC_SIZE
);
2251 debug
->i_private
= inode
->i_private
;
2252 file
->private_data
= debug
;
2260 lpfc_debugfs_nvmeio_trc_write(struct file
*file
, const char __user
*buf
,
2261 size_t nbytes
, loff_t
*ppos
)
2263 struct lpfc_debug
*debug
= file
->private_data
;
2264 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
2273 memset(mybuf
, 0, sizeof(mybuf
));
2275 if (copy_from_user(mybuf
, buf
, nbytes
))
2279 if ((strncmp(pbuf
, "off", sizeof("off") - 1) == 0)) {
2280 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
2281 "0570 nvmeio_trc_off\n");
2282 phba
->nvmeio_trc_output_idx
= 0;
2283 phba
->nvmeio_trc_on
= 0;
2284 return strlen(pbuf
);
2285 } else if ((strncmp(pbuf
, "on", sizeof("on") - 1) == 0)) {
2286 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
2287 "0571 nvmeio_trc_on\n");
2288 phba
->nvmeio_trc_output_idx
= 0;
2289 phba
->nvmeio_trc_on
= 1;
2290 return strlen(pbuf
);
2293 /* We must be off to allocate the trace buffer */
2294 if (phba
->nvmeio_trc_on
!= 0)
2297 /* If not on or off, the parameter is the trace buffer size */
2298 i
= kstrtoul(pbuf
, 0, &sz
);
2301 phba
->nvmeio_trc_size
= (uint32_t)sz
;
2303 /* It must be a power of 2 - round down */
2310 if (phba
->nvmeio_trc_size
!= sz
)
2311 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
2312 "0572 nvmeio_trc_size changed to %ld\n",
2314 phba
->nvmeio_trc_size
= (uint32_t)sz
;
2316 /* If one previously exists, free it */
2317 kfree(phba
->nvmeio_trc
);
2319 /* Allocate new trace buffer and initialize */
2320 phba
->nvmeio_trc
= kzalloc((sizeof(struct lpfc_debugfs_nvmeio_trc
) *
2322 if (!phba
->nvmeio_trc
) {
2323 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
2324 "0573 Cannot create debugfs "
2325 "nvmeio_trc buffer\n");
2328 atomic_set(&phba
->nvmeio_trc_cnt
, 0);
2329 phba
->nvmeio_trc_on
= 0;
2330 phba
->nvmeio_trc_output_idx
= 0;
2332 return strlen(pbuf
);
2336 lpfc_debugfs_cpucheck_open(struct inode
*inode
, struct file
*file
)
2338 struct lpfc_vport
*vport
= inode
->i_private
;
2339 struct lpfc_debug
*debug
;
2342 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
2346 /* Round to page boundary */
2347 debug
->buffer
= kmalloc(LPFC_CPUCHECK_SIZE
, GFP_KERNEL
);
2348 if (!debug
->buffer
) {
2353 debug
->len
= lpfc_debugfs_cpucheck_data(vport
, debug
->buffer
,
2354 LPFC_NVMEKTIME_SIZE
);
2356 debug
->i_private
= inode
->i_private
;
2357 file
->private_data
= debug
;
2365 lpfc_debugfs_cpucheck_write(struct file
*file
, const char __user
*buf
,
2366 size_t nbytes
, loff_t
*ppos
)
2368 struct lpfc_debug
*debug
= file
->private_data
;
2369 struct lpfc_vport
*vport
= (struct lpfc_vport
*)debug
->i_private
;
2370 struct lpfc_hba
*phba
= vport
->phba
;
2378 memset(mybuf
, 0, sizeof(mybuf
));
2380 if (copy_from_user(mybuf
, buf
, nbytes
))
2384 if ((strncmp(pbuf
, "on", sizeof("on") - 1) == 0)) {
2385 if (phba
->nvmet_support
)
2386 phba
->cpucheck_on
|= LPFC_CHECK_NVMET_IO
;
2388 phba
->cpucheck_on
|= LPFC_CHECK_NVME_IO
;
2389 return strlen(pbuf
);
2390 } else if ((strncmp(pbuf
, "rcv",
2391 sizeof("rcv") - 1) == 0)) {
2392 if (phba
->nvmet_support
)
2393 phba
->cpucheck_on
|= LPFC_CHECK_NVMET_RCV
;
2396 return strlen(pbuf
);
2397 } else if ((strncmp(pbuf
, "off",
2398 sizeof("off") - 1) == 0)) {
2399 phba
->cpucheck_on
= LPFC_CHECK_OFF
;
2400 return strlen(pbuf
);
2401 } else if ((strncmp(pbuf
, "zero",
2402 sizeof("zero") - 1) == 0)) {
2403 for (i
= 0; i
< phba
->sli4_hba
.num_present_cpu
; i
++) {
2404 if (i
>= LPFC_CHECK_CPU_CNT
)
2406 phba
->cpucheck_rcv_io
[i
] = 0;
2407 phba
->cpucheck_xmt_io
[i
] = 0;
2408 phba
->cpucheck_cmpl_io
[i
] = 0;
2409 phba
->cpucheck_ccmpl_io
[i
] = 0;
2411 return strlen(pbuf
);
2417 * ---------------------------------
2418 * iDiag debugfs file access methods
2419 * ---------------------------------
2421 * All access methods are through the proper SLI4 PCI function's debugfs
2424 * /sys/kernel/debug/lpfc/fn<#>/iDiag
2428 * lpfc_idiag_cmd_get - Get and parse idiag debugfs comands from user space
2429 * @buf: The pointer to the user space buffer.
2430 * @nbytes: The number of bytes in the user space buffer.
2431 * @idiag_cmd: pointer to the idiag command struct.
2433 * This routine reads data from debugfs user space buffer and parses the
2434 * buffer for getting the idiag command and arguments. The while space in
2435 * between the set of data is used as the parsing separator.
2437 * This routine returns 0 when successful, it returns proper error code
2438 * back to the user space in error conditions.
2440 static int lpfc_idiag_cmd_get(const char __user
*buf
, size_t nbytes
,
2441 struct lpfc_idiag_cmd
*idiag_cmd
)
2444 char *pbuf
, *step_str
;
2448 memset(mybuf
, 0, sizeof(mybuf
));
2449 memset(idiag_cmd
, 0, sizeof(*idiag_cmd
));
2450 bsize
= min(nbytes
, (sizeof(mybuf
)-1));
2452 if (copy_from_user(mybuf
, buf
, bsize
))
2455 step_str
= strsep(&pbuf
, "\t ");
2457 /* The opcode must present */
2461 idiag_cmd
->opcode
= simple_strtol(step_str
, NULL
, 0);
2462 if (idiag_cmd
->opcode
== 0)
2465 for (i
= 0; i
< LPFC_IDIAG_CMD_DATA_SIZE
; i
++) {
2466 step_str
= strsep(&pbuf
, "\t ");
2469 idiag_cmd
->data
[i
] = simple_strtol(step_str
, NULL
, 0);
2475 * lpfc_idiag_open - idiag open debugfs
2476 * @inode: The inode pointer that contains a pointer to phba.
2477 * @file: The file pointer to attach the file operation.
2480 * This routine is the entry point for the debugfs open file operation. It
2481 * gets the reference to phba from the i_private field in @inode, it then
2482 * allocates buffer for the file operation, performs the necessary PCI config
2483 * space read into the allocated buffer according to the idiag user command
2484 * setup, and then returns a pointer to buffer in the private_data field in
2488 * This function returns zero if successful. On error it will return an
2489 * negative error value.
2492 lpfc_idiag_open(struct inode
*inode
, struct file
*file
)
2494 struct lpfc_debug
*debug
;
2496 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
2500 debug
->i_private
= inode
->i_private
;
2501 debug
->buffer
= NULL
;
2502 file
->private_data
= debug
;
2508 * lpfc_idiag_release - Release idiag access file operation
2509 * @inode: The inode pointer that contains a vport pointer. (unused)
2510 * @file: The file pointer that contains the buffer to release.
2513 * This routine is the generic release routine for the idiag access file
2514 * operation, it frees the buffer that was allocated when the debugfs file
2518 * This function returns zero.
2521 lpfc_idiag_release(struct inode
*inode
, struct file
*file
)
2523 struct lpfc_debug
*debug
= file
->private_data
;
2525 /* Free the buffers to the file operation */
2526 kfree(debug
->buffer
);
2533 * lpfc_idiag_cmd_release - Release idiag cmd access file operation
2534 * @inode: The inode pointer that contains a vport pointer. (unused)
2535 * @file: The file pointer that contains the buffer to release.
2538 * This routine frees the buffer that was allocated when the debugfs file
2539 * was opened. It also reset the fields in the idiag command struct in the
2540 * case of command for write operation.
2543 * This function returns zero.
2546 lpfc_idiag_cmd_release(struct inode
*inode
, struct file
*file
)
2548 struct lpfc_debug
*debug
= file
->private_data
;
2550 if (debug
->op
== LPFC_IDIAG_OP_WR
) {
2551 switch (idiag
.cmd
.opcode
) {
2552 case LPFC_IDIAG_CMD_PCICFG_WR
:
2553 case LPFC_IDIAG_CMD_PCICFG_ST
:
2554 case LPFC_IDIAG_CMD_PCICFG_CL
:
2555 case LPFC_IDIAG_CMD_QUEACC_WR
:
2556 case LPFC_IDIAG_CMD_QUEACC_ST
:
2557 case LPFC_IDIAG_CMD_QUEACC_CL
:
2558 memset(&idiag
, 0, sizeof(idiag
));
2565 /* Free the buffers to the file operation */
2566 kfree(debug
->buffer
);
2573 * lpfc_idiag_pcicfg_read - idiag debugfs read pcicfg
2574 * @file: The file pointer to read from.
2575 * @buf: The buffer to copy the data to.
2576 * @nbytes: The number of bytes to read.
2577 * @ppos: The position in the file to start reading from.
2580 * This routine reads data from the @phba pci config space according to the
2581 * idiag command, and copies to user @buf. Depending on the PCI config space
2582 * read command setup, it does either a single register read of a byte
2583 * (8 bits), a word (16 bits), or a dword (32 bits) or browsing through all
2584 * registers from the 4K extended PCI config space.
2587 * This function returns the amount of data that was read (this could be less
2588 * than @nbytes if the end of the file was reached) or a negative error value.
2591 lpfc_idiag_pcicfg_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
2594 struct lpfc_debug
*debug
= file
->private_data
;
2595 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
2596 int offset_label
, offset
, len
= 0, index
= LPFC_PCI_CFG_RD_SIZE
;
2599 struct pci_dev
*pdev
;
2604 pdev
= phba
->pcidev
;
2608 /* This is a user read operation */
2609 debug
->op
= LPFC_IDIAG_OP_RD
;
2612 debug
->buffer
= kmalloc(LPFC_PCI_CFG_SIZE
, GFP_KERNEL
);
2615 pbuffer
= debug
->buffer
;
2620 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_RD
) {
2621 where
= idiag
.cmd
.data
[IDIAG_PCICFG_WHERE_INDX
];
2622 count
= idiag
.cmd
.data
[IDIAG_PCICFG_COUNT_INDX
];
2626 /* Read single PCI config space register */
2628 case SIZE_U8
: /* byte (8 bits) */
2629 pci_read_config_byte(pdev
, where
, &u8val
);
2630 len
+= scnprintf(pbuffer
+len
, LPFC_PCI_CFG_SIZE
-len
,
2631 "%03x: %02x\n", where
, u8val
);
2633 case SIZE_U16
: /* word (16 bits) */
2634 pci_read_config_word(pdev
, where
, &u16val
);
2635 len
+= scnprintf(pbuffer
+len
, LPFC_PCI_CFG_SIZE
-len
,
2636 "%03x: %04x\n", where
, u16val
);
2638 case SIZE_U32
: /* double word (32 bits) */
2639 pci_read_config_dword(pdev
, where
, &u32val
);
2640 len
+= scnprintf(pbuffer
+len
, LPFC_PCI_CFG_SIZE
-len
,
2641 "%03x: %08x\n", where
, u32val
);
2643 case LPFC_PCI_CFG_BROWSE
: /* browse all */
2651 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
2655 /* Browse all PCI config space registers */
2656 offset_label
= idiag
.offset
.last_rd
;
2657 offset
= offset_label
;
2659 /* Read PCI config space */
2660 len
+= scnprintf(pbuffer
+len
, LPFC_PCI_CFG_SIZE
-len
,
2661 "%03x: ", offset_label
);
2663 pci_read_config_dword(pdev
, offset
, &u32val
);
2664 len
+= scnprintf(pbuffer
+len
, LPFC_PCI_CFG_SIZE
-len
,
2666 offset
+= sizeof(uint32_t);
2667 if (offset
>= LPFC_PCI_CFG_SIZE
) {
2668 len
+= scnprintf(pbuffer
+len
,
2669 LPFC_PCI_CFG_SIZE
-len
, "\n");
2672 index
-= sizeof(uint32_t);
2674 len
+= scnprintf(pbuffer
+len
, LPFC_PCI_CFG_SIZE
-len
,
2676 else if (!(index
% (8 * sizeof(uint32_t)))) {
2677 offset_label
+= (8 * sizeof(uint32_t));
2678 len
+= scnprintf(pbuffer
+len
, LPFC_PCI_CFG_SIZE
-len
,
2679 "\n%03x: ", offset_label
);
2683 /* Set up the offset for next portion of pci cfg read */
2685 idiag
.offset
.last_rd
+= LPFC_PCI_CFG_RD_SIZE
;
2686 if (idiag
.offset
.last_rd
>= LPFC_PCI_CFG_SIZE
)
2687 idiag
.offset
.last_rd
= 0;
2689 idiag
.offset
.last_rd
= 0;
2691 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
2695 * lpfc_idiag_pcicfg_write - Syntax check and set up idiag pcicfg commands
2696 * @file: The file pointer to read from.
2697 * @buf: The buffer to copy the user data from.
2698 * @nbytes: The number of bytes to get.
2699 * @ppos: The position in the file to start reading from.
2701 * This routine get the debugfs idiag command struct from user space and
2702 * then perform the syntax check for PCI config space read or write command
2703 * accordingly. In the case of PCI config space read command, it sets up
2704 * the command in the idiag command struct for the debugfs read operation.
2705 * In the case of PCI config space write operation, it executes the write
2706 * operation into the PCI config space accordingly.
2708 * It returns the @nbytges passing in from debugfs user space when successful.
2709 * In case of error conditions, it returns proper error code back to the user
2713 lpfc_idiag_pcicfg_write(struct file
*file
, const char __user
*buf
,
2714 size_t nbytes
, loff_t
*ppos
)
2716 struct lpfc_debug
*debug
= file
->private_data
;
2717 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
2718 uint32_t where
, value
, count
;
2722 struct pci_dev
*pdev
;
2725 pdev
= phba
->pcidev
;
2729 /* This is a user write operation */
2730 debug
->op
= LPFC_IDIAG_OP_WR
;
2732 rc
= lpfc_idiag_cmd_get(buf
, nbytes
, &idiag
.cmd
);
2736 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_RD
) {
2737 /* Sanity check on PCI config read command line arguments */
2738 if (rc
!= LPFC_PCI_CFG_RD_CMD_ARG
)
2740 /* Read command from PCI config space, set up command fields */
2741 where
= idiag
.cmd
.data
[IDIAG_PCICFG_WHERE_INDX
];
2742 count
= idiag
.cmd
.data
[IDIAG_PCICFG_COUNT_INDX
];
2743 if (count
== LPFC_PCI_CFG_BROWSE
) {
2744 if (where
% sizeof(uint32_t))
2746 /* Starting offset to browse */
2747 idiag
.offset
.last_rd
= where
;
2748 } else if ((count
!= sizeof(uint8_t)) &&
2749 (count
!= sizeof(uint16_t)) &&
2750 (count
!= sizeof(uint32_t)))
2752 if (count
== sizeof(uint8_t)) {
2753 if (where
> LPFC_PCI_CFG_SIZE
- sizeof(uint8_t))
2755 if (where
% sizeof(uint8_t))
2758 if (count
== sizeof(uint16_t)) {
2759 if (where
> LPFC_PCI_CFG_SIZE
- sizeof(uint16_t))
2761 if (where
% sizeof(uint16_t))
2764 if (count
== sizeof(uint32_t)) {
2765 if (where
> LPFC_PCI_CFG_SIZE
- sizeof(uint32_t))
2767 if (where
% sizeof(uint32_t))
2770 } else if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_WR
||
2771 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_ST
||
2772 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_CL
) {
2773 /* Sanity check on PCI config write command line arguments */
2774 if (rc
!= LPFC_PCI_CFG_WR_CMD_ARG
)
2776 /* Write command to PCI config space, read-modify-write */
2777 where
= idiag
.cmd
.data
[IDIAG_PCICFG_WHERE_INDX
];
2778 count
= idiag
.cmd
.data
[IDIAG_PCICFG_COUNT_INDX
];
2779 value
= idiag
.cmd
.data
[IDIAG_PCICFG_VALUE_INDX
];
2781 if ((count
!= sizeof(uint8_t)) &&
2782 (count
!= sizeof(uint16_t)) &&
2783 (count
!= sizeof(uint32_t)))
2785 if (count
== sizeof(uint8_t)) {
2786 if (where
> LPFC_PCI_CFG_SIZE
- sizeof(uint8_t))
2788 if (where
% sizeof(uint8_t))
2790 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_WR
)
2791 pci_write_config_byte(pdev
, where
,
2793 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_ST
) {
2794 rc
= pci_read_config_byte(pdev
, where
, &u8val
);
2796 u8val
|= (uint8_t)value
;
2797 pci_write_config_byte(pdev
, where
,
2801 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_CL
) {
2802 rc
= pci_read_config_byte(pdev
, where
, &u8val
);
2804 u8val
&= (uint8_t)(~value
);
2805 pci_write_config_byte(pdev
, where
,
2810 if (count
== sizeof(uint16_t)) {
2811 if (where
> LPFC_PCI_CFG_SIZE
- sizeof(uint16_t))
2813 if (where
% sizeof(uint16_t))
2815 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_WR
)
2816 pci_write_config_word(pdev
, where
,
2818 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_ST
) {
2819 rc
= pci_read_config_word(pdev
, where
, &u16val
);
2821 u16val
|= (uint16_t)value
;
2822 pci_write_config_word(pdev
, where
,
2826 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_CL
) {
2827 rc
= pci_read_config_word(pdev
, where
, &u16val
);
2829 u16val
&= (uint16_t)(~value
);
2830 pci_write_config_word(pdev
, where
,
2835 if (count
== sizeof(uint32_t)) {
2836 if (where
> LPFC_PCI_CFG_SIZE
- sizeof(uint32_t))
2838 if (where
% sizeof(uint32_t))
2840 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_WR
)
2841 pci_write_config_dword(pdev
, where
, value
);
2842 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_ST
) {
2843 rc
= pci_read_config_dword(pdev
, where
,
2847 pci_write_config_dword(pdev
, where
,
2851 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_CL
) {
2852 rc
= pci_read_config_dword(pdev
, where
,
2856 pci_write_config_dword(pdev
, where
,
2862 /* All other opecodes are illegal for now */
2867 memset(&idiag
, 0, sizeof(idiag
));
2872 * lpfc_idiag_baracc_read - idiag debugfs pci bar access read
2873 * @file: The file pointer to read from.
2874 * @buf: The buffer to copy the data to.
2875 * @nbytes: The number of bytes to read.
2876 * @ppos: The position in the file to start reading from.
2879 * This routine reads data from the @phba pci bar memory mapped space
2880 * according to the idiag command, and copies to user @buf.
2883 * This function returns the amount of data that was read (this could be less
2884 * than @nbytes if the end of the file was reached) or a negative error value.
2887 lpfc_idiag_baracc_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
2890 struct lpfc_debug
*debug
= file
->private_data
;
2891 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
2892 int offset_label
, offset
, offset_run
, len
= 0, index
;
2893 int bar_num
, acc_range
, bar_size
;
2895 void __iomem
*mem_mapped_bar
;
2897 struct pci_dev
*pdev
;
2900 pdev
= phba
->pcidev
;
2904 /* This is a user read operation */
2905 debug
->op
= LPFC_IDIAG_OP_RD
;
2908 debug
->buffer
= kmalloc(LPFC_PCI_BAR_RD_BUF_SIZE
, GFP_KERNEL
);
2911 pbuffer
= debug
->buffer
;
2916 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_RD
) {
2917 bar_num
= idiag
.cmd
.data
[IDIAG_BARACC_BAR_NUM_INDX
];
2918 offset
= idiag
.cmd
.data
[IDIAG_BARACC_OFF_SET_INDX
];
2919 acc_range
= idiag
.cmd
.data
[IDIAG_BARACC_ACC_MOD_INDX
];
2920 bar_size
= idiag
.cmd
.data
[IDIAG_BARACC_BAR_SZE_INDX
];
2927 if_type
= bf_get(lpfc_sli_intf_if_type
, &phba
->sli4_hba
.sli_intf
);
2928 if (if_type
== LPFC_SLI_INTF_IF_TYPE_0
) {
2929 if (bar_num
== IDIAG_BARACC_BAR_0
)
2930 mem_mapped_bar
= phba
->sli4_hba
.conf_regs_memmap_p
;
2931 else if (bar_num
== IDIAG_BARACC_BAR_1
)
2932 mem_mapped_bar
= phba
->sli4_hba
.ctrl_regs_memmap_p
;
2933 else if (bar_num
== IDIAG_BARACC_BAR_2
)
2934 mem_mapped_bar
= phba
->sli4_hba
.drbl_regs_memmap_p
;
2937 } else if (if_type
== LPFC_SLI_INTF_IF_TYPE_2
) {
2938 if (bar_num
== IDIAG_BARACC_BAR_0
)
2939 mem_mapped_bar
= phba
->sli4_hba
.conf_regs_memmap_p
;
2945 /* Read single PCI bar space register */
2946 if (acc_range
== SINGLE_WORD
) {
2947 offset_run
= offset
;
2948 u32val
= readl(mem_mapped_bar
+ offset_run
);
2949 len
+= scnprintf(pbuffer
+len
, LPFC_PCI_BAR_RD_BUF_SIZE
-len
,
2950 "%05x: %08x\n", offset_run
, u32val
);
2954 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
2958 /* Browse all PCI bar space registers */
2959 offset_label
= idiag
.offset
.last_rd
;
2960 offset_run
= offset_label
;
2962 /* Read PCI bar memory mapped space */
2963 len
+= scnprintf(pbuffer
+len
, LPFC_PCI_BAR_RD_BUF_SIZE
-len
,
2964 "%05x: ", offset_label
);
2965 index
= LPFC_PCI_BAR_RD_SIZE
;
2967 u32val
= readl(mem_mapped_bar
+ offset_run
);
2968 len
+= scnprintf(pbuffer
+len
, LPFC_PCI_BAR_RD_BUF_SIZE
-len
,
2970 offset_run
+= sizeof(uint32_t);
2971 if (acc_range
== LPFC_PCI_BAR_BROWSE
) {
2972 if (offset_run
>= bar_size
) {
2973 len
+= scnprintf(pbuffer
+len
,
2974 LPFC_PCI_BAR_RD_BUF_SIZE
-len
, "\n");
2978 if (offset_run
>= offset
+
2979 (acc_range
* sizeof(uint32_t))) {
2980 len
+= scnprintf(pbuffer
+len
,
2981 LPFC_PCI_BAR_RD_BUF_SIZE
-len
, "\n");
2985 index
-= sizeof(uint32_t);
2987 len
+= scnprintf(pbuffer
+len
,
2988 LPFC_PCI_BAR_RD_BUF_SIZE
-len
, "\n");
2989 else if (!(index
% (8 * sizeof(uint32_t)))) {
2990 offset_label
+= (8 * sizeof(uint32_t));
2991 len
+= scnprintf(pbuffer
+len
,
2992 LPFC_PCI_BAR_RD_BUF_SIZE
-len
,
2993 "\n%05x: ", offset_label
);
2997 /* Set up the offset for next portion of pci bar read */
2999 idiag
.offset
.last_rd
+= LPFC_PCI_BAR_RD_SIZE
;
3000 if (acc_range
== LPFC_PCI_BAR_BROWSE
) {
3001 if (idiag
.offset
.last_rd
>= bar_size
)
3002 idiag
.offset
.last_rd
= 0;
3004 if (offset_run
>= offset
+
3005 (acc_range
* sizeof(uint32_t)))
3006 idiag
.offset
.last_rd
= offset
;
3009 if (acc_range
== LPFC_PCI_BAR_BROWSE
)
3010 idiag
.offset
.last_rd
= 0;
3012 idiag
.offset
.last_rd
= offset
;
3015 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
3019 * lpfc_idiag_baracc_write - Syntax check and set up idiag bar access commands
3020 * @file: The file pointer to read from.
3021 * @buf: The buffer to copy the user data from.
3022 * @nbytes: The number of bytes to get.
3023 * @ppos: The position in the file to start reading from.
3025 * This routine get the debugfs idiag command struct from user space and
3026 * then perform the syntax check for PCI bar memory mapped space read or
3027 * write command accordingly. In the case of PCI bar memory mapped space
3028 * read command, it sets up the command in the idiag command struct for
3029 * the debugfs read operation. In the case of PCI bar memorpy mapped space
3030 * write operation, it executes the write operation into the PCI bar memory
3031 * mapped space accordingly.
3033 * It returns the @nbytges passing in from debugfs user space when successful.
3034 * In case of error conditions, it returns proper error code back to the user
3038 lpfc_idiag_baracc_write(struct file
*file
, const char __user
*buf
,
3039 size_t nbytes
, loff_t
*ppos
)
3041 struct lpfc_debug
*debug
= file
->private_data
;
3042 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
3043 uint32_t bar_num
, bar_size
, offset
, value
, acc_range
;
3044 struct pci_dev
*pdev
;
3045 void __iomem
*mem_mapped_bar
;
3050 pdev
= phba
->pcidev
;
3054 /* This is a user write operation */
3055 debug
->op
= LPFC_IDIAG_OP_WR
;
3057 rc
= lpfc_idiag_cmd_get(buf
, nbytes
, &idiag
.cmd
);
3061 if_type
= bf_get(lpfc_sli_intf_if_type
, &phba
->sli4_hba
.sli_intf
);
3062 bar_num
= idiag
.cmd
.data
[IDIAG_BARACC_BAR_NUM_INDX
];
3064 if (if_type
== LPFC_SLI_INTF_IF_TYPE_0
) {
3065 if ((bar_num
!= IDIAG_BARACC_BAR_0
) &&
3066 (bar_num
!= IDIAG_BARACC_BAR_1
) &&
3067 (bar_num
!= IDIAG_BARACC_BAR_2
))
3069 } else if (if_type
== LPFC_SLI_INTF_IF_TYPE_2
) {
3070 if (bar_num
!= IDIAG_BARACC_BAR_0
)
3075 if (if_type
== LPFC_SLI_INTF_IF_TYPE_0
) {
3076 if (bar_num
== IDIAG_BARACC_BAR_0
) {
3077 idiag
.cmd
.data
[IDIAG_BARACC_BAR_SZE_INDX
] =
3078 LPFC_PCI_IF0_BAR0_SIZE
;
3079 mem_mapped_bar
= phba
->sli4_hba
.conf_regs_memmap_p
;
3080 } else if (bar_num
== IDIAG_BARACC_BAR_1
) {
3081 idiag
.cmd
.data
[IDIAG_BARACC_BAR_SZE_INDX
] =
3082 LPFC_PCI_IF0_BAR1_SIZE
;
3083 mem_mapped_bar
= phba
->sli4_hba
.ctrl_regs_memmap_p
;
3084 } else if (bar_num
== IDIAG_BARACC_BAR_2
) {
3085 idiag
.cmd
.data
[IDIAG_BARACC_BAR_SZE_INDX
] =
3086 LPFC_PCI_IF0_BAR2_SIZE
;
3087 mem_mapped_bar
= phba
->sli4_hba
.drbl_regs_memmap_p
;
3090 } else if (if_type
== LPFC_SLI_INTF_IF_TYPE_2
) {
3091 if (bar_num
== IDIAG_BARACC_BAR_0
) {
3092 idiag
.cmd
.data
[IDIAG_BARACC_BAR_SZE_INDX
] =
3093 LPFC_PCI_IF2_BAR0_SIZE
;
3094 mem_mapped_bar
= phba
->sli4_hba
.conf_regs_memmap_p
;
3100 offset
= idiag
.cmd
.data
[IDIAG_BARACC_OFF_SET_INDX
];
3101 if (offset
% sizeof(uint32_t))
3104 bar_size
= idiag
.cmd
.data
[IDIAG_BARACC_BAR_SZE_INDX
];
3105 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_RD
) {
3106 /* Sanity check on PCI config read command line arguments */
3107 if (rc
!= LPFC_PCI_BAR_RD_CMD_ARG
)
3109 acc_range
= idiag
.cmd
.data
[IDIAG_BARACC_ACC_MOD_INDX
];
3110 if (acc_range
== LPFC_PCI_BAR_BROWSE
) {
3111 if (offset
> bar_size
- sizeof(uint32_t))
3113 /* Starting offset to browse */
3114 idiag
.offset
.last_rd
= offset
;
3115 } else if (acc_range
> SINGLE_WORD
) {
3116 if (offset
+ acc_range
* sizeof(uint32_t) > bar_size
)
3118 /* Starting offset to browse */
3119 idiag
.offset
.last_rd
= offset
;
3120 } else if (acc_range
!= SINGLE_WORD
)
3122 } else if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_WR
||
3123 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_ST
||
3124 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_CL
) {
3125 /* Sanity check on PCI bar write command line arguments */
3126 if (rc
!= LPFC_PCI_BAR_WR_CMD_ARG
)
3128 /* Write command to PCI bar space, read-modify-write */
3129 acc_range
= SINGLE_WORD
;
3130 value
= idiag
.cmd
.data
[IDIAG_BARACC_REG_VAL_INDX
];
3131 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_WR
) {
3132 writel(value
, mem_mapped_bar
+ offset
);
3133 readl(mem_mapped_bar
+ offset
);
3135 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_ST
) {
3136 u32val
= readl(mem_mapped_bar
+ offset
);
3138 writel(u32val
, mem_mapped_bar
+ offset
);
3139 readl(mem_mapped_bar
+ offset
);
3141 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_CL
) {
3142 u32val
= readl(mem_mapped_bar
+ offset
);
3144 writel(u32val
, mem_mapped_bar
+ offset
);
3145 readl(mem_mapped_bar
+ offset
);
3148 /* All other opecodes are illegal for now */
3153 memset(&idiag
, 0, sizeof(idiag
));
3158 __lpfc_idiag_print_wq(struct lpfc_queue
*qp
, char *wqtype
,
3159 char *pbuffer
, int len
)
3164 len
+= scnprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3165 "\t\t%s WQ info: ", wqtype
);
3166 len
+= scnprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3167 "AssocCQID[%04d]: WQ-STAT[oflow:x%x posted:x%llx]\n",
3168 qp
->assoc_qid
, qp
->q_cnt_1
,
3169 (unsigned long long)qp
->q_cnt_4
);
3170 len
+= scnprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3171 "\t\tWQID[%02d], QE-CNT[%04d], QE-SZ[%04d], "
3172 "HST-IDX[%04d], PRT-IDX[%04d], PST[%03d]",
3173 qp
->queue_id
, qp
->entry_count
,
3174 qp
->entry_size
, qp
->host_index
,
3175 qp
->hba_index
, qp
->entry_repost
);
3176 len
+= scnprintf(pbuffer
+ len
,
3177 LPFC_QUE_INFO_GET_BUF_SIZE
- len
, "\n");
3182 lpfc_idiag_wqs_for_cq(struct lpfc_hba
*phba
, char *wqtype
, char *pbuffer
,
3183 int *len
, int max_cnt
, int cq_id
)
3185 struct lpfc_queue
*qp
;
3188 for (qidx
= 0; qidx
< phba
->cfg_fcp_io_channel
; qidx
++) {
3189 qp
= phba
->sli4_hba
.fcp_wq
[qidx
];
3190 if (qp
->assoc_qid
!= cq_id
)
3192 *len
= __lpfc_idiag_print_wq(qp
, wqtype
, pbuffer
, *len
);
3193 if (*len
>= max_cnt
)
3196 for (qidx
= 0; qidx
< phba
->cfg_nvme_io_channel
; qidx
++) {
3197 qp
= phba
->sli4_hba
.nvme_wq
[qidx
];
3198 if (qp
->assoc_qid
!= cq_id
)
3200 *len
= __lpfc_idiag_print_wq(qp
, wqtype
, pbuffer
, *len
);
3201 if (*len
>= max_cnt
)
3208 __lpfc_idiag_print_cq(struct lpfc_queue
*qp
, char *cqtype
,
3209 char *pbuffer
, int len
)
3214 len
+= scnprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3215 "\t%s CQ info: ", cqtype
);
3216 len
+= scnprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3217 "AssocEQID[%02d]: CQ STAT[max:x%x relw:x%x "
3218 "xabt:x%x wq:x%llx]\n",
3219 qp
->assoc_qid
, qp
->q_cnt_1
, qp
->q_cnt_2
,
3220 qp
->q_cnt_3
, (unsigned long long)qp
->q_cnt_4
);
3221 len
+= scnprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3222 "\tCQID[%02d], QE-CNT[%04d], QE-SZ[%04d], "
3223 "HST-IDX[%04d], PRT-IDX[%04d], PST[%03d]",
3224 qp
->queue_id
, qp
->entry_count
,
3225 qp
->entry_size
, qp
->host_index
,
3226 qp
->hba_index
, qp
->entry_repost
);
3228 len
+= scnprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
, "\n");
3234 __lpfc_idiag_print_rqpair(struct lpfc_queue
*qp
, struct lpfc_queue
*datqp
,
3235 char *rqtype
, char *pbuffer
, int len
)
3240 len
+= scnprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3241 "\t\t%s RQ info: ", rqtype
);
3242 len
+= scnprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3243 "AssocCQID[%02d]: RQ-STAT[nopost:x%x nobuf:x%x "
3244 "posted:x%x rcv:x%llx]\n",
3245 qp
->assoc_qid
, qp
->q_cnt_1
, qp
->q_cnt_2
,
3246 qp
->q_cnt_3
, (unsigned long long)qp
->q_cnt_4
);
3247 len
+= scnprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3248 "\t\tHQID[%02d], QE-CNT[%04d], QE-SZ[%04d], "
3249 "HST-IDX[%04d], PRT-IDX[%04d], PST[%03d]\n",
3250 qp
->queue_id
, qp
->entry_count
, qp
->entry_size
,
3251 qp
->host_index
, qp
->hba_index
, qp
->entry_repost
);
3252 len
+= scnprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3253 "\t\tDQID[%02d], QE-CNT[%04d], QE-SZ[%04d], "
3254 "HST-IDX[%04d], PRT-IDX[%04d], PST[%03d]\n",
3255 datqp
->queue_id
, datqp
->entry_count
,
3256 datqp
->entry_size
, datqp
->host_index
,
3257 datqp
->hba_index
, datqp
->entry_repost
);
3262 lpfc_idiag_cqs_for_eq(struct lpfc_hba
*phba
, char *pbuffer
,
3263 int *len
, int max_cnt
, int eqidx
, int eq_id
)
3265 struct lpfc_queue
*qp
;
3268 for (qidx
= 0; qidx
< phba
->cfg_fcp_io_channel
; qidx
++) {
3269 qp
= phba
->sli4_hba
.fcp_cq
[qidx
];
3270 if (qp
->assoc_qid
!= eq_id
)
3273 *len
= __lpfc_idiag_print_cq(qp
, "FCP", pbuffer
, *len
);
3275 /* Reset max counter */
3278 if (*len
>= max_cnt
)
3281 rc
= lpfc_idiag_wqs_for_cq(phba
, "FCP", pbuffer
, len
,
3282 max_cnt
, qp
->queue_id
);
3287 for (qidx
= 0; qidx
< phba
->cfg_nvme_io_channel
; qidx
++) {
3288 qp
= phba
->sli4_hba
.nvme_cq
[qidx
];
3289 if (qp
->assoc_qid
!= eq_id
)
3292 *len
= __lpfc_idiag_print_cq(qp
, "NVME", pbuffer
, *len
);
3294 /* Reset max counter */
3297 if (*len
>= max_cnt
)
3300 rc
= lpfc_idiag_wqs_for_cq(phba
, "NVME", pbuffer
, len
,
3301 max_cnt
, qp
->queue_id
);
3306 if ((eqidx
< phba
->cfg_nvmet_mrq
) && phba
->nvmet_support
) {
3308 qp
= phba
->sli4_hba
.nvmet_cqset
[eqidx
];
3309 *len
= __lpfc_idiag_print_cq(qp
, "NVMET CQset", pbuffer
, *len
);
3311 /* Reset max counter */
3314 if (*len
>= max_cnt
)
3318 qp
= phba
->sli4_hba
.nvmet_mrq_hdr
[eqidx
];
3319 *len
= __lpfc_idiag_print_rqpair(qp
,
3320 phba
->sli4_hba
.nvmet_mrq_data
[eqidx
],
3321 "NVMET MRQ", pbuffer
, *len
);
3323 if (*len
>= max_cnt
)
3331 __lpfc_idiag_print_eq(struct lpfc_queue
*qp
, char *eqtype
,
3332 char *pbuffer
, int len
)
3337 len
+= scnprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3338 "\n%s EQ info: EQ-STAT[max:x%x noE:x%x "
3339 "cqe_proc:x%x eqe_proc:x%llx eqd %d]\n",
3340 eqtype
, qp
->q_cnt_1
, qp
->q_cnt_2
, qp
->q_cnt_3
,
3341 (unsigned long long)qp
->q_cnt_4
, qp
->q_mode
);
3342 len
+= scnprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3343 "EQID[%02d], QE-CNT[%04d], QE-SZ[%04d], "
3344 "HST-IDX[%04d], PRT-IDX[%04d], PST[%03d]",
3345 qp
->queue_id
, qp
->entry_count
, qp
->entry_size
,
3346 qp
->host_index
, qp
->hba_index
, qp
->entry_repost
);
3347 len
+= scnprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
, "\n");
3353 * lpfc_idiag_queinfo_read - idiag debugfs read queue information
3354 * @file: The file pointer to read from.
3355 * @buf: The buffer to copy the data to.
3356 * @nbytes: The number of bytes to read.
3357 * @ppos: The position in the file to start reading from.
3360 * This routine reads data from the @phba SLI4 PCI function queue information,
3361 * and copies to user @buf.
3362 * This routine only returns 1 EQs worth of information. It remembers the last
3363 * EQ read and jumps to the next EQ. Thus subsequent calls to queInfo will
3364 * retrieve all EQs allocated for the phba.
3367 * This function returns the amount of data that was read (this could be less
3368 * than @nbytes if the end of the file was reached) or a negative error value.
3371 lpfc_idiag_queinfo_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
3374 struct lpfc_debug
*debug
= file
->private_data
;
3375 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
3377 int max_cnt
, rc
, x
, len
= 0;
3378 struct lpfc_queue
*qp
= NULL
;
3381 debug
->buffer
= kmalloc(LPFC_QUE_INFO_GET_BUF_SIZE
, GFP_KERNEL
);
3384 pbuffer
= debug
->buffer
;
3385 max_cnt
= LPFC_QUE_INFO_GET_BUF_SIZE
- 256;
3390 spin_lock_irq(&phba
->hbalock
);
3392 /* Fast-path event queue */
3393 if (phba
->sli4_hba
.hba_eq
&& phba
->io_channel_irqs
) {
3395 x
= phba
->lpfc_idiag_last_eq
;
3396 if (phba
->cfg_fof
&& (x
>= phba
->io_channel_irqs
)) {
3397 phba
->lpfc_idiag_last_eq
= 0;
3400 phba
->lpfc_idiag_last_eq
++;
3401 if (phba
->lpfc_idiag_last_eq
>= phba
->io_channel_irqs
)
3402 if (phba
->cfg_fof
== 0)
3403 phba
->lpfc_idiag_last_eq
= 0;
3405 len
+= scnprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3406 "EQ %d out of %d HBA EQs\n",
3407 x
, phba
->io_channel_irqs
);
3410 qp
= phba
->sli4_hba
.hba_eq
[x
];
3414 len
= __lpfc_idiag_print_eq(qp
, "HBA", pbuffer
, len
);
3416 /* Reset max counter */
3422 /* will dump both fcp and nvme cqs/wqs for the eq */
3423 rc
= lpfc_idiag_cqs_for_eq(phba
, pbuffer
, &len
,
3424 max_cnt
, x
, qp
->queue_id
);
3428 /* Only EQ 0 has slow path CQs configured */
3432 /* Slow-path mailbox CQ */
3433 qp
= phba
->sli4_hba
.mbx_cq
;
3434 len
= __lpfc_idiag_print_cq(qp
, "MBX", pbuffer
, len
);
3438 /* Slow-path MBOX MQ */
3439 qp
= phba
->sli4_hba
.mbx_wq
;
3440 len
= __lpfc_idiag_print_wq(qp
, "MBX", pbuffer
, len
);
3444 /* Slow-path ELS response CQ */
3445 qp
= phba
->sli4_hba
.els_cq
;
3446 len
= __lpfc_idiag_print_cq(qp
, "ELS", pbuffer
, len
);
3447 /* Reset max counter */
3453 /* Slow-path ELS WQ */
3454 qp
= phba
->sli4_hba
.els_wq
;
3455 len
= __lpfc_idiag_print_wq(qp
, "ELS", pbuffer
, len
);
3459 qp
= phba
->sli4_hba
.hdr_rq
;
3460 len
= __lpfc_idiag_print_rqpair(qp
, phba
->sli4_hba
.dat_rq
,
3461 "ELS RQpair", pbuffer
, len
);
3465 /* Slow-path NVME LS response CQ */
3466 qp
= phba
->sli4_hba
.nvmels_cq
;
3467 len
= __lpfc_idiag_print_cq(qp
, "NVME LS",
3469 /* Reset max counter */
3475 /* Slow-path NVME LS WQ */
3476 qp
= phba
->sli4_hba
.nvmels_wq
;
3477 len
= __lpfc_idiag_print_wq(qp
, "NVME LS",
3486 if (phba
->cfg_fof
) {
3488 qp
= phba
->sli4_hba
.fof_eq
;
3489 len
= __lpfc_idiag_print_eq(qp
, "FOF", pbuffer
, len
);
3491 /* Reset max counter */
3499 qp
= phba
->sli4_hba
.oas_cq
;
3500 len
= __lpfc_idiag_print_cq(qp
, "OAS", pbuffer
, len
);
3501 /* Reset max counter */
3508 qp
= phba
->sli4_hba
.oas_wq
;
3509 len
= __lpfc_idiag_print_wq(qp
, "OAS", pbuffer
, len
);
3514 spin_unlock_irq(&phba
->hbalock
);
3515 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
3518 len
+= scnprintf(pbuffer
+ len
,
3519 LPFC_QUE_INFO_GET_BUF_SIZE
- len
, "Truncated ...\n");
3521 spin_unlock_irq(&phba
->hbalock
);
3522 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
3526 * lpfc_idiag_que_param_check - queue access command parameter sanity check
3527 * @q: The pointer to queue structure.
3528 * @index: The index into a queue entry.
3529 * @count: The number of queue entries to access.
3532 * The routine performs sanity check on device queue access method commands.
3535 * This function returns -EINVAL when fails the sanity check, otherwise, it
3539 lpfc_idiag_que_param_check(struct lpfc_queue
*q
, int index
, int count
)
3541 /* Only support single entry read or browsing */
3542 if ((count
!= 1) && (count
!= LPFC_QUE_ACC_BROWSE
))
3544 if (index
> q
->entry_count
- 1)
3550 * lpfc_idiag_queacc_read_qe - read a single entry from the given queue index
3551 * @pbuffer: The pointer to buffer to copy the read data into.
3552 * @pque: The pointer to the queue to be read.
3553 * @index: The index into the queue entry.
3556 * This routine reads out a single entry from the given queue's index location
3557 * and copies it into the buffer provided.
3560 * This function returns 0 when it fails, otherwise, it returns the length of
3561 * the data read into the buffer provided.
3564 lpfc_idiag_queacc_read_qe(char *pbuffer
, int len
, struct lpfc_queue
*pque
,
3570 if (!pbuffer
|| !pque
)
3573 esize
= pque
->entry_size
;
3574 len
+= scnprintf(pbuffer
+len
, LPFC_QUE_ACC_BUF_SIZE
-len
,
3575 "QE-INDEX[%04d]:\n", index
);
3578 pentry
= pque
->qe
[index
].address
;
3580 len
+= scnprintf(pbuffer
+len
, LPFC_QUE_ACC_BUF_SIZE
-len
,
3583 offset
+= sizeof(uint32_t);
3584 esize
-= sizeof(uint32_t);
3585 if (esize
> 0 && !(offset
% (4 * sizeof(uint32_t))))
3586 len
+= scnprintf(pbuffer
+len
,
3587 LPFC_QUE_ACC_BUF_SIZE
-len
, "\n");
3589 len
+= scnprintf(pbuffer
+len
, LPFC_QUE_ACC_BUF_SIZE
-len
, "\n");
3595 * lpfc_idiag_queacc_read - idiag debugfs read port queue
3596 * @file: The file pointer to read from.
3597 * @buf: The buffer to copy the data to.
3598 * @nbytes: The number of bytes to read.
3599 * @ppos: The position in the file to start reading from.
3602 * This routine reads data from the @phba device queue memory according to the
3603 * idiag command, and copies to user @buf. Depending on the queue dump read
3604 * command setup, it does either a single queue entry read or browing through
3605 * all entries of the queue.
3608 * This function returns the amount of data that was read (this could be less
3609 * than @nbytes if the end of the file was reached) or a negative error value.
3612 lpfc_idiag_queacc_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
3615 struct lpfc_debug
*debug
= file
->private_data
;
3616 uint32_t last_index
, index
, count
;
3617 struct lpfc_queue
*pque
= NULL
;
3621 /* This is a user read operation */
3622 debug
->op
= LPFC_IDIAG_OP_RD
;
3625 debug
->buffer
= kmalloc(LPFC_QUE_ACC_BUF_SIZE
, GFP_KERNEL
);
3628 pbuffer
= debug
->buffer
;
3633 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_RD
) {
3634 index
= idiag
.cmd
.data
[IDIAG_QUEACC_INDEX_INDX
];
3635 count
= idiag
.cmd
.data
[IDIAG_QUEACC_COUNT_INDX
];
3636 pque
= (struct lpfc_queue
*)idiag
.ptr_private
;
3640 /* Browse the queue starting from index */
3641 if (count
== LPFC_QUE_ACC_BROWSE
)
3644 /* Read a single entry from the queue */
3645 len
= lpfc_idiag_queacc_read_qe(pbuffer
, len
, pque
, index
);
3647 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
3651 /* Browse all entries from the queue */
3652 last_index
= idiag
.offset
.last_rd
;
3655 while (len
< LPFC_QUE_ACC_SIZE
- pque
->entry_size
) {
3656 len
= lpfc_idiag_queacc_read_qe(pbuffer
, len
, pque
, index
);
3658 if (index
> pque
->entry_count
- 1)
3662 /* Set up the offset for next portion of pci cfg read */
3663 if (index
> pque
->entry_count
- 1)
3665 idiag
.offset
.last_rd
= index
;
3667 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
3671 * lpfc_idiag_queacc_write - Syntax check and set up idiag queacc commands
3672 * @file: The file pointer to read from.
3673 * @buf: The buffer to copy the user data from.
3674 * @nbytes: The number of bytes to get.
3675 * @ppos: The position in the file to start reading from.
3677 * This routine get the debugfs idiag command struct from user space and then
3678 * perform the syntax check for port queue read (dump) or write (set) command
3679 * accordingly. In the case of port queue read command, it sets up the command
3680 * in the idiag command struct for the following debugfs read operation. In
3681 * the case of port queue write operation, it executes the write operation
3682 * into the port queue entry accordingly.
3684 * It returns the @nbytges passing in from debugfs user space when successful.
3685 * In case of error conditions, it returns proper error code back to the user
3689 lpfc_idiag_queacc_write(struct file
*file
, const char __user
*buf
,
3690 size_t nbytes
, loff_t
*ppos
)
3692 struct lpfc_debug
*debug
= file
->private_data
;
3693 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
3694 uint32_t qidx
, quetp
, queid
, index
, count
, offset
, value
;
3696 struct lpfc_queue
*pque
, *qp
;
3699 /* This is a user write operation */
3700 debug
->op
= LPFC_IDIAG_OP_WR
;
3702 rc
= lpfc_idiag_cmd_get(buf
, nbytes
, &idiag
.cmd
);
3706 /* Get and sanity check on command feilds */
3707 quetp
= idiag
.cmd
.data
[IDIAG_QUEACC_QUETP_INDX
];
3708 queid
= idiag
.cmd
.data
[IDIAG_QUEACC_QUEID_INDX
];
3709 index
= idiag
.cmd
.data
[IDIAG_QUEACC_INDEX_INDX
];
3710 count
= idiag
.cmd
.data
[IDIAG_QUEACC_COUNT_INDX
];
3711 offset
= idiag
.cmd
.data
[IDIAG_QUEACC_OFFST_INDX
];
3712 value
= idiag
.cmd
.data
[IDIAG_QUEACC_VALUE_INDX
];
3714 /* Sanity check on command line arguments */
3715 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_WR
||
3716 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_ST
||
3717 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_CL
) {
3718 if (rc
!= LPFC_QUE_ACC_WR_CMD_ARG
)
3722 } else if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_RD
) {
3723 if (rc
!= LPFC_QUE_ACC_RD_CMD_ARG
)
3730 /* HBA event queue */
3731 if (phba
->sli4_hba
.hba_eq
) {
3732 for (qidx
= 0; qidx
< phba
->io_channel_irqs
; qidx
++) {
3733 qp
= phba
->sli4_hba
.hba_eq
[qidx
];
3734 if (qp
&& qp
->queue_id
== queid
) {
3736 rc
= lpfc_idiag_que_param_check(qp
,
3740 idiag
.ptr_private
= qp
;
3748 /* MBX complete queue */
3749 if (phba
->sli4_hba
.mbx_cq
&&
3750 phba
->sli4_hba
.mbx_cq
->queue_id
== queid
) {
3752 rc
= lpfc_idiag_que_param_check(
3753 phba
->sli4_hba
.mbx_cq
, index
, count
);
3756 idiag
.ptr_private
= phba
->sli4_hba
.mbx_cq
;
3759 /* ELS complete queue */
3760 if (phba
->sli4_hba
.els_cq
&&
3761 phba
->sli4_hba
.els_cq
->queue_id
== queid
) {
3763 rc
= lpfc_idiag_que_param_check(
3764 phba
->sli4_hba
.els_cq
, index
, count
);
3767 idiag
.ptr_private
= phba
->sli4_hba
.els_cq
;
3770 /* NVME LS complete queue */
3771 if (phba
->sli4_hba
.nvmels_cq
&&
3772 phba
->sli4_hba
.nvmels_cq
->queue_id
== queid
) {
3774 rc
= lpfc_idiag_que_param_check(
3775 phba
->sli4_hba
.nvmels_cq
, index
, count
);
3778 idiag
.ptr_private
= phba
->sli4_hba
.nvmels_cq
;
3781 /* FCP complete queue */
3782 if (phba
->sli4_hba
.fcp_cq
) {
3783 for (qidx
= 0; qidx
< phba
->cfg_fcp_io_channel
;
3785 qp
= phba
->sli4_hba
.fcp_cq
[qidx
];
3786 if (qp
&& qp
->queue_id
== queid
) {
3788 rc
= lpfc_idiag_que_param_check(
3792 idiag
.ptr_private
= qp
;
3797 /* NVME complete queue */
3798 if (phba
->sli4_hba
.nvme_cq
) {
3801 if (phba
->sli4_hba
.nvme_cq
[qidx
] &&
3802 phba
->sli4_hba
.nvme_cq
[qidx
]->queue_id
==
3805 rc
= lpfc_idiag_que_param_check(
3806 phba
->sli4_hba
.nvme_cq
[qidx
],
3811 phba
->sli4_hba
.nvme_cq
[qidx
];
3814 } while (++qidx
< phba
->cfg_nvme_io_channel
);
3819 /* MBX work queue */
3820 if (phba
->sli4_hba
.mbx_wq
&&
3821 phba
->sli4_hba
.mbx_wq
->queue_id
== queid
) {
3823 rc
= lpfc_idiag_que_param_check(
3824 phba
->sli4_hba
.mbx_wq
, index
, count
);
3827 idiag
.ptr_private
= phba
->sli4_hba
.mbx_wq
;
3833 /* ELS work queue */
3834 if (phba
->sli4_hba
.els_wq
&&
3835 phba
->sli4_hba
.els_wq
->queue_id
== queid
) {
3837 rc
= lpfc_idiag_que_param_check(
3838 phba
->sli4_hba
.els_wq
, index
, count
);
3841 idiag
.ptr_private
= phba
->sli4_hba
.els_wq
;
3844 /* NVME LS work queue */
3845 if (phba
->sli4_hba
.nvmels_wq
&&
3846 phba
->sli4_hba
.nvmels_wq
->queue_id
== queid
) {
3848 rc
= lpfc_idiag_que_param_check(
3849 phba
->sli4_hba
.nvmels_wq
, index
, count
);
3852 idiag
.ptr_private
= phba
->sli4_hba
.nvmels_wq
;
3855 /* FCP work queue */
3856 if (phba
->sli4_hba
.fcp_wq
) {
3857 for (qidx
= 0; qidx
< phba
->cfg_fcp_io_channel
;
3859 qp
= phba
->sli4_hba
.fcp_wq
[qidx
];
3860 if (qp
&& qp
->queue_id
== queid
) {
3862 rc
= lpfc_idiag_que_param_check(
3866 idiag
.ptr_private
= qp
;
3871 /* NVME work queue */
3872 if (phba
->sli4_hba
.nvme_wq
) {
3873 for (qidx
= 0; qidx
< phba
->cfg_nvme_io_channel
;
3875 qp
= phba
->sli4_hba
.nvme_wq
[qidx
];
3876 if (qp
&& qp
->queue_id
== queid
) {
3878 rc
= lpfc_idiag_que_param_check(
3882 idiag
.ptr_private
= qp
;
3888 /* NVME work queues */
3889 if (phba
->sli4_hba
.nvme_wq
) {
3890 for (qidx
= 0; qidx
< phba
->cfg_nvme_io_channel
;
3892 if (!phba
->sli4_hba
.nvme_wq
[qidx
])
3894 if (phba
->sli4_hba
.nvme_wq
[qidx
]->queue_id
==
3897 rc
= lpfc_idiag_que_param_check(
3898 phba
->sli4_hba
.nvme_wq
[qidx
],
3903 phba
->sli4_hba
.nvme_wq
[qidx
];
3912 if (phba
->sli4_hba
.hdr_rq
&&
3913 phba
->sli4_hba
.hdr_rq
->queue_id
== queid
) {
3915 rc
= lpfc_idiag_que_param_check(
3916 phba
->sli4_hba
.hdr_rq
, index
, count
);
3919 idiag
.ptr_private
= phba
->sli4_hba
.hdr_rq
;
3923 if (phba
->sli4_hba
.dat_rq
&&
3924 phba
->sli4_hba
.dat_rq
->queue_id
== queid
) {
3926 rc
= lpfc_idiag_que_param_check(
3927 phba
->sli4_hba
.dat_rq
, index
, count
);
3930 idiag
.ptr_private
= phba
->sli4_hba
.dat_rq
;
3942 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_RD
) {
3943 if (count
== LPFC_QUE_ACC_BROWSE
)
3944 idiag
.offset
.last_rd
= index
;
3947 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_WR
||
3948 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_ST
||
3949 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_CL
) {
3950 /* Additional sanity checks on write operation */
3951 pque
= (struct lpfc_queue
*)idiag
.ptr_private
;
3952 if (offset
> pque
->entry_size
/sizeof(uint32_t) - 1)
3954 pentry
= pque
->qe
[index
].address
;
3956 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_WR
)
3958 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_ST
)
3960 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_CL
)
3966 /* Clean out command structure on command error out */
3967 memset(&idiag
, 0, sizeof(idiag
));
3972 * lpfc_idiag_drbacc_read_reg - idiag debugfs read a doorbell register
3973 * @phba: The pointer to hba structure.
3974 * @pbuffer: The pointer to the buffer to copy the data to.
3975 * @len: The lenght of bytes to copied.
3976 * @drbregid: The id to doorbell registers.
3979 * This routine reads a doorbell register and copies its content to the
3980 * user buffer pointed to by @pbuffer.
3983 * This function returns the amount of data that was copied into @pbuffer.
3986 lpfc_idiag_drbacc_read_reg(struct lpfc_hba
*phba
, char *pbuffer
,
3987 int len
, uint32_t drbregid
)
3995 len
+= scnprintf(pbuffer
+ len
, LPFC_DRB_ACC_BUF_SIZE
-len
,
3996 "EQ-DRB-REG: 0x%08x\n",
3997 readl(phba
->sli4_hba
.EQDBregaddr
));
4000 len
+= scnprintf(pbuffer
+ len
, LPFC_DRB_ACC_BUF_SIZE
- len
,
4001 "CQ-DRB-REG: 0x%08x\n",
4002 readl(phba
->sli4_hba
.CQDBregaddr
));
4005 len
+= scnprintf(pbuffer
+len
, LPFC_DRB_ACC_BUF_SIZE
-len
,
4006 "MQ-DRB-REG: 0x%08x\n",
4007 readl(phba
->sli4_hba
.MQDBregaddr
));
4010 len
+= scnprintf(pbuffer
+len
, LPFC_DRB_ACC_BUF_SIZE
-len
,
4011 "WQ-DRB-REG: 0x%08x\n",
4012 readl(phba
->sli4_hba
.WQDBregaddr
));
4015 len
+= scnprintf(pbuffer
+len
, LPFC_DRB_ACC_BUF_SIZE
-len
,
4016 "RQ-DRB-REG: 0x%08x\n",
4017 readl(phba
->sli4_hba
.RQDBregaddr
));
4027 * lpfc_idiag_drbacc_read - idiag debugfs read port doorbell
4028 * @file: The file pointer to read from.
4029 * @buf: The buffer to copy the data to.
4030 * @nbytes: The number of bytes to read.
4031 * @ppos: The position in the file to start reading from.
4034 * This routine reads data from the @phba device doorbell register according
4035 * to the idiag command, and copies to user @buf. Depending on the doorbell
4036 * register read command setup, it does either a single doorbell register
4037 * read or dump all doorbell registers.
4040 * This function returns the amount of data that was read (this could be less
4041 * than @nbytes if the end of the file was reached) or a negative error value.
4044 lpfc_idiag_drbacc_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
4047 struct lpfc_debug
*debug
= file
->private_data
;
4048 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
4049 uint32_t drb_reg_id
, i
;
4053 /* This is a user read operation */
4054 debug
->op
= LPFC_IDIAG_OP_RD
;
4057 debug
->buffer
= kmalloc(LPFC_DRB_ACC_BUF_SIZE
, GFP_KERNEL
);
4060 pbuffer
= debug
->buffer
;
4065 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_RD
)
4066 drb_reg_id
= idiag
.cmd
.data
[IDIAG_DRBACC_REGID_INDX
];
4070 if (drb_reg_id
== LPFC_DRB_ACC_ALL
)
4071 for (i
= 1; i
<= LPFC_DRB_MAX
; i
++)
4072 len
= lpfc_idiag_drbacc_read_reg(phba
,
4075 len
= lpfc_idiag_drbacc_read_reg(phba
,
4076 pbuffer
, len
, drb_reg_id
);
4078 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
4082 * lpfc_idiag_drbacc_write - Syntax check and set up idiag drbacc commands
4083 * @file: The file pointer to read from.
4084 * @buf: The buffer to copy the user data from.
4085 * @nbytes: The number of bytes to get.
4086 * @ppos: The position in the file to start reading from.
4088 * This routine get the debugfs idiag command struct from user space and then
4089 * perform the syntax check for port doorbell register read (dump) or write
4090 * (set) command accordingly. In the case of port queue read command, it sets
4091 * up the command in the idiag command struct for the following debugfs read
4092 * operation. In the case of port doorbell register write operation, it
4093 * executes the write operation into the port doorbell register accordingly.
4095 * It returns the @nbytges passing in from debugfs user space when successful.
4096 * In case of error conditions, it returns proper error code back to the user
4100 lpfc_idiag_drbacc_write(struct file
*file
, const char __user
*buf
,
4101 size_t nbytes
, loff_t
*ppos
)
4103 struct lpfc_debug
*debug
= file
->private_data
;
4104 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
4105 uint32_t drb_reg_id
, value
, reg_val
= 0;
4106 void __iomem
*drb_reg
;
4109 /* This is a user write operation */
4110 debug
->op
= LPFC_IDIAG_OP_WR
;
4112 rc
= lpfc_idiag_cmd_get(buf
, nbytes
, &idiag
.cmd
);
4116 /* Sanity check on command line arguments */
4117 drb_reg_id
= idiag
.cmd
.data
[IDIAG_DRBACC_REGID_INDX
];
4118 value
= idiag
.cmd
.data
[IDIAG_DRBACC_VALUE_INDX
];
4120 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_WR
||
4121 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_ST
||
4122 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_CL
) {
4123 if (rc
!= LPFC_DRB_ACC_WR_CMD_ARG
)
4125 if (drb_reg_id
> LPFC_DRB_MAX
)
4127 } else if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_RD
) {
4128 if (rc
!= LPFC_DRB_ACC_RD_CMD_ARG
)
4130 if ((drb_reg_id
> LPFC_DRB_MAX
) &&
4131 (drb_reg_id
!= LPFC_DRB_ACC_ALL
))
4136 /* Perform the write access operation */
4137 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_WR
||
4138 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_ST
||
4139 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_CL
) {
4140 switch (drb_reg_id
) {
4142 drb_reg
= phba
->sli4_hba
.EQDBregaddr
;
4145 drb_reg
= phba
->sli4_hba
.CQDBregaddr
;
4148 drb_reg
= phba
->sli4_hba
.MQDBregaddr
;
4151 drb_reg
= phba
->sli4_hba
.WQDBregaddr
;
4154 drb_reg
= phba
->sli4_hba
.RQDBregaddr
;
4160 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_WR
)
4162 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_ST
) {
4163 reg_val
= readl(drb_reg
);
4166 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_CL
) {
4167 reg_val
= readl(drb_reg
);
4170 writel(reg_val
, drb_reg
);
4171 readl(drb_reg
); /* flush */
4176 /* Clean out command structure on command error out */
4177 memset(&idiag
, 0, sizeof(idiag
));
4182 * lpfc_idiag_ctlacc_read_reg - idiag debugfs read a control registers
4183 * @phba: The pointer to hba structure.
4184 * @pbuffer: The pointer to the buffer to copy the data to.
4185 * @len: The lenght of bytes to copied.
4186 * @drbregid: The id to doorbell registers.
4189 * This routine reads a control register and copies its content to the
4190 * user buffer pointed to by @pbuffer.
4193 * This function returns the amount of data that was copied into @pbuffer.
4196 lpfc_idiag_ctlacc_read_reg(struct lpfc_hba
*phba
, char *pbuffer
,
4197 int len
, uint32_t ctlregid
)
4204 case LPFC_CTL_PORT_SEM
:
4205 len
+= scnprintf(pbuffer
+len
, LPFC_CTL_ACC_BUF_SIZE
-len
,
4206 "Port SemReg: 0x%08x\n",
4207 readl(phba
->sli4_hba
.conf_regs_memmap_p
+
4208 LPFC_CTL_PORT_SEM_OFFSET
));
4210 case LPFC_CTL_PORT_STA
:
4211 len
+= scnprintf(pbuffer
+len
, LPFC_CTL_ACC_BUF_SIZE
-len
,
4212 "Port StaReg: 0x%08x\n",
4213 readl(phba
->sli4_hba
.conf_regs_memmap_p
+
4214 LPFC_CTL_PORT_STA_OFFSET
));
4216 case LPFC_CTL_PORT_CTL
:
4217 len
+= scnprintf(pbuffer
+len
, LPFC_CTL_ACC_BUF_SIZE
-len
,
4218 "Port CtlReg: 0x%08x\n",
4219 readl(phba
->sli4_hba
.conf_regs_memmap_p
+
4220 LPFC_CTL_PORT_CTL_OFFSET
));
4222 case LPFC_CTL_PORT_ER1
:
4223 len
+= scnprintf(pbuffer
+len
, LPFC_CTL_ACC_BUF_SIZE
-len
,
4224 "Port Er1Reg: 0x%08x\n",
4225 readl(phba
->sli4_hba
.conf_regs_memmap_p
+
4226 LPFC_CTL_PORT_ER1_OFFSET
));
4228 case LPFC_CTL_PORT_ER2
:
4229 len
+= scnprintf(pbuffer
+len
, LPFC_CTL_ACC_BUF_SIZE
-len
,
4230 "Port Er2Reg: 0x%08x\n",
4231 readl(phba
->sli4_hba
.conf_regs_memmap_p
+
4232 LPFC_CTL_PORT_ER2_OFFSET
));
4234 case LPFC_CTL_PDEV_CTL
:
4235 len
+= scnprintf(pbuffer
+len
, LPFC_CTL_ACC_BUF_SIZE
-len
,
4236 "PDev CtlReg: 0x%08x\n",
4237 readl(phba
->sli4_hba
.conf_regs_memmap_p
+
4238 LPFC_CTL_PDEV_CTL_OFFSET
));
4247 * lpfc_idiag_ctlacc_read - idiag debugfs read port and device control register
4248 * @file: The file pointer to read from.
4249 * @buf: The buffer to copy the data to.
4250 * @nbytes: The number of bytes to read.
4251 * @ppos: The position in the file to start reading from.
4254 * This routine reads data from the @phba port and device registers according
4255 * to the idiag command, and copies to user @buf.
4258 * This function returns the amount of data that was read (this could be less
4259 * than @nbytes if the end of the file was reached) or a negative error value.
4262 lpfc_idiag_ctlacc_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
4265 struct lpfc_debug
*debug
= file
->private_data
;
4266 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
4267 uint32_t ctl_reg_id
, i
;
4271 /* This is a user read operation */
4272 debug
->op
= LPFC_IDIAG_OP_RD
;
4275 debug
->buffer
= kmalloc(LPFC_CTL_ACC_BUF_SIZE
, GFP_KERNEL
);
4278 pbuffer
= debug
->buffer
;
4283 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_RD
)
4284 ctl_reg_id
= idiag
.cmd
.data
[IDIAG_CTLACC_REGID_INDX
];
4288 if (ctl_reg_id
== LPFC_CTL_ACC_ALL
)
4289 for (i
= 1; i
<= LPFC_CTL_MAX
; i
++)
4290 len
= lpfc_idiag_ctlacc_read_reg(phba
,
4293 len
= lpfc_idiag_ctlacc_read_reg(phba
,
4294 pbuffer
, len
, ctl_reg_id
);
4296 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
4300 * lpfc_idiag_ctlacc_write - Syntax check and set up idiag ctlacc commands
4301 * @file: The file pointer to read from.
4302 * @buf: The buffer to copy the user data from.
4303 * @nbytes: The number of bytes to get.
4304 * @ppos: The position in the file to start reading from.
4306 * This routine get the debugfs idiag command struct from user space and then
4307 * perform the syntax check for port and device control register read (dump)
4308 * or write (set) command accordingly.
4310 * It returns the @nbytges passing in from debugfs user space when successful.
4311 * In case of error conditions, it returns proper error code back to the user
4315 lpfc_idiag_ctlacc_write(struct file
*file
, const char __user
*buf
,
4316 size_t nbytes
, loff_t
*ppos
)
4318 struct lpfc_debug
*debug
= file
->private_data
;
4319 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
4320 uint32_t ctl_reg_id
, value
, reg_val
= 0;
4321 void __iomem
*ctl_reg
;
4324 /* This is a user write operation */
4325 debug
->op
= LPFC_IDIAG_OP_WR
;
4327 rc
= lpfc_idiag_cmd_get(buf
, nbytes
, &idiag
.cmd
);
4331 /* Sanity check on command line arguments */
4332 ctl_reg_id
= idiag
.cmd
.data
[IDIAG_CTLACC_REGID_INDX
];
4333 value
= idiag
.cmd
.data
[IDIAG_CTLACC_VALUE_INDX
];
4335 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_WR
||
4336 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_ST
||
4337 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_CL
) {
4338 if (rc
!= LPFC_CTL_ACC_WR_CMD_ARG
)
4340 if (ctl_reg_id
> LPFC_CTL_MAX
)
4342 } else if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_RD
) {
4343 if (rc
!= LPFC_CTL_ACC_RD_CMD_ARG
)
4345 if ((ctl_reg_id
> LPFC_CTL_MAX
) &&
4346 (ctl_reg_id
!= LPFC_CTL_ACC_ALL
))
4351 /* Perform the write access operation */
4352 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_WR
||
4353 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_ST
||
4354 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_CL
) {
4355 switch (ctl_reg_id
) {
4356 case LPFC_CTL_PORT_SEM
:
4357 ctl_reg
= phba
->sli4_hba
.conf_regs_memmap_p
+
4358 LPFC_CTL_PORT_SEM_OFFSET
;
4360 case LPFC_CTL_PORT_STA
:
4361 ctl_reg
= phba
->sli4_hba
.conf_regs_memmap_p
+
4362 LPFC_CTL_PORT_STA_OFFSET
;
4364 case LPFC_CTL_PORT_CTL
:
4365 ctl_reg
= phba
->sli4_hba
.conf_regs_memmap_p
+
4366 LPFC_CTL_PORT_CTL_OFFSET
;
4368 case LPFC_CTL_PORT_ER1
:
4369 ctl_reg
= phba
->sli4_hba
.conf_regs_memmap_p
+
4370 LPFC_CTL_PORT_ER1_OFFSET
;
4372 case LPFC_CTL_PORT_ER2
:
4373 ctl_reg
= phba
->sli4_hba
.conf_regs_memmap_p
+
4374 LPFC_CTL_PORT_ER2_OFFSET
;
4376 case LPFC_CTL_PDEV_CTL
:
4377 ctl_reg
= phba
->sli4_hba
.conf_regs_memmap_p
+
4378 LPFC_CTL_PDEV_CTL_OFFSET
;
4384 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_WR
)
4386 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_ST
) {
4387 reg_val
= readl(ctl_reg
);
4390 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_CL
) {
4391 reg_val
= readl(ctl_reg
);
4394 writel(reg_val
, ctl_reg
);
4395 readl(ctl_reg
); /* flush */
4400 /* Clean out command structure on command error out */
4401 memset(&idiag
, 0, sizeof(idiag
));
4406 * lpfc_idiag_mbxacc_get_setup - idiag debugfs get mailbox access setup
4407 * @phba: Pointer to HBA context object.
4408 * @pbuffer: Pointer to data buffer.
4411 * This routine gets the driver mailbox access debugfs setup information.
4414 * This function returns the amount of data that was read (this could be less
4415 * than @nbytes if the end of the file was reached) or a negative error value.
4418 lpfc_idiag_mbxacc_get_setup(struct lpfc_hba
*phba
, char *pbuffer
)
4420 uint32_t mbx_dump_map
, mbx_dump_cnt
, mbx_word_cnt
, mbx_mbox_cmd
;
4423 mbx_mbox_cmd
= idiag
.cmd
.data
[IDIAG_MBXACC_MBCMD_INDX
];
4424 mbx_dump_map
= idiag
.cmd
.data
[IDIAG_MBXACC_DPMAP_INDX
];
4425 mbx_dump_cnt
= idiag
.cmd
.data
[IDIAG_MBXACC_DPCNT_INDX
];
4426 mbx_word_cnt
= idiag
.cmd
.data
[IDIAG_MBXACC_WDCNT_INDX
];
4428 len
+= scnprintf(pbuffer
+len
, LPFC_MBX_ACC_BUF_SIZE
-len
,
4429 "mbx_dump_map: 0x%08x\n", mbx_dump_map
);
4430 len
+= scnprintf(pbuffer
+len
, LPFC_MBX_ACC_BUF_SIZE
-len
,
4431 "mbx_dump_cnt: %04d\n", mbx_dump_cnt
);
4432 len
+= scnprintf(pbuffer
+len
, LPFC_MBX_ACC_BUF_SIZE
-len
,
4433 "mbx_word_cnt: %04d\n", mbx_word_cnt
);
4434 len
+= scnprintf(pbuffer
+len
, LPFC_MBX_ACC_BUF_SIZE
-len
,
4435 "mbx_mbox_cmd: 0x%02x\n", mbx_mbox_cmd
);
4441 * lpfc_idiag_mbxacc_read - idiag debugfs read on mailbox access
4442 * @file: The file pointer to read from.
4443 * @buf: The buffer to copy the data to.
4444 * @nbytes: The number of bytes to read.
4445 * @ppos: The position in the file to start reading from.
4448 * This routine reads data from the @phba driver mailbox access debugfs setup
4452 * This function returns the amount of data that was read (this could be less
4453 * than @nbytes if the end of the file was reached) or a negative error value.
4456 lpfc_idiag_mbxacc_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
4459 struct lpfc_debug
*debug
= file
->private_data
;
4460 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
4464 /* This is a user read operation */
4465 debug
->op
= LPFC_IDIAG_OP_RD
;
4468 debug
->buffer
= kmalloc(LPFC_MBX_ACC_BUF_SIZE
, GFP_KERNEL
);
4471 pbuffer
= debug
->buffer
;
4476 if ((idiag
.cmd
.opcode
!= LPFC_IDIAG_CMD_MBXACC_DP
) &&
4477 (idiag
.cmd
.opcode
!= LPFC_IDIAG_BSG_MBXACC_DP
))
4480 len
= lpfc_idiag_mbxacc_get_setup(phba
, pbuffer
);
4482 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
4486 * lpfc_idiag_mbxacc_write - Syntax check and set up idiag mbxacc commands
4487 * @file: The file pointer to read from.
4488 * @buf: The buffer to copy the user data from.
4489 * @nbytes: The number of bytes to get.
4490 * @ppos: The position in the file to start reading from.
4492 * This routine get the debugfs idiag command struct from user space and then
4493 * perform the syntax check for driver mailbox command (dump) and sets up the
4494 * necessary states in the idiag command struct accordingly.
4496 * It returns the @nbytges passing in from debugfs user space when successful.
4497 * In case of error conditions, it returns proper error code back to the user
4501 lpfc_idiag_mbxacc_write(struct file
*file
, const char __user
*buf
,
4502 size_t nbytes
, loff_t
*ppos
)
4504 struct lpfc_debug
*debug
= file
->private_data
;
4505 uint32_t mbx_dump_map
, mbx_dump_cnt
, mbx_word_cnt
, mbx_mbox_cmd
;
4508 /* This is a user write operation */
4509 debug
->op
= LPFC_IDIAG_OP_WR
;
4511 rc
= lpfc_idiag_cmd_get(buf
, nbytes
, &idiag
.cmd
);
4515 /* Sanity check on command line arguments */
4516 mbx_mbox_cmd
= idiag
.cmd
.data
[IDIAG_MBXACC_MBCMD_INDX
];
4517 mbx_dump_map
= idiag
.cmd
.data
[IDIAG_MBXACC_DPMAP_INDX
];
4518 mbx_dump_cnt
= idiag
.cmd
.data
[IDIAG_MBXACC_DPCNT_INDX
];
4519 mbx_word_cnt
= idiag
.cmd
.data
[IDIAG_MBXACC_WDCNT_INDX
];
4521 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_MBXACC_DP
) {
4522 if (!(mbx_dump_map
& LPFC_MBX_DMP_MBX_ALL
))
4524 if ((mbx_dump_map
& ~LPFC_MBX_DMP_MBX_ALL
) &&
4525 (mbx_dump_map
!= LPFC_MBX_DMP_ALL
))
4527 if (mbx_word_cnt
> sizeof(MAILBOX_t
))
4529 } else if (idiag
.cmd
.opcode
== LPFC_IDIAG_BSG_MBXACC_DP
) {
4530 if (!(mbx_dump_map
& LPFC_BSG_DMP_MBX_ALL
))
4532 if ((mbx_dump_map
& ~LPFC_BSG_DMP_MBX_ALL
) &&
4533 (mbx_dump_map
!= LPFC_MBX_DMP_ALL
))
4535 if (mbx_word_cnt
> (BSG_MBOX_SIZE
)/4)
4537 if (mbx_mbox_cmd
!= 0x9b)
4542 if (mbx_word_cnt
== 0)
4544 if (rc
!= LPFC_MBX_DMP_ARG
)
4546 if (mbx_mbox_cmd
& ~0xff)
4549 /* condition for stop mailbox dump */
4550 if (mbx_dump_cnt
== 0)
4556 /* Clean out command structure on command error out */
4557 memset(&idiag
, 0, sizeof(idiag
));
4561 /* Clean out command structure on command error out */
4562 memset(&idiag
, 0, sizeof(idiag
));
4567 * lpfc_idiag_extacc_avail_get - get the available extents information
4568 * @phba: pointer to lpfc hba data structure.
4569 * @pbuffer: pointer to internal buffer.
4570 * @len: length into the internal buffer data has been copied.
4573 * This routine is to get the available extent information.
4576 * overall lenth of the data read into the internal buffer.
4579 lpfc_idiag_extacc_avail_get(struct lpfc_hba
*phba
, char *pbuffer
, int len
)
4581 uint16_t ext_cnt
, ext_size
;
4583 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4584 "\nAvailable Extents Information:\n");
4586 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4587 "\tPort Available VPI extents: ");
4588 lpfc_sli4_get_avail_extnt_rsrc(phba
, LPFC_RSC_TYPE_FCOE_VPI
,
4589 &ext_cnt
, &ext_size
);
4590 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4591 "Count %3d, Size %3d\n", ext_cnt
, ext_size
);
4593 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4594 "\tPort Available VFI extents: ");
4595 lpfc_sli4_get_avail_extnt_rsrc(phba
, LPFC_RSC_TYPE_FCOE_VFI
,
4596 &ext_cnt
, &ext_size
);
4597 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4598 "Count %3d, Size %3d\n", ext_cnt
, ext_size
);
4600 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4601 "\tPort Available RPI extents: ");
4602 lpfc_sli4_get_avail_extnt_rsrc(phba
, LPFC_RSC_TYPE_FCOE_RPI
,
4603 &ext_cnt
, &ext_size
);
4604 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4605 "Count %3d, Size %3d\n", ext_cnt
, ext_size
);
4607 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4608 "\tPort Available XRI extents: ");
4609 lpfc_sli4_get_avail_extnt_rsrc(phba
, LPFC_RSC_TYPE_FCOE_XRI
,
4610 &ext_cnt
, &ext_size
);
4611 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4612 "Count %3d, Size %3d\n", ext_cnt
, ext_size
);
4618 * lpfc_idiag_extacc_alloc_get - get the allocated extents information
4619 * @phba: pointer to lpfc hba data structure.
4620 * @pbuffer: pointer to internal buffer.
4621 * @len: length into the internal buffer data has been copied.
4624 * This routine is to get the allocated extent information.
4627 * overall lenth of the data read into the internal buffer.
4630 lpfc_idiag_extacc_alloc_get(struct lpfc_hba
*phba
, char *pbuffer
, int len
)
4632 uint16_t ext_cnt
, ext_size
;
4635 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4636 "\nAllocated Extents Information:\n");
4638 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4639 "\tHost Allocated VPI extents: ");
4640 rc
= lpfc_sli4_get_allocated_extnts(phba
, LPFC_RSC_TYPE_FCOE_VPI
,
4641 &ext_cnt
, &ext_size
);
4643 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4644 "Port %d Extent %3d, Size %3d\n",
4645 phba
->brd_no
, ext_cnt
, ext_size
);
4647 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4650 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4651 "\tHost Allocated VFI extents: ");
4652 rc
= lpfc_sli4_get_allocated_extnts(phba
, LPFC_RSC_TYPE_FCOE_VFI
,
4653 &ext_cnt
, &ext_size
);
4655 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4656 "Port %d Extent %3d, Size %3d\n",
4657 phba
->brd_no
, ext_cnt
, ext_size
);
4659 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4662 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4663 "\tHost Allocated RPI extents: ");
4664 rc
= lpfc_sli4_get_allocated_extnts(phba
, LPFC_RSC_TYPE_FCOE_RPI
,
4665 &ext_cnt
, &ext_size
);
4667 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4668 "Port %d Extent %3d, Size %3d\n",
4669 phba
->brd_no
, ext_cnt
, ext_size
);
4671 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4674 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4675 "\tHost Allocated XRI extents: ");
4676 rc
= lpfc_sli4_get_allocated_extnts(phba
, LPFC_RSC_TYPE_FCOE_XRI
,
4677 &ext_cnt
, &ext_size
);
4679 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4680 "Port %d Extent %3d, Size %3d\n",
4681 phba
->brd_no
, ext_cnt
, ext_size
);
4683 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4690 * lpfc_idiag_extacc_drivr_get - get driver extent information
4691 * @phba: pointer to lpfc hba data structure.
4692 * @pbuffer: pointer to internal buffer.
4693 * @len: length into the internal buffer data has been copied.
4696 * This routine is to get the driver extent information.
4699 * overall lenth of the data read into the internal buffer.
4702 lpfc_idiag_extacc_drivr_get(struct lpfc_hba
*phba
, char *pbuffer
, int len
)
4704 struct lpfc_rsrc_blks
*rsrc_blks
;
4707 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4708 "\nDriver Extents Information:\n");
4710 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4711 "\tVPI extents:\n");
4713 list_for_each_entry(rsrc_blks
, &phba
->lpfc_vpi_blk_list
, list
) {
4714 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4715 "\t\tBlock %3d: Start %4d, Count %4d\n",
4716 index
, rsrc_blks
->rsrc_start
,
4717 rsrc_blks
->rsrc_size
);
4720 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4721 "\tVFI extents:\n");
4723 list_for_each_entry(rsrc_blks
, &phba
->sli4_hba
.lpfc_vfi_blk_list
,
4725 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4726 "\t\tBlock %3d: Start %4d, Count %4d\n",
4727 index
, rsrc_blks
->rsrc_start
,
4728 rsrc_blks
->rsrc_size
);
4732 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4733 "\tRPI extents:\n");
4735 list_for_each_entry(rsrc_blks
, &phba
->sli4_hba
.lpfc_rpi_blk_list
,
4737 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4738 "\t\tBlock %3d: Start %4d, Count %4d\n",
4739 index
, rsrc_blks
->rsrc_start
,
4740 rsrc_blks
->rsrc_size
);
4744 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4745 "\tXRI extents:\n");
4747 list_for_each_entry(rsrc_blks
, &phba
->sli4_hba
.lpfc_xri_blk_list
,
4749 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4750 "\t\tBlock %3d: Start %4d, Count %4d\n",
4751 index
, rsrc_blks
->rsrc_start
,
4752 rsrc_blks
->rsrc_size
);
4760 * lpfc_idiag_extacc_write - Syntax check and set up idiag extacc commands
4761 * @file: The file pointer to read from.
4762 * @buf: The buffer to copy the user data from.
4763 * @nbytes: The number of bytes to get.
4764 * @ppos: The position in the file to start reading from.
4766 * This routine get the debugfs idiag command struct from user space and then
4767 * perform the syntax check for extent information access commands and sets
4768 * up the necessary states in the idiag command struct accordingly.
4770 * It returns the @nbytges passing in from debugfs user space when successful.
4771 * In case of error conditions, it returns proper error code back to the user
4775 lpfc_idiag_extacc_write(struct file
*file
, const char __user
*buf
,
4776 size_t nbytes
, loff_t
*ppos
)
4778 struct lpfc_debug
*debug
= file
->private_data
;
4782 /* This is a user write operation */
4783 debug
->op
= LPFC_IDIAG_OP_WR
;
4785 rc
= lpfc_idiag_cmd_get(buf
, nbytes
, &idiag
.cmd
);
4789 ext_map
= idiag
.cmd
.data
[IDIAG_EXTACC_EXMAP_INDX
];
4791 if (idiag
.cmd
.opcode
!= LPFC_IDIAG_CMD_EXTACC_RD
)
4793 if (rc
!= LPFC_EXT_ACC_CMD_ARG
)
4795 if (!(ext_map
& LPFC_EXT_ACC_ALL
))
4800 /* Clean out command structure on command error out */
4801 memset(&idiag
, 0, sizeof(idiag
));
4806 * lpfc_idiag_extacc_read - idiag debugfs read access to extent information
4807 * @file: The file pointer to read from.
4808 * @buf: The buffer to copy the data to.
4809 * @nbytes: The number of bytes to read.
4810 * @ppos: The position in the file to start reading from.
4813 * This routine reads data from the proper extent information according to
4814 * the idiag command, and copies to user @buf.
4817 * This function returns the amount of data that was read (this could be less
4818 * than @nbytes if the end of the file was reached) or a negative error value.
4821 lpfc_idiag_extacc_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
4824 struct lpfc_debug
*debug
= file
->private_data
;
4825 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
4830 /* This is a user read operation */
4831 debug
->op
= LPFC_IDIAG_OP_RD
;
4834 debug
->buffer
= kmalloc(LPFC_EXT_ACC_BUF_SIZE
, GFP_KERNEL
);
4837 pbuffer
= debug
->buffer
;
4840 if (idiag
.cmd
.opcode
!= LPFC_IDIAG_CMD_EXTACC_RD
)
4843 ext_map
= idiag
.cmd
.data
[IDIAG_EXTACC_EXMAP_INDX
];
4844 if (ext_map
& LPFC_EXT_ACC_AVAIL
)
4845 len
= lpfc_idiag_extacc_avail_get(phba
, pbuffer
, len
);
4846 if (ext_map
& LPFC_EXT_ACC_ALLOC
)
4847 len
= lpfc_idiag_extacc_alloc_get(phba
, pbuffer
, len
);
4848 if (ext_map
& LPFC_EXT_ACC_DRIVR
)
4849 len
= lpfc_idiag_extacc_drivr_get(phba
, pbuffer
, len
);
4851 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
4854 #undef lpfc_debugfs_op_disc_trc
4855 static const struct file_operations lpfc_debugfs_op_disc_trc
= {
4856 .owner
= THIS_MODULE
,
4857 .open
= lpfc_debugfs_disc_trc_open
,
4858 .llseek
= lpfc_debugfs_lseek
,
4859 .read
= lpfc_debugfs_read
,
4860 .release
= lpfc_debugfs_release
,
4863 #undef lpfc_debugfs_op_nodelist
4864 static const struct file_operations lpfc_debugfs_op_nodelist
= {
4865 .owner
= THIS_MODULE
,
4866 .open
= lpfc_debugfs_nodelist_open
,
4867 .llseek
= lpfc_debugfs_lseek
,
4868 .read
= lpfc_debugfs_read
,
4869 .release
= lpfc_debugfs_release
,
4872 #undef lpfc_debugfs_op_hbqinfo
4873 static const struct file_operations lpfc_debugfs_op_hbqinfo
= {
4874 .owner
= THIS_MODULE
,
4875 .open
= lpfc_debugfs_hbqinfo_open
,
4876 .llseek
= lpfc_debugfs_lseek
,
4877 .read
= lpfc_debugfs_read
,
4878 .release
= lpfc_debugfs_release
,
4881 #undef lpfc_debugfs_op_dumpHBASlim
4882 static const struct file_operations lpfc_debugfs_op_dumpHBASlim
= {
4883 .owner
= THIS_MODULE
,
4884 .open
= lpfc_debugfs_dumpHBASlim_open
,
4885 .llseek
= lpfc_debugfs_lseek
,
4886 .read
= lpfc_debugfs_read
,
4887 .release
= lpfc_debugfs_release
,
4890 #undef lpfc_debugfs_op_dumpHostSlim
4891 static const struct file_operations lpfc_debugfs_op_dumpHostSlim
= {
4892 .owner
= THIS_MODULE
,
4893 .open
= lpfc_debugfs_dumpHostSlim_open
,
4894 .llseek
= lpfc_debugfs_lseek
,
4895 .read
= lpfc_debugfs_read
,
4896 .release
= lpfc_debugfs_release
,
4899 #undef lpfc_debugfs_op_nvmestat
4900 static const struct file_operations lpfc_debugfs_op_nvmestat
= {
4901 .owner
= THIS_MODULE
,
4902 .open
= lpfc_debugfs_nvmestat_open
,
4903 .llseek
= lpfc_debugfs_lseek
,
4904 .read
= lpfc_debugfs_read
,
4905 .write
= lpfc_debugfs_nvmestat_write
,
4906 .release
= lpfc_debugfs_release
,
4909 #undef lpfc_debugfs_op_nvmektime
4910 static const struct file_operations lpfc_debugfs_op_nvmektime
= {
4911 .owner
= THIS_MODULE
,
4912 .open
= lpfc_debugfs_nvmektime_open
,
4913 .llseek
= lpfc_debugfs_lseek
,
4914 .read
= lpfc_debugfs_read
,
4915 .write
= lpfc_debugfs_nvmektime_write
,
4916 .release
= lpfc_debugfs_release
,
4919 #undef lpfc_debugfs_op_nvmeio_trc
4920 static const struct file_operations lpfc_debugfs_op_nvmeio_trc
= {
4921 .owner
= THIS_MODULE
,
4922 .open
= lpfc_debugfs_nvmeio_trc_open
,
4923 .llseek
= lpfc_debugfs_lseek
,
4924 .read
= lpfc_debugfs_read
,
4925 .write
= lpfc_debugfs_nvmeio_trc_write
,
4926 .release
= lpfc_debugfs_release
,
4929 #undef lpfc_debugfs_op_cpucheck
4930 static const struct file_operations lpfc_debugfs_op_cpucheck
= {
4931 .owner
= THIS_MODULE
,
4932 .open
= lpfc_debugfs_cpucheck_open
,
4933 .llseek
= lpfc_debugfs_lseek
,
4934 .read
= lpfc_debugfs_read
,
4935 .write
= lpfc_debugfs_cpucheck_write
,
4936 .release
= lpfc_debugfs_release
,
4939 #undef lpfc_debugfs_op_dumpData
4940 static const struct file_operations lpfc_debugfs_op_dumpData
= {
4941 .owner
= THIS_MODULE
,
4942 .open
= lpfc_debugfs_dumpData_open
,
4943 .llseek
= lpfc_debugfs_lseek
,
4944 .read
= lpfc_debugfs_read
,
4945 .write
= lpfc_debugfs_dumpDataDif_write
,
4946 .release
= lpfc_debugfs_dumpDataDif_release
,
4949 #undef lpfc_debugfs_op_dumpDif
4950 static const struct file_operations lpfc_debugfs_op_dumpDif
= {
4951 .owner
= THIS_MODULE
,
4952 .open
= lpfc_debugfs_dumpDif_open
,
4953 .llseek
= lpfc_debugfs_lseek
,
4954 .read
= lpfc_debugfs_read
,
4955 .write
= lpfc_debugfs_dumpDataDif_write
,
4956 .release
= lpfc_debugfs_dumpDataDif_release
,
4959 #undef lpfc_debugfs_op_dif_err
4960 static const struct file_operations lpfc_debugfs_op_dif_err
= {
4961 .owner
= THIS_MODULE
,
4962 .open
= simple_open
,
4963 .llseek
= lpfc_debugfs_lseek
,
4964 .read
= lpfc_debugfs_dif_err_read
,
4965 .write
= lpfc_debugfs_dif_err_write
,
4966 .release
= lpfc_debugfs_dif_err_release
,
4969 #undef lpfc_debugfs_op_slow_ring_trc
4970 static const struct file_operations lpfc_debugfs_op_slow_ring_trc
= {
4971 .owner
= THIS_MODULE
,
4972 .open
= lpfc_debugfs_slow_ring_trc_open
,
4973 .llseek
= lpfc_debugfs_lseek
,
4974 .read
= lpfc_debugfs_read
,
4975 .release
= lpfc_debugfs_release
,
4978 static struct dentry
*lpfc_debugfs_root
= NULL
;
4979 static atomic_t lpfc_debugfs_hba_count
;
4982 * File operations for the iDiag debugfs
4984 #undef lpfc_idiag_op_pciCfg
4985 static const struct file_operations lpfc_idiag_op_pciCfg
= {
4986 .owner
= THIS_MODULE
,
4987 .open
= lpfc_idiag_open
,
4988 .llseek
= lpfc_debugfs_lseek
,
4989 .read
= lpfc_idiag_pcicfg_read
,
4990 .write
= lpfc_idiag_pcicfg_write
,
4991 .release
= lpfc_idiag_cmd_release
,
4994 #undef lpfc_idiag_op_barAcc
4995 static const struct file_operations lpfc_idiag_op_barAcc
= {
4996 .owner
= THIS_MODULE
,
4997 .open
= lpfc_idiag_open
,
4998 .llseek
= lpfc_debugfs_lseek
,
4999 .read
= lpfc_idiag_baracc_read
,
5000 .write
= lpfc_idiag_baracc_write
,
5001 .release
= lpfc_idiag_cmd_release
,
5004 #undef lpfc_idiag_op_queInfo
5005 static const struct file_operations lpfc_idiag_op_queInfo
= {
5006 .owner
= THIS_MODULE
,
5007 .open
= lpfc_idiag_open
,
5008 .read
= lpfc_idiag_queinfo_read
,
5009 .release
= lpfc_idiag_release
,
5012 #undef lpfc_idiag_op_queAcc
5013 static const struct file_operations lpfc_idiag_op_queAcc
= {
5014 .owner
= THIS_MODULE
,
5015 .open
= lpfc_idiag_open
,
5016 .llseek
= lpfc_debugfs_lseek
,
5017 .read
= lpfc_idiag_queacc_read
,
5018 .write
= lpfc_idiag_queacc_write
,
5019 .release
= lpfc_idiag_cmd_release
,
5022 #undef lpfc_idiag_op_drbAcc
5023 static const struct file_operations lpfc_idiag_op_drbAcc
= {
5024 .owner
= THIS_MODULE
,
5025 .open
= lpfc_idiag_open
,
5026 .llseek
= lpfc_debugfs_lseek
,
5027 .read
= lpfc_idiag_drbacc_read
,
5028 .write
= lpfc_idiag_drbacc_write
,
5029 .release
= lpfc_idiag_cmd_release
,
5032 #undef lpfc_idiag_op_ctlAcc
5033 static const struct file_operations lpfc_idiag_op_ctlAcc
= {
5034 .owner
= THIS_MODULE
,
5035 .open
= lpfc_idiag_open
,
5036 .llseek
= lpfc_debugfs_lseek
,
5037 .read
= lpfc_idiag_ctlacc_read
,
5038 .write
= lpfc_idiag_ctlacc_write
,
5039 .release
= lpfc_idiag_cmd_release
,
5042 #undef lpfc_idiag_op_mbxAcc
5043 static const struct file_operations lpfc_idiag_op_mbxAcc
= {
5044 .owner
= THIS_MODULE
,
5045 .open
= lpfc_idiag_open
,
5046 .llseek
= lpfc_debugfs_lseek
,
5047 .read
= lpfc_idiag_mbxacc_read
,
5048 .write
= lpfc_idiag_mbxacc_write
,
5049 .release
= lpfc_idiag_cmd_release
,
5052 #undef lpfc_idiag_op_extAcc
5053 static const struct file_operations lpfc_idiag_op_extAcc
= {
5054 .owner
= THIS_MODULE
,
5055 .open
= lpfc_idiag_open
,
5056 .llseek
= lpfc_debugfs_lseek
,
5057 .read
= lpfc_idiag_extacc_read
,
5058 .write
= lpfc_idiag_extacc_write
,
5059 .release
= lpfc_idiag_cmd_release
,
5064 /* lpfc_idiag_mbxacc_dump_bsg_mbox - idiag debugfs dump bsg mailbox command
5065 * @phba: Pointer to HBA context object.
5066 * @dmabuf: Pointer to a DMA buffer descriptor.
5069 * This routine dump a bsg pass-through non-embedded mailbox command with
5073 lpfc_idiag_mbxacc_dump_bsg_mbox(struct lpfc_hba
*phba
, enum nemb_type nemb_tp
,
5074 enum mbox_type mbox_tp
, enum dma_type dma_tp
,
5075 enum sta_type sta_tp
,
5076 struct lpfc_dmabuf
*dmabuf
, uint32_t ext_buf
)
5078 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
5079 uint32_t *mbx_mbox_cmd
, *mbx_dump_map
, *mbx_dump_cnt
, *mbx_word_cnt
;
5080 char line_buf
[LPFC_MBX_ACC_LBUF_SZ
];
5082 uint32_t do_dump
= 0;
5086 if (idiag
.cmd
.opcode
!= LPFC_IDIAG_BSG_MBXACC_DP
)
5089 mbx_mbox_cmd
= &idiag
.cmd
.data
[IDIAG_MBXACC_MBCMD_INDX
];
5090 mbx_dump_map
= &idiag
.cmd
.data
[IDIAG_MBXACC_DPMAP_INDX
];
5091 mbx_dump_cnt
= &idiag
.cmd
.data
[IDIAG_MBXACC_DPCNT_INDX
];
5092 mbx_word_cnt
= &idiag
.cmd
.data
[IDIAG_MBXACC_WDCNT_INDX
];
5094 if (!(*mbx_dump_map
& LPFC_MBX_DMP_ALL
) ||
5095 (*mbx_dump_cnt
== 0) ||
5096 (*mbx_word_cnt
== 0))
5099 if (*mbx_mbox_cmd
!= 0x9B)
5102 if ((mbox_tp
== mbox_rd
) && (dma_tp
== dma_mbox
)) {
5103 if (*mbx_dump_map
& LPFC_BSG_DMP_MBX_RD_MBX
) {
5104 do_dump
|= LPFC_BSG_DMP_MBX_RD_MBX
;
5105 pr_err("\nRead mbox command (x%x), "
5106 "nemb:0x%x, extbuf_cnt:%d:\n",
5107 sta_tp
, nemb_tp
, ext_buf
);
5110 if ((mbox_tp
== mbox_rd
) && (dma_tp
== dma_ebuf
)) {
5111 if (*mbx_dump_map
& LPFC_BSG_DMP_MBX_RD_BUF
) {
5112 do_dump
|= LPFC_BSG_DMP_MBX_RD_BUF
;
5113 pr_err("\nRead mbox buffer (x%x), "
5114 "nemb:0x%x, extbuf_seq:%d:\n",
5115 sta_tp
, nemb_tp
, ext_buf
);
5118 if ((mbox_tp
== mbox_wr
) && (dma_tp
== dma_mbox
)) {
5119 if (*mbx_dump_map
& LPFC_BSG_DMP_MBX_WR_MBX
) {
5120 do_dump
|= LPFC_BSG_DMP_MBX_WR_MBX
;
5121 pr_err("\nWrite mbox command (x%x), "
5122 "nemb:0x%x, extbuf_cnt:%d:\n",
5123 sta_tp
, nemb_tp
, ext_buf
);
5126 if ((mbox_tp
== mbox_wr
) && (dma_tp
== dma_ebuf
)) {
5127 if (*mbx_dump_map
& LPFC_BSG_DMP_MBX_WR_BUF
) {
5128 do_dump
|= LPFC_BSG_DMP_MBX_WR_BUF
;
5129 pr_err("\nWrite mbox buffer (x%x), "
5130 "nemb:0x%x, extbuf_seq:%d:\n",
5131 sta_tp
, nemb_tp
, ext_buf
);
5135 /* dump buffer content */
5137 pword
= (uint32_t *)dmabuf
->virt
;
5138 for (i
= 0; i
< *mbx_word_cnt
; i
++) {
5141 pr_err("%s\n", line_buf
);
5143 len
+= scnprintf(line_buf
+len
,
5144 LPFC_MBX_ACC_LBUF_SZ
-len
,
5147 len
+= scnprintf(line_buf
+len
, LPFC_MBX_ACC_LBUF_SZ
-len
,
5148 "%08x ", (uint32_t)*pword
);
5152 pr_err("%s\n", line_buf
);
5156 /* Clean out command structure on reaching dump count */
5157 if (*mbx_dump_cnt
== 0)
5158 memset(&idiag
, 0, sizeof(idiag
));
5163 /* lpfc_idiag_mbxacc_dump_issue_mbox - idiag debugfs dump issue mailbox command
5164 * @phba: Pointer to HBA context object.
5165 * @dmabuf: Pointer to a DMA buffer descriptor.
5168 * This routine dump a pass-through non-embedded mailbox command from issue
5172 lpfc_idiag_mbxacc_dump_issue_mbox(struct lpfc_hba
*phba
, MAILBOX_t
*pmbox
)
5174 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
5175 uint32_t *mbx_dump_map
, *mbx_dump_cnt
, *mbx_word_cnt
, *mbx_mbox_cmd
;
5176 char line_buf
[LPFC_MBX_ACC_LBUF_SZ
];
5182 if (idiag
.cmd
.opcode
!= LPFC_IDIAG_CMD_MBXACC_DP
)
5185 mbx_mbox_cmd
= &idiag
.cmd
.data
[IDIAG_MBXACC_MBCMD_INDX
];
5186 mbx_dump_map
= &idiag
.cmd
.data
[IDIAG_MBXACC_DPMAP_INDX
];
5187 mbx_dump_cnt
= &idiag
.cmd
.data
[IDIAG_MBXACC_DPCNT_INDX
];
5188 mbx_word_cnt
= &idiag
.cmd
.data
[IDIAG_MBXACC_WDCNT_INDX
];
5190 if (!(*mbx_dump_map
& LPFC_MBX_DMP_MBX_ALL
) ||
5191 (*mbx_dump_cnt
== 0) ||
5192 (*mbx_word_cnt
== 0))
5195 if ((*mbx_mbox_cmd
!= LPFC_MBX_ALL_CMD
) &&
5196 (*mbx_mbox_cmd
!= pmbox
->mbxCommand
))
5199 /* dump buffer content */
5200 if (*mbx_dump_map
& LPFC_MBX_DMP_MBX_WORD
) {
5201 pr_err("Mailbox command:0x%x dump by word:\n",
5203 pword
= (uint32_t *)pmbox
;
5204 for (i
= 0; i
< *mbx_word_cnt
; i
++) {
5207 pr_err("%s\n", line_buf
);
5209 memset(line_buf
, 0, LPFC_MBX_ACC_LBUF_SZ
);
5210 len
+= scnprintf(line_buf
+len
,
5211 LPFC_MBX_ACC_LBUF_SZ
-len
,
5214 len
+= scnprintf(line_buf
+len
, LPFC_MBX_ACC_LBUF_SZ
-len
,
5216 ((uint32_t)*pword
) & 0xffffffff);
5220 pr_err("%s\n", line_buf
);
5223 if (*mbx_dump_map
& LPFC_MBX_DMP_MBX_BYTE
) {
5224 pr_err("Mailbox command:0x%x dump by byte:\n",
5226 pbyte
= (uint8_t *)pmbox
;
5227 for (i
= 0; i
< *mbx_word_cnt
; i
++) {
5230 pr_err("%s\n", line_buf
);
5232 memset(line_buf
, 0, LPFC_MBX_ACC_LBUF_SZ
);
5233 len
+= scnprintf(line_buf
+len
,
5234 LPFC_MBX_ACC_LBUF_SZ
-len
,
5237 for (j
= 0; j
< 4; j
++) {
5238 len
+= scnprintf(line_buf
+len
,
5239 LPFC_MBX_ACC_LBUF_SZ
-len
,
5241 ((uint8_t)*pbyte
) & 0xff);
5244 len
+= scnprintf(line_buf
+len
,
5245 LPFC_MBX_ACC_LBUF_SZ
-len
, " ");
5248 pr_err("%s\n", line_buf
);
5253 /* Clean out command structure on reaching dump count */
5254 if (*mbx_dump_cnt
== 0)
5255 memset(&idiag
, 0, sizeof(idiag
));
5261 * lpfc_debugfs_initialize - Initialize debugfs for a vport
5262 * @vport: The vport pointer to initialize.
5265 * When Debugfs is configured this routine sets up the lpfc debugfs file system.
5266 * If not already created, this routine will create the lpfc directory, and
5267 * lpfcX directory (for this HBA), and vportX directory for this vport. It will
5268 * also create each file used to access lpfc specific debugfs information.
5271 lpfc_debugfs_initialize(struct lpfc_vport
*vport
)
5273 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
5274 struct lpfc_hba
*phba
= vport
->phba
;
5277 bool pport_setup
= false;
5279 if (!lpfc_debugfs_enable
)
5282 /* Setup lpfc root directory */
5283 if (!lpfc_debugfs_root
) {
5284 lpfc_debugfs_root
= debugfs_create_dir("lpfc", NULL
);
5285 atomic_set(&lpfc_debugfs_hba_count
, 0);
5286 if (!lpfc_debugfs_root
) {
5287 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5288 "0408 Cannot create debugfs root\n");
5292 if (!lpfc_debugfs_start_time
)
5293 lpfc_debugfs_start_time
= jiffies
;
5295 /* Setup funcX directory for specific HBA PCI function */
5296 snprintf(name
, sizeof(name
), "fn%d", phba
->brd_no
);
5297 if (!phba
->hba_debugfs_root
) {
5299 phba
->hba_debugfs_root
=
5300 debugfs_create_dir(name
, lpfc_debugfs_root
);
5301 if (!phba
->hba_debugfs_root
) {
5302 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5303 "0412 Cannot create debugfs hba\n");
5306 atomic_inc(&lpfc_debugfs_hba_count
);
5307 atomic_set(&phba
->debugfs_vport_count
, 0);
5310 snprintf(name
, sizeof(name
), "hbqinfo");
5311 phba
->debug_hbqinfo
=
5312 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5313 phba
->hba_debugfs_root
,
5314 phba
, &lpfc_debugfs_op_hbqinfo
);
5315 if (!phba
->debug_hbqinfo
) {
5316 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5317 "0411 Cannot create debugfs hbqinfo\n");
5321 /* Setup dumpHBASlim */
5322 if (phba
->sli_rev
< LPFC_SLI_REV4
) {
5323 snprintf(name
, sizeof(name
), "dumpHBASlim");
5324 phba
->debug_dumpHBASlim
=
5325 debugfs_create_file(name
,
5326 S_IFREG
|S_IRUGO
|S_IWUSR
,
5327 phba
->hba_debugfs_root
,
5328 phba
, &lpfc_debugfs_op_dumpHBASlim
);
5329 if (!phba
->debug_dumpHBASlim
) {
5330 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5331 "0413 Cannot create debugfs "
5336 phba
->debug_dumpHBASlim
= NULL
;
5338 /* Setup dumpHostSlim */
5339 if (phba
->sli_rev
< LPFC_SLI_REV4
) {
5340 snprintf(name
, sizeof(name
), "dumpHostSlim");
5341 phba
->debug_dumpHostSlim
=
5342 debugfs_create_file(name
,
5343 S_IFREG
|S_IRUGO
|S_IWUSR
,
5344 phba
->hba_debugfs_root
,
5345 phba
, &lpfc_debugfs_op_dumpHostSlim
);
5346 if (!phba
->debug_dumpHostSlim
) {
5347 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5348 "0414 Cannot create debugfs "
5353 phba
->debug_dumpHostSlim
= NULL
;
5355 /* Setup dumpData */
5356 snprintf(name
, sizeof(name
), "dumpData");
5357 phba
->debug_dumpData
=
5358 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5359 phba
->hba_debugfs_root
,
5360 phba
, &lpfc_debugfs_op_dumpData
);
5361 if (!phba
->debug_dumpData
) {
5362 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5363 "0800 Cannot create debugfs dumpData\n");
5368 snprintf(name
, sizeof(name
), "dumpDif");
5369 phba
->debug_dumpDif
=
5370 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5371 phba
->hba_debugfs_root
,
5372 phba
, &lpfc_debugfs_op_dumpDif
);
5373 if (!phba
->debug_dumpDif
) {
5374 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5375 "0801 Cannot create debugfs dumpDif\n");
5379 /* Setup DIF Error Injections */
5380 snprintf(name
, sizeof(name
), "InjErrLBA");
5381 phba
->debug_InjErrLBA
=
5382 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5383 phba
->hba_debugfs_root
,
5384 phba
, &lpfc_debugfs_op_dif_err
);
5385 if (!phba
->debug_InjErrLBA
) {
5386 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5387 "0807 Cannot create debugfs InjErrLBA\n");
5390 phba
->lpfc_injerr_lba
= LPFC_INJERR_LBA_OFF
;
5392 snprintf(name
, sizeof(name
), "InjErrNPortID");
5393 phba
->debug_InjErrNPortID
=
5394 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5395 phba
->hba_debugfs_root
,
5396 phba
, &lpfc_debugfs_op_dif_err
);
5397 if (!phba
->debug_InjErrNPortID
) {
5398 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5399 "0809 Cannot create debugfs InjErrNPortID\n");
5403 snprintf(name
, sizeof(name
), "InjErrWWPN");
5404 phba
->debug_InjErrWWPN
=
5405 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5406 phba
->hba_debugfs_root
,
5407 phba
, &lpfc_debugfs_op_dif_err
);
5408 if (!phba
->debug_InjErrWWPN
) {
5409 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5410 "0810 Cannot create debugfs InjErrWWPN\n");
5414 snprintf(name
, sizeof(name
), "writeGuardInjErr");
5415 phba
->debug_writeGuard
=
5416 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5417 phba
->hba_debugfs_root
,
5418 phba
, &lpfc_debugfs_op_dif_err
);
5419 if (!phba
->debug_writeGuard
) {
5420 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5421 "0802 Cannot create debugfs writeGuard\n");
5425 snprintf(name
, sizeof(name
), "writeAppInjErr");
5426 phba
->debug_writeApp
=
5427 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5428 phba
->hba_debugfs_root
,
5429 phba
, &lpfc_debugfs_op_dif_err
);
5430 if (!phba
->debug_writeApp
) {
5431 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5432 "0803 Cannot create debugfs writeApp\n");
5436 snprintf(name
, sizeof(name
), "writeRefInjErr");
5437 phba
->debug_writeRef
=
5438 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5439 phba
->hba_debugfs_root
,
5440 phba
, &lpfc_debugfs_op_dif_err
);
5441 if (!phba
->debug_writeRef
) {
5442 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5443 "0804 Cannot create debugfs writeRef\n");
5447 snprintf(name
, sizeof(name
), "readGuardInjErr");
5448 phba
->debug_readGuard
=
5449 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5450 phba
->hba_debugfs_root
,
5451 phba
, &lpfc_debugfs_op_dif_err
);
5452 if (!phba
->debug_readGuard
) {
5453 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5454 "0808 Cannot create debugfs readGuard\n");
5458 snprintf(name
, sizeof(name
), "readAppInjErr");
5459 phba
->debug_readApp
=
5460 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5461 phba
->hba_debugfs_root
,
5462 phba
, &lpfc_debugfs_op_dif_err
);
5463 if (!phba
->debug_readApp
) {
5464 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5465 "0805 Cannot create debugfs readApp\n");
5469 snprintf(name
, sizeof(name
), "readRefInjErr");
5470 phba
->debug_readRef
=
5471 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5472 phba
->hba_debugfs_root
,
5473 phba
, &lpfc_debugfs_op_dif_err
);
5474 if (!phba
->debug_readRef
) {
5475 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5476 "0806 Cannot create debugfs readApp\n");
5480 /* Setup slow ring trace */
5481 if (lpfc_debugfs_max_slow_ring_trc
) {
5482 num
= lpfc_debugfs_max_slow_ring_trc
- 1;
5483 if (num
& lpfc_debugfs_max_slow_ring_trc
) {
5484 /* Change to be a power of 2 */
5485 num
= lpfc_debugfs_max_slow_ring_trc
;
5491 lpfc_debugfs_max_slow_ring_trc
= (1 << i
);
5492 pr_err("lpfc_debugfs_max_disc_trc changed to "
5493 "%d\n", lpfc_debugfs_max_disc_trc
);
5497 snprintf(name
, sizeof(name
), "slow_ring_trace");
5498 phba
->debug_slow_ring_trc
=
5499 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5500 phba
->hba_debugfs_root
,
5501 phba
, &lpfc_debugfs_op_slow_ring_trc
);
5502 if (!phba
->debug_slow_ring_trc
) {
5503 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5504 "0415 Cannot create debugfs "
5505 "slow_ring_trace\n");
5508 if (!phba
->slow_ring_trc
) {
5509 phba
->slow_ring_trc
= kmalloc(
5510 (sizeof(struct lpfc_debugfs_trc
) *
5511 lpfc_debugfs_max_slow_ring_trc
),
5513 if (!phba
->slow_ring_trc
) {
5514 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5515 "0416 Cannot create debugfs "
5516 "slow_ring buffer\n");
5519 atomic_set(&phba
->slow_ring_trc_cnt
, 0);
5520 memset(phba
->slow_ring_trc
, 0,
5521 (sizeof(struct lpfc_debugfs_trc
) *
5522 lpfc_debugfs_max_slow_ring_trc
));
5525 snprintf(name
, sizeof(name
), "nvmeio_trc");
5526 phba
->debug_nvmeio_trc
=
5527 debugfs_create_file(name
, 0644,
5528 phba
->hba_debugfs_root
,
5529 phba
, &lpfc_debugfs_op_nvmeio_trc
);
5530 if (!phba
->debug_nvmeio_trc
) {
5531 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5532 "0574 No create debugfs nvmeio_trc\n");
5536 atomic_set(&phba
->nvmeio_trc_cnt
, 0);
5537 if (lpfc_debugfs_max_nvmeio_trc
) {
5538 num
= lpfc_debugfs_max_nvmeio_trc
- 1;
5539 if (num
& lpfc_debugfs_max_disc_trc
) {
5540 /* Change to be a power of 2 */
5541 num
= lpfc_debugfs_max_nvmeio_trc
;
5547 lpfc_debugfs_max_nvmeio_trc
= (1 << i
);
5548 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
5549 "0575 lpfc_debugfs_max_nvmeio_trc "
5551 lpfc_debugfs_max_nvmeio_trc
);
5553 phba
->nvmeio_trc_size
= lpfc_debugfs_max_nvmeio_trc
;
5555 /* Allocate trace buffer and initialize */
5556 phba
->nvmeio_trc
= kzalloc(
5557 (sizeof(struct lpfc_debugfs_nvmeio_trc
) *
5558 phba
->nvmeio_trc_size
), GFP_KERNEL
);
5560 if (!phba
->nvmeio_trc
) {
5561 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
5562 "0576 Cannot create debugfs "
5563 "nvmeio_trc buffer\n");
5566 phba
->nvmeio_trc_on
= 1;
5567 phba
->nvmeio_trc_output_idx
= 0;
5568 phba
->nvmeio_trc
= NULL
;
5571 phba
->nvmeio_trc_size
= 0;
5572 phba
->nvmeio_trc_on
= 0;
5573 phba
->nvmeio_trc_output_idx
= 0;
5574 phba
->nvmeio_trc
= NULL
;
5578 snprintf(name
, sizeof(name
), "vport%d", vport
->vpi
);
5579 if (!vport
->vport_debugfs_root
) {
5580 vport
->vport_debugfs_root
=
5581 debugfs_create_dir(name
, phba
->hba_debugfs_root
);
5582 if (!vport
->vport_debugfs_root
) {
5583 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5584 "0417 Can't create debugfs\n");
5587 atomic_inc(&phba
->debugfs_vport_count
);
5590 if (lpfc_debugfs_max_disc_trc
) {
5591 num
= lpfc_debugfs_max_disc_trc
- 1;
5592 if (num
& lpfc_debugfs_max_disc_trc
) {
5593 /* Change to be a power of 2 */
5594 num
= lpfc_debugfs_max_disc_trc
;
5600 lpfc_debugfs_max_disc_trc
= (1 << i
);
5601 pr_err("lpfc_debugfs_max_disc_trc changed to %d\n",
5602 lpfc_debugfs_max_disc_trc
);
5606 vport
->disc_trc
= kzalloc(
5607 (sizeof(struct lpfc_debugfs_trc
) * lpfc_debugfs_max_disc_trc
),
5610 if (!vport
->disc_trc
) {
5611 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5612 "0418 Cannot create debugfs disc trace "
5616 atomic_set(&vport
->disc_trc_cnt
, 0);
5618 snprintf(name
, sizeof(name
), "discovery_trace");
5619 vport
->debug_disc_trc
=
5620 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5621 vport
->vport_debugfs_root
,
5622 vport
, &lpfc_debugfs_op_disc_trc
);
5623 if (!vport
->debug_disc_trc
) {
5624 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5625 "0419 Cannot create debugfs "
5626 "discovery_trace\n");
5629 snprintf(name
, sizeof(name
), "nodelist");
5630 vport
->debug_nodelist
=
5631 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5632 vport
->vport_debugfs_root
,
5633 vport
, &lpfc_debugfs_op_nodelist
);
5634 if (!vport
->debug_nodelist
) {
5635 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5636 "2985 Can't create debugfs nodelist\n");
5640 snprintf(name
, sizeof(name
), "nvmestat");
5641 vport
->debug_nvmestat
=
5642 debugfs_create_file(name
, 0644,
5643 vport
->vport_debugfs_root
,
5644 vport
, &lpfc_debugfs_op_nvmestat
);
5645 if (!vport
->debug_nvmestat
) {
5646 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5647 "0811 Cannot create debugfs nvmestat\n");
5651 snprintf(name
, sizeof(name
), "nvmektime");
5652 vport
->debug_nvmektime
=
5653 debugfs_create_file(name
, 0644,
5654 vport
->vport_debugfs_root
,
5655 vport
, &lpfc_debugfs_op_nvmektime
);
5656 if (!vport
->debug_nvmektime
) {
5657 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5658 "0815 Cannot create debugfs nvmektime\n");
5662 snprintf(name
, sizeof(name
), "cpucheck");
5663 vport
->debug_cpucheck
=
5664 debugfs_create_file(name
, 0644,
5665 vport
->vport_debugfs_root
,
5666 vport
, &lpfc_debugfs_op_cpucheck
);
5667 if (!vport
->debug_cpucheck
) {
5668 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5669 "0819 Cannot create debugfs cpucheck\n");
5674 * The following section is for additional directories/files for the
5682 * iDiag debugfs root entry points for SLI4 device only
5684 if (phba
->sli_rev
< LPFC_SLI_REV4
)
5687 snprintf(name
, sizeof(name
), "iDiag");
5688 if (!phba
->idiag_root
) {
5690 debugfs_create_dir(name
, phba
->hba_debugfs_root
);
5691 if (!phba
->idiag_root
) {
5692 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5693 "2922 Can't create idiag debugfs\n");
5696 /* Initialize iDiag data structure */
5697 memset(&idiag
, 0, sizeof(idiag
));
5700 /* iDiag read PCI config space */
5701 snprintf(name
, sizeof(name
), "pciCfg");
5702 if (!phba
->idiag_pci_cfg
) {
5703 phba
->idiag_pci_cfg
=
5704 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5705 phba
->idiag_root
, phba
, &lpfc_idiag_op_pciCfg
);
5706 if (!phba
->idiag_pci_cfg
) {
5707 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5708 "2923 Can't create idiag debugfs\n");
5711 idiag
.offset
.last_rd
= 0;
5714 /* iDiag PCI BAR access */
5715 snprintf(name
, sizeof(name
), "barAcc");
5716 if (!phba
->idiag_bar_acc
) {
5717 phba
->idiag_bar_acc
=
5718 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5719 phba
->idiag_root
, phba
, &lpfc_idiag_op_barAcc
);
5720 if (!phba
->idiag_bar_acc
) {
5721 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5722 "3056 Can't create idiag debugfs\n");
5725 idiag
.offset
.last_rd
= 0;
5728 /* iDiag get PCI function queue information */
5729 snprintf(name
, sizeof(name
), "queInfo");
5730 if (!phba
->idiag_que_info
) {
5731 phba
->idiag_que_info
=
5732 debugfs_create_file(name
, S_IFREG
|S_IRUGO
,
5733 phba
->idiag_root
, phba
, &lpfc_idiag_op_queInfo
);
5734 if (!phba
->idiag_que_info
) {
5735 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5736 "2924 Can't create idiag debugfs\n");
5741 /* iDiag access PCI function queue */
5742 snprintf(name
, sizeof(name
), "queAcc");
5743 if (!phba
->idiag_que_acc
) {
5744 phba
->idiag_que_acc
=
5745 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5746 phba
->idiag_root
, phba
, &lpfc_idiag_op_queAcc
);
5747 if (!phba
->idiag_que_acc
) {
5748 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5749 "2926 Can't create idiag debugfs\n");
5754 /* iDiag access PCI function doorbell registers */
5755 snprintf(name
, sizeof(name
), "drbAcc");
5756 if (!phba
->idiag_drb_acc
) {
5757 phba
->idiag_drb_acc
=
5758 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5759 phba
->idiag_root
, phba
, &lpfc_idiag_op_drbAcc
);
5760 if (!phba
->idiag_drb_acc
) {
5761 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5762 "2927 Can't create idiag debugfs\n");
5767 /* iDiag access PCI function control registers */
5768 snprintf(name
, sizeof(name
), "ctlAcc");
5769 if (!phba
->idiag_ctl_acc
) {
5770 phba
->idiag_ctl_acc
=
5771 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5772 phba
->idiag_root
, phba
, &lpfc_idiag_op_ctlAcc
);
5773 if (!phba
->idiag_ctl_acc
) {
5774 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5775 "2981 Can't create idiag debugfs\n");
5780 /* iDiag access mbox commands */
5781 snprintf(name
, sizeof(name
), "mbxAcc");
5782 if (!phba
->idiag_mbx_acc
) {
5783 phba
->idiag_mbx_acc
=
5784 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5785 phba
->idiag_root
, phba
, &lpfc_idiag_op_mbxAcc
);
5786 if (!phba
->idiag_mbx_acc
) {
5787 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5788 "2980 Can't create idiag debugfs\n");
5793 /* iDiag extents access commands */
5794 if (phba
->sli4_hba
.extents_in_use
) {
5795 snprintf(name
, sizeof(name
), "extAcc");
5796 if (!phba
->idiag_ext_acc
) {
5797 phba
->idiag_ext_acc
=
5798 debugfs_create_file(name
,
5799 S_IFREG
|S_IRUGO
|S_IWUSR
,
5800 phba
->idiag_root
, phba
,
5801 &lpfc_idiag_op_extAcc
);
5802 if (!phba
->idiag_ext_acc
) {
5803 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5817 * lpfc_debugfs_terminate - Tear down debugfs infrastructure for this vport
5818 * @vport: The vport pointer to remove from debugfs.
5821 * When Debugfs is configured this routine removes debugfs file system elements
5822 * that are specific to this vport. It also checks to see if there are any
5823 * users left for the debugfs directories associated with the HBA and driver. If
5824 * this is the last user of the HBA directory or driver directory then it will
5825 * remove those from the debugfs infrastructure as well.
5828 lpfc_debugfs_terminate(struct lpfc_vport
*vport
)
5830 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
5831 struct lpfc_hba
*phba
= vport
->phba
;
5833 kfree(vport
->disc_trc
);
5834 vport
->disc_trc
= NULL
;
5836 debugfs_remove(vport
->debug_disc_trc
); /* discovery_trace */
5837 vport
->debug_disc_trc
= NULL
;
5839 debugfs_remove(vport
->debug_nodelist
); /* nodelist */
5840 vport
->debug_nodelist
= NULL
;
5842 debugfs_remove(vport
->debug_nvmestat
); /* nvmestat */
5843 vport
->debug_nvmestat
= NULL
;
5845 debugfs_remove(vport
->debug_nvmektime
); /* nvmektime */
5846 vport
->debug_nvmektime
= NULL
;
5848 debugfs_remove(vport
->debug_cpucheck
); /* cpucheck */
5849 vport
->debug_cpucheck
= NULL
;
5851 if (vport
->vport_debugfs_root
) {
5852 debugfs_remove(vport
->vport_debugfs_root
); /* vportX */
5853 vport
->vport_debugfs_root
= NULL
;
5854 atomic_dec(&phba
->debugfs_vport_count
);
5857 if (atomic_read(&phba
->debugfs_vport_count
) == 0) {
5859 debugfs_remove(phba
->debug_hbqinfo
); /* hbqinfo */
5860 phba
->debug_hbqinfo
= NULL
;
5862 debugfs_remove(phba
->debug_dumpHBASlim
); /* HBASlim */
5863 phba
->debug_dumpHBASlim
= NULL
;
5865 debugfs_remove(phba
->debug_dumpHostSlim
); /* HostSlim */
5866 phba
->debug_dumpHostSlim
= NULL
;
5868 debugfs_remove(phba
->debug_dumpData
); /* dumpData */
5869 phba
->debug_dumpData
= NULL
;
5871 debugfs_remove(phba
->debug_dumpDif
); /* dumpDif */
5872 phba
->debug_dumpDif
= NULL
;
5874 debugfs_remove(phba
->debug_InjErrLBA
); /* InjErrLBA */
5875 phba
->debug_InjErrLBA
= NULL
;
5877 debugfs_remove(phba
->debug_InjErrNPortID
);
5878 phba
->debug_InjErrNPortID
= NULL
;
5880 debugfs_remove(phba
->debug_InjErrWWPN
); /* InjErrWWPN */
5881 phba
->debug_InjErrWWPN
= NULL
;
5883 debugfs_remove(phba
->debug_writeGuard
); /* writeGuard */
5884 phba
->debug_writeGuard
= NULL
;
5886 debugfs_remove(phba
->debug_writeApp
); /* writeApp */
5887 phba
->debug_writeApp
= NULL
;
5889 debugfs_remove(phba
->debug_writeRef
); /* writeRef */
5890 phba
->debug_writeRef
= NULL
;
5892 debugfs_remove(phba
->debug_readGuard
); /* readGuard */
5893 phba
->debug_readGuard
= NULL
;
5895 debugfs_remove(phba
->debug_readApp
); /* readApp */
5896 phba
->debug_readApp
= NULL
;
5898 debugfs_remove(phba
->debug_readRef
); /* readRef */
5899 phba
->debug_readRef
= NULL
;
5901 kfree(phba
->slow_ring_trc
);
5902 phba
->slow_ring_trc
= NULL
;
5904 /* slow_ring_trace */
5905 debugfs_remove(phba
->debug_slow_ring_trc
);
5906 phba
->debug_slow_ring_trc
= NULL
;
5908 debugfs_remove(phba
->debug_nvmeio_trc
);
5909 phba
->debug_nvmeio_trc
= NULL
;
5911 kfree(phba
->nvmeio_trc
);
5912 phba
->nvmeio_trc
= NULL
;
5917 if (phba
->sli_rev
== LPFC_SLI_REV4
) {
5919 debugfs_remove(phba
->idiag_ext_acc
);
5920 phba
->idiag_ext_acc
= NULL
;
5923 debugfs_remove(phba
->idiag_mbx_acc
);
5924 phba
->idiag_mbx_acc
= NULL
;
5927 debugfs_remove(phba
->idiag_ctl_acc
);
5928 phba
->idiag_ctl_acc
= NULL
;
5931 debugfs_remove(phba
->idiag_drb_acc
);
5932 phba
->idiag_drb_acc
= NULL
;
5935 debugfs_remove(phba
->idiag_que_acc
);
5936 phba
->idiag_que_acc
= NULL
;
5939 debugfs_remove(phba
->idiag_que_info
);
5940 phba
->idiag_que_info
= NULL
;
5943 debugfs_remove(phba
->idiag_bar_acc
);
5944 phba
->idiag_bar_acc
= NULL
;
5947 debugfs_remove(phba
->idiag_pci_cfg
);
5948 phba
->idiag_pci_cfg
= NULL
;
5950 /* Finally remove the iDiag debugfs root */
5951 debugfs_remove(phba
->idiag_root
);
5952 phba
->idiag_root
= NULL
;
5955 if (phba
->hba_debugfs_root
) {
5956 debugfs_remove(phba
->hba_debugfs_root
); /* fnX */
5957 phba
->hba_debugfs_root
= NULL
;
5958 atomic_dec(&lpfc_debugfs_hba_count
);
5961 if (atomic_read(&lpfc_debugfs_hba_count
) == 0) {
5962 debugfs_remove(lpfc_debugfs_root
); /* lpfc */
5963 lpfc_debugfs_root
= NULL
;
5971 * Driver debug utility routines outside of debugfs. The debug utility
5972 * routines implemented here is intended to be used in the instrumented
5973 * debug driver for debugging host or port issues.
5977 * lpfc_debug_dump_all_queues - dump all the queues with a hba
5978 * @phba: Pointer to HBA context object.
5980 * This function dumps entries of all the queues asociated with the @phba.
5983 lpfc_debug_dump_all_queues(struct lpfc_hba
*phba
)
5988 * Dump Work Queues (WQs)
5990 lpfc_debug_dump_wq(phba
, DUMP_MBX
, 0);
5991 lpfc_debug_dump_wq(phba
, DUMP_ELS
, 0);
5992 lpfc_debug_dump_wq(phba
, DUMP_NVMELS
, 0);
5994 for (idx
= 0; idx
< phba
->cfg_fcp_io_channel
; idx
++)
5995 lpfc_debug_dump_wq(phba
, DUMP_FCP
, idx
);
5997 for (idx
= 0; idx
< phba
->cfg_nvme_io_channel
; idx
++)
5998 lpfc_debug_dump_wq(phba
, DUMP_NVME
, idx
);
6000 lpfc_debug_dump_hdr_rq(phba
);
6001 lpfc_debug_dump_dat_rq(phba
);
6003 * Dump Complete Queues (CQs)
6005 lpfc_debug_dump_cq(phba
, DUMP_MBX
, 0);
6006 lpfc_debug_dump_cq(phba
, DUMP_ELS
, 0);
6007 lpfc_debug_dump_cq(phba
, DUMP_NVMELS
, 0);
6009 for (idx
= 0; idx
< phba
->cfg_fcp_io_channel
; idx
++)
6010 lpfc_debug_dump_cq(phba
, DUMP_FCP
, idx
);
6012 for (idx
= 0; idx
< phba
->cfg_nvme_io_channel
; idx
++)
6013 lpfc_debug_dump_cq(phba
, DUMP_NVME
, idx
);
6016 * Dump Event Queues (EQs)
6018 for (idx
= 0; idx
< phba
->io_channel_irqs
; idx
++)
6019 lpfc_debug_dump_hba_eq(phba
, idx
);