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
;
748 struct lpfc_nvmet_rcv_ctx
*ctxp
, *next_ctxp
;
752 if (phba
->nvmet_support
) {
753 if (!phba
->targetport
)
755 tgtp
= (struct lpfc_nvmet_tgtport
*)phba
->targetport
->private;
756 len
+= snprintf(buf
+ len
, size
- len
,
757 "\nNVME Targetport Statistics\n");
759 len
+= snprintf(buf
+ len
, size
- len
,
760 "LS: Rcv %08x Drop %08x Abort %08x\n",
761 atomic_read(&tgtp
->rcv_ls_req_in
),
762 atomic_read(&tgtp
->rcv_ls_req_drop
),
763 atomic_read(&tgtp
->xmt_ls_abort
));
764 if (atomic_read(&tgtp
->rcv_ls_req_in
) !=
765 atomic_read(&tgtp
->rcv_ls_req_out
)) {
766 len
+= snprintf(buf
+ len
, size
- len
,
767 "Rcv LS: in %08x != out %08x\n",
768 atomic_read(&tgtp
->rcv_ls_req_in
),
769 atomic_read(&tgtp
->rcv_ls_req_out
));
772 len
+= snprintf(buf
+ len
, size
- len
,
773 "LS: Xmt %08x Drop %08x Cmpl %08x Err %08x\n",
774 atomic_read(&tgtp
->xmt_ls_rsp
),
775 atomic_read(&tgtp
->xmt_ls_drop
),
776 atomic_read(&tgtp
->xmt_ls_rsp_cmpl
),
777 atomic_read(&tgtp
->xmt_ls_rsp_error
));
779 len
+= snprintf(buf
+ len
, size
- len
,
780 "FCP: Rcv %08x Drop %08x\n",
781 atomic_read(&tgtp
->rcv_fcp_cmd_in
),
782 atomic_read(&tgtp
->rcv_fcp_cmd_drop
));
784 if (atomic_read(&tgtp
->rcv_fcp_cmd_in
) !=
785 atomic_read(&tgtp
->rcv_fcp_cmd_out
)) {
786 len
+= snprintf(buf
+ len
, size
- len
,
787 "Rcv FCP: in %08x != out %08x\n",
788 atomic_read(&tgtp
->rcv_fcp_cmd_in
),
789 atomic_read(&tgtp
->rcv_fcp_cmd_out
));
792 len
+= snprintf(buf
+ len
, size
- len
,
793 "FCP Rsp: read %08x readrsp %08x "
794 "write %08x rsp %08x\n",
795 atomic_read(&tgtp
->xmt_fcp_read
),
796 atomic_read(&tgtp
->xmt_fcp_read_rsp
),
797 atomic_read(&tgtp
->xmt_fcp_write
),
798 atomic_read(&tgtp
->xmt_fcp_rsp
));
800 len
+= snprintf(buf
+ len
, size
- len
,
801 "FCP Rsp Cmpl: %08x err %08x drop %08x\n",
802 atomic_read(&tgtp
->xmt_fcp_rsp_cmpl
),
803 atomic_read(&tgtp
->xmt_fcp_rsp_error
),
804 atomic_read(&tgtp
->xmt_fcp_rsp_drop
));
806 len
+= snprintf(buf
+ len
, size
- len
,
807 "ABORT: Xmt %08x Cmpl %08x\n",
808 atomic_read(&tgtp
->xmt_fcp_abort
),
809 atomic_read(&tgtp
->xmt_fcp_abort_cmpl
));
811 len
+= snprintf(buf
+ len
, size
- len
,
812 "ABORT: Sol %08x Usol %08x Err %08x Cmpl %08x",
813 atomic_read(&tgtp
->xmt_abort_sol
),
814 atomic_read(&tgtp
->xmt_abort_unsol
),
815 atomic_read(&tgtp
->xmt_abort_rsp
),
816 atomic_read(&tgtp
->xmt_abort_rsp_error
));
818 len
+= snprintf(buf
+ len
, size
- len
, "\n");
821 spin_lock(&phba
->sli4_hba
.abts_nvme_buf_list_lock
);
822 list_for_each_entry_safe(ctxp
, next_ctxp
,
823 &phba
->sli4_hba
.lpfc_abts_nvmet_ctx_list
,
827 spin_unlock(&phba
->sli4_hba
.abts_nvme_buf_list_lock
);
829 len
+= snprintf(buf
+ len
, size
- len
,
830 "ABORT: %d ctx entries\n", cnt
);
831 spin_lock(&phba
->sli4_hba
.abts_nvme_buf_list_lock
);
832 list_for_each_entry_safe(ctxp
, next_ctxp
,
833 &phba
->sli4_hba
.lpfc_abts_nvmet_ctx_list
,
835 if (len
>= (size
- LPFC_DEBUG_OUT_LINE_SZ
))
837 len
+= snprintf(buf
+ len
, size
- len
,
838 "Entry: oxid %x state %x "
840 ctxp
->oxid
, ctxp
->state
,
843 spin_unlock(&phba
->sli4_hba
.abts_nvme_buf_list_lock
);
846 len
+= snprintf(buf
+ len
, size
- len
,
847 "IO_CTX: %08x outstanding %08x total %08x\n",
848 phba
->sli4_hba
.nvmet_ctx_cnt
,
849 phba
->sli4_hba
.nvmet_io_wait_cnt
,
850 phba
->sli4_hba
.nvmet_io_wait_total
);
852 if (!(phba
->cfg_enable_fc4_type
& LPFC_ENABLE_NVME
))
855 len
+= snprintf(buf
+ len
, size
- len
,
856 "\nNVME Lport Statistics\n");
858 len
+= snprintf(buf
+ len
, size
- len
,
859 "LS: Xmt %016llx Cmpl %016llx\n",
860 phba
->fc4NvmeLsRequests
,
861 phba
->fc4NvmeLsCmpls
);
863 len
+= snprintf(buf
+ len
, size
- len
,
864 "FCP: Rd %016llx Wr %016llx IO %016llx\n",
865 phba
->fc4NvmeInputRequests
,
866 phba
->fc4NvmeOutputRequests
,
867 phba
->fc4NvmeControlRequests
);
869 len
+= snprintf(buf
+ len
, size
- len
,
870 " Cmpl %016llx\n", phba
->fc4NvmeIoCmpls
);
878 * lpfc_debugfs_nvmektime_data - Dump target node list to a buffer
879 * @vport: The vport to gather target node info from.
880 * @buf: The buffer to dump log into.
881 * @size: The maximum amount of data to process.
884 * This routine dumps the NVME statistics associated with @vport
887 * This routine returns the amount of bytes that were dumped into @buf and will
891 lpfc_debugfs_nvmektime_data(struct lpfc_vport
*vport
, char *buf
, int size
)
893 struct lpfc_hba
*phba
= vport
->phba
;
896 if (phba
->nvmet_support
== 0) {
898 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
899 "ktime %s: Total Samples: %lld\n",
900 (phba
->ktime_on
? "Enabled" : "Disabled"),
901 phba
->ktime_data_samples
);
902 if (phba
->ktime_data_samples
== 0)
906 buf
+ len
, PAGE_SIZE
- len
,
907 "Segment 1: Last NVME Cmd cmpl "
908 "done -to- Start of next NVME cnd (in driver)\n");
910 buf
+ len
, PAGE_SIZE
- len
,
911 "avg:%08lld min:%08lld max %08lld\n",
912 div_u64(phba
->ktime_seg1_total
,
913 phba
->ktime_data_samples
),
914 phba
->ktime_seg1_min
,
915 phba
->ktime_seg1_max
);
917 buf
+ len
, PAGE_SIZE
- len
,
918 "Segment 2: Driver start of NVME cmd "
919 "-to- Firmware WQ doorbell\n");
921 buf
+ len
, PAGE_SIZE
- len
,
922 "avg:%08lld min:%08lld max %08lld\n",
923 div_u64(phba
->ktime_seg2_total
,
924 phba
->ktime_data_samples
),
925 phba
->ktime_seg2_min
,
926 phba
->ktime_seg2_max
);
928 buf
+ len
, PAGE_SIZE
- len
,
929 "Segment 3: Firmware WQ doorbell -to- "
932 buf
+ len
, PAGE_SIZE
- len
,
933 "avg:%08lld min:%08lld max %08lld\n",
934 div_u64(phba
->ktime_seg3_total
,
935 phba
->ktime_data_samples
),
936 phba
->ktime_seg3_min
,
937 phba
->ktime_seg3_max
);
939 buf
+ len
, PAGE_SIZE
- len
,
940 "Segment 4: MSI-X ISR cmpl -to- "
943 buf
+ len
, PAGE_SIZE
- len
,
944 "avg:%08lld min:%08lld max %08lld\n",
945 div_u64(phba
->ktime_seg4_total
,
946 phba
->ktime_data_samples
),
947 phba
->ktime_seg4_min
,
948 phba
->ktime_seg4_max
);
950 buf
+ len
, PAGE_SIZE
- len
,
951 "Total IO avg time: %08lld\n",
952 div_u64(phba
->ktime_seg1_total
+
953 phba
->ktime_seg2_total
+
954 phba
->ktime_seg3_total
+
955 phba
->ktime_seg4_total
,
956 phba
->ktime_data_samples
));
961 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
962 "ktime %s: Total Samples: %lld %lld\n",
963 (phba
->ktime_on
? "Enabled" : "Disabled"),
964 phba
->ktime_data_samples
,
965 phba
->ktime_status_samples
);
966 if (phba
->ktime_data_samples
== 0)
969 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
970 "Segment 1: MSI-X ISR Rcv cmd -to- "
971 "cmd pass to NVME Layer\n");
972 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
973 "avg:%08lld min:%08lld max %08lld\n",
974 div_u64(phba
->ktime_seg1_total
,
975 phba
->ktime_data_samples
),
976 phba
->ktime_seg1_min
,
977 phba
->ktime_seg1_max
);
978 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
979 "Segment 2: cmd pass to NVME Layer- "
980 "-to- Driver rcv cmd OP (action)\n");
981 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
982 "avg:%08lld min:%08lld max %08lld\n",
983 div_u64(phba
->ktime_seg2_total
,
984 phba
->ktime_data_samples
),
985 phba
->ktime_seg2_min
,
986 phba
->ktime_seg2_max
);
987 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
988 "Segment 3: Driver rcv cmd OP -to- "
989 "Firmware WQ doorbell: cmd\n");
990 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
991 "avg:%08lld min:%08lld max %08lld\n",
992 div_u64(phba
->ktime_seg3_total
,
993 phba
->ktime_data_samples
),
994 phba
->ktime_seg3_min
,
995 phba
->ktime_seg3_max
);
996 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
997 "Segment 4: Firmware WQ doorbell: cmd "
998 "-to- MSI-X ISR for cmd cmpl\n");
999 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
1000 "avg:%08lld min:%08lld max %08lld\n",
1001 div_u64(phba
->ktime_seg4_total
,
1002 phba
->ktime_data_samples
),
1003 phba
->ktime_seg4_min
,
1004 phba
->ktime_seg4_max
);
1005 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
1006 "Segment 5: MSI-X ISR for cmd cmpl "
1007 "-to- NVME layer passed cmd done\n");
1008 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
1009 "avg:%08lld min:%08lld max %08lld\n",
1010 div_u64(phba
->ktime_seg5_total
,
1011 phba
->ktime_data_samples
),
1012 phba
->ktime_seg5_min
,
1013 phba
->ktime_seg5_max
);
1015 if (phba
->ktime_status_samples
== 0) {
1016 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
1017 "Total: cmd received by MSI-X ISR "
1018 "-to- cmd completed on wire\n");
1019 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
1020 "avg:%08lld min:%08lld "
1022 div_u64(phba
->ktime_seg10_total
,
1023 phba
->ktime_data_samples
),
1024 phba
->ktime_seg10_min
,
1025 phba
->ktime_seg10_max
);
1029 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
1030 "Segment 6: NVME layer passed cmd done "
1031 "-to- Driver rcv rsp status OP\n");
1032 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
1033 "avg:%08lld min:%08lld max %08lld\n",
1034 div_u64(phba
->ktime_seg6_total
,
1035 phba
->ktime_status_samples
),
1036 phba
->ktime_seg6_min
,
1037 phba
->ktime_seg6_max
);
1038 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
1039 "Segment 7: Driver rcv rsp status OP "
1040 "-to- Firmware WQ doorbell: status\n");
1041 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
1042 "avg:%08lld min:%08lld max %08lld\n",
1043 div_u64(phba
->ktime_seg7_total
,
1044 phba
->ktime_status_samples
),
1045 phba
->ktime_seg7_min
,
1046 phba
->ktime_seg7_max
);
1047 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
1048 "Segment 8: Firmware WQ doorbell: status"
1049 " -to- MSI-X ISR for status cmpl\n");
1050 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
1051 "avg:%08lld min:%08lld max %08lld\n",
1052 div_u64(phba
->ktime_seg8_total
,
1053 phba
->ktime_status_samples
),
1054 phba
->ktime_seg8_min
,
1055 phba
->ktime_seg8_max
);
1056 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
1057 "Segment 9: MSI-X ISR for status cmpl "
1058 "-to- NVME layer passed status done\n");
1059 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
1060 "avg:%08lld min:%08lld max %08lld\n",
1061 div_u64(phba
->ktime_seg9_total
,
1062 phba
->ktime_status_samples
),
1063 phba
->ktime_seg9_min
,
1064 phba
->ktime_seg9_max
);
1065 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
1066 "Total: cmd received by MSI-X ISR -to- "
1067 "cmd completed on wire\n");
1068 len
+= snprintf(buf
+ len
, PAGE_SIZE
-len
,
1069 "avg:%08lld min:%08lld max %08lld\n",
1070 div_u64(phba
->ktime_seg10_total
,
1071 phba
->ktime_status_samples
),
1072 phba
->ktime_seg10_min
,
1073 phba
->ktime_seg10_max
);
1078 * lpfc_debugfs_nvmeio_trc_data - Dump NVME IO trace list to a buffer
1079 * @phba: The phba to gather target node info from.
1080 * @buf: The buffer to dump log into.
1081 * @size: The maximum amount of data to process.
1084 * This routine dumps the NVME IO trace associated with @phba
1087 * This routine returns the amount of bytes that were dumped into @buf and will
1091 lpfc_debugfs_nvmeio_trc_data(struct lpfc_hba
*phba
, char *buf
, int size
)
1093 struct lpfc_debugfs_nvmeio_trc
*dtp
;
1094 int i
, state
, index
, skip
;
1097 state
= phba
->nvmeio_trc_on
;
1099 index
= (atomic_read(&phba
->nvmeio_trc_cnt
) + 1) &
1100 (phba
->nvmeio_trc_size
- 1);
1101 skip
= phba
->nvmeio_trc_output_idx
;
1103 len
+= snprintf(buf
+ len
, size
- len
,
1104 "%s IO Trace %s: next_idx %d skip %d size %d\n",
1105 (phba
->nvmet_support
? "NVME" : "NVMET"),
1106 (state
? "Enabled" : "Disabled"),
1107 index
, skip
, phba
->nvmeio_trc_size
);
1109 if (!phba
->nvmeio_trc
|| state
)
1112 /* trace MUST bhe off to continue */
1114 for (i
= index
; i
< phba
->nvmeio_trc_size
; i
++) {
1119 dtp
= phba
->nvmeio_trc
+ i
;
1120 phba
->nvmeio_trc_output_idx
++;
1125 len
+= snprintf(buf
+ len
, size
- len
, dtp
->fmt
,
1126 dtp
->data1
, dtp
->data2
, dtp
->data3
);
1128 if (phba
->nvmeio_trc_output_idx
>= phba
->nvmeio_trc_size
) {
1129 phba
->nvmeio_trc_output_idx
= 0;
1130 len
+= snprintf(buf
+ len
, size
- len
,
1131 "Trace Complete\n");
1135 if (len
>= (size
- LPFC_DEBUG_OUT_LINE_SZ
)) {
1136 len
+= snprintf(buf
+ len
, size
- len
,
1137 "Trace Continue (%d of %d)\n",
1138 phba
->nvmeio_trc_output_idx
,
1139 phba
->nvmeio_trc_size
);
1143 for (i
= 0; i
< index
; i
++) {
1148 dtp
= phba
->nvmeio_trc
+ i
;
1149 phba
->nvmeio_trc_output_idx
++;
1154 len
+= snprintf(buf
+ len
, size
- len
, dtp
->fmt
,
1155 dtp
->data1
, dtp
->data2
, dtp
->data3
);
1157 if (phba
->nvmeio_trc_output_idx
>= phba
->nvmeio_trc_size
) {
1158 phba
->nvmeio_trc_output_idx
= 0;
1159 len
+= snprintf(buf
+ len
, size
- len
,
1160 "Trace Complete\n");
1164 if (len
>= (size
- LPFC_DEBUG_OUT_LINE_SZ
)) {
1165 len
+= snprintf(buf
+ len
, size
- len
,
1166 "Trace Continue (%d of %d)\n",
1167 phba
->nvmeio_trc_output_idx
,
1168 phba
->nvmeio_trc_size
);
1173 len
+= snprintf(buf
+ len
, size
- len
,
1180 * lpfc_debugfs_cpucheck_data - Dump target node list to a buffer
1181 * @vport: The vport to gather target node info from.
1182 * @buf: The buffer to dump log into.
1183 * @size: The maximum amount of data to process.
1186 * This routine dumps the NVME statistics associated with @vport
1189 * This routine returns the amount of bytes that were dumped into @buf and will
1193 lpfc_debugfs_cpucheck_data(struct lpfc_vport
*vport
, char *buf
, int size
)
1195 struct lpfc_hba
*phba
= vport
->phba
;
1198 uint32_t tot_xmt
= 0;
1199 uint32_t tot_rcv
= 0;
1200 uint32_t tot_cmpl
= 0;
1201 uint32_t tot_ccmpl
= 0;
1203 if (phba
->nvmet_support
== 0) {
1204 /* NVME Initiator */
1205 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
1207 (phba
->cpucheck_on
& LPFC_CHECK_NVME_IO
?
1208 "Enabled" : "Disabled"));
1209 for (i
= 0; i
< phba
->sli4_hba
.num_present_cpu
; i
++) {
1210 if (i
>= LPFC_CHECK_CPU_CNT
)
1212 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
1213 "%02d: xmit x%08x cmpl x%08x\n",
1214 i
, phba
->cpucheck_xmt_io
[i
],
1215 phba
->cpucheck_cmpl_io
[i
]);
1216 tot_xmt
+= phba
->cpucheck_xmt_io
[i
];
1217 tot_cmpl
+= phba
->cpucheck_cmpl_io
[i
];
1219 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
1220 "tot:xmit x%08x cmpl x%08x\n",
1226 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
1228 (phba
->cpucheck_on
& LPFC_CHECK_NVMET_IO
?
1229 "IO Enabled - " : "IO Disabled - "));
1230 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
1232 (phba
->cpucheck_on
& LPFC_CHECK_NVMET_RCV
?
1233 "Rcv Enabled\n" : "Rcv Disabled\n"));
1234 for (i
= 0; i
< phba
->sli4_hba
.num_present_cpu
; i
++) {
1235 if (i
>= LPFC_CHECK_CPU_CNT
)
1237 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
1238 "%02d: xmit x%08x ccmpl x%08x "
1239 "cmpl x%08x rcv x%08x\n",
1240 i
, phba
->cpucheck_xmt_io
[i
],
1241 phba
->cpucheck_ccmpl_io
[i
],
1242 phba
->cpucheck_cmpl_io
[i
],
1243 phba
->cpucheck_rcv_io
[i
]);
1244 tot_xmt
+= phba
->cpucheck_xmt_io
[i
];
1245 tot_rcv
+= phba
->cpucheck_rcv_io
[i
];
1246 tot_cmpl
+= phba
->cpucheck_cmpl_io
[i
];
1247 tot_ccmpl
+= phba
->cpucheck_ccmpl_io
[i
];
1249 len
+= snprintf(buf
+ len
, PAGE_SIZE
- len
,
1250 "tot:xmit x%08x ccmpl x%08x cmpl x%08x rcv x%08x\n",
1251 tot_xmt
, tot_ccmpl
, tot_cmpl
, tot_rcv
);
1258 * lpfc_debugfs_disc_trc - Store discovery trace log
1259 * @vport: The vport to associate this trace string with for retrieval.
1260 * @mask: Log entry classification.
1261 * @fmt: Format string to be displayed when dumping the log.
1262 * @data1: 1st data parameter to be applied to @fmt.
1263 * @data2: 2nd data parameter to be applied to @fmt.
1264 * @data3: 3rd data parameter to be applied to @fmt.
1267 * This routine is used by the driver code to add a debugfs log entry to the
1268 * discovery trace buffer associated with @vport. Only entries with a @mask that
1269 * match the current debugfs discovery mask will be saved. Entries that do not
1270 * match will be thrown away. @fmt, @data1, @data2, and @data3 are used like
1271 * printf when displaying the log.
1274 lpfc_debugfs_disc_trc(struct lpfc_vport
*vport
, int mask
, char *fmt
,
1275 uint32_t data1
, uint32_t data2
, uint32_t data3
)
1277 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
1278 struct lpfc_debugfs_trc
*dtp
;
1281 if (!(lpfc_debugfs_mask_disc_trc
& mask
))
1284 if (!lpfc_debugfs_enable
|| !lpfc_debugfs_max_disc_trc
||
1285 !vport
|| !vport
->disc_trc
)
1288 index
= atomic_inc_return(&vport
->disc_trc_cnt
) &
1289 (lpfc_debugfs_max_disc_trc
- 1);
1290 dtp
= vport
->disc_trc
+ index
;
1295 dtp
->seq_cnt
= atomic_inc_return(&lpfc_debugfs_seq_trc_cnt
);
1302 * lpfc_debugfs_slow_ring_trc - Store slow ring trace log
1303 * @phba: The phba to associate this trace string with for retrieval.
1304 * @fmt: Format string to be displayed when dumping the log.
1305 * @data1: 1st data parameter to be applied to @fmt.
1306 * @data2: 2nd data parameter to be applied to @fmt.
1307 * @data3: 3rd data parameter to be applied to @fmt.
1310 * This routine is used by the driver code to add a debugfs log entry to the
1311 * discovery trace buffer associated with @vport. @fmt, @data1, @data2, and
1312 * @data3 are used like printf when displaying the log.
1315 lpfc_debugfs_slow_ring_trc(struct lpfc_hba
*phba
, char *fmt
,
1316 uint32_t data1
, uint32_t data2
, uint32_t data3
)
1318 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
1319 struct lpfc_debugfs_trc
*dtp
;
1322 if (!lpfc_debugfs_enable
|| !lpfc_debugfs_max_slow_ring_trc
||
1323 !phba
|| !phba
->slow_ring_trc
)
1326 index
= atomic_inc_return(&phba
->slow_ring_trc_cnt
) &
1327 (lpfc_debugfs_max_slow_ring_trc
- 1);
1328 dtp
= phba
->slow_ring_trc
+ index
;
1333 dtp
->seq_cnt
= atomic_inc_return(&lpfc_debugfs_seq_trc_cnt
);
1340 * lpfc_debugfs_nvme_trc - Store NVME/NVMET trace log
1341 * @phba: The phba to associate this trace string with for retrieval.
1342 * @fmt: Format string to be displayed when dumping the log.
1343 * @data1: 1st data parameter to be applied to @fmt.
1344 * @data2: 2nd data parameter to be applied to @fmt.
1345 * @data3: 3rd data parameter to be applied to @fmt.
1348 * This routine is used by the driver code to add a debugfs log entry to the
1349 * nvme trace buffer associated with @phba. @fmt, @data1, @data2, and
1350 * @data3 are used like printf when displaying the log.
1353 lpfc_debugfs_nvme_trc(struct lpfc_hba
*phba
, char *fmt
,
1354 uint16_t data1
, uint16_t data2
, uint32_t data3
)
1356 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
1357 struct lpfc_debugfs_nvmeio_trc
*dtp
;
1360 if (!phba
->nvmeio_trc_on
|| !phba
->nvmeio_trc
)
1363 index
= atomic_inc_return(&phba
->nvmeio_trc_cnt
) &
1364 (phba
->nvmeio_trc_size
- 1);
1365 dtp
= phba
->nvmeio_trc
+ index
;
1373 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
1375 * lpfc_debugfs_disc_trc_open - Open the discovery trace log
1376 * @inode: The inode pointer that contains a vport pointer.
1377 * @file: The file pointer to attach the log output.
1380 * This routine is the entry point for the debugfs open file operation. It gets
1381 * the vport from the i_private field in @inode, allocates the necessary buffer
1382 * for the log, fills the buffer from the in-memory log for this vport, and then
1383 * returns a pointer to that log in the private_data field in @file.
1386 * This function returns zero if successful. On error it will return a negative
1390 lpfc_debugfs_disc_trc_open(struct inode
*inode
, struct file
*file
)
1392 struct lpfc_vport
*vport
= inode
->i_private
;
1393 struct lpfc_debug
*debug
;
1397 if (!lpfc_debugfs_max_disc_trc
) {
1402 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
1406 /* Round to page boundary */
1407 size
= (lpfc_debugfs_max_disc_trc
* LPFC_DEBUG_TRC_ENTRY_SIZE
);
1408 size
= PAGE_ALIGN(size
);
1410 debug
->buffer
= kmalloc(size
, GFP_KERNEL
);
1411 if (!debug
->buffer
) {
1416 debug
->len
= lpfc_debugfs_disc_trc_data(vport
, debug
->buffer
, size
);
1417 file
->private_data
= debug
;
1425 * lpfc_debugfs_slow_ring_trc_open - Open the Slow Ring trace log
1426 * @inode: The inode pointer that contains a vport pointer.
1427 * @file: The file pointer to attach the log output.
1430 * This routine is the entry point for the debugfs open file operation. It gets
1431 * the vport from the i_private field in @inode, allocates the necessary buffer
1432 * for the log, fills the buffer from the in-memory log for this vport, and then
1433 * returns a pointer to that log in the private_data field in @file.
1436 * This function returns zero if successful. On error it will return a negative
1440 lpfc_debugfs_slow_ring_trc_open(struct inode
*inode
, struct file
*file
)
1442 struct lpfc_hba
*phba
= inode
->i_private
;
1443 struct lpfc_debug
*debug
;
1447 if (!lpfc_debugfs_max_slow_ring_trc
) {
1452 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
1456 /* Round to page boundary */
1457 size
= (lpfc_debugfs_max_slow_ring_trc
* LPFC_DEBUG_TRC_ENTRY_SIZE
);
1458 size
= PAGE_ALIGN(size
);
1460 debug
->buffer
= kmalloc(size
, GFP_KERNEL
);
1461 if (!debug
->buffer
) {
1466 debug
->len
= lpfc_debugfs_slow_ring_trc_data(phba
, debug
->buffer
, size
);
1467 file
->private_data
= debug
;
1475 * lpfc_debugfs_hbqinfo_open - Open the hbqinfo debugfs buffer
1476 * @inode: The inode pointer that contains a vport pointer.
1477 * @file: The file pointer to attach the log output.
1480 * This routine is the entry point for the debugfs open file operation. It gets
1481 * the vport from the i_private field in @inode, allocates the necessary buffer
1482 * for the log, fills the buffer from the in-memory log for this vport, and then
1483 * returns a pointer to that log in the private_data field in @file.
1486 * This function returns zero if successful. On error it will return a negative
1490 lpfc_debugfs_hbqinfo_open(struct inode
*inode
, struct file
*file
)
1492 struct lpfc_hba
*phba
= inode
->i_private
;
1493 struct lpfc_debug
*debug
;
1496 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
1500 /* Round to page boundary */
1501 debug
->buffer
= kmalloc(LPFC_HBQINFO_SIZE
, GFP_KERNEL
);
1502 if (!debug
->buffer
) {
1507 debug
->len
= lpfc_debugfs_hbqinfo_data(phba
, debug
->buffer
,
1509 file
->private_data
= debug
;
1517 * lpfc_debugfs_dumpHBASlim_open - Open the Dump HBA SLIM debugfs buffer
1518 * @inode: The inode pointer that contains a vport pointer.
1519 * @file: The file pointer to attach the log output.
1522 * This routine is the entry point for the debugfs open file operation. It gets
1523 * the vport from the i_private field in @inode, allocates the necessary buffer
1524 * for the log, fills the buffer from the in-memory log for this vport, and then
1525 * returns a pointer to that log in the private_data field in @file.
1528 * This function returns zero if successful. On error it will return a negative
1532 lpfc_debugfs_dumpHBASlim_open(struct inode
*inode
, struct file
*file
)
1534 struct lpfc_hba
*phba
= inode
->i_private
;
1535 struct lpfc_debug
*debug
;
1538 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
1542 /* Round to page boundary */
1543 debug
->buffer
= kmalloc(LPFC_DUMPHBASLIM_SIZE
, GFP_KERNEL
);
1544 if (!debug
->buffer
) {
1549 debug
->len
= lpfc_debugfs_dumpHBASlim_data(phba
, debug
->buffer
,
1550 LPFC_DUMPHBASLIM_SIZE
);
1551 file
->private_data
= debug
;
1559 * lpfc_debugfs_dumpHostSlim_open - Open the Dump Host SLIM debugfs buffer
1560 * @inode: The inode pointer that contains a vport pointer.
1561 * @file: The file pointer to attach the log output.
1564 * This routine is the entry point for the debugfs open file operation. It gets
1565 * the vport from the i_private field in @inode, allocates the necessary buffer
1566 * for the log, fills the buffer from the in-memory log for this vport, and then
1567 * returns a pointer to that log in the private_data field in @file.
1570 * This function returns zero if successful. On error it will return a negative
1574 lpfc_debugfs_dumpHostSlim_open(struct inode
*inode
, struct file
*file
)
1576 struct lpfc_hba
*phba
= inode
->i_private
;
1577 struct lpfc_debug
*debug
;
1580 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
1584 /* Round to page boundary */
1585 debug
->buffer
= kmalloc(LPFC_DUMPHOSTSLIM_SIZE
, GFP_KERNEL
);
1586 if (!debug
->buffer
) {
1591 debug
->len
= lpfc_debugfs_dumpHostSlim_data(phba
, debug
->buffer
,
1592 LPFC_DUMPHOSTSLIM_SIZE
);
1593 file
->private_data
= debug
;
1601 lpfc_debugfs_dumpData_open(struct inode
*inode
, struct file
*file
)
1603 struct lpfc_debug
*debug
;
1606 if (!_dump_buf_data
)
1609 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
1613 /* Round to page boundary */
1614 pr_err("9059 BLKGRD: %s: _dump_buf_data=0x%p\n",
1615 __func__
, _dump_buf_data
);
1616 debug
->buffer
= _dump_buf_data
;
1617 if (!debug
->buffer
) {
1622 debug
->len
= (1 << _dump_buf_data_order
) << PAGE_SHIFT
;
1623 file
->private_data
= debug
;
1631 lpfc_debugfs_dumpDif_open(struct inode
*inode
, struct file
*file
)
1633 struct lpfc_debug
*debug
;
1639 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
1643 /* Round to page boundary */
1644 pr_err("9060 BLKGRD: %s: _dump_buf_dif=0x%p file=%pD\n",
1645 __func__
, _dump_buf_dif
, file
);
1646 debug
->buffer
= _dump_buf_dif
;
1647 if (!debug
->buffer
) {
1652 debug
->len
= (1 << _dump_buf_dif_order
) << PAGE_SHIFT
;
1653 file
->private_data
= debug
;
1661 lpfc_debugfs_dumpDataDif_write(struct file
*file
, const char __user
*buf
,
1662 size_t nbytes
, loff_t
*ppos
)
1665 * The Data/DIF buffers only save one failing IO
1666 * The write op is used as a reset mechanism after an IO has
1667 * already been saved to the next one can be saved
1669 spin_lock(&_dump_buf_lock
);
1671 memset((void *)_dump_buf_data
, 0,
1672 ((1 << PAGE_SHIFT
) << _dump_buf_data_order
));
1673 memset((void *)_dump_buf_dif
, 0,
1674 ((1 << PAGE_SHIFT
) << _dump_buf_dif_order
));
1678 spin_unlock(&_dump_buf_lock
);
1684 lpfc_debugfs_dif_err_read(struct file
*file
, char __user
*buf
,
1685 size_t nbytes
, loff_t
*ppos
)
1687 struct dentry
*dent
= file
->f_path
.dentry
;
1688 struct lpfc_hba
*phba
= file
->private_data
;
1693 if (dent
== phba
->debug_writeGuard
)
1694 cnt
= snprintf(cbuf
, 32, "%u\n", phba
->lpfc_injerr_wgrd_cnt
);
1695 else if (dent
== phba
->debug_writeApp
)
1696 cnt
= snprintf(cbuf
, 32, "%u\n", phba
->lpfc_injerr_wapp_cnt
);
1697 else if (dent
== phba
->debug_writeRef
)
1698 cnt
= snprintf(cbuf
, 32, "%u\n", phba
->lpfc_injerr_wref_cnt
);
1699 else if (dent
== phba
->debug_readGuard
)
1700 cnt
= snprintf(cbuf
, 32, "%u\n", phba
->lpfc_injerr_rgrd_cnt
);
1701 else if (dent
== phba
->debug_readApp
)
1702 cnt
= snprintf(cbuf
, 32, "%u\n", phba
->lpfc_injerr_rapp_cnt
);
1703 else if (dent
== phba
->debug_readRef
)
1704 cnt
= snprintf(cbuf
, 32, "%u\n", phba
->lpfc_injerr_rref_cnt
);
1705 else if (dent
== phba
->debug_InjErrNPortID
)
1706 cnt
= snprintf(cbuf
, 32, "0x%06x\n", phba
->lpfc_injerr_nportid
);
1707 else if (dent
== phba
->debug_InjErrWWPN
) {
1708 memcpy(&tmp
, &phba
->lpfc_injerr_wwpn
, sizeof(struct lpfc_name
));
1709 tmp
= cpu_to_be64(tmp
);
1710 cnt
= snprintf(cbuf
, 32, "0x%016llx\n", tmp
);
1711 } else if (dent
== phba
->debug_InjErrLBA
) {
1712 if (phba
->lpfc_injerr_lba
== (sector_t
)(-1))
1713 cnt
= snprintf(cbuf
, 32, "off\n");
1715 cnt
= snprintf(cbuf
, 32, "0x%llx\n",
1716 (uint64_t) phba
->lpfc_injerr_lba
);
1718 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
1719 "0547 Unknown debugfs error injection entry\n");
1721 return simple_read_from_buffer(buf
, nbytes
, ppos
, &cbuf
, cnt
);
1725 lpfc_debugfs_dif_err_write(struct file
*file
, const char __user
*buf
,
1726 size_t nbytes
, loff_t
*ppos
)
1728 struct dentry
*dent
= file
->f_path
.dentry
;
1729 struct lpfc_hba
*phba
= file
->private_data
;
1734 memset(dstbuf
, 0, 33);
1735 size
= (nbytes
< 32) ? nbytes
: 32;
1736 if (copy_from_user(dstbuf
, buf
, size
))
1739 if (dent
== phba
->debug_InjErrLBA
) {
1740 if ((buf
[0] == 'o') && (buf
[1] == 'f') && (buf
[2] == 'f'))
1741 tmp
= (uint64_t)(-1);
1744 if ((tmp
== 0) && (kstrtoull(dstbuf
, 0, &tmp
)))
1747 if (dent
== phba
->debug_writeGuard
)
1748 phba
->lpfc_injerr_wgrd_cnt
= (uint32_t)tmp
;
1749 else if (dent
== phba
->debug_writeApp
)
1750 phba
->lpfc_injerr_wapp_cnt
= (uint32_t)tmp
;
1751 else if (dent
== phba
->debug_writeRef
)
1752 phba
->lpfc_injerr_wref_cnt
= (uint32_t)tmp
;
1753 else if (dent
== phba
->debug_readGuard
)
1754 phba
->lpfc_injerr_rgrd_cnt
= (uint32_t)tmp
;
1755 else if (dent
== phba
->debug_readApp
)
1756 phba
->lpfc_injerr_rapp_cnt
= (uint32_t)tmp
;
1757 else if (dent
== phba
->debug_readRef
)
1758 phba
->lpfc_injerr_rref_cnt
= (uint32_t)tmp
;
1759 else if (dent
== phba
->debug_InjErrLBA
)
1760 phba
->lpfc_injerr_lba
= (sector_t
)tmp
;
1761 else if (dent
== phba
->debug_InjErrNPortID
)
1762 phba
->lpfc_injerr_nportid
= (uint32_t)(tmp
& Mask_DID
);
1763 else if (dent
== phba
->debug_InjErrWWPN
) {
1764 tmp
= cpu_to_be64(tmp
);
1765 memcpy(&phba
->lpfc_injerr_wwpn
, &tmp
, sizeof(struct lpfc_name
));
1767 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
1768 "0548 Unknown debugfs error injection entry\n");
1774 lpfc_debugfs_dif_err_release(struct inode
*inode
, struct file
*file
)
1780 * lpfc_debugfs_nodelist_open - Open the nodelist debugfs file
1781 * @inode: The inode pointer that contains a vport pointer.
1782 * @file: The file pointer to attach the log output.
1785 * This routine is the entry point for the debugfs open file operation. It gets
1786 * the vport from the i_private field in @inode, allocates the necessary buffer
1787 * for the log, fills the buffer from the in-memory log for this vport, and then
1788 * returns a pointer to that log in the private_data field in @file.
1791 * This function returns zero if successful. On error it will return a negative
1795 lpfc_debugfs_nodelist_open(struct inode
*inode
, struct file
*file
)
1797 struct lpfc_vport
*vport
= inode
->i_private
;
1798 struct lpfc_debug
*debug
;
1801 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
1805 /* Round to page boundary */
1806 debug
->buffer
= kmalloc(LPFC_NODELIST_SIZE
, GFP_KERNEL
);
1807 if (!debug
->buffer
) {
1812 debug
->len
= lpfc_debugfs_nodelist_data(vport
, debug
->buffer
,
1813 LPFC_NODELIST_SIZE
);
1814 file
->private_data
= debug
;
1822 * lpfc_debugfs_lseek - Seek through a debugfs file
1823 * @file: The file pointer to seek through.
1824 * @off: The offset to seek to or the amount to seek by.
1825 * @whence: Indicates how to seek.
1828 * This routine is the entry point for the debugfs lseek file operation. The
1829 * @whence parameter indicates whether @off is the offset to directly seek to,
1830 * or if it is a value to seek forward or reverse by. This function figures out
1831 * what the new offset of the debugfs file will be and assigns that value to the
1832 * f_pos field of @file.
1835 * This function returns the new offset if successful and returns a negative
1836 * error if unable to process the seek.
1839 lpfc_debugfs_lseek(struct file
*file
, loff_t off
, int whence
)
1841 struct lpfc_debug
*debug
= file
->private_data
;
1842 return fixed_size_llseek(file
, off
, whence
, debug
->len
);
1846 * lpfc_debugfs_read - Read a debugfs file
1847 * @file: The file pointer to read from.
1848 * @buf: The buffer to copy the data to.
1849 * @nbytes: The number of bytes to read.
1850 * @ppos: The position in the file to start reading from.
1853 * This routine reads data from from the buffer indicated in the private_data
1854 * field of @file. It will start reading at @ppos and copy up to @nbytes of
1858 * This function returns the amount of data that was read (this could be less
1859 * than @nbytes if the end of the file was reached) or a negative error value.
1862 lpfc_debugfs_read(struct file
*file
, char __user
*buf
,
1863 size_t nbytes
, loff_t
*ppos
)
1865 struct lpfc_debug
*debug
= file
->private_data
;
1867 return simple_read_from_buffer(buf
, nbytes
, ppos
, debug
->buffer
,
1872 * lpfc_debugfs_release - Release the buffer used to store debugfs file data
1873 * @inode: The inode pointer that contains a vport pointer. (unused)
1874 * @file: The file pointer that contains the buffer to release.
1877 * This routine frees the buffer that was allocated when the debugfs file was
1881 * This function returns zero.
1884 lpfc_debugfs_release(struct inode
*inode
, struct file
*file
)
1886 struct lpfc_debug
*debug
= file
->private_data
;
1888 kfree(debug
->buffer
);
1895 lpfc_debugfs_dumpDataDif_release(struct inode
*inode
, struct file
*file
)
1897 struct lpfc_debug
*debug
= file
->private_data
;
1899 debug
->buffer
= NULL
;
1907 lpfc_debugfs_nvmestat_open(struct inode
*inode
, struct file
*file
)
1909 struct lpfc_vport
*vport
= inode
->i_private
;
1910 struct lpfc_debug
*debug
;
1913 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
1917 /* Round to page boundary */
1918 debug
->buffer
= kmalloc(LPFC_NVMESTAT_SIZE
, GFP_KERNEL
);
1919 if (!debug
->buffer
) {
1924 debug
->len
= lpfc_debugfs_nvmestat_data(vport
, debug
->buffer
,
1925 LPFC_NVMESTAT_SIZE
);
1927 debug
->i_private
= inode
->i_private
;
1928 file
->private_data
= debug
;
1936 lpfc_debugfs_nvmestat_write(struct file
*file
, const char __user
*buf
,
1937 size_t nbytes
, loff_t
*ppos
)
1939 struct lpfc_debug
*debug
= file
->private_data
;
1940 struct lpfc_vport
*vport
= (struct lpfc_vport
*)debug
->i_private
;
1941 struct lpfc_hba
*phba
= vport
->phba
;
1942 struct lpfc_nvmet_tgtport
*tgtp
;
1946 if (!phba
->targetport
)
1952 /* Protect copy from user */
1953 if (!access_ok(VERIFY_READ
, buf
, nbytes
))
1956 memset(mybuf
, 0, sizeof(mybuf
));
1958 if (copy_from_user(mybuf
, buf
, nbytes
))
1962 tgtp
= (struct lpfc_nvmet_tgtport
*)phba
->targetport
->private;
1963 if ((strncmp(pbuf
, "reset", strlen("reset")) == 0) ||
1964 (strncmp(pbuf
, "zero", strlen("zero")) == 0)) {
1965 atomic_set(&tgtp
->rcv_ls_req_in
, 0);
1966 atomic_set(&tgtp
->rcv_ls_req_out
, 0);
1967 atomic_set(&tgtp
->rcv_ls_req_drop
, 0);
1968 atomic_set(&tgtp
->xmt_ls_abort
, 0);
1969 atomic_set(&tgtp
->xmt_ls_abort_cmpl
, 0);
1970 atomic_set(&tgtp
->xmt_ls_rsp
, 0);
1971 atomic_set(&tgtp
->xmt_ls_drop
, 0);
1972 atomic_set(&tgtp
->xmt_ls_rsp_error
, 0);
1973 atomic_set(&tgtp
->xmt_ls_rsp_cmpl
, 0);
1975 atomic_set(&tgtp
->rcv_fcp_cmd_in
, 0);
1976 atomic_set(&tgtp
->rcv_fcp_cmd_out
, 0);
1977 atomic_set(&tgtp
->rcv_fcp_cmd_drop
, 0);
1978 atomic_set(&tgtp
->xmt_fcp_drop
, 0);
1979 atomic_set(&tgtp
->xmt_fcp_read_rsp
, 0);
1980 atomic_set(&tgtp
->xmt_fcp_read
, 0);
1981 atomic_set(&tgtp
->xmt_fcp_write
, 0);
1982 atomic_set(&tgtp
->xmt_fcp_rsp
, 0);
1983 atomic_set(&tgtp
->xmt_fcp_release
, 0);
1984 atomic_set(&tgtp
->xmt_fcp_rsp_cmpl
, 0);
1985 atomic_set(&tgtp
->xmt_fcp_rsp_error
, 0);
1986 atomic_set(&tgtp
->xmt_fcp_rsp_drop
, 0);
1988 atomic_set(&tgtp
->xmt_fcp_abort
, 0);
1989 atomic_set(&tgtp
->xmt_fcp_abort_cmpl
, 0);
1990 atomic_set(&tgtp
->xmt_abort_sol
, 0);
1991 atomic_set(&tgtp
->xmt_abort_unsol
, 0);
1992 atomic_set(&tgtp
->xmt_abort_rsp
, 0);
1993 atomic_set(&tgtp
->xmt_abort_rsp_error
, 0);
1999 lpfc_debugfs_nvmektime_open(struct inode
*inode
, struct file
*file
)
2001 struct lpfc_vport
*vport
= inode
->i_private
;
2002 struct lpfc_debug
*debug
;
2005 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
2009 /* Round to page boundary */
2010 debug
->buffer
= kmalloc(LPFC_NVMEKTIME_SIZE
, GFP_KERNEL
);
2011 if (!debug
->buffer
) {
2016 debug
->len
= lpfc_debugfs_nvmektime_data(vport
, debug
->buffer
,
2017 LPFC_NVMEKTIME_SIZE
);
2019 debug
->i_private
= inode
->i_private
;
2020 file
->private_data
= debug
;
2028 lpfc_debugfs_nvmektime_write(struct file
*file
, const char __user
*buf
,
2029 size_t nbytes
, loff_t
*ppos
)
2031 struct lpfc_debug
*debug
= file
->private_data
;
2032 struct lpfc_vport
*vport
= (struct lpfc_vport
*)debug
->i_private
;
2033 struct lpfc_hba
*phba
= vport
->phba
;
2040 /* Protect copy from user */
2041 if (!access_ok(VERIFY_READ
, buf
, nbytes
))
2044 memset(mybuf
, 0, sizeof(mybuf
));
2046 if (copy_from_user(mybuf
, buf
, nbytes
))
2050 if ((strncmp(pbuf
, "on", sizeof("on") - 1) == 0)) {
2051 phba
->ktime_data_samples
= 0;
2052 phba
->ktime_status_samples
= 0;
2053 phba
->ktime_seg1_total
= 0;
2054 phba
->ktime_seg1_max
= 0;
2055 phba
->ktime_seg1_min
= 0xffffffff;
2056 phba
->ktime_seg2_total
= 0;
2057 phba
->ktime_seg2_max
= 0;
2058 phba
->ktime_seg2_min
= 0xffffffff;
2059 phba
->ktime_seg3_total
= 0;
2060 phba
->ktime_seg3_max
= 0;
2061 phba
->ktime_seg3_min
= 0xffffffff;
2062 phba
->ktime_seg4_total
= 0;
2063 phba
->ktime_seg4_max
= 0;
2064 phba
->ktime_seg4_min
= 0xffffffff;
2065 phba
->ktime_seg5_total
= 0;
2066 phba
->ktime_seg5_max
= 0;
2067 phba
->ktime_seg5_min
= 0xffffffff;
2068 phba
->ktime_seg6_total
= 0;
2069 phba
->ktime_seg6_max
= 0;
2070 phba
->ktime_seg6_min
= 0xffffffff;
2071 phba
->ktime_seg7_total
= 0;
2072 phba
->ktime_seg7_max
= 0;
2073 phba
->ktime_seg7_min
= 0xffffffff;
2074 phba
->ktime_seg8_total
= 0;
2075 phba
->ktime_seg8_max
= 0;
2076 phba
->ktime_seg8_min
= 0xffffffff;
2077 phba
->ktime_seg9_total
= 0;
2078 phba
->ktime_seg9_max
= 0;
2079 phba
->ktime_seg9_min
= 0xffffffff;
2080 phba
->ktime_seg10_total
= 0;
2081 phba
->ktime_seg10_max
= 0;
2082 phba
->ktime_seg10_min
= 0xffffffff;
2085 return strlen(pbuf
);
2086 } else if ((strncmp(pbuf
, "off",
2087 sizeof("off") - 1) == 0)) {
2089 return strlen(pbuf
);
2090 } else if ((strncmp(pbuf
, "zero",
2091 sizeof("zero") - 1) == 0)) {
2092 phba
->ktime_data_samples
= 0;
2093 phba
->ktime_status_samples
= 0;
2094 phba
->ktime_seg1_total
= 0;
2095 phba
->ktime_seg1_max
= 0;
2096 phba
->ktime_seg1_min
= 0xffffffff;
2097 phba
->ktime_seg2_total
= 0;
2098 phba
->ktime_seg2_max
= 0;
2099 phba
->ktime_seg2_min
= 0xffffffff;
2100 phba
->ktime_seg3_total
= 0;
2101 phba
->ktime_seg3_max
= 0;
2102 phba
->ktime_seg3_min
= 0xffffffff;
2103 phba
->ktime_seg4_total
= 0;
2104 phba
->ktime_seg4_max
= 0;
2105 phba
->ktime_seg4_min
= 0xffffffff;
2106 phba
->ktime_seg5_total
= 0;
2107 phba
->ktime_seg5_max
= 0;
2108 phba
->ktime_seg5_min
= 0xffffffff;
2109 phba
->ktime_seg6_total
= 0;
2110 phba
->ktime_seg6_max
= 0;
2111 phba
->ktime_seg6_min
= 0xffffffff;
2112 phba
->ktime_seg7_total
= 0;
2113 phba
->ktime_seg7_max
= 0;
2114 phba
->ktime_seg7_min
= 0xffffffff;
2115 phba
->ktime_seg8_total
= 0;
2116 phba
->ktime_seg8_max
= 0;
2117 phba
->ktime_seg8_min
= 0xffffffff;
2118 phba
->ktime_seg9_total
= 0;
2119 phba
->ktime_seg9_max
= 0;
2120 phba
->ktime_seg9_min
= 0xffffffff;
2121 phba
->ktime_seg10_total
= 0;
2122 phba
->ktime_seg10_max
= 0;
2123 phba
->ktime_seg10_min
= 0xffffffff;
2124 return strlen(pbuf
);
2130 lpfc_debugfs_nvmeio_trc_open(struct inode
*inode
, struct file
*file
)
2132 struct lpfc_hba
*phba
= inode
->i_private
;
2133 struct lpfc_debug
*debug
;
2136 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
2140 /* Round to page boundary */
2141 debug
->buffer
= kmalloc(LPFC_NVMEIO_TRC_SIZE
, GFP_KERNEL
);
2142 if (!debug
->buffer
) {
2147 debug
->len
= lpfc_debugfs_nvmeio_trc_data(phba
, debug
->buffer
,
2148 LPFC_NVMEIO_TRC_SIZE
);
2150 debug
->i_private
= inode
->i_private
;
2151 file
->private_data
= debug
;
2159 lpfc_debugfs_nvmeio_trc_write(struct file
*file
, const char __user
*buf
,
2160 size_t nbytes
, loff_t
*ppos
)
2162 struct lpfc_debug
*debug
= file
->private_data
;
2163 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
2172 /* Protect copy from user */
2173 if (!access_ok(VERIFY_READ
, buf
, nbytes
))
2176 memset(mybuf
, 0, sizeof(mybuf
));
2178 if (copy_from_user(mybuf
, buf
, nbytes
))
2182 if ((strncmp(pbuf
, "off", sizeof("off") - 1) == 0)) {
2183 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
2184 "0570 nvmeio_trc_off\n");
2185 phba
->nvmeio_trc_output_idx
= 0;
2186 phba
->nvmeio_trc_on
= 0;
2187 return strlen(pbuf
);
2188 } else if ((strncmp(pbuf
, "on", sizeof("on") - 1) == 0)) {
2189 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
2190 "0571 nvmeio_trc_on\n");
2191 phba
->nvmeio_trc_output_idx
= 0;
2192 phba
->nvmeio_trc_on
= 1;
2193 return strlen(pbuf
);
2196 /* We must be off to allocate the trace buffer */
2197 if (phba
->nvmeio_trc_on
!= 0)
2200 /* If not on or off, the parameter is the trace buffer size */
2201 i
= kstrtoul(pbuf
, 0, &sz
);
2204 phba
->nvmeio_trc_size
= (uint32_t)sz
;
2206 /* It must be a power of 2 - round down */
2213 if (phba
->nvmeio_trc_size
!= sz
)
2214 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
2215 "0572 nvmeio_trc_size changed to %ld\n",
2217 phba
->nvmeio_trc_size
= (uint32_t)sz
;
2219 /* If one previously exists, free it */
2220 kfree(phba
->nvmeio_trc
);
2222 /* Allocate new trace buffer and initialize */
2223 phba
->nvmeio_trc
= kmalloc((sizeof(struct lpfc_debugfs_nvmeio_trc
) *
2225 if (!phba
->nvmeio_trc
) {
2226 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
2227 "0573 Cannot create debugfs "
2228 "nvmeio_trc buffer\n");
2231 memset(phba
->nvmeio_trc
, 0,
2232 (sizeof(struct lpfc_debugfs_nvmeio_trc
) * sz
));
2233 atomic_set(&phba
->nvmeio_trc_cnt
, 0);
2234 phba
->nvmeio_trc_on
= 0;
2235 phba
->nvmeio_trc_output_idx
= 0;
2237 return strlen(pbuf
);
2241 lpfc_debugfs_cpucheck_open(struct inode
*inode
, struct file
*file
)
2243 struct lpfc_vport
*vport
= inode
->i_private
;
2244 struct lpfc_debug
*debug
;
2247 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
2251 /* Round to page boundary */
2252 debug
->buffer
= kmalloc(LPFC_CPUCHECK_SIZE
, GFP_KERNEL
);
2253 if (!debug
->buffer
) {
2258 debug
->len
= lpfc_debugfs_cpucheck_data(vport
, debug
->buffer
,
2259 LPFC_NVMEKTIME_SIZE
);
2261 debug
->i_private
= inode
->i_private
;
2262 file
->private_data
= debug
;
2270 lpfc_debugfs_cpucheck_write(struct file
*file
, const char __user
*buf
,
2271 size_t nbytes
, loff_t
*ppos
)
2273 struct lpfc_debug
*debug
= file
->private_data
;
2274 struct lpfc_vport
*vport
= (struct lpfc_vport
*)debug
->i_private
;
2275 struct lpfc_hba
*phba
= vport
->phba
;
2283 /* Protect copy from user */
2284 if (!access_ok(VERIFY_READ
, buf
, nbytes
))
2287 memset(mybuf
, 0, sizeof(mybuf
));
2289 if (copy_from_user(mybuf
, buf
, nbytes
))
2293 if ((strncmp(pbuf
, "on", sizeof("on") - 1) == 0)) {
2294 if (phba
->nvmet_support
)
2295 phba
->cpucheck_on
|= LPFC_CHECK_NVMET_IO
;
2297 phba
->cpucheck_on
|= LPFC_CHECK_NVME_IO
;
2298 return strlen(pbuf
);
2299 } else if ((strncmp(pbuf
, "rcv",
2300 sizeof("rcv") - 1) == 0)) {
2301 if (phba
->nvmet_support
)
2302 phba
->cpucheck_on
|= LPFC_CHECK_NVMET_RCV
;
2305 return strlen(pbuf
);
2306 } else if ((strncmp(pbuf
, "off",
2307 sizeof("off") - 1) == 0)) {
2308 phba
->cpucheck_on
= LPFC_CHECK_OFF
;
2309 return strlen(pbuf
);
2310 } else if ((strncmp(pbuf
, "zero",
2311 sizeof("zero") - 1) == 0)) {
2312 for (i
= 0; i
< phba
->sli4_hba
.num_present_cpu
; i
++) {
2313 if (i
>= LPFC_CHECK_CPU_CNT
)
2315 phba
->cpucheck_rcv_io
[i
] = 0;
2316 phba
->cpucheck_xmt_io
[i
] = 0;
2317 phba
->cpucheck_cmpl_io
[i
] = 0;
2318 phba
->cpucheck_ccmpl_io
[i
] = 0;
2320 return strlen(pbuf
);
2326 * ---------------------------------
2327 * iDiag debugfs file access methods
2328 * ---------------------------------
2330 * All access methods are through the proper SLI4 PCI function's debugfs
2333 * /sys/kernel/debug/lpfc/fn<#>/iDiag
2337 * lpfc_idiag_cmd_get - Get and parse idiag debugfs comands from user space
2338 * @buf: The pointer to the user space buffer.
2339 * @nbytes: The number of bytes in the user space buffer.
2340 * @idiag_cmd: pointer to the idiag command struct.
2342 * This routine reads data from debugfs user space buffer and parses the
2343 * buffer for getting the idiag command and arguments. The while space in
2344 * between the set of data is used as the parsing separator.
2346 * This routine returns 0 when successful, it returns proper error code
2347 * back to the user space in error conditions.
2349 static int lpfc_idiag_cmd_get(const char __user
*buf
, size_t nbytes
,
2350 struct lpfc_idiag_cmd
*idiag_cmd
)
2353 char *pbuf
, *step_str
;
2357 /* Protect copy from user */
2358 if (!access_ok(VERIFY_READ
, buf
, nbytes
))
2361 memset(mybuf
, 0, sizeof(mybuf
));
2362 memset(idiag_cmd
, 0, sizeof(*idiag_cmd
));
2363 bsize
= min(nbytes
, (sizeof(mybuf
)-1));
2365 if (copy_from_user(mybuf
, buf
, bsize
))
2368 step_str
= strsep(&pbuf
, "\t ");
2370 /* The opcode must present */
2374 idiag_cmd
->opcode
= simple_strtol(step_str
, NULL
, 0);
2375 if (idiag_cmd
->opcode
== 0)
2378 for (i
= 0; i
< LPFC_IDIAG_CMD_DATA_SIZE
; i
++) {
2379 step_str
= strsep(&pbuf
, "\t ");
2382 idiag_cmd
->data
[i
] = simple_strtol(step_str
, NULL
, 0);
2388 * lpfc_idiag_open - idiag open debugfs
2389 * @inode: The inode pointer that contains a pointer to phba.
2390 * @file: The file pointer to attach the file operation.
2393 * This routine is the entry point for the debugfs open file operation. It
2394 * gets the reference to phba from the i_private field in @inode, it then
2395 * allocates buffer for the file operation, performs the necessary PCI config
2396 * space read into the allocated buffer according to the idiag user command
2397 * setup, and then returns a pointer to buffer in the private_data field in
2401 * This function returns zero if successful. On error it will return an
2402 * negative error value.
2405 lpfc_idiag_open(struct inode
*inode
, struct file
*file
)
2407 struct lpfc_debug
*debug
;
2409 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
2413 debug
->i_private
= inode
->i_private
;
2414 debug
->buffer
= NULL
;
2415 file
->private_data
= debug
;
2421 * lpfc_idiag_release - Release idiag access file operation
2422 * @inode: The inode pointer that contains a vport pointer. (unused)
2423 * @file: The file pointer that contains the buffer to release.
2426 * This routine is the generic release routine for the idiag access file
2427 * operation, it frees the buffer that was allocated when the debugfs file
2431 * This function returns zero.
2434 lpfc_idiag_release(struct inode
*inode
, struct file
*file
)
2436 struct lpfc_debug
*debug
= file
->private_data
;
2438 /* Free the buffers to the file operation */
2439 kfree(debug
->buffer
);
2446 * lpfc_idiag_cmd_release - Release idiag cmd access file operation
2447 * @inode: The inode pointer that contains a vport pointer. (unused)
2448 * @file: The file pointer that contains the buffer to release.
2451 * This routine frees the buffer that was allocated when the debugfs file
2452 * was opened. It also reset the fields in the idiag command struct in the
2453 * case of command for write operation.
2456 * This function returns zero.
2459 lpfc_idiag_cmd_release(struct inode
*inode
, struct file
*file
)
2461 struct lpfc_debug
*debug
= file
->private_data
;
2463 if (debug
->op
== LPFC_IDIAG_OP_WR
) {
2464 switch (idiag
.cmd
.opcode
) {
2465 case LPFC_IDIAG_CMD_PCICFG_WR
:
2466 case LPFC_IDIAG_CMD_PCICFG_ST
:
2467 case LPFC_IDIAG_CMD_PCICFG_CL
:
2468 case LPFC_IDIAG_CMD_QUEACC_WR
:
2469 case LPFC_IDIAG_CMD_QUEACC_ST
:
2470 case LPFC_IDIAG_CMD_QUEACC_CL
:
2471 memset(&idiag
, 0, sizeof(idiag
));
2478 /* Free the buffers to the file operation */
2479 kfree(debug
->buffer
);
2486 * lpfc_idiag_pcicfg_read - idiag debugfs read pcicfg
2487 * @file: The file pointer to read from.
2488 * @buf: The buffer to copy the data to.
2489 * @nbytes: The number of bytes to read.
2490 * @ppos: The position in the file to start reading from.
2493 * This routine reads data from the @phba pci config space according to the
2494 * idiag command, and copies to user @buf. Depending on the PCI config space
2495 * read command setup, it does either a single register read of a byte
2496 * (8 bits), a word (16 bits), or a dword (32 bits) or browsing through all
2497 * registers from the 4K extended PCI config space.
2500 * This function returns the amount of data that was read (this could be less
2501 * than @nbytes if the end of the file was reached) or a negative error value.
2504 lpfc_idiag_pcicfg_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
2507 struct lpfc_debug
*debug
= file
->private_data
;
2508 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
2509 int offset_label
, offset
, len
= 0, index
= LPFC_PCI_CFG_RD_SIZE
;
2512 struct pci_dev
*pdev
;
2517 pdev
= phba
->pcidev
;
2521 /* This is a user read operation */
2522 debug
->op
= LPFC_IDIAG_OP_RD
;
2525 debug
->buffer
= kmalloc(LPFC_PCI_CFG_SIZE
, GFP_KERNEL
);
2528 pbuffer
= debug
->buffer
;
2533 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_RD
) {
2534 where
= idiag
.cmd
.data
[IDIAG_PCICFG_WHERE_INDX
];
2535 count
= idiag
.cmd
.data
[IDIAG_PCICFG_COUNT_INDX
];
2539 /* Read single PCI config space register */
2541 case SIZE_U8
: /* byte (8 bits) */
2542 pci_read_config_byte(pdev
, where
, &u8val
);
2543 len
+= snprintf(pbuffer
+len
, LPFC_PCI_CFG_SIZE
-len
,
2544 "%03x: %02x\n", where
, u8val
);
2546 case SIZE_U16
: /* word (16 bits) */
2547 pci_read_config_word(pdev
, where
, &u16val
);
2548 len
+= snprintf(pbuffer
+len
, LPFC_PCI_CFG_SIZE
-len
,
2549 "%03x: %04x\n", where
, u16val
);
2551 case SIZE_U32
: /* double word (32 bits) */
2552 pci_read_config_dword(pdev
, where
, &u32val
);
2553 len
+= snprintf(pbuffer
+len
, LPFC_PCI_CFG_SIZE
-len
,
2554 "%03x: %08x\n", where
, u32val
);
2556 case LPFC_PCI_CFG_BROWSE
: /* browse all */
2564 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
2568 /* Browse all PCI config space registers */
2569 offset_label
= idiag
.offset
.last_rd
;
2570 offset
= offset_label
;
2572 /* Read PCI config space */
2573 len
+= snprintf(pbuffer
+len
, LPFC_PCI_CFG_SIZE
-len
,
2574 "%03x: ", offset_label
);
2576 pci_read_config_dword(pdev
, offset
, &u32val
);
2577 len
+= snprintf(pbuffer
+len
, LPFC_PCI_CFG_SIZE
-len
,
2579 offset
+= sizeof(uint32_t);
2580 if (offset
>= LPFC_PCI_CFG_SIZE
) {
2581 len
+= snprintf(pbuffer
+len
,
2582 LPFC_PCI_CFG_SIZE
-len
, "\n");
2585 index
-= sizeof(uint32_t);
2587 len
+= snprintf(pbuffer
+len
, LPFC_PCI_CFG_SIZE
-len
,
2589 else if (!(index
% (8 * sizeof(uint32_t)))) {
2590 offset_label
+= (8 * sizeof(uint32_t));
2591 len
+= snprintf(pbuffer
+len
, LPFC_PCI_CFG_SIZE
-len
,
2592 "\n%03x: ", offset_label
);
2596 /* Set up the offset for next portion of pci cfg read */
2598 idiag
.offset
.last_rd
+= LPFC_PCI_CFG_RD_SIZE
;
2599 if (idiag
.offset
.last_rd
>= LPFC_PCI_CFG_SIZE
)
2600 idiag
.offset
.last_rd
= 0;
2602 idiag
.offset
.last_rd
= 0;
2604 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
2608 * lpfc_idiag_pcicfg_write - Syntax check and set up idiag pcicfg commands
2609 * @file: The file pointer to read from.
2610 * @buf: The buffer to copy the user data from.
2611 * @nbytes: The number of bytes to get.
2612 * @ppos: The position in the file to start reading from.
2614 * This routine get the debugfs idiag command struct from user space and
2615 * then perform the syntax check for PCI config space read or write command
2616 * accordingly. In the case of PCI config space read command, it sets up
2617 * the command in the idiag command struct for the debugfs read operation.
2618 * In the case of PCI config space write operation, it executes the write
2619 * operation into the PCI config space accordingly.
2621 * It returns the @nbytges passing in from debugfs user space when successful.
2622 * In case of error conditions, it returns proper error code back to the user
2626 lpfc_idiag_pcicfg_write(struct file
*file
, const char __user
*buf
,
2627 size_t nbytes
, loff_t
*ppos
)
2629 struct lpfc_debug
*debug
= file
->private_data
;
2630 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
2631 uint32_t where
, value
, count
;
2635 struct pci_dev
*pdev
;
2638 pdev
= phba
->pcidev
;
2642 /* This is a user write operation */
2643 debug
->op
= LPFC_IDIAG_OP_WR
;
2645 rc
= lpfc_idiag_cmd_get(buf
, nbytes
, &idiag
.cmd
);
2649 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_RD
) {
2650 /* Sanity check on PCI config read command line arguments */
2651 if (rc
!= LPFC_PCI_CFG_RD_CMD_ARG
)
2653 /* Read command from PCI config space, set up command fields */
2654 where
= idiag
.cmd
.data
[IDIAG_PCICFG_WHERE_INDX
];
2655 count
= idiag
.cmd
.data
[IDIAG_PCICFG_COUNT_INDX
];
2656 if (count
== LPFC_PCI_CFG_BROWSE
) {
2657 if (where
% sizeof(uint32_t))
2659 /* Starting offset to browse */
2660 idiag
.offset
.last_rd
= where
;
2661 } else if ((count
!= sizeof(uint8_t)) &&
2662 (count
!= sizeof(uint16_t)) &&
2663 (count
!= sizeof(uint32_t)))
2665 if (count
== sizeof(uint8_t)) {
2666 if (where
> LPFC_PCI_CFG_SIZE
- sizeof(uint8_t))
2668 if (where
% sizeof(uint8_t))
2671 if (count
== sizeof(uint16_t)) {
2672 if (where
> LPFC_PCI_CFG_SIZE
- sizeof(uint16_t))
2674 if (where
% sizeof(uint16_t))
2677 if (count
== sizeof(uint32_t)) {
2678 if (where
> LPFC_PCI_CFG_SIZE
- sizeof(uint32_t))
2680 if (where
% sizeof(uint32_t))
2683 } else if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_WR
||
2684 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_ST
||
2685 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_CL
) {
2686 /* Sanity check on PCI config write command line arguments */
2687 if (rc
!= LPFC_PCI_CFG_WR_CMD_ARG
)
2689 /* Write command to PCI config space, read-modify-write */
2690 where
= idiag
.cmd
.data
[IDIAG_PCICFG_WHERE_INDX
];
2691 count
= idiag
.cmd
.data
[IDIAG_PCICFG_COUNT_INDX
];
2692 value
= idiag
.cmd
.data
[IDIAG_PCICFG_VALUE_INDX
];
2694 if ((count
!= sizeof(uint8_t)) &&
2695 (count
!= sizeof(uint16_t)) &&
2696 (count
!= sizeof(uint32_t)))
2698 if (count
== sizeof(uint8_t)) {
2699 if (where
> LPFC_PCI_CFG_SIZE
- sizeof(uint8_t))
2701 if (where
% sizeof(uint8_t))
2703 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_WR
)
2704 pci_write_config_byte(pdev
, where
,
2706 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_ST
) {
2707 rc
= pci_read_config_byte(pdev
, where
, &u8val
);
2709 u8val
|= (uint8_t)value
;
2710 pci_write_config_byte(pdev
, where
,
2714 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_CL
) {
2715 rc
= pci_read_config_byte(pdev
, where
, &u8val
);
2717 u8val
&= (uint8_t)(~value
);
2718 pci_write_config_byte(pdev
, where
,
2723 if (count
== sizeof(uint16_t)) {
2724 if (where
> LPFC_PCI_CFG_SIZE
- sizeof(uint16_t))
2726 if (where
% sizeof(uint16_t))
2728 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_WR
)
2729 pci_write_config_word(pdev
, where
,
2731 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_ST
) {
2732 rc
= pci_read_config_word(pdev
, where
, &u16val
);
2734 u16val
|= (uint16_t)value
;
2735 pci_write_config_word(pdev
, where
,
2739 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_CL
) {
2740 rc
= pci_read_config_word(pdev
, where
, &u16val
);
2742 u16val
&= (uint16_t)(~value
);
2743 pci_write_config_word(pdev
, where
,
2748 if (count
== sizeof(uint32_t)) {
2749 if (where
> LPFC_PCI_CFG_SIZE
- sizeof(uint32_t))
2751 if (where
% sizeof(uint32_t))
2753 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_WR
)
2754 pci_write_config_dword(pdev
, where
, value
);
2755 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_ST
) {
2756 rc
= pci_read_config_dword(pdev
, where
,
2760 pci_write_config_dword(pdev
, where
,
2764 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_CL
) {
2765 rc
= pci_read_config_dword(pdev
, where
,
2769 pci_write_config_dword(pdev
, where
,
2775 /* All other opecodes are illegal for now */
2780 memset(&idiag
, 0, sizeof(idiag
));
2785 * lpfc_idiag_baracc_read - idiag debugfs pci bar access read
2786 * @file: The file pointer to read from.
2787 * @buf: The buffer to copy the data to.
2788 * @nbytes: The number of bytes to read.
2789 * @ppos: The position in the file to start reading from.
2792 * This routine reads data from the @phba pci bar memory mapped space
2793 * according to the idiag command, and copies to user @buf.
2796 * This function returns the amount of data that was read (this could be less
2797 * than @nbytes if the end of the file was reached) or a negative error value.
2800 lpfc_idiag_baracc_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
2803 struct lpfc_debug
*debug
= file
->private_data
;
2804 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
2805 int offset_label
, offset
, offset_run
, len
= 0, index
;
2806 int bar_num
, acc_range
, bar_size
;
2808 void __iomem
*mem_mapped_bar
;
2810 struct pci_dev
*pdev
;
2813 pdev
= phba
->pcidev
;
2817 /* This is a user read operation */
2818 debug
->op
= LPFC_IDIAG_OP_RD
;
2821 debug
->buffer
= kmalloc(LPFC_PCI_BAR_RD_BUF_SIZE
, GFP_KERNEL
);
2824 pbuffer
= debug
->buffer
;
2829 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_RD
) {
2830 bar_num
= idiag
.cmd
.data
[IDIAG_BARACC_BAR_NUM_INDX
];
2831 offset
= idiag
.cmd
.data
[IDIAG_BARACC_OFF_SET_INDX
];
2832 acc_range
= idiag
.cmd
.data
[IDIAG_BARACC_ACC_MOD_INDX
];
2833 bar_size
= idiag
.cmd
.data
[IDIAG_BARACC_BAR_SZE_INDX
];
2840 if_type
= bf_get(lpfc_sli_intf_if_type
, &phba
->sli4_hba
.sli_intf
);
2841 if (if_type
== LPFC_SLI_INTF_IF_TYPE_0
) {
2842 if (bar_num
== IDIAG_BARACC_BAR_0
)
2843 mem_mapped_bar
= phba
->sli4_hba
.conf_regs_memmap_p
;
2844 else if (bar_num
== IDIAG_BARACC_BAR_1
)
2845 mem_mapped_bar
= phba
->sli4_hba
.ctrl_regs_memmap_p
;
2846 else if (bar_num
== IDIAG_BARACC_BAR_2
)
2847 mem_mapped_bar
= phba
->sli4_hba
.drbl_regs_memmap_p
;
2850 } else if (if_type
== LPFC_SLI_INTF_IF_TYPE_2
) {
2851 if (bar_num
== IDIAG_BARACC_BAR_0
)
2852 mem_mapped_bar
= phba
->sli4_hba
.conf_regs_memmap_p
;
2858 /* Read single PCI bar space register */
2859 if (acc_range
== SINGLE_WORD
) {
2860 offset_run
= offset
;
2861 u32val
= readl(mem_mapped_bar
+ offset_run
);
2862 len
+= snprintf(pbuffer
+len
, LPFC_PCI_BAR_RD_BUF_SIZE
-len
,
2863 "%05x: %08x\n", offset_run
, u32val
);
2867 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
2871 /* Browse all PCI bar space registers */
2872 offset_label
= idiag
.offset
.last_rd
;
2873 offset_run
= offset_label
;
2875 /* Read PCI bar memory mapped space */
2876 len
+= snprintf(pbuffer
+len
, LPFC_PCI_BAR_RD_BUF_SIZE
-len
,
2877 "%05x: ", offset_label
);
2878 index
= LPFC_PCI_BAR_RD_SIZE
;
2880 u32val
= readl(mem_mapped_bar
+ offset_run
);
2881 len
+= snprintf(pbuffer
+len
, LPFC_PCI_BAR_RD_BUF_SIZE
-len
,
2883 offset_run
+= sizeof(uint32_t);
2884 if (acc_range
== LPFC_PCI_BAR_BROWSE
) {
2885 if (offset_run
>= bar_size
) {
2886 len
+= snprintf(pbuffer
+len
,
2887 LPFC_PCI_BAR_RD_BUF_SIZE
-len
, "\n");
2891 if (offset_run
>= offset
+
2892 (acc_range
* sizeof(uint32_t))) {
2893 len
+= snprintf(pbuffer
+len
,
2894 LPFC_PCI_BAR_RD_BUF_SIZE
-len
, "\n");
2898 index
-= sizeof(uint32_t);
2900 len
+= snprintf(pbuffer
+len
,
2901 LPFC_PCI_BAR_RD_BUF_SIZE
-len
, "\n");
2902 else if (!(index
% (8 * sizeof(uint32_t)))) {
2903 offset_label
+= (8 * sizeof(uint32_t));
2904 len
+= snprintf(pbuffer
+len
,
2905 LPFC_PCI_BAR_RD_BUF_SIZE
-len
,
2906 "\n%05x: ", offset_label
);
2910 /* Set up the offset for next portion of pci bar read */
2912 idiag
.offset
.last_rd
+= LPFC_PCI_BAR_RD_SIZE
;
2913 if (acc_range
== LPFC_PCI_BAR_BROWSE
) {
2914 if (idiag
.offset
.last_rd
>= bar_size
)
2915 idiag
.offset
.last_rd
= 0;
2917 if (offset_run
>= offset
+
2918 (acc_range
* sizeof(uint32_t)))
2919 idiag
.offset
.last_rd
= offset
;
2922 if (acc_range
== LPFC_PCI_BAR_BROWSE
)
2923 idiag
.offset
.last_rd
= 0;
2925 idiag
.offset
.last_rd
= offset
;
2928 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
2932 * lpfc_idiag_baracc_write - Syntax check and set up idiag bar access commands
2933 * @file: The file pointer to read from.
2934 * @buf: The buffer to copy the user data from.
2935 * @nbytes: The number of bytes to get.
2936 * @ppos: The position in the file to start reading from.
2938 * This routine get the debugfs idiag command struct from user space and
2939 * then perform the syntax check for PCI bar memory mapped space read or
2940 * write command accordingly. In the case of PCI bar memory mapped space
2941 * read command, it sets up the command in the idiag command struct for
2942 * the debugfs read operation. In the case of PCI bar memorpy mapped space
2943 * write operation, it executes the write operation into the PCI bar memory
2944 * mapped space accordingly.
2946 * It returns the @nbytges passing in from debugfs user space when successful.
2947 * In case of error conditions, it returns proper error code back to the user
2951 lpfc_idiag_baracc_write(struct file
*file
, const char __user
*buf
,
2952 size_t nbytes
, loff_t
*ppos
)
2954 struct lpfc_debug
*debug
= file
->private_data
;
2955 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
2956 uint32_t bar_num
, bar_size
, offset
, value
, acc_range
;
2957 struct pci_dev
*pdev
;
2958 void __iomem
*mem_mapped_bar
;
2963 pdev
= phba
->pcidev
;
2967 /* This is a user write operation */
2968 debug
->op
= LPFC_IDIAG_OP_WR
;
2970 rc
= lpfc_idiag_cmd_get(buf
, nbytes
, &idiag
.cmd
);
2974 if_type
= bf_get(lpfc_sli_intf_if_type
, &phba
->sli4_hba
.sli_intf
);
2975 bar_num
= idiag
.cmd
.data
[IDIAG_BARACC_BAR_NUM_INDX
];
2977 if (if_type
== LPFC_SLI_INTF_IF_TYPE_0
) {
2978 if ((bar_num
!= IDIAG_BARACC_BAR_0
) &&
2979 (bar_num
!= IDIAG_BARACC_BAR_1
) &&
2980 (bar_num
!= IDIAG_BARACC_BAR_2
))
2982 } else if (if_type
== LPFC_SLI_INTF_IF_TYPE_2
) {
2983 if (bar_num
!= IDIAG_BARACC_BAR_0
)
2988 if (if_type
== LPFC_SLI_INTF_IF_TYPE_0
) {
2989 if (bar_num
== IDIAG_BARACC_BAR_0
) {
2990 idiag
.cmd
.data
[IDIAG_BARACC_BAR_SZE_INDX
] =
2991 LPFC_PCI_IF0_BAR0_SIZE
;
2992 mem_mapped_bar
= phba
->sli4_hba
.conf_regs_memmap_p
;
2993 } else if (bar_num
== IDIAG_BARACC_BAR_1
) {
2994 idiag
.cmd
.data
[IDIAG_BARACC_BAR_SZE_INDX
] =
2995 LPFC_PCI_IF0_BAR1_SIZE
;
2996 mem_mapped_bar
= phba
->sli4_hba
.ctrl_regs_memmap_p
;
2997 } else if (bar_num
== IDIAG_BARACC_BAR_2
) {
2998 idiag
.cmd
.data
[IDIAG_BARACC_BAR_SZE_INDX
] =
2999 LPFC_PCI_IF0_BAR2_SIZE
;
3000 mem_mapped_bar
= phba
->sli4_hba
.drbl_regs_memmap_p
;
3003 } else if (if_type
== LPFC_SLI_INTF_IF_TYPE_2
) {
3004 if (bar_num
== IDIAG_BARACC_BAR_0
) {
3005 idiag
.cmd
.data
[IDIAG_BARACC_BAR_SZE_INDX
] =
3006 LPFC_PCI_IF2_BAR0_SIZE
;
3007 mem_mapped_bar
= phba
->sli4_hba
.conf_regs_memmap_p
;
3013 offset
= idiag
.cmd
.data
[IDIAG_BARACC_OFF_SET_INDX
];
3014 if (offset
% sizeof(uint32_t))
3017 bar_size
= idiag
.cmd
.data
[IDIAG_BARACC_BAR_SZE_INDX
];
3018 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_RD
) {
3019 /* Sanity check on PCI config read command line arguments */
3020 if (rc
!= LPFC_PCI_BAR_RD_CMD_ARG
)
3022 acc_range
= idiag
.cmd
.data
[IDIAG_BARACC_ACC_MOD_INDX
];
3023 if (acc_range
== LPFC_PCI_BAR_BROWSE
) {
3024 if (offset
> bar_size
- sizeof(uint32_t))
3026 /* Starting offset to browse */
3027 idiag
.offset
.last_rd
= offset
;
3028 } else if (acc_range
> SINGLE_WORD
) {
3029 if (offset
+ acc_range
* sizeof(uint32_t) > bar_size
)
3031 /* Starting offset to browse */
3032 idiag
.offset
.last_rd
= offset
;
3033 } else if (acc_range
!= SINGLE_WORD
)
3035 } else if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_WR
||
3036 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_ST
||
3037 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_CL
) {
3038 /* Sanity check on PCI bar write command line arguments */
3039 if (rc
!= LPFC_PCI_BAR_WR_CMD_ARG
)
3041 /* Write command to PCI bar space, read-modify-write */
3042 acc_range
= SINGLE_WORD
;
3043 value
= idiag
.cmd
.data
[IDIAG_BARACC_REG_VAL_INDX
];
3044 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_WR
) {
3045 writel(value
, mem_mapped_bar
+ offset
);
3046 readl(mem_mapped_bar
+ offset
);
3048 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_ST
) {
3049 u32val
= readl(mem_mapped_bar
+ offset
);
3051 writel(u32val
, mem_mapped_bar
+ offset
);
3052 readl(mem_mapped_bar
+ offset
);
3054 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_CL
) {
3055 u32val
= readl(mem_mapped_bar
+ offset
);
3057 writel(u32val
, mem_mapped_bar
+ offset
);
3058 readl(mem_mapped_bar
+ offset
);
3061 /* All other opecodes are illegal for now */
3066 memset(&idiag
, 0, sizeof(idiag
));
3071 __lpfc_idiag_print_wq(struct lpfc_queue
*qp
, char *wqtype
,
3072 char *pbuffer
, int len
)
3077 len
+= snprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3078 "\t\t%s WQ info: ", wqtype
);
3079 len
+= snprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3080 "AssocCQID[%04d]: WQ-STAT[oflow:x%x posted:x%llx]\n",
3081 qp
->assoc_qid
, qp
->q_cnt_1
,
3082 (unsigned long long)qp
->q_cnt_4
);
3083 len
+= snprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3084 "\t\tWQID[%02d], QE-CNT[%04d], QE-SZ[%04d], "
3085 "HST-IDX[%04d], PRT-IDX[%04d], PST[%03d]",
3086 qp
->queue_id
, qp
->entry_count
,
3087 qp
->entry_size
, qp
->host_index
,
3088 qp
->hba_index
, qp
->entry_repost
);
3089 len
+= snprintf(pbuffer
+ len
,
3090 LPFC_QUE_INFO_GET_BUF_SIZE
- len
, "\n");
3095 lpfc_idiag_wqs_for_cq(struct lpfc_hba
*phba
, char *wqtype
, char *pbuffer
,
3096 int *len
, int max_cnt
, int cq_id
)
3098 struct lpfc_queue
*qp
;
3101 for (qidx
= 0; qidx
< phba
->cfg_fcp_io_channel
; qidx
++) {
3102 qp
= phba
->sli4_hba
.fcp_wq
[qidx
];
3103 if (qp
->assoc_qid
!= cq_id
)
3105 *len
= __lpfc_idiag_print_wq(qp
, wqtype
, pbuffer
, *len
);
3106 if (*len
>= max_cnt
)
3109 for (qidx
= 0; qidx
< phba
->cfg_nvme_io_channel
; qidx
++) {
3110 qp
= phba
->sli4_hba
.nvme_wq
[qidx
];
3111 if (qp
->assoc_qid
!= cq_id
)
3113 *len
= __lpfc_idiag_print_wq(qp
, wqtype
, pbuffer
, *len
);
3114 if (*len
>= max_cnt
)
3121 __lpfc_idiag_print_cq(struct lpfc_queue
*qp
, char *cqtype
,
3122 char *pbuffer
, int len
)
3127 len
+= snprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3128 "\t%s CQ info: ", cqtype
);
3129 len
+= snprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3130 "AssocEQID[%02d]: CQ STAT[max:x%x relw:x%x "
3131 "xabt:x%x wq:x%llx]\n",
3132 qp
->assoc_qid
, qp
->q_cnt_1
, qp
->q_cnt_2
,
3133 qp
->q_cnt_3
, (unsigned long long)qp
->q_cnt_4
);
3134 len
+= snprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3135 "\tCQID[%02d], QE-CNT[%04d], QE-SZ[%04d], "
3136 "HST-IDX[%04d], PRT-IDX[%04d], PST[%03d]",
3137 qp
->queue_id
, qp
->entry_count
,
3138 qp
->entry_size
, qp
->host_index
,
3139 qp
->hba_index
, qp
->entry_repost
);
3141 len
+= snprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
, "\n");
3147 __lpfc_idiag_print_rqpair(struct lpfc_queue
*qp
, struct lpfc_queue
*datqp
,
3148 char *rqtype
, char *pbuffer
, int len
)
3153 len
+= snprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3154 "\t\t%s RQ info: ", rqtype
);
3155 len
+= snprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3156 "AssocCQID[%02d]: RQ-STAT[nopost:x%x nobuf:x%x "
3157 "posted:x%x rcv:x%llx]\n",
3158 qp
->assoc_qid
, qp
->q_cnt_1
, qp
->q_cnt_2
,
3159 qp
->q_cnt_3
, (unsigned long long)qp
->q_cnt_4
);
3160 len
+= snprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3161 "\t\tHQID[%02d], QE-CNT[%04d], QE-SZ[%04d], "
3162 "HST-IDX[%04d], PRT-IDX[%04d], PST[%03d]\n",
3163 qp
->queue_id
, qp
->entry_count
, qp
->entry_size
,
3164 qp
->host_index
, qp
->hba_index
, qp
->entry_repost
);
3165 len
+= snprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3166 "\t\tDQID[%02d], QE-CNT[%04d], QE-SZ[%04d], "
3167 "HST-IDX[%04d], PRT-IDX[%04d], PST[%03d]\n",
3168 datqp
->queue_id
, datqp
->entry_count
,
3169 datqp
->entry_size
, datqp
->host_index
,
3170 datqp
->hba_index
, datqp
->entry_repost
);
3175 lpfc_idiag_cqs_for_eq(struct lpfc_hba
*phba
, char *pbuffer
,
3176 int *len
, int max_cnt
, int eqidx
, int eq_id
)
3178 struct lpfc_queue
*qp
;
3181 for (qidx
= 0; qidx
< phba
->cfg_fcp_io_channel
; qidx
++) {
3182 qp
= phba
->sli4_hba
.fcp_cq
[qidx
];
3183 if (qp
->assoc_qid
!= eq_id
)
3186 *len
= __lpfc_idiag_print_cq(qp
, "FCP", pbuffer
, *len
);
3188 /* Reset max counter */
3191 if (*len
>= max_cnt
)
3194 rc
= lpfc_idiag_wqs_for_cq(phba
, "FCP", pbuffer
, len
,
3195 max_cnt
, qp
->queue_id
);
3200 for (qidx
= 0; qidx
< phba
->cfg_nvme_io_channel
; qidx
++) {
3201 qp
= phba
->sli4_hba
.nvme_cq
[qidx
];
3202 if (qp
->assoc_qid
!= eq_id
)
3205 *len
= __lpfc_idiag_print_cq(qp
, "NVME", pbuffer
, *len
);
3207 /* Reset max counter */
3210 if (*len
>= max_cnt
)
3213 rc
= lpfc_idiag_wqs_for_cq(phba
, "NVME", pbuffer
, len
,
3214 max_cnt
, qp
->queue_id
);
3219 if (eqidx
< phba
->cfg_nvmet_mrq
) {
3221 qp
= phba
->sli4_hba
.nvmet_cqset
[eqidx
];
3222 *len
= __lpfc_idiag_print_cq(qp
, "NVMET CQset", pbuffer
, *len
);
3224 /* Reset max counter */
3227 if (*len
>= max_cnt
)
3231 qp
= phba
->sli4_hba
.nvmet_mrq_hdr
[eqidx
];
3232 *len
= __lpfc_idiag_print_rqpair(qp
,
3233 phba
->sli4_hba
.nvmet_mrq_data
[eqidx
],
3234 "NVMET MRQ", pbuffer
, *len
);
3236 if (*len
>= max_cnt
)
3244 __lpfc_idiag_print_eq(struct lpfc_queue
*qp
, char *eqtype
,
3245 char *pbuffer
, int len
)
3250 len
+= snprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3251 "\n%s EQ info: EQ-STAT[max:x%x noE:x%x "
3252 "bs:x%x proc:x%llx]\n",
3253 eqtype
, qp
->q_cnt_1
, qp
->q_cnt_2
, qp
->q_cnt_3
,
3254 (unsigned long long)qp
->q_cnt_4
);
3255 len
+= snprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3256 "EQID[%02d], QE-CNT[%04d], QE-SZ[%04d], "
3257 "HST-IDX[%04d], PRT-IDX[%04d], PST[%03d]",
3258 qp
->queue_id
, qp
->entry_count
, qp
->entry_size
,
3259 qp
->host_index
, qp
->hba_index
, qp
->entry_repost
);
3260 len
+= snprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
, "\n");
3266 * lpfc_idiag_queinfo_read - idiag debugfs read queue information
3267 * @file: The file pointer to read from.
3268 * @buf: The buffer to copy the data to.
3269 * @nbytes: The number of bytes to read.
3270 * @ppos: The position in the file to start reading from.
3273 * This routine reads data from the @phba SLI4 PCI function queue information,
3274 * and copies to user @buf.
3275 * This routine only returns 1 EQs worth of information. It remembers the last
3276 * EQ read and jumps to the next EQ. Thus subsequent calls to queInfo will
3277 * retrieve all EQs allocated for the phba.
3280 * This function returns the amount of data that was read (this could be less
3281 * than @nbytes if the end of the file was reached) or a negative error value.
3284 lpfc_idiag_queinfo_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
3287 struct lpfc_debug
*debug
= file
->private_data
;
3288 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
3290 int max_cnt
, rc
, x
, len
= 0;
3291 struct lpfc_queue
*qp
= NULL
;
3294 debug
->buffer
= kmalloc(LPFC_QUE_INFO_GET_BUF_SIZE
, GFP_KERNEL
);
3297 pbuffer
= debug
->buffer
;
3298 max_cnt
= LPFC_QUE_INFO_GET_BUF_SIZE
- 256;
3303 spin_lock_irq(&phba
->hbalock
);
3305 /* Fast-path event queue */
3306 if (phba
->sli4_hba
.hba_eq
&& phba
->io_channel_irqs
) {
3308 x
= phba
->lpfc_idiag_last_eq
;
3309 if (phba
->cfg_fof
&& (x
>= phba
->io_channel_irqs
)) {
3310 phba
->lpfc_idiag_last_eq
= 0;
3313 phba
->lpfc_idiag_last_eq
++;
3314 if (phba
->lpfc_idiag_last_eq
>= phba
->io_channel_irqs
)
3315 if (phba
->cfg_fof
== 0)
3316 phba
->lpfc_idiag_last_eq
= 0;
3318 len
+= snprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3319 "EQ %d out of %d HBA EQs\n",
3320 x
, phba
->io_channel_irqs
);
3323 qp
= phba
->sli4_hba
.hba_eq
[x
];
3327 len
= __lpfc_idiag_print_eq(qp
, "HBA", pbuffer
, len
);
3329 /* Reset max counter */
3335 /* will dump both fcp and nvme cqs/wqs for the eq */
3336 rc
= lpfc_idiag_cqs_for_eq(phba
, pbuffer
, &len
,
3337 max_cnt
, x
, qp
->queue_id
);
3341 /* Only EQ 0 has slow path CQs configured */
3345 /* Slow-path mailbox CQ */
3346 qp
= phba
->sli4_hba
.mbx_cq
;
3347 len
= __lpfc_idiag_print_cq(qp
, "MBX", pbuffer
, len
);
3351 /* Slow-path MBOX MQ */
3352 qp
= phba
->sli4_hba
.mbx_wq
;
3353 len
= __lpfc_idiag_print_wq(qp
, "MBX", pbuffer
, len
);
3357 /* Slow-path ELS response CQ */
3358 qp
= phba
->sli4_hba
.els_cq
;
3359 len
= __lpfc_idiag_print_cq(qp
, "ELS", pbuffer
, len
);
3360 /* Reset max counter */
3366 /* Slow-path ELS WQ */
3367 qp
= phba
->sli4_hba
.els_wq
;
3368 len
= __lpfc_idiag_print_wq(qp
, "ELS", pbuffer
, len
);
3372 /* Slow-path NVME LS response CQ */
3373 qp
= phba
->sli4_hba
.nvmels_cq
;
3374 len
= __lpfc_idiag_print_cq(qp
, "NVME LS",
3376 /* Reset max counter */
3382 /* Slow-path NVME LS WQ */
3383 qp
= phba
->sli4_hba
.nvmels_wq
;
3384 len
= __lpfc_idiag_print_wq(qp
, "NVME LS",
3389 qp
= phba
->sli4_hba
.hdr_rq
;
3390 len
= __lpfc_idiag_print_rqpair(qp
, phba
->sli4_hba
.dat_rq
,
3391 "RQpair", pbuffer
, len
);
3399 if (phba
->cfg_fof
) {
3401 qp
= phba
->sli4_hba
.fof_eq
;
3402 len
= __lpfc_idiag_print_eq(qp
, "FOF", pbuffer
, len
);
3404 /* Reset max counter */
3412 qp
= phba
->sli4_hba
.oas_cq
;
3413 len
= __lpfc_idiag_print_cq(qp
, "OAS", pbuffer
, len
);
3414 /* Reset max counter */
3421 qp
= phba
->sli4_hba
.oas_wq
;
3422 len
= __lpfc_idiag_print_wq(qp
, "OAS", pbuffer
, len
);
3427 spin_unlock_irq(&phba
->hbalock
);
3428 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
3431 len
+= snprintf(pbuffer
+ len
,
3432 LPFC_QUE_INFO_GET_BUF_SIZE
- len
, "Truncated ...\n");
3434 spin_unlock_irq(&phba
->hbalock
);
3435 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
3439 * lpfc_idiag_que_param_check - queue access command parameter sanity check
3440 * @q: The pointer to queue structure.
3441 * @index: The index into a queue entry.
3442 * @count: The number of queue entries to access.
3445 * The routine performs sanity check on device queue access method commands.
3448 * This function returns -EINVAL when fails the sanity check, otherwise, it
3452 lpfc_idiag_que_param_check(struct lpfc_queue
*q
, int index
, int count
)
3454 /* Only support single entry read or browsing */
3455 if ((count
!= 1) && (count
!= LPFC_QUE_ACC_BROWSE
))
3457 if (index
> q
->entry_count
- 1)
3463 * lpfc_idiag_queacc_read_qe - read a single entry from the given queue index
3464 * @pbuffer: The pointer to buffer to copy the read data into.
3465 * @pque: The pointer to the queue to be read.
3466 * @index: The index into the queue entry.
3469 * This routine reads out a single entry from the given queue's index location
3470 * and copies it into the buffer provided.
3473 * This function returns 0 when it fails, otherwise, it returns the length of
3474 * the data read into the buffer provided.
3477 lpfc_idiag_queacc_read_qe(char *pbuffer
, int len
, struct lpfc_queue
*pque
,
3483 if (!pbuffer
|| !pque
)
3486 esize
= pque
->entry_size
;
3487 len
+= snprintf(pbuffer
+len
, LPFC_QUE_ACC_BUF_SIZE
-len
,
3488 "QE-INDEX[%04d]:\n", index
);
3491 pentry
= pque
->qe
[index
].address
;
3493 len
+= snprintf(pbuffer
+len
, LPFC_QUE_ACC_BUF_SIZE
-len
,
3496 offset
+= sizeof(uint32_t);
3497 esize
-= sizeof(uint32_t);
3498 if (esize
> 0 && !(offset
% (4 * sizeof(uint32_t))))
3499 len
+= snprintf(pbuffer
+len
,
3500 LPFC_QUE_ACC_BUF_SIZE
-len
, "\n");
3502 len
+= snprintf(pbuffer
+len
, LPFC_QUE_ACC_BUF_SIZE
-len
, "\n");
3508 * lpfc_idiag_queacc_read - idiag debugfs read port queue
3509 * @file: The file pointer to read from.
3510 * @buf: The buffer to copy the data to.
3511 * @nbytes: The number of bytes to read.
3512 * @ppos: The position in the file to start reading from.
3515 * This routine reads data from the @phba device queue memory according to the
3516 * idiag command, and copies to user @buf. Depending on the queue dump read
3517 * command setup, it does either a single queue entry read or browing through
3518 * all entries of the queue.
3521 * This function returns the amount of data that was read (this could be less
3522 * than @nbytes if the end of the file was reached) or a negative error value.
3525 lpfc_idiag_queacc_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
3528 struct lpfc_debug
*debug
= file
->private_data
;
3529 uint32_t last_index
, index
, count
;
3530 struct lpfc_queue
*pque
= NULL
;
3534 /* This is a user read operation */
3535 debug
->op
= LPFC_IDIAG_OP_RD
;
3538 debug
->buffer
= kmalloc(LPFC_QUE_ACC_BUF_SIZE
, GFP_KERNEL
);
3541 pbuffer
= debug
->buffer
;
3546 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_RD
) {
3547 index
= idiag
.cmd
.data
[IDIAG_QUEACC_INDEX_INDX
];
3548 count
= idiag
.cmd
.data
[IDIAG_QUEACC_COUNT_INDX
];
3549 pque
= (struct lpfc_queue
*)idiag
.ptr_private
;
3553 /* Browse the queue starting from index */
3554 if (count
== LPFC_QUE_ACC_BROWSE
)
3557 /* Read a single entry from the queue */
3558 len
= lpfc_idiag_queacc_read_qe(pbuffer
, len
, pque
, index
);
3560 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
3564 /* Browse all entries from the queue */
3565 last_index
= idiag
.offset
.last_rd
;
3568 while (len
< LPFC_QUE_ACC_SIZE
- pque
->entry_size
) {
3569 len
= lpfc_idiag_queacc_read_qe(pbuffer
, len
, pque
, index
);
3571 if (index
> pque
->entry_count
- 1)
3575 /* Set up the offset for next portion of pci cfg read */
3576 if (index
> pque
->entry_count
- 1)
3578 idiag
.offset
.last_rd
= index
;
3580 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
3584 * lpfc_idiag_queacc_write - Syntax check and set up idiag queacc commands
3585 * @file: The file pointer to read from.
3586 * @buf: The buffer to copy the user data from.
3587 * @nbytes: The number of bytes to get.
3588 * @ppos: The position in the file to start reading from.
3590 * This routine get the debugfs idiag command struct from user space and then
3591 * perform the syntax check for port queue read (dump) or write (set) command
3592 * accordingly. In the case of port queue read command, it sets up the command
3593 * in the idiag command struct for the following debugfs read operation. In
3594 * the case of port queue write operation, it executes the write operation
3595 * into the port queue entry accordingly.
3597 * It returns the @nbytges passing in from debugfs user space when successful.
3598 * In case of error conditions, it returns proper error code back to the user
3602 lpfc_idiag_queacc_write(struct file
*file
, const char __user
*buf
,
3603 size_t nbytes
, loff_t
*ppos
)
3605 struct lpfc_debug
*debug
= file
->private_data
;
3606 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
3607 uint32_t qidx
, quetp
, queid
, index
, count
, offset
, value
;
3609 struct lpfc_queue
*pque
, *qp
;
3612 /* This is a user write operation */
3613 debug
->op
= LPFC_IDIAG_OP_WR
;
3615 rc
= lpfc_idiag_cmd_get(buf
, nbytes
, &idiag
.cmd
);
3619 /* Get and sanity check on command feilds */
3620 quetp
= idiag
.cmd
.data
[IDIAG_QUEACC_QUETP_INDX
];
3621 queid
= idiag
.cmd
.data
[IDIAG_QUEACC_QUEID_INDX
];
3622 index
= idiag
.cmd
.data
[IDIAG_QUEACC_INDEX_INDX
];
3623 count
= idiag
.cmd
.data
[IDIAG_QUEACC_COUNT_INDX
];
3624 offset
= idiag
.cmd
.data
[IDIAG_QUEACC_OFFST_INDX
];
3625 value
= idiag
.cmd
.data
[IDIAG_QUEACC_VALUE_INDX
];
3627 /* Sanity check on command line arguments */
3628 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_WR
||
3629 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_ST
||
3630 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_CL
) {
3631 if (rc
!= LPFC_QUE_ACC_WR_CMD_ARG
)
3635 } else if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_RD
) {
3636 if (rc
!= LPFC_QUE_ACC_RD_CMD_ARG
)
3643 /* HBA event queue */
3644 if (phba
->sli4_hba
.hba_eq
) {
3645 for (qidx
= 0; qidx
< phba
->io_channel_irqs
; qidx
++) {
3646 qp
= phba
->sli4_hba
.hba_eq
[qidx
];
3647 if (qp
&& qp
->queue_id
== queid
) {
3649 rc
= lpfc_idiag_que_param_check(qp
,
3653 idiag
.ptr_private
= qp
;
3661 /* MBX complete queue */
3662 if (phba
->sli4_hba
.mbx_cq
&&
3663 phba
->sli4_hba
.mbx_cq
->queue_id
== queid
) {
3665 rc
= lpfc_idiag_que_param_check(
3666 phba
->sli4_hba
.mbx_cq
, index
, count
);
3669 idiag
.ptr_private
= phba
->sli4_hba
.mbx_cq
;
3672 /* ELS complete queue */
3673 if (phba
->sli4_hba
.els_cq
&&
3674 phba
->sli4_hba
.els_cq
->queue_id
== queid
) {
3676 rc
= lpfc_idiag_que_param_check(
3677 phba
->sli4_hba
.els_cq
, index
, count
);
3680 idiag
.ptr_private
= phba
->sli4_hba
.els_cq
;
3683 /* NVME LS complete queue */
3684 if (phba
->sli4_hba
.nvmels_cq
&&
3685 phba
->sli4_hba
.nvmels_cq
->queue_id
== queid
) {
3687 rc
= lpfc_idiag_que_param_check(
3688 phba
->sli4_hba
.nvmels_cq
, index
, count
);
3691 idiag
.ptr_private
= phba
->sli4_hba
.nvmels_cq
;
3694 /* FCP complete queue */
3695 if (phba
->sli4_hba
.fcp_cq
) {
3696 for (qidx
= 0; qidx
< phba
->cfg_fcp_io_channel
;
3698 qp
= phba
->sli4_hba
.fcp_cq
[qidx
];
3699 if (qp
&& qp
->queue_id
== queid
) {
3701 rc
= lpfc_idiag_que_param_check(
3705 idiag
.ptr_private
= qp
;
3710 /* NVME complete queue */
3711 if (phba
->sli4_hba
.nvme_cq
) {
3714 if (phba
->sli4_hba
.nvme_cq
[qidx
] &&
3715 phba
->sli4_hba
.nvme_cq
[qidx
]->queue_id
==
3718 rc
= lpfc_idiag_que_param_check(
3719 phba
->sli4_hba
.nvme_cq
[qidx
],
3724 phba
->sli4_hba
.nvme_cq
[qidx
];
3727 } while (++qidx
< phba
->cfg_nvme_io_channel
);
3732 /* MBX work queue */
3733 if (phba
->sli4_hba
.mbx_wq
&&
3734 phba
->sli4_hba
.mbx_wq
->queue_id
== queid
) {
3736 rc
= lpfc_idiag_que_param_check(
3737 phba
->sli4_hba
.mbx_wq
, index
, count
);
3740 idiag
.ptr_private
= phba
->sli4_hba
.mbx_wq
;
3746 /* ELS work queue */
3747 if (phba
->sli4_hba
.els_wq
&&
3748 phba
->sli4_hba
.els_wq
->queue_id
== queid
) {
3750 rc
= lpfc_idiag_que_param_check(
3751 phba
->sli4_hba
.els_wq
, index
, count
);
3754 idiag
.ptr_private
= phba
->sli4_hba
.els_wq
;
3757 /* NVME LS work queue */
3758 if (phba
->sli4_hba
.nvmels_wq
&&
3759 phba
->sli4_hba
.nvmels_wq
->queue_id
== queid
) {
3761 rc
= lpfc_idiag_que_param_check(
3762 phba
->sli4_hba
.nvmels_wq
, index
, count
);
3765 idiag
.ptr_private
= phba
->sli4_hba
.nvmels_wq
;
3768 /* FCP work queue */
3769 if (phba
->sli4_hba
.fcp_wq
) {
3770 for (qidx
= 0; qidx
< phba
->cfg_fcp_io_channel
;
3772 qp
= phba
->sli4_hba
.fcp_wq
[qidx
];
3773 if (qp
&& qp
->queue_id
== queid
) {
3775 rc
= lpfc_idiag_que_param_check(
3779 idiag
.ptr_private
= qp
;
3784 /* NVME work queue */
3785 if (phba
->sli4_hba
.nvme_wq
) {
3786 for (qidx
= 0; qidx
< phba
->cfg_nvme_io_channel
;
3788 qp
= phba
->sli4_hba
.nvme_wq
[qidx
];
3789 if (qp
&& qp
->queue_id
== queid
) {
3791 rc
= lpfc_idiag_que_param_check(
3795 idiag
.ptr_private
= qp
;
3801 /* NVME work queues */
3802 if (phba
->sli4_hba
.nvme_wq
) {
3803 for (qidx
= 0; qidx
< phba
->cfg_nvme_io_channel
;
3805 if (!phba
->sli4_hba
.nvme_wq
[qidx
])
3807 if (phba
->sli4_hba
.nvme_wq
[qidx
]->queue_id
==
3810 rc
= lpfc_idiag_que_param_check(
3811 phba
->sli4_hba
.nvme_wq
[qidx
],
3816 phba
->sli4_hba
.nvme_wq
[qidx
];
3825 if (phba
->sli4_hba
.hdr_rq
&&
3826 phba
->sli4_hba
.hdr_rq
->queue_id
== queid
) {
3828 rc
= lpfc_idiag_que_param_check(
3829 phba
->sli4_hba
.hdr_rq
, index
, count
);
3832 idiag
.ptr_private
= phba
->sli4_hba
.hdr_rq
;
3836 if (phba
->sli4_hba
.dat_rq
&&
3837 phba
->sli4_hba
.dat_rq
->queue_id
== queid
) {
3839 rc
= lpfc_idiag_que_param_check(
3840 phba
->sli4_hba
.dat_rq
, index
, count
);
3843 idiag
.ptr_private
= phba
->sli4_hba
.dat_rq
;
3855 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_RD
) {
3856 if (count
== LPFC_QUE_ACC_BROWSE
)
3857 idiag
.offset
.last_rd
= index
;
3860 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_WR
||
3861 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_ST
||
3862 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_CL
) {
3863 /* Additional sanity checks on write operation */
3864 pque
= (struct lpfc_queue
*)idiag
.ptr_private
;
3865 if (offset
> pque
->entry_size
/sizeof(uint32_t) - 1)
3867 pentry
= pque
->qe
[index
].address
;
3869 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_WR
)
3871 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_ST
)
3873 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_CL
)
3879 /* Clean out command structure on command error out */
3880 memset(&idiag
, 0, sizeof(idiag
));
3885 * lpfc_idiag_drbacc_read_reg - idiag debugfs read a doorbell register
3886 * @phba: The pointer to hba structure.
3887 * @pbuffer: The pointer to the buffer to copy the data to.
3888 * @len: The lenght of bytes to copied.
3889 * @drbregid: The id to doorbell registers.
3892 * This routine reads a doorbell register and copies its content to the
3893 * user buffer pointed to by @pbuffer.
3896 * This function returns the amount of data that was copied into @pbuffer.
3899 lpfc_idiag_drbacc_read_reg(struct lpfc_hba
*phba
, char *pbuffer
,
3900 int len
, uint32_t drbregid
)
3908 len
+= snprintf(pbuffer
+len
, LPFC_DRB_ACC_BUF_SIZE
-len
,
3909 "EQCQ-DRB-REG: 0x%08x\n",
3910 readl(phba
->sli4_hba
.EQCQDBregaddr
));
3913 len
+= snprintf(pbuffer
+len
, LPFC_DRB_ACC_BUF_SIZE
-len
,
3914 "MQ-DRB-REG: 0x%08x\n",
3915 readl(phba
->sli4_hba
.MQDBregaddr
));
3918 len
+= snprintf(pbuffer
+len
, LPFC_DRB_ACC_BUF_SIZE
-len
,
3919 "WQ-DRB-REG: 0x%08x\n",
3920 readl(phba
->sli4_hba
.WQDBregaddr
));
3923 len
+= snprintf(pbuffer
+len
, LPFC_DRB_ACC_BUF_SIZE
-len
,
3924 "RQ-DRB-REG: 0x%08x\n",
3925 readl(phba
->sli4_hba
.RQDBregaddr
));
3935 * lpfc_idiag_drbacc_read - idiag debugfs read port doorbell
3936 * @file: The file pointer to read from.
3937 * @buf: The buffer to copy the data to.
3938 * @nbytes: The number of bytes to read.
3939 * @ppos: The position in the file to start reading from.
3942 * This routine reads data from the @phba device doorbell register according
3943 * to the idiag command, and copies to user @buf. Depending on the doorbell
3944 * register read command setup, it does either a single doorbell register
3945 * read or dump all doorbell registers.
3948 * This function returns the amount of data that was read (this could be less
3949 * than @nbytes if the end of the file was reached) or a negative error value.
3952 lpfc_idiag_drbacc_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
3955 struct lpfc_debug
*debug
= file
->private_data
;
3956 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
3957 uint32_t drb_reg_id
, i
;
3961 /* This is a user read operation */
3962 debug
->op
= LPFC_IDIAG_OP_RD
;
3965 debug
->buffer
= kmalloc(LPFC_DRB_ACC_BUF_SIZE
, GFP_KERNEL
);
3968 pbuffer
= debug
->buffer
;
3973 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_RD
)
3974 drb_reg_id
= idiag
.cmd
.data
[IDIAG_DRBACC_REGID_INDX
];
3978 if (drb_reg_id
== LPFC_DRB_ACC_ALL
)
3979 for (i
= 1; i
<= LPFC_DRB_MAX
; i
++)
3980 len
= lpfc_idiag_drbacc_read_reg(phba
,
3983 len
= lpfc_idiag_drbacc_read_reg(phba
,
3984 pbuffer
, len
, drb_reg_id
);
3986 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
3990 * lpfc_idiag_drbacc_write - Syntax check and set up idiag drbacc commands
3991 * @file: The file pointer to read from.
3992 * @buf: The buffer to copy the user data from.
3993 * @nbytes: The number of bytes to get.
3994 * @ppos: The position in the file to start reading from.
3996 * This routine get the debugfs idiag command struct from user space and then
3997 * perform the syntax check for port doorbell register read (dump) or write
3998 * (set) command accordingly. In the case of port queue read command, it sets
3999 * up the command in the idiag command struct for the following debugfs read
4000 * operation. In the case of port doorbell register write operation, it
4001 * executes the write operation into the port doorbell register accordingly.
4003 * It returns the @nbytges passing in from debugfs user space when successful.
4004 * In case of error conditions, it returns proper error code back to the user
4008 lpfc_idiag_drbacc_write(struct file
*file
, const char __user
*buf
,
4009 size_t nbytes
, loff_t
*ppos
)
4011 struct lpfc_debug
*debug
= file
->private_data
;
4012 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
4013 uint32_t drb_reg_id
, value
, reg_val
= 0;
4014 void __iomem
*drb_reg
;
4017 /* This is a user write operation */
4018 debug
->op
= LPFC_IDIAG_OP_WR
;
4020 rc
= lpfc_idiag_cmd_get(buf
, nbytes
, &idiag
.cmd
);
4024 /* Sanity check on command line arguments */
4025 drb_reg_id
= idiag
.cmd
.data
[IDIAG_DRBACC_REGID_INDX
];
4026 value
= idiag
.cmd
.data
[IDIAG_DRBACC_VALUE_INDX
];
4028 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_WR
||
4029 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_ST
||
4030 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_CL
) {
4031 if (rc
!= LPFC_DRB_ACC_WR_CMD_ARG
)
4033 if (drb_reg_id
> LPFC_DRB_MAX
)
4035 } else if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_RD
) {
4036 if (rc
!= LPFC_DRB_ACC_RD_CMD_ARG
)
4038 if ((drb_reg_id
> LPFC_DRB_MAX
) &&
4039 (drb_reg_id
!= LPFC_DRB_ACC_ALL
))
4044 /* Perform the write access operation */
4045 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_WR
||
4046 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_ST
||
4047 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_CL
) {
4048 switch (drb_reg_id
) {
4050 drb_reg
= phba
->sli4_hba
.EQCQDBregaddr
;
4053 drb_reg
= phba
->sli4_hba
.MQDBregaddr
;
4056 drb_reg
= phba
->sli4_hba
.WQDBregaddr
;
4059 drb_reg
= phba
->sli4_hba
.RQDBregaddr
;
4065 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_WR
)
4067 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_ST
) {
4068 reg_val
= readl(drb_reg
);
4071 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_CL
) {
4072 reg_val
= readl(drb_reg
);
4075 writel(reg_val
, drb_reg
);
4076 readl(drb_reg
); /* flush */
4081 /* Clean out command structure on command error out */
4082 memset(&idiag
, 0, sizeof(idiag
));
4087 * lpfc_idiag_ctlacc_read_reg - idiag debugfs read a control registers
4088 * @phba: The pointer to hba structure.
4089 * @pbuffer: The pointer to the buffer to copy the data to.
4090 * @len: The lenght of bytes to copied.
4091 * @drbregid: The id to doorbell registers.
4094 * This routine reads a control register and copies its content to the
4095 * user buffer pointed to by @pbuffer.
4098 * This function returns the amount of data that was copied into @pbuffer.
4101 lpfc_idiag_ctlacc_read_reg(struct lpfc_hba
*phba
, char *pbuffer
,
4102 int len
, uint32_t ctlregid
)
4109 case LPFC_CTL_PORT_SEM
:
4110 len
+= snprintf(pbuffer
+len
, LPFC_CTL_ACC_BUF_SIZE
-len
,
4111 "Port SemReg: 0x%08x\n",
4112 readl(phba
->sli4_hba
.conf_regs_memmap_p
+
4113 LPFC_CTL_PORT_SEM_OFFSET
));
4115 case LPFC_CTL_PORT_STA
:
4116 len
+= snprintf(pbuffer
+len
, LPFC_CTL_ACC_BUF_SIZE
-len
,
4117 "Port StaReg: 0x%08x\n",
4118 readl(phba
->sli4_hba
.conf_regs_memmap_p
+
4119 LPFC_CTL_PORT_STA_OFFSET
));
4121 case LPFC_CTL_PORT_CTL
:
4122 len
+= snprintf(pbuffer
+len
, LPFC_CTL_ACC_BUF_SIZE
-len
,
4123 "Port CtlReg: 0x%08x\n",
4124 readl(phba
->sli4_hba
.conf_regs_memmap_p
+
4125 LPFC_CTL_PORT_CTL_OFFSET
));
4127 case LPFC_CTL_PORT_ER1
:
4128 len
+= snprintf(pbuffer
+len
, LPFC_CTL_ACC_BUF_SIZE
-len
,
4129 "Port Er1Reg: 0x%08x\n",
4130 readl(phba
->sli4_hba
.conf_regs_memmap_p
+
4131 LPFC_CTL_PORT_ER1_OFFSET
));
4133 case LPFC_CTL_PORT_ER2
:
4134 len
+= snprintf(pbuffer
+len
, LPFC_CTL_ACC_BUF_SIZE
-len
,
4135 "Port Er2Reg: 0x%08x\n",
4136 readl(phba
->sli4_hba
.conf_regs_memmap_p
+
4137 LPFC_CTL_PORT_ER2_OFFSET
));
4139 case LPFC_CTL_PDEV_CTL
:
4140 len
+= snprintf(pbuffer
+len
, LPFC_CTL_ACC_BUF_SIZE
-len
,
4141 "PDev CtlReg: 0x%08x\n",
4142 readl(phba
->sli4_hba
.conf_regs_memmap_p
+
4143 LPFC_CTL_PDEV_CTL_OFFSET
));
4152 * lpfc_idiag_ctlacc_read - idiag debugfs read port and device control register
4153 * @file: The file pointer to read from.
4154 * @buf: The buffer to copy the data to.
4155 * @nbytes: The number of bytes to read.
4156 * @ppos: The position in the file to start reading from.
4159 * This routine reads data from the @phba port and device registers according
4160 * to the idiag command, and copies to user @buf.
4163 * This function returns the amount of data that was read (this could be less
4164 * than @nbytes if the end of the file was reached) or a negative error value.
4167 lpfc_idiag_ctlacc_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
4170 struct lpfc_debug
*debug
= file
->private_data
;
4171 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
4172 uint32_t ctl_reg_id
, i
;
4176 /* This is a user read operation */
4177 debug
->op
= LPFC_IDIAG_OP_RD
;
4180 debug
->buffer
= kmalloc(LPFC_CTL_ACC_BUF_SIZE
, GFP_KERNEL
);
4183 pbuffer
= debug
->buffer
;
4188 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_RD
)
4189 ctl_reg_id
= idiag
.cmd
.data
[IDIAG_CTLACC_REGID_INDX
];
4193 if (ctl_reg_id
== LPFC_CTL_ACC_ALL
)
4194 for (i
= 1; i
<= LPFC_CTL_MAX
; i
++)
4195 len
= lpfc_idiag_ctlacc_read_reg(phba
,
4198 len
= lpfc_idiag_ctlacc_read_reg(phba
,
4199 pbuffer
, len
, ctl_reg_id
);
4201 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
4205 * lpfc_idiag_ctlacc_write - Syntax check and set up idiag ctlacc commands
4206 * @file: The file pointer to read from.
4207 * @buf: The buffer to copy the user data from.
4208 * @nbytes: The number of bytes to get.
4209 * @ppos: The position in the file to start reading from.
4211 * This routine get the debugfs idiag command struct from user space and then
4212 * perform the syntax check for port and device control register read (dump)
4213 * or write (set) command accordingly.
4215 * It returns the @nbytges passing in from debugfs user space when successful.
4216 * In case of error conditions, it returns proper error code back to the user
4220 lpfc_idiag_ctlacc_write(struct file
*file
, const char __user
*buf
,
4221 size_t nbytes
, loff_t
*ppos
)
4223 struct lpfc_debug
*debug
= file
->private_data
;
4224 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
4225 uint32_t ctl_reg_id
, value
, reg_val
= 0;
4226 void __iomem
*ctl_reg
;
4229 /* This is a user write operation */
4230 debug
->op
= LPFC_IDIAG_OP_WR
;
4232 rc
= lpfc_idiag_cmd_get(buf
, nbytes
, &idiag
.cmd
);
4236 /* Sanity check on command line arguments */
4237 ctl_reg_id
= idiag
.cmd
.data
[IDIAG_CTLACC_REGID_INDX
];
4238 value
= idiag
.cmd
.data
[IDIAG_CTLACC_VALUE_INDX
];
4240 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_WR
||
4241 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_ST
||
4242 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_CL
) {
4243 if (rc
!= LPFC_CTL_ACC_WR_CMD_ARG
)
4245 if (ctl_reg_id
> LPFC_CTL_MAX
)
4247 } else if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_RD
) {
4248 if (rc
!= LPFC_CTL_ACC_RD_CMD_ARG
)
4250 if ((ctl_reg_id
> LPFC_CTL_MAX
) &&
4251 (ctl_reg_id
!= LPFC_CTL_ACC_ALL
))
4256 /* Perform the write access operation */
4257 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_WR
||
4258 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_ST
||
4259 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_CL
) {
4260 switch (ctl_reg_id
) {
4261 case LPFC_CTL_PORT_SEM
:
4262 ctl_reg
= phba
->sli4_hba
.conf_regs_memmap_p
+
4263 LPFC_CTL_PORT_SEM_OFFSET
;
4265 case LPFC_CTL_PORT_STA
:
4266 ctl_reg
= phba
->sli4_hba
.conf_regs_memmap_p
+
4267 LPFC_CTL_PORT_STA_OFFSET
;
4269 case LPFC_CTL_PORT_CTL
:
4270 ctl_reg
= phba
->sli4_hba
.conf_regs_memmap_p
+
4271 LPFC_CTL_PORT_CTL_OFFSET
;
4273 case LPFC_CTL_PORT_ER1
:
4274 ctl_reg
= phba
->sli4_hba
.conf_regs_memmap_p
+
4275 LPFC_CTL_PORT_ER1_OFFSET
;
4277 case LPFC_CTL_PORT_ER2
:
4278 ctl_reg
= phba
->sli4_hba
.conf_regs_memmap_p
+
4279 LPFC_CTL_PORT_ER2_OFFSET
;
4281 case LPFC_CTL_PDEV_CTL
:
4282 ctl_reg
= phba
->sli4_hba
.conf_regs_memmap_p
+
4283 LPFC_CTL_PDEV_CTL_OFFSET
;
4289 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_WR
)
4291 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_ST
) {
4292 reg_val
= readl(ctl_reg
);
4295 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_CL
) {
4296 reg_val
= readl(ctl_reg
);
4299 writel(reg_val
, ctl_reg
);
4300 readl(ctl_reg
); /* flush */
4305 /* Clean out command structure on command error out */
4306 memset(&idiag
, 0, sizeof(idiag
));
4311 * lpfc_idiag_mbxacc_get_setup - idiag debugfs get mailbox access setup
4312 * @phba: Pointer to HBA context object.
4313 * @pbuffer: Pointer to data buffer.
4316 * This routine gets the driver mailbox access debugfs setup information.
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_get_setup(struct lpfc_hba
*phba
, char *pbuffer
)
4325 uint32_t mbx_dump_map
, mbx_dump_cnt
, mbx_word_cnt
, mbx_mbox_cmd
;
4328 mbx_mbox_cmd
= idiag
.cmd
.data
[IDIAG_MBXACC_MBCMD_INDX
];
4329 mbx_dump_map
= idiag
.cmd
.data
[IDIAG_MBXACC_DPMAP_INDX
];
4330 mbx_dump_cnt
= idiag
.cmd
.data
[IDIAG_MBXACC_DPCNT_INDX
];
4331 mbx_word_cnt
= idiag
.cmd
.data
[IDIAG_MBXACC_WDCNT_INDX
];
4333 len
+= snprintf(pbuffer
+len
, LPFC_MBX_ACC_BUF_SIZE
-len
,
4334 "mbx_dump_map: 0x%08x\n", mbx_dump_map
);
4335 len
+= snprintf(pbuffer
+len
, LPFC_MBX_ACC_BUF_SIZE
-len
,
4336 "mbx_dump_cnt: %04d\n", mbx_dump_cnt
);
4337 len
+= snprintf(pbuffer
+len
, LPFC_MBX_ACC_BUF_SIZE
-len
,
4338 "mbx_word_cnt: %04d\n", mbx_word_cnt
);
4339 len
+= snprintf(pbuffer
+len
, LPFC_MBX_ACC_BUF_SIZE
-len
,
4340 "mbx_mbox_cmd: 0x%02x\n", mbx_mbox_cmd
);
4346 * lpfc_idiag_mbxacc_read - idiag debugfs read on mailbox access
4347 * @file: The file pointer to read from.
4348 * @buf: The buffer to copy the data to.
4349 * @nbytes: The number of bytes to read.
4350 * @ppos: The position in the file to start reading from.
4353 * This routine reads data from the @phba driver mailbox access debugfs setup
4357 * This function returns the amount of data that was read (this could be less
4358 * than @nbytes if the end of the file was reached) or a negative error value.
4361 lpfc_idiag_mbxacc_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
4364 struct lpfc_debug
*debug
= file
->private_data
;
4365 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
4369 /* This is a user read operation */
4370 debug
->op
= LPFC_IDIAG_OP_RD
;
4373 debug
->buffer
= kmalloc(LPFC_MBX_ACC_BUF_SIZE
, GFP_KERNEL
);
4376 pbuffer
= debug
->buffer
;
4381 if ((idiag
.cmd
.opcode
!= LPFC_IDIAG_CMD_MBXACC_DP
) &&
4382 (idiag
.cmd
.opcode
!= LPFC_IDIAG_BSG_MBXACC_DP
))
4385 len
= lpfc_idiag_mbxacc_get_setup(phba
, pbuffer
);
4387 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
4391 * lpfc_idiag_mbxacc_write - Syntax check and set up idiag mbxacc commands
4392 * @file: The file pointer to read from.
4393 * @buf: The buffer to copy the user data from.
4394 * @nbytes: The number of bytes to get.
4395 * @ppos: The position in the file to start reading from.
4397 * This routine get the debugfs idiag command struct from user space and then
4398 * perform the syntax check for driver mailbox command (dump) and sets up the
4399 * necessary states in the idiag command struct accordingly.
4401 * It returns the @nbytges passing in from debugfs user space when successful.
4402 * In case of error conditions, it returns proper error code back to the user
4406 lpfc_idiag_mbxacc_write(struct file
*file
, const char __user
*buf
,
4407 size_t nbytes
, loff_t
*ppos
)
4409 struct lpfc_debug
*debug
= file
->private_data
;
4410 uint32_t mbx_dump_map
, mbx_dump_cnt
, mbx_word_cnt
, mbx_mbox_cmd
;
4413 /* This is a user write operation */
4414 debug
->op
= LPFC_IDIAG_OP_WR
;
4416 rc
= lpfc_idiag_cmd_get(buf
, nbytes
, &idiag
.cmd
);
4420 /* Sanity check on command line arguments */
4421 mbx_mbox_cmd
= idiag
.cmd
.data
[IDIAG_MBXACC_MBCMD_INDX
];
4422 mbx_dump_map
= idiag
.cmd
.data
[IDIAG_MBXACC_DPMAP_INDX
];
4423 mbx_dump_cnt
= idiag
.cmd
.data
[IDIAG_MBXACC_DPCNT_INDX
];
4424 mbx_word_cnt
= idiag
.cmd
.data
[IDIAG_MBXACC_WDCNT_INDX
];
4426 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_MBXACC_DP
) {
4427 if (!(mbx_dump_map
& LPFC_MBX_DMP_MBX_ALL
))
4429 if ((mbx_dump_map
& ~LPFC_MBX_DMP_MBX_ALL
) &&
4430 (mbx_dump_map
!= LPFC_MBX_DMP_ALL
))
4432 if (mbx_word_cnt
> sizeof(MAILBOX_t
))
4434 } else if (idiag
.cmd
.opcode
== LPFC_IDIAG_BSG_MBXACC_DP
) {
4435 if (!(mbx_dump_map
& LPFC_BSG_DMP_MBX_ALL
))
4437 if ((mbx_dump_map
& ~LPFC_BSG_DMP_MBX_ALL
) &&
4438 (mbx_dump_map
!= LPFC_MBX_DMP_ALL
))
4440 if (mbx_word_cnt
> (BSG_MBOX_SIZE
)/4)
4442 if (mbx_mbox_cmd
!= 0x9b)
4447 if (mbx_word_cnt
== 0)
4449 if (rc
!= LPFC_MBX_DMP_ARG
)
4451 if (mbx_mbox_cmd
& ~0xff)
4454 /* condition for stop mailbox dump */
4455 if (mbx_dump_cnt
== 0)
4461 /* Clean out command structure on command error out */
4462 memset(&idiag
, 0, sizeof(idiag
));
4466 /* Clean out command structure on command error out */
4467 memset(&idiag
, 0, sizeof(idiag
));
4472 * lpfc_idiag_extacc_avail_get - get the available extents information
4473 * @phba: pointer to lpfc hba data structure.
4474 * @pbuffer: pointer to internal buffer.
4475 * @len: length into the internal buffer data has been copied.
4478 * This routine is to get the available extent information.
4481 * overall lenth of the data read into the internal buffer.
4484 lpfc_idiag_extacc_avail_get(struct lpfc_hba
*phba
, char *pbuffer
, int len
)
4486 uint16_t ext_cnt
, ext_size
;
4488 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4489 "\nAvailable Extents Information:\n");
4491 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4492 "\tPort Available VPI extents: ");
4493 lpfc_sli4_get_avail_extnt_rsrc(phba
, LPFC_RSC_TYPE_FCOE_VPI
,
4494 &ext_cnt
, &ext_size
);
4495 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4496 "Count %3d, Size %3d\n", ext_cnt
, ext_size
);
4498 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4499 "\tPort Available VFI extents: ");
4500 lpfc_sli4_get_avail_extnt_rsrc(phba
, LPFC_RSC_TYPE_FCOE_VFI
,
4501 &ext_cnt
, &ext_size
);
4502 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4503 "Count %3d, Size %3d\n", ext_cnt
, ext_size
);
4505 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4506 "\tPort Available RPI extents: ");
4507 lpfc_sli4_get_avail_extnt_rsrc(phba
, LPFC_RSC_TYPE_FCOE_RPI
,
4508 &ext_cnt
, &ext_size
);
4509 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4510 "Count %3d, Size %3d\n", ext_cnt
, ext_size
);
4512 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4513 "\tPort Available XRI extents: ");
4514 lpfc_sli4_get_avail_extnt_rsrc(phba
, LPFC_RSC_TYPE_FCOE_XRI
,
4515 &ext_cnt
, &ext_size
);
4516 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4517 "Count %3d, Size %3d\n", ext_cnt
, ext_size
);
4523 * lpfc_idiag_extacc_alloc_get - get the allocated extents information
4524 * @phba: pointer to lpfc hba data structure.
4525 * @pbuffer: pointer to internal buffer.
4526 * @len: length into the internal buffer data has been copied.
4529 * This routine is to get the allocated extent information.
4532 * overall lenth of the data read into the internal buffer.
4535 lpfc_idiag_extacc_alloc_get(struct lpfc_hba
*phba
, char *pbuffer
, int len
)
4537 uint16_t ext_cnt
, ext_size
;
4540 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4541 "\nAllocated Extents Information:\n");
4543 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4544 "\tHost Allocated VPI extents: ");
4545 rc
= lpfc_sli4_get_allocated_extnts(phba
, LPFC_RSC_TYPE_FCOE_VPI
,
4546 &ext_cnt
, &ext_size
);
4548 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4549 "Port %d Extent %3d, Size %3d\n",
4550 phba
->brd_no
, ext_cnt
, ext_size
);
4552 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4555 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4556 "\tHost Allocated VFI extents: ");
4557 rc
= lpfc_sli4_get_allocated_extnts(phba
, LPFC_RSC_TYPE_FCOE_VFI
,
4558 &ext_cnt
, &ext_size
);
4560 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4561 "Port %d Extent %3d, Size %3d\n",
4562 phba
->brd_no
, ext_cnt
, ext_size
);
4564 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4567 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4568 "\tHost Allocated RPI extents: ");
4569 rc
= lpfc_sli4_get_allocated_extnts(phba
, LPFC_RSC_TYPE_FCOE_RPI
,
4570 &ext_cnt
, &ext_size
);
4572 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4573 "Port %d Extent %3d, Size %3d\n",
4574 phba
->brd_no
, ext_cnt
, ext_size
);
4576 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4579 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4580 "\tHost Allocated XRI extents: ");
4581 rc
= lpfc_sli4_get_allocated_extnts(phba
, LPFC_RSC_TYPE_FCOE_XRI
,
4582 &ext_cnt
, &ext_size
);
4584 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4585 "Port %d Extent %3d, Size %3d\n",
4586 phba
->brd_no
, ext_cnt
, ext_size
);
4588 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4595 * lpfc_idiag_extacc_drivr_get - get driver extent information
4596 * @phba: pointer to lpfc hba data structure.
4597 * @pbuffer: pointer to internal buffer.
4598 * @len: length into the internal buffer data has been copied.
4601 * This routine is to get the driver extent information.
4604 * overall lenth of the data read into the internal buffer.
4607 lpfc_idiag_extacc_drivr_get(struct lpfc_hba
*phba
, char *pbuffer
, int len
)
4609 struct lpfc_rsrc_blks
*rsrc_blks
;
4612 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4613 "\nDriver Extents Information:\n");
4615 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4616 "\tVPI extents:\n");
4618 list_for_each_entry(rsrc_blks
, &phba
->lpfc_vpi_blk_list
, list
) {
4619 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4620 "\t\tBlock %3d: Start %4d, Count %4d\n",
4621 index
, rsrc_blks
->rsrc_start
,
4622 rsrc_blks
->rsrc_size
);
4625 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4626 "\tVFI extents:\n");
4628 list_for_each_entry(rsrc_blks
, &phba
->sli4_hba
.lpfc_vfi_blk_list
,
4630 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4631 "\t\tBlock %3d: Start %4d, Count %4d\n",
4632 index
, rsrc_blks
->rsrc_start
,
4633 rsrc_blks
->rsrc_size
);
4637 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4638 "\tRPI extents:\n");
4640 list_for_each_entry(rsrc_blks
, &phba
->sli4_hba
.lpfc_rpi_blk_list
,
4642 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4643 "\t\tBlock %3d: Start %4d, Count %4d\n",
4644 index
, rsrc_blks
->rsrc_start
,
4645 rsrc_blks
->rsrc_size
);
4649 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4650 "\tXRI extents:\n");
4652 list_for_each_entry(rsrc_blks
, &phba
->sli4_hba
.lpfc_xri_blk_list
,
4654 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
4655 "\t\tBlock %3d: Start %4d, Count %4d\n",
4656 index
, rsrc_blks
->rsrc_start
,
4657 rsrc_blks
->rsrc_size
);
4665 * lpfc_idiag_extacc_write - Syntax check and set up idiag extacc commands
4666 * @file: The file pointer to read from.
4667 * @buf: The buffer to copy the user data from.
4668 * @nbytes: The number of bytes to get.
4669 * @ppos: The position in the file to start reading from.
4671 * This routine get the debugfs idiag command struct from user space and then
4672 * perform the syntax check for extent information access commands and sets
4673 * up the necessary states in the idiag command struct accordingly.
4675 * It returns the @nbytges passing in from debugfs user space when successful.
4676 * In case of error conditions, it returns proper error code back to the user
4680 lpfc_idiag_extacc_write(struct file
*file
, const char __user
*buf
,
4681 size_t nbytes
, loff_t
*ppos
)
4683 struct lpfc_debug
*debug
= file
->private_data
;
4687 /* This is a user write operation */
4688 debug
->op
= LPFC_IDIAG_OP_WR
;
4690 rc
= lpfc_idiag_cmd_get(buf
, nbytes
, &idiag
.cmd
);
4694 ext_map
= idiag
.cmd
.data
[IDIAG_EXTACC_EXMAP_INDX
];
4696 if (idiag
.cmd
.opcode
!= LPFC_IDIAG_CMD_EXTACC_RD
)
4698 if (rc
!= LPFC_EXT_ACC_CMD_ARG
)
4700 if (!(ext_map
& LPFC_EXT_ACC_ALL
))
4705 /* Clean out command structure on command error out */
4706 memset(&idiag
, 0, sizeof(idiag
));
4711 * lpfc_idiag_extacc_read - idiag debugfs read access to extent information
4712 * @file: The file pointer to read from.
4713 * @buf: The buffer to copy the data to.
4714 * @nbytes: The number of bytes to read.
4715 * @ppos: The position in the file to start reading from.
4718 * This routine reads data from the proper extent information according to
4719 * the idiag command, and copies to user @buf.
4722 * This function returns the amount of data that was read (this could be less
4723 * than @nbytes if the end of the file was reached) or a negative error value.
4726 lpfc_idiag_extacc_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
4729 struct lpfc_debug
*debug
= file
->private_data
;
4730 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
4735 /* This is a user read operation */
4736 debug
->op
= LPFC_IDIAG_OP_RD
;
4739 debug
->buffer
= kmalloc(LPFC_EXT_ACC_BUF_SIZE
, GFP_KERNEL
);
4742 pbuffer
= debug
->buffer
;
4745 if (idiag
.cmd
.opcode
!= LPFC_IDIAG_CMD_EXTACC_RD
)
4748 ext_map
= idiag
.cmd
.data
[IDIAG_EXTACC_EXMAP_INDX
];
4749 if (ext_map
& LPFC_EXT_ACC_AVAIL
)
4750 len
= lpfc_idiag_extacc_avail_get(phba
, pbuffer
, len
);
4751 if (ext_map
& LPFC_EXT_ACC_ALLOC
)
4752 len
= lpfc_idiag_extacc_alloc_get(phba
, pbuffer
, len
);
4753 if (ext_map
& LPFC_EXT_ACC_DRIVR
)
4754 len
= lpfc_idiag_extacc_drivr_get(phba
, pbuffer
, len
);
4756 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
4759 #undef lpfc_debugfs_op_disc_trc
4760 static const struct file_operations lpfc_debugfs_op_disc_trc
= {
4761 .owner
= THIS_MODULE
,
4762 .open
= lpfc_debugfs_disc_trc_open
,
4763 .llseek
= lpfc_debugfs_lseek
,
4764 .read
= lpfc_debugfs_read
,
4765 .release
= lpfc_debugfs_release
,
4768 #undef lpfc_debugfs_op_nodelist
4769 static const struct file_operations lpfc_debugfs_op_nodelist
= {
4770 .owner
= THIS_MODULE
,
4771 .open
= lpfc_debugfs_nodelist_open
,
4772 .llseek
= lpfc_debugfs_lseek
,
4773 .read
= lpfc_debugfs_read
,
4774 .release
= lpfc_debugfs_release
,
4777 #undef lpfc_debugfs_op_hbqinfo
4778 static const struct file_operations lpfc_debugfs_op_hbqinfo
= {
4779 .owner
= THIS_MODULE
,
4780 .open
= lpfc_debugfs_hbqinfo_open
,
4781 .llseek
= lpfc_debugfs_lseek
,
4782 .read
= lpfc_debugfs_read
,
4783 .release
= lpfc_debugfs_release
,
4786 #undef lpfc_debugfs_op_dumpHBASlim
4787 static const struct file_operations lpfc_debugfs_op_dumpHBASlim
= {
4788 .owner
= THIS_MODULE
,
4789 .open
= lpfc_debugfs_dumpHBASlim_open
,
4790 .llseek
= lpfc_debugfs_lseek
,
4791 .read
= lpfc_debugfs_read
,
4792 .release
= lpfc_debugfs_release
,
4795 #undef lpfc_debugfs_op_dumpHostSlim
4796 static const struct file_operations lpfc_debugfs_op_dumpHostSlim
= {
4797 .owner
= THIS_MODULE
,
4798 .open
= lpfc_debugfs_dumpHostSlim_open
,
4799 .llseek
= lpfc_debugfs_lseek
,
4800 .read
= lpfc_debugfs_read
,
4801 .release
= lpfc_debugfs_release
,
4804 #undef lpfc_debugfs_op_nvmestat
4805 static const struct file_operations lpfc_debugfs_op_nvmestat
= {
4806 .owner
= THIS_MODULE
,
4807 .open
= lpfc_debugfs_nvmestat_open
,
4808 .llseek
= lpfc_debugfs_lseek
,
4809 .read
= lpfc_debugfs_read
,
4810 .write
= lpfc_debugfs_nvmestat_write
,
4811 .release
= lpfc_debugfs_release
,
4814 #undef lpfc_debugfs_op_nvmektime
4815 static const struct file_operations lpfc_debugfs_op_nvmektime
= {
4816 .owner
= THIS_MODULE
,
4817 .open
= lpfc_debugfs_nvmektime_open
,
4818 .llseek
= lpfc_debugfs_lseek
,
4819 .read
= lpfc_debugfs_read
,
4820 .write
= lpfc_debugfs_nvmektime_write
,
4821 .release
= lpfc_debugfs_release
,
4824 #undef lpfc_debugfs_op_nvmeio_trc
4825 static const struct file_operations lpfc_debugfs_op_nvmeio_trc
= {
4826 .owner
= THIS_MODULE
,
4827 .open
= lpfc_debugfs_nvmeio_trc_open
,
4828 .llseek
= lpfc_debugfs_lseek
,
4829 .read
= lpfc_debugfs_read
,
4830 .write
= lpfc_debugfs_nvmeio_trc_write
,
4831 .release
= lpfc_debugfs_release
,
4834 #undef lpfc_debugfs_op_cpucheck
4835 static const struct file_operations lpfc_debugfs_op_cpucheck
= {
4836 .owner
= THIS_MODULE
,
4837 .open
= lpfc_debugfs_cpucheck_open
,
4838 .llseek
= lpfc_debugfs_lseek
,
4839 .read
= lpfc_debugfs_read
,
4840 .write
= lpfc_debugfs_cpucheck_write
,
4841 .release
= lpfc_debugfs_release
,
4844 #undef lpfc_debugfs_op_dumpData
4845 static const struct file_operations lpfc_debugfs_op_dumpData
= {
4846 .owner
= THIS_MODULE
,
4847 .open
= lpfc_debugfs_dumpData_open
,
4848 .llseek
= lpfc_debugfs_lseek
,
4849 .read
= lpfc_debugfs_read
,
4850 .write
= lpfc_debugfs_dumpDataDif_write
,
4851 .release
= lpfc_debugfs_dumpDataDif_release
,
4854 #undef lpfc_debugfs_op_dumpDif
4855 static const struct file_operations lpfc_debugfs_op_dumpDif
= {
4856 .owner
= THIS_MODULE
,
4857 .open
= lpfc_debugfs_dumpDif_open
,
4858 .llseek
= lpfc_debugfs_lseek
,
4859 .read
= lpfc_debugfs_read
,
4860 .write
= lpfc_debugfs_dumpDataDif_write
,
4861 .release
= lpfc_debugfs_dumpDataDif_release
,
4864 #undef lpfc_debugfs_op_dif_err
4865 static const struct file_operations lpfc_debugfs_op_dif_err
= {
4866 .owner
= THIS_MODULE
,
4867 .open
= simple_open
,
4868 .llseek
= lpfc_debugfs_lseek
,
4869 .read
= lpfc_debugfs_dif_err_read
,
4870 .write
= lpfc_debugfs_dif_err_write
,
4871 .release
= lpfc_debugfs_dif_err_release
,
4874 #undef lpfc_debugfs_op_slow_ring_trc
4875 static const struct file_operations lpfc_debugfs_op_slow_ring_trc
= {
4876 .owner
= THIS_MODULE
,
4877 .open
= lpfc_debugfs_slow_ring_trc_open
,
4878 .llseek
= lpfc_debugfs_lseek
,
4879 .read
= lpfc_debugfs_read
,
4880 .release
= lpfc_debugfs_release
,
4883 static struct dentry
*lpfc_debugfs_root
= NULL
;
4884 static atomic_t lpfc_debugfs_hba_count
;
4887 * File operations for the iDiag debugfs
4889 #undef lpfc_idiag_op_pciCfg
4890 static const struct file_operations lpfc_idiag_op_pciCfg
= {
4891 .owner
= THIS_MODULE
,
4892 .open
= lpfc_idiag_open
,
4893 .llseek
= lpfc_debugfs_lseek
,
4894 .read
= lpfc_idiag_pcicfg_read
,
4895 .write
= lpfc_idiag_pcicfg_write
,
4896 .release
= lpfc_idiag_cmd_release
,
4899 #undef lpfc_idiag_op_barAcc
4900 static const struct file_operations lpfc_idiag_op_barAcc
= {
4901 .owner
= THIS_MODULE
,
4902 .open
= lpfc_idiag_open
,
4903 .llseek
= lpfc_debugfs_lseek
,
4904 .read
= lpfc_idiag_baracc_read
,
4905 .write
= lpfc_idiag_baracc_write
,
4906 .release
= lpfc_idiag_cmd_release
,
4909 #undef lpfc_idiag_op_queInfo
4910 static const struct file_operations lpfc_idiag_op_queInfo
= {
4911 .owner
= THIS_MODULE
,
4912 .open
= lpfc_idiag_open
,
4913 .read
= lpfc_idiag_queinfo_read
,
4914 .release
= lpfc_idiag_release
,
4917 #undef lpfc_idiag_op_queAcc
4918 static const struct file_operations lpfc_idiag_op_queAcc
= {
4919 .owner
= THIS_MODULE
,
4920 .open
= lpfc_idiag_open
,
4921 .llseek
= lpfc_debugfs_lseek
,
4922 .read
= lpfc_idiag_queacc_read
,
4923 .write
= lpfc_idiag_queacc_write
,
4924 .release
= lpfc_idiag_cmd_release
,
4927 #undef lpfc_idiag_op_drbAcc
4928 static const struct file_operations lpfc_idiag_op_drbAcc
= {
4929 .owner
= THIS_MODULE
,
4930 .open
= lpfc_idiag_open
,
4931 .llseek
= lpfc_debugfs_lseek
,
4932 .read
= lpfc_idiag_drbacc_read
,
4933 .write
= lpfc_idiag_drbacc_write
,
4934 .release
= lpfc_idiag_cmd_release
,
4937 #undef lpfc_idiag_op_ctlAcc
4938 static const struct file_operations lpfc_idiag_op_ctlAcc
= {
4939 .owner
= THIS_MODULE
,
4940 .open
= lpfc_idiag_open
,
4941 .llseek
= lpfc_debugfs_lseek
,
4942 .read
= lpfc_idiag_ctlacc_read
,
4943 .write
= lpfc_idiag_ctlacc_write
,
4944 .release
= lpfc_idiag_cmd_release
,
4947 #undef lpfc_idiag_op_mbxAcc
4948 static const struct file_operations lpfc_idiag_op_mbxAcc
= {
4949 .owner
= THIS_MODULE
,
4950 .open
= lpfc_idiag_open
,
4951 .llseek
= lpfc_debugfs_lseek
,
4952 .read
= lpfc_idiag_mbxacc_read
,
4953 .write
= lpfc_idiag_mbxacc_write
,
4954 .release
= lpfc_idiag_cmd_release
,
4957 #undef lpfc_idiag_op_extAcc
4958 static const struct file_operations lpfc_idiag_op_extAcc
= {
4959 .owner
= THIS_MODULE
,
4960 .open
= lpfc_idiag_open
,
4961 .llseek
= lpfc_debugfs_lseek
,
4962 .read
= lpfc_idiag_extacc_read
,
4963 .write
= lpfc_idiag_extacc_write
,
4964 .release
= lpfc_idiag_cmd_release
,
4969 /* lpfc_idiag_mbxacc_dump_bsg_mbox - idiag debugfs dump bsg mailbox command
4970 * @phba: Pointer to HBA context object.
4971 * @dmabuf: Pointer to a DMA buffer descriptor.
4974 * This routine dump a bsg pass-through non-embedded mailbox command with
4978 lpfc_idiag_mbxacc_dump_bsg_mbox(struct lpfc_hba
*phba
, enum nemb_type nemb_tp
,
4979 enum mbox_type mbox_tp
, enum dma_type dma_tp
,
4980 enum sta_type sta_tp
,
4981 struct lpfc_dmabuf
*dmabuf
, uint32_t ext_buf
)
4983 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
4984 uint32_t *mbx_mbox_cmd
, *mbx_dump_map
, *mbx_dump_cnt
, *mbx_word_cnt
;
4985 char line_buf
[LPFC_MBX_ACC_LBUF_SZ
];
4987 uint32_t do_dump
= 0;
4991 if (idiag
.cmd
.opcode
!= LPFC_IDIAG_BSG_MBXACC_DP
)
4994 mbx_mbox_cmd
= &idiag
.cmd
.data
[IDIAG_MBXACC_MBCMD_INDX
];
4995 mbx_dump_map
= &idiag
.cmd
.data
[IDIAG_MBXACC_DPMAP_INDX
];
4996 mbx_dump_cnt
= &idiag
.cmd
.data
[IDIAG_MBXACC_DPCNT_INDX
];
4997 mbx_word_cnt
= &idiag
.cmd
.data
[IDIAG_MBXACC_WDCNT_INDX
];
4999 if (!(*mbx_dump_map
& LPFC_MBX_DMP_ALL
) ||
5000 (*mbx_dump_cnt
== 0) ||
5001 (*mbx_word_cnt
== 0))
5004 if (*mbx_mbox_cmd
!= 0x9B)
5007 if ((mbox_tp
== mbox_rd
) && (dma_tp
== dma_mbox
)) {
5008 if (*mbx_dump_map
& LPFC_BSG_DMP_MBX_RD_MBX
) {
5009 do_dump
|= LPFC_BSG_DMP_MBX_RD_MBX
;
5010 pr_err("\nRead mbox command (x%x), "
5011 "nemb:0x%x, extbuf_cnt:%d:\n",
5012 sta_tp
, nemb_tp
, ext_buf
);
5015 if ((mbox_tp
== mbox_rd
) && (dma_tp
== dma_ebuf
)) {
5016 if (*mbx_dump_map
& LPFC_BSG_DMP_MBX_RD_BUF
) {
5017 do_dump
|= LPFC_BSG_DMP_MBX_RD_BUF
;
5018 pr_err("\nRead mbox buffer (x%x), "
5019 "nemb:0x%x, extbuf_seq:%d:\n",
5020 sta_tp
, nemb_tp
, ext_buf
);
5023 if ((mbox_tp
== mbox_wr
) && (dma_tp
== dma_mbox
)) {
5024 if (*mbx_dump_map
& LPFC_BSG_DMP_MBX_WR_MBX
) {
5025 do_dump
|= LPFC_BSG_DMP_MBX_WR_MBX
;
5026 pr_err("\nWrite mbox command (x%x), "
5027 "nemb:0x%x, extbuf_cnt:%d:\n",
5028 sta_tp
, nemb_tp
, ext_buf
);
5031 if ((mbox_tp
== mbox_wr
) && (dma_tp
== dma_ebuf
)) {
5032 if (*mbx_dump_map
& LPFC_BSG_DMP_MBX_WR_BUF
) {
5033 do_dump
|= LPFC_BSG_DMP_MBX_WR_BUF
;
5034 pr_err("\nWrite mbox buffer (x%x), "
5035 "nemb:0x%x, extbuf_seq:%d:\n",
5036 sta_tp
, nemb_tp
, ext_buf
);
5040 /* dump buffer content */
5042 pword
= (uint32_t *)dmabuf
->virt
;
5043 for (i
= 0; i
< *mbx_word_cnt
; i
++) {
5046 pr_err("%s\n", line_buf
);
5048 len
+= snprintf(line_buf
+len
,
5049 LPFC_MBX_ACC_LBUF_SZ
-len
,
5052 len
+= snprintf(line_buf
+len
, LPFC_MBX_ACC_LBUF_SZ
-len
,
5053 "%08x ", (uint32_t)*pword
);
5057 pr_err("%s\n", line_buf
);
5061 /* Clean out command structure on reaching dump count */
5062 if (*mbx_dump_cnt
== 0)
5063 memset(&idiag
, 0, sizeof(idiag
));
5068 /* lpfc_idiag_mbxacc_dump_issue_mbox - idiag debugfs dump issue mailbox command
5069 * @phba: Pointer to HBA context object.
5070 * @dmabuf: Pointer to a DMA buffer descriptor.
5073 * This routine dump a pass-through non-embedded mailbox command from issue
5077 lpfc_idiag_mbxacc_dump_issue_mbox(struct lpfc_hba
*phba
, MAILBOX_t
*pmbox
)
5079 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
5080 uint32_t *mbx_dump_map
, *mbx_dump_cnt
, *mbx_word_cnt
, *mbx_mbox_cmd
;
5081 char line_buf
[LPFC_MBX_ACC_LBUF_SZ
];
5087 if (idiag
.cmd
.opcode
!= LPFC_IDIAG_CMD_MBXACC_DP
)
5090 mbx_mbox_cmd
= &idiag
.cmd
.data
[IDIAG_MBXACC_MBCMD_INDX
];
5091 mbx_dump_map
= &idiag
.cmd
.data
[IDIAG_MBXACC_DPMAP_INDX
];
5092 mbx_dump_cnt
= &idiag
.cmd
.data
[IDIAG_MBXACC_DPCNT_INDX
];
5093 mbx_word_cnt
= &idiag
.cmd
.data
[IDIAG_MBXACC_WDCNT_INDX
];
5095 if (!(*mbx_dump_map
& LPFC_MBX_DMP_MBX_ALL
) ||
5096 (*mbx_dump_cnt
== 0) ||
5097 (*mbx_word_cnt
== 0))
5100 if ((*mbx_mbox_cmd
!= LPFC_MBX_ALL_CMD
) &&
5101 (*mbx_mbox_cmd
!= pmbox
->mbxCommand
))
5104 /* dump buffer content */
5105 if (*mbx_dump_map
& LPFC_MBX_DMP_MBX_WORD
) {
5106 pr_err("Mailbox command:0x%x dump by word:\n",
5108 pword
= (uint32_t *)pmbox
;
5109 for (i
= 0; i
< *mbx_word_cnt
; i
++) {
5112 pr_err("%s\n", line_buf
);
5114 memset(line_buf
, 0, LPFC_MBX_ACC_LBUF_SZ
);
5115 len
+= snprintf(line_buf
+len
,
5116 LPFC_MBX_ACC_LBUF_SZ
-len
,
5119 len
+= snprintf(line_buf
+len
, LPFC_MBX_ACC_LBUF_SZ
-len
,
5121 ((uint32_t)*pword
) & 0xffffffff);
5125 pr_err("%s\n", line_buf
);
5128 if (*mbx_dump_map
& LPFC_MBX_DMP_MBX_BYTE
) {
5129 pr_err("Mailbox command:0x%x dump by byte:\n",
5131 pbyte
= (uint8_t *)pmbox
;
5132 for (i
= 0; i
< *mbx_word_cnt
; i
++) {
5135 pr_err("%s\n", line_buf
);
5137 memset(line_buf
, 0, LPFC_MBX_ACC_LBUF_SZ
);
5138 len
+= snprintf(line_buf
+len
,
5139 LPFC_MBX_ACC_LBUF_SZ
-len
,
5142 for (j
= 0; j
< 4; j
++) {
5143 len
+= snprintf(line_buf
+len
,
5144 LPFC_MBX_ACC_LBUF_SZ
-len
,
5146 ((uint8_t)*pbyte
) & 0xff);
5149 len
+= snprintf(line_buf
+len
,
5150 LPFC_MBX_ACC_LBUF_SZ
-len
, " ");
5153 pr_err("%s\n", line_buf
);
5158 /* Clean out command structure on reaching dump count */
5159 if (*mbx_dump_cnt
== 0)
5160 memset(&idiag
, 0, sizeof(idiag
));
5166 * lpfc_debugfs_initialize - Initialize debugfs for a vport
5167 * @vport: The vport pointer to initialize.
5170 * When Debugfs is configured this routine sets up the lpfc debugfs file system.
5171 * If not already created, this routine will create the lpfc directory, and
5172 * lpfcX directory (for this HBA), and vportX directory for this vport. It will
5173 * also create each file used to access lpfc specific debugfs information.
5176 lpfc_debugfs_initialize(struct lpfc_vport
*vport
)
5178 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
5179 struct lpfc_hba
*phba
= vport
->phba
;
5182 bool pport_setup
= false;
5184 if (!lpfc_debugfs_enable
)
5187 /* Setup lpfc root directory */
5188 if (!lpfc_debugfs_root
) {
5189 lpfc_debugfs_root
= debugfs_create_dir("lpfc", NULL
);
5190 atomic_set(&lpfc_debugfs_hba_count
, 0);
5191 if (!lpfc_debugfs_root
) {
5192 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5193 "0408 Cannot create debugfs root\n");
5197 if (!lpfc_debugfs_start_time
)
5198 lpfc_debugfs_start_time
= jiffies
;
5200 /* Setup funcX directory for specific HBA PCI function */
5201 snprintf(name
, sizeof(name
), "fn%d", phba
->brd_no
);
5202 if (!phba
->hba_debugfs_root
) {
5204 phba
->hba_debugfs_root
=
5205 debugfs_create_dir(name
, lpfc_debugfs_root
);
5206 if (!phba
->hba_debugfs_root
) {
5207 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5208 "0412 Cannot create debugfs hba\n");
5211 atomic_inc(&lpfc_debugfs_hba_count
);
5212 atomic_set(&phba
->debugfs_vport_count
, 0);
5215 snprintf(name
, sizeof(name
), "hbqinfo");
5216 phba
->debug_hbqinfo
=
5217 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5218 phba
->hba_debugfs_root
,
5219 phba
, &lpfc_debugfs_op_hbqinfo
);
5220 if (!phba
->debug_hbqinfo
) {
5221 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5222 "0411 Cannot create debugfs hbqinfo\n");
5226 /* Setup dumpHBASlim */
5227 if (phba
->sli_rev
< LPFC_SLI_REV4
) {
5228 snprintf(name
, sizeof(name
), "dumpHBASlim");
5229 phba
->debug_dumpHBASlim
=
5230 debugfs_create_file(name
,
5231 S_IFREG
|S_IRUGO
|S_IWUSR
,
5232 phba
->hba_debugfs_root
,
5233 phba
, &lpfc_debugfs_op_dumpHBASlim
);
5234 if (!phba
->debug_dumpHBASlim
) {
5235 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5236 "0413 Cannot create debugfs "
5241 phba
->debug_dumpHBASlim
= NULL
;
5243 /* Setup dumpHostSlim */
5244 if (phba
->sli_rev
< LPFC_SLI_REV4
) {
5245 snprintf(name
, sizeof(name
), "dumpHostSlim");
5246 phba
->debug_dumpHostSlim
=
5247 debugfs_create_file(name
,
5248 S_IFREG
|S_IRUGO
|S_IWUSR
,
5249 phba
->hba_debugfs_root
,
5250 phba
, &lpfc_debugfs_op_dumpHostSlim
);
5251 if (!phba
->debug_dumpHostSlim
) {
5252 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5253 "0414 Cannot create debugfs "
5258 phba
->debug_dumpHostSlim
= NULL
;
5260 /* Setup dumpData */
5261 snprintf(name
, sizeof(name
), "dumpData");
5262 phba
->debug_dumpData
=
5263 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5264 phba
->hba_debugfs_root
,
5265 phba
, &lpfc_debugfs_op_dumpData
);
5266 if (!phba
->debug_dumpData
) {
5267 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5268 "0800 Cannot create debugfs dumpData\n");
5273 snprintf(name
, sizeof(name
), "dumpDif");
5274 phba
->debug_dumpDif
=
5275 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5276 phba
->hba_debugfs_root
,
5277 phba
, &lpfc_debugfs_op_dumpDif
);
5278 if (!phba
->debug_dumpDif
) {
5279 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5280 "0801 Cannot create debugfs dumpDif\n");
5284 /* Setup DIF Error Injections */
5285 snprintf(name
, sizeof(name
), "InjErrLBA");
5286 phba
->debug_InjErrLBA
=
5287 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5288 phba
->hba_debugfs_root
,
5289 phba
, &lpfc_debugfs_op_dif_err
);
5290 if (!phba
->debug_InjErrLBA
) {
5291 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5292 "0807 Cannot create debugfs InjErrLBA\n");
5295 phba
->lpfc_injerr_lba
= LPFC_INJERR_LBA_OFF
;
5297 snprintf(name
, sizeof(name
), "InjErrNPortID");
5298 phba
->debug_InjErrNPortID
=
5299 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5300 phba
->hba_debugfs_root
,
5301 phba
, &lpfc_debugfs_op_dif_err
);
5302 if (!phba
->debug_InjErrNPortID
) {
5303 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5304 "0809 Cannot create debugfs InjErrNPortID\n");
5308 snprintf(name
, sizeof(name
), "InjErrWWPN");
5309 phba
->debug_InjErrWWPN
=
5310 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5311 phba
->hba_debugfs_root
,
5312 phba
, &lpfc_debugfs_op_dif_err
);
5313 if (!phba
->debug_InjErrWWPN
) {
5314 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5315 "0810 Cannot create debugfs InjErrWWPN\n");
5319 snprintf(name
, sizeof(name
), "writeGuardInjErr");
5320 phba
->debug_writeGuard
=
5321 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5322 phba
->hba_debugfs_root
,
5323 phba
, &lpfc_debugfs_op_dif_err
);
5324 if (!phba
->debug_writeGuard
) {
5325 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5326 "0802 Cannot create debugfs writeGuard\n");
5330 snprintf(name
, sizeof(name
), "writeAppInjErr");
5331 phba
->debug_writeApp
=
5332 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5333 phba
->hba_debugfs_root
,
5334 phba
, &lpfc_debugfs_op_dif_err
);
5335 if (!phba
->debug_writeApp
) {
5336 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5337 "0803 Cannot create debugfs writeApp\n");
5341 snprintf(name
, sizeof(name
), "writeRefInjErr");
5342 phba
->debug_writeRef
=
5343 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5344 phba
->hba_debugfs_root
,
5345 phba
, &lpfc_debugfs_op_dif_err
);
5346 if (!phba
->debug_writeRef
) {
5347 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5348 "0804 Cannot create debugfs writeRef\n");
5352 snprintf(name
, sizeof(name
), "readGuardInjErr");
5353 phba
->debug_readGuard
=
5354 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5355 phba
->hba_debugfs_root
,
5356 phba
, &lpfc_debugfs_op_dif_err
);
5357 if (!phba
->debug_readGuard
) {
5358 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5359 "0808 Cannot create debugfs readGuard\n");
5363 snprintf(name
, sizeof(name
), "readAppInjErr");
5364 phba
->debug_readApp
=
5365 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5366 phba
->hba_debugfs_root
,
5367 phba
, &lpfc_debugfs_op_dif_err
);
5368 if (!phba
->debug_readApp
) {
5369 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5370 "0805 Cannot create debugfs readApp\n");
5374 snprintf(name
, sizeof(name
), "readRefInjErr");
5375 phba
->debug_readRef
=
5376 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5377 phba
->hba_debugfs_root
,
5378 phba
, &lpfc_debugfs_op_dif_err
);
5379 if (!phba
->debug_readRef
) {
5380 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5381 "0806 Cannot create debugfs readApp\n");
5385 /* Setup slow ring trace */
5386 if (lpfc_debugfs_max_slow_ring_trc
) {
5387 num
= lpfc_debugfs_max_slow_ring_trc
- 1;
5388 if (num
& lpfc_debugfs_max_slow_ring_trc
) {
5389 /* Change to be a power of 2 */
5390 num
= lpfc_debugfs_max_slow_ring_trc
;
5396 lpfc_debugfs_max_slow_ring_trc
= (1 << i
);
5397 pr_err("lpfc_debugfs_max_disc_trc changed to "
5398 "%d\n", lpfc_debugfs_max_disc_trc
);
5402 snprintf(name
, sizeof(name
), "slow_ring_trace");
5403 phba
->debug_slow_ring_trc
=
5404 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5405 phba
->hba_debugfs_root
,
5406 phba
, &lpfc_debugfs_op_slow_ring_trc
);
5407 if (!phba
->debug_slow_ring_trc
) {
5408 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5409 "0415 Cannot create debugfs "
5410 "slow_ring_trace\n");
5413 if (!phba
->slow_ring_trc
) {
5414 phba
->slow_ring_trc
= kmalloc(
5415 (sizeof(struct lpfc_debugfs_trc
) *
5416 lpfc_debugfs_max_slow_ring_trc
),
5418 if (!phba
->slow_ring_trc
) {
5419 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5420 "0416 Cannot create debugfs "
5421 "slow_ring buffer\n");
5424 atomic_set(&phba
->slow_ring_trc_cnt
, 0);
5425 memset(phba
->slow_ring_trc
, 0,
5426 (sizeof(struct lpfc_debugfs_trc
) *
5427 lpfc_debugfs_max_slow_ring_trc
));
5430 snprintf(name
, sizeof(name
), "nvmeio_trc");
5431 phba
->debug_nvmeio_trc
=
5432 debugfs_create_file(name
, 0644,
5433 phba
->hba_debugfs_root
,
5434 phba
, &lpfc_debugfs_op_nvmeio_trc
);
5435 if (!phba
->debug_nvmeio_trc
) {
5436 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5437 "0574 No create debugfs nvmeio_trc\n");
5441 atomic_set(&phba
->nvmeio_trc_cnt
, 0);
5442 if (lpfc_debugfs_max_nvmeio_trc
) {
5443 num
= lpfc_debugfs_max_nvmeio_trc
- 1;
5444 if (num
& lpfc_debugfs_max_disc_trc
) {
5445 /* Change to be a power of 2 */
5446 num
= lpfc_debugfs_max_nvmeio_trc
;
5452 lpfc_debugfs_max_nvmeio_trc
= (1 << i
);
5453 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
5454 "0575 lpfc_debugfs_max_nvmeio_trc "
5456 lpfc_debugfs_max_nvmeio_trc
);
5458 phba
->nvmeio_trc_size
= lpfc_debugfs_max_nvmeio_trc
;
5460 /* Allocate trace buffer and initialize */
5461 phba
->nvmeio_trc
= kmalloc(
5462 (sizeof(struct lpfc_debugfs_nvmeio_trc
) *
5463 phba
->nvmeio_trc_size
), GFP_KERNEL
);
5465 if (!phba
->nvmeio_trc
) {
5466 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
5467 "0576 Cannot create debugfs "
5468 "nvmeio_trc buffer\n");
5471 memset(phba
->nvmeio_trc
, 0,
5472 (sizeof(struct lpfc_debugfs_nvmeio_trc
) *
5473 phba
->nvmeio_trc_size
));
5474 phba
->nvmeio_trc_on
= 1;
5475 phba
->nvmeio_trc_output_idx
= 0;
5476 phba
->nvmeio_trc
= NULL
;
5479 phba
->nvmeio_trc_size
= 0;
5480 phba
->nvmeio_trc_on
= 0;
5481 phba
->nvmeio_trc_output_idx
= 0;
5482 phba
->nvmeio_trc
= NULL
;
5486 snprintf(name
, sizeof(name
), "vport%d", vport
->vpi
);
5487 if (!vport
->vport_debugfs_root
) {
5488 vport
->vport_debugfs_root
=
5489 debugfs_create_dir(name
, phba
->hba_debugfs_root
);
5490 if (!vport
->vport_debugfs_root
) {
5491 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5492 "0417 Can't create debugfs\n");
5495 atomic_inc(&phba
->debugfs_vport_count
);
5498 if (lpfc_debugfs_max_disc_trc
) {
5499 num
= lpfc_debugfs_max_disc_trc
- 1;
5500 if (num
& lpfc_debugfs_max_disc_trc
) {
5501 /* Change to be a power of 2 */
5502 num
= lpfc_debugfs_max_disc_trc
;
5508 lpfc_debugfs_max_disc_trc
= (1 << i
);
5509 pr_err("lpfc_debugfs_max_disc_trc changed to %d\n",
5510 lpfc_debugfs_max_disc_trc
);
5514 vport
->disc_trc
= kzalloc(
5515 (sizeof(struct lpfc_debugfs_trc
) * lpfc_debugfs_max_disc_trc
),
5518 if (!vport
->disc_trc
) {
5519 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5520 "0418 Cannot create debugfs disc trace "
5524 atomic_set(&vport
->disc_trc_cnt
, 0);
5526 snprintf(name
, sizeof(name
), "discovery_trace");
5527 vport
->debug_disc_trc
=
5528 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5529 vport
->vport_debugfs_root
,
5530 vport
, &lpfc_debugfs_op_disc_trc
);
5531 if (!vport
->debug_disc_trc
) {
5532 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5533 "0419 Cannot create debugfs "
5534 "discovery_trace\n");
5537 snprintf(name
, sizeof(name
), "nodelist");
5538 vport
->debug_nodelist
=
5539 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5540 vport
->vport_debugfs_root
,
5541 vport
, &lpfc_debugfs_op_nodelist
);
5542 if (!vport
->debug_nodelist
) {
5543 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5544 "2985 Can't create debugfs nodelist\n");
5548 snprintf(name
, sizeof(name
), "nvmestat");
5549 vport
->debug_nvmestat
=
5550 debugfs_create_file(name
, 0644,
5551 vport
->vport_debugfs_root
,
5552 vport
, &lpfc_debugfs_op_nvmestat
);
5553 if (!vport
->debug_nvmestat
) {
5554 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5555 "0811 Cannot create debugfs nvmestat\n");
5559 snprintf(name
, sizeof(name
), "nvmektime");
5560 vport
->debug_nvmektime
=
5561 debugfs_create_file(name
, 0644,
5562 vport
->vport_debugfs_root
,
5563 vport
, &lpfc_debugfs_op_nvmektime
);
5564 if (!vport
->debug_nvmektime
) {
5565 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5566 "0815 Cannot create debugfs nvmektime\n");
5570 snprintf(name
, sizeof(name
), "cpucheck");
5571 vport
->debug_cpucheck
=
5572 debugfs_create_file(name
, 0644,
5573 vport
->vport_debugfs_root
,
5574 vport
, &lpfc_debugfs_op_cpucheck
);
5575 if (!vport
->debug_cpucheck
) {
5576 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5577 "0819 Cannot create debugfs cpucheck\n");
5582 * The following section is for additional directories/files for the
5590 * iDiag debugfs root entry points for SLI4 device only
5592 if (phba
->sli_rev
< LPFC_SLI_REV4
)
5595 snprintf(name
, sizeof(name
), "iDiag");
5596 if (!phba
->idiag_root
) {
5598 debugfs_create_dir(name
, phba
->hba_debugfs_root
);
5599 if (!phba
->idiag_root
) {
5600 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5601 "2922 Can't create idiag debugfs\n");
5604 /* Initialize iDiag data structure */
5605 memset(&idiag
, 0, sizeof(idiag
));
5608 /* iDiag read PCI config space */
5609 snprintf(name
, sizeof(name
), "pciCfg");
5610 if (!phba
->idiag_pci_cfg
) {
5611 phba
->idiag_pci_cfg
=
5612 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5613 phba
->idiag_root
, phba
, &lpfc_idiag_op_pciCfg
);
5614 if (!phba
->idiag_pci_cfg
) {
5615 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5616 "2923 Can't create idiag debugfs\n");
5619 idiag
.offset
.last_rd
= 0;
5622 /* iDiag PCI BAR access */
5623 snprintf(name
, sizeof(name
), "barAcc");
5624 if (!phba
->idiag_bar_acc
) {
5625 phba
->idiag_bar_acc
=
5626 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5627 phba
->idiag_root
, phba
, &lpfc_idiag_op_barAcc
);
5628 if (!phba
->idiag_bar_acc
) {
5629 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5630 "3056 Can't create idiag debugfs\n");
5633 idiag
.offset
.last_rd
= 0;
5636 /* iDiag get PCI function queue information */
5637 snprintf(name
, sizeof(name
), "queInfo");
5638 if (!phba
->idiag_que_info
) {
5639 phba
->idiag_que_info
=
5640 debugfs_create_file(name
, S_IFREG
|S_IRUGO
,
5641 phba
->idiag_root
, phba
, &lpfc_idiag_op_queInfo
);
5642 if (!phba
->idiag_que_info
) {
5643 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5644 "2924 Can't create idiag debugfs\n");
5649 /* iDiag access PCI function queue */
5650 snprintf(name
, sizeof(name
), "queAcc");
5651 if (!phba
->idiag_que_acc
) {
5652 phba
->idiag_que_acc
=
5653 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5654 phba
->idiag_root
, phba
, &lpfc_idiag_op_queAcc
);
5655 if (!phba
->idiag_que_acc
) {
5656 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5657 "2926 Can't create idiag debugfs\n");
5662 /* iDiag access PCI function doorbell registers */
5663 snprintf(name
, sizeof(name
), "drbAcc");
5664 if (!phba
->idiag_drb_acc
) {
5665 phba
->idiag_drb_acc
=
5666 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5667 phba
->idiag_root
, phba
, &lpfc_idiag_op_drbAcc
);
5668 if (!phba
->idiag_drb_acc
) {
5669 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5670 "2927 Can't create idiag debugfs\n");
5675 /* iDiag access PCI function control registers */
5676 snprintf(name
, sizeof(name
), "ctlAcc");
5677 if (!phba
->idiag_ctl_acc
) {
5678 phba
->idiag_ctl_acc
=
5679 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5680 phba
->idiag_root
, phba
, &lpfc_idiag_op_ctlAcc
);
5681 if (!phba
->idiag_ctl_acc
) {
5682 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5683 "2981 Can't create idiag debugfs\n");
5688 /* iDiag access mbox commands */
5689 snprintf(name
, sizeof(name
), "mbxAcc");
5690 if (!phba
->idiag_mbx_acc
) {
5691 phba
->idiag_mbx_acc
=
5692 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5693 phba
->idiag_root
, phba
, &lpfc_idiag_op_mbxAcc
);
5694 if (!phba
->idiag_mbx_acc
) {
5695 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5696 "2980 Can't create idiag debugfs\n");
5701 /* iDiag extents access commands */
5702 if (phba
->sli4_hba
.extents_in_use
) {
5703 snprintf(name
, sizeof(name
), "extAcc");
5704 if (!phba
->idiag_ext_acc
) {
5705 phba
->idiag_ext_acc
=
5706 debugfs_create_file(name
,
5707 S_IFREG
|S_IRUGO
|S_IWUSR
,
5708 phba
->idiag_root
, phba
,
5709 &lpfc_idiag_op_extAcc
);
5710 if (!phba
->idiag_ext_acc
) {
5711 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5725 * lpfc_debugfs_terminate - Tear down debugfs infrastructure for this vport
5726 * @vport: The vport pointer to remove from debugfs.
5729 * When Debugfs is configured this routine removes debugfs file system elements
5730 * that are specific to this vport. It also checks to see if there are any
5731 * users left for the debugfs directories associated with the HBA and driver. If
5732 * this is the last user of the HBA directory or driver directory then it will
5733 * remove those from the debugfs infrastructure as well.
5736 lpfc_debugfs_terminate(struct lpfc_vport
*vport
)
5738 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
5739 struct lpfc_hba
*phba
= vport
->phba
;
5741 kfree(vport
->disc_trc
);
5742 vport
->disc_trc
= NULL
;
5744 debugfs_remove(vport
->debug_disc_trc
); /* discovery_trace */
5745 vport
->debug_disc_trc
= NULL
;
5747 debugfs_remove(vport
->debug_nodelist
); /* nodelist */
5748 vport
->debug_nodelist
= NULL
;
5750 debugfs_remove(vport
->debug_nvmestat
); /* nvmestat */
5751 vport
->debug_nvmestat
= NULL
;
5753 debugfs_remove(vport
->debug_nvmektime
); /* nvmektime */
5754 vport
->debug_nvmektime
= NULL
;
5756 debugfs_remove(vport
->debug_cpucheck
); /* cpucheck */
5757 vport
->debug_cpucheck
= NULL
;
5759 if (vport
->vport_debugfs_root
) {
5760 debugfs_remove(vport
->vport_debugfs_root
); /* vportX */
5761 vport
->vport_debugfs_root
= NULL
;
5762 atomic_dec(&phba
->debugfs_vport_count
);
5765 if (atomic_read(&phba
->debugfs_vport_count
) == 0) {
5767 debugfs_remove(phba
->debug_hbqinfo
); /* hbqinfo */
5768 phba
->debug_hbqinfo
= NULL
;
5770 debugfs_remove(phba
->debug_dumpHBASlim
); /* HBASlim */
5771 phba
->debug_dumpHBASlim
= NULL
;
5773 debugfs_remove(phba
->debug_dumpHostSlim
); /* HostSlim */
5774 phba
->debug_dumpHostSlim
= NULL
;
5776 debugfs_remove(phba
->debug_dumpData
); /* dumpData */
5777 phba
->debug_dumpData
= NULL
;
5779 debugfs_remove(phba
->debug_dumpDif
); /* dumpDif */
5780 phba
->debug_dumpDif
= NULL
;
5782 debugfs_remove(phba
->debug_InjErrLBA
); /* InjErrLBA */
5783 phba
->debug_InjErrLBA
= NULL
;
5785 debugfs_remove(phba
->debug_InjErrNPortID
);
5786 phba
->debug_InjErrNPortID
= NULL
;
5788 debugfs_remove(phba
->debug_InjErrWWPN
); /* InjErrWWPN */
5789 phba
->debug_InjErrWWPN
= NULL
;
5791 debugfs_remove(phba
->debug_writeGuard
); /* writeGuard */
5792 phba
->debug_writeGuard
= NULL
;
5794 debugfs_remove(phba
->debug_writeApp
); /* writeApp */
5795 phba
->debug_writeApp
= NULL
;
5797 debugfs_remove(phba
->debug_writeRef
); /* writeRef */
5798 phba
->debug_writeRef
= NULL
;
5800 debugfs_remove(phba
->debug_readGuard
); /* readGuard */
5801 phba
->debug_readGuard
= NULL
;
5803 debugfs_remove(phba
->debug_readApp
); /* readApp */
5804 phba
->debug_readApp
= NULL
;
5806 debugfs_remove(phba
->debug_readRef
); /* readRef */
5807 phba
->debug_readRef
= NULL
;
5809 kfree(phba
->slow_ring_trc
);
5810 phba
->slow_ring_trc
= NULL
;
5812 /* slow_ring_trace */
5813 debugfs_remove(phba
->debug_slow_ring_trc
);
5814 phba
->debug_slow_ring_trc
= NULL
;
5816 debugfs_remove(phba
->debug_nvmeio_trc
);
5817 phba
->debug_nvmeio_trc
= NULL
;
5819 kfree(phba
->nvmeio_trc
);
5820 phba
->nvmeio_trc
= NULL
;
5825 if (phba
->sli_rev
== LPFC_SLI_REV4
) {
5827 debugfs_remove(phba
->idiag_ext_acc
);
5828 phba
->idiag_ext_acc
= NULL
;
5831 debugfs_remove(phba
->idiag_mbx_acc
);
5832 phba
->idiag_mbx_acc
= NULL
;
5835 debugfs_remove(phba
->idiag_ctl_acc
);
5836 phba
->idiag_ctl_acc
= NULL
;
5839 debugfs_remove(phba
->idiag_drb_acc
);
5840 phba
->idiag_drb_acc
= NULL
;
5843 debugfs_remove(phba
->idiag_que_acc
);
5844 phba
->idiag_que_acc
= NULL
;
5847 debugfs_remove(phba
->idiag_que_info
);
5848 phba
->idiag_que_info
= NULL
;
5851 debugfs_remove(phba
->idiag_bar_acc
);
5852 phba
->idiag_bar_acc
= NULL
;
5855 debugfs_remove(phba
->idiag_pci_cfg
);
5856 phba
->idiag_pci_cfg
= NULL
;
5858 /* Finally remove the iDiag debugfs root */
5859 debugfs_remove(phba
->idiag_root
);
5860 phba
->idiag_root
= NULL
;
5863 if (phba
->hba_debugfs_root
) {
5864 debugfs_remove(phba
->hba_debugfs_root
); /* fnX */
5865 phba
->hba_debugfs_root
= NULL
;
5866 atomic_dec(&lpfc_debugfs_hba_count
);
5869 if (atomic_read(&lpfc_debugfs_hba_count
) == 0) {
5870 debugfs_remove(lpfc_debugfs_root
); /* lpfc */
5871 lpfc_debugfs_root
= NULL
;
5879 * Driver debug utility routines outside of debugfs. The debug utility
5880 * routines implemented here is intended to be used in the instrumented
5881 * debug driver for debugging host or port issues.
5885 * lpfc_debug_dump_all_queues - dump all the queues with a hba
5886 * @phba: Pointer to HBA context object.
5888 * This function dumps entries of all the queues asociated with the @phba.
5891 lpfc_debug_dump_all_queues(struct lpfc_hba
*phba
)
5896 * Dump Work Queues (WQs)
5898 lpfc_debug_dump_wq(phba
, DUMP_MBX
, 0);
5899 lpfc_debug_dump_wq(phba
, DUMP_ELS
, 0);
5900 lpfc_debug_dump_wq(phba
, DUMP_NVMELS
, 0);
5902 for (idx
= 0; idx
< phba
->cfg_fcp_io_channel
; idx
++)
5903 lpfc_debug_dump_wq(phba
, DUMP_FCP
, idx
);
5905 for (idx
= 0; idx
< phba
->cfg_nvme_io_channel
; idx
++)
5906 lpfc_debug_dump_wq(phba
, DUMP_NVME
, idx
);
5908 lpfc_debug_dump_hdr_rq(phba
);
5909 lpfc_debug_dump_dat_rq(phba
);
5911 * Dump Complete Queues (CQs)
5913 lpfc_debug_dump_cq(phba
, DUMP_MBX
, 0);
5914 lpfc_debug_dump_cq(phba
, DUMP_ELS
, 0);
5915 lpfc_debug_dump_cq(phba
, DUMP_NVMELS
, 0);
5917 for (idx
= 0; idx
< phba
->cfg_fcp_io_channel
; idx
++)
5918 lpfc_debug_dump_cq(phba
, DUMP_FCP
, idx
);
5920 for (idx
= 0; idx
< phba
->cfg_nvme_io_channel
; idx
++)
5921 lpfc_debug_dump_cq(phba
, DUMP_NVME
, idx
);
5924 * Dump Event Queues (EQs)
5926 for (idx
= 0; idx
< phba
->io_channel_irqs
; idx
++)
5927 lpfc_debug_dump_hba_eq(phba
, idx
);