1 /*******************************************************************
2 * This file is part of the Emulex Linux Device Driver for *
3 * Fibre Channel Host Bus Adapters. *
4 * Copyright (C) 2017-2020 Broadcom. All Rights Reserved. The term *
5 * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. *
6 * Copyright (C) 2007-2015 Emulex. All rights reserved. *
7 * EMULEX and SLI are trademarks of Emulex. *
10 * This program is free software; you can redistribute it and/or *
11 * modify it under the terms of version 2 of the GNU General *
12 * Public License as published by the Free Software Foundation. *
13 * This program is distributed in the hope that it will be useful. *
14 * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND *
15 * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, *
16 * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE *
17 * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD *
18 * TO BE LEGALLY INVALID. See the GNU General Public License for *
19 * more details, a copy of which can be found in the file COPYING *
20 * included with this package. *
21 *******************************************************************/
23 #include <linux/blkdev.h>
24 #include <linux/delay.h>
25 #include <linux/module.h>
26 #include <linux/dma-mapping.h>
27 #include <linux/idr.h>
28 #include <linux/interrupt.h>
29 #include <linux/kthread.h>
30 #include <linux/slab.h>
31 #include <linux/pci.h>
32 #include <linux/spinlock.h>
33 #include <linux/ctype.h>
34 #include <linux/vmalloc.h>
36 #include <scsi/scsi.h>
37 #include <scsi/scsi_device.h>
38 #include <scsi/scsi_host.h>
39 #include <scsi/scsi_transport_fc.h>
40 #include <scsi/fc/fc_fs.h>
45 #include "lpfc_sli4.h"
47 #include "lpfc_disc.h"
49 #include "lpfc_scsi.h"
50 #include "lpfc_nvme.h"
51 #include "lpfc_logmsg.h"
52 #include "lpfc_crtn.h"
53 #include "lpfc_vport.h"
54 #include "lpfc_version.h"
55 #include "lpfc_compat.h"
56 #include "lpfc_debugfs.h"
59 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
63 * To access this interface the user should:
64 * # mount -t debugfs none /sys/kernel/debug
66 * The lpfc debugfs directory hierarchy is:
67 * /sys/kernel/debug/lpfc/fnX/vportY
68 * where X is the lpfc hba function unique_id
69 * where Y is the vport VPI on that hba
71 * Debugging services available per vport:
73 * This is an ACSII readable file that contains a trace of the last
74 * lpfc_debugfs_max_disc_trc events that happened on a specific vport.
75 * See lpfc_debugfs.h for different categories of discovery events.
76 * To enable the discovery trace, the following module parameters must be set:
77 * lpfc_debugfs_enable=1 Turns on lpfc debugfs filesystem support
78 * lpfc_debugfs_max_disc_trc=X Where X is the event trace depth for
79 * EACH vport. X MUST also be a power of 2.
80 * lpfc_debugfs_mask_disc_trc=Y Where Y is an event mask as defined in
84 * This is an ACSII readable file that contains a trace of the last
85 * lpfc_debugfs_max_slow_ring_trc events that happened on a specific HBA.
86 * To enable the slow ring trace, the following module parameters must be set:
87 * lpfc_debugfs_enable=1 Turns on lpfc debugfs filesystem support
88 * lpfc_debugfs_max_slow_ring_trc=X Where X is the event trace depth for
89 * the HBA. X MUST also be a power of 2.
91 static int lpfc_debugfs_enable
= 1;
92 module_param(lpfc_debugfs_enable
, int, S_IRUGO
);
93 MODULE_PARM_DESC(lpfc_debugfs_enable
, "Enable debugfs services");
95 /* This MUST be a power of 2 */
96 static int lpfc_debugfs_max_disc_trc
;
97 module_param(lpfc_debugfs_max_disc_trc
, int, S_IRUGO
);
98 MODULE_PARM_DESC(lpfc_debugfs_max_disc_trc
,
99 "Set debugfs discovery trace depth");
101 /* This MUST be a power of 2 */
102 static int lpfc_debugfs_max_slow_ring_trc
;
103 module_param(lpfc_debugfs_max_slow_ring_trc
, int, S_IRUGO
);
104 MODULE_PARM_DESC(lpfc_debugfs_max_slow_ring_trc
,
105 "Set debugfs slow ring trace depth");
107 /* This MUST be a power of 2 */
108 static int lpfc_debugfs_max_nvmeio_trc
;
109 module_param(lpfc_debugfs_max_nvmeio_trc
, int, 0444);
110 MODULE_PARM_DESC(lpfc_debugfs_max_nvmeio_trc
,
111 "Set debugfs NVME IO trace depth");
113 static int lpfc_debugfs_mask_disc_trc
;
114 module_param(lpfc_debugfs_mask_disc_trc
, int, S_IRUGO
);
115 MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc
,
116 "Set debugfs discovery trace mask");
118 #include <linux/debugfs.h>
120 static atomic_t lpfc_debugfs_seq_trc_cnt
= ATOMIC_INIT(0);
121 static unsigned long lpfc_debugfs_start_time
= 0L;
124 static struct lpfc_idiag idiag
;
127 * lpfc_debugfs_disc_trc_data - Dump discovery logging to a buffer
128 * @vport: The vport to gather the log info from.
129 * @buf: The buffer to dump log into.
130 * @size: The maximum amount of data to process.
133 * This routine gathers the lpfc discovery debugfs data from the @vport and
134 * dumps it to @buf up to @size number of bytes. It will start at the next entry
135 * in the log and process the log until the end of the buffer. Then it will
136 * gather from the beginning of the log and process until the current entry.
139 * Discovery logging will be disabled while while this routine dumps the log.
142 * This routine returns the amount of bytes that were dumped into @buf and will
146 lpfc_debugfs_disc_trc_data(struct lpfc_vport
*vport
, char *buf
, int size
)
148 int i
, index
, len
, enable
;
150 struct lpfc_debugfs_trc
*dtp
;
153 buffer
= kmalloc(LPFC_DEBUG_TRC_ENTRY_SIZE
, GFP_KERNEL
);
157 enable
= lpfc_debugfs_enable
;
158 lpfc_debugfs_enable
= 0;
161 index
= (atomic_read(&vport
->disc_trc_cnt
) + 1) &
162 (lpfc_debugfs_max_disc_trc
- 1);
163 for (i
= index
; i
< lpfc_debugfs_max_disc_trc
; i
++) {
164 dtp
= vport
->disc_trc
+ i
;
167 ms
= jiffies_to_msecs(dtp
->jif
- lpfc_debugfs_start_time
);
169 LPFC_DEBUG_TRC_ENTRY_SIZE
, "%010d:%010d ms:%s\n",
170 dtp
->seq_cnt
, ms
, dtp
->fmt
);
171 len
+= scnprintf(buf
+len
, size
-len
, buffer
,
172 dtp
->data1
, dtp
->data2
, dtp
->data3
);
174 for (i
= 0; i
< index
; i
++) {
175 dtp
= vport
->disc_trc
+ i
;
178 ms
= jiffies_to_msecs(dtp
->jif
- lpfc_debugfs_start_time
);
180 LPFC_DEBUG_TRC_ENTRY_SIZE
, "%010d:%010d ms:%s\n",
181 dtp
->seq_cnt
, ms
, dtp
->fmt
);
182 len
+= scnprintf(buf
+len
, size
-len
, buffer
,
183 dtp
->data1
, dtp
->data2
, dtp
->data3
);
186 lpfc_debugfs_enable
= enable
;
193 * lpfc_debugfs_slow_ring_trc_data - Dump slow ring logging to a buffer
194 * @phba: The HBA to gather the log info from.
195 * @buf: The buffer to dump log into.
196 * @size: The maximum amount of data to process.
199 * This routine gathers the lpfc slow ring debugfs data from the @phba and
200 * dumps it to @buf up to @size number of bytes. It will start at the next entry
201 * in the log and process the log until the end of the buffer. Then it will
202 * gather from the beginning of the log and process until the current entry.
205 * Slow ring logging will be disabled while while this routine dumps the log.
208 * This routine returns the amount of bytes that were dumped into @buf and will
212 lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba
*phba
, char *buf
, int size
)
214 int i
, index
, len
, enable
;
216 struct lpfc_debugfs_trc
*dtp
;
219 buffer
= kmalloc(LPFC_DEBUG_TRC_ENTRY_SIZE
, GFP_KERNEL
);
223 enable
= lpfc_debugfs_enable
;
224 lpfc_debugfs_enable
= 0;
227 index
= (atomic_read(&phba
->slow_ring_trc_cnt
) + 1) &
228 (lpfc_debugfs_max_slow_ring_trc
- 1);
229 for (i
= index
; i
< lpfc_debugfs_max_slow_ring_trc
; i
++) {
230 dtp
= phba
->slow_ring_trc
+ i
;
233 ms
= jiffies_to_msecs(dtp
->jif
- lpfc_debugfs_start_time
);
235 LPFC_DEBUG_TRC_ENTRY_SIZE
, "%010d:%010d ms:%s\n",
236 dtp
->seq_cnt
, ms
, dtp
->fmt
);
237 len
+= scnprintf(buf
+len
, size
-len
, buffer
,
238 dtp
->data1
, dtp
->data2
, dtp
->data3
);
240 for (i
= 0; i
< index
; i
++) {
241 dtp
= phba
->slow_ring_trc
+ i
;
244 ms
= jiffies_to_msecs(dtp
->jif
- lpfc_debugfs_start_time
);
246 LPFC_DEBUG_TRC_ENTRY_SIZE
, "%010d:%010d ms:%s\n",
247 dtp
->seq_cnt
, ms
, dtp
->fmt
);
248 len
+= scnprintf(buf
+len
, size
-len
, buffer
,
249 dtp
->data1
, dtp
->data2
, dtp
->data3
);
252 lpfc_debugfs_enable
= enable
;
258 static int lpfc_debugfs_last_hbq
= -1;
261 * lpfc_debugfs_hbqinfo_data - Dump host buffer queue info to a buffer
262 * @phba: The HBA to gather host buffer info from.
263 * @buf: The buffer to dump log into.
264 * @size: The maximum amount of data to process.
267 * This routine dumps the host buffer queue info from the @phba to @buf up to
268 * @size number of bytes. A header that describes the current hbq state will be
269 * dumped to @buf first and then info on each hbq entry will be dumped to @buf
270 * until @size bytes have been dumped or all the hbq info has been dumped.
273 * This routine will rotate through each configured HBQ each time called.
276 * This routine returns the amount of bytes that were dumped into @buf and will
280 lpfc_debugfs_hbqinfo_data(struct lpfc_hba
*phba
, char *buf
, int size
)
283 int i
, j
, found
, posted
, low
;
284 uint32_t phys
, raw_index
, getidx
;
285 struct lpfc_hbq_init
*hip
;
287 struct lpfc_hbq_entry
*hbqe
;
288 struct lpfc_dmabuf
*d_buf
;
289 struct hbq_dmabuf
*hbq_buf
;
291 if (phba
->sli_rev
!= 3)
294 spin_lock_irq(&phba
->hbalock
);
296 /* toggle between multiple hbqs, if any */
297 i
= lpfc_sli_hbq_count();
299 lpfc_debugfs_last_hbq
++;
300 if (lpfc_debugfs_last_hbq
>= i
)
301 lpfc_debugfs_last_hbq
= 0;
304 lpfc_debugfs_last_hbq
= 0;
306 i
= lpfc_debugfs_last_hbq
;
308 len
+= scnprintf(buf
+len
, size
-len
, "HBQ %d Info\n", i
);
310 hbqs
= &phba
->hbqs
[i
];
312 list_for_each_entry(d_buf
, &hbqs
->hbq_buffer_list
, list
)
315 hip
= lpfc_hbq_defs
[i
];
316 len
+= scnprintf(buf
+len
, size
-len
,
317 "idx:%d prof:%d rn:%d bufcnt:%d icnt:%d acnt:%d posted %d\n",
318 hip
->hbq_index
, hip
->profile
, hip
->rn
,
319 hip
->buffer_count
, hip
->init_count
, hip
->add_count
, posted
);
321 raw_index
= phba
->hbq_get
[i
];
322 getidx
= le32_to_cpu(raw_index
);
323 len
+= scnprintf(buf
+len
, size
-len
,
324 "entries:%d bufcnt:%d Put:%d nPut:%d localGet:%d hbaGet:%d\n",
325 hbqs
->entry_count
, hbqs
->buffer_count
, hbqs
->hbqPutIdx
,
326 hbqs
->next_hbqPutIdx
, hbqs
->local_hbqGetIdx
, getidx
);
328 hbqe
= (struct lpfc_hbq_entry
*) phba
->hbqs
[i
].hbq_virt
;
329 for (j
=0; j
<hbqs
->entry_count
; j
++) {
330 len
+= scnprintf(buf
+len
, size
-len
,
331 "%03d: %08x %04x %05x ", j
,
332 le32_to_cpu(hbqe
->bde
.addrLow
),
333 le32_to_cpu(hbqe
->bde
.tus
.w
),
334 le32_to_cpu(hbqe
->buffer_tag
));
338 /* First calculate if slot has an associated posted buffer */
339 low
= hbqs
->hbqPutIdx
- posted
;
341 if ((j
>= hbqs
->hbqPutIdx
) || (j
< low
)) {
342 len
+= scnprintf(buf
+ len
, size
- len
,
348 if ((j
>= hbqs
->hbqPutIdx
) &&
349 (j
< (hbqs
->entry_count
+low
))) {
350 len
+= scnprintf(buf
+ len
, size
- len
,
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
+= scnprintf(buf
+len
, size
-len
,
362 "Buf%d: x%px %06x\n", i
,
363 hbq_buf
->dbuf
.virt
, hbq_buf
->tag
);
370 len
+= scnprintf(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_xripool
;
384 * lpfc_debugfs_common_xri_data - Dump Hardware Queue info to a buffer
385 * @phba: The HBA to gather host buffer info from.
386 * @buf: The buffer to dump log into.
387 * @size: The maximum amount of data to process.
390 * This routine dumps the Hardware Queue info from the @phba to @buf up to
391 * @size number of bytes. A header that describes the current hdwq state will be
392 * dumped to @buf first and then info on each hdwq entry will be dumped to @buf
393 * until @size bytes have been dumped or all the hdwq info has been dumped.
396 * This routine will rotate through each configured Hardware Queue each
400 * This routine returns the amount of bytes that were dumped into @buf and will
404 lpfc_debugfs_commonxripools_data(struct lpfc_hba
*phba
, char *buf
, int size
)
406 struct lpfc_sli4_hdw_queue
*qp
;
411 for (i
= 0; i
< phba
->cfg_hdw_queue
; i
++) {
412 if (len
> (LPFC_DUMP_MULTIXRIPOOL_SIZE
- 80))
414 qp
= &phba
->sli4_hba
.hdwq
[lpfc_debugfs_last_xripool
];
416 len
+= scnprintf(buf
+ len
, size
- len
, "HdwQ %d Info ", i
);
417 spin_lock_irqsave(&qp
->abts_io_buf_list_lock
, iflag
);
418 spin_lock(&qp
->io_buf_list_get_lock
);
419 spin_lock(&qp
->io_buf_list_put_lock
);
420 out
= qp
->total_io_bufs
- (qp
->get_io_bufs
+ qp
->put_io_bufs
+
421 qp
->abts_scsi_io_bufs
+ qp
->abts_nvme_io_bufs
);
422 len
+= scnprintf(buf
+ len
, size
- len
,
423 "tot:%d get:%d put:%d mt:%d "
424 "ABTS scsi:%d nvme:%d Out:%d\n",
425 qp
->total_io_bufs
, qp
->get_io_bufs
, qp
->put_io_bufs
,
426 qp
->empty_io_bufs
, qp
->abts_scsi_io_bufs
,
427 qp
->abts_nvme_io_bufs
, out
);
428 spin_unlock(&qp
->io_buf_list_put_lock
);
429 spin_unlock(&qp
->io_buf_list_get_lock
);
430 spin_unlock_irqrestore(&qp
->abts_io_buf_list_lock
, iflag
);
432 lpfc_debugfs_last_xripool
++;
433 if (lpfc_debugfs_last_xripool
>= phba
->cfg_hdw_queue
)
434 lpfc_debugfs_last_xripool
= 0;
441 * lpfc_debugfs_multixripools_data - Display multi-XRI pools information
442 * @phba: The HBA to gather host buffer info from.
443 * @buf: The buffer to dump log into.
444 * @size: The maximum amount of data to process.
447 * This routine displays current multi-XRI pools information including XRI
448 * count in public, private and txcmplq. It also displays current high and
452 * This routine returns the amount of bytes that were dumped into @buf and will
456 lpfc_debugfs_multixripools_data(struct lpfc_hba
*phba
, char *buf
, int size
)
460 struct lpfc_sli4_hdw_queue
*qp
;
461 struct lpfc_multixri_pool
*multixri_pool
;
462 struct lpfc_pvt_pool
*pvt_pool
;
463 struct lpfc_pbl_pool
*pbl_pool
;
465 char tmp
[LPFC_DEBUG_OUT_LINE_SZ
] = {0};
467 if (phba
->sli_rev
!= LPFC_SLI_REV4
)
470 if (!phba
->sli4_hba
.hdwq
)
473 if (!phba
->cfg_xri_rebalancing
) {
474 i
= lpfc_debugfs_commonxripools_data(phba
, buf
, size
);
479 * Pbl: Current number of free XRIs in public pool
480 * Pvt: Current number of free XRIs in private pool
481 * Busy: Current number of outstanding XRIs
482 * HWM: Current high watermark
483 * pvt_empty: Incremented by 1 when IO submission fails (no xri)
484 * pbl_empty: Incremented by 1 when all pbl_pool are empty during
487 scnprintf(tmp
, sizeof(tmp
),
488 "HWQ: Pbl Pvt Busy HWM | pvt_empty pbl_empty ");
489 if (strlcat(buf
, tmp
, size
) >= size
)
490 return strnlen(buf
, size
);
494 * MAXH: Max high watermark seen so far
495 * above_lmt: Incremented by 1 if xri_owned > xri_limit during
497 * below_lmt: Incremented by 1 if xri_owned <= xri_limit during
499 * locPbl_hit: Incremented by 1 if successfully get a batch of XRI from
501 * othPbl_hit: Incremented by 1 if successfully get a batch of XRI from
504 scnprintf(tmp
, sizeof(tmp
),
505 "MAXH above_lmt below_lmt locPbl_hit othPbl_hit");
506 if (strlcat(buf
, tmp
, size
) >= size
)
507 return strnlen(buf
, size
);
510 * sPbl: snapshot of Pbl 15 sec after stat gets cleared
511 * sPvt: snapshot of Pvt 15 sec after stat gets cleared
512 * sBusy: snapshot of Busy 15 sec after stat gets cleared
514 scnprintf(tmp
, sizeof(tmp
),
515 " | sPbl sPvt sBusy");
516 if (strlcat(buf
, tmp
, size
) >= size
)
517 return strnlen(buf
, size
);
520 scnprintf(tmp
, sizeof(tmp
), "\n");
521 if (strlcat(buf
, tmp
, size
) >= size
)
522 return strnlen(buf
, size
);
524 hwq_count
= phba
->cfg_hdw_queue
;
525 for (i
= 0; i
< hwq_count
; i
++) {
526 qp
= &phba
->sli4_hba
.hdwq
[i
];
527 multixri_pool
= qp
->p_multixri_pool
;
530 pbl_pool
= &multixri_pool
->pbl_pool
;
531 pvt_pool
= &multixri_pool
->pvt_pool
;
532 txcmplq_cnt
= qp
->io_wq
->pring
->txcmplq_cnt
;
534 scnprintf(tmp
, sizeof(tmp
),
535 "%03d: %4d %4d %4d %4d | %10d %10d ",
536 i
, pbl_pool
->count
, pvt_pool
->count
,
537 txcmplq_cnt
, pvt_pool
->high_watermark
,
538 qp
->empty_io_bufs
, multixri_pool
->pbl_empty_count
);
539 if (strlcat(buf
, tmp
, size
) >= size
)
543 scnprintf(tmp
, sizeof(tmp
),
544 "%4d %10d %10d %10d %10d",
545 multixri_pool
->stat_max_hwm
,
546 multixri_pool
->above_limit_count
,
547 multixri_pool
->below_limit_count
,
548 multixri_pool
->local_pbl_hit_count
,
549 multixri_pool
->other_pbl_hit_count
);
550 if (strlcat(buf
, tmp
, size
) >= size
)
553 scnprintf(tmp
, sizeof(tmp
),
555 multixri_pool
->stat_pbl_count
,
556 multixri_pool
->stat_pvt_count
,
557 multixri_pool
->stat_busy_count
);
558 if (strlcat(buf
, tmp
, size
) >= size
)
562 scnprintf(tmp
, sizeof(tmp
), "\n");
563 if (strlcat(buf
, tmp
, size
) >= size
)
566 return strnlen(buf
, size
);
570 #ifdef LPFC_HDWQ_LOCK_STAT
571 static int lpfc_debugfs_last_lock
;
574 * lpfc_debugfs_lockstat_data - Dump Hardware Queue info to a buffer
575 * @phba: The HBA to gather host buffer info from.
576 * @buf: The buffer to dump log into.
577 * @size: The maximum amount of data to process.
580 * This routine dumps the Hardware Queue info from the @phba to @buf up to
581 * @size number of bytes. A header that describes the current hdwq state will be
582 * dumped to @buf first and then info on each hdwq entry will be dumped to @buf
583 * until @size bytes have been dumped or all the hdwq info has been dumped.
586 * This routine will rotate through each configured Hardware Queue each
590 * This routine returns the amount of bytes that were dumped into @buf and will
594 lpfc_debugfs_lockstat_data(struct lpfc_hba
*phba
, char *buf
, int size
)
596 struct lpfc_sli4_hdw_queue
*qp
;
600 if (phba
->sli_rev
!= LPFC_SLI_REV4
)
603 if (!phba
->sli4_hba
.hdwq
)
606 for (i
= 0; i
< phba
->cfg_hdw_queue
; i
++) {
607 if (len
> (LPFC_HDWQINFO_SIZE
- 100))
609 qp
= &phba
->sli4_hba
.hdwq
[lpfc_debugfs_last_lock
];
611 len
+= scnprintf(buf
+ len
, size
- len
, "HdwQ %03d Lock ", i
);
612 if (phba
->cfg_xri_rebalancing
) {
613 len
+= scnprintf(buf
+ len
, size
- len
,
614 "get_pvt:%d mv_pvt:%d "
615 "mv2pub:%d mv2pvt:%d "
616 "put_pvt:%d put_pub:%d wq:%d\n",
617 qp
->lock_conflict
.alloc_pvt_pool
,
618 qp
->lock_conflict
.mv_from_pvt_pool
,
619 qp
->lock_conflict
.mv_to_pub_pool
,
620 qp
->lock_conflict
.mv_to_pvt_pool
,
621 qp
->lock_conflict
.free_pvt_pool
,
622 qp
->lock_conflict
.free_pub_pool
,
623 qp
->lock_conflict
.wq_access
);
625 len
+= scnprintf(buf
+ len
, size
- len
,
626 "get:%d put:%d free:%d wq:%d\n",
627 qp
->lock_conflict
.alloc_xri_get
,
628 qp
->lock_conflict
.alloc_xri_put
,
629 qp
->lock_conflict
.free_xri
,
630 qp
->lock_conflict
.wq_access
);
633 lpfc_debugfs_last_lock
++;
634 if (lpfc_debugfs_last_lock
>= phba
->cfg_hdw_queue
)
635 lpfc_debugfs_last_lock
= 0;
642 static int lpfc_debugfs_last_hba_slim_off
;
645 * lpfc_debugfs_dumpHBASlim_data - Dump HBA SLIM info to a buffer
646 * @phba: The HBA to gather SLIM info from.
647 * @buf: The buffer to dump log into.
648 * @size: The maximum amount of data to process.
651 * This routine dumps the current contents of HBA SLIM for the HBA associated
652 * with @phba to @buf up to @size bytes of data. This is the raw HBA SLIM data.
655 * This routine will only dump up to 1024 bytes of data each time called and
656 * should be called multiple times to dump the entire HBA SLIM.
659 * This routine returns the amount of bytes that were dumped into @buf and will
663 lpfc_debugfs_dumpHBASlim_data(struct lpfc_hba
*phba
, char *buf
, int size
)
670 buffer
= kmalloc(1024, GFP_KERNEL
);
675 spin_lock_irq(&phba
->hbalock
);
677 len
+= scnprintf(buf
+len
, size
-len
, "HBA SLIM\n");
678 lpfc_memcpy_from_slim(buffer
,
679 phba
->MBslimaddr
+ lpfc_debugfs_last_hba_slim_off
, 1024);
681 ptr
= (uint32_t *)&buffer
[0];
682 off
= lpfc_debugfs_last_hba_slim_off
;
684 /* Set it up for the next time */
685 lpfc_debugfs_last_hba_slim_off
+= 1024;
686 if (lpfc_debugfs_last_hba_slim_off
>= 4096)
687 lpfc_debugfs_last_hba_slim_off
= 0;
691 len
+= scnprintf(buf
+len
, size
-len
,
692 "%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n",
693 off
, *ptr
, *(ptr
+1), *(ptr
+2), *(ptr
+3), *(ptr
+4),
694 *(ptr
+5), *(ptr
+6), *(ptr
+7));
696 i
-= (8 * sizeof(uint32_t));
697 off
+= (8 * sizeof(uint32_t));
700 spin_unlock_irq(&phba
->hbalock
);
707 * lpfc_debugfs_dumpHostSlim_data - Dump host SLIM info to a buffer
708 * @phba: The HBA to gather Host SLIM info from.
709 * @buf: The buffer to dump log into.
710 * @size: The maximum amount of data to process.
713 * This routine dumps the current contents of host SLIM for the host associated
714 * with @phba to @buf up to @size bytes of data. The dump will contain the
715 * Mailbox, PCB, Rings, and Registers that are located in host memory.
718 * This routine returns the amount of bytes that were dumped into @buf and will
722 lpfc_debugfs_dumpHostSlim_data(struct lpfc_hba
*phba
, char *buf
, int size
)
726 uint32_t word0
, word1
, word2
, word3
;
728 struct lpfc_pgp
*pgpp
;
729 struct lpfc_sli
*psli
= &phba
->sli
;
730 struct lpfc_sli_ring
*pring
;
733 spin_lock_irq(&phba
->hbalock
);
735 len
+= scnprintf(buf
+len
, size
-len
, "SLIM Mailbox\n");
736 ptr
= (uint32_t *)phba
->slim2p
.virt
;
737 i
= sizeof(MAILBOX_t
);
739 len
+= scnprintf(buf
+len
, size
-len
,
740 "%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n",
741 off
, *ptr
, *(ptr
+1), *(ptr
+2), *(ptr
+3), *(ptr
+4),
742 *(ptr
+5), *(ptr
+6), *(ptr
+7));
744 i
-= (8 * sizeof(uint32_t));
745 off
+= (8 * sizeof(uint32_t));
748 len
+= scnprintf(buf
+len
, size
-len
, "SLIM PCB\n");
749 ptr
= (uint32_t *)phba
->pcb
;
752 len
+= scnprintf(buf
+len
, size
-len
,
753 "%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n",
754 off
, *ptr
, *(ptr
+1), *(ptr
+2), *(ptr
+3), *(ptr
+4),
755 *(ptr
+5), *(ptr
+6), *(ptr
+7));
757 i
-= (8 * sizeof(uint32_t));
758 off
+= (8 * sizeof(uint32_t));
761 if (phba
->sli_rev
<= LPFC_SLI_REV3
) {
762 for (i
= 0; i
< 4; i
++) {
763 pgpp
= &phba
->port_gp
[i
];
764 pring
= &psli
->sli3_ring
[i
];
765 len
+= scnprintf(buf
+len
, size
-len
,
766 "Ring %d: CMD GetInx:%d "
769 "RSP PutInx:%d Max:%d\n",
771 pring
->sli
.sli3
.numCiocb
,
772 pring
->sli
.sli3
.next_cmdidx
,
773 pring
->sli
.sli3
.local_getidx
,
774 pring
->flag
, pgpp
->rspPutInx
,
775 pring
->sli
.sli3
.numRiocb
);
778 word0
= readl(phba
->HAregaddr
);
779 word1
= readl(phba
->CAregaddr
);
780 word2
= readl(phba
->HSregaddr
);
781 word3
= readl(phba
->HCregaddr
);
782 len
+= scnprintf(buf
+len
, size
-len
, "HA:%08x CA:%08x HS:%08x "
783 "HC:%08x\n", word0
, word1
, word2
, word3
);
785 spin_unlock_irq(&phba
->hbalock
);
790 * lpfc_debugfs_nodelist_data - Dump target node list to a buffer
791 * @vport: The vport to gather target node info from.
792 * @buf: The buffer to dump log into.
793 * @size: The maximum amount of data to process.
796 * This routine dumps the current target node list associated with @vport to
797 * @buf up to @size bytes of data. Each node entry in the dump will contain a
798 * node state, DID, WWPN, WWNN, RPI, flags, type, and other useful fields.
801 * This routine returns the amount of bytes that were dumped into @buf and will
805 lpfc_debugfs_nodelist_data(struct lpfc_vport
*vport
, char *buf
, int size
)
808 int i
, iocnt
, outio
, cnt
;
809 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
810 struct lpfc_hba
*phba
= vport
->phba
;
811 struct lpfc_nodelist
*ndlp
;
812 unsigned char *statep
;
813 struct nvme_fc_local_port
*localport
;
814 struct nvme_fc_remote_port
*nrport
= NULL
;
815 struct lpfc_nvme_rport
*rport
;
817 cnt
= (LPFC_NODELIST_SIZE
/ LPFC_NODELIST_ENTRY_SIZE
);
820 len
+= scnprintf(buf
+len
, size
-len
, "\nFCP Nodelist Entries ...\n");
821 spin_lock_irq(shost
->host_lock
);
822 list_for_each_entry(ndlp
, &vport
->fc_nodes
, nlp_listp
) {
825 len
+= scnprintf(buf
+len
, size
-len
,
826 "Missing Nodelist Entries\n");
830 switch (ndlp
->nlp_state
) {
831 case NLP_STE_UNUSED_NODE
:
834 case NLP_STE_PLOGI_ISSUE
:
837 case NLP_STE_ADISC_ISSUE
:
840 case NLP_STE_REG_LOGIN_ISSUE
:
843 case NLP_STE_PRLI_ISSUE
:
846 case NLP_STE_LOGO_ISSUE
:
849 case NLP_STE_UNMAPPED_NODE
:
853 case NLP_STE_MAPPED_NODE
:
857 case NLP_STE_NPR_NODE
:
863 len
+= scnprintf(buf
+len
, size
-len
, "%s DID:x%06x ",
864 statep
, ndlp
->nlp_DID
);
865 len
+= scnprintf(buf
+len
, size
-len
,
867 wwn_to_u64(ndlp
->nlp_portname
.u
.wwn
));
868 len
+= scnprintf(buf
+len
, size
-len
,
870 wwn_to_u64(ndlp
->nlp_nodename
.u
.wwn
));
871 if (ndlp
->nlp_flag
& NLP_RPI_REGISTERED
)
872 len
+= scnprintf(buf
+len
, size
-len
, "RPI:%03d ",
875 len
+= scnprintf(buf
+len
, size
-len
, "RPI:none ");
876 len
+= scnprintf(buf
+len
, size
-len
, "flag:x%08x ",
879 len
+= scnprintf(buf
+len
, size
-len
, "UNKNOWN_TYPE ");
880 if (ndlp
->nlp_type
& NLP_FC_NODE
)
881 len
+= scnprintf(buf
+len
, size
-len
, "FC_NODE ");
882 if (ndlp
->nlp_type
& NLP_FABRIC
) {
883 len
+= scnprintf(buf
+len
, size
-len
, "FABRIC ");
886 if (ndlp
->nlp_type
& NLP_FCP_TARGET
)
887 len
+= scnprintf(buf
+len
, size
-len
, "FCP_TGT sid:%d ",
889 if (ndlp
->nlp_type
& NLP_FCP_INITIATOR
)
890 len
+= scnprintf(buf
+len
, size
-len
, "FCP_INITIATOR ");
891 if (ndlp
->nlp_type
& NLP_NVME_TARGET
)
892 len
+= scnprintf(buf
+ len
,
893 size
- len
, "NVME_TGT sid:%d ",
895 if (ndlp
->nlp_type
& NLP_NVME_INITIATOR
)
896 len
+= scnprintf(buf
+ len
,
897 size
- len
, "NVME_INITIATOR ");
898 len
+= scnprintf(buf
+len
, size
-len
, "refcnt:%x",
899 kref_read(&ndlp
->kref
));
901 i
= atomic_read(&ndlp
->cmd_pending
);
902 len
+= scnprintf(buf
+ len
, size
- len
,
903 " OutIO:x%x Qdepth x%x",
904 i
, ndlp
->cmd_qdepth
);
907 len
+= scnprintf(buf
+ len
, size
- len
, "defer:%x ",
908 ndlp
->nlp_defer_did
);
909 len
+= scnprintf(buf
+len
, size
-len
, "\n");
911 spin_unlock_irq(shost
->host_lock
);
913 len
+= scnprintf(buf
+ len
, size
- len
,
914 "\nOutstanding IO x%x\n", outio
);
916 if (phba
->nvmet_support
&& phba
->targetport
&& (vport
== phba
->pport
)) {
917 len
+= scnprintf(buf
+ len
, size
- len
,
918 "\nNVME Targetport Entry ...\n");
920 /* Port state is only one of two values for now. */
921 if (phba
->targetport
->port_id
)
922 statep
= "REGISTERED";
925 len
+= scnprintf(buf
+ len
, size
- len
,
926 "TGT WWNN x%llx WWPN x%llx State %s\n",
927 wwn_to_u64(vport
->fc_nodename
.u
.wwn
),
928 wwn_to_u64(vport
->fc_portname
.u
.wwn
),
930 len
+= scnprintf(buf
+ len
, size
- len
,
931 " Targetport DID x%06x\n",
932 phba
->targetport
->port_id
);
936 len
+= scnprintf(buf
+ len
, size
- len
,
937 "\nNVME Lport/Rport Entries ...\n");
939 localport
= vport
->localport
;
943 spin_lock_irq(shost
->host_lock
);
945 /* Port state is only one of two values for now. */
946 if (localport
->port_id
)
951 len
+= scnprintf(buf
+ len
, size
- len
,
952 "Lport DID x%06x PortState %s\n",
953 localport
->port_id
, statep
);
955 len
+= scnprintf(buf
+ len
, size
- len
, "\tRport List:\n");
956 list_for_each_entry(ndlp
, &vport
->fc_nodes
, nlp_listp
) {
957 /* local short-hand pointer. */
958 spin_lock(&ndlp
->lock
);
959 rport
= lpfc_ndlp_get_nrport(ndlp
);
961 nrport
= rport
->remoteport
;
964 spin_unlock(&ndlp
->lock
);
968 /* Port state is only one of two values for now. */
969 switch (nrport
->port_state
) {
970 case FC_OBJSTATE_ONLINE
:
973 case FC_OBJSTATE_UNKNOWN
:
977 statep
= "UNSUPPORTED";
981 /* Tab in to show lport ownership. */
982 len
+= scnprintf(buf
+ len
, size
- len
,
983 "\t%s Port ID:x%06x ",
984 statep
, nrport
->port_id
);
985 len
+= scnprintf(buf
+ len
, size
- len
, "WWPN x%llx ",
987 len
+= scnprintf(buf
+ len
, size
- len
, "WWNN x%llx ",
990 /* An NVME rport can have multiple roles. */
991 if (nrport
->port_role
& FC_PORT_ROLE_NVME_INITIATOR
)
992 len
+= scnprintf(buf
+ len
, size
- len
,
994 if (nrport
->port_role
& FC_PORT_ROLE_NVME_TARGET
)
995 len
+= scnprintf(buf
+ len
, size
- len
,
997 if (nrport
->port_role
& FC_PORT_ROLE_NVME_DISCOVERY
)
998 len
+= scnprintf(buf
+ len
, size
- len
,
1000 if (nrport
->port_role
& ~(FC_PORT_ROLE_NVME_INITIATOR
|
1001 FC_PORT_ROLE_NVME_TARGET
|
1002 FC_PORT_ROLE_NVME_DISCOVERY
))
1003 len
+= scnprintf(buf
+ len
, size
- len
,
1006 /* Terminate the string. */
1007 len
+= scnprintf(buf
+ len
, size
- len
, "\n");
1010 spin_unlock_irq(shost
->host_lock
);
1016 * lpfc_debugfs_nvmestat_data - Dump target node list to a buffer
1017 * @vport: The vport to gather target node info from.
1018 * @buf: The buffer to dump log into.
1019 * @size: The maximum amount of data to process.
1022 * This routine dumps the NVME statistics associated with @vport
1025 * This routine returns the amount of bytes that were dumped into @buf and will
1029 lpfc_debugfs_nvmestat_data(struct lpfc_vport
*vport
, char *buf
, int size
)
1031 struct lpfc_hba
*phba
= vport
->phba
;
1032 struct lpfc_nvmet_tgtport
*tgtp
;
1033 struct lpfc_async_xchg_ctx
*ctxp
, *next_ctxp
;
1034 struct nvme_fc_local_port
*localport
;
1035 struct lpfc_fc4_ctrl_stat
*cstat
;
1036 struct lpfc_nvme_lport
*lport
;
1037 uint64_t data1
, data2
, data3
;
1038 uint64_t tot
, totin
, totout
;
1042 if (phba
->nvmet_support
) {
1043 if (!phba
->targetport
)
1045 tgtp
= (struct lpfc_nvmet_tgtport
*)phba
->targetport
->private;
1046 len
+= scnprintf(buf
+ len
, size
- len
,
1047 "\nNVME Targetport Statistics\n");
1049 len
+= scnprintf(buf
+ len
, size
- len
,
1050 "LS: Rcv %08x Drop %08x Abort %08x\n",
1051 atomic_read(&tgtp
->rcv_ls_req_in
),
1052 atomic_read(&tgtp
->rcv_ls_req_drop
),
1053 atomic_read(&tgtp
->xmt_ls_abort
));
1054 if (atomic_read(&tgtp
->rcv_ls_req_in
) !=
1055 atomic_read(&tgtp
->rcv_ls_req_out
)) {
1056 len
+= scnprintf(buf
+ len
, size
- len
,
1057 "Rcv LS: in %08x != out %08x\n",
1058 atomic_read(&tgtp
->rcv_ls_req_in
),
1059 atomic_read(&tgtp
->rcv_ls_req_out
));
1062 len
+= scnprintf(buf
+ len
, size
- len
,
1063 "LS: Xmt %08x Drop %08x Cmpl %08x\n",
1064 atomic_read(&tgtp
->xmt_ls_rsp
),
1065 atomic_read(&tgtp
->xmt_ls_drop
),
1066 atomic_read(&tgtp
->xmt_ls_rsp_cmpl
));
1068 len
+= scnprintf(buf
+ len
, size
- len
,
1069 "LS: RSP Abort %08x xb %08x Err %08x\n",
1070 atomic_read(&tgtp
->xmt_ls_rsp_aborted
),
1071 atomic_read(&tgtp
->xmt_ls_rsp_xb_set
),
1072 atomic_read(&tgtp
->xmt_ls_rsp_error
));
1074 len
+= scnprintf(buf
+ len
, size
- len
,
1075 "FCP: Rcv %08x Defer %08x Release %08x "
1077 atomic_read(&tgtp
->rcv_fcp_cmd_in
),
1078 atomic_read(&tgtp
->rcv_fcp_cmd_defer
),
1079 atomic_read(&tgtp
->xmt_fcp_release
),
1080 atomic_read(&tgtp
->rcv_fcp_cmd_drop
));
1082 if (atomic_read(&tgtp
->rcv_fcp_cmd_in
) !=
1083 atomic_read(&tgtp
->rcv_fcp_cmd_out
)) {
1084 len
+= scnprintf(buf
+ len
, size
- len
,
1085 "Rcv FCP: in %08x != out %08x\n",
1086 atomic_read(&tgtp
->rcv_fcp_cmd_in
),
1087 atomic_read(&tgtp
->rcv_fcp_cmd_out
));
1090 len
+= scnprintf(buf
+ len
, size
- len
,
1091 "FCP Rsp: read %08x readrsp %08x "
1092 "write %08x rsp %08x\n",
1093 atomic_read(&tgtp
->xmt_fcp_read
),
1094 atomic_read(&tgtp
->xmt_fcp_read_rsp
),
1095 atomic_read(&tgtp
->xmt_fcp_write
),
1096 atomic_read(&tgtp
->xmt_fcp_rsp
));
1098 len
+= scnprintf(buf
+ len
, size
- len
,
1099 "FCP Rsp Cmpl: %08x err %08x drop %08x\n",
1100 atomic_read(&tgtp
->xmt_fcp_rsp_cmpl
),
1101 atomic_read(&tgtp
->xmt_fcp_rsp_error
),
1102 atomic_read(&tgtp
->xmt_fcp_rsp_drop
));
1104 len
+= scnprintf(buf
+ len
, size
- len
,
1105 "FCP Rsp Abort: %08x xb %08x xricqe %08x\n",
1106 atomic_read(&tgtp
->xmt_fcp_rsp_aborted
),
1107 atomic_read(&tgtp
->xmt_fcp_rsp_xb_set
),
1108 atomic_read(&tgtp
->xmt_fcp_xri_abort_cqe
));
1110 len
+= scnprintf(buf
+ len
, size
- len
,
1111 "ABORT: Xmt %08x Cmpl %08x\n",
1112 atomic_read(&tgtp
->xmt_fcp_abort
),
1113 atomic_read(&tgtp
->xmt_fcp_abort_cmpl
));
1115 len
+= scnprintf(buf
+ len
, size
- len
,
1116 "ABORT: Sol %08x Usol %08x Err %08x Cmpl %08x",
1117 atomic_read(&tgtp
->xmt_abort_sol
),
1118 atomic_read(&tgtp
->xmt_abort_unsol
),
1119 atomic_read(&tgtp
->xmt_abort_rsp
),
1120 atomic_read(&tgtp
->xmt_abort_rsp_error
));
1122 len
+= scnprintf(buf
+ len
, size
- len
, "\n");
1125 spin_lock(&phba
->sli4_hba
.abts_nvmet_buf_list_lock
);
1126 list_for_each_entry_safe(ctxp
, next_ctxp
,
1127 &phba
->sli4_hba
.lpfc_abts_nvmet_ctx_list
,
1131 spin_unlock(&phba
->sli4_hba
.abts_nvmet_buf_list_lock
);
1133 len
+= scnprintf(buf
+ len
, size
- len
,
1134 "ABORT: %d ctx entries\n", cnt
);
1135 spin_lock(&phba
->sli4_hba
.abts_nvmet_buf_list_lock
);
1136 list_for_each_entry_safe(ctxp
, next_ctxp
,
1137 &phba
->sli4_hba
.lpfc_abts_nvmet_ctx_list
,
1139 if (len
>= (size
- LPFC_DEBUG_OUT_LINE_SZ
))
1141 len
+= scnprintf(buf
+ len
, size
- len
,
1142 "Entry: oxid %x state %x "
1144 ctxp
->oxid
, ctxp
->state
,
1147 spin_unlock(&phba
->sli4_hba
.abts_nvmet_buf_list_lock
);
1150 /* Calculate outstanding IOs */
1151 tot
= atomic_read(&tgtp
->rcv_fcp_cmd_drop
);
1152 tot
+= atomic_read(&tgtp
->xmt_fcp_release
);
1153 tot
= atomic_read(&tgtp
->rcv_fcp_cmd_in
) - tot
;
1155 len
+= scnprintf(buf
+ len
, size
- len
,
1156 "IO_CTX: %08x WAIT: cur %08x tot %08x\n"
1157 "CTX Outstanding %08llx\n",
1158 phba
->sli4_hba
.nvmet_xri_cnt
,
1159 phba
->sli4_hba
.nvmet_io_wait_cnt
,
1160 phba
->sli4_hba
.nvmet_io_wait_total
,
1163 if (!(vport
->cfg_enable_fc4_type
& LPFC_ENABLE_NVME
))
1166 localport
= vport
->localport
;
1169 lport
= (struct lpfc_nvme_lport
*)localport
->private;
1173 len
+= scnprintf(buf
+ len
, size
- len
,
1174 "\nNVME HDWQ Statistics\n");
1176 len
+= scnprintf(buf
+ len
, size
- len
,
1177 "LS: Xmt %016x Cmpl %016x\n",
1178 atomic_read(&lport
->fc4NvmeLsRequests
),
1179 atomic_read(&lport
->fc4NvmeLsCmpls
));
1183 for (i
= 0; i
< phba
->cfg_hdw_queue
; i
++) {
1184 cstat
= &phba
->sli4_hba
.hdwq
[i
].nvme_cstat
;
1185 tot
= cstat
->io_cmpls
;
1187 data1
= cstat
->input_requests
;
1188 data2
= cstat
->output_requests
;
1189 data3
= cstat
->control_requests
;
1190 totout
+= (data1
+ data2
+ data3
);
1192 /* Limit to 32, debugfs display buffer limitation */
1196 len
+= scnprintf(buf
+ len
, PAGE_SIZE
- len
,
1197 "HDWQ (%d): Rd %016llx Wr %016llx "
1199 i
, data1
, data2
, data3
);
1200 len
+= scnprintf(buf
+ len
, PAGE_SIZE
- len
,
1201 "Cmpl %016llx OutIO %016llx\n",
1202 tot
, ((data1
+ data2
+ data3
) - tot
));
1204 len
+= scnprintf(buf
+ len
, PAGE_SIZE
- len
,
1205 "Total FCP Cmpl %016llx Issue %016llx "
1207 totin
, totout
, totout
- totin
);
1209 len
+= scnprintf(buf
+ len
, size
- len
,
1210 "LS Xmt Err: Abrt %08x Err %08x "
1211 "Cmpl Err: xb %08x Err %08x\n",
1212 atomic_read(&lport
->xmt_ls_abort
),
1213 atomic_read(&lport
->xmt_ls_err
),
1214 atomic_read(&lport
->cmpl_ls_xb
),
1215 atomic_read(&lport
->cmpl_ls_err
));
1217 len
+= scnprintf(buf
+ len
, size
- len
,
1218 "FCP Xmt Err: noxri %06x nondlp %06x "
1219 "qdepth %06x wqerr %06x err %06x Abrt %06x\n",
1220 atomic_read(&lport
->xmt_fcp_noxri
),
1221 atomic_read(&lport
->xmt_fcp_bad_ndlp
),
1222 atomic_read(&lport
->xmt_fcp_qdepth
),
1223 atomic_read(&lport
->xmt_fcp_wqerr
),
1224 atomic_read(&lport
->xmt_fcp_err
),
1225 atomic_read(&lport
->xmt_fcp_abort
));
1227 len
+= scnprintf(buf
+ len
, size
- len
,
1228 "FCP Cmpl Err: xb %08x Err %08x\n",
1229 atomic_read(&lport
->cmpl_fcp_xb
),
1230 atomic_read(&lport
->cmpl_fcp_err
));
1238 * lpfc_debugfs_scsistat_data - Dump target node list to a buffer
1239 * @vport: The vport to gather target node info from.
1240 * @buf: The buffer to dump log into.
1241 * @size: The maximum amount of data to process.
1244 * This routine dumps the SCSI statistics associated with @vport
1247 * This routine returns the amount of bytes that were dumped into @buf and will
1251 lpfc_debugfs_scsistat_data(struct lpfc_vport
*vport
, char *buf
, int size
)
1254 struct lpfc_hba
*phba
= vport
->phba
;
1255 struct lpfc_fc4_ctrl_stat
*cstat
;
1256 u64 data1
, data2
, data3
;
1257 u64 tot
, totin
, totout
;
1259 char tmp
[LPFC_MAX_SCSI_INFO_TMP_LEN
] = {0};
1261 if (!(vport
->cfg_enable_fc4_type
& LPFC_ENABLE_FCP
) ||
1262 (phba
->sli_rev
!= LPFC_SLI_REV4
))
1265 scnprintf(buf
, size
, "SCSI HDWQ Statistics\n");
1269 for (i
= 0; i
< phba
->cfg_hdw_queue
; i
++) {
1270 cstat
= &phba
->sli4_hba
.hdwq
[i
].scsi_cstat
;
1271 tot
= cstat
->io_cmpls
;
1273 data1
= cstat
->input_requests
;
1274 data2
= cstat
->output_requests
;
1275 data3
= cstat
->control_requests
;
1276 totout
+= (data1
+ data2
+ data3
);
1278 scnprintf(tmp
, sizeof(tmp
), "HDWQ (%d): Rd %016llx Wr %016llx "
1279 "IO %016llx ", i
, data1
, data2
, data3
);
1280 if (strlcat(buf
, tmp
, size
) >= size
)
1283 scnprintf(tmp
, sizeof(tmp
), "Cmpl %016llx OutIO %016llx\n",
1284 tot
, ((data1
+ data2
+ data3
) - tot
));
1285 if (strlcat(buf
, tmp
, size
) >= size
)
1288 scnprintf(tmp
, sizeof(tmp
), "Total FCP Cmpl %016llx Issue %016llx "
1289 "OutIO %016llx\n", totin
, totout
, totout
- totin
);
1290 strlcat(buf
, tmp
, size
);
1293 len
= strnlen(buf
, size
);
1299 lpfc_io_ktime(struct lpfc_hba
*phba
, struct lpfc_io_buf
*lpfc_cmd
)
1301 uint64_t seg1
, seg2
, seg3
, seg4
;
1304 if (!lpfc_cmd
->ts_last_cmd
||
1305 !lpfc_cmd
->ts_cmd_start
||
1306 !lpfc_cmd
->ts_cmd_wqput
||
1307 !lpfc_cmd
->ts_isr_cmpl
||
1308 !lpfc_cmd
->ts_data_io
)
1311 if (lpfc_cmd
->ts_data_io
< lpfc_cmd
->ts_cmd_start
)
1313 if (lpfc_cmd
->ts_cmd_start
< lpfc_cmd
->ts_last_cmd
)
1315 if (lpfc_cmd
->ts_cmd_wqput
< lpfc_cmd
->ts_cmd_start
)
1317 if (lpfc_cmd
->ts_isr_cmpl
< lpfc_cmd
->ts_cmd_wqput
)
1319 if (lpfc_cmd
->ts_data_io
< lpfc_cmd
->ts_isr_cmpl
)
1322 * Segment 1 - Time from Last FCP command cmpl is handed
1323 * off to NVME Layer to start of next command.
1324 * Segment 2 - Time from Driver receives a IO cmd start
1325 * from NVME Layer to WQ put is done on IO cmd.
1326 * Segment 3 - Time from Driver WQ put is done on IO cmd
1327 * to MSI-X ISR for IO cmpl.
1328 * Segment 4 - Time from MSI-X ISR for IO cmpl to when
1329 * cmpl is handled off to the NVME Layer.
1331 seg1
= lpfc_cmd
->ts_cmd_start
- lpfc_cmd
->ts_last_cmd
;
1332 if (seg1
> 5000000) /* 5 ms - for sequential IOs only */
1335 /* Calculate times relative to start of IO */
1336 seg2
= (lpfc_cmd
->ts_cmd_wqput
- lpfc_cmd
->ts_cmd_start
);
1338 seg3
= lpfc_cmd
->ts_isr_cmpl
- lpfc_cmd
->ts_cmd_start
;
1344 seg4
= lpfc_cmd
->ts_data_io
- lpfc_cmd
->ts_cmd_start
;
1349 phba
->ktime_data_samples
++;
1350 phba
->ktime_seg1_total
+= seg1
;
1351 if (seg1
< phba
->ktime_seg1_min
)
1352 phba
->ktime_seg1_min
= seg1
;
1353 else if (seg1
> phba
->ktime_seg1_max
)
1354 phba
->ktime_seg1_max
= seg1
;
1355 phba
->ktime_seg2_total
+= seg2
;
1356 if (seg2
< phba
->ktime_seg2_min
)
1357 phba
->ktime_seg2_min
= seg2
;
1358 else if (seg2
> phba
->ktime_seg2_max
)
1359 phba
->ktime_seg2_max
= seg2
;
1360 phba
->ktime_seg3_total
+= seg3
;
1361 if (seg3
< phba
->ktime_seg3_min
)
1362 phba
->ktime_seg3_min
= seg3
;
1363 else if (seg3
> phba
->ktime_seg3_max
)
1364 phba
->ktime_seg3_max
= seg3
;
1365 phba
->ktime_seg4_total
+= seg4
;
1366 if (seg4
< phba
->ktime_seg4_min
)
1367 phba
->ktime_seg4_min
= seg4
;
1368 else if (seg4
> phba
->ktime_seg4_max
)
1369 phba
->ktime_seg4_max
= seg4
;
1371 lpfc_cmd
->ts_last_cmd
= 0;
1372 lpfc_cmd
->ts_cmd_start
= 0;
1373 lpfc_cmd
->ts_cmd_wqput
= 0;
1374 lpfc_cmd
->ts_isr_cmpl
= 0;
1375 lpfc_cmd
->ts_data_io
= 0;
1379 * lpfc_debugfs_ioktime_data - Dump target node list to a buffer
1380 * @vport: The vport to gather target node info from.
1381 * @buf: The buffer to dump log into.
1382 * @size: The maximum amount of data to process.
1385 * This routine dumps the NVME statistics associated with @vport
1388 * This routine returns the amount of bytes that were dumped into @buf and will
1392 lpfc_debugfs_ioktime_data(struct lpfc_vport
*vport
, char *buf
, int size
)
1394 struct lpfc_hba
*phba
= vport
->phba
;
1397 if (phba
->nvmet_support
== 0) {
1399 len
+= scnprintf(buf
+ len
, PAGE_SIZE
- len
,
1400 "ktime %s: Total Samples: %lld\n",
1401 (phba
->ktime_on
? "Enabled" : "Disabled"),
1402 phba
->ktime_data_samples
);
1403 if (phba
->ktime_data_samples
== 0)
1407 buf
+ len
, PAGE_SIZE
- len
,
1408 "Segment 1: Last Cmd cmpl "
1409 "done -to- Start of next Cmd (in driver)\n");
1411 buf
+ len
, PAGE_SIZE
- len
,
1412 "avg:%08lld min:%08lld max %08lld\n",
1413 div_u64(phba
->ktime_seg1_total
,
1414 phba
->ktime_data_samples
),
1415 phba
->ktime_seg1_min
,
1416 phba
->ktime_seg1_max
);
1418 buf
+ len
, PAGE_SIZE
- len
,
1419 "Segment 2: Driver start of Cmd "
1420 "-to- Firmware WQ doorbell\n");
1422 buf
+ len
, PAGE_SIZE
- len
,
1423 "avg:%08lld min:%08lld max %08lld\n",
1424 div_u64(phba
->ktime_seg2_total
,
1425 phba
->ktime_data_samples
),
1426 phba
->ktime_seg2_min
,
1427 phba
->ktime_seg2_max
);
1429 buf
+ len
, PAGE_SIZE
- len
,
1430 "Segment 3: Firmware WQ doorbell -to- "
1431 "MSI-X ISR cmpl\n");
1433 buf
+ len
, PAGE_SIZE
- len
,
1434 "avg:%08lld min:%08lld max %08lld\n",
1435 div_u64(phba
->ktime_seg3_total
,
1436 phba
->ktime_data_samples
),
1437 phba
->ktime_seg3_min
,
1438 phba
->ktime_seg3_max
);
1440 buf
+ len
, PAGE_SIZE
- len
,
1441 "Segment 4: MSI-X ISR cmpl -to- "
1444 buf
+ len
, PAGE_SIZE
- len
,
1445 "avg:%08lld min:%08lld max %08lld\n",
1446 div_u64(phba
->ktime_seg4_total
,
1447 phba
->ktime_data_samples
),
1448 phba
->ktime_seg4_min
,
1449 phba
->ktime_seg4_max
);
1451 buf
+ len
, PAGE_SIZE
- len
,
1452 "Total IO avg time: %08lld\n",
1453 div_u64(phba
->ktime_seg1_total
+
1454 phba
->ktime_seg2_total
+
1455 phba
->ktime_seg3_total
+
1456 phba
->ktime_seg4_total
,
1457 phba
->ktime_data_samples
));
1462 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
1463 "ktime %s: Total Samples: %lld %lld\n",
1464 (phba
->ktime_on
? "Enabled" : "Disabled"),
1465 phba
->ktime_data_samples
,
1466 phba
->ktime_status_samples
);
1467 if (phba
->ktime_data_samples
== 0)
1470 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
1471 "Segment 1: MSI-X ISR Rcv cmd -to- "
1472 "cmd pass to NVME Layer\n");
1473 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
1474 "avg:%08lld min:%08lld max %08lld\n",
1475 div_u64(phba
->ktime_seg1_total
,
1476 phba
->ktime_data_samples
),
1477 phba
->ktime_seg1_min
,
1478 phba
->ktime_seg1_max
);
1479 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
1480 "Segment 2: cmd pass to NVME Layer- "
1481 "-to- Driver rcv cmd OP (action)\n");
1482 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
1483 "avg:%08lld min:%08lld max %08lld\n",
1484 div_u64(phba
->ktime_seg2_total
,
1485 phba
->ktime_data_samples
),
1486 phba
->ktime_seg2_min
,
1487 phba
->ktime_seg2_max
);
1488 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
1489 "Segment 3: Driver rcv cmd OP -to- "
1490 "Firmware WQ doorbell: cmd\n");
1491 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
1492 "avg:%08lld min:%08lld max %08lld\n",
1493 div_u64(phba
->ktime_seg3_total
,
1494 phba
->ktime_data_samples
),
1495 phba
->ktime_seg3_min
,
1496 phba
->ktime_seg3_max
);
1497 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
1498 "Segment 4: Firmware WQ doorbell: cmd "
1499 "-to- MSI-X ISR for cmd cmpl\n");
1500 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
1501 "avg:%08lld min:%08lld max %08lld\n",
1502 div_u64(phba
->ktime_seg4_total
,
1503 phba
->ktime_data_samples
),
1504 phba
->ktime_seg4_min
,
1505 phba
->ktime_seg4_max
);
1506 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
1507 "Segment 5: MSI-X ISR for cmd cmpl "
1508 "-to- NVME layer passed cmd done\n");
1509 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
1510 "avg:%08lld min:%08lld max %08lld\n",
1511 div_u64(phba
->ktime_seg5_total
,
1512 phba
->ktime_data_samples
),
1513 phba
->ktime_seg5_min
,
1514 phba
->ktime_seg5_max
);
1516 if (phba
->ktime_status_samples
== 0) {
1517 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
1518 "Total: cmd received by MSI-X ISR "
1519 "-to- cmd completed on wire\n");
1520 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
1521 "avg:%08lld min:%08lld "
1523 div_u64(phba
->ktime_seg10_total
,
1524 phba
->ktime_data_samples
),
1525 phba
->ktime_seg10_min
,
1526 phba
->ktime_seg10_max
);
1530 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
1531 "Segment 6: NVME layer passed cmd done "
1532 "-to- Driver rcv rsp status OP\n");
1533 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
1534 "avg:%08lld min:%08lld max %08lld\n",
1535 div_u64(phba
->ktime_seg6_total
,
1536 phba
->ktime_status_samples
),
1537 phba
->ktime_seg6_min
,
1538 phba
->ktime_seg6_max
);
1539 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
1540 "Segment 7: Driver rcv rsp status OP "
1541 "-to- Firmware WQ doorbell: status\n");
1542 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
1543 "avg:%08lld min:%08lld max %08lld\n",
1544 div_u64(phba
->ktime_seg7_total
,
1545 phba
->ktime_status_samples
),
1546 phba
->ktime_seg7_min
,
1547 phba
->ktime_seg7_max
);
1548 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
1549 "Segment 8: Firmware WQ doorbell: status"
1550 " -to- MSI-X ISR for status cmpl\n");
1551 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
1552 "avg:%08lld min:%08lld max %08lld\n",
1553 div_u64(phba
->ktime_seg8_total
,
1554 phba
->ktime_status_samples
),
1555 phba
->ktime_seg8_min
,
1556 phba
->ktime_seg8_max
);
1557 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
1558 "Segment 9: MSI-X ISR for status cmpl "
1559 "-to- NVME layer passed status done\n");
1560 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
1561 "avg:%08lld min:%08lld max %08lld\n",
1562 div_u64(phba
->ktime_seg9_total
,
1563 phba
->ktime_status_samples
),
1564 phba
->ktime_seg9_min
,
1565 phba
->ktime_seg9_max
);
1566 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
1567 "Total: cmd received by MSI-X ISR -to- "
1568 "cmd completed on wire\n");
1569 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
1570 "avg:%08lld min:%08lld max %08lld\n",
1571 div_u64(phba
->ktime_seg10_total
,
1572 phba
->ktime_status_samples
),
1573 phba
->ktime_seg10_min
,
1574 phba
->ktime_seg10_max
);
1579 * lpfc_debugfs_nvmeio_trc_data - Dump NVME IO trace list to a buffer
1580 * @phba: The phba to gather target node info from.
1581 * @buf: The buffer to dump log into.
1582 * @size: The maximum amount of data to process.
1585 * This routine dumps the NVME IO trace associated with @phba
1588 * This routine returns the amount of bytes that were dumped into @buf and will
1592 lpfc_debugfs_nvmeio_trc_data(struct lpfc_hba
*phba
, char *buf
, int size
)
1594 struct lpfc_debugfs_nvmeio_trc
*dtp
;
1595 int i
, state
, index
, skip
;
1598 state
= phba
->nvmeio_trc_on
;
1600 index
= (atomic_read(&phba
->nvmeio_trc_cnt
) + 1) &
1601 (phba
->nvmeio_trc_size
- 1);
1602 skip
= phba
->nvmeio_trc_output_idx
;
1604 len
+= scnprintf(buf
+ len
, size
- len
,
1605 "%s IO Trace %s: next_idx %d skip %d size %d\n",
1606 (phba
->nvmet_support
? "NVME" : "NVMET"),
1607 (state
? "Enabled" : "Disabled"),
1608 index
, skip
, phba
->nvmeio_trc_size
);
1610 if (!phba
->nvmeio_trc
|| state
)
1613 /* trace MUST bhe off to continue */
1615 for (i
= index
; i
< phba
->nvmeio_trc_size
; i
++) {
1620 dtp
= phba
->nvmeio_trc
+ i
;
1621 phba
->nvmeio_trc_output_idx
++;
1626 len
+= scnprintf(buf
+ len
, size
- len
, dtp
->fmt
,
1627 dtp
->data1
, dtp
->data2
, dtp
->data3
);
1629 if (phba
->nvmeio_trc_output_idx
>= phba
->nvmeio_trc_size
) {
1630 phba
->nvmeio_trc_output_idx
= 0;
1631 len
+= scnprintf(buf
+ len
, size
- len
,
1632 "Trace Complete\n");
1636 if (len
>= (size
- LPFC_DEBUG_OUT_LINE_SZ
)) {
1637 len
+= scnprintf(buf
+ len
, size
- len
,
1638 "Trace Continue (%d of %d)\n",
1639 phba
->nvmeio_trc_output_idx
,
1640 phba
->nvmeio_trc_size
);
1644 for (i
= 0; i
< index
; i
++) {
1649 dtp
= phba
->nvmeio_trc
+ i
;
1650 phba
->nvmeio_trc_output_idx
++;
1655 len
+= scnprintf(buf
+ len
, size
- len
, dtp
->fmt
,
1656 dtp
->data1
, dtp
->data2
, dtp
->data3
);
1658 if (phba
->nvmeio_trc_output_idx
>= phba
->nvmeio_trc_size
) {
1659 phba
->nvmeio_trc_output_idx
= 0;
1660 len
+= scnprintf(buf
+ len
, size
- len
,
1661 "Trace Complete\n");
1665 if (len
>= (size
- LPFC_DEBUG_OUT_LINE_SZ
)) {
1666 len
+= scnprintf(buf
+ len
, size
- len
,
1667 "Trace Continue (%d of %d)\n",
1668 phba
->nvmeio_trc_output_idx
,
1669 phba
->nvmeio_trc_size
);
1674 len
+= scnprintf(buf
+ len
, size
- len
,
1681 * lpfc_debugfs_hdwqstat_data - Dump I/O stats to a buffer
1682 * @vport: The vport to gather target node info from.
1683 * @buf: The buffer to dump log into.
1684 * @size: The maximum amount of data to process.
1687 * This routine dumps the NVME + SCSI statistics associated with @vport
1690 * This routine returns the amount of bytes that were dumped into @buf and will
1694 lpfc_debugfs_hdwqstat_data(struct lpfc_vport
*vport
, char *buf
, int size
)
1696 struct lpfc_hba
*phba
= vport
->phba
;
1697 struct lpfc_hdwq_stat
*c_stat
;
1702 char tmp
[LPFC_MAX_SCSI_INFO_TMP_LEN
] = {0};
1704 scnprintf(tmp
, sizeof(tmp
), "HDWQ Stats:\n\n");
1705 if (strlcat(buf
, tmp
, size
) >= size
)
1708 scnprintf(tmp
, sizeof(tmp
), "(NVME Accounting: %s) ",
1709 (phba
->hdwqstat_on
&
1710 (LPFC_CHECK_NVME_IO
| LPFC_CHECK_NVMET_IO
) ?
1711 "Enabled" : "Disabled"));
1712 if (strlcat(buf
, tmp
, size
) >= size
)
1715 scnprintf(tmp
, sizeof(tmp
), "(SCSI Accounting: %s) ",
1716 (phba
->hdwqstat_on
& LPFC_CHECK_SCSI_IO
?
1717 "Enabled" : "Disabled"));
1718 if (strlcat(buf
, tmp
, size
) >= size
)
1721 scnprintf(tmp
, sizeof(tmp
), "\n\n");
1722 if (strlcat(buf
, tmp
, size
) >= size
)
1725 for (i
= 0; i
< phba
->cfg_hdw_queue
; i
++) {
1730 for_each_present_cpu(j
) {
1731 c_stat
= per_cpu_ptr(phba
->sli4_hba
.c_stat
, j
);
1733 /* Only display for this HDWQ */
1734 if (i
!= c_stat
->hdwq_no
)
1737 /* Only display non-zero counters */
1738 if (!c_stat
->xmt_io
&& !c_stat
->cmpl_io
&&
1742 if (!tot_xmt
&& !tot_cmpl
&& !tot_rcv
) {
1743 /* Print HDWQ string only the first time */
1744 scnprintf(tmp
, sizeof(tmp
), "[HDWQ %d]:\t", i
);
1745 if (strlcat(buf
, tmp
, size
) >= size
)
1749 tot_xmt
+= c_stat
->xmt_io
;
1750 tot_cmpl
+= c_stat
->cmpl_io
;
1751 if (phba
->nvmet_support
)
1752 tot_rcv
+= c_stat
->rcv_io
;
1754 scnprintf(tmp
, sizeof(tmp
), "| [CPU %d]: ", j
);
1755 if (strlcat(buf
, tmp
, size
) >= size
)
1758 if (phba
->nvmet_support
) {
1759 scnprintf(tmp
, sizeof(tmp
),
1760 "XMT 0x%x CMPL 0x%x RCV 0x%x |",
1761 c_stat
->xmt_io
, c_stat
->cmpl_io
,
1763 if (strlcat(buf
, tmp
, size
) >= size
)
1766 scnprintf(tmp
, sizeof(tmp
),
1767 "XMT 0x%x CMPL 0x%x |",
1768 c_stat
->xmt_io
, c_stat
->cmpl_io
);
1769 if (strlcat(buf
, tmp
, size
) >= size
)
1774 /* Check if nothing to display */
1775 if (!tot_xmt
&& !tot_cmpl
&& !tot_rcv
)
1778 scnprintf(tmp
, sizeof(tmp
), "\t->\t[HDWQ Total: ");
1779 if (strlcat(buf
, tmp
, size
) >= size
)
1782 if (phba
->nvmet_support
) {
1783 scnprintf(tmp
, sizeof(tmp
),
1784 "XMT 0x%x CMPL 0x%x RCV 0x%x]\n\n",
1785 tot_xmt
, tot_cmpl
, tot_rcv
);
1786 if (strlcat(buf
, tmp
, size
) >= size
)
1789 scnprintf(tmp
, sizeof(tmp
),
1790 "XMT 0x%x CMPL 0x%x]\n\n",
1792 if (strlcat(buf
, tmp
, size
) >= size
)
1798 len
= strnlen(buf
, size
);
1805 * lpfc_debugfs_disc_trc - Store discovery trace log
1806 * @vport: The vport to associate this trace string with for retrieval.
1807 * @mask: Log entry classification.
1808 * @fmt: Format string to be displayed when dumping the log.
1809 * @data1: 1st data parameter to be applied to @fmt.
1810 * @data2: 2nd data parameter to be applied to @fmt.
1811 * @data3: 3rd data parameter to be applied to @fmt.
1814 * This routine is used by the driver code to add a debugfs log entry to the
1815 * discovery trace buffer associated with @vport. Only entries with a @mask that
1816 * match the current debugfs discovery mask will be saved. Entries that do not
1817 * match will be thrown away. @fmt, @data1, @data2, and @data3 are used like
1818 * printf when displaying the log.
1821 lpfc_debugfs_disc_trc(struct lpfc_vport
*vport
, int mask
, char *fmt
,
1822 uint32_t data1
, uint32_t data2
, uint32_t data3
)
1824 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
1825 struct lpfc_debugfs_trc
*dtp
;
1828 if (!(lpfc_debugfs_mask_disc_trc
& mask
))
1831 if (!lpfc_debugfs_enable
|| !lpfc_debugfs_max_disc_trc
||
1832 !vport
|| !vport
->disc_trc
)
1835 index
= atomic_inc_return(&vport
->disc_trc_cnt
) &
1836 (lpfc_debugfs_max_disc_trc
- 1);
1837 dtp
= vport
->disc_trc
+ index
;
1842 dtp
->seq_cnt
= atomic_inc_return(&lpfc_debugfs_seq_trc_cnt
);
1849 * lpfc_debugfs_slow_ring_trc - Store slow ring trace log
1850 * @phba: The phba to associate this trace string with for retrieval.
1851 * @fmt: Format string to be displayed when dumping the log.
1852 * @data1: 1st data parameter to be applied to @fmt.
1853 * @data2: 2nd data parameter to be applied to @fmt.
1854 * @data3: 3rd data parameter to be applied to @fmt.
1857 * This routine is used by the driver code to add a debugfs log entry to the
1858 * discovery trace buffer associated with @vport. @fmt, @data1, @data2, and
1859 * @data3 are used like printf when displaying the log.
1862 lpfc_debugfs_slow_ring_trc(struct lpfc_hba
*phba
, char *fmt
,
1863 uint32_t data1
, uint32_t data2
, uint32_t data3
)
1865 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
1866 struct lpfc_debugfs_trc
*dtp
;
1869 if (!lpfc_debugfs_enable
|| !lpfc_debugfs_max_slow_ring_trc
||
1870 !phba
|| !phba
->slow_ring_trc
)
1873 index
= atomic_inc_return(&phba
->slow_ring_trc_cnt
) &
1874 (lpfc_debugfs_max_slow_ring_trc
- 1);
1875 dtp
= phba
->slow_ring_trc
+ index
;
1880 dtp
->seq_cnt
= atomic_inc_return(&lpfc_debugfs_seq_trc_cnt
);
1887 * lpfc_debugfs_nvme_trc - Store NVME/NVMET trace log
1888 * @phba: The phba to associate this trace string with for retrieval.
1889 * @fmt: Format string to be displayed when dumping the log.
1890 * @data1: 1st data parameter to be applied to @fmt.
1891 * @data2: 2nd data parameter to be applied to @fmt.
1892 * @data3: 3rd data parameter to be applied to @fmt.
1895 * This routine is used by the driver code to add a debugfs log entry to the
1896 * nvme trace buffer associated with @phba. @fmt, @data1, @data2, and
1897 * @data3 are used like printf when displaying the log.
1900 lpfc_debugfs_nvme_trc(struct lpfc_hba
*phba
, char *fmt
,
1901 uint16_t data1
, uint16_t data2
, uint32_t data3
)
1903 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
1904 struct lpfc_debugfs_nvmeio_trc
*dtp
;
1907 if (!phba
->nvmeio_trc_on
|| !phba
->nvmeio_trc
)
1910 index
= atomic_inc_return(&phba
->nvmeio_trc_cnt
) &
1911 (phba
->nvmeio_trc_size
- 1);
1912 dtp
= phba
->nvmeio_trc
+ index
;
1920 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
1922 * lpfc_debugfs_disc_trc_open - Open the discovery trace log
1923 * @inode: The inode pointer that contains a vport pointer.
1924 * @file: The file pointer to attach the log output.
1927 * This routine is the entry point for the debugfs open file operation. It gets
1928 * the vport from the i_private field in @inode, allocates the necessary buffer
1929 * for the log, fills the buffer from the in-memory log for this vport, and then
1930 * returns a pointer to that log in the private_data field in @file.
1933 * This function returns zero if successful. On error it will return a negative
1937 lpfc_debugfs_disc_trc_open(struct inode
*inode
, struct file
*file
)
1939 struct lpfc_vport
*vport
= inode
->i_private
;
1940 struct lpfc_debug
*debug
;
1944 if (!lpfc_debugfs_max_disc_trc
) {
1949 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
1953 /* Round to page boundary */
1954 size
= (lpfc_debugfs_max_disc_trc
* LPFC_DEBUG_TRC_ENTRY_SIZE
);
1955 size
= PAGE_ALIGN(size
);
1957 debug
->buffer
= kmalloc(size
, GFP_KERNEL
);
1958 if (!debug
->buffer
) {
1963 debug
->len
= lpfc_debugfs_disc_trc_data(vport
, debug
->buffer
, size
);
1964 file
->private_data
= debug
;
1972 * lpfc_debugfs_slow_ring_trc_open - Open the Slow Ring trace log
1973 * @inode: The inode pointer that contains a vport pointer.
1974 * @file: The file pointer to attach the log output.
1977 * This routine is the entry point for the debugfs open file operation. It gets
1978 * the vport from the i_private field in @inode, allocates the necessary buffer
1979 * for the log, fills the buffer from the in-memory log for this vport, and then
1980 * returns a pointer to that log in the private_data field in @file.
1983 * This function returns zero if successful. On error it will return a negative
1987 lpfc_debugfs_slow_ring_trc_open(struct inode
*inode
, struct file
*file
)
1989 struct lpfc_hba
*phba
= inode
->i_private
;
1990 struct lpfc_debug
*debug
;
1994 if (!lpfc_debugfs_max_slow_ring_trc
) {
1999 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
2003 /* Round to page boundary */
2004 size
= (lpfc_debugfs_max_slow_ring_trc
* LPFC_DEBUG_TRC_ENTRY_SIZE
);
2005 size
= PAGE_ALIGN(size
);
2007 debug
->buffer
= kmalloc(size
, GFP_KERNEL
);
2008 if (!debug
->buffer
) {
2013 debug
->len
= lpfc_debugfs_slow_ring_trc_data(phba
, debug
->buffer
, size
);
2014 file
->private_data
= debug
;
2022 * lpfc_debugfs_hbqinfo_open - Open the hbqinfo debugfs buffer
2023 * @inode: The inode pointer that contains a vport pointer.
2024 * @file: The file pointer to attach the log output.
2027 * This routine is the entry point for the debugfs open file operation. It gets
2028 * the vport from the i_private field in @inode, allocates the necessary buffer
2029 * for the log, fills the buffer from the in-memory log for this vport, and then
2030 * returns a pointer to that log in the private_data field in @file.
2033 * This function returns zero if successful. On error it will return a negative
2037 lpfc_debugfs_hbqinfo_open(struct inode
*inode
, struct file
*file
)
2039 struct lpfc_hba
*phba
= inode
->i_private
;
2040 struct lpfc_debug
*debug
;
2043 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
2047 /* Round to page boundary */
2048 debug
->buffer
= kmalloc(LPFC_HBQINFO_SIZE
, GFP_KERNEL
);
2049 if (!debug
->buffer
) {
2054 debug
->len
= lpfc_debugfs_hbqinfo_data(phba
, debug
->buffer
,
2056 file
->private_data
= debug
;
2064 * lpfc_debugfs_multixripools_open - Open the multixripool debugfs buffer
2065 * @inode: The inode pointer that contains a hba pointer.
2066 * @file: The file pointer to attach the log output.
2069 * This routine is the entry point for the debugfs open file operation. It gets
2070 * the hba from the i_private field in @inode, allocates the necessary buffer
2071 * for the log, fills the buffer from the in-memory log for this hba, and then
2072 * returns a pointer to that log in the private_data field in @file.
2075 * This function returns zero if successful. On error it will return a negative
2079 lpfc_debugfs_multixripools_open(struct inode
*inode
, struct file
*file
)
2081 struct lpfc_hba
*phba
= inode
->i_private
;
2082 struct lpfc_debug
*debug
;
2085 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
2089 /* Round to page boundary */
2090 debug
->buffer
= kzalloc(LPFC_DUMP_MULTIXRIPOOL_SIZE
, GFP_KERNEL
);
2091 if (!debug
->buffer
) {
2096 debug
->len
= lpfc_debugfs_multixripools_data(
2097 phba
, debug
->buffer
, LPFC_DUMP_MULTIXRIPOOL_SIZE
);
2099 debug
->i_private
= inode
->i_private
;
2100 file
->private_data
= debug
;
2107 #ifdef LPFC_HDWQ_LOCK_STAT
2109 * lpfc_debugfs_lockstat_open - Open the lockstat debugfs buffer
2110 * @inode: The inode pointer that contains a vport pointer.
2111 * @file: The file pointer to attach the log output.
2114 * This routine is the entry point for the debugfs open file operation. It gets
2115 * the vport from the i_private field in @inode, allocates the necessary buffer
2116 * for the log, fills the buffer from the in-memory log for this vport, and then
2117 * returns a pointer to that log in the private_data field in @file.
2120 * This function returns zero if successful. On error it will return a negative
2124 lpfc_debugfs_lockstat_open(struct inode
*inode
, struct file
*file
)
2126 struct lpfc_hba
*phba
= inode
->i_private
;
2127 struct lpfc_debug
*debug
;
2130 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
2134 /* Round to page boundary */
2135 debug
->buffer
= kmalloc(LPFC_HDWQINFO_SIZE
, GFP_KERNEL
);
2136 if (!debug
->buffer
) {
2141 debug
->len
= lpfc_debugfs_lockstat_data(phba
, debug
->buffer
,
2143 file
->private_data
= debug
;
2151 lpfc_debugfs_lockstat_write(struct file
*file
, const char __user
*buf
,
2152 size_t nbytes
, loff_t
*ppos
)
2154 struct lpfc_debug
*debug
= file
->private_data
;
2155 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
2156 struct lpfc_sli4_hdw_queue
*qp
;
2161 memset(mybuf
, 0, sizeof(mybuf
));
2163 if (copy_from_user(mybuf
, buf
, nbytes
))
2167 if ((strncmp(pbuf
, "reset", strlen("reset")) == 0) ||
2168 (strncmp(pbuf
, "zero", strlen("zero")) == 0)) {
2169 for (i
= 0; i
< phba
->cfg_hdw_queue
; i
++) {
2170 qp
= &phba
->sli4_hba
.hdwq
[i
];
2171 qp
->lock_conflict
.alloc_xri_get
= 0;
2172 qp
->lock_conflict
.alloc_xri_put
= 0;
2173 qp
->lock_conflict
.free_xri
= 0;
2174 qp
->lock_conflict
.wq_access
= 0;
2175 qp
->lock_conflict
.alloc_pvt_pool
= 0;
2176 qp
->lock_conflict
.mv_from_pvt_pool
= 0;
2177 qp
->lock_conflict
.mv_to_pub_pool
= 0;
2178 qp
->lock_conflict
.mv_to_pvt_pool
= 0;
2179 qp
->lock_conflict
.free_pvt_pool
= 0;
2180 qp
->lock_conflict
.free_pub_pool
= 0;
2181 qp
->lock_conflict
.wq_access
= 0;
2188 static int lpfc_debugfs_ras_log_data(struct lpfc_hba
*phba
,
2189 char *buffer
, int size
)
2192 struct lpfc_dmabuf
*dmabuf
, *next
;
2194 memset(buffer
, 0, size
);
2196 spin_lock_irq(&phba
->hbalock
);
2197 if (phba
->ras_fwlog
.state
!= ACTIVE
) {
2198 spin_unlock_irq(&phba
->hbalock
);
2201 spin_unlock_irq(&phba
->hbalock
);
2203 list_for_each_entry_safe(dmabuf
, next
,
2204 &phba
->ras_fwlog
.fwlog_buff_list
, list
) {
2205 /* Check if copying will go over size and a '\0' char */
2206 if ((copied
+ LPFC_RAS_MAX_ENTRY_SIZE
) >= (size
- 1)) {
2207 memcpy(buffer
+ copied
, dmabuf
->virt
,
2209 copied
+= size
- copied
- 1;
2212 memcpy(buffer
+ copied
, dmabuf
->virt
, LPFC_RAS_MAX_ENTRY_SIZE
);
2213 copied
+= LPFC_RAS_MAX_ENTRY_SIZE
;
2219 lpfc_debugfs_ras_log_release(struct inode
*inode
, struct file
*file
)
2221 struct lpfc_debug
*debug
= file
->private_data
;
2223 vfree(debug
->buffer
);
2230 * lpfc_debugfs_ras_log_open - Open the RAS log debugfs buffer
2231 * @inode: The inode pointer that contains a vport pointer.
2232 * @file: The file pointer to attach the log output.
2235 * This routine is the entry point for the debugfs open file operation. It gets
2236 * the vport from the i_private field in @inode, allocates the necessary buffer
2237 * for the log, fills the buffer from the in-memory log for this vport, and then
2238 * returns a pointer to that log in the private_data field in @file.
2241 * This function returns zero if successful. On error it will return a negative
2245 lpfc_debugfs_ras_log_open(struct inode
*inode
, struct file
*file
)
2247 struct lpfc_hba
*phba
= inode
->i_private
;
2248 struct lpfc_debug
*debug
;
2252 spin_lock_irq(&phba
->hbalock
);
2253 if (phba
->ras_fwlog
.state
!= ACTIVE
) {
2254 spin_unlock_irq(&phba
->hbalock
);
2258 spin_unlock_irq(&phba
->hbalock
);
2259 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
2263 size
= LPFC_RAS_MIN_BUFF_POST_SIZE
* phba
->cfg_ras_fwlog_buffsize
;
2264 debug
->buffer
= vmalloc(size
);
2268 debug
->len
= lpfc_debugfs_ras_log_data(phba
, debug
->buffer
, size
);
2269 if (debug
->len
< 0) {
2273 file
->private_data
= debug
;
2278 vfree(debug
->buffer
);
2286 * lpfc_debugfs_dumpHBASlim_open - Open the Dump HBA SLIM debugfs buffer
2287 * @inode: The inode pointer that contains a vport pointer.
2288 * @file: The file pointer to attach the log output.
2291 * This routine is the entry point for the debugfs open file operation. It gets
2292 * the vport from the i_private field in @inode, allocates the necessary buffer
2293 * for the log, fills the buffer from the in-memory log for this vport, and then
2294 * returns a pointer to that log in the private_data field in @file.
2297 * This function returns zero if successful. On error it will return a negative
2301 lpfc_debugfs_dumpHBASlim_open(struct inode
*inode
, struct file
*file
)
2303 struct lpfc_hba
*phba
= inode
->i_private
;
2304 struct lpfc_debug
*debug
;
2307 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
2311 /* Round to page boundary */
2312 debug
->buffer
= kmalloc(LPFC_DUMPHBASLIM_SIZE
, GFP_KERNEL
);
2313 if (!debug
->buffer
) {
2318 debug
->len
= lpfc_debugfs_dumpHBASlim_data(phba
, debug
->buffer
,
2319 LPFC_DUMPHBASLIM_SIZE
);
2320 file
->private_data
= debug
;
2328 * lpfc_debugfs_dumpHostSlim_open - Open the Dump Host SLIM debugfs buffer
2329 * @inode: The inode pointer that contains a vport pointer.
2330 * @file: The file pointer to attach the log output.
2333 * This routine is the entry point for the debugfs open file operation. It gets
2334 * the vport from the i_private field in @inode, allocates the necessary buffer
2335 * for the log, fills the buffer from the in-memory log for this vport, and then
2336 * returns a pointer to that log in the private_data field in @file.
2339 * This function returns zero if successful. On error it will return a negative
2343 lpfc_debugfs_dumpHostSlim_open(struct inode
*inode
, struct file
*file
)
2345 struct lpfc_hba
*phba
= inode
->i_private
;
2346 struct lpfc_debug
*debug
;
2349 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
2353 /* Round to page boundary */
2354 debug
->buffer
= kmalloc(LPFC_DUMPHOSTSLIM_SIZE
, GFP_KERNEL
);
2355 if (!debug
->buffer
) {
2360 debug
->len
= lpfc_debugfs_dumpHostSlim_data(phba
, debug
->buffer
,
2361 LPFC_DUMPHOSTSLIM_SIZE
);
2362 file
->private_data
= debug
;
2370 lpfc_debugfs_dif_err_read(struct file
*file
, char __user
*buf
,
2371 size_t nbytes
, loff_t
*ppos
)
2373 struct dentry
*dent
= file
->f_path
.dentry
;
2374 struct lpfc_hba
*phba
= file
->private_data
;
2379 if (dent
== phba
->debug_writeGuard
)
2380 cnt
= scnprintf(cbuf
, 32, "%u\n", phba
->lpfc_injerr_wgrd_cnt
);
2381 else if (dent
== phba
->debug_writeApp
)
2382 cnt
= scnprintf(cbuf
, 32, "%u\n", phba
->lpfc_injerr_wapp_cnt
);
2383 else if (dent
== phba
->debug_writeRef
)
2384 cnt
= scnprintf(cbuf
, 32, "%u\n", phba
->lpfc_injerr_wref_cnt
);
2385 else if (dent
== phba
->debug_readGuard
)
2386 cnt
= scnprintf(cbuf
, 32, "%u\n", phba
->lpfc_injerr_rgrd_cnt
);
2387 else if (dent
== phba
->debug_readApp
)
2388 cnt
= scnprintf(cbuf
, 32, "%u\n", phba
->lpfc_injerr_rapp_cnt
);
2389 else if (dent
== phba
->debug_readRef
)
2390 cnt
= scnprintf(cbuf
, 32, "%u\n", phba
->lpfc_injerr_rref_cnt
);
2391 else if (dent
== phba
->debug_InjErrNPortID
)
2392 cnt
= scnprintf(cbuf
, 32, "0x%06x\n",
2393 phba
->lpfc_injerr_nportid
);
2394 else if (dent
== phba
->debug_InjErrWWPN
) {
2395 memcpy(&tmp
, &phba
->lpfc_injerr_wwpn
, sizeof(struct lpfc_name
));
2396 tmp
= cpu_to_be64(tmp
);
2397 cnt
= scnprintf(cbuf
, 32, "0x%016llx\n", tmp
);
2398 } else if (dent
== phba
->debug_InjErrLBA
) {
2399 if (phba
->lpfc_injerr_lba
== (sector_t
)(-1))
2400 cnt
= scnprintf(cbuf
, 32, "off\n");
2402 cnt
= scnprintf(cbuf
, 32, "0x%llx\n",
2403 (uint64_t) phba
->lpfc_injerr_lba
);
2405 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
2406 "0547 Unknown debugfs error injection entry\n");
2408 return simple_read_from_buffer(buf
, nbytes
, ppos
, &cbuf
, cnt
);
2412 lpfc_debugfs_dif_err_write(struct file
*file
, const char __user
*buf
,
2413 size_t nbytes
, loff_t
*ppos
)
2415 struct dentry
*dent
= file
->f_path
.dentry
;
2416 struct lpfc_hba
*phba
= file
->private_data
;
2421 memset(dstbuf
, 0, 33);
2422 size
= (nbytes
< 32) ? nbytes
: 32;
2423 if (copy_from_user(dstbuf
, buf
, size
))
2426 if (dent
== phba
->debug_InjErrLBA
) {
2427 if ((dstbuf
[0] == 'o') && (dstbuf
[1] == 'f') &&
2429 tmp
= (uint64_t)(-1);
2432 if ((tmp
== 0) && (kstrtoull(dstbuf
, 0, &tmp
)))
2435 if (dent
== phba
->debug_writeGuard
)
2436 phba
->lpfc_injerr_wgrd_cnt
= (uint32_t)tmp
;
2437 else if (dent
== phba
->debug_writeApp
)
2438 phba
->lpfc_injerr_wapp_cnt
= (uint32_t)tmp
;
2439 else if (dent
== phba
->debug_writeRef
)
2440 phba
->lpfc_injerr_wref_cnt
= (uint32_t)tmp
;
2441 else if (dent
== phba
->debug_readGuard
)
2442 phba
->lpfc_injerr_rgrd_cnt
= (uint32_t)tmp
;
2443 else if (dent
== phba
->debug_readApp
)
2444 phba
->lpfc_injerr_rapp_cnt
= (uint32_t)tmp
;
2445 else if (dent
== phba
->debug_readRef
)
2446 phba
->lpfc_injerr_rref_cnt
= (uint32_t)tmp
;
2447 else if (dent
== phba
->debug_InjErrLBA
)
2448 phba
->lpfc_injerr_lba
= (sector_t
)tmp
;
2449 else if (dent
== phba
->debug_InjErrNPortID
)
2450 phba
->lpfc_injerr_nportid
= (uint32_t)(tmp
& Mask_DID
);
2451 else if (dent
== phba
->debug_InjErrWWPN
) {
2452 tmp
= cpu_to_be64(tmp
);
2453 memcpy(&phba
->lpfc_injerr_wwpn
, &tmp
, sizeof(struct lpfc_name
));
2455 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
2456 "0548 Unknown debugfs error injection entry\n");
2462 lpfc_debugfs_dif_err_release(struct inode
*inode
, struct file
*file
)
2468 * lpfc_debugfs_nodelist_open - Open the nodelist debugfs file
2469 * @inode: The inode pointer that contains a vport pointer.
2470 * @file: The file pointer to attach the log output.
2473 * This routine is the entry point for the debugfs open file operation. It gets
2474 * the vport from the i_private field in @inode, allocates the necessary buffer
2475 * for the log, fills the buffer from the in-memory log for this vport, and then
2476 * returns a pointer to that log in the private_data field in @file.
2479 * This function returns zero if successful. On error it will return a negative
2483 lpfc_debugfs_nodelist_open(struct inode
*inode
, struct file
*file
)
2485 struct lpfc_vport
*vport
= inode
->i_private
;
2486 struct lpfc_debug
*debug
;
2489 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
2493 /* Round to page boundary */
2494 debug
->buffer
= kmalloc(LPFC_NODELIST_SIZE
, GFP_KERNEL
);
2495 if (!debug
->buffer
) {
2500 debug
->len
= lpfc_debugfs_nodelist_data(vport
, debug
->buffer
,
2501 LPFC_NODELIST_SIZE
);
2502 file
->private_data
= debug
;
2510 * lpfc_debugfs_lseek - Seek through a debugfs file
2511 * @file: The file pointer to seek through.
2512 * @off: The offset to seek to or the amount to seek by.
2513 * @whence: Indicates how to seek.
2516 * This routine is the entry point for the debugfs lseek file operation. The
2517 * @whence parameter indicates whether @off is the offset to directly seek to,
2518 * or if it is a value to seek forward or reverse by. This function figures out
2519 * what the new offset of the debugfs file will be and assigns that value to the
2520 * f_pos field of @file.
2523 * This function returns the new offset if successful and returns a negative
2524 * error if unable to process the seek.
2527 lpfc_debugfs_lseek(struct file
*file
, loff_t off
, int whence
)
2529 struct lpfc_debug
*debug
= file
->private_data
;
2530 return fixed_size_llseek(file
, off
, whence
, debug
->len
);
2534 * lpfc_debugfs_read - Read a debugfs file
2535 * @file: The file pointer to read from.
2536 * @buf: The buffer to copy the data to.
2537 * @nbytes: The number of bytes to read.
2538 * @ppos: The position in the file to start reading from.
2541 * This routine reads data from from the buffer indicated in the private_data
2542 * field of @file. It will start reading at @ppos and copy up to @nbytes of
2546 * This function returns the amount of data that was read (this could be less
2547 * than @nbytes if the end of the file was reached) or a negative error value.
2550 lpfc_debugfs_read(struct file
*file
, char __user
*buf
,
2551 size_t nbytes
, loff_t
*ppos
)
2553 struct lpfc_debug
*debug
= file
->private_data
;
2555 return simple_read_from_buffer(buf
, nbytes
, ppos
, debug
->buffer
,
2560 * lpfc_debugfs_release - Release the buffer used to store debugfs file data
2561 * @inode: The inode pointer that contains a vport pointer. (unused)
2562 * @file: The file pointer that contains the buffer to release.
2565 * This routine frees the buffer that was allocated when the debugfs file was
2569 * This function returns zero.
2572 lpfc_debugfs_release(struct inode
*inode
, struct file
*file
)
2574 struct lpfc_debug
*debug
= file
->private_data
;
2576 kfree(debug
->buffer
);
2583 * lpfc_debugfs_multixripools_write - Clear multi-XRI pools statistics
2584 * @file: The file pointer to read from.
2585 * @buf: The buffer to copy the user data from.
2586 * @nbytes: The number of bytes to get.
2587 * @ppos: The position in the file to start reading from.
2590 * This routine clears multi-XRI pools statistics when buf contains "clear".
2593 * It returns the @nbytges passing in from debugfs user space when successful.
2594 * In case of error conditions, it returns proper error code back to the user
2598 lpfc_debugfs_multixripools_write(struct file
*file
, const char __user
*buf
,
2599 size_t nbytes
, loff_t
*ppos
)
2601 struct lpfc_debug
*debug
= file
->private_data
;
2602 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
2607 struct lpfc_sli4_hdw_queue
*qp
;
2608 struct lpfc_multixri_pool
*multixri_pool
;
2613 memset(mybuf
, 0, sizeof(mybuf
));
2615 if (copy_from_user(mybuf
, buf
, nbytes
))
2619 if ((strncmp(pbuf
, "clear", strlen("clear"))) == 0) {
2620 hwq_count
= phba
->cfg_hdw_queue
;
2621 for (i
= 0; i
< hwq_count
; i
++) {
2622 qp
= &phba
->sli4_hba
.hdwq
[i
];
2623 multixri_pool
= qp
->p_multixri_pool
;
2627 qp
->empty_io_bufs
= 0;
2628 multixri_pool
->pbl_empty_count
= 0;
2629 #ifdef LPFC_MXP_STAT
2630 multixri_pool
->above_limit_count
= 0;
2631 multixri_pool
->below_limit_count
= 0;
2632 multixri_pool
->stat_max_hwm
= 0;
2633 multixri_pool
->local_pbl_hit_count
= 0;
2634 multixri_pool
->other_pbl_hit_count
= 0;
2636 multixri_pool
->stat_pbl_count
= 0;
2637 multixri_pool
->stat_pvt_count
= 0;
2638 multixri_pool
->stat_busy_count
= 0;
2639 multixri_pool
->stat_snapshot_taken
= 0;
2642 return strlen(pbuf
);
2649 lpfc_debugfs_nvmestat_open(struct inode
*inode
, struct file
*file
)
2651 struct lpfc_vport
*vport
= inode
->i_private
;
2652 struct lpfc_debug
*debug
;
2655 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
2659 /* Round to page boundary */
2660 debug
->buffer
= kmalloc(LPFC_NVMESTAT_SIZE
, GFP_KERNEL
);
2661 if (!debug
->buffer
) {
2666 debug
->len
= lpfc_debugfs_nvmestat_data(vport
, debug
->buffer
,
2667 LPFC_NVMESTAT_SIZE
);
2669 debug
->i_private
= inode
->i_private
;
2670 file
->private_data
= debug
;
2678 lpfc_debugfs_nvmestat_write(struct file
*file
, const char __user
*buf
,
2679 size_t nbytes
, loff_t
*ppos
)
2681 struct lpfc_debug
*debug
= file
->private_data
;
2682 struct lpfc_vport
*vport
= (struct lpfc_vport
*)debug
->i_private
;
2683 struct lpfc_hba
*phba
= vport
->phba
;
2684 struct lpfc_nvmet_tgtport
*tgtp
;
2688 if (!phba
->targetport
)
2694 memset(mybuf
, 0, sizeof(mybuf
));
2696 if (copy_from_user(mybuf
, buf
, nbytes
))
2700 tgtp
= (struct lpfc_nvmet_tgtport
*)phba
->targetport
->private;
2701 if ((strncmp(pbuf
, "reset", strlen("reset")) == 0) ||
2702 (strncmp(pbuf
, "zero", strlen("zero")) == 0)) {
2703 atomic_set(&tgtp
->rcv_ls_req_in
, 0);
2704 atomic_set(&tgtp
->rcv_ls_req_out
, 0);
2705 atomic_set(&tgtp
->rcv_ls_req_drop
, 0);
2706 atomic_set(&tgtp
->xmt_ls_abort
, 0);
2707 atomic_set(&tgtp
->xmt_ls_abort_cmpl
, 0);
2708 atomic_set(&tgtp
->xmt_ls_rsp
, 0);
2709 atomic_set(&tgtp
->xmt_ls_drop
, 0);
2710 atomic_set(&tgtp
->xmt_ls_rsp_error
, 0);
2711 atomic_set(&tgtp
->xmt_ls_rsp_cmpl
, 0);
2713 atomic_set(&tgtp
->rcv_fcp_cmd_in
, 0);
2714 atomic_set(&tgtp
->rcv_fcp_cmd_out
, 0);
2715 atomic_set(&tgtp
->rcv_fcp_cmd_drop
, 0);
2716 atomic_set(&tgtp
->xmt_fcp_drop
, 0);
2717 atomic_set(&tgtp
->xmt_fcp_read_rsp
, 0);
2718 atomic_set(&tgtp
->xmt_fcp_read
, 0);
2719 atomic_set(&tgtp
->xmt_fcp_write
, 0);
2720 atomic_set(&tgtp
->xmt_fcp_rsp
, 0);
2721 atomic_set(&tgtp
->xmt_fcp_release
, 0);
2722 atomic_set(&tgtp
->xmt_fcp_rsp_cmpl
, 0);
2723 atomic_set(&tgtp
->xmt_fcp_rsp_error
, 0);
2724 atomic_set(&tgtp
->xmt_fcp_rsp_drop
, 0);
2726 atomic_set(&tgtp
->xmt_fcp_abort
, 0);
2727 atomic_set(&tgtp
->xmt_fcp_abort_cmpl
, 0);
2728 atomic_set(&tgtp
->xmt_abort_sol
, 0);
2729 atomic_set(&tgtp
->xmt_abort_unsol
, 0);
2730 atomic_set(&tgtp
->xmt_abort_rsp
, 0);
2731 atomic_set(&tgtp
->xmt_abort_rsp_error
, 0);
2737 lpfc_debugfs_scsistat_open(struct inode
*inode
, struct file
*file
)
2739 struct lpfc_vport
*vport
= inode
->i_private
;
2740 struct lpfc_debug
*debug
;
2743 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
2747 /* Round to page boundary */
2748 debug
->buffer
= kzalloc(LPFC_SCSISTAT_SIZE
, GFP_KERNEL
);
2749 if (!debug
->buffer
) {
2754 debug
->len
= lpfc_debugfs_scsistat_data(vport
, debug
->buffer
,
2755 LPFC_SCSISTAT_SIZE
);
2757 debug
->i_private
= inode
->i_private
;
2758 file
->private_data
= debug
;
2766 lpfc_debugfs_scsistat_write(struct file
*file
, const char __user
*buf
,
2767 size_t nbytes
, loff_t
*ppos
)
2769 struct lpfc_debug
*debug
= file
->private_data
;
2770 struct lpfc_vport
*vport
= (struct lpfc_vport
*)debug
->i_private
;
2771 struct lpfc_hba
*phba
= vport
->phba
;
2772 char mybuf
[6] = {0};
2775 if (copy_from_user(mybuf
, buf
, (nbytes
>= sizeof(mybuf
)) ?
2776 (sizeof(mybuf
) - 1) : nbytes
))
2779 if ((strncmp(&mybuf
[0], "reset", strlen("reset")) == 0) ||
2780 (strncmp(&mybuf
[0], "zero", strlen("zero")) == 0)) {
2781 for (i
= 0; i
< phba
->cfg_hdw_queue
; i
++) {
2782 memset(&phba
->sli4_hba
.hdwq
[i
].scsi_cstat
, 0,
2783 sizeof(phba
->sli4_hba
.hdwq
[i
].scsi_cstat
));
2791 lpfc_debugfs_ioktime_open(struct inode
*inode
, struct file
*file
)
2793 struct lpfc_vport
*vport
= inode
->i_private
;
2794 struct lpfc_debug
*debug
;
2797 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
2801 /* Round to page boundary */
2802 debug
->buffer
= kmalloc(LPFC_IOKTIME_SIZE
, GFP_KERNEL
);
2803 if (!debug
->buffer
) {
2808 debug
->len
= lpfc_debugfs_ioktime_data(vport
, debug
->buffer
,
2811 debug
->i_private
= inode
->i_private
;
2812 file
->private_data
= debug
;
2820 lpfc_debugfs_ioktime_write(struct file
*file
, const char __user
*buf
,
2821 size_t nbytes
, loff_t
*ppos
)
2823 struct lpfc_debug
*debug
= file
->private_data
;
2824 struct lpfc_vport
*vport
= (struct lpfc_vport
*)debug
->i_private
;
2825 struct lpfc_hba
*phba
= vport
->phba
;
2832 memset(mybuf
, 0, sizeof(mybuf
));
2834 if (copy_from_user(mybuf
, buf
, nbytes
))
2838 if ((strncmp(pbuf
, "on", sizeof("on") - 1) == 0)) {
2839 phba
->ktime_data_samples
= 0;
2840 phba
->ktime_status_samples
= 0;
2841 phba
->ktime_seg1_total
= 0;
2842 phba
->ktime_seg1_max
= 0;
2843 phba
->ktime_seg1_min
= 0xffffffff;
2844 phba
->ktime_seg2_total
= 0;
2845 phba
->ktime_seg2_max
= 0;
2846 phba
->ktime_seg2_min
= 0xffffffff;
2847 phba
->ktime_seg3_total
= 0;
2848 phba
->ktime_seg3_max
= 0;
2849 phba
->ktime_seg3_min
= 0xffffffff;
2850 phba
->ktime_seg4_total
= 0;
2851 phba
->ktime_seg4_max
= 0;
2852 phba
->ktime_seg4_min
= 0xffffffff;
2853 phba
->ktime_seg5_total
= 0;
2854 phba
->ktime_seg5_max
= 0;
2855 phba
->ktime_seg5_min
= 0xffffffff;
2856 phba
->ktime_seg6_total
= 0;
2857 phba
->ktime_seg6_max
= 0;
2858 phba
->ktime_seg6_min
= 0xffffffff;
2859 phba
->ktime_seg7_total
= 0;
2860 phba
->ktime_seg7_max
= 0;
2861 phba
->ktime_seg7_min
= 0xffffffff;
2862 phba
->ktime_seg8_total
= 0;
2863 phba
->ktime_seg8_max
= 0;
2864 phba
->ktime_seg8_min
= 0xffffffff;
2865 phba
->ktime_seg9_total
= 0;
2866 phba
->ktime_seg9_max
= 0;
2867 phba
->ktime_seg9_min
= 0xffffffff;
2868 phba
->ktime_seg10_total
= 0;
2869 phba
->ktime_seg10_max
= 0;
2870 phba
->ktime_seg10_min
= 0xffffffff;
2873 return strlen(pbuf
);
2874 } else if ((strncmp(pbuf
, "off",
2875 sizeof("off") - 1) == 0)) {
2877 return strlen(pbuf
);
2878 } else if ((strncmp(pbuf
, "zero",
2879 sizeof("zero") - 1) == 0)) {
2880 phba
->ktime_data_samples
= 0;
2881 phba
->ktime_status_samples
= 0;
2882 phba
->ktime_seg1_total
= 0;
2883 phba
->ktime_seg1_max
= 0;
2884 phba
->ktime_seg1_min
= 0xffffffff;
2885 phba
->ktime_seg2_total
= 0;
2886 phba
->ktime_seg2_max
= 0;
2887 phba
->ktime_seg2_min
= 0xffffffff;
2888 phba
->ktime_seg3_total
= 0;
2889 phba
->ktime_seg3_max
= 0;
2890 phba
->ktime_seg3_min
= 0xffffffff;
2891 phba
->ktime_seg4_total
= 0;
2892 phba
->ktime_seg4_max
= 0;
2893 phba
->ktime_seg4_min
= 0xffffffff;
2894 phba
->ktime_seg5_total
= 0;
2895 phba
->ktime_seg5_max
= 0;
2896 phba
->ktime_seg5_min
= 0xffffffff;
2897 phba
->ktime_seg6_total
= 0;
2898 phba
->ktime_seg6_max
= 0;
2899 phba
->ktime_seg6_min
= 0xffffffff;
2900 phba
->ktime_seg7_total
= 0;
2901 phba
->ktime_seg7_max
= 0;
2902 phba
->ktime_seg7_min
= 0xffffffff;
2903 phba
->ktime_seg8_total
= 0;
2904 phba
->ktime_seg8_max
= 0;
2905 phba
->ktime_seg8_min
= 0xffffffff;
2906 phba
->ktime_seg9_total
= 0;
2907 phba
->ktime_seg9_max
= 0;
2908 phba
->ktime_seg9_min
= 0xffffffff;
2909 phba
->ktime_seg10_total
= 0;
2910 phba
->ktime_seg10_max
= 0;
2911 phba
->ktime_seg10_min
= 0xffffffff;
2912 return strlen(pbuf
);
2918 lpfc_debugfs_nvmeio_trc_open(struct inode
*inode
, struct file
*file
)
2920 struct lpfc_hba
*phba
= inode
->i_private
;
2921 struct lpfc_debug
*debug
;
2924 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
2928 /* Round to page boundary */
2929 debug
->buffer
= kmalloc(LPFC_NVMEIO_TRC_SIZE
, GFP_KERNEL
);
2930 if (!debug
->buffer
) {
2935 debug
->len
= lpfc_debugfs_nvmeio_trc_data(phba
, debug
->buffer
,
2936 LPFC_NVMEIO_TRC_SIZE
);
2938 debug
->i_private
= inode
->i_private
;
2939 file
->private_data
= debug
;
2947 lpfc_debugfs_nvmeio_trc_write(struct file
*file
, const char __user
*buf
,
2948 size_t nbytes
, loff_t
*ppos
)
2950 struct lpfc_debug
*debug
= file
->private_data
;
2951 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
2960 memset(mybuf
, 0, sizeof(mybuf
));
2962 if (copy_from_user(mybuf
, buf
, nbytes
))
2966 if ((strncmp(pbuf
, "off", sizeof("off") - 1) == 0)) {
2967 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
2968 "0570 nvmeio_trc_off\n");
2969 phba
->nvmeio_trc_output_idx
= 0;
2970 phba
->nvmeio_trc_on
= 0;
2971 return strlen(pbuf
);
2972 } else if ((strncmp(pbuf
, "on", sizeof("on") - 1) == 0)) {
2973 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
2974 "0571 nvmeio_trc_on\n");
2975 phba
->nvmeio_trc_output_idx
= 0;
2976 phba
->nvmeio_trc_on
= 1;
2977 return strlen(pbuf
);
2980 /* We must be off to allocate the trace buffer */
2981 if (phba
->nvmeio_trc_on
!= 0)
2984 /* If not on or off, the parameter is the trace buffer size */
2985 i
= kstrtoul(pbuf
, 0, &sz
);
2988 phba
->nvmeio_trc_size
= (uint32_t)sz
;
2990 /* It must be a power of 2 - round down */
2997 if (phba
->nvmeio_trc_size
!= sz
)
2998 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
2999 "0572 nvmeio_trc_size changed to %ld\n",
3001 phba
->nvmeio_trc_size
= (uint32_t)sz
;
3003 /* If one previously exists, free it */
3004 kfree(phba
->nvmeio_trc
);
3006 /* Allocate new trace buffer and initialize */
3007 phba
->nvmeio_trc
= kzalloc((sizeof(struct lpfc_debugfs_nvmeio_trc
) *
3009 if (!phba
->nvmeio_trc
) {
3010 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
3011 "0573 Cannot create debugfs "
3012 "nvmeio_trc buffer\n");
3015 atomic_set(&phba
->nvmeio_trc_cnt
, 0);
3016 phba
->nvmeio_trc_on
= 0;
3017 phba
->nvmeio_trc_output_idx
= 0;
3019 return strlen(pbuf
);
3023 lpfc_debugfs_hdwqstat_open(struct inode
*inode
, struct file
*file
)
3025 struct lpfc_vport
*vport
= inode
->i_private
;
3026 struct lpfc_debug
*debug
;
3029 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
3033 /* Round to page boundary */
3034 debug
->buffer
= kcalloc(1, LPFC_SCSISTAT_SIZE
, GFP_KERNEL
);
3035 if (!debug
->buffer
) {
3040 debug
->len
= lpfc_debugfs_hdwqstat_data(vport
, debug
->buffer
,
3041 LPFC_SCSISTAT_SIZE
);
3043 debug
->i_private
= inode
->i_private
;
3044 file
->private_data
= debug
;
3052 lpfc_debugfs_hdwqstat_write(struct file
*file
, const char __user
*buf
,
3053 size_t nbytes
, loff_t
*ppos
)
3055 struct lpfc_debug
*debug
= file
->private_data
;
3056 struct lpfc_vport
*vport
= (struct lpfc_vport
*)debug
->i_private
;
3057 struct lpfc_hba
*phba
= vport
->phba
;
3058 struct lpfc_hdwq_stat
*c_stat
;
3066 memset(mybuf
, 0, sizeof(mybuf
));
3068 if (copy_from_user(mybuf
, buf
, nbytes
))
3072 if ((strncmp(pbuf
, "on", sizeof("on") - 1) == 0)) {
3073 if (phba
->nvmet_support
)
3074 phba
->hdwqstat_on
|= LPFC_CHECK_NVMET_IO
;
3076 phba
->hdwqstat_on
|= (LPFC_CHECK_NVME_IO
|
3077 LPFC_CHECK_SCSI_IO
);
3078 return strlen(pbuf
);
3079 } else if ((strncmp(pbuf
, "nvme_on", sizeof("nvme_on") - 1) == 0)) {
3080 if (phba
->nvmet_support
)
3081 phba
->hdwqstat_on
|= LPFC_CHECK_NVMET_IO
;
3083 phba
->hdwqstat_on
|= LPFC_CHECK_NVME_IO
;
3084 return strlen(pbuf
);
3085 } else if ((strncmp(pbuf
, "scsi_on", sizeof("scsi_on") - 1) == 0)) {
3086 if (!phba
->nvmet_support
)
3087 phba
->hdwqstat_on
|= LPFC_CHECK_SCSI_IO
;
3088 return strlen(pbuf
);
3089 } else if ((strncmp(pbuf
, "nvme_off", sizeof("nvme_off") - 1) == 0)) {
3090 phba
->hdwqstat_on
&= ~(LPFC_CHECK_NVME_IO
|
3091 LPFC_CHECK_NVMET_IO
);
3092 return strlen(pbuf
);
3093 } else if ((strncmp(pbuf
, "scsi_off", sizeof("scsi_off") - 1) == 0)) {
3094 phba
->hdwqstat_on
&= ~LPFC_CHECK_SCSI_IO
;
3095 return strlen(pbuf
);
3096 } else if ((strncmp(pbuf
, "off",
3097 sizeof("off") - 1) == 0)) {
3098 phba
->hdwqstat_on
= LPFC_CHECK_OFF
;
3099 return strlen(pbuf
);
3100 } else if ((strncmp(pbuf
, "zero",
3101 sizeof("zero") - 1) == 0)) {
3102 for_each_present_cpu(i
) {
3103 c_stat
= per_cpu_ptr(phba
->sli4_hba
.c_stat
, i
);
3105 c_stat
->cmpl_io
= 0;
3108 return strlen(pbuf
);
3114 * ---------------------------------
3115 * iDiag debugfs file access methods
3116 * ---------------------------------
3118 * All access methods are through the proper SLI4 PCI function's debugfs
3121 * /sys/kernel/debug/lpfc/fn<#>/iDiag
3125 * lpfc_idiag_cmd_get - Get and parse idiag debugfs comands from user space
3126 * @buf: The pointer to the user space buffer.
3127 * @nbytes: The number of bytes in the user space buffer.
3128 * @idiag_cmd: pointer to the idiag command struct.
3130 * This routine reads data from debugfs user space buffer and parses the
3131 * buffer for getting the idiag command and arguments. The while space in
3132 * between the set of data is used as the parsing separator.
3134 * This routine returns 0 when successful, it returns proper error code
3135 * back to the user space in error conditions.
3137 static int lpfc_idiag_cmd_get(const char __user
*buf
, size_t nbytes
,
3138 struct lpfc_idiag_cmd
*idiag_cmd
)
3141 char *pbuf
, *step_str
;
3145 memset(mybuf
, 0, sizeof(mybuf
));
3146 memset(idiag_cmd
, 0, sizeof(*idiag_cmd
));
3147 bsize
= min(nbytes
, (sizeof(mybuf
)-1));
3149 if (copy_from_user(mybuf
, buf
, bsize
))
3152 step_str
= strsep(&pbuf
, "\t ");
3154 /* The opcode must present */
3158 idiag_cmd
->opcode
= simple_strtol(step_str
, NULL
, 0);
3159 if (idiag_cmd
->opcode
== 0)
3162 for (i
= 0; i
< LPFC_IDIAG_CMD_DATA_SIZE
; i
++) {
3163 step_str
= strsep(&pbuf
, "\t ");
3166 idiag_cmd
->data
[i
] = simple_strtol(step_str
, NULL
, 0);
3172 * lpfc_idiag_open - idiag open debugfs
3173 * @inode: The inode pointer that contains a pointer to phba.
3174 * @file: The file pointer to attach the file operation.
3177 * This routine is the entry point for the debugfs open file operation. It
3178 * gets the reference to phba from the i_private field in @inode, it then
3179 * allocates buffer for the file operation, performs the necessary PCI config
3180 * space read into the allocated buffer according to the idiag user command
3181 * setup, and then returns a pointer to buffer in the private_data field in
3185 * This function returns zero if successful. On error it will return an
3186 * negative error value.
3189 lpfc_idiag_open(struct inode
*inode
, struct file
*file
)
3191 struct lpfc_debug
*debug
;
3193 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
3197 debug
->i_private
= inode
->i_private
;
3198 debug
->buffer
= NULL
;
3199 file
->private_data
= debug
;
3205 * lpfc_idiag_release - Release idiag access file operation
3206 * @inode: The inode pointer that contains a vport pointer. (unused)
3207 * @file: The file pointer that contains the buffer to release.
3210 * This routine is the generic release routine for the idiag access file
3211 * operation, it frees the buffer that was allocated when the debugfs file
3215 * This function returns zero.
3218 lpfc_idiag_release(struct inode
*inode
, struct file
*file
)
3220 struct lpfc_debug
*debug
= file
->private_data
;
3222 /* Free the buffers to the file operation */
3223 kfree(debug
->buffer
);
3230 * lpfc_idiag_cmd_release - Release idiag cmd access file operation
3231 * @inode: The inode pointer that contains a vport pointer. (unused)
3232 * @file: The file pointer that contains the buffer to release.
3235 * This routine frees the buffer that was allocated when the debugfs file
3236 * was opened. It also reset the fields in the idiag command struct in the
3237 * case of command for write operation.
3240 * This function returns zero.
3243 lpfc_idiag_cmd_release(struct inode
*inode
, struct file
*file
)
3245 struct lpfc_debug
*debug
= file
->private_data
;
3247 if (debug
->op
== LPFC_IDIAG_OP_WR
) {
3248 switch (idiag
.cmd
.opcode
) {
3249 case LPFC_IDIAG_CMD_PCICFG_WR
:
3250 case LPFC_IDIAG_CMD_PCICFG_ST
:
3251 case LPFC_IDIAG_CMD_PCICFG_CL
:
3252 case LPFC_IDIAG_CMD_QUEACC_WR
:
3253 case LPFC_IDIAG_CMD_QUEACC_ST
:
3254 case LPFC_IDIAG_CMD_QUEACC_CL
:
3255 memset(&idiag
, 0, sizeof(idiag
));
3262 /* Free the buffers to the file operation */
3263 kfree(debug
->buffer
);
3270 * lpfc_idiag_pcicfg_read - idiag debugfs read pcicfg
3271 * @file: The file pointer to read from.
3272 * @buf: The buffer to copy the data to.
3273 * @nbytes: The number of bytes to read.
3274 * @ppos: The position in the file to start reading from.
3277 * This routine reads data from the @phba pci config space according to the
3278 * idiag command, and copies to user @buf. Depending on the PCI config space
3279 * read command setup, it does either a single register read of a byte
3280 * (8 bits), a word (16 bits), or a dword (32 bits) or browsing through all
3281 * registers from the 4K extended PCI config space.
3284 * This function returns the amount of data that was read (this could be less
3285 * than @nbytes if the end of the file was reached) or a negative error value.
3288 lpfc_idiag_pcicfg_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
3291 struct lpfc_debug
*debug
= file
->private_data
;
3292 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
3293 int offset_label
, offset
, len
= 0, index
= LPFC_PCI_CFG_RD_SIZE
;
3296 struct pci_dev
*pdev
;
3301 pdev
= phba
->pcidev
;
3305 /* This is a user read operation */
3306 debug
->op
= LPFC_IDIAG_OP_RD
;
3309 debug
->buffer
= kmalloc(LPFC_PCI_CFG_SIZE
, GFP_KERNEL
);
3312 pbuffer
= debug
->buffer
;
3317 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_RD
) {
3318 where
= idiag
.cmd
.data
[IDIAG_PCICFG_WHERE_INDX
];
3319 count
= idiag
.cmd
.data
[IDIAG_PCICFG_COUNT_INDX
];
3323 /* Read single PCI config space register */
3325 case SIZE_U8
: /* byte (8 bits) */
3326 pci_read_config_byte(pdev
, where
, &u8val
);
3327 len
+= scnprintf(pbuffer
+len
, LPFC_PCI_CFG_SIZE
-len
,
3328 "%03x: %02x\n", where
, u8val
);
3330 case SIZE_U16
: /* word (16 bits) */
3331 pci_read_config_word(pdev
, where
, &u16val
);
3332 len
+= scnprintf(pbuffer
+len
, LPFC_PCI_CFG_SIZE
-len
,
3333 "%03x: %04x\n", where
, u16val
);
3335 case SIZE_U32
: /* double word (32 bits) */
3336 pci_read_config_dword(pdev
, where
, &u32val
);
3337 len
+= scnprintf(pbuffer
+len
, LPFC_PCI_CFG_SIZE
-len
,
3338 "%03x: %08x\n", where
, u32val
);
3340 case LPFC_PCI_CFG_BROWSE
: /* browse all */
3347 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
3351 /* Browse all PCI config space registers */
3352 offset_label
= idiag
.offset
.last_rd
;
3353 offset
= offset_label
;
3355 /* Read PCI config space */
3356 len
+= scnprintf(pbuffer
+len
, LPFC_PCI_CFG_SIZE
-len
,
3357 "%03x: ", offset_label
);
3359 pci_read_config_dword(pdev
, offset
, &u32val
);
3360 len
+= scnprintf(pbuffer
+len
, LPFC_PCI_CFG_SIZE
-len
,
3362 offset
+= sizeof(uint32_t);
3363 if (offset
>= LPFC_PCI_CFG_SIZE
) {
3364 len
+= scnprintf(pbuffer
+len
,
3365 LPFC_PCI_CFG_SIZE
-len
, "\n");
3368 index
-= sizeof(uint32_t);
3370 len
+= scnprintf(pbuffer
+len
, LPFC_PCI_CFG_SIZE
-len
,
3372 else if (!(index
% (8 * sizeof(uint32_t)))) {
3373 offset_label
+= (8 * sizeof(uint32_t));
3374 len
+= scnprintf(pbuffer
+len
, LPFC_PCI_CFG_SIZE
-len
,
3375 "\n%03x: ", offset_label
);
3379 /* Set up the offset for next portion of pci cfg read */
3381 idiag
.offset
.last_rd
+= LPFC_PCI_CFG_RD_SIZE
;
3382 if (idiag
.offset
.last_rd
>= LPFC_PCI_CFG_SIZE
)
3383 idiag
.offset
.last_rd
= 0;
3385 idiag
.offset
.last_rd
= 0;
3387 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
3391 * lpfc_idiag_pcicfg_write - Syntax check and set up idiag pcicfg commands
3392 * @file: The file pointer to read from.
3393 * @buf: The buffer to copy the user data from.
3394 * @nbytes: The number of bytes to get.
3395 * @ppos: The position in the file to start reading from.
3397 * This routine get the debugfs idiag command struct from user space and
3398 * then perform the syntax check for PCI config space read or write command
3399 * accordingly. In the case of PCI config space read command, it sets up
3400 * the command in the idiag command struct for the debugfs read operation.
3401 * In the case of PCI config space write operation, it executes the write
3402 * operation into the PCI config space accordingly.
3404 * It returns the @nbytges passing in from debugfs user space when successful.
3405 * In case of error conditions, it returns proper error code back to the user
3409 lpfc_idiag_pcicfg_write(struct file
*file
, const char __user
*buf
,
3410 size_t nbytes
, loff_t
*ppos
)
3412 struct lpfc_debug
*debug
= file
->private_data
;
3413 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
3414 uint32_t where
, value
, count
;
3418 struct pci_dev
*pdev
;
3421 pdev
= phba
->pcidev
;
3425 /* This is a user write operation */
3426 debug
->op
= LPFC_IDIAG_OP_WR
;
3428 rc
= lpfc_idiag_cmd_get(buf
, nbytes
, &idiag
.cmd
);
3432 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_RD
) {
3433 /* Sanity check on PCI config read command line arguments */
3434 if (rc
!= LPFC_PCI_CFG_RD_CMD_ARG
)
3436 /* Read command from PCI config space, set up command fields */
3437 where
= idiag
.cmd
.data
[IDIAG_PCICFG_WHERE_INDX
];
3438 count
= idiag
.cmd
.data
[IDIAG_PCICFG_COUNT_INDX
];
3439 if (count
== LPFC_PCI_CFG_BROWSE
) {
3440 if (where
% sizeof(uint32_t))
3442 /* Starting offset to browse */
3443 idiag
.offset
.last_rd
= where
;
3444 } else if ((count
!= sizeof(uint8_t)) &&
3445 (count
!= sizeof(uint16_t)) &&
3446 (count
!= sizeof(uint32_t)))
3448 if (count
== sizeof(uint8_t)) {
3449 if (where
> LPFC_PCI_CFG_SIZE
- sizeof(uint8_t))
3451 if (where
% sizeof(uint8_t))
3454 if (count
== sizeof(uint16_t)) {
3455 if (where
> LPFC_PCI_CFG_SIZE
- sizeof(uint16_t))
3457 if (where
% sizeof(uint16_t))
3460 if (count
== sizeof(uint32_t)) {
3461 if (where
> LPFC_PCI_CFG_SIZE
- sizeof(uint32_t))
3463 if (where
% sizeof(uint32_t))
3466 } else if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_WR
||
3467 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_ST
||
3468 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_CL
) {
3469 /* Sanity check on PCI config write command line arguments */
3470 if (rc
!= LPFC_PCI_CFG_WR_CMD_ARG
)
3472 /* Write command to PCI config space, read-modify-write */
3473 where
= idiag
.cmd
.data
[IDIAG_PCICFG_WHERE_INDX
];
3474 count
= idiag
.cmd
.data
[IDIAG_PCICFG_COUNT_INDX
];
3475 value
= idiag
.cmd
.data
[IDIAG_PCICFG_VALUE_INDX
];
3477 if ((count
!= sizeof(uint8_t)) &&
3478 (count
!= sizeof(uint16_t)) &&
3479 (count
!= sizeof(uint32_t)))
3481 if (count
== sizeof(uint8_t)) {
3482 if (where
> LPFC_PCI_CFG_SIZE
- sizeof(uint8_t))
3484 if (where
% sizeof(uint8_t))
3486 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_WR
)
3487 pci_write_config_byte(pdev
, where
,
3489 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_ST
) {
3490 rc
= pci_read_config_byte(pdev
, where
, &u8val
);
3492 u8val
|= (uint8_t)value
;
3493 pci_write_config_byte(pdev
, where
,
3497 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_CL
) {
3498 rc
= pci_read_config_byte(pdev
, where
, &u8val
);
3500 u8val
&= (uint8_t)(~value
);
3501 pci_write_config_byte(pdev
, where
,
3506 if (count
== sizeof(uint16_t)) {
3507 if (where
> LPFC_PCI_CFG_SIZE
- sizeof(uint16_t))
3509 if (where
% sizeof(uint16_t))
3511 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_WR
)
3512 pci_write_config_word(pdev
, where
,
3514 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_ST
) {
3515 rc
= pci_read_config_word(pdev
, where
, &u16val
);
3517 u16val
|= (uint16_t)value
;
3518 pci_write_config_word(pdev
, where
,
3522 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_CL
) {
3523 rc
= pci_read_config_word(pdev
, where
, &u16val
);
3525 u16val
&= (uint16_t)(~value
);
3526 pci_write_config_word(pdev
, where
,
3531 if (count
== sizeof(uint32_t)) {
3532 if (where
> LPFC_PCI_CFG_SIZE
- sizeof(uint32_t))
3534 if (where
% sizeof(uint32_t))
3536 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_WR
)
3537 pci_write_config_dword(pdev
, where
, value
);
3538 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_ST
) {
3539 rc
= pci_read_config_dword(pdev
, where
,
3543 pci_write_config_dword(pdev
, where
,
3547 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_CL
) {
3548 rc
= pci_read_config_dword(pdev
, where
,
3552 pci_write_config_dword(pdev
, where
,
3558 /* All other opecodes are illegal for now */
3563 memset(&idiag
, 0, sizeof(idiag
));
3568 * lpfc_idiag_baracc_read - idiag debugfs pci bar access read
3569 * @file: The file pointer to read from.
3570 * @buf: The buffer to copy the data to.
3571 * @nbytes: The number of bytes to read.
3572 * @ppos: The position in the file to start reading from.
3575 * This routine reads data from the @phba pci bar memory mapped space
3576 * according to the idiag command, and copies to user @buf.
3579 * This function returns the amount of data that was read (this could be less
3580 * than @nbytes if the end of the file was reached) or a negative error value.
3583 lpfc_idiag_baracc_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
3586 struct lpfc_debug
*debug
= file
->private_data
;
3587 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
3588 int offset_label
, offset
, offset_run
, len
= 0, index
;
3589 int bar_num
, acc_range
, bar_size
;
3591 void __iomem
*mem_mapped_bar
;
3593 struct pci_dev
*pdev
;
3596 pdev
= phba
->pcidev
;
3600 /* This is a user read operation */
3601 debug
->op
= LPFC_IDIAG_OP_RD
;
3604 debug
->buffer
= kmalloc(LPFC_PCI_BAR_RD_BUF_SIZE
, GFP_KERNEL
);
3607 pbuffer
= debug
->buffer
;
3612 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_RD
) {
3613 bar_num
= idiag
.cmd
.data
[IDIAG_BARACC_BAR_NUM_INDX
];
3614 offset
= idiag
.cmd
.data
[IDIAG_BARACC_OFF_SET_INDX
];
3615 acc_range
= idiag
.cmd
.data
[IDIAG_BARACC_ACC_MOD_INDX
];
3616 bar_size
= idiag
.cmd
.data
[IDIAG_BARACC_BAR_SZE_INDX
];
3623 if_type
= bf_get(lpfc_sli_intf_if_type
, &phba
->sli4_hba
.sli_intf
);
3624 if (if_type
== LPFC_SLI_INTF_IF_TYPE_0
) {
3625 if (bar_num
== IDIAG_BARACC_BAR_0
)
3626 mem_mapped_bar
= phba
->sli4_hba
.conf_regs_memmap_p
;
3627 else if (bar_num
== IDIAG_BARACC_BAR_1
)
3628 mem_mapped_bar
= phba
->sli4_hba
.ctrl_regs_memmap_p
;
3629 else if (bar_num
== IDIAG_BARACC_BAR_2
)
3630 mem_mapped_bar
= phba
->sli4_hba
.drbl_regs_memmap_p
;
3633 } else if (if_type
== LPFC_SLI_INTF_IF_TYPE_2
) {
3634 if (bar_num
== IDIAG_BARACC_BAR_0
)
3635 mem_mapped_bar
= phba
->sli4_hba
.conf_regs_memmap_p
;
3641 /* Read single PCI bar space register */
3642 if (acc_range
== SINGLE_WORD
) {
3643 offset_run
= offset
;
3644 u32val
= readl(mem_mapped_bar
+ offset_run
);
3645 len
+= scnprintf(pbuffer
+len
, LPFC_PCI_BAR_RD_BUF_SIZE
-len
,
3646 "%05x: %08x\n", offset_run
, u32val
);
3650 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
3654 /* Browse all PCI bar space registers */
3655 offset_label
= idiag
.offset
.last_rd
;
3656 offset_run
= offset_label
;
3658 /* Read PCI bar memory mapped space */
3659 len
+= scnprintf(pbuffer
+len
, LPFC_PCI_BAR_RD_BUF_SIZE
-len
,
3660 "%05x: ", offset_label
);
3661 index
= LPFC_PCI_BAR_RD_SIZE
;
3663 u32val
= readl(mem_mapped_bar
+ offset_run
);
3664 len
+= scnprintf(pbuffer
+len
, LPFC_PCI_BAR_RD_BUF_SIZE
-len
,
3666 offset_run
+= sizeof(uint32_t);
3667 if (acc_range
== LPFC_PCI_BAR_BROWSE
) {
3668 if (offset_run
>= bar_size
) {
3669 len
+= scnprintf(pbuffer
+len
,
3670 LPFC_PCI_BAR_RD_BUF_SIZE
-len
, "\n");
3674 if (offset_run
>= offset
+
3675 (acc_range
* sizeof(uint32_t))) {
3676 len
+= scnprintf(pbuffer
+len
,
3677 LPFC_PCI_BAR_RD_BUF_SIZE
-len
, "\n");
3681 index
-= sizeof(uint32_t);
3683 len
+= scnprintf(pbuffer
+len
,
3684 LPFC_PCI_BAR_RD_BUF_SIZE
-len
, "\n");
3685 else if (!(index
% (8 * sizeof(uint32_t)))) {
3686 offset_label
+= (8 * sizeof(uint32_t));
3687 len
+= scnprintf(pbuffer
+len
,
3688 LPFC_PCI_BAR_RD_BUF_SIZE
-len
,
3689 "\n%05x: ", offset_label
);
3693 /* Set up the offset for next portion of pci bar read */
3695 idiag
.offset
.last_rd
+= LPFC_PCI_BAR_RD_SIZE
;
3696 if (acc_range
== LPFC_PCI_BAR_BROWSE
) {
3697 if (idiag
.offset
.last_rd
>= bar_size
)
3698 idiag
.offset
.last_rd
= 0;
3700 if (offset_run
>= offset
+
3701 (acc_range
* sizeof(uint32_t)))
3702 idiag
.offset
.last_rd
= offset
;
3705 if (acc_range
== LPFC_PCI_BAR_BROWSE
)
3706 idiag
.offset
.last_rd
= 0;
3708 idiag
.offset
.last_rd
= offset
;
3711 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
3715 * lpfc_idiag_baracc_write - Syntax check and set up idiag bar access commands
3716 * @file: The file pointer to read from.
3717 * @buf: The buffer to copy the user data from.
3718 * @nbytes: The number of bytes to get.
3719 * @ppos: The position in the file to start reading from.
3721 * This routine get the debugfs idiag command struct from user space and
3722 * then perform the syntax check for PCI bar memory mapped space read or
3723 * write command accordingly. In the case of PCI bar memory mapped space
3724 * read command, it sets up the command in the idiag command struct for
3725 * the debugfs read operation. In the case of PCI bar memorpy mapped space
3726 * write operation, it executes the write operation into the PCI bar memory
3727 * mapped space accordingly.
3729 * It returns the @nbytges passing in from debugfs user space when successful.
3730 * In case of error conditions, it returns proper error code back to the user
3734 lpfc_idiag_baracc_write(struct file
*file
, const char __user
*buf
,
3735 size_t nbytes
, loff_t
*ppos
)
3737 struct lpfc_debug
*debug
= file
->private_data
;
3738 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
3739 uint32_t bar_num
, bar_size
, offset
, value
, acc_range
;
3740 struct pci_dev
*pdev
;
3741 void __iomem
*mem_mapped_bar
;
3746 pdev
= phba
->pcidev
;
3750 /* This is a user write operation */
3751 debug
->op
= LPFC_IDIAG_OP_WR
;
3753 rc
= lpfc_idiag_cmd_get(buf
, nbytes
, &idiag
.cmd
);
3757 if_type
= bf_get(lpfc_sli_intf_if_type
, &phba
->sli4_hba
.sli_intf
);
3758 bar_num
= idiag
.cmd
.data
[IDIAG_BARACC_BAR_NUM_INDX
];
3760 if (if_type
== LPFC_SLI_INTF_IF_TYPE_0
) {
3761 if ((bar_num
!= IDIAG_BARACC_BAR_0
) &&
3762 (bar_num
!= IDIAG_BARACC_BAR_1
) &&
3763 (bar_num
!= IDIAG_BARACC_BAR_2
))
3765 } else if (if_type
== LPFC_SLI_INTF_IF_TYPE_2
) {
3766 if (bar_num
!= IDIAG_BARACC_BAR_0
)
3771 if (if_type
== LPFC_SLI_INTF_IF_TYPE_0
) {
3772 if (bar_num
== IDIAG_BARACC_BAR_0
) {
3773 idiag
.cmd
.data
[IDIAG_BARACC_BAR_SZE_INDX
] =
3774 LPFC_PCI_IF0_BAR0_SIZE
;
3775 mem_mapped_bar
= phba
->sli4_hba
.conf_regs_memmap_p
;
3776 } else if (bar_num
== IDIAG_BARACC_BAR_1
) {
3777 idiag
.cmd
.data
[IDIAG_BARACC_BAR_SZE_INDX
] =
3778 LPFC_PCI_IF0_BAR1_SIZE
;
3779 mem_mapped_bar
= phba
->sli4_hba
.ctrl_regs_memmap_p
;
3780 } else if (bar_num
== IDIAG_BARACC_BAR_2
) {
3781 idiag
.cmd
.data
[IDIAG_BARACC_BAR_SZE_INDX
] =
3782 LPFC_PCI_IF0_BAR2_SIZE
;
3783 mem_mapped_bar
= phba
->sli4_hba
.drbl_regs_memmap_p
;
3786 } else if (if_type
== LPFC_SLI_INTF_IF_TYPE_2
) {
3787 if (bar_num
== IDIAG_BARACC_BAR_0
) {
3788 idiag
.cmd
.data
[IDIAG_BARACC_BAR_SZE_INDX
] =
3789 LPFC_PCI_IF2_BAR0_SIZE
;
3790 mem_mapped_bar
= phba
->sli4_hba
.conf_regs_memmap_p
;
3796 offset
= idiag
.cmd
.data
[IDIAG_BARACC_OFF_SET_INDX
];
3797 if (offset
% sizeof(uint32_t))
3800 bar_size
= idiag
.cmd
.data
[IDIAG_BARACC_BAR_SZE_INDX
];
3801 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_RD
) {
3802 /* Sanity check on PCI config read command line arguments */
3803 if (rc
!= LPFC_PCI_BAR_RD_CMD_ARG
)
3805 acc_range
= idiag
.cmd
.data
[IDIAG_BARACC_ACC_MOD_INDX
];
3806 if (acc_range
== LPFC_PCI_BAR_BROWSE
) {
3807 if (offset
> bar_size
- sizeof(uint32_t))
3809 /* Starting offset to browse */
3810 idiag
.offset
.last_rd
= offset
;
3811 } else if (acc_range
> SINGLE_WORD
) {
3812 if (offset
+ acc_range
* sizeof(uint32_t) > bar_size
)
3814 /* Starting offset to browse */
3815 idiag
.offset
.last_rd
= offset
;
3816 } else if (acc_range
!= SINGLE_WORD
)
3818 } else if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_WR
||
3819 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_ST
||
3820 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_CL
) {
3821 /* Sanity check on PCI bar write command line arguments */
3822 if (rc
!= LPFC_PCI_BAR_WR_CMD_ARG
)
3824 /* Write command to PCI bar space, read-modify-write */
3825 acc_range
= SINGLE_WORD
;
3826 value
= idiag
.cmd
.data
[IDIAG_BARACC_REG_VAL_INDX
];
3827 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_WR
) {
3828 writel(value
, mem_mapped_bar
+ offset
);
3829 readl(mem_mapped_bar
+ offset
);
3831 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_ST
) {
3832 u32val
= readl(mem_mapped_bar
+ offset
);
3834 writel(u32val
, mem_mapped_bar
+ offset
);
3835 readl(mem_mapped_bar
+ offset
);
3837 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_CL
) {
3838 u32val
= readl(mem_mapped_bar
+ offset
);
3840 writel(u32val
, mem_mapped_bar
+ offset
);
3841 readl(mem_mapped_bar
+ offset
);
3844 /* All other opecodes are illegal for now */
3849 memset(&idiag
, 0, sizeof(idiag
));
3854 __lpfc_idiag_print_wq(struct lpfc_queue
*qp
, char *wqtype
,
3855 char *pbuffer
, int len
)
3860 len
+= scnprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3861 "\t\t%s WQ info: ", wqtype
);
3862 len
+= scnprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3863 "AssocCQID[%04d]: WQ-STAT[oflow:x%x posted:x%llx]\n",
3864 qp
->assoc_qid
, qp
->q_cnt_1
,
3865 (unsigned long long)qp
->q_cnt_4
);
3866 len
+= scnprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3867 "\t\tWQID[%02d], QE-CNT[%04d], QE-SZ[%04d], "
3868 "HST-IDX[%04d], PRT-IDX[%04d], NTFI[%03d]",
3869 qp
->queue_id
, qp
->entry_count
,
3870 qp
->entry_size
, qp
->host_index
,
3871 qp
->hba_index
, qp
->notify_interval
);
3872 len
+= scnprintf(pbuffer
+ len
,
3873 LPFC_QUE_INFO_GET_BUF_SIZE
- len
, "\n");
3878 lpfc_idiag_wqs_for_cq(struct lpfc_hba
*phba
, char *wqtype
, char *pbuffer
,
3879 int *len
, int max_cnt
, int cq_id
)
3881 struct lpfc_queue
*qp
;
3884 for (qidx
= 0; qidx
< phba
->cfg_hdw_queue
; qidx
++) {
3885 qp
= phba
->sli4_hba
.hdwq
[qidx
].io_wq
;
3886 if (qp
->assoc_qid
!= cq_id
)
3888 *len
= __lpfc_idiag_print_wq(qp
, wqtype
, pbuffer
, *len
);
3889 if (*len
>= max_cnt
)
3896 __lpfc_idiag_print_cq(struct lpfc_queue
*qp
, char *cqtype
,
3897 char *pbuffer
, int len
)
3902 len
+= scnprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3903 "\t%s CQ info: ", cqtype
);
3904 len
+= scnprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3905 "AssocEQID[%02d]: CQ STAT[max:x%x relw:x%x "
3906 "xabt:x%x wq:x%llx]\n",
3907 qp
->assoc_qid
, qp
->q_cnt_1
, qp
->q_cnt_2
,
3908 qp
->q_cnt_3
, (unsigned long long)qp
->q_cnt_4
);
3909 len
+= scnprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3910 "\tCQID[%02d], QE-CNT[%04d], QE-SZ[%04d], "
3911 "HST-IDX[%04d], NTFI[%03d], PLMT[%03d]",
3912 qp
->queue_id
, qp
->entry_count
,
3913 qp
->entry_size
, qp
->host_index
,
3914 qp
->notify_interval
, qp
->max_proc_limit
);
3916 len
+= scnprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3923 __lpfc_idiag_print_rqpair(struct lpfc_queue
*qp
, struct lpfc_queue
*datqp
,
3924 char *rqtype
, char *pbuffer
, int len
)
3929 len
+= scnprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3930 "\t\t%s RQ info: ", rqtype
);
3931 len
+= scnprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3932 "AssocCQID[%02d]: RQ-STAT[nopost:x%x nobuf:x%x "
3933 "posted:x%x rcv:x%llx]\n",
3934 qp
->assoc_qid
, qp
->q_cnt_1
, qp
->q_cnt_2
,
3935 qp
->q_cnt_3
, (unsigned long long)qp
->q_cnt_4
);
3936 len
+= scnprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3937 "\t\tHQID[%02d], QE-CNT[%04d], QE-SZ[%04d], "
3938 "HST-IDX[%04d], PRT-IDX[%04d], NTFI[%03d]\n",
3939 qp
->queue_id
, qp
->entry_count
, qp
->entry_size
,
3940 qp
->host_index
, qp
->hba_index
, qp
->notify_interval
);
3941 len
+= scnprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3942 "\t\tDQID[%02d], QE-CNT[%04d], QE-SZ[%04d], "
3943 "HST-IDX[%04d], PRT-IDX[%04d], NTFI[%03d]\n",
3944 datqp
->queue_id
, datqp
->entry_count
,
3945 datqp
->entry_size
, datqp
->host_index
,
3946 datqp
->hba_index
, datqp
->notify_interval
);
3951 lpfc_idiag_cqs_for_eq(struct lpfc_hba
*phba
, char *pbuffer
,
3952 int *len
, int max_cnt
, int eqidx
, int eq_id
)
3954 struct lpfc_queue
*qp
;
3957 qp
= phba
->sli4_hba
.hdwq
[eqidx
].io_cq
;
3959 *len
= __lpfc_idiag_print_cq(qp
, "IO", pbuffer
, *len
);
3961 /* Reset max counter */
3964 if (*len
>= max_cnt
)
3967 rc
= lpfc_idiag_wqs_for_cq(phba
, "IO", pbuffer
, len
,
3968 max_cnt
, qp
->queue_id
);
3972 if ((eqidx
< phba
->cfg_nvmet_mrq
) && phba
->nvmet_support
) {
3974 qp
= phba
->sli4_hba
.nvmet_cqset
[eqidx
];
3975 *len
= __lpfc_idiag_print_cq(qp
, "NVMET CQset", pbuffer
, *len
);
3977 /* Reset max counter */
3980 if (*len
>= max_cnt
)
3984 qp
= phba
->sli4_hba
.nvmet_mrq_hdr
[eqidx
];
3985 *len
= __lpfc_idiag_print_rqpair(qp
,
3986 phba
->sli4_hba
.nvmet_mrq_data
[eqidx
],
3987 "NVMET MRQ", pbuffer
, *len
);
3989 if (*len
>= max_cnt
)
3997 __lpfc_idiag_print_eq(struct lpfc_queue
*qp
, char *eqtype
,
3998 char *pbuffer
, int len
)
4003 len
+= scnprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
4004 "\n%s EQ info: EQ-STAT[max:x%x noE:x%x "
4005 "cqe_proc:x%x eqe_proc:x%llx eqd %d]\n",
4006 eqtype
, qp
->q_cnt_1
, qp
->q_cnt_2
, qp
->q_cnt_3
,
4007 (unsigned long long)qp
->q_cnt_4
, qp
->q_mode
);
4008 len
+= scnprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
4009 "EQID[%02d], QE-CNT[%04d], QE-SZ[%04d], "
4010 "HST-IDX[%04d], NTFI[%03d], PLMT[%03d], AFFIN[%03d]",
4011 qp
->queue_id
, qp
->entry_count
, qp
->entry_size
,
4012 qp
->host_index
, qp
->notify_interval
,
4013 qp
->max_proc_limit
, qp
->chann
);
4014 len
+= scnprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
4021 * lpfc_idiag_queinfo_read - idiag debugfs read queue information
4022 * @file: The file pointer to read from.
4023 * @buf: The buffer to copy the data to.
4024 * @nbytes: The number of bytes to read.
4025 * @ppos: The position in the file to start reading from.
4028 * This routine reads data from the @phba SLI4 PCI function queue information,
4029 * and copies to user @buf.
4030 * This routine only returns 1 EQs worth of information. It remembers the last
4031 * EQ read and jumps to the next EQ. Thus subsequent calls to queInfo will
4032 * retrieve all EQs allocated for the phba.
4035 * This function returns the amount of data that was read (this could be less
4036 * than @nbytes if the end of the file was reached) or a negative error value.
4039 lpfc_idiag_queinfo_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
4042 struct lpfc_debug
*debug
= file
->private_data
;
4043 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
4045 int max_cnt
, rc
, x
, len
= 0;
4046 struct lpfc_queue
*qp
= NULL
;
4049 debug
->buffer
= kmalloc(LPFC_QUE_INFO_GET_BUF_SIZE
, GFP_KERNEL
);
4052 pbuffer
= debug
->buffer
;
4053 max_cnt
= LPFC_QUE_INFO_GET_BUF_SIZE
- 256;
4058 spin_lock_irq(&phba
->hbalock
);
4060 /* Fast-path event queue */
4061 if (phba
->sli4_hba
.hdwq
&& phba
->cfg_hdw_queue
) {
4063 x
= phba
->lpfc_idiag_last_eq
;
4064 phba
->lpfc_idiag_last_eq
++;
4065 if (phba
->lpfc_idiag_last_eq
>= phba
->cfg_hdw_queue
)
4066 phba
->lpfc_idiag_last_eq
= 0;
4068 len
+= scnprintf(pbuffer
+ len
,
4069 LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
4070 "HDWQ %d out of %d HBA HDWQs\n",
4071 x
, phba
->cfg_hdw_queue
);
4074 qp
= phba
->sli4_hba
.hdwq
[x
].hba_eq
;
4078 len
= __lpfc_idiag_print_eq(qp
, "HBA", pbuffer
, len
);
4080 /* Reset max counter */
4086 /* will dump both fcp and nvme cqs/wqs for the eq */
4087 rc
= lpfc_idiag_cqs_for_eq(phba
, pbuffer
, &len
,
4088 max_cnt
, x
, qp
->queue_id
);
4092 /* Only EQ 0 has slow path CQs configured */
4096 /* Slow-path mailbox CQ */
4097 qp
= phba
->sli4_hba
.mbx_cq
;
4098 len
= __lpfc_idiag_print_cq(qp
, "MBX", pbuffer
, len
);
4102 /* Slow-path MBOX MQ */
4103 qp
= phba
->sli4_hba
.mbx_wq
;
4104 len
= __lpfc_idiag_print_wq(qp
, "MBX", pbuffer
, len
);
4108 /* Slow-path ELS response CQ */
4109 qp
= phba
->sli4_hba
.els_cq
;
4110 len
= __lpfc_idiag_print_cq(qp
, "ELS", pbuffer
, len
);
4111 /* Reset max counter */
4117 /* Slow-path ELS WQ */
4118 qp
= phba
->sli4_hba
.els_wq
;
4119 len
= __lpfc_idiag_print_wq(qp
, "ELS", pbuffer
, len
);
4123 qp
= phba
->sli4_hba
.hdr_rq
;
4124 len
= __lpfc_idiag_print_rqpair(qp
, phba
->sli4_hba
.dat_rq
,
4125 "ELS RQpair", pbuffer
, len
);
4129 /* Slow-path NVME LS response CQ */
4130 qp
= phba
->sli4_hba
.nvmels_cq
;
4131 len
= __lpfc_idiag_print_cq(qp
, "NVME LS",
4133 /* Reset max counter */
4139 /* Slow-path NVME LS WQ */
4140 qp
= phba
->sli4_hba
.nvmels_wq
;
4141 len
= __lpfc_idiag_print_wq(qp
, "NVME LS",
4149 spin_unlock_irq(&phba
->hbalock
);
4150 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
4153 len
+= scnprintf(pbuffer
+ len
,
4154 LPFC_QUE_INFO_GET_BUF_SIZE
- len
, "Truncated ...\n");
4156 spin_unlock_irq(&phba
->hbalock
);
4157 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
4161 * lpfc_idiag_que_param_check - queue access command parameter sanity check
4162 * @q: The pointer to queue structure.
4163 * @index: The index into a queue entry.
4164 * @count: The number of queue entries to access.
4167 * The routine performs sanity check on device queue access method commands.
4170 * This function returns -EINVAL when fails the sanity check, otherwise, it
4174 lpfc_idiag_que_param_check(struct lpfc_queue
*q
, int index
, int count
)
4176 /* Only support single entry read or browsing */
4177 if ((count
!= 1) && (count
!= LPFC_QUE_ACC_BROWSE
))
4179 if (index
> q
->entry_count
- 1)
4185 * lpfc_idiag_queacc_read_qe - read a single entry from the given queue index
4186 * @pbuffer: The pointer to buffer to copy the read data into.
4187 * @len: Length of the buffer.
4188 * @pque: The pointer to the queue to be read.
4189 * @index: The index into the queue entry.
4192 * This routine reads out a single entry from the given queue's index location
4193 * and copies it into the buffer provided.
4196 * This function returns 0 when it fails, otherwise, it returns the length of
4197 * the data read into the buffer provided.
4200 lpfc_idiag_queacc_read_qe(char *pbuffer
, int len
, struct lpfc_queue
*pque
,
4206 if (!pbuffer
|| !pque
)
4209 esize
= pque
->entry_size
;
4210 len
+= scnprintf(pbuffer
+len
, LPFC_QUE_ACC_BUF_SIZE
-len
,
4211 "QE-INDEX[%04d]:\n", index
);
4214 pentry
= lpfc_sli4_qe(pque
, index
);
4216 len
+= scnprintf(pbuffer
+len
, LPFC_QUE_ACC_BUF_SIZE
-len
,
4219 offset
+= sizeof(uint32_t);
4220 esize
-= sizeof(uint32_t);
4221 if (esize
> 0 && !(offset
% (4 * sizeof(uint32_t))))
4222 len
+= scnprintf(pbuffer
+len
,
4223 LPFC_QUE_ACC_BUF_SIZE
-len
, "\n");
4225 len
+= scnprintf(pbuffer
+len
, LPFC_QUE_ACC_BUF_SIZE
-len
, "\n");
4231 * lpfc_idiag_queacc_read - idiag debugfs read port queue
4232 * @file: The file pointer to read from.
4233 * @buf: The buffer to copy the data to.
4234 * @nbytes: The number of bytes to read.
4235 * @ppos: The position in the file to start reading from.
4238 * This routine reads data from the @phba device queue memory according to the
4239 * idiag command, and copies to user @buf. Depending on the queue dump read
4240 * command setup, it does either a single queue entry read or browing through
4241 * all entries of the queue.
4244 * This function returns the amount of data that was read (this could be less
4245 * than @nbytes if the end of the file was reached) or a negative error value.
4248 lpfc_idiag_queacc_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
4251 struct lpfc_debug
*debug
= file
->private_data
;
4252 uint32_t last_index
, index
, count
;
4253 struct lpfc_queue
*pque
= NULL
;
4257 /* This is a user read operation */
4258 debug
->op
= LPFC_IDIAG_OP_RD
;
4261 debug
->buffer
= kmalloc(LPFC_QUE_ACC_BUF_SIZE
, GFP_KERNEL
);
4264 pbuffer
= debug
->buffer
;
4269 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_RD
) {
4270 index
= idiag
.cmd
.data
[IDIAG_QUEACC_INDEX_INDX
];
4271 count
= idiag
.cmd
.data
[IDIAG_QUEACC_COUNT_INDX
];
4272 pque
= (struct lpfc_queue
*)idiag
.ptr_private
;
4276 /* Browse the queue starting from index */
4277 if (count
== LPFC_QUE_ACC_BROWSE
)
4280 /* Read a single entry from the queue */
4281 len
= lpfc_idiag_queacc_read_qe(pbuffer
, len
, pque
, index
);
4283 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
4287 /* Browse all entries from the queue */
4288 last_index
= idiag
.offset
.last_rd
;
4291 while (len
< LPFC_QUE_ACC_SIZE
- pque
->entry_size
) {
4292 len
= lpfc_idiag_queacc_read_qe(pbuffer
, len
, pque
, index
);
4294 if (index
> pque
->entry_count
- 1)
4298 /* Set up the offset for next portion of pci cfg read */
4299 if (index
> pque
->entry_count
- 1)
4301 idiag
.offset
.last_rd
= index
;
4303 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
4307 * lpfc_idiag_queacc_write - Syntax check and set up idiag queacc commands
4308 * @file: The file pointer to read from.
4309 * @buf: The buffer to copy the user data from.
4310 * @nbytes: The number of bytes to get.
4311 * @ppos: The position in the file to start reading from.
4313 * This routine get the debugfs idiag command struct from user space and then
4314 * perform the syntax check for port queue read (dump) or write (set) command
4315 * accordingly. In the case of port queue read command, it sets up the command
4316 * in the idiag command struct for the following debugfs read operation. In
4317 * the case of port queue write operation, it executes the write operation
4318 * into the port queue entry accordingly.
4320 * It returns the @nbytges passing in from debugfs user space when successful.
4321 * In case of error conditions, it returns proper error code back to the user
4325 lpfc_idiag_queacc_write(struct file
*file
, const char __user
*buf
,
4326 size_t nbytes
, loff_t
*ppos
)
4328 struct lpfc_debug
*debug
= file
->private_data
;
4329 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
4330 uint32_t qidx
, quetp
, queid
, index
, count
, offset
, value
;
4332 struct lpfc_queue
*pque
, *qp
;
4335 /* This is a user write operation */
4336 debug
->op
= LPFC_IDIAG_OP_WR
;
4338 rc
= lpfc_idiag_cmd_get(buf
, nbytes
, &idiag
.cmd
);
4342 /* Get and sanity check on command feilds */
4343 quetp
= idiag
.cmd
.data
[IDIAG_QUEACC_QUETP_INDX
];
4344 queid
= idiag
.cmd
.data
[IDIAG_QUEACC_QUEID_INDX
];
4345 index
= idiag
.cmd
.data
[IDIAG_QUEACC_INDEX_INDX
];
4346 count
= idiag
.cmd
.data
[IDIAG_QUEACC_COUNT_INDX
];
4347 offset
= idiag
.cmd
.data
[IDIAG_QUEACC_OFFST_INDX
];
4348 value
= idiag
.cmd
.data
[IDIAG_QUEACC_VALUE_INDX
];
4350 /* Sanity check on command line arguments */
4351 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_WR
||
4352 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_ST
||
4353 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_CL
) {
4354 if (rc
!= LPFC_QUE_ACC_WR_CMD_ARG
)
4358 } else if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_RD
) {
4359 if (rc
!= LPFC_QUE_ACC_RD_CMD_ARG
)
4366 /* HBA event queue */
4367 if (phba
->sli4_hba
.hdwq
) {
4368 for (qidx
= 0; qidx
< phba
->cfg_hdw_queue
; qidx
++) {
4369 qp
= phba
->sli4_hba
.hdwq
[qidx
].hba_eq
;
4370 if (qp
&& qp
->queue_id
== queid
) {
4372 rc
= lpfc_idiag_que_param_check(qp
,
4376 idiag
.ptr_private
= qp
;
4384 /* MBX complete queue */
4385 if (phba
->sli4_hba
.mbx_cq
&&
4386 phba
->sli4_hba
.mbx_cq
->queue_id
== queid
) {
4388 rc
= lpfc_idiag_que_param_check(
4389 phba
->sli4_hba
.mbx_cq
, index
, count
);
4392 idiag
.ptr_private
= phba
->sli4_hba
.mbx_cq
;
4395 /* ELS complete queue */
4396 if (phba
->sli4_hba
.els_cq
&&
4397 phba
->sli4_hba
.els_cq
->queue_id
== queid
) {
4399 rc
= lpfc_idiag_que_param_check(
4400 phba
->sli4_hba
.els_cq
, index
, count
);
4403 idiag
.ptr_private
= phba
->sli4_hba
.els_cq
;
4406 /* NVME LS complete queue */
4407 if (phba
->sli4_hba
.nvmels_cq
&&
4408 phba
->sli4_hba
.nvmels_cq
->queue_id
== queid
) {
4410 rc
= lpfc_idiag_que_param_check(
4411 phba
->sli4_hba
.nvmels_cq
, index
, count
);
4414 idiag
.ptr_private
= phba
->sli4_hba
.nvmels_cq
;
4417 /* FCP complete queue */
4418 if (phba
->sli4_hba
.hdwq
) {
4419 for (qidx
= 0; qidx
< phba
->cfg_hdw_queue
;
4421 qp
= phba
->sli4_hba
.hdwq
[qidx
].io_cq
;
4422 if (qp
&& qp
->queue_id
== queid
) {
4424 rc
= lpfc_idiag_que_param_check(
4428 idiag
.ptr_private
= qp
;
4436 /* MBX work queue */
4437 if (phba
->sli4_hba
.mbx_wq
&&
4438 phba
->sli4_hba
.mbx_wq
->queue_id
== queid
) {
4440 rc
= lpfc_idiag_que_param_check(
4441 phba
->sli4_hba
.mbx_wq
, index
, count
);
4444 idiag
.ptr_private
= phba
->sli4_hba
.mbx_wq
;
4450 /* ELS work queue */
4451 if (phba
->sli4_hba
.els_wq
&&
4452 phba
->sli4_hba
.els_wq
->queue_id
== queid
) {
4454 rc
= lpfc_idiag_que_param_check(
4455 phba
->sli4_hba
.els_wq
, index
, count
);
4458 idiag
.ptr_private
= phba
->sli4_hba
.els_wq
;
4461 /* NVME LS work queue */
4462 if (phba
->sli4_hba
.nvmels_wq
&&
4463 phba
->sli4_hba
.nvmels_wq
->queue_id
== queid
) {
4465 rc
= lpfc_idiag_que_param_check(
4466 phba
->sli4_hba
.nvmels_wq
, index
, count
);
4469 idiag
.ptr_private
= phba
->sli4_hba
.nvmels_wq
;
4473 if (phba
->sli4_hba
.hdwq
) {
4474 /* FCP/SCSI work queue */
4475 for (qidx
= 0; qidx
< phba
->cfg_hdw_queue
; qidx
++) {
4476 qp
= phba
->sli4_hba
.hdwq
[qidx
].io_wq
;
4477 if (qp
&& qp
->queue_id
== queid
) {
4479 rc
= lpfc_idiag_que_param_check(
4483 idiag
.ptr_private
= qp
;
4492 if (phba
->sli4_hba
.hdr_rq
&&
4493 phba
->sli4_hba
.hdr_rq
->queue_id
== queid
) {
4495 rc
= lpfc_idiag_que_param_check(
4496 phba
->sli4_hba
.hdr_rq
, index
, count
);
4499 idiag
.ptr_private
= phba
->sli4_hba
.hdr_rq
;
4503 if (phba
->sli4_hba
.dat_rq
&&
4504 phba
->sli4_hba
.dat_rq
->queue_id
== queid
) {
4506 rc
= lpfc_idiag_que_param_check(
4507 phba
->sli4_hba
.dat_rq
, index
, count
);
4510 idiag
.ptr_private
= phba
->sli4_hba
.dat_rq
;
4520 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_RD
) {
4521 if (count
== LPFC_QUE_ACC_BROWSE
)
4522 idiag
.offset
.last_rd
= index
;
4525 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_WR
||
4526 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_ST
||
4527 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_CL
) {
4528 /* Additional sanity checks on write operation */
4529 pque
= (struct lpfc_queue
*)idiag
.ptr_private
;
4530 if (offset
> pque
->entry_size
/sizeof(uint32_t) - 1)
4532 pentry
= lpfc_sli4_qe(pque
, index
);
4534 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_WR
)
4536 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_ST
)
4538 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_CL
)
4544 /* Clean out command structure on command error out */
4545 memset(&idiag
, 0, sizeof(idiag
));
4550 * lpfc_idiag_drbacc_read_reg - idiag debugfs read a doorbell register
4551 * @phba: The pointer to hba structure.
4552 * @pbuffer: The pointer to the buffer to copy the data to.
4553 * @len: The length of bytes to copied.
4554 * @drbregid: The id to doorbell registers.
4557 * This routine reads a doorbell register and copies its content to the
4558 * user buffer pointed to by @pbuffer.
4561 * This function returns the amount of data that was copied into @pbuffer.
4564 lpfc_idiag_drbacc_read_reg(struct lpfc_hba
*phba
, char *pbuffer
,
4565 int len
, uint32_t drbregid
)
4573 len
+= scnprintf(pbuffer
+ len
, LPFC_DRB_ACC_BUF_SIZE
-len
,
4574 "EQ-DRB-REG: 0x%08x\n",
4575 readl(phba
->sli4_hba
.EQDBregaddr
));
4578 len
+= scnprintf(pbuffer
+ len
, LPFC_DRB_ACC_BUF_SIZE
- len
,
4579 "CQ-DRB-REG: 0x%08x\n",
4580 readl(phba
->sli4_hba
.CQDBregaddr
));
4583 len
+= scnprintf(pbuffer
+len
, LPFC_DRB_ACC_BUF_SIZE
-len
,
4584 "MQ-DRB-REG: 0x%08x\n",
4585 readl(phba
->sli4_hba
.MQDBregaddr
));
4588 len
+= scnprintf(pbuffer
+len
, LPFC_DRB_ACC_BUF_SIZE
-len
,
4589 "WQ-DRB-REG: 0x%08x\n",
4590 readl(phba
->sli4_hba
.WQDBregaddr
));
4593 len
+= scnprintf(pbuffer
+len
, LPFC_DRB_ACC_BUF_SIZE
-len
,
4594 "RQ-DRB-REG: 0x%08x\n",
4595 readl(phba
->sli4_hba
.RQDBregaddr
));
4605 * lpfc_idiag_drbacc_read - idiag debugfs read port doorbell
4606 * @file: The file pointer to read from.
4607 * @buf: The buffer to copy the data to.
4608 * @nbytes: The number of bytes to read.
4609 * @ppos: The position in the file to start reading from.
4612 * This routine reads data from the @phba device doorbell register according
4613 * to the idiag command, and copies to user @buf. Depending on the doorbell
4614 * register read command setup, it does either a single doorbell register
4615 * read or dump all doorbell registers.
4618 * This function returns the amount of data that was read (this could be less
4619 * than @nbytes if the end of the file was reached) or a negative error value.
4622 lpfc_idiag_drbacc_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
4625 struct lpfc_debug
*debug
= file
->private_data
;
4626 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
4627 uint32_t drb_reg_id
, i
;
4631 /* This is a user read operation */
4632 debug
->op
= LPFC_IDIAG_OP_RD
;
4635 debug
->buffer
= kmalloc(LPFC_DRB_ACC_BUF_SIZE
, GFP_KERNEL
);
4638 pbuffer
= debug
->buffer
;
4643 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_RD
)
4644 drb_reg_id
= idiag
.cmd
.data
[IDIAG_DRBACC_REGID_INDX
];
4648 if (drb_reg_id
== LPFC_DRB_ACC_ALL
)
4649 for (i
= 1; i
<= LPFC_DRB_MAX
; i
++)
4650 len
= lpfc_idiag_drbacc_read_reg(phba
,
4653 len
= lpfc_idiag_drbacc_read_reg(phba
,
4654 pbuffer
, len
, drb_reg_id
);
4656 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
4660 * lpfc_idiag_drbacc_write - Syntax check and set up idiag drbacc commands
4661 * @file: The file pointer to read from.
4662 * @buf: The buffer to copy the user data from.
4663 * @nbytes: The number of bytes to get.
4664 * @ppos: The position in the file to start reading from.
4666 * This routine get the debugfs idiag command struct from user space and then
4667 * perform the syntax check for port doorbell register read (dump) or write
4668 * (set) command accordingly. In the case of port queue read command, it sets
4669 * up the command in the idiag command struct for the following debugfs read
4670 * operation. In the case of port doorbell register write operation, it
4671 * executes the write operation into the port doorbell register accordingly.
4673 * It returns the @nbytges passing in from debugfs user space when successful.
4674 * In case of error conditions, it returns proper error code back to the user
4678 lpfc_idiag_drbacc_write(struct file
*file
, const char __user
*buf
,
4679 size_t nbytes
, loff_t
*ppos
)
4681 struct lpfc_debug
*debug
= file
->private_data
;
4682 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
4683 uint32_t drb_reg_id
, value
, reg_val
= 0;
4684 void __iomem
*drb_reg
;
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 /* Sanity check on command line arguments */
4695 drb_reg_id
= idiag
.cmd
.data
[IDIAG_DRBACC_REGID_INDX
];
4696 value
= idiag
.cmd
.data
[IDIAG_DRBACC_VALUE_INDX
];
4698 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_WR
||
4699 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_ST
||
4700 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_CL
) {
4701 if (rc
!= LPFC_DRB_ACC_WR_CMD_ARG
)
4703 if (drb_reg_id
> LPFC_DRB_MAX
)
4705 } else if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_RD
) {
4706 if (rc
!= LPFC_DRB_ACC_RD_CMD_ARG
)
4708 if ((drb_reg_id
> LPFC_DRB_MAX
) &&
4709 (drb_reg_id
!= LPFC_DRB_ACC_ALL
))
4714 /* Perform the write access operation */
4715 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_WR
||
4716 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_ST
||
4717 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_CL
) {
4718 switch (drb_reg_id
) {
4720 drb_reg
= phba
->sli4_hba
.EQDBregaddr
;
4723 drb_reg
= phba
->sli4_hba
.CQDBregaddr
;
4726 drb_reg
= phba
->sli4_hba
.MQDBregaddr
;
4729 drb_reg
= phba
->sli4_hba
.WQDBregaddr
;
4732 drb_reg
= phba
->sli4_hba
.RQDBregaddr
;
4738 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_WR
)
4740 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_ST
) {
4741 reg_val
= readl(drb_reg
);
4744 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_CL
) {
4745 reg_val
= readl(drb_reg
);
4748 writel(reg_val
, drb_reg
);
4749 readl(drb_reg
); /* flush */
4754 /* Clean out command structure on command error out */
4755 memset(&idiag
, 0, sizeof(idiag
));
4760 * lpfc_idiag_ctlacc_read_reg - idiag debugfs read a control registers
4761 * @phba: The pointer to hba structure.
4762 * @pbuffer: The pointer to the buffer to copy the data to.
4763 * @len: The length of bytes to copied.
4764 * @ctlregid: The id to doorbell registers.
4767 * This routine reads a control register and copies its content to the
4768 * user buffer pointed to by @pbuffer.
4771 * This function returns the amount of data that was copied into @pbuffer.
4774 lpfc_idiag_ctlacc_read_reg(struct lpfc_hba
*phba
, char *pbuffer
,
4775 int len
, uint32_t ctlregid
)
4782 case LPFC_CTL_PORT_SEM
:
4783 len
+= scnprintf(pbuffer
+len
, LPFC_CTL_ACC_BUF_SIZE
-len
,
4784 "Port SemReg: 0x%08x\n",
4785 readl(phba
->sli4_hba
.conf_regs_memmap_p
+
4786 LPFC_CTL_PORT_SEM_OFFSET
));
4788 case LPFC_CTL_PORT_STA
:
4789 len
+= scnprintf(pbuffer
+len
, LPFC_CTL_ACC_BUF_SIZE
-len
,
4790 "Port StaReg: 0x%08x\n",
4791 readl(phba
->sli4_hba
.conf_regs_memmap_p
+
4792 LPFC_CTL_PORT_STA_OFFSET
));
4794 case LPFC_CTL_PORT_CTL
:
4795 len
+= scnprintf(pbuffer
+len
, LPFC_CTL_ACC_BUF_SIZE
-len
,
4796 "Port CtlReg: 0x%08x\n",
4797 readl(phba
->sli4_hba
.conf_regs_memmap_p
+
4798 LPFC_CTL_PORT_CTL_OFFSET
));
4800 case LPFC_CTL_PORT_ER1
:
4801 len
+= scnprintf(pbuffer
+len
, LPFC_CTL_ACC_BUF_SIZE
-len
,
4802 "Port Er1Reg: 0x%08x\n",
4803 readl(phba
->sli4_hba
.conf_regs_memmap_p
+
4804 LPFC_CTL_PORT_ER1_OFFSET
));
4806 case LPFC_CTL_PORT_ER2
:
4807 len
+= scnprintf(pbuffer
+len
, LPFC_CTL_ACC_BUF_SIZE
-len
,
4808 "Port Er2Reg: 0x%08x\n",
4809 readl(phba
->sli4_hba
.conf_regs_memmap_p
+
4810 LPFC_CTL_PORT_ER2_OFFSET
));
4812 case LPFC_CTL_PDEV_CTL
:
4813 len
+= scnprintf(pbuffer
+len
, LPFC_CTL_ACC_BUF_SIZE
-len
,
4814 "PDev CtlReg: 0x%08x\n",
4815 readl(phba
->sli4_hba
.conf_regs_memmap_p
+
4816 LPFC_CTL_PDEV_CTL_OFFSET
));
4825 * lpfc_idiag_ctlacc_read - idiag debugfs read port and device control register
4826 * @file: The file pointer to read from.
4827 * @buf: The buffer to copy the data to.
4828 * @nbytes: The number of bytes to read.
4829 * @ppos: The position in the file to start reading from.
4832 * This routine reads data from the @phba port and device registers according
4833 * to the idiag command, and copies to user @buf.
4836 * This function returns the amount of data that was read (this could be less
4837 * than @nbytes if the end of the file was reached) or a negative error value.
4840 lpfc_idiag_ctlacc_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
4843 struct lpfc_debug
*debug
= file
->private_data
;
4844 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
4845 uint32_t ctl_reg_id
, i
;
4849 /* This is a user read operation */
4850 debug
->op
= LPFC_IDIAG_OP_RD
;
4853 debug
->buffer
= kmalloc(LPFC_CTL_ACC_BUF_SIZE
, GFP_KERNEL
);
4856 pbuffer
= debug
->buffer
;
4861 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_RD
)
4862 ctl_reg_id
= idiag
.cmd
.data
[IDIAG_CTLACC_REGID_INDX
];
4866 if (ctl_reg_id
== LPFC_CTL_ACC_ALL
)
4867 for (i
= 1; i
<= LPFC_CTL_MAX
; i
++)
4868 len
= lpfc_idiag_ctlacc_read_reg(phba
,
4871 len
= lpfc_idiag_ctlacc_read_reg(phba
,
4872 pbuffer
, len
, ctl_reg_id
);
4874 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
4878 * lpfc_idiag_ctlacc_write - Syntax check and set up idiag ctlacc commands
4879 * @file: The file pointer to read from.
4880 * @buf: The buffer to copy the user data from.
4881 * @nbytes: The number of bytes to get.
4882 * @ppos: The position in the file to start reading from.
4884 * This routine get the debugfs idiag command struct from user space and then
4885 * perform the syntax check for port and device control register read (dump)
4886 * or write (set) command accordingly.
4888 * It returns the @nbytges passing in from debugfs user space when successful.
4889 * In case of error conditions, it returns proper error code back to the user
4893 lpfc_idiag_ctlacc_write(struct file
*file
, const char __user
*buf
,
4894 size_t nbytes
, loff_t
*ppos
)
4896 struct lpfc_debug
*debug
= file
->private_data
;
4897 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
4898 uint32_t ctl_reg_id
, value
, reg_val
= 0;
4899 void __iomem
*ctl_reg
;
4902 /* This is a user write operation */
4903 debug
->op
= LPFC_IDIAG_OP_WR
;
4905 rc
= lpfc_idiag_cmd_get(buf
, nbytes
, &idiag
.cmd
);
4909 /* Sanity check on command line arguments */
4910 ctl_reg_id
= idiag
.cmd
.data
[IDIAG_CTLACC_REGID_INDX
];
4911 value
= idiag
.cmd
.data
[IDIAG_CTLACC_VALUE_INDX
];
4913 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_WR
||
4914 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_ST
||
4915 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_CL
) {
4916 if (rc
!= LPFC_CTL_ACC_WR_CMD_ARG
)
4918 if (ctl_reg_id
> LPFC_CTL_MAX
)
4920 } else if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_RD
) {
4921 if (rc
!= LPFC_CTL_ACC_RD_CMD_ARG
)
4923 if ((ctl_reg_id
> LPFC_CTL_MAX
) &&
4924 (ctl_reg_id
!= LPFC_CTL_ACC_ALL
))
4929 /* Perform the write access operation */
4930 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_WR
||
4931 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_ST
||
4932 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_CL
) {
4933 switch (ctl_reg_id
) {
4934 case LPFC_CTL_PORT_SEM
:
4935 ctl_reg
= phba
->sli4_hba
.conf_regs_memmap_p
+
4936 LPFC_CTL_PORT_SEM_OFFSET
;
4938 case LPFC_CTL_PORT_STA
:
4939 ctl_reg
= phba
->sli4_hba
.conf_regs_memmap_p
+
4940 LPFC_CTL_PORT_STA_OFFSET
;
4942 case LPFC_CTL_PORT_CTL
:
4943 ctl_reg
= phba
->sli4_hba
.conf_regs_memmap_p
+
4944 LPFC_CTL_PORT_CTL_OFFSET
;
4946 case LPFC_CTL_PORT_ER1
:
4947 ctl_reg
= phba
->sli4_hba
.conf_regs_memmap_p
+
4948 LPFC_CTL_PORT_ER1_OFFSET
;
4950 case LPFC_CTL_PORT_ER2
:
4951 ctl_reg
= phba
->sli4_hba
.conf_regs_memmap_p
+
4952 LPFC_CTL_PORT_ER2_OFFSET
;
4954 case LPFC_CTL_PDEV_CTL
:
4955 ctl_reg
= phba
->sli4_hba
.conf_regs_memmap_p
+
4956 LPFC_CTL_PDEV_CTL_OFFSET
;
4962 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_WR
)
4964 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_ST
) {
4965 reg_val
= readl(ctl_reg
);
4968 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_CL
) {
4969 reg_val
= readl(ctl_reg
);
4972 writel(reg_val
, ctl_reg
);
4973 readl(ctl_reg
); /* flush */
4978 /* Clean out command structure on command error out */
4979 memset(&idiag
, 0, sizeof(idiag
));
4984 * lpfc_idiag_mbxacc_get_setup - idiag debugfs get mailbox access setup
4985 * @phba: Pointer to HBA context object.
4986 * @pbuffer: Pointer to data buffer.
4989 * This routine gets the driver mailbox access debugfs setup information.
4992 * This function returns the amount of data that was read (this could be less
4993 * than @nbytes if the end of the file was reached) or a negative error value.
4996 lpfc_idiag_mbxacc_get_setup(struct lpfc_hba
*phba
, char *pbuffer
)
4998 uint32_t mbx_dump_map
, mbx_dump_cnt
, mbx_word_cnt
, mbx_mbox_cmd
;
5001 mbx_mbox_cmd
= idiag
.cmd
.data
[IDIAG_MBXACC_MBCMD_INDX
];
5002 mbx_dump_map
= idiag
.cmd
.data
[IDIAG_MBXACC_DPMAP_INDX
];
5003 mbx_dump_cnt
= idiag
.cmd
.data
[IDIAG_MBXACC_DPCNT_INDX
];
5004 mbx_word_cnt
= idiag
.cmd
.data
[IDIAG_MBXACC_WDCNT_INDX
];
5006 len
+= scnprintf(pbuffer
+len
, LPFC_MBX_ACC_BUF_SIZE
-len
,
5007 "mbx_dump_map: 0x%08x\n", mbx_dump_map
);
5008 len
+= scnprintf(pbuffer
+len
, LPFC_MBX_ACC_BUF_SIZE
-len
,
5009 "mbx_dump_cnt: %04d\n", mbx_dump_cnt
);
5010 len
+= scnprintf(pbuffer
+len
, LPFC_MBX_ACC_BUF_SIZE
-len
,
5011 "mbx_word_cnt: %04d\n", mbx_word_cnt
);
5012 len
+= scnprintf(pbuffer
+len
, LPFC_MBX_ACC_BUF_SIZE
-len
,
5013 "mbx_mbox_cmd: 0x%02x\n", mbx_mbox_cmd
);
5019 * lpfc_idiag_mbxacc_read - idiag debugfs read on mailbox access
5020 * @file: The file pointer to read from.
5021 * @buf: The buffer to copy the data to.
5022 * @nbytes: The number of bytes to read.
5023 * @ppos: The position in the file to start reading from.
5026 * This routine reads data from the @phba driver mailbox access debugfs setup
5030 * This function returns the amount of data that was read (this could be less
5031 * than @nbytes if the end of the file was reached) or a negative error value.
5034 lpfc_idiag_mbxacc_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
5037 struct lpfc_debug
*debug
= file
->private_data
;
5038 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
5042 /* This is a user read operation */
5043 debug
->op
= LPFC_IDIAG_OP_RD
;
5046 debug
->buffer
= kmalloc(LPFC_MBX_ACC_BUF_SIZE
, GFP_KERNEL
);
5049 pbuffer
= debug
->buffer
;
5054 if ((idiag
.cmd
.opcode
!= LPFC_IDIAG_CMD_MBXACC_DP
) &&
5055 (idiag
.cmd
.opcode
!= LPFC_IDIAG_BSG_MBXACC_DP
))
5058 len
= lpfc_idiag_mbxacc_get_setup(phba
, pbuffer
);
5060 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
5064 * lpfc_idiag_mbxacc_write - Syntax check and set up idiag mbxacc commands
5065 * @file: The file pointer to read from.
5066 * @buf: The buffer to copy the user data from.
5067 * @nbytes: The number of bytes to get.
5068 * @ppos: The position in the file to start reading from.
5070 * This routine get the debugfs idiag command struct from user space and then
5071 * perform the syntax check for driver mailbox command (dump) and sets up the
5072 * necessary states in the idiag command struct accordingly.
5074 * It returns the @nbytges passing in from debugfs user space when successful.
5075 * In case of error conditions, it returns proper error code back to the user
5079 lpfc_idiag_mbxacc_write(struct file
*file
, const char __user
*buf
,
5080 size_t nbytes
, loff_t
*ppos
)
5082 struct lpfc_debug
*debug
= file
->private_data
;
5083 uint32_t mbx_dump_map
, mbx_dump_cnt
, mbx_word_cnt
, mbx_mbox_cmd
;
5086 /* This is a user write operation */
5087 debug
->op
= LPFC_IDIAG_OP_WR
;
5089 rc
= lpfc_idiag_cmd_get(buf
, nbytes
, &idiag
.cmd
);
5093 /* Sanity check on command line arguments */
5094 mbx_mbox_cmd
= idiag
.cmd
.data
[IDIAG_MBXACC_MBCMD_INDX
];
5095 mbx_dump_map
= idiag
.cmd
.data
[IDIAG_MBXACC_DPMAP_INDX
];
5096 mbx_dump_cnt
= idiag
.cmd
.data
[IDIAG_MBXACC_DPCNT_INDX
];
5097 mbx_word_cnt
= idiag
.cmd
.data
[IDIAG_MBXACC_WDCNT_INDX
];
5099 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_MBXACC_DP
) {
5100 if (!(mbx_dump_map
& LPFC_MBX_DMP_MBX_ALL
))
5102 if ((mbx_dump_map
& ~LPFC_MBX_DMP_MBX_ALL
) &&
5103 (mbx_dump_map
!= LPFC_MBX_DMP_ALL
))
5105 if (mbx_word_cnt
> sizeof(MAILBOX_t
))
5107 } else if (idiag
.cmd
.opcode
== LPFC_IDIAG_BSG_MBXACC_DP
) {
5108 if (!(mbx_dump_map
& LPFC_BSG_DMP_MBX_ALL
))
5110 if ((mbx_dump_map
& ~LPFC_BSG_DMP_MBX_ALL
) &&
5111 (mbx_dump_map
!= LPFC_MBX_DMP_ALL
))
5113 if (mbx_word_cnt
> (BSG_MBOX_SIZE
)/4)
5115 if (mbx_mbox_cmd
!= 0x9b)
5120 if (mbx_word_cnt
== 0)
5122 if (rc
!= LPFC_MBX_DMP_ARG
)
5124 if (mbx_mbox_cmd
& ~0xff)
5127 /* condition for stop mailbox dump */
5128 if (mbx_dump_cnt
== 0)
5134 /* Clean out command structure on command error out */
5135 memset(&idiag
, 0, sizeof(idiag
));
5139 /* Clean out command structure on command error out */
5140 memset(&idiag
, 0, sizeof(idiag
));
5145 * lpfc_idiag_extacc_avail_get - get the available extents information
5146 * @phba: pointer to lpfc hba data structure.
5147 * @pbuffer: pointer to internal buffer.
5148 * @len: length into the internal buffer data has been copied.
5151 * This routine is to get the available extent information.
5154 * overall lenth of the data read into the internal buffer.
5157 lpfc_idiag_extacc_avail_get(struct lpfc_hba
*phba
, char *pbuffer
, int len
)
5159 uint16_t ext_cnt
, ext_size
;
5161 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
5162 "\nAvailable Extents Information:\n");
5164 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
5165 "\tPort Available VPI extents: ");
5166 lpfc_sli4_get_avail_extnt_rsrc(phba
, LPFC_RSC_TYPE_FCOE_VPI
,
5167 &ext_cnt
, &ext_size
);
5168 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
5169 "Count %3d, Size %3d\n", ext_cnt
, ext_size
);
5171 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
5172 "\tPort Available VFI extents: ");
5173 lpfc_sli4_get_avail_extnt_rsrc(phba
, LPFC_RSC_TYPE_FCOE_VFI
,
5174 &ext_cnt
, &ext_size
);
5175 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
5176 "Count %3d, Size %3d\n", ext_cnt
, ext_size
);
5178 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
5179 "\tPort Available RPI extents: ");
5180 lpfc_sli4_get_avail_extnt_rsrc(phba
, LPFC_RSC_TYPE_FCOE_RPI
,
5181 &ext_cnt
, &ext_size
);
5182 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
5183 "Count %3d, Size %3d\n", ext_cnt
, ext_size
);
5185 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
5186 "\tPort Available XRI extents: ");
5187 lpfc_sli4_get_avail_extnt_rsrc(phba
, LPFC_RSC_TYPE_FCOE_XRI
,
5188 &ext_cnt
, &ext_size
);
5189 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
5190 "Count %3d, Size %3d\n", ext_cnt
, ext_size
);
5196 * lpfc_idiag_extacc_alloc_get - get the allocated extents information
5197 * @phba: pointer to lpfc hba data structure.
5198 * @pbuffer: pointer to internal buffer.
5199 * @len: length into the internal buffer data has been copied.
5202 * This routine is to get the allocated extent information.
5205 * overall lenth of the data read into the internal buffer.
5208 lpfc_idiag_extacc_alloc_get(struct lpfc_hba
*phba
, char *pbuffer
, int len
)
5210 uint16_t ext_cnt
, ext_size
;
5213 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
5214 "\nAllocated Extents Information:\n");
5216 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
5217 "\tHost Allocated VPI extents: ");
5218 rc
= lpfc_sli4_get_allocated_extnts(phba
, LPFC_RSC_TYPE_FCOE_VPI
,
5219 &ext_cnt
, &ext_size
);
5221 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
5222 "Port %d Extent %3d, Size %3d\n",
5223 phba
->brd_no
, ext_cnt
, ext_size
);
5225 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
5228 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
5229 "\tHost Allocated VFI extents: ");
5230 rc
= lpfc_sli4_get_allocated_extnts(phba
, LPFC_RSC_TYPE_FCOE_VFI
,
5231 &ext_cnt
, &ext_size
);
5233 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
5234 "Port %d Extent %3d, Size %3d\n",
5235 phba
->brd_no
, ext_cnt
, ext_size
);
5237 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
5240 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
5241 "\tHost Allocated RPI extents: ");
5242 rc
= lpfc_sli4_get_allocated_extnts(phba
, LPFC_RSC_TYPE_FCOE_RPI
,
5243 &ext_cnt
, &ext_size
);
5245 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
5246 "Port %d Extent %3d, Size %3d\n",
5247 phba
->brd_no
, ext_cnt
, ext_size
);
5249 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
5252 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
5253 "\tHost Allocated XRI extents: ");
5254 rc
= lpfc_sli4_get_allocated_extnts(phba
, LPFC_RSC_TYPE_FCOE_XRI
,
5255 &ext_cnt
, &ext_size
);
5257 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
5258 "Port %d Extent %3d, Size %3d\n",
5259 phba
->brd_no
, ext_cnt
, ext_size
);
5261 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
5268 * lpfc_idiag_extacc_drivr_get - get driver extent information
5269 * @phba: pointer to lpfc hba data structure.
5270 * @pbuffer: pointer to internal buffer.
5271 * @len: length into the internal buffer data has been copied.
5274 * This routine is to get the driver extent information.
5277 * overall lenth of the data read into the internal buffer.
5280 lpfc_idiag_extacc_drivr_get(struct lpfc_hba
*phba
, char *pbuffer
, int len
)
5282 struct lpfc_rsrc_blks
*rsrc_blks
;
5285 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
5286 "\nDriver Extents Information:\n");
5288 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
5289 "\tVPI extents:\n");
5291 list_for_each_entry(rsrc_blks
, &phba
->lpfc_vpi_blk_list
, list
) {
5292 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
5293 "\t\tBlock %3d: Start %4d, Count %4d\n",
5294 index
, rsrc_blks
->rsrc_start
,
5295 rsrc_blks
->rsrc_size
);
5298 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
5299 "\tVFI extents:\n");
5301 list_for_each_entry(rsrc_blks
, &phba
->sli4_hba
.lpfc_vfi_blk_list
,
5303 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
5304 "\t\tBlock %3d: Start %4d, Count %4d\n",
5305 index
, rsrc_blks
->rsrc_start
,
5306 rsrc_blks
->rsrc_size
);
5310 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
5311 "\tRPI extents:\n");
5313 list_for_each_entry(rsrc_blks
, &phba
->sli4_hba
.lpfc_rpi_blk_list
,
5315 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
5316 "\t\tBlock %3d: Start %4d, Count %4d\n",
5317 index
, rsrc_blks
->rsrc_start
,
5318 rsrc_blks
->rsrc_size
);
5322 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
5323 "\tXRI extents:\n");
5325 list_for_each_entry(rsrc_blks
, &phba
->sli4_hba
.lpfc_xri_blk_list
,
5327 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
5328 "\t\tBlock %3d: Start %4d, Count %4d\n",
5329 index
, rsrc_blks
->rsrc_start
,
5330 rsrc_blks
->rsrc_size
);
5338 * lpfc_idiag_extacc_write - Syntax check and set up idiag extacc commands
5339 * @file: The file pointer to read from.
5340 * @buf: The buffer to copy the user data from.
5341 * @nbytes: The number of bytes to get.
5342 * @ppos: The position in the file to start reading from.
5344 * This routine get the debugfs idiag command struct from user space and then
5345 * perform the syntax check for extent information access commands and sets
5346 * up the necessary states in the idiag command struct accordingly.
5348 * It returns the @nbytges passing in from debugfs user space when successful.
5349 * In case of error conditions, it returns proper error code back to the user
5353 lpfc_idiag_extacc_write(struct file
*file
, const char __user
*buf
,
5354 size_t nbytes
, loff_t
*ppos
)
5356 struct lpfc_debug
*debug
= file
->private_data
;
5360 /* This is a user write operation */
5361 debug
->op
= LPFC_IDIAG_OP_WR
;
5363 rc
= lpfc_idiag_cmd_get(buf
, nbytes
, &idiag
.cmd
);
5367 ext_map
= idiag
.cmd
.data
[IDIAG_EXTACC_EXMAP_INDX
];
5369 if (idiag
.cmd
.opcode
!= LPFC_IDIAG_CMD_EXTACC_RD
)
5371 if (rc
!= LPFC_EXT_ACC_CMD_ARG
)
5373 if (!(ext_map
& LPFC_EXT_ACC_ALL
))
5378 /* Clean out command structure on command error out */
5379 memset(&idiag
, 0, sizeof(idiag
));
5384 * lpfc_idiag_extacc_read - idiag debugfs read access to extent information
5385 * @file: The file pointer to read from.
5386 * @buf: The buffer to copy the data to.
5387 * @nbytes: The number of bytes to read.
5388 * @ppos: The position in the file to start reading from.
5391 * This routine reads data from the proper extent information according to
5392 * the idiag command, and copies to user @buf.
5395 * This function returns the amount of data that was read (this could be less
5396 * than @nbytes if the end of the file was reached) or a negative error value.
5399 lpfc_idiag_extacc_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
5402 struct lpfc_debug
*debug
= file
->private_data
;
5403 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
5408 /* This is a user read operation */
5409 debug
->op
= LPFC_IDIAG_OP_RD
;
5412 debug
->buffer
= kmalloc(LPFC_EXT_ACC_BUF_SIZE
, GFP_KERNEL
);
5415 pbuffer
= debug
->buffer
;
5418 if (idiag
.cmd
.opcode
!= LPFC_IDIAG_CMD_EXTACC_RD
)
5421 ext_map
= idiag
.cmd
.data
[IDIAG_EXTACC_EXMAP_INDX
];
5422 if (ext_map
& LPFC_EXT_ACC_AVAIL
)
5423 len
= lpfc_idiag_extacc_avail_get(phba
, pbuffer
, len
);
5424 if (ext_map
& LPFC_EXT_ACC_ALLOC
)
5425 len
= lpfc_idiag_extacc_alloc_get(phba
, pbuffer
, len
);
5426 if (ext_map
& LPFC_EXT_ACC_DRIVR
)
5427 len
= lpfc_idiag_extacc_drivr_get(phba
, pbuffer
, len
);
5429 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
5432 #undef lpfc_debugfs_op_disc_trc
5433 static const struct file_operations lpfc_debugfs_op_disc_trc
= {
5434 .owner
= THIS_MODULE
,
5435 .open
= lpfc_debugfs_disc_trc_open
,
5436 .llseek
= lpfc_debugfs_lseek
,
5437 .read
= lpfc_debugfs_read
,
5438 .release
= lpfc_debugfs_release
,
5441 #undef lpfc_debugfs_op_nodelist
5442 static const struct file_operations lpfc_debugfs_op_nodelist
= {
5443 .owner
= THIS_MODULE
,
5444 .open
= lpfc_debugfs_nodelist_open
,
5445 .llseek
= lpfc_debugfs_lseek
,
5446 .read
= lpfc_debugfs_read
,
5447 .release
= lpfc_debugfs_release
,
5450 #undef lpfc_debugfs_op_multixripools
5451 static const struct file_operations lpfc_debugfs_op_multixripools
= {
5452 .owner
= THIS_MODULE
,
5453 .open
= lpfc_debugfs_multixripools_open
,
5454 .llseek
= lpfc_debugfs_lseek
,
5455 .read
= lpfc_debugfs_read
,
5456 .write
= lpfc_debugfs_multixripools_write
,
5457 .release
= lpfc_debugfs_release
,
5460 #undef lpfc_debugfs_op_hbqinfo
5461 static const struct file_operations lpfc_debugfs_op_hbqinfo
= {
5462 .owner
= THIS_MODULE
,
5463 .open
= lpfc_debugfs_hbqinfo_open
,
5464 .llseek
= lpfc_debugfs_lseek
,
5465 .read
= lpfc_debugfs_read
,
5466 .release
= lpfc_debugfs_release
,
5469 #ifdef LPFC_HDWQ_LOCK_STAT
5470 #undef lpfc_debugfs_op_lockstat
5471 static const struct file_operations lpfc_debugfs_op_lockstat
= {
5472 .owner
= THIS_MODULE
,
5473 .open
= lpfc_debugfs_lockstat_open
,
5474 .llseek
= lpfc_debugfs_lseek
,
5475 .read
= lpfc_debugfs_read
,
5476 .write
= lpfc_debugfs_lockstat_write
,
5477 .release
= lpfc_debugfs_release
,
5481 #undef lpfc_debugfs_ras_log
5482 static const struct file_operations lpfc_debugfs_ras_log
= {
5483 .owner
= THIS_MODULE
,
5484 .open
= lpfc_debugfs_ras_log_open
,
5485 .llseek
= lpfc_debugfs_lseek
,
5486 .read
= lpfc_debugfs_read
,
5487 .release
= lpfc_debugfs_ras_log_release
,
5490 #undef lpfc_debugfs_op_dumpHBASlim
5491 static const struct file_operations lpfc_debugfs_op_dumpHBASlim
= {
5492 .owner
= THIS_MODULE
,
5493 .open
= lpfc_debugfs_dumpHBASlim_open
,
5494 .llseek
= lpfc_debugfs_lseek
,
5495 .read
= lpfc_debugfs_read
,
5496 .release
= lpfc_debugfs_release
,
5499 #undef lpfc_debugfs_op_dumpHostSlim
5500 static const struct file_operations lpfc_debugfs_op_dumpHostSlim
= {
5501 .owner
= THIS_MODULE
,
5502 .open
= lpfc_debugfs_dumpHostSlim_open
,
5503 .llseek
= lpfc_debugfs_lseek
,
5504 .read
= lpfc_debugfs_read
,
5505 .release
= lpfc_debugfs_release
,
5508 #undef lpfc_debugfs_op_nvmestat
5509 static const struct file_operations lpfc_debugfs_op_nvmestat
= {
5510 .owner
= THIS_MODULE
,
5511 .open
= lpfc_debugfs_nvmestat_open
,
5512 .llseek
= lpfc_debugfs_lseek
,
5513 .read
= lpfc_debugfs_read
,
5514 .write
= lpfc_debugfs_nvmestat_write
,
5515 .release
= lpfc_debugfs_release
,
5518 #undef lpfc_debugfs_op_scsistat
5519 static const struct file_operations lpfc_debugfs_op_scsistat
= {
5520 .owner
= THIS_MODULE
,
5521 .open
= lpfc_debugfs_scsistat_open
,
5522 .llseek
= lpfc_debugfs_lseek
,
5523 .read
= lpfc_debugfs_read
,
5524 .write
= lpfc_debugfs_scsistat_write
,
5525 .release
= lpfc_debugfs_release
,
5528 #undef lpfc_debugfs_op_ioktime
5529 static const struct file_operations lpfc_debugfs_op_ioktime
= {
5530 .owner
= THIS_MODULE
,
5531 .open
= lpfc_debugfs_ioktime_open
,
5532 .llseek
= lpfc_debugfs_lseek
,
5533 .read
= lpfc_debugfs_read
,
5534 .write
= lpfc_debugfs_ioktime_write
,
5535 .release
= lpfc_debugfs_release
,
5538 #undef lpfc_debugfs_op_nvmeio_trc
5539 static const struct file_operations lpfc_debugfs_op_nvmeio_trc
= {
5540 .owner
= THIS_MODULE
,
5541 .open
= lpfc_debugfs_nvmeio_trc_open
,
5542 .llseek
= lpfc_debugfs_lseek
,
5543 .read
= lpfc_debugfs_read
,
5544 .write
= lpfc_debugfs_nvmeio_trc_write
,
5545 .release
= lpfc_debugfs_release
,
5548 #undef lpfc_debugfs_op_hdwqstat
5549 static const struct file_operations lpfc_debugfs_op_hdwqstat
= {
5550 .owner
= THIS_MODULE
,
5551 .open
= lpfc_debugfs_hdwqstat_open
,
5552 .llseek
= lpfc_debugfs_lseek
,
5553 .read
= lpfc_debugfs_read
,
5554 .write
= lpfc_debugfs_hdwqstat_write
,
5555 .release
= lpfc_debugfs_release
,
5558 #undef lpfc_debugfs_op_dif_err
5559 static const struct file_operations lpfc_debugfs_op_dif_err
= {
5560 .owner
= THIS_MODULE
,
5561 .open
= simple_open
,
5562 .llseek
= lpfc_debugfs_lseek
,
5563 .read
= lpfc_debugfs_dif_err_read
,
5564 .write
= lpfc_debugfs_dif_err_write
,
5565 .release
= lpfc_debugfs_dif_err_release
,
5568 #undef lpfc_debugfs_op_slow_ring_trc
5569 static const struct file_operations lpfc_debugfs_op_slow_ring_trc
= {
5570 .owner
= THIS_MODULE
,
5571 .open
= lpfc_debugfs_slow_ring_trc_open
,
5572 .llseek
= lpfc_debugfs_lseek
,
5573 .read
= lpfc_debugfs_read
,
5574 .release
= lpfc_debugfs_release
,
5577 static struct dentry
*lpfc_debugfs_root
= NULL
;
5578 static atomic_t lpfc_debugfs_hba_count
;
5581 * File operations for the iDiag debugfs
5583 #undef lpfc_idiag_op_pciCfg
5584 static const struct file_operations lpfc_idiag_op_pciCfg
= {
5585 .owner
= THIS_MODULE
,
5586 .open
= lpfc_idiag_open
,
5587 .llseek
= lpfc_debugfs_lseek
,
5588 .read
= lpfc_idiag_pcicfg_read
,
5589 .write
= lpfc_idiag_pcicfg_write
,
5590 .release
= lpfc_idiag_cmd_release
,
5593 #undef lpfc_idiag_op_barAcc
5594 static const struct file_operations lpfc_idiag_op_barAcc
= {
5595 .owner
= THIS_MODULE
,
5596 .open
= lpfc_idiag_open
,
5597 .llseek
= lpfc_debugfs_lseek
,
5598 .read
= lpfc_idiag_baracc_read
,
5599 .write
= lpfc_idiag_baracc_write
,
5600 .release
= lpfc_idiag_cmd_release
,
5603 #undef lpfc_idiag_op_queInfo
5604 static const struct file_operations lpfc_idiag_op_queInfo
= {
5605 .owner
= THIS_MODULE
,
5606 .open
= lpfc_idiag_open
,
5607 .read
= lpfc_idiag_queinfo_read
,
5608 .release
= lpfc_idiag_release
,
5611 #undef lpfc_idiag_op_queAcc
5612 static const struct file_operations lpfc_idiag_op_queAcc
= {
5613 .owner
= THIS_MODULE
,
5614 .open
= lpfc_idiag_open
,
5615 .llseek
= lpfc_debugfs_lseek
,
5616 .read
= lpfc_idiag_queacc_read
,
5617 .write
= lpfc_idiag_queacc_write
,
5618 .release
= lpfc_idiag_cmd_release
,
5621 #undef lpfc_idiag_op_drbAcc
5622 static const struct file_operations lpfc_idiag_op_drbAcc
= {
5623 .owner
= THIS_MODULE
,
5624 .open
= lpfc_idiag_open
,
5625 .llseek
= lpfc_debugfs_lseek
,
5626 .read
= lpfc_idiag_drbacc_read
,
5627 .write
= lpfc_idiag_drbacc_write
,
5628 .release
= lpfc_idiag_cmd_release
,
5631 #undef lpfc_idiag_op_ctlAcc
5632 static const struct file_operations lpfc_idiag_op_ctlAcc
= {
5633 .owner
= THIS_MODULE
,
5634 .open
= lpfc_idiag_open
,
5635 .llseek
= lpfc_debugfs_lseek
,
5636 .read
= lpfc_idiag_ctlacc_read
,
5637 .write
= lpfc_idiag_ctlacc_write
,
5638 .release
= lpfc_idiag_cmd_release
,
5641 #undef lpfc_idiag_op_mbxAcc
5642 static const struct file_operations lpfc_idiag_op_mbxAcc
= {
5643 .owner
= THIS_MODULE
,
5644 .open
= lpfc_idiag_open
,
5645 .llseek
= lpfc_debugfs_lseek
,
5646 .read
= lpfc_idiag_mbxacc_read
,
5647 .write
= lpfc_idiag_mbxacc_write
,
5648 .release
= lpfc_idiag_cmd_release
,
5651 #undef lpfc_idiag_op_extAcc
5652 static const struct file_operations lpfc_idiag_op_extAcc
= {
5653 .owner
= THIS_MODULE
,
5654 .open
= lpfc_idiag_open
,
5655 .llseek
= lpfc_debugfs_lseek
,
5656 .read
= lpfc_idiag_extacc_read
,
5657 .write
= lpfc_idiag_extacc_write
,
5658 .release
= lpfc_idiag_cmd_release
,
5662 /* lpfc_idiag_mbxacc_dump_bsg_mbox - idiag debugfs dump bsg mailbox command
5663 * @phba: Pointer to HBA context object.
5664 * @dmabuf: Pointer to a DMA buffer descriptor.
5667 * This routine dump a bsg pass-through non-embedded mailbox command with
5671 lpfc_idiag_mbxacc_dump_bsg_mbox(struct lpfc_hba
*phba
, enum nemb_type nemb_tp
,
5672 enum mbox_type mbox_tp
, enum dma_type dma_tp
,
5673 enum sta_type sta_tp
,
5674 struct lpfc_dmabuf
*dmabuf
, uint32_t ext_buf
)
5676 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
5677 uint32_t *mbx_mbox_cmd
, *mbx_dump_map
, *mbx_dump_cnt
, *mbx_word_cnt
;
5678 char line_buf
[LPFC_MBX_ACC_LBUF_SZ
];
5680 uint32_t do_dump
= 0;
5684 if (idiag
.cmd
.opcode
!= LPFC_IDIAG_BSG_MBXACC_DP
)
5687 mbx_mbox_cmd
= &idiag
.cmd
.data
[IDIAG_MBXACC_MBCMD_INDX
];
5688 mbx_dump_map
= &idiag
.cmd
.data
[IDIAG_MBXACC_DPMAP_INDX
];
5689 mbx_dump_cnt
= &idiag
.cmd
.data
[IDIAG_MBXACC_DPCNT_INDX
];
5690 mbx_word_cnt
= &idiag
.cmd
.data
[IDIAG_MBXACC_WDCNT_INDX
];
5692 if (!(*mbx_dump_map
& LPFC_MBX_DMP_ALL
) ||
5693 (*mbx_dump_cnt
== 0) ||
5694 (*mbx_word_cnt
== 0))
5697 if (*mbx_mbox_cmd
!= 0x9B)
5700 if ((mbox_tp
== mbox_rd
) && (dma_tp
== dma_mbox
)) {
5701 if (*mbx_dump_map
& LPFC_BSG_DMP_MBX_RD_MBX
) {
5702 do_dump
|= LPFC_BSG_DMP_MBX_RD_MBX
;
5703 pr_err("\nRead mbox command (x%x), "
5704 "nemb:0x%x, extbuf_cnt:%d:\n",
5705 sta_tp
, nemb_tp
, ext_buf
);
5708 if ((mbox_tp
== mbox_rd
) && (dma_tp
== dma_ebuf
)) {
5709 if (*mbx_dump_map
& LPFC_BSG_DMP_MBX_RD_BUF
) {
5710 do_dump
|= LPFC_BSG_DMP_MBX_RD_BUF
;
5711 pr_err("\nRead mbox buffer (x%x), "
5712 "nemb:0x%x, extbuf_seq:%d:\n",
5713 sta_tp
, nemb_tp
, ext_buf
);
5716 if ((mbox_tp
== mbox_wr
) && (dma_tp
== dma_mbox
)) {
5717 if (*mbx_dump_map
& LPFC_BSG_DMP_MBX_WR_MBX
) {
5718 do_dump
|= LPFC_BSG_DMP_MBX_WR_MBX
;
5719 pr_err("\nWrite mbox command (x%x), "
5720 "nemb:0x%x, extbuf_cnt:%d:\n",
5721 sta_tp
, nemb_tp
, ext_buf
);
5724 if ((mbox_tp
== mbox_wr
) && (dma_tp
== dma_ebuf
)) {
5725 if (*mbx_dump_map
& LPFC_BSG_DMP_MBX_WR_BUF
) {
5726 do_dump
|= LPFC_BSG_DMP_MBX_WR_BUF
;
5727 pr_err("\nWrite mbox buffer (x%x), "
5728 "nemb:0x%x, extbuf_seq:%d:\n",
5729 sta_tp
, nemb_tp
, ext_buf
);
5733 /* dump buffer content */
5735 pword
= (uint32_t *)dmabuf
->virt
;
5736 for (i
= 0; i
< *mbx_word_cnt
; i
++) {
5739 pr_err("%s\n", line_buf
);
5741 len
+= scnprintf(line_buf
+len
,
5742 LPFC_MBX_ACC_LBUF_SZ
-len
,
5745 len
+= scnprintf(line_buf
+len
, LPFC_MBX_ACC_LBUF_SZ
-len
,
5746 "%08x ", (uint32_t)*pword
);
5750 pr_err("%s\n", line_buf
);
5754 /* Clean out command structure on reaching dump count */
5755 if (*mbx_dump_cnt
== 0)
5756 memset(&idiag
, 0, sizeof(idiag
));
5761 /* lpfc_idiag_mbxacc_dump_issue_mbox - idiag debugfs dump issue mailbox command
5762 * @phba: Pointer to HBA context object.
5763 * @dmabuf: Pointer to a DMA buffer descriptor.
5766 * This routine dump a pass-through non-embedded mailbox command from issue
5770 lpfc_idiag_mbxacc_dump_issue_mbox(struct lpfc_hba
*phba
, MAILBOX_t
*pmbox
)
5772 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
5773 uint32_t *mbx_dump_map
, *mbx_dump_cnt
, *mbx_word_cnt
, *mbx_mbox_cmd
;
5774 char line_buf
[LPFC_MBX_ACC_LBUF_SZ
];
5780 if (idiag
.cmd
.opcode
!= LPFC_IDIAG_CMD_MBXACC_DP
)
5783 mbx_mbox_cmd
= &idiag
.cmd
.data
[IDIAG_MBXACC_MBCMD_INDX
];
5784 mbx_dump_map
= &idiag
.cmd
.data
[IDIAG_MBXACC_DPMAP_INDX
];
5785 mbx_dump_cnt
= &idiag
.cmd
.data
[IDIAG_MBXACC_DPCNT_INDX
];
5786 mbx_word_cnt
= &idiag
.cmd
.data
[IDIAG_MBXACC_WDCNT_INDX
];
5788 if (!(*mbx_dump_map
& LPFC_MBX_DMP_MBX_ALL
) ||
5789 (*mbx_dump_cnt
== 0) ||
5790 (*mbx_word_cnt
== 0))
5793 if ((*mbx_mbox_cmd
!= LPFC_MBX_ALL_CMD
) &&
5794 (*mbx_mbox_cmd
!= pmbox
->mbxCommand
))
5797 /* dump buffer content */
5798 if (*mbx_dump_map
& LPFC_MBX_DMP_MBX_WORD
) {
5799 pr_err("Mailbox command:0x%x dump by word:\n",
5801 pword
= (uint32_t *)pmbox
;
5802 for (i
= 0; i
< *mbx_word_cnt
; i
++) {
5805 pr_err("%s\n", line_buf
);
5807 memset(line_buf
, 0, LPFC_MBX_ACC_LBUF_SZ
);
5808 len
+= scnprintf(line_buf
+len
,
5809 LPFC_MBX_ACC_LBUF_SZ
-len
,
5812 len
+= scnprintf(line_buf
+len
, LPFC_MBX_ACC_LBUF_SZ
-len
,
5814 ((uint32_t)*pword
) & 0xffffffff);
5818 pr_err("%s\n", line_buf
);
5821 if (*mbx_dump_map
& LPFC_MBX_DMP_MBX_BYTE
) {
5822 pr_err("Mailbox command:0x%x dump by byte:\n",
5824 pbyte
= (uint8_t *)pmbox
;
5825 for (i
= 0; i
< *mbx_word_cnt
; i
++) {
5828 pr_err("%s\n", line_buf
);
5830 memset(line_buf
, 0, LPFC_MBX_ACC_LBUF_SZ
);
5831 len
+= scnprintf(line_buf
+len
,
5832 LPFC_MBX_ACC_LBUF_SZ
-len
,
5835 for (j
= 0; j
< 4; j
++) {
5836 len
+= scnprintf(line_buf
+len
,
5837 LPFC_MBX_ACC_LBUF_SZ
-len
,
5839 ((uint8_t)*pbyte
) & 0xff);
5842 len
+= scnprintf(line_buf
+len
,
5843 LPFC_MBX_ACC_LBUF_SZ
-len
, " ");
5846 pr_err("%s\n", line_buf
);
5851 /* Clean out command structure on reaching dump count */
5852 if (*mbx_dump_cnt
== 0)
5853 memset(&idiag
, 0, sizeof(idiag
));
5859 * lpfc_debugfs_initialize - Initialize debugfs for a vport
5860 * @vport: The vport pointer to initialize.
5863 * When Debugfs is configured this routine sets up the lpfc debugfs file system.
5864 * If not already created, this routine will create the lpfc directory, and
5865 * lpfcX directory (for this HBA), and vportX directory for this vport. It will
5866 * also create each file used to access lpfc specific debugfs information.
5869 lpfc_debugfs_initialize(struct lpfc_vport
*vport
)
5871 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
5872 struct lpfc_hba
*phba
= vport
->phba
;
5875 bool pport_setup
= false;
5877 if (!lpfc_debugfs_enable
)
5880 /* Setup lpfc root directory */
5881 if (!lpfc_debugfs_root
) {
5882 lpfc_debugfs_root
= debugfs_create_dir("lpfc", NULL
);
5883 atomic_set(&lpfc_debugfs_hba_count
, 0);
5885 if (!lpfc_debugfs_start_time
)
5886 lpfc_debugfs_start_time
= jiffies
;
5888 /* Setup funcX directory for specific HBA PCI function */
5889 snprintf(name
, sizeof(name
), "fn%d", phba
->brd_no
);
5890 if (!phba
->hba_debugfs_root
) {
5892 phba
->hba_debugfs_root
=
5893 debugfs_create_dir(name
, lpfc_debugfs_root
);
5894 atomic_inc(&lpfc_debugfs_hba_count
);
5895 atomic_set(&phba
->debugfs_vport_count
, 0);
5897 /* Multi-XRI pools */
5898 snprintf(name
, sizeof(name
), "multixripools");
5899 phba
->debug_multixri_pools
=
5900 debugfs_create_file(name
, S_IFREG
| 0644,
5901 phba
->hba_debugfs_root
,
5903 &lpfc_debugfs_op_multixripools
);
5904 if (!phba
->debug_multixri_pools
) {
5905 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5906 "0527 Cannot create debugfs multixripools\n");
5911 snprintf(name
, sizeof(name
), "ras_log");
5912 phba
->debug_ras_log
=
5913 debugfs_create_file(name
, 0644,
5914 phba
->hba_debugfs_root
,
5915 phba
, &lpfc_debugfs_ras_log
);
5916 if (!phba
->debug_ras_log
) {
5917 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5918 "6148 Cannot create debugfs"
5924 snprintf(name
, sizeof(name
), "hbqinfo");
5925 phba
->debug_hbqinfo
=
5926 debugfs_create_file(name
, S_IFREG
| 0644,
5927 phba
->hba_debugfs_root
,
5928 phba
, &lpfc_debugfs_op_hbqinfo
);
5930 #ifdef LPFC_HDWQ_LOCK_STAT
5931 /* Setup lockstat */
5932 snprintf(name
, sizeof(name
), "lockstat");
5933 phba
->debug_lockstat
=
5934 debugfs_create_file(name
, S_IFREG
| 0644,
5935 phba
->hba_debugfs_root
,
5936 phba
, &lpfc_debugfs_op_lockstat
);
5937 if (!phba
->debug_lockstat
) {
5938 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5939 "4610 Can't create debugfs lockstat\n");
5944 /* Setup dumpHBASlim */
5945 if (phba
->sli_rev
< LPFC_SLI_REV4
) {
5946 snprintf(name
, sizeof(name
), "dumpHBASlim");
5947 phba
->debug_dumpHBASlim
=
5948 debugfs_create_file(name
,
5949 S_IFREG
|S_IRUGO
|S_IWUSR
,
5950 phba
->hba_debugfs_root
,
5951 phba
, &lpfc_debugfs_op_dumpHBASlim
);
5953 phba
->debug_dumpHBASlim
= NULL
;
5955 /* Setup dumpHostSlim */
5956 if (phba
->sli_rev
< LPFC_SLI_REV4
) {
5957 snprintf(name
, sizeof(name
), "dumpHostSlim");
5958 phba
->debug_dumpHostSlim
=
5959 debugfs_create_file(name
,
5960 S_IFREG
|S_IRUGO
|S_IWUSR
,
5961 phba
->hba_debugfs_root
,
5962 phba
, &lpfc_debugfs_op_dumpHostSlim
);
5964 phba
->debug_dumpHostSlim
= NULL
;
5966 /* Setup DIF Error Injections */
5967 snprintf(name
, sizeof(name
), "InjErrLBA");
5968 phba
->debug_InjErrLBA
=
5969 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5970 phba
->hba_debugfs_root
,
5971 phba
, &lpfc_debugfs_op_dif_err
);
5972 phba
->lpfc_injerr_lba
= LPFC_INJERR_LBA_OFF
;
5974 snprintf(name
, sizeof(name
), "InjErrNPortID");
5975 phba
->debug_InjErrNPortID
=
5976 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5977 phba
->hba_debugfs_root
,
5978 phba
, &lpfc_debugfs_op_dif_err
);
5980 snprintf(name
, sizeof(name
), "InjErrWWPN");
5981 phba
->debug_InjErrWWPN
=
5982 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5983 phba
->hba_debugfs_root
,
5984 phba
, &lpfc_debugfs_op_dif_err
);
5986 snprintf(name
, sizeof(name
), "writeGuardInjErr");
5987 phba
->debug_writeGuard
=
5988 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5989 phba
->hba_debugfs_root
,
5990 phba
, &lpfc_debugfs_op_dif_err
);
5992 snprintf(name
, sizeof(name
), "writeAppInjErr");
5993 phba
->debug_writeApp
=
5994 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5995 phba
->hba_debugfs_root
,
5996 phba
, &lpfc_debugfs_op_dif_err
);
5998 snprintf(name
, sizeof(name
), "writeRefInjErr");
5999 phba
->debug_writeRef
=
6000 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
6001 phba
->hba_debugfs_root
,
6002 phba
, &lpfc_debugfs_op_dif_err
);
6004 snprintf(name
, sizeof(name
), "readGuardInjErr");
6005 phba
->debug_readGuard
=
6006 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
6007 phba
->hba_debugfs_root
,
6008 phba
, &lpfc_debugfs_op_dif_err
);
6010 snprintf(name
, sizeof(name
), "readAppInjErr");
6011 phba
->debug_readApp
=
6012 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
6013 phba
->hba_debugfs_root
,
6014 phba
, &lpfc_debugfs_op_dif_err
);
6016 snprintf(name
, sizeof(name
), "readRefInjErr");
6017 phba
->debug_readRef
=
6018 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
6019 phba
->hba_debugfs_root
,
6020 phba
, &lpfc_debugfs_op_dif_err
);
6022 /* Setup slow ring trace */
6023 if (lpfc_debugfs_max_slow_ring_trc
) {
6024 num
= lpfc_debugfs_max_slow_ring_trc
- 1;
6025 if (num
& lpfc_debugfs_max_slow_ring_trc
) {
6026 /* Change to be a power of 2 */
6027 num
= lpfc_debugfs_max_slow_ring_trc
;
6033 lpfc_debugfs_max_slow_ring_trc
= (1 << i
);
6034 pr_err("lpfc_debugfs_max_disc_trc changed to "
6035 "%d\n", lpfc_debugfs_max_disc_trc
);
6039 snprintf(name
, sizeof(name
), "slow_ring_trace");
6040 phba
->debug_slow_ring_trc
=
6041 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
6042 phba
->hba_debugfs_root
,
6043 phba
, &lpfc_debugfs_op_slow_ring_trc
);
6044 if (!phba
->slow_ring_trc
) {
6045 phba
->slow_ring_trc
= kmalloc(
6046 (sizeof(struct lpfc_debugfs_trc
) *
6047 lpfc_debugfs_max_slow_ring_trc
),
6049 if (!phba
->slow_ring_trc
) {
6050 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
6051 "0416 Cannot create debugfs "
6052 "slow_ring buffer\n");
6055 atomic_set(&phba
->slow_ring_trc_cnt
, 0);
6056 memset(phba
->slow_ring_trc
, 0,
6057 (sizeof(struct lpfc_debugfs_trc
) *
6058 lpfc_debugfs_max_slow_ring_trc
));
6061 snprintf(name
, sizeof(name
), "nvmeio_trc");
6062 phba
->debug_nvmeio_trc
=
6063 debugfs_create_file(name
, 0644,
6064 phba
->hba_debugfs_root
,
6065 phba
, &lpfc_debugfs_op_nvmeio_trc
);
6067 atomic_set(&phba
->nvmeio_trc_cnt
, 0);
6068 if (lpfc_debugfs_max_nvmeio_trc
) {
6069 num
= lpfc_debugfs_max_nvmeio_trc
- 1;
6070 if (num
& lpfc_debugfs_max_disc_trc
) {
6071 /* Change to be a power of 2 */
6072 num
= lpfc_debugfs_max_nvmeio_trc
;
6078 lpfc_debugfs_max_nvmeio_trc
= (1 << i
);
6079 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
6080 "0575 lpfc_debugfs_max_nvmeio_trc "
6082 lpfc_debugfs_max_nvmeio_trc
);
6084 phba
->nvmeio_trc_size
= lpfc_debugfs_max_nvmeio_trc
;
6086 /* Allocate trace buffer and initialize */
6087 phba
->nvmeio_trc
= kzalloc(
6088 (sizeof(struct lpfc_debugfs_nvmeio_trc
) *
6089 phba
->nvmeio_trc_size
), GFP_KERNEL
);
6091 if (!phba
->nvmeio_trc
) {
6092 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
6093 "0576 Cannot create debugfs "
6094 "nvmeio_trc buffer\n");
6097 phba
->nvmeio_trc_on
= 1;
6098 phba
->nvmeio_trc_output_idx
= 0;
6099 phba
->nvmeio_trc
= NULL
;
6102 phba
->nvmeio_trc_size
= 0;
6103 phba
->nvmeio_trc_on
= 0;
6104 phba
->nvmeio_trc_output_idx
= 0;
6105 phba
->nvmeio_trc
= NULL
;
6109 snprintf(name
, sizeof(name
), "vport%d", vport
->vpi
);
6110 if (!vport
->vport_debugfs_root
) {
6111 vport
->vport_debugfs_root
=
6112 debugfs_create_dir(name
, phba
->hba_debugfs_root
);
6113 atomic_inc(&phba
->debugfs_vport_count
);
6116 if (lpfc_debugfs_max_disc_trc
) {
6117 num
= lpfc_debugfs_max_disc_trc
- 1;
6118 if (num
& lpfc_debugfs_max_disc_trc
) {
6119 /* Change to be a power of 2 */
6120 num
= lpfc_debugfs_max_disc_trc
;
6126 lpfc_debugfs_max_disc_trc
= (1 << i
);
6127 pr_err("lpfc_debugfs_max_disc_trc changed to %d\n",
6128 lpfc_debugfs_max_disc_trc
);
6132 vport
->disc_trc
= kzalloc(
6133 (sizeof(struct lpfc_debugfs_trc
) * lpfc_debugfs_max_disc_trc
),
6136 if (!vport
->disc_trc
) {
6137 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
6138 "0418 Cannot create debugfs disc trace "
6142 atomic_set(&vport
->disc_trc_cnt
, 0);
6144 snprintf(name
, sizeof(name
), "discovery_trace");
6145 vport
->debug_disc_trc
=
6146 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
6147 vport
->vport_debugfs_root
,
6148 vport
, &lpfc_debugfs_op_disc_trc
);
6149 snprintf(name
, sizeof(name
), "nodelist");
6150 vport
->debug_nodelist
=
6151 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
6152 vport
->vport_debugfs_root
,
6153 vport
, &lpfc_debugfs_op_nodelist
);
6155 snprintf(name
, sizeof(name
), "nvmestat");
6156 vport
->debug_nvmestat
=
6157 debugfs_create_file(name
, 0644,
6158 vport
->vport_debugfs_root
,
6159 vport
, &lpfc_debugfs_op_nvmestat
);
6161 snprintf(name
, sizeof(name
), "scsistat");
6162 vport
->debug_scsistat
=
6163 debugfs_create_file(name
, 0644,
6164 vport
->vport_debugfs_root
,
6165 vport
, &lpfc_debugfs_op_scsistat
);
6166 if (!vport
->debug_scsistat
) {
6167 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
6168 "4611 Cannot create debugfs scsistat\n");
6172 snprintf(name
, sizeof(name
), "ioktime");
6173 vport
->debug_ioktime
=
6174 debugfs_create_file(name
, 0644,
6175 vport
->vport_debugfs_root
,
6176 vport
, &lpfc_debugfs_op_ioktime
);
6177 if (!vport
->debug_ioktime
) {
6178 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
6179 "0815 Cannot create debugfs ioktime\n");
6183 snprintf(name
, sizeof(name
), "hdwqstat");
6184 vport
->debug_hdwqstat
=
6185 debugfs_create_file(name
, 0644,
6186 vport
->vport_debugfs_root
,
6187 vport
, &lpfc_debugfs_op_hdwqstat
);
6190 * The following section is for additional directories/files for the
6198 * iDiag debugfs root entry points for SLI4 device only
6200 if (phba
->sli_rev
< LPFC_SLI_REV4
)
6203 snprintf(name
, sizeof(name
), "iDiag");
6204 if (!phba
->idiag_root
) {
6206 debugfs_create_dir(name
, phba
->hba_debugfs_root
);
6207 /* Initialize iDiag data structure */
6208 memset(&idiag
, 0, sizeof(idiag
));
6211 /* iDiag read PCI config space */
6212 snprintf(name
, sizeof(name
), "pciCfg");
6213 if (!phba
->idiag_pci_cfg
) {
6214 phba
->idiag_pci_cfg
=
6215 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
6216 phba
->idiag_root
, phba
, &lpfc_idiag_op_pciCfg
);
6217 idiag
.offset
.last_rd
= 0;
6220 /* iDiag PCI BAR access */
6221 snprintf(name
, sizeof(name
), "barAcc");
6222 if (!phba
->idiag_bar_acc
) {
6223 phba
->idiag_bar_acc
=
6224 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
6225 phba
->idiag_root
, phba
, &lpfc_idiag_op_barAcc
);
6226 idiag
.offset
.last_rd
= 0;
6229 /* iDiag get PCI function queue information */
6230 snprintf(name
, sizeof(name
), "queInfo");
6231 if (!phba
->idiag_que_info
) {
6232 phba
->idiag_que_info
=
6233 debugfs_create_file(name
, S_IFREG
|S_IRUGO
,
6234 phba
->idiag_root
, phba
, &lpfc_idiag_op_queInfo
);
6237 /* iDiag access PCI function queue */
6238 snprintf(name
, sizeof(name
), "queAcc");
6239 if (!phba
->idiag_que_acc
) {
6240 phba
->idiag_que_acc
=
6241 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
6242 phba
->idiag_root
, phba
, &lpfc_idiag_op_queAcc
);
6245 /* iDiag access PCI function doorbell registers */
6246 snprintf(name
, sizeof(name
), "drbAcc");
6247 if (!phba
->idiag_drb_acc
) {
6248 phba
->idiag_drb_acc
=
6249 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
6250 phba
->idiag_root
, phba
, &lpfc_idiag_op_drbAcc
);
6253 /* iDiag access PCI function control registers */
6254 snprintf(name
, sizeof(name
), "ctlAcc");
6255 if (!phba
->idiag_ctl_acc
) {
6256 phba
->idiag_ctl_acc
=
6257 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
6258 phba
->idiag_root
, phba
, &lpfc_idiag_op_ctlAcc
);
6261 /* iDiag access mbox commands */
6262 snprintf(name
, sizeof(name
), "mbxAcc");
6263 if (!phba
->idiag_mbx_acc
) {
6264 phba
->idiag_mbx_acc
=
6265 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
6266 phba
->idiag_root
, phba
, &lpfc_idiag_op_mbxAcc
);
6269 /* iDiag extents access commands */
6270 if (phba
->sli4_hba
.extents_in_use
) {
6271 snprintf(name
, sizeof(name
), "extAcc");
6272 if (!phba
->idiag_ext_acc
) {
6273 phba
->idiag_ext_acc
=
6274 debugfs_create_file(name
,
6275 S_IFREG
|S_IRUGO
|S_IWUSR
,
6276 phba
->idiag_root
, phba
,
6277 &lpfc_idiag_op_extAcc
);
6287 * lpfc_debugfs_terminate - Tear down debugfs infrastructure for this vport
6288 * @vport: The vport pointer to remove from debugfs.
6291 * When Debugfs is configured this routine removes debugfs file system elements
6292 * that are specific to this vport. It also checks to see if there are any
6293 * users left for the debugfs directories associated with the HBA and driver. If
6294 * this is the last user of the HBA directory or driver directory then it will
6295 * remove those from the debugfs infrastructure as well.
6298 lpfc_debugfs_terminate(struct lpfc_vport
*vport
)
6300 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
6301 struct lpfc_hba
*phba
= vport
->phba
;
6303 kfree(vport
->disc_trc
);
6304 vport
->disc_trc
= NULL
;
6306 debugfs_remove(vport
->debug_disc_trc
); /* discovery_trace */
6307 vport
->debug_disc_trc
= NULL
;
6309 debugfs_remove(vport
->debug_nodelist
); /* nodelist */
6310 vport
->debug_nodelist
= NULL
;
6312 debugfs_remove(vport
->debug_nvmestat
); /* nvmestat */
6313 vport
->debug_nvmestat
= NULL
;
6315 debugfs_remove(vport
->debug_scsistat
); /* scsistat */
6316 vport
->debug_scsistat
= NULL
;
6318 debugfs_remove(vport
->debug_ioktime
); /* ioktime */
6319 vport
->debug_ioktime
= NULL
;
6321 debugfs_remove(vport
->debug_hdwqstat
); /* hdwqstat */
6322 vport
->debug_hdwqstat
= NULL
;
6324 if (vport
->vport_debugfs_root
) {
6325 debugfs_remove(vport
->vport_debugfs_root
); /* vportX */
6326 vport
->vport_debugfs_root
= NULL
;
6327 atomic_dec(&phba
->debugfs_vport_count
);
6330 if (atomic_read(&phba
->debugfs_vport_count
) == 0) {
6332 debugfs_remove(phba
->debug_multixri_pools
); /* multixripools*/
6333 phba
->debug_multixri_pools
= NULL
;
6335 debugfs_remove(phba
->debug_hbqinfo
); /* hbqinfo */
6336 phba
->debug_hbqinfo
= NULL
;
6338 debugfs_remove(phba
->debug_ras_log
);
6339 phba
->debug_ras_log
= NULL
;
6341 #ifdef LPFC_HDWQ_LOCK_STAT
6342 debugfs_remove(phba
->debug_lockstat
); /* lockstat */
6343 phba
->debug_lockstat
= NULL
;
6345 debugfs_remove(phba
->debug_dumpHBASlim
); /* HBASlim */
6346 phba
->debug_dumpHBASlim
= NULL
;
6348 debugfs_remove(phba
->debug_dumpHostSlim
); /* HostSlim */
6349 phba
->debug_dumpHostSlim
= NULL
;
6351 debugfs_remove(phba
->debug_InjErrLBA
); /* InjErrLBA */
6352 phba
->debug_InjErrLBA
= NULL
;
6354 debugfs_remove(phba
->debug_InjErrNPortID
);
6355 phba
->debug_InjErrNPortID
= NULL
;
6357 debugfs_remove(phba
->debug_InjErrWWPN
); /* InjErrWWPN */
6358 phba
->debug_InjErrWWPN
= NULL
;
6360 debugfs_remove(phba
->debug_writeGuard
); /* writeGuard */
6361 phba
->debug_writeGuard
= NULL
;
6363 debugfs_remove(phba
->debug_writeApp
); /* writeApp */
6364 phba
->debug_writeApp
= NULL
;
6366 debugfs_remove(phba
->debug_writeRef
); /* writeRef */
6367 phba
->debug_writeRef
= NULL
;
6369 debugfs_remove(phba
->debug_readGuard
); /* readGuard */
6370 phba
->debug_readGuard
= NULL
;
6372 debugfs_remove(phba
->debug_readApp
); /* readApp */
6373 phba
->debug_readApp
= NULL
;
6375 debugfs_remove(phba
->debug_readRef
); /* readRef */
6376 phba
->debug_readRef
= NULL
;
6378 kfree(phba
->slow_ring_trc
);
6379 phba
->slow_ring_trc
= NULL
;
6381 /* slow_ring_trace */
6382 debugfs_remove(phba
->debug_slow_ring_trc
);
6383 phba
->debug_slow_ring_trc
= NULL
;
6385 debugfs_remove(phba
->debug_nvmeio_trc
);
6386 phba
->debug_nvmeio_trc
= NULL
;
6388 kfree(phba
->nvmeio_trc
);
6389 phba
->nvmeio_trc
= NULL
;
6394 if (phba
->sli_rev
== LPFC_SLI_REV4
) {
6396 debugfs_remove(phba
->idiag_ext_acc
);
6397 phba
->idiag_ext_acc
= NULL
;
6400 debugfs_remove(phba
->idiag_mbx_acc
);
6401 phba
->idiag_mbx_acc
= NULL
;
6404 debugfs_remove(phba
->idiag_ctl_acc
);
6405 phba
->idiag_ctl_acc
= NULL
;
6408 debugfs_remove(phba
->idiag_drb_acc
);
6409 phba
->idiag_drb_acc
= NULL
;
6412 debugfs_remove(phba
->idiag_que_acc
);
6413 phba
->idiag_que_acc
= NULL
;
6416 debugfs_remove(phba
->idiag_que_info
);
6417 phba
->idiag_que_info
= NULL
;
6420 debugfs_remove(phba
->idiag_bar_acc
);
6421 phba
->idiag_bar_acc
= NULL
;
6424 debugfs_remove(phba
->idiag_pci_cfg
);
6425 phba
->idiag_pci_cfg
= NULL
;
6427 /* Finally remove the iDiag debugfs root */
6428 debugfs_remove(phba
->idiag_root
);
6429 phba
->idiag_root
= NULL
;
6432 if (phba
->hba_debugfs_root
) {
6433 debugfs_remove(phba
->hba_debugfs_root
); /* fnX */
6434 phba
->hba_debugfs_root
= NULL
;
6435 atomic_dec(&lpfc_debugfs_hba_count
);
6438 if (atomic_read(&lpfc_debugfs_hba_count
) == 0) {
6439 debugfs_remove(lpfc_debugfs_root
); /* lpfc */
6440 lpfc_debugfs_root
= NULL
;
6448 * Driver debug utility routines outside of debugfs. The debug utility
6449 * routines implemented here is intended to be used in the instrumented
6450 * debug driver for debugging host or port issues.
6454 * lpfc_debug_dump_all_queues - dump all the queues with a hba
6455 * @phba: Pointer to HBA context object.
6457 * This function dumps entries of all the queues asociated with the @phba.
6460 lpfc_debug_dump_all_queues(struct lpfc_hba
*phba
)
6465 * Dump Work Queues (WQs)
6467 lpfc_debug_dump_wq(phba
, DUMP_MBX
, 0);
6468 lpfc_debug_dump_wq(phba
, DUMP_ELS
, 0);
6469 lpfc_debug_dump_wq(phba
, DUMP_NVMELS
, 0);
6471 for (idx
= 0; idx
< phba
->cfg_hdw_queue
; idx
++)
6472 lpfc_debug_dump_wq(phba
, DUMP_IO
, idx
);
6474 lpfc_debug_dump_hdr_rq(phba
);
6475 lpfc_debug_dump_dat_rq(phba
);
6477 * Dump Complete Queues (CQs)
6479 lpfc_debug_dump_cq(phba
, DUMP_MBX
, 0);
6480 lpfc_debug_dump_cq(phba
, DUMP_ELS
, 0);
6481 lpfc_debug_dump_cq(phba
, DUMP_NVMELS
, 0);
6483 for (idx
= 0; idx
< phba
->cfg_hdw_queue
; idx
++)
6484 lpfc_debug_dump_cq(phba
, DUMP_IO
, idx
);
6487 * Dump Event Queues (EQs)
6489 for (idx
= 0; idx
< phba
->cfg_hdw_queue
; idx
++)
6490 lpfc_debug_dump_hba_eq(phba
, idx
);