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
+= snprintf(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
+= snprintf(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
+= snprintf(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
+= snprintf(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
+= snprintf(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
+= snprintf(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
+= snprintf(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
+= snprintf(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
+= snprintf(buf
+len
, size
-len
, "Unused\n");
349 if ((j
>= hbqs
->hbqPutIdx
) &&
350 (j
< (hbqs
->entry_count
+low
))) {
351 len
+= snprintf(buf
+len
, size
-len
, "Unused\n");
356 /* Get the Buffer info for the posted buffer */
357 list_for_each_entry(d_buf
, &hbqs
->hbq_buffer_list
, list
) {
358 hbq_buf
= container_of(d_buf
, struct hbq_dmabuf
, dbuf
);
359 phys
= ((uint64_t)hbq_buf
->dbuf
.phys
& 0xffffffff);
360 if (phys
== le32_to_cpu(hbqe
->bde
.addrLow
)) {
361 len
+= snprintf(buf
+len
, size
-len
,
362 "Buf%d: %p %06x\n", i
,
363 hbq_buf
->dbuf
.virt
, hbq_buf
->tag
);
370 len
+= snprintf(buf
+len
, size
-len
, "No DMAinfo?\n");
374 if (len
> LPFC_HBQINFO_SIZE
- 54)
377 spin_unlock_irq(&phba
->hbalock
);
381 static int lpfc_debugfs_last_hba_slim_off
;
384 * lpfc_debugfs_dumpHBASlim_data - Dump HBA SLIM info to a buffer
385 * @phba: The HBA to gather SLIM info from.
386 * @buf: The buffer to dump log into.
387 * @size: The maximum amount of data to process.
390 * This routine dumps the current contents of HBA SLIM for the HBA associated
391 * with @phba to @buf up to @size bytes of data. This is the raw HBA SLIM data.
394 * This routine will only dump up to 1024 bytes of data each time called and
395 * should be called multiple times to dump the entire HBA SLIM.
398 * This routine returns the amount of bytes that were dumped into @buf and will
402 lpfc_debugfs_dumpHBASlim_data(struct lpfc_hba
*phba
, char *buf
, int size
)
409 buffer
= kmalloc(1024, GFP_KERNEL
);
414 spin_lock_irq(&phba
->hbalock
);
416 len
+= snprintf(buf
+len
, size
-len
, "HBA SLIM\n");
417 lpfc_memcpy_from_slim(buffer
,
418 phba
->MBslimaddr
+ lpfc_debugfs_last_hba_slim_off
, 1024);
420 ptr
= (uint32_t *)&buffer
[0];
421 off
= lpfc_debugfs_last_hba_slim_off
;
423 /* Set it up for the next time */
424 lpfc_debugfs_last_hba_slim_off
+= 1024;
425 if (lpfc_debugfs_last_hba_slim_off
>= 4096)
426 lpfc_debugfs_last_hba_slim_off
= 0;
430 len
+= snprintf(buf
+len
, size
-len
,
431 "%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n",
432 off
, *ptr
, *(ptr
+1), *(ptr
+2), *(ptr
+3), *(ptr
+4),
433 *(ptr
+5), *(ptr
+6), *(ptr
+7));
435 i
-= (8 * sizeof(uint32_t));
436 off
+= (8 * sizeof(uint32_t));
439 spin_unlock_irq(&phba
->hbalock
);
446 * lpfc_debugfs_dumpHostSlim_data - Dump host SLIM info to a buffer
447 * @phba: The HBA to gather Host SLIM info from.
448 * @buf: The buffer to dump log into.
449 * @size: The maximum amount of data to process.
452 * This routine dumps the current contents of host SLIM for the host associated
453 * with @phba to @buf up to @size bytes of data. The dump will contain the
454 * Mailbox, PCB, Rings, and Registers that are located in host memory.
457 * This routine returns the amount of bytes that were dumped into @buf and will
461 lpfc_debugfs_dumpHostSlim_data(struct lpfc_hba
*phba
, char *buf
, int size
)
465 uint32_t word0
, word1
, word2
, word3
;
467 struct lpfc_pgp
*pgpp
;
468 struct lpfc_sli
*psli
= &phba
->sli
;
469 struct lpfc_sli_ring
*pring
;
472 spin_lock_irq(&phba
->hbalock
);
474 len
+= snprintf(buf
+len
, size
-len
, "SLIM Mailbox\n");
475 ptr
= (uint32_t *)phba
->slim2p
.virt
;
476 i
= sizeof(MAILBOX_t
);
478 len
+= snprintf(buf
+len
, size
-len
,
479 "%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n",
480 off
, *ptr
, *(ptr
+1), *(ptr
+2), *(ptr
+3), *(ptr
+4),
481 *(ptr
+5), *(ptr
+6), *(ptr
+7));
483 i
-= (8 * sizeof(uint32_t));
484 off
+= (8 * sizeof(uint32_t));
487 len
+= snprintf(buf
+len
, size
-len
, "SLIM PCB\n");
488 ptr
= (uint32_t *)phba
->pcb
;
491 len
+= snprintf(buf
+len
, size
-len
,
492 "%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n",
493 off
, *ptr
, *(ptr
+1), *(ptr
+2), *(ptr
+3), *(ptr
+4),
494 *(ptr
+5), *(ptr
+6), *(ptr
+7));
496 i
-= (8 * sizeof(uint32_t));
497 off
+= (8 * sizeof(uint32_t));
500 if (phba
->sli_rev
<= LPFC_SLI_REV3
) {
501 for (i
= 0; i
< 4; i
++) {
502 pgpp
= &phba
->port_gp
[i
];
503 pring
= &psli
->sli3_ring
[i
];
504 len
+= snprintf(buf
+len
, size
-len
,
505 "Ring %d: CMD GetInx:%d "
508 "RSP PutInx:%d Max:%d\n",
510 pring
->sli
.sli3
.numCiocb
,
511 pring
->sli
.sli3
.next_cmdidx
,
512 pring
->sli
.sli3
.local_getidx
,
513 pring
->flag
, pgpp
->rspPutInx
,
514 pring
->sli
.sli3
.numRiocb
);
517 word0
= readl(phba
->HAregaddr
);
518 word1
= readl(phba
->CAregaddr
);
519 word2
= readl(phba
->HSregaddr
);
520 word3
= readl(phba
->HCregaddr
);
521 len
+= snprintf(buf
+len
, size
-len
, "HA:%08x CA:%08x HS:%08x "
522 "HC:%08x\n", word0
, word1
, word2
, word3
);
524 spin_unlock_irq(&phba
->hbalock
);
529 * lpfc_debugfs_nodelist_data - Dump target node list to a buffer
530 * @vport: The vport to gather target node info from.
531 * @buf: The buffer to dump log into.
532 * @size: The maximum amount of data to process.
535 * This routine dumps the current target node list associated with @vport to
536 * @buf up to @size bytes of data. Each node entry in the dump will contain a
537 * node state, DID, WWPN, WWNN, RPI, flags, type, and other useful fields.
540 * This routine returns the amount of bytes that were dumped into @buf and will
544 lpfc_debugfs_nodelist_data(struct lpfc_vport
*vport
, char *buf
, int size
)
547 int i
, iocnt
, outio
, cnt
;
548 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
549 struct lpfc_hba
*phba
= vport
->phba
;
550 struct lpfc_nodelist
*ndlp
;
551 unsigned char *statep
;
552 struct nvme_fc_local_port
*localport
;
553 struct lpfc_nvmet_tgtport
*tgtp
;
554 struct nvme_fc_remote_port
*nrport
;
555 struct lpfc_nvme_rport
*rport
;
557 cnt
= (LPFC_NODELIST_SIZE
/ LPFC_NODELIST_ENTRY_SIZE
);
560 len
+= snprintf(buf
+len
, size
-len
, "\nFCP Nodelist Entries ...\n");
561 spin_lock_irq(shost
->host_lock
);
562 list_for_each_entry(ndlp
, &vport
->fc_nodes
, nlp_listp
) {
565 len
+= snprintf(buf
+len
, size
-len
,
566 "Missing Nodelist Entries\n");
570 switch (ndlp
->nlp_state
) {
571 case NLP_STE_UNUSED_NODE
:
574 case NLP_STE_PLOGI_ISSUE
:
577 case NLP_STE_ADISC_ISSUE
:
580 case NLP_STE_REG_LOGIN_ISSUE
:
583 case NLP_STE_PRLI_ISSUE
:
586 case NLP_STE_LOGO_ISSUE
:
589 case NLP_STE_UNMAPPED_NODE
:
593 case NLP_STE_MAPPED_NODE
:
597 case NLP_STE_NPR_NODE
:
603 len
+= snprintf(buf
+len
, size
-len
, "%s DID:x%06x ",
604 statep
, ndlp
->nlp_DID
);
605 len
+= snprintf(buf
+len
, size
-len
,
607 wwn_to_u64(ndlp
->nlp_portname
.u
.wwn
));
608 len
+= snprintf(buf
+len
, size
-len
,
610 wwn_to_u64(ndlp
->nlp_nodename
.u
.wwn
));
611 if (ndlp
->nlp_flag
& NLP_RPI_REGISTERED
)
612 len
+= snprintf(buf
+len
, size
-len
, "RPI:%03d ",
615 len
+= snprintf(buf
+len
, size
-len
, "RPI:none ");
616 len
+= snprintf(buf
+len
, size
-len
, "flag:x%08x ",
619 len
+= snprintf(buf
+len
, size
-len
, "UNKNOWN_TYPE ");
620 if (ndlp
->nlp_type
& NLP_FC_NODE
)
621 len
+= snprintf(buf
+len
, size
-len
, "FC_NODE ");
622 if (ndlp
->nlp_type
& NLP_FABRIC
) {
623 len
+= snprintf(buf
+len
, size
-len
, "FABRIC ");
626 if (ndlp
->nlp_type
& NLP_FCP_TARGET
)
627 len
+= snprintf(buf
+len
, size
-len
, "FCP_TGT sid:%d ",
629 if (ndlp
->nlp_type
& NLP_FCP_INITIATOR
)
630 len
+= snprintf(buf
+len
, size
-len
, "FCP_INITIATOR ");
631 if (ndlp
->nlp_type
& NLP_NVME_TARGET
)
632 len
+= snprintf(buf
+ len
,
633 size
- len
, "NVME_TGT sid:%d ",
635 if (ndlp
->nlp_type
& NLP_NVME_INITIATOR
)
636 len
+= snprintf(buf
+ len
,
637 size
- len
, "NVME_INITIATOR ");
638 len
+= snprintf(buf
+len
, size
-len
, "usgmap:%x ",
640 len
+= snprintf(buf
+len
, size
-len
, "refcnt:%x",
641 kref_read(&ndlp
->kref
));
643 i
= atomic_read(&ndlp
->cmd_pending
);
644 len
+= snprintf(buf
+ len
, size
- len
,
645 " OutIO:x%x Qdepth x%x",
646 i
, ndlp
->cmd_qdepth
);
649 len
+= snprintf(buf
+len
, size
-len
, "\n");
651 spin_unlock_irq(shost
->host_lock
);
653 len
+= snprintf(buf
+ len
, size
- len
,
654 "\nOutstanding IO x%x\n", outio
);
656 if (phba
->nvmet_support
&& phba
->targetport
&& (vport
== phba
->pport
)) {
657 tgtp
= (struct lpfc_nvmet_tgtport
*)phba
->targetport
->private;
658 len
+= snprintf(buf
+ len
, size
- len
,
659 "\nNVME Targetport Entry ...\n");
661 /* Port state is only one of two values for now. */
662 if (phba
->targetport
->port_id
)
663 statep
= "REGISTERED";
666 len
+= snprintf(buf
+ len
, size
- len
,
667 "TGT WWNN x%llx WWPN x%llx State %s\n",
668 wwn_to_u64(vport
->fc_nodename
.u
.wwn
),
669 wwn_to_u64(vport
->fc_portname
.u
.wwn
),
671 len
+= snprintf(buf
+ len
, size
- len
,
672 " Targetport DID x%06x\n",
673 phba
->targetport
->port_id
);
677 len
+= snprintf(buf
+ len
, size
- len
,
678 "\nNVME Lport/Rport Entries ...\n");
680 localport
= vport
->localport
;
684 spin_lock_irq(shost
->host_lock
);
686 /* Port state is only one of two values for now. */
687 if (localport
->port_id
)
692 len
+= snprintf(buf
+ len
, size
- len
,
693 "Lport DID x%06x PortState %s\n",
694 localport
->port_id
, statep
);
696 len
+= snprintf(buf
+ len
, size
- len
, "\tRport List:\n");
697 list_for_each_entry(ndlp
, &vport
->fc_nodes
, nlp_listp
) {
698 /* local short-hand pointer. */
699 rport
= lpfc_ndlp_get_nrport(ndlp
);
703 nrport
= rport
->remoteport
;
707 /* Port state is only one of two values for now. */
708 switch (nrport
->port_state
) {
709 case FC_OBJSTATE_ONLINE
:
712 case FC_OBJSTATE_UNKNOWN
:
716 statep
= "UNSUPPORTED";
720 /* Tab in to show lport ownership. */
721 len
+= snprintf(buf
+ len
, size
- len
,
722 "\t%s Port ID:x%06x ",
723 statep
, nrport
->port_id
);
724 len
+= snprintf(buf
+ len
, size
- len
, "WWPN x%llx ",
726 len
+= snprintf(buf
+ len
, size
- len
, "WWNN x%llx ",
729 /* An NVME rport can have multiple roles. */
730 if (nrport
->port_role
& FC_PORT_ROLE_NVME_INITIATOR
)
731 len
+= snprintf(buf
+ len
, size
- len
,
733 if (nrport
->port_role
& FC_PORT_ROLE_NVME_TARGET
)
734 len
+= snprintf(buf
+ len
, size
- len
,
736 if (nrport
->port_role
& FC_PORT_ROLE_NVME_DISCOVERY
)
737 len
+= snprintf(buf
+ len
, size
- len
,
739 if (nrport
->port_role
& ~(FC_PORT_ROLE_NVME_INITIATOR
|
740 FC_PORT_ROLE_NVME_TARGET
|
741 FC_PORT_ROLE_NVME_DISCOVERY
))
742 len
+= snprintf(buf
+ len
, size
- len
,
745 /* Terminate the string. */
746 len
+= snprintf(buf
+ len
, size
- len
, "\n");
749 spin_unlock_irq(shost
->host_lock
);
755 * lpfc_debugfs_nvmestat_data - Dump target node list to a buffer
756 * @vport: The vport to gather target node info from.
757 * @buf: The buffer to dump log into.
758 * @size: The maximum amount of data to process.
761 * This routine dumps the NVME statistics associated with @vport
764 * This routine returns the amount of bytes that were dumped into @buf and will
768 lpfc_debugfs_nvmestat_data(struct lpfc_vport
*vport
, char *buf
, int size
)
770 struct lpfc_hba
*phba
= vport
->phba
;
771 struct lpfc_nvmet_tgtport
*tgtp
;
772 struct lpfc_nvmet_rcv_ctx
*ctxp
, *next_ctxp
;
773 struct nvme_fc_local_port
*localport
;
774 struct lpfc_nvme_ctrl_stat
*cstat
;
775 struct lpfc_nvme_lport
*lport
;
776 uint64_t data1
, data2
, data3
;
777 uint64_t tot
, totin
, totout
;
781 if (phba
->nvmet_support
) {
782 if (!phba
->targetport
)
784 tgtp
= (struct lpfc_nvmet_tgtport
*)phba
->targetport
->private;
785 len
+= snprintf(buf
+ len
, size
- len
,
786 "\nNVME Targetport Statistics\n");
788 len
+= snprintf(buf
+ len
, size
- len
,
789 "LS: Rcv %08x Drop %08x Abort %08x\n",
790 atomic_read(&tgtp
->rcv_ls_req_in
),
791 atomic_read(&tgtp
->rcv_ls_req_drop
),
792 atomic_read(&tgtp
->xmt_ls_abort
));
793 if (atomic_read(&tgtp
->rcv_ls_req_in
) !=
794 atomic_read(&tgtp
->rcv_ls_req_out
)) {
795 len
+= snprintf(buf
+ len
, size
- len
,
796 "Rcv LS: in %08x != out %08x\n",
797 atomic_read(&tgtp
->rcv_ls_req_in
),
798 atomic_read(&tgtp
->rcv_ls_req_out
));
801 len
+= snprintf(buf
+ len
, size
- len
,
802 "LS: Xmt %08x Drop %08x Cmpl %08x\n",
803 atomic_read(&tgtp
->xmt_ls_rsp
),
804 atomic_read(&tgtp
->xmt_ls_drop
),
805 atomic_read(&tgtp
->xmt_ls_rsp_cmpl
));
807 len
+= snprintf(buf
+ len
, size
- len
,
808 "LS: RSP Abort %08x xb %08x Err %08x\n",
809 atomic_read(&tgtp
->xmt_ls_rsp_aborted
),
810 atomic_read(&tgtp
->xmt_ls_rsp_xb_set
),
811 atomic_read(&tgtp
->xmt_ls_rsp_error
));
813 len
+= snprintf(buf
+ len
, size
- len
,
814 "FCP: Rcv %08x Defer %08x Release %08x "
816 atomic_read(&tgtp
->rcv_fcp_cmd_in
),
817 atomic_read(&tgtp
->rcv_fcp_cmd_defer
),
818 atomic_read(&tgtp
->xmt_fcp_release
),
819 atomic_read(&tgtp
->rcv_fcp_cmd_drop
));
821 if (atomic_read(&tgtp
->rcv_fcp_cmd_in
) !=
822 atomic_read(&tgtp
->rcv_fcp_cmd_out
)) {
823 len
+= snprintf(buf
+ len
, size
- len
,
824 "Rcv FCP: in %08x != out %08x\n",
825 atomic_read(&tgtp
->rcv_fcp_cmd_in
),
826 atomic_read(&tgtp
->rcv_fcp_cmd_out
));
829 len
+= snprintf(buf
+ len
, size
- len
,
830 "FCP Rsp: read %08x readrsp %08x "
831 "write %08x rsp %08x\n",
832 atomic_read(&tgtp
->xmt_fcp_read
),
833 atomic_read(&tgtp
->xmt_fcp_read_rsp
),
834 atomic_read(&tgtp
->xmt_fcp_write
),
835 atomic_read(&tgtp
->xmt_fcp_rsp
));
837 len
+= snprintf(buf
+ len
, size
- len
,
838 "FCP Rsp Cmpl: %08x err %08x drop %08x\n",
839 atomic_read(&tgtp
->xmt_fcp_rsp_cmpl
),
840 atomic_read(&tgtp
->xmt_fcp_rsp_error
),
841 atomic_read(&tgtp
->xmt_fcp_rsp_drop
));
843 len
+= snprintf(buf
+ len
, size
- len
,
844 "FCP Rsp Abort: %08x xb %08x xricqe %08x\n",
845 atomic_read(&tgtp
->xmt_fcp_rsp_aborted
),
846 atomic_read(&tgtp
->xmt_fcp_rsp_xb_set
),
847 atomic_read(&tgtp
->xmt_fcp_xri_abort_cqe
));
849 len
+= snprintf(buf
+ len
, size
- len
,
850 "ABORT: Xmt %08x Cmpl %08x\n",
851 atomic_read(&tgtp
->xmt_fcp_abort
),
852 atomic_read(&tgtp
->xmt_fcp_abort_cmpl
));
854 len
+= snprintf(buf
+ len
, size
- len
,
855 "ABORT: Sol %08x Usol %08x Err %08x Cmpl %08x",
856 atomic_read(&tgtp
->xmt_abort_sol
),
857 atomic_read(&tgtp
->xmt_abort_unsol
),
858 atomic_read(&tgtp
->xmt_abort_rsp
),
859 atomic_read(&tgtp
->xmt_abort_rsp_error
));
861 len
+= snprintf(buf
+ len
, size
- len
, "\n");
864 spin_lock(&phba
->sli4_hba
.abts_nvme_buf_list_lock
);
865 list_for_each_entry_safe(ctxp
, next_ctxp
,
866 &phba
->sli4_hba
.lpfc_abts_nvmet_ctx_list
,
870 spin_unlock(&phba
->sli4_hba
.abts_nvme_buf_list_lock
);
872 len
+= snprintf(buf
+ len
, size
- len
,
873 "ABORT: %d ctx entries\n", cnt
);
874 spin_lock(&phba
->sli4_hba
.abts_nvme_buf_list_lock
);
875 list_for_each_entry_safe(ctxp
, next_ctxp
,
876 &phba
->sli4_hba
.lpfc_abts_nvmet_ctx_list
,
878 if (len
>= (size
- LPFC_DEBUG_OUT_LINE_SZ
))
880 len
+= snprintf(buf
+ len
, size
- len
,
881 "Entry: oxid %x state %x "
883 ctxp
->oxid
, ctxp
->state
,
886 spin_unlock(&phba
->sli4_hba
.abts_nvme_buf_list_lock
);
889 /* Calculate outstanding IOs */
890 tot
= atomic_read(&tgtp
->rcv_fcp_cmd_drop
);
891 tot
+= atomic_read(&tgtp
->xmt_fcp_release
);
892 tot
= atomic_read(&tgtp
->rcv_fcp_cmd_in
) - tot
;
894 len
+= snprintf(buf
+ len
, size
- len
,
895 "IO_CTX: %08x WAIT: cur %08x tot %08x\n"
896 "CTX Outstanding %08llx\n",
897 phba
->sli4_hba
.nvmet_xri_cnt
,
898 phba
->sli4_hba
.nvmet_io_wait_cnt
,
899 phba
->sli4_hba
.nvmet_io_wait_total
,
902 if (!(phba
->cfg_enable_fc4_type
& LPFC_ENABLE_NVME
))
905 localport
= vport
->localport
;
908 lport
= (struct lpfc_nvme_lport
*)localport
->private;
912 len
+= snprintf(buf
+ len
, size
- len
,
913 "\nNVME Lport Statistics\n");
915 len
+= snprintf(buf
+ len
, size
- len
,
916 "LS: Xmt %016x Cmpl %016x\n",
917 atomic_read(&lport
->fc4NvmeLsRequests
),
918 atomic_read(&lport
->fc4NvmeLsCmpls
));
920 if (phba
->cfg_nvme_io_channel
< 32)
921 maxch
= phba
->cfg_nvme_io_channel
;
926 for (i
= 0; i
< phba
->cfg_nvme_io_channel
; i
++) {
927 cstat
= &lport
->cstat
[i
];
928 tot
= atomic_read(&cstat
->fc4NvmeIoCmpls
);
930 data1
= atomic_read(&cstat
->fc4NvmeInputRequests
);
931 data2
= atomic_read(&cstat
->fc4NvmeOutputRequests
);
932 data3
= atomic_read(&cstat
->fc4NvmeControlRequests
);
933 totout
+= (data1
+ data2
+ data3
);
935 /* Limit to 32, debugfs display buffer limitation */
939 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
940 "FCP (%d): Rd %016llx Wr %016llx "
942 i
, data1
, data2
, data3
);
943 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
944 "Cmpl %016llx OutIO %016llx\n",
945 tot
, ((data1
+ data2
+ data3
) - tot
));
947 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
948 "Total FCP Cmpl %016llx Issue %016llx "
950 totin
, totout
, totout
- totin
);
952 len
+= snprintf(buf
+ len
, size
- len
,
953 "LS Xmt Err: Abrt %08x Err %08x "
954 "Cmpl Err: xb %08x Err %08x\n",
955 atomic_read(&lport
->xmt_ls_abort
),
956 atomic_read(&lport
->xmt_ls_err
),
957 atomic_read(&lport
->cmpl_ls_xb
),
958 atomic_read(&lport
->cmpl_ls_err
));
960 len
+= snprintf(buf
+ len
, size
- len
,
961 "FCP Xmt Err: noxri %06x nondlp %06x "
962 "qdepth %06x wqerr %06x err %06x Abrt %06x\n",
963 atomic_read(&lport
->xmt_fcp_noxri
),
964 atomic_read(&lport
->xmt_fcp_bad_ndlp
),
965 atomic_read(&lport
->xmt_fcp_qdepth
),
966 atomic_read(&lport
->xmt_fcp_wqerr
),
967 atomic_read(&lport
->xmt_fcp_err
),
968 atomic_read(&lport
->xmt_fcp_abort
));
970 len
+= snprintf(buf
+ len
, size
- len
,
971 "FCP Cmpl Err: xb %08x Err %08x\n",
972 atomic_read(&lport
->cmpl_fcp_xb
),
973 atomic_read(&lport
->cmpl_fcp_err
));
982 * lpfc_debugfs_nvmektime_data - Dump target node list to a buffer
983 * @vport: The vport to gather target node info from.
984 * @buf: The buffer to dump log into.
985 * @size: The maximum amount of data to process.
988 * This routine dumps the NVME statistics associated with @vport
991 * This routine returns the amount of bytes that were dumped into @buf and will
995 lpfc_debugfs_nvmektime_data(struct lpfc_vport
*vport
, char *buf
, int size
)
997 struct lpfc_hba
*phba
= vport
->phba
;
1000 if (phba
->nvmet_support
== 0) {
1001 /* NVME Initiator */
1002 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
1003 "ktime %s: Total Samples: %lld\n",
1004 (phba
->ktime_on
? "Enabled" : "Disabled"),
1005 phba
->ktime_data_samples
);
1006 if (phba
->ktime_data_samples
== 0)
1010 buf
+ len
, PAGE_SIZE
- len
,
1011 "Segment 1: Last NVME Cmd cmpl "
1012 "done -to- Start of next NVME cnd (in driver)\n");
1014 buf
+ len
, PAGE_SIZE
- len
,
1015 "avg:%08lld min:%08lld max %08lld\n",
1016 div_u64(phba
->ktime_seg1_total
,
1017 phba
->ktime_data_samples
),
1018 phba
->ktime_seg1_min
,
1019 phba
->ktime_seg1_max
);
1021 buf
+ len
, PAGE_SIZE
- len
,
1022 "Segment 2: Driver start of NVME cmd "
1023 "-to- Firmware WQ doorbell\n");
1025 buf
+ len
, PAGE_SIZE
- len
,
1026 "avg:%08lld min:%08lld max %08lld\n",
1027 div_u64(phba
->ktime_seg2_total
,
1028 phba
->ktime_data_samples
),
1029 phba
->ktime_seg2_min
,
1030 phba
->ktime_seg2_max
);
1032 buf
+ len
, PAGE_SIZE
- len
,
1033 "Segment 3: Firmware WQ doorbell -to- "
1034 "MSI-X ISR cmpl\n");
1036 buf
+ len
, PAGE_SIZE
- len
,
1037 "avg:%08lld min:%08lld max %08lld\n",
1038 div_u64(phba
->ktime_seg3_total
,
1039 phba
->ktime_data_samples
),
1040 phba
->ktime_seg3_min
,
1041 phba
->ktime_seg3_max
);
1043 buf
+ len
, PAGE_SIZE
- len
,
1044 "Segment 4: MSI-X ISR cmpl -to- "
1045 "NVME cmpl done\n");
1047 buf
+ len
, PAGE_SIZE
- len
,
1048 "avg:%08lld min:%08lld max %08lld\n",
1049 div_u64(phba
->ktime_seg4_total
,
1050 phba
->ktime_data_samples
),
1051 phba
->ktime_seg4_min
,
1052 phba
->ktime_seg4_max
);
1054 buf
+ len
, PAGE_SIZE
- len
,
1055 "Total IO avg time: %08lld\n",
1056 div_u64(phba
->ktime_seg1_total
+
1057 phba
->ktime_seg2_total
+
1058 phba
->ktime_seg3_total
+
1059 phba
->ktime_seg4_total
,
1060 phba
->ktime_data_samples
));
1065 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
1066 "ktime %s: Total Samples: %lld %lld\n",
1067 (phba
->ktime_on
? "Enabled" : "Disabled"),
1068 phba
->ktime_data_samples
,
1069 phba
->ktime_status_samples
);
1070 if (phba
->ktime_data_samples
== 0)
1073 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
1074 "Segment 1: MSI-X ISR Rcv cmd -to- "
1075 "cmd pass to NVME Layer\n");
1076 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
1077 "avg:%08lld min:%08lld max %08lld\n",
1078 div_u64(phba
->ktime_seg1_total
,
1079 phba
->ktime_data_samples
),
1080 phba
->ktime_seg1_min
,
1081 phba
->ktime_seg1_max
);
1082 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
1083 "Segment 2: cmd pass to NVME Layer- "
1084 "-to- Driver rcv cmd OP (action)\n");
1085 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
1086 "avg:%08lld min:%08lld max %08lld\n",
1087 div_u64(phba
->ktime_seg2_total
,
1088 phba
->ktime_data_samples
),
1089 phba
->ktime_seg2_min
,
1090 phba
->ktime_seg2_max
);
1091 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
1092 "Segment 3: Driver rcv cmd OP -to- "
1093 "Firmware WQ doorbell: cmd\n");
1094 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
1095 "avg:%08lld min:%08lld max %08lld\n",
1096 div_u64(phba
->ktime_seg3_total
,
1097 phba
->ktime_data_samples
),
1098 phba
->ktime_seg3_min
,
1099 phba
->ktime_seg3_max
);
1100 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
1101 "Segment 4: Firmware WQ doorbell: cmd "
1102 "-to- MSI-X ISR for cmd cmpl\n");
1103 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
1104 "avg:%08lld min:%08lld max %08lld\n",
1105 div_u64(phba
->ktime_seg4_total
,
1106 phba
->ktime_data_samples
),
1107 phba
->ktime_seg4_min
,
1108 phba
->ktime_seg4_max
);
1109 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
1110 "Segment 5: MSI-X ISR for cmd cmpl "
1111 "-to- NVME layer passed cmd done\n");
1112 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
1113 "avg:%08lld min:%08lld max %08lld\n",
1114 div_u64(phba
->ktime_seg5_total
,
1115 phba
->ktime_data_samples
),
1116 phba
->ktime_seg5_min
,
1117 phba
->ktime_seg5_max
);
1119 if (phba
->ktime_status_samples
== 0) {
1120 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
1121 "Total: cmd received by MSI-X ISR "
1122 "-to- cmd completed on wire\n");
1123 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
1124 "avg:%08lld min:%08lld "
1126 div_u64(phba
->ktime_seg10_total
,
1127 phba
->ktime_data_samples
),
1128 phba
->ktime_seg10_min
,
1129 phba
->ktime_seg10_max
);
1133 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
1134 "Segment 6: NVME layer passed cmd done "
1135 "-to- Driver rcv rsp status OP\n");
1136 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
1137 "avg:%08lld min:%08lld max %08lld\n",
1138 div_u64(phba
->ktime_seg6_total
,
1139 phba
->ktime_status_samples
),
1140 phba
->ktime_seg6_min
,
1141 phba
->ktime_seg6_max
);
1142 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
1143 "Segment 7: Driver rcv rsp status OP "
1144 "-to- Firmware WQ doorbell: status\n");
1145 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
1146 "avg:%08lld min:%08lld max %08lld\n",
1147 div_u64(phba
->ktime_seg7_total
,
1148 phba
->ktime_status_samples
),
1149 phba
->ktime_seg7_min
,
1150 phba
->ktime_seg7_max
);
1151 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
1152 "Segment 8: Firmware WQ doorbell: status"
1153 " -to- MSI-X ISR for status cmpl\n");
1154 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
1155 "avg:%08lld min:%08lld max %08lld\n",
1156 div_u64(phba
->ktime_seg8_total
,
1157 phba
->ktime_status_samples
),
1158 phba
->ktime_seg8_min
,
1159 phba
->ktime_seg8_max
);
1160 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
1161 "Segment 9: MSI-X ISR for status cmpl "
1162 "-to- NVME layer passed status done\n");
1163 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
1164 "avg:%08lld min:%08lld max %08lld\n",
1165 div_u64(phba
->ktime_seg9_total
,
1166 phba
->ktime_status_samples
),
1167 phba
->ktime_seg9_min
,
1168 phba
->ktime_seg9_max
);
1169 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
1170 "Total: cmd received by MSI-X ISR -to- "
1171 "cmd completed on wire\n");
1172 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
1173 "avg:%08lld min:%08lld max %08lld\n",
1174 div_u64(phba
->ktime_seg10_total
,
1175 phba
->ktime_status_samples
),
1176 phba
->ktime_seg10_min
,
1177 phba
->ktime_seg10_max
);
1182 * lpfc_debugfs_nvmeio_trc_data - Dump NVME IO trace list to a buffer
1183 * @phba: The phba to gather target node info from.
1184 * @buf: The buffer to dump log into.
1185 * @size: The maximum amount of data to process.
1188 * This routine dumps the NVME IO trace associated with @phba
1191 * This routine returns the amount of bytes that were dumped into @buf and will
1195 lpfc_debugfs_nvmeio_trc_data(struct lpfc_hba
*phba
, char *buf
, int size
)
1197 struct lpfc_debugfs_nvmeio_trc
*dtp
;
1198 int i
, state
, index
, skip
;
1201 state
= phba
->nvmeio_trc_on
;
1203 index
= (atomic_read(&phba
->nvmeio_trc_cnt
) + 1) &
1204 (phba
->nvmeio_trc_size
- 1);
1205 skip
= phba
->nvmeio_trc_output_idx
;
1207 len
+= snprintf(buf
+ len
, size
- len
,
1208 "%s IO Trace %s: next_idx %d skip %d size %d\n",
1209 (phba
->nvmet_support
? "NVME" : "NVMET"),
1210 (state
? "Enabled" : "Disabled"),
1211 index
, skip
, phba
->nvmeio_trc_size
);
1213 if (!phba
->nvmeio_trc
|| state
)
1216 /* trace MUST bhe off to continue */
1218 for (i
= index
; i
< phba
->nvmeio_trc_size
; i
++) {
1223 dtp
= phba
->nvmeio_trc
+ i
;
1224 phba
->nvmeio_trc_output_idx
++;
1229 len
+= snprintf(buf
+ len
, size
- len
, dtp
->fmt
,
1230 dtp
->data1
, dtp
->data2
, dtp
->data3
);
1232 if (phba
->nvmeio_trc_output_idx
>= phba
->nvmeio_trc_size
) {
1233 phba
->nvmeio_trc_output_idx
= 0;
1234 len
+= snprintf(buf
+ len
, size
- len
,
1235 "Trace Complete\n");
1239 if (len
>= (size
- LPFC_DEBUG_OUT_LINE_SZ
)) {
1240 len
+= snprintf(buf
+ len
, size
- len
,
1241 "Trace Continue (%d of %d)\n",
1242 phba
->nvmeio_trc_output_idx
,
1243 phba
->nvmeio_trc_size
);
1247 for (i
= 0; i
< index
; i
++) {
1252 dtp
= phba
->nvmeio_trc
+ i
;
1253 phba
->nvmeio_trc_output_idx
++;
1258 len
+= snprintf(buf
+ len
, size
- len
, dtp
->fmt
,
1259 dtp
->data1
, dtp
->data2
, dtp
->data3
);
1261 if (phba
->nvmeio_trc_output_idx
>= phba
->nvmeio_trc_size
) {
1262 phba
->nvmeio_trc_output_idx
= 0;
1263 len
+= snprintf(buf
+ len
, size
- len
,
1264 "Trace Complete\n");
1268 if (len
>= (size
- LPFC_DEBUG_OUT_LINE_SZ
)) {
1269 len
+= snprintf(buf
+ len
, size
- len
,
1270 "Trace Continue (%d of %d)\n",
1271 phba
->nvmeio_trc_output_idx
,
1272 phba
->nvmeio_trc_size
);
1277 len
+= snprintf(buf
+ len
, size
- len
,
1284 * lpfc_debugfs_cpucheck_data - Dump target node list to a buffer
1285 * @vport: The vport to gather target node info from.
1286 * @buf: The buffer to dump log into.
1287 * @size: The maximum amount of data to process.
1290 * This routine dumps the NVME statistics associated with @vport
1293 * This routine returns the amount of bytes that were dumped into @buf and will
1297 lpfc_debugfs_cpucheck_data(struct lpfc_vport
*vport
, char *buf
, int size
)
1299 struct lpfc_hba
*phba
= vport
->phba
;
1302 uint32_t tot_xmt
= 0;
1303 uint32_t tot_rcv
= 0;
1304 uint32_t tot_cmpl
= 0;
1305 uint32_t tot_ccmpl
= 0;
1307 if (phba
->nvmet_support
== 0) {
1308 /* NVME Initiator */
1309 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
1311 (phba
->cpucheck_on
& LPFC_CHECK_NVME_IO
?
1312 "Enabled" : "Disabled"));
1313 for (i
= 0; i
< phba
->sli4_hba
.num_present_cpu
; i
++) {
1314 if (i
>= LPFC_CHECK_CPU_CNT
)
1316 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
1317 "%02d: xmit x%08x cmpl x%08x\n",
1318 i
, phba
->cpucheck_xmt_io
[i
],
1319 phba
->cpucheck_cmpl_io
[i
]);
1320 tot_xmt
+= phba
->cpucheck_xmt_io
[i
];
1321 tot_cmpl
+= phba
->cpucheck_cmpl_io
[i
];
1323 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
1324 "tot:xmit x%08x cmpl x%08x\n",
1330 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
1332 (phba
->cpucheck_on
& LPFC_CHECK_NVMET_IO
?
1333 "IO Enabled - " : "IO Disabled - "));
1334 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
1336 (phba
->cpucheck_on
& LPFC_CHECK_NVMET_RCV
?
1337 "Rcv Enabled\n" : "Rcv Disabled\n"));
1338 for (i
= 0; i
< phba
->sli4_hba
.num_present_cpu
; i
++) {
1339 if (i
>= LPFC_CHECK_CPU_CNT
)
1341 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
1342 "%02d: xmit x%08x ccmpl x%08x "
1343 "cmpl x%08x rcv x%08x\n",
1344 i
, phba
->cpucheck_xmt_io
[i
],
1345 phba
->cpucheck_ccmpl_io
[i
],
1346 phba
->cpucheck_cmpl_io
[i
],
1347 phba
->cpucheck_rcv_io
[i
]);
1348 tot_xmt
+= phba
->cpucheck_xmt_io
[i
];
1349 tot_rcv
+= phba
->cpucheck_rcv_io
[i
];
1350 tot_cmpl
+= phba
->cpucheck_cmpl_io
[i
];
1351 tot_ccmpl
+= phba
->cpucheck_ccmpl_io
[i
];
1353 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
1354 "tot:xmit x%08x ccmpl x%08x cmpl x%08x rcv x%08x\n",
1355 tot_xmt
, tot_ccmpl
, tot_cmpl
, tot_rcv
);
1362 * lpfc_debugfs_disc_trc - Store discovery trace log
1363 * @vport: The vport to associate this trace string with for retrieval.
1364 * @mask: Log entry classification.
1365 * @fmt: Format string to be displayed when dumping the log.
1366 * @data1: 1st data parameter to be applied to @fmt.
1367 * @data2: 2nd data parameter to be applied to @fmt.
1368 * @data3: 3rd data parameter to be applied to @fmt.
1371 * This routine is used by the driver code to add a debugfs log entry to the
1372 * discovery trace buffer associated with @vport. Only entries with a @mask that
1373 * match the current debugfs discovery mask will be saved. Entries that do not
1374 * match will be thrown away. @fmt, @data1, @data2, and @data3 are used like
1375 * printf when displaying the log.
1378 lpfc_debugfs_disc_trc(struct lpfc_vport
*vport
, int mask
, char *fmt
,
1379 uint32_t data1
, uint32_t data2
, uint32_t data3
)
1381 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
1382 struct lpfc_debugfs_trc
*dtp
;
1385 if (!(lpfc_debugfs_mask_disc_trc
& mask
))
1388 if (!lpfc_debugfs_enable
|| !lpfc_debugfs_max_disc_trc
||
1389 !vport
|| !vport
->disc_trc
)
1392 index
= atomic_inc_return(&vport
->disc_trc_cnt
) &
1393 (lpfc_debugfs_max_disc_trc
- 1);
1394 dtp
= vport
->disc_trc
+ index
;
1399 dtp
->seq_cnt
= atomic_inc_return(&lpfc_debugfs_seq_trc_cnt
);
1406 * lpfc_debugfs_slow_ring_trc - Store slow ring trace log
1407 * @phba: The phba to associate this trace string with for retrieval.
1408 * @fmt: Format string to be displayed when dumping the log.
1409 * @data1: 1st data parameter to be applied to @fmt.
1410 * @data2: 2nd data parameter to be applied to @fmt.
1411 * @data3: 3rd data parameter to be applied to @fmt.
1414 * This routine is used by the driver code to add a debugfs log entry to the
1415 * discovery trace buffer associated with @vport. @fmt, @data1, @data2, and
1416 * @data3 are used like printf when displaying the log.
1419 lpfc_debugfs_slow_ring_trc(struct lpfc_hba
*phba
, char *fmt
,
1420 uint32_t data1
, uint32_t data2
, uint32_t data3
)
1422 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
1423 struct lpfc_debugfs_trc
*dtp
;
1426 if (!lpfc_debugfs_enable
|| !lpfc_debugfs_max_slow_ring_trc
||
1427 !phba
|| !phba
->slow_ring_trc
)
1430 index
= atomic_inc_return(&phba
->slow_ring_trc_cnt
) &
1431 (lpfc_debugfs_max_slow_ring_trc
- 1);
1432 dtp
= phba
->slow_ring_trc
+ index
;
1437 dtp
->seq_cnt
= atomic_inc_return(&lpfc_debugfs_seq_trc_cnt
);
1444 * lpfc_debugfs_nvme_trc - Store NVME/NVMET trace log
1445 * @phba: The phba to associate this trace string with for retrieval.
1446 * @fmt: Format string to be displayed when dumping the log.
1447 * @data1: 1st data parameter to be applied to @fmt.
1448 * @data2: 2nd data parameter to be applied to @fmt.
1449 * @data3: 3rd data parameter to be applied to @fmt.
1452 * This routine is used by the driver code to add a debugfs log entry to the
1453 * nvme trace buffer associated with @phba. @fmt, @data1, @data2, and
1454 * @data3 are used like printf when displaying the log.
1457 lpfc_debugfs_nvme_trc(struct lpfc_hba
*phba
, char *fmt
,
1458 uint16_t data1
, uint16_t data2
, uint32_t data3
)
1460 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
1461 struct lpfc_debugfs_nvmeio_trc
*dtp
;
1464 if (!phba
->nvmeio_trc_on
|| !phba
->nvmeio_trc
)
1467 index
= atomic_inc_return(&phba
->nvmeio_trc_cnt
) &
1468 (phba
->nvmeio_trc_size
- 1);
1469 dtp
= phba
->nvmeio_trc
+ index
;
1477 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
1479 * lpfc_debugfs_disc_trc_open - Open the discovery trace log
1480 * @inode: The inode pointer that contains a vport pointer.
1481 * @file: The file pointer to attach the log output.
1484 * This routine is the entry point for the debugfs open file operation. It gets
1485 * the vport from the i_private field in @inode, allocates the necessary buffer
1486 * for the log, fills the buffer from the in-memory log for this vport, and then
1487 * returns a pointer to that log in the private_data field in @file.
1490 * This function returns zero if successful. On error it will return a negative
1494 lpfc_debugfs_disc_trc_open(struct inode
*inode
, struct file
*file
)
1496 struct lpfc_vport
*vport
= inode
->i_private
;
1497 struct lpfc_debug
*debug
;
1501 if (!lpfc_debugfs_max_disc_trc
) {
1506 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
1510 /* Round to page boundary */
1511 size
= (lpfc_debugfs_max_disc_trc
* LPFC_DEBUG_TRC_ENTRY_SIZE
);
1512 size
= PAGE_ALIGN(size
);
1514 debug
->buffer
= kmalloc(size
, GFP_KERNEL
);
1515 if (!debug
->buffer
) {
1520 debug
->len
= lpfc_debugfs_disc_trc_data(vport
, debug
->buffer
, size
);
1521 file
->private_data
= debug
;
1529 * lpfc_debugfs_slow_ring_trc_open - Open the Slow Ring trace log
1530 * @inode: The inode pointer that contains a vport pointer.
1531 * @file: The file pointer to attach the log output.
1534 * This routine is the entry point for the debugfs open file operation. It gets
1535 * the vport from the i_private field in @inode, allocates the necessary buffer
1536 * for the log, fills the buffer from the in-memory log for this vport, and then
1537 * returns a pointer to that log in the private_data field in @file.
1540 * This function returns zero if successful. On error it will return a negative
1544 lpfc_debugfs_slow_ring_trc_open(struct inode
*inode
, struct file
*file
)
1546 struct lpfc_hba
*phba
= inode
->i_private
;
1547 struct lpfc_debug
*debug
;
1551 if (!lpfc_debugfs_max_slow_ring_trc
) {
1556 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
1560 /* Round to page boundary */
1561 size
= (lpfc_debugfs_max_slow_ring_trc
* LPFC_DEBUG_TRC_ENTRY_SIZE
);
1562 size
= PAGE_ALIGN(size
);
1564 debug
->buffer
= kmalloc(size
, GFP_KERNEL
);
1565 if (!debug
->buffer
) {
1570 debug
->len
= lpfc_debugfs_slow_ring_trc_data(phba
, debug
->buffer
, size
);
1571 file
->private_data
= debug
;
1579 * lpfc_debugfs_hbqinfo_open - Open the hbqinfo debugfs buffer
1580 * @inode: The inode pointer that contains a vport pointer.
1581 * @file: The file pointer to attach the log output.
1584 * This routine is the entry point for the debugfs open file operation. It gets
1585 * the vport from the i_private field in @inode, allocates the necessary buffer
1586 * for the log, fills the buffer from the in-memory log for this vport, and then
1587 * returns a pointer to that log in the private_data field in @file.
1590 * This function returns zero if successful. On error it will return a negative
1594 lpfc_debugfs_hbqinfo_open(struct inode
*inode
, struct file
*file
)
1596 struct lpfc_hba
*phba
= inode
->i_private
;
1597 struct lpfc_debug
*debug
;
1600 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
1604 /* Round to page boundary */
1605 debug
->buffer
= kmalloc(LPFC_HBQINFO_SIZE
, GFP_KERNEL
);
1606 if (!debug
->buffer
) {
1611 debug
->len
= lpfc_debugfs_hbqinfo_data(phba
, debug
->buffer
,
1613 file
->private_data
= debug
;
1621 * lpfc_debugfs_dumpHBASlim_open - Open the Dump HBA SLIM debugfs buffer
1622 * @inode: The inode pointer that contains a vport pointer.
1623 * @file: The file pointer to attach the log output.
1626 * This routine is the entry point for the debugfs open file operation. It gets
1627 * the vport from the i_private field in @inode, allocates the necessary buffer
1628 * for the log, fills the buffer from the in-memory log for this vport, and then
1629 * returns a pointer to that log in the private_data field in @file.
1632 * This function returns zero if successful. On error it will return a negative
1636 lpfc_debugfs_dumpHBASlim_open(struct inode
*inode
, struct file
*file
)
1638 struct lpfc_hba
*phba
= inode
->i_private
;
1639 struct lpfc_debug
*debug
;
1642 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
1646 /* Round to page boundary */
1647 debug
->buffer
= kmalloc(LPFC_DUMPHBASLIM_SIZE
, GFP_KERNEL
);
1648 if (!debug
->buffer
) {
1653 debug
->len
= lpfc_debugfs_dumpHBASlim_data(phba
, debug
->buffer
,
1654 LPFC_DUMPHBASLIM_SIZE
);
1655 file
->private_data
= debug
;
1663 * lpfc_debugfs_dumpHostSlim_open - Open the Dump Host SLIM debugfs buffer
1664 * @inode: The inode pointer that contains a vport pointer.
1665 * @file: The file pointer to attach the log output.
1668 * This routine is the entry point for the debugfs open file operation. It gets
1669 * the vport from the i_private field in @inode, allocates the necessary buffer
1670 * for the log, fills the buffer from the in-memory log for this vport, and then
1671 * returns a pointer to that log in the private_data field in @file.
1674 * This function returns zero if successful. On error it will return a negative
1678 lpfc_debugfs_dumpHostSlim_open(struct inode
*inode
, struct file
*file
)
1680 struct lpfc_hba
*phba
= inode
->i_private
;
1681 struct lpfc_debug
*debug
;
1684 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
1688 /* Round to page boundary */
1689 debug
->buffer
= kmalloc(LPFC_DUMPHOSTSLIM_SIZE
, GFP_KERNEL
);
1690 if (!debug
->buffer
) {
1695 debug
->len
= lpfc_debugfs_dumpHostSlim_data(phba
, debug
->buffer
,
1696 LPFC_DUMPHOSTSLIM_SIZE
);
1697 file
->private_data
= debug
;
1705 lpfc_debugfs_dumpData_open(struct inode
*inode
, struct file
*file
)
1707 struct lpfc_debug
*debug
;
1710 if (!_dump_buf_data
)
1713 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
1717 /* Round to page boundary */
1718 pr_err("9059 BLKGRD: %s: _dump_buf_data=0x%p\n",
1719 __func__
, _dump_buf_data
);
1720 debug
->buffer
= _dump_buf_data
;
1721 if (!debug
->buffer
) {
1726 debug
->len
= (1 << _dump_buf_data_order
) << PAGE_SHIFT
;
1727 file
->private_data
= debug
;
1735 lpfc_debugfs_dumpDif_open(struct inode
*inode
, struct file
*file
)
1737 struct lpfc_debug
*debug
;
1743 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
1747 /* Round to page boundary */
1748 pr_err("9060 BLKGRD: %s: _dump_buf_dif=0x%p file=%pD\n",
1749 __func__
, _dump_buf_dif
, file
);
1750 debug
->buffer
= _dump_buf_dif
;
1751 if (!debug
->buffer
) {
1756 debug
->len
= (1 << _dump_buf_dif_order
) << PAGE_SHIFT
;
1757 file
->private_data
= debug
;
1765 lpfc_debugfs_dumpDataDif_write(struct file
*file
, const char __user
*buf
,
1766 size_t nbytes
, loff_t
*ppos
)
1769 * The Data/DIF buffers only save one failing IO
1770 * The write op is used as a reset mechanism after an IO has
1771 * already been saved to the next one can be saved
1773 spin_lock(&_dump_buf_lock
);
1775 memset((void *)_dump_buf_data
, 0,
1776 ((1 << PAGE_SHIFT
) << _dump_buf_data_order
));
1777 memset((void *)_dump_buf_dif
, 0,
1778 ((1 << PAGE_SHIFT
) << _dump_buf_dif_order
));
1782 spin_unlock(&_dump_buf_lock
);
1788 lpfc_debugfs_dif_err_read(struct file
*file
, char __user
*buf
,
1789 size_t nbytes
, loff_t
*ppos
)
1791 struct dentry
*dent
= file
->f_path
.dentry
;
1792 struct lpfc_hba
*phba
= file
->private_data
;
1797 if (dent
== phba
->debug_writeGuard
)
1798 cnt
= snprintf(cbuf
, 32, "%u\n", phba
->lpfc_injerr_wgrd_cnt
);
1799 else if (dent
== phba
->debug_writeApp
)
1800 cnt
= snprintf(cbuf
, 32, "%u\n", phba
->lpfc_injerr_wapp_cnt
);
1801 else if (dent
== phba
->debug_writeRef
)
1802 cnt
= snprintf(cbuf
, 32, "%u\n", phba
->lpfc_injerr_wref_cnt
);
1803 else if (dent
== phba
->debug_readGuard
)
1804 cnt
= snprintf(cbuf
, 32, "%u\n", phba
->lpfc_injerr_rgrd_cnt
);
1805 else if (dent
== phba
->debug_readApp
)
1806 cnt
= snprintf(cbuf
, 32, "%u\n", phba
->lpfc_injerr_rapp_cnt
);
1807 else if (dent
== phba
->debug_readRef
)
1808 cnt
= snprintf(cbuf
, 32, "%u\n", phba
->lpfc_injerr_rref_cnt
);
1809 else if (dent
== phba
->debug_InjErrNPortID
)
1810 cnt
= snprintf(cbuf
, 32, "0x%06x\n", phba
->lpfc_injerr_nportid
);
1811 else if (dent
== phba
->debug_InjErrWWPN
) {
1812 memcpy(&tmp
, &phba
->lpfc_injerr_wwpn
, sizeof(struct lpfc_name
));
1813 tmp
= cpu_to_be64(tmp
);
1814 cnt
= snprintf(cbuf
, 32, "0x%016llx\n", tmp
);
1815 } else if (dent
== phba
->debug_InjErrLBA
) {
1816 if (phba
->lpfc_injerr_lba
== (sector_t
)(-1))
1817 cnt
= snprintf(cbuf
, 32, "off\n");
1819 cnt
= snprintf(cbuf
, 32, "0x%llx\n",
1820 (uint64_t) phba
->lpfc_injerr_lba
);
1822 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
1823 "0547 Unknown debugfs error injection entry\n");
1825 return simple_read_from_buffer(buf
, nbytes
, ppos
, &cbuf
, cnt
);
1829 lpfc_debugfs_dif_err_write(struct file
*file
, const char __user
*buf
,
1830 size_t nbytes
, loff_t
*ppos
)
1832 struct dentry
*dent
= file
->f_path
.dentry
;
1833 struct lpfc_hba
*phba
= file
->private_data
;
1838 memset(dstbuf
, 0, 33);
1839 size
= (nbytes
< 32) ? nbytes
: 32;
1840 if (copy_from_user(dstbuf
, buf
, size
))
1843 if (dent
== phba
->debug_InjErrLBA
) {
1844 if ((buf
[0] == 'o') && (buf
[1] == 'f') && (buf
[2] == 'f'))
1845 tmp
= (uint64_t)(-1);
1848 if ((tmp
== 0) && (kstrtoull(dstbuf
, 0, &tmp
)))
1851 if (dent
== phba
->debug_writeGuard
)
1852 phba
->lpfc_injerr_wgrd_cnt
= (uint32_t)tmp
;
1853 else if (dent
== phba
->debug_writeApp
)
1854 phba
->lpfc_injerr_wapp_cnt
= (uint32_t)tmp
;
1855 else if (dent
== phba
->debug_writeRef
)
1856 phba
->lpfc_injerr_wref_cnt
= (uint32_t)tmp
;
1857 else if (dent
== phba
->debug_readGuard
)
1858 phba
->lpfc_injerr_rgrd_cnt
= (uint32_t)tmp
;
1859 else if (dent
== phba
->debug_readApp
)
1860 phba
->lpfc_injerr_rapp_cnt
= (uint32_t)tmp
;
1861 else if (dent
== phba
->debug_readRef
)
1862 phba
->lpfc_injerr_rref_cnt
= (uint32_t)tmp
;
1863 else if (dent
== phba
->debug_InjErrLBA
)
1864 phba
->lpfc_injerr_lba
= (sector_t
)tmp
;
1865 else if (dent
== phba
->debug_InjErrNPortID
)
1866 phba
->lpfc_injerr_nportid
= (uint32_t)(tmp
& Mask_DID
);
1867 else if (dent
== phba
->debug_InjErrWWPN
) {
1868 tmp
= cpu_to_be64(tmp
);
1869 memcpy(&phba
->lpfc_injerr_wwpn
, &tmp
, sizeof(struct lpfc_name
));
1871 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
1872 "0548 Unknown debugfs error injection entry\n");
1878 lpfc_debugfs_dif_err_release(struct inode
*inode
, struct file
*file
)
1884 * lpfc_debugfs_nodelist_open - Open the nodelist debugfs file
1885 * @inode: The inode pointer that contains a vport pointer.
1886 * @file: The file pointer to attach the log output.
1889 * This routine is the entry point for the debugfs open file operation. It gets
1890 * the vport from the i_private field in @inode, allocates the necessary buffer
1891 * for the log, fills the buffer from the in-memory log for this vport, and then
1892 * returns a pointer to that log in the private_data field in @file.
1895 * This function returns zero if successful. On error it will return a negative
1899 lpfc_debugfs_nodelist_open(struct inode
*inode
, struct file
*file
)
1901 struct lpfc_vport
*vport
= inode
->i_private
;
1902 struct lpfc_debug
*debug
;
1905 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
1909 /* Round to page boundary */
1910 debug
->buffer
= kmalloc(LPFC_NODELIST_SIZE
, GFP_KERNEL
);
1911 if (!debug
->buffer
) {
1916 debug
->len
= lpfc_debugfs_nodelist_data(vport
, debug
->buffer
,
1917 LPFC_NODELIST_SIZE
);
1918 file
->private_data
= debug
;
1926 * lpfc_debugfs_lseek - Seek through a debugfs file
1927 * @file: The file pointer to seek through.
1928 * @off: The offset to seek to or the amount to seek by.
1929 * @whence: Indicates how to seek.
1932 * This routine is the entry point for the debugfs lseek file operation. The
1933 * @whence parameter indicates whether @off is the offset to directly seek to,
1934 * or if it is a value to seek forward or reverse by. This function figures out
1935 * what the new offset of the debugfs file will be and assigns that value to the
1936 * f_pos field of @file.
1939 * This function returns the new offset if successful and returns a negative
1940 * error if unable to process the seek.
1943 lpfc_debugfs_lseek(struct file
*file
, loff_t off
, int whence
)
1945 struct lpfc_debug
*debug
= file
->private_data
;
1946 return fixed_size_llseek(file
, off
, whence
, debug
->len
);
1950 * lpfc_debugfs_read - Read a debugfs file
1951 * @file: The file pointer to read from.
1952 * @buf: The buffer to copy the data to.
1953 * @nbytes: The number of bytes to read.
1954 * @ppos: The position in the file to start reading from.
1957 * This routine reads data from from the buffer indicated in the private_data
1958 * field of @file. It will start reading at @ppos and copy up to @nbytes of
1962 * This function returns the amount of data that was read (this could be less
1963 * than @nbytes if the end of the file was reached) or a negative error value.
1966 lpfc_debugfs_read(struct file
*file
, char __user
*buf
,
1967 size_t nbytes
, loff_t
*ppos
)
1969 struct lpfc_debug
*debug
= file
->private_data
;
1971 return simple_read_from_buffer(buf
, nbytes
, ppos
, debug
->buffer
,
1976 * lpfc_debugfs_release - Release the buffer used to store debugfs file data
1977 * @inode: The inode pointer that contains a vport pointer. (unused)
1978 * @file: The file pointer that contains the buffer to release.
1981 * This routine frees the buffer that was allocated when the debugfs file was
1985 * This function returns zero.
1988 lpfc_debugfs_release(struct inode
*inode
, struct file
*file
)
1990 struct lpfc_debug
*debug
= file
->private_data
;
1992 kfree(debug
->buffer
);
1999 lpfc_debugfs_dumpDataDif_release(struct inode
*inode
, struct file
*file
)
2001 struct lpfc_debug
*debug
= file
->private_data
;
2003 debug
->buffer
= NULL
;
2011 lpfc_debugfs_nvmestat_open(struct inode
*inode
, struct file
*file
)
2013 struct lpfc_vport
*vport
= inode
->i_private
;
2014 struct lpfc_debug
*debug
;
2017 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
2021 /* Round to page boundary */
2022 debug
->buffer
= kmalloc(LPFC_NVMESTAT_SIZE
, GFP_KERNEL
);
2023 if (!debug
->buffer
) {
2028 debug
->len
= lpfc_debugfs_nvmestat_data(vport
, debug
->buffer
,
2029 LPFC_NVMESTAT_SIZE
);
2031 debug
->i_private
= inode
->i_private
;
2032 file
->private_data
= debug
;
2040 lpfc_debugfs_nvmestat_write(struct file
*file
, const char __user
*buf
,
2041 size_t nbytes
, loff_t
*ppos
)
2043 struct lpfc_debug
*debug
= file
->private_data
;
2044 struct lpfc_vport
*vport
= (struct lpfc_vport
*)debug
->i_private
;
2045 struct lpfc_hba
*phba
= vport
->phba
;
2046 struct lpfc_nvmet_tgtport
*tgtp
;
2050 if (!phba
->targetport
)
2056 memset(mybuf
, 0, sizeof(mybuf
));
2058 if (copy_from_user(mybuf
, buf
, nbytes
))
2062 tgtp
= (struct lpfc_nvmet_tgtport
*)phba
->targetport
->private;
2063 if ((strncmp(pbuf
, "reset", strlen("reset")) == 0) ||
2064 (strncmp(pbuf
, "zero", strlen("zero")) == 0)) {
2065 atomic_set(&tgtp
->rcv_ls_req_in
, 0);
2066 atomic_set(&tgtp
->rcv_ls_req_out
, 0);
2067 atomic_set(&tgtp
->rcv_ls_req_drop
, 0);
2068 atomic_set(&tgtp
->xmt_ls_abort
, 0);
2069 atomic_set(&tgtp
->xmt_ls_abort_cmpl
, 0);
2070 atomic_set(&tgtp
->xmt_ls_rsp
, 0);
2071 atomic_set(&tgtp
->xmt_ls_drop
, 0);
2072 atomic_set(&tgtp
->xmt_ls_rsp_error
, 0);
2073 atomic_set(&tgtp
->xmt_ls_rsp_cmpl
, 0);
2075 atomic_set(&tgtp
->rcv_fcp_cmd_in
, 0);
2076 atomic_set(&tgtp
->rcv_fcp_cmd_out
, 0);
2077 atomic_set(&tgtp
->rcv_fcp_cmd_drop
, 0);
2078 atomic_set(&tgtp
->xmt_fcp_drop
, 0);
2079 atomic_set(&tgtp
->xmt_fcp_read_rsp
, 0);
2080 atomic_set(&tgtp
->xmt_fcp_read
, 0);
2081 atomic_set(&tgtp
->xmt_fcp_write
, 0);
2082 atomic_set(&tgtp
->xmt_fcp_rsp
, 0);
2083 atomic_set(&tgtp
->xmt_fcp_release
, 0);
2084 atomic_set(&tgtp
->xmt_fcp_rsp_cmpl
, 0);
2085 atomic_set(&tgtp
->xmt_fcp_rsp_error
, 0);
2086 atomic_set(&tgtp
->xmt_fcp_rsp_drop
, 0);
2088 atomic_set(&tgtp
->xmt_fcp_abort
, 0);
2089 atomic_set(&tgtp
->xmt_fcp_abort_cmpl
, 0);
2090 atomic_set(&tgtp
->xmt_abort_sol
, 0);
2091 atomic_set(&tgtp
->xmt_abort_unsol
, 0);
2092 atomic_set(&tgtp
->xmt_abort_rsp
, 0);
2093 atomic_set(&tgtp
->xmt_abort_rsp_error
, 0);
2099 lpfc_debugfs_nvmektime_open(struct inode
*inode
, struct file
*file
)
2101 struct lpfc_vport
*vport
= inode
->i_private
;
2102 struct lpfc_debug
*debug
;
2105 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
2109 /* Round to page boundary */
2110 debug
->buffer
= kmalloc(LPFC_NVMEKTIME_SIZE
, GFP_KERNEL
);
2111 if (!debug
->buffer
) {
2116 debug
->len
= lpfc_debugfs_nvmektime_data(vport
, debug
->buffer
,
2117 LPFC_NVMEKTIME_SIZE
);
2119 debug
->i_private
= inode
->i_private
;
2120 file
->private_data
= debug
;
2128 lpfc_debugfs_nvmektime_write(struct file
*file
, const char __user
*buf
,
2129 size_t nbytes
, loff_t
*ppos
)
2131 struct lpfc_debug
*debug
= file
->private_data
;
2132 struct lpfc_vport
*vport
= (struct lpfc_vport
*)debug
->i_private
;
2133 struct lpfc_hba
*phba
= vport
->phba
;
2140 memset(mybuf
, 0, sizeof(mybuf
));
2142 if (copy_from_user(mybuf
, buf
, nbytes
))
2146 if ((strncmp(pbuf
, "on", sizeof("on") - 1) == 0)) {
2147 phba
->ktime_data_samples
= 0;
2148 phba
->ktime_status_samples
= 0;
2149 phba
->ktime_seg1_total
= 0;
2150 phba
->ktime_seg1_max
= 0;
2151 phba
->ktime_seg1_min
= 0xffffffff;
2152 phba
->ktime_seg2_total
= 0;
2153 phba
->ktime_seg2_max
= 0;
2154 phba
->ktime_seg2_min
= 0xffffffff;
2155 phba
->ktime_seg3_total
= 0;
2156 phba
->ktime_seg3_max
= 0;
2157 phba
->ktime_seg3_min
= 0xffffffff;
2158 phba
->ktime_seg4_total
= 0;
2159 phba
->ktime_seg4_max
= 0;
2160 phba
->ktime_seg4_min
= 0xffffffff;
2161 phba
->ktime_seg5_total
= 0;
2162 phba
->ktime_seg5_max
= 0;
2163 phba
->ktime_seg5_min
= 0xffffffff;
2164 phba
->ktime_seg6_total
= 0;
2165 phba
->ktime_seg6_max
= 0;
2166 phba
->ktime_seg6_min
= 0xffffffff;
2167 phba
->ktime_seg7_total
= 0;
2168 phba
->ktime_seg7_max
= 0;
2169 phba
->ktime_seg7_min
= 0xffffffff;
2170 phba
->ktime_seg8_total
= 0;
2171 phba
->ktime_seg8_max
= 0;
2172 phba
->ktime_seg8_min
= 0xffffffff;
2173 phba
->ktime_seg9_total
= 0;
2174 phba
->ktime_seg9_max
= 0;
2175 phba
->ktime_seg9_min
= 0xffffffff;
2176 phba
->ktime_seg10_total
= 0;
2177 phba
->ktime_seg10_max
= 0;
2178 phba
->ktime_seg10_min
= 0xffffffff;
2181 return strlen(pbuf
);
2182 } else if ((strncmp(pbuf
, "off",
2183 sizeof("off") - 1) == 0)) {
2185 return strlen(pbuf
);
2186 } else if ((strncmp(pbuf
, "zero",
2187 sizeof("zero") - 1) == 0)) {
2188 phba
->ktime_data_samples
= 0;
2189 phba
->ktime_status_samples
= 0;
2190 phba
->ktime_seg1_total
= 0;
2191 phba
->ktime_seg1_max
= 0;
2192 phba
->ktime_seg1_min
= 0xffffffff;
2193 phba
->ktime_seg2_total
= 0;
2194 phba
->ktime_seg2_max
= 0;
2195 phba
->ktime_seg2_min
= 0xffffffff;
2196 phba
->ktime_seg3_total
= 0;
2197 phba
->ktime_seg3_max
= 0;
2198 phba
->ktime_seg3_min
= 0xffffffff;
2199 phba
->ktime_seg4_total
= 0;
2200 phba
->ktime_seg4_max
= 0;
2201 phba
->ktime_seg4_min
= 0xffffffff;
2202 phba
->ktime_seg5_total
= 0;
2203 phba
->ktime_seg5_max
= 0;
2204 phba
->ktime_seg5_min
= 0xffffffff;
2205 phba
->ktime_seg6_total
= 0;
2206 phba
->ktime_seg6_max
= 0;
2207 phba
->ktime_seg6_min
= 0xffffffff;
2208 phba
->ktime_seg7_total
= 0;
2209 phba
->ktime_seg7_max
= 0;
2210 phba
->ktime_seg7_min
= 0xffffffff;
2211 phba
->ktime_seg8_total
= 0;
2212 phba
->ktime_seg8_max
= 0;
2213 phba
->ktime_seg8_min
= 0xffffffff;
2214 phba
->ktime_seg9_total
= 0;
2215 phba
->ktime_seg9_max
= 0;
2216 phba
->ktime_seg9_min
= 0xffffffff;
2217 phba
->ktime_seg10_total
= 0;
2218 phba
->ktime_seg10_max
= 0;
2219 phba
->ktime_seg10_min
= 0xffffffff;
2220 return strlen(pbuf
);
2226 lpfc_debugfs_nvmeio_trc_open(struct inode
*inode
, struct file
*file
)
2228 struct lpfc_hba
*phba
= inode
->i_private
;
2229 struct lpfc_debug
*debug
;
2232 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
2236 /* Round to page boundary */
2237 debug
->buffer
= kmalloc(LPFC_NVMEIO_TRC_SIZE
, GFP_KERNEL
);
2238 if (!debug
->buffer
) {
2243 debug
->len
= lpfc_debugfs_nvmeio_trc_data(phba
, debug
->buffer
,
2244 LPFC_NVMEIO_TRC_SIZE
);
2246 debug
->i_private
= inode
->i_private
;
2247 file
->private_data
= debug
;
2255 lpfc_debugfs_nvmeio_trc_write(struct file
*file
, const char __user
*buf
,
2256 size_t nbytes
, loff_t
*ppos
)
2258 struct lpfc_debug
*debug
= file
->private_data
;
2259 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
2268 memset(mybuf
, 0, sizeof(mybuf
));
2270 if (copy_from_user(mybuf
, buf
, nbytes
))
2274 if ((strncmp(pbuf
, "off", sizeof("off") - 1) == 0)) {
2275 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
2276 "0570 nvmeio_trc_off\n");
2277 phba
->nvmeio_trc_output_idx
= 0;
2278 phba
->nvmeio_trc_on
= 0;
2279 return strlen(pbuf
);
2280 } else if ((strncmp(pbuf
, "on", sizeof("on") - 1) == 0)) {
2281 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
2282 "0571 nvmeio_trc_on\n");
2283 phba
->nvmeio_trc_output_idx
= 0;
2284 phba
->nvmeio_trc_on
= 1;
2285 return strlen(pbuf
);
2288 /* We must be off to allocate the trace buffer */
2289 if (phba
->nvmeio_trc_on
!= 0)
2292 /* If not on or off, the parameter is the trace buffer size */
2293 i
= kstrtoul(pbuf
, 0, &sz
);
2296 phba
->nvmeio_trc_size
= (uint32_t)sz
;
2298 /* It must be a power of 2 - round down */
2305 if (phba
->nvmeio_trc_size
!= sz
)
2306 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
2307 "0572 nvmeio_trc_size changed to %ld\n",
2309 phba
->nvmeio_trc_size
= (uint32_t)sz
;
2311 /* If one previously exists, free it */
2312 kfree(phba
->nvmeio_trc
);
2314 /* Allocate new trace buffer and initialize */
2315 phba
->nvmeio_trc
= kzalloc((sizeof(struct lpfc_debugfs_nvmeio_trc
) *
2317 if (!phba
->nvmeio_trc
) {
2318 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
2319 "0573 Cannot create debugfs "
2320 "nvmeio_trc buffer\n");
2323 atomic_set(&phba
->nvmeio_trc_cnt
, 0);
2324 phba
->nvmeio_trc_on
= 0;
2325 phba
->nvmeio_trc_output_idx
= 0;
2327 return strlen(pbuf
);
2331 lpfc_debugfs_cpucheck_open(struct inode
*inode
, struct file
*file
)
2333 struct lpfc_vport
*vport
= inode
->i_private
;
2334 struct lpfc_debug
*debug
;
2337 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
2341 /* Round to page boundary */
2342 debug
->buffer
= kmalloc(LPFC_CPUCHECK_SIZE
, GFP_KERNEL
);
2343 if (!debug
->buffer
) {
2348 debug
->len
= lpfc_debugfs_cpucheck_data(vport
, debug
->buffer
,
2349 LPFC_NVMEKTIME_SIZE
);
2351 debug
->i_private
= inode
->i_private
;
2352 file
->private_data
= debug
;
2360 lpfc_debugfs_cpucheck_write(struct file
*file
, const char __user
*buf
,
2361 size_t nbytes
, loff_t
*ppos
)
2363 struct lpfc_debug
*debug
= file
->private_data
;
2364 struct lpfc_vport
*vport
= (struct lpfc_vport
*)debug
->i_private
;
2365 struct lpfc_hba
*phba
= vport
->phba
;
2373 memset(mybuf
, 0, sizeof(mybuf
));
2375 if (copy_from_user(mybuf
, buf
, nbytes
))
2379 if ((strncmp(pbuf
, "on", sizeof("on") - 1) == 0)) {
2380 if (phba
->nvmet_support
)
2381 phba
->cpucheck_on
|= LPFC_CHECK_NVMET_IO
;
2383 phba
->cpucheck_on
|= LPFC_CHECK_NVME_IO
;
2384 return strlen(pbuf
);
2385 } else if ((strncmp(pbuf
, "rcv",
2386 sizeof("rcv") - 1) == 0)) {
2387 if (phba
->nvmet_support
)
2388 phba
->cpucheck_on
|= LPFC_CHECK_NVMET_RCV
;
2391 return strlen(pbuf
);
2392 } else if ((strncmp(pbuf
, "off",
2393 sizeof("off") - 1) == 0)) {
2394 phba
->cpucheck_on
= LPFC_CHECK_OFF
;
2395 return strlen(pbuf
);
2396 } else if ((strncmp(pbuf
, "zero",
2397 sizeof("zero") - 1) == 0)) {
2398 for (i
= 0; i
< phba
->sli4_hba
.num_present_cpu
; i
++) {
2399 if (i
>= LPFC_CHECK_CPU_CNT
)
2401 phba
->cpucheck_rcv_io
[i
] = 0;
2402 phba
->cpucheck_xmt_io
[i
] = 0;
2403 phba
->cpucheck_cmpl_io
[i
] = 0;
2404 phba
->cpucheck_ccmpl_io
[i
] = 0;
2406 return strlen(pbuf
);
2412 * ---------------------------------
2413 * iDiag debugfs file access methods
2414 * ---------------------------------
2416 * All access methods are through the proper SLI4 PCI function's debugfs
2419 * /sys/kernel/debug/lpfc/fn<#>/iDiag
2423 * lpfc_idiag_cmd_get - Get and parse idiag debugfs comands from user space
2424 * @buf: The pointer to the user space buffer.
2425 * @nbytes: The number of bytes in the user space buffer.
2426 * @idiag_cmd: pointer to the idiag command struct.
2428 * This routine reads data from debugfs user space buffer and parses the
2429 * buffer for getting the idiag command and arguments. The while space in
2430 * between the set of data is used as the parsing separator.
2432 * This routine returns 0 when successful, it returns proper error code
2433 * back to the user space in error conditions.
2435 static int lpfc_idiag_cmd_get(const char __user
*buf
, size_t nbytes
,
2436 struct lpfc_idiag_cmd
*idiag_cmd
)
2439 char *pbuf
, *step_str
;
2443 memset(mybuf
, 0, sizeof(mybuf
));
2444 memset(idiag_cmd
, 0, sizeof(*idiag_cmd
));
2445 bsize
= min(nbytes
, (sizeof(mybuf
)-1));
2447 if (copy_from_user(mybuf
, buf
, bsize
))
2450 step_str
= strsep(&pbuf
, "\t ");
2452 /* The opcode must present */
2456 idiag_cmd
->opcode
= simple_strtol(step_str
, NULL
, 0);
2457 if (idiag_cmd
->opcode
== 0)
2460 for (i
= 0; i
< LPFC_IDIAG_CMD_DATA_SIZE
; i
++) {
2461 step_str
= strsep(&pbuf
, "\t ");
2464 idiag_cmd
->data
[i
] = simple_strtol(step_str
, NULL
, 0);
2470 * lpfc_idiag_open - idiag open debugfs
2471 * @inode: The inode pointer that contains a pointer to phba.
2472 * @file: The file pointer to attach the file operation.
2475 * This routine is the entry point for the debugfs open file operation. It
2476 * gets the reference to phba from the i_private field in @inode, it then
2477 * allocates buffer for the file operation, performs the necessary PCI config
2478 * space read into the allocated buffer according to the idiag user command
2479 * setup, and then returns a pointer to buffer in the private_data field in
2483 * This function returns zero if successful. On error it will return an
2484 * negative error value.
2487 lpfc_idiag_open(struct inode
*inode
, struct file
*file
)
2489 struct lpfc_debug
*debug
;
2491 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
2495 debug
->i_private
= inode
->i_private
;
2496 debug
->buffer
= NULL
;
2497 file
->private_data
= debug
;
2503 * lpfc_idiag_release - Release idiag access file operation
2504 * @inode: The inode pointer that contains a vport pointer. (unused)
2505 * @file: The file pointer that contains the buffer to release.
2508 * This routine is the generic release routine for the idiag access file
2509 * operation, it frees the buffer that was allocated when the debugfs file
2513 * This function returns zero.
2516 lpfc_idiag_release(struct inode
*inode
, struct file
*file
)
2518 struct lpfc_debug
*debug
= file
->private_data
;
2520 /* Free the buffers to the file operation */
2521 kfree(debug
->buffer
);
2528 * lpfc_idiag_cmd_release - Release idiag cmd access file operation
2529 * @inode: The inode pointer that contains a vport pointer. (unused)
2530 * @file: The file pointer that contains the buffer to release.
2533 * This routine frees the buffer that was allocated when the debugfs file
2534 * was opened. It also reset the fields in the idiag command struct in the
2535 * case of command for write operation.
2538 * This function returns zero.
2541 lpfc_idiag_cmd_release(struct inode
*inode
, struct file
*file
)
2543 struct lpfc_debug
*debug
= file
->private_data
;
2545 if (debug
->op
== LPFC_IDIAG_OP_WR
) {
2546 switch (idiag
.cmd
.opcode
) {
2547 case LPFC_IDIAG_CMD_PCICFG_WR
:
2548 case LPFC_IDIAG_CMD_PCICFG_ST
:
2549 case LPFC_IDIAG_CMD_PCICFG_CL
:
2550 case LPFC_IDIAG_CMD_QUEACC_WR
:
2551 case LPFC_IDIAG_CMD_QUEACC_ST
:
2552 case LPFC_IDIAG_CMD_QUEACC_CL
:
2553 memset(&idiag
, 0, sizeof(idiag
));
2560 /* Free the buffers to the file operation */
2561 kfree(debug
->buffer
);
2568 * lpfc_idiag_pcicfg_read - idiag debugfs read pcicfg
2569 * @file: The file pointer to read from.
2570 * @buf: The buffer to copy the data to.
2571 * @nbytes: The number of bytes to read.
2572 * @ppos: The position in the file to start reading from.
2575 * This routine reads data from the @phba pci config space according to the
2576 * idiag command, and copies to user @buf. Depending on the PCI config space
2577 * read command setup, it does either a single register read of a byte
2578 * (8 bits), a word (16 bits), or a dword (32 bits) or browsing through all
2579 * registers from the 4K extended PCI config space.
2582 * This function returns the amount of data that was read (this could be less
2583 * than @nbytes if the end of the file was reached) or a negative error value.
2586 lpfc_idiag_pcicfg_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
2589 struct lpfc_debug
*debug
= file
->private_data
;
2590 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
2591 int offset_label
, offset
, len
= 0, index
= LPFC_PCI_CFG_RD_SIZE
;
2594 struct pci_dev
*pdev
;
2599 pdev
= phba
->pcidev
;
2603 /* This is a user read operation */
2604 debug
->op
= LPFC_IDIAG_OP_RD
;
2607 debug
->buffer
= kmalloc(LPFC_PCI_CFG_SIZE
, GFP_KERNEL
);
2610 pbuffer
= debug
->buffer
;
2615 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_RD
) {
2616 where
= idiag
.cmd
.data
[IDIAG_PCICFG_WHERE_INDX
];
2617 count
= idiag
.cmd
.data
[IDIAG_PCICFG_COUNT_INDX
];
2621 /* Read single PCI config space register */
2623 case SIZE_U8
: /* byte (8 bits) */
2624 pci_read_config_byte(pdev
, where
, &u8val
);
2625 len
+= snprintf(pbuffer
+len
, LPFC_PCI_CFG_SIZE
-len
,
2626 "%03x: %02x\n", where
, u8val
);
2628 case SIZE_U16
: /* word (16 bits) */
2629 pci_read_config_word(pdev
, where
, &u16val
);
2630 len
+= snprintf(pbuffer
+len
, LPFC_PCI_CFG_SIZE
-len
,
2631 "%03x: %04x\n", where
, u16val
);
2633 case SIZE_U32
: /* double word (32 bits) */
2634 pci_read_config_dword(pdev
, where
, &u32val
);
2635 len
+= snprintf(pbuffer
+len
, LPFC_PCI_CFG_SIZE
-len
,
2636 "%03x: %08x\n", where
, u32val
);
2638 case LPFC_PCI_CFG_BROWSE
: /* browse all */
2646 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
2650 /* Browse all PCI config space registers */
2651 offset_label
= idiag
.offset
.last_rd
;
2652 offset
= offset_label
;
2654 /* Read PCI config space */
2655 len
+= snprintf(pbuffer
+len
, LPFC_PCI_CFG_SIZE
-len
,
2656 "%03x: ", offset_label
);
2658 pci_read_config_dword(pdev
, offset
, &u32val
);
2659 len
+= snprintf(pbuffer
+len
, LPFC_PCI_CFG_SIZE
-len
,
2661 offset
+= sizeof(uint32_t);
2662 if (offset
>= LPFC_PCI_CFG_SIZE
) {
2663 len
+= snprintf(pbuffer
+len
,
2664 LPFC_PCI_CFG_SIZE
-len
, "\n");
2667 index
-= sizeof(uint32_t);
2669 len
+= snprintf(pbuffer
+len
, LPFC_PCI_CFG_SIZE
-len
,
2671 else if (!(index
% (8 * sizeof(uint32_t)))) {
2672 offset_label
+= (8 * sizeof(uint32_t));
2673 len
+= snprintf(pbuffer
+len
, LPFC_PCI_CFG_SIZE
-len
,
2674 "\n%03x: ", offset_label
);
2678 /* Set up the offset for next portion of pci cfg read */
2680 idiag
.offset
.last_rd
+= LPFC_PCI_CFG_RD_SIZE
;
2681 if (idiag
.offset
.last_rd
>= LPFC_PCI_CFG_SIZE
)
2682 idiag
.offset
.last_rd
= 0;
2684 idiag
.offset
.last_rd
= 0;
2686 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
2690 * lpfc_idiag_pcicfg_write - Syntax check and set up idiag pcicfg commands
2691 * @file: The file pointer to read from.
2692 * @buf: The buffer to copy the user data from.
2693 * @nbytes: The number of bytes to get.
2694 * @ppos: The position in the file to start reading from.
2696 * This routine get the debugfs idiag command struct from user space and
2697 * then perform the syntax check for PCI config space read or write command
2698 * accordingly. In the case of PCI config space read command, it sets up
2699 * the command in the idiag command struct for the debugfs read operation.
2700 * In the case of PCI config space write operation, it executes the write
2701 * operation into the PCI config space accordingly.
2703 * It returns the @nbytges passing in from debugfs user space when successful.
2704 * In case of error conditions, it returns proper error code back to the user
2708 lpfc_idiag_pcicfg_write(struct file
*file
, const char __user
*buf
,
2709 size_t nbytes
, loff_t
*ppos
)
2711 struct lpfc_debug
*debug
= file
->private_data
;
2712 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
2713 uint32_t where
, value
, count
;
2717 struct pci_dev
*pdev
;
2720 pdev
= phba
->pcidev
;
2724 /* This is a user write operation */
2725 debug
->op
= LPFC_IDIAG_OP_WR
;
2727 rc
= lpfc_idiag_cmd_get(buf
, nbytes
, &idiag
.cmd
);
2731 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_RD
) {
2732 /* Sanity check on PCI config read command line arguments */
2733 if (rc
!= LPFC_PCI_CFG_RD_CMD_ARG
)
2735 /* Read command from PCI config space, set up command fields */
2736 where
= idiag
.cmd
.data
[IDIAG_PCICFG_WHERE_INDX
];
2737 count
= idiag
.cmd
.data
[IDIAG_PCICFG_COUNT_INDX
];
2738 if (count
== LPFC_PCI_CFG_BROWSE
) {
2739 if (where
% sizeof(uint32_t))
2741 /* Starting offset to browse */
2742 idiag
.offset
.last_rd
= where
;
2743 } else if ((count
!= sizeof(uint8_t)) &&
2744 (count
!= sizeof(uint16_t)) &&
2745 (count
!= sizeof(uint32_t)))
2747 if (count
== sizeof(uint8_t)) {
2748 if (where
> LPFC_PCI_CFG_SIZE
- sizeof(uint8_t))
2750 if (where
% sizeof(uint8_t))
2753 if (count
== sizeof(uint16_t)) {
2754 if (where
> LPFC_PCI_CFG_SIZE
- sizeof(uint16_t))
2756 if (where
% sizeof(uint16_t))
2759 if (count
== sizeof(uint32_t)) {
2760 if (where
> LPFC_PCI_CFG_SIZE
- sizeof(uint32_t))
2762 if (where
% sizeof(uint32_t))
2765 } else if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_WR
||
2766 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_ST
||
2767 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_CL
) {
2768 /* Sanity check on PCI config write command line arguments */
2769 if (rc
!= LPFC_PCI_CFG_WR_CMD_ARG
)
2771 /* Write command to PCI config space, read-modify-write */
2772 where
= idiag
.cmd
.data
[IDIAG_PCICFG_WHERE_INDX
];
2773 count
= idiag
.cmd
.data
[IDIAG_PCICFG_COUNT_INDX
];
2774 value
= idiag
.cmd
.data
[IDIAG_PCICFG_VALUE_INDX
];
2776 if ((count
!= sizeof(uint8_t)) &&
2777 (count
!= sizeof(uint16_t)) &&
2778 (count
!= sizeof(uint32_t)))
2780 if (count
== sizeof(uint8_t)) {
2781 if (where
> LPFC_PCI_CFG_SIZE
- sizeof(uint8_t))
2783 if (where
% sizeof(uint8_t))
2785 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_WR
)
2786 pci_write_config_byte(pdev
, where
,
2788 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_ST
) {
2789 rc
= pci_read_config_byte(pdev
, where
, &u8val
);
2791 u8val
|= (uint8_t)value
;
2792 pci_write_config_byte(pdev
, where
,
2796 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_CL
) {
2797 rc
= pci_read_config_byte(pdev
, where
, &u8val
);
2799 u8val
&= (uint8_t)(~value
);
2800 pci_write_config_byte(pdev
, where
,
2805 if (count
== sizeof(uint16_t)) {
2806 if (where
> LPFC_PCI_CFG_SIZE
- sizeof(uint16_t))
2808 if (where
% sizeof(uint16_t))
2810 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_WR
)
2811 pci_write_config_word(pdev
, where
,
2813 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_ST
) {
2814 rc
= pci_read_config_word(pdev
, where
, &u16val
);
2816 u16val
|= (uint16_t)value
;
2817 pci_write_config_word(pdev
, where
,
2821 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_CL
) {
2822 rc
= pci_read_config_word(pdev
, where
, &u16val
);
2824 u16val
&= (uint16_t)(~value
);
2825 pci_write_config_word(pdev
, where
,
2830 if (count
== sizeof(uint32_t)) {
2831 if (where
> LPFC_PCI_CFG_SIZE
- sizeof(uint32_t))
2833 if (where
% sizeof(uint32_t))
2835 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_WR
)
2836 pci_write_config_dword(pdev
, where
, value
);
2837 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_ST
) {
2838 rc
= pci_read_config_dword(pdev
, where
,
2842 pci_write_config_dword(pdev
, where
,
2846 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_CL
) {
2847 rc
= pci_read_config_dword(pdev
, where
,
2851 pci_write_config_dword(pdev
, where
,
2857 /* All other opecodes are illegal for now */
2862 memset(&idiag
, 0, sizeof(idiag
));
2867 * lpfc_idiag_baracc_read - idiag debugfs pci bar access read
2868 * @file: The file pointer to read from.
2869 * @buf: The buffer to copy the data to.
2870 * @nbytes: The number of bytes to read.
2871 * @ppos: The position in the file to start reading from.
2874 * This routine reads data from the @phba pci bar memory mapped space
2875 * according to the idiag command, and copies to user @buf.
2878 * This function returns the amount of data that was read (this could be less
2879 * than @nbytes if the end of the file was reached) or a negative error value.
2882 lpfc_idiag_baracc_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
2885 struct lpfc_debug
*debug
= file
->private_data
;
2886 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
2887 int offset_label
, offset
, offset_run
, len
= 0, index
;
2888 int bar_num
, acc_range
, bar_size
;
2890 void __iomem
*mem_mapped_bar
;
2892 struct pci_dev
*pdev
;
2895 pdev
= phba
->pcidev
;
2899 /* This is a user read operation */
2900 debug
->op
= LPFC_IDIAG_OP_RD
;
2903 debug
->buffer
= kmalloc(LPFC_PCI_BAR_RD_BUF_SIZE
, GFP_KERNEL
);
2906 pbuffer
= debug
->buffer
;
2911 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_RD
) {
2912 bar_num
= idiag
.cmd
.data
[IDIAG_BARACC_BAR_NUM_INDX
];
2913 offset
= idiag
.cmd
.data
[IDIAG_BARACC_OFF_SET_INDX
];
2914 acc_range
= idiag
.cmd
.data
[IDIAG_BARACC_ACC_MOD_INDX
];
2915 bar_size
= idiag
.cmd
.data
[IDIAG_BARACC_BAR_SZE_INDX
];
2922 if_type
= bf_get(lpfc_sli_intf_if_type
, &phba
->sli4_hba
.sli_intf
);
2923 if (if_type
== LPFC_SLI_INTF_IF_TYPE_0
) {
2924 if (bar_num
== IDIAG_BARACC_BAR_0
)
2925 mem_mapped_bar
= phba
->sli4_hba
.conf_regs_memmap_p
;
2926 else if (bar_num
== IDIAG_BARACC_BAR_1
)
2927 mem_mapped_bar
= phba
->sli4_hba
.ctrl_regs_memmap_p
;
2928 else if (bar_num
== IDIAG_BARACC_BAR_2
)
2929 mem_mapped_bar
= phba
->sli4_hba
.drbl_regs_memmap_p
;
2932 } else if (if_type
== LPFC_SLI_INTF_IF_TYPE_2
) {
2933 if (bar_num
== IDIAG_BARACC_BAR_0
)
2934 mem_mapped_bar
= phba
->sli4_hba
.conf_regs_memmap_p
;
2940 /* Read single PCI bar space register */
2941 if (acc_range
== SINGLE_WORD
) {
2942 offset_run
= offset
;
2943 u32val
= readl(mem_mapped_bar
+ offset_run
);
2944 len
+= snprintf(pbuffer
+len
, LPFC_PCI_BAR_RD_BUF_SIZE
-len
,
2945 "%05x: %08x\n", offset_run
, u32val
);
2949 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
2953 /* Browse all PCI bar space registers */
2954 offset_label
= idiag
.offset
.last_rd
;
2955 offset_run
= offset_label
;
2957 /* Read PCI bar memory mapped space */
2958 len
+= snprintf(pbuffer
+len
, LPFC_PCI_BAR_RD_BUF_SIZE
-len
,
2959 "%05x: ", offset_label
);
2960 index
= LPFC_PCI_BAR_RD_SIZE
;
2962 u32val
= readl(mem_mapped_bar
+ offset_run
);
2963 len
+= snprintf(pbuffer
+len
, LPFC_PCI_BAR_RD_BUF_SIZE
-len
,
2965 offset_run
+= sizeof(uint32_t);
2966 if (acc_range
== LPFC_PCI_BAR_BROWSE
) {
2967 if (offset_run
>= bar_size
) {
2968 len
+= snprintf(pbuffer
+len
,
2969 LPFC_PCI_BAR_RD_BUF_SIZE
-len
, "\n");
2973 if (offset_run
>= offset
+
2974 (acc_range
* sizeof(uint32_t))) {
2975 len
+= snprintf(pbuffer
+len
,
2976 LPFC_PCI_BAR_RD_BUF_SIZE
-len
, "\n");
2980 index
-= sizeof(uint32_t);
2982 len
+= snprintf(pbuffer
+len
,
2983 LPFC_PCI_BAR_RD_BUF_SIZE
-len
, "\n");
2984 else if (!(index
% (8 * sizeof(uint32_t)))) {
2985 offset_label
+= (8 * sizeof(uint32_t));
2986 len
+= snprintf(pbuffer
+len
,
2987 LPFC_PCI_BAR_RD_BUF_SIZE
-len
,
2988 "\n%05x: ", offset_label
);
2992 /* Set up the offset for next portion of pci bar read */
2994 idiag
.offset
.last_rd
+= LPFC_PCI_BAR_RD_SIZE
;
2995 if (acc_range
== LPFC_PCI_BAR_BROWSE
) {
2996 if (idiag
.offset
.last_rd
>= bar_size
)
2997 idiag
.offset
.last_rd
= 0;
2999 if (offset_run
>= offset
+
3000 (acc_range
* sizeof(uint32_t)))
3001 idiag
.offset
.last_rd
= offset
;
3004 if (acc_range
== LPFC_PCI_BAR_BROWSE
)
3005 idiag
.offset
.last_rd
= 0;
3007 idiag
.offset
.last_rd
= offset
;
3010 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
3014 * lpfc_idiag_baracc_write - Syntax check and set up idiag bar access commands
3015 * @file: The file pointer to read from.
3016 * @buf: The buffer to copy the user data from.
3017 * @nbytes: The number of bytes to get.
3018 * @ppos: The position in the file to start reading from.
3020 * This routine get the debugfs idiag command struct from user space and
3021 * then perform the syntax check for PCI bar memory mapped space read or
3022 * write command accordingly. In the case of PCI bar memory mapped space
3023 * read command, it sets up the command in the idiag command struct for
3024 * the debugfs read operation. In the case of PCI bar memorpy mapped space
3025 * write operation, it executes the write operation into the PCI bar memory
3026 * mapped space accordingly.
3028 * It returns the @nbytges passing in from debugfs user space when successful.
3029 * In case of error conditions, it returns proper error code back to the user
3033 lpfc_idiag_baracc_write(struct file
*file
, const char __user
*buf
,
3034 size_t nbytes
, loff_t
*ppos
)
3036 struct lpfc_debug
*debug
= file
->private_data
;
3037 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
3038 uint32_t bar_num
, bar_size
, offset
, value
, acc_range
;
3039 struct pci_dev
*pdev
;
3040 void __iomem
*mem_mapped_bar
;
3045 pdev
= phba
->pcidev
;
3049 /* This is a user write operation */
3050 debug
->op
= LPFC_IDIAG_OP_WR
;
3052 rc
= lpfc_idiag_cmd_get(buf
, nbytes
, &idiag
.cmd
);
3056 if_type
= bf_get(lpfc_sli_intf_if_type
, &phba
->sli4_hba
.sli_intf
);
3057 bar_num
= idiag
.cmd
.data
[IDIAG_BARACC_BAR_NUM_INDX
];
3059 if (if_type
== LPFC_SLI_INTF_IF_TYPE_0
) {
3060 if ((bar_num
!= IDIAG_BARACC_BAR_0
) &&
3061 (bar_num
!= IDIAG_BARACC_BAR_1
) &&
3062 (bar_num
!= IDIAG_BARACC_BAR_2
))
3064 } else if (if_type
== LPFC_SLI_INTF_IF_TYPE_2
) {
3065 if (bar_num
!= IDIAG_BARACC_BAR_0
)
3070 if (if_type
== LPFC_SLI_INTF_IF_TYPE_0
) {
3071 if (bar_num
== IDIAG_BARACC_BAR_0
) {
3072 idiag
.cmd
.data
[IDIAG_BARACC_BAR_SZE_INDX
] =
3073 LPFC_PCI_IF0_BAR0_SIZE
;
3074 mem_mapped_bar
= phba
->sli4_hba
.conf_regs_memmap_p
;
3075 } else if (bar_num
== IDIAG_BARACC_BAR_1
) {
3076 idiag
.cmd
.data
[IDIAG_BARACC_BAR_SZE_INDX
] =
3077 LPFC_PCI_IF0_BAR1_SIZE
;
3078 mem_mapped_bar
= phba
->sli4_hba
.ctrl_regs_memmap_p
;
3079 } else if (bar_num
== IDIAG_BARACC_BAR_2
) {
3080 idiag
.cmd
.data
[IDIAG_BARACC_BAR_SZE_INDX
] =
3081 LPFC_PCI_IF0_BAR2_SIZE
;
3082 mem_mapped_bar
= phba
->sli4_hba
.drbl_regs_memmap_p
;
3085 } else if (if_type
== LPFC_SLI_INTF_IF_TYPE_2
) {
3086 if (bar_num
== IDIAG_BARACC_BAR_0
) {
3087 idiag
.cmd
.data
[IDIAG_BARACC_BAR_SZE_INDX
] =
3088 LPFC_PCI_IF2_BAR0_SIZE
;
3089 mem_mapped_bar
= phba
->sli4_hba
.conf_regs_memmap_p
;
3095 offset
= idiag
.cmd
.data
[IDIAG_BARACC_OFF_SET_INDX
];
3096 if (offset
% sizeof(uint32_t))
3099 bar_size
= idiag
.cmd
.data
[IDIAG_BARACC_BAR_SZE_INDX
];
3100 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_RD
) {
3101 /* Sanity check on PCI config read command line arguments */
3102 if (rc
!= LPFC_PCI_BAR_RD_CMD_ARG
)
3104 acc_range
= idiag
.cmd
.data
[IDIAG_BARACC_ACC_MOD_INDX
];
3105 if (acc_range
== LPFC_PCI_BAR_BROWSE
) {
3106 if (offset
> bar_size
- sizeof(uint32_t))
3108 /* Starting offset to browse */
3109 idiag
.offset
.last_rd
= offset
;
3110 } else if (acc_range
> SINGLE_WORD
) {
3111 if (offset
+ acc_range
* sizeof(uint32_t) > bar_size
)
3113 /* Starting offset to browse */
3114 idiag
.offset
.last_rd
= offset
;
3115 } else if (acc_range
!= SINGLE_WORD
)
3117 } else if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_WR
||
3118 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_ST
||
3119 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_CL
) {
3120 /* Sanity check on PCI bar write command line arguments */
3121 if (rc
!= LPFC_PCI_BAR_WR_CMD_ARG
)
3123 /* Write command to PCI bar space, read-modify-write */
3124 acc_range
= SINGLE_WORD
;
3125 value
= idiag
.cmd
.data
[IDIAG_BARACC_REG_VAL_INDX
];
3126 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_WR
) {
3127 writel(value
, mem_mapped_bar
+ offset
);
3128 readl(mem_mapped_bar
+ offset
);
3130 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_ST
) {
3131 u32val
= readl(mem_mapped_bar
+ offset
);
3133 writel(u32val
, mem_mapped_bar
+ offset
);
3134 readl(mem_mapped_bar
+ offset
);
3136 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_CL
) {
3137 u32val
= readl(mem_mapped_bar
+ offset
);
3139 writel(u32val
, mem_mapped_bar
+ offset
);
3140 readl(mem_mapped_bar
+ offset
);
3143 /* All other opecodes are illegal for now */
3148 memset(&idiag
, 0, sizeof(idiag
));
3153 __lpfc_idiag_print_wq(struct lpfc_queue
*qp
, char *wqtype
,
3154 char *pbuffer
, int len
)
3159 len
+= snprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3160 "\t\t%s WQ info: ", wqtype
);
3161 len
+= snprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3162 "AssocCQID[%04d]: WQ-STAT[oflow:x%x posted:x%llx]\n",
3163 qp
->assoc_qid
, qp
->q_cnt_1
,
3164 (unsigned long long)qp
->q_cnt_4
);
3165 len
+= snprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3166 "\t\tWQID[%02d], QE-CNT[%04d], QE-SZ[%04d], "
3167 "HST-IDX[%04d], PRT-IDX[%04d], PST[%03d]",
3168 qp
->queue_id
, qp
->entry_count
,
3169 qp
->entry_size
, qp
->host_index
,
3170 qp
->hba_index
, qp
->entry_repost
);
3171 len
+= snprintf(pbuffer
+ len
,
3172 LPFC_QUE_INFO_GET_BUF_SIZE
- len
, "\n");
3177 lpfc_idiag_wqs_for_cq(struct lpfc_hba
*phba
, char *wqtype
, char *pbuffer
,
3178 int *len
, int max_cnt
, int cq_id
)
3180 struct lpfc_queue
*qp
;
3183 for (qidx
= 0; qidx
< phba
->cfg_fcp_io_channel
; qidx
++) {
3184 qp
= phba
->sli4_hba
.fcp_wq
[qidx
];
3185 if (qp
->assoc_qid
!= cq_id
)
3187 *len
= __lpfc_idiag_print_wq(qp
, wqtype
, pbuffer
, *len
);
3188 if (*len
>= max_cnt
)
3191 for (qidx
= 0; qidx
< phba
->cfg_nvme_io_channel
; qidx
++) {
3192 qp
= phba
->sli4_hba
.nvme_wq
[qidx
];
3193 if (qp
->assoc_qid
!= cq_id
)
3195 *len
= __lpfc_idiag_print_wq(qp
, wqtype
, pbuffer
, *len
);
3196 if (*len
>= max_cnt
)
3203 __lpfc_idiag_print_cq(struct lpfc_queue
*qp
, char *cqtype
,
3204 char *pbuffer
, int len
)
3209 len
+= snprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3210 "\t%s CQ info: ", cqtype
);
3211 len
+= snprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3212 "AssocEQID[%02d]: CQ STAT[max:x%x relw:x%x "
3213 "xabt:x%x wq:x%llx]\n",
3214 qp
->assoc_qid
, qp
->q_cnt_1
, qp
->q_cnt_2
,
3215 qp
->q_cnt_3
, (unsigned long long)qp
->q_cnt_4
);
3216 len
+= snprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3217 "\tCQID[%02d], QE-CNT[%04d], QE-SZ[%04d], "
3218 "HST-IDX[%04d], PRT-IDX[%04d], PST[%03d]",
3219 qp
->queue_id
, qp
->entry_count
,
3220 qp
->entry_size
, qp
->host_index
,
3221 qp
->hba_index
, qp
->entry_repost
);
3223 len
+= snprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
, "\n");
3229 __lpfc_idiag_print_rqpair(struct lpfc_queue
*qp
, struct lpfc_queue
*datqp
,
3230 char *rqtype
, char *pbuffer
, int len
)
3235 len
+= snprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3236 "\t\t%s RQ info: ", rqtype
);
3237 len
+= snprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3238 "AssocCQID[%02d]: RQ-STAT[nopost:x%x nobuf:x%x "
3239 "posted:x%x rcv:x%llx]\n",
3240 qp
->assoc_qid
, qp
->q_cnt_1
, qp
->q_cnt_2
,
3241 qp
->q_cnt_3
, (unsigned long long)qp
->q_cnt_4
);
3242 len
+= snprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3243 "\t\tHQID[%02d], QE-CNT[%04d], QE-SZ[%04d], "
3244 "HST-IDX[%04d], PRT-IDX[%04d], PST[%03d]\n",
3245 qp
->queue_id
, qp
->entry_count
, qp
->entry_size
,
3246 qp
->host_index
, qp
->hba_index
, qp
->entry_repost
);
3247 len
+= snprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3248 "\t\tDQID[%02d], QE-CNT[%04d], QE-SZ[%04d], "
3249 "HST-IDX[%04d], PRT-IDX[%04d], PST[%03d]\n",
3250 datqp
->queue_id
, datqp
->entry_count
,
3251 datqp
->entry_size
, datqp
->host_index
,
3252 datqp
->hba_index
, datqp
->entry_repost
);
3257 lpfc_idiag_cqs_for_eq(struct lpfc_hba
*phba
, char *pbuffer
,
3258 int *len
, int max_cnt
, int eqidx
, int eq_id
)
3260 struct lpfc_queue
*qp
;
3263 for (qidx
= 0; qidx
< phba
->cfg_fcp_io_channel
; qidx
++) {
3264 qp
= phba
->sli4_hba
.fcp_cq
[qidx
];
3265 if (qp
->assoc_qid
!= eq_id
)
3268 *len
= __lpfc_idiag_print_cq(qp
, "FCP", pbuffer
, *len
);
3270 /* Reset max counter */
3273 if (*len
>= max_cnt
)
3276 rc
= lpfc_idiag_wqs_for_cq(phba
, "FCP", pbuffer
, len
,
3277 max_cnt
, qp
->queue_id
);
3282 for (qidx
= 0; qidx
< phba
->cfg_nvme_io_channel
; qidx
++) {
3283 qp
= phba
->sli4_hba
.nvme_cq
[qidx
];
3284 if (qp
->assoc_qid
!= eq_id
)
3287 *len
= __lpfc_idiag_print_cq(qp
, "NVME", pbuffer
, *len
);
3289 /* Reset max counter */
3292 if (*len
>= max_cnt
)
3295 rc
= lpfc_idiag_wqs_for_cq(phba
, "NVME", pbuffer
, len
,
3296 max_cnt
, qp
->queue_id
);
3301 if ((eqidx
< phba
->cfg_nvmet_mrq
) && phba
->nvmet_support
) {
3303 qp
= phba
->sli4_hba
.nvmet_cqset
[eqidx
];
3304 *len
= __lpfc_idiag_print_cq(qp
, "NVMET CQset", pbuffer
, *len
);
3306 /* Reset max counter */
3309 if (*len
>= max_cnt
)
3313 qp
= phba
->sli4_hba
.nvmet_mrq_hdr
[eqidx
];
3314 *len
= __lpfc_idiag_print_rqpair(qp
,
3315 phba
->sli4_hba
.nvmet_mrq_data
[eqidx
],
3316 "NVMET MRQ", pbuffer
, *len
);
3318 if (*len
>= max_cnt
)
3326 __lpfc_idiag_print_eq(struct lpfc_queue
*qp
, char *eqtype
,
3327 char *pbuffer
, int len
)
3332 len
+= snprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3333 "\n%s EQ info: EQ-STAT[max:x%x noE:x%x "
3334 "cqe_proc:x%x eqe_proc:x%llx eqd %d]\n",
3335 eqtype
, qp
->q_cnt_1
, qp
->q_cnt_2
, qp
->q_cnt_3
,
3336 (unsigned long long)qp
->q_cnt_4
, qp
->q_mode
);
3337 len
+= snprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3338 "EQID[%02d], QE-CNT[%04d], QE-SZ[%04d], "
3339 "HST-IDX[%04d], PRT-IDX[%04d], PST[%03d]",
3340 qp
->queue_id
, qp
->entry_count
, qp
->entry_size
,
3341 qp
->host_index
, qp
->hba_index
, qp
->entry_repost
);
3342 len
+= snprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
, "\n");
3348 * lpfc_idiag_queinfo_read - idiag debugfs read queue information
3349 * @file: The file pointer to read from.
3350 * @buf: The buffer to copy the data to.
3351 * @nbytes: The number of bytes to read.
3352 * @ppos: The position in the file to start reading from.
3355 * This routine reads data from the @phba SLI4 PCI function queue information,
3356 * and copies to user @buf.
3357 * This routine only returns 1 EQs worth of information. It remembers the last
3358 * EQ read and jumps to the next EQ. Thus subsequent calls to queInfo will
3359 * retrieve all EQs allocated for the phba.
3362 * This function returns the amount of data that was read (this could be less
3363 * than @nbytes if the end of the file was reached) or a negative error value.
3366 lpfc_idiag_queinfo_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
3369 struct lpfc_debug
*debug
= file
->private_data
;
3370 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
3372 int max_cnt
, rc
, x
, len
= 0;
3373 struct lpfc_queue
*qp
= NULL
;
3376 debug
->buffer
= kmalloc(LPFC_QUE_INFO_GET_BUF_SIZE
, GFP_KERNEL
);
3379 pbuffer
= debug
->buffer
;
3380 max_cnt
= LPFC_QUE_INFO_GET_BUF_SIZE
- 256;
3385 spin_lock_irq(&phba
->hbalock
);
3387 /* Fast-path event queue */
3388 if (phba
->sli4_hba
.hba_eq
&& phba
->io_channel_irqs
) {
3390 x
= phba
->lpfc_idiag_last_eq
;
3391 if (phba
->cfg_fof
&& (x
>= phba
->io_channel_irqs
)) {
3392 phba
->lpfc_idiag_last_eq
= 0;
3395 phba
->lpfc_idiag_last_eq
++;
3396 if (phba
->lpfc_idiag_last_eq
>= phba
->io_channel_irqs
)
3397 if (phba
->cfg_fof
== 0)
3398 phba
->lpfc_idiag_last_eq
= 0;
3400 len
+= snprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3401 "EQ %d out of %d HBA EQs\n",
3402 x
, phba
->io_channel_irqs
);
3405 qp
= phba
->sli4_hba
.hba_eq
[x
];
3409 len
= __lpfc_idiag_print_eq(qp
, "HBA", pbuffer
, len
);
3411 /* Reset max counter */
3417 /* will dump both fcp and nvme cqs/wqs for the eq */
3418 rc
= lpfc_idiag_cqs_for_eq(phba
, pbuffer
, &len
,
3419 max_cnt
, x
, qp
->queue_id
);
3423 /* Only EQ 0 has slow path CQs configured */
3427 /* Slow-path mailbox CQ */
3428 qp
= phba
->sli4_hba
.mbx_cq
;
3429 len
= __lpfc_idiag_print_cq(qp
, "MBX", pbuffer
, len
);
3433 /* Slow-path MBOX MQ */
3434 qp
= phba
->sli4_hba
.mbx_wq
;
3435 len
= __lpfc_idiag_print_wq(qp
, "MBX", pbuffer
, len
);
3439 /* Slow-path ELS response CQ */
3440 qp
= phba
->sli4_hba
.els_cq
;
3441 len
= __lpfc_idiag_print_cq(qp
, "ELS", pbuffer
, len
);
3442 /* Reset max counter */
3448 /* Slow-path ELS WQ */
3449 qp
= phba
->sli4_hba
.els_wq
;
3450 len
= __lpfc_idiag_print_wq(qp
, "ELS", pbuffer
, len
);
3454 qp
= phba
->sli4_hba
.hdr_rq
;
3455 len
= __lpfc_idiag_print_rqpair(qp
, phba
->sli4_hba
.dat_rq
,
3456 "ELS RQpair", pbuffer
, len
);
3460 /* Slow-path NVME LS response CQ */
3461 qp
= phba
->sli4_hba
.nvmels_cq
;
3462 len
= __lpfc_idiag_print_cq(qp
, "NVME LS",
3464 /* Reset max counter */
3470 /* Slow-path NVME LS WQ */
3471 qp
= phba
->sli4_hba
.nvmels_wq
;
3472 len
= __lpfc_idiag_print_wq(qp
, "NVME LS",
3481 if (phba
->cfg_fof
) {
3483 qp
= phba
->sli4_hba
.fof_eq
;
3484 len
= __lpfc_idiag_print_eq(qp
, "FOF", pbuffer
, len
);
3486 /* Reset max counter */
3494 qp
= phba
->sli4_hba
.oas_cq
;
3495 len
= __lpfc_idiag_print_cq(qp
, "OAS", pbuffer
, len
);
3496 /* Reset max counter */
3503 qp
= phba
->sli4_hba
.oas_wq
;
3504 len
= __lpfc_idiag_print_wq(qp
, "OAS", pbuffer
, len
);
3509 spin_unlock_irq(&phba
->hbalock
);
3510 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
3513 len
+= snprintf(pbuffer
+ len
,
3514 LPFC_QUE_INFO_GET_BUF_SIZE
- len
, "Truncated ...\n");
3516 spin_unlock_irq(&phba
->hbalock
);
3517 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
3521 * lpfc_idiag_que_param_check - queue access command parameter sanity check
3522 * @q: The pointer to queue structure.
3523 * @index: The index into a queue entry.
3524 * @count: The number of queue entries to access.
3527 * The routine performs sanity check on device queue access method commands.
3530 * This function returns -EINVAL when fails the sanity check, otherwise, it
3534 lpfc_idiag_que_param_check(struct lpfc_queue
*q
, int index
, int count
)
3536 /* Only support single entry read or browsing */
3537 if ((count
!= 1) && (count
!= LPFC_QUE_ACC_BROWSE
))
3539 if (index
> q
->entry_count
- 1)
3545 * lpfc_idiag_queacc_read_qe - read a single entry from the given queue index
3546 * @pbuffer: The pointer to buffer to copy the read data into.
3547 * @pque: The pointer to the queue to be read.
3548 * @index: The index into the queue entry.
3551 * This routine reads out a single entry from the given queue's index location
3552 * and copies it into the buffer provided.
3555 * This function returns 0 when it fails, otherwise, it returns the length of
3556 * the data read into the buffer provided.
3559 lpfc_idiag_queacc_read_qe(char *pbuffer
, int len
, struct lpfc_queue
*pque
,
3565 if (!pbuffer
|| !pque
)
3568 esize
= pque
->entry_size
;
3569 len
+= snprintf(pbuffer
+len
, LPFC_QUE_ACC_BUF_SIZE
-len
,
3570 "QE-INDEX[%04d]:\n", index
);
3573 pentry
= pque
->qe
[index
].address
;
3575 len
+= snprintf(pbuffer
+len
, LPFC_QUE_ACC_BUF_SIZE
-len
,
3578 offset
+= sizeof(uint32_t);
3579 esize
-= sizeof(uint32_t);
3580 if (esize
> 0 && !(offset
% (4 * sizeof(uint32_t))))
3581 len
+= snprintf(pbuffer
+len
,
3582 LPFC_QUE_ACC_BUF_SIZE
-len
, "\n");
3584 len
+= snprintf(pbuffer
+len
, LPFC_QUE_ACC_BUF_SIZE
-len
, "\n");
3590 * lpfc_idiag_queacc_read - idiag debugfs read port queue
3591 * @file: The file pointer to read from.
3592 * @buf: The buffer to copy the data to.
3593 * @nbytes: The number of bytes to read.
3594 * @ppos: The position in the file to start reading from.
3597 * This routine reads data from the @phba device queue memory according to the
3598 * idiag command, and copies to user @buf. Depending on the queue dump read
3599 * command setup, it does either a single queue entry read or browing through
3600 * all entries of the queue.
3603 * This function returns the amount of data that was read (this could be less
3604 * than @nbytes if the end of the file was reached) or a negative error value.
3607 lpfc_idiag_queacc_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
3610 struct lpfc_debug
*debug
= file
->private_data
;
3611 uint32_t last_index
, index
, count
;
3612 struct lpfc_queue
*pque
= NULL
;
3616 /* This is a user read operation */
3617 debug
->op
= LPFC_IDIAG_OP_RD
;
3620 debug
->buffer
= kmalloc(LPFC_QUE_ACC_BUF_SIZE
, GFP_KERNEL
);
3623 pbuffer
= debug
->buffer
;
3628 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_RD
) {
3629 index
= idiag
.cmd
.data
[IDIAG_QUEACC_INDEX_INDX
];
3630 count
= idiag
.cmd
.data
[IDIAG_QUEACC_COUNT_INDX
];
3631 pque
= (struct lpfc_queue
*)idiag
.ptr_private
;
3635 /* Browse the queue starting from index */
3636 if (count
== LPFC_QUE_ACC_BROWSE
)
3639 /* Read a single entry from the queue */
3640 len
= lpfc_idiag_queacc_read_qe(pbuffer
, len
, pque
, index
);
3642 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
3646 /* Browse all entries from the queue */
3647 last_index
= idiag
.offset
.last_rd
;
3650 while (len
< LPFC_QUE_ACC_SIZE
- pque
->entry_size
) {
3651 len
= lpfc_idiag_queacc_read_qe(pbuffer
, len
, pque
, index
);
3653 if (index
> pque
->entry_count
- 1)
3657 /* Set up the offset for next portion of pci cfg read */
3658 if (index
> pque
->entry_count
- 1)
3660 idiag
.offset
.last_rd
= index
;
3662 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
3666 * lpfc_idiag_queacc_write - Syntax check and set up idiag queacc commands
3667 * @file: The file pointer to read from.
3668 * @buf: The buffer to copy the user data from.
3669 * @nbytes: The number of bytes to get.
3670 * @ppos: The position in the file to start reading from.
3672 * This routine get the debugfs idiag command struct from user space and then
3673 * perform the syntax check for port queue read (dump) or write (set) command
3674 * accordingly. In the case of port queue read command, it sets up the command
3675 * in the idiag command struct for the following debugfs read operation. In
3676 * the case of port queue write operation, it executes the write operation
3677 * into the port queue entry accordingly.
3679 * It returns the @nbytges passing in from debugfs user space when successful.
3680 * In case of error conditions, it returns proper error code back to the user
3684 lpfc_idiag_queacc_write(struct file
*file
, const char __user
*buf
,
3685 size_t nbytes
, loff_t
*ppos
)
3687 struct lpfc_debug
*debug
= file
->private_data
;
3688 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
3689 uint32_t qidx
, quetp
, queid
, index
, count
, offset
, value
;
3691 struct lpfc_queue
*pque
, *qp
;
3694 /* This is a user write operation */
3695 debug
->op
= LPFC_IDIAG_OP_WR
;
3697 rc
= lpfc_idiag_cmd_get(buf
, nbytes
, &idiag
.cmd
);
3701 /* Get and sanity check on command feilds */
3702 quetp
= idiag
.cmd
.data
[IDIAG_QUEACC_QUETP_INDX
];
3703 queid
= idiag
.cmd
.data
[IDIAG_QUEACC_QUEID_INDX
];
3704 index
= idiag
.cmd
.data
[IDIAG_QUEACC_INDEX_INDX
];
3705 count
= idiag
.cmd
.data
[IDIAG_QUEACC_COUNT_INDX
];
3706 offset
= idiag
.cmd
.data
[IDIAG_QUEACC_OFFST_INDX
];
3707 value
= idiag
.cmd
.data
[IDIAG_QUEACC_VALUE_INDX
];
3709 /* Sanity check on command line arguments */
3710 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_WR
||
3711 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_ST
||
3712 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_CL
) {
3713 if (rc
!= LPFC_QUE_ACC_WR_CMD_ARG
)
3717 } else if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_RD
) {
3718 if (rc
!= LPFC_QUE_ACC_RD_CMD_ARG
)
3725 /* HBA event queue */
3726 if (phba
->sli4_hba
.hba_eq
) {
3727 for (qidx
= 0; qidx
< phba
->io_channel_irqs
; qidx
++) {
3728 qp
= phba
->sli4_hba
.hba_eq
[qidx
];
3729 if (qp
&& qp
->queue_id
== queid
) {
3731 rc
= lpfc_idiag_que_param_check(qp
,
3735 idiag
.ptr_private
= qp
;
3743 /* MBX complete queue */
3744 if (phba
->sli4_hba
.mbx_cq
&&
3745 phba
->sli4_hba
.mbx_cq
->queue_id
== queid
) {
3747 rc
= lpfc_idiag_que_param_check(
3748 phba
->sli4_hba
.mbx_cq
, index
, count
);
3751 idiag
.ptr_private
= phba
->sli4_hba
.mbx_cq
;
3754 /* ELS complete queue */
3755 if (phba
->sli4_hba
.els_cq
&&
3756 phba
->sli4_hba
.els_cq
->queue_id
== queid
) {
3758 rc
= lpfc_idiag_que_param_check(
3759 phba
->sli4_hba
.els_cq
, index
, count
);
3762 idiag
.ptr_private
= phba
->sli4_hba
.els_cq
;
3765 /* NVME LS complete queue */
3766 if (phba
->sli4_hba
.nvmels_cq
&&
3767 phba
->sli4_hba
.nvmels_cq
->queue_id
== queid
) {
3769 rc
= lpfc_idiag_que_param_check(
3770 phba
->sli4_hba
.nvmels_cq
, index
, count
);
3773 idiag
.ptr_private
= phba
->sli4_hba
.nvmels_cq
;
3776 /* FCP complete queue */
3777 if (phba
->sli4_hba
.fcp_cq
) {
3778 for (qidx
= 0; qidx
< phba
->cfg_fcp_io_channel
;
3780 qp
= phba
->sli4_hba
.fcp_cq
[qidx
];
3781 if (qp
&& qp
->queue_id
== queid
) {
3783 rc
= lpfc_idiag_que_param_check(
3787 idiag
.ptr_private
= qp
;
3792 /* NVME complete queue */
3793 if (phba
->sli4_hba
.nvme_cq
) {
3796 if (phba
->sli4_hba
.nvme_cq
[qidx
] &&
3797 phba
->sli4_hba
.nvme_cq
[qidx
]->queue_id
==
3800 rc
= lpfc_idiag_que_param_check(
3801 phba
->sli4_hba
.nvme_cq
[qidx
],
3806 phba
->sli4_hba
.nvme_cq
[qidx
];
3809 } while (++qidx
< phba
->cfg_nvme_io_channel
);
3814 /* MBX work queue */
3815 if (phba
->sli4_hba
.mbx_wq
&&
3816 phba
->sli4_hba
.mbx_wq
->queue_id
== queid
) {
3818 rc
= lpfc_idiag_que_param_check(
3819 phba
->sli4_hba
.mbx_wq
, index
, count
);
3822 idiag
.ptr_private
= phba
->sli4_hba
.mbx_wq
;
3828 /* ELS work queue */
3829 if (phba
->sli4_hba
.els_wq
&&
3830 phba
->sli4_hba
.els_wq
->queue_id
== queid
) {
3832 rc
= lpfc_idiag_que_param_check(
3833 phba
->sli4_hba
.els_wq
, index
, count
);
3836 idiag
.ptr_private
= phba
->sli4_hba
.els_wq
;
3839 /* NVME LS work queue */
3840 if (phba
->sli4_hba
.nvmels_wq
&&
3841 phba
->sli4_hba
.nvmels_wq
->queue_id
== queid
) {
3843 rc
= lpfc_idiag_que_param_check(
3844 phba
->sli4_hba
.nvmels_wq
, index
, count
);
3847 idiag
.ptr_private
= phba
->sli4_hba
.nvmels_wq
;
3850 /* FCP work queue */
3851 if (phba
->sli4_hba
.fcp_wq
) {
3852 for (qidx
= 0; qidx
< phba
->cfg_fcp_io_channel
;
3854 qp
= phba
->sli4_hba
.fcp_wq
[qidx
];
3855 if (qp
&& qp
->queue_id
== queid
) {
3857 rc
= lpfc_idiag_que_param_check(
3861 idiag
.ptr_private
= qp
;
3866 /* NVME work queue */
3867 if (phba
->sli4_hba
.nvme_wq
) {
3868 for (qidx
= 0; qidx
< phba
->cfg_nvme_io_channel
;
3870 qp
= phba
->sli4_hba
.nvme_wq
[qidx
];
3871 if (qp
&& qp
->queue_id
== queid
) {
3873 rc
= lpfc_idiag_que_param_check(
3877 idiag
.ptr_private
= qp
;
3883 /* NVME work queues */
3884 if (phba
->sli4_hba
.nvme_wq
) {
3885 for (qidx
= 0; qidx
< phba
->cfg_nvme_io_channel
;
3887 if (!phba
->sli4_hba
.nvme_wq
[qidx
])
3889 if (phba
->sli4_hba
.nvme_wq
[qidx
]->queue_id
==
3892 rc
= lpfc_idiag_que_param_check(
3893 phba
->sli4_hba
.nvme_wq
[qidx
],
3898 phba
->sli4_hba
.nvme_wq
[qidx
];
3907 if (phba
->sli4_hba
.hdr_rq
&&
3908 phba
->sli4_hba
.hdr_rq
->queue_id
== queid
) {
3910 rc
= lpfc_idiag_que_param_check(
3911 phba
->sli4_hba
.hdr_rq
, index
, count
);
3914 idiag
.ptr_private
= phba
->sli4_hba
.hdr_rq
;
3918 if (phba
->sli4_hba
.dat_rq
&&
3919 phba
->sli4_hba
.dat_rq
->queue_id
== queid
) {
3921 rc
= lpfc_idiag_que_param_check(
3922 phba
->sli4_hba
.dat_rq
, index
, count
);
3925 idiag
.ptr_private
= phba
->sli4_hba
.dat_rq
;
3937 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_RD
) {
3938 if (count
== LPFC_QUE_ACC_BROWSE
)
3939 idiag
.offset
.last_rd
= index
;
3942 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_WR
||
3943 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_ST
||
3944 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_CL
) {
3945 /* Additional sanity checks on write operation */
3946 pque
= (struct lpfc_queue
*)idiag
.ptr_private
;
3947 if (offset
> pque
->entry_size
/sizeof(uint32_t) - 1)
3949 pentry
= pque
->qe
[index
].address
;
3951 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_WR
)
3953 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_ST
)
3955 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_CL
)
3961 /* Clean out command structure on command error out */
3962 memset(&idiag
, 0, sizeof(idiag
));
3967 * lpfc_idiag_drbacc_read_reg - idiag debugfs read a doorbell register
3968 * @phba: The pointer to hba structure.
3969 * @pbuffer: The pointer to the buffer to copy the data to.
3970 * @len: The lenght of bytes to copied.
3971 * @drbregid: The id to doorbell registers.
3974 * This routine reads a doorbell register and copies its content to the
3975 * user buffer pointed to by @pbuffer.
3978 * This function returns the amount of data that was copied into @pbuffer.
3981 lpfc_idiag_drbacc_read_reg(struct lpfc_hba
*phba
, char *pbuffer
,
3982 int len
, uint32_t drbregid
)
3990 len
+= snprintf(pbuffer
+ len
, LPFC_DRB_ACC_BUF_SIZE
-len
,
3991 "EQ-DRB-REG: 0x%08x\n",
3992 readl(phba
->sli4_hba
.EQDBregaddr
));
3995 len
+= snprintf(pbuffer
+ len
, LPFC_DRB_ACC_BUF_SIZE
- len
,
3996 "CQ-DRB-REG: 0x%08x\n",
3997 readl(phba
->sli4_hba
.CQDBregaddr
));
4000 len
+= snprintf(pbuffer
+len
, LPFC_DRB_ACC_BUF_SIZE
-len
,
4001 "MQ-DRB-REG: 0x%08x\n",
4002 readl(phba
->sli4_hba
.MQDBregaddr
));
4005 len
+= snprintf(pbuffer
+len
, LPFC_DRB_ACC_BUF_SIZE
-len
,
4006 "WQ-DRB-REG: 0x%08x\n",
4007 readl(phba
->sli4_hba
.WQDBregaddr
));
4010 len
+= snprintf(pbuffer
+len
, LPFC_DRB_ACC_BUF_SIZE
-len
,
4011 "RQ-DRB-REG: 0x%08x\n",
4012 readl(phba
->sli4_hba
.RQDBregaddr
));
4022 * lpfc_idiag_drbacc_read - idiag debugfs read port doorbell
4023 * @file: The file pointer to read from.
4024 * @buf: The buffer to copy the data to.
4025 * @nbytes: The number of bytes to read.
4026 * @ppos: The position in the file to start reading from.
4029 * This routine reads data from the @phba device doorbell register according
4030 * to the idiag command, and copies to user @buf. Depending on the doorbell
4031 * register read command setup, it does either a single doorbell register
4032 * read or dump all doorbell registers.
4035 * This function returns the amount of data that was read (this could be less
4036 * than @nbytes if the end of the file was reached) or a negative error value.
4039 lpfc_idiag_drbacc_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
4042 struct lpfc_debug
*debug
= file
->private_data
;
4043 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
4044 uint32_t drb_reg_id
, i
;
4048 /* This is a user read operation */
4049 debug
->op
= LPFC_IDIAG_OP_RD
;
4052 debug
->buffer
= kmalloc(LPFC_DRB_ACC_BUF_SIZE
, GFP_KERNEL
);
4055 pbuffer
= debug
->buffer
;
4060 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_RD
)
4061 drb_reg_id
= idiag
.cmd
.data
[IDIAG_DRBACC_REGID_INDX
];
4065 if (drb_reg_id
== LPFC_DRB_ACC_ALL
)
4066 for (i
= 1; i
<= LPFC_DRB_MAX
; i
++)
4067 len
= lpfc_idiag_drbacc_read_reg(phba
,
4070 len
= lpfc_idiag_drbacc_read_reg(phba
,
4071 pbuffer
, len
, drb_reg_id
);
4073 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
4077 * lpfc_idiag_drbacc_write - Syntax check and set up idiag drbacc commands
4078 * @file: The file pointer to read from.
4079 * @buf: The buffer to copy the user data from.
4080 * @nbytes: The number of bytes to get.
4081 * @ppos: The position in the file to start reading from.
4083 * This routine get the debugfs idiag command struct from user space and then
4084 * perform the syntax check for port doorbell register read (dump) or write
4085 * (set) command accordingly. In the case of port queue read command, it sets
4086 * up the command in the idiag command struct for the following debugfs read
4087 * operation. In the case of port doorbell register write operation, it
4088 * executes the write operation into the port doorbell register accordingly.
4090 * It returns the @nbytges passing in from debugfs user space when successful.
4091 * In case of error conditions, it returns proper error code back to the user
4095 lpfc_idiag_drbacc_write(struct file
*file
, const char __user
*buf
,
4096 size_t nbytes
, loff_t
*ppos
)
4098 struct lpfc_debug
*debug
= file
->private_data
;
4099 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
4100 uint32_t drb_reg_id
, value
, reg_val
= 0;
4101 void __iomem
*drb_reg
;
4104 /* This is a user write operation */
4105 debug
->op
= LPFC_IDIAG_OP_WR
;
4107 rc
= lpfc_idiag_cmd_get(buf
, nbytes
, &idiag
.cmd
);
4111 /* Sanity check on command line arguments */
4112 drb_reg_id
= idiag
.cmd
.data
[IDIAG_DRBACC_REGID_INDX
];
4113 value
= idiag
.cmd
.data
[IDIAG_DRBACC_VALUE_INDX
];
4115 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_WR
||
4116 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_ST
||
4117 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_CL
) {
4118 if (rc
!= LPFC_DRB_ACC_WR_CMD_ARG
)
4120 if (drb_reg_id
> LPFC_DRB_MAX
)
4122 } else if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_RD
) {
4123 if (rc
!= LPFC_DRB_ACC_RD_CMD_ARG
)
4125 if ((drb_reg_id
> LPFC_DRB_MAX
) &&
4126 (drb_reg_id
!= LPFC_DRB_ACC_ALL
))
4131 /* Perform the write access operation */
4132 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_WR
||
4133 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_ST
||
4134 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_CL
) {
4135 switch (drb_reg_id
) {
4137 drb_reg
= phba
->sli4_hba
.EQDBregaddr
;
4140 drb_reg
= phba
->sli4_hba
.CQDBregaddr
;
4143 drb_reg
= phba
->sli4_hba
.MQDBregaddr
;
4146 drb_reg
= phba
->sli4_hba
.WQDBregaddr
;
4149 drb_reg
= phba
->sli4_hba
.RQDBregaddr
;
4155 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_WR
)
4157 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_ST
) {
4158 reg_val
= readl(drb_reg
);
4161 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_CL
) {
4162 reg_val
= readl(drb_reg
);
4165 writel(reg_val
, drb_reg
);
4166 readl(drb_reg
); /* flush */
4171 /* Clean out command structure on command error out */
4172 memset(&idiag
, 0, sizeof(idiag
));
4177 * lpfc_idiag_ctlacc_read_reg - idiag debugfs read a control registers
4178 * @phba: The pointer to hba structure.
4179 * @pbuffer: The pointer to the buffer to copy the data to.
4180 * @len: The lenght of bytes to copied.
4181 * @drbregid: The id to doorbell registers.
4184 * This routine reads a control register and copies its content to the
4185 * user buffer pointed to by @pbuffer.
4188 * This function returns the amount of data that was copied into @pbuffer.
4191 lpfc_idiag_ctlacc_read_reg(struct lpfc_hba
*phba
, char *pbuffer
,
4192 int len
, uint32_t ctlregid
)
4199 case LPFC_CTL_PORT_SEM
:
4200 len
+= snprintf(pbuffer
+len
, LPFC_CTL_ACC_BUF_SIZE
-len
,
4201 "Port SemReg: 0x%08x\n",
4202 readl(phba
->sli4_hba
.conf_regs_memmap_p
+
4203 LPFC_CTL_PORT_SEM_OFFSET
));
4205 case LPFC_CTL_PORT_STA
:
4206 len
+= snprintf(pbuffer
+len
, LPFC_CTL_ACC_BUF_SIZE
-len
,
4207 "Port StaReg: 0x%08x\n",
4208 readl(phba
->sli4_hba
.conf_regs_memmap_p
+
4209 LPFC_CTL_PORT_STA_OFFSET
));
4211 case LPFC_CTL_PORT_CTL
:
4212 len
+= snprintf(pbuffer
+len
, LPFC_CTL_ACC_BUF_SIZE
-len
,
4213 "Port CtlReg: 0x%08x\n",
4214 readl(phba
->sli4_hba
.conf_regs_memmap_p
+
4215 LPFC_CTL_PORT_CTL_OFFSET
));
4217 case LPFC_CTL_PORT_ER1
:
4218 len
+= snprintf(pbuffer
+len
, LPFC_CTL_ACC_BUF_SIZE
-len
,
4219 "Port Er1Reg: 0x%08x\n",
4220 readl(phba
->sli4_hba
.conf_regs_memmap_p
+
4221 LPFC_CTL_PORT_ER1_OFFSET
));
4223 case LPFC_CTL_PORT_ER2
:
4224 len
+= snprintf(pbuffer
+len
, LPFC_CTL_ACC_BUF_SIZE
-len
,
4225 "Port Er2Reg: 0x%08x\n",
4226 readl(phba
->sli4_hba
.conf_regs_memmap_p
+
4227 LPFC_CTL_PORT_ER2_OFFSET
));
4229 case LPFC_CTL_PDEV_CTL
:
4230 len
+= snprintf(pbuffer
+len
, LPFC_CTL_ACC_BUF_SIZE
-len
,
4231 "PDev CtlReg: 0x%08x\n",
4232 readl(phba
->sli4_hba
.conf_regs_memmap_p
+
4233 LPFC_CTL_PDEV_CTL_OFFSET
));
4242 * lpfc_idiag_ctlacc_read - idiag debugfs read port and device control register
4243 * @file: The file pointer to read from.
4244 * @buf: The buffer to copy the data to.
4245 * @nbytes: The number of bytes to read.
4246 * @ppos: The position in the file to start reading from.
4249 * This routine reads data from the @phba port and device registers according
4250 * to the idiag command, and copies to user @buf.
4253 * This function returns the amount of data that was read (this could be less
4254 * than @nbytes if the end of the file was reached) or a negative error value.
4257 lpfc_idiag_ctlacc_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
4260 struct lpfc_debug
*debug
= file
->private_data
;
4261 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
4262 uint32_t ctl_reg_id
, i
;
4266 /* This is a user read operation */
4267 debug
->op
= LPFC_IDIAG_OP_RD
;
4270 debug
->buffer
= kmalloc(LPFC_CTL_ACC_BUF_SIZE
, GFP_KERNEL
);
4273 pbuffer
= debug
->buffer
;
4278 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_RD
)
4279 ctl_reg_id
= idiag
.cmd
.data
[IDIAG_CTLACC_REGID_INDX
];
4283 if (ctl_reg_id
== LPFC_CTL_ACC_ALL
)
4284 for (i
= 1; i
<= LPFC_CTL_MAX
; i
++)
4285 len
= lpfc_idiag_ctlacc_read_reg(phba
,
4288 len
= lpfc_idiag_ctlacc_read_reg(phba
,
4289 pbuffer
, len
, ctl_reg_id
);
4291 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
4295 * lpfc_idiag_ctlacc_write - Syntax check and set up idiag ctlacc commands
4296 * @file: The file pointer to read from.
4297 * @buf: The buffer to copy the user data from.
4298 * @nbytes: The number of bytes to get.
4299 * @ppos: The position in the file to start reading from.
4301 * This routine get the debugfs idiag command struct from user space and then
4302 * perform the syntax check for port and device control register read (dump)
4303 * or write (set) command accordingly.
4305 * It returns the @nbytges passing in from debugfs user space when successful.
4306 * In case of error conditions, it returns proper error code back to the user
4310 lpfc_idiag_ctlacc_write(struct file
*file
, const char __user
*buf
,
4311 size_t nbytes
, loff_t
*ppos
)
4313 struct lpfc_debug
*debug
= file
->private_data
;
4314 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
4315 uint32_t ctl_reg_id
, value
, reg_val
= 0;
4316 void __iomem
*ctl_reg
;
4319 /* This is a user write operation */
4320 debug
->op
= LPFC_IDIAG_OP_WR
;
4322 rc
= lpfc_idiag_cmd_get(buf
, nbytes
, &idiag
.cmd
);
4326 /* Sanity check on command line arguments */
4327 ctl_reg_id
= idiag
.cmd
.data
[IDIAG_CTLACC_REGID_INDX
];
4328 value
= idiag
.cmd
.data
[IDIAG_CTLACC_VALUE_INDX
];
4330 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_WR
||
4331 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_ST
||
4332 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_CL
) {
4333 if (rc
!= LPFC_CTL_ACC_WR_CMD_ARG
)
4335 if (ctl_reg_id
> LPFC_CTL_MAX
)
4337 } else if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_RD
) {
4338 if (rc
!= LPFC_CTL_ACC_RD_CMD_ARG
)
4340 if ((ctl_reg_id
> LPFC_CTL_MAX
) &&
4341 (ctl_reg_id
!= LPFC_CTL_ACC_ALL
))
4346 /* Perform the write access operation */
4347 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_WR
||
4348 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_ST
||
4349 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_CL
) {
4350 switch (ctl_reg_id
) {
4351 case LPFC_CTL_PORT_SEM
:
4352 ctl_reg
= phba
->sli4_hba
.conf_regs_memmap_p
+
4353 LPFC_CTL_PORT_SEM_OFFSET
;
4355 case LPFC_CTL_PORT_STA
:
4356 ctl_reg
= phba
->sli4_hba
.conf_regs_memmap_p
+
4357 LPFC_CTL_PORT_STA_OFFSET
;
4359 case LPFC_CTL_PORT_CTL
:
4360 ctl_reg
= phba
->sli4_hba
.conf_regs_memmap_p
+
4361 LPFC_CTL_PORT_CTL_OFFSET
;
4363 case LPFC_CTL_PORT_ER1
:
4364 ctl_reg
= phba
->sli4_hba
.conf_regs_memmap_p
+
4365 LPFC_CTL_PORT_ER1_OFFSET
;
4367 case LPFC_CTL_PORT_ER2
:
4368 ctl_reg
= phba
->sli4_hba
.conf_regs_memmap_p
+
4369 LPFC_CTL_PORT_ER2_OFFSET
;
4371 case LPFC_CTL_PDEV_CTL
:
4372 ctl_reg
= phba
->sli4_hba
.conf_regs_memmap_p
+
4373 LPFC_CTL_PDEV_CTL_OFFSET
;
4379 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_WR
)
4381 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_ST
) {
4382 reg_val
= readl(ctl_reg
);
4385 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_CL
) {
4386 reg_val
= readl(ctl_reg
);
4389 writel(reg_val
, ctl_reg
);
4390 readl(ctl_reg
); /* flush */
4395 /* Clean out command structure on command error out */
4396 memset(&idiag
, 0, sizeof(idiag
));
4401 * lpfc_idiag_mbxacc_get_setup - idiag debugfs get mailbox access setup
4402 * @phba: Pointer to HBA context object.
4403 * @pbuffer: Pointer to data buffer.
4406 * This routine gets the driver mailbox access debugfs setup information.
4409 * This function returns the amount of data that was read (this could be less
4410 * than @nbytes if the end of the file was reached) or a negative error value.
4413 lpfc_idiag_mbxacc_get_setup(struct lpfc_hba
*phba
, char *pbuffer
)
4415 uint32_t mbx_dump_map
, mbx_dump_cnt
, mbx_word_cnt
, mbx_mbox_cmd
;
4418 mbx_mbox_cmd
= idiag
.cmd
.data
[IDIAG_MBXACC_MBCMD_INDX
];
4419 mbx_dump_map
= idiag
.cmd
.data
[IDIAG_MBXACC_DPMAP_INDX
];
4420 mbx_dump_cnt
= idiag
.cmd
.data
[IDIAG_MBXACC_DPCNT_INDX
];
4421 mbx_word_cnt
= idiag
.cmd
.data
[IDIAG_MBXACC_WDCNT_INDX
];
4423 len
+= snprintf(pbuffer
+len
, LPFC_MBX_ACC_BUF_SIZE
-len
,
4424 "mbx_dump_map: 0x%08x\n", mbx_dump_map
);
4425 len
+= snprintf(pbuffer
+len
, LPFC_MBX_ACC_BUF_SIZE
-len
,
4426 "mbx_dump_cnt: %04d\n", mbx_dump_cnt
);
4427 len
+= snprintf(pbuffer
+len
, LPFC_MBX_ACC_BUF_SIZE
-len
,
4428 "mbx_word_cnt: %04d\n", mbx_word_cnt
);
4429 len
+= snprintf(pbuffer
+len
, LPFC_MBX_ACC_BUF_SIZE
-len
,
4430 "mbx_mbox_cmd: 0x%02x\n", mbx_mbox_cmd
);
4436 * lpfc_idiag_mbxacc_read - idiag debugfs read on mailbox access
4437 * @file: The file pointer to read from.
4438 * @buf: The buffer to copy the data to.
4439 * @nbytes: The number of bytes to read.
4440 * @ppos: The position in the file to start reading from.
4443 * This routine reads data from the @phba driver mailbox access debugfs setup
4447 * This function returns the amount of data that was read (this could be less
4448 * than @nbytes if the end of the file was reached) or a negative error value.
4451 lpfc_idiag_mbxacc_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
4454 struct lpfc_debug
*debug
= file
->private_data
;
4455 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
4459 /* This is a user read operation */
4460 debug
->op
= LPFC_IDIAG_OP_RD
;
4463 debug
->buffer
= kmalloc(LPFC_MBX_ACC_BUF_SIZE
, GFP_KERNEL
);
4466 pbuffer
= debug
->buffer
;
4471 if ((idiag
.cmd
.opcode
!= LPFC_IDIAG_CMD_MBXACC_DP
) &&
4472 (idiag
.cmd
.opcode
!= LPFC_IDIAG_BSG_MBXACC_DP
))
4475 len
= lpfc_idiag_mbxacc_get_setup(phba
, pbuffer
);
4477 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
4481 * lpfc_idiag_mbxacc_write - Syntax check and set up idiag mbxacc commands
4482 * @file: The file pointer to read from.
4483 * @buf: The buffer to copy the user data from.
4484 * @nbytes: The number of bytes to get.
4485 * @ppos: The position in the file to start reading from.
4487 * This routine get the debugfs idiag command struct from user space and then
4488 * perform the syntax check for driver mailbox command (dump) and sets up the
4489 * necessary states in the idiag command struct accordingly.
4491 * It returns the @nbytges passing in from debugfs user space when successful.
4492 * In case of error conditions, it returns proper error code back to the user
4496 lpfc_idiag_mbxacc_write(struct file
*file
, const char __user
*buf
,
4497 size_t nbytes
, loff_t
*ppos
)
4499 struct lpfc_debug
*debug
= file
->private_data
;
4500 uint32_t mbx_dump_map
, mbx_dump_cnt
, mbx_word_cnt
, mbx_mbox_cmd
;
4503 /* This is a user write operation */
4504 debug
->op
= LPFC_IDIAG_OP_WR
;
4506 rc
= lpfc_idiag_cmd_get(buf
, nbytes
, &idiag
.cmd
);
4510 /* Sanity check on command line arguments */
4511 mbx_mbox_cmd
= idiag
.cmd
.data
[IDIAG_MBXACC_MBCMD_INDX
];
4512 mbx_dump_map
= idiag
.cmd
.data
[IDIAG_MBXACC_DPMAP_INDX
];
4513 mbx_dump_cnt
= idiag
.cmd
.data
[IDIAG_MBXACC_DPCNT_INDX
];
4514 mbx_word_cnt
= idiag
.cmd
.data
[IDIAG_MBXACC_WDCNT_INDX
];
4516 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_MBXACC_DP
) {
4517 if (!(mbx_dump_map
& LPFC_MBX_DMP_MBX_ALL
))
4519 if ((mbx_dump_map
& ~LPFC_MBX_DMP_MBX_ALL
) &&
4520 (mbx_dump_map
!= LPFC_MBX_DMP_ALL
))
4522 if (mbx_word_cnt
> sizeof(MAILBOX_t
))
4524 } else if (idiag
.cmd
.opcode
== LPFC_IDIAG_BSG_MBXACC_DP
) {
4525 if (!(mbx_dump_map
& LPFC_BSG_DMP_MBX_ALL
))
4527 if ((mbx_dump_map
& ~LPFC_BSG_DMP_MBX_ALL
) &&
4528 (mbx_dump_map
!= LPFC_MBX_DMP_ALL
))
4530 if (mbx_word_cnt
> (BSG_MBOX_SIZE
)/4)
4532 if (mbx_mbox_cmd
!= 0x9b)
4537 if (mbx_word_cnt
== 0)
4539 if (rc
!= LPFC_MBX_DMP_ARG
)
4541 if (mbx_mbox_cmd
& ~0xff)
4544 /* condition for stop mailbox dump */
4545 if (mbx_dump_cnt
== 0)
4551 /* Clean out command structure on command error out */
4552 memset(&idiag
, 0, sizeof(idiag
));
4556 /* Clean out command structure on command error out */
4557 memset(&idiag
, 0, sizeof(idiag
));
4562 * lpfc_idiag_extacc_avail_get - get the available extents information
4563 * @phba: pointer to lpfc hba data structure.
4564 * @pbuffer: pointer to internal buffer.
4565 * @len: length into the internal buffer data has been copied.
4568 * This routine is to get the available extent information.
4571 * overall lenth of the data read into the internal buffer.
4574 lpfc_idiag_extacc_avail_get(struct lpfc_hba
*phba
, char *pbuffer
, int len
)
4576 uint16_t ext_cnt
, ext_size
;
4578 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4579 "\nAvailable Extents Information:\n");
4581 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4582 "\tPort Available VPI extents: ");
4583 lpfc_sli4_get_avail_extnt_rsrc(phba
, LPFC_RSC_TYPE_FCOE_VPI
,
4584 &ext_cnt
, &ext_size
);
4585 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4586 "Count %3d, Size %3d\n", ext_cnt
, ext_size
);
4588 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4589 "\tPort Available VFI extents: ");
4590 lpfc_sli4_get_avail_extnt_rsrc(phba
, LPFC_RSC_TYPE_FCOE_VFI
,
4591 &ext_cnt
, &ext_size
);
4592 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4593 "Count %3d, Size %3d\n", ext_cnt
, ext_size
);
4595 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4596 "\tPort Available RPI extents: ");
4597 lpfc_sli4_get_avail_extnt_rsrc(phba
, LPFC_RSC_TYPE_FCOE_RPI
,
4598 &ext_cnt
, &ext_size
);
4599 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4600 "Count %3d, Size %3d\n", ext_cnt
, ext_size
);
4602 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4603 "\tPort Available XRI extents: ");
4604 lpfc_sli4_get_avail_extnt_rsrc(phba
, LPFC_RSC_TYPE_FCOE_XRI
,
4605 &ext_cnt
, &ext_size
);
4606 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4607 "Count %3d, Size %3d\n", ext_cnt
, ext_size
);
4613 * lpfc_idiag_extacc_alloc_get - get the allocated extents information
4614 * @phba: pointer to lpfc hba data structure.
4615 * @pbuffer: pointer to internal buffer.
4616 * @len: length into the internal buffer data has been copied.
4619 * This routine is to get the allocated extent information.
4622 * overall lenth of the data read into the internal buffer.
4625 lpfc_idiag_extacc_alloc_get(struct lpfc_hba
*phba
, char *pbuffer
, int len
)
4627 uint16_t ext_cnt
, ext_size
;
4630 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4631 "\nAllocated Extents Information:\n");
4633 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4634 "\tHost Allocated VPI extents: ");
4635 rc
= lpfc_sli4_get_allocated_extnts(phba
, LPFC_RSC_TYPE_FCOE_VPI
,
4636 &ext_cnt
, &ext_size
);
4638 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4639 "Port %d Extent %3d, Size %3d\n",
4640 phba
->brd_no
, ext_cnt
, ext_size
);
4642 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4645 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4646 "\tHost Allocated VFI extents: ");
4647 rc
= lpfc_sli4_get_allocated_extnts(phba
, LPFC_RSC_TYPE_FCOE_VFI
,
4648 &ext_cnt
, &ext_size
);
4650 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4651 "Port %d Extent %3d, Size %3d\n",
4652 phba
->brd_no
, ext_cnt
, ext_size
);
4654 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4657 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4658 "\tHost Allocated RPI extents: ");
4659 rc
= lpfc_sli4_get_allocated_extnts(phba
, LPFC_RSC_TYPE_FCOE_RPI
,
4660 &ext_cnt
, &ext_size
);
4662 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4663 "Port %d Extent %3d, Size %3d\n",
4664 phba
->brd_no
, ext_cnt
, ext_size
);
4666 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4669 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4670 "\tHost Allocated XRI extents: ");
4671 rc
= lpfc_sli4_get_allocated_extnts(phba
, LPFC_RSC_TYPE_FCOE_XRI
,
4672 &ext_cnt
, &ext_size
);
4674 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4675 "Port %d Extent %3d, Size %3d\n",
4676 phba
->brd_no
, ext_cnt
, ext_size
);
4678 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4685 * lpfc_idiag_extacc_drivr_get - get driver extent information
4686 * @phba: pointer to lpfc hba data structure.
4687 * @pbuffer: pointer to internal buffer.
4688 * @len: length into the internal buffer data has been copied.
4691 * This routine is to get the driver extent information.
4694 * overall lenth of the data read into the internal buffer.
4697 lpfc_idiag_extacc_drivr_get(struct lpfc_hba
*phba
, char *pbuffer
, int len
)
4699 struct lpfc_rsrc_blks
*rsrc_blks
;
4702 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4703 "\nDriver Extents Information:\n");
4705 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4706 "\tVPI extents:\n");
4708 list_for_each_entry(rsrc_blks
, &phba
->lpfc_vpi_blk_list
, list
) {
4709 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4710 "\t\tBlock %3d: Start %4d, Count %4d\n",
4711 index
, rsrc_blks
->rsrc_start
,
4712 rsrc_blks
->rsrc_size
);
4715 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4716 "\tVFI extents:\n");
4718 list_for_each_entry(rsrc_blks
, &phba
->sli4_hba
.lpfc_vfi_blk_list
,
4720 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4721 "\t\tBlock %3d: Start %4d, Count %4d\n",
4722 index
, rsrc_blks
->rsrc_start
,
4723 rsrc_blks
->rsrc_size
);
4727 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4728 "\tRPI extents:\n");
4730 list_for_each_entry(rsrc_blks
, &phba
->sli4_hba
.lpfc_rpi_blk_list
,
4732 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4733 "\t\tBlock %3d: Start %4d, Count %4d\n",
4734 index
, rsrc_blks
->rsrc_start
,
4735 rsrc_blks
->rsrc_size
);
4739 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4740 "\tXRI extents:\n");
4742 list_for_each_entry(rsrc_blks
, &phba
->sli4_hba
.lpfc_xri_blk_list
,
4744 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4745 "\t\tBlock %3d: Start %4d, Count %4d\n",
4746 index
, rsrc_blks
->rsrc_start
,
4747 rsrc_blks
->rsrc_size
);
4755 * lpfc_idiag_extacc_write - Syntax check and set up idiag extacc commands
4756 * @file: The file pointer to read from.
4757 * @buf: The buffer to copy the user data from.
4758 * @nbytes: The number of bytes to get.
4759 * @ppos: The position in the file to start reading from.
4761 * This routine get the debugfs idiag command struct from user space and then
4762 * perform the syntax check for extent information access commands and sets
4763 * up the necessary states in the idiag command struct accordingly.
4765 * It returns the @nbytges passing in from debugfs user space when successful.
4766 * In case of error conditions, it returns proper error code back to the user
4770 lpfc_idiag_extacc_write(struct file
*file
, const char __user
*buf
,
4771 size_t nbytes
, loff_t
*ppos
)
4773 struct lpfc_debug
*debug
= file
->private_data
;
4777 /* This is a user write operation */
4778 debug
->op
= LPFC_IDIAG_OP_WR
;
4780 rc
= lpfc_idiag_cmd_get(buf
, nbytes
, &idiag
.cmd
);
4784 ext_map
= idiag
.cmd
.data
[IDIAG_EXTACC_EXMAP_INDX
];
4786 if (idiag
.cmd
.opcode
!= LPFC_IDIAG_CMD_EXTACC_RD
)
4788 if (rc
!= LPFC_EXT_ACC_CMD_ARG
)
4790 if (!(ext_map
& LPFC_EXT_ACC_ALL
))
4795 /* Clean out command structure on command error out */
4796 memset(&idiag
, 0, sizeof(idiag
));
4801 * lpfc_idiag_extacc_read - idiag debugfs read access to extent information
4802 * @file: The file pointer to read from.
4803 * @buf: The buffer to copy the data to.
4804 * @nbytes: The number of bytes to read.
4805 * @ppos: The position in the file to start reading from.
4808 * This routine reads data from the proper extent information according to
4809 * the idiag command, and copies to user @buf.
4812 * This function returns the amount of data that was read (this could be less
4813 * than @nbytes if the end of the file was reached) or a negative error value.
4816 lpfc_idiag_extacc_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
4819 struct lpfc_debug
*debug
= file
->private_data
;
4820 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
4825 /* This is a user read operation */
4826 debug
->op
= LPFC_IDIAG_OP_RD
;
4829 debug
->buffer
= kmalloc(LPFC_EXT_ACC_BUF_SIZE
, GFP_KERNEL
);
4832 pbuffer
= debug
->buffer
;
4835 if (idiag
.cmd
.opcode
!= LPFC_IDIAG_CMD_EXTACC_RD
)
4838 ext_map
= idiag
.cmd
.data
[IDIAG_EXTACC_EXMAP_INDX
];
4839 if (ext_map
& LPFC_EXT_ACC_AVAIL
)
4840 len
= lpfc_idiag_extacc_avail_get(phba
, pbuffer
, len
);
4841 if (ext_map
& LPFC_EXT_ACC_ALLOC
)
4842 len
= lpfc_idiag_extacc_alloc_get(phba
, pbuffer
, len
);
4843 if (ext_map
& LPFC_EXT_ACC_DRIVR
)
4844 len
= lpfc_idiag_extacc_drivr_get(phba
, pbuffer
, len
);
4846 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
4849 #undef lpfc_debugfs_op_disc_trc
4850 static const struct file_operations lpfc_debugfs_op_disc_trc
= {
4851 .owner
= THIS_MODULE
,
4852 .open
= lpfc_debugfs_disc_trc_open
,
4853 .llseek
= lpfc_debugfs_lseek
,
4854 .read
= lpfc_debugfs_read
,
4855 .release
= lpfc_debugfs_release
,
4858 #undef lpfc_debugfs_op_nodelist
4859 static const struct file_operations lpfc_debugfs_op_nodelist
= {
4860 .owner
= THIS_MODULE
,
4861 .open
= lpfc_debugfs_nodelist_open
,
4862 .llseek
= lpfc_debugfs_lseek
,
4863 .read
= lpfc_debugfs_read
,
4864 .release
= lpfc_debugfs_release
,
4867 #undef lpfc_debugfs_op_hbqinfo
4868 static const struct file_operations lpfc_debugfs_op_hbqinfo
= {
4869 .owner
= THIS_MODULE
,
4870 .open
= lpfc_debugfs_hbqinfo_open
,
4871 .llseek
= lpfc_debugfs_lseek
,
4872 .read
= lpfc_debugfs_read
,
4873 .release
= lpfc_debugfs_release
,
4876 #undef lpfc_debugfs_op_dumpHBASlim
4877 static const struct file_operations lpfc_debugfs_op_dumpHBASlim
= {
4878 .owner
= THIS_MODULE
,
4879 .open
= lpfc_debugfs_dumpHBASlim_open
,
4880 .llseek
= lpfc_debugfs_lseek
,
4881 .read
= lpfc_debugfs_read
,
4882 .release
= lpfc_debugfs_release
,
4885 #undef lpfc_debugfs_op_dumpHostSlim
4886 static const struct file_operations lpfc_debugfs_op_dumpHostSlim
= {
4887 .owner
= THIS_MODULE
,
4888 .open
= lpfc_debugfs_dumpHostSlim_open
,
4889 .llseek
= lpfc_debugfs_lseek
,
4890 .read
= lpfc_debugfs_read
,
4891 .release
= lpfc_debugfs_release
,
4894 #undef lpfc_debugfs_op_nvmestat
4895 static const struct file_operations lpfc_debugfs_op_nvmestat
= {
4896 .owner
= THIS_MODULE
,
4897 .open
= lpfc_debugfs_nvmestat_open
,
4898 .llseek
= lpfc_debugfs_lseek
,
4899 .read
= lpfc_debugfs_read
,
4900 .write
= lpfc_debugfs_nvmestat_write
,
4901 .release
= lpfc_debugfs_release
,
4904 #undef lpfc_debugfs_op_nvmektime
4905 static const struct file_operations lpfc_debugfs_op_nvmektime
= {
4906 .owner
= THIS_MODULE
,
4907 .open
= lpfc_debugfs_nvmektime_open
,
4908 .llseek
= lpfc_debugfs_lseek
,
4909 .read
= lpfc_debugfs_read
,
4910 .write
= lpfc_debugfs_nvmektime_write
,
4911 .release
= lpfc_debugfs_release
,
4914 #undef lpfc_debugfs_op_nvmeio_trc
4915 static const struct file_operations lpfc_debugfs_op_nvmeio_trc
= {
4916 .owner
= THIS_MODULE
,
4917 .open
= lpfc_debugfs_nvmeio_trc_open
,
4918 .llseek
= lpfc_debugfs_lseek
,
4919 .read
= lpfc_debugfs_read
,
4920 .write
= lpfc_debugfs_nvmeio_trc_write
,
4921 .release
= lpfc_debugfs_release
,
4924 #undef lpfc_debugfs_op_cpucheck
4925 static const struct file_operations lpfc_debugfs_op_cpucheck
= {
4926 .owner
= THIS_MODULE
,
4927 .open
= lpfc_debugfs_cpucheck_open
,
4928 .llseek
= lpfc_debugfs_lseek
,
4929 .read
= lpfc_debugfs_read
,
4930 .write
= lpfc_debugfs_cpucheck_write
,
4931 .release
= lpfc_debugfs_release
,
4934 #undef lpfc_debugfs_op_dumpData
4935 static const struct file_operations lpfc_debugfs_op_dumpData
= {
4936 .owner
= THIS_MODULE
,
4937 .open
= lpfc_debugfs_dumpData_open
,
4938 .llseek
= lpfc_debugfs_lseek
,
4939 .read
= lpfc_debugfs_read
,
4940 .write
= lpfc_debugfs_dumpDataDif_write
,
4941 .release
= lpfc_debugfs_dumpDataDif_release
,
4944 #undef lpfc_debugfs_op_dumpDif
4945 static const struct file_operations lpfc_debugfs_op_dumpDif
= {
4946 .owner
= THIS_MODULE
,
4947 .open
= lpfc_debugfs_dumpDif_open
,
4948 .llseek
= lpfc_debugfs_lseek
,
4949 .read
= lpfc_debugfs_read
,
4950 .write
= lpfc_debugfs_dumpDataDif_write
,
4951 .release
= lpfc_debugfs_dumpDataDif_release
,
4954 #undef lpfc_debugfs_op_dif_err
4955 static const struct file_operations lpfc_debugfs_op_dif_err
= {
4956 .owner
= THIS_MODULE
,
4957 .open
= simple_open
,
4958 .llseek
= lpfc_debugfs_lseek
,
4959 .read
= lpfc_debugfs_dif_err_read
,
4960 .write
= lpfc_debugfs_dif_err_write
,
4961 .release
= lpfc_debugfs_dif_err_release
,
4964 #undef lpfc_debugfs_op_slow_ring_trc
4965 static const struct file_operations lpfc_debugfs_op_slow_ring_trc
= {
4966 .owner
= THIS_MODULE
,
4967 .open
= lpfc_debugfs_slow_ring_trc_open
,
4968 .llseek
= lpfc_debugfs_lseek
,
4969 .read
= lpfc_debugfs_read
,
4970 .release
= lpfc_debugfs_release
,
4973 static struct dentry
*lpfc_debugfs_root
= NULL
;
4974 static atomic_t lpfc_debugfs_hba_count
;
4977 * File operations for the iDiag debugfs
4979 #undef lpfc_idiag_op_pciCfg
4980 static const struct file_operations lpfc_idiag_op_pciCfg
= {
4981 .owner
= THIS_MODULE
,
4982 .open
= lpfc_idiag_open
,
4983 .llseek
= lpfc_debugfs_lseek
,
4984 .read
= lpfc_idiag_pcicfg_read
,
4985 .write
= lpfc_idiag_pcicfg_write
,
4986 .release
= lpfc_idiag_cmd_release
,
4989 #undef lpfc_idiag_op_barAcc
4990 static const struct file_operations lpfc_idiag_op_barAcc
= {
4991 .owner
= THIS_MODULE
,
4992 .open
= lpfc_idiag_open
,
4993 .llseek
= lpfc_debugfs_lseek
,
4994 .read
= lpfc_idiag_baracc_read
,
4995 .write
= lpfc_idiag_baracc_write
,
4996 .release
= lpfc_idiag_cmd_release
,
4999 #undef lpfc_idiag_op_queInfo
5000 static const struct file_operations lpfc_idiag_op_queInfo
= {
5001 .owner
= THIS_MODULE
,
5002 .open
= lpfc_idiag_open
,
5003 .read
= lpfc_idiag_queinfo_read
,
5004 .release
= lpfc_idiag_release
,
5007 #undef lpfc_idiag_op_queAcc
5008 static const struct file_operations lpfc_idiag_op_queAcc
= {
5009 .owner
= THIS_MODULE
,
5010 .open
= lpfc_idiag_open
,
5011 .llseek
= lpfc_debugfs_lseek
,
5012 .read
= lpfc_idiag_queacc_read
,
5013 .write
= lpfc_idiag_queacc_write
,
5014 .release
= lpfc_idiag_cmd_release
,
5017 #undef lpfc_idiag_op_drbAcc
5018 static const struct file_operations lpfc_idiag_op_drbAcc
= {
5019 .owner
= THIS_MODULE
,
5020 .open
= lpfc_idiag_open
,
5021 .llseek
= lpfc_debugfs_lseek
,
5022 .read
= lpfc_idiag_drbacc_read
,
5023 .write
= lpfc_idiag_drbacc_write
,
5024 .release
= lpfc_idiag_cmd_release
,
5027 #undef lpfc_idiag_op_ctlAcc
5028 static const struct file_operations lpfc_idiag_op_ctlAcc
= {
5029 .owner
= THIS_MODULE
,
5030 .open
= lpfc_idiag_open
,
5031 .llseek
= lpfc_debugfs_lseek
,
5032 .read
= lpfc_idiag_ctlacc_read
,
5033 .write
= lpfc_idiag_ctlacc_write
,
5034 .release
= lpfc_idiag_cmd_release
,
5037 #undef lpfc_idiag_op_mbxAcc
5038 static const struct file_operations lpfc_idiag_op_mbxAcc
= {
5039 .owner
= THIS_MODULE
,
5040 .open
= lpfc_idiag_open
,
5041 .llseek
= lpfc_debugfs_lseek
,
5042 .read
= lpfc_idiag_mbxacc_read
,
5043 .write
= lpfc_idiag_mbxacc_write
,
5044 .release
= lpfc_idiag_cmd_release
,
5047 #undef lpfc_idiag_op_extAcc
5048 static const struct file_operations lpfc_idiag_op_extAcc
= {
5049 .owner
= THIS_MODULE
,
5050 .open
= lpfc_idiag_open
,
5051 .llseek
= lpfc_debugfs_lseek
,
5052 .read
= lpfc_idiag_extacc_read
,
5053 .write
= lpfc_idiag_extacc_write
,
5054 .release
= lpfc_idiag_cmd_release
,
5059 /* lpfc_idiag_mbxacc_dump_bsg_mbox - idiag debugfs dump bsg mailbox command
5060 * @phba: Pointer to HBA context object.
5061 * @dmabuf: Pointer to a DMA buffer descriptor.
5064 * This routine dump a bsg pass-through non-embedded mailbox command with
5068 lpfc_idiag_mbxacc_dump_bsg_mbox(struct lpfc_hba
*phba
, enum nemb_type nemb_tp
,
5069 enum mbox_type mbox_tp
, enum dma_type dma_tp
,
5070 enum sta_type sta_tp
,
5071 struct lpfc_dmabuf
*dmabuf
, uint32_t ext_buf
)
5073 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
5074 uint32_t *mbx_mbox_cmd
, *mbx_dump_map
, *mbx_dump_cnt
, *mbx_word_cnt
;
5075 char line_buf
[LPFC_MBX_ACC_LBUF_SZ
];
5077 uint32_t do_dump
= 0;
5081 if (idiag
.cmd
.opcode
!= LPFC_IDIAG_BSG_MBXACC_DP
)
5084 mbx_mbox_cmd
= &idiag
.cmd
.data
[IDIAG_MBXACC_MBCMD_INDX
];
5085 mbx_dump_map
= &idiag
.cmd
.data
[IDIAG_MBXACC_DPMAP_INDX
];
5086 mbx_dump_cnt
= &idiag
.cmd
.data
[IDIAG_MBXACC_DPCNT_INDX
];
5087 mbx_word_cnt
= &idiag
.cmd
.data
[IDIAG_MBXACC_WDCNT_INDX
];
5089 if (!(*mbx_dump_map
& LPFC_MBX_DMP_ALL
) ||
5090 (*mbx_dump_cnt
== 0) ||
5091 (*mbx_word_cnt
== 0))
5094 if (*mbx_mbox_cmd
!= 0x9B)
5097 if ((mbox_tp
== mbox_rd
) && (dma_tp
== dma_mbox
)) {
5098 if (*mbx_dump_map
& LPFC_BSG_DMP_MBX_RD_MBX
) {
5099 do_dump
|= LPFC_BSG_DMP_MBX_RD_MBX
;
5100 pr_err("\nRead mbox command (x%x), "
5101 "nemb:0x%x, extbuf_cnt:%d:\n",
5102 sta_tp
, nemb_tp
, ext_buf
);
5105 if ((mbox_tp
== mbox_rd
) && (dma_tp
== dma_ebuf
)) {
5106 if (*mbx_dump_map
& LPFC_BSG_DMP_MBX_RD_BUF
) {
5107 do_dump
|= LPFC_BSG_DMP_MBX_RD_BUF
;
5108 pr_err("\nRead mbox buffer (x%x), "
5109 "nemb:0x%x, extbuf_seq:%d:\n",
5110 sta_tp
, nemb_tp
, ext_buf
);
5113 if ((mbox_tp
== mbox_wr
) && (dma_tp
== dma_mbox
)) {
5114 if (*mbx_dump_map
& LPFC_BSG_DMP_MBX_WR_MBX
) {
5115 do_dump
|= LPFC_BSG_DMP_MBX_WR_MBX
;
5116 pr_err("\nWrite mbox command (x%x), "
5117 "nemb:0x%x, extbuf_cnt:%d:\n",
5118 sta_tp
, nemb_tp
, ext_buf
);
5121 if ((mbox_tp
== mbox_wr
) && (dma_tp
== dma_ebuf
)) {
5122 if (*mbx_dump_map
& LPFC_BSG_DMP_MBX_WR_BUF
) {
5123 do_dump
|= LPFC_BSG_DMP_MBX_WR_BUF
;
5124 pr_err("\nWrite mbox buffer (x%x), "
5125 "nemb:0x%x, extbuf_seq:%d:\n",
5126 sta_tp
, nemb_tp
, ext_buf
);
5130 /* dump buffer content */
5132 pword
= (uint32_t *)dmabuf
->virt
;
5133 for (i
= 0; i
< *mbx_word_cnt
; i
++) {
5136 pr_err("%s\n", line_buf
);
5138 len
+= snprintf(line_buf
+len
,
5139 LPFC_MBX_ACC_LBUF_SZ
-len
,
5142 len
+= snprintf(line_buf
+len
, LPFC_MBX_ACC_LBUF_SZ
-len
,
5143 "%08x ", (uint32_t)*pword
);
5147 pr_err("%s\n", line_buf
);
5151 /* Clean out command structure on reaching dump count */
5152 if (*mbx_dump_cnt
== 0)
5153 memset(&idiag
, 0, sizeof(idiag
));
5158 /* lpfc_idiag_mbxacc_dump_issue_mbox - idiag debugfs dump issue mailbox command
5159 * @phba: Pointer to HBA context object.
5160 * @dmabuf: Pointer to a DMA buffer descriptor.
5163 * This routine dump a pass-through non-embedded mailbox command from issue
5167 lpfc_idiag_mbxacc_dump_issue_mbox(struct lpfc_hba
*phba
, MAILBOX_t
*pmbox
)
5169 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
5170 uint32_t *mbx_dump_map
, *mbx_dump_cnt
, *mbx_word_cnt
, *mbx_mbox_cmd
;
5171 char line_buf
[LPFC_MBX_ACC_LBUF_SZ
];
5177 if (idiag
.cmd
.opcode
!= LPFC_IDIAG_CMD_MBXACC_DP
)
5180 mbx_mbox_cmd
= &idiag
.cmd
.data
[IDIAG_MBXACC_MBCMD_INDX
];
5181 mbx_dump_map
= &idiag
.cmd
.data
[IDIAG_MBXACC_DPMAP_INDX
];
5182 mbx_dump_cnt
= &idiag
.cmd
.data
[IDIAG_MBXACC_DPCNT_INDX
];
5183 mbx_word_cnt
= &idiag
.cmd
.data
[IDIAG_MBXACC_WDCNT_INDX
];
5185 if (!(*mbx_dump_map
& LPFC_MBX_DMP_MBX_ALL
) ||
5186 (*mbx_dump_cnt
== 0) ||
5187 (*mbx_word_cnt
== 0))
5190 if ((*mbx_mbox_cmd
!= LPFC_MBX_ALL_CMD
) &&
5191 (*mbx_mbox_cmd
!= pmbox
->mbxCommand
))
5194 /* dump buffer content */
5195 if (*mbx_dump_map
& LPFC_MBX_DMP_MBX_WORD
) {
5196 pr_err("Mailbox command:0x%x dump by word:\n",
5198 pword
= (uint32_t *)pmbox
;
5199 for (i
= 0; i
< *mbx_word_cnt
; i
++) {
5202 pr_err("%s\n", line_buf
);
5204 memset(line_buf
, 0, LPFC_MBX_ACC_LBUF_SZ
);
5205 len
+= snprintf(line_buf
+len
,
5206 LPFC_MBX_ACC_LBUF_SZ
-len
,
5209 len
+= snprintf(line_buf
+len
, LPFC_MBX_ACC_LBUF_SZ
-len
,
5211 ((uint32_t)*pword
) & 0xffffffff);
5215 pr_err("%s\n", line_buf
);
5218 if (*mbx_dump_map
& LPFC_MBX_DMP_MBX_BYTE
) {
5219 pr_err("Mailbox command:0x%x dump by byte:\n",
5221 pbyte
= (uint8_t *)pmbox
;
5222 for (i
= 0; i
< *mbx_word_cnt
; i
++) {
5225 pr_err("%s\n", line_buf
);
5227 memset(line_buf
, 0, LPFC_MBX_ACC_LBUF_SZ
);
5228 len
+= snprintf(line_buf
+len
,
5229 LPFC_MBX_ACC_LBUF_SZ
-len
,
5232 for (j
= 0; j
< 4; j
++) {
5233 len
+= snprintf(line_buf
+len
,
5234 LPFC_MBX_ACC_LBUF_SZ
-len
,
5236 ((uint8_t)*pbyte
) & 0xff);
5239 len
+= snprintf(line_buf
+len
,
5240 LPFC_MBX_ACC_LBUF_SZ
-len
, " ");
5243 pr_err("%s\n", line_buf
);
5248 /* Clean out command structure on reaching dump count */
5249 if (*mbx_dump_cnt
== 0)
5250 memset(&idiag
, 0, sizeof(idiag
));
5256 * lpfc_debugfs_initialize - Initialize debugfs for a vport
5257 * @vport: The vport pointer to initialize.
5260 * When Debugfs is configured this routine sets up the lpfc debugfs file system.
5261 * If not already created, this routine will create the lpfc directory, and
5262 * lpfcX directory (for this HBA), and vportX directory for this vport. It will
5263 * also create each file used to access lpfc specific debugfs information.
5266 lpfc_debugfs_initialize(struct lpfc_vport
*vport
)
5268 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
5269 struct lpfc_hba
*phba
= vport
->phba
;
5272 bool pport_setup
= false;
5274 if (!lpfc_debugfs_enable
)
5277 /* Setup lpfc root directory */
5278 if (!lpfc_debugfs_root
) {
5279 lpfc_debugfs_root
= debugfs_create_dir("lpfc", NULL
);
5280 atomic_set(&lpfc_debugfs_hba_count
, 0);
5281 if (!lpfc_debugfs_root
) {
5282 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5283 "0408 Cannot create debugfs root\n");
5287 if (!lpfc_debugfs_start_time
)
5288 lpfc_debugfs_start_time
= jiffies
;
5290 /* Setup funcX directory for specific HBA PCI function */
5291 snprintf(name
, sizeof(name
), "fn%d", phba
->brd_no
);
5292 if (!phba
->hba_debugfs_root
) {
5294 phba
->hba_debugfs_root
=
5295 debugfs_create_dir(name
, lpfc_debugfs_root
);
5296 if (!phba
->hba_debugfs_root
) {
5297 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5298 "0412 Cannot create debugfs hba\n");
5301 atomic_inc(&lpfc_debugfs_hba_count
);
5302 atomic_set(&phba
->debugfs_vport_count
, 0);
5305 snprintf(name
, sizeof(name
), "hbqinfo");
5306 phba
->debug_hbqinfo
=
5307 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5308 phba
->hba_debugfs_root
,
5309 phba
, &lpfc_debugfs_op_hbqinfo
);
5310 if (!phba
->debug_hbqinfo
) {
5311 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5312 "0411 Cannot create debugfs hbqinfo\n");
5316 /* Setup dumpHBASlim */
5317 if (phba
->sli_rev
< LPFC_SLI_REV4
) {
5318 snprintf(name
, sizeof(name
), "dumpHBASlim");
5319 phba
->debug_dumpHBASlim
=
5320 debugfs_create_file(name
,
5321 S_IFREG
|S_IRUGO
|S_IWUSR
,
5322 phba
->hba_debugfs_root
,
5323 phba
, &lpfc_debugfs_op_dumpHBASlim
);
5324 if (!phba
->debug_dumpHBASlim
) {
5325 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5326 "0413 Cannot create debugfs "
5331 phba
->debug_dumpHBASlim
= NULL
;
5333 /* Setup dumpHostSlim */
5334 if (phba
->sli_rev
< LPFC_SLI_REV4
) {
5335 snprintf(name
, sizeof(name
), "dumpHostSlim");
5336 phba
->debug_dumpHostSlim
=
5337 debugfs_create_file(name
,
5338 S_IFREG
|S_IRUGO
|S_IWUSR
,
5339 phba
->hba_debugfs_root
,
5340 phba
, &lpfc_debugfs_op_dumpHostSlim
);
5341 if (!phba
->debug_dumpHostSlim
) {
5342 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5343 "0414 Cannot create debugfs "
5348 phba
->debug_dumpHostSlim
= NULL
;
5350 /* Setup dumpData */
5351 snprintf(name
, sizeof(name
), "dumpData");
5352 phba
->debug_dumpData
=
5353 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5354 phba
->hba_debugfs_root
,
5355 phba
, &lpfc_debugfs_op_dumpData
);
5356 if (!phba
->debug_dumpData
) {
5357 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5358 "0800 Cannot create debugfs dumpData\n");
5363 snprintf(name
, sizeof(name
), "dumpDif");
5364 phba
->debug_dumpDif
=
5365 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5366 phba
->hba_debugfs_root
,
5367 phba
, &lpfc_debugfs_op_dumpDif
);
5368 if (!phba
->debug_dumpDif
) {
5369 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5370 "0801 Cannot create debugfs dumpDif\n");
5374 /* Setup DIF Error Injections */
5375 snprintf(name
, sizeof(name
), "InjErrLBA");
5376 phba
->debug_InjErrLBA
=
5377 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5378 phba
->hba_debugfs_root
,
5379 phba
, &lpfc_debugfs_op_dif_err
);
5380 if (!phba
->debug_InjErrLBA
) {
5381 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5382 "0807 Cannot create debugfs InjErrLBA\n");
5385 phba
->lpfc_injerr_lba
= LPFC_INJERR_LBA_OFF
;
5387 snprintf(name
, sizeof(name
), "InjErrNPortID");
5388 phba
->debug_InjErrNPortID
=
5389 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5390 phba
->hba_debugfs_root
,
5391 phba
, &lpfc_debugfs_op_dif_err
);
5392 if (!phba
->debug_InjErrNPortID
) {
5393 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5394 "0809 Cannot create debugfs InjErrNPortID\n");
5398 snprintf(name
, sizeof(name
), "InjErrWWPN");
5399 phba
->debug_InjErrWWPN
=
5400 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5401 phba
->hba_debugfs_root
,
5402 phba
, &lpfc_debugfs_op_dif_err
);
5403 if (!phba
->debug_InjErrWWPN
) {
5404 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5405 "0810 Cannot create debugfs InjErrWWPN\n");
5409 snprintf(name
, sizeof(name
), "writeGuardInjErr");
5410 phba
->debug_writeGuard
=
5411 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5412 phba
->hba_debugfs_root
,
5413 phba
, &lpfc_debugfs_op_dif_err
);
5414 if (!phba
->debug_writeGuard
) {
5415 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5416 "0802 Cannot create debugfs writeGuard\n");
5420 snprintf(name
, sizeof(name
), "writeAppInjErr");
5421 phba
->debug_writeApp
=
5422 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5423 phba
->hba_debugfs_root
,
5424 phba
, &lpfc_debugfs_op_dif_err
);
5425 if (!phba
->debug_writeApp
) {
5426 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5427 "0803 Cannot create debugfs writeApp\n");
5431 snprintf(name
, sizeof(name
), "writeRefInjErr");
5432 phba
->debug_writeRef
=
5433 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5434 phba
->hba_debugfs_root
,
5435 phba
, &lpfc_debugfs_op_dif_err
);
5436 if (!phba
->debug_writeRef
) {
5437 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5438 "0804 Cannot create debugfs writeRef\n");
5442 snprintf(name
, sizeof(name
), "readGuardInjErr");
5443 phba
->debug_readGuard
=
5444 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5445 phba
->hba_debugfs_root
,
5446 phba
, &lpfc_debugfs_op_dif_err
);
5447 if (!phba
->debug_readGuard
) {
5448 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5449 "0808 Cannot create debugfs readGuard\n");
5453 snprintf(name
, sizeof(name
), "readAppInjErr");
5454 phba
->debug_readApp
=
5455 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5456 phba
->hba_debugfs_root
,
5457 phba
, &lpfc_debugfs_op_dif_err
);
5458 if (!phba
->debug_readApp
) {
5459 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5460 "0805 Cannot create debugfs readApp\n");
5464 snprintf(name
, sizeof(name
), "readRefInjErr");
5465 phba
->debug_readRef
=
5466 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5467 phba
->hba_debugfs_root
,
5468 phba
, &lpfc_debugfs_op_dif_err
);
5469 if (!phba
->debug_readRef
) {
5470 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5471 "0806 Cannot create debugfs readApp\n");
5475 /* Setup slow ring trace */
5476 if (lpfc_debugfs_max_slow_ring_trc
) {
5477 num
= lpfc_debugfs_max_slow_ring_trc
- 1;
5478 if (num
& lpfc_debugfs_max_slow_ring_trc
) {
5479 /* Change to be a power of 2 */
5480 num
= lpfc_debugfs_max_slow_ring_trc
;
5486 lpfc_debugfs_max_slow_ring_trc
= (1 << i
);
5487 pr_err("lpfc_debugfs_max_disc_trc changed to "
5488 "%d\n", lpfc_debugfs_max_disc_trc
);
5492 snprintf(name
, sizeof(name
), "slow_ring_trace");
5493 phba
->debug_slow_ring_trc
=
5494 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5495 phba
->hba_debugfs_root
,
5496 phba
, &lpfc_debugfs_op_slow_ring_trc
);
5497 if (!phba
->debug_slow_ring_trc
) {
5498 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5499 "0415 Cannot create debugfs "
5500 "slow_ring_trace\n");
5503 if (!phba
->slow_ring_trc
) {
5504 phba
->slow_ring_trc
= kmalloc(
5505 (sizeof(struct lpfc_debugfs_trc
) *
5506 lpfc_debugfs_max_slow_ring_trc
),
5508 if (!phba
->slow_ring_trc
) {
5509 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5510 "0416 Cannot create debugfs "
5511 "slow_ring buffer\n");
5514 atomic_set(&phba
->slow_ring_trc_cnt
, 0);
5515 memset(phba
->slow_ring_trc
, 0,
5516 (sizeof(struct lpfc_debugfs_trc
) *
5517 lpfc_debugfs_max_slow_ring_trc
));
5520 snprintf(name
, sizeof(name
), "nvmeio_trc");
5521 phba
->debug_nvmeio_trc
=
5522 debugfs_create_file(name
, 0644,
5523 phba
->hba_debugfs_root
,
5524 phba
, &lpfc_debugfs_op_nvmeio_trc
);
5525 if (!phba
->debug_nvmeio_trc
) {
5526 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5527 "0574 No create debugfs nvmeio_trc\n");
5531 atomic_set(&phba
->nvmeio_trc_cnt
, 0);
5532 if (lpfc_debugfs_max_nvmeio_trc
) {
5533 num
= lpfc_debugfs_max_nvmeio_trc
- 1;
5534 if (num
& lpfc_debugfs_max_disc_trc
) {
5535 /* Change to be a power of 2 */
5536 num
= lpfc_debugfs_max_nvmeio_trc
;
5542 lpfc_debugfs_max_nvmeio_trc
= (1 << i
);
5543 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
5544 "0575 lpfc_debugfs_max_nvmeio_trc "
5546 lpfc_debugfs_max_nvmeio_trc
);
5548 phba
->nvmeio_trc_size
= lpfc_debugfs_max_nvmeio_trc
;
5550 /* Allocate trace buffer and initialize */
5551 phba
->nvmeio_trc
= kzalloc(
5552 (sizeof(struct lpfc_debugfs_nvmeio_trc
) *
5553 phba
->nvmeio_trc_size
), GFP_KERNEL
);
5555 if (!phba
->nvmeio_trc
) {
5556 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
5557 "0576 Cannot create debugfs "
5558 "nvmeio_trc buffer\n");
5561 phba
->nvmeio_trc_on
= 1;
5562 phba
->nvmeio_trc_output_idx
= 0;
5563 phba
->nvmeio_trc
= NULL
;
5566 phba
->nvmeio_trc_size
= 0;
5567 phba
->nvmeio_trc_on
= 0;
5568 phba
->nvmeio_trc_output_idx
= 0;
5569 phba
->nvmeio_trc
= NULL
;
5573 snprintf(name
, sizeof(name
), "vport%d", vport
->vpi
);
5574 if (!vport
->vport_debugfs_root
) {
5575 vport
->vport_debugfs_root
=
5576 debugfs_create_dir(name
, phba
->hba_debugfs_root
);
5577 if (!vport
->vport_debugfs_root
) {
5578 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5579 "0417 Can't create debugfs\n");
5582 atomic_inc(&phba
->debugfs_vport_count
);
5585 if (lpfc_debugfs_max_disc_trc
) {
5586 num
= lpfc_debugfs_max_disc_trc
- 1;
5587 if (num
& lpfc_debugfs_max_disc_trc
) {
5588 /* Change to be a power of 2 */
5589 num
= lpfc_debugfs_max_disc_trc
;
5595 lpfc_debugfs_max_disc_trc
= (1 << i
);
5596 pr_err("lpfc_debugfs_max_disc_trc changed to %d\n",
5597 lpfc_debugfs_max_disc_trc
);
5601 vport
->disc_trc
= kzalloc(
5602 (sizeof(struct lpfc_debugfs_trc
) * lpfc_debugfs_max_disc_trc
),
5605 if (!vport
->disc_trc
) {
5606 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5607 "0418 Cannot create debugfs disc trace "
5611 atomic_set(&vport
->disc_trc_cnt
, 0);
5613 snprintf(name
, sizeof(name
), "discovery_trace");
5614 vport
->debug_disc_trc
=
5615 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5616 vport
->vport_debugfs_root
,
5617 vport
, &lpfc_debugfs_op_disc_trc
);
5618 if (!vport
->debug_disc_trc
) {
5619 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5620 "0419 Cannot create debugfs "
5621 "discovery_trace\n");
5624 snprintf(name
, sizeof(name
), "nodelist");
5625 vport
->debug_nodelist
=
5626 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5627 vport
->vport_debugfs_root
,
5628 vport
, &lpfc_debugfs_op_nodelist
);
5629 if (!vport
->debug_nodelist
) {
5630 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5631 "2985 Can't create debugfs nodelist\n");
5635 snprintf(name
, sizeof(name
), "nvmestat");
5636 vport
->debug_nvmestat
=
5637 debugfs_create_file(name
, 0644,
5638 vport
->vport_debugfs_root
,
5639 vport
, &lpfc_debugfs_op_nvmestat
);
5640 if (!vport
->debug_nvmestat
) {
5641 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5642 "0811 Cannot create debugfs nvmestat\n");
5646 snprintf(name
, sizeof(name
), "nvmektime");
5647 vport
->debug_nvmektime
=
5648 debugfs_create_file(name
, 0644,
5649 vport
->vport_debugfs_root
,
5650 vport
, &lpfc_debugfs_op_nvmektime
);
5651 if (!vport
->debug_nvmektime
) {
5652 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5653 "0815 Cannot create debugfs nvmektime\n");
5657 snprintf(name
, sizeof(name
), "cpucheck");
5658 vport
->debug_cpucheck
=
5659 debugfs_create_file(name
, 0644,
5660 vport
->vport_debugfs_root
,
5661 vport
, &lpfc_debugfs_op_cpucheck
);
5662 if (!vport
->debug_cpucheck
) {
5663 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5664 "0819 Cannot create debugfs cpucheck\n");
5669 * The following section is for additional directories/files for the
5677 * iDiag debugfs root entry points for SLI4 device only
5679 if (phba
->sli_rev
< LPFC_SLI_REV4
)
5682 snprintf(name
, sizeof(name
), "iDiag");
5683 if (!phba
->idiag_root
) {
5685 debugfs_create_dir(name
, phba
->hba_debugfs_root
);
5686 if (!phba
->idiag_root
) {
5687 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5688 "2922 Can't create idiag debugfs\n");
5691 /* Initialize iDiag data structure */
5692 memset(&idiag
, 0, sizeof(idiag
));
5695 /* iDiag read PCI config space */
5696 snprintf(name
, sizeof(name
), "pciCfg");
5697 if (!phba
->idiag_pci_cfg
) {
5698 phba
->idiag_pci_cfg
=
5699 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5700 phba
->idiag_root
, phba
, &lpfc_idiag_op_pciCfg
);
5701 if (!phba
->idiag_pci_cfg
) {
5702 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5703 "2923 Can't create idiag debugfs\n");
5706 idiag
.offset
.last_rd
= 0;
5709 /* iDiag PCI BAR access */
5710 snprintf(name
, sizeof(name
), "barAcc");
5711 if (!phba
->idiag_bar_acc
) {
5712 phba
->idiag_bar_acc
=
5713 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5714 phba
->idiag_root
, phba
, &lpfc_idiag_op_barAcc
);
5715 if (!phba
->idiag_bar_acc
) {
5716 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5717 "3056 Can't create idiag debugfs\n");
5720 idiag
.offset
.last_rd
= 0;
5723 /* iDiag get PCI function queue information */
5724 snprintf(name
, sizeof(name
), "queInfo");
5725 if (!phba
->idiag_que_info
) {
5726 phba
->idiag_que_info
=
5727 debugfs_create_file(name
, S_IFREG
|S_IRUGO
,
5728 phba
->idiag_root
, phba
, &lpfc_idiag_op_queInfo
);
5729 if (!phba
->idiag_que_info
) {
5730 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5731 "2924 Can't create idiag debugfs\n");
5736 /* iDiag access PCI function queue */
5737 snprintf(name
, sizeof(name
), "queAcc");
5738 if (!phba
->idiag_que_acc
) {
5739 phba
->idiag_que_acc
=
5740 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5741 phba
->idiag_root
, phba
, &lpfc_idiag_op_queAcc
);
5742 if (!phba
->idiag_que_acc
) {
5743 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5744 "2926 Can't create idiag debugfs\n");
5749 /* iDiag access PCI function doorbell registers */
5750 snprintf(name
, sizeof(name
), "drbAcc");
5751 if (!phba
->idiag_drb_acc
) {
5752 phba
->idiag_drb_acc
=
5753 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5754 phba
->idiag_root
, phba
, &lpfc_idiag_op_drbAcc
);
5755 if (!phba
->idiag_drb_acc
) {
5756 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5757 "2927 Can't create idiag debugfs\n");
5762 /* iDiag access PCI function control registers */
5763 snprintf(name
, sizeof(name
), "ctlAcc");
5764 if (!phba
->idiag_ctl_acc
) {
5765 phba
->idiag_ctl_acc
=
5766 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5767 phba
->idiag_root
, phba
, &lpfc_idiag_op_ctlAcc
);
5768 if (!phba
->idiag_ctl_acc
) {
5769 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5770 "2981 Can't create idiag debugfs\n");
5775 /* iDiag access mbox commands */
5776 snprintf(name
, sizeof(name
), "mbxAcc");
5777 if (!phba
->idiag_mbx_acc
) {
5778 phba
->idiag_mbx_acc
=
5779 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5780 phba
->idiag_root
, phba
, &lpfc_idiag_op_mbxAcc
);
5781 if (!phba
->idiag_mbx_acc
) {
5782 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5783 "2980 Can't create idiag debugfs\n");
5788 /* iDiag extents access commands */
5789 if (phba
->sli4_hba
.extents_in_use
) {
5790 snprintf(name
, sizeof(name
), "extAcc");
5791 if (!phba
->idiag_ext_acc
) {
5792 phba
->idiag_ext_acc
=
5793 debugfs_create_file(name
,
5794 S_IFREG
|S_IRUGO
|S_IWUSR
,
5795 phba
->idiag_root
, phba
,
5796 &lpfc_idiag_op_extAcc
);
5797 if (!phba
->idiag_ext_acc
) {
5798 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5812 * lpfc_debugfs_terminate - Tear down debugfs infrastructure for this vport
5813 * @vport: The vport pointer to remove from debugfs.
5816 * When Debugfs is configured this routine removes debugfs file system elements
5817 * that are specific to this vport. It also checks to see if there are any
5818 * users left for the debugfs directories associated with the HBA and driver. If
5819 * this is the last user of the HBA directory or driver directory then it will
5820 * remove those from the debugfs infrastructure as well.
5823 lpfc_debugfs_terminate(struct lpfc_vport
*vport
)
5825 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
5826 struct lpfc_hba
*phba
= vport
->phba
;
5828 kfree(vport
->disc_trc
);
5829 vport
->disc_trc
= NULL
;
5831 debugfs_remove(vport
->debug_disc_trc
); /* discovery_trace */
5832 vport
->debug_disc_trc
= NULL
;
5834 debugfs_remove(vport
->debug_nodelist
); /* nodelist */
5835 vport
->debug_nodelist
= NULL
;
5837 debugfs_remove(vport
->debug_nvmestat
); /* nvmestat */
5838 vport
->debug_nvmestat
= NULL
;
5840 debugfs_remove(vport
->debug_nvmektime
); /* nvmektime */
5841 vport
->debug_nvmektime
= NULL
;
5843 debugfs_remove(vport
->debug_cpucheck
); /* cpucheck */
5844 vport
->debug_cpucheck
= NULL
;
5846 if (vport
->vport_debugfs_root
) {
5847 debugfs_remove(vport
->vport_debugfs_root
); /* vportX */
5848 vport
->vport_debugfs_root
= NULL
;
5849 atomic_dec(&phba
->debugfs_vport_count
);
5852 if (atomic_read(&phba
->debugfs_vport_count
) == 0) {
5854 debugfs_remove(phba
->debug_hbqinfo
); /* hbqinfo */
5855 phba
->debug_hbqinfo
= NULL
;
5857 debugfs_remove(phba
->debug_dumpHBASlim
); /* HBASlim */
5858 phba
->debug_dumpHBASlim
= NULL
;
5860 debugfs_remove(phba
->debug_dumpHostSlim
); /* HostSlim */
5861 phba
->debug_dumpHostSlim
= NULL
;
5863 debugfs_remove(phba
->debug_dumpData
); /* dumpData */
5864 phba
->debug_dumpData
= NULL
;
5866 debugfs_remove(phba
->debug_dumpDif
); /* dumpDif */
5867 phba
->debug_dumpDif
= NULL
;
5869 debugfs_remove(phba
->debug_InjErrLBA
); /* InjErrLBA */
5870 phba
->debug_InjErrLBA
= NULL
;
5872 debugfs_remove(phba
->debug_InjErrNPortID
);
5873 phba
->debug_InjErrNPortID
= NULL
;
5875 debugfs_remove(phba
->debug_InjErrWWPN
); /* InjErrWWPN */
5876 phba
->debug_InjErrWWPN
= NULL
;
5878 debugfs_remove(phba
->debug_writeGuard
); /* writeGuard */
5879 phba
->debug_writeGuard
= NULL
;
5881 debugfs_remove(phba
->debug_writeApp
); /* writeApp */
5882 phba
->debug_writeApp
= NULL
;
5884 debugfs_remove(phba
->debug_writeRef
); /* writeRef */
5885 phba
->debug_writeRef
= NULL
;
5887 debugfs_remove(phba
->debug_readGuard
); /* readGuard */
5888 phba
->debug_readGuard
= NULL
;
5890 debugfs_remove(phba
->debug_readApp
); /* readApp */
5891 phba
->debug_readApp
= NULL
;
5893 debugfs_remove(phba
->debug_readRef
); /* readRef */
5894 phba
->debug_readRef
= NULL
;
5896 kfree(phba
->slow_ring_trc
);
5897 phba
->slow_ring_trc
= NULL
;
5899 /* slow_ring_trace */
5900 debugfs_remove(phba
->debug_slow_ring_trc
);
5901 phba
->debug_slow_ring_trc
= NULL
;
5903 debugfs_remove(phba
->debug_nvmeio_trc
);
5904 phba
->debug_nvmeio_trc
= NULL
;
5906 kfree(phba
->nvmeio_trc
);
5907 phba
->nvmeio_trc
= NULL
;
5912 if (phba
->sli_rev
== LPFC_SLI_REV4
) {
5914 debugfs_remove(phba
->idiag_ext_acc
);
5915 phba
->idiag_ext_acc
= NULL
;
5918 debugfs_remove(phba
->idiag_mbx_acc
);
5919 phba
->idiag_mbx_acc
= NULL
;
5922 debugfs_remove(phba
->idiag_ctl_acc
);
5923 phba
->idiag_ctl_acc
= NULL
;
5926 debugfs_remove(phba
->idiag_drb_acc
);
5927 phba
->idiag_drb_acc
= NULL
;
5930 debugfs_remove(phba
->idiag_que_acc
);
5931 phba
->idiag_que_acc
= NULL
;
5934 debugfs_remove(phba
->idiag_que_info
);
5935 phba
->idiag_que_info
= NULL
;
5938 debugfs_remove(phba
->idiag_bar_acc
);
5939 phba
->idiag_bar_acc
= NULL
;
5942 debugfs_remove(phba
->idiag_pci_cfg
);
5943 phba
->idiag_pci_cfg
= NULL
;
5945 /* Finally remove the iDiag debugfs root */
5946 debugfs_remove(phba
->idiag_root
);
5947 phba
->idiag_root
= NULL
;
5950 if (phba
->hba_debugfs_root
) {
5951 debugfs_remove(phba
->hba_debugfs_root
); /* fnX */
5952 phba
->hba_debugfs_root
= NULL
;
5953 atomic_dec(&lpfc_debugfs_hba_count
);
5956 if (atomic_read(&lpfc_debugfs_hba_count
) == 0) {
5957 debugfs_remove(lpfc_debugfs_root
); /* lpfc */
5958 lpfc_debugfs_root
= NULL
;
5966 * Driver debug utility routines outside of debugfs. The debug utility
5967 * routines implemented here is intended to be used in the instrumented
5968 * debug driver for debugging host or port issues.
5972 * lpfc_debug_dump_all_queues - dump all the queues with a hba
5973 * @phba: Pointer to HBA context object.
5975 * This function dumps entries of all the queues asociated with the @phba.
5978 lpfc_debug_dump_all_queues(struct lpfc_hba
*phba
)
5983 * Dump Work Queues (WQs)
5985 lpfc_debug_dump_wq(phba
, DUMP_MBX
, 0);
5986 lpfc_debug_dump_wq(phba
, DUMP_ELS
, 0);
5987 lpfc_debug_dump_wq(phba
, DUMP_NVMELS
, 0);
5989 for (idx
= 0; idx
< phba
->cfg_fcp_io_channel
; idx
++)
5990 lpfc_debug_dump_wq(phba
, DUMP_FCP
, idx
);
5992 for (idx
= 0; idx
< phba
->cfg_nvme_io_channel
; idx
++)
5993 lpfc_debug_dump_wq(phba
, DUMP_NVME
, idx
);
5995 lpfc_debug_dump_hdr_rq(phba
);
5996 lpfc_debug_dump_dat_rq(phba
);
5998 * Dump Complete Queues (CQs)
6000 lpfc_debug_dump_cq(phba
, DUMP_MBX
, 0);
6001 lpfc_debug_dump_cq(phba
, DUMP_ELS
, 0);
6002 lpfc_debug_dump_cq(phba
, DUMP_NVMELS
, 0);
6004 for (idx
= 0; idx
< phba
->cfg_fcp_io_channel
; idx
++)
6005 lpfc_debug_dump_cq(phba
, DUMP_FCP
, idx
);
6007 for (idx
= 0; idx
< phba
->cfg_nvme_io_channel
; idx
++)
6008 lpfc_debug_dump_cq(phba
, DUMP_NVME
, idx
);
6011 * Dump Event Queues (EQs)
6013 for (idx
= 0; idx
< phba
->io_channel_irqs
; idx
++)
6014 lpfc_debug_dump_hba_eq(phba
, idx
);