1 /*******************************************************************
2 * This file is part of the Emulex Linux Device Driver for *
3 * Fibre Channel Host Bus Adapters. *
4 * Copyright (C) 2017 Broadcom. All Rights Reserved. The term *
5 * “Broadcom” refers to Broadcom Limited 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 "entrys:%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
)
548 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
549 struct lpfc_hba
*phba
= vport
->phba
;
550 struct lpfc_nodelist
*ndlp
;
551 unsigned char *statep
;
552 struct nvme_fc_local_port
*localport
;
553 struct lpfc_nvme_lport
*lport
;
554 struct lpfc_nvme_rport
*rport
;
555 struct lpfc_nvmet_tgtport
*tgtp
;
556 struct nvme_fc_remote_port
*nrport
;
558 cnt
= (LPFC_NODELIST_SIZE
/ LPFC_NODELIST_ENTRY_SIZE
);
560 len
+= snprintf(buf
+len
, size
-len
, "\nFCP Nodelist Entries ...\n");
561 spin_lock_irq(shost
->host_lock
);
562 list_for_each_entry(ndlp
, &vport
->fc_nodes
, nlp_listp
) {
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
:
591 case NLP_STE_MAPPED_NODE
:
594 case NLP_STE_NPR_NODE
:
600 len
+= snprintf(buf
+len
, size
-len
, "%s DID:x%06x ",
601 statep
, ndlp
->nlp_DID
);
602 len
+= snprintf(buf
+len
, size
-len
,
604 wwn_to_u64(ndlp
->nlp_portname
.u
.wwn
));
605 len
+= snprintf(buf
+len
, size
-len
,
607 wwn_to_u64(ndlp
->nlp_nodename
.u
.wwn
));
608 if (ndlp
->nlp_flag
& NLP_RPI_REGISTERED
)
609 len
+= snprintf(buf
+len
, size
-len
, "RPI:%03d ",
612 len
+= snprintf(buf
+len
, size
-len
, "RPI:none ");
613 len
+= snprintf(buf
+len
, size
-len
, "flag:x%08x ",
616 len
+= snprintf(buf
+len
, size
-len
, "UNKNOWN_TYPE ");
617 if (ndlp
->nlp_type
& NLP_FC_NODE
)
618 len
+= snprintf(buf
+len
, size
-len
, "FC_NODE ");
619 if (ndlp
->nlp_type
& NLP_FABRIC
)
620 len
+= snprintf(buf
+len
, size
-len
, "FABRIC ");
621 if (ndlp
->nlp_type
& NLP_FCP_TARGET
)
622 len
+= snprintf(buf
+len
, size
-len
, "FCP_TGT sid:%d ",
624 if (ndlp
->nlp_type
& NLP_FCP_INITIATOR
)
625 len
+= snprintf(buf
+len
, size
-len
, "FCP_INITIATOR ");
626 len
+= snprintf(buf
+len
, size
-len
, "usgmap:%x ",
628 len
+= snprintf(buf
+len
, size
-len
, "refcnt:%x",
629 kref_read(&ndlp
->kref
));
630 len
+= snprintf(buf
+len
, size
-len
, "\n");
632 spin_unlock_irq(shost
->host_lock
);
634 if (phba
->nvmet_support
&& phba
->targetport
&& (vport
== phba
->pport
)) {
635 tgtp
= (struct lpfc_nvmet_tgtport
*)phba
->targetport
->private;
636 len
+= snprintf(buf
+ len
, size
- len
,
637 "\nNVME Targetport Entry ...\n");
639 /* Port state is only one of two values for now. */
640 if (phba
->targetport
->port_id
)
641 statep
= "REGISTERED";
644 len
+= snprintf(buf
+ len
, size
- len
,
645 "TGT WWNN x%llx WWPN x%llx State %s\n",
646 wwn_to_u64(vport
->fc_nodename
.u
.wwn
),
647 wwn_to_u64(vport
->fc_portname
.u
.wwn
),
649 len
+= snprintf(buf
+ len
, size
- len
,
650 " Targetport DID x%06x\n",
651 phba
->targetport
->port_id
);
655 len
+= snprintf(buf
+ len
, size
- len
,
656 "\nNVME Lport/Rport Entries ...\n");
658 localport
= vport
->localport
;
662 spin_lock_irq(shost
->host_lock
);
663 lport
= (struct lpfc_nvme_lport
*)localport
->private;
665 /* Port state is only one of two values for now. */
666 if (localport
->port_id
)
671 len
+= snprintf(buf
+ len
, size
- len
,
672 "Lport DID x%06x PortState %s\n",
673 localport
->port_id
, statep
);
675 len
+= snprintf(buf
+ len
, size
- len
, "\tRport List:\n");
676 list_for_each_entry(rport
, &lport
->rport_list
, list
) {
677 /* local short-hand pointer. */
678 nrport
= rport
->remoteport
;
680 /* Port state is only one of two values for now. */
681 switch (nrport
->port_state
) {
682 case FC_OBJSTATE_ONLINE
:
685 case FC_OBJSTATE_UNKNOWN
:
689 statep
= "UNSUPPORTED";
693 /* Tab in to show lport ownership. */
694 len
+= snprintf(buf
+ len
, size
- len
,
695 "\t%s Port ID:x%06x ",
696 statep
, nrport
->port_id
);
697 len
+= snprintf(buf
+ len
, size
- len
, "WWPN x%llx ",
699 len
+= snprintf(buf
+ len
, size
- len
, "WWNN x%llx ",
701 switch (nrport
->port_role
) {
702 case FC_PORT_ROLE_NVME_INITIATOR
:
703 len
+= snprintf(buf
+ len
, size
- len
,
706 case FC_PORT_ROLE_NVME_TARGET
:
707 len
+= snprintf(buf
+ len
, size
- len
,
710 case FC_PORT_ROLE_NVME_DISCOVERY
:
711 len
+= snprintf(buf
+ len
, size
- len
,
715 len
+= snprintf(buf
+ len
, size
- len
,
721 /* Terminate the string. */
722 len
+= snprintf(buf
+ len
, size
- len
, "\n");
725 spin_unlock_irq(shost
->host_lock
);
731 * lpfc_debugfs_nvmestat_data - Dump target node list to a buffer
732 * @vport: The vport to gather target node info from.
733 * @buf: The buffer to dump log into.
734 * @size: The maximum amount of data to process.
737 * This routine dumps the NVME statistics associated with @vport
740 * This routine returns the amount of bytes that were dumped into @buf and will
744 lpfc_debugfs_nvmestat_data(struct lpfc_vport
*vport
, char *buf
, int size
)
746 struct lpfc_hba
*phba
= vport
->phba
;
747 struct lpfc_nvmet_tgtport
*tgtp
;
750 if (phba
->nvmet_support
) {
751 if (!phba
->targetport
)
753 tgtp
= (struct lpfc_nvmet_tgtport
*)phba
->targetport
->private;
754 len
+= snprintf(buf
+len
, size
-len
,
755 "\nNVME Targetport Statistics\n");
757 len
+= snprintf(buf
+len
, size
-len
,
758 "LS: Rcv %08x Drop %08x Abort %08x\n",
759 atomic_read(&tgtp
->rcv_ls_req_in
),
760 atomic_read(&tgtp
->rcv_ls_req_drop
),
761 atomic_read(&tgtp
->xmt_ls_abort
));
762 if (atomic_read(&tgtp
->rcv_ls_req_in
) !=
763 atomic_read(&tgtp
->rcv_ls_req_out
)) {
764 len
+= snprintf(buf
+len
, size
-len
,
765 "Rcv LS: in %08x != out %08x\n",
766 atomic_read(&tgtp
->rcv_ls_req_in
),
767 atomic_read(&tgtp
->rcv_ls_req_out
));
770 len
+= snprintf(buf
+len
, size
-len
,
771 "LS: Xmt %08x Drop %08x Cmpl %08x Err %08x\n",
772 atomic_read(&tgtp
->xmt_ls_rsp
),
773 atomic_read(&tgtp
->xmt_ls_drop
),
774 atomic_read(&tgtp
->xmt_ls_rsp_cmpl
),
775 atomic_read(&tgtp
->xmt_ls_rsp_error
));
777 len
+= snprintf(buf
+len
, size
-len
,
778 "FCP: Rcv %08x Drop %08x\n",
779 atomic_read(&tgtp
->rcv_fcp_cmd_in
),
780 atomic_read(&tgtp
->rcv_fcp_cmd_drop
));
782 if (atomic_read(&tgtp
->rcv_fcp_cmd_in
) !=
783 atomic_read(&tgtp
->rcv_fcp_cmd_out
)) {
784 len
+= snprintf(buf
+len
, size
-len
,
785 "Rcv FCP: in %08x != out %08x\n",
786 atomic_read(&tgtp
->rcv_fcp_cmd_in
),
787 atomic_read(&tgtp
->rcv_fcp_cmd_out
));
790 len
+= snprintf(buf
+len
, size
-len
,
791 "FCP Rsp: read %08x readrsp %08x write %08x rsp %08x\n",
792 atomic_read(&tgtp
->xmt_fcp_read
),
793 atomic_read(&tgtp
->xmt_fcp_read_rsp
),
794 atomic_read(&tgtp
->xmt_fcp_write
),
795 atomic_read(&tgtp
->xmt_fcp_rsp
));
797 len
+= snprintf(buf
+len
, size
-len
,
798 "FCP Rsp: abort %08x drop %08x\n",
799 atomic_read(&tgtp
->xmt_fcp_abort
),
800 atomic_read(&tgtp
->xmt_fcp_drop
));
802 len
+= snprintf(buf
+len
, size
-len
,
803 "FCP Rsp Cmpl: %08x err %08x drop %08x\n",
804 atomic_read(&tgtp
->xmt_fcp_rsp_cmpl
),
805 atomic_read(&tgtp
->xmt_fcp_rsp_error
),
806 atomic_read(&tgtp
->xmt_fcp_rsp_drop
));
808 len
+= snprintf(buf
+len
, size
-len
,
809 "ABORT: Xmt %08x Err %08x Cmpl %08x",
810 atomic_read(&tgtp
->xmt_abort_rsp
),
811 atomic_read(&tgtp
->xmt_abort_rsp_error
),
812 atomic_read(&tgtp
->xmt_abort_cmpl
));
814 len
+= snprintf(buf
+len
, size
-len
, "\n");
816 if (!(phba
->cfg_enable_fc4_type
& LPFC_ENABLE_NVME
))
819 len
+= snprintf(buf
+ len
, size
- len
,
820 "\nNVME Lport Statistics\n");
822 len
+= snprintf(buf
+ len
, size
- len
,
823 "LS: Xmt %016llx Cmpl %016llx\n",
824 phba
->fc4NvmeLsRequests
,
825 phba
->fc4NvmeLsCmpls
);
827 len
+= snprintf(buf
+ len
, size
- len
,
828 "FCP: Rd %016llx Wr %016llx IO %016llx\n",
829 phba
->fc4NvmeInputRequests
,
830 phba
->fc4NvmeOutputRequests
,
831 phba
->fc4NvmeControlRequests
);
833 len
+= snprintf(buf
+ len
, size
- len
,
834 " Cmpl %016llx\n", phba
->fc4NvmeIoCmpls
);
842 * lpfc_debugfs_nvmektime_data - Dump target node list to a buffer
843 * @vport: The vport to gather target node info from.
844 * @buf: The buffer to dump log into.
845 * @size: The maximum amount of data to process.
848 * This routine dumps the NVME statistics associated with @vport
851 * This routine returns the amount of bytes that were dumped into @buf and will
855 lpfc_debugfs_nvmektime_data(struct lpfc_vport
*vport
, char *buf
, int size
)
857 struct lpfc_hba
*phba
= vport
->phba
;
860 if (phba
->nvmet_support
== 0) {
862 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
863 "ktime %s: Total Samples: %lld\n",
864 (phba
->ktime_on
? "Enabled" : "Disabled"),
865 phba
->ktime_data_samples
);
866 if (phba
->ktime_data_samples
== 0)
870 buf
+ len
, PAGE_SIZE
- len
,
871 "Segment 1: Last NVME Cmd cmpl "
872 "done -to- Start of next NVME cnd (in driver)\n");
874 buf
+ len
, PAGE_SIZE
- len
,
875 "avg:%08lld min:%08lld max %08lld\n",
876 div_u64(phba
->ktime_seg1_total
,
877 phba
->ktime_data_samples
),
878 phba
->ktime_seg1_min
,
879 phba
->ktime_seg1_max
);
881 buf
+ len
, PAGE_SIZE
- len
,
882 "Segment 2: Driver start of NVME cmd "
883 "-to- Firmware WQ doorbell\n");
885 buf
+ len
, PAGE_SIZE
- len
,
886 "avg:%08lld min:%08lld max %08lld\n",
887 div_u64(phba
->ktime_seg2_total
,
888 phba
->ktime_data_samples
),
889 phba
->ktime_seg2_min
,
890 phba
->ktime_seg2_max
);
892 buf
+ len
, PAGE_SIZE
- len
,
893 "Segment 3: Firmware WQ doorbell -to- "
896 buf
+ len
, PAGE_SIZE
- len
,
897 "avg:%08lld min:%08lld max %08lld\n",
898 div_u64(phba
->ktime_seg3_total
,
899 phba
->ktime_data_samples
),
900 phba
->ktime_seg3_min
,
901 phba
->ktime_seg3_max
);
903 buf
+ len
, PAGE_SIZE
- len
,
904 "Segment 4: MSI-X ISR cmpl -to- "
907 buf
+ len
, PAGE_SIZE
- len
,
908 "avg:%08lld min:%08lld max %08lld\n",
909 div_u64(phba
->ktime_seg4_total
,
910 phba
->ktime_data_samples
),
911 phba
->ktime_seg4_min
,
912 phba
->ktime_seg4_max
);
914 buf
+ len
, PAGE_SIZE
- len
,
915 "Total IO avg time: %08lld\n",
916 div_u64(phba
->ktime_seg1_total
+
917 phba
->ktime_seg2_total
+
918 phba
->ktime_seg3_total
+
919 phba
->ktime_seg4_total
,
920 phba
->ktime_data_samples
));
925 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
926 "ktime %s: Total Samples: %lld %lld\n",
927 (phba
->ktime_on
? "Enabled" : "Disabled"),
928 phba
->ktime_data_samples
,
929 phba
->ktime_status_samples
);
930 if (phba
->ktime_data_samples
== 0)
933 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
934 "Segment 1: MSI-X ISR Rcv cmd -to- "
935 "cmd pass to NVME Layer\n");
936 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
937 "avg:%08lld min:%08lld max %08lld\n",
938 div_u64(phba
->ktime_seg1_total
,
939 phba
->ktime_data_samples
),
940 phba
->ktime_seg1_min
,
941 phba
->ktime_seg1_max
);
942 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
943 "Segment 2: cmd pass to NVME Layer- "
944 "-to- Driver rcv cmd OP (action)\n");
945 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
946 "avg:%08lld min:%08lld max %08lld\n",
947 div_u64(phba
->ktime_seg2_total
,
948 phba
->ktime_data_samples
),
949 phba
->ktime_seg2_min
,
950 phba
->ktime_seg2_max
);
951 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
952 "Segment 3: Driver rcv cmd OP -to- "
953 "Firmware WQ doorbell: cmd\n");
954 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
955 "avg:%08lld min:%08lld max %08lld\n",
956 div_u64(phba
->ktime_seg3_total
,
957 phba
->ktime_data_samples
),
958 phba
->ktime_seg3_min
,
959 phba
->ktime_seg3_max
);
960 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
961 "Segment 4: Firmware WQ doorbell: cmd "
962 "-to- MSI-X ISR for cmd cmpl\n");
963 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
964 "avg:%08lld min:%08lld max %08lld\n",
965 div_u64(phba
->ktime_seg4_total
,
966 phba
->ktime_data_samples
),
967 phba
->ktime_seg4_min
,
968 phba
->ktime_seg4_max
);
969 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
970 "Segment 5: MSI-X ISR for cmd cmpl "
971 "-to- NVME layer passed cmd done\n");
972 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
973 "avg:%08lld min:%08lld max %08lld\n",
974 div_u64(phba
->ktime_seg5_total
,
975 phba
->ktime_data_samples
),
976 phba
->ktime_seg5_min
,
977 phba
->ktime_seg5_max
);
979 if (phba
->ktime_status_samples
== 0) {
980 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
981 "Total: cmd received by MSI-X ISR "
982 "-to- cmd completed on wire\n");
983 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
984 "avg:%08lld min:%08lld "
986 div_u64(phba
->ktime_seg10_total
,
987 phba
->ktime_data_samples
),
988 phba
->ktime_seg10_min
,
989 phba
->ktime_seg10_max
);
993 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
994 "Segment 6: NVME layer passed cmd done "
995 "-to- Driver rcv rsp status OP\n");
996 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
997 "avg:%08lld min:%08lld max %08lld\n",
998 div_u64(phba
->ktime_seg6_total
,
999 phba
->ktime_status_samples
),
1000 phba
->ktime_seg6_min
,
1001 phba
->ktime_seg6_max
);
1002 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
1003 "Segment 7: Driver rcv rsp status OP "
1004 "-to- Firmware WQ doorbell: status\n");
1005 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
1006 "avg:%08lld min:%08lld max %08lld\n",
1007 div_u64(phba
->ktime_seg7_total
,
1008 phba
->ktime_status_samples
),
1009 phba
->ktime_seg7_min
,
1010 phba
->ktime_seg7_max
);
1011 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
1012 "Segment 8: Firmware WQ doorbell: status"
1013 " -to- MSI-X ISR for status cmpl\n");
1014 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
1015 "avg:%08lld min:%08lld max %08lld\n",
1016 div_u64(phba
->ktime_seg8_total
,
1017 phba
->ktime_status_samples
),
1018 phba
->ktime_seg8_min
,
1019 phba
->ktime_seg8_max
);
1020 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
1021 "Segment 9: MSI-X ISR for status cmpl "
1022 "-to- NVME layer passed status done\n");
1023 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
1024 "avg:%08lld min:%08lld max %08lld\n",
1025 div_u64(phba
->ktime_seg9_total
,
1026 phba
->ktime_status_samples
),
1027 phba
->ktime_seg9_min
,
1028 phba
->ktime_seg9_max
);
1029 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
1030 "Total: cmd received by MSI-X ISR -to- "
1031 "cmd completed on wire\n");
1032 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
1033 "avg:%08lld min:%08lld max %08lld\n",
1034 div_u64(phba
->ktime_seg10_total
,
1035 phba
->ktime_status_samples
),
1036 phba
->ktime_seg10_min
,
1037 phba
->ktime_seg10_max
);
1042 * lpfc_debugfs_nvmeio_trc_data - Dump NVME IO trace list to a buffer
1043 * @phba: The phba to gather target node info from.
1044 * @buf: The buffer to dump log into.
1045 * @size: The maximum amount of data to process.
1048 * This routine dumps the NVME IO trace associated with @phba
1051 * This routine returns the amount of bytes that were dumped into @buf and will
1055 lpfc_debugfs_nvmeio_trc_data(struct lpfc_hba
*phba
, char *buf
, int size
)
1057 struct lpfc_debugfs_nvmeio_trc
*dtp
;
1058 int i
, state
, index
, skip
;
1061 state
= phba
->nvmeio_trc_on
;
1063 index
= (atomic_read(&phba
->nvmeio_trc_cnt
) + 1) &
1064 (phba
->nvmeio_trc_size
- 1);
1065 skip
= phba
->nvmeio_trc_output_idx
;
1067 len
+= snprintf(buf
+ len
, size
- len
,
1068 "%s IO Trace %s: next_idx %d skip %d size %d\n",
1069 (phba
->nvmet_support
? "NVME" : "NVMET"),
1070 (state
? "Enabled" : "Disabled"),
1071 index
, skip
, phba
->nvmeio_trc_size
);
1073 if (!phba
->nvmeio_trc
|| state
)
1076 /* trace MUST bhe off to continue */
1078 for (i
= index
; i
< phba
->nvmeio_trc_size
; i
++) {
1083 dtp
= phba
->nvmeio_trc
+ i
;
1084 phba
->nvmeio_trc_output_idx
++;
1089 len
+= snprintf(buf
+ len
, size
- len
, dtp
->fmt
,
1090 dtp
->data1
, dtp
->data2
, dtp
->data3
);
1092 if (phba
->nvmeio_trc_output_idx
>= phba
->nvmeio_trc_size
) {
1093 phba
->nvmeio_trc_output_idx
= 0;
1094 len
+= snprintf(buf
+ len
, size
- len
,
1095 "Trace Complete\n");
1099 if (len
>= (size
- LPFC_DEBUG_OUT_LINE_SZ
)) {
1100 len
+= snprintf(buf
+ len
, size
- len
,
1101 "Trace Continue (%d of %d)\n",
1102 phba
->nvmeio_trc_output_idx
,
1103 phba
->nvmeio_trc_size
);
1107 for (i
= 0; i
< index
; i
++) {
1112 dtp
= phba
->nvmeio_trc
+ i
;
1113 phba
->nvmeio_trc_output_idx
++;
1118 len
+= snprintf(buf
+ len
, size
- len
, dtp
->fmt
,
1119 dtp
->data1
, dtp
->data2
, dtp
->data3
);
1121 if (phba
->nvmeio_trc_output_idx
>= phba
->nvmeio_trc_size
) {
1122 phba
->nvmeio_trc_output_idx
= 0;
1123 len
+= snprintf(buf
+ len
, size
- len
,
1124 "Trace Complete\n");
1128 if (len
>= (size
- LPFC_DEBUG_OUT_LINE_SZ
)) {
1129 len
+= snprintf(buf
+ len
, size
- len
,
1130 "Trace Continue (%d of %d)\n",
1131 phba
->nvmeio_trc_output_idx
,
1132 phba
->nvmeio_trc_size
);
1137 len
+= snprintf(buf
+ len
, size
- len
,
1144 * lpfc_debugfs_cpucheck_data - Dump target node list to a buffer
1145 * @vport: The vport to gather target node info from.
1146 * @buf: The buffer to dump log into.
1147 * @size: The maximum amount of data to process.
1150 * This routine dumps the NVME statistics associated with @vport
1153 * This routine returns the amount of bytes that were dumped into @buf and will
1157 lpfc_debugfs_cpucheck_data(struct lpfc_vport
*vport
, char *buf
, int size
)
1159 struct lpfc_hba
*phba
= vport
->phba
;
1162 uint32_t tot_xmt
= 0;
1163 uint32_t tot_rcv
= 0;
1164 uint32_t tot_cmpl
= 0;
1165 uint32_t tot_ccmpl
= 0;
1167 if (phba
->nvmet_support
== 0) {
1168 /* NVME Initiator */
1169 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
1171 (phba
->cpucheck_on
& LPFC_CHECK_NVME_IO
?
1172 "Enabled" : "Disabled"));
1173 for (i
= 0; i
< phba
->sli4_hba
.num_present_cpu
; i
++) {
1174 if (i
>= LPFC_CHECK_CPU_CNT
)
1176 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
1177 "%02d: xmit x%08x cmpl x%08x\n",
1178 i
, phba
->cpucheck_xmt_io
[i
],
1179 phba
->cpucheck_cmpl_io
[i
]);
1180 tot_xmt
+= phba
->cpucheck_xmt_io
[i
];
1181 tot_cmpl
+= phba
->cpucheck_cmpl_io
[i
];
1183 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
1184 "tot:xmit x%08x cmpl x%08x\n",
1190 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
1192 (phba
->cpucheck_on
& LPFC_CHECK_NVMET_IO
?
1193 "IO Enabled - " : "IO Disabled - "));
1194 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
1196 (phba
->cpucheck_on
& LPFC_CHECK_NVMET_RCV
?
1197 "Rcv Enabled\n" : "Rcv Disabled\n"));
1198 for (i
= 0; i
< phba
->sli4_hba
.num_present_cpu
; i
++) {
1199 if (i
>= LPFC_CHECK_CPU_CNT
)
1201 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
1202 "%02d: xmit x%08x ccmpl x%08x "
1203 "cmpl x%08x rcv x%08x\n",
1204 i
, phba
->cpucheck_xmt_io
[i
],
1205 phba
->cpucheck_ccmpl_io
[i
],
1206 phba
->cpucheck_cmpl_io
[i
],
1207 phba
->cpucheck_rcv_io
[i
]);
1208 tot_xmt
+= phba
->cpucheck_xmt_io
[i
];
1209 tot_rcv
+= phba
->cpucheck_rcv_io
[i
];
1210 tot_cmpl
+= phba
->cpucheck_cmpl_io
[i
];
1211 tot_ccmpl
+= phba
->cpucheck_ccmpl_io
[i
];
1213 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
1214 "tot:xmit x%08x ccmpl x%08x cmpl x%08x rcv x%08x\n",
1215 tot_xmt
, tot_ccmpl
, tot_cmpl
, tot_rcv
);
1222 * lpfc_debugfs_disc_trc - Store discovery trace log
1223 * @vport: The vport to associate this trace string with for retrieval.
1224 * @mask: Log entry classification.
1225 * @fmt: Format string to be displayed when dumping the log.
1226 * @data1: 1st data parameter to be applied to @fmt.
1227 * @data2: 2nd data parameter to be applied to @fmt.
1228 * @data3: 3rd data parameter to be applied to @fmt.
1231 * This routine is used by the driver code to add a debugfs log entry to the
1232 * discovery trace buffer associated with @vport. Only entries with a @mask that
1233 * match the current debugfs discovery mask will be saved. Entries that do not
1234 * match will be thrown away. @fmt, @data1, @data2, and @data3 are used like
1235 * printf when displaying the log.
1238 lpfc_debugfs_disc_trc(struct lpfc_vport
*vport
, int mask
, char *fmt
,
1239 uint32_t data1
, uint32_t data2
, uint32_t data3
)
1241 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
1242 struct lpfc_debugfs_trc
*dtp
;
1245 if (!(lpfc_debugfs_mask_disc_trc
& mask
))
1248 if (!lpfc_debugfs_enable
|| !lpfc_debugfs_max_disc_trc
||
1249 !vport
|| !vport
->disc_trc
)
1252 index
= atomic_inc_return(&vport
->disc_trc_cnt
) &
1253 (lpfc_debugfs_max_disc_trc
- 1);
1254 dtp
= vport
->disc_trc
+ index
;
1259 dtp
->seq_cnt
= atomic_inc_return(&lpfc_debugfs_seq_trc_cnt
);
1266 * lpfc_debugfs_slow_ring_trc - Store slow ring trace log
1267 * @phba: The phba to associate this trace string with for retrieval.
1268 * @fmt: Format string to be displayed when dumping the log.
1269 * @data1: 1st data parameter to be applied to @fmt.
1270 * @data2: 2nd data parameter to be applied to @fmt.
1271 * @data3: 3rd data parameter to be applied to @fmt.
1274 * This routine is used by the driver code to add a debugfs log entry to the
1275 * discovery trace buffer associated with @vport. @fmt, @data1, @data2, and
1276 * @data3 are used like printf when displaying the log.
1279 lpfc_debugfs_slow_ring_trc(struct lpfc_hba
*phba
, char *fmt
,
1280 uint32_t data1
, uint32_t data2
, uint32_t data3
)
1282 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
1283 struct lpfc_debugfs_trc
*dtp
;
1286 if (!lpfc_debugfs_enable
|| !lpfc_debugfs_max_slow_ring_trc
||
1287 !phba
|| !phba
->slow_ring_trc
)
1290 index
= atomic_inc_return(&phba
->slow_ring_trc_cnt
) &
1291 (lpfc_debugfs_max_slow_ring_trc
- 1);
1292 dtp
= phba
->slow_ring_trc
+ index
;
1297 dtp
->seq_cnt
= atomic_inc_return(&lpfc_debugfs_seq_trc_cnt
);
1304 * lpfc_debugfs_nvme_trc - Store NVME/NVMET trace log
1305 * @phba: The phba to associate this trace string with for retrieval.
1306 * @fmt: Format string to be displayed when dumping the log.
1307 * @data1: 1st data parameter to be applied to @fmt.
1308 * @data2: 2nd data parameter to be applied to @fmt.
1309 * @data3: 3rd data parameter to be applied to @fmt.
1312 * This routine is used by the driver code to add a debugfs log entry to the
1313 * nvme trace buffer associated with @phba. @fmt, @data1, @data2, and
1314 * @data3 are used like printf when displaying the log.
1317 lpfc_debugfs_nvme_trc(struct lpfc_hba
*phba
, char *fmt
,
1318 uint16_t data1
, uint16_t data2
, uint32_t data3
)
1320 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
1321 struct lpfc_debugfs_nvmeio_trc
*dtp
;
1324 if (!phba
->nvmeio_trc_on
|| !phba
->nvmeio_trc
)
1327 index
= atomic_inc_return(&phba
->nvmeio_trc_cnt
) &
1328 (phba
->nvmeio_trc_size
- 1);
1329 dtp
= phba
->nvmeio_trc
+ index
;
1337 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
1339 * lpfc_debugfs_disc_trc_open - Open the discovery trace log
1340 * @inode: The inode pointer that contains a vport pointer.
1341 * @file: The file pointer to attach the log output.
1344 * This routine is the entry point for the debugfs open file operation. It gets
1345 * the vport from the i_private field in @inode, allocates the necessary buffer
1346 * for the log, fills the buffer from the in-memory log for this vport, and then
1347 * returns a pointer to that log in the private_data field in @file.
1350 * This function returns zero if successful. On error it will return a negative
1354 lpfc_debugfs_disc_trc_open(struct inode
*inode
, struct file
*file
)
1356 struct lpfc_vport
*vport
= inode
->i_private
;
1357 struct lpfc_debug
*debug
;
1361 if (!lpfc_debugfs_max_disc_trc
) {
1366 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
1370 /* Round to page boundary */
1371 size
= (lpfc_debugfs_max_disc_trc
* LPFC_DEBUG_TRC_ENTRY_SIZE
);
1372 size
= PAGE_ALIGN(size
);
1374 debug
->buffer
= kmalloc(size
, GFP_KERNEL
);
1375 if (!debug
->buffer
) {
1380 debug
->len
= lpfc_debugfs_disc_trc_data(vport
, debug
->buffer
, size
);
1381 file
->private_data
= debug
;
1389 * lpfc_debugfs_slow_ring_trc_open - Open the Slow Ring trace log
1390 * @inode: The inode pointer that contains a vport pointer.
1391 * @file: The file pointer to attach the log output.
1394 * This routine is the entry point for the debugfs open file operation. It gets
1395 * the vport from the i_private field in @inode, allocates the necessary buffer
1396 * for the log, fills the buffer from the in-memory log for this vport, and then
1397 * returns a pointer to that log in the private_data field in @file.
1400 * This function returns zero if successful. On error it will return a negative
1404 lpfc_debugfs_slow_ring_trc_open(struct inode
*inode
, struct file
*file
)
1406 struct lpfc_hba
*phba
= inode
->i_private
;
1407 struct lpfc_debug
*debug
;
1411 if (!lpfc_debugfs_max_slow_ring_trc
) {
1416 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
1420 /* Round to page boundary */
1421 size
= (lpfc_debugfs_max_slow_ring_trc
* LPFC_DEBUG_TRC_ENTRY_SIZE
);
1422 size
= PAGE_ALIGN(size
);
1424 debug
->buffer
= kmalloc(size
, GFP_KERNEL
);
1425 if (!debug
->buffer
) {
1430 debug
->len
= lpfc_debugfs_slow_ring_trc_data(phba
, debug
->buffer
, size
);
1431 file
->private_data
= debug
;
1439 * lpfc_debugfs_hbqinfo_open - Open the hbqinfo debugfs buffer
1440 * @inode: The inode pointer that contains a vport pointer.
1441 * @file: The file pointer to attach the log output.
1444 * This routine is the entry point for the debugfs open file operation. It gets
1445 * the vport from the i_private field in @inode, allocates the necessary buffer
1446 * for the log, fills the buffer from the in-memory log for this vport, and then
1447 * returns a pointer to that log in the private_data field in @file.
1450 * This function returns zero if successful. On error it will return a negative
1454 lpfc_debugfs_hbqinfo_open(struct inode
*inode
, struct file
*file
)
1456 struct lpfc_hba
*phba
= inode
->i_private
;
1457 struct lpfc_debug
*debug
;
1460 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
1464 /* Round to page boundary */
1465 debug
->buffer
= kmalloc(LPFC_HBQINFO_SIZE
, GFP_KERNEL
);
1466 if (!debug
->buffer
) {
1471 debug
->len
= lpfc_debugfs_hbqinfo_data(phba
, debug
->buffer
,
1473 file
->private_data
= debug
;
1481 * lpfc_debugfs_dumpHBASlim_open - Open the Dump HBA SLIM debugfs buffer
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_dumpHBASlim_open(struct inode
*inode
, struct file
*file
)
1498 struct lpfc_hba
*phba
= inode
->i_private
;
1499 struct lpfc_debug
*debug
;
1502 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
1506 /* Round to page boundary */
1507 debug
->buffer
= kmalloc(LPFC_DUMPHBASLIM_SIZE
, GFP_KERNEL
);
1508 if (!debug
->buffer
) {
1513 debug
->len
= lpfc_debugfs_dumpHBASlim_data(phba
, debug
->buffer
,
1514 LPFC_DUMPHBASLIM_SIZE
);
1515 file
->private_data
= debug
;
1523 * lpfc_debugfs_dumpHostSlim_open - Open the Dump Host SLIM debugfs buffer
1524 * @inode: The inode pointer that contains a vport pointer.
1525 * @file: The file pointer to attach the log output.
1528 * This routine is the entry point for the debugfs open file operation. It gets
1529 * the vport from the i_private field in @inode, allocates the necessary buffer
1530 * for the log, fills the buffer from the in-memory log for this vport, and then
1531 * returns a pointer to that log in the private_data field in @file.
1534 * This function returns zero if successful. On error it will return a negative
1538 lpfc_debugfs_dumpHostSlim_open(struct inode
*inode
, struct file
*file
)
1540 struct lpfc_hba
*phba
= inode
->i_private
;
1541 struct lpfc_debug
*debug
;
1544 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
1548 /* Round to page boundary */
1549 debug
->buffer
= kmalloc(LPFC_DUMPHOSTSLIM_SIZE
, GFP_KERNEL
);
1550 if (!debug
->buffer
) {
1555 debug
->len
= lpfc_debugfs_dumpHostSlim_data(phba
, debug
->buffer
,
1556 LPFC_DUMPHOSTSLIM_SIZE
);
1557 file
->private_data
= debug
;
1565 lpfc_debugfs_dumpData_open(struct inode
*inode
, struct file
*file
)
1567 struct lpfc_debug
*debug
;
1570 if (!_dump_buf_data
)
1573 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
1577 /* Round to page boundary */
1578 pr_err("9059 BLKGRD: %s: _dump_buf_data=0x%p\n",
1579 __func__
, _dump_buf_data
);
1580 debug
->buffer
= _dump_buf_data
;
1581 if (!debug
->buffer
) {
1586 debug
->len
= (1 << _dump_buf_data_order
) << PAGE_SHIFT
;
1587 file
->private_data
= debug
;
1595 lpfc_debugfs_dumpDif_open(struct inode
*inode
, struct file
*file
)
1597 struct lpfc_debug
*debug
;
1603 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
1607 /* Round to page boundary */
1608 pr_err("9060 BLKGRD: %s: _dump_buf_dif=0x%p file=%pD\n",
1609 __func__
, _dump_buf_dif
, file
);
1610 debug
->buffer
= _dump_buf_dif
;
1611 if (!debug
->buffer
) {
1616 debug
->len
= (1 << _dump_buf_dif_order
) << PAGE_SHIFT
;
1617 file
->private_data
= debug
;
1625 lpfc_debugfs_dumpDataDif_write(struct file
*file
, const char __user
*buf
,
1626 size_t nbytes
, loff_t
*ppos
)
1629 * The Data/DIF buffers only save one failing IO
1630 * The write op is used as a reset mechanism after an IO has
1631 * already been saved to the next one can be saved
1633 spin_lock(&_dump_buf_lock
);
1635 memset((void *)_dump_buf_data
, 0,
1636 ((1 << PAGE_SHIFT
) << _dump_buf_data_order
));
1637 memset((void *)_dump_buf_dif
, 0,
1638 ((1 << PAGE_SHIFT
) << _dump_buf_dif_order
));
1642 spin_unlock(&_dump_buf_lock
);
1648 lpfc_debugfs_dif_err_read(struct file
*file
, char __user
*buf
,
1649 size_t nbytes
, loff_t
*ppos
)
1651 struct dentry
*dent
= file
->f_path
.dentry
;
1652 struct lpfc_hba
*phba
= file
->private_data
;
1657 if (dent
== phba
->debug_writeGuard
)
1658 cnt
= snprintf(cbuf
, 32, "%u\n", phba
->lpfc_injerr_wgrd_cnt
);
1659 else if (dent
== phba
->debug_writeApp
)
1660 cnt
= snprintf(cbuf
, 32, "%u\n", phba
->lpfc_injerr_wapp_cnt
);
1661 else if (dent
== phba
->debug_writeRef
)
1662 cnt
= snprintf(cbuf
, 32, "%u\n", phba
->lpfc_injerr_wref_cnt
);
1663 else if (dent
== phba
->debug_readGuard
)
1664 cnt
= snprintf(cbuf
, 32, "%u\n", phba
->lpfc_injerr_rgrd_cnt
);
1665 else if (dent
== phba
->debug_readApp
)
1666 cnt
= snprintf(cbuf
, 32, "%u\n", phba
->lpfc_injerr_rapp_cnt
);
1667 else if (dent
== phba
->debug_readRef
)
1668 cnt
= snprintf(cbuf
, 32, "%u\n", phba
->lpfc_injerr_rref_cnt
);
1669 else if (dent
== phba
->debug_InjErrNPortID
)
1670 cnt
= snprintf(cbuf
, 32, "0x%06x\n", phba
->lpfc_injerr_nportid
);
1671 else if (dent
== phba
->debug_InjErrWWPN
) {
1672 memcpy(&tmp
, &phba
->lpfc_injerr_wwpn
, sizeof(struct lpfc_name
));
1673 tmp
= cpu_to_be64(tmp
);
1674 cnt
= snprintf(cbuf
, 32, "0x%016llx\n", tmp
);
1675 } else if (dent
== phba
->debug_InjErrLBA
) {
1676 if (phba
->lpfc_injerr_lba
== (sector_t
)(-1))
1677 cnt
= snprintf(cbuf
, 32, "off\n");
1679 cnt
= snprintf(cbuf
, 32, "0x%llx\n",
1680 (uint64_t) phba
->lpfc_injerr_lba
);
1682 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
1683 "0547 Unknown debugfs error injection entry\n");
1685 return simple_read_from_buffer(buf
, nbytes
, ppos
, &cbuf
, cnt
);
1689 lpfc_debugfs_dif_err_write(struct file
*file
, const char __user
*buf
,
1690 size_t nbytes
, loff_t
*ppos
)
1692 struct dentry
*dent
= file
->f_path
.dentry
;
1693 struct lpfc_hba
*phba
= file
->private_data
;
1698 memset(dstbuf
, 0, 33);
1699 size
= (nbytes
< 32) ? nbytes
: 32;
1700 if (copy_from_user(dstbuf
, buf
, size
))
1703 if (dent
== phba
->debug_InjErrLBA
) {
1704 if ((buf
[0] == 'o') && (buf
[1] == 'f') && (buf
[2] == 'f'))
1705 tmp
= (uint64_t)(-1);
1708 if ((tmp
== 0) && (kstrtoull(dstbuf
, 0, &tmp
)))
1711 if (dent
== phba
->debug_writeGuard
)
1712 phba
->lpfc_injerr_wgrd_cnt
= (uint32_t)tmp
;
1713 else if (dent
== phba
->debug_writeApp
)
1714 phba
->lpfc_injerr_wapp_cnt
= (uint32_t)tmp
;
1715 else if (dent
== phba
->debug_writeRef
)
1716 phba
->lpfc_injerr_wref_cnt
= (uint32_t)tmp
;
1717 else if (dent
== phba
->debug_readGuard
)
1718 phba
->lpfc_injerr_rgrd_cnt
= (uint32_t)tmp
;
1719 else if (dent
== phba
->debug_readApp
)
1720 phba
->lpfc_injerr_rapp_cnt
= (uint32_t)tmp
;
1721 else if (dent
== phba
->debug_readRef
)
1722 phba
->lpfc_injerr_rref_cnt
= (uint32_t)tmp
;
1723 else if (dent
== phba
->debug_InjErrLBA
)
1724 phba
->lpfc_injerr_lba
= (sector_t
)tmp
;
1725 else if (dent
== phba
->debug_InjErrNPortID
)
1726 phba
->lpfc_injerr_nportid
= (uint32_t)(tmp
& Mask_DID
);
1727 else if (dent
== phba
->debug_InjErrWWPN
) {
1728 tmp
= cpu_to_be64(tmp
);
1729 memcpy(&phba
->lpfc_injerr_wwpn
, &tmp
, sizeof(struct lpfc_name
));
1731 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
1732 "0548 Unknown debugfs error injection entry\n");
1738 lpfc_debugfs_dif_err_release(struct inode
*inode
, struct file
*file
)
1744 * lpfc_debugfs_nodelist_open - Open the nodelist debugfs file
1745 * @inode: The inode pointer that contains a vport pointer.
1746 * @file: The file pointer to attach the log output.
1749 * This routine is the entry point for the debugfs open file operation. It gets
1750 * the vport from the i_private field in @inode, allocates the necessary buffer
1751 * for the log, fills the buffer from the in-memory log for this vport, and then
1752 * returns a pointer to that log in the private_data field in @file.
1755 * This function returns zero if successful. On error it will return a negative
1759 lpfc_debugfs_nodelist_open(struct inode
*inode
, struct file
*file
)
1761 struct lpfc_vport
*vport
= inode
->i_private
;
1762 struct lpfc_debug
*debug
;
1765 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
1769 /* Round to page boundary */
1770 debug
->buffer
= kmalloc(LPFC_NODELIST_SIZE
, GFP_KERNEL
);
1771 if (!debug
->buffer
) {
1776 debug
->len
= lpfc_debugfs_nodelist_data(vport
, debug
->buffer
,
1777 LPFC_NODELIST_SIZE
);
1778 file
->private_data
= debug
;
1786 * lpfc_debugfs_lseek - Seek through a debugfs file
1787 * @file: The file pointer to seek through.
1788 * @off: The offset to seek to or the amount to seek by.
1789 * @whence: Indicates how to seek.
1792 * This routine is the entry point for the debugfs lseek file operation. The
1793 * @whence parameter indicates whether @off is the offset to directly seek to,
1794 * or if it is a value to seek forward or reverse by. This function figures out
1795 * what the new offset of the debugfs file will be and assigns that value to the
1796 * f_pos field of @file.
1799 * This function returns the new offset if successful and returns a negative
1800 * error if unable to process the seek.
1803 lpfc_debugfs_lseek(struct file
*file
, loff_t off
, int whence
)
1805 struct lpfc_debug
*debug
= file
->private_data
;
1806 return fixed_size_llseek(file
, off
, whence
, debug
->len
);
1810 * lpfc_debugfs_read - Read a debugfs file
1811 * @file: The file pointer to read from.
1812 * @buf: The buffer to copy the data to.
1813 * @nbytes: The number of bytes to read.
1814 * @ppos: The position in the file to start reading from.
1817 * This routine reads data from from the buffer indicated in the private_data
1818 * field of @file. It will start reading at @ppos and copy up to @nbytes of
1822 * This function returns the amount of data that was read (this could be less
1823 * than @nbytes if the end of the file was reached) or a negative error value.
1826 lpfc_debugfs_read(struct file
*file
, char __user
*buf
,
1827 size_t nbytes
, loff_t
*ppos
)
1829 struct lpfc_debug
*debug
= file
->private_data
;
1831 return simple_read_from_buffer(buf
, nbytes
, ppos
, debug
->buffer
,
1836 * lpfc_debugfs_release - Release the buffer used to store debugfs file data
1837 * @inode: The inode pointer that contains a vport pointer. (unused)
1838 * @file: The file pointer that contains the buffer to release.
1841 * This routine frees the buffer that was allocated when the debugfs file was
1845 * This function returns zero.
1848 lpfc_debugfs_release(struct inode
*inode
, struct file
*file
)
1850 struct lpfc_debug
*debug
= file
->private_data
;
1852 kfree(debug
->buffer
);
1859 lpfc_debugfs_dumpDataDif_release(struct inode
*inode
, struct file
*file
)
1861 struct lpfc_debug
*debug
= file
->private_data
;
1863 debug
->buffer
= NULL
;
1871 lpfc_debugfs_nvmestat_open(struct inode
*inode
, struct file
*file
)
1873 struct lpfc_vport
*vport
= inode
->i_private
;
1874 struct lpfc_debug
*debug
;
1877 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
1881 /* Round to page boundary */
1882 debug
->buffer
= kmalloc(LPFC_NVMESTAT_SIZE
, GFP_KERNEL
);
1883 if (!debug
->buffer
) {
1888 debug
->len
= lpfc_debugfs_nvmestat_data(vport
, debug
->buffer
,
1889 LPFC_NVMESTAT_SIZE
);
1891 debug
->i_private
= inode
->i_private
;
1892 file
->private_data
= debug
;
1900 lpfc_debugfs_nvmestat_write(struct file
*file
, const char __user
*buf
,
1901 size_t nbytes
, loff_t
*ppos
)
1903 struct lpfc_debug
*debug
= file
->private_data
;
1904 struct lpfc_vport
*vport
= (struct lpfc_vport
*)debug
->i_private
;
1905 struct lpfc_hba
*phba
= vport
->phba
;
1906 struct lpfc_nvmet_tgtport
*tgtp
;
1910 if (!phba
->targetport
)
1916 /* Protect copy from user */
1917 if (!access_ok(VERIFY_READ
, buf
, nbytes
))
1920 memset(mybuf
, 0, sizeof(mybuf
));
1922 if (copy_from_user(mybuf
, buf
, nbytes
))
1926 tgtp
= (struct lpfc_nvmet_tgtport
*)phba
->targetport
->private;
1927 if ((strncmp(pbuf
, "reset", strlen("reset")) == 0) ||
1928 (strncmp(pbuf
, "zero", strlen("zero")) == 0)) {
1929 atomic_set(&tgtp
->rcv_ls_req_in
, 0);
1930 atomic_set(&tgtp
->rcv_ls_req_out
, 0);
1931 atomic_set(&tgtp
->rcv_ls_req_drop
, 0);
1932 atomic_set(&tgtp
->xmt_ls_abort
, 0);
1933 atomic_set(&tgtp
->xmt_ls_rsp
, 0);
1934 atomic_set(&tgtp
->xmt_ls_drop
, 0);
1935 atomic_set(&tgtp
->xmt_ls_rsp_error
, 0);
1936 atomic_set(&tgtp
->xmt_ls_rsp_cmpl
, 0);
1938 atomic_set(&tgtp
->rcv_fcp_cmd_in
, 0);
1939 atomic_set(&tgtp
->rcv_fcp_cmd_out
, 0);
1940 atomic_set(&tgtp
->rcv_fcp_cmd_drop
, 0);
1941 atomic_set(&tgtp
->xmt_fcp_abort
, 0);
1942 atomic_set(&tgtp
->xmt_fcp_drop
, 0);
1943 atomic_set(&tgtp
->xmt_fcp_read_rsp
, 0);
1944 atomic_set(&tgtp
->xmt_fcp_read
, 0);
1945 atomic_set(&tgtp
->xmt_fcp_write
, 0);
1946 atomic_set(&tgtp
->xmt_fcp_rsp
, 0);
1947 atomic_set(&tgtp
->xmt_fcp_rsp_cmpl
, 0);
1948 atomic_set(&tgtp
->xmt_fcp_rsp_error
, 0);
1949 atomic_set(&tgtp
->xmt_fcp_rsp_drop
, 0);
1951 atomic_set(&tgtp
->xmt_abort_rsp
, 0);
1952 atomic_set(&tgtp
->xmt_abort_rsp_error
, 0);
1953 atomic_set(&tgtp
->xmt_abort_cmpl
, 0);
1959 lpfc_debugfs_nvmektime_open(struct inode
*inode
, struct file
*file
)
1961 struct lpfc_vport
*vport
= inode
->i_private
;
1962 struct lpfc_debug
*debug
;
1965 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
1969 /* Round to page boundary */
1970 debug
->buffer
= kmalloc(LPFC_NVMEKTIME_SIZE
, GFP_KERNEL
);
1971 if (!debug
->buffer
) {
1976 debug
->len
= lpfc_debugfs_nvmektime_data(vport
, debug
->buffer
,
1977 LPFC_NVMEKTIME_SIZE
);
1979 debug
->i_private
= inode
->i_private
;
1980 file
->private_data
= debug
;
1988 lpfc_debugfs_nvmektime_write(struct file
*file
, const char __user
*buf
,
1989 size_t nbytes
, loff_t
*ppos
)
1991 struct lpfc_debug
*debug
= file
->private_data
;
1992 struct lpfc_vport
*vport
= (struct lpfc_vport
*)debug
->i_private
;
1993 struct lpfc_hba
*phba
= vport
->phba
;
2000 /* Protect copy from user */
2001 if (!access_ok(VERIFY_READ
, buf
, nbytes
))
2004 memset(mybuf
, 0, sizeof(mybuf
));
2006 if (copy_from_user(mybuf
, buf
, nbytes
))
2010 if ((strncmp(pbuf
, "on", sizeof("on") - 1) == 0)) {
2011 phba
->ktime_data_samples
= 0;
2012 phba
->ktime_status_samples
= 0;
2013 phba
->ktime_seg1_total
= 0;
2014 phba
->ktime_seg1_max
= 0;
2015 phba
->ktime_seg1_min
= 0xffffffff;
2016 phba
->ktime_seg2_total
= 0;
2017 phba
->ktime_seg2_max
= 0;
2018 phba
->ktime_seg2_min
= 0xffffffff;
2019 phba
->ktime_seg3_total
= 0;
2020 phba
->ktime_seg3_max
= 0;
2021 phba
->ktime_seg3_min
= 0xffffffff;
2022 phba
->ktime_seg4_total
= 0;
2023 phba
->ktime_seg4_max
= 0;
2024 phba
->ktime_seg4_min
= 0xffffffff;
2025 phba
->ktime_seg5_total
= 0;
2026 phba
->ktime_seg5_max
= 0;
2027 phba
->ktime_seg5_min
= 0xffffffff;
2028 phba
->ktime_seg6_total
= 0;
2029 phba
->ktime_seg6_max
= 0;
2030 phba
->ktime_seg6_min
= 0xffffffff;
2031 phba
->ktime_seg7_total
= 0;
2032 phba
->ktime_seg7_max
= 0;
2033 phba
->ktime_seg7_min
= 0xffffffff;
2034 phba
->ktime_seg8_total
= 0;
2035 phba
->ktime_seg8_max
= 0;
2036 phba
->ktime_seg8_min
= 0xffffffff;
2037 phba
->ktime_seg9_total
= 0;
2038 phba
->ktime_seg9_max
= 0;
2039 phba
->ktime_seg9_min
= 0xffffffff;
2040 phba
->ktime_seg10_total
= 0;
2041 phba
->ktime_seg10_max
= 0;
2042 phba
->ktime_seg10_min
= 0xffffffff;
2045 return strlen(pbuf
);
2046 } else if ((strncmp(pbuf
, "off",
2047 sizeof("off") - 1) == 0)) {
2049 return strlen(pbuf
);
2050 } else if ((strncmp(pbuf
, "zero",
2051 sizeof("zero") - 1) == 0)) {
2052 phba
->ktime_data_samples
= 0;
2053 phba
->ktime_status_samples
= 0;
2054 phba
->ktime_seg1_total
= 0;
2055 phba
->ktime_seg1_max
= 0;
2056 phba
->ktime_seg1_min
= 0xffffffff;
2057 phba
->ktime_seg2_total
= 0;
2058 phba
->ktime_seg2_max
= 0;
2059 phba
->ktime_seg2_min
= 0xffffffff;
2060 phba
->ktime_seg3_total
= 0;
2061 phba
->ktime_seg3_max
= 0;
2062 phba
->ktime_seg3_min
= 0xffffffff;
2063 phba
->ktime_seg4_total
= 0;
2064 phba
->ktime_seg4_max
= 0;
2065 phba
->ktime_seg4_min
= 0xffffffff;
2066 phba
->ktime_seg5_total
= 0;
2067 phba
->ktime_seg5_max
= 0;
2068 phba
->ktime_seg5_min
= 0xffffffff;
2069 phba
->ktime_seg6_total
= 0;
2070 phba
->ktime_seg6_max
= 0;
2071 phba
->ktime_seg6_min
= 0xffffffff;
2072 phba
->ktime_seg7_total
= 0;
2073 phba
->ktime_seg7_max
= 0;
2074 phba
->ktime_seg7_min
= 0xffffffff;
2075 phba
->ktime_seg8_total
= 0;
2076 phba
->ktime_seg8_max
= 0;
2077 phba
->ktime_seg8_min
= 0xffffffff;
2078 phba
->ktime_seg9_total
= 0;
2079 phba
->ktime_seg9_max
= 0;
2080 phba
->ktime_seg9_min
= 0xffffffff;
2081 phba
->ktime_seg10_total
= 0;
2082 phba
->ktime_seg10_max
= 0;
2083 phba
->ktime_seg10_min
= 0xffffffff;
2084 return strlen(pbuf
);
2090 lpfc_debugfs_nvmeio_trc_open(struct inode
*inode
, struct file
*file
)
2092 struct lpfc_hba
*phba
= inode
->i_private
;
2093 struct lpfc_debug
*debug
;
2096 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
2100 /* Round to page boundary */
2101 debug
->buffer
= kmalloc(LPFC_NVMEIO_TRC_SIZE
, GFP_KERNEL
);
2102 if (!debug
->buffer
) {
2107 debug
->len
= lpfc_debugfs_nvmeio_trc_data(phba
, debug
->buffer
,
2108 LPFC_NVMEIO_TRC_SIZE
);
2110 debug
->i_private
= inode
->i_private
;
2111 file
->private_data
= debug
;
2119 lpfc_debugfs_nvmeio_trc_write(struct file
*file
, const char __user
*buf
,
2120 size_t nbytes
, loff_t
*ppos
)
2122 struct lpfc_debug
*debug
= file
->private_data
;
2123 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
2132 /* Protect copy from user */
2133 if (!access_ok(VERIFY_READ
, buf
, nbytes
))
2136 memset(mybuf
, 0, sizeof(mybuf
));
2138 if (copy_from_user(mybuf
, buf
, nbytes
))
2142 if ((strncmp(pbuf
, "off", sizeof("off") - 1) == 0)) {
2143 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
2144 "0570 nvmeio_trc_off\n");
2145 phba
->nvmeio_trc_output_idx
= 0;
2146 phba
->nvmeio_trc_on
= 0;
2147 return strlen(pbuf
);
2148 } else if ((strncmp(pbuf
, "on", sizeof("on") - 1) == 0)) {
2149 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
2150 "0571 nvmeio_trc_on\n");
2151 phba
->nvmeio_trc_output_idx
= 0;
2152 phba
->nvmeio_trc_on
= 1;
2153 return strlen(pbuf
);
2156 /* We must be off to allocate the trace buffer */
2157 if (phba
->nvmeio_trc_on
!= 0)
2160 /* If not on or off, the parameter is the trace buffer size */
2161 i
= kstrtoul(pbuf
, 0, &sz
);
2164 phba
->nvmeio_trc_size
= (uint32_t)sz
;
2166 /* It must be a power of 2 - round down */
2173 if (phba
->nvmeio_trc_size
!= sz
)
2174 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
2175 "0572 nvmeio_trc_size changed to %ld\n",
2177 phba
->nvmeio_trc_size
= (uint32_t)sz
;
2179 /* If one previously exists, free it */
2180 kfree(phba
->nvmeio_trc
);
2182 /* Allocate new trace buffer and initialize */
2183 phba
->nvmeio_trc
= kmalloc((sizeof(struct lpfc_debugfs_nvmeio_trc
) *
2185 if (!phba
->nvmeio_trc
) {
2186 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
2187 "0573 Cannot create debugfs "
2188 "nvmeio_trc buffer\n");
2191 memset(phba
->nvmeio_trc
, 0,
2192 (sizeof(struct lpfc_debugfs_nvmeio_trc
) * sz
));
2193 atomic_set(&phba
->nvmeio_trc_cnt
, 0);
2194 phba
->nvmeio_trc_on
= 0;
2195 phba
->nvmeio_trc_output_idx
= 0;
2197 return strlen(pbuf
);
2201 lpfc_debugfs_cpucheck_open(struct inode
*inode
, struct file
*file
)
2203 struct lpfc_vport
*vport
= inode
->i_private
;
2204 struct lpfc_debug
*debug
;
2207 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
2211 /* Round to page boundary */
2212 debug
->buffer
= kmalloc(LPFC_CPUCHECK_SIZE
, GFP_KERNEL
);
2213 if (!debug
->buffer
) {
2218 debug
->len
= lpfc_debugfs_cpucheck_data(vport
, debug
->buffer
,
2219 LPFC_NVMEKTIME_SIZE
);
2221 debug
->i_private
= inode
->i_private
;
2222 file
->private_data
= debug
;
2230 lpfc_debugfs_cpucheck_write(struct file
*file
, const char __user
*buf
,
2231 size_t nbytes
, loff_t
*ppos
)
2233 struct lpfc_debug
*debug
= file
->private_data
;
2234 struct lpfc_vport
*vport
= (struct lpfc_vport
*)debug
->i_private
;
2235 struct lpfc_hba
*phba
= vport
->phba
;
2243 /* Protect copy from user */
2244 if (!access_ok(VERIFY_READ
, buf
, nbytes
))
2247 memset(mybuf
, 0, sizeof(mybuf
));
2249 if (copy_from_user(mybuf
, buf
, nbytes
))
2253 if ((strncmp(pbuf
, "on", sizeof("on") - 1) == 0)) {
2254 if (phba
->nvmet_support
)
2255 phba
->cpucheck_on
|= LPFC_CHECK_NVMET_IO
;
2257 phba
->cpucheck_on
|= LPFC_CHECK_NVME_IO
;
2258 return strlen(pbuf
);
2259 } else if ((strncmp(pbuf
, "rcv",
2260 sizeof("rcv") - 1) == 0)) {
2261 if (phba
->nvmet_support
)
2262 phba
->cpucheck_on
|= LPFC_CHECK_NVMET_RCV
;
2265 return strlen(pbuf
);
2266 } else if ((strncmp(pbuf
, "off",
2267 sizeof("off") - 1) == 0)) {
2268 phba
->cpucheck_on
= LPFC_CHECK_OFF
;
2269 return strlen(pbuf
);
2270 } else if ((strncmp(pbuf
, "zero",
2271 sizeof("zero") - 1) == 0)) {
2272 for (i
= 0; i
< phba
->sli4_hba
.num_present_cpu
; i
++) {
2273 if (i
>= LPFC_CHECK_CPU_CNT
)
2275 phba
->cpucheck_rcv_io
[i
] = 0;
2276 phba
->cpucheck_xmt_io
[i
] = 0;
2277 phba
->cpucheck_cmpl_io
[i
] = 0;
2278 phba
->cpucheck_ccmpl_io
[i
] = 0;
2280 return strlen(pbuf
);
2286 * ---------------------------------
2287 * iDiag debugfs file access methods
2288 * ---------------------------------
2290 * All access methods are through the proper SLI4 PCI function's debugfs
2293 * /sys/kernel/debug/lpfc/fn<#>/iDiag
2297 * lpfc_idiag_cmd_get - Get and parse idiag debugfs comands from user space
2298 * @buf: The pointer to the user space buffer.
2299 * @nbytes: The number of bytes in the user space buffer.
2300 * @idiag_cmd: pointer to the idiag command struct.
2302 * This routine reads data from debugfs user space buffer and parses the
2303 * buffer for getting the idiag command and arguments. The while space in
2304 * between the set of data is used as the parsing separator.
2306 * This routine returns 0 when successful, it returns proper error code
2307 * back to the user space in error conditions.
2309 static int lpfc_idiag_cmd_get(const char __user
*buf
, size_t nbytes
,
2310 struct lpfc_idiag_cmd
*idiag_cmd
)
2313 char *pbuf
, *step_str
;
2317 /* Protect copy from user */
2318 if (!access_ok(VERIFY_READ
, buf
, nbytes
))
2321 memset(mybuf
, 0, sizeof(mybuf
));
2322 memset(idiag_cmd
, 0, sizeof(*idiag_cmd
));
2323 bsize
= min(nbytes
, (sizeof(mybuf
)-1));
2325 if (copy_from_user(mybuf
, buf
, bsize
))
2328 step_str
= strsep(&pbuf
, "\t ");
2330 /* The opcode must present */
2334 idiag_cmd
->opcode
= simple_strtol(step_str
, NULL
, 0);
2335 if (idiag_cmd
->opcode
== 0)
2338 for (i
= 0; i
< LPFC_IDIAG_CMD_DATA_SIZE
; i
++) {
2339 step_str
= strsep(&pbuf
, "\t ");
2342 idiag_cmd
->data
[i
] = simple_strtol(step_str
, NULL
, 0);
2348 * lpfc_idiag_open - idiag open debugfs
2349 * @inode: The inode pointer that contains a pointer to phba.
2350 * @file: The file pointer to attach the file operation.
2353 * This routine is the entry point for the debugfs open file operation. It
2354 * gets the reference to phba from the i_private field in @inode, it then
2355 * allocates buffer for the file operation, performs the necessary PCI config
2356 * space read into the allocated buffer according to the idiag user command
2357 * setup, and then returns a pointer to buffer in the private_data field in
2361 * This function returns zero if successful. On error it will return an
2362 * negative error value.
2365 lpfc_idiag_open(struct inode
*inode
, struct file
*file
)
2367 struct lpfc_debug
*debug
;
2369 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
2373 debug
->i_private
= inode
->i_private
;
2374 debug
->buffer
= NULL
;
2375 file
->private_data
= debug
;
2381 * lpfc_idiag_release - Release idiag access file operation
2382 * @inode: The inode pointer that contains a vport pointer. (unused)
2383 * @file: The file pointer that contains the buffer to release.
2386 * This routine is the generic release routine for the idiag access file
2387 * operation, it frees the buffer that was allocated when the debugfs file
2391 * This function returns zero.
2394 lpfc_idiag_release(struct inode
*inode
, struct file
*file
)
2396 struct lpfc_debug
*debug
= file
->private_data
;
2398 /* Free the buffers to the file operation */
2399 kfree(debug
->buffer
);
2406 * lpfc_idiag_cmd_release - Release idiag cmd access file operation
2407 * @inode: The inode pointer that contains a vport pointer. (unused)
2408 * @file: The file pointer that contains the buffer to release.
2411 * This routine frees the buffer that was allocated when the debugfs file
2412 * was opened. It also reset the fields in the idiag command struct in the
2413 * case of command for write operation.
2416 * This function returns zero.
2419 lpfc_idiag_cmd_release(struct inode
*inode
, struct file
*file
)
2421 struct lpfc_debug
*debug
= file
->private_data
;
2423 if (debug
->op
== LPFC_IDIAG_OP_WR
) {
2424 switch (idiag
.cmd
.opcode
) {
2425 case LPFC_IDIAG_CMD_PCICFG_WR
:
2426 case LPFC_IDIAG_CMD_PCICFG_ST
:
2427 case LPFC_IDIAG_CMD_PCICFG_CL
:
2428 case LPFC_IDIAG_CMD_QUEACC_WR
:
2429 case LPFC_IDIAG_CMD_QUEACC_ST
:
2430 case LPFC_IDIAG_CMD_QUEACC_CL
:
2431 memset(&idiag
, 0, sizeof(idiag
));
2438 /* Free the buffers to the file operation */
2439 kfree(debug
->buffer
);
2446 * lpfc_idiag_pcicfg_read - idiag debugfs read pcicfg
2447 * @file: The file pointer to read from.
2448 * @buf: The buffer to copy the data to.
2449 * @nbytes: The number of bytes to read.
2450 * @ppos: The position in the file to start reading from.
2453 * This routine reads data from the @phba pci config space according to the
2454 * idiag command, and copies to user @buf. Depending on the PCI config space
2455 * read command setup, it does either a single register read of a byte
2456 * (8 bits), a word (16 bits), or a dword (32 bits) or browsing through all
2457 * registers from the 4K extended PCI config space.
2460 * This function returns the amount of data that was read (this could be less
2461 * than @nbytes if the end of the file was reached) or a negative error value.
2464 lpfc_idiag_pcicfg_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
2467 struct lpfc_debug
*debug
= file
->private_data
;
2468 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
2469 int offset_label
, offset
, len
= 0, index
= LPFC_PCI_CFG_RD_SIZE
;
2472 struct pci_dev
*pdev
;
2477 pdev
= phba
->pcidev
;
2481 /* This is a user read operation */
2482 debug
->op
= LPFC_IDIAG_OP_RD
;
2485 debug
->buffer
= kmalloc(LPFC_PCI_CFG_SIZE
, GFP_KERNEL
);
2488 pbuffer
= debug
->buffer
;
2493 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_RD
) {
2494 where
= idiag
.cmd
.data
[IDIAG_PCICFG_WHERE_INDX
];
2495 count
= idiag
.cmd
.data
[IDIAG_PCICFG_COUNT_INDX
];
2499 /* Read single PCI config space register */
2501 case SIZE_U8
: /* byte (8 bits) */
2502 pci_read_config_byte(pdev
, where
, &u8val
);
2503 len
+= snprintf(pbuffer
+len
, LPFC_PCI_CFG_SIZE
-len
,
2504 "%03x: %02x\n", where
, u8val
);
2506 case SIZE_U16
: /* word (16 bits) */
2507 pci_read_config_word(pdev
, where
, &u16val
);
2508 len
+= snprintf(pbuffer
+len
, LPFC_PCI_CFG_SIZE
-len
,
2509 "%03x: %04x\n", where
, u16val
);
2511 case SIZE_U32
: /* double word (32 bits) */
2512 pci_read_config_dword(pdev
, where
, &u32val
);
2513 len
+= snprintf(pbuffer
+len
, LPFC_PCI_CFG_SIZE
-len
,
2514 "%03x: %08x\n", where
, u32val
);
2516 case LPFC_PCI_CFG_BROWSE
: /* browse all */
2524 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
2528 /* Browse all PCI config space registers */
2529 offset_label
= idiag
.offset
.last_rd
;
2530 offset
= offset_label
;
2532 /* Read PCI config space */
2533 len
+= snprintf(pbuffer
+len
, LPFC_PCI_CFG_SIZE
-len
,
2534 "%03x: ", offset_label
);
2536 pci_read_config_dword(pdev
, offset
, &u32val
);
2537 len
+= snprintf(pbuffer
+len
, LPFC_PCI_CFG_SIZE
-len
,
2539 offset
+= sizeof(uint32_t);
2540 if (offset
>= LPFC_PCI_CFG_SIZE
) {
2541 len
+= snprintf(pbuffer
+len
,
2542 LPFC_PCI_CFG_SIZE
-len
, "\n");
2545 index
-= sizeof(uint32_t);
2547 len
+= snprintf(pbuffer
+len
, LPFC_PCI_CFG_SIZE
-len
,
2549 else if (!(index
% (8 * sizeof(uint32_t)))) {
2550 offset_label
+= (8 * sizeof(uint32_t));
2551 len
+= snprintf(pbuffer
+len
, LPFC_PCI_CFG_SIZE
-len
,
2552 "\n%03x: ", offset_label
);
2556 /* Set up the offset for next portion of pci cfg read */
2558 idiag
.offset
.last_rd
+= LPFC_PCI_CFG_RD_SIZE
;
2559 if (idiag
.offset
.last_rd
>= LPFC_PCI_CFG_SIZE
)
2560 idiag
.offset
.last_rd
= 0;
2562 idiag
.offset
.last_rd
= 0;
2564 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
2568 * lpfc_idiag_pcicfg_write - Syntax check and set up idiag pcicfg commands
2569 * @file: The file pointer to read from.
2570 * @buf: The buffer to copy the user data from.
2571 * @nbytes: The number of bytes to get.
2572 * @ppos: The position in the file to start reading from.
2574 * This routine get the debugfs idiag command struct from user space and
2575 * then perform the syntax check for PCI config space read or write command
2576 * accordingly. In the case of PCI config space read command, it sets up
2577 * the command in the idiag command struct for the debugfs read operation.
2578 * In the case of PCI config space write operation, it executes the write
2579 * operation into the PCI config space accordingly.
2581 * It returns the @nbytges passing in from debugfs user space when successful.
2582 * In case of error conditions, it returns proper error code back to the user
2586 lpfc_idiag_pcicfg_write(struct file
*file
, const char __user
*buf
,
2587 size_t nbytes
, loff_t
*ppos
)
2589 struct lpfc_debug
*debug
= file
->private_data
;
2590 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
2591 uint32_t where
, value
, count
;
2595 struct pci_dev
*pdev
;
2598 pdev
= phba
->pcidev
;
2602 /* This is a user write operation */
2603 debug
->op
= LPFC_IDIAG_OP_WR
;
2605 rc
= lpfc_idiag_cmd_get(buf
, nbytes
, &idiag
.cmd
);
2609 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_RD
) {
2610 /* Sanity check on PCI config read command line arguments */
2611 if (rc
!= LPFC_PCI_CFG_RD_CMD_ARG
)
2613 /* Read command from PCI config space, set up command fields */
2614 where
= idiag
.cmd
.data
[IDIAG_PCICFG_WHERE_INDX
];
2615 count
= idiag
.cmd
.data
[IDIAG_PCICFG_COUNT_INDX
];
2616 if (count
== LPFC_PCI_CFG_BROWSE
) {
2617 if (where
% sizeof(uint32_t))
2619 /* Starting offset to browse */
2620 idiag
.offset
.last_rd
= where
;
2621 } else if ((count
!= sizeof(uint8_t)) &&
2622 (count
!= sizeof(uint16_t)) &&
2623 (count
!= sizeof(uint32_t)))
2625 if (count
== sizeof(uint8_t)) {
2626 if (where
> LPFC_PCI_CFG_SIZE
- sizeof(uint8_t))
2628 if (where
% sizeof(uint8_t))
2631 if (count
== sizeof(uint16_t)) {
2632 if (where
> LPFC_PCI_CFG_SIZE
- sizeof(uint16_t))
2634 if (where
% sizeof(uint16_t))
2637 if (count
== sizeof(uint32_t)) {
2638 if (where
> LPFC_PCI_CFG_SIZE
- sizeof(uint32_t))
2640 if (where
% sizeof(uint32_t))
2643 } else if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_WR
||
2644 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_ST
||
2645 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_CL
) {
2646 /* Sanity check on PCI config write command line arguments */
2647 if (rc
!= LPFC_PCI_CFG_WR_CMD_ARG
)
2649 /* Write command to PCI config space, read-modify-write */
2650 where
= idiag
.cmd
.data
[IDIAG_PCICFG_WHERE_INDX
];
2651 count
= idiag
.cmd
.data
[IDIAG_PCICFG_COUNT_INDX
];
2652 value
= idiag
.cmd
.data
[IDIAG_PCICFG_VALUE_INDX
];
2654 if ((count
!= sizeof(uint8_t)) &&
2655 (count
!= sizeof(uint16_t)) &&
2656 (count
!= sizeof(uint32_t)))
2658 if (count
== sizeof(uint8_t)) {
2659 if (where
> LPFC_PCI_CFG_SIZE
- sizeof(uint8_t))
2661 if (where
% sizeof(uint8_t))
2663 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_WR
)
2664 pci_write_config_byte(pdev
, where
,
2666 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_ST
) {
2667 rc
= pci_read_config_byte(pdev
, where
, &u8val
);
2669 u8val
|= (uint8_t)value
;
2670 pci_write_config_byte(pdev
, where
,
2674 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_CL
) {
2675 rc
= pci_read_config_byte(pdev
, where
, &u8val
);
2677 u8val
&= (uint8_t)(~value
);
2678 pci_write_config_byte(pdev
, where
,
2683 if (count
== sizeof(uint16_t)) {
2684 if (where
> LPFC_PCI_CFG_SIZE
- sizeof(uint16_t))
2686 if (where
% sizeof(uint16_t))
2688 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_WR
)
2689 pci_write_config_word(pdev
, where
,
2691 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_ST
) {
2692 rc
= pci_read_config_word(pdev
, where
, &u16val
);
2694 u16val
|= (uint16_t)value
;
2695 pci_write_config_word(pdev
, where
,
2699 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_CL
) {
2700 rc
= pci_read_config_word(pdev
, where
, &u16val
);
2702 u16val
&= (uint16_t)(~value
);
2703 pci_write_config_word(pdev
, where
,
2708 if (count
== sizeof(uint32_t)) {
2709 if (where
> LPFC_PCI_CFG_SIZE
- sizeof(uint32_t))
2711 if (where
% sizeof(uint32_t))
2713 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_WR
)
2714 pci_write_config_dword(pdev
, where
, value
);
2715 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_ST
) {
2716 rc
= pci_read_config_dword(pdev
, where
,
2720 pci_write_config_dword(pdev
, where
,
2724 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_CL
) {
2725 rc
= pci_read_config_dword(pdev
, where
,
2729 pci_write_config_dword(pdev
, where
,
2735 /* All other opecodes are illegal for now */
2740 memset(&idiag
, 0, sizeof(idiag
));
2745 * lpfc_idiag_baracc_read - idiag debugfs pci bar access read
2746 * @file: The file pointer to read from.
2747 * @buf: The buffer to copy the data to.
2748 * @nbytes: The number of bytes to read.
2749 * @ppos: The position in the file to start reading from.
2752 * This routine reads data from the @phba pci bar memory mapped space
2753 * according to the idiag command, and copies to user @buf.
2756 * This function returns the amount of data that was read (this could be less
2757 * than @nbytes if the end of the file was reached) or a negative error value.
2760 lpfc_idiag_baracc_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
2763 struct lpfc_debug
*debug
= file
->private_data
;
2764 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
2765 int offset_label
, offset
, offset_run
, len
= 0, index
;
2766 int bar_num
, acc_range
, bar_size
;
2768 void __iomem
*mem_mapped_bar
;
2770 struct pci_dev
*pdev
;
2773 pdev
= phba
->pcidev
;
2777 /* This is a user read operation */
2778 debug
->op
= LPFC_IDIAG_OP_RD
;
2781 debug
->buffer
= kmalloc(LPFC_PCI_BAR_RD_BUF_SIZE
, GFP_KERNEL
);
2784 pbuffer
= debug
->buffer
;
2789 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_RD
) {
2790 bar_num
= idiag
.cmd
.data
[IDIAG_BARACC_BAR_NUM_INDX
];
2791 offset
= idiag
.cmd
.data
[IDIAG_BARACC_OFF_SET_INDX
];
2792 acc_range
= idiag
.cmd
.data
[IDIAG_BARACC_ACC_MOD_INDX
];
2793 bar_size
= idiag
.cmd
.data
[IDIAG_BARACC_BAR_SZE_INDX
];
2800 if_type
= bf_get(lpfc_sli_intf_if_type
, &phba
->sli4_hba
.sli_intf
);
2801 if (if_type
== LPFC_SLI_INTF_IF_TYPE_0
) {
2802 if (bar_num
== IDIAG_BARACC_BAR_0
)
2803 mem_mapped_bar
= phba
->sli4_hba
.conf_regs_memmap_p
;
2804 else if (bar_num
== IDIAG_BARACC_BAR_1
)
2805 mem_mapped_bar
= phba
->sli4_hba
.ctrl_regs_memmap_p
;
2806 else if (bar_num
== IDIAG_BARACC_BAR_2
)
2807 mem_mapped_bar
= phba
->sli4_hba
.drbl_regs_memmap_p
;
2810 } else if (if_type
== LPFC_SLI_INTF_IF_TYPE_2
) {
2811 if (bar_num
== IDIAG_BARACC_BAR_0
)
2812 mem_mapped_bar
= phba
->sli4_hba
.conf_regs_memmap_p
;
2818 /* Read single PCI bar space register */
2819 if (acc_range
== SINGLE_WORD
) {
2820 offset_run
= offset
;
2821 u32val
= readl(mem_mapped_bar
+ offset_run
);
2822 len
+= snprintf(pbuffer
+len
, LPFC_PCI_BAR_RD_BUF_SIZE
-len
,
2823 "%05x: %08x\n", offset_run
, u32val
);
2827 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
2831 /* Browse all PCI bar space registers */
2832 offset_label
= idiag
.offset
.last_rd
;
2833 offset_run
= offset_label
;
2835 /* Read PCI bar memory mapped space */
2836 len
+= snprintf(pbuffer
+len
, LPFC_PCI_BAR_RD_BUF_SIZE
-len
,
2837 "%05x: ", offset_label
);
2838 index
= LPFC_PCI_BAR_RD_SIZE
;
2840 u32val
= readl(mem_mapped_bar
+ offset_run
);
2841 len
+= snprintf(pbuffer
+len
, LPFC_PCI_BAR_RD_BUF_SIZE
-len
,
2843 offset_run
+= sizeof(uint32_t);
2844 if (acc_range
== LPFC_PCI_BAR_BROWSE
) {
2845 if (offset_run
>= bar_size
) {
2846 len
+= snprintf(pbuffer
+len
,
2847 LPFC_PCI_BAR_RD_BUF_SIZE
-len
, "\n");
2851 if (offset_run
>= offset
+
2852 (acc_range
* sizeof(uint32_t))) {
2853 len
+= snprintf(pbuffer
+len
,
2854 LPFC_PCI_BAR_RD_BUF_SIZE
-len
, "\n");
2858 index
-= sizeof(uint32_t);
2860 len
+= snprintf(pbuffer
+len
,
2861 LPFC_PCI_BAR_RD_BUF_SIZE
-len
, "\n");
2862 else if (!(index
% (8 * sizeof(uint32_t)))) {
2863 offset_label
+= (8 * sizeof(uint32_t));
2864 len
+= snprintf(pbuffer
+len
,
2865 LPFC_PCI_BAR_RD_BUF_SIZE
-len
,
2866 "\n%05x: ", offset_label
);
2870 /* Set up the offset for next portion of pci bar read */
2872 idiag
.offset
.last_rd
+= LPFC_PCI_BAR_RD_SIZE
;
2873 if (acc_range
== LPFC_PCI_BAR_BROWSE
) {
2874 if (idiag
.offset
.last_rd
>= bar_size
)
2875 idiag
.offset
.last_rd
= 0;
2877 if (offset_run
>= offset
+
2878 (acc_range
* sizeof(uint32_t)))
2879 idiag
.offset
.last_rd
= offset
;
2882 if (acc_range
== LPFC_PCI_BAR_BROWSE
)
2883 idiag
.offset
.last_rd
= 0;
2885 idiag
.offset
.last_rd
= offset
;
2888 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
2892 * lpfc_idiag_baracc_write - Syntax check and set up idiag bar access commands
2893 * @file: The file pointer to read from.
2894 * @buf: The buffer to copy the user data from.
2895 * @nbytes: The number of bytes to get.
2896 * @ppos: The position in the file to start reading from.
2898 * This routine get the debugfs idiag command struct from user space and
2899 * then perform the syntax check for PCI bar memory mapped space read or
2900 * write command accordingly. In the case of PCI bar memory mapped space
2901 * read command, it sets up the command in the idiag command struct for
2902 * the debugfs read operation. In the case of PCI bar memorpy mapped space
2903 * write operation, it executes the write operation into the PCI bar memory
2904 * mapped space accordingly.
2906 * It returns the @nbytges passing in from debugfs user space when successful.
2907 * In case of error conditions, it returns proper error code back to the user
2911 lpfc_idiag_baracc_write(struct file
*file
, const char __user
*buf
,
2912 size_t nbytes
, loff_t
*ppos
)
2914 struct lpfc_debug
*debug
= file
->private_data
;
2915 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
2916 uint32_t bar_num
, bar_size
, offset
, value
, acc_range
;
2917 struct pci_dev
*pdev
;
2918 void __iomem
*mem_mapped_bar
;
2923 pdev
= phba
->pcidev
;
2927 /* This is a user write operation */
2928 debug
->op
= LPFC_IDIAG_OP_WR
;
2930 rc
= lpfc_idiag_cmd_get(buf
, nbytes
, &idiag
.cmd
);
2934 if_type
= bf_get(lpfc_sli_intf_if_type
, &phba
->sli4_hba
.sli_intf
);
2935 bar_num
= idiag
.cmd
.data
[IDIAG_BARACC_BAR_NUM_INDX
];
2937 if (if_type
== LPFC_SLI_INTF_IF_TYPE_0
) {
2938 if ((bar_num
!= IDIAG_BARACC_BAR_0
) &&
2939 (bar_num
!= IDIAG_BARACC_BAR_1
) &&
2940 (bar_num
!= IDIAG_BARACC_BAR_2
))
2942 } else if (if_type
== LPFC_SLI_INTF_IF_TYPE_2
) {
2943 if (bar_num
!= IDIAG_BARACC_BAR_0
)
2948 if (if_type
== LPFC_SLI_INTF_IF_TYPE_0
) {
2949 if (bar_num
== IDIAG_BARACC_BAR_0
) {
2950 idiag
.cmd
.data
[IDIAG_BARACC_BAR_SZE_INDX
] =
2951 LPFC_PCI_IF0_BAR0_SIZE
;
2952 mem_mapped_bar
= phba
->sli4_hba
.conf_regs_memmap_p
;
2953 } else if (bar_num
== IDIAG_BARACC_BAR_1
) {
2954 idiag
.cmd
.data
[IDIAG_BARACC_BAR_SZE_INDX
] =
2955 LPFC_PCI_IF0_BAR1_SIZE
;
2956 mem_mapped_bar
= phba
->sli4_hba
.ctrl_regs_memmap_p
;
2957 } else if (bar_num
== IDIAG_BARACC_BAR_2
) {
2958 idiag
.cmd
.data
[IDIAG_BARACC_BAR_SZE_INDX
] =
2959 LPFC_PCI_IF0_BAR2_SIZE
;
2960 mem_mapped_bar
= phba
->sli4_hba
.drbl_regs_memmap_p
;
2963 } else if (if_type
== LPFC_SLI_INTF_IF_TYPE_2
) {
2964 if (bar_num
== IDIAG_BARACC_BAR_0
) {
2965 idiag
.cmd
.data
[IDIAG_BARACC_BAR_SZE_INDX
] =
2966 LPFC_PCI_IF2_BAR0_SIZE
;
2967 mem_mapped_bar
= phba
->sli4_hba
.conf_regs_memmap_p
;
2973 offset
= idiag
.cmd
.data
[IDIAG_BARACC_OFF_SET_INDX
];
2974 if (offset
% sizeof(uint32_t))
2977 bar_size
= idiag
.cmd
.data
[IDIAG_BARACC_BAR_SZE_INDX
];
2978 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_RD
) {
2979 /* Sanity check on PCI config read command line arguments */
2980 if (rc
!= LPFC_PCI_BAR_RD_CMD_ARG
)
2982 acc_range
= idiag
.cmd
.data
[IDIAG_BARACC_ACC_MOD_INDX
];
2983 if (acc_range
== LPFC_PCI_BAR_BROWSE
) {
2984 if (offset
> bar_size
- sizeof(uint32_t))
2986 /* Starting offset to browse */
2987 idiag
.offset
.last_rd
= offset
;
2988 } else if (acc_range
> SINGLE_WORD
) {
2989 if (offset
+ acc_range
* sizeof(uint32_t) > bar_size
)
2991 /* Starting offset to browse */
2992 idiag
.offset
.last_rd
= offset
;
2993 } else if (acc_range
!= SINGLE_WORD
)
2995 } else if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_WR
||
2996 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_ST
||
2997 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_CL
) {
2998 /* Sanity check on PCI bar write command line arguments */
2999 if (rc
!= LPFC_PCI_BAR_WR_CMD_ARG
)
3001 /* Write command to PCI bar space, read-modify-write */
3002 acc_range
= SINGLE_WORD
;
3003 value
= idiag
.cmd
.data
[IDIAG_BARACC_REG_VAL_INDX
];
3004 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_WR
) {
3005 writel(value
, mem_mapped_bar
+ offset
);
3006 readl(mem_mapped_bar
+ offset
);
3008 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_ST
) {
3009 u32val
= readl(mem_mapped_bar
+ offset
);
3011 writel(u32val
, mem_mapped_bar
+ offset
);
3012 readl(mem_mapped_bar
+ offset
);
3014 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_CL
) {
3015 u32val
= readl(mem_mapped_bar
+ offset
);
3017 writel(u32val
, mem_mapped_bar
+ offset
);
3018 readl(mem_mapped_bar
+ offset
);
3021 /* All other opecodes are illegal for now */
3026 memset(&idiag
, 0, sizeof(idiag
));
3031 __lpfc_idiag_print_wq(struct lpfc_queue
*qp
, char *wqtype
,
3032 char *pbuffer
, int len
)
3037 len
+= snprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3038 "\t\t%s WQ info: ", wqtype
);
3039 len
+= snprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3040 "AssocCQID[%04d]: WQ-STAT[oflow:x%x posted:x%llx]\n",
3041 qp
->assoc_qid
, qp
->q_cnt_1
,
3042 (unsigned long long)qp
->q_cnt_4
);
3043 len
+= snprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3044 "\t\tWQID[%02d], QE-CNT[%04d], QE-SIZE[%04d], "
3045 "HOST-IDX[%04d], PORT-IDX[%04d]",
3046 qp
->queue_id
, qp
->entry_count
,
3047 qp
->entry_size
, qp
->host_index
,
3049 len
+= snprintf(pbuffer
+ len
,
3050 LPFC_QUE_INFO_GET_BUF_SIZE
- len
, "\n");
3055 lpfc_idiag_wqs_for_cq(struct lpfc_hba
*phba
, char *wqtype
, char *pbuffer
,
3056 int *len
, int max_cnt
, int cq_id
)
3058 struct lpfc_queue
*qp
;
3061 for (qidx
= 0; qidx
< phba
->cfg_fcp_io_channel
; qidx
++) {
3062 qp
= phba
->sli4_hba
.fcp_wq
[qidx
];
3063 if (qp
->assoc_qid
!= cq_id
)
3065 *len
= __lpfc_idiag_print_wq(qp
, wqtype
, pbuffer
, *len
);
3066 if (*len
>= max_cnt
)
3069 for (qidx
= 0; qidx
< phba
->cfg_nvme_io_channel
; qidx
++) {
3070 qp
= phba
->sli4_hba
.nvme_wq
[qidx
];
3071 if (qp
->assoc_qid
!= cq_id
)
3073 *len
= __lpfc_idiag_print_wq(qp
, wqtype
, pbuffer
, *len
);
3074 if (*len
>= max_cnt
)
3081 __lpfc_idiag_print_cq(struct lpfc_queue
*qp
, char *cqtype
,
3082 char *pbuffer
, int len
)
3087 len
+= snprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3088 "\t%s CQ info: ", cqtype
);
3089 len
+= snprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3090 "AssocEQID[%02d]: CQ STAT[max:x%x relw:x%x "
3091 "xabt:x%x wq:x%llx]\n",
3092 qp
->assoc_qid
, qp
->q_cnt_1
, qp
->q_cnt_2
,
3093 qp
->q_cnt_3
, (unsigned long long)qp
->q_cnt_4
);
3094 len
+= snprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3095 "\tCQID[%02d], QE-CNT[%04d], QE-SIZE[%04d], "
3096 "HOST-IDX[%04d], PORT-IDX[%04d]",
3097 qp
->queue_id
, qp
->entry_count
,
3098 qp
->entry_size
, qp
->host_index
,
3101 len
+= snprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
, "\n");
3107 __lpfc_idiag_print_rqpair(struct lpfc_queue
*qp
, struct lpfc_queue
*datqp
,
3108 char *rqtype
, char *pbuffer
, int len
)
3113 len
+= snprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3114 "\t\t%s RQ info: ", rqtype
);
3115 len
+= snprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3116 "AssocCQID[%02d]: RQ-STAT[nopost:x%x nobuf:x%x "
3117 "trunc:x%x rcv:x%llx]\n",
3118 qp
->assoc_qid
, qp
->q_cnt_1
, qp
->q_cnt_2
,
3119 qp
->q_cnt_3
, (unsigned long long)qp
->q_cnt_4
);
3120 len
+= snprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3121 "\t\tHQID[%02d], QE-CNT[%04d], QE-SIZE[%04d], "
3122 "HOST-IDX[%04d], PORT-IDX[%04d]\n",
3123 qp
->queue_id
, qp
->entry_count
, qp
->entry_size
,
3124 qp
->host_index
, qp
->hba_index
);
3125 len
+= snprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3126 "\t\tDQID[%02d], QE-CNT[%04d], QE-SIZE[%04d], "
3127 "HOST-IDX[%04d], PORT-IDX[%04d]\n",
3128 datqp
->queue_id
, datqp
->entry_count
,
3129 datqp
->entry_size
, datqp
->host_index
,
3131 len
+= snprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
, "\n");
3137 lpfc_idiag_cqs_for_eq(struct lpfc_hba
*phba
, char *pbuffer
,
3138 int *len
, int max_cnt
, int eqidx
, int eq_id
)
3140 struct lpfc_queue
*qp
;
3143 for (qidx
= 0; qidx
< phba
->cfg_fcp_io_channel
; qidx
++) {
3144 qp
= phba
->sli4_hba
.fcp_cq
[qidx
];
3145 if (qp
->assoc_qid
!= eq_id
)
3148 *len
= __lpfc_idiag_print_cq(qp
, "FCP", pbuffer
, *len
);
3150 /* Reset max counter */
3153 if (*len
>= max_cnt
)
3156 rc
= lpfc_idiag_wqs_for_cq(phba
, "FCP", pbuffer
, len
,
3157 max_cnt
, qp
->queue_id
);
3162 for (qidx
= 0; qidx
< phba
->cfg_nvme_io_channel
; qidx
++) {
3163 qp
= phba
->sli4_hba
.nvme_cq
[qidx
];
3164 if (qp
->assoc_qid
!= eq_id
)
3167 *len
= __lpfc_idiag_print_cq(qp
, "NVME", pbuffer
, *len
);
3169 /* Reset max counter */
3172 if (*len
>= max_cnt
)
3175 rc
= lpfc_idiag_wqs_for_cq(phba
, "NVME", pbuffer
, len
,
3176 max_cnt
, qp
->queue_id
);
3181 if (eqidx
< phba
->cfg_nvmet_mrq
) {
3183 qp
= phba
->sli4_hba
.nvmet_cqset
[eqidx
];
3184 *len
= __lpfc_idiag_print_cq(qp
, "NVMET CQset", pbuffer
, *len
);
3186 /* Reset max counter */
3189 if (*len
>= max_cnt
)
3193 qp
= phba
->sli4_hba
.nvmet_mrq_hdr
[eqidx
];
3194 *len
= __lpfc_idiag_print_rqpair(qp
,
3195 phba
->sli4_hba
.nvmet_mrq_data
[eqidx
],
3196 "NVMET MRQ", pbuffer
, *len
);
3198 if (*len
>= max_cnt
)
3206 __lpfc_idiag_print_eq(struct lpfc_queue
*qp
, char *eqtype
,
3207 char *pbuffer
, int len
)
3212 len
+= snprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3213 "\n%s EQ info: EQ-STAT[max:x%x noE:x%x "
3214 "bs:x%x proc:x%llx]\n",
3215 eqtype
, qp
->q_cnt_1
, qp
->q_cnt_2
, qp
->q_cnt_3
,
3216 (unsigned long long)qp
->q_cnt_4
);
3217 len
+= snprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3218 "EQID[%02d], QE-CNT[%04d], QE-SIZE[%04d], "
3219 "HOST-IDX[%04d], PORT-IDX[%04d]",
3220 qp
->queue_id
, qp
->entry_count
, qp
->entry_size
,
3221 qp
->host_index
, qp
->hba_index
);
3222 len
+= snprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
, "\n");
3228 * lpfc_idiag_queinfo_read - idiag debugfs read queue information
3229 * @file: The file pointer to read from.
3230 * @buf: The buffer to copy the data to.
3231 * @nbytes: The number of bytes to read.
3232 * @ppos: The position in the file to start reading from.
3235 * This routine reads data from the @phba SLI4 PCI function queue information,
3236 * and copies to user @buf.
3237 * This routine only returns 1 EQs worth of information. It remembers the last
3238 * EQ read and jumps to the next EQ. Thus subsequent calls to queInfo will
3239 * retrieve all EQs allocated for the phba.
3242 * This function returns the amount of data that was read (this could be less
3243 * than @nbytes if the end of the file was reached) or a negative error value.
3246 lpfc_idiag_queinfo_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
3249 struct lpfc_debug
*debug
= file
->private_data
;
3250 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
3252 int max_cnt
, rc
, x
, len
= 0;
3253 struct lpfc_queue
*qp
= NULL
;
3256 debug
->buffer
= kmalloc(LPFC_QUE_INFO_GET_BUF_SIZE
, GFP_KERNEL
);
3259 pbuffer
= debug
->buffer
;
3260 max_cnt
= LPFC_QUE_INFO_GET_BUF_SIZE
- 256;
3265 spin_lock_irq(&phba
->hbalock
);
3267 /* Fast-path event queue */
3268 if (phba
->sli4_hba
.hba_eq
&& phba
->io_channel_irqs
) {
3270 x
= phba
->lpfc_idiag_last_eq
;
3271 if (phba
->cfg_fof
&& (x
>= phba
->io_channel_irqs
)) {
3272 phba
->lpfc_idiag_last_eq
= 0;
3275 phba
->lpfc_idiag_last_eq
++;
3276 if (phba
->lpfc_idiag_last_eq
>= phba
->io_channel_irqs
)
3277 if (phba
->cfg_fof
== 0)
3278 phba
->lpfc_idiag_last_eq
= 0;
3280 len
+= snprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3281 "EQ %d out of %d HBA EQs\n",
3282 x
, phba
->io_channel_irqs
);
3285 qp
= phba
->sli4_hba
.hba_eq
[x
];
3289 len
= __lpfc_idiag_print_eq(qp
, "HBA", pbuffer
, len
);
3291 /* Reset max counter */
3297 /* will dump both fcp and nvme cqs/wqs for the eq */
3298 rc
= lpfc_idiag_cqs_for_eq(phba
, pbuffer
, &len
,
3299 max_cnt
, x
, qp
->queue_id
);
3303 /* Only EQ 0 has slow path CQs configured */
3307 /* Slow-path mailbox CQ */
3308 qp
= phba
->sli4_hba
.mbx_cq
;
3309 len
= __lpfc_idiag_print_cq(qp
, "MBX", pbuffer
, len
);
3313 /* Slow-path MBOX MQ */
3314 qp
= phba
->sli4_hba
.mbx_wq
;
3315 len
= __lpfc_idiag_print_wq(qp
, "MBX", pbuffer
, len
);
3319 /* Slow-path ELS response CQ */
3320 qp
= phba
->sli4_hba
.els_cq
;
3321 len
= __lpfc_idiag_print_cq(qp
, "ELS", pbuffer
, len
);
3322 /* Reset max counter */
3328 /* Slow-path ELS WQ */
3329 qp
= phba
->sli4_hba
.els_wq
;
3330 len
= __lpfc_idiag_print_wq(qp
, "ELS", pbuffer
, len
);
3334 /* Slow-path NVME LS response CQ */
3335 qp
= phba
->sli4_hba
.nvmels_cq
;
3336 len
= __lpfc_idiag_print_cq(qp
, "NVME LS",
3338 /* Reset max counter */
3344 /* Slow-path NVME LS WQ */
3345 qp
= phba
->sli4_hba
.nvmels_wq
;
3346 len
= __lpfc_idiag_print_wq(qp
, "NVME LS",
3351 qp
= phba
->sli4_hba
.hdr_rq
;
3352 len
= __lpfc_idiag_print_rqpair(qp
, phba
->sli4_hba
.dat_rq
,
3353 "RQpair", pbuffer
, len
);
3361 if (phba
->cfg_fof
) {
3363 qp
= phba
->sli4_hba
.fof_eq
;
3364 len
= __lpfc_idiag_print_eq(qp
, "FOF", pbuffer
, len
);
3366 /* Reset max counter */
3374 qp
= phba
->sli4_hba
.oas_cq
;
3375 len
= __lpfc_idiag_print_cq(qp
, "OAS", pbuffer
, len
);
3376 /* Reset max counter */
3383 qp
= phba
->sli4_hba
.oas_wq
;
3384 len
= __lpfc_idiag_print_wq(qp
, "OAS", pbuffer
, len
);
3389 spin_unlock_irq(&phba
->hbalock
);
3390 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
3393 len
+= snprintf(pbuffer
+ len
,
3394 LPFC_QUE_INFO_GET_BUF_SIZE
- len
, "Truncated ...\n");
3396 spin_unlock_irq(&phba
->hbalock
);
3397 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
3401 * lpfc_idiag_que_param_check - queue access command parameter sanity check
3402 * @q: The pointer to queue structure.
3403 * @index: The index into a queue entry.
3404 * @count: The number of queue entries to access.
3407 * The routine performs sanity check on device queue access method commands.
3410 * This function returns -EINVAL when fails the sanity check, otherwise, it
3414 lpfc_idiag_que_param_check(struct lpfc_queue
*q
, int index
, int count
)
3416 /* Only support single entry read or browsing */
3417 if ((count
!= 1) && (count
!= LPFC_QUE_ACC_BROWSE
))
3419 if (index
> q
->entry_count
- 1)
3425 * lpfc_idiag_queacc_read_qe - read a single entry from the given queue index
3426 * @pbuffer: The pointer to buffer to copy the read data into.
3427 * @pque: The pointer to the queue to be read.
3428 * @index: The index into the queue entry.
3431 * This routine reads out a single entry from the given queue's index location
3432 * and copies it into the buffer provided.
3435 * This function returns 0 when it fails, otherwise, it returns the length of
3436 * the data read into the buffer provided.
3439 lpfc_idiag_queacc_read_qe(char *pbuffer
, int len
, struct lpfc_queue
*pque
,
3445 if (!pbuffer
|| !pque
)
3448 esize
= pque
->entry_size
;
3449 len
+= snprintf(pbuffer
+len
, LPFC_QUE_ACC_BUF_SIZE
-len
,
3450 "QE-INDEX[%04d]:\n", index
);
3453 pentry
= pque
->qe
[index
].address
;
3455 len
+= snprintf(pbuffer
+len
, LPFC_QUE_ACC_BUF_SIZE
-len
,
3458 offset
+= sizeof(uint32_t);
3459 esize
-= sizeof(uint32_t);
3460 if (esize
> 0 && !(offset
% (4 * sizeof(uint32_t))))
3461 len
+= snprintf(pbuffer
+len
,
3462 LPFC_QUE_ACC_BUF_SIZE
-len
, "\n");
3464 len
+= snprintf(pbuffer
+len
, LPFC_QUE_ACC_BUF_SIZE
-len
, "\n");
3470 * lpfc_idiag_queacc_read - idiag debugfs read port queue
3471 * @file: The file pointer to read from.
3472 * @buf: The buffer to copy the data to.
3473 * @nbytes: The number of bytes to read.
3474 * @ppos: The position in the file to start reading from.
3477 * This routine reads data from the @phba device queue memory according to the
3478 * idiag command, and copies to user @buf. Depending on the queue dump read
3479 * command setup, it does either a single queue entry read or browing through
3480 * all entries of the queue.
3483 * This function returns the amount of data that was read (this could be less
3484 * than @nbytes if the end of the file was reached) or a negative error value.
3487 lpfc_idiag_queacc_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
3490 struct lpfc_debug
*debug
= file
->private_data
;
3491 uint32_t last_index
, index
, count
;
3492 struct lpfc_queue
*pque
= NULL
;
3496 /* This is a user read operation */
3497 debug
->op
= LPFC_IDIAG_OP_RD
;
3500 debug
->buffer
= kmalloc(LPFC_QUE_ACC_BUF_SIZE
, GFP_KERNEL
);
3503 pbuffer
= debug
->buffer
;
3508 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_RD
) {
3509 index
= idiag
.cmd
.data
[IDIAG_QUEACC_INDEX_INDX
];
3510 count
= idiag
.cmd
.data
[IDIAG_QUEACC_COUNT_INDX
];
3511 pque
= (struct lpfc_queue
*)idiag
.ptr_private
;
3515 /* Browse the queue starting from index */
3516 if (count
== LPFC_QUE_ACC_BROWSE
)
3519 /* Read a single entry from the queue */
3520 len
= lpfc_idiag_queacc_read_qe(pbuffer
, len
, pque
, index
);
3522 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
3526 /* Browse all entries from the queue */
3527 last_index
= idiag
.offset
.last_rd
;
3530 while (len
< LPFC_QUE_ACC_SIZE
- pque
->entry_size
) {
3531 len
= lpfc_idiag_queacc_read_qe(pbuffer
, len
, pque
, index
);
3533 if (index
> pque
->entry_count
- 1)
3537 /* Set up the offset for next portion of pci cfg read */
3538 if (index
> pque
->entry_count
- 1)
3540 idiag
.offset
.last_rd
= index
;
3542 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
3546 * lpfc_idiag_queacc_write - Syntax check and set up idiag queacc commands
3547 * @file: The file pointer to read from.
3548 * @buf: The buffer to copy the user data from.
3549 * @nbytes: The number of bytes to get.
3550 * @ppos: The position in the file to start reading from.
3552 * This routine get the debugfs idiag command struct from user space and then
3553 * perform the syntax check for port queue read (dump) or write (set) command
3554 * accordingly. In the case of port queue read command, it sets up the command
3555 * in the idiag command struct for the following debugfs read operation. In
3556 * the case of port queue write operation, it executes the write operation
3557 * into the port queue entry accordingly.
3559 * It returns the @nbytges passing in from debugfs user space when successful.
3560 * In case of error conditions, it returns proper error code back to the user
3564 lpfc_idiag_queacc_write(struct file
*file
, const char __user
*buf
,
3565 size_t nbytes
, loff_t
*ppos
)
3567 struct lpfc_debug
*debug
= file
->private_data
;
3568 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
3569 uint32_t qidx
, quetp
, queid
, index
, count
, offset
, value
;
3571 struct lpfc_queue
*pque
, *qp
;
3574 /* This is a user write operation */
3575 debug
->op
= LPFC_IDIAG_OP_WR
;
3577 rc
= lpfc_idiag_cmd_get(buf
, nbytes
, &idiag
.cmd
);
3581 /* Get and sanity check on command feilds */
3582 quetp
= idiag
.cmd
.data
[IDIAG_QUEACC_QUETP_INDX
];
3583 queid
= idiag
.cmd
.data
[IDIAG_QUEACC_QUEID_INDX
];
3584 index
= idiag
.cmd
.data
[IDIAG_QUEACC_INDEX_INDX
];
3585 count
= idiag
.cmd
.data
[IDIAG_QUEACC_COUNT_INDX
];
3586 offset
= idiag
.cmd
.data
[IDIAG_QUEACC_OFFST_INDX
];
3587 value
= idiag
.cmd
.data
[IDIAG_QUEACC_VALUE_INDX
];
3589 /* Sanity check on command line arguments */
3590 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_WR
||
3591 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_ST
||
3592 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_CL
) {
3593 if (rc
!= LPFC_QUE_ACC_WR_CMD_ARG
)
3597 } else if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_RD
) {
3598 if (rc
!= LPFC_QUE_ACC_RD_CMD_ARG
)
3605 /* HBA event queue */
3606 if (phba
->sli4_hba
.hba_eq
) {
3607 for (qidx
= 0; qidx
< phba
->io_channel_irqs
; qidx
++) {
3608 qp
= phba
->sli4_hba
.hba_eq
[qidx
];
3609 if (qp
&& qp
->queue_id
== queid
) {
3611 rc
= lpfc_idiag_que_param_check(qp
,
3615 idiag
.ptr_private
= qp
;
3623 /* MBX complete queue */
3624 if (phba
->sli4_hba
.mbx_cq
&&
3625 phba
->sli4_hba
.mbx_cq
->queue_id
== queid
) {
3627 rc
= lpfc_idiag_que_param_check(
3628 phba
->sli4_hba
.mbx_cq
, index
, count
);
3631 idiag
.ptr_private
= phba
->sli4_hba
.mbx_cq
;
3634 /* ELS complete queue */
3635 if (phba
->sli4_hba
.els_cq
&&
3636 phba
->sli4_hba
.els_cq
->queue_id
== queid
) {
3638 rc
= lpfc_idiag_que_param_check(
3639 phba
->sli4_hba
.els_cq
, index
, count
);
3642 idiag
.ptr_private
= phba
->sli4_hba
.els_cq
;
3645 /* NVME LS complete queue */
3646 if (phba
->sli4_hba
.nvmels_cq
&&
3647 phba
->sli4_hba
.nvmels_cq
->queue_id
== queid
) {
3649 rc
= lpfc_idiag_que_param_check(
3650 phba
->sli4_hba
.nvmels_cq
, index
, count
);
3653 idiag
.ptr_private
= phba
->sli4_hba
.nvmels_cq
;
3656 /* FCP complete queue */
3657 if (phba
->sli4_hba
.fcp_cq
) {
3658 for (qidx
= 0; qidx
< phba
->cfg_fcp_io_channel
;
3660 qp
= phba
->sli4_hba
.fcp_cq
[qidx
];
3661 if (qp
&& qp
->queue_id
== queid
) {
3663 rc
= lpfc_idiag_que_param_check(
3667 idiag
.ptr_private
= qp
;
3672 /* NVME complete queue */
3673 if (phba
->sli4_hba
.nvme_cq
) {
3676 if (phba
->sli4_hba
.nvme_cq
[qidx
] &&
3677 phba
->sli4_hba
.nvme_cq
[qidx
]->queue_id
==
3680 rc
= lpfc_idiag_que_param_check(
3681 phba
->sli4_hba
.nvme_cq
[qidx
],
3686 phba
->sli4_hba
.nvme_cq
[qidx
];
3689 } while (++qidx
< phba
->cfg_nvme_io_channel
);
3694 /* MBX work queue */
3695 if (phba
->sli4_hba
.mbx_wq
&&
3696 phba
->sli4_hba
.mbx_wq
->queue_id
== queid
) {
3698 rc
= lpfc_idiag_que_param_check(
3699 phba
->sli4_hba
.mbx_wq
, index
, count
);
3702 idiag
.ptr_private
= phba
->sli4_hba
.mbx_wq
;
3708 /* ELS work queue */
3709 if (phba
->sli4_hba
.els_wq
&&
3710 phba
->sli4_hba
.els_wq
->queue_id
== queid
) {
3712 rc
= lpfc_idiag_que_param_check(
3713 phba
->sli4_hba
.els_wq
, index
, count
);
3716 idiag
.ptr_private
= phba
->sli4_hba
.els_wq
;
3719 /* NVME LS work queue */
3720 if (phba
->sli4_hba
.nvmels_wq
&&
3721 phba
->sli4_hba
.nvmels_wq
->queue_id
== queid
) {
3723 rc
= lpfc_idiag_que_param_check(
3724 phba
->sli4_hba
.nvmels_wq
, index
, count
);
3727 idiag
.ptr_private
= phba
->sli4_hba
.nvmels_wq
;
3730 /* FCP work queue */
3731 if (phba
->sli4_hba
.fcp_wq
) {
3732 for (qidx
= 0; qidx
< phba
->cfg_fcp_io_channel
;
3734 qp
= phba
->sli4_hba
.fcp_wq
[qidx
];
3735 if (qp
&& qp
->queue_id
== queid
) {
3737 rc
= lpfc_idiag_que_param_check(
3741 idiag
.ptr_private
= qp
;
3746 /* NVME work queue */
3747 if (phba
->sli4_hba
.nvme_wq
) {
3748 for (qidx
= 0; qidx
< phba
->cfg_nvme_io_channel
;
3750 qp
= phba
->sli4_hba
.nvme_wq
[qidx
];
3751 if (qp
&& qp
->queue_id
== queid
) {
3753 rc
= lpfc_idiag_que_param_check(
3757 idiag
.ptr_private
= qp
;
3763 /* NVME work queues */
3764 if (phba
->sli4_hba
.nvme_wq
) {
3765 for (qidx
= 0; qidx
< phba
->cfg_nvme_io_channel
;
3767 if (!phba
->sli4_hba
.nvme_wq
[qidx
])
3769 if (phba
->sli4_hba
.nvme_wq
[qidx
]->queue_id
==
3772 rc
= lpfc_idiag_que_param_check(
3773 phba
->sli4_hba
.nvme_wq
[qidx
],
3778 phba
->sli4_hba
.nvme_wq
[qidx
];
3787 if (phba
->sli4_hba
.hdr_rq
&&
3788 phba
->sli4_hba
.hdr_rq
->queue_id
== queid
) {
3790 rc
= lpfc_idiag_que_param_check(
3791 phba
->sli4_hba
.hdr_rq
, index
, count
);
3794 idiag
.ptr_private
= phba
->sli4_hba
.hdr_rq
;
3798 if (phba
->sli4_hba
.dat_rq
&&
3799 phba
->sli4_hba
.dat_rq
->queue_id
== queid
) {
3801 rc
= lpfc_idiag_que_param_check(
3802 phba
->sli4_hba
.dat_rq
, index
, count
);
3805 idiag
.ptr_private
= phba
->sli4_hba
.dat_rq
;
3817 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_RD
) {
3818 if (count
== LPFC_QUE_ACC_BROWSE
)
3819 idiag
.offset
.last_rd
= index
;
3822 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_WR
||
3823 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_ST
||
3824 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_CL
) {
3825 /* Additional sanity checks on write operation */
3826 pque
= (struct lpfc_queue
*)idiag
.ptr_private
;
3827 if (offset
> pque
->entry_size
/sizeof(uint32_t) - 1)
3829 pentry
= pque
->qe
[index
].address
;
3831 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_WR
)
3833 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_ST
)
3835 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_CL
)
3841 /* Clean out command structure on command error out */
3842 memset(&idiag
, 0, sizeof(idiag
));
3847 * lpfc_idiag_drbacc_read_reg - idiag debugfs read a doorbell register
3848 * @phba: The pointer to hba structure.
3849 * @pbuffer: The pointer to the buffer to copy the data to.
3850 * @len: The lenght of bytes to copied.
3851 * @drbregid: The id to doorbell registers.
3854 * This routine reads a doorbell register and copies its content to the
3855 * user buffer pointed to by @pbuffer.
3858 * This function returns the amount of data that was copied into @pbuffer.
3861 lpfc_idiag_drbacc_read_reg(struct lpfc_hba
*phba
, char *pbuffer
,
3862 int len
, uint32_t drbregid
)
3870 len
+= snprintf(pbuffer
+len
, LPFC_DRB_ACC_BUF_SIZE
-len
,
3871 "EQCQ-DRB-REG: 0x%08x\n",
3872 readl(phba
->sli4_hba
.EQCQDBregaddr
));
3875 len
+= snprintf(pbuffer
+len
, LPFC_DRB_ACC_BUF_SIZE
-len
,
3876 "MQ-DRB-REG: 0x%08x\n",
3877 readl(phba
->sli4_hba
.MQDBregaddr
));
3880 len
+= snprintf(pbuffer
+len
, LPFC_DRB_ACC_BUF_SIZE
-len
,
3881 "WQ-DRB-REG: 0x%08x\n",
3882 readl(phba
->sli4_hba
.WQDBregaddr
));
3885 len
+= snprintf(pbuffer
+len
, LPFC_DRB_ACC_BUF_SIZE
-len
,
3886 "RQ-DRB-REG: 0x%08x\n",
3887 readl(phba
->sli4_hba
.RQDBregaddr
));
3897 * lpfc_idiag_drbacc_read - idiag debugfs read port doorbell
3898 * @file: The file pointer to read from.
3899 * @buf: The buffer to copy the data to.
3900 * @nbytes: The number of bytes to read.
3901 * @ppos: The position in the file to start reading from.
3904 * This routine reads data from the @phba device doorbell register according
3905 * to the idiag command, and copies to user @buf. Depending on the doorbell
3906 * register read command setup, it does either a single doorbell register
3907 * read or dump all doorbell registers.
3910 * This function returns the amount of data that was read (this could be less
3911 * than @nbytes if the end of the file was reached) or a negative error value.
3914 lpfc_idiag_drbacc_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
3917 struct lpfc_debug
*debug
= file
->private_data
;
3918 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
3919 uint32_t drb_reg_id
, i
;
3923 /* This is a user read operation */
3924 debug
->op
= LPFC_IDIAG_OP_RD
;
3927 debug
->buffer
= kmalloc(LPFC_DRB_ACC_BUF_SIZE
, GFP_KERNEL
);
3930 pbuffer
= debug
->buffer
;
3935 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_RD
)
3936 drb_reg_id
= idiag
.cmd
.data
[IDIAG_DRBACC_REGID_INDX
];
3940 if (drb_reg_id
== LPFC_DRB_ACC_ALL
)
3941 for (i
= 1; i
<= LPFC_DRB_MAX
; i
++)
3942 len
= lpfc_idiag_drbacc_read_reg(phba
,
3945 len
= lpfc_idiag_drbacc_read_reg(phba
,
3946 pbuffer
, len
, drb_reg_id
);
3948 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
3952 * lpfc_idiag_drbacc_write - Syntax check and set up idiag drbacc commands
3953 * @file: The file pointer to read from.
3954 * @buf: The buffer to copy the user data from.
3955 * @nbytes: The number of bytes to get.
3956 * @ppos: The position in the file to start reading from.
3958 * This routine get the debugfs idiag command struct from user space and then
3959 * perform the syntax check for port doorbell register read (dump) or write
3960 * (set) command accordingly. In the case of port queue read command, it sets
3961 * up the command in the idiag command struct for the following debugfs read
3962 * operation. In the case of port doorbell register write operation, it
3963 * executes the write operation into the port doorbell register accordingly.
3965 * It returns the @nbytges passing in from debugfs user space when successful.
3966 * In case of error conditions, it returns proper error code back to the user
3970 lpfc_idiag_drbacc_write(struct file
*file
, const char __user
*buf
,
3971 size_t nbytes
, loff_t
*ppos
)
3973 struct lpfc_debug
*debug
= file
->private_data
;
3974 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
3975 uint32_t drb_reg_id
, value
, reg_val
= 0;
3976 void __iomem
*drb_reg
;
3979 /* This is a user write operation */
3980 debug
->op
= LPFC_IDIAG_OP_WR
;
3982 rc
= lpfc_idiag_cmd_get(buf
, nbytes
, &idiag
.cmd
);
3986 /* Sanity check on command line arguments */
3987 drb_reg_id
= idiag
.cmd
.data
[IDIAG_DRBACC_REGID_INDX
];
3988 value
= idiag
.cmd
.data
[IDIAG_DRBACC_VALUE_INDX
];
3990 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_WR
||
3991 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_ST
||
3992 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_CL
) {
3993 if (rc
!= LPFC_DRB_ACC_WR_CMD_ARG
)
3995 if (drb_reg_id
> LPFC_DRB_MAX
)
3997 } else if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_RD
) {
3998 if (rc
!= LPFC_DRB_ACC_RD_CMD_ARG
)
4000 if ((drb_reg_id
> LPFC_DRB_MAX
) &&
4001 (drb_reg_id
!= LPFC_DRB_ACC_ALL
))
4006 /* Perform the write access operation */
4007 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_WR
||
4008 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_ST
||
4009 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_CL
) {
4010 switch (drb_reg_id
) {
4012 drb_reg
= phba
->sli4_hba
.EQCQDBregaddr
;
4015 drb_reg
= phba
->sli4_hba
.MQDBregaddr
;
4018 drb_reg
= phba
->sli4_hba
.WQDBregaddr
;
4021 drb_reg
= phba
->sli4_hba
.RQDBregaddr
;
4027 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_WR
)
4029 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_ST
) {
4030 reg_val
= readl(drb_reg
);
4033 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_CL
) {
4034 reg_val
= readl(drb_reg
);
4037 writel(reg_val
, drb_reg
);
4038 readl(drb_reg
); /* flush */
4043 /* Clean out command structure on command error out */
4044 memset(&idiag
, 0, sizeof(idiag
));
4049 * lpfc_idiag_ctlacc_read_reg - idiag debugfs read a control registers
4050 * @phba: The pointer to hba structure.
4051 * @pbuffer: The pointer to the buffer to copy the data to.
4052 * @len: The lenght of bytes to copied.
4053 * @drbregid: The id to doorbell registers.
4056 * This routine reads a control register and copies its content to the
4057 * user buffer pointed to by @pbuffer.
4060 * This function returns the amount of data that was copied into @pbuffer.
4063 lpfc_idiag_ctlacc_read_reg(struct lpfc_hba
*phba
, char *pbuffer
,
4064 int len
, uint32_t ctlregid
)
4071 case LPFC_CTL_PORT_SEM
:
4072 len
+= snprintf(pbuffer
+len
, LPFC_CTL_ACC_BUF_SIZE
-len
,
4073 "Port SemReg: 0x%08x\n",
4074 readl(phba
->sli4_hba
.conf_regs_memmap_p
+
4075 LPFC_CTL_PORT_SEM_OFFSET
));
4077 case LPFC_CTL_PORT_STA
:
4078 len
+= snprintf(pbuffer
+len
, LPFC_CTL_ACC_BUF_SIZE
-len
,
4079 "Port StaReg: 0x%08x\n",
4080 readl(phba
->sli4_hba
.conf_regs_memmap_p
+
4081 LPFC_CTL_PORT_STA_OFFSET
));
4083 case LPFC_CTL_PORT_CTL
:
4084 len
+= snprintf(pbuffer
+len
, LPFC_CTL_ACC_BUF_SIZE
-len
,
4085 "Port CtlReg: 0x%08x\n",
4086 readl(phba
->sli4_hba
.conf_regs_memmap_p
+
4087 LPFC_CTL_PORT_CTL_OFFSET
));
4089 case LPFC_CTL_PORT_ER1
:
4090 len
+= snprintf(pbuffer
+len
, LPFC_CTL_ACC_BUF_SIZE
-len
,
4091 "Port Er1Reg: 0x%08x\n",
4092 readl(phba
->sli4_hba
.conf_regs_memmap_p
+
4093 LPFC_CTL_PORT_ER1_OFFSET
));
4095 case LPFC_CTL_PORT_ER2
:
4096 len
+= snprintf(pbuffer
+len
, LPFC_CTL_ACC_BUF_SIZE
-len
,
4097 "Port Er2Reg: 0x%08x\n",
4098 readl(phba
->sli4_hba
.conf_regs_memmap_p
+
4099 LPFC_CTL_PORT_ER2_OFFSET
));
4101 case LPFC_CTL_PDEV_CTL
:
4102 len
+= snprintf(pbuffer
+len
, LPFC_CTL_ACC_BUF_SIZE
-len
,
4103 "PDev CtlReg: 0x%08x\n",
4104 readl(phba
->sli4_hba
.conf_regs_memmap_p
+
4105 LPFC_CTL_PDEV_CTL_OFFSET
));
4114 * lpfc_idiag_ctlacc_read - idiag debugfs read port and device control register
4115 * @file: The file pointer to read from.
4116 * @buf: The buffer to copy the data to.
4117 * @nbytes: The number of bytes to read.
4118 * @ppos: The position in the file to start reading from.
4121 * This routine reads data from the @phba port and device registers according
4122 * to the idiag command, and copies to user @buf.
4125 * This function returns the amount of data that was read (this could be less
4126 * than @nbytes if the end of the file was reached) or a negative error value.
4129 lpfc_idiag_ctlacc_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
4132 struct lpfc_debug
*debug
= file
->private_data
;
4133 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
4134 uint32_t ctl_reg_id
, i
;
4138 /* This is a user read operation */
4139 debug
->op
= LPFC_IDIAG_OP_RD
;
4142 debug
->buffer
= kmalloc(LPFC_CTL_ACC_BUF_SIZE
, GFP_KERNEL
);
4145 pbuffer
= debug
->buffer
;
4150 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_RD
)
4151 ctl_reg_id
= idiag
.cmd
.data
[IDIAG_CTLACC_REGID_INDX
];
4155 if (ctl_reg_id
== LPFC_CTL_ACC_ALL
)
4156 for (i
= 1; i
<= LPFC_CTL_MAX
; i
++)
4157 len
= lpfc_idiag_ctlacc_read_reg(phba
,
4160 len
= lpfc_idiag_ctlacc_read_reg(phba
,
4161 pbuffer
, len
, ctl_reg_id
);
4163 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
4167 * lpfc_idiag_ctlacc_write - Syntax check and set up idiag ctlacc commands
4168 * @file: The file pointer to read from.
4169 * @buf: The buffer to copy the user data from.
4170 * @nbytes: The number of bytes to get.
4171 * @ppos: The position in the file to start reading from.
4173 * This routine get the debugfs idiag command struct from user space and then
4174 * perform the syntax check for port and device control register read (dump)
4175 * or write (set) command accordingly.
4177 * It returns the @nbytges passing in from debugfs user space when successful.
4178 * In case of error conditions, it returns proper error code back to the user
4182 lpfc_idiag_ctlacc_write(struct file
*file
, const char __user
*buf
,
4183 size_t nbytes
, loff_t
*ppos
)
4185 struct lpfc_debug
*debug
= file
->private_data
;
4186 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
4187 uint32_t ctl_reg_id
, value
, reg_val
= 0;
4188 void __iomem
*ctl_reg
;
4191 /* This is a user write operation */
4192 debug
->op
= LPFC_IDIAG_OP_WR
;
4194 rc
= lpfc_idiag_cmd_get(buf
, nbytes
, &idiag
.cmd
);
4198 /* Sanity check on command line arguments */
4199 ctl_reg_id
= idiag
.cmd
.data
[IDIAG_CTLACC_REGID_INDX
];
4200 value
= idiag
.cmd
.data
[IDIAG_CTLACC_VALUE_INDX
];
4202 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_WR
||
4203 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_ST
||
4204 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_CL
) {
4205 if (rc
!= LPFC_CTL_ACC_WR_CMD_ARG
)
4207 if (ctl_reg_id
> LPFC_CTL_MAX
)
4209 } else if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_RD
) {
4210 if (rc
!= LPFC_CTL_ACC_RD_CMD_ARG
)
4212 if ((ctl_reg_id
> LPFC_CTL_MAX
) &&
4213 (ctl_reg_id
!= LPFC_CTL_ACC_ALL
))
4218 /* Perform the write access operation */
4219 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_WR
||
4220 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_ST
||
4221 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_CL
) {
4222 switch (ctl_reg_id
) {
4223 case LPFC_CTL_PORT_SEM
:
4224 ctl_reg
= phba
->sli4_hba
.conf_regs_memmap_p
+
4225 LPFC_CTL_PORT_SEM_OFFSET
;
4227 case LPFC_CTL_PORT_STA
:
4228 ctl_reg
= phba
->sli4_hba
.conf_regs_memmap_p
+
4229 LPFC_CTL_PORT_STA_OFFSET
;
4231 case LPFC_CTL_PORT_CTL
:
4232 ctl_reg
= phba
->sli4_hba
.conf_regs_memmap_p
+
4233 LPFC_CTL_PORT_CTL_OFFSET
;
4235 case LPFC_CTL_PORT_ER1
:
4236 ctl_reg
= phba
->sli4_hba
.conf_regs_memmap_p
+
4237 LPFC_CTL_PORT_ER1_OFFSET
;
4239 case LPFC_CTL_PORT_ER2
:
4240 ctl_reg
= phba
->sli4_hba
.conf_regs_memmap_p
+
4241 LPFC_CTL_PORT_ER2_OFFSET
;
4243 case LPFC_CTL_PDEV_CTL
:
4244 ctl_reg
= phba
->sli4_hba
.conf_regs_memmap_p
+
4245 LPFC_CTL_PDEV_CTL_OFFSET
;
4251 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_WR
)
4253 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_ST
) {
4254 reg_val
= readl(ctl_reg
);
4257 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_CL
) {
4258 reg_val
= readl(ctl_reg
);
4261 writel(reg_val
, ctl_reg
);
4262 readl(ctl_reg
); /* flush */
4267 /* Clean out command structure on command error out */
4268 memset(&idiag
, 0, sizeof(idiag
));
4273 * lpfc_idiag_mbxacc_get_setup - idiag debugfs get mailbox access setup
4274 * @phba: Pointer to HBA context object.
4275 * @pbuffer: Pointer to data buffer.
4278 * This routine gets the driver mailbox access debugfs setup information.
4281 * This function returns the amount of data that was read (this could be less
4282 * than @nbytes if the end of the file was reached) or a negative error value.
4285 lpfc_idiag_mbxacc_get_setup(struct lpfc_hba
*phba
, char *pbuffer
)
4287 uint32_t mbx_dump_map
, mbx_dump_cnt
, mbx_word_cnt
, mbx_mbox_cmd
;
4290 mbx_mbox_cmd
= idiag
.cmd
.data
[IDIAG_MBXACC_MBCMD_INDX
];
4291 mbx_dump_map
= idiag
.cmd
.data
[IDIAG_MBXACC_DPMAP_INDX
];
4292 mbx_dump_cnt
= idiag
.cmd
.data
[IDIAG_MBXACC_DPCNT_INDX
];
4293 mbx_word_cnt
= idiag
.cmd
.data
[IDIAG_MBXACC_WDCNT_INDX
];
4295 len
+= snprintf(pbuffer
+len
, LPFC_MBX_ACC_BUF_SIZE
-len
,
4296 "mbx_dump_map: 0x%08x\n", mbx_dump_map
);
4297 len
+= snprintf(pbuffer
+len
, LPFC_MBX_ACC_BUF_SIZE
-len
,
4298 "mbx_dump_cnt: %04d\n", mbx_dump_cnt
);
4299 len
+= snprintf(pbuffer
+len
, LPFC_MBX_ACC_BUF_SIZE
-len
,
4300 "mbx_word_cnt: %04d\n", mbx_word_cnt
);
4301 len
+= snprintf(pbuffer
+len
, LPFC_MBX_ACC_BUF_SIZE
-len
,
4302 "mbx_mbox_cmd: 0x%02x\n", mbx_mbox_cmd
);
4308 * lpfc_idiag_mbxacc_read - idiag debugfs read on mailbox access
4309 * @file: The file pointer to read from.
4310 * @buf: The buffer to copy the data to.
4311 * @nbytes: The number of bytes to read.
4312 * @ppos: The position in the file to start reading from.
4315 * This routine reads data from the @phba driver mailbox access debugfs setup
4319 * This function returns the amount of data that was read (this could be less
4320 * than @nbytes if the end of the file was reached) or a negative error value.
4323 lpfc_idiag_mbxacc_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
4326 struct lpfc_debug
*debug
= file
->private_data
;
4327 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
4331 /* This is a user read operation */
4332 debug
->op
= LPFC_IDIAG_OP_RD
;
4335 debug
->buffer
= kmalloc(LPFC_MBX_ACC_BUF_SIZE
, GFP_KERNEL
);
4338 pbuffer
= debug
->buffer
;
4343 if ((idiag
.cmd
.opcode
!= LPFC_IDIAG_CMD_MBXACC_DP
) &&
4344 (idiag
.cmd
.opcode
!= LPFC_IDIAG_BSG_MBXACC_DP
))
4347 len
= lpfc_idiag_mbxacc_get_setup(phba
, pbuffer
);
4349 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
4353 * lpfc_idiag_mbxacc_write - Syntax check and set up idiag mbxacc commands
4354 * @file: The file pointer to read from.
4355 * @buf: The buffer to copy the user data from.
4356 * @nbytes: The number of bytes to get.
4357 * @ppos: The position in the file to start reading from.
4359 * This routine get the debugfs idiag command struct from user space and then
4360 * perform the syntax check for driver mailbox command (dump) and sets up the
4361 * necessary states in the idiag command struct accordingly.
4363 * It returns the @nbytges passing in from debugfs user space when successful.
4364 * In case of error conditions, it returns proper error code back to the user
4368 lpfc_idiag_mbxacc_write(struct file
*file
, const char __user
*buf
,
4369 size_t nbytes
, loff_t
*ppos
)
4371 struct lpfc_debug
*debug
= file
->private_data
;
4372 uint32_t mbx_dump_map
, mbx_dump_cnt
, mbx_word_cnt
, mbx_mbox_cmd
;
4375 /* This is a user write operation */
4376 debug
->op
= LPFC_IDIAG_OP_WR
;
4378 rc
= lpfc_idiag_cmd_get(buf
, nbytes
, &idiag
.cmd
);
4382 /* Sanity check on command line arguments */
4383 mbx_mbox_cmd
= idiag
.cmd
.data
[IDIAG_MBXACC_MBCMD_INDX
];
4384 mbx_dump_map
= idiag
.cmd
.data
[IDIAG_MBXACC_DPMAP_INDX
];
4385 mbx_dump_cnt
= idiag
.cmd
.data
[IDIAG_MBXACC_DPCNT_INDX
];
4386 mbx_word_cnt
= idiag
.cmd
.data
[IDIAG_MBXACC_WDCNT_INDX
];
4388 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_MBXACC_DP
) {
4389 if (!(mbx_dump_map
& LPFC_MBX_DMP_MBX_ALL
))
4391 if ((mbx_dump_map
& ~LPFC_MBX_DMP_MBX_ALL
) &&
4392 (mbx_dump_map
!= LPFC_MBX_DMP_ALL
))
4394 if (mbx_word_cnt
> sizeof(MAILBOX_t
))
4396 } else if (idiag
.cmd
.opcode
== LPFC_IDIAG_BSG_MBXACC_DP
) {
4397 if (!(mbx_dump_map
& LPFC_BSG_DMP_MBX_ALL
))
4399 if ((mbx_dump_map
& ~LPFC_BSG_DMP_MBX_ALL
) &&
4400 (mbx_dump_map
!= LPFC_MBX_DMP_ALL
))
4402 if (mbx_word_cnt
> (BSG_MBOX_SIZE
)/4)
4404 if (mbx_mbox_cmd
!= 0x9b)
4409 if (mbx_word_cnt
== 0)
4411 if (rc
!= LPFC_MBX_DMP_ARG
)
4413 if (mbx_mbox_cmd
& ~0xff)
4416 /* condition for stop mailbox dump */
4417 if (mbx_dump_cnt
== 0)
4423 /* Clean out command structure on command error out */
4424 memset(&idiag
, 0, sizeof(idiag
));
4428 /* Clean out command structure on command error out */
4429 memset(&idiag
, 0, sizeof(idiag
));
4434 * lpfc_idiag_extacc_avail_get - get the available extents information
4435 * @phba: pointer to lpfc hba data structure.
4436 * @pbuffer: pointer to internal buffer.
4437 * @len: length into the internal buffer data has been copied.
4440 * This routine is to get the available extent information.
4443 * overall lenth of the data read into the internal buffer.
4446 lpfc_idiag_extacc_avail_get(struct lpfc_hba
*phba
, char *pbuffer
, int len
)
4448 uint16_t ext_cnt
, ext_size
;
4450 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4451 "\nAvailable Extents Information:\n");
4453 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4454 "\tPort Available VPI extents: ");
4455 lpfc_sli4_get_avail_extnt_rsrc(phba
, LPFC_RSC_TYPE_FCOE_VPI
,
4456 &ext_cnt
, &ext_size
);
4457 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4458 "Count %3d, Size %3d\n", ext_cnt
, ext_size
);
4460 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4461 "\tPort Available VFI extents: ");
4462 lpfc_sli4_get_avail_extnt_rsrc(phba
, LPFC_RSC_TYPE_FCOE_VFI
,
4463 &ext_cnt
, &ext_size
);
4464 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4465 "Count %3d, Size %3d\n", ext_cnt
, ext_size
);
4467 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4468 "\tPort Available RPI extents: ");
4469 lpfc_sli4_get_avail_extnt_rsrc(phba
, LPFC_RSC_TYPE_FCOE_RPI
,
4470 &ext_cnt
, &ext_size
);
4471 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4472 "Count %3d, Size %3d\n", ext_cnt
, ext_size
);
4474 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4475 "\tPort Available XRI extents: ");
4476 lpfc_sli4_get_avail_extnt_rsrc(phba
, LPFC_RSC_TYPE_FCOE_XRI
,
4477 &ext_cnt
, &ext_size
);
4478 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4479 "Count %3d, Size %3d\n", ext_cnt
, ext_size
);
4485 * lpfc_idiag_extacc_alloc_get - get the allocated extents information
4486 * @phba: pointer to lpfc hba data structure.
4487 * @pbuffer: pointer to internal buffer.
4488 * @len: length into the internal buffer data has been copied.
4491 * This routine is to get the allocated extent information.
4494 * overall lenth of the data read into the internal buffer.
4497 lpfc_idiag_extacc_alloc_get(struct lpfc_hba
*phba
, char *pbuffer
, int len
)
4499 uint16_t ext_cnt
, ext_size
;
4502 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4503 "\nAllocated Extents Information:\n");
4505 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4506 "\tHost Allocated VPI extents: ");
4507 rc
= lpfc_sli4_get_allocated_extnts(phba
, LPFC_RSC_TYPE_FCOE_VPI
,
4508 &ext_cnt
, &ext_size
);
4510 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4511 "Port %d Extent %3d, Size %3d\n",
4512 phba
->brd_no
, ext_cnt
, ext_size
);
4514 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4517 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4518 "\tHost Allocated VFI extents: ");
4519 rc
= lpfc_sli4_get_allocated_extnts(phba
, LPFC_RSC_TYPE_FCOE_VFI
,
4520 &ext_cnt
, &ext_size
);
4522 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4523 "Port %d Extent %3d, Size %3d\n",
4524 phba
->brd_no
, ext_cnt
, ext_size
);
4526 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4529 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4530 "\tHost Allocated RPI extents: ");
4531 rc
= lpfc_sli4_get_allocated_extnts(phba
, LPFC_RSC_TYPE_FCOE_RPI
,
4532 &ext_cnt
, &ext_size
);
4534 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4535 "Port %d Extent %3d, Size %3d\n",
4536 phba
->brd_no
, ext_cnt
, ext_size
);
4538 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4541 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4542 "\tHost Allocated XRI extents: ");
4543 rc
= lpfc_sli4_get_allocated_extnts(phba
, LPFC_RSC_TYPE_FCOE_XRI
,
4544 &ext_cnt
, &ext_size
);
4546 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4547 "Port %d Extent %3d, Size %3d\n",
4548 phba
->brd_no
, ext_cnt
, ext_size
);
4550 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4557 * lpfc_idiag_extacc_drivr_get - get driver extent information
4558 * @phba: pointer to lpfc hba data structure.
4559 * @pbuffer: pointer to internal buffer.
4560 * @len: length into the internal buffer data has been copied.
4563 * This routine is to get the driver extent information.
4566 * overall lenth of the data read into the internal buffer.
4569 lpfc_idiag_extacc_drivr_get(struct lpfc_hba
*phba
, char *pbuffer
, int len
)
4571 struct lpfc_rsrc_blks
*rsrc_blks
;
4574 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4575 "\nDriver Extents Information:\n");
4577 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4578 "\tVPI extents:\n");
4580 list_for_each_entry(rsrc_blks
, &phba
->lpfc_vpi_blk_list
, list
) {
4581 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4582 "\t\tBlock %3d: Start %4d, Count %4d\n",
4583 index
, rsrc_blks
->rsrc_start
,
4584 rsrc_blks
->rsrc_size
);
4587 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4588 "\tVFI extents:\n");
4590 list_for_each_entry(rsrc_blks
, &phba
->sli4_hba
.lpfc_vfi_blk_list
,
4592 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4593 "\t\tBlock %3d: Start %4d, Count %4d\n",
4594 index
, rsrc_blks
->rsrc_start
,
4595 rsrc_blks
->rsrc_size
);
4599 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4600 "\tRPI extents:\n");
4602 list_for_each_entry(rsrc_blks
, &phba
->sli4_hba
.lpfc_rpi_blk_list
,
4604 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4605 "\t\tBlock %3d: Start %4d, Count %4d\n",
4606 index
, rsrc_blks
->rsrc_start
,
4607 rsrc_blks
->rsrc_size
);
4611 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4612 "\tXRI extents:\n");
4614 list_for_each_entry(rsrc_blks
, &phba
->sli4_hba
.lpfc_xri_blk_list
,
4616 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4617 "\t\tBlock %3d: Start %4d, Count %4d\n",
4618 index
, rsrc_blks
->rsrc_start
,
4619 rsrc_blks
->rsrc_size
);
4627 * lpfc_idiag_extacc_write - Syntax check and set up idiag extacc commands
4628 * @file: The file pointer to read from.
4629 * @buf: The buffer to copy the user data from.
4630 * @nbytes: The number of bytes to get.
4631 * @ppos: The position in the file to start reading from.
4633 * This routine get the debugfs idiag command struct from user space and then
4634 * perform the syntax check for extent information access commands and sets
4635 * up the necessary states in the idiag command struct accordingly.
4637 * It returns the @nbytges passing in from debugfs user space when successful.
4638 * In case of error conditions, it returns proper error code back to the user
4642 lpfc_idiag_extacc_write(struct file
*file
, const char __user
*buf
,
4643 size_t nbytes
, loff_t
*ppos
)
4645 struct lpfc_debug
*debug
= file
->private_data
;
4649 /* This is a user write operation */
4650 debug
->op
= LPFC_IDIAG_OP_WR
;
4652 rc
= lpfc_idiag_cmd_get(buf
, nbytes
, &idiag
.cmd
);
4656 ext_map
= idiag
.cmd
.data
[IDIAG_EXTACC_EXMAP_INDX
];
4658 if (idiag
.cmd
.opcode
!= LPFC_IDIAG_CMD_EXTACC_RD
)
4660 if (rc
!= LPFC_EXT_ACC_CMD_ARG
)
4662 if (!(ext_map
& LPFC_EXT_ACC_ALL
))
4667 /* Clean out command structure on command error out */
4668 memset(&idiag
, 0, sizeof(idiag
));
4673 * lpfc_idiag_extacc_read - idiag debugfs read access to extent information
4674 * @file: The file pointer to read from.
4675 * @buf: The buffer to copy the data to.
4676 * @nbytes: The number of bytes to read.
4677 * @ppos: The position in the file to start reading from.
4680 * This routine reads data from the proper extent information according to
4681 * the idiag command, and copies to user @buf.
4684 * This function returns the amount of data that was read (this could be less
4685 * than @nbytes if the end of the file was reached) or a negative error value.
4688 lpfc_idiag_extacc_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
4691 struct lpfc_debug
*debug
= file
->private_data
;
4692 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
4697 /* This is a user read operation */
4698 debug
->op
= LPFC_IDIAG_OP_RD
;
4701 debug
->buffer
= kmalloc(LPFC_EXT_ACC_BUF_SIZE
, GFP_KERNEL
);
4704 pbuffer
= debug
->buffer
;
4707 if (idiag
.cmd
.opcode
!= LPFC_IDIAG_CMD_EXTACC_RD
)
4710 ext_map
= idiag
.cmd
.data
[IDIAG_EXTACC_EXMAP_INDX
];
4711 if (ext_map
& LPFC_EXT_ACC_AVAIL
)
4712 len
= lpfc_idiag_extacc_avail_get(phba
, pbuffer
, len
);
4713 if (ext_map
& LPFC_EXT_ACC_ALLOC
)
4714 len
= lpfc_idiag_extacc_alloc_get(phba
, pbuffer
, len
);
4715 if (ext_map
& LPFC_EXT_ACC_DRIVR
)
4716 len
= lpfc_idiag_extacc_drivr_get(phba
, pbuffer
, len
);
4718 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
4721 #undef lpfc_debugfs_op_disc_trc
4722 static const struct file_operations lpfc_debugfs_op_disc_trc
= {
4723 .owner
= THIS_MODULE
,
4724 .open
= lpfc_debugfs_disc_trc_open
,
4725 .llseek
= lpfc_debugfs_lseek
,
4726 .read
= lpfc_debugfs_read
,
4727 .release
= lpfc_debugfs_release
,
4730 #undef lpfc_debugfs_op_nodelist
4731 static const struct file_operations lpfc_debugfs_op_nodelist
= {
4732 .owner
= THIS_MODULE
,
4733 .open
= lpfc_debugfs_nodelist_open
,
4734 .llseek
= lpfc_debugfs_lseek
,
4735 .read
= lpfc_debugfs_read
,
4736 .release
= lpfc_debugfs_release
,
4739 #undef lpfc_debugfs_op_hbqinfo
4740 static const struct file_operations lpfc_debugfs_op_hbqinfo
= {
4741 .owner
= THIS_MODULE
,
4742 .open
= lpfc_debugfs_hbqinfo_open
,
4743 .llseek
= lpfc_debugfs_lseek
,
4744 .read
= lpfc_debugfs_read
,
4745 .release
= lpfc_debugfs_release
,
4748 #undef lpfc_debugfs_op_dumpHBASlim
4749 static const struct file_operations lpfc_debugfs_op_dumpHBASlim
= {
4750 .owner
= THIS_MODULE
,
4751 .open
= lpfc_debugfs_dumpHBASlim_open
,
4752 .llseek
= lpfc_debugfs_lseek
,
4753 .read
= lpfc_debugfs_read
,
4754 .release
= lpfc_debugfs_release
,
4757 #undef lpfc_debugfs_op_dumpHostSlim
4758 static const struct file_operations lpfc_debugfs_op_dumpHostSlim
= {
4759 .owner
= THIS_MODULE
,
4760 .open
= lpfc_debugfs_dumpHostSlim_open
,
4761 .llseek
= lpfc_debugfs_lseek
,
4762 .read
= lpfc_debugfs_read
,
4763 .release
= lpfc_debugfs_release
,
4766 #undef lpfc_debugfs_op_nvmestat
4767 static const struct file_operations lpfc_debugfs_op_nvmestat
= {
4768 .owner
= THIS_MODULE
,
4769 .open
= lpfc_debugfs_nvmestat_open
,
4770 .llseek
= lpfc_debugfs_lseek
,
4771 .read
= lpfc_debugfs_read
,
4772 .write
= lpfc_debugfs_nvmestat_write
,
4773 .release
= lpfc_debugfs_release
,
4776 #undef lpfc_debugfs_op_nvmektime
4777 static const struct file_operations lpfc_debugfs_op_nvmektime
= {
4778 .owner
= THIS_MODULE
,
4779 .open
= lpfc_debugfs_nvmektime_open
,
4780 .llseek
= lpfc_debugfs_lseek
,
4781 .read
= lpfc_debugfs_read
,
4782 .write
= lpfc_debugfs_nvmektime_write
,
4783 .release
= lpfc_debugfs_release
,
4786 #undef lpfc_debugfs_op_nvmeio_trc
4787 static const struct file_operations lpfc_debugfs_op_nvmeio_trc
= {
4788 .owner
= THIS_MODULE
,
4789 .open
= lpfc_debugfs_nvmeio_trc_open
,
4790 .llseek
= lpfc_debugfs_lseek
,
4791 .read
= lpfc_debugfs_read
,
4792 .write
= lpfc_debugfs_nvmeio_trc_write
,
4793 .release
= lpfc_debugfs_release
,
4796 #undef lpfc_debugfs_op_cpucheck
4797 static const struct file_operations lpfc_debugfs_op_cpucheck
= {
4798 .owner
= THIS_MODULE
,
4799 .open
= lpfc_debugfs_cpucheck_open
,
4800 .llseek
= lpfc_debugfs_lseek
,
4801 .read
= lpfc_debugfs_read
,
4802 .write
= lpfc_debugfs_cpucheck_write
,
4803 .release
= lpfc_debugfs_release
,
4806 #undef lpfc_debugfs_op_dumpData
4807 static const struct file_operations lpfc_debugfs_op_dumpData
= {
4808 .owner
= THIS_MODULE
,
4809 .open
= lpfc_debugfs_dumpData_open
,
4810 .llseek
= lpfc_debugfs_lseek
,
4811 .read
= lpfc_debugfs_read
,
4812 .write
= lpfc_debugfs_dumpDataDif_write
,
4813 .release
= lpfc_debugfs_dumpDataDif_release
,
4816 #undef lpfc_debugfs_op_dumpDif
4817 static const struct file_operations lpfc_debugfs_op_dumpDif
= {
4818 .owner
= THIS_MODULE
,
4819 .open
= lpfc_debugfs_dumpDif_open
,
4820 .llseek
= lpfc_debugfs_lseek
,
4821 .read
= lpfc_debugfs_read
,
4822 .write
= lpfc_debugfs_dumpDataDif_write
,
4823 .release
= lpfc_debugfs_dumpDataDif_release
,
4826 #undef lpfc_debugfs_op_dif_err
4827 static const struct file_operations lpfc_debugfs_op_dif_err
= {
4828 .owner
= THIS_MODULE
,
4829 .open
= simple_open
,
4830 .llseek
= lpfc_debugfs_lseek
,
4831 .read
= lpfc_debugfs_dif_err_read
,
4832 .write
= lpfc_debugfs_dif_err_write
,
4833 .release
= lpfc_debugfs_dif_err_release
,
4836 #undef lpfc_debugfs_op_slow_ring_trc
4837 static const struct file_operations lpfc_debugfs_op_slow_ring_trc
= {
4838 .owner
= THIS_MODULE
,
4839 .open
= lpfc_debugfs_slow_ring_trc_open
,
4840 .llseek
= lpfc_debugfs_lseek
,
4841 .read
= lpfc_debugfs_read
,
4842 .release
= lpfc_debugfs_release
,
4845 static struct dentry
*lpfc_debugfs_root
= NULL
;
4846 static atomic_t lpfc_debugfs_hba_count
;
4849 * File operations for the iDiag debugfs
4851 #undef lpfc_idiag_op_pciCfg
4852 static const struct file_operations lpfc_idiag_op_pciCfg
= {
4853 .owner
= THIS_MODULE
,
4854 .open
= lpfc_idiag_open
,
4855 .llseek
= lpfc_debugfs_lseek
,
4856 .read
= lpfc_idiag_pcicfg_read
,
4857 .write
= lpfc_idiag_pcicfg_write
,
4858 .release
= lpfc_idiag_cmd_release
,
4861 #undef lpfc_idiag_op_barAcc
4862 static const struct file_operations lpfc_idiag_op_barAcc
= {
4863 .owner
= THIS_MODULE
,
4864 .open
= lpfc_idiag_open
,
4865 .llseek
= lpfc_debugfs_lseek
,
4866 .read
= lpfc_idiag_baracc_read
,
4867 .write
= lpfc_idiag_baracc_write
,
4868 .release
= lpfc_idiag_cmd_release
,
4871 #undef lpfc_idiag_op_queInfo
4872 static const struct file_operations lpfc_idiag_op_queInfo
= {
4873 .owner
= THIS_MODULE
,
4874 .open
= lpfc_idiag_open
,
4875 .read
= lpfc_idiag_queinfo_read
,
4876 .release
= lpfc_idiag_release
,
4879 #undef lpfc_idiag_op_queAcc
4880 static const struct file_operations lpfc_idiag_op_queAcc
= {
4881 .owner
= THIS_MODULE
,
4882 .open
= lpfc_idiag_open
,
4883 .llseek
= lpfc_debugfs_lseek
,
4884 .read
= lpfc_idiag_queacc_read
,
4885 .write
= lpfc_idiag_queacc_write
,
4886 .release
= lpfc_idiag_cmd_release
,
4889 #undef lpfc_idiag_op_drbAcc
4890 static const struct file_operations lpfc_idiag_op_drbAcc
= {
4891 .owner
= THIS_MODULE
,
4892 .open
= lpfc_idiag_open
,
4893 .llseek
= lpfc_debugfs_lseek
,
4894 .read
= lpfc_idiag_drbacc_read
,
4895 .write
= lpfc_idiag_drbacc_write
,
4896 .release
= lpfc_idiag_cmd_release
,
4899 #undef lpfc_idiag_op_ctlAcc
4900 static const struct file_operations lpfc_idiag_op_ctlAcc
= {
4901 .owner
= THIS_MODULE
,
4902 .open
= lpfc_idiag_open
,
4903 .llseek
= lpfc_debugfs_lseek
,
4904 .read
= lpfc_idiag_ctlacc_read
,
4905 .write
= lpfc_idiag_ctlacc_write
,
4906 .release
= lpfc_idiag_cmd_release
,
4909 #undef lpfc_idiag_op_mbxAcc
4910 static const struct file_operations lpfc_idiag_op_mbxAcc
= {
4911 .owner
= THIS_MODULE
,
4912 .open
= lpfc_idiag_open
,
4913 .llseek
= lpfc_debugfs_lseek
,
4914 .read
= lpfc_idiag_mbxacc_read
,
4915 .write
= lpfc_idiag_mbxacc_write
,
4916 .release
= lpfc_idiag_cmd_release
,
4919 #undef lpfc_idiag_op_extAcc
4920 static const struct file_operations lpfc_idiag_op_extAcc
= {
4921 .owner
= THIS_MODULE
,
4922 .open
= lpfc_idiag_open
,
4923 .llseek
= lpfc_debugfs_lseek
,
4924 .read
= lpfc_idiag_extacc_read
,
4925 .write
= lpfc_idiag_extacc_write
,
4926 .release
= lpfc_idiag_cmd_release
,
4931 /* lpfc_idiag_mbxacc_dump_bsg_mbox - idiag debugfs dump bsg mailbox command
4932 * @phba: Pointer to HBA context object.
4933 * @dmabuf: Pointer to a DMA buffer descriptor.
4936 * This routine dump a bsg pass-through non-embedded mailbox command with
4940 lpfc_idiag_mbxacc_dump_bsg_mbox(struct lpfc_hba
*phba
, enum nemb_type nemb_tp
,
4941 enum mbox_type mbox_tp
, enum dma_type dma_tp
,
4942 enum sta_type sta_tp
,
4943 struct lpfc_dmabuf
*dmabuf
, uint32_t ext_buf
)
4945 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
4946 uint32_t *mbx_mbox_cmd
, *mbx_dump_map
, *mbx_dump_cnt
, *mbx_word_cnt
;
4947 char line_buf
[LPFC_MBX_ACC_LBUF_SZ
];
4949 uint32_t do_dump
= 0;
4953 if (idiag
.cmd
.opcode
!= LPFC_IDIAG_BSG_MBXACC_DP
)
4956 mbx_mbox_cmd
= &idiag
.cmd
.data
[IDIAG_MBXACC_MBCMD_INDX
];
4957 mbx_dump_map
= &idiag
.cmd
.data
[IDIAG_MBXACC_DPMAP_INDX
];
4958 mbx_dump_cnt
= &idiag
.cmd
.data
[IDIAG_MBXACC_DPCNT_INDX
];
4959 mbx_word_cnt
= &idiag
.cmd
.data
[IDIAG_MBXACC_WDCNT_INDX
];
4961 if (!(*mbx_dump_map
& LPFC_MBX_DMP_ALL
) ||
4962 (*mbx_dump_cnt
== 0) ||
4963 (*mbx_word_cnt
== 0))
4966 if (*mbx_mbox_cmd
!= 0x9B)
4969 if ((mbox_tp
== mbox_rd
) && (dma_tp
== dma_mbox
)) {
4970 if (*mbx_dump_map
& LPFC_BSG_DMP_MBX_RD_MBX
) {
4971 do_dump
|= LPFC_BSG_DMP_MBX_RD_MBX
;
4972 pr_err("\nRead mbox command (x%x), "
4973 "nemb:0x%x, extbuf_cnt:%d:\n",
4974 sta_tp
, nemb_tp
, ext_buf
);
4977 if ((mbox_tp
== mbox_rd
) && (dma_tp
== dma_ebuf
)) {
4978 if (*mbx_dump_map
& LPFC_BSG_DMP_MBX_RD_BUF
) {
4979 do_dump
|= LPFC_BSG_DMP_MBX_RD_BUF
;
4980 pr_err("\nRead mbox buffer (x%x), "
4981 "nemb:0x%x, extbuf_seq:%d:\n",
4982 sta_tp
, nemb_tp
, ext_buf
);
4985 if ((mbox_tp
== mbox_wr
) && (dma_tp
== dma_mbox
)) {
4986 if (*mbx_dump_map
& LPFC_BSG_DMP_MBX_WR_MBX
) {
4987 do_dump
|= LPFC_BSG_DMP_MBX_WR_MBX
;
4988 pr_err("\nWrite mbox command (x%x), "
4989 "nemb:0x%x, extbuf_cnt:%d:\n",
4990 sta_tp
, nemb_tp
, ext_buf
);
4993 if ((mbox_tp
== mbox_wr
) && (dma_tp
== dma_ebuf
)) {
4994 if (*mbx_dump_map
& LPFC_BSG_DMP_MBX_WR_BUF
) {
4995 do_dump
|= LPFC_BSG_DMP_MBX_WR_BUF
;
4996 pr_err("\nWrite mbox buffer (x%x), "
4997 "nemb:0x%x, extbuf_seq:%d:\n",
4998 sta_tp
, nemb_tp
, ext_buf
);
5002 /* dump buffer content */
5004 pword
= (uint32_t *)dmabuf
->virt
;
5005 for (i
= 0; i
< *mbx_word_cnt
; i
++) {
5008 pr_err("%s\n", line_buf
);
5010 len
+= snprintf(line_buf
+len
,
5011 LPFC_MBX_ACC_LBUF_SZ
-len
,
5014 len
+= snprintf(line_buf
+len
, LPFC_MBX_ACC_LBUF_SZ
-len
,
5015 "%08x ", (uint32_t)*pword
);
5019 pr_err("%s\n", line_buf
);
5023 /* Clean out command structure on reaching dump count */
5024 if (*mbx_dump_cnt
== 0)
5025 memset(&idiag
, 0, sizeof(idiag
));
5030 /* lpfc_idiag_mbxacc_dump_issue_mbox - idiag debugfs dump issue mailbox command
5031 * @phba: Pointer to HBA context object.
5032 * @dmabuf: Pointer to a DMA buffer descriptor.
5035 * This routine dump a pass-through non-embedded mailbox command from issue
5039 lpfc_idiag_mbxacc_dump_issue_mbox(struct lpfc_hba
*phba
, MAILBOX_t
*pmbox
)
5041 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
5042 uint32_t *mbx_dump_map
, *mbx_dump_cnt
, *mbx_word_cnt
, *mbx_mbox_cmd
;
5043 char line_buf
[LPFC_MBX_ACC_LBUF_SZ
];
5049 if (idiag
.cmd
.opcode
!= LPFC_IDIAG_CMD_MBXACC_DP
)
5052 mbx_mbox_cmd
= &idiag
.cmd
.data
[IDIAG_MBXACC_MBCMD_INDX
];
5053 mbx_dump_map
= &idiag
.cmd
.data
[IDIAG_MBXACC_DPMAP_INDX
];
5054 mbx_dump_cnt
= &idiag
.cmd
.data
[IDIAG_MBXACC_DPCNT_INDX
];
5055 mbx_word_cnt
= &idiag
.cmd
.data
[IDIAG_MBXACC_WDCNT_INDX
];
5057 if (!(*mbx_dump_map
& LPFC_MBX_DMP_MBX_ALL
) ||
5058 (*mbx_dump_cnt
== 0) ||
5059 (*mbx_word_cnt
== 0))
5062 if ((*mbx_mbox_cmd
!= LPFC_MBX_ALL_CMD
) &&
5063 (*mbx_mbox_cmd
!= pmbox
->mbxCommand
))
5066 /* dump buffer content */
5067 if (*mbx_dump_map
& LPFC_MBX_DMP_MBX_WORD
) {
5068 pr_err("Mailbox command:0x%x dump by word:\n",
5070 pword
= (uint32_t *)pmbox
;
5071 for (i
= 0; i
< *mbx_word_cnt
; i
++) {
5074 pr_err("%s\n", line_buf
);
5076 memset(line_buf
, 0, LPFC_MBX_ACC_LBUF_SZ
);
5077 len
+= snprintf(line_buf
+len
,
5078 LPFC_MBX_ACC_LBUF_SZ
-len
,
5081 len
+= snprintf(line_buf
+len
, LPFC_MBX_ACC_LBUF_SZ
-len
,
5083 ((uint32_t)*pword
) & 0xffffffff);
5087 pr_err("%s\n", line_buf
);
5090 if (*mbx_dump_map
& LPFC_MBX_DMP_MBX_BYTE
) {
5091 pr_err("Mailbox command:0x%x dump by byte:\n",
5093 pbyte
= (uint8_t *)pmbox
;
5094 for (i
= 0; i
< *mbx_word_cnt
; i
++) {
5097 pr_err("%s\n", line_buf
);
5099 memset(line_buf
, 0, LPFC_MBX_ACC_LBUF_SZ
);
5100 len
+= snprintf(line_buf
+len
,
5101 LPFC_MBX_ACC_LBUF_SZ
-len
,
5104 for (j
= 0; j
< 4; j
++) {
5105 len
+= snprintf(line_buf
+len
,
5106 LPFC_MBX_ACC_LBUF_SZ
-len
,
5108 ((uint8_t)*pbyte
) & 0xff);
5111 len
+= snprintf(line_buf
+len
,
5112 LPFC_MBX_ACC_LBUF_SZ
-len
, " ");
5115 pr_err("%s\n", line_buf
);
5120 /* Clean out command structure on reaching dump count */
5121 if (*mbx_dump_cnt
== 0)
5122 memset(&idiag
, 0, sizeof(idiag
));
5128 * lpfc_debugfs_initialize - Initialize debugfs for a vport
5129 * @vport: The vport pointer to initialize.
5132 * When Debugfs is configured this routine sets up the lpfc debugfs file system.
5133 * If not already created, this routine will create the lpfc directory, and
5134 * lpfcX directory (for this HBA), and vportX directory for this vport. It will
5135 * also create each file used to access lpfc specific debugfs information.
5138 lpfc_debugfs_initialize(struct lpfc_vport
*vport
)
5140 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
5141 struct lpfc_hba
*phba
= vport
->phba
;
5144 bool pport_setup
= false;
5146 if (!lpfc_debugfs_enable
)
5149 /* Setup lpfc root directory */
5150 if (!lpfc_debugfs_root
) {
5151 lpfc_debugfs_root
= debugfs_create_dir("lpfc", NULL
);
5152 atomic_set(&lpfc_debugfs_hba_count
, 0);
5153 if (!lpfc_debugfs_root
) {
5154 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5155 "0408 Cannot create debugfs root\n");
5159 if (!lpfc_debugfs_start_time
)
5160 lpfc_debugfs_start_time
= jiffies
;
5162 /* Setup funcX directory for specific HBA PCI function */
5163 snprintf(name
, sizeof(name
), "fn%d", phba
->brd_no
);
5164 if (!phba
->hba_debugfs_root
) {
5166 phba
->hba_debugfs_root
=
5167 debugfs_create_dir(name
, lpfc_debugfs_root
);
5168 if (!phba
->hba_debugfs_root
) {
5169 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5170 "0412 Cannot create debugfs hba\n");
5173 atomic_inc(&lpfc_debugfs_hba_count
);
5174 atomic_set(&phba
->debugfs_vport_count
, 0);
5177 snprintf(name
, sizeof(name
), "hbqinfo");
5178 phba
->debug_hbqinfo
=
5179 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5180 phba
->hba_debugfs_root
,
5181 phba
, &lpfc_debugfs_op_hbqinfo
);
5182 if (!phba
->debug_hbqinfo
) {
5183 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5184 "0411 Cannot create debugfs hbqinfo\n");
5188 /* Setup dumpHBASlim */
5189 if (phba
->sli_rev
< LPFC_SLI_REV4
) {
5190 snprintf(name
, sizeof(name
), "dumpHBASlim");
5191 phba
->debug_dumpHBASlim
=
5192 debugfs_create_file(name
,
5193 S_IFREG
|S_IRUGO
|S_IWUSR
,
5194 phba
->hba_debugfs_root
,
5195 phba
, &lpfc_debugfs_op_dumpHBASlim
);
5196 if (!phba
->debug_dumpHBASlim
) {
5197 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5198 "0413 Cannot create debugfs "
5203 phba
->debug_dumpHBASlim
= NULL
;
5205 /* Setup dumpHostSlim */
5206 if (phba
->sli_rev
< LPFC_SLI_REV4
) {
5207 snprintf(name
, sizeof(name
), "dumpHostSlim");
5208 phba
->debug_dumpHostSlim
=
5209 debugfs_create_file(name
,
5210 S_IFREG
|S_IRUGO
|S_IWUSR
,
5211 phba
->hba_debugfs_root
,
5212 phba
, &lpfc_debugfs_op_dumpHostSlim
);
5213 if (!phba
->debug_dumpHostSlim
) {
5214 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5215 "0414 Cannot create debugfs "
5220 phba
->debug_dumpHostSlim
= NULL
;
5222 /* Setup dumpData */
5223 snprintf(name
, sizeof(name
), "dumpData");
5224 phba
->debug_dumpData
=
5225 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5226 phba
->hba_debugfs_root
,
5227 phba
, &lpfc_debugfs_op_dumpData
);
5228 if (!phba
->debug_dumpData
) {
5229 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5230 "0800 Cannot create debugfs dumpData\n");
5235 snprintf(name
, sizeof(name
), "dumpDif");
5236 phba
->debug_dumpDif
=
5237 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5238 phba
->hba_debugfs_root
,
5239 phba
, &lpfc_debugfs_op_dumpDif
);
5240 if (!phba
->debug_dumpDif
) {
5241 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5242 "0801 Cannot create debugfs dumpDif\n");
5246 /* Setup DIF Error Injections */
5247 snprintf(name
, sizeof(name
), "InjErrLBA");
5248 phba
->debug_InjErrLBA
=
5249 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5250 phba
->hba_debugfs_root
,
5251 phba
, &lpfc_debugfs_op_dif_err
);
5252 if (!phba
->debug_InjErrLBA
) {
5253 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5254 "0807 Cannot create debugfs InjErrLBA\n");
5257 phba
->lpfc_injerr_lba
= LPFC_INJERR_LBA_OFF
;
5259 snprintf(name
, sizeof(name
), "InjErrNPortID");
5260 phba
->debug_InjErrNPortID
=
5261 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5262 phba
->hba_debugfs_root
,
5263 phba
, &lpfc_debugfs_op_dif_err
);
5264 if (!phba
->debug_InjErrNPortID
) {
5265 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5266 "0809 Cannot create debugfs InjErrNPortID\n");
5270 snprintf(name
, sizeof(name
), "InjErrWWPN");
5271 phba
->debug_InjErrWWPN
=
5272 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5273 phba
->hba_debugfs_root
,
5274 phba
, &lpfc_debugfs_op_dif_err
);
5275 if (!phba
->debug_InjErrWWPN
) {
5276 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5277 "0810 Cannot create debugfs InjErrWWPN\n");
5281 snprintf(name
, sizeof(name
), "writeGuardInjErr");
5282 phba
->debug_writeGuard
=
5283 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5284 phba
->hba_debugfs_root
,
5285 phba
, &lpfc_debugfs_op_dif_err
);
5286 if (!phba
->debug_writeGuard
) {
5287 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5288 "0802 Cannot create debugfs writeGuard\n");
5292 snprintf(name
, sizeof(name
), "writeAppInjErr");
5293 phba
->debug_writeApp
=
5294 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5295 phba
->hba_debugfs_root
,
5296 phba
, &lpfc_debugfs_op_dif_err
);
5297 if (!phba
->debug_writeApp
) {
5298 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5299 "0803 Cannot create debugfs writeApp\n");
5303 snprintf(name
, sizeof(name
), "writeRefInjErr");
5304 phba
->debug_writeRef
=
5305 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5306 phba
->hba_debugfs_root
,
5307 phba
, &lpfc_debugfs_op_dif_err
);
5308 if (!phba
->debug_writeRef
) {
5309 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5310 "0804 Cannot create debugfs writeRef\n");
5314 snprintf(name
, sizeof(name
), "readGuardInjErr");
5315 phba
->debug_readGuard
=
5316 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5317 phba
->hba_debugfs_root
,
5318 phba
, &lpfc_debugfs_op_dif_err
);
5319 if (!phba
->debug_readGuard
) {
5320 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5321 "0808 Cannot create debugfs readGuard\n");
5325 snprintf(name
, sizeof(name
), "readAppInjErr");
5326 phba
->debug_readApp
=
5327 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5328 phba
->hba_debugfs_root
,
5329 phba
, &lpfc_debugfs_op_dif_err
);
5330 if (!phba
->debug_readApp
) {
5331 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5332 "0805 Cannot create debugfs readApp\n");
5336 snprintf(name
, sizeof(name
), "readRefInjErr");
5337 phba
->debug_readRef
=
5338 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5339 phba
->hba_debugfs_root
,
5340 phba
, &lpfc_debugfs_op_dif_err
);
5341 if (!phba
->debug_readRef
) {
5342 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5343 "0806 Cannot create debugfs readApp\n");
5347 /* Setup slow ring trace */
5348 if (lpfc_debugfs_max_slow_ring_trc
) {
5349 num
= lpfc_debugfs_max_slow_ring_trc
- 1;
5350 if (num
& lpfc_debugfs_max_slow_ring_trc
) {
5351 /* Change to be a power of 2 */
5352 num
= lpfc_debugfs_max_slow_ring_trc
;
5358 lpfc_debugfs_max_slow_ring_trc
= (1 << i
);
5359 pr_err("lpfc_debugfs_max_disc_trc changed to "
5360 "%d\n", lpfc_debugfs_max_disc_trc
);
5364 snprintf(name
, sizeof(name
), "slow_ring_trace");
5365 phba
->debug_slow_ring_trc
=
5366 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5367 phba
->hba_debugfs_root
,
5368 phba
, &lpfc_debugfs_op_slow_ring_trc
);
5369 if (!phba
->debug_slow_ring_trc
) {
5370 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5371 "0415 Cannot create debugfs "
5372 "slow_ring_trace\n");
5375 if (!phba
->slow_ring_trc
) {
5376 phba
->slow_ring_trc
= kmalloc(
5377 (sizeof(struct lpfc_debugfs_trc
) *
5378 lpfc_debugfs_max_slow_ring_trc
),
5380 if (!phba
->slow_ring_trc
) {
5381 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5382 "0416 Cannot create debugfs "
5383 "slow_ring buffer\n");
5386 atomic_set(&phba
->slow_ring_trc_cnt
, 0);
5387 memset(phba
->slow_ring_trc
, 0,
5388 (sizeof(struct lpfc_debugfs_trc
) *
5389 lpfc_debugfs_max_slow_ring_trc
));
5392 snprintf(name
, sizeof(name
), "nvmeio_trc");
5393 phba
->debug_nvmeio_trc
=
5394 debugfs_create_file(name
, 0644,
5395 phba
->hba_debugfs_root
,
5396 phba
, &lpfc_debugfs_op_nvmeio_trc
);
5397 if (!phba
->debug_nvmeio_trc
) {
5398 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5399 "0574 No create debugfs nvmeio_trc\n");
5403 atomic_set(&phba
->nvmeio_trc_cnt
, 0);
5404 if (lpfc_debugfs_max_nvmeio_trc
) {
5405 num
= lpfc_debugfs_max_nvmeio_trc
- 1;
5406 if (num
& lpfc_debugfs_max_disc_trc
) {
5407 /* Change to be a power of 2 */
5408 num
= lpfc_debugfs_max_nvmeio_trc
;
5414 lpfc_debugfs_max_nvmeio_trc
= (1 << i
);
5415 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
5416 "0575 lpfc_debugfs_max_nvmeio_trc "
5418 lpfc_debugfs_max_nvmeio_trc
);
5420 phba
->nvmeio_trc_size
= lpfc_debugfs_max_nvmeio_trc
;
5422 /* Allocate trace buffer and initialize */
5423 phba
->nvmeio_trc
= kmalloc(
5424 (sizeof(struct lpfc_debugfs_nvmeio_trc
) *
5425 phba
->nvmeio_trc_size
), GFP_KERNEL
);
5427 if (!phba
->nvmeio_trc
) {
5428 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
5429 "0576 Cannot create debugfs "
5430 "nvmeio_trc buffer\n");
5433 memset(phba
->nvmeio_trc
, 0,
5434 (sizeof(struct lpfc_debugfs_nvmeio_trc
) *
5435 phba
->nvmeio_trc_size
));
5436 phba
->nvmeio_trc_on
= 1;
5437 phba
->nvmeio_trc_output_idx
= 0;
5438 phba
->nvmeio_trc
= NULL
;
5441 phba
->nvmeio_trc_size
= 0;
5442 phba
->nvmeio_trc_on
= 0;
5443 phba
->nvmeio_trc_output_idx
= 0;
5444 phba
->nvmeio_trc
= NULL
;
5448 snprintf(name
, sizeof(name
), "vport%d", vport
->vpi
);
5449 if (!vport
->vport_debugfs_root
) {
5450 vport
->vport_debugfs_root
=
5451 debugfs_create_dir(name
, phba
->hba_debugfs_root
);
5452 if (!vport
->vport_debugfs_root
) {
5453 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5454 "0417 Can't create debugfs\n");
5457 atomic_inc(&phba
->debugfs_vport_count
);
5460 if (lpfc_debugfs_max_disc_trc
) {
5461 num
= lpfc_debugfs_max_disc_trc
- 1;
5462 if (num
& lpfc_debugfs_max_disc_trc
) {
5463 /* Change to be a power of 2 */
5464 num
= lpfc_debugfs_max_disc_trc
;
5470 lpfc_debugfs_max_disc_trc
= (1 << i
);
5471 pr_err("lpfc_debugfs_max_disc_trc changed to %d\n",
5472 lpfc_debugfs_max_disc_trc
);
5476 vport
->disc_trc
= kzalloc(
5477 (sizeof(struct lpfc_debugfs_trc
) * lpfc_debugfs_max_disc_trc
),
5480 if (!vport
->disc_trc
) {
5481 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5482 "0418 Cannot create debugfs disc trace "
5486 atomic_set(&vport
->disc_trc_cnt
, 0);
5488 snprintf(name
, sizeof(name
), "discovery_trace");
5489 vport
->debug_disc_trc
=
5490 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5491 vport
->vport_debugfs_root
,
5492 vport
, &lpfc_debugfs_op_disc_trc
);
5493 if (!vport
->debug_disc_trc
) {
5494 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5495 "0419 Cannot create debugfs "
5496 "discovery_trace\n");
5499 snprintf(name
, sizeof(name
), "nodelist");
5500 vport
->debug_nodelist
=
5501 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5502 vport
->vport_debugfs_root
,
5503 vport
, &lpfc_debugfs_op_nodelist
);
5504 if (!vport
->debug_nodelist
) {
5505 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5506 "2985 Can't create debugfs nodelist\n");
5510 snprintf(name
, sizeof(name
), "nvmestat");
5511 vport
->debug_nvmestat
=
5512 debugfs_create_file(name
, 0644,
5513 vport
->vport_debugfs_root
,
5514 vport
, &lpfc_debugfs_op_nvmestat
);
5515 if (!vport
->debug_nvmestat
) {
5516 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5517 "0811 Cannot create debugfs nvmestat\n");
5521 snprintf(name
, sizeof(name
), "nvmektime");
5522 vport
->debug_nvmektime
=
5523 debugfs_create_file(name
, 0644,
5524 vport
->vport_debugfs_root
,
5525 vport
, &lpfc_debugfs_op_nvmektime
);
5526 if (!vport
->debug_nvmektime
) {
5527 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5528 "0815 Cannot create debugfs nvmektime\n");
5532 snprintf(name
, sizeof(name
), "cpucheck");
5533 vport
->debug_cpucheck
=
5534 debugfs_create_file(name
, 0644,
5535 vport
->vport_debugfs_root
,
5536 vport
, &lpfc_debugfs_op_cpucheck
);
5537 if (!vport
->debug_cpucheck
) {
5538 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5539 "0819 Cannot create debugfs cpucheck\n");
5544 * The following section is for additional directories/files for the
5552 * iDiag debugfs root entry points for SLI4 device only
5554 if (phba
->sli_rev
< LPFC_SLI_REV4
)
5557 snprintf(name
, sizeof(name
), "iDiag");
5558 if (!phba
->idiag_root
) {
5560 debugfs_create_dir(name
, phba
->hba_debugfs_root
);
5561 if (!phba
->idiag_root
) {
5562 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5563 "2922 Can't create idiag debugfs\n");
5566 /* Initialize iDiag data structure */
5567 memset(&idiag
, 0, sizeof(idiag
));
5570 /* iDiag read PCI config space */
5571 snprintf(name
, sizeof(name
), "pciCfg");
5572 if (!phba
->idiag_pci_cfg
) {
5573 phba
->idiag_pci_cfg
=
5574 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5575 phba
->idiag_root
, phba
, &lpfc_idiag_op_pciCfg
);
5576 if (!phba
->idiag_pci_cfg
) {
5577 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5578 "2923 Can't create idiag debugfs\n");
5581 idiag
.offset
.last_rd
= 0;
5584 /* iDiag PCI BAR access */
5585 snprintf(name
, sizeof(name
), "barAcc");
5586 if (!phba
->idiag_bar_acc
) {
5587 phba
->idiag_bar_acc
=
5588 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5589 phba
->idiag_root
, phba
, &lpfc_idiag_op_barAcc
);
5590 if (!phba
->idiag_bar_acc
) {
5591 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5592 "3056 Can't create idiag debugfs\n");
5595 idiag
.offset
.last_rd
= 0;
5598 /* iDiag get PCI function queue information */
5599 snprintf(name
, sizeof(name
), "queInfo");
5600 if (!phba
->idiag_que_info
) {
5601 phba
->idiag_que_info
=
5602 debugfs_create_file(name
, S_IFREG
|S_IRUGO
,
5603 phba
->idiag_root
, phba
, &lpfc_idiag_op_queInfo
);
5604 if (!phba
->idiag_que_info
) {
5605 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5606 "2924 Can't create idiag debugfs\n");
5611 /* iDiag access PCI function queue */
5612 snprintf(name
, sizeof(name
), "queAcc");
5613 if (!phba
->idiag_que_acc
) {
5614 phba
->idiag_que_acc
=
5615 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5616 phba
->idiag_root
, phba
, &lpfc_idiag_op_queAcc
);
5617 if (!phba
->idiag_que_acc
) {
5618 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5619 "2926 Can't create idiag debugfs\n");
5624 /* iDiag access PCI function doorbell registers */
5625 snprintf(name
, sizeof(name
), "drbAcc");
5626 if (!phba
->idiag_drb_acc
) {
5627 phba
->idiag_drb_acc
=
5628 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5629 phba
->idiag_root
, phba
, &lpfc_idiag_op_drbAcc
);
5630 if (!phba
->idiag_drb_acc
) {
5631 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5632 "2927 Can't create idiag debugfs\n");
5637 /* iDiag access PCI function control registers */
5638 snprintf(name
, sizeof(name
), "ctlAcc");
5639 if (!phba
->idiag_ctl_acc
) {
5640 phba
->idiag_ctl_acc
=
5641 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5642 phba
->idiag_root
, phba
, &lpfc_idiag_op_ctlAcc
);
5643 if (!phba
->idiag_ctl_acc
) {
5644 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5645 "2981 Can't create idiag debugfs\n");
5650 /* iDiag access mbox commands */
5651 snprintf(name
, sizeof(name
), "mbxAcc");
5652 if (!phba
->idiag_mbx_acc
) {
5653 phba
->idiag_mbx_acc
=
5654 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5655 phba
->idiag_root
, phba
, &lpfc_idiag_op_mbxAcc
);
5656 if (!phba
->idiag_mbx_acc
) {
5657 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5658 "2980 Can't create idiag debugfs\n");
5663 /* iDiag extents access commands */
5664 if (phba
->sli4_hba
.extents_in_use
) {
5665 snprintf(name
, sizeof(name
), "extAcc");
5666 if (!phba
->idiag_ext_acc
) {
5667 phba
->idiag_ext_acc
=
5668 debugfs_create_file(name
,
5669 S_IFREG
|S_IRUGO
|S_IWUSR
,
5670 phba
->idiag_root
, phba
,
5671 &lpfc_idiag_op_extAcc
);
5672 if (!phba
->idiag_ext_acc
) {
5673 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5687 * lpfc_debugfs_terminate - Tear down debugfs infrastructure for this vport
5688 * @vport: The vport pointer to remove from debugfs.
5691 * When Debugfs is configured this routine removes debugfs file system elements
5692 * that are specific to this vport. It also checks to see if there are any
5693 * users left for the debugfs directories associated with the HBA and driver. If
5694 * this is the last user of the HBA directory or driver directory then it will
5695 * remove those from the debugfs infrastructure as well.
5698 lpfc_debugfs_terminate(struct lpfc_vport
*vport
)
5700 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
5701 struct lpfc_hba
*phba
= vport
->phba
;
5703 if (vport
->disc_trc
) {
5704 kfree(vport
->disc_trc
);
5705 vport
->disc_trc
= NULL
;
5708 debugfs_remove(vport
->debug_disc_trc
); /* discovery_trace */
5709 vport
->debug_disc_trc
= NULL
;
5711 debugfs_remove(vport
->debug_nodelist
); /* nodelist */
5712 vport
->debug_nodelist
= NULL
;
5714 debugfs_remove(vport
->debug_nvmestat
); /* nvmestat */
5715 vport
->debug_nvmestat
= NULL
;
5717 debugfs_remove(vport
->debug_nvmektime
); /* nvmektime */
5718 vport
->debug_nvmektime
= NULL
;
5720 debugfs_remove(vport
->debug_cpucheck
); /* cpucheck */
5721 vport
->debug_cpucheck
= NULL
;
5723 if (vport
->vport_debugfs_root
) {
5724 debugfs_remove(vport
->vport_debugfs_root
); /* vportX */
5725 vport
->vport_debugfs_root
= NULL
;
5726 atomic_dec(&phba
->debugfs_vport_count
);
5729 if (atomic_read(&phba
->debugfs_vport_count
) == 0) {
5731 debugfs_remove(phba
->debug_hbqinfo
); /* hbqinfo */
5732 phba
->debug_hbqinfo
= NULL
;
5734 debugfs_remove(phba
->debug_dumpHBASlim
); /* HBASlim */
5735 phba
->debug_dumpHBASlim
= NULL
;
5737 debugfs_remove(phba
->debug_dumpHostSlim
); /* HostSlim */
5738 phba
->debug_dumpHostSlim
= NULL
;
5740 debugfs_remove(phba
->debug_dumpData
); /* dumpData */
5741 phba
->debug_dumpData
= NULL
;
5743 debugfs_remove(phba
->debug_dumpDif
); /* dumpDif */
5744 phba
->debug_dumpDif
= NULL
;
5746 debugfs_remove(phba
->debug_InjErrLBA
); /* InjErrLBA */
5747 phba
->debug_InjErrLBA
= NULL
;
5749 debugfs_remove(phba
->debug_InjErrNPortID
);
5750 phba
->debug_InjErrNPortID
= NULL
;
5752 debugfs_remove(phba
->debug_InjErrWWPN
); /* InjErrWWPN */
5753 phba
->debug_InjErrWWPN
= NULL
;
5755 debugfs_remove(phba
->debug_writeGuard
); /* writeGuard */
5756 phba
->debug_writeGuard
= NULL
;
5758 debugfs_remove(phba
->debug_writeApp
); /* writeApp */
5759 phba
->debug_writeApp
= NULL
;
5761 debugfs_remove(phba
->debug_writeRef
); /* writeRef */
5762 phba
->debug_writeRef
= NULL
;
5764 debugfs_remove(phba
->debug_readGuard
); /* readGuard */
5765 phba
->debug_readGuard
= NULL
;
5767 debugfs_remove(phba
->debug_readApp
); /* readApp */
5768 phba
->debug_readApp
= NULL
;
5770 debugfs_remove(phba
->debug_readRef
); /* readRef */
5771 phba
->debug_readRef
= NULL
;
5773 if (phba
->slow_ring_trc
) {
5774 kfree(phba
->slow_ring_trc
);
5775 phba
->slow_ring_trc
= NULL
;
5778 /* slow_ring_trace */
5779 debugfs_remove(phba
->debug_slow_ring_trc
);
5780 phba
->debug_slow_ring_trc
= NULL
;
5782 debugfs_remove(phba
->debug_nvmeio_trc
);
5783 phba
->debug_nvmeio_trc
= NULL
;
5785 kfree(phba
->nvmeio_trc
);
5786 phba
->nvmeio_trc
= NULL
;
5791 if (phba
->sli_rev
== LPFC_SLI_REV4
) {
5793 debugfs_remove(phba
->idiag_ext_acc
);
5794 phba
->idiag_ext_acc
= NULL
;
5797 debugfs_remove(phba
->idiag_mbx_acc
);
5798 phba
->idiag_mbx_acc
= NULL
;
5801 debugfs_remove(phba
->idiag_ctl_acc
);
5802 phba
->idiag_ctl_acc
= NULL
;
5805 debugfs_remove(phba
->idiag_drb_acc
);
5806 phba
->idiag_drb_acc
= NULL
;
5809 debugfs_remove(phba
->idiag_que_acc
);
5810 phba
->idiag_que_acc
= NULL
;
5813 debugfs_remove(phba
->idiag_que_info
);
5814 phba
->idiag_que_info
= NULL
;
5817 debugfs_remove(phba
->idiag_bar_acc
);
5818 phba
->idiag_bar_acc
= NULL
;
5821 debugfs_remove(phba
->idiag_pci_cfg
);
5822 phba
->idiag_pci_cfg
= NULL
;
5824 /* Finally remove the iDiag debugfs root */
5825 debugfs_remove(phba
->idiag_root
);
5826 phba
->idiag_root
= NULL
;
5829 if (phba
->hba_debugfs_root
) {
5830 debugfs_remove(phba
->hba_debugfs_root
); /* fnX */
5831 phba
->hba_debugfs_root
= NULL
;
5832 atomic_dec(&lpfc_debugfs_hba_count
);
5835 debugfs_remove(lpfc_debugfs_root
); /* lpfc */
5836 lpfc_debugfs_root
= NULL
;
5843 * Driver debug utility routines outside of debugfs. The debug utility
5844 * routines implemented here is intended to be used in the instrumented
5845 * debug driver for debugging host or port issues.
5849 * lpfc_debug_dump_all_queues - dump all the queues with a hba
5850 * @phba: Pointer to HBA context object.
5852 * This function dumps entries of all the queues asociated with the @phba.
5855 lpfc_debug_dump_all_queues(struct lpfc_hba
*phba
)
5860 * Dump Work Queues (WQs)
5862 lpfc_debug_dump_wq(phba
, DUMP_MBX
, 0);
5863 lpfc_debug_dump_wq(phba
, DUMP_ELS
, 0);
5864 lpfc_debug_dump_wq(phba
, DUMP_NVMELS
, 0);
5866 for (idx
= 0; idx
< phba
->cfg_fcp_io_channel
; idx
++)
5867 lpfc_debug_dump_wq(phba
, DUMP_FCP
, idx
);
5869 for (idx
= 0; idx
< phba
->cfg_nvme_io_channel
; idx
++)
5870 lpfc_debug_dump_wq(phba
, DUMP_NVME
, idx
);
5872 lpfc_debug_dump_hdr_rq(phba
);
5873 lpfc_debug_dump_dat_rq(phba
);
5875 * Dump Complete Queues (CQs)
5877 lpfc_debug_dump_cq(phba
, DUMP_MBX
, 0);
5878 lpfc_debug_dump_cq(phba
, DUMP_ELS
, 0);
5879 lpfc_debug_dump_cq(phba
, DUMP_NVMELS
, 0);
5881 for (idx
= 0; idx
< phba
->cfg_fcp_io_channel
; idx
++)
5882 lpfc_debug_dump_cq(phba
, DUMP_FCP
, idx
);
5884 for (idx
= 0; idx
< phba
->cfg_nvme_io_channel
; idx
++)
5885 lpfc_debug_dump_cq(phba
, DUMP_NVME
, idx
);
5888 * Dump Event Queues (EQs)
5890 for (idx
= 0; idx
< phba
->io_channel_irqs
; idx
++)
5891 lpfc_debug_dump_hba_eq(phba
, idx
);