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 nvme_fc_remote_port
*nrport
= NULL
;
554 struct lpfc_nvme_rport
*rport
;
556 cnt
= (LPFC_NODELIST_SIZE
/ LPFC_NODELIST_ENTRY_SIZE
);
559 len
+= snprintf(buf
+len
, size
-len
, "\nFCP Nodelist Entries ...\n");
560 spin_lock_irq(shost
->host_lock
);
561 list_for_each_entry(ndlp
, &vport
->fc_nodes
, nlp_listp
) {
564 len
+= snprintf(buf
+len
, size
-len
,
565 "Missing Nodelist Entries\n");
569 switch (ndlp
->nlp_state
) {
570 case NLP_STE_UNUSED_NODE
:
573 case NLP_STE_PLOGI_ISSUE
:
576 case NLP_STE_ADISC_ISSUE
:
579 case NLP_STE_REG_LOGIN_ISSUE
:
582 case NLP_STE_PRLI_ISSUE
:
585 case NLP_STE_LOGO_ISSUE
:
588 case NLP_STE_UNMAPPED_NODE
:
592 case NLP_STE_MAPPED_NODE
:
596 case NLP_STE_NPR_NODE
:
602 len
+= snprintf(buf
+len
, size
-len
, "%s DID:x%06x ",
603 statep
, ndlp
->nlp_DID
);
604 len
+= snprintf(buf
+len
, size
-len
,
606 wwn_to_u64(ndlp
->nlp_portname
.u
.wwn
));
607 len
+= snprintf(buf
+len
, size
-len
,
609 wwn_to_u64(ndlp
->nlp_nodename
.u
.wwn
));
610 if (ndlp
->nlp_flag
& NLP_RPI_REGISTERED
)
611 len
+= snprintf(buf
+len
, size
-len
, "RPI:%03d ",
614 len
+= snprintf(buf
+len
, size
-len
, "RPI:none ");
615 len
+= snprintf(buf
+len
, size
-len
, "flag:x%08x ",
618 len
+= snprintf(buf
+len
, size
-len
, "UNKNOWN_TYPE ");
619 if (ndlp
->nlp_type
& NLP_FC_NODE
)
620 len
+= snprintf(buf
+len
, size
-len
, "FC_NODE ");
621 if (ndlp
->nlp_type
& NLP_FABRIC
) {
622 len
+= snprintf(buf
+len
, size
-len
, "FABRIC ");
625 if (ndlp
->nlp_type
& NLP_FCP_TARGET
)
626 len
+= snprintf(buf
+len
, size
-len
, "FCP_TGT sid:%d ",
628 if (ndlp
->nlp_type
& NLP_FCP_INITIATOR
)
629 len
+= snprintf(buf
+len
, size
-len
, "FCP_INITIATOR ");
630 if (ndlp
->nlp_type
& NLP_NVME_TARGET
)
631 len
+= snprintf(buf
+ len
,
632 size
- len
, "NVME_TGT sid:%d ",
634 if (ndlp
->nlp_type
& NLP_NVME_INITIATOR
)
635 len
+= snprintf(buf
+ len
,
636 size
- len
, "NVME_INITIATOR ");
637 len
+= snprintf(buf
+len
, size
-len
, "usgmap:%x ",
639 len
+= snprintf(buf
+len
, size
-len
, "refcnt:%x",
640 kref_read(&ndlp
->kref
));
642 i
= atomic_read(&ndlp
->cmd_pending
);
643 len
+= snprintf(buf
+ len
, size
- len
,
644 " OutIO:x%x Qdepth x%x",
645 i
, ndlp
->cmd_qdepth
);
648 len
+= snprintf(buf
+ len
, size
- len
, "defer:%x ",
649 ndlp
->nlp_defer_did
);
650 len
+= snprintf(buf
+len
, size
-len
, "\n");
652 spin_unlock_irq(shost
->host_lock
);
654 len
+= snprintf(buf
+ len
, size
- len
,
655 "\nOutstanding IO x%x\n", outio
);
657 if (phba
->nvmet_support
&& phba
->targetport
&& (vport
== phba
->pport
)) {
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 spin_lock(&phba
->hbalock
);
700 rport
= lpfc_ndlp_get_nrport(ndlp
);
702 nrport
= rport
->remoteport
;
705 spin_unlock(&phba
->hbalock
);
709 /* Port state is only one of two values for now. */
710 switch (nrport
->port_state
) {
711 case FC_OBJSTATE_ONLINE
:
714 case FC_OBJSTATE_UNKNOWN
:
718 statep
= "UNSUPPORTED";
722 /* Tab in to show lport ownership. */
723 len
+= snprintf(buf
+ len
, size
- len
,
724 "\t%s Port ID:x%06x ",
725 statep
, nrport
->port_id
);
726 len
+= snprintf(buf
+ len
, size
- len
, "WWPN x%llx ",
728 len
+= snprintf(buf
+ len
, size
- len
, "WWNN x%llx ",
731 /* An NVME rport can have multiple roles. */
732 if (nrport
->port_role
& FC_PORT_ROLE_NVME_INITIATOR
)
733 len
+= snprintf(buf
+ len
, size
- len
,
735 if (nrport
->port_role
& FC_PORT_ROLE_NVME_TARGET
)
736 len
+= snprintf(buf
+ len
, size
- len
,
738 if (nrport
->port_role
& FC_PORT_ROLE_NVME_DISCOVERY
)
739 len
+= snprintf(buf
+ len
, size
- len
,
741 if (nrport
->port_role
& ~(FC_PORT_ROLE_NVME_INITIATOR
|
742 FC_PORT_ROLE_NVME_TARGET
|
743 FC_PORT_ROLE_NVME_DISCOVERY
))
744 len
+= snprintf(buf
+ len
, size
- len
,
747 /* Terminate the string. */
748 len
+= snprintf(buf
+ len
, size
- len
, "\n");
751 spin_unlock_irq(shost
->host_lock
);
757 * lpfc_debugfs_nvmestat_data - Dump target node list to a buffer
758 * @vport: The vport to gather target node info from.
759 * @buf: The buffer to dump log into.
760 * @size: The maximum amount of data to process.
763 * This routine dumps the NVME statistics associated with @vport
766 * This routine returns the amount of bytes that were dumped into @buf and will
770 lpfc_debugfs_nvmestat_data(struct lpfc_vport
*vport
, char *buf
, int size
)
772 struct lpfc_hba
*phba
= vport
->phba
;
773 struct lpfc_nvmet_tgtport
*tgtp
;
774 struct lpfc_nvmet_rcv_ctx
*ctxp
, *next_ctxp
;
775 struct nvme_fc_local_port
*localport
;
776 struct lpfc_nvme_ctrl_stat
*cstat
;
777 struct lpfc_nvme_lport
*lport
;
778 uint64_t data1
, data2
, data3
;
779 uint64_t tot
, totin
, totout
;
783 if (phba
->nvmet_support
) {
784 if (!phba
->targetport
)
786 tgtp
= (struct lpfc_nvmet_tgtport
*)phba
->targetport
->private;
787 len
+= snprintf(buf
+ len
, size
- len
,
788 "\nNVME Targetport Statistics\n");
790 len
+= snprintf(buf
+ len
, size
- len
,
791 "LS: Rcv %08x Drop %08x Abort %08x\n",
792 atomic_read(&tgtp
->rcv_ls_req_in
),
793 atomic_read(&tgtp
->rcv_ls_req_drop
),
794 atomic_read(&tgtp
->xmt_ls_abort
));
795 if (atomic_read(&tgtp
->rcv_ls_req_in
) !=
796 atomic_read(&tgtp
->rcv_ls_req_out
)) {
797 len
+= snprintf(buf
+ len
, size
- len
,
798 "Rcv LS: in %08x != out %08x\n",
799 atomic_read(&tgtp
->rcv_ls_req_in
),
800 atomic_read(&tgtp
->rcv_ls_req_out
));
803 len
+= snprintf(buf
+ len
, size
- len
,
804 "LS: Xmt %08x Drop %08x Cmpl %08x\n",
805 atomic_read(&tgtp
->xmt_ls_rsp
),
806 atomic_read(&tgtp
->xmt_ls_drop
),
807 atomic_read(&tgtp
->xmt_ls_rsp_cmpl
));
809 len
+= snprintf(buf
+ len
, size
- len
,
810 "LS: RSP Abort %08x xb %08x Err %08x\n",
811 atomic_read(&tgtp
->xmt_ls_rsp_aborted
),
812 atomic_read(&tgtp
->xmt_ls_rsp_xb_set
),
813 atomic_read(&tgtp
->xmt_ls_rsp_error
));
815 len
+= snprintf(buf
+ len
, size
- len
,
816 "FCP: Rcv %08x Defer %08x Release %08x "
818 atomic_read(&tgtp
->rcv_fcp_cmd_in
),
819 atomic_read(&tgtp
->rcv_fcp_cmd_defer
),
820 atomic_read(&tgtp
->xmt_fcp_release
),
821 atomic_read(&tgtp
->rcv_fcp_cmd_drop
));
823 if (atomic_read(&tgtp
->rcv_fcp_cmd_in
) !=
824 atomic_read(&tgtp
->rcv_fcp_cmd_out
)) {
825 len
+= snprintf(buf
+ len
, size
- len
,
826 "Rcv FCP: in %08x != out %08x\n",
827 atomic_read(&tgtp
->rcv_fcp_cmd_in
),
828 atomic_read(&tgtp
->rcv_fcp_cmd_out
));
831 len
+= snprintf(buf
+ len
, size
- len
,
832 "FCP Rsp: read %08x readrsp %08x "
833 "write %08x rsp %08x\n",
834 atomic_read(&tgtp
->xmt_fcp_read
),
835 atomic_read(&tgtp
->xmt_fcp_read_rsp
),
836 atomic_read(&tgtp
->xmt_fcp_write
),
837 atomic_read(&tgtp
->xmt_fcp_rsp
));
839 len
+= snprintf(buf
+ len
, size
- len
,
840 "FCP Rsp Cmpl: %08x err %08x drop %08x\n",
841 atomic_read(&tgtp
->xmt_fcp_rsp_cmpl
),
842 atomic_read(&tgtp
->xmt_fcp_rsp_error
),
843 atomic_read(&tgtp
->xmt_fcp_rsp_drop
));
845 len
+= snprintf(buf
+ len
, size
- len
,
846 "FCP Rsp Abort: %08x xb %08x xricqe %08x\n",
847 atomic_read(&tgtp
->xmt_fcp_rsp_aborted
),
848 atomic_read(&tgtp
->xmt_fcp_rsp_xb_set
),
849 atomic_read(&tgtp
->xmt_fcp_xri_abort_cqe
));
851 len
+= snprintf(buf
+ len
, size
- len
,
852 "ABORT: Xmt %08x Cmpl %08x\n",
853 atomic_read(&tgtp
->xmt_fcp_abort
),
854 atomic_read(&tgtp
->xmt_fcp_abort_cmpl
));
856 len
+= snprintf(buf
+ len
, size
- len
,
857 "ABORT: Sol %08x Usol %08x Err %08x Cmpl %08x",
858 atomic_read(&tgtp
->xmt_abort_sol
),
859 atomic_read(&tgtp
->xmt_abort_unsol
),
860 atomic_read(&tgtp
->xmt_abort_rsp
),
861 atomic_read(&tgtp
->xmt_abort_rsp_error
));
863 len
+= snprintf(buf
+ len
, size
- len
, "\n");
866 spin_lock(&phba
->sli4_hba
.abts_nvme_buf_list_lock
);
867 list_for_each_entry_safe(ctxp
, next_ctxp
,
868 &phba
->sli4_hba
.lpfc_abts_nvmet_ctx_list
,
872 spin_unlock(&phba
->sli4_hba
.abts_nvme_buf_list_lock
);
874 len
+= snprintf(buf
+ len
, size
- len
,
875 "ABORT: %d ctx entries\n", cnt
);
876 spin_lock(&phba
->sli4_hba
.abts_nvme_buf_list_lock
);
877 list_for_each_entry_safe(ctxp
, next_ctxp
,
878 &phba
->sli4_hba
.lpfc_abts_nvmet_ctx_list
,
880 if (len
>= (size
- LPFC_DEBUG_OUT_LINE_SZ
))
882 len
+= snprintf(buf
+ len
, size
- len
,
883 "Entry: oxid %x state %x "
885 ctxp
->oxid
, ctxp
->state
,
888 spin_unlock(&phba
->sli4_hba
.abts_nvme_buf_list_lock
);
891 /* Calculate outstanding IOs */
892 tot
= atomic_read(&tgtp
->rcv_fcp_cmd_drop
);
893 tot
+= atomic_read(&tgtp
->xmt_fcp_release
);
894 tot
= atomic_read(&tgtp
->rcv_fcp_cmd_in
) - tot
;
896 len
+= snprintf(buf
+ len
, size
- len
,
897 "IO_CTX: %08x WAIT: cur %08x tot %08x\n"
898 "CTX Outstanding %08llx\n",
899 phba
->sli4_hba
.nvmet_xri_cnt
,
900 phba
->sli4_hba
.nvmet_io_wait_cnt
,
901 phba
->sli4_hba
.nvmet_io_wait_total
,
904 if (!(phba
->cfg_enable_fc4_type
& LPFC_ENABLE_NVME
))
907 localport
= vport
->localport
;
910 lport
= (struct lpfc_nvme_lport
*)localport
->private;
914 len
+= snprintf(buf
+ len
, size
- len
,
915 "\nNVME Lport Statistics\n");
917 len
+= snprintf(buf
+ len
, size
- len
,
918 "LS: Xmt %016x Cmpl %016x\n",
919 atomic_read(&lport
->fc4NvmeLsRequests
),
920 atomic_read(&lport
->fc4NvmeLsCmpls
));
922 if (phba
->cfg_nvme_io_channel
< 32)
923 maxch
= phba
->cfg_nvme_io_channel
;
928 for (i
= 0; i
< phba
->cfg_nvme_io_channel
; i
++) {
929 cstat
= &lport
->cstat
[i
];
930 tot
= atomic_read(&cstat
->fc4NvmeIoCmpls
);
932 data1
= atomic_read(&cstat
->fc4NvmeInputRequests
);
933 data2
= atomic_read(&cstat
->fc4NvmeOutputRequests
);
934 data3
= atomic_read(&cstat
->fc4NvmeControlRequests
);
935 totout
+= (data1
+ data2
+ data3
);
937 /* Limit to 32, debugfs display buffer limitation */
941 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
942 "FCP (%d): Rd %016llx Wr %016llx "
944 i
, data1
, data2
, data3
);
945 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
946 "Cmpl %016llx OutIO %016llx\n",
947 tot
, ((data1
+ data2
+ data3
) - tot
));
949 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
950 "Total FCP Cmpl %016llx Issue %016llx "
952 totin
, totout
, totout
- totin
);
954 len
+= snprintf(buf
+ len
, size
- len
,
955 "LS Xmt Err: Abrt %08x Err %08x "
956 "Cmpl Err: xb %08x Err %08x\n",
957 atomic_read(&lport
->xmt_ls_abort
),
958 atomic_read(&lport
->xmt_ls_err
),
959 atomic_read(&lport
->cmpl_ls_xb
),
960 atomic_read(&lport
->cmpl_ls_err
));
962 len
+= snprintf(buf
+ len
, size
- len
,
963 "FCP Xmt Err: noxri %06x nondlp %06x "
964 "qdepth %06x wqerr %06x err %06x Abrt %06x\n",
965 atomic_read(&lport
->xmt_fcp_noxri
),
966 atomic_read(&lport
->xmt_fcp_bad_ndlp
),
967 atomic_read(&lport
->xmt_fcp_qdepth
),
968 atomic_read(&lport
->xmt_fcp_wqerr
),
969 atomic_read(&lport
->xmt_fcp_err
),
970 atomic_read(&lport
->xmt_fcp_abort
));
972 len
+= snprintf(buf
+ len
, size
- len
,
973 "FCP Cmpl Err: xb %08x Err %08x\n",
974 atomic_read(&lport
->cmpl_fcp_xb
),
975 atomic_read(&lport
->cmpl_fcp_err
));
984 * lpfc_debugfs_nvmektime_data - Dump target node list to a buffer
985 * @vport: The vport to gather target node info from.
986 * @buf: The buffer to dump log into.
987 * @size: The maximum amount of data to process.
990 * This routine dumps the NVME statistics associated with @vport
993 * This routine returns the amount of bytes that were dumped into @buf and will
997 lpfc_debugfs_nvmektime_data(struct lpfc_vport
*vport
, char *buf
, int size
)
999 struct lpfc_hba
*phba
= vport
->phba
;
1002 if (phba
->nvmet_support
== 0) {
1003 /* NVME Initiator */
1004 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
1005 "ktime %s: Total Samples: %lld\n",
1006 (phba
->ktime_on
? "Enabled" : "Disabled"),
1007 phba
->ktime_data_samples
);
1008 if (phba
->ktime_data_samples
== 0)
1012 buf
+ len
, PAGE_SIZE
- len
,
1013 "Segment 1: Last NVME Cmd cmpl "
1014 "done -to- Start of next NVME cnd (in driver)\n");
1016 buf
+ len
, PAGE_SIZE
- len
,
1017 "avg:%08lld min:%08lld max %08lld\n",
1018 div_u64(phba
->ktime_seg1_total
,
1019 phba
->ktime_data_samples
),
1020 phba
->ktime_seg1_min
,
1021 phba
->ktime_seg1_max
);
1023 buf
+ len
, PAGE_SIZE
- len
,
1024 "Segment 2: Driver start of NVME cmd "
1025 "-to- Firmware WQ doorbell\n");
1027 buf
+ len
, PAGE_SIZE
- len
,
1028 "avg:%08lld min:%08lld max %08lld\n",
1029 div_u64(phba
->ktime_seg2_total
,
1030 phba
->ktime_data_samples
),
1031 phba
->ktime_seg2_min
,
1032 phba
->ktime_seg2_max
);
1034 buf
+ len
, PAGE_SIZE
- len
,
1035 "Segment 3: Firmware WQ doorbell -to- "
1036 "MSI-X ISR cmpl\n");
1038 buf
+ len
, PAGE_SIZE
- len
,
1039 "avg:%08lld min:%08lld max %08lld\n",
1040 div_u64(phba
->ktime_seg3_total
,
1041 phba
->ktime_data_samples
),
1042 phba
->ktime_seg3_min
,
1043 phba
->ktime_seg3_max
);
1045 buf
+ len
, PAGE_SIZE
- len
,
1046 "Segment 4: MSI-X ISR cmpl -to- "
1047 "NVME cmpl done\n");
1049 buf
+ len
, PAGE_SIZE
- len
,
1050 "avg:%08lld min:%08lld max %08lld\n",
1051 div_u64(phba
->ktime_seg4_total
,
1052 phba
->ktime_data_samples
),
1053 phba
->ktime_seg4_min
,
1054 phba
->ktime_seg4_max
);
1056 buf
+ len
, PAGE_SIZE
- len
,
1057 "Total IO avg time: %08lld\n",
1058 div_u64(phba
->ktime_seg1_total
+
1059 phba
->ktime_seg2_total
+
1060 phba
->ktime_seg3_total
+
1061 phba
->ktime_seg4_total
,
1062 phba
->ktime_data_samples
));
1067 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
1068 "ktime %s: Total Samples: %lld %lld\n",
1069 (phba
->ktime_on
? "Enabled" : "Disabled"),
1070 phba
->ktime_data_samples
,
1071 phba
->ktime_status_samples
);
1072 if (phba
->ktime_data_samples
== 0)
1075 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
1076 "Segment 1: MSI-X ISR Rcv cmd -to- "
1077 "cmd pass to NVME Layer\n");
1078 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
1079 "avg:%08lld min:%08lld max %08lld\n",
1080 div_u64(phba
->ktime_seg1_total
,
1081 phba
->ktime_data_samples
),
1082 phba
->ktime_seg1_min
,
1083 phba
->ktime_seg1_max
);
1084 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
1085 "Segment 2: cmd pass to NVME Layer- "
1086 "-to- Driver rcv cmd OP (action)\n");
1087 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
1088 "avg:%08lld min:%08lld max %08lld\n",
1089 div_u64(phba
->ktime_seg2_total
,
1090 phba
->ktime_data_samples
),
1091 phba
->ktime_seg2_min
,
1092 phba
->ktime_seg2_max
);
1093 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
1094 "Segment 3: Driver rcv cmd OP -to- "
1095 "Firmware WQ doorbell: cmd\n");
1096 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
1097 "avg:%08lld min:%08lld max %08lld\n",
1098 div_u64(phba
->ktime_seg3_total
,
1099 phba
->ktime_data_samples
),
1100 phba
->ktime_seg3_min
,
1101 phba
->ktime_seg3_max
);
1102 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
1103 "Segment 4: Firmware WQ doorbell: cmd "
1104 "-to- MSI-X ISR for cmd cmpl\n");
1105 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
1106 "avg:%08lld min:%08lld max %08lld\n",
1107 div_u64(phba
->ktime_seg4_total
,
1108 phba
->ktime_data_samples
),
1109 phba
->ktime_seg4_min
,
1110 phba
->ktime_seg4_max
);
1111 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
1112 "Segment 5: MSI-X ISR for cmd cmpl "
1113 "-to- NVME layer passed cmd done\n");
1114 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
1115 "avg:%08lld min:%08lld max %08lld\n",
1116 div_u64(phba
->ktime_seg5_total
,
1117 phba
->ktime_data_samples
),
1118 phba
->ktime_seg5_min
,
1119 phba
->ktime_seg5_max
);
1121 if (phba
->ktime_status_samples
== 0) {
1122 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
1123 "Total: cmd received by MSI-X ISR "
1124 "-to- cmd completed on wire\n");
1125 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
1126 "avg:%08lld min:%08lld "
1128 div_u64(phba
->ktime_seg10_total
,
1129 phba
->ktime_data_samples
),
1130 phba
->ktime_seg10_min
,
1131 phba
->ktime_seg10_max
);
1135 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
1136 "Segment 6: NVME layer passed cmd done "
1137 "-to- Driver rcv rsp status OP\n");
1138 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
1139 "avg:%08lld min:%08lld max %08lld\n",
1140 div_u64(phba
->ktime_seg6_total
,
1141 phba
->ktime_status_samples
),
1142 phba
->ktime_seg6_min
,
1143 phba
->ktime_seg6_max
);
1144 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
1145 "Segment 7: Driver rcv rsp status OP "
1146 "-to- Firmware WQ doorbell: status\n");
1147 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
1148 "avg:%08lld min:%08lld max %08lld\n",
1149 div_u64(phba
->ktime_seg7_total
,
1150 phba
->ktime_status_samples
),
1151 phba
->ktime_seg7_min
,
1152 phba
->ktime_seg7_max
);
1153 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
1154 "Segment 8: Firmware WQ doorbell: status"
1155 " -to- MSI-X ISR for status cmpl\n");
1156 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
1157 "avg:%08lld min:%08lld max %08lld\n",
1158 div_u64(phba
->ktime_seg8_total
,
1159 phba
->ktime_status_samples
),
1160 phba
->ktime_seg8_min
,
1161 phba
->ktime_seg8_max
);
1162 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
1163 "Segment 9: MSI-X ISR for status cmpl "
1164 "-to- NVME layer passed status done\n");
1165 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
1166 "avg:%08lld min:%08lld max %08lld\n",
1167 div_u64(phba
->ktime_seg9_total
,
1168 phba
->ktime_status_samples
),
1169 phba
->ktime_seg9_min
,
1170 phba
->ktime_seg9_max
);
1171 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
1172 "Total: cmd received by MSI-X ISR -to- "
1173 "cmd completed on wire\n");
1174 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
1175 "avg:%08lld min:%08lld max %08lld\n",
1176 div_u64(phba
->ktime_seg10_total
,
1177 phba
->ktime_status_samples
),
1178 phba
->ktime_seg10_min
,
1179 phba
->ktime_seg10_max
);
1184 * lpfc_debugfs_nvmeio_trc_data - Dump NVME IO trace list to a buffer
1185 * @phba: The phba to gather target node info from.
1186 * @buf: The buffer to dump log into.
1187 * @size: The maximum amount of data to process.
1190 * This routine dumps the NVME IO trace associated with @phba
1193 * This routine returns the amount of bytes that were dumped into @buf and will
1197 lpfc_debugfs_nvmeio_trc_data(struct lpfc_hba
*phba
, char *buf
, int size
)
1199 struct lpfc_debugfs_nvmeio_trc
*dtp
;
1200 int i
, state
, index
, skip
;
1203 state
= phba
->nvmeio_trc_on
;
1205 index
= (atomic_read(&phba
->nvmeio_trc_cnt
) + 1) &
1206 (phba
->nvmeio_trc_size
- 1);
1207 skip
= phba
->nvmeio_trc_output_idx
;
1209 len
+= snprintf(buf
+ len
, size
- len
,
1210 "%s IO Trace %s: next_idx %d skip %d size %d\n",
1211 (phba
->nvmet_support
? "NVME" : "NVMET"),
1212 (state
? "Enabled" : "Disabled"),
1213 index
, skip
, phba
->nvmeio_trc_size
);
1215 if (!phba
->nvmeio_trc
|| state
)
1218 /* trace MUST bhe off to continue */
1220 for (i
= index
; i
< phba
->nvmeio_trc_size
; i
++) {
1225 dtp
= phba
->nvmeio_trc
+ i
;
1226 phba
->nvmeio_trc_output_idx
++;
1231 len
+= snprintf(buf
+ len
, size
- len
, dtp
->fmt
,
1232 dtp
->data1
, dtp
->data2
, dtp
->data3
);
1234 if (phba
->nvmeio_trc_output_idx
>= phba
->nvmeio_trc_size
) {
1235 phba
->nvmeio_trc_output_idx
= 0;
1236 len
+= snprintf(buf
+ len
, size
- len
,
1237 "Trace Complete\n");
1241 if (len
>= (size
- LPFC_DEBUG_OUT_LINE_SZ
)) {
1242 len
+= snprintf(buf
+ len
, size
- len
,
1243 "Trace Continue (%d of %d)\n",
1244 phba
->nvmeio_trc_output_idx
,
1245 phba
->nvmeio_trc_size
);
1249 for (i
= 0; i
< index
; i
++) {
1254 dtp
= phba
->nvmeio_trc
+ i
;
1255 phba
->nvmeio_trc_output_idx
++;
1260 len
+= snprintf(buf
+ len
, size
- len
, dtp
->fmt
,
1261 dtp
->data1
, dtp
->data2
, dtp
->data3
);
1263 if (phba
->nvmeio_trc_output_idx
>= phba
->nvmeio_trc_size
) {
1264 phba
->nvmeio_trc_output_idx
= 0;
1265 len
+= snprintf(buf
+ len
, size
- len
,
1266 "Trace Complete\n");
1270 if (len
>= (size
- LPFC_DEBUG_OUT_LINE_SZ
)) {
1271 len
+= snprintf(buf
+ len
, size
- len
,
1272 "Trace Continue (%d of %d)\n",
1273 phba
->nvmeio_trc_output_idx
,
1274 phba
->nvmeio_trc_size
);
1279 len
+= snprintf(buf
+ len
, size
- len
,
1286 * lpfc_debugfs_cpucheck_data - Dump target node list to a buffer
1287 * @vport: The vport to gather target node info from.
1288 * @buf: The buffer to dump log into.
1289 * @size: The maximum amount of data to process.
1292 * This routine dumps the NVME statistics associated with @vport
1295 * This routine returns the amount of bytes that were dumped into @buf and will
1299 lpfc_debugfs_cpucheck_data(struct lpfc_vport
*vport
, char *buf
, int size
)
1301 struct lpfc_hba
*phba
= vport
->phba
;
1304 uint32_t tot_xmt
= 0;
1305 uint32_t tot_rcv
= 0;
1306 uint32_t tot_cmpl
= 0;
1307 uint32_t tot_ccmpl
= 0;
1309 if (phba
->nvmet_support
== 0) {
1310 /* NVME Initiator */
1311 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
1313 (phba
->cpucheck_on
& LPFC_CHECK_NVME_IO
?
1314 "Enabled" : "Disabled"));
1315 for (i
= 0; i
< phba
->sli4_hba
.num_present_cpu
; i
++) {
1316 if (i
>= LPFC_CHECK_CPU_CNT
)
1318 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
1319 "%02d: xmit x%08x cmpl x%08x\n",
1320 i
, phba
->cpucheck_xmt_io
[i
],
1321 phba
->cpucheck_cmpl_io
[i
]);
1322 tot_xmt
+= phba
->cpucheck_xmt_io
[i
];
1323 tot_cmpl
+= phba
->cpucheck_cmpl_io
[i
];
1325 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
1326 "tot:xmit x%08x cmpl x%08x\n",
1332 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
1334 (phba
->cpucheck_on
& LPFC_CHECK_NVMET_IO
?
1335 "IO Enabled - " : "IO Disabled - "));
1336 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
1338 (phba
->cpucheck_on
& LPFC_CHECK_NVMET_RCV
?
1339 "Rcv Enabled\n" : "Rcv Disabled\n"));
1340 for (i
= 0; i
< phba
->sli4_hba
.num_present_cpu
; i
++) {
1341 if (i
>= LPFC_CHECK_CPU_CNT
)
1343 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
1344 "%02d: xmit x%08x ccmpl x%08x "
1345 "cmpl x%08x rcv x%08x\n",
1346 i
, phba
->cpucheck_xmt_io
[i
],
1347 phba
->cpucheck_ccmpl_io
[i
],
1348 phba
->cpucheck_cmpl_io
[i
],
1349 phba
->cpucheck_rcv_io
[i
]);
1350 tot_xmt
+= phba
->cpucheck_xmt_io
[i
];
1351 tot_rcv
+= phba
->cpucheck_rcv_io
[i
];
1352 tot_cmpl
+= phba
->cpucheck_cmpl_io
[i
];
1353 tot_ccmpl
+= phba
->cpucheck_ccmpl_io
[i
];
1355 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
1356 "tot:xmit x%08x ccmpl x%08x cmpl x%08x rcv x%08x\n",
1357 tot_xmt
, tot_ccmpl
, tot_cmpl
, tot_rcv
);
1364 * lpfc_debugfs_disc_trc - Store discovery trace log
1365 * @vport: The vport to associate this trace string with for retrieval.
1366 * @mask: Log entry classification.
1367 * @fmt: Format string to be displayed when dumping the log.
1368 * @data1: 1st data parameter to be applied to @fmt.
1369 * @data2: 2nd data parameter to be applied to @fmt.
1370 * @data3: 3rd data parameter to be applied to @fmt.
1373 * This routine is used by the driver code to add a debugfs log entry to the
1374 * discovery trace buffer associated with @vport. Only entries with a @mask that
1375 * match the current debugfs discovery mask will be saved. Entries that do not
1376 * match will be thrown away. @fmt, @data1, @data2, and @data3 are used like
1377 * printf when displaying the log.
1380 lpfc_debugfs_disc_trc(struct lpfc_vport
*vport
, int mask
, char *fmt
,
1381 uint32_t data1
, uint32_t data2
, uint32_t data3
)
1383 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
1384 struct lpfc_debugfs_trc
*dtp
;
1387 if (!(lpfc_debugfs_mask_disc_trc
& mask
))
1390 if (!lpfc_debugfs_enable
|| !lpfc_debugfs_max_disc_trc
||
1391 !vport
|| !vport
->disc_trc
)
1394 index
= atomic_inc_return(&vport
->disc_trc_cnt
) &
1395 (lpfc_debugfs_max_disc_trc
- 1);
1396 dtp
= vport
->disc_trc
+ index
;
1401 dtp
->seq_cnt
= atomic_inc_return(&lpfc_debugfs_seq_trc_cnt
);
1408 * lpfc_debugfs_slow_ring_trc - Store slow ring trace log
1409 * @phba: The phba to associate this trace string with for retrieval.
1410 * @fmt: Format string to be displayed when dumping the log.
1411 * @data1: 1st data parameter to be applied to @fmt.
1412 * @data2: 2nd data parameter to be applied to @fmt.
1413 * @data3: 3rd data parameter to be applied to @fmt.
1416 * This routine is used by the driver code to add a debugfs log entry to the
1417 * discovery trace buffer associated with @vport. @fmt, @data1, @data2, and
1418 * @data3 are used like printf when displaying the log.
1421 lpfc_debugfs_slow_ring_trc(struct lpfc_hba
*phba
, char *fmt
,
1422 uint32_t data1
, uint32_t data2
, uint32_t data3
)
1424 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
1425 struct lpfc_debugfs_trc
*dtp
;
1428 if (!lpfc_debugfs_enable
|| !lpfc_debugfs_max_slow_ring_trc
||
1429 !phba
|| !phba
->slow_ring_trc
)
1432 index
= atomic_inc_return(&phba
->slow_ring_trc_cnt
) &
1433 (lpfc_debugfs_max_slow_ring_trc
- 1);
1434 dtp
= phba
->slow_ring_trc
+ index
;
1439 dtp
->seq_cnt
= atomic_inc_return(&lpfc_debugfs_seq_trc_cnt
);
1446 * lpfc_debugfs_nvme_trc - Store NVME/NVMET trace log
1447 * @phba: The phba to associate this trace string with for retrieval.
1448 * @fmt: Format string to be displayed when dumping the log.
1449 * @data1: 1st data parameter to be applied to @fmt.
1450 * @data2: 2nd data parameter to be applied to @fmt.
1451 * @data3: 3rd data parameter to be applied to @fmt.
1454 * This routine is used by the driver code to add a debugfs log entry to the
1455 * nvme trace buffer associated with @phba. @fmt, @data1, @data2, and
1456 * @data3 are used like printf when displaying the log.
1459 lpfc_debugfs_nvme_trc(struct lpfc_hba
*phba
, char *fmt
,
1460 uint16_t data1
, uint16_t data2
, uint32_t data3
)
1462 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
1463 struct lpfc_debugfs_nvmeio_trc
*dtp
;
1466 if (!phba
->nvmeio_trc_on
|| !phba
->nvmeio_trc
)
1469 index
= atomic_inc_return(&phba
->nvmeio_trc_cnt
) &
1470 (phba
->nvmeio_trc_size
- 1);
1471 dtp
= phba
->nvmeio_trc
+ index
;
1479 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
1481 * lpfc_debugfs_disc_trc_open - Open the discovery trace log
1482 * @inode: The inode pointer that contains a vport pointer.
1483 * @file: The file pointer to attach the log output.
1486 * This routine is the entry point for the debugfs open file operation. It gets
1487 * the vport from the i_private field in @inode, allocates the necessary buffer
1488 * for the log, fills the buffer from the in-memory log for this vport, and then
1489 * returns a pointer to that log in the private_data field in @file.
1492 * This function returns zero if successful. On error it will return a negative
1496 lpfc_debugfs_disc_trc_open(struct inode
*inode
, struct file
*file
)
1498 struct lpfc_vport
*vport
= inode
->i_private
;
1499 struct lpfc_debug
*debug
;
1503 if (!lpfc_debugfs_max_disc_trc
) {
1508 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
1512 /* Round to page boundary */
1513 size
= (lpfc_debugfs_max_disc_trc
* LPFC_DEBUG_TRC_ENTRY_SIZE
);
1514 size
= PAGE_ALIGN(size
);
1516 debug
->buffer
= kmalloc(size
, GFP_KERNEL
);
1517 if (!debug
->buffer
) {
1522 debug
->len
= lpfc_debugfs_disc_trc_data(vport
, debug
->buffer
, size
);
1523 file
->private_data
= debug
;
1531 * lpfc_debugfs_slow_ring_trc_open - Open the Slow Ring trace log
1532 * @inode: The inode pointer that contains a vport pointer.
1533 * @file: The file pointer to attach the log output.
1536 * This routine is the entry point for the debugfs open file operation. It gets
1537 * the vport from the i_private field in @inode, allocates the necessary buffer
1538 * for the log, fills the buffer from the in-memory log for this vport, and then
1539 * returns a pointer to that log in the private_data field in @file.
1542 * This function returns zero if successful. On error it will return a negative
1546 lpfc_debugfs_slow_ring_trc_open(struct inode
*inode
, struct file
*file
)
1548 struct lpfc_hba
*phba
= inode
->i_private
;
1549 struct lpfc_debug
*debug
;
1553 if (!lpfc_debugfs_max_slow_ring_trc
) {
1558 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
1562 /* Round to page boundary */
1563 size
= (lpfc_debugfs_max_slow_ring_trc
* LPFC_DEBUG_TRC_ENTRY_SIZE
);
1564 size
= PAGE_ALIGN(size
);
1566 debug
->buffer
= kmalloc(size
, GFP_KERNEL
);
1567 if (!debug
->buffer
) {
1572 debug
->len
= lpfc_debugfs_slow_ring_trc_data(phba
, debug
->buffer
, size
);
1573 file
->private_data
= debug
;
1581 * lpfc_debugfs_hbqinfo_open - Open the hbqinfo debugfs buffer
1582 * @inode: The inode pointer that contains a vport pointer.
1583 * @file: The file pointer to attach the log output.
1586 * This routine is the entry point for the debugfs open file operation. It gets
1587 * the vport from the i_private field in @inode, allocates the necessary buffer
1588 * for the log, fills the buffer from the in-memory log for this vport, and then
1589 * returns a pointer to that log in the private_data field in @file.
1592 * This function returns zero if successful. On error it will return a negative
1596 lpfc_debugfs_hbqinfo_open(struct inode
*inode
, struct file
*file
)
1598 struct lpfc_hba
*phba
= inode
->i_private
;
1599 struct lpfc_debug
*debug
;
1602 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
1606 /* Round to page boundary */
1607 debug
->buffer
= kmalloc(LPFC_HBQINFO_SIZE
, GFP_KERNEL
);
1608 if (!debug
->buffer
) {
1613 debug
->len
= lpfc_debugfs_hbqinfo_data(phba
, debug
->buffer
,
1615 file
->private_data
= debug
;
1623 * lpfc_debugfs_dumpHBASlim_open - Open the Dump HBA SLIM debugfs buffer
1624 * @inode: The inode pointer that contains a vport pointer.
1625 * @file: The file pointer to attach the log output.
1628 * This routine is the entry point for the debugfs open file operation. It gets
1629 * the vport from the i_private field in @inode, allocates the necessary buffer
1630 * for the log, fills the buffer from the in-memory log for this vport, and then
1631 * returns a pointer to that log in the private_data field in @file.
1634 * This function returns zero if successful. On error it will return a negative
1638 lpfc_debugfs_dumpHBASlim_open(struct inode
*inode
, struct file
*file
)
1640 struct lpfc_hba
*phba
= inode
->i_private
;
1641 struct lpfc_debug
*debug
;
1644 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
1648 /* Round to page boundary */
1649 debug
->buffer
= kmalloc(LPFC_DUMPHBASLIM_SIZE
, GFP_KERNEL
);
1650 if (!debug
->buffer
) {
1655 debug
->len
= lpfc_debugfs_dumpHBASlim_data(phba
, debug
->buffer
,
1656 LPFC_DUMPHBASLIM_SIZE
);
1657 file
->private_data
= debug
;
1665 * lpfc_debugfs_dumpHostSlim_open - Open the Dump Host SLIM debugfs buffer
1666 * @inode: The inode pointer that contains a vport pointer.
1667 * @file: The file pointer to attach the log output.
1670 * This routine is the entry point for the debugfs open file operation. It gets
1671 * the vport from the i_private field in @inode, allocates the necessary buffer
1672 * for the log, fills the buffer from the in-memory log for this vport, and then
1673 * returns a pointer to that log in the private_data field in @file.
1676 * This function returns zero if successful. On error it will return a negative
1680 lpfc_debugfs_dumpHostSlim_open(struct inode
*inode
, struct file
*file
)
1682 struct lpfc_hba
*phba
= inode
->i_private
;
1683 struct lpfc_debug
*debug
;
1686 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
1690 /* Round to page boundary */
1691 debug
->buffer
= kmalloc(LPFC_DUMPHOSTSLIM_SIZE
, GFP_KERNEL
);
1692 if (!debug
->buffer
) {
1697 debug
->len
= lpfc_debugfs_dumpHostSlim_data(phba
, debug
->buffer
,
1698 LPFC_DUMPHOSTSLIM_SIZE
);
1699 file
->private_data
= debug
;
1707 lpfc_debugfs_dumpData_open(struct inode
*inode
, struct file
*file
)
1709 struct lpfc_debug
*debug
;
1712 if (!_dump_buf_data
)
1715 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
1719 /* Round to page boundary */
1720 pr_err("9059 BLKGRD: %s: _dump_buf_data=0x%p\n",
1721 __func__
, _dump_buf_data
);
1722 debug
->buffer
= _dump_buf_data
;
1723 if (!debug
->buffer
) {
1728 debug
->len
= (1 << _dump_buf_data_order
) << PAGE_SHIFT
;
1729 file
->private_data
= debug
;
1737 lpfc_debugfs_dumpDif_open(struct inode
*inode
, struct file
*file
)
1739 struct lpfc_debug
*debug
;
1745 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
1749 /* Round to page boundary */
1750 pr_err("9060 BLKGRD: %s: _dump_buf_dif=0x%p file=%pD\n",
1751 __func__
, _dump_buf_dif
, file
);
1752 debug
->buffer
= _dump_buf_dif
;
1753 if (!debug
->buffer
) {
1758 debug
->len
= (1 << _dump_buf_dif_order
) << PAGE_SHIFT
;
1759 file
->private_data
= debug
;
1767 lpfc_debugfs_dumpDataDif_write(struct file
*file
, const char __user
*buf
,
1768 size_t nbytes
, loff_t
*ppos
)
1771 * The Data/DIF buffers only save one failing IO
1772 * The write op is used as a reset mechanism after an IO has
1773 * already been saved to the next one can be saved
1775 spin_lock(&_dump_buf_lock
);
1777 memset((void *)_dump_buf_data
, 0,
1778 ((1 << PAGE_SHIFT
) << _dump_buf_data_order
));
1779 memset((void *)_dump_buf_dif
, 0,
1780 ((1 << PAGE_SHIFT
) << _dump_buf_dif_order
));
1784 spin_unlock(&_dump_buf_lock
);
1790 lpfc_debugfs_dif_err_read(struct file
*file
, char __user
*buf
,
1791 size_t nbytes
, loff_t
*ppos
)
1793 struct dentry
*dent
= file
->f_path
.dentry
;
1794 struct lpfc_hba
*phba
= file
->private_data
;
1799 if (dent
== phba
->debug_writeGuard
)
1800 cnt
= snprintf(cbuf
, 32, "%u\n", phba
->lpfc_injerr_wgrd_cnt
);
1801 else if (dent
== phba
->debug_writeApp
)
1802 cnt
= snprintf(cbuf
, 32, "%u\n", phba
->lpfc_injerr_wapp_cnt
);
1803 else if (dent
== phba
->debug_writeRef
)
1804 cnt
= snprintf(cbuf
, 32, "%u\n", phba
->lpfc_injerr_wref_cnt
);
1805 else if (dent
== phba
->debug_readGuard
)
1806 cnt
= snprintf(cbuf
, 32, "%u\n", phba
->lpfc_injerr_rgrd_cnt
);
1807 else if (dent
== phba
->debug_readApp
)
1808 cnt
= snprintf(cbuf
, 32, "%u\n", phba
->lpfc_injerr_rapp_cnt
);
1809 else if (dent
== phba
->debug_readRef
)
1810 cnt
= snprintf(cbuf
, 32, "%u\n", phba
->lpfc_injerr_rref_cnt
);
1811 else if (dent
== phba
->debug_InjErrNPortID
)
1812 cnt
= snprintf(cbuf
, 32, "0x%06x\n", phba
->lpfc_injerr_nportid
);
1813 else if (dent
== phba
->debug_InjErrWWPN
) {
1814 memcpy(&tmp
, &phba
->lpfc_injerr_wwpn
, sizeof(struct lpfc_name
));
1815 tmp
= cpu_to_be64(tmp
);
1816 cnt
= snprintf(cbuf
, 32, "0x%016llx\n", tmp
);
1817 } else if (dent
== phba
->debug_InjErrLBA
) {
1818 if (phba
->lpfc_injerr_lba
== (sector_t
)(-1))
1819 cnt
= snprintf(cbuf
, 32, "off\n");
1821 cnt
= snprintf(cbuf
, 32, "0x%llx\n",
1822 (uint64_t) phba
->lpfc_injerr_lba
);
1824 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
1825 "0547 Unknown debugfs error injection entry\n");
1827 return simple_read_from_buffer(buf
, nbytes
, ppos
, &cbuf
, cnt
);
1831 lpfc_debugfs_dif_err_write(struct file
*file
, const char __user
*buf
,
1832 size_t nbytes
, loff_t
*ppos
)
1834 struct dentry
*dent
= file
->f_path
.dentry
;
1835 struct lpfc_hba
*phba
= file
->private_data
;
1840 memset(dstbuf
, 0, 33);
1841 size
= (nbytes
< 32) ? nbytes
: 32;
1842 if (copy_from_user(dstbuf
, buf
, size
))
1845 if (dent
== phba
->debug_InjErrLBA
) {
1846 if ((buf
[0] == 'o') && (buf
[1] == 'f') && (buf
[2] == 'f'))
1847 tmp
= (uint64_t)(-1);
1850 if ((tmp
== 0) && (kstrtoull(dstbuf
, 0, &tmp
)))
1853 if (dent
== phba
->debug_writeGuard
)
1854 phba
->lpfc_injerr_wgrd_cnt
= (uint32_t)tmp
;
1855 else if (dent
== phba
->debug_writeApp
)
1856 phba
->lpfc_injerr_wapp_cnt
= (uint32_t)tmp
;
1857 else if (dent
== phba
->debug_writeRef
)
1858 phba
->lpfc_injerr_wref_cnt
= (uint32_t)tmp
;
1859 else if (dent
== phba
->debug_readGuard
)
1860 phba
->lpfc_injerr_rgrd_cnt
= (uint32_t)tmp
;
1861 else if (dent
== phba
->debug_readApp
)
1862 phba
->lpfc_injerr_rapp_cnt
= (uint32_t)tmp
;
1863 else if (dent
== phba
->debug_readRef
)
1864 phba
->lpfc_injerr_rref_cnt
= (uint32_t)tmp
;
1865 else if (dent
== phba
->debug_InjErrLBA
)
1866 phba
->lpfc_injerr_lba
= (sector_t
)tmp
;
1867 else if (dent
== phba
->debug_InjErrNPortID
)
1868 phba
->lpfc_injerr_nportid
= (uint32_t)(tmp
& Mask_DID
);
1869 else if (dent
== phba
->debug_InjErrWWPN
) {
1870 tmp
= cpu_to_be64(tmp
);
1871 memcpy(&phba
->lpfc_injerr_wwpn
, &tmp
, sizeof(struct lpfc_name
));
1873 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
1874 "0548 Unknown debugfs error injection entry\n");
1880 lpfc_debugfs_dif_err_release(struct inode
*inode
, struct file
*file
)
1886 * lpfc_debugfs_nodelist_open - Open the nodelist debugfs file
1887 * @inode: The inode pointer that contains a vport pointer.
1888 * @file: The file pointer to attach the log output.
1891 * This routine is the entry point for the debugfs open file operation. It gets
1892 * the vport from the i_private field in @inode, allocates the necessary buffer
1893 * for the log, fills the buffer from the in-memory log for this vport, and then
1894 * returns a pointer to that log in the private_data field in @file.
1897 * This function returns zero if successful. On error it will return a negative
1901 lpfc_debugfs_nodelist_open(struct inode
*inode
, struct file
*file
)
1903 struct lpfc_vport
*vport
= inode
->i_private
;
1904 struct lpfc_debug
*debug
;
1907 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
1911 /* Round to page boundary */
1912 debug
->buffer
= kmalloc(LPFC_NODELIST_SIZE
, GFP_KERNEL
);
1913 if (!debug
->buffer
) {
1918 debug
->len
= lpfc_debugfs_nodelist_data(vport
, debug
->buffer
,
1919 LPFC_NODELIST_SIZE
);
1920 file
->private_data
= debug
;
1928 * lpfc_debugfs_lseek - Seek through a debugfs file
1929 * @file: The file pointer to seek through.
1930 * @off: The offset to seek to or the amount to seek by.
1931 * @whence: Indicates how to seek.
1934 * This routine is the entry point for the debugfs lseek file operation. The
1935 * @whence parameter indicates whether @off is the offset to directly seek to,
1936 * or if it is a value to seek forward or reverse by. This function figures out
1937 * what the new offset of the debugfs file will be and assigns that value to the
1938 * f_pos field of @file.
1941 * This function returns the new offset if successful and returns a negative
1942 * error if unable to process the seek.
1945 lpfc_debugfs_lseek(struct file
*file
, loff_t off
, int whence
)
1947 struct lpfc_debug
*debug
= file
->private_data
;
1948 return fixed_size_llseek(file
, off
, whence
, debug
->len
);
1952 * lpfc_debugfs_read - Read a debugfs file
1953 * @file: The file pointer to read from.
1954 * @buf: The buffer to copy the data to.
1955 * @nbytes: The number of bytes to read.
1956 * @ppos: The position in the file to start reading from.
1959 * This routine reads data from from the buffer indicated in the private_data
1960 * field of @file. It will start reading at @ppos and copy up to @nbytes of
1964 * This function returns the amount of data that was read (this could be less
1965 * than @nbytes if the end of the file was reached) or a negative error value.
1968 lpfc_debugfs_read(struct file
*file
, char __user
*buf
,
1969 size_t nbytes
, loff_t
*ppos
)
1971 struct lpfc_debug
*debug
= file
->private_data
;
1973 return simple_read_from_buffer(buf
, nbytes
, ppos
, debug
->buffer
,
1978 * lpfc_debugfs_release - Release the buffer used to store debugfs file data
1979 * @inode: The inode pointer that contains a vport pointer. (unused)
1980 * @file: The file pointer that contains the buffer to release.
1983 * This routine frees the buffer that was allocated when the debugfs file was
1987 * This function returns zero.
1990 lpfc_debugfs_release(struct inode
*inode
, struct file
*file
)
1992 struct lpfc_debug
*debug
= file
->private_data
;
1994 kfree(debug
->buffer
);
2001 lpfc_debugfs_dumpDataDif_release(struct inode
*inode
, struct file
*file
)
2003 struct lpfc_debug
*debug
= file
->private_data
;
2005 debug
->buffer
= NULL
;
2013 lpfc_debugfs_nvmestat_open(struct inode
*inode
, struct file
*file
)
2015 struct lpfc_vport
*vport
= inode
->i_private
;
2016 struct lpfc_debug
*debug
;
2019 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
2023 /* Round to page boundary */
2024 debug
->buffer
= kmalloc(LPFC_NVMESTAT_SIZE
, GFP_KERNEL
);
2025 if (!debug
->buffer
) {
2030 debug
->len
= lpfc_debugfs_nvmestat_data(vport
, debug
->buffer
,
2031 LPFC_NVMESTAT_SIZE
);
2033 debug
->i_private
= inode
->i_private
;
2034 file
->private_data
= debug
;
2042 lpfc_debugfs_nvmestat_write(struct file
*file
, const char __user
*buf
,
2043 size_t nbytes
, loff_t
*ppos
)
2045 struct lpfc_debug
*debug
= file
->private_data
;
2046 struct lpfc_vport
*vport
= (struct lpfc_vport
*)debug
->i_private
;
2047 struct lpfc_hba
*phba
= vport
->phba
;
2048 struct lpfc_nvmet_tgtport
*tgtp
;
2052 if (!phba
->targetport
)
2058 memset(mybuf
, 0, sizeof(mybuf
));
2060 if (copy_from_user(mybuf
, buf
, nbytes
))
2064 tgtp
= (struct lpfc_nvmet_tgtport
*)phba
->targetport
->private;
2065 if ((strncmp(pbuf
, "reset", strlen("reset")) == 0) ||
2066 (strncmp(pbuf
, "zero", strlen("zero")) == 0)) {
2067 atomic_set(&tgtp
->rcv_ls_req_in
, 0);
2068 atomic_set(&tgtp
->rcv_ls_req_out
, 0);
2069 atomic_set(&tgtp
->rcv_ls_req_drop
, 0);
2070 atomic_set(&tgtp
->xmt_ls_abort
, 0);
2071 atomic_set(&tgtp
->xmt_ls_abort_cmpl
, 0);
2072 atomic_set(&tgtp
->xmt_ls_rsp
, 0);
2073 atomic_set(&tgtp
->xmt_ls_drop
, 0);
2074 atomic_set(&tgtp
->xmt_ls_rsp_error
, 0);
2075 atomic_set(&tgtp
->xmt_ls_rsp_cmpl
, 0);
2077 atomic_set(&tgtp
->rcv_fcp_cmd_in
, 0);
2078 atomic_set(&tgtp
->rcv_fcp_cmd_out
, 0);
2079 atomic_set(&tgtp
->rcv_fcp_cmd_drop
, 0);
2080 atomic_set(&tgtp
->xmt_fcp_drop
, 0);
2081 atomic_set(&tgtp
->xmt_fcp_read_rsp
, 0);
2082 atomic_set(&tgtp
->xmt_fcp_read
, 0);
2083 atomic_set(&tgtp
->xmt_fcp_write
, 0);
2084 atomic_set(&tgtp
->xmt_fcp_rsp
, 0);
2085 atomic_set(&tgtp
->xmt_fcp_release
, 0);
2086 atomic_set(&tgtp
->xmt_fcp_rsp_cmpl
, 0);
2087 atomic_set(&tgtp
->xmt_fcp_rsp_error
, 0);
2088 atomic_set(&tgtp
->xmt_fcp_rsp_drop
, 0);
2090 atomic_set(&tgtp
->xmt_fcp_abort
, 0);
2091 atomic_set(&tgtp
->xmt_fcp_abort_cmpl
, 0);
2092 atomic_set(&tgtp
->xmt_abort_sol
, 0);
2093 atomic_set(&tgtp
->xmt_abort_unsol
, 0);
2094 atomic_set(&tgtp
->xmt_abort_rsp
, 0);
2095 atomic_set(&tgtp
->xmt_abort_rsp_error
, 0);
2101 lpfc_debugfs_nvmektime_open(struct inode
*inode
, struct file
*file
)
2103 struct lpfc_vport
*vport
= inode
->i_private
;
2104 struct lpfc_debug
*debug
;
2107 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
2111 /* Round to page boundary */
2112 debug
->buffer
= kmalloc(LPFC_NVMEKTIME_SIZE
, GFP_KERNEL
);
2113 if (!debug
->buffer
) {
2118 debug
->len
= lpfc_debugfs_nvmektime_data(vport
, debug
->buffer
,
2119 LPFC_NVMEKTIME_SIZE
);
2121 debug
->i_private
= inode
->i_private
;
2122 file
->private_data
= debug
;
2130 lpfc_debugfs_nvmektime_write(struct file
*file
, const char __user
*buf
,
2131 size_t nbytes
, loff_t
*ppos
)
2133 struct lpfc_debug
*debug
= file
->private_data
;
2134 struct lpfc_vport
*vport
= (struct lpfc_vport
*)debug
->i_private
;
2135 struct lpfc_hba
*phba
= vport
->phba
;
2142 memset(mybuf
, 0, sizeof(mybuf
));
2144 if (copy_from_user(mybuf
, buf
, nbytes
))
2148 if ((strncmp(pbuf
, "on", sizeof("on") - 1) == 0)) {
2149 phba
->ktime_data_samples
= 0;
2150 phba
->ktime_status_samples
= 0;
2151 phba
->ktime_seg1_total
= 0;
2152 phba
->ktime_seg1_max
= 0;
2153 phba
->ktime_seg1_min
= 0xffffffff;
2154 phba
->ktime_seg2_total
= 0;
2155 phba
->ktime_seg2_max
= 0;
2156 phba
->ktime_seg2_min
= 0xffffffff;
2157 phba
->ktime_seg3_total
= 0;
2158 phba
->ktime_seg3_max
= 0;
2159 phba
->ktime_seg3_min
= 0xffffffff;
2160 phba
->ktime_seg4_total
= 0;
2161 phba
->ktime_seg4_max
= 0;
2162 phba
->ktime_seg4_min
= 0xffffffff;
2163 phba
->ktime_seg5_total
= 0;
2164 phba
->ktime_seg5_max
= 0;
2165 phba
->ktime_seg5_min
= 0xffffffff;
2166 phba
->ktime_seg6_total
= 0;
2167 phba
->ktime_seg6_max
= 0;
2168 phba
->ktime_seg6_min
= 0xffffffff;
2169 phba
->ktime_seg7_total
= 0;
2170 phba
->ktime_seg7_max
= 0;
2171 phba
->ktime_seg7_min
= 0xffffffff;
2172 phba
->ktime_seg8_total
= 0;
2173 phba
->ktime_seg8_max
= 0;
2174 phba
->ktime_seg8_min
= 0xffffffff;
2175 phba
->ktime_seg9_total
= 0;
2176 phba
->ktime_seg9_max
= 0;
2177 phba
->ktime_seg9_min
= 0xffffffff;
2178 phba
->ktime_seg10_total
= 0;
2179 phba
->ktime_seg10_max
= 0;
2180 phba
->ktime_seg10_min
= 0xffffffff;
2183 return strlen(pbuf
);
2184 } else if ((strncmp(pbuf
, "off",
2185 sizeof("off") - 1) == 0)) {
2187 return strlen(pbuf
);
2188 } else if ((strncmp(pbuf
, "zero",
2189 sizeof("zero") - 1) == 0)) {
2190 phba
->ktime_data_samples
= 0;
2191 phba
->ktime_status_samples
= 0;
2192 phba
->ktime_seg1_total
= 0;
2193 phba
->ktime_seg1_max
= 0;
2194 phba
->ktime_seg1_min
= 0xffffffff;
2195 phba
->ktime_seg2_total
= 0;
2196 phba
->ktime_seg2_max
= 0;
2197 phba
->ktime_seg2_min
= 0xffffffff;
2198 phba
->ktime_seg3_total
= 0;
2199 phba
->ktime_seg3_max
= 0;
2200 phba
->ktime_seg3_min
= 0xffffffff;
2201 phba
->ktime_seg4_total
= 0;
2202 phba
->ktime_seg4_max
= 0;
2203 phba
->ktime_seg4_min
= 0xffffffff;
2204 phba
->ktime_seg5_total
= 0;
2205 phba
->ktime_seg5_max
= 0;
2206 phba
->ktime_seg5_min
= 0xffffffff;
2207 phba
->ktime_seg6_total
= 0;
2208 phba
->ktime_seg6_max
= 0;
2209 phba
->ktime_seg6_min
= 0xffffffff;
2210 phba
->ktime_seg7_total
= 0;
2211 phba
->ktime_seg7_max
= 0;
2212 phba
->ktime_seg7_min
= 0xffffffff;
2213 phba
->ktime_seg8_total
= 0;
2214 phba
->ktime_seg8_max
= 0;
2215 phba
->ktime_seg8_min
= 0xffffffff;
2216 phba
->ktime_seg9_total
= 0;
2217 phba
->ktime_seg9_max
= 0;
2218 phba
->ktime_seg9_min
= 0xffffffff;
2219 phba
->ktime_seg10_total
= 0;
2220 phba
->ktime_seg10_max
= 0;
2221 phba
->ktime_seg10_min
= 0xffffffff;
2222 return strlen(pbuf
);
2228 lpfc_debugfs_nvmeio_trc_open(struct inode
*inode
, struct file
*file
)
2230 struct lpfc_hba
*phba
= inode
->i_private
;
2231 struct lpfc_debug
*debug
;
2234 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
2238 /* Round to page boundary */
2239 debug
->buffer
= kmalloc(LPFC_NVMEIO_TRC_SIZE
, GFP_KERNEL
);
2240 if (!debug
->buffer
) {
2245 debug
->len
= lpfc_debugfs_nvmeio_trc_data(phba
, debug
->buffer
,
2246 LPFC_NVMEIO_TRC_SIZE
);
2248 debug
->i_private
= inode
->i_private
;
2249 file
->private_data
= debug
;
2257 lpfc_debugfs_nvmeio_trc_write(struct file
*file
, const char __user
*buf
,
2258 size_t nbytes
, loff_t
*ppos
)
2260 struct lpfc_debug
*debug
= file
->private_data
;
2261 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
2270 memset(mybuf
, 0, sizeof(mybuf
));
2272 if (copy_from_user(mybuf
, buf
, nbytes
))
2276 if ((strncmp(pbuf
, "off", sizeof("off") - 1) == 0)) {
2277 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
2278 "0570 nvmeio_trc_off\n");
2279 phba
->nvmeio_trc_output_idx
= 0;
2280 phba
->nvmeio_trc_on
= 0;
2281 return strlen(pbuf
);
2282 } else if ((strncmp(pbuf
, "on", sizeof("on") - 1) == 0)) {
2283 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
2284 "0571 nvmeio_trc_on\n");
2285 phba
->nvmeio_trc_output_idx
= 0;
2286 phba
->nvmeio_trc_on
= 1;
2287 return strlen(pbuf
);
2290 /* We must be off to allocate the trace buffer */
2291 if (phba
->nvmeio_trc_on
!= 0)
2294 /* If not on or off, the parameter is the trace buffer size */
2295 i
= kstrtoul(pbuf
, 0, &sz
);
2298 phba
->nvmeio_trc_size
= (uint32_t)sz
;
2300 /* It must be a power of 2 - round down */
2307 if (phba
->nvmeio_trc_size
!= sz
)
2308 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
2309 "0572 nvmeio_trc_size changed to %ld\n",
2311 phba
->nvmeio_trc_size
= (uint32_t)sz
;
2313 /* If one previously exists, free it */
2314 kfree(phba
->nvmeio_trc
);
2316 /* Allocate new trace buffer and initialize */
2317 phba
->nvmeio_trc
= kzalloc((sizeof(struct lpfc_debugfs_nvmeio_trc
) *
2319 if (!phba
->nvmeio_trc
) {
2320 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
2321 "0573 Cannot create debugfs "
2322 "nvmeio_trc buffer\n");
2325 atomic_set(&phba
->nvmeio_trc_cnt
, 0);
2326 phba
->nvmeio_trc_on
= 0;
2327 phba
->nvmeio_trc_output_idx
= 0;
2329 return strlen(pbuf
);
2333 lpfc_debugfs_cpucheck_open(struct inode
*inode
, struct file
*file
)
2335 struct lpfc_vport
*vport
= inode
->i_private
;
2336 struct lpfc_debug
*debug
;
2339 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
2343 /* Round to page boundary */
2344 debug
->buffer
= kmalloc(LPFC_CPUCHECK_SIZE
, GFP_KERNEL
);
2345 if (!debug
->buffer
) {
2350 debug
->len
= lpfc_debugfs_cpucheck_data(vport
, debug
->buffer
,
2351 LPFC_NVMEKTIME_SIZE
);
2353 debug
->i_private
= inode
->i_private
;
2354 file
->private_data
= debug
;
2362 lpfc_debugfs_cpucheck_write(struct file
*file
, const char __user
*buf
,
2363 size_t nbytes
, loff_t
*ppos
)
2365 struct lpfc_debug
*debug
= file
->private_data
;
2366 struct lpfc_vport
*vport
= (struct lpfc_vport
*)debug
->i_private
;
2367 struct lpfc_hba
*phba
= vport
->phba
;
2375 memset(mybuf
, 0, sizeof(mybuf
));
2377 if (copy_from_user(mybuf
, buf
, nbytes
))
2381 if ((strncmp(pbuf
, "on", sizeof("on") - 1) == 0)) {
2382 if (phba
->nvmet_support
)
2383 phba
->cpucheck_on
|= LPFC_CHECK_NVMET_IO
;
2385 phba
->cpucheck_on
|= LPFC_CHECK_NVME_IO
;
2386 return strlen(pbuf
);
2387 } else if ((strncmp(pbuf
, "rcv",
2388 sizeof("rcv") - 1) == 0)) {
2389 if (phba
->nvmet_support
)
2390 phba
->cpucheck_on
|= LPFC_CHECK_NVMET_RCV
;
2393 return strlen(pbuf
);
2394 } else if ((strncmp(pbuf
, "off",
2395 sizeof("off") - 1) == 0)) {
2396 phba
->cpucheck_on
= LPFC_CHECK_OFF
;
2397 return strlen(pbuf
);
2398 } else if ((strncmp(pbuf
, "zero",
2399 sizeof("zero") - 1) == 0)) {
2400 for (i
= 0; i
< phba
->sli4_hba
.num_present_cpu
; i
++) {
2401 if (i
>= LPFC_CHECK_CPU_CNT
)
2403 phba
->cpucheck_rcv_io
[i
] = 0;
2404 phba
->cpucheck_xmt_io
[i
] = 0;
2405 phba
->cpucheck_cmpl_io
[i
] = 0;
2406 phba
->cpucheck_ccmpl_io
[i
] = 0;
2408 return strlen(pbuf
);
2414 * ---------------------------------
2415 * iDiag debugfs file access methods
2416 * ---------------------------------
2418 * All access methods are through the proper SLI4 PCI function's debugfs
2421 * /sys/kernel/debug/lpfc/fn<#>/iDiag
2425 * lpfc_idiag_cmd_get - Get and parse idiag debugfs comands from user space
2426 * @buf: The pointer to the user space buffer.
2427 * @nbytes: The number of bytes in the user space buffer.
2428 * @idiag_cmd: pointer to the idiag command struct.
2430 * This routine reads data from debugfs user space buffer and parses the
2431 * buffer for getting the idiag command and arguments. The while space in
2432 * between the set of data is used as the parsing separator.
2434 * This routine returns 0 when successful, it returns proper error code
2435 * back to the user space in error conditions.
2437 static int lpfc_idiag_cmd_get(const char __user
*buf
, size_t nbytes
,
2438 struct lpfc_idiag_cmd
*idiag_cmd
)
2441 char *pbuf
, *step_str
;
2445 memset(mybuf
, 0, sizeof(mybuf
));
2446 memset(idiag_cmd
, 0, sizeof(*idiag_cmd
));
2447 bsize
= min(nbytes
, (sizeof(mybuf
)-1));
2449 if (copy_from_user(mybuf
, buf
, bsize
))
2452 step_str
= strsep(&pbuf
, "\t ");
2454 /* The opcode must present */
2458 idiag_cmd
->opcode
= simple_strtol(step_str
, NULL
, 0);
2459 if (idiag_cmd
->opcode
== 0)
2462 for (i
= 0; i
< LPFC_IDIAG_CMD_DATA_SIZE
; i
++) {
2463 step_str
= strsep(&pbuf
, "\t ");
2466 idiag_cmd
->data
[i
] = simple_strtol(step_str
, NULL
, 0);
2472 * lpfc_idiag_open - idiag open debugfs
2473 * @inode: The inode pointer that contains a pointer to phba.
2474 * @file: The file pointer to attach the file operation.
2477 * This routine is the entry point for the debugfs open file operation. It
2478 * gets the reference to phba from the i_private field in @inode, it then
2479 * allocates buffer for the file operation, performs the necessary PCI config
2480 * space read into the allocated buffer according to the idiag user command
2481 * setup, and then returns a pointer to buffer in the private_data field in
2485 * This function returns zero if successful. On error it will return an
2486 * negative error value.
2489 lpfc_idiag_open(struct inode
*inode
, struct file
*file
)
2491 struct lpfc_debug
*debug
;
2493 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
2497 debug
->i_private
= inode
->i_private
;
2498 debug
->buffer
= NULL
;
2499 file
->private_data
= debug
;
2505 * lpfc_idiag_release - Release idiag access file operation
2506 * @inode: The inode pointer that contains a vport pointer. (unused)
2507 * @file: The file pointer that contains the buffer to release.
2510 * This routine is the generic release routine for the idiag access file
2511 * operation, it frees the buffer that was allocated when the debugfs file
2515 * This function returns zero.
2518 lpfc_idiag_release(struct inode
*inode
, struct file
*file
)
2520 struct lpfc_debug
*debug
= file
->private_data
;
2522 /* Free the buffers to the file operation */
2523 kfree(debug
->buffer
);
2530 * lpfc_idiag_cmd_release - Release idiag cmd access file operation
2531 * @inode: The inode pointer that contains a vport pointer. (unused)
2532 * @file: The file pointer that contains the buffer to release.
2535 * This routine frees the buffer that was allocated when the debugfs file
2536 * was opened. It also reset the fields in the idiag command struct in the
2537 * case of command for write operation.
2540 * This function returns zero.
2543 lpfc_idiag_cmd_release(struct inode
*inode
, struct file
*file
)
2545 struct lpfc_debug
*debug
= file
->private_data
;
2547 if (debug
->op
== LPFC_IDIAG_OP_WR
) {
2548 switch (idiag
.cmd
.opcode
) {
2549 case LPFC_IDIAG_CMD_PCICFG_WR
:
2550 case LPFC_IDIAG_CMD_PCICFG_ST
:
2551 case LPFC_IDIAG_CMD_PCICFG_CL
:
2552 case LPFC_IDIAG_CMD_QUEACC_WR
:
2553 case LPFC_IDIAG_CMD_QUEACC_ST
:
2554 case LPFC_IDIAG_CMD_QUEACC_CL
:
2555 memset(&idiag
, 0, sizeof(idiag
));
2562 /* Free the buffers to the file operation */
2563 kfree(debug
->buffer
);
2570 * lpfc_idiag_pcicfg_read - idiag debugfs read pcicfg
2571 * @file: The file pointer to read from.
2572 * @buf: The buffer to copy the data to.
2573 * @nbytes: The number of bytes to read.
2574 * @ppos: The position in the file to start reading from.
2577 * This routine reads data from the @phba pci config space according to the
2578 * idiag command, and copies to user @buf. Depending on the PCI config space
2579 * read command setup, it does either a single register read of a byte
2580 * (8 bits), a word (16 bits), or a dword (32 bits) or browsing through all
2581 * registers from the 4K extended PCI config space.
2584 * This function returns the amount of data that was read (this could be less
2585 * than @nbytes if the end of the file was reached) or a negative error value.
2588 lpfc_idiag_pcicfg_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
2591 struct lpfc_debug
*debug
= file
->private_data
;
2592 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
2593 int offset_label
, offset
, len
= 0, index
= LPFC_PCI_CFG_RD_SIZE
;
2596 struct pci_dev
*pdev
;
2601 pdev
= phba
->pcidev
;
2605 /* This is a user read operation */
2606 debug
->op
= LPFC_IDIAG_OP_RD
;
2609 debug
->buffer
= kmalloc(LPFC_PCI_CFG_SIZE
, GFP_KERNEL
);
2612 pbuffer
= debug
->buffer
;
2617 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_RD
) {
2618 where
= idiag
.cmd
.data
[IDIAG_PCICFG_WHERE_INDX
];
2619 count
= idiag
.cmd
.data
[IDIAG_PCICFG_COUNT_INDX
];
2623 /* Read single PCI config space register */
2625 case SIZE_U8
: /* byte (8 bits) */
2626 pci_read_config_byte(pdev
, where
, &u8val
);
2627 len
+= snprintf(pbuffer
+len
, LPFC_PCI_CFG_SIZE
-len
,
2628 "%03x: %02x\n", where
, u8val
);
2630 case SIZE_U16
: /* word (16 bits) */
2631 pci_read_config_word(pdev
, where
, &u16val
);
2632 len
+= snprintf(pbuffer
+len
, LPFC_PCI_CFG_SIZE
-len
,
2633 "%03x: %04x\n", where
, u16val
);
2635 case SIZE_U32
: /* double word (32 bits) */
2636 pci_read_config_dword(pdev
, where
, &u32val
);
2637 len
+= snprintf(pbuffer
+len
, LPFC_PCI_CFG_SIZE
-len
,
2638 "%03x: %08x\n", where
, u32val
);
2640 case LPFC_PCI_CFG_BROWSE
: /* browse all */
2648 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
2652 /* Browse all PCI config space registers */
2653 offset_label
= idiag
.offset
.last_rd
;
2654 offset
= offset_label
;
2656 /* Read PCI config space */
2657 len
+= snprintf(pbuffer
+len
, LPFC_PCI_CFG_SIZE
-len
,
2658 "%03x: ", offset_label
);
2660 pci_read_config_dword(pdev
, offset
, &u32val
);
2661 len
+= snprintf(pbuffer
+len
, LPFC_PCI_CFG_SIZE
-len
,
2663 offset
+= sizeof(uint32_t);
2664 if (offset
>= LPFC_PCI_CFG_SIZE
) {
2665 len
+= snprintf(pbuffer
+len
,
2666 LPFC_PCI_CFG_SIZE
-len
, "\n");
2669 index
-= sizeof(uint32_t);
2671 len
+= snprintf(pbuffer
+len
, LPFC_PCI_CFG_SIZE
-len
,
2673 else if (!(index
% (8 * sizeof(uint32_t)))) {
2674 offset_label
+= (8 * sizeof(uint32_t));
2675 len
+= snprintf(pbuffer
+len
, LPFC_PCI_CFG_SIZE
-len
,
2676 "\n%03x: ", offset_label
);
2680 /* Set up the offset for next portion of pci cfg read */
2682 idiag
.offset
.last_rd
+= LPFC_PCI_CFG_RD_SIZE
;
2683 if (idiag
.offset
.last_rd
>= LPFC_PCI_CFG_SIZE
)
2684 idiag
.offset
.last_rd
= 0;
2686 idiag
.offset
.last_rd
= 0;
2688 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
2692 * lpfc_idiag_pcicfg_write - Syntax check and set up idiag pcicfg commands
2693 * @file: The file pointer to read from.
2694 * @buf: The buffer to copy the user data from.
2695 * @nbytes: The number of bytes to get.
2696 * @ppos: The position in the file to start reading from.
2698 * This routine get the debugfs idiag command struct from user space and
2699 * then perform the syntax check for PCI config space read or write command
2700 * accordingly. In the case of PCI config space read command, it sets up
2701 * the command in the idiag command struct for the debugfs read operation.
2702 * In the case of PCI config space write operation, it executes the write
2703 * operation into the PCI config space accordingly.
2705 * It returns the @nbytges passing in from debugfs user space when successful.
2706 * In case of error conditions, it returns proper error code back to the user
2710 lpfc_idiag_pcicfg_write(struct file
*file
, const char __user
*buf
,
2711 size_t nbytes
, loff_t
*ppos
)
2713 struct lpfc_debug
*debug
= file
->private_data
;
2714 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
2715 uint32_t where
, value
, count
;
2719 struct pci_dev
*pdev
;
2722 pdev
= phba
->pcidev
;
2726 /* This is a user write operation */
2727 debug
->op
= LPFC_IDIAG_OP_WR
;
2729 rc
= lpfc_idiag_cmd_get(buf
, nbytes
, &idiag
.cmd
);
2733 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_RD
) {
2734 /* Sanity check on PCI config read command line arguments */
2735 if (rc
!= LPFC_PCI_CFG_RD_CMD_ARG
)
2737 /* Read command from PCI config space, set up command fields */
2738 where
= idiag
.cmd
.data
[IDIAG_PCICFG_WHERE_INDX
];
2739 count
= idiag
.cmd
.data
[IDIAG_PCICFG_COUNT_INDX
];
2740 if (count
== LPFC_PCI_CFG_BROWSE
) {
2741 if (where
% sizeof(uint32_t))
2743 /* Starting offset to browse */
2744 idiag
.offset
.last_rd
= where
;
2745 } else if ((count
!= sizeof(uint8_t)) &&
2746 (count
!= sizeof(uint16_t)) &&
2747 (count
!= sizeof(uint32_t)))
2749 if (count
== sizeof(uint8_t)) {
2750 if (where
> LPFC_PCI_CFG_SIZE
- sizeof(uint8_t))
2752 if (where
% sizeof(uint8_t))
2755 if (count
== sizeof(uint16_t)) {
2756 if (where
> LPFC_PCI_CFG_SIZE
- sizeof(uint16_t))
2758 if (where
% sizeof(uint16_t))
2761 if (count
== sizeof(uint32_t)) {
2762 if (where
> LPFC_PCI_CFG_SIZE
- sizeof(uint32_t))
2764 if (where
% sizeof(uint32_t))
2767 } else if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_WR
||
2768 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_ST
||
2769 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_CL
) {
2770 /* Sanity check on PCI config write command line arguments */
2771 if (rc
!= LPFC_PCI_CFG_WR_CMD_ARG
)
2773 /* Write command to PCI config space, read-modify-write */
2774 where
= idiag
.cmd
.data
[IDIAG_PCICFG_WHERE_INDX
];
2775 count
= idiag
.cmd
.data
[IDIAG_PCICFG_COUNT_INDX
];
2776 value
= idiag
.cmd
.data
[IDIAG_PCICFG_VALUE_INDX
];
2778 if ((count
!= sizeof(uint8_t)) &&
2779 (count
!= sizeof(uint16_t)) &&
2780 (count
!= sizeof(uint32_t)))
2782 if (count
== sizeof(uint8_t)) {
2783 if (where
> LPFC_PCI_CFG_SIZE
- sizeof(uint8_t))
2785 if (where
% sizeof(uint8_t))
2787 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_WR
)
2788 pci_write_config_byte(pdev
, where
,
2790 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_ST
) {
2791 rc
= pci_read_config_byte(pdev
, where
, &u8val
);
2793 u8val
|= (uint8_t)value
;
2794 pci_write_config_byte(pdev
, where
,
2798 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_CL
) {
2799 rc
= pci_read_config_byte(pdev
, where
, &u8val
);
2801 u8val
&= (uint8_t)(~value
);
2802 pci_write_config_byte(pdev
, where
,
2807 if (count
== sizeof(uint16_t)) {
2808 if (where
> LPFC_PCI_CFG_SIZE
- sizeof(uint16_t))
2810 if (where
% sizeof(uint16_t))
2812 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_WR
)
2813 pci_write_config_word(pdev
, where
,
2815 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_ST
) {
2816 rc
= pci_read_config_word(pdev
, where
, &u16val
);
2818 u16val
|= (uint16_t)value
;
2819 pci_write_config_word(pdev
, where
,
2823 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_CL
) {
2824 rc
= pci_read_config_word(pdev
, where
, &u16val
);
2826 u16val
&= (uint16_t)(~value
);
2827 pci_write_config_word(pdev
, where
,
2832 if (count
== sizeof(uint32_t)) {
2833 if (where
> LPFC_PCI_CFG_SIZE
- sizeof(uint32_t))
2835 if (where
% sizeof(uint32_t))
2837 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_WR
)
2838 pci_write_config_dword(pdev
, where
, value
);
2839 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_ST
) {
2840 rc
= pci_read_config_dword(pdev
, where
,
2844 pci_write_config_dword(pdev
, where
,
2848 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_CL
) {
2849 rc
= pci_read_config_dword(pdev
, where
,
2853 pci_write_config_dword(pdev
, where
,
2859 /* All other opecodes are illegal for now */
2864 memset(&idiag
, 0, sizeof(idiag
));
2869 * lpfc_idiag_baracc_read - idiag debugfs pci bar access read
2870 * @file: The file pointer to read from.
2871 * @buf: The buffer to copy the data to.
2872 * @nbytes: The number of bytes to read.
2873 * @ppos: The position in the file to start reading from.
2876 * This routine reads data from the @phba pci bar memory mapped space
2877 * according to the idiag command, and copies to user @buf.
2880 * This function returns the amount of data that was read (this could be less
2881 * than @nbytes if the end of the file was reached) or a negative error value.
2884 lpfc_idiag_baracc_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
2887 struct lpfc_debug
*debug
= file
->private_data
;
2888 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
2889 int offset_label
, offset
, offset_run
, len
= 0, index
;
2890 int bar_num
, acc_range
, bar_size
;
2892 void __iomem
*mem_mapped_bar
;
2894 struct pci_dev
*pdev
;
2897 pdev
= phba
->pcidev
;
2901 /* This is a user read operation */
2902 debug
->op
= LPFC_IDIAG_OP_RD
;
2905 debug
->buffer
= kmalloc(LPFC_PCI_BAR_RD_BUF_SIZE
, GFP_KERNEL
);
2908 pbuffer
= debug
->buffer
;
2913 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_RD
) {
2914 bar_num
= idiag
.cmd
.data
[IDIAG_BARACC_BAR_NUM_INDX
];
2915 offset
= idiag
.cmd
.data
[IDIAG_BARACC_OFF_SET_INDX
];
2916 acc_range
= idiag
.cmd
.data
[IDIAG_BARACC_ACC_MOD_INDX
];
2917 bar_size
= idiag
.cmd
.data
[IDIAG_BARACC_BAR_SZE_INDX
];
2924 if_type
= bf_get(lpfc_sli_intf_if_type
, &phba
->sli4_hba
.sli_intf
);
2925 if (if_type
== LPFC_SLI_INTF_IF_TYPE_0
) {
2926 if (bar_num
== IDIAG_BARACC_BAR_0
)
2927 mem_mapped_bar
= phba
->sli4_hba
.conf_regs_memmap_p
;
2928 else if (bar_num
== IDIAG_BARACC_BAR_1
)
2929 mem_mapped_bar
= phba
->sli4_hba
.ctrl_regs_memmap_p
;
2930 else if (bar_num
== IDIAG_BARACC_BAR_2
)
2931 mem_mapped_bar
= phba
->sli4_hba
.drbl_regs_memmap_p
;
2934 } else if (if_type
== LPFC_SLI_INTF_IF_TYPE_2
) {
2935 if (bar_num
== IDIAG_BARACC_BAR_0
)
2936 mem_mapped_bar
= phba
->sli4_hba
.conf_regs_memmap_p
;
2942 /* Read single PCI bar space register */
2943 if (acc_range
== SINGLE_WORD
) {
2944 offset_run
= offset
;
2945 u32val
= readl(mem_mapped_bar
+ offset_run
);
2946 len
+= snprintf(pbuffer
+len
, LPFC_PCI_BAR_RD_BUF_SIZE
-len
,
2947 "%05x: %08x\n", offset_run
, u32val
);
2951 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
2955 /* Browse all PCI bar space registers */
2956 offset_label
= idiag
.offset
.last_rd
;
2957 offset_run
= offset_label
;
2959 /* Read PCI bar memory mapped space */
2960 len
+= snprintf(pbuffer
+len
, LPFC_PCI_BAR_RD_BUF_SIZE
-len
,
2961 "%05x: ", offset_label
);
2962 index
= LPFC_PCI_BAR_RD_SIZE
;
2964 u32val
= readl(mem_mapped_bar
+ offset_run
);
2965 len
+= snprintf(pbuffer
+len
, LPFC_PCI_BAR_RD_BUF_SIZE
-len
,
2967 offset_run
+= sizeof(uint32_t);
2968 if (acc_range
== LPFC_PCI_BAR_BROWSE
) {
2969 if (offset_run
>= bar_size
) {
2970 len
+= snprintf(pbuffer
+len
,
2971 LPFC_PCI_BAR_RD_BUF_SIZE
-len
, "\n");
2975 if (offset_run
>= offset
+
2976 (acc_range
* sizeof(uint32_t))) {
2977 len
+= snprintf(pbuffer
+len
,
2978 LPFC_PCI_BAR_RD_BUF_SIZE
-len
, "\n");
2982 index
-= sizeof(uint32_t);
2984 len
+= snprintf(pbuffer
+len
,
2985 LPFC_PCI_BAR_RD_BUF_SIZE
-len
, "\n");
2986 else if (!(index
% (8 * sizeof(uint32_t)))) {
2987 offset_label
+= (8 * sizeof(uint32_t));
2988 len
+= snprintf(pbuffer
+len
,
2989 LPFC_PCI_BAR_RD_BUF_SIZE
-len
,
2990 "\n%05x: ", offset_label
);
2994 /* Set up the offset for next portion of pci bar read */
2996 idiag
.offset
.last_rd
+= LPFC_PCI_BAR_RD_SIZE
;
2997 if (acc_range
== LPFC_PCI_BAR_BROWSE
) {
2998 if (idiag
.offset
.last_rd
>= bar_size
)
2999 idiag
.offset
.last_rd
= 0;
3001 if (offset_run
>= offset
+
3002 (acc_range
* sizeof(uint32_t)))
3003 idiag
.offset
.last_rd
= offset
;
3006 if (acc_range
== LPFC_PCI_BAR_BROWSE
)
3007 idiag
.offset
.last_rd
= 0;
3009 idiag
.offset
.last_rd
= offset
;
3012 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
3016 * lpfc_idiag_baracc_write - Syntax check and set up idiag bar access commands
3017 * @file: The file pointer to read from.
3018 * @buf: The buffer to copy the user data from.
3019 * @nbytes: The number of bytes to get.
3020 * @ppos: The position in the file to start reading from.
3022 * This routine get the debugfs idiag command struct from user space and
3023 * then perform the syntax check for PCI bar memory mapped space read or
3024 * write command accordingly. In the case of PCI bar memory mapped space
3025 * read command, it sets up the command in the idiag command struct for
3026 * the debugfs read operation. In the case of PCI bar memorpy mapped space
3027 * write operation, it executes the write operation into the PCI bar memory
3028 * mapped space accordingly.
3030 * It returns the @nbytges passing in from debugfs user space when successful.
3031 * In case of error conditions, it returns proper error code back to the user
3035 lpfc_idiag_baracc_write(struct file
*file
, const char __user
*buf
,
3036 size_t nbytes
, loff_t
*ppos
)
3038 struct lpfc_debug
*debug
= file
->private_data
;
3039 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
3040 uint32_t bar_num
, bar_size
, offset
, value
, acc_range
;
3041 struct pci_dev
*pdev
;
3042 void __iomem
*mem_mapped_bar
;
3047 pdev
= phba
->pcidev
;
3051 /* This is a user write operation */
3052 debug
->op
= LPFC_IDIAG_OP_WR
;
3054 rc
= lpfc_idiag_cmd_get(buf
, nbytes
, &idiag
.cmd
);
3058 if_type
= bf_get(lpfc_sli_intf_if_type
, &phba
->sli4_hba
.sli_intf
);
3059 bar_num
= idiag
.cmd
.data
[IDIAG_BARACC_BAR_NUM_INDX
];
3061 if (if_type
== LPFC_SLI_INTF_IF_TYPE_0
) {
3062 if ((bar_num
!= IDIAG_BARACC_BAR_0
) &&
3063 (bar_num
!= IDIAG_BARACC_BAR_1
) &&
3064 (bar_num
!= IDIAG_BARACC_BAR_2
))
3066 } else if (if_type
== LPFC_SLI_INTF_IF_TYPE_2
) {
3067 if (bar_num
!= IDIAG_BARACC_BAR_0
)
3072 if (if_type
== LPFC_SLI_INTF_IF_TYPE_0
) {
3073 if (bar_num
== IDIAG_BARACC_BAR_0
) {
3074 idiag
.cmd
.data
[IDIAG_BARACC_BAR_SZE_INDX
] =
3075 LPFC_PCI_IF0_BAR0_SIZE
;
3076 mem_mapped_bar
= phba
->sli4_hba
.conf_regs_memmap_p
;
3077 } else if (bar_num
== IDIAG_BARACC_BAR_1
) {
3078 idiag
.cmd
.data
[IDIAG_BARACC_BAR_SZE_INDX
] =
3079 LPFC_PCI_IF0_BAR1_SIZE
;
3080 mem_mapped_bar
= phba
->sli4_hba
.ctrl_regs_memmap_p
;
3081 } else if (bar_num
== IDIAG_BARACC_BAR_2
) {
3082 idiag
.cmd
.data
[IDIAG_BARACC_BAR_SZE_INDX
] =
3083 LPFC_PCI_IF0_BAR2_SIZE
;
3084 mem_mapped_bar
= phba
->sli4_hba
.drbl_regs_memmap_p
;
3087 } else if (if_type
== LPFC_SLI_INTF_IF_TYPE_2
) {
3088 if (bar_num
== IDIAG_BARACC_BAR_0
) {
3089 idiag
.cmd
.data
[IDIAG_BARACC_BAR_SZE_INDX
] =
3090 LPFC_PCI_IF2_BAR0_SIZE
;
3091 mem_mapped_bar
= phba
->sli4_hba
.conf_regs_memmap_p
;
3097 offset
= idiag
.cmd
.data
[IDIAG_BARACC_OFF_SET_INDX
];
3098 if (offset
% sizeof(uint32_t))
3101 bar_size
= idiag
.cmd
.data
[IDIAG_BARACC_BAR_SZE_INDX
];
3102 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_RD
) {
3103 /* Sanity check on PCI config read command line arguments */
3104 if (rc
!= LPFC_PCI_BAR_RD_CMD_ARG
)
3106 acc_range
= idiag
.cmd
.data
[IDIAG_BARACC_ACC_MOD_INDX
];
3107 if (acc_range
== LPFC_PCI_BAR_BROWSE
) {
3108 if (offset
> bar_size
- sizeof(uint32_t))
3110 /* Starting offset to browse */
3111 idiag
.offset
.last_rd
= offset
;
3112 } else if (acc_range
> SINGLE_WORD
) {
3113 if (offset
+ acc_range
* sizeof(uint32_t) > bar_size
)
3115 /* Starting offset to browse */
3116 idiag
.offset
.last_rd
= offset
;
3117 } else if (acc_range
!= SINGLE_WORD
)
3119 } else if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_WR
||
3120 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_ST
||
3121 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_CL
) {
3122 /* Sanity check on PCI bar write command line arguments */
3123 if (rc
!= LPFC_PCI_BAR_WR_CMD_ARG
)
3125 /* Write command to PCI bar space, read-modify-write */
3126 acc_range
= SINGLE_WORD
;
3127 value
= idiag
.cmd
.data
[IDIAG_BARACC_REG_VAL_INDX
];
3128 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_WR
) {
3129 writel(value
, mem_mapped_bar
+ offset
);
3130 readl(mem_mapped_bar
+ offset
);
3132 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_ST
) {
3133 u32val
= readl(mem_mapped_bar
+ offset
);
3135 writel(u32val
, mem_mapped_bar
+ offset
);
3136 readl(mem_mapped_bar
+ offset
);
3138 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_CL
) {
3139 u32val
= readl(mem_mapped_bar
+ offset
);
3141 writel(u32val
, mem_mapped_bar
+ offset
);
3142 readl(mem_mapped_bar
+ offset
);
3145 /* All other opecodes are illegal for now */
3150 memset(&idiag
, 0, sizeof(idiag
));
3155 __lpfc_idiag_print_wq(struct lpfc_queue
*qp
, char *wqtype
,
3156 char *pbuffer
, int len
)
3161 len
+= snprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3162 "\t\t%s WQ info: ", wqtype
);
3163 len
+= snprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3164 "AssocCQID[%04d]: WQ-STAT[oflow:x%x posted:x%llx]\n",
3165 qp
->assoc_qid
, qp
->q_cnt_1
,
3166 (unsigned long long)qp
->q_cnt_4
);
3167 len
+= snprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3168 "\t\tWQID[%02d], QE-CNT[%04d], QE-SZ[%04d], "
3169 "HST-IDX[%04d], PRT-IDX[%04d], PST[%03d]",
3170 qp
->queue_id
, qp
->entry_count
,
3171 qp
->entry_size
, qp
->host_index
,
3172 qp
->hba_index
, qp
->entry_repost
);
3173 len
+= snprintf(pbuffer
+ len
,
3174 LPFC_QUE_INFO_GET_BUF_SIZE
- len
, "\n");
3179 lpfc_idiag_wqs_for_cq(struct lpfc_hba
*phba
, char *wqtype
, char *pbuffer
,
3180 int *len
, int max_cnt
, int cq_id
)
3182 struct lpfc_queue
*qp
;
3185 for (qidx
= 0; qidx
< phba
->cfg_fcp_io_channel
; qidx
++) {
3186 qp
= phba
->sli4_hba
.fcp_wq
[qidx
];
3187 if (qp
->assoc_qid
!= cq_id
)
3189 *len
= __lpfc_idiag_print_wq(qp
, wqtype
, pbuffer
, *len
);
3190 if (*len
>= max_cnt
)
3193 for (qidx
= 0; qidx
< phba
->cfg_nvme_io_channel
; qidx
++) {
3194 qp
= phba
->sli4_hba
.nvme_wq
[qidx
];
3195 if (qp
->assoc_qid
!= cq_id
)
3197 *len
= __lpfc_idiag_print_wq(qp
, wqtype
, pbuffer
, *len
);
3198 if (*len
>= max_cnt
)
3205 __lpfc_idiag_print_cq(struct lpfc_queue
*qp
, char *cqtype
,
3206 char *pbuffer
, int len
)
3211 len
+= snprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3212 "\t%s CQ info: ", cqtype
);
3213 len
+= snprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3214 "AssocEQID[%02d]: CQ STAT[max:x%x relw:x%x "
3215 "xabt:x%x wq:x%llx]\n",
3216 qp
->assoc_qid
, qp
->q_cnt_1
, qp
->q_cnt_2
,
3217 qp
->q_cnt_3
, (unsigned long long)qp
->q_cnt_4
);
3218 len
+= snprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3219 "\tCQID[%02d], QE-CNT[%04d], QE-SZ[%04d], "
3220 "HST-IDX[%04d], PRT-IDX[%04d], PST[%03d]",
3221 qp
->queue_id
, qp
->entry_count
,
3222 qp
->entry_size
, qp
->host_index
,
3223 qp
->hba_index
, qp
->entry_repost
);
3225 len
+= snprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
, "\n");
3231 __lpfc_idiag_print_rqpair(struct lpfc_queue
*qp
, struct lpfc_queue
*datqp
,
3232 char *rqtype
, char *pbuffer
, int len
)
3237 len
+= snprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3238 "\t\t%s RQ info: ", rqtype
);
3239 len
+= snprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3240 "AssocCQID[%02d]: RQ-STAT[nopost:x%x nobuf:x%x "
3241 "posted:x%x rcv:x%llx]\n",
3242 qp
->assoc_qid
, qp
->q_cnt_1
, qp
->q_cnt_2
,
3243 qp
->q_cnt_3
, (unsigned long long)qp
->q_cnt_4
);
3244 len
+= snprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3245 "\t\tHQID[%02d], QE-CNT[%04d], QE-SZ[%04d], "
3246 "HST-IDX[%04d], PRT-IDX[%04d], PST[%03d]\n",
3247 qp
->queue_id
, qp
->entry_count
, qp
->entry_size
,
3248 qp
->host_index
, qp
->hba_index
, qp
->entry_repost
);
3249 len
+= snprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3250 "\t\tDQID[%02d], QE-CNT[%04d], QE-SZ[%04d], "
3251 "HST-IDX[%04d], PRT-IDX[%04d], PST[%03d]\n",
3252 datqp
->queue_id
, datqp
->entry_count
,
3253 datqp
->entry_size
, datqp
->host_index
,
3254 datqp
->hba_index
, datqp
->entry_repost
);
3259 lpfc_idiag_cqs_for_eq(struct lpfc_hba
*phba
, char *pbuffer
,
3260 int *len
, int max_cnt
, int eqidx
, int eq_id
)
3262 struct lpfc_queue
*qp
;
3265 for (qidx
= 0; qidx
< phba
->cfg_fcp_io_channel
; qidx
++) {
3266 qp
= phba
->sli4_hba
.fcp_cq
[qidx
];
3267 if (qp
->assoc_qid
!= eq_id
)
3270 *len
= __lpfc_idiag_print_cq(qp
, "FCP", pbuffer
, *len
);
3272 /* Reset max counter */
3275 if (*len
>= max_cnt
)
3278 rc
= lpfc_idiag_wqs_for_cq(phba
, "FCP", pbuffer
, len
,
3279 max_cnt
, qp
->queue_id
);
3284 for (qidx
= 0; qidx
< phba
->cfg_nvme_io_channel
; qidx
++) {
3285 qp
= phba
->sli4_hba
.nvme_cq
[qidx
];
3286 if (qp
->assoc_qid
!= eq_id
)
3289 *len
= __lpfc_idiag_print_cq(qp
, "NVME", pbuffer
, *len
);
3291 /* Reset max counter */
3294 if (*len
>= max_cnt
)
3297 rc
= lpfc_idiag_wqs_for_cq(phba
, "NVME", pbuffer
, len
,
3298 max_cnt
, qp
->queue_id
);
3303 if ((eqidx
< phba
->cfg_nvmet_mrq
) && phba
->nvmet_support
) {
3305 qp
= phba
->sli4_hba
.nvmet_cqset
[eqidx
];
3306 *len
= __lpfc_idiag_print_cq(qp
, "NVMET CQset", pbuffer
, *len
);
3308 /* Reset max counter */
3311 if (*len
>= max_cnt
)
3315 qp
= phba
->sli4_hba
.nvmet_mrq_hdr
[eqidx
];
3316 *len
= __lpfc_idiag_print_rqpair(qp
,
3317 phba
->sli4_hba
.nvmet_mrq_data
[eqidx
],
3318 "NVMET MRQ", pbuffer
, *len
);
3320 if (*len
>= max_cnt
)
3328 __lpfc_idiag_print_eq(struct lpfc_queue
*qp
, char *eqtype
,
3329 char *pbuffer
, int len
)
3334 len
+= snprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3335 "\n%s EQ info: EQ-STAT[max:x%x noE:x%x "
3336 "cqe_proc:x%x eqe_proc:x%llx eqd %d]\n",
3337 eqtype
, qp
->q_cnt_1
, qp
->q_cnt_2
, qp
->q_cnt_3
,
3338 (unsigned long long)qp
->q_cnt_4
, qp
->q_mode
);
3339 len
+= snprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3340 "EQID[%02d], QE-CNT[%04d], QE-SZ[%04d], "
3341 "HST-IDX[%04d], PRT-IDX[%04d], PST[%03d]",
3342 qp
->queue_id
, qp
->entry_count
, qp
->entry_size
,
3343 qp
->host_index
, qp
->hba_index
, qp
->entry_repost
);
3344 len
+= snprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
, "\n");
3350 * lpfc_idiag_queinfo_read - idiag debugfs read queue information
3351 * @file: The file pointer to read from.
3352 * @buf: The buffer to copy the data to.
3353 * @nbytes: The number of bytes to read.
3354 * @ppos: The position in the file to start reading from.
3357 * This routine reads data from the @phba SLI4 PCI function queue information,
3358 * and copies to user @buf.
3359 * This routine only returns 1 EQs worth of information. It remembers the last
3360 * EQ read and jumps to the next EQ. Thus subsequent calls to queInfo will
3361 * retrieve all EQs allocated for the phba.
3364 * This function returns the amount of data that was read (this could be less
3365 * than @nbytes if the end of the file was reached) or a negative error value.
3368 lpfc_idiag_queinfo_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
3371 struct lpfc_debug
*debug
= file
->private_data
;
3372 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
3374 int max_cnt
, rc
, x
, len
= 0;
3375 struct lpfc_queue
*qp
= NULL
;
3378 debug
->buffer
= kmalloc(LPFC_QUE_INFO_GET_BUF_SIZE
, GFP_KERNEL
);
3381 pbuffer
= debug
->buffer
;
3382 max_cnt
= LPFC_QUE_INFO_GET_BUF_SIZE
- 256;
3387 spin_lock_irq(&phba
->hbalock
);
3389 /* Fast-path event queue */
3390 if (phba
->sli4_hba
.hba_eq
&& phba
->io_channel_irqs
) {
3392 x
= phba
->lpfc_idiag_last_eq
;
3393 if (phba
->cfg_fof
&& (x
>= phba
->io_channel_irqs
)) {
3394 phba
->lpfc_idiag_last_eq
= 0;
3397 phba
->lpfc_idiag_last_eq
++;
3398 if (phba
->lpfc_idiag_last_eq
>= phba
->io_channel_irqs
)
3399 if (phba
->cfg_fof
== 0)
3400 phba
->lpfc_idiag_last_eq
= 0;
3402 len
+= snprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3403 "EQ %d out of %d HBA EQs\n",
3404 x
, phba
->io_channel_irqs
);
3407 qp
= phba
->sli4_hba
.hba_eq
[x
];
3411 len
= __lpfc_idiag_print_eq(qp
, "HBA", pbuffer
, len
);
3413 /* Reset max counter */
3419 /* will dump both fcp and nvme cqs/wqs for the eq */
3420 rc
= lpfc_idiag_cqs_for_eq(phba
, pbuffer
, &len
,
3421 max_cnt
, x
, qp
->queue_id
);
3425 /* Only EQ 0 has slow path CQs configured */
3429 /* Slow-path mailbox CQ */
3430 qp
= phba
->sli4_hba
.mbx_cq
;
3431 len
= __lpfc_idiag_print_cq(qp
, "MBX", pbuffer
, len
);
3435 /* Slow-path MBOX MQ */
3436 qp
= phba
->sli4_hba
.mbx_wq
;
3437 len
= __lpfc_idiag_print_wq(qp
, "MBX", pbuffer
, len
);
3441 /* Slow-path ELS response CQ */
3442 qp
= phba
->sli4_hba
.els_cq
;
3443 len
= __lpfc_idiag_print_cq(qp
, "ELS", pbuffer
, len
);
3444 /* Reset max counter */
3450 /* Slow-path ELS WQ */
3451 qp
= phba
->sli4_hba
.els_wq
;
3452 len
= __lpfc_idiag_print_wq(qp
, "ELS", pbuffer
, len
);
3456 qp
= phba
->sli4_hba
.hdr_rq
;
3457 len
= __lpfc_idiag_print_rqpair(qp
, phba
->sli4_hba
.dat_rq
,
3458 "ELS RQpair", pbuffer
, len
);
3462 /* Slow-path NVME LS response CQ */
3463 qp
= phba
->sli4_hba
.nvmels_cq
;
3464 len
= __lpfc_idiag_print_cq(qp
, "NVME LS",
3466 /* Reset max counter */
3472 /* Slow-path NVME LS WQ */
3473 qp
= phba
->sli4_hba
.nvmels_wq
;
3474 len
= __lpfc_idiag_print_wq(qp
, "NVME LS",
3483 if (phba
->cfg_fof
) {
3485 qp
= phba
->sli4_hba
.fof_eq
;
3486 len
= __lpfc_idiag_print_eq(qp
, "FOF", pbuffer
, len
);
3488 /* Reset max counter */
3496 qp
= phba
->sli4_hba
.oas_cq
;
3497 len
= __lpfc_idiag_print_cq(qp
, "OAS", pbuffer
, len
);
3498 /* Reset max counter */
3505 qp
= phba
->sli4_hba
.oas_wq
;
3506 len
= __lpfc_idiag_print_wq(qp
, "OAS", pbuffer
, len
);
3511 spin_unlock_irq(&phba
->hbalock
);
3512 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
3515 len
+= snprintf(pbuffer
+ len
,
3516 LPFC_QUE_INFO_GET_BUF_SIZE
- len
, "Truncated ...\n");
3518 spin_unlock_irq(&phba
->hbalock
);
3519 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
3523 * lpfc_idiag_que_param_check - queue access command parameter sanity check
3524 * @q: The pointer to queue structure.
3525 * @index: The index into a queue entry.
3526 * @count: The number of queue entries to access.
3529 * The routine performs sanity check on device queue access method commands.
3532 * This function returns -EINVAL when fails the sanity check, otherwise, it
3536 lpfc_idiag_que_param_check(struct lpfc_queue
*q
, int index
, int count
)
3538 /* Only support single entry read or browsing */
3539 if ((count
!= 1) && (count
!= LPFC_QUE_ACC_BROWSE
))
3541 if (index
> q
->entry_count
- 1)
3547 * lpfc_idiag_queacc_read_qe - read a single entry from the given queue index
3548 * @pbuffer: The pointer to buffer to copy the read data into.
3549 * @pque: The pointer to the queue to be read.
3550 * @index: The index into the queue entry.
3553 * This routine reads out a single entry from the given queue's index location
3554 * and copies it into the buffer provided.
3557 * This function returns 0 when it fails, otherwise, it returns the length of
3558 * the data read into the buffer provided.
3561 lpfc_idiag_queacc_read_qe(char *pbuffer
, int len
, struct lpfc_queue
*pque
,
3567 if (!pbuffer
|| !pque
)
3570 esize
= pque
->entry_size
;
3571 len
+= snprintf(pbuffer
+len
, LPFC_QUE_ACC_BUF_SIZE
-len
,
3572 "QE-INDEX[%04d]:\n", index
);
3575 pentry
= pque
->qe
[index
].address
;
3577 len
+= snprintf(pbuffer
+len
, LPFC_QUE_ACC_BUF_SIZE
-len
,
3580 offset
+= sizeof(uint32_t);
3581 esize
-= sizeof(uint32_t);
3582 if (esize
> 0 && !(offset
% (4 * sizeof(uint32_t))))
3583 len
+= snprintf(pbuffer
+len
,
3584 LPFC_QUE_ACC_BUF_SIZE
-len
, "\n");
3586 len
+= snprintf(pbuffer
+len
, LPFC_QUE_ACC_BUF_SIZE
-len
, "\n");
3592 * lpfc_idiag_queacc_read - idiag debugfs read port queue
3593 * @file: The file pointer to read from.
3594 * @buf: The buffer to copy the data to.
3595 * @nbytes: The number of bytes to read.
3596 * @ppos: The position in the file to start reading from.
3599 * This routine reads data from the @phba device queue memory according to the
3600 * idiag command, and copies to user @buf. Depending on the queue dump read
3601 * command setup, it does either a single queue entry read or browing through
3602 * all entries of the queue.
3605 * This function returns the amount of data that was read (this could be less
3606 * than @nbytes if the end of the file was reached) or a negative error value.
3609 lpfc_idiag_queacc_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
3612 struct lpfc_debug
*debug
= file
->private_data
;
3613 uint32_t last_index
, index
, count
;
3614 struct lpfc_queue
*pque
= NULL
;
3618 /* This is a user read operation */
3619 debug
->op
= LPFC_IDIAG_OP_RD
;
3622 debug
->buffer
= kmalloc(LPFC_QUE_ACC_BUF_SIZE
, GFP_KERNEL
);
3625 pbuffer
= debug
->buffer
;
3630 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_RD
) {
3631 index
= idiag
.cmd
.data
[IDIAG_QUEACC_INDEX_INDX
];
3632 count
= idiag
.cmd
.data
[IDIAG_QUEACC_COUNT_INDX
];
3633 pque
= (struct lpfc_queue
*)idiag
.ptr_private
;
3637 /* Browse the queue starting from index */
3638 if (count
== LPFC_QUE_ACC_BROWSE
)
3641 /* Read a single entry from the queue */
3642 len
= lpfc_idiag_queacc_read_qe(pbuffer
, len
, pque
, index
);
3644 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
3648 /* Browse all entries from the queue */
3649 last_index
= idiag
.offset
.last_rd
;
3652 while (len
< LPFC_QUE_ACC_SIZE
- pque
->entry_size
) {
3653 len
= lpfc_idiag_queacc_read_qe(pbuffer
, len
, pque
, index
);
3655 if (index
> pque
->entry_count
- 1)
3659 /* Set up the offset for next portion of pci cfg read */
3660 if (index
> pque
->entry_count
- 1)
3662 idiag
.offset
.last_rd
= index
;
3664 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
3668 * lpfc_idiag_queacc_write - Syntax check and set up idiag queacc commands
3669 * @file: The file pointer to read from.
3670 * @buf: The buffer to copy the user data from.
3671 * @nbytes: The number of bytes to get.
3672 * @ppos: The position in the file to start reading from.
3674 * This routine get the debugfs idiag command struct from user space and then
3675 * perform the syntax check for port queue read (dump) or write (set) command
3676 * accordingly. In the case of port queue read command, it sets up the command
3677 * in the idiag command struct for the following debugfs read operation. In
3678 * the case of port queue write operation, it executes the write operation
3679 * into the port queue entry accordingly.
3681 * It returns the @nbytges passing in from debugfs user space when successful.
3682 * In case of error conditions, it returns proper error code back to the user
3686 lpfc_idiag_queacc_write(struct file
*file
, const char __user
*buf
,
3687 size_t nbytes
, loff_t
*ppos
)
3689 struct lpfc_debug
*debug
= file
->private_data
;
3690 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
3691 uint32_t qidx
, quetp
, queid
, index
, count
, offset
, value
;
3693 struct lpfc_queue
*pque
, *qp
;
3696 /* This is a user write operation */
3697 debug
->op
= LPFC_IDIAG_OP_WR
;
3699 rc
= lpfc_idiag_cmd_get(buf
, nbytes
, &idiag
.cmd
);
3703 /* Get and sanity check on command feilds */
3704 quetp
= idiag
.cmd
.data
[IDIAG_QUEACC_QUETP_INDX
];
3705 queid
= idiag
.cmd
.data
[IDIAG_QUEACC_QUEID_INDX
];
3706 index
= idiag
.cmd
.data
[IDIAG_QUEACC_INDEX_INDX
];
3707 count
= idiag
.cmd
.data
[IDIAG_QUEACC_COUNT_INDX
];
3708 offset
= idiag
.cmd
.data
[IDIAG_QUEACC_OFFST_INDX
];
3709 value
= idiag
.cmd
.data
[IDIAG_QUEACC_VALUE_INDX
];
3711 /* Sanity check on command line arguments */
3712 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_WR
||
3713 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_ST
||
3714 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_CL
) {
3715 if (rc
!= LPFC_QUE_ACC_WR_CMD_ARG
)
3719 } else if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_RD
) {
3720 if (rc
!= LPFC_QUE_ACC_RD_CMD_ARG
)
3727 /* HBA event queue */
3728 if (phba
->sli4_hba
.hba_eq
) {
3729 for (qidx
= 0; qidx
< phba
->io_channel_irqs
; qidx
++) {
3730 qp
= phba
->sli4_hba
.hba_eq
[qidx
];
3731 if (qp
&& qp
->queue_id
== queid
) {
3733 rc
= lpfc_idiag_que_param_check(qp
,
3737 idiag
.ptr_private
= qp
;
3745 /* MBX complete queue */
3746 if (phba
->sli4_hba
.mbx_cq
&&
3747 phba
->sli4_hba
.mbx_cq
->queue_id
== queid
) {
3749 rc
= lpfc_idiag_que_param_check(
3750 phba
->sli4_hba
.mbx_cq
, index
, count
);
3753 idiag
.ptr_private
= phba
->sli4_hba
.mbx_cq
;
3756 /* ELS complete queue */
3757 if (phba
->sli4_hba
.els_cq
&&
3758 phba
->sli4_hba
.els_cq
->queue_id
== queid
) {
3760 rc
= lpfc_idiag_que_param_check(
3761 phba
->sli4_hba
.els_cq
, index
, count
);
3764 idiag
.ptr_private
= phba
->sli4_hba
.els_cq
;
3767 /* NVME LS complete queue */
3768 if (phba
->sli4_hba
.nvmels_cq
&&
3769 phba
->sli4_hba
.nvmels_cq
->queue_id
== queid
) {
3771 rc
= lpfc_idiag_que_param_check(
3772 phba
->sli4_hba
.nvmels_cq
, index
, count
);
3775 idiag
.ptr_private
= phba
->sli4_hba
.nvmels_cq
;
3778 /* FCP complete queue */
3779 if (phba
->sli4_hba
.fcp_cq
) {
3780 for (qidx
= 0; qidx
< phba
->cfg_fcp_io_channel
;
3782 qp
= phba
->sli4_hba
.fcp_cq
[qidx
];
3783 if (qp
&& qp
->queue_id
== queid
) {
3785 rc
= lpfc_idiag_que_param_check(
3789 idiag
.ptr_private
= qp
;
3794 /* NVME complete queue */
3795 if (phba
->sli4_hba
.nvme_cq
) {
3798 if (phba
->sli4_hba
.nvme_cq
[qidx
] &&
3799 phba
->sli4_hba
.nvme_cq
[qidx
]->queue_id
==
3802 rc
= lpfc_idiag_que_param_check(
3803 phba
->sli4_hba
.nvme_cq
[qidx
],
3808 phba
->sli4_hba
.nvme_cq
[qidx
];
3811 } while (++qidx
< phba
->cfg_nvme_io_channel
);
3816 /* MBX work queue */
3817 if (phba
->sli4_hba
.mbx_wq
&&
3818 phba
->sli4_hba
.mbx_wq
->queue_id
== queid
) {
3820 rc
= lpfc_idiag_que_param_check(
3821 phba
->sli4_hba
.mbx_wq
, index
, count
);
3824 idiag
.ptr_private
= phba
->sli4_hba
.mbx_wq
;
3830 /* ELS work queue */
3831 if (phba
->sli4_hba
.els_wq
&&
3832 phba
->sli4_hba
.els_wq
->queue_id
== queid
) {
3834 rc
= lpfc_idiag_que_param_check(
3835 phba
->sli4_hba
.els_wq
, index
, count
);
3838 idiag
.ptr_private
= phba
->sli4_hba
.els_wq
;
3841 /* NVME LS work queue */
3842 if (phba
->sli4_hba
.nvmels_wq
&&
3843 phba
->sli4_hba
.nvmels_wq
->queue_id
== queid
) {
3845 rc
= lpfc_idiag_que_param_check(
3846 phba
->sli4_hba
.nvmels_wq
, index
, count
);
3849 idiag
.ptr_private
= phba
->sli4_hba
.nvmels_wq
;
3852 /* FCP work queue */
3853 if (phba
->sli4_hba
.fcp_wq
) {
3854 for (qidx
= 0; qidx
< phba
->cfg_fcp_io_channel
;
3856 qp
= phba
->sli4_hba
.fcp_wq
[qidx
];
3857 if (qp
&& qp
->queue_id
== queid
) {
3859 rc
= lpfc_idiag_que_param_check(
3863 idiag
.ptr_private
= qp
;
3868 /* NVME work queue */
3869 if (phba
->sli4_hba
.nvme_wq
) {
3870 for (qidx
= 0; qidx
< phba
->cfg_nvme_io_channel
;
3872 qp
= phba
->sli4_hba
.nvme_wq
[qidx
];
3873 if (qp
&& qp
->queue_id
== queid
) {
3875 rc
= lpfc_idiag_que_param_check(
3879 idiag
.ptr_private
= qp
;
3885 /* NVME work queues */
3886 if (phba
->sli4_hba
.nvme_wq
) {
3887 for (qidx
= 0; qidx
< phba
->cfg_nvme_io_channel
;
3889 if (!phba
->sli4_hba
.nvme_wq
[qidx
])
3891 if (phba
->sli4_hba
.nvme_wq
[qidx
]->queue_id
==
3894 rc
= lpfc_idiag_que_param_check(
3895 phba
->sli4_hba
.nvme_wq
[qidx
],
3900 phba
->sli4_hba
.nvme_wq
[qidx
];
3909 if (phba
->sli4_hba
.hdr_rq
&&
3910 phba
->sli4_hba
.hdr_rq
->queue_id
== queid
) {
3912 rc
= lpfc_idiag_que_param_check(
3913 phba
->sli4_hba
.hdr_rq
, index
, count
);
3916 idiag
.ptr_private
= phba
->sli4_hba
.hdr_rq
;
3920 if (phba
->sli4_hba
.dat_rq
&&
3921 phba
->sli4_hba
.dat_rq
->queue_id
== queid
) {
3923 rc
= lpfc_idiag_que_param_check(
3924 phba
->sli4_hba
.dat_rq
, index
, count
);
3927 idiag
.ptr_private
= phba
->sli4_hba
.dat_rq
;
3939 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_RD
) {
3940 if (count
== LPFC_QUE_ACC_BROWSE
)
3941 idiag
.offset
.last_rd
= index
;
3944 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_WR
||
3945 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_ST
||
3946 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_CL
) {
3947 /* Additional sanity checks on write operation */
3948 pque
= (struct lpfc_queue
*)idiag
.ptr_private
;
3949 if (offset
> pque
->entry_size
/sizeof(uint32_t) - 1)
3951 pentry
= pque
->qe
[index
].address
;
3953 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_WR
)
3955 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_ST
)
3957 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_CL
)
3963 /* Clean out command structure on command error out */
3964 memset(&idiag
, 0, sizeof(idiag
));
3969 * lpfc_idiag_drbacc_read_reg - idiag debugfs read a doorbell register
3970 * @phba: The pointer to hba structure.
3971 * @pbuffer: The pointer to the buffer to copy the data to.
3972 * @len: The lenght of bytes to copied.
3973 * @drbregid: The id to doorbell registers.
3976 * This routine reads a doorbell register and copies its content to the
3977 * user buffer pointed to by @pbuffer.
3980 * This function returns the amount of data that was copied into @pbuffer.
3983 lpfc_idiag_drbacc_read_reg(struct lpfc_hba
*phba
, char *pbuffer
,
3984 int len
, uint32_t drbregid
)
3992 len
+= snprintf(pbuffer
+ len
, LPFC_DRB_ACC_BUF_SIZE
-len
,
3993 "EQ-DRB-REG: 0x%08x\n",
3994 readl(phba
->sli4_hba
.EQDBregaddr
));
3997 len
+= snprintf(pbuffer
+ len
, LPFC_DRB_ACC_BUF_SIZE
- len
,
3998 "CQ-DRB-REG: 0x%08x\n",
3999 readl(phba
->sli4_hba
.CQDBregaddr
));
4002 len
+= snprintf(pbuffer
+len
, LPFC_DRB_ACC_BUF_SIZE
-len
,
4003 "MQ-DRB-REG: 0x%08x\n",
4004 readl(phba
->sli4_hba
.MQDBregaddr
));
4007 len
+= snprintf(pbuffer
+len
, LPFC_DRB_ACC_BUF_SIZE
-len
,
4008 "WQ-DRB-REG: 0x%08x\n",
4009 readl(phba
->sli4_hba
.WQDBregaddr
));
4012 len
+= snprintf(pbuffer
+len
, LPFC_DRB_ACC_BUF_SIZE
-len
,
4013 "RQ-DRB-REG: 0x%08x\n",
4014 readl(phba
->sli4_hba
.RQDBregaddr
));
4024 * lpfc_idiag_drbacc_read - idiag debugfs read port doorbell
4025 * @file: The file pointer to read from.
4026 * @buf: The buffer to copy the data to.
4027 * @nbytes: The number of bytes to read.
4028 * @ppos: The position in the file to start reading from.
4031 * This routine reads data from the @phba device doorbell register according
4032 * to the idiag command, and copies to user @buf. Depending on the doorbell
4033 * register read command setup, it does either a single doorbell register
4034 * read or dump all doorbell registers.
4037 * This function returns the amount of data that was read (this could be less
4038 * than @nbytes if the end of the file was reached) or a negative error value.
4041 lpfc_idiag_drbacc_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
4044 struct lpfc_debug
*debug
= file
->private_data
;
4045 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
4046 uint32_t drb_reg_id
, i
;
4050 /* This is a user read operation */
4051 debug
->op
= LPFC_IDIAG_OP_RD
;
4054 debug
->buffer
= kmalloc(LPFC_DRB_ACC_BUF_SIZE
, GFP_KERNEL
);
4057 pbuffer
= debug
->buffer
;
4062 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_RD
)
4063 drb_reg_id
= idiag
.cmd
.data
[IDIAG_DRBACC_REGID_INDX
];
4067 if (drb_reg_id
== LPFC_DRB_ACC_ALL
)
4068 for (i
= 1; i
<= LPFC_DRB_MAX
; i
++)
4069 len
= lpfc_idiag_drbacc_read_reg(phba
,
4072 len
= lpfc_idiag_drbacc_read_reg(phba
,
4073 pbuffer
, len
, drb_reg_id
);
4075 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
4079 * lpfc_idiag_drbacc_write - Syntax check and set up idiag drbacc commands
4080 * @file: The file pointer to read from.
4081 * @buf: The buffer to copy the user data from.
4082 * @nbytes: The number of bytes to get.
4083 * @ppos: The position in the file to start reading from.
4085 * This routine get the debugfs idiag command struct from user space and then
4086 * perform the syntax check for port doorbell register read (dump) or write
4087 * (set) command accordingly. In the case of port queue read command, it sets
4088 * up the command in the idiag command struct for the following debugfs read
4089 * operation. In the case of port doorbell register write operation, it
4090 * executes the write operation into the port doorbell register accordingly.
4092 * It returns the @nbytges passing in from debugfs user space when successful.
4093 * In case of error conditions, it returns proper error code back to the user
4097 lpfc_idiag_drbacc_write(struct file
*file
, const char __user
*buf
,
4098 size_t nbytes
, loff_t
*ppos
)
4100 struct lpfc_debug
*debug
= file
->private_data
;
4101 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
4102 uint32_t drb_reg_id
, value
, reg_val
= 0;
4103 void __iomem
*drb_reg
;
4106 /* This is a user write operation */
4107 debug
->op
= LPFC_IDIAG_OP_WR
;
4109 rc
= lpfc_idiag_cmd_get(buf
, nbytes
, &idiag
.cmd
);
4113 /* Sanity check on command line arguments */
4114 drb_reg_id
= idiag
.cmd
.data
[IDIAG_DRBACC_REGID_INDX
];
4115 value
= idiag
.cmd
.data
[IDIAG_DRBACC_VALUE_INDX
];
4117 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_WR
||
4118 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_ST
||
4119 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_CL
) {
4120 if (rc
!= LPFC_DRB_ACC_WR_CMD_ARG
)
4122 if (drb_reg_id
> LPFC_DRB_MAX
)
4124 } else if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_RD
) {
4125 if (rc
!= LPFC_DRB_ACC_RD_CMD_ARG
)
4127 if ((drb_reg_id
> LPFC_DRB_MAX
) &&
4128 (drb_reg_id
!= LPFC_DRB_ACC_ALL
))
4133 /* Perform the write access operation */
4134 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_WR
||
4135 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_ST
||
4136 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_CL
) {
4137 switch (drb_reg_id
) {
4139 drb_reg
= phba
->sli4_hba
.EQDBregaddr
;
4142 drb_reg
= phba
->sli4_hba
.CQDBregaddr
;
4145 drb_reg
= phba
->sli4_hba
.MQDBregaddr
;
4148 drb_reg
= phba
->sli4_hba
.WQDBregaddr
;
4151 drb_reg
= phba
->sli4_hba
.RQDBregaddr
;
4157 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_WR
)
4159 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_ST
) {
4160 reg_val
= readl(drb_reg
);
4163 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_CL
) {
4164 reg_val
= readl(drb_reg
);
4167 writel(reg_val
, drb_reg
);
4168 readl(drb_reg
); /* flush */
4173 /* Clean out command structure on command error out */
4174 memset(&idiag
, 0, sizeof(idiag
));
4179 * lpfc_idiag_ctlacc_read_reg - idiag debugfs read a control registers
4180 * @phba: The pointer to hba structure.
4181 * @pbuffer: The pointer to the buffer to copy the data to.
4182 * @len: The lenght of bytes to copied.
4183 * @drbregid: The id to doorbell registers.
4186 * This routine reads a control register and copies its content to the
4187 * user buffer pointed to by @pbuffer.
4190 * This function returns the amount of data that was copied into @pbuffer.
4193 lpfc_idiag_ctlacc_read_reg(struct lpfc_hba
*phba
, char *pbuffer
,
4194 int len
, uint32_t ctlregid
)
4201 case LPFC_CTL_PORT_SEM
:
4202 len
+= snprintf(pbuffer
+len
, LPFC_CTL_ACC_BUF_SIZE
-len
,
4203 "Port SemReg: 0x%08x\n",
4204 readl(phba
->sli4_hba
.conf_regs_memmap_p
+
4205 LPFC_CTL_PORT_SEM_OFFSET
));
4207 case LPFC_CTL_PORT_STA
:
4208 len
+= snprintf(pbuffer
+len
, LPFC_CTL_ACC_BUF_SIZE
-len
,
4209 "Port StaReg: 0x%08x\n",
4210 readl(phba
->sli4_hba
.conf_regs_memmap_p
+
4211 LPFC_CTL_PORT_STA_OFFSET
));
4213 case LPFC_CTL_PORT_CTL
:
4214 len
+= snprintf(pbuffer
+len
, LPFC_CTL_ACC_BUF_SIZE
-len
,
4215 "Port CtlReg: 0x%08x\n",
4216 readl(phba
->sli4_hba
.conf_regs_memmap_p
+
4217 LPFC_CTL_PORT_CTL_OFFSET
));
4219 case LPFC_CTL_PORT_ER1
:
4220 len
+= snprintf(pbuffer
+len
, LPFC_CTL_ACC_BUF_SIZE
-len
,
4221 "Port Er1Reg: 0x%08x\n",
4222 readl(phba
->sli4_hba
.conf_regs_memmap_p
+
4223 LPFC_CTL_PORT_ER1_OFFSET
));
4225 case LPFC_CTL_PORT_ER2
:
4226 len
+= snprintf(pbuffer
+len
, LPFC_CTL_ACC_BUF_SIZE
-len
,
4227 "Port Er2Reg: 0x%08x\n",
4228 readl(phba
->sli4_hba
.conf_regs_memmap_p
+
4229 LPFC_CTL_PORT_ER2_OFFSET
));
4231 case LPFC_CTL_PDEV_CTL
:
4232 len
+= snprintf(pbuffer
+len
, LPFC_CTL_ACC_BUF_SIZE
-len
,
4233 "PDev CtlReg: 0x%08x\n",
4234 readl(phba
->sli4_hba
.conf_regs_memmap_p
+
4235 LPFC_CTL_PDEV_CTL_OFFSET
));
4244 * lpfc_idiag_ctlacc_read - idiag debugfs read port and device control register
4245 * @file: The file pointer to read from.
4246 * @buf: The buffer to copy the data to.
4247 * @nbytes: The number of bytes to read.
4248 * @ppos: The position in the file to start reading from.
4251 * This routine reads data from the @phba port and device registers according
4252 * to the idiag command, and copies to user @buf.
4255 * This function returns the amount of data that was read (this could be less
4256 * than @nbytes if the end of the file was reached) or a negative error value.
4259 lpfc_idiag_ctlacc_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
4262 struct lpfc_debug
*debug
= file
->private_data
;
4263 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
4264 uint32_t ctl_reg_id
, i
;
4268 /* This is a user read operation */
4269 debug
->op
= LPFC_IDIAG_OP_RD
;
4272 debug
->buffer
= kmalloc(LPFC_CTL_ACC_BUF_SIZE
, GFP_KERNEL
);
4275 pbuffer
= debug
->buffer
;
4280 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_RD
)
4281 ctl_reg_id
= idiag
.cmd
.data
[IDIAG_CTLACC_REGID_INDX
];
4285 if (ctl_reg_id
== LPFC_CTL_ACC_ALL
)
4286 for (i
= 1; i
<= LPFC_CTL_MAX
; i
++)
4287 len
= lpfc_idiag_ctlacc_read_reg(phba
,
4290 len
= lpfc_idiag_ctlacc_read_reg(phba
,
4291 pbuffer
, len
, ctl_reg_id
);
4293 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
4297 * lpfc_idiag_ctlacc_write - Syntax check and set up idiag ctlacc commands
4298 * @file: The file pointer to read from.
4299 * @buf: The buffer to copy the user data from.
4300 * @nbytes: The number of bytes to get.
4301 * @ppos: The position in the file to start reading from.
4303 * This routine get the debugfs idiag command struct from user space and then
4304 * perform the syntax check for port and device control register read (dump)
4305 * or write (set) command accordingly.
4307 * It returns the @nbytges passing in from debugfs user space when successful.
4308 * In case of error conditions, it returns proper error code back to the user
4312 lpfc_idiag_ctlacc_write(struct file
*file
, const char __user
*buf
,
4313 size_t nbytes
, loff_t
*ppos
)
4315 struct lpfc_debug
*debug
= file
->private_data
;
4316 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
4317 uint32_t ctl_reg_id
, value
, reg_val
= 0;
4318 void __iomem
*ctl_reg
;
4321 /* This is a user write operation */
4322 debug
->op
= LPFC_IDIAG_OP_WR
;
4324 rc
= lpfc_idiag_cmd_get(buf
, nbytes
, &idiag
.cmd
);
4328 /* Sanity check on command line arguments */
4329 ctl_reg_id
= idiag
.cmd
.data
[IDIAG_CTLACC_REGID_INDX
];
4330 value
= idiag
.cmd
.data
[IDIAG_CTLACC_VALUE_INDX
];
4332 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_WR
||
4333 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_ST
||
4334 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_CL
) {
4335 if (rc
!= LPFC_CTL_ACC_WR_CMD_ARG
)
4337 if (ctl_reg_id
> LPFC_CTL_MAX
)
4339 } else if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_RD
) {
4340 if (rc
!= LPFC_CTL_ACC_RD_CMD_ARG
)
4342 if ((ctl_reg_id
> LPFC_CTL_MAX
) &&
4343 (ctl_reg_id
!= LPFC_CTL_ACC_ALL
))
4348 /* Perform the write access operation */
4349 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_WR
||
4350 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_ST
||
4351 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_CL
) {
4352 switch (ctl_reg_id
) {
4353 case LPFC_CTL_PORT_SEM
:
4354 ctl_reg
= phba
->sli4_hba
.conf_regs_memmap_p
+
4355 LPFC_CTL_PORT_SEM_OFFSET
;
4357 case LPFC_CTL_PORT_STA
:
4358 ctl_reg
= phba
->sli4_hba
.conf_regs_memmap_p
+
4359 LPFC_CTL_PORT_STA_OFFSET
;
4361 case LPFC_CTL_PORT_CTL
:
4362 ctl_reg
= phba
->sli4_hba
.conf_regs_memmap_p
+
4363 LPFC_CTL_PORT_CTL_OFFSET
;
4365 case LPFC_CTL_PORT_ER1
:
4366 ctl_reg
= phba
->sli4_hba
.conf_regs_memmap_p
+
4367 LPFC_CTL_PORT_ER1_OFFSET
;
4369 case LPFC_CTL_PORT_ER2
:
4370 ctl_reg
= phba
->sli4_hba
.conf_regs_memmap_p
+
4371 LPFC_CTL_PORT_ER2_OFFSET
;
4373 case LPFC_CTL_PDEV_CTL
:
4374 ctl_reg
= phba
->sli4_hba
.conf_regs_memmap_p
+
4375 LPFC_CTL_PDEV_CTL_OFFSET
;
4381 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_WR
)
4383 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_ST
) {
4384 reg_val
= readl(ctl_reg
);
4387 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_CL
) {
4388 reg_val
= readl(ctl_reg
);
4391 writel(reg_val
, ctl_reg
);
4392 readl(ctl_reg
); /* flush */
4397 /* Clean out command structure on command error out */
4398 memset(&idiag
, 0, sizeof(idiag
));
4403 * lpfc_idiag_mbxacc_get_setup - idiag debugfs get mailbox access setup
4404 * @phba: Pointer to HBA context object.
4405 * @pbuffer: Pointer to data buffer.
4408 * This routine gets the driver mailbox access debugfs setup information.
4411 * This function returns the amount of data that was read (this could be less
4412 * than @nbytes if the end of the file was reached) or a negative error value.
4415 lpfc_idiag_mbxacc_get_setup(struct lpfc_hba
*phba
, char *pbuffer
)
4417 uint32_t mbx_dump_map
, mbx_dump_cnt
, mbx_word_cnt
, mbx_mbox_cmd
;
4420 mbx_mbox_cmd
= idiag
.cmd
.data
[IDIAG_MBXACC_MBCMD_INDX
];
4421 mbx_dump_map
= idiag
.cmd
.data
[IDIAG_MBXACC_DPMAP_INDX
];
4422 mbx_dump_cnt
= idiag
.cmd
.data
[IDIAG_MBXACC_DPCNT_INDX
];
4423 mbx_word_cnt
= idiag
.cmd
.data
[IDIAG_MBXACC_WDCNT_INDX
];
4425 len
+= snprintf(pbuffer
+len
, LPFC_MBX_ACC_BUF_SIZE
-len
,
4426 "mbx_dump_map: 0x%08x\n", mbx_dump_map
);
4427 len
+= snprintf(pbuffer
+len
, LPFC_MBX_ACC_BUF_SIZE
-len
,
4428 "mbx_dump_cnt: %04d\n", mbx_dump_cnt
);
4429 len
+= snprintf(pbuffer
+len
, LPFC_MBX_ACC_BUF_SIZE
-len
,
4430 "mbx_word_cnt: %04d\n", mbx_word_cnt
);
4431 len
+= snprintf(pbuffer
+len
, LPFC_MBX_ACC_BUF_SIZE
-len
,
4432 "mbx_mbox_cmd: 0x%02x\n", mbx_mbox_cmd
);
4438 * lpfc_idiag_mbxacc_read - idiag debugfs read on mailbox access
4439 * @file: The file pointer to read from.
4440 * @buf: The buffer to copy the data to.
4441 * @nbytes: The number of bytes to read.
4442 * @ppos: The position in the file to start reading from.
4445 * This routine reads data from the @phba driver mailbox access debugfs setup
4449 * This function returns the amount of data that was read (this could be less
4450 * than @nbytes if the end of the file was reached) or a negative error value.
4453 lpfc_idiag_mbxacc_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
4456 struct lpfc_debug
*debug
= file
->private_data
;
4457 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
4461 /* This is a user read operation */
4462 debug
->op
= LPFC_IDIAG_OP_RD
;
4465 debug
->buffer
= kmalloc(LPFC_MBX_ACC_BUF_SIZE
, GFP_KERNEL
);
4468 pbuffer
= debug
->buffer
;
4473 if ((idiag
.cmd
.opcode
!= LPFC_IDIAG_CMD_MBXACC_DP
) &&
4474 (idiag
.cmd
.opcode
!= LPFC_IDIAG_BSG_MBXACC_DP
))
4477 len
= lpfc_idiag_mbxacc_get_setup(phba
, pbuffer
);
4479 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
4483 * lpfc_idiag_mbxacc_write - Syntax check and set up idiag mbxacc commands
4484 * @file: The file pointer to read from.
4485 * @buf: The buffer to copy the user data from.
4486 * @nbytes: The number of bytes to get.
4487 * @ppos: The position in the file to start reading from.
4489 * This routine get the debugfs idiag command struct from user space and then
4490 * perform the syntax check for driver mailbox command (dump) and sets up the
4491 * necessary states in the idiag command struct accordingly.
4493 * It returns the @nbytges passing in from debugfs user space when successful.
4494 * In case of error conditions, it returns proper error code back to the user
4498 lpfc_idiag_mbxacc_write(struct file
*file
, const char __user
*buf
,
4499 size_t nbytes
, loff_t
*ppos
)
4501 struct lpfc_debug
*debug
= file
->private_data
;
4502 uint32_t mbx_dump_map
, mbx_dump_cnt
, mbx_word_cnt
, mbx_mbox_cmd
;
4505 /* This is a user write operation */
4506 debug
->op
= LPFC_IDIAG_OP_WR
;
4508 rc
= lpfc_idiag_cmd_get(buf
, nbytes
, &idiag
.cmd
);
4512 /* Sanity check on command line arguments */
4513 mbx_mbox_cmd
= idiag
.cmd
.data
[IDIAG_MBXACC_MBCMD_INDX
];
4514 mbx_dump_map
= idiag
.cmd
.data
[IDIAG_MBXACC_DPMAP_INDX
];
4515 mbx_dump_cnt
= idiag
.cmd
.data
[IDIAG_MBXACC_DPCNT_INDX
];
4516 mbx_word_cnt
= idiag
.cmd
.data
[IDIAG_MBXACC_WDCNT_INDX
];
4518 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_MBXACC_DP
) {
4519 if (!(mbx_dump_map
& LPFC_MBX_DMP_MBX_ALL
))
4521 if ((mbx_dump_map
& ~LPFC_MBX_DMP_MBX_ALL
) &&
4522 (mbx_dump_map
!= LPFC_MBX_DMP_ALL
))
4524 if (mbx_word_cnt
> sizeof(MAILBOX_t
))
4526 } else if (idiag
.cmd
.opcode
== LPFC_IDIAG_BSG_MBXACC_DP
) {
4527 if (!(mbx_dump_map
& LPFC_BSG_DMP_MBX_ALL
))
4529 if ((mbx_dump_map
& ~LPFC_BSG_DMP_MBX_ALL
) &&
4530 (mbx_dump_map
!= LPFC_MBX_DMP_ALL
))
4532 if (mbx_word_cnt
> (BSG_MBOX_SIZE
)/4)
4534 if (mbx_mbox_cmd
!= 0x9b)
4539 if (mbx_word_cnt
== 0)
4541 if (rc
!= LPFC_MBX_DMP_ARG
)
4543 if (mbx_mbox_cmd
& ~0xff)
4546 /* condition for stop mailbox dump */
4547 if (mbx_dump_cnt
== 0)
4553 /* Clean out command structure on command error out */
4554 memset(&idiag
, 0, sizeof(idiag
));
4558 /* Clean out command structure on command error out */
4559 memset(&idiag
, 0, sizeof(idiag
));
4564 * lpfc_idiag_extacc_avail_get - get the available extents information
4565 * @phba: pointer to lpfc hba data structure.
4566 * @pbuffer: pointer to internal buffer.
4567 * @len: length into the internal buffer data has been copied.
4570 * This routine is to get the available extent information.
4573 * overall lenth of the data read into the internal buffer.
4576 lpfc_idiag_extacc_avail_get(struct lpfc_hba
*phba
, char *pbuffer
, int len
)
4578 uint16_t ext_cnt
, ext_size
;
4580 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4581 "\nAvailable Extents Information:\n");
4583 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4584 "\tPort Available VPI extents: ");
4585 lpfc_sli4_get_avail_extnt_rsrc(phba
, LPFC_RSC_TYPE_FCOE_VPI
,
4586 &ext_cnt
, &ext_size
);
4587 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4588 "Count %3d, Size %3d\n", ext_cnt
, ext_size
);
4590 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4591 "\tPort Available VFI extents: ");
4592 lpfc_sli4_get_avail_extnt_rsrc(phba
, LPFC_RSC_TYPE_FCOE_VFI
,
4593 &ext_cnt
, &ext_size
);
4594 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4595 "Count %3d, Size %3d\n", ext_cnt
, ext_size
);
4597 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4598 "\tPort Available RPI extents: ");
4599 lpfc_sli4_get_avail_extnt_rsrc(phba
, LPFC_RSC_TYPE_FCOE_RPI
,
4600 &ext_cnt
, &ext_size
);
4601 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4602 "Count %3d, Size %3d\n", ext_cnt
, ext_size
);
4604 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4605 "\tPort Available XRI extents: ");
4606 lpfc_sli4_get_avail_extnt_rsrc(phba
, LPFC_RSC_TYPE_FCOE_XRI
,
4607 &ext_cnt
, &ext_size
);
4608 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4609 "Count %3d, Size %3d\n", ext_cnt
, ext_size
);
4615 * lpfc_idiag_extacc_alloc_get - get the allocated extents information
4616 * @phba: pointer to lpfc hba data structure.
4617 * @pbuffer: pointer to internal buffer.
4618 * @len: length into the internal buffer data has been copied.
4621 * This routine is to get the allocated extent information.
4624 * overall lenth of the data read into the internal buffer.
4627 lpfc_idiag_extacc_alloc_get(struct lpfc_hba
*phba
, char *pbuffer
, int len
)
4629 uint16_t ext_cnt
, ext_size
;
4632 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4633 "\nAllocated Extents Information:\n");
4635 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4636 "\tHost Allocated VPI extents: ");
4637 rc
= lpfc_sli4_get_allocated_extnts(phba
, LPFC_RSC_TYPE_FCOE_VPI
,
4638 &ext_cnt
, &ext_size
);
4640 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4641 "Port %d Extent %3d, Size %3d\n",
4642 phba
->brd_no
, ext_cnt
, ext_size
);
4644 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4647 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4648 "\tHost Allocated VFI extents: ");
4649 rc
= lpfc_sli4_get_allocated_extnts(phba
, LPFC_RSC_TYPE_FCOE_VFI
,
4650 &ext_cnt
, &ext_size
);
4652 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4653 "Port %d Extent %3d, Size %3d\n",
4654 phba
->brd_no
, ext_cnt
, ext_size
);
4656 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4659 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4660 "\tHost Allocated RPI extents: ");
4661 rc
= lpfc_sli4_get_allocated_extnts(phba
, LPFC_RSC_TYPE_FCOE_RPI
,
4662 &ext_cnt
, &ext_size
);
4664 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4665 "Port %d Extent %3d, Size %3d\n",
4666 phba
->brd_no
, ext_cnt
, ext_size
);
4668 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4671 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4672 "\tHost Allocated XRI extents: ");
4673 rc
= lpfc_sli4_get_allocated_extnts(phba
, LPFC_RSC_TYPE_FCOE_XRI
,
4674 &ext_cnt
, &ext_size
);
4676 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4677 "Port %d Extent %3d, Size %3d\n",
4678 phba
->brd_no
, ext_cnt
, ext_size
);
4680 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4687 * lpfc_idiag_extacc_drivr_get - get driver extent information
4688 * @phba: pointer to lpfc hba data structure.
4689 * @pbuffer: pointer to internal buffer.
4690 * @len: length into the internal buffer data has been copied.
4693 * This routine is to get the driver extent information.
4696 * overall lenth of the data read into the internal buffer.
4699 lpfc_idiag_extacc_drivr_get(struct lpfc_hba
*phba
, char *pbuffer
, int len
)
4701 struct lpfc_rsrc_blks
*rsrc_blks
;
4704 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4705 "\nDriver Extents Information:\n");
4707 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4708 "\tVPI extents:\n");
4710 list_for_each_entry(rsrc_blks
, &phba
->lpfc_vpi_blk_list
, list
) {
4711 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4712 "\t\tBlock %3d: Start %4d, Count %4d\n",
4713 index
, rsrc_blks
->rsrc_start
,
4714 rsrc_blks
->rsrc_size
);
4717 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4718 "\tVFI extents:\n");
4720 list_for_each_entry(rsrc_blks
, &phba
->sli4_hba
.lpfc_vfi_blk_list
,
4722 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4723 "\t\tBlock %3d: Start %4d, Count %4d\n",
4724 index
, rsrc_blks
->rsrc_start
,
4725 rsrc_blks
->rsrc_size
);
4729 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4730 "\tRPI extents:\n");
4732 list_for_each_entry(rsrc_blks
, &phba
->sli4_hba
.lpfc_rpi_blk_list
,
4734 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4735 "\t\tBlock %3d: Start %4d, Count %4d\n",
4736 index
, rsrc_blks
->rsrc_start
,
4737 rsrc_blks
->rsrc_size
);
4741 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4742 "\tXRI extents:\n");
4744 list_for_each_entry(rsrc_blks
, &phba
->sli4_hba
.lpfc_xri_blk_list
,
4746 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4747 "\t\tBlock %3d: Start %4d, Count %4d\n",
4748 index
, rsrc_blks
->rsrc_start
,
4749 rsrc_blks
->rsrc_size
);
4757 * lpfc_idiag_extacc_write - Syntax check and set up idiag extacc commands
4758 * @file: The file pointer to read from.
4759 * @buf: The buffer to copy the user data from.
4760 * @nbytes: The number of bytes to get.
4761 * @ppos: The position in the file to start reading from.
4763 * This routine get the debugfs idiag command struct from user space and then
4764 * perform the syntax check for extent information access commands and sets
4765 * up the necessary states in the idiag command struct accordingly.
4767 * It returns the @nbytges passing in from debugfs user space when successful.
4768 * In case of error conditions, it returns proper error code back to the user
4772 lpfc_idiag_extacc_write(struct file
*file
, const char __user
*buf
,
4773 size_t nbytes
, loff_t
*ppos
)
4775 struct lpfc_debug
*debug
= file
->private_data
;
4779 /* This is a user write operation */
4780 debug
->op
= LPFC_IDIAG_OP_WR
;
4782 rc
= lpfc_idiag_cmd_get(buf
, nbytes
, &idiag
.cmd
);
4786 ext_map
= idiag
.cmd
.data
[IDIAG_EXTACC_EXMAP_INDX
];
4788 if (idiag
.cmd
.opcode
!= LPFC_IDIAG_CMD_EXTACC_RD
)
4790 if (rc
!= LPFC_EXT_ACC_CMD_ARG
)
4792 if (!(ext_map
& LPFC_EXT_ACC_ALL
))
4797 /* Clean out command structure on command error out */
4798 memset(&idiag
, 0, sizeof(idiag
));
4803 * lpfc_idiag_extacc_read - idiag debugfs read access to extent information
4804 * @file: The file pointer to read from.
4805 * @buf: The buffer to copy the data to.
4806 * @nbytes: The number of bytes to read.
4807 * @ppos: The position in the file to start reading from.
4810 * This routine reads data from the proper extent information according to
4811 * the idiag command, and copies to user @buf.
4814 * This function returns the amount of data that was read (this could be less
4815 * than @nbytes if the end of the file was reached) or a negative error value.
4818 lpfc_idiag_extacc_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
4821 struct lpfc_debug
*debug
= file
->private_data
;
4822 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
4827 /* This is a user read operation */
4828 debug
->op
= LPFC_IDIAG_OP_RD
;
4831 debug
->buffer
= kmalloc(LPFC_EXT_ACC_BUF_SIZE
, GFP_KERNEL
);
4834 pbuffer
= debug
->buffer
;
4837 if (idiag
.cmd
.opcode
!= LPFC_IDIAG_CMD_EXTACC_RD
)
4840 ext_map
= idiag
.cmd
.data
[IDIAG_EXTACC_EXMAP_INDX
];
4841 if (ext_map
& LPFC_EXT_ACC_AVAIL
)
4842 len
= lpfc_idiag_extacc_avail_get(phba
, pbuffer
, len
);
4843 if (ext_map
& LPFC_EXT_ACC_ALLOC
)
4844 len
= lpfc_idiag_extacc_alloc_get(phba
, pbuffer
, len
);
4845 if (ext_map
& LPFC_EXT_ACC_DRIVR
)
4846 len
= lpfc_idiag_extacc_drivr_get(phba
, pbuffer
, len
);
4848 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
4851 #undef lpfc_debugfs_op_disc_trc
4852 static const struct file_operations lpfc_debugfs_op_disc_trc
= {
4853 .owner
= THIS_MODULE
,
4854 .open
= lpfc_debugfs_disc_trc_open
,
4855 .llseek
= lpfc_debugfs_lseek
,
4856 .read
= lpfc_debugfs_read
,
4857 .release
= lpfc_debugfs_release
,
4860 #undef lpfc_debugfs_op_nodelist
4861 static const struct file_operations lpfc_debugfs_op_nodelist
= {
4862 .owner
= THIS_MODULE
,
4863 .open
= lpfc_debugfs_nodelist_open
,
4864 .llseek
= lpfc_debugfs_lseek
,
4865 .read
= lpfc_debugfs_read
,
4866 .release
= lpfc_debugfs_release
,
4869 #undef lpfc_debugfs_op_hbqinfo
4870 static const struct file_operations lpfc_debugfs_op_hbqinfo
= {
4871 .owner
= THIS_MODULE
,
4872 .open
= lpfc_debugfs_hbqinfo_open
,
4873 .llseek
= lpfc_debugfs_lseek
,
4874 .read
= lpfc_debugfs_read
,
4875 .release
= lpfc_debugfs_release
,
4878 #undef lpfc_debugfs_op_dumpHBASlim
4879 static const struct file_operations lpfc_debugfs_op_dumpHBASlim
= {
4880 .owner
= THIS_MODULE
,
4881 .open
= lpfc_debugfs_dumpHBASlim_open
,
4882 .llseek
= lpfc_debugfs_lseek
,
4883 .read
= lpfc_debugfs_read
,
4884 .release
= lpfc_debugfs_release
,
4887 #undef lpfc_debugfs_op_dumpHostSlim
4888 static const struct file_operations lpfc_debugfs_op_dumpHostSlim
= {
4889 .owner
= THIS_MODULE
,
4890 .open
= lpfc_debugfs_dumpHostSlim_open
,
4891 .llseek
= lpfc_debugfs_lseek
,
4892 .read
= lpfc_debugfs_read
,
4893 .release
= lpfc_debugfs_release
,
4896 #undef lpfc_debugfs_op_nvmestat
4897 static const struct file_operations lpfc_debugfs_op_nvmestat
= {
4898 .owner
= THIS_MODULE
,
4899 .open
= lpfc_debugfs_nvmestat_open
,
4900 .llseek
= lpfc_debugfs_lseek
,
4901 .read
= lpfc_debugfs_read
,
4902 .write
= lpfc_debugfs_nvmestat_write
,
4903 .release
= lpfc_debugfs_release
,
4906 #undef lpfc_debugfs_op_nvmektime
4907 static const struct file_operations lpfc_debugfs_op_nvmektime
= {
4908 .owner
= THIS_MODULE
,
4909 .open
= lpfc_debugfs_nvmektime_open
,
4910 .llseek
= lpfc_debugfs_lseek
,
4911 .read
= lpfc_debugfs_read
,
4912 .write
= lpfc_debugfs_nvmektime_write
,
4913 .release
= lpfc_debugfs_release
,
4916 #undef lpfc_debugfs_op_nvmeio_trc
4917 static const struct file_operations lpfc_debugfs_op_nvmeio_trc
= {
4918 .owner
= THIS_MODULE
,
4919 .open
= lpfc_debugfs_nvmeio_trc_open
,
4920 .llseek
= lpfc_debugfs_lseek
,
4921 .read
= lpfc_debugfs_read
,
4922 .write
= lpfc_debugfs_nvmeio_trc_write
,
4923 .release
= lpfc_debugfs_release
,
4926 #undef lpfc_debugfs_op_cpucheck
4927 static const struct file_operations lpfc_debugfs_op_cpucheck
= {
4928 .owner
= THIS_MODULE
,
4929 .open
= lpfc_debugfs_cpucheck_open
,
4930 .llseek
= lpfc_debugfs_lseek
,
4931 .read
= lpfc_debugfs_read
,
4932 .write
= lpfc_debugfs_cpucheck_write
,
4933 .release
= lpfc_debugfs_release
,
4936 #undef lpfc_debugfs_op_dumpData
4937 static const struct file_operations lpfc_debugfs_op_dumpData
= {
4938 .owner
= THIS_MODULE
,
4939 .open
= lpfc_debugfs_dumpData_open
,
4940 .llseek
= lpfc_debugfs_lseek
,
4941 .read
= lpfc_debugfs_read
,
4942 .write
= lpfc_debugfs_dumpDataDif_write
,
4943 .release
= lpfc_debugfs_dumpDataDif_release
,
4946 #undef lpfc_debugfs_op_dumpDif
4947 static const struct file_operations lpfc_debugfs_op_dumpDif
= {
4948 .owner
= THIS_MODULE
,
4949 .open
= lpfc_debugfs_dumpDif_open
,
4950 .llseek
= lpfc_debugfs_lseek
,
4951 .read
= lpfc_debugfs_read
,
4952 .write
= lpfc_debugfs_dumpDataDif_write
,
4953 .release
= lpfc_debugfs_dumpDataDif_release
,
4956 #undef lpfc_debugfs_op_dif_err
4957 static const struct file_operations lpfc_debugfs_op_dif_err
= {
4958 .owner
= THIS_MODULE
,
4959 .open
= simple_open
,
4960 .llseek
= lpfc_debugfs_lseek
,
4961 .read
= lpfc_debugfs_dif_err_read
,
4962 .write
= lpfc_debugfs_dif_err_write
,
4963 .release
= lpfc_debugfs_dif_err_release
,
4966 #undef lpfc_debugfs_op_slow_ring_trc
4967 static const struct file_operations lpfc_debugfs_op_slow_ring_trc
= {
4968 .owner
= THIS_MODULE
,
4969 .open
= lpfc_debugfs_slow_ring_trc_open
,
4970 .llseek
= lpfc_debugfs_lseek
,
4971 .read
= lpfc_debugfs_read
,
4972 .release
= lpfc_debugfs_release
,
4975 static struct dentry
*lpfc_debugfs_root
= NULL
;
4976 static atomic_t lpfc_debugfs_hba_count
;
4979 * File operations for the iDiag debugfs
4981 #undef lpfc_idiag_op_pciCfg
4982 static const struct file_operations lpfc_idiag_op_pciCfg
= {
4983 .owner
= THIS_MODULE
,
4984 .open
= lpfc_idiag_open
,
4985 .llseek
= lpfc_debugfs_lseek
,
4986 .read
= lpfc_idiag_pcicfg_read
,
4987 .write
= lpfc_idiag_pcicfg_write
,
4988 .release
= lpfc_idiag_cmd_release
,
4991 #undef lpfc_idiag_op_barAcc
4992 static const struct file_operations lpfc_idiag_op_barAcc
= {
4993 .owner
= THIS_MODULE
,
4994 .open
= lpfc_idiag_open
,
4995 .llseek
= lpfc_debugfs_lseek
,
4996 .read
= lpfc_idiag_baracc_read
,
4997 .write
= lpfc_idiag_baracc_write
,
4998 .release
= lpfc_idiag_cmd_release
,
5001 #undef lpfc_idiag_op_queInfo
5002 static const struct file_operations lpfc_idiag_op_queInfo
= {
5003 .owner
= THIS_MODULE
,
5004 .open
= lpfc_idiag_open
,
5005 .read
= lpfc_idiag_queinfo_read
,
5006 .release
= lpfc_idiag_release
,
5009 #undef lpfc_idiag_op_queAcc
5010 static const struct file_operations lpfc_idiag_op_queAcc
= {
5011 .owner
= THIS_MODULE
,
5012 .open
= lpfc_idiag_open
,
5013 .llseek
= lpfc_debugfs_lseek
,
5014 .read
= lpfc_idiag_queacc_read
,
5015 .write
= lpfc_idiag_queacc_write
,
5016 .release
= lpfc_idiag_cmd_release
,
5019 #undef lpfc_idiag_op_drbAcc
5020 static const struct file_operations lpfc_idiag_op_drbAcc
= {
5021 .owner
= THIS_MODULE
,
5022 .open
= lpfc_idiag_open
,
5023 .llseek
= lpfc_debugfs_lseek
,
5024 .read
= lpfc_idiag_drbacc_read
,
5025 .write
= lpfc_idiag_drbacc_write
,
5026 .release
= lpfc_idiag_cmd_release
,
5029 #undef lpfc_idiag_op_ctlAcc
5030 static const struct file_operations lpfc_idiag_op_ctlAcc
= {
5031 .owner
= THIS_MODULE
,
5032 .open
= lpfc_idiag_open
,
5033 .llseek
= lpfc_debugfs_lseek
,
5034 .read
= lpfc_idiag_ctlacc_read
,
5035 .write
= lpfc_idiag_ctlacc_write
,
5036 .release
= lpfc_idiag_cmd_release
,
5039 #undef lpfc_idiag_op_mbxAcc
5040 static const struct file_operations lpfc_idiag_op_mbxAcc
= {
5041 .owner
= THIS_MODULE
,
5042 .open
= lpfc_idiag_open
,
5043 .llseek
= lpfc_debugfs_lseek
,
5044 .read
= lpfc_idiag_mbxacc_read
,
5045 .write
= lpfc_idiag_mbxacc_write
,
5046 .release
= lpfc_idiag_cmd_release
,
5049 #undef lpfc_idiag_op_extAcc
5050 static const struct file_operations lpfc_idiag_op_extAcc
= {
5051 .owner
= THIS_MODULE
,
5052 .open
= lpfc_idiag_open
,
5053 .llseek
= lpfc_debugfs_lseek
,
5054 .read
= lpfc_idiag_extacc_read
,
5055 .write
= lpfc_idiag_extacc_write
,
5056 .release
= lpfc_idiag_cmd_release
,
5061 /* lpfc_idiag_mbxacc_dump_bsg_mbox - idiag debugfs dump bsg mailbox command
5062 * @phba: Pointer to HBA context object.
5063 * @dmabuf: Pointer to a DMA buffer descriptor.
5066 * This routine dump a bsg pass-through non-embedded mailbox command with
5070 lpfc_idiag_mbxacc_dump_bsg_mbox(struct lpfc_hba
*phba
, enum nemb_type nemb_tp
,
5071 enum mbox_type mbox_tp
, enum dma_type dma_tp
,
5072 enum sta_type sta_tp
,
5073 struct lpfc_dmabuf
*dmabuf
, uint32_t ext_buf
)
5075 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
5076 uint32_t *mbx_mbox_cmd
, *mbx_dump_map
, *mbx_dump_cnt
, *mbx_word_cnt
;
5077 char line_buf
[LPFC_MBX_ACC_LBUF_SZ
];
5079 uint32_t do_dump
= 0;
5083 if (idiag
.cmd
.opcode
!= LPFC_IDIAG_BSG_MBXACC_DP
)
5086 mbx_mbox_cmd
= &idiag
.cmd
.data
[IDIAG_MBXACC_MBCMD_INDX
];
5087 mbx_dump_map
= &idiag
.cmd
.data
[IDIAG_MBXACC_DPMAP_INDX
];
5088 mbx_dump_cnt
= &idiag
.cmd
.data
[IDIAG_MBXACC_DPCNT_INDX
];
5089 mbx_word_cnt
= &idiag
.cmd
.data
[IDIAG_MBXACC_WDCNT_INDX
];
5091 if (!(*mbx_dump_map
& LPFC_MBX_DMP_ALL
) ||
5092 (*mbx_dump_cnt
== 0) ||
5093 (*mbx_word_cnt
== 0))
5096 if (*mbx_mbox_cmd
!= 0x9B)
5099 if ((mbox_tp
== mbox_rd
) && (dma_tp
== dma_mbox
)) {
5100 if (*mbx_dump_map
& LPFC_BSG_DMP_MBX_RD_MBX
) {
5101 do_dump
|= LPFC_BSG_DMP_MBX_RD_MBX
;
5102 pr_err("\nRead mbox command (x%x), "
5103 "nemb:0x%x, extbuf_cnt:%d:\n",
5104 sta_tp
, nemb_tp
, ext_buf
);
5107 if ((mbox_tp
== mbox_rd
) && (dma_tp
== dma_ebuf
)) {
5108 if (*mbx_dump_map
& LPFC_BSG_DMP_MBX_RD_BUF
) {
5109 do_dump
|= LPFC_BSG_DMP_MBX_RD_BUF
;
5110 pr_err("\nRead mbox buffer (x%x), "
5111 "nemb:0x%x, extbuf_seq:%d:\n",
5112 sta_tp
, nemb_tp
, ext_buf
);
5115 if ((mbox_tp
== mbox_wr
) && (dma_tp
== dma_mbox
)) {
5116 if (*mbx_dump_map
& LPFC_BSG_DMP_MBX_WR_MBX
) {
5117 do_dump
|= LPFC_BSG_DMP_MBX_WR_MBX
;
5118 pr_err("\nWrite mbox command (x%x), "
5119 "nemb:0x%x, extbuf_cnt:%d:\n",
5120 sta_tp
, nemb_tp
, ext_buf
);
5123 if ((mbox_tp
== mbox_wr
) && (dma_tp
== dma_ebuf
)) {
5124 if (*mbx_dump_map
& LPFC_BSG_DMP_MBX_WR_BUF
) {
5125 do_dump
|= LPFC_BSG_DMP_MBX_WR_BUF
;
5126 pr_err("\nWrite mbox buffer (x%x), "
5127 "nemb:0x%x, extbuf_seq:%d:\n",
5128 sta_tp
, nemb_tp
, ext_buf
);
5132 /* dump buffer content */
5134 pword
= (uint32_t *)dmabuf
->virt
;
5135 for (i
= 0; i
< *mbx_word_cnt
; i
++) {
5138 pr_err("%s\n", line_buf
);
5140 len
+= snprintf(line_buf
+len
,
5141 LPFC_MBX_ACC_LBUF_SZ
-len
,
5144 len
+= snprintf(line_buf
+len
, LPFC_MBX_ACC_LBUF_SZ
-len
,
5145 "%08x ", (uint32_t)*pword
);
5149 pr_err("%s\n", line_buf
);
5153 /* Clean out command structure on reaching dump count */
5154 if (*mbx_dump_cnt
== 0)
5155 memset(&idiag
, 0, sizeof(idiag
));
5160 /* lpfc_idiag_mbxacc_dump_issue_mbox - idiag debugfs dump issue mailbox command
5161 * @phba: Pointer to HBA context object.
5162 * @dmabuf: Pointer to a DMA buffer descriptor.
5165 * This routine dump a pass-through non-embedded mailbox command from issue
5169 lpfc_idiag_mbxacc_dump_issue_mbox(struct lpfc_hba
*phba
, MAILBOX_t
*pmbox
)
5171 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
5172 uint32_t *mbx_dump_map
, *mbx_dump_cnt
, *mbx_word_cnt
, *mbx_mbox_cmd
;
5173 char line_buf
[LPFC_MBX_ACC_LBUF_SZ
];
5179 if (idiag
.cmd
.opcode
!= LPFC_IDIAG_CMD_MBXACC_DP
)
5182 mbx_mbox_cmd
= &idiag
.cmd
.data
[IDIAG_MBXACC_MBCMD_INDX
];
5183 mbx_dump_map
= &idiag
.cmd
.data
[IDIAG_MBXACC_DPMAP_INDX
];
5184 mbx_dump_cnt
= &idiag
.cmd
.data
[IDIAG_MBXACC_DPCNT_INDX
];
5185 mbx_word_cnt
= &idiag
.cmd
.data
[IDIAG_MBXACC_WDCNT_INDX
];
5187 if (!(*mbx_dump_map
& LPFC_MBX_DMP_MBX_ALL
) ||
5188 (*mbx_dump_cnt
== 0) ||
5189 (*mbx_word_cnt
== 0))
5192 if ((*mbx_mbox_cmd
!= LPFC_MBX_ALL_CMD
) &&
5193 (*mbx_mbox_cmd
!= pmbox
->mbxCommand
))
5196 /* dump buffer content */
5197 if (*mbx_dump_map
& LPFC_MBX_DMP_MBX_WORD
) {
5198 pr_err("Mailbox command:0x%x dump by word:\n",
5200 pword
= (uint32_t *)pmbox
;
5201 for (i
= 0; i
< *mbx_word_cnt
; i
++) {
5204 pr_err("%s\n", line_buf
);
5206 memset(line_buf
, 0, LPFC_MBX_ACC_LBUF_SZ
);
5207 len
+= snprintf(line_buf
+len
,
5208 LPFC_MBX_ACC_LBUF_SZ
-len
,
5211 len
+= snprintf(line_buf
+len
, LPFC_MBX_ACC_LBUF_SZ
-len
,
5213 ((uint32_t)*pword
) & 0xffffffff);
5217 pr_err("%s\n", line_buf
);
5220 if (*mbx_dump_map
& LPFC_MBX_DMP_MBX_BYTE
) {
5221 pr_err("Mailbox command:0x%x dump by byte:\n",
5223 pbyte
= (uint8_t *)pmbox
;
5224 for (i
= 0; i
< *mbx_word_cnt
; i
++) {
5227 pr_err("%s\n", line_buf
);
5229 memset(line_buf
, 0, LPFC_MBX_ACC_LBUF_SZ
);
5230 len
+= snprintf(line_buf
+len
,
5231 LPFC_MBX_ACC_LBUF_SZ
-len
,
5234 for (j
= 0; j
< 4; j
++) {
5235 len
+= snprintf(line_buf
+len
,
5236 LPFC_MBX_ACC_LBUF_SZ
-len
,
5238 ((uint8_t)*pbyte
) & 0xff);
5241 len
+= snprintf(line_buf
+len
,
5242 LPFC_MBX_ACC_LBUF_SZ
-len
, " ");
5245 pr_err("%s\n", line_buf
);
5250 /* Clean out command structure on reaching dump count */
5251 if (*mbx_dump_cnt
== 0)
5252 memset(&idiag
, 0, sizeof(idiag
));
5258 * lpfc_debugfs_initialize - Initialize debugfs for a vport
5259 * @vport: The vport pointer to initialize.
5262 * When Debugfs is configured this routine sets up the lpfc debugfs file system.
5263 * If not already created, this routine will create the lpfc directory, and
5264 * lpfcX directory (for this HBA), and vportX directory for this vport. It will
5265 * also create each file used to access lpfc specific debugfs information.
5268 lpfc_debugfs_initialize(struct lpfc_vport
*vport
)
5270 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
5271 struct lpfc_hba
*phba
= vport
->phba
;
5274 bool pport_setup
= false;
5276 if (!lpfc_debugfs_enable
)
5279 /* Setup lpfc root directory */
5280 if (!lpfc_debugfs_root
) {
5281 lpfc_debugfs_root
= debugfs_create_dir("lpfc", NULL
);
5282 atomic_set(&lpfc_debugfs_hba_count
, 0);
5283 if (!lpfc_debugfs_root
) {
5284 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5285 "0408 Cannot create debugfs root\n");
5289 if (!lpfc_debugfs_start_time
)
5290 lpfc_debugfs_start_time
= jiffies
;
5292 /* Setup funcX directory for specific HBA PCI function */
5293 snprintf(name
, sizeof(name
), "fn%d", phba
->brd_no
);
5294 if (!phba
->hba_debugfs_root
) {
5296 phba
->hba_debugfs_root
=
5297 debugfs_create_dir(name
, lpfc_debugfs_root
);
5298 if (!phba
->hba_debugfs_root
) {
5299 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5300 "0412 Cannot create debugfs hba\n");
5303 atomic_inc(&lpfc_debugfs_hba_count
);
5304 atomic_set(&phba
->debugfs_vport_count
, 0);
5307 snprintf(name
, sizeof(name
), "hbqinfo");
5308 phba
->debug_hbqinfo
=
5309 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5310 phba
->hba_debugfs_root
,
5311 phba
, &lpfc_debugfs_op_hbqinfo
);
5312 if (!phba
->debug_hbqinfo
) {
5313 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5314 "0411 Cannot create debugfs hbqinfo\n");
5318 /* Setup dumpHBASlim */
5319 if (phba
->sli_rev
< LPFC_SLI_REV4
) {
5320 snprintf(name
, sizeof(name
), "dumpHBASlim");
5321 phba
->debug_dumpHBASlim
=
5322 debugfs_create_file(name
,
5323 S_IFREG
|S_IRUGO
|S_IWUSR
,
5324 phba
->hba_debugfs_root
,
5325 phba
, &lpfc_debugfs_op_dumpHBASlim
);
5326 if (!phba
->debug_dumpHBASlim
) {
5327 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5328 "0413 Cannot create debugfs "
5333 phba
->debug_dumpHBASlim
= NULL
;
5335 /* Setup dumpHostSlim */
5336 if (phba
->sli_rev
< LPFC_SLI_REV4
) {
5337 snprintf(name
, sizeof(name
), "dumpHostSlim");
5338 phba
->debug_dumpHostSlim
=
5339 debugfs_create_file(name
,
5340 S_IFREG
|S_IRUGO
|S_IWUSR
,
5341 phba
->hba_debugfs_root
,
5342 phba
, &lpfc_debugfs_op_dumpHostSlim
);
5343 if (!phba
->debug_dumpHostSlim
) {
5344 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5345 "0414 Cannot create debugfs "
5350 phba
->debug_dumpHostSlim
= NULL
;
5352 /* Setup dumpData */
5353 snprintf(name
, sizeof(name
), "dumpData");
5354 phba
->debug_dumpData
=
5355 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5356 phba
->hba_debugfs_root
,
5357 phba
, &lpfc_debugfs_op_dumpData
);
5358 if (!phba
->debug_dumpData
) {
5359 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5360 "0800 Cannot create debugfs dumpData\n");
5365 snprintf(name
, sizeof(name
), "dumpDif");
5366 phba
->debug_dumpDif
=
5367 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5368 phba
->hba_debugfs_root
,
5369 phba
, &lpfc_debugfs_op_dumpDif
);
5370 if (!phba
->debug_dumpDif
) {
5371 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5372 "0801 Cannot create debugfs dumpDif\n");
5376 /* Setup DIF Error Injections */
5377 snprintf(name
, sizeof(name
), "InjErrLBA");
5378 phba
->debug_InjErrLBA
=
5379 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5380 phba
->hba_debugfs_root
,
5381 phba
, &lpfc_debugfs_op_dif_err
);
5382 if (!phba
->debug_InjErrLBA
) {
5383 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5384 "0807 Cannot create debugfs InjErrLBA\n");
5387 phba
->lpfc_injerr_lba
= LPFC_INJERR_LBA_OFF
;
5389 snprintf(name
, sizeof(name
), "InjErrNPortID");
5390 phba
->debug_InjErrNPortID
=
5391 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5392 phba
->hba_debugfs_root
,
5393 phba
, &lpfc_debugfs_op_dif_err
);
5394 if (!phba
->debug_InjErrNPortID
) {
5395 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5396 "0809 Cannot create debugfs InjErrNPortID\n");
5400 snprintf(name
, sizeof(name
), "InjErrWWPN");
5401 phba
->debug_InjErrWWPN
=
5402 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5403 phba
->hba_debugfs_root
,
5404 phba
, &lpfc_debugfs_op_dif_err
);
5405 if (!phba
->debug_InjErrWWPN
) {
5406 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5407 "0810 Cannot create debugfs InjErrWWPN\n");
5411 snprintf(name
, sizeof(name
), "writeGuardInjErr");
5412 phba
->debug_writeGuard
=
5413 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5414 phba
->hba_debugfs_root
,
5415 phba
, &lpfc_debugfs_op_dif_err
);
5416 if (!phba
->debug_writeGuard
) {
5417 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5418 "0802 Cannot create debugfs writeGuard\n");
5422 snprintf(name
, sizeof(name
), "writeAppInjErr");
5423 phba
->debug_writeApp
=
5424 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5425 phba
->hba_debugfs_root
,
5426 phba
, &lpfc_debugfs_op_dif_err
);
5427 if (!phba
->debug_writeApp
) {
5428 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5429 "0803 Cannot create debugfs writeApp\n");
5433 snprintf(name
, sizeof(name
), "writeRefInjErr");
5434 phba
->debug_writeRef
=
5435 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5436 phba
->hba_debugfs_root
,
5437 phba
, &lpfc_debugfs_op_dif_err
);
5438 if (!phba
->debug_writeRef
) {
5439 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5440 "0804 Cannot create debugfs writeRef\n");
5444 snprintf(name
, sizeof(name
), "readGuardInjErr");
5445 phba
->debug_readGuard
=
5446 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5447 phba
->hba_debugfs_root
,
5448 phba
, &lpfc_debugfs_op_dif_err
);
5449 if (!phba
->debug_readGuard
) {
5450 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5451 "0808 Cannot create debugfs readGuard\n");
5455 snprintf(name
, sizeof(name
), "readAppInjErr");
5456 phba
->debug_readApp
=
5457 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5458 phba
->hba_debugfs_root
,
5459 phba
, &lpfc_debugfs_op_dif_err
);
5460 if (!phba
->debug_readApp
) {
5461 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5462 "0805 Cannot create debugfs readApp\n");
5466 snprintf(name
, sizeof(name
), "readRefInjErr");
5467 phba
->debug_readRef
=
5468 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5469 phba
->hba_debugfs_root
,
5470 phba
, &lpfc_debugfs_op_dif_err
);
5471 if (!phba
->debug_readRef
) {
5472 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5473 "0806 Cannot create debugfs readApp\n");
5477 /* Setup slow ring trace */
5478 if (lpfc_debugfs_max_slow_ring_trc
) {
5479 num
= lpfc_debugfs_max_slow_ring_trc
- 1;
5480 if (num
& lpfc_debugfs_max_slow_ring_trc
) {
5481 /* Change to be a power of 2 */
5482 num
= lpfc_debugfs_max_slow_ring_trc
;
5488 lpfc_debugfs_max_slow_ring_trc
= (1 << i
);
5489 pr_err("lpfc_debugfs_max_disc_trc changed to "
5490 "%d\n", lpfc_debugfs_max_disc_trc
);
5494 snprintf(name
, sizeof(name
), "slow_ring_trace");
5495 phba
->debug_slow_ring_trc
=
5496 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5497 phba
->hba_debugfs_root
,
5498 phba
, &lpfc_debugfs_op_slow_ring_trc
);
5499 if (!phba
->debug_slow_ring_trc
) {
5500 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5501 "0415 Cannot create debugfs "
5502 "slow_ring_trace\n");
5505 if (!phba
->slow_ring_trc
) {
5506 phba
->slow_ring_trc
= kmalloc(
5507 (sizeof(struct lpfc_debugfs_trc
) *
5508 lpfc_debugfs_max_slow_ring_trc
),
5510 if (!phba
->slow_ring_trc
) {
5511 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5512 "0416 Cannot create debugfs "
5513 "slow_ring buffer\n");
5516 atomic_set(&phba
->slow_ring_trc_cnt
, 0);
5517 memset(phba
->slow_ring_trc
, 0,
5518 (sizeof(struct lpfc_debugfs_trc
) *
5519 lpfc_debugfs_max_slow_ring_trc
));
5522 snprintf(name
, sizeof(name
), "nvmeio_trc");
5523 phba
->debug_nvmeio_trc
=
5524 debugfs_create_file(name
, 0644,
5525 phba
->hba_debugfs_root
,
5526 phba
, &lpfc_debugfs_op_nvmeio_trc
);
5527 if (!phba
->debug_nvmeio_trc
) {
5528 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5529 "0574 No create debugfs nvmeio_trc\n");
5533 atomic_set(&phba
->nvmeio_trc_cnt
, 0);
5534 if (lpfc_debugfs_max_nvmeio_trc
) {
5535 num
= lpfc_debugfs_max_nvmeio_trc
- 1;
5536 if (num
& lpfc_debugfs_max_disc_trc
) {
5537 /* Change to be a power of 2 */
5538 num
= lpfc_debugfs_max_nvmeio_trc
;
5544 lpfc_debugfs_max_nvmeio_trc
= (1 << i
);
5545 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
5546 "0575 lpfc_debugfs_max_nvmeio_trc "
5548 lpfc_debugfs_max_nvmeio_trc
);
5550 phba
->nvmeio_trc_size
= lpfc_debugfs_max_nvmeio_trc
;
5552 /* Allocate trace buffer and initialize */
5553 phba
->nvmeio_trc
= kzalloc(
5554 (sizeof(struct lpfc_debugfs_nvmeio_trc
) *
5555 phba
->nvmeio_trc_size
), GFP_KERNEL
);
5557 if (!phba
->nvmeio_trc
) {
5558 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
5559 "0576 Cannot create debugfs "
5560 "nvmeio_trc buffer\n");
5563 phba
->nvmeio_trc_on
= 1;
5564 phba
->nvmeio_trc_output_idx
= 0;
5565 phba
->nvmeio_trc
= NULL
;
5568 phba
->nvmeio_trc_size
= 0;
5569 phba
->nvmeio_trc_on
= 0;
5570 phba
->nvmeio_trc_output_idx
= 0;
5571 phba
->nvmeio_trc
= NULL
;
5575 snprintf(name
, sizeof(name
), "vport%d", vport
->vpi
);
5576 if (!vport
->vport_debugfs_root
) {
5577 vport
->vport_debugfs_root
=
5578 debugfs_create_dir(name
, phba
->hba_debugfs_root
);
5579 if (!vport
->vport_debugfs_root
) {
5580 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5581 "0417 Can't create debugfs\n");
5584 atomic_inc(&phba
->debugfs_vport_count
);
5587 if (lpfc_debugfs_max_disc_trc
) {
5588 num
= lpfc_debugfs_max_disc_trc
- 1;
5589 if (num
& lpfc_debugfs_max_disc_trc
) {
5590 /* Change to be a power of 2 */
5591 num
= lpfc_debugfs_max_disc_trc
;
5597 lpfc_debugfs_max_disc_trc
= (1 << i
);
5598 pr_err("lpfc_debugfs_max_disc_trc changed to %d\n",
5599 lpfc_debugfs_max_disc_trc
);
5603 vport
->disc_trc
= kzalloc(
5604 (sizeof(struct lpfc_debugfs_trc
) * lpfc_debugfs_max_disc_trc
),
5607 if (!vport
->disc_trc
) {
5608 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5609 "0418 Cannot create debugfs disc trace "
5613 atomic_set(&vport
->disc_trc_cnt
, 0);
5615 snprintf(name
, sizeof(name
), "discovery_trace");
5616 vport
->debug_disc_trc
=
5617 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5618 vport
->vport_debugfs_root
,
5619 vport
, &lpfc_debugfs_op_disc_trc
);
5620 if (!vport
->debug_disc_trc
) {
5621 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5622 "0419 Cannot create debugfs "
5623 "discovery_trace\n");
5626 snprintf(name
, sizeof(name
), "nodelist");
5627 vport
->debug_nodelist
=
5628 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5629 vport
->vport_debugfs_root
,
5630 vport
, &lpfc_debugfs_op_nodelist
);
5631 if (!vport
->debug_nodelist
) {
5632 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5633 "2985 Can't create debugfs nodelist\n");
5637 snprintf(name
, sizeof(name
), "nvmestat");
5638 vport
->debug_nvmestat
=
5639 debugfs_create_file(name
, 0644,
5640 vport
->vport_debugfs_root
,
5641 vport
, &lpfc_debugfs_op_nvmestat
);
5642 if (!vport
->debug_nvmestat
) {
5643 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5644 "0811 Cannot create debugfs nvmestat\n");
5648 snprintf(name
, sizeof(name
), "nvmektime");
5649 vport
->debug_nvmektime
=
5650 debugfs_create_file(name
, 0644,
5651 vport
->vport_debugfs_root
,
5652 vport
, &lpfc_debugfs_op_nvmektime
);
5653 if (!vport
->debug_nvmektime
) {
5654 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5655 "0815 Cannot create debugfs nvmektime\n");
5659 snprintf(name
, sizeof(name
), "cpucheck");
5660 vport
->debug_cpucheck
=
5661 debugfs_create_file(name
, 0644,
5662 vport
->vport_debugfs_root
,
5663 vport
, &lpfc_debugfs_op_cpucheck
);
5664 if (!vport
->debug_cpucheck
) {
5665 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5666 "0819 Cannot create debugfs cpucheck\n");
5671 * The following section is for additional directories/files for the
5679 * iDiag debugfs root entry points for SLI4 device only
5681 if (phba
->sli_rev
< LPFC_SLI_REV4
)
5684 snprintf(name
, sizeof(name
), "iDiag");
5685 if (!phba
->idiag_root
) {
5687 debugfs_create_dir(name
, phba
->hba_debugfs_root
);
5688 if (!phba
->idiag_root
) {
5689 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5690 "2922 Can't create idiag debugfs\n");
5693 /* Initialize iDiag data structure */
5694 memset(&idiag
, 0, sizeof(idiag
));
5697 /* iDiag read PCI config space */
5698 snprintf(name
, sizeof(name
), "pciCfg");
5699 if (!phba
->idiag_pci_cfg
) {
5700 phba
->idiag_pci_cfg
=
5701 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5702 phba
->idiag_root
, phba
, &lpfc_idiag_op_pciCfg
);
5703 if (!phba
->idiag_pci_cfg
) {
5704 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5705 "2923 Can't create idiag debugfs\n");
5708 idiag
.offset
.last_rd
= 0;
5711 /* iDiag PCI BAR access */
5712 snprintf(name
, sizeof(name
), "barAcc");
5713 if (!phba
->idiag_bar_acc
) {
5714 phba
->idiag_bar_acc
=
5715 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5716 phba
->idiag_root
, phba
, &lpfc_idiag_op_barAcc
);
5717 if (!phba
->idiag_bar_acc
) {
5718 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5719 "3056 Can't create idiag debugfs\n");
5722 idiag
.offset
.last_rd
= 0;
5725 /* iDiag get PCI function queue information */
5726 snprintf(name
, sizeof(name
), "queInfo");
5727 if (!phba
->idiag_que_info
) {
5728 phba
->idiag_que_info
=
5729 debugfs_create_file(name
, S_IFREG
|S_IRUGO
,
5730 phba
->idiag_root
, phba
, &lpfc_idiag_op_queInfo
);
5731 if (!phba
->idiag_que_info
) {
5732 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5733 "2924 Can't create idiag debugfs\n");
5738 /* iDiag access PCI function queue */
5739 snprintf(name
, sizeof(name
), "queAcc");
5740 if (!phba
->idiag_que_acc
) {
5741 phba
->idiag_que_acc
=
5742 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5743 phba
->idiag_root
, phba
, &lpfc_idiag_op_queAcc
);
5744 if (!phba
->idiag_que_acc
) {
5745 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5746 "2926 Can't create idiag debugfs\n");
5751 /* iDiag access PCI function doorbell registers */
5752 snprintf(name
, sizeof(name
), "drbAcc");
5753 if (!phba
->idiag_drb_acc
) {
5754 phba
->idiag_drb_acc
=
5755 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5756 phba
->idiag_root
, phba
, &lpfc_idiag_op_drbAcc
);
5757 if (!phba
->idiag_drb_acc
) {
5758 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5759 "2927 Can't create idiag debugfs\n");
5764 /* iDiag access PCI function control registers */
5765 snprintf(name
, sizeof(name
), "ctlAcc");
5766 if (!phba
->idiag_ctl_acc
) {
5767 phba
->idiag_ctl_acc
=
5768 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5769 phba
->idiag_root
, phba
, &lpfc_idiag_op_ctlAcc
);
5770 if (!phba
->idiag_ctl_acc
) {
5771 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5772 "2981 Can't create idiag debugfs\n");
5777 /* iDiag access mbox commands */
5778 snprintf(name
, sizeof(name
), "mbxAcc");
5779 if (!phba
->idiag_mbx_acc
) {
5780 phba
->idiag_mbx_acc
=
5781 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5782 phba
->idiag_root
, phba
, &lpfc_idiag_op_mbxAcc
);
5783 if (!phba
->idiag_mbx_acc
) {
5784 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5785 "2980 Can't create idiag debugfs\n");
5790 /* iDiag extents access commands */
5791 if (phba
->sli4_hba
.extents_in_use
) {
5792 snprintf(name
, sizeof(name
), "extAcc");
5793 if (!phba
->idiag_ext_acc
) {
5794 phba
->idiag_ext_acc
=
5795 debugfs_create_file(name
,
5796 S_IFREG
|S_IRUGO
|S_IWUSR
,
5797 phba
->idiag_root
, phba
,
5798 &lpfc_idiag_op_extAcc
);
5799 if (!phba
->idiag_ext_acc
) {
5800 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5814 * lpfc_debugfs_terminate - Tear down debugfs infrastructure for this vport
5815 * @vport: The vport pointer to remove from debugfs.
5818 * When Debugfs is configured this routine removes debugfs file system elements
5819 * that are specific to this vport. It also checks to see if there are any
5820 * users left for the debugfs directories associated with the HBA and driver. If
5821 * this is the last user of the HBA directory or driver directory then it will
5822 * remove those from the debugfs infrastructure as well.
5825 lpfc_debugfs_terminate(struct lpfc_vport
*vport
)
5827 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
5828 struct lpfc_hba
*phba
= vport
->phba
;
5830 kfree(vport
->disc_trc
);
5831 vport
->disc_trc
= NULL
;
5833 debugfs_remove(vport
->debug_disc_trc
); /* discovery_trace */
5834 vport
->debug_disc_trc
= NULL
;
5836 debugfs_remove(vport
->debug_nodelist
); /* nodelist */
5837 vport
->debug_nodelist
= NULL
;
5839 debugfs_remove(vport
->debug_nvmestat
); /* nvmestat */
5840 vport
->debug_nvmestat
= NULL
;
5842 debugfs_remove(vport
->debug_nvmektime
); /* nvmektime */
5843 vport
->debug_nvmektime
= NULL
;
5845 debugfs_remove(vport
->debug_cpucheck
); /* cpucheck */
5846 vport
->debug_cpucheck
= NULL
;
5848 if (vport
->vport_debugfs_root
) {
5849 debugfs_remove(vport
->vport_debugfs_root
); /* vportX */
5850 vport
->vport_debugfs_root
= NULL
;
5851 atomic_dec(&phba
->debugfs_vport_count
);
5854 if (atomic_read(&phba
->debugfs_vport_count
) == 0) {
5856 debugfs_remove(phba
->debug_hbqinfo
); /* hbqinfo */
5857 phba
->debug_hbqinfo
= NULL
;
5859 debugfs_remove(phba
->debug_dumpHBASlim
); /* HBASlim */
5860 phba
->debug_dumpHBASlim
= NULL
;
5862 debugfs_remove(phba
->debug_dumpHostSlim
); /* HostSlim */
5863 phba
->debug_dumpHostSlim
= NULL
;
5865 debugfs_remove(phba
->debug_dumpData
); /* dumpData */
5866 phba
->debug_dumpData
= NULL
;
5868 debugfs_remove(phba
->debug_dumpDif
); /* dumpDif */
5869 phba
->debug_dumpDif
= NULL
;
5871 debugfs_remove(phba
->debug_InjErrLBA
); /* InjErrLBA */
5872 phba
->debug_InjErrLBA
= NULL
;
5874 debugfs_remove(phba
->debug_InjErrNPortID
);
5875 phba
->debug_InjErrNPortID
= NULL
;
5877 debugfs_remove(phba
->debug_InjErrWWPN
); /* InjErrWWPN */
5878 phba
->debug_InjErrWWPN
= NULL
;
5880 debugfs_remove(phba
->debug_writeGuard
); /* writeGuard */
5881 phba
->debug_writeGuard
= NULL
;
5883 debugfs_remove(phba
->debug_writeApp
); /* writeApp */
5884 phba
->debug_writeApp
= NULL
;
5886 debugfs_remove(phba
->debug_writeRef
); /* writeRef */
5887 phba
->debug_writeRef
= NULL
;
5889 debugfs_remove(phba
->debug_readGuard
); /* readGuard */
5890 phba
->debug_readGuard
= NULL
;
5892 debugfs_remove(phba
->debug_readApp
); /* readApp */
5893 phba
->debug_readApp
= NULL
;
5895 debugfs_remove(phba
->debug_readRef
); /* readRef */
5896 phba
->debug_readRef
= NULL
;
5898 kfree(phba
->slow_ring_trc
);
5899 phba
->slow_ring_trc
= NULL
;
5901 /* slow_ring_trace */
5902 debugfs_remove(phba
->debug_slow_ring_trc
);
5903 phba
->debug_slow_ring_trc
= NULL
;
5905 debugfs_remove(phba
->debug_nvmeio_trc
);
5906 phba
->debug_nvmeio_trc
= NULL
;
5908 kfree(phba
->nvmeio_trc
);
5909 phba
->nvmeio_trc
= NULL
;
5914 if (phba
->sli_rev
== LPFC_SLI_REV4
) {
5916 debugfs_remove(phba
->idiag_ext_acc
);
5917 phba
->idiag_ext_acc
= NULL
;
5920 debugfs_remove(phba
->idiag_mbx_acc
);
5921 phba
->idiag_mbx_acc
= NULL
;
5924 debugfs_remove(phba
->idiag_ctl_acc
);
5925 phba
->idiag_ctl_acc
= NULL
;
5928 debugfs_remove(phba
->idiag_drb_acc
);
5929 phba
->idiag_drb_acc
= NULL
;
5932 debugfs_remove(phba
->idiag_que_acc
);
5933 phba
->idiag_que_acc
= NULL
;
5936 debugfs_remove(phba
->idiag_que_info
);
5937 phba
->idiag_que_info
= NULL
;
5940 debugfs_remove(phba
->idiag_bar_acc
);
5941 phba
->idiag_bar_acc
= NULL
;
5944 debugfs_remove(phba
->idiag_pci_cfg
);
5945 phba
->idiag_pci_cfg
= NULL
;
5947 /* Finally remove the iDiag debugfs root */
5948 debugfs_remove(phba
->idiag_root
);
5949 phba
->idiag_root
= NULL
;
5952 if (phba
->hba_debugfs_root
) {
5953 debugfs_remove(phba
->hba_debugfs_root
); /* fnX */
5954 phba
->hba_debugfs_root
= NULL
;
5955 atomic_dec(&lpfc_debugfs_hba_count
);
5958 if (atomic_read(&lpfc_debugfs_hba_count
) == 0) {
5959 debugfs_remove(lpfc_debugfs_root
); /* lpfc */
5960 lpfc_debugfs_root
= NULL
;
5968 * Driver debug utility routines outside of debugfs. The debug utility
5969 * routines implemented here is intended to be used in the instrumented
5970 * debug driver for debugging host or port issues.
5974 * lpfc_debug_dump_all_queues - dump all the queues with a hba
5975 * @phba: Pointer to HBA context object.
5977 * This function dumps entries of all the queues asociated with the @phba.
5980 lpfc_debug_dump_all_queues(struct lpfc_hba
*phba
)
5985 * Dump Work Queues (WQs)
5987 lpfc_debug_dump_wq(phba
, DUMP_MBX
, 0);
5988 lpfc_debug_dump_wq(phba
, DUMP_ELS
, 0);
5989 lpfc_debug_dump_wq(phba
, DUMP_NVMELS
, 0);
5991 for (idx
= 0; idx
< phba
->cfg_fcp_io_channel
; idx
++)
5992 lpfc_debug_dump_wq(phba
, DUMP_FCP
, idx
);
5994 for (idx
= 0; idx
< phba
->cfg_nvme_io_channel
; idx
++)
5995 lpfc_debug_dump_wq(phba
, DUMP_NVME
, idx
);
5997 lpfc_debug_dump_hdr_rq(phba
);
5998 lpfc_debug_dump_dat_rq(phba
);
6000 * Dump Complete Queues (CQs)
6002 lpfc_debug_dump_cq(phba
, DUMP_MBX
, 0);
6003 lpfc_debug_dump_cq(phba
, DUMP_ELS
, 0);
6004 lpfc_debug_dump_cq(phba
, DUMP_NVMELS
, 0);
6006 for (idx
= 0; idx
< phba
->cfg_fcp_io_channel
; idx
++)
6007 lpfc_debug_dump_cq(phba
, DUMP_FCP
, idx
);
6009 for (idx
= 0; idx
< phba
->cfg_nvme_io_channel
; idx
++)
6010 lpfc_debug_dump_cq(phba
, DUMP_NVME
, idx
);
6013 * Dump Event Queues (EQs)
6015 for (idx
= 0; idx
< phba
->io_channel_irqs
; idx
++)
6016 lpfc_debug_dump_hba_eq(phba
, idx
);