1 /*******************************************************************
2 * This file is part of the Emulex Linux Device Driver for *
3 * Fibre Channel Host Bus Adapters. *
4 * Copyright (C) 2017-2019 Broadcom. All Rights Reserved. The term *
5 * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. *
6 * Copyright (C) 2007-2015 Emulex. All rights reserved. *
7 * EMULEX and SLI are trademarks of Emulex. *
10 * This program is free software; you can redistribute it and/or *
11 * modify it under the terms of version 2 of the GNU General *
12 * Public License as published by the Free Software Foundation. *
13 * This program is distributed in the hope that it will be useful. *
14 * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND *
15 * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, *
16 * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE *
17 * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD *
18 * TO BE LEGALLY INVALID. See the GNU General Public License for *
19 * more details, a copy of which can be found in the file COPYING *
20 * included with this package. *
21 *******************************************************************/
23 #include <linux/blkdev.h>
24 #include <linux/delay.h>
25 #include <linux/module.h>
26 #include <linux/dma-mapping.h>
27 #include <linux/idr.h>
28 #include <linux/interrupt.h>
29 #include <linux/kthread.h>
30 #include <linux/slab.h>
31 #include <linux/pci.h>
32 #include <linux/spinlock.h>
33 #include <linux/ctype.h>
35 #include <scsi/scsi.h>
36 #include <scsi/scsi_device.h>
37 #include <scsi/scsi_host.h>
38 #include <scsi/scsi_transport_fc.h>
39 #include <scsi/fc/fc_fs.h>
41 #include <linux/nvme-fc-driver.h>
46 #include "lpfc_sli4.h"
48 #include "lpfc_disc.h"
50 #include "lpfc_scsi.h"
51 #include "lpfc_nvme.h"
52 #include "lpfc_nvmet.h"
53 #include "lpfc_logmsg.h"
54 #include "lpfc_crtn.h"
55 #include "lpfc_vport.h"
56 #include "lpfc_version.h"
57 #include "lpfc_compat.h"
58 #include "lpfc_debugfs.h"
61 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
65 * To access this interface the user should:
66 * # mount -t debugfs none /sys/kernel/debug
68 * The lpfc debugfs directory hierarchy is:
69 * /sys/kernel/debug/lpfc/fnX/vportY
70 * where X is the lpfc hba function unique_id
71 * where Y is the vport VPI on that hba
73 * Debugging services available per vport:
75 * This is an ACSII readable file that contains a trace of the last
76 * lpfc_debugfs_max_disc_trc events that happened on a specific vport.
77 * See lpfc_debugfs.h for different categories of discovery events.
78 * To enable the discovery trace, the following module parameters must be set:
79 * lpfc_debugfs_enable=1 Turns on lpfc debugfs filesystem support
80 * lpfc_debugfs_max_disc_trc=X Where X is the event trace depth for
81 * EACH vport. X MUST also be a power of 2.
82 * lpfc_debugfs_mask_disc_trc=Y Where Y is an event mask as defined in
86 * This is an ACSII readable file that contains a trace of the last
87 * lpfc_debugfs_max_slow_ring_trc events that happened on a specific HBA.
88 * To enable the slow ring trace, the following module parameters must be set:
89 * lpfc_debugfs_enable=1 Turns on lpfc debugfs filesystem support
90 * lpfc_debugfs_max_slow_ring_trc=X Where X is the event trace depth for
91 * the HBA. X MUST also be a power of 2.
93 static int lpfc_debugfs_enable
= 1;
94 module_param(lpfc_debugfs_enable
, int, S_IRUGO
);
95 MODULE_PARM_DESC(lpfc_debugfs_enable
, "Enable debugfs services");
97 /* This MUST be a power of 2 */
98 static int lpfc_debugfs_max_disc_trc
;
99 module_param(lpfc_debugfs_max_disc_trc
, int, S_IRUGO
);
100 MODULE_PARM_DESC(lpfc_debugfs_max_disc_trc
,
101 "Set debugfs discovery trace depth");
103 /* This MUST be a power of 2 */
104 static int lpfc_debugfs_max_slow_ring_trc
;
105 module_param(lpfc_debugfs_max_slow_ring_trc
, int, S_IRUGO
);
106 MODULE_PARM_DESC(lpfc_debugfs_max_slow_ring_trc
,
107 "Set debugfs slow ring trace depth");
109 /* This MUST be a power of 2 */
110 static int lpfc_debugfs_max_nvmeio_trc
;
111 module_param(lpfc_debugfs_max_nvmeio_trc
, int, 0444);
112 MODULE_PARM_DESC(lpfc_debugfs_max_nvmeio_trc
,
113 "Set debugfs NVME IO trace depth");
115 static int lpfc_debugfs_mask_disc_trc
;
116 module_param(lpfc_debugfs_mask_disc_trc
, int, S_IRUGO
);
117 MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc
,
118 "Set debugfs discovery trace mask");
120 #include <linux/debugfs.h>
122 static atomic_t lpfc_debugfs_seq_trc_cnt
= ATOMIC_INIT(0);
123 static unsigned long lpfc_debugfs_start_time
= 0L;
126 static struct lpfc_idiag idiag
;
129 * lpfc_debugfs_disc_trc_data - Dump discovery logging to a buffer
130 * @vport: The vport to gather the log info from.
131 * @buf: The buffer to dump log into.
132 * @size: The maximum amount of data to process.
135 * This routine gathers the lpfc discovery debugfs data from the @vport and
136 * dumps it to @buf up to @size number of bytes. It will start at the next entry
137 * in the log and process the log until the end of the buffer. Then it will
138 * gather from the beginning of the log and process until the current entry.
141 * Discovery logging will be disabled while while this routine dumps the log.
144 * This routine returns the amount of bytes that were dumped into @buf and will
148 lpfc_debugfs_disc_trc_data(struct lpfc_vport
*vport
, char *buf
, int size
)
150 int i
, index
, len
, enable
;
152 struct lpfc_debugfs_trc
*dtp
;
155 buffer
= kmalloc(LPFC_DEBUG_TRC_ENTRY_SIZE
, GFP_KERNEL
);
159 enable
= lpfc_debugfs_enable
;
160 lpfc_debugfs_enable
= 0;
163 index
= (atomic_read(&vport
->disc_trc_cnt
) + 1) &
164 (lpfc_debugfs_max_disc_trc
- 1);
165 for (i
= index
; i
< lpfc_debugfs_max_disc_trc
; i
++) {
166 dtp
= vport
->disc_trc
+ i
;
169 ms
= jiffies_to_msecs(dtp
->jif
- lpfc_debugfs_start_time
);
171 LPFC_DEBUG_TRC_ENTRY_SIZE
, "%010d:%010d ms:%s\n",
172 dtp
->seq_cnt
, ms
, dtp
->fmt
);
173 len
+= scnprintf(buf
+len
, size
-len
, buffer
,
174 dtp
->data1
, dtp
->data2
, dtp
->data3
);
176 for (i
= 0; i
< index
; i
++) {
177 dtp
= vport
->disc_trc
+ i
;
180 ms
= jiffies_to_msecs(dtp
->jif
- lpfc_debugfs_start_time
);
182 LPFC_DEBUG_TRC_ENTRY_SIZE
, "%010d:%010d ms:%s\n",
183 dtp
->seq_cnt
, ms
, dtp
->fmt
);
184 len
+= scnprintf(buf
+len
, size
-len
, buffer
,
185 dtp
->data1
, dtp
->data2
, dtp
->data3
);
188 lpfc_debugfs_enable
= enable
;
195 * lpfc_debugfs_slow_ring_trc_data - Dump slow ring logging to a buffer
196 * @phba: The HBA to gather the log info from.
197 * @buf: The buffer to dump log into.
198 * @size: The maximum amount of data to process.
201 * This routine gathers the lpfc slow ring debugfs data from the @phba and
202 * dumps it to @buf up to @size number of bytes. It will start at the next entry
203 * in the log and process the log until the end of the buffer. Then it will
204 * gather from the beginning of the log and process until the current entry.
207 * Slow ring logging will be disabled while while this routine dumps the log.
210 * This routine returns the amount of bytes that were dumped into @buf and will
214 lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba
*phba
, char *buf
, int size
)
216 int i
, index
, len
, enable
;
218 struct lpfc_debugfs_trc
*dtp
;
221 buffer
= kmalloc(LPFC_DEBUG_TRC_ENTRY_SIZE
, GFP_KERNEL
);
225 enable
= lpfc_debugfs_enable
;
226 lpfc_debugfs_enable
= 0;
229 index
= (atomic_read(&phba
->slow_ring_trc_cnt
) + 1) &
230 (lpfc_debugfs_max_slow_ring_trc
- 1);
231 for (i
= index
; i
< lpfc_debugfs_max_slow_ring_trc
; i
++) {
232 dtp
= phba
->slow_ring_trc
+ i
;
235 ms
= jiffies_to_msecs(dtp
->jif
- lpfc_debugfs_start_time
);
237 LPFC_DEBUG_TRC_ENTRY_SIZE
, "%010d:%010d ms:%s\n",
238 dtp
->seq_cnt
, ms
, dtp
->fmt
);
239 len
+= scnprintf(buf
+len
, size
-len
, buffer
,
240 dtp
->data1
, dtp
->data2
, dtp
->data3
);
242 for (i
= 0; i
< index
; i
++) {
243 dtp
= phba
->slow_ring_trc
+ i
;
246 ms
= jiffies_to_msecs(dtp
->jif
- lpfc_debugfs_start_time
);
248 LPFC_DEBUG_TRC_ENTRY_SIZE
, "%010d:%010d ms:%s\n",
249 dtp
->seq_cnt
, ms
, dtp
->fmt
);
250 len
+= scnprintf(buf
+len
, size
-len
, buffer
,
251 dtp
->data1
, dtp
->data2
, dtp
->data3
);
254 lpfc_debugfs_enable
= enable
;
260 static int lpfc_debugfs_last_hbq
= -1;
263 * lpfc_debugfs_hbqinfo_data - Dump host buffer queue info to a buffer
264 * @phba: The HBA to gather host buffer info from.
265 * @buf: The buffer to dump log into.
266 * @size: The maximum amount of data to process.
269 * This routine dumps the host buffer queue info from the @phba to @buf up to
270 * @size number of bytes. A header that describes the current hbq state will be
271 * dumped to @buf first and then info on each hbq entry will be dumped to @buf
272 * until @size bytes have been dumped or all the hbq info has been dumped.
275 * This routine will rotate through each configured HBQ each time called.
278 * This routine returns the amount of bytes that were dumped into @buf and will
282 lpfc_debugfs_hbqinfo_data(struct lpfc_hba
*phba
, char *buf
, int size
)
285 int i
, j
, found
, posted
, low
;
286 uint32_t phys
, raw_index
, getidx
;
287 struct lpfc_hbq_init
*hip
;
289 struct lpfc_hbq_entry
*hbqe
;
290 struct lpfc_dmabuf
*d_buf
;
291 struct hbq_dmabuf
*hbq_buf
;
293 if (phba
->sli_rev
!= 3)
296 spin_lock_irq(&phba
->hbalock
);
298 /* toggle between multiple hbqs, if any */
299 i
= lpfc_sli_hbq_count();
301 lpfc_debugfs_last_hbq
++;
302 if (lpfc_debugfs_last_hbq
>= i
)
303 lpfc_debugfs_last_hbq
= 0;
306 lpfc_debugfs_last_hbq
= 0;
308 i
= lpfc_debugfs_last_hbq
;
310 len
+= scnprintf(buf
+len
, size
-len
, "HBQ %d Info\n", i
);
312 hbqs
= &phba
->hbqs
[i
];
314 list_for_each_entry(d_buf
, &hbqs
->hbq_buffer_list
, list
)
317 hip
= lpfc_hbq_defs
[i
];
318 len
+= scnprintf(buf
+len
, size
-len
,
319 "idx:%d prof:%d rn:%d bufcnt:%d icnt:%d acnt:%d posted %d\n",
320 hip
->hbq_index
, hip
->profile
, hip
->rn
,
321 hip
->buffer_count
, hip
->init_count
, hip
->add_count
, posted
);
323 raw_index
= phba
->hbq_get
[i
];
324 getidx
= le32_to_cpu(raw_index
);
325 len
+= scnprintf(buf
+len
, size
-len
,
326 "entries:%d bufcnt:%d Put:%d nPut:%d localGet:%d hbaGet:%d\n",
327 hbqs
->entry_count
, hbqs
->buffer_count
, hbqs
->hbqPutIdx
,
328 hbqs
->next_hbqPutIdx
, hbqs
->local_hbqGetIdx
, getidx
);
330 hbqe
= (struct lpfc_hbq_entry
*) phba
->hbqs
[i
].hbq_virt
;
331 for (j
=0; j
<hbqs
->entry_count
; j
++) {
332 len
+= scnprintf(buf
+len
, size
-len
,
333 "%03d: %08x %04x %05x ", j
,
334 le32_to_cpu(hbqe
->bde
.addrLow
),
335 le32_to_cpu(hbqe
->bde
.tus
.w
),
336 le32_to_cpu(hbqe
->buffer_tag
));
340 /* First calculate if slot has an associated posted buffer */
341 low
= hbqs
->hbqPutIdx
- posted
;
343 if ((j
>= hbqs
->hbqPutIdx
) || (j
< low
)) {
344 len
+= scnprintf(buf
+ len
, size
- len
,
350 if ((j
>= hbqs
->hbqPutIdx
) &&
351 (j
< (hbqs
->entry_count
+low
))) {
352 len
+= scnprintf(buf
+ len
, size
- len
,
358 /* Get the Buffer info for the posted buffer */
359 list_for_each_entry(d_buf
, &hbqs
->hbq_buffer_list
, list
) {
360 hbq_buf
= container_of(d_buf
, struct hbq_dmabuf
, dbuf
);
361 phys
= ((uint64_t)hbq_buf
->dbuf
.phys
& 0xffffffff);
362 if (phys
== le32_to_cpu(hbqe
->bde
.addrLow
)) {
363 len
+= scnprintf(buf
+len
, size
-len
,
364 "Buf%d: %p %06x\n", i
,
365 hbq_buf
->dbuf
.virt
, hbq_buf
->tag
);
372 len
+= scnprintf(buf
+len
, size
-len
, "No DMAinfo?\n");
376 if (len
> LPFC_HBQINFO_SIZE
- 54)
379 spin_unlock_irq(&phba
->hbalock
);
383 static int lpfc_debugfs_last_xripool
;
386 * lpfc_debugfs_common_xri_data - Dump Hardware Queue info to a buffer
387 * @phba: The HBA to gather host buffer info from.
388 * @buf: The buffer to dump log into.
389 * @size: The maximum amount of data to process.
392 * This routine dumps the Hardware Queue info from the @phba to @buf up to
393 * @size number of bytes. A header that describes the current hdwq state will be
394 * dumped to @buf first and then info on each hdwq entry will be dumped to @buf
395 * until @size bytes have been dumped or all the hdwq info has been dumped.
398 * This routine will rotate through each configured Hardware Queue each
402 * This routine returns the amount of bytes that were dumped into @buf and will
406 lpfc_debugfs_commonxripools_data(struct lpfc_hba
*phba
, char *buf
, int size
)
408 struct lpfc_sli4_hdw_queue
*qp
;
413 for (i
= 0; i
< phba
->cfg_hdw_queue
; i
++) {
414 if (len
> (LPFC_DUMP_MULTIXRIPOOL_SIZE
- 80))
416 qp
= &phba
->sli4_hba
.hdwq
[lpfc_debugfs_last_xripool
];
418 len
+= scnprintf(buf
+ len
, size
- len
, "HdwQ %d Info ", i
);
419 spin_lock_irqsave(&qp
->abts_scsi_buf_list_lock
, iflag
);
420 spin_lock(&qp
->abts_nvme_buf_list_lock
);
421 spin_lock(&qp
->io_buf_list_get_lock
);
422 spin_lock(&qp
->io_buf_list_put_lock
);
423 out
= qp
->total_io_bufs
- (qp
->get_io_bufs
+ qp
->put_io_bufs
+
424 qp
->abts_scsi_io_bufs
+ qp
->abts_nvme_io_bufs
);
425 len
+= scnprintf(buf
+ len
, size
- len
,
426 "tot:%d get:%d put:%d mt:%d "
427 "ABTS scsi:%d nvme:%d Out:%d\n",
428 qp
->total_io_bufs
, qp
->get_io_bufs
, qp
->put_io_bufs
,
429 qp
->empty_io_bufs
, qp
->abts_scsi_io_bufs
,
430 qp
->abts_nvme_io_bufs
, out
);
431 spin_unlock(&qp
->io_buf_list_put_lock
);
432 spin_unlock(&qp
->io_buf_list_get_lock
);
433 spin_unlock(&qp
->abts_nvme_buf_list_lock
);
434 spin_unlock_irqrestore(&qp
->abts_scsi_buf_list_lock
, iflag
);
436 lpfc_debugfs_last_xripool
++;
437 if (lpfc_debugfs_last_xripool
>= phba
->cfg_hdw_queue
)
438 lpfc_debugfs_last_xripool
= 0;
445 * lpfc_debugfs_multixripools_data - Display multi-XRI pools information
446 * @phba: The HBA to gather host buffer info from.
447 * @buf: The buffer to dump log into.
448 * @size: The maximum amount of data to process.
451 * This routine displays current multi-XRI pools information including XRI
452 * count in public, private and txcmplq. It also displays current high and
456 * This routine returns the amount of bytes that were dumped into @buf and will
460 lpfc_debugfs_multixripools_data(struct lpfc_hba
*phba
, char *buf
, int size
)
464 struct lpfc_sli4_hdw_queue
*qp
;
465 struct lpfc_multixri_pool
*multixri_pool
;
466 struct lpfc_pvt_pool
*pvt_pool
;
467 struct lpfc_pbl_pool
*pbl_pool
;
469 char tmp
[LPFC_DEBUG_OUT_LINE_SZ
] = {0};
471 if (phba
->sli_rev
!= LPFC_SLI_REV4
)
474 if (!phba
->sli4_hba
.hdwq
)
477 if (!phba
->cfg_xri_rebalancing
) {
478 i
= lpfc_debugfs_commonxripools_data(phba
, buf
, size
);
483 * Pbl: Current number of free XRIs in public pool
484 * Pvt: Current number of free XRIs in private pool
485 * Busy: Current number of outstanding XRIs
486 * HWM: Current high watermark
487 * pvt_empty: Incremented by 1 when IO submission fails (no xri)
488 * pbl_empty: Incremented by 1 when all pbl_pool are empty during
491 scnprintf(tmp
, sizeof(tmp
),
492 "HWQ: Pbl Pvt Busy HWM | pvt_empty pbl_empty ");
493 if (strlcat(buf
, tmp
, size
) >= size
)
494 return strnlen(buf
, size
);
498 * MAXH: Max high watermark seen so far
499 * above_lmt: Incremented by 1 if xri_owned > xri_limit during
501 * below_lmt: Incremented by 1 if xri_owned <= xri_limit during
503 * locPbl_hit: Incremented by 1 if successfully get a batch of XRI from
505 * othPbl_hit: Incremented by 1 if successfully get a batch of XRI from
508 scnprintf(tmp
, sizeof(tmp
),
509 "MAXH above_lmt below_lmt locPbl_hit othPbl_hit");
510 if (strlcat(buf
, tmp
, size
) >= size
)
511 return strnlen(buf
, size
);
514 * sPbl: snapshot of Pbl 15 sec after stat gets cleared
515 * sPvt: snapshot of Pvt 15 sec after stat gets cleared
516 * sBusy: snapshot of Busy 15 sec after stat gets cleared
518 scnprintf(tmp
, sizeof(tmp
),
519 " | sPbl sPvt sBusy");
520 if (strlcat(buf
, tmp
, size
) >= size
)
521 return strnlen(buf
, size
);
524 scnprintf(tmp
, sizeof(tmp
), "\n");
525 if (strlcat(buf
, tmp
, size
) >= size
)
526 return strnlen(buf
, size
);
528 hwq_count
= phba
->cfg_hdw_queue
;
529 for (i
= 0; i
< hwq_count
; i
++) {
530 qp
= &phba
->sli4_hba
.hdwq
[i
];
531 multixri_pool
= qp
->p_multixri_pool
;
534 pbl_pool
= &multixri_pool
->pbl_pool
;
535 pvt_pool
= &multixri_pool
->pvt_pool
;
536 txcmplq_cnt
= qp
->fcp_wq
->pring
->txcmplq_cnt
;
538 txcmplq_cnt
+= qp
->nvme_wq
->pring
->txcmplq_cnt
;
540 scnprintf(tmp
, sizeof(tmp
),
541 "%03d: %4d %4d %4d %4d | %10d %10d ",
542 i
, pbl_pool
->count
, pvt_pool
->count
,
543 txcmplq_cnt
, pvt_pool
->high_watermark
,
544 qp
->empty_io_bufs
, multixri_pool
->pbl_empty_count
);
545 if (strlcat(buf
, tmp
, size
) >= size
)
549 scnprintf(tmp
, sizeof(tmp
),
550 "%4d %10d %10d %10d %10d",
551 multixri_pool
->stat_max_hwm
,
552 multixri_pool
->above_limit_count
,
553 multixri_pool
->below_limit_count
,
554 multixri_pool
->local_pbl_hit_count
,
555 multixri_pool
->other_pbl_hit_count
);
556 if (strlcat(buf
, tmp
, size
) >= size
)
559 scnprintf(tmp
, sizeof(tmp
),
561 multixri_pool
->stat_pbl_count
,
562 multixri_pool
->stat_pvt_count
,
563 multixri_pool
->stat_busy_count
);
564 if (strlcat(buf
, tmp
, size
) >= size
)
568 scnprintf(tmp
, sizeof(tmp
), "\n");
569 if (strlcat(buf
, tmp
, size
) >= size
)
572 return strnlen(buf
, size
);
576 #ifdef LPFC_HDWQ_LOCK_STAT
577 static int lpfc_debugfs_last_lock
;
580 * lpfc_debugfs_lockstat_data - Dump Hardware Queue info to a buffer
581 * @phba: The HBA to gather host buffer info from.
582 * @buf: The buffer to dump log into.
583 * @size: The maximum amount of data to process.
586 * This routine dumps the Hardware Queue info from the @phba to @buf up to
587 * @size number of bytes. A header that describes the current hdwq state will be
588 * dumped to @buf first and then info on each hdwq entry will be dumped to @buf
589 * until @size bytes have been dumped or all the hdwq info has been dumped.
592 * This routine will rotate through each configured Hardware Queue each
596 * This routine returns the amount of bytes that were dumped into @buf and will
600 lpfc_debugfs_lockstat_data(struct lpfc_hba
*phba
, char *buf
, int size
)
602 struct lpfc_sli4_hdw_queue
*qp
;
606 if (phba
->sli_rev
!= LPFC_SLI_REV4
)
609 if (!phba
->sli4_hba
.hdwq
)
612 for (i
= 0; i
< phba
->cfg_hdw_queue
; i
++) {
613 if (len
> (LPFC_HDWQINFO_SIZE
- 100))
615 qp
= &phba
->sli4_hba
.hdwq
[lpfc_debugfs_last_lock
];
617 len
+= scnprintf(buf
+ len
, size
- len
, "HdwQ %03d Lock ", i
);
618 if (phba
->cfg_xri_rebalancing
) {
619 len
+= scnprintf(buf
+ len
, size
- len
,
620 "get_pvt:%d mv_pvt:%d "
621 "mv2pub:%d mv2pvt:%d "
622 "put_pvt:%d put_pub:%d wq:%d\n",
623 qp
->lock_conflict
.alloc_pvt_pool
,
624 qp
->lock_conflict
.mv_from_pvt_pool
,
625 qp
->lock_conflict
.mv_to_pub_pool
,
626 qp
->lock_conflict
.mv_to_pvt_pool
,
627 qp
->lock_conflict
.free_pvt_pool
,
628 qp
->lock_conflict
.free_pub_pool
,
629 qp
->lock_conflict
.wq_access
);
631 len
+= scnprintf(buf
+ len
, size
- len
,
632 "get:%d put:%d free:%d wq:%d\n",
633 qp
->lock_conflict
.alloc_xri_get
,
634 qp
->lock_conflict
.alloc_xri_put
,
635 qp
->lock_conflict
.free_xri
,
636 qp
->lock_conflict
.wq_access
);
639 lpfc_debugfs_last_lock
++;
640 if (lpfc_debugfs_last_lock
>= phba
->cfg_hdw_queue
)
641 lpfc_debugfs_last_lock
= 0;
648 static int lpfc_debugfs_last_hba_slim_off
;
651 * lpfc_debugfs_dumpHBASlim_data - Dump HBA SLIM info to a buffer
652 * @phba: The HBA to gather SLIM info from.
653 * @buf: The buffer to dump log into.
654 * @size: The maximum amount of data to process.
657 * This routine dumps the current contents of HBA SLIM for the HBA associated
658 * with @phba to @buf up to @size bytes of data. This is the raw HBA SLIM data.
661 * This routine will only dump up to 1024 bytes of data each time called and
662 * should be called multiple times to dump the entire HBA SLIM.
665 * This routine returns the amount of bytes that were dumped into @buf and will
669 lpfc_debugfs_dumpHBASlim_data(struct lpfc_hba
*phba
, char *buf
, int size
)
676 buffer
= kmalloc(1024, GFP_KERNEL
);
681 spin_lock_irq(&phba
->hbalock
);
683 len
+= scnprintf(buf
+len
, size
-len
, "HBA SLIM\n");
684 lpfc_memcpy_from_slim(buffer
,
685 phba
->MBslimaddr
+ lpfc_debugfs_last_hba_slim_off
, 1024);
687 ptr
= (uint32_t *)&buffer
[0];
688 off
= lpfc_debugfs_last_hba_slim_off
;
690 /* Set it up for the next time */
691 lpfc_debugfs_last_hba_slim_off
+= 1024;
692 if (lpfc_debugfs_last_hba_slim_off
>= 4096)
693 lpfc_debugfs_last_hba_slim_off
= 0;
697 len
+= scnprintf(buf
+len
, size
-len
,
698 "%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n",
699 off
, *ptr
, *(ptr
+1), *(ptr
+2), *(ptr
+3), *(ptr
+4),
700 *(ptr
+5), *(ptr
+6), *(ptr
+7));
702 i
-= (8 * sizeof(uint32_t));
703 off
+= (8 * sizeof(uint32_t));
706 spin_unlock_irq(&phba
->hbalock
);
713 * lpfc_debugfs_dumpHostSlim_data - Dump host SLIM info to a buffer
714 * @phba: The HBA to gather Host SLIM info from.
715 * @buf: The buffer to dump log into.
716 * @size: The maximum amount of data to process.
719 * This routine dumps the current contents of host SLIM for the host associated
720 * with @phba to @buf up to @size bytes of data. The dump will contain the
721 * Mailbox, PCB, Rings, and Registers that are located in host memory.
724 * This routine returns the amount of bytes that were dumped into @buf and will
728 lpfc_debugfs_dumpHostSlim_data(struct lpfc_hba
*phba
, char *buf
, int size
)
732 uint32_t word0
, word1
, word2
, word3
;
734 struct lpfc_pgp
*pgpp
;
735 struct lpfc_sli
*psli
= &phba
->sli
;
736 struct lpfc_sli_ring
*pring
;
739 spin_lock_irq(&phba
->hbalock
);
741 len
+= scnprintf(buf
+len
, size
-len
, "SLIM Mailbox\n");
742 ptr
= (uint32_t *)phba
->slim2p
.virt
;
743 i
= sizeof(MAILBOX_t
);
745 len
+= scnprintf(buf
+len
, size
-len
,
746 "%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n",
747 off
, *ptr
, *(ptr
+1), *(ptr
+2), *(ptr
+3), *(ptr
+4),
748 *(ptr
+5), *(ptr
+6), *(ptr
+7));
750 i
-= (8 * sizeof(uint32_t));
751 off
+= (8 * sizeof(uint32_t));
754 len
+= scnprintf(buf
+len
, size
-len
, "SLIM PCB\n");
755 ptr
= (uint32_t *)phba
->pcb
;
758 len
+= scnprintf(buf
+len
, size
-len
,
759 "%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n",
760 off
, *ptr
, *(ptr
+1), *(ptr
+2), *(ptr
+3), *(ptr
+4),
761 *(ptr
+5), *(ptr
+6), *(ptr
+7));
763 i
-= (8 * sizeof(uint32_t));
764 off
+= (8 * sizeof(uint32_t));
767 if (phba
->sli_rev
<= LPFC_SLI_REV3
) {
768 for (i
= 0; i
< 4; i
++) {
769 pgpp
= &phba
->port_gp
[i
];
770 pring
= &psli
->sli3_ring
[i
];
771 len
+= scnprintf(buf
+len
, size
-len
,
772 "Ring %d: CMD GetInx:%d "
775 "RSP PutInx:%d Max:%d\n",
777 pring
->sli
.sli3
.numCiocb
,
778 pring
->sli
.sli3
.next_cmdidx
,
779 pring
->sli
.sli3
.local_getidx
,
780 pring
->flag
, pgpp
->rspPutInx
,
781 pring
->sli
.sli3
.numRiocb
);
784 word0
= readl(phba
->HAregaddr
);
785 word1
= readl(phba
->CAregaddr
);
786 word2
= readl(phba
->HSregaddr
);
787 word3
= readl(phba
->HCregaddr
);
788 len
+= scnprintf(buf
+len
, size
-len
, "HA:%08x CA:%08x HS:%08x "
789 "HC:%08x\n", word0
, word1
, word2
, word3
);
791 spin_unlock_irq(&phba
->hbalock
);
796 * lpfc_debugfs_nodelist_data - Dump target node list to a buffer
797 * @vport: The vport to gather target node info from.
798 * @buf: The buffer to dump log into.
799 * @size: The maximum amount of data to process.
802 * This routine dumps the current target node list associated with @vport to
803 * @buf up to @size bytes of data. Each node entry in the dump will contain a
804 * node state, DID, WWPN, WWNN, RPI, flags, type, and other useful fields.
807 * This routine returns the amount of bytes that were dumped into @buf and will
811 lpfc_debugfs_nodelist_data(struct lpfc_vport
*vport
, char *buf
, int size
)
814 int i
, iocnt
, outio
, cnt
;
815 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
816 struct lpfc_hba
*phba
= vport
->phba
;
817 struct lpfc_nodelist
*ndlp
;
818 unsigned char *statep
;
819 struct nvme_fc_local_port
*localport
;
820 struct nvme_fc_remote_port
*nrport
= NULL
;
821 struct lpfc_nvme_rport
*rport
;
823 cnt
= (LPFC_NODELIST_SIZE
/ LPFC_NODELIST_ENTRY_SIZE
);
826 len
+= scnprintf(buf
+len
, size
-len
, "\nFCP Nodelist Entries ...\n");
827 spin_lock_irq(shost
->host_lock
);
828 list_for_each_entry(ndlp
, &vport
->fc_nodes
, nlp_listp
) {
831 len
+= scnprintf(buf
+len
, size
-len
,
832 "Missing Nodelist Entries\n");
836 switch (ndlp
->nlp_state
) {
837 case NLP_STE_UNUSED_NODE
:
840 case NLP_STE_PLOGI_ISSUE
:
843 case NLP_STE_ADISC_ISSUE
:
846 case NLP_STE_REG_LOGIN_ISSUE
:
849 case NLP_STE_PRLI_ISSUE
:
852 case NLP_STE_LOGO_ISSUE
:
855 case NLP_STE_UNMAPPED_NODE
:
859 case NLP_STE_MAPPED_NODE
:
863 case NLP_STE_NPR_NODE
:
869 len
+= scnprintf(buf
+len
, size
-len
, "%s DID:x%06x ",
870 statep
, ndlp
->nlp_DID
);
871 len
+= scnprintf(buf
+len
, size
-len
,
873 wwn_to_u64(ndlp
->nlp_portname
.u
.wwn
));
874 len
+= scnprintf(buf
+len
, size
-len
,
876 wwn_to_u64(ndlp
->nlp_nodename
.u
.wwn
));
877 if (ndlp
->nlp_flag
& NLP_RPI_REGISTERED
)
878 len
+= scnprintf(buf
+len
, size
-len
, "RPI:%03d ",
881 len
+= scnprintf(buf
+len
, size
-len
, "RPI:none ");
882 len
+= scnprintf(buf
+len
, size
-len
, "flag:x%08x ",
885 len
+= scnprintf(buf
+len
, size
-len
, "UNKNOWN_TYPE ");
886 if (ndlp
->nlp_type
& NLP_FC_NODE
)
887 len
+= scnprintf(buf
+len
, size
-len
, "FC_NODE ");
888 if (ndlp
->nlp_type
& NLP_FABRIC
) {
889 len
+= scnprintf(buf
+len
, size
-len
, "FABRIC ");
892 if (ndlp
->nlp_type
& NLP_FCP_TARGET
)
893 len
+= scnprintf(buf
+len
, size
-len
, "FCP_TGT sid:%d ",
895 if (ndlp
->nlp_type
& NLP_FCP_INITIATOR
)
896 len
+= scnprintf(buf
+len
, size
-len
, "FCP_INITIATOR ");
897 if (ndlp
->nlp_type
& NLP_NVME_TARGET
)
898 len
+= scnprintf(buf
+ len
,
899 size
- len
, "NVME_TGT sid:%d ",
901 if (ndlp
->nlp_type
& NLP_NVME_INITIATOR
)
902 len
+= scnprintf(buf
+ len
,
903 size
- len
, "NVME_INITIATOR ");
904 len
+= scnprintf(buf
+len
, size
-len
, "usgmap:%x ",
906 len
+= scnprintf(buf
+len
, size
-len
, "refcnt:%x",
907 kref_read(&ndlp
->kref
));
909 i
= atomic_read(&ndlp
->cmd_pending
);
910 len
+= scnprintf(buf
+ len
, size
- len
,
911 " OutIO:x%x Qdepth x%x",
912 i
, ndlp
->cmd_qdepth
);
915 len
+= scnprintf(buf
+ len
, size
- len
, "defer:%x ",
916 ndlp
->nlp_defer_did
);
917 len
+= scnprintf(buf
+len
, size
-len
, "\n");
919 spin_unlock_irq(shost
->host_lock
);
921 len
+= scnprintf(buf
+ len
, size
- len
,
922 "\nOutstanding IO x%x\n", outio
);
924 if (phba
->nvmet_support
&& phba
->targetport
&& (vport
== phba
->pport
)) {
925 len
+= scnprintf(buf
+ len
, size
- len
,
926 "\nNVME Targetport Entry ...\n");
928 /* Port state is only one of two values for now. */
929 if (phba
->targetport
->port_id
)
930 statep
= "REGISTERED";
933 len
+= scnprintf(buf
+ len
, size
- len
,
934 "TGT WWNN x%llx WWPN x%llx State %s\n",
935 wwn_to_u64(vport
->fc_nodename
.u
.wwn
),
936 wwn_to_u64(vport
->fc_portname
.u
.wwn
),
938 len
+= scnprintf(buf
+ len
, size
- len
,
939 " Targetport DID x%06x\n",
940 phba
->targetport
->port_id
);
944 len
+= scnprintf(buf
+ len
, size
- len
,
945 "\nNVME Lport/Rport Entries ...\n");
947 localport
= vport
->localport
;
951 spin_lock_irq(shost
->host_lock
);
953 /* Port state is only one of two values for now. */
954 if (localport
->port_id
)
959 len
+= scnprintf(buf
+ len
, size
- len
,
960 "Lport DID x%06x PortState %s\n",
961 localport
->port_id
, statep
);
963 len
+= scnprintf(buf
+ len
, size
- len
, "\tRport List:\n");
964 list_for_each_entry(ndlp
, &vport
->fc_nodes
, nlp_listp
) {
965 /* local short-hand pointer. */
966 spin_lock(&phba
->hbalock
);
967 rport
= lpfc_ndlp_get_nrport(ndlp
);
969 nrport
= rport
->remoteport
;
972 spin_unlock(&phba
->hbalock
);
976 /* Port state is only one of two values for now. */
977 switch (nrport
->port_state
) {
978 case FC_OBJSTATE_ONLINE
:
981 case FC_OBJSTATE_UNKNOWN
:
985 statep
= "UNSUPPORTED";
989 /* Tab in to show lport ownership. */
990 len
+= scnprintf(buf
+ len
, size
- len
,
991 "\t%s Port ID:x%06x ",
992 statep
, nrport
->port_id
);
993 len
+= scnprintf(buf
+ len
, size
- len
, "WWPN x%llx ",
995 len
+= scnprintf(buf
+ len
, size
- len
, "WWNN x%llx ",
998 /* An NVME rport can have multiple roles. */
999 if (nrport
->port_role
& FC_PORT_ROLE_NVME_INITIATOR
)
1000 len
+= scnprintf(buf
+ len
, size
- len
,
1002 if (nrport
->port_role
& FC_PORT_ROLE_NVME_TARGET
)
1003 len
+= scnprintf(buf
+ len
, size
- len
,
1005 if (nrport
->port_role
& FC_PORT_ROLE_NVME_DISCOVERY
)
1006 len
+= scnprintf(buf
+ len
, size
- len
,
1008 if (nrport
->port_role
& ~(FC_PORT_ROLE_NVME_INITIATOR
|
1009 FC_PORT_ROLE_NVME_TARGET
|
1010 FC_PORT_ROLE_NVME_DISCOVERY
))
1011 len
+= scnprintf(buf
+ len
, size
- len
,
1014 /* Terminate the string. */
1015 len
+= scnprintf(buf
+ len
, size
- len
, "\n");
1018 spin_unlock_irq(shost
->host_lock
);
1024 * lpfc_debugfs_nvmestat_data - Dump target node list to a buffer
1025 * @vport: The vport to gather target node info from.
1026 * @buf: The buffer to dump log into.
1027 * @size: The maximum amount of data to process.
1030 * This routine dumps the NVME statistics associated with @vport
1033 * This routine returns the amount of bytes that were dumped into @buf and will
1037 lpfc_debugfs_nvmestat_data(struct lpfc_vport
*vport
, char *buf
, int size
)
1039 struct lpfc_hba
*phba
= vport
->phba
;
1040 struct lpfc_nvmet_tgtport
*tgtp
;
1041 struct lpfc_nvmet_rcv_ctx
*ctxp
, *next_ctxp
;
1042 struct nvme_fc_local_port
*localport
;
1043 struct lpfc_fc4_ctrl_stat
*cstat
;
1044 struct lpfc_nvme_lport
*lport
;
1045 uint64_t data1
, data2
, data3
;
1046 uint64_t tot
, totin
, totout
;
1050 if (phba
->nvmet_support
) {
1051 if (!phba
->targetport
)
1053 tgtp
= (struct lpfc_nvmet_tgtport
*)phba
->targetport
->private;
1054 len
+= scnprintf(buf
+ len
, size
- len
,
1055 "\nNVME Targetport Statistics\n");
1057 len
+= scnprintf(buf
+ len
, size
- len
,
1058 "LS: Rcv %08x Drop %08x Abort %08x\n",
1059 atomic_read(&tgtp
->rcv_ls_req_in
),
1060 atomic_read(&tgtp
->rcv_ls_req_drop
),
1061 atomic_read(&tgtp
->xmt_ls_abort
));
1062 if (atomic_read(&tgtp
->rcv_ls_req_in
) !=
1063 atomic_read(&tgtp
->rcv_ls_req_out
)) {
1064 len
+= scnprintf(buf
+ len
, size
- len
,
1065 "Rcv LS: in %08x != out %08x\n",
1066 atomic_read(&tgtp
->rcv_ls_req_in
),
1067 atomic_read(&tgtp
->rcv_ls_req_out
));
1070 len
+= scnprintf(buf
+ len
, size
- len
,
1071 "LS: Xmt %08x Drop %08x Cmpl %08x\n",
1072 atomic_read(&tgtp
->xmt_ls_rsp
),
1073 atomic_read(&tgtp
->xmt_ls_drop
),
1074 atomic_read(&tgtp
->xmt_ls_rsp_cmpl
));
1076 len
+= scnprintf(buf
+ len
, size
- len
,
1077 "LS: RSP Abort %08x xb %08x Err %08x\n",
1078 atomic_read(&tgtp
->xmt_ls_rsp_aborted
),
1079 atomic_read(&tgtp
->xmt_ls_rsp_xb_set
),
1080 atomic_read(&tgtp
->xmt_ls_rsp_error
));
1082 len
+= scnprintf(buf
+ len
, size
- len
,
1083 "FCP: Rcv %08x Defer %08x Release %08x "
1085 atomic_read(&tgtp
->rcv_fcp_cmd_in
),
1086 atomic_read(&tgtp
->rcv_fcp_cmd_defer
),
1087 atomic_read(&tgtp
->xmt_fcp_release
),
1088 atomic_read(&tgtp
->rcv_fcp_cmd_drop
));
1090 if (atomic_read(&tgtp
->rcv_fcp_cmd_in
) !=
1091 atomic_read(&tgtp
->rcv_fcp_cmd_out
)) {
1092 len
+= scnprintf(buf
+ len
, size
- len
,
1093 "Rcv FCP: in %08x != out %08x\n",
1094 atomic_read(&tgtp
->rcv_fcp_cmd_in
),
1095 atomic_read(&tgtp
->rcv_fcp_cmd_out
));
1098 len
+= scnprintf(buf
+ len
, size
- len
,
1099 "FCP Rsp: read %08x readrsp %08x "
1100 "write %08x rsp %08x\n",
1101 atomic_read(&tgtp
->xmt_fcp_read
),
1102 atomic_read(&tgtp
->xmt_fcp_read_rsp
),
1103 atomic_read(&tgtp
->xmt_fcp_write
),
1104 atomic_read(&tgtp
->xmt_fcp_rsp
));
1106 len
+= scnprintf(buf
+ len
, size
- len
,
1107 "FCP Rsp Cmpl: %08x err %08x drop %08x\n",
1108 atomic_read(&tgtp
->xmt_fcp_rsp_cmpl
),
1109 atomic_read(&tgtp
->xmt_fcp_rsp_error
),
1110 atomic_read(&tgtp
->xmt_fcp_rsp_drop
));
1112 len
+= scnprintf(buf
+ len
, size
- len
,
1113 "FCP Rsp Abort: %08x xb %08x xricqe %08x\n",
1114 atomic_read(&tgtp
->xmt_fcp_rsp_aborted
),
1115 atomic_read(&tgtp
->xmt_fcp_rsp_xb_set
),
1116 atomic_read(&tgtp
->xmt_fcp_xri_abort_cqe
));
1118 len
+= scnprintf(buf
+ len
, size
- len
,
1119 "ABORT: Xmt %08x Cmpl %08x\n",
1120 atomic_read(&tgtp
->xmt_fcp_abort
),
1121 atomic_read(&tgtp
->xmt_fcp_abort_cmpl
));
1123 len
+= scnprintf(buf
+ len
, size
- len
,
1124 "ABORT: Sol %08x Usol %08x Err %08x Cmpl %08x",
1125 atomic_read(&tgtp
->xmt_abort_sol
),
1126 atomic_read(&tgtp
->xmt_abort_unsol
),
1127 atomic_read(&tgtp
->xmt_abort_rsp
),
1128 atomic_read(&tgtp
->xmt_abort_rsp_error
));
1130 len
+= scnprintf(buf
+ len
, size
- len
, "\n");
1133 spin_lock(&phba
->sli4_hba
.abts_nvmet_buf_list_lock
);
1134 list_for_each_entry_safe(ctxp
, next_ctxp
,
1135 &phba
->sli4_hba
.lpfc_abts_nvmet_ctx_list
,
1139 spin_unlock(&phba
->sli4_hba
.abts_nvmet_buf_list_lock
);
1141 len
+= scnprintf(buf
+ len
, size
- len
,
1142 "ABORT: %d ctx entries\n", cnt
);
1143 spin_lock(&phba
->sli4_hba
.abts_nvmet_buf_list_lock
);
1144 list_for_each_entry_safe(ctxp
, next_ctxp
,
1145 &phba
->sli4_hba
.lpfc_abts_nvmet_ctx_list
,
1147 if (len
>= (size
- LPFC_DEBUG_OUT_LINE_SZ
))
1149 len
+= scnprintf(buf
+ len
, size
- len
,
1150 "Entry: oxid %x state %x "
1152 ctxp
->oxid
, ctxp
->state
,
1155 spin_unlock(&phba
->sli4_hba
.abts_nvmet_buf_list_lock
);
1158 /* Calculate outstanding IOs */
1159 tot
= atomic_read(&tgtp
->rcv_fcp_cmd_drop
);
1160 tot
+= atomic_read(&tgtp
->xmt_fcp_release
);
1161 tot
= atomic_read(&tgtp
->rcv_fcp_cmd_in
) - tot
;
1163 len
+= scnprintf(buf
+ len
, size
- len
,
1164 "IO_CTX: %08x WAIT: cur %08x tot %08x\n"
1165 "CTX Outstanding %08llx\n",
1166 phba
->sli4_hba
.nvmet_xri_cnt
,
1167 phba
->sli4_hba
.nvmet_io_wait_cnt
,
1168 phba
->sli4_hba
.nvmet_io_wait_total
,
1171 if (!(vport
->cfg_enable_fc4_type
& LPFC_ENABLE_NVME
))
1174 localport
= vport
->localport
;
1177 lport
= (struct lpfc_nvme_lport
*)localport
->private;
1181 len
+= scnprintf(buf
+ len
, size
- len
,
1182 "\nNVME HDWQ Statistics\n");
1184 len
+= scnprintf(buf
+ len
, size
- len
,
1185 "LS: Xmt %016x Cmpl %016x\n",
1186 atomic_read(&lport
->fc4NvmeLsRequests
),
1187 atomic_read(&lport
->fc4NvmeLsCmpls
));
1191 for (i
= 0; i
< phba
->cfg_hdw_queue
; i
++) {
1192 cstat
= &phba
->sli4_hba
.hdwq
[i
].nvme_cstat
;
1193 tot
= cstat
->io_cmpls
;
1195 data1
= cstat
->input_requests
;
1196 data2
= cstat
->output_requests
;
1197 data3
= cstat
->control_requests
;
1198 totout
+= (data1
+ data2
+ data3
);
1200 /* Limit to 32, debugfs display buffer limitation */
1204 len
+= scnprintf(buf
+ len
, PAGE_SIZE
- len
,
1205 "HDWQ (%d): Rd %016llx Wr %016llx "
1207 i
, data1
, data2
, data3
);
1208 len
+= scnprintf(buf
+ len
, PAGE_SIZE
- len
,
1209 "Cmpl %016llx OutIO %016llx\n",
1210 tot
, ((data1
+ data2
+ data3
) - tot
));
1212 len
+= scnprintf(buf
+ len
, PAGE_SIZE
- len
,
1213 "Total FCP Cmpl %016llx Issue %016llx "
1215 totin
, totout
, totout
- totin
);
1217 len
+= scnprintf(buf
+ len
, size
- len
,
1218 "LS Xmt Err: Abrt %08x Err %08x "
1219 "Cmpl Err: xb %08x Err %08x\n",
1220 atomic_read(&lport
->xmt_ls_abort
),
1221 atomic_read(&lport
->xmt_ls_err
),
1222 atomic_read(&lport
->cmpl_ls_xb
),
1223 atomic_read(&lport
->cmpl_ls_err
));
1225 len
+= scnprintf(buf
+ len
, size
- len
,
1226 "FCP Xmt Err: noxri %06x nondlp %06x "
1227 "qdepth %06x wqerr %06x err %06x Abrt %06x\n",
1228 atomic_read(&lport
->xmt_fcp_noxri
),
1229 atomic_read(&lport
->xmt_fcp_bad_ndlp
),
1230 atomic_read(&lport
->xmt_fcp_qdepth
),
1231 atomic_read(&lport
->xmt_fcp_wqerr
),
1232 atomic_read(&lport
->xmt_fcp_err
),
1233 atomic_read(&lport
->xmt_fcp_abort
));
1235 len
+= scnprintf(buf
+ len
, size
- len
,
1236 "FCP Cmpl Err: xb %08x Err %08x\n",
1237 atomic_read(&lport
->cmpl_fcp_xb
),
1238 atomic_read(&lport
->cmpl_fcp_err
));
1246 * lpfc_debugfs_scsistat_data - Dump target node list to a buffer
1247 * @vport: The vport to gather target node info from.
1248 * @buf: The buffer to dump log into.
1249 * @size: The maximum amount of data to process.
1252 * This routine dumps the SCSI statistics associated with @vport
1255 * This routine returns the amount of bytes that were dumped into @buf and will
1259 lpfc_debugfs_scsistat_data(struct lpfc_vport
*vport
, char *buf
, int size
)
1262 struct lpfc_hba
*phba
= vport
->phba
;
1263 struct lpfc_fc4_ctrl_stat
*cstat
;
1264 u64 data1
, data2
, data3
;
1265 u64 tot
, totin
, totout
;
1267 char tmp
[LPFC_MAX_SCSI_INFO_TMP_LEN
] = {0};
1269 if (!(vport
->cfg_enable_fc4_type
& LPFC_ENABLE_FCP
) ||
1270 (phba
->sli_rev
!= LPFC_SLI_REV4
))
1273 scnprintf(buf
, size
, "SCSI HDWQ Statistics\n");
1277 for (i
= 0; i
< phba
->cfg_hdw_queue
; i
++) {
1278 cstat
= &phba
->sli4_hba
.hdwq
[i
].scsi_cstat
;
1279 tot
= cstat
->io_cmpls
;
1281 data1
= cstat
->input_requests
;
1282 data2
= cstat
->output_requests
;
1283 data3
= cstat
->control_requests
;
1284 totout
+= (data1
+ data2
+ data3
);
1286 scnprintf(tmp
, sizeof(tmp
), "HDWQ (%d): Rd %016llx Wr %016llx "
1287 "IO %016llx ", i
, data1
, data2
, data3
);
1288 if (strlcat(buf
, tmp
, size
) >= size
)
1291 scnprintf(tmp
, sizeof(tmp
), "Cmpl %016llx OutIO %016llx\n",
1292 tot
, ((data1
+ data2
+ data3
) - tot
));
1293 if (strlcat(buf
, tmp
, size
) >= size
)
1296 scnprintf(tmp
, sizeof(tmp
), "Total FCP Cmpl %016llx Issue %016llx "
1297 "OutIO %016llx\n", totin
, totout
, totout
- totin
);
1298 strlcat(buf
, tmp
, size
);
1301 len
= strnlen(buf
, size
);
1307 * lpfc_debugfs_nvmektime_data - Dump target node list to a buffer
1308 * @vport: The vport to gather target node info from.
1309 * @buf: The buffer to dump log into.
1310 * @size: The maximum amount of data to process.
1313 * This routine dumps the NVME statistics associated with @vport
1316 * This routine returns the amount of bytes that were dumped into @buf and will
1320 lpfc_debugfs_nvmektime_data(struct lpfc_vport
*vport
, char *buf
, int size
)
1322 struct lpfc_hba
*phba
= vport
->phba
;
1325 if (phba
->nvmet_support
== 0) {
1326 /* NVME Initiator */
1327 len
+= scnprintf(buf
+ len
, PAGE_SIZE
- len
,
1328 "ktime %s: Total Samples: %lld\n",
1329 (phba
->ktime_on
? "Enabled" : "Disabled"),
1330 phba
->ktime_data_samples
);
1331 if (phba
->ktime_data_samples
== 0)
1335 buf
+ len
, PAGE_SIZE
- len
,
1336 "Segment 1: Last NVME Cmd cmpl "
1337 "done -to- Start of next NVME cnd (in driver)\n");
1339 buf
+ len
, PAGE_SIZE
- len
,
1340 "avg:%08lld min:%08lld max %08lld\n",
1341 div_u64(phba
->ktime_seg1_total
,
1342 phba
->ktime_data_samples
),
1343 phba
->ktime_seg1_min
,
1344 phba
->ktime_seg1_max
);
1346 buf
+ len
, PAGE_SIZE
- len
,
1347 "Segment 2: Driver start of NVME cmd "
1348 "-to- Firmware WQ doorbell\n");
1350 buf
+ len
, PAGE_SIZE
- len
,
1351 "avg:%08lld min:%08lld max %08lld\n",
1352 div_u64(phba
->ktime_seg2_total
,
1353 phba
->ktime_data_samples
),
1354 phba
->ktime_seg2_min
,
1355 phba
->ktime_seg2_max
);
1357 buf
+ len
, PAGE_SIZE
- len
,
1358 "Segment 3: Firmware WQ doorbell -to- "
1359 "MSI-X ISR cmpl\n");
1361 buf
+ len
, PAGE_SIZE
- len
,
1362 "avg:%08lld min:%08lld max %08lld\n",
1363 div_u64(phba
->ktime_seg3_total
,
1364 phba
->ktime_data_samples
),
1365 phba
->ktime_seg3_min
,
1366 phba
->ktime_seg3_max
);
1368 buf
+ len
, PAGE_SIZE
- len
,
1369 "Segment 4: MSI-X ISR cmpl -to- "
1370 "NVME cmpl done\n");
1372 buf
+ len
, PAGE_SIZE
- len
,
1373 "avg:%08lld min:%08lld max %08lld\n",
1374 div_u64(phba
->ktime_seg4_total
,
1375 phba
->ktime_data_samples
),
1376 phba
->ktime_seg4_min
,
1377 phba
->ktime_seg4_max
);
1379 buf
+ len
, PAGE_SIZE
- len
,
1380 "Total IO avg time: %08lld\n",
1381 div_u64(phba
->ktime_seg1_total
+
1382 phba
->ktime_seg2_total
+
1383 phba
->ktime_seg3_total
+
1384 phba
->ktime_seg4_total
,
1385 phba
->ktime_data_samples
));
1390 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
1391 "ktime %s: Total Samples: %lld %lld\n",
1392 (phba
->ktime_on
? "Enabled" : "Disabled"),
1393 phba
->ktime_data_samples
,
1394 phba
->ktime_status_samples
);
1395 if (phba
->ktime_data_samples
== 0)
1398 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
1399 "Segment 1: MSI-X ISR Rcv cmd -to- "
1400 "cmd pass to NVME Layer\n");
1401 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
1402 "avg:%08lld min:%08lld max %08lld\n",
1403 div_u64(phba
->ktime_seg1_total
,
1404 phba
->ktime_data_samples
),
1405 phba
->ktime_seg1_min
,
1406 phba
->ktime_seg1_max
);
1407 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
1408 "Segment 2: cmd pass to NVME Layer- "
1409 "-to- Driver rcv cmd OP (action)\n");
1410 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
1411 "avg:%08lld min:%08lld max %08lld\n",
1412 div_u64(phba
->ktime_seg2_total
,
1413 phba
->ktime_data_samples
),
1414 phba
->ktime_seg2_min
,
1415 phba
->ktime_seg2_max
);
1416 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
1417 "Segment 3: Driver rcv cmd OP -to- "
1418 "Firmware WQ doorbell: cmd\n");
1419 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
1420 "avg:%08lld min:%08lld max %08lld\n",
1421 div_u64(phba
->ktime_seg3_total
,
1422 phba
->ktime_data_samples
),
1423 phba
->ktime_seg3_min
,
1424 phba
->ktime_seg3_max
);
1425 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
1426 "Segment 4: Firmware WQ doorbell: cmd "
1427 "-to- MSI-X ISR for cmd cmpl\n");
1428 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
1429 "avg:%08lld min:%08lld max %08lld\n",
1430 div_u64(phba
->ktime_seg4_total
,
1431 phba
->ktime_data_samples
),
1432 phba
->ktime_seg4_min
,
1433 phba
->ktime_seg4_max
);
1434 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
1435 "Segment 5: MSI-X ISR for cmd cmpl "
1436 "-to- NVME layer passed cmd done\n");
1437 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
1438 "avg:%08lld min:%08lld max %08lld\n",
1439 div_u64(phba
->ktime_seg5_total
,
1440 phba
->ktime_data_samples
),
1441 phba
->ktime_seg5_min
,
1442 phba
->ktime_seg5_max
);
1444 if (phba
->ktime_status_samples
== 0) {
1445 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
1446 "Total: cmd received by MSI-X ISR "
1447 "-to- cmd completed on wire\n");
1448 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
1449 "avg:%08lld min:%08lld "
1451 div_u64(phba
->ktime_seg10_total
,
1452 phba
->ktime_data_samples
),
1453 phba
->ktime_seg10_min
,
1454 phba
->ktime_seg10_max
);
1458 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
1459 "Segment 6: NVME layer passed cmd done "
1460 "-to- Driver rcv rsp status OP\n");
1461 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
1462 "avg:%08lld min:%08lld max %08lld\n",
1463 div_u64(phba
->ktime_seg6_total
,
1464 phba
->ktime_status_samples
),
1465 phba
->ktime_seg6_min
,
1466 phba
->ktime_seg6_max
);
1467 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
1468 "Segment 7: Driver rcv rsp status OP "
1469 "-to- Firmware WQ doorbell: status\n");
1470 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
1471 "avg:%08lld min:%08lld max %08lld\n",
1472 div_u64(phba
->ktime_seg7_total
,
1473 phba
->ktime_status_samples
),
1474 phba
->ktime_seg7_min
,
1475 phba
->ktime_seg7_max
);
1476 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
1477 "Segment 8: Firmware WQ doorbell: status"
1478 " -to- MSI-X ISR for status cmpl\n");
1479 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
1480 "avg:%08lld min:%08lld max %08lld\n",
1481 div_u64(phba
->ktime_seg8_total
,
1482 phba
->ktime_status_samples
),
1483 phba
->ktime_seg8_min
,
1484 phba
->ktime_seg8_max
);
1485 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
1486 "Segment 9: MSI-X ISR for status cmpl "
1487 "-to- NVME layer passed status done\n");
1488 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
1489 "avg:%08lld min:%08lld max %08lld\n",
1490 div_u64(phba
->ktime_seg9_total
,
1491 phba
->ktime_status_samples
),
1492 phba
->ktime_seg9_min
,
1493 phba
->ktime_seg9_max
);
1494 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
1495 "Total: cmd received by MSI-X ISR -to- "
1496 "cmd completed on wire\n");
1497 len
+= scnprintf(buf
+ len
, PAGE_SIZE
-len
,
1498 "avg:%08lld min:%08lld max %08lld\n",
1499 div_u64(phba
->ktime_seg10_total
,
1500 phba
->ktime_status_samples
),
1501 phba
->ktime_seg10_min
,
1502 phba
->ktime_seg10_max
);
1507 * lpfc_debugfs_nvmeio_trc_data - Dump NVME IO trace list to a buffer
1508 * @phba: The phba to gather target node info from.
1509 * @buf: The buffer to dump log into.
1510 * @size: The maximum amount of data to process.
1513 * This routine dumps the NVME IO trace associated with @phba
1516 * This routine returns the amount of bytes that were dumped into @buf and will
1520 lpfc_debugfs_nvmeio_trc_data(struct lpfc_hba
*phba
, char *buf
, int size
)
1522 struct lpfc_debugfs_nvmeio_trc
*dtp
;
1523 int i
, state
, index
, skip
;
1526 state
= phba
->nvmeio_trc_on
;
1528 index
= (atomic_read(&phba
->nvmeio_trc_cnt
) + 1) &
1529 (phba
->nvmeio_trc_size
- 1);
1530 skip
= phba
->nvmeio_trc_output_idx
;
1532 len
+= scnprintf(buf
+ len
, size
- len
,
1533 "%s IO Trace %s: next_idx %d skip %d size %d\n",
1534 (phba
->nvmet_support
? "NVME" : "NVMET"),
1535 (state
? "Enabled" : "Disabled"),
1536 index
, skip
, phba
->nvmeio_trc_size
);
1538 if (!phba
->nvmeio_trc
|| state
)
1541 /* trace MUST bhe off to continue */
1543 for (i
= index
; i
< phba
->nvmeio_trc_size
; i
++) {
1548 dtp
= phba
->nvmeio_trc
+ i
;
1549 phba
->nvmeio_trc_output_idx
++;
1554 len
+= scnprintf(buf
+ len
, size
- len
, dtp
->fmt
,
1555 dtp
->data1
, dtp
->data2
, dtp
->data3
);
1557 if (phba
->nvmeio_trc_output_idx
>= phba
->nvmeio_trc_size
) {
1558 phba
->nvmeio_trc_output_idx
= 0;
1559 len
+= scnprintf(buf
+ len
, size
- len
,
1560 "Trace Complete\n");
1564 if (len
>= (size
- LPFC_DEBUG_OUT_LINE_SZ
)) {
1565 len
+= scnprintf(buf
+ len
, size
- len
,
1566 "Trace Continue (%d of %d)\n",
1567 phba
->nvmeio_trc_output_idx
,
1568 phba
->nvmeio_trc_size
);
1572 for (i
= 0; i
< index
; i
++) {
1577 dtp
= phba
->nvmeio_trc
+ i
;
1578 phba
->nvmeio_trc_output_idx
++;
1583 len
+= scnprintf(buf
+ len
, size
- len
, dtp
->fmt
,
1584 dtp
->data1
, dtp
->data2
, dtp
->data3
);
1586 if (phba
->nvmeio_trc_output_idx
>= phba
->nvmeio_trc_size
) {
1587 phba
->nvmeio_trc_output_idx
= 0;
1588 len
+= scnprintf(buf
+ len
, size
- len
,
1589 "Trace Complete\n");
1593 if (len
>= (size
- LPFC_DEBUG_OUT_LINE_SZ
)) {
1594 len
+= scnprintf(buf
+ len
, size
- len
,
1595 "Trace Continue (%d of %d)\n",
1596 phba
->nvmeio_trc_output_idx
,
1597 phba
->nvmeio_trc_size
);
1602 len
+= scnprintf(buf
+ len
, size
- len
,
1609 * lpfc_debugfs_cpucheck_data - Dump target node list to a buffer
1610 * @vport: The vport to gather target node info from.
1611 * @buf: The buffer to dump log into.
1612 * @size: The maximum amount of data to process.
1615 * This routine dumps the NVME statistics associated with @vport
1618 * This routine returns the amount of bytes that were dumped into @buf and will
1622 lpfc_debugfs_cpucheck_data(struct lpfc_vport
*vport
, char *buf
, int size
)
1624 struct lpfc_hba
*phba
= vport
->phba
;
1625 struct lpfc_sli4_hdw_queue
*qp
;
1632 len
+= scnprintf(buf
+ len
, PAGE_SIZE
- len
,
1634 (phba
->cpucheck_on
& LPFC_CHECK_NVME_IO
?
1635 "Enabled" : "Disabled"));
1636 if (phba
->nvmet_support
) {
1637 len
+= scnprintf(buf
+ len
, PAGE_SIZE
- len
,
1639 (phba
->cpucheck_on
& LPFC_CHECK_NVMET_RCV
?
1640 "Rcv Enabled\n" : "Rcv Disabled\n"));
1642 len
+= scnprintf(buf
+ len
, PAGE_SIZE
- len
, "\n");
1644 max_cnt
= size
- LPFC_DEBUG_OUT_LINE_SZ
;
1646 for (i
= 0; i
< phba
->cfg_hdw_queue
; i
++) {
1647 qp
= &phba
->sli4_hba
.hdwq
[i
];
1652 for (j
= 0; j
< LPFC_CHECK_CPU_CNT
; j
++) {
1653 tot_xmt
+= qp
->cpucheck_xmt_io
[j
];
1654 tot_cmpl
+= qp
->cpucheck_cmpl_io
[j
];
1655 if (phba
->nvmet_support
)
1656 tot_rcv
+= qp
->cpucheck_rcv_io
[j
];
1659 /* Only display Hardware Qs with something */
1660 if (!tot_xmt
&& !tot_cmpl
&& !tot_rcv
)
1663 len
+= scnprintf(buf
+ len
, PAGE_SIZE
- len
,
1665 for (j
= 0; j
< LPFC_CHECK_CPU_CNT
; j
++) {
1666 /* Only display non-zero counters */
1667 if (!qp
->cpucheck_xmt_io
[j
] &&
1668 !qp
->cpucheck_cmpl_io
[j
] &&
1669 !qp
->cpucheck_rcv_io
[j
])
1671 if (phba
->nvmet_support
) {
1672 len
+= scnprintf(buf
+ len
, PAGE_SIZE
- len
,
1673 "CPU %03d: %x/%x/%x ", j
,
1674 qp
->cpucheck_rcv_io
[j
],
1675 qp
->cpucheck_xmt_io
[j
],
1676 qp
->cpucheck_cmpl_io
[j
]);
1678 len
+= scnprintf(buf
+ len
, PAGE_SIZE
- len
,
1679 "CPU %03d: %x/%x ", j
,
1680 qp
->cpucheck_xmt_io
[j
],
1681 qp
->cpucheck_cmpl_io
[j
]);
1684 len
+= scnprintf(buf
+ len
, PAGE_SIZE
- len
,
1685 "Total: %x\n", tot_xmt
);
1686 if (len
>= max_cnt
) {
1687 len
+= scnprintf(buf
+ len
, PAGE_SIZE
- len
,
1698 * lpfc_debugfs_disc_trc - Store discovery trace log
1699 * @vport: The vport to associate this trace string with for retrieval.
1700 * @mask: Log entry classification.
1701 * @fmt: Format string to be displayed when dumping the log.
1702 * @data1: 1st data parameter to be applied to @fmt.
1703 * @data2: 2nd data parameter to be applied to @fmt.
1704 * @data3: 3rd data parameter to be applied to @fmt.
1707 * This routine is used by the driver code to add a debugfs log entry to the
1708 * discovery trace buffer associated with @vport. Only entries with a @mask that
1709 * match the current debugfs discovery mask will be saved. Entries that do not
1710 * match will be thrown away. @fmt, @data1, @data2, and @data3 are used like
1711 * printf when displaying the log.
1714 lpfc_debugfs_disc_trc(struct lpfc_vport
*vport
, int mask
, char *fmt
,
1715 uint32_t data1
, uint32_t data2
, uint32_t data3
)
1717 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
1718 struct lpfc_debugfs_trc
*dtp
;
1721 if (!(lpfc_debugfs_mask_disc_trc
& mask
))
1724 if (!lpfc_debugfs_enable
|| !lpfc_debugfs_max_disc_trc
||
1725 !vport
|| !vport
->disc_trc
)
1728 index
= atomic_inc_return(&vport
->disc_trc_cnt
) &
1729 (lpfc_debugfs_max_disc_trc
- 1);
1730 dtp
= vport
->disc_trc
+ index
;
1735 dtp
->seq_cnt
= atomic_inc_return(&lpfc_debugfs_seq_trc_cnt
);
1742 * lpfc_debugfs_slow_ring_trc - Store slow ring trace log
1743 * @phba: The phba to associate this trace string with for retrieval.
1744 * @fmt: Format string to be displayed when dumping the log.
1745 * @data1: 1st data parameter to be applied to @fmt.
1746 * @data2: 2nd data parameter to be applied to @fmt.
1747 * @data3: 3rd data parameter to be applied to @fmt.
1750 * This routine is used by the driver code to add a debugfs log entry to the
1751 * discovery trace buffer associated with @vport. @fmt, @data1, @data2, and
1752 * @data3 are used like printf when displaying the log.
1755 lpfc_debugfs_slow_ring_trc(struct lpfc_hba
*phba
, char *fmt
,
1756 uint32_t data1
, uint32_t data2
, uint32_t data3
)
1758 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
1759 struct lpfc_debugfs_trc
*dtp
;
1762 if (!lpfc_debugfs_enable
|| !lpfc_debugfs_max_slow_ring_trc
||
1763 !phba
|| !phba
->slow_ring_trc
)
1766 index
= atomic_inc_return(&phba
->slow_ring_trc_cnt
) &
1767 (lpfc_debugfs_max_slow_ring_trc
- 1);
1768 dtp
= phba
->slow_ring_trc
+ index
;
1773 dtp
->seq_cnt
= atomic_inc_return(&lpfc_debugfs_seq_trc_cnt
);
1780 * lpfc_debugfs_nvme_trc - Store NVME/NVMET trace log
1781 * @phba: The phba to associate this trace string with for retrieval.
1782 * @fmt: Format string to be displayed when dumping the log.
1783 * @data1: 1st data parameter to be applied to @fmt.
1784 * @data2: 2nd data parameter to be applied to @fmt.
1785 * @data3: 3rd data parameter to be applied to @fmt.
1788 * This routine is used by the driver code to add a debugfs log entry to the
1789 * nvme trace buffer associated with @phba. @fmt, @data1, @data2, and
1790 * @data3 are used like printf when displaying the log.
1793 lpfc_debugfs_nvme_trc(struct lpfc_hba
*phba
, char *fmt
,
1794 uint16_t data1
, uint16_t data2
, uint32_t data3
)
1796 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
1797 struct lpfc_debugfs_nvmeio_trc
*dtp
;
1800 if (!phba
->nvmeio_trc_on
|| !phba
->nvmeio_trc
)
1803 index
= atomic_inc_return(&phba
->nvmeio_trc_cnt
) &
1804 (phba
->nvmeio_trc_size
- 1);
1805 dtp
= phba
->nvmeio_trc
+ index
;
1813 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
1815 * lpfc_debugfs_disc_trc_open - Open the discovery trace log
1816 * @inode: The inode pointer that contains a vport pointer.
1817 * @file: The file pointer to attach the log output.
1820 * This routine is the entry point for the debugfs open file operation. It gets
1821 * the vport from the i_private field in @inode, allocates the necessary buffer
1822 * for the log, fills the buffer from the in-memory log for this vport, and then
1823 * returns a pointer to that log in the private_data field in @file.
1826 * This function returns zero if successful. On error it will return a negative
1830 lpfc_debugfs_disc_trc_open(struct inode
*inode
, struct file
*file
)
1832 struct lpfc_vport
*vport
= inode
->i_private
;
1833 struct lpfc_debug
*debug
;
1837 if (!lpfc_debugfs_max_disc_trc
) {
1842 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
1846 /* Round to page boundary */
1847 size
= (lpfc_debugfs_max_disc_trc
* LPFC_DEBUG_TRC_ENTRY_SIZE
);
1848 size
= PAGE_ALIGN(size
);
1850 debug
->buffer
= kmalloc(size
, GFP_KERNEL
);
1851 if (!debug
->buffer
) {
1856 debug
->len
= lpfc_debugfs_disc_trc_data(vport
, debug
->buffer
, size
);
1857 file
->private_data
= debug
;
1865 * lpfc_debugfs_slow_ring_trc_open - Open the Slow Ring trace log
1866 * @inode: The inode pointer that contains a vport pointer.
1867 * @file: The file pointer to attach the log output.
1870 * This routine is the entry point for the debugfs open file operation. It gets
1871 * the vport from the i_private field in @inode, allocates the necessary buffer
1872 * for the log, fills the buffer from the in-memory log for this vport, and then
1873 * returns a pointer to that log in the private_data field in @file.
1876 * This function returns zero if successful. On error it will return a negative
1880 lpfc_debugfs_slow_ring_trc_open(struct inode
*inode
, struct file
*file
)
1882 struct lpfc_hba
*phba
= inode
->i_private
;
1883 struct lpfc_debug
*debug
;
1887 if (!lpfc_debugfs_max_slow_ring_trc
) {
1892 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
1896 /* Round to page boundary */
1897 size
= (lpfc_debugfs_max_slow_ring_trc
* LPFC_DEBUG_TRC_ENTRY_SIZE
);
1898 size
= PAGE_ALIGN(size
);
1900 debug
->buffer
= kmalloc(size
, GFP_KERNEL
);
1901 if (!debug
->buffer
) {
1906 debug
->len
= lpfc_debugfs_slow_ring_trc_data(phba
, debug
->buffer
, size
);
1907 file
->private_data
= debug
;
1915 * lpfc_debugfs_hbqinfo_open - Open the hbqinfo debugfs buffer
1916 * @inode: The inode pointer that contains a vport pointer.
1917 * @file: The file pointer to attach the log output.
1920 * This routine is the entry point for the debugfs open file operation. It gets
1921 * the vport from the i_private field in @inode, allocates the necessary buffer
1922 * for the log, fills the buffer from the in-memory log for this vport, and then
1923 * returns a pointer to that log in the private_data field in @file.
1926 * This function returns zero if successful. On error it will return a negative
1930 lpfc_debugfs_hbqinfo_open(struct inode
*inode
, struct file
*file
)
1932 struct lpfc_hba
*phba
= inode
->i_private
;
1933 struct lpfc_debug
*debug
;
1936 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
1940 /* Round to page boundary */
1941 debug
->buffer
= kmalloc(LPFC_HBQINFO_SIZE
, GFP_KERNEL
);
1942 if (!debug
->buffer
) {
1947 debug
->len
= lpfc_debugfs_hbqinfo_data(phba
, debug
->buffer
,
1949 file
->private_data
= debug
;
1957 * lpfc_debugfs_multixripools_open - Open the multixripool debugfs buffer
1958 * @inode: The inode pointer that contains a hba pointer.
1959 * @file: The file pointer to attach the log output.
1962 * This routine is the entry point for the debugfs open file operation. It gets
1963 * the hba from the i_private field in @inode, allocates the necessary buffer
1964 * for the log, fills the buffer from the in-memory log for this hba, and then
1965 * returns a pointer to that log in the private_data field in @file.
1968 * This function returns zero if successful. On error it will return a negative
1972 lpfc_debugfs_multixripools_open(struct inode
*inode
, struct file
*file
)
1974 struct lpfc_hba
*phba
= inode
->i_private
;
1975 struct lpfc_debug
*debug
;
1978 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
1982 /* Round to page boundary */
1983 debug
->buffer
= kzalloc(LPFC_DUMP_MULTIXRIPOOL_SIZE
, GFP_KERNEL
);
1984 if (!debug
->buffer
) {
1989 debug
->len
= lpfc_debugfs_multixripools_data(
1990 phba
, debug
->buffer
, LPFC_DUMP_MULTIXRIPOOL_SIZE
);
1992 debug
->i_private
= inode
->i_private
;
1993 file
->private_data
= debug
;
2000 #ifdef LPFC_HDWQ_LOCK_STAT
2002 * lpfc_debugfs_lockstat_open - Open the lockstat debugfs buffer
2003 * @inode: The inode pointer that contains a vport pointer.
2004 * @file: The file pointer to attach the log output.
2007 * This routine is the entry point for the debugfs open file operation. It gets
2008 * the vport from the i_private field in @inode, allocates the necessary buffer
2009 * for the log, fills the buffer from the in-memory log for this vport, and then
2010 * returns a pointer to that log in the private_data field in @file.
2013 * This function returns zero if successful. On error it will return a negative
2017 lpfc_debugfs_lockstat_open(struct inode
*inode
, struct file
*file
)
2019 struct lpfc_hba
*phba
= inode
->i_private
;
2020 struct lpfc_debug
*debug
;
2023 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
2027 /* Round to page boundary */
2028 debug
->buffer
= kmalloc(LPFC_HDWQINFO_SIZE
, GFP_KERNEL
);
2029 if (!debug
->buffer
) {
2034 debug
->len
= lpfc_debugfs_lockstat_data(phba
, debug
->buffer
,
2036 file
->private_data
= debug
;
2044 lpfc_debugfs_lockstat_write(struct file
*file
, const char __user
*buf
,
2045 size_t nbytes
, loff_t
*ppos
)
2047 struct lpfc_debug
*debug
= file
->private_data
;
2048 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
2049 struct lpfc_sli4_hdw_queue
*qp
;
2054 /* Protect copy from user */
2055 if (!access_ok(buf
, nbytes
))
2058 memset(mybuf
, 0, sizeof(mybuf
));
2060 if (copy_from_user(mybuf
, buf
, nbytes
))
2064 if ((strncmp(pbuf
, "reset", strlen("reset")) == 0) ||
2065 (strncmp(pbuf
, "zero", strlen("zero")) == 0)) {
2066 for (i
= 0; i
< phba
->cfg_hdw_queue
; i
++) {
2067 qp
= &phba
->sli4_hba
.hdwq
[i
];
2068 qp
->lock_conflict
.alloc_xri_get
= 0;
2069 qp
->lock_conflict
.alloc_xri_put
= 0;
2070 qp
->lock_conflict
.free_xri
= 0;
2071 qp
->lock_conflict
.wq_access
= 0;
2072 qp
->lock_conflict
.alloc_pvt_pool
= 0;
2073 qp
->lock_conflict
.mv_from_pvt_pool
= 0;
2074 qp
->lock_conflict
.mv_to_pub_pool
= 0;
2075 qp
->lock_conflict
.mv_to_pvt_pool
= 0;
2076 qp
->lock_conflict
.free_pvt_pool
= 0;
2077 qp
->lock_conflict
.free_pub_pool
= 0;
2078 qp
->lock_conflict
.wq_access
= 0;
2086 * lpfc_debugfs_dumpHBASlim_open - Open the Dump HBA SLIM debugfs buffer
2087 * @inode: The inode pointer that contains a vport pointer.
2088 * @file: The file pointer to attach the log output.
2091 * This routine is the entry point for the debugfs open file operation. It gets
2092 * the vport from the i_private field in @inode, allocates the necessary buffer
2093 * for the log, fills the buffer from the in-memory log for this vport, and then
2094 * returns a pointer to that log in the private_data field in @file.
2097 * This function returns zero if successful. On error it will return a negative
2101 lpfc_debugfs_dumpHBASlim_open(struct inode
*inode
, struct file
*file
)
2103 struct lpfc_hba
*phba
= inode
->i_private
;
2104 struct lpfc_debug
*debug
;
2107 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
2111 /* Round to page boundary */
2112 debug
->buffer
= kmalloc(LPFC_DUMPHBASLIM_SIZE
, GFP_KERNEL
);
2113 if (!debug
->buffer
) {
2118 debug
->len
= lpfc_debugfs_dumpHBASlim_data(phba
, debug
->buffer
,
2119 LPFC_DUMPHBASLIM_SIZE
);
2120 file
->private_data
= debug
;
2128 * lpfc_debugfs_dumpHostSlim_open - Open the Dump Host SLIM debugfs buffer
2129 * @inode: The inode pointer that contains a vport pointer.
2130 * @file: The file pointer to attach the log output.
2133 * This routine is the entry point for the debugfs open file operation. It gets
2134 * the vport from the i_private field in @inode, allocates the necessary buffer
2135 * for the log, fills the buffer from the in-memory log for this vport, and then
2136 * returns a pointer to that log in the private_data field in @file.
2139 * This function returns zero if successful. On error it will return a negative
2143 lpfc_debugfs_dumpHostSlim_open(struct inode
*inode
, struct file
*file
)
2145 struct lpfc_hba
*phba
= inode
->i_private
;
2146 struct lpfc_debug
*debug
;
2149 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
2153 /* Round to page boundary */
2154 debug
->buffer
= kmalloc(LPFC_DUMPHOSTSLIM_SIZE
, GFP_KERNEL
);
2155 if (!debug
->buffer
) {
2160 debug
->len
= lpfc_debugfs_dumpHostSlim_data(phba
, debug
->buffer
,
2161 LPFC_DUMPHOSTSLIM_SIZE
);
2162 file
->private_data
= debug
;
2170 lpfc_debugfs_dumpData_open(struct inode
*inode
, struct file
*file
)
2172 struct lpfc_debug
*debug
;
2175 if (!_dump_buf_data
)
2178 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
2182 /* Round to page boundary */
2183 pr_err("9059 BLKGRD: %s: _dump_buf_data=0x%p\n",
2184 __func__
, _dump_buf_data
);
2185 debug
->buffer
= _dump_buf_data
;
2186 if (!debug
->buffer
) {
2191 debug
->len
= (1 << _dump_buf_data_order
) << PAGE_SHIFT
;
2192 file
->private_data
= debug
;
2200 lpfc_debugfs_dumpDif_open(struct inode
*inode
, struct file
*file
)
2202 struct lpfc_debug
*debug
;
2208 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
2212 /* Round to page boundary */
2213 pr_err("9060 BLKGRD: %s: _dump_buf_dif=0x%p file=%pD\n",
2214 __func__
, _dump_buf_dif
, file
);
2215 debug
->buffer
= _dump_buf_dif
;
2216 if (!debug
->buffer
) {
2221 debug
->len
= (1 << _dump_buf_dif_order
) << PAGE_SHIFT
;
2222 file
->private_data
= debug
;
2230 lpfc_debugfs_dumpDataDif_write(struct file
*file
, const char __user
*buf
,
2231 size_t nbytes
, loff_t
*ppos
)
2234 * The Data/DIF buffers only save one failing IO
2235 * The write op is used as a reset mechanism after an IO has
2236 * already been saved to the next one can be saved
2238 spin_lock(&_dump_buf_lock
);
2240 memset((void *)_dump_buf_data
, 0,
2241 ((1 << PAGE_SHIFT
) << _dump_buf_data_order
));
2242 memset((void *)_dump_buf_dif
, 0,
2243 ((1 << PAGE_SHIFT
) << _dump_buf_dif_order
));
2247 spin_unlock(&_dump_buf_lock
);
2253 lpfc_debugfs_dif_err_read(struct file
*file
, char __user
*buf
,
2254 size_t nbytes
, loff_t
*ppos
)
2256 struct dentry
*dent
= file
->f_path
.dentry
;
2257 struct lpfc_hba
*phba
= file
->private_data
;
2262 if (dent
== phba
->debug_writeGuard
)
2263 cnt
= scnprintf(cbuf
, 32, "%u\n", phba
->lpfc_injerr_wgrd_cnt
);
2264 else if (dent
== phba
->debug_writeApp
)
2265 cnt
= scnprintf(cbuf
, 32, "%u\n", phba
->lpfc_injerr_wapp_cnt
);
2266 else if (dent
== phba
->debug_writeRef
)
2267 cnt
= scnprintf(cbuf
, 32, "%u\n", phba
->lpfc_injerr_wref_cnt
);
2268 else if (dent
== phba
->debug_readGuard
)
2269 cnt
= scnprintf(cbuf
, 32, "%u\n", phba
->lpfc_injerr_rgrd_cnt
);
2270 else if (dent
== phba
->debug_readApp
)
2271 cnt
= scnprintf(cbuf
, 32, "%u\n", phba
->lpfc_injerr_rapp_cnt
);
2272 else if (dent
== phba
->debug_readRef
)
2273 cnt
= scnprintf(cbuf
, 32, "%u\n", phba
->lpfc_injerr_rref_cnt
);
2274 else if (dent
== phba
->debug_InjErrNPortID
)
2275 cnt
= scnprintf(cbuf
, 32, "0x%06x\n",
2276 phba
->lpfc_injerr_nportid
);
2277 else if (dent
== phba
->debug_InjErrWWPN
) {
2278 memcpy(&tmp
, &phba
->lpfc_injerr_wwpn
, sizeof(struct lpfc_name
));
2279 tmp
= cpu_to_be64(tmp
);
2280 cnt
= scnprintf(cbuf
, 32, "0x%016llx\n", tmp
);
2281 } else if (dent
== phba
->debug_InjErrLBA
) {
2282 if (phba
->lpfc_injerr_lba
== (sector_t
)(-1))
2283 cnt
= scnprintf(cbuf
, 32, "off\n");
2285 cnt
= scnprintf(cbuf
, 32, "0x%llx\n",
2286 (uint64_t) phba
->lpfc_injerr_lba
);
2288 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
2289 "0547 Unknown debugfs error injection entry\n");
2291 return simple_read_from_buffer(buf
, nbytes
, ppos
, &cbuf
, cnt
);
2295 lpfc_debugfs_dif_err_write(struct file
*file
, const char __user
*buf
,
2296 size_t nbytes
, loff_t
*ppos
)
2298 struct dentry
*dent
= file
->f_path
.dentry
;
2299 struct lpfc_hba
*phba
= file
->private_data
;
2304 memset(dstbuf
, 0, 33);
2305 size
= (nbytes
< 32) ? nbytes
: 32;
2306 if (copy_from_user(dstbuf
, buf
, size
))
2309 if (dent
== phba
->debug_InjErrLBA
) {
2310 if ((buf
[0] == 'o') && (buf
[1] == 'f') && (buf
[2] == 'f'))
2311 tmp
= (uint64_t)(-1);
2314 if ((tmp
== 0) && (kstrtoull(dstbuf
, 0, &tmp
)))
2317 if (dent
== phba
->debug_writeGuard
)
2318 phba
->lpfc_injerr_wgrd_cnt
= (uint32_t)tmp
;
2319 else if (dent
== phba
->debug_writeApp
)
2320 phba
->lpfc_injerr_wapp_cnt
= (uint32_t)tmp
;
2321 else if (dent
== phba
->debug_writeRef
)
2322 phba
->lpfc_injerr_wref_cnt
= (uint32_t)tmp
;
2323 else if (dent
== phba
->debug_readGuard
)
2324 phba
->lpfc_injerr_rgrd_cnt
= (uint32_t)tmp
;
2325 else if (dent
== phba
->debug_readApp
)
2326 phba
->lpfc_injerr_rapp_cnt
= (uint32_t)tmp
;
2327 else if (dent
== phba
->debug_readRef
)
2328 phba
->lpfc_injerr_rref_cnt
= (uint32_t)tmp
;
2329 else if (dent
== phba
->debug_InjErrLBA
)
2330 phba
->lpfc_injerr_lba
= (sector_t
)tmp
;
2331 else if (dent
== phba
->debug_InjErrNPortID
)
2332 phba
->lpfc_injerr_nportid
= (uint32_t)(tmp
& Mask_DID
);
2333 else if (dent
== phba
->debug_InjErrWWPN
) {
2334 tmp
= cpu_to_be64(tmp
);
2335 memcpy(&phba
->lpfc_injerr_wwpn
, &tmp
, sizeof(struct lpfc_name
));
2337 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
2338 "0548 Unknown debugfs error injection entry\n");
2344 lpfc_debugfs_dif_err_release(struct inode
*inode
, struct file
*file
)
2350 * lpfc_debugfs_nodelist_open - Open the nodelist debugfs file
2351 * @inode: The inode pointer that contains a vport pointer.
2352 * @file: The file pointer to attach the log output.
2355 * This routine is the entry point for the debugfs open file operation. It gets
2356 * the vport from the i_private field in @inode, allocates the necessary buffer
2357 * for the log, fills the buffer from the in-memory log for this vport, and then
2358 * returns a pointer to that log in the private_data field in @file.
2361 * This function returns zero if successful. On error it will return a negative
2365 lpfc_debugfs_nodelist_open(struct inode
*inode
, struct file
*file
)
2367 struct lpfc_vport
*vport
= inode
->i_private
;
2368 struct lpfc_debug
*debug
;
2371 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
2375 /* Round to page boundary */
2376 debug
->buffer
= kmalloc(LPFC_NODELIST_SIZE
, GFP_KERNEL
);
2377 if (!debug
->buffer
) {
2382 debug
->len
= lpfc_debugfs_nodelist_data(vport
, debug
->buffer
,
2383 LPFC_NODELIST_SIZE
);
2384 file
->private_data
= debug
;
2392 * lpfc_debugfs_lseek - Seek through a debugfs file
2393 * @file: The file pointer to seek through.
2394 * @off: The offset to seek to or the amount to seek by.
2395 * @whence: Indicates how to seek.
2398 * This routine is the entry point for the debugfs lseek file operation. The
2399 * @whence parameter indicates whether @off is the offset to directly seek to,
2400 * or if it is a value to seek forward or reverse by. This function figures out
2401 * what the new offset of the debugfs file will be and assigns that value to the
2402 * f_pos field of @file.
2405 * This function returns the new offset if successful and returns a negative
2406 * error if unable to process the seek.
2409 lpfc_debugfs_lseek(struct file
*file
, loff_t off
, int whence
)
2411 struct lpfc_debug
*debug
= file
->private_data
;
2412 return fixed_size_llseek(file
, off
, whence
, debug
->len
);
2416 * lpfc_debugfs_read - Read a debugfs file
2417 * @file: The file pointer to read from.
2418 * @buf: The buffer to copy the data to.
2419 * @nbytes: The number of bytes to read.
2420 * @ppos: The position in the file to start reading from.
2423 * This routine reads data from from the buffer indicated in the private_data
2424 * field of @file. It will start reading at @ppos and copy up to @nbytes of
2428 * This function returns the amount of data that was read (this could be less
2429 * than @nbytes if the end of the file was reached) or a negative error value.
2432 lpfc_debugfs_read(struct file
*file
, char __user
*buf
,
2433 size_t nbytes
, loff_t
*ppos
)
2435 struct lpfc_debug
*debug
= file
->private_data
;
2437 return simple_read_from_buffer(buf
, nbytes
, ppos
, debug
->buffer
,
2442 * lpfc_debugfs_release - Release the buffer used to store debugfs file data
2443 * @inode: The inode pointer that contains a vport pointer. (unused)
2444 * @file: The file pointer that contains the buffer to release.
2447 * This routine frees the buffer that was allocated when the debugfs file was
2451 * This function returns zero.
2454 lpfc_debugfs_release(struct inode
*inode
, struct file
*file
)
2456 struct lpfc_debug
*debug
= file
->private_data
;
2458 kfree(debug
->buffer
);
2465 lpfc_debugfs_dumpDataDif_release(struct inode
*inode
, struct file
*file
)
2467 struct lpfc_debug
*debug
= file
->private_data
;
2469 debug
->buffer
= NULL
;
2476 * lpfc_debugfs_multixripools_write - Clear multi-XRI pools statistics
2477 * @file: The file pointer to read from.
2478 * @buf: The buffer to copy the user data from.
2479 * @nbytes: The number of bytes to get.
2480 * @ppos: The position in the file to start reading from.
2483 * This routine clears multi-XRI pools statistics when buf contains "clear".
2486 * It returns the @nbytges passing in from debugfs user space when successful.
2487 * In case of error conditions, it returns proper error code back to the user
2491 lpfc_debugfs_multixripools_write(struct file
*file
, const char __user
*buf
,
2492 size_t nbytes
, loff_t
*ppos
)
2494 struct lpfc_debug
*debug
= file
->private_data
;
2495 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
2500 struct lpfc_sli4_hdw_queue
*qp
;
2501 struct lpfc_multixri_pool
*multixri_pool
;
2506 /* Protect copy from user */
2507 if (!access_ok(buf
, nbytes
))
2510 memset(mybuf
, 0, sizeof(mybuf
));
2512 if (copy_from_user(mybuf
, buf
, nbytes
))
2516 if ((strncmp(pbuf
, "clear", strlen("clear"))) == 0) {
2517 hwq_count
= phba
->cfg_hdw_queue
;
2518 for (i
= 0; i
< hwq_count
; i
++) {
2519 qp
= &phba
->sli4_hba
.hdwq
[i
];
2520 multixri_pool
= qp
->p_multixri_pool
;
2524 qp
->empty_io_bufs
= 0;
2525 multixri_pool
->pbl_empty_count
= 0;
2526 #ifdef LPFC_MXP_STAT
2527 multixri_pool
->above_limit_count
= 0;
2528 multixri_pool
->below_limit_count
= 0;
2529 multixri_pool
->stat_max_hwm
= 0;
2530 multixri_pool
->local_pbl_hit_count
= 0;
2531 multixri_pool
->other_pbl_hit_count
= 0;
2533 multixri_pool
->stat_pbl_count
= 0;
2534 multixri_pool
->stat_pvt_count
= 0;
2535 multixri_pool
->stat_busy_count
= 0;
2536 multixri_pool
->stat_snapshot_taken
= 0;
2539 return strlen(pbuf
);
2546 lpfc_debugfs_nvmestat_open(struct inode
*inode
, struct file
*file
)
2548 struct lpfc_vport
*vport
= inode
->i_private
;
2549 struct lpfc_debug
*debug
;
2552 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
2556 /* Round to page boundary */
2557 debug
->buffer
= kmalloc(LPFC_NVMESTAT_SIZE
, GFP_KERNEL
);
2558 if (!debug
->buffer
) {
2563 debug
->len
= lpfc_debugfs_nvmestat_data(vport
, debug
->buffer
,
2564 LPFC_NVMESTAT_SIZE
);
2566 debug
->i_private
= inode
->i_private
;
2567 file
->private_data
= debug
;
2575 lpfc_debugfs_nvmestat_write(struct file
*file
, const char __user
*buf
,
2576 size_t nbytes
, loff_t
*ppos
)
2578 struct lpfc_debug
*debug
= file
->private_data
;
2579 struct lpfc_vport
*vport
= (struct lpfc_vport
*)debug
->i_private
;
2580 struct lpfc_hba
*phba
= vport
->phba
;
2581 struct lpfc_nvmet_tgtport
*tgtp
;
2585 if (!phba
->targetport
)
2591 memset(mybuf
, 0, sizeof(mybuf
));
2593 if (copy_from_user(mybuf
, buf
, nbytes
))
2597 tgtp
= (struct lpfc_nvmet_tgtport
*)phba
->targetport
->private;
2598 if ((strncmp(pbuf
, "reset", strlen("reset")) == 0) ||
2599 (strncmp(pbuf
, "zero", strlen("zero")) == 0)) {
2600 atomic_set(&tgtp
->rcv_ls_req_in
, 0);
2601 atomic_set(&tgtp
->rcv_ls_req_out
, 0);
2602 atomic_set(&tgtp
->rcv_ls_req_drop
, 0);
2603 atomic_set(&tgtp
->xmt_ls_abort
, 0);
2604 atomic_set(&tgtp
->xmt_ls_abort_cmpl
, 0);
2605 atomic_set(&tgtp
->xmt_ls_rsp
, 0);
2606 atomic_set(&tgtp
->xmt_ls_drop
, 0);
2607 atomic_set(&tgtp
->xmt_ls_rsp_error
, 0);
2608 atomic_set(&tgtp
->xmt_ls_rsp_cmpl
, 0);
2610 atomic_set(&tgtp
->rcv_fcp_cmd_in
, 0);
2611 atomic_set(&tgtp
->rcv_fcp_cmd_out
, 0);
2612 atomic_set(&tgtp
->rcv_fcp_cmd_drop
, 0);
2613 atomic_set(&tgtp
->xmt_fcp_drop
, 0);
2614 atomic_set(&tgtp
->xmt_fcp_read_rsp
, 0);
2615 atomic_set(&tgtp
->xmt_fcp_read
, 0);
2616 atomic_set(&tgtp
->xmt_fcp_write
, 0);
2617 atomic_set(&tgtp
->xmt_fcp_rsp
, 0);
2618 atomic_set(&tgtp
->xmt_fcp_release
, 0);
2619 atomic_set(&tgtp
->xmt_fcp_rsp_cmpl
, 0);
2620 atomic_set(&tgtp
->xmt_fcp_rsp_error
, 0);
2621 atomic_set(&tgtp
->xmt_fcp_rsp_drop
, 0);
2623 atomic_set(&tgtp
->xmt_fcp_abort
, 0);
2624 atomic_set(&tgtp
->xmt_fcp_abort_cmpl
, 0);
2625 atomic_set(&tgtp
->xmt_abort_sol
, 0);
2626 atomic_set(&tgtp
->xmt_abort_unsol
, 0);
2627 atomic_set(&tgtp
->xmt_abort_rsp
, 0);
2628 atomic_set(&tgtp
->xmt_abort_rsp_error
, 0);
2634 lpfc_debugfs_scsistat_open(struct inode
*inode
, struct file
*file
)
2636 struct lpfc_vport
*vport
= inode
->i_private
;
2637 struct lpfc_debug
*debug
;
2640 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
2644 /* Round to page boundary */
2645 debug
->buffer
= kzalloc(LPFC_SCSISTAT_SIZE
, GFP_KERNEL
);
2646 if (!debug
->buffer
) {
2651 debug
->len
= lpfc_debugfs_scsistat_data(vport
, debug
->buffer
,
2652 LPFC_SCSISTAT_SIZE
);
2654 debug
->i_private
= inode
->i_private
;
2655 file
->private_data
= debug
;
2663 lpfc_debugfs_scsistat_write(struct file
*file
, const char __user
*buf
,
2664 size_t nbytes
, loff_t
*ppos
)
2666 struct lpfc_debug
*debug
= file
->private_data
;
2667 struct lpfc_vport
*vport
= (struct lpfc_vport
*)debug
->i_private
;
2668 struct lpfc_hba
*phba
= vport
->phba
;
2669 char mybuf
[6] = {0};
2672 /* Protect copy from user */
2673 if (!access_ok(buf
, nbytes
))
2676 if (copy_from_user(mybuf
, buf
, (nbytes
>= sizeof(mybuf
)) ?
2677 (sizeof(mybuf
) - 1) : nbytes
))
2680 if ((strncmp(&mybuf
[0], "reset", strlen("reset")) == 0) ||
2681 (strncmp(&mybuf
[0], "zero", strlen("zero")) == 0)) {
2682 for (i
= 0; i
< phba
->cfg_hdw_queue
; i
++) {
2683 memset(&phba
->sli4_hba
.hdwq
[i
].scsi_cstat
, 0,
2684 sizeof(phba
->sli4_hba
.hdwq
[i
].scsi_cstat
));
2692 lpfc_debugfs_nvmektime_open(struct inode
*inode
, struct file
*file
)
2694 struct lpfc_vport
*vport
= inode
->i_private
;
2695 struct lpfc_debug
*debug
;
2698 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
2702 /* Round to page boundary */
2703 debug
->buffer
= kmalloc(LPFC_NVMEKTIME_SIZE
, GFP_KERNEL
);
2704 if (!debug
->buffer
) {
2709 debug
->len
= lpfc_debugfs_nvmektime_data(vport
, debug
->buffer
,
2710 LPFC_NVMEKTIME_SIZE
);
2712 debug
->i_private
= inode
->i_private
;
2713 file
->private_data
= debug
;
2721 lpfc_debugfs_nvmektime_write(struct file
*file
, const char __user
*buf
,
2722 size_t nbytes
, loff_t
*ppos
)
2724 struct lpfc_debug
*debug
= file
->private_data
;
2725 struct lpfc_vport
*vport
= (struct lpfc_vport
*)debug
->i_private
;
2726 struct lpfc_hba
*phba
= vport
->phba
;
2733 memset(mybuf
, 0, sizeof(mybuf
));
2735 if (copy_from_user(mybuf
, buf
, nbytes
))
2739 if ((strncmp(pbuf
, "on", sizeof("on") - 1) == 0)) {
2740 phba
->ktime_data_samples
= 0;
2741 phba
->ktime_status_samples
= 0;
2742 phba
->ktime_seg1_total
= 0;
2743 phba
->ktime_seg1_max
= 0;
2744 phba
->ktime_seg1_min
= 0xffffffff;
2745 phba
->ktime_seg2_total
= 0;
2746 phba
->ktime_seg2_max
= 0;
2747 phba
->ktime_seg2_min
= 0xffffffff;
2748 phba
->ktime_seg3_total
= 0;
2749 phba
->ktime_seg3_max
= 0;
2750 phba
->ktime_seg3_min
= 0xffffffff;
2751 phba
->ktime_seg4_total
= 0;
2752 phba
->ktime_seg4_max
= 0;
2753 phba
->ktime_seg4_min
= 0xffffffff;
2754 phba
->ktime_seg5_total
= 0;
2755 phba
->ktime_seg5_max
= 0;
2756 phba
->ktime_seg5_min
= 0xffffffff;
2757 phba
->ktime_seg6_total
= 0;
2758 phba
->ktime_seg6_max
= 0;
2759 phba
->ktime_seg6_min
= 0xffffffff;
2760 phba
->ktime_seg7_total
= 0;
2761 phba
->ktime_seg7_max
= 0;
2762 phba
->ktime_seg7_min
= 0xffffffff;
2763 phba
->ktime_seg8_total
= 0;
2764 phba
->ktime_seg8_max
= 0;
2765 phba
->ktime_seg8_min
= 0xffffffff;
2766 phba
->ktime_seg9_total
= 0;
2767 phba
->ktime_seg9_max
= 0;
2768 phba
->ktime_seg9_min
= 0xffffffff;
2769 phba
->ktime_seg10_total
= 0;
2770 phba
->ktime_seg10_max
= 0;
2771 phba
->ktime_seg10_min
= 0xffffffff;
2774 return strlen(pbuf
);
2775 } else if ((strncmp(pbuf
, "off",
2776 sizeof("off") - 1) == 0)) {
2778 return strlen(pbuf
);
2779 } else if ((strncmp(pbuf
, "zero",
2780 sizeof("zero") - 1) == 0)) {
2781 phba
->ktime_data_samples
= 0;
2782 phba
->ktime_status_samples
= 0;
2783 phba
->ktime_seg1_total
= 0;
2784 phba
->ktime_seg1_max
= 0;
2785 phba
->ktime_seg1_min
= 0xffffffff;
2786 phba
->ktime_seg2_total
= 0;
2787 phba
->ktime_seg2_max
= 0;
2788 phba
->ktime_seg2_min
= 0xffffffff;
2789 phba
->ktime_seg3_total
= 0;
2790 phba
->ktime_seg3_max
= 0;
2791 phba
->ktime_seg3_min
= 0xffffffff;
2792 phba
->ktime_seg4_total
= 0;
2793 phba
->ktime_seg4_max
= 0;
2794 phba
->ktime_seg4_min
= 0xffffffff;
2795 phba
->ktime_seg5_total
= 0;
2796 phba
->ktime_seg5_max
= 0;
2797 phba
->ktime_seg5_min
= 0xffffffff;
2798 phba
->ktime_seg6_total
= 0;
2799 phba
->ktime_seg6_max
= 0;
2800 phba
->ktime_seg6_min
= 0xffffffff;
2801 phba
->ktime_seg7_total
= 0;
2802 phba
->ktime_seg7_max
= 0;
2803 phba
->ktime_seg7_min
= 0xffffffff;
2804 phba
->ktime_seg8_total
= 0;
2805 phba
->ktime_seg8_max
= 0;
2806 phba
->ktime_seg8_min
= 0xffffffff;
2807 phba
->ktime_seg9_total
= 0;
2808 phba
->ktime_seg9_max
= 0;
2809 phba
->ktime_seg9_min
= 0xffffffff;
2810 phba
->ktime_seg10_total
= 0;
2811 phba
->ktime_seg10_max
= 0;
2812 phba
->ktime_seg10_min
= 0xffffffff;
2813 return strlen(pbuf
);
2819 lpfc_debugfs_nvmeio_trc_open(struct inode
*inode
, struct file
*file
)
2821 struct lpfc_hba
*phba
= inode
->i_private
;
2822 struct lpfc_debug
*debug
;
2825 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
2829 /* Round to page boundary */
2830 debug
->buffer
= kmalloc(LPFC_NVMEIO_TRC_SIZE
, GFP_KERNEL
);
2831 if (!debug
->buffer
) {
2836 debug
->len
= lpfc_debugfs_nvmeio_trc_data(phba
, debug
->buffer
,
2837 LPFC_NVMEIO_TRC_SIZE
);
2839 debug
->i_private
= inode
->i_private
;
2840 file
->private_data
= debug
;
2848 lpfc_debugfs_nvmeio_trc_write(struct file
*file
, const char __user
*buf
,
2849 size_t nbytes
, loff_t
*ppos
)
2851 struct lpfc_debug
*debug
= file
->private_data
;
2852 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
2861 memset(mybuf
, 0, sizeof(mybuf
));
2863 if (copy_from_user(mybuf
, buf
, nbytes
))
2867 if ((strncmp(pbuf
, "off", sizeof("off") - 1) == 0)) {
2868 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
2869 "0570 nvmeio_trc_off\n");
2870 phba
->nvmeio_trc_output_idx
= 0;
2871 phba
->nvmeio_trc_on
= 0;
2872 return strlen(pbuf
);
2873 } else if ((strncmp(pbuf
, "on", sizeof("on") - 1) == 0)) {
2874 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
2875 "0571 nvmeio_trc_on\n");
2876 phba
->nvmeio_trc_output_idx
= 0;
2877 phba
->nvmeio_trc_on
= 1;
2878 return strlen(pbuf
);
2881 /* We must be off to allocate the trace buffer */
2882 if (phba
->nvmeio_trc_on
!= 0)
2885 /* If not on or off, the parameter is the trace buffer size */
2886 i
= kstrtoul(pbuf
, 0, &sz
);
2889 phba
->nvmeio_trc_size
= (uint32_t)sz
;
2891 /* It must be a power of 2 - round down */
2898 if (phba
->nvmeio_trc_size
!= sz
)
2899 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
2900 "0572 nvmeio_trc_size changed to %ld\n",
2902 phba
->nvmeio_trc_size
= (uint32_t)sz
;
2904 /* If one previously exists, free it */
2905 kfree(phba
->nvmeio_trc
);
2907 /* Allocate new trace buffer and initialize */
2908 phba
->nvmeio_trc
= kzalloc((sizeof(struct lpfc_debugfs_nvmeio_trc
) *
2910 if (!phba
->nvmeio_trc
) {
2911 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
2912 "0573 Cannot create debugfs "
2913 "nvmeio_trc buffer\n");
2916 atomic_set(&phba
->nvmeio_trc_cnt
, 0);
2917 phba
->nvmeio_trc_on
= 0;
2918 phba
->nvmeio_trc_output_idx
= 0;
2920 return strlen(pbuf
);
2924 lpfc_debugfs_cpucheck_open(struct inode
*inode
, struct file
*file
)
2926 struct lpfc_vport
*vport
= inode
->i_private
;
2927 struct lpfc_debug
*debug
;
2930 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
2934 /* Round to page boundary */
2935 debug
->buffer
= kmalloc(LPFC_CPUCHECK_SIZE
, GFP_KERNEL
);
2936 if (!debug
->buffer
) {
2941 debug
->len
= lpfc_debugfs_cpucheck_data(vport
, debug
->buffer
,
2942 LPFC_CPUCHECK_SIZE
);
2944 debug
->i_private
= inode
->i_private
;
2945 file
->private_data
= debug
;
2953 lpfc_debugfs_cpucheck_write(struct file
*file
, const char __user
*buf
,
2954 size_t nbytes
, loff_t
*ppos
)
2956 struct lpfc_debug
*debug
= file
->private_data
;
2957 struct lpfc_vport
*vport
= (struct lpfc_vport
*)debug
->i_private
;
2958 struct lpfc_hba
*phba
= vport
->phba
;
2959 struct lpfc_sli4_hdw_queue
*qp
;
2967 memset(mybuf
, 0, sizeof(mybuf
));
2969 if (copy_from_user(mybuf
, buf
, nbytes
))
2973 if ((strncmp(pbuf
, "on", sizeof("on") - 1) == 0)) {
2974 if (phba
->nvmet_support
)
2975 phba
->cpucheck_on
|= LPFC_CHECK_NVMET_IO
;
2977 phba
->cpucheck_on
|= (LPFC_CHECK_NVME_IO
|
2978 LPFC_CHECK_SCSI_IO
);
2979 return strlen(pbuf
);
2980 } else if ((strncmp(pbuf
, "nvme_on", sizeof("nvme_on") - 1) == 0)) {
2981 if (phba
->nvmet_support
)
2982 phba
->cpucheck_on
|= LPFC_CHECK_NVMET_IO
;
2984 phba
->cpucheck_on
|= LPFC_CHECK_NVME_IO
;
2985 return strlen(pbuf
);
2986 } else if ((strncmp(pbuf
, "scsi_on", sizeof("scsi_on") - 1) == 0)) {
2987 phba
->cpucheck_on
|= LPFC_CHECK_SCSI_IO
;
2988 return strlen(pbuf
);
2989 } else if ((strncmp(pbuf
, "rcv",
2990 sizeof("rcv") - 1) == 0)) {
2991 if (phba
->nvmet_support
)
2992 phba
->cpucheck_on
|= LPFC_CHECK_NVMET_RCV
;
2995 return strlen(pbuf
);
2996 } else if ((strncmp(pbuf
, "off",
2997 sizeof("off") - 1) == 0)) {
2998 phba
->cpucheck_on
= LPFC_CHECK_OFF
;
2999 return strlen(pbuf
);
3000 } else if ((strncmp(pbuf
, "zero",
3001 sizeof("zero") - 1) == 0)) {
3002 for (i
= 0; i
< phba
->cfg_hdw_queue
; i
++) {
3003 qp
= &phba
->sli4_hba
.hdwq
[i
];
3005 for (j
= 0; j
< LPFC_CHECK_CPU_CNT
; j
++) {
3006 qp
->cpucheck_rcv_io
[j
] = 0;
3007 qp
->cpucheck_xmt_io
[j
] = 0;
3008 qp
->cpucheck_cmpl_io
[j
] = 0;
3011 return strlen(pbuf
);
3017 * ---------------------------------
3018 * iDiag debugfs file access methods
3019 * ---------------------------------
3021 * All access methods are through the proper SLI4 PCI function's debugfs
3024 * /sys/kernel/debug/lpfc/fn<#>/iDiag
3028 * lpfc_idiag_cmd_get - Get and parse idiag debugfs comands from user space
3029 * @buf: The pointer to the user space buffer.
3030 * @nbytes: The number of bytes in the user space buffer.
3031 * @idiag_cmd: pointer to the idiag command struct.
3033 * This routine reads data from debugfs user space buffer and parses the
3034 * buffer for getting the idiag command and arguments. The while space in
3035 * between the set of data is used as the parsing separator.
3037 * This routine returns 0 when successful, it returns proper error code
3038 * back to the user space in error conditions.
3040 static int lpfc_idiag_cmd_get(const char __user
*buf
, size_t nbytes
,
3041 struct lpfc_idiag_cmd
*idiag_cmd
)
3044 char *pbuf
, *step_str
;
3048 memset(mybuf
, 0, sizeof(mybuf
));
3049 memset(idiag_cmd
, 0, sizeof(*idiag_cmd
));
3050 bsize
= min(nbytes
, (sizeof(mybuf
)-1));
3052 if (copy_from_user(mybuf
, buf
, bsize
))
3055 step_str
= strsep(&pbuf
, "\t ");
3057 /* The opcode must present */
3061 idiag_cmd
->opcode
= simple_strtol(step_str
, NULL
, 0);
3062 if (idiag_cmd
->opcode
== 0)
3065 for (i
= 0; i
< LPFC_IDIAG_CMD_DATA_SIZE
; i
++) {
3066 step_str
= strsep(&pbuf
, "\t ");
3069 idiag_cmd
->data
[i
] = simple_strtol(step_str
, NULL
, 0);
3075 * lpfc_idiag_open - idiag open debugfs
3076 * @inode: The inode pointer that contains a pointer to phba.
3077 * @file: The file pointer to attach the file operation.
3080 * This routine is the entry point for the debugfs open file operation. It
3081 * gets the reference to phba from the i_private field in @inode, it then
3082 * allocates buffer for the file operation, performs the necessary PCI config
3083 * space read into the allocated buffer according to the idiag user command
3084 * setup, and then returns a pointer to buffer in the private_data field in
3088 * This function returns zero if successful. On error it will return an
3089 * negative error value.
3092 lpfc_idiag_open(struct inode
*inode
, struct file
*file
)
3094 struct lpfc_debug
*debug
;
3096 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
3100 debug
->i_private
= inode
->i_private
;
3101 debug
->buffer
= NULL
;
3102 file
->private_data
= debug
;
3108 * lpfc_idiag_release - Release idiag access file operation
3109 * @inode: The inode pointer that contains a vport pointer. (unused)
3110 * @file: The file pointer that contains the buffer to release.
3113 * This routine is the generic release routine for the idiag access file
3114 * operation, it frees the buffer that was allocated when the debugfs file
3118 * This function returns zero.
3121 lpfc_idiag_release(struct inode
*inode
, struct file
*file
)
3123 struct lpfc_debug
*debug
= file
->private_data
;
3125 /* Free the buffers to the file operation */
3126 kfree(debug
->buffer
);
3133 * lpfc_idiag_cmd_release - Release idiag cmd access file operation
3134 * @inode: The inode pointer that contains a vport pointer. (unused)
3135 * @file: The file pointer that contains the buffer to release.
3138 * This routine frees the buffer that was allocated when the debugfs file
3139 * was opened. It also reset the fields in the idiag command struct in the
3140 * case of command for write operation.
3143 * This function returns zero.
3146 lpfc_idiag_cmd_release(struct inode
*inode
, struct file
*file
)
3148 struct lpfc_debug
*debug
= file
->private_data
;
3150 if (debug
->op
== LPFC_IDIAG_OP_WR
) {
3151 switch (idiag
.cmd
.opcode
) {
3152 case LPFC_IDIAG_CMD_PCICFG_WR
:
3153 case LPFC_IDIAG_CMD_PCICFG_ST
:
3154 case LPFC_IDIAG_CMD_PCICFG_CL
:
3155 case LPFC_IDIAG_CMD_QUEACC_WR
:
3156 case LPFC_IDIAG_CMD_QUEACC_ST
:
3157 case LPFC_IDIAG_CMD_QUEACC_CL
:
3158 memset(&idiag
, 0, sizeof(idiag
));
3165 /* Free the buffers to the file operation */
3166 kfree(debug
->buffer
);
3173 * lpfc_idiag_pcicfg_read - idiag debugfs read pcicfg
3174 * @file: The file pointer to read from.
3175 * @buf: The buffer to copy the data to.
3176 * @nbytes: The number of bytes to read.
3177 * @ppos: The position in the file to start reading from.
3180 * This routine reads data from the @phba pci config space according to the
3181 * idiag command, and copies to user @buf. Depending on the PCI config space
3182 * read command setup, it does either a single register read of a byte
3183 * (8 bits), a word (16 bits), or a dword (32 bits) or browsing through all
3184 * registers from the 4K extended PCI config space.
3187 * This function returns the amount of data that was read (this could be less
3188 * than @nbytes if the end of the file was reached) or a negative error value.
3191 lpfc_idiag_pcicfg_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
3194 struct lpfc_debug
*debug
= file
->private_data
;
3195 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
3196 int offset_label
, offset
, len
= 0, index
= LPFC_PCI_CFG_RD_SIZE
;
3199 struct pci_dev
*pdev
;
3204 pdev
= phba
->pcidev
;
3208 /* This is a user read operation */
3209 debug
->op
= LPFC_IDIAG_OP_RD
;
3212 debug
->buffer
= kmalloc(LPFC_PCI_CFG_SIZE
, GFP_KERNEL
);
3215 pbuffer
= debug
->buffer
;
3220 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_RD
) {
3221 where
= idiag
.cmd
.data
[IDIAG_PCICFG_WHERE_INDX
];
3222 count
= idiag
.cmd
.data
[IDIAG_PCICFG_COUNT_INDX
];
3226 /* Read single PCI config space register */
3228 case SIZE_U8
: /* byte (8 bits) */
3229 pci_read_config_byte(pdev
, where
, &u8val
);
3230 len
+= scnprintf(pbuffer
+len
, LPFC_PCI_CFG_SIZE
-len
,
3231 "%03x: %02x\n", where
, u8val
);
3233 case SIZE_U16
: /* word (16 bits) */
3234 pci_read_config_word(pdev
, where
, &u16val
);
3235 len
+= scnprintf(pbuffer
+len
, LPFC_PCI_CFG_SIZE
-len
,
3236 "%03x: %04x\n", where
, u16val
);
3238 case SIZE_U32
: /* double word (32 bits) */
3239 pci_read_config_dword(pdev
, where
, &u32val
);
3240 len
+= scnprintf(pbuffer
+len
, LPFC_PCI_CFG_SIZE
-len
,
3241 "%03x: %08x\n", where
, u32val
);
3243 case LPFC_PCI_CFG_BROWSE
: /* browse all */
3251 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
3255 /* Browse all PCI config space registers */
3256 offset_label
= idiag
.offset
.last_rd
;
3257 offset
= offset_label
;
3259 /* Read PCI config space */
3260 len
+= scnprintf(pbuffer
+len
, LPFC_PCI_CFG_SIZE
-len
,
3261 "%03x: ", offset_label
);
3263 pci_read_config_dword(pdev
, offset
, &u32val
);
3264 len
+= scnprintf(pbuffer
+len
, LPFC_PCI_CFG_SIZE
-len
,
3266 offset
+= sizeof(uint32_t);
3267 if (offset
>= LPFC_PCI_CFG_SIZE
) {
3268 len
+= scnprintf(pbuffer
+len
,
3269 LPFC_PCI_CFG_SIZE
-len
, "\n");
3272 index
-= sizeof(uint32_t);
3274 len
+= scnprintf(pbuffer
+len
, LPFC_PCI_CFG_SIZE
-len
,
3276 else if (!(index
% (8 * sizeof(uint32_t)))) {
3277 offset_label
+= (8 * sizeof(uint32_t));
3278 len
+= scnprintf(pbuffer
+len
, LPFC_PCI_CFG_SIZE
-len
,
3279 "\n%03x: ", offset_label
);
3283 /* Set up the offset for next portion of pci cfg read */
3285 idiag
.offset
.last_rd
+= LPFC_PCI_CFG_RD_SIZE
;
3286 if (idiag
.offset
.last_rd
>= LPFC_PCI_CFG_SIZE
)
3287 idiag
.offset
.last_rd
= 0;
3289 idiag
.offset
.last_rd
= 0;
3291 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
3295 * lpfc_idiag_pcicfg_write - Syntax check and set up idiag pcicfg commands
3296 * @file: The file pointer to read from.
3297 * @buf: The buffer to copy the user data from.
3298 * @nbytes: The number of bytes to get.
3299 * @ppos: The position in the file to start reading from.
3301 * This routine get the debugfs idiag command struct from user space and
3302 * then perform the syntax check for PCI config space read or write command
3303 * accordingly. In the case of PCI config space read command, it sets up
3304 * the command in the idiag command struct for the debugfs read operation.
3305 * In the case of PCI config space write operation, it executes the write
3306 * operation into the PCI config space accordingly.
3308 * It returns the @nbytges passing in from debugfs user space when successful.
3309 * In case of error conditions, it returns proper error code back to the user
3313 lpfc_idiag_pcicfg_write(struct file
*file
, const char __user
*buf
,
3314 size_t nbytes
, loff_t
*ppos
)
3316 struct lpfc_debug
*debug
= file
->private_data
;
3317 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
3318 uint32_t where
, value
, count
;
3322 struct pci_dev
*pdev
;
3325 pdev
= phba
->pcidev
;
3329 /* This is a user write operation */
3330 debug
->op
= LPFC_IDIAG_OP_WR
;
3332 rc
= lpfc_idiag_cmd_get(buf
, nbytes
, &idiag
.cmd
);
3336 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_RD
) {
3337 /* Sanity check on PCI config read command line arguments */
3338 if (rc
!= LPFC_PCI_CFG_RD_CMD_ARG
)
3340 /* Read command from PCI config space, set up command fields */
3341 where
= idiag
.cmd
.data
[IDIAG_PCICFG_WHERE_INDX
];
3342 count
= idiag
.cmd
.data
[IDIAG_PCICFG_COUNT_INDX
];
3343 if (count
== LPFC_PCI_CFG_BROWSE
) {
3344 if (where
% sizeof(uint32_t))
3346 /* Starting offset to browse */
3347 idiag
.offset
.last_rd
= where
;
3348 } else if ((count
!= sizeof(uint8_t)) &&
3349 (count
!= sizeof(uint16_t)) &&
3350 (count
!= sizeof(uint32_t)))
3352 if (count
== sizeof(uint8_t)) {
3353 if (where
> LPFC_PCI_CFG_SIZE
- sizeof(uint8_t))
3355 if (where
% sizeof(uint8_t))
3358 if (count
== sizeof(uint16_t)) {
3359 if (where
> LPFC_PCI_CFG_SIZE
- sizeof(uint16_t))
3361 if (where
% sizeof(uint16_t))
3364 if (count
== sizeof(uint32_t)) {
3365 if (where
> LPFC_PCI_CFG_SIZE
- sizeof(uint32_t))
3367 if (where
% sizeof(uint32_t))
3370 } else if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_WR
||
3371 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_ST
||
3372 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_CL
) {
3373 /* Sanity check on PCI config write command line arguments */
3374 if (rc
!= LPFC_PCI_CFG_WR_CMD_ARG
)
3376 /* Write command to PCI config space, read-modify-write */
3377 where
= idiag
.cmd
.data
[IDIAG_PCICFG_WHERE_INDX
];
3378 count
= idiag
.cmd
.data
[IDIAG_PCICFG_COUNT_INDX
];
3379 value
= idiag
.cmd
.data
[IDIAG_PCICFG_VALUE_INDX
];
3381 if ((count
!= sizeof(uint8_t)) &&
3382 (count
!= sizeof(uint16_t)) &&
3383 (count
!= sizeof(uint32_t)))
3385 if (count
== sizeof(uint8_t)) {
3386 if (where
> LPFC_PCI_CFG_SIZE
- sizeof(uint8_t))
3388 if (where
% sizeof(uint8_t))
3390 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_WR
)
3391 pci_write_config_byte(pdev
, where
,
3393 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_ST
) {
3394 rc
= pci_read_config_byte(pdev
, where
, &u8val
);
3396 u8val
|= (uint8_t)value
;
3397 pci_write_config_byte(pdev
, where
,
3401 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_CL
) {
3402 rc
= pci_read_config_byte(pdev
, where
, &u8val
);
3404 u8val
&= (uint8_t)(~value
);
3405 pci_write_config_byte(pdev
, where
,
3410 if (count
== sizeof(uint16_t)) {
3411 if (where
> LPFC_PCI_CFG_SIZE
- sizeof(uint16_t))
3413 if (where
% sizeof(uint16_t))
3415 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_WR
)
3416 pci_write_config_word(pdev
, where
,
3418 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_ST
) {
3419 rc
= pci_read_config_word(pdev
, where
, &u16val
);
3421 u16val
|= (uint16_t)value
;
3422 pci_write_config_word(pdev
, where
,
3426 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_CL
) {
3427 rc
= pci_read_config_word(pdev
, where
, &u16val
);
3429 u16val
&= (uint16_t)(~value
);
3430 pci_write_config_word(pdev
, where
,
3435 if (count
== sizeof(uint32_t)) {
3436 if (where
> LPFC_PCI_CFG_SIZE
- sizeof(uint32_t))
3438 if (where
% sizeof(uint32_t))
3440 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_WR
)
3441 pci_write_config_dword(pdev
, where
, value
);
3442 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_ST
) {
3443 rc
= pci_read_config_dword(pdev
, where
,
3447 pci_write_config_dword(pdev
, where
,
3451 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_CL
) {
3452 rc
= pci_read_config_dword(pdev
, where
,
3456 pci_write_config_dword(pdev
, where
,
3462 /* All other opecodes are illegal for now */
3467 memset(&idiag
, 0, sizeof(idiag
));
3472 * lpfc_idiag_baracc_read - idiag debugfs pci bar access read
3473 * @file: The file pointer to read from.
3474 * @buf: The buffer to copy the data to.
3475 * @nbytes: The number of bytes to read.
3476 * @ppos: The position in the file to start reading from.
3479 * This routine reads data from the @phba pci bar memory mapped space
3480 * according to the idiag command, and copies to user @buf.
3483 * This function returns the amount of data that was read (this could be less
3484 * than @nbytes if the end of the file was reached) or a negative error value.
3487 lpfc_idiag_baracc_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
3490 struct lpfc_debug
*debug
= file
->private_data
;
3491 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
3492 int offset_label
, offset
, offset_run
, len
= 0, index
;
3493 int bar_num
, acc_range
, bar_size
;
3495 void __iomem
*mem_mapped_bar
;
3497 struct pci_dev
*pdev
;
3500 pdev
= phba
->pcidev
;
3504 /* This is a user read operation */
3505 debug
->op
= LPFC_IDIAG_OP_RD
;
3508 debug
->buffer
= kmalloc(LPFC_PCI_BAR_RD_BUF_SIZE
, GFP_KERNEL
);
3511 pbuffer
= debug
->buffer
;
3516 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_RD
) {
3517 bar_num
= idiag
.cmd
.data
[IDIAG_BARACC_BAR_NUM_INDX
];
3518 offset
= idiag
.cmd
.data
[IDIAG_BARACC_OFF_SET_INDX
];
3519 acc_range
= idiag
.cmd
.data
[IDIAG_BARACC_ACC_MOD_INDX
];
3520 bar_size
= idiag
.cmd
.data
[IDIAG_BARACC_BAR_SZE_INDX
];
3527 if_type
= bf_get(lpfc_sli_intf_if_type
, &phba
->sli4_hba
.sli_intf
);
3528 if (if_type
== LPFC_SLI_INTF_IF_TYPE_0
) {
3529 if (bar_num
== IDIAG_BARACC_BAR_0
)
3530 mem_mapped_bar
= phba
->sli4_hba
.conf_regs_memmap_p
;
3531 else if (bar_num
== IDIAG_BARACC_BAR_1
)
3532 mem_mapped_bar
= phba
->sli4_hba
.ctrl_regs_memmap_p
;
3533 else if (bar_num
== IDIAG_BARACC_BAR_2
)
3534 mem_mapped_bar
= phba
->sli4_hba
.drbl_regs_memmap_p
;
3537 } else if (if_type
== LPFC_SLI_INTF_IF_TYPE_2
) {
3538 if (bar_num
== IDIAG_BARACC_BAR_0
)
3539 mem_mapped_bar
= phba
->sli4_hba
.conf_regs_memmap_p
;
3545 /* Read single PCI bar space register */
3546 if (acc_range
== SINGLE_WORD
) {
3547 offset_run
= offset
;
3548 u32val
= readl(mem_mapped_bar
+ offset_run
);
3549 len
+= scnprintf(pbuffer
+len
, LPFC_PCI_BAR_RD_BUF_SIZE
-len
,
3550 "%05x: %08x\n", offset_run
, u32val
);
3554 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
3558 /* Browse all PCI bar space registers */
3559 offset_label
= idiag
.offset
.last_rd
;
3560 offset_run
= offset_label
;
3562 /* Read PCI bar memory mapped space */
3563 len
+= scnprintf(pbuffer
+len
, LPFC_PCI_BAR_RD_BUF_SIZE
-len
,
3564 "%05x: ", offset_label
);
3565 index
= LPFC_PCI_BAR_RD_SIZE
;
3567 u32val
= readl(mem_mapped_bar
+ offset_run
);
3568 len
+= scnprintf(pbuffer
+len
, LPFC_PCI_BAR_RD_BUF_SIZE
-len
,
3570 offset_run
+= sizeof(uint32_t);
3571 if (acc_range
== LPFC_PCI_BAR_BROWSE
) {
3572 if (offset_run
>= bar_size
) {
3573 len
+= scnprintf(pbuffer
+len
,
3574 LPFC_PCI_BAR_RD_BUF_SIZE
-len
, "\n");
3578 if (offset_run
>= offset
+
3579 (acc_range
* sizeof(uint32_t))) {
3580 len
+= scnprintf(pbuffer
+len
,
3581 LPFC_PCI_BAR_RD_BUF_SIZE
-len
, "\n");
3585 index
-= sizeof(uint32_t);
3587 len
+= scnprintf(pbuffer
+len
,
3588 LPFC_PCI_BAR_RD_BUF_SIZE
-len
, "\n");
3589 else if (!(index
% (8 * sizeof(uint32_t)))) {
3590 offset_label
+= (8 * sizeof(uint32_t));
3591 len
+= scnprintf(pbuffer
+len
,
3592 LPFC_PCI_BAR_RD_BUF_SIZE
-len
,
3593 "\n%05x: ", offset_label
);
3597 /* Set up the offset for next portion of pci bar read */
3599 idiag
.offset
.last_rd
+= LPFC_PCI_BAR_RD_SIZE
;
3600 if (acc_range
== LPFC_PCI_BAR_BROWSE
) {
3601 if (idiag
.offset
.last_rd
>= bar_size
)
3602 idiag
.offset
.last_rd
= 0;
3604 if (offset_run
>= offset
+
3605 (acc_range
* sizeof(uint32_t)))
3606 idiag
.offset
.last_rd
= offset
;
3609 if (acc_range
== LPFC_PCI_BAR_BROWSE
)
3610 idiag
.offset
.last_rd
= 0;
3612 idiag
.offset
.last_rd
= offset
;
3615 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
3619 * lpfc_idiag_baracc_write - Syntax check and set up idiag bar access commands
3620 * @file: The file pointer to read from.
3621 * @buf: The buffer to copy the user data from.
3622 * @nbytes: The number of bytes to get.
3623 * @ppos: The position in the file to start reading from.
3625 * This routine get the debugfs idiag command struct from user space and
3626 * then perform the syntax check for PCI bar memory mapped space read or
3627 * write command accordingly. In the case of PCI bar memory mapped space
3628 * read command, it sets up the command in the idiag command struct for
3629 * the debugfs read operation. In the case of PCI bar memorpy mapped space
3630 * write operation, it executes the write operation into the PCI bar memory
3631 * mapped space accordingly.
3633 * It returns the @nbytges passing in from debugfs user space when successful.
3634 * In case of error conditions, it returns proper error code back to the user
3638 lpfc_idiag_baracc_write(struct file
*file
, const char __user
*buf
,
3639 size_t nbytes
, loff_t
*ppos
)
3641 struct lpfc_debug
*debug
= file
->private_data
;
3642 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
3643 uint32_t bar_num
, bar_size
, offset
, value
, acc_range
;
3644 struct pci_dev
*pdev
;
3645 void __iomem
*mem_mapped_bar
;
3650 pdev
= phba
->pcidev
;
3654 /* This is a user write operation */
3655 debug
->op
= LPFC_IDIAG_OP_WR
;
3657 rc
= lpfc_idiag_cmd_get(buf
, nbytes
, &idiag
.cmd
);
3661 if_type
= bf_get(lpfc_sli_intf_if_type
, &phba
->sli4_hba
.sli_intf
);
3662 bar_num
= idiag
.cmd
.data
[IDIAG_BARACC_BAR_NUM_INDX
];
3664 if (if_type
== LPFC_SLI_INTF_IF_TYPE_0
) {
3665 if ((bar_num
!= IDIAG_BARACC_BAR_0
) &&
3666 (bar_num
!= IDIAG_BARACC_BAR_1
) &&
3667 (bar_num
!= IDIAG_BARACC_BAR_2
))
3669 } else if (if_type
== LPFC_SLI_INTF_IF_TYPE_2
) {
3670 if (bar_num
!= IDIAG_BARACC_BAR_0
)
3675 if (if_type
== LPFC_SLI_INTF_IF_TYPE_0
) {
3676 if (bar_num
== IDIAG_BARACC_BAR_0
) {
3677 idiag
.cmd
.data
[IDIAG_BARACC_BAR_SZE_INDX
] =
3678 LPFC_PCI_IF0_BAR0_SIZE
;
3679 mem_mapped_bar
= phba
->sli4_hba
.conf_regs_memmap_p
;
3680 } else if (bar_num
== IDIAG_BARACC_BAR_1
) {
3681 idiag
.cmd
.data
[IDIAG_BARACC_BAR_SZE_INDX
] =
3682 LPFC_PCI_IF0_BAR1_SIZE
;
3683 mem_mapped_bar
= phba
->sli4_hba
.ctrl_regs_memmap_p
;
3684 } else if (bar_num
== IDIAG_BARACC_BAR_2
) {
3685 idiag
.cmd
.data
[IDIAG_BARACC_BAR_SZE_INDX
] =
3686 LPFC_PCI_IF0_BAR2_SIZE
;
3687 mem_mapped_bar
= phba
->sli4_hba
.drbl_regs_memmap_p
;
3690 } else if (if_type
== LPFC_SLI_INTF_IF_TYPE_2
) {
3691 if (bar_num
== IDIAG_BARACC_BAR_0
) {
3692 idiag
.cmd
.data
[IDIAG_BARACC_BAR_SZE_INDX
] =
3693 LPFC_PCI_IF2_BAR0_SIZE
;
3694 mem_mapped_bar
= phba
->sli4_hba
.conf_regs_memmap_p
;
3700 offset
= idiag
.cmd
.data
[IDIAG_BARACC_OFF_SET_INDX
];
3701 if (offset
% sizeof(uint32_t))
3704 bar_size
= idiag
.cmd
.data
[IDIAG_BARACC_BAR_SZE_INDX
];
3705 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_RD
) {
3706 /* Sanity check on PCI config read command line arguments */
3707 if (rc
!= LPFC_PCI_BAR_RD_CMD_ARG
)
3709 acc_range
= idiag
.cmd
.data
[IDIAG_BARACC_ACC_MOD_INDX
];
3710 if (acc_range
== LPFC_PCI_BAR_BROWSE
) {
3711 if (offset
> bar_size
- sizeof(uint32_t))
3713 /* Starting offset to browse */
3714 idiag
.offset
.last_rd
= offset
;
3715 } else if (acc_range
> SINGLE_WORD
) {
3716 if (offset
+ acc_range
* sizeof(uint32_t) > bar_size
)
3718 /* Starting offset to browse */
3719 idiag
.offset
.last_rd
= offset
;
3720 } else if (acc_range
!= SINGLE_WORD
)
3722 } else if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_WR
||
3723 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_ST
||
3724 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_CL
) {
3725 /* Sanity check on PCI bar write command line arguments */
3726 if (rc
!= LPFC_PCI_BAR_WR_CMD_ARG
)
3728 /* Write command to PCI bar space, read-modify-write */
3729 acc_range
= SINGLE_WORD
;
3730 value
= idiag
.cmd
.data
[IDIAG_BARACC_REG_VAL_INDX
];
3731 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_WR
) {
3732 writel(value
, mem_mapped_bar
+ offset
);
3733 readl(mem_mapped_bar
+ offset
);
3735 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_ST
) {
3736 u32val
= readl(mem_mapped_bar
+ offset
);
3738 writel(u32val
, mem_mapped_bar
+ offset
);
3739 readl(mem_mapped_bar
+ offset
);
3741 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_CL
) {
3742 u32val
= readl(mem_mapped_bar
+ offset
);
3744 writel(u32val
, mem_mapped_bar
+ offset
);
3745 readl(mem_mapped_bar
+ offset
);
3748 /* All other opecodes are illegal for now */
3753 memset(&idiag
, 0, sizeof(idiag
));
3758 __lpfc_idiag_print_wq(struct lpfc_queue
*qp
, char *wqtype
,
3759 char *pbuffer
, int len
)
3764 len
+= scnprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3765 "\t\t%s WQ info: ", wqtype
);
3766 len
+= scnprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3767 "AssocCQID[%04d]: WQ-STAT[oflow:x%x posted:x%llx]\n",
3768 qp
->assoc_qid
, qp
->q_cnt_1
,
3769 (unsigned long long)qp
->q_cnt_4
);
3770 len
+= scnprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3771 "\t\tWQID[%02d], QE-CNT[%04d], QE-SZ[%04d], "
3772 "HST-IDX[%04d], PRT-IDX[%04d], NTFI[%03d]",
3773 qp
->queue_id
, qp
->entry_count
,
3774 qp
->entry_size
, qp
->host_index
,
3775 qp
->hba_index
, qp
->notify_interval
);
3776 len
+= scnprintf(pbuffer
+ len
,
3777 LPFC_QUE_INFO_GET_BUF_SIZE
- len
, "\n");
3782 lpfc_idiag_wqs_for_cq(struct lpfc_hba
*phba
, char *wqtype
, char *pbuffer
,
3783 int *len
, int max_cnt
, int cq_id
)
3785 struct lpfc_queue
*qp
;
3788 for (qidx
= 0; qidx
< phba
->cfg_hdw_queue
; qidx
++) {
3789 qp
= phba
->sli4_hba
.hdwq
[qidx
].fcp_wq
;
3790 if (qp
->assoc_qid
!= cq_id
)
3792 *len
= __lpfc_idiag_print_wq(qp
, wqtype
, pbuffer
, *len
);
3793 if (*len
>= max_cnt
)
3796 if (phba
->cfg_enable_fc4_type
& LPFC_ENABLE_NVME
) {
3797 for (qidx
= 0; qidx
< phba
->cfg_hdw_queue
; qidx
++) {
3798 qp
= phba
->sli4_hba
.hdwq
[qidx
].nvme_wq
;
3799 if (qp
->assoc_qid
!= cq_id
)
3801 *len
= __lpfc_idiag_print_wq(qp
, wqtype
, pbuffer
, *len
);
3802 if (*len
>= max_cnt
)
3810 __lpfc_idiag_print_cq(struct lpfc_queue
*qp
, char *cqtype
,
3811 char *pbuffer
, int len
)
3816 len
+= scnprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3817 "\t%s CQ info: ", cqtype
);
3818 len
+= scnprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3819 "AssocEQID[%02d]: CQ STAT[max:x%x relw:x%x "
3820 "xabt:x%x wq:x%llx]\n",
3821 qp
->assoc_qid
, qp
->q_cnt_1
, qp
->q_cnt_2
,
3822 qp
->q_cnt_3
, (unsigned long long)qp
->q_cnt_4
);
3823 len
+= scnprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3824 "\tCQID[%02d], QE-CNT[%04d], QE-SZ[%04d], "
3825 "HST-IDX[%04d], NTFI[%03d], PLMT[%03d]",
3826 qp
->queue_id
, qp
->entry_count
,
3827 qp
->entry_size
, qp
->host_index
,
3828 qp
->notify_interval
, qp
->max_proc_limit
);
3830 len
+= scnprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3837 __lpfc_idiag_print_rqpair(struct lpfc_queue
*qp
, struct lpfc_queue
*datqp
,
3838 char *rqtype
, char *pbuffer
, int len
)
3843 len
+= scnprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3844 "\t\t%s RQ info: ", rqtype
);
3845 len
+= scnprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3846 "AssocCQID[%02d]: RQ-STAT[nopost:x%x nobuf:x%x "
3847 "posted:x%x rcv:x%llx]\n",
3848 qp
->assoc_qid
, qp
->q_cnt_1
, qp
->q_cnt_2
,
3849 qp
->q_cnt_3
, (unsigned long long)qp
->q_cnt_4
);
3850 len
+= scnprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3851 "\t\tHQID[%02d], QE-CNT[%04d], QE-SZ[%04d], "
3852 "HST-IDX[%04d], PRT-IDX[%04d], NTFI[%03d]\n",
3853 qp
->queue_id
, qp
->entry_count
, qp
->entry_size
,
3854 qp
->host_index
, qp
->hba_index
, qp
->notify_interval
);
3855 len
+= scnprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3856 "\t\tDQID[%02d], QE-CNT[%04d], QE-SZ[%04d], "
3857 "HST-IDX[%04d], PRT-IDX[%04d], NTFI[%03d]\n",
3858 datqp
->queue_id
, datqp
->entry_count
,
3859 datqp
->entry_size
, datqp
->host_index
,
3860 datqp
->hba_index
, datqp
->notify_interval
);
3865 lpfc_idiag_cqs_for_eq(struct lpfc_hba
*phba
, char *pbuffer
,
3866 int *len
, int max_cnt
, int eqidx
, int eq_id
)
3868 struct lpfc_queue
*qp
;
3871 qp
= phba
->sli4_hba
.hdwq
[eqidx
].fcp_cq
;
3873 *len
= __lpfc_idiag_print_cq(qp
, "FCP", pbuffer
, *len
);
3875 /* Reset max counter */
3878 if (*len
>= max_cnt
)
3881 rc
= lpfc_idiag_wqs_for_cq(phba
, "FCP", pbuffer
, len
,
3882 max_cnt
, qp
->queue_id
);
3886 if (phba
->cfg_enable_fc4_type
& LPFC_ENABLE_NVME
) {
3887 qp
= phba
->sli4_hba
.hdwq
[eqidx
].nvme_cq
;
3889 *len
= __lpfc_idiag_print_cq(qp
, "NVME", pbuffer
, *len
);
3891 /* Reset max counter */
3894 if (*len
>= max_cnt
)
3897 rc
= lpfc_idiag_wqs_for_cq(phba
, "NVME", pbuffer
, len
,
3898 max_cnt
, qp
->queue_id
);
3903 if ((eqidx
< phba
->cfg_nvmet_mrq
) && phba
->nvmet_support
) {
3905 qp
= phba
->sli4_hba
.nvmet_cqset
[eqidx
];
3906 *len
= __lpfc_idiag_print_cq(qp
, "NVMET CQset", pbuffer
, *len
);
3908 /* Reset max counter */
3911 if (*len
>= max_cnt
)
3915 qp
= phba
->sli4_hba
.nvmet_mrq_hdr
[eqidx
];
3916 *len
= __lpfc_idiag_print_rqpair(qp
,
3917 phba
->sli4_hba
.nvmet_mrq_data
[eqidx
],
3918 "NVMET MRQ", pbuffer
, *len
);
3920 if (*len
>= max_cnt
)
3928 __lpfc_idiag_print_eq(struct lpfc_queue
*qp
, char *eqtype
,
3929 char *pbuffer
, int len
)
3934 len
+= scnprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3935 "\n%s EQ info: EQ-STAT[max:x%x noE:x%x "
3936 "cqe_proc:x%x eqe_proc:x%llx eqd %d]\n",
3937 eqtype
, qp
->q_cnt_1
, qp
->q_cnt_2
, qp
->q_cnt_3
,
3938 (unsigned long long)qp
->q_cnt_4
, qp
->q_mode
);
3939 len
+= scnprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3940 "EQID[%02d], QE-CNT[%04d], QE-SZ[%04d], "
3941 "HST-IDX[%04d], NTFI[%03d], PLMT[%03d], AFFIN[%03d]",
3942 qp
->queue_id
, qp
->entry_count
, qp
->entry_size
,
3943 qp
->host_index
, qp
->notify_interval
,
3944 qp
->max_proc_limit
, qp
->chann
);
3945 len
+= scnprintf(pbuffer
+ len
, LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
3952 * lpfc_idiag_queinfo_read - idiag debugfs read queue information
3953 * @file: The file pointer to read from.
3954 * @buf: The buffer to copy the data to.
3955 * @nbytes: The number of bytes to read.
3956 * @ppos: The position in the file to start reading from.
3959 * This routine reads data from the @phba SLI4 PCI function queue information,
3960 * and copies to user @buf.
3961 * This routine only returns 1 EQs worth of information. It remembers the last
3962 * EQ read and jumps to the next EQ. Thus subsequent calls to queInfo will
3963 * retrieve all EQs allocated for the phba.
3966 * This function returns the amount of data that was read (this could be less
3967 * than @nbytes if the end of the file was reached) or a negative error value.
3970 lpfc_idiag_queinfo_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
3973 struct lpfc_debug
*debug
= file
->private_data
;
3974 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
3976 int max_cnt
, rc
, x
, len
= 0;
3977 struct lpfc_queue
*qp
= NULL
;
3980 debug
->buffer
= kmalloc(LPFC_QUE_INFO_GET_BUF_SIZE
, GFP_KERNEL
);
3983 pbuffer
= debug
->buffer
;
3984 max_cnt
= LPFC_QUE_INFO_GET_BUF_SIZE
- 256;
3989 spin_lock_irq(&phba
->hbalock
);
3991 /* Fast-path event queue */
3992 if (phba
->sli4_hba
.hdwq
&& phba
->cfg_hdw_queue
) {
3994 x
= phba
->lpfc_idiag_last_eq
;
3995 phba
->lpfc_idiag_last_eq
++;
3996 if (phba
->lpfc_idiag_last_eq
>= phba
->cfg_hdw_queue
)
3997 phba
->lpfc_idiag_last_eq
= 0;
3999 len
+= scnprintf(pbuffer
+ len
,
4000 LPFC_QUE_INFO_GET_BUF_SIZE
- len
,
4001 "HDWQ %d out of %d HBA HDWQs\n",
4002 x
, phba
->cfg_hdw_queue
);
4005 qp
= phba
->sli4_hba
.hdwq
[x
].hba_eq
;
4009 len
= __lpfc_idiag_print_eq(qp
, "HBA", pbuffer
, len
);
4011 /* Reset max counter */
4017 /* will dump both fcp and nvme cqs/wqs for the eq */
4018 rc
= lpfc_idiag_cqs_for_eq(phba
, pbuffer
, &len
,
4019 max_cnt
, x
, qp
->queue_id
);
4023 /* Only EQ 0 has slow path CQs configured */
4027 /* Slow-path mailbox CQ */
4028 qp
= phba
->sli4_hba
.mbx_cq
;
4029 len
= __lpfc_idiag_print_cq(qp
, "MBX", pbuffer
, len
);
4033 /* Slow-path MBOX MQ */
4034 qp
= phba
->sli4_hba
.mbx_wq
;
4035 len
= __lpfc_idiag_print_wq(qp
, "MBX", pbuffer
, len
);
4039 /* Slow-path ELS response CQ */
4040 qp
= phba
->sli4_hba
.els_cq
;
4041 len
= __lpfc_idiag_print_cq(qp
, "ELS", pbuffer
, len
);
4042 /* Reset max counter */
4048 /* Slow-path ELS WQ */
4049 qp
= phba
->sli4_hba
.els_wq
;
4050 len
= __lpfc_idiag_print_wq(qp
, "ELS", pbuffer
, len
);
4054 qp
= phba
->sli4_hba
.hdr_rq
;
4055 len
= __lpfc_idiag_print_rqpair(qp
, phba
->sli4_hba
.dat_rq
,
4056 "ELS RQpair", pbuffer
, len
);
4060 /* Slow-path NVME LS response CQ */
4061 qp
= phba
->sli4_hba
.nvmels_cq
;
4062 len
= __lpfc_idiag_print_cq(qp
, "NVME LS",
4064 /* Reset max counter */
4070 /* Slow-path NVME LS WQ */
4071 qp
= phba
->sli4_hba
.nvmels_wq
;
4072 len
= __lpfc_idiag_print_wq(qp
, "NVME LS",
4080 spin_unlock_irq(&phba
->hbalock
);
4081 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
4084 len
+= scnprintf(pbuffer
+ len
,
4085 LPFC_QUE_INFO_GET_BUF_SIZE
- len
, "Truncated ...\n");
4087 spin_unlock_irq(&phba
->hbalock
);
4088 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
4092 * lpfc_idiag_que_param_check - queue access command parameter sanity check
4093 * @q: The pointer to queue structure.
4094 * @index: The index into a queue entry.
4095 * @count: The number of queue entries to access.
4098 * The routine performs sanity check on device queue access method commands.
4101 * This function returns -EINVAL when fails the sanity check, otherwise, it
4105 lpfc_idiag_que_param_check(struct lpfc_queue
*q
, int index
, int count
)
4107 /* Only support single entry read or browsing */
4108 if ((count
!= 1) && (count
!= LPFC_QUE_ACC_BROWSE
))
4110 if (index
> q
->entry_count
- 1)
4116 * lpfc_idiag_queacc_read_qe - read a single entry from the given queue index
4117 * @pbuffer: The pointer to buffer to copy the read data into.
4118 * @pque: The pointer to the queue to be read.
4119 * @index: The index into the queue entry.
4122 * This routine reads out a single entry from the given queue's index location
4123 * and copies it into the buffer provided.
4126 * This function returns 0 when it fails, otherwise, it returns the length of
4127 * the data read into the buffer provided.
4130 lpfc_idiag_queacc_read_qe(char *pbuffer
, int len
, struct lpfc_queue
*pque
,
4136 if (!pbuffer
|| !pque
)
4139 esize
= pque
->entry_size
;
4140 len
+= scnprintf(pbuffer
+len
, LPFC_QUE_ACC_BUF_SIZE
-len
,
4141 "QE-INDEX[%04d]:\n", index
);
4144 pentry
= lpfc_sli4_qe(pque
, index
);
4146 len
+= scnprintf(pbuffer
+len
, LPFC_QUE_ACC_BUF_SIZE
-len
,
4149 offset
+= sizeof(uint32_t);
4150 esize
-= sizeof(uint32_t);
4151 if (esize
> 0 && !(offset
% (4 * sizeof(uint32_t))))
4152 len
+= scnprintf(pbuffer
+len
,
4153 LPFC_QUE_ACC_BUF_SIZE
-len
, "\n");
4155 len
+= scnprintf(pbuffer
+len
, LPFC_QUE_ACC_BUF_SIZE
-len
, "\n");
4161 * lpfc_idiag_queacc_read - idiag debugfs read port queue
4162 * @file: The file pointer to read from.
4163 * @buf: The buffer to copy the data to.
4164 * @nbytes: The number of bytes to read.
4165 * @ppos: The position in the file to start reading from.
4168 * This routine reads data from the @phba device queue memory according to the
4169 * idiag command, and copies to user @buf. Depending on the queue dump read
4170 * command setup, it does either a single queue entry read or browing through
4171 * all entries of the queue.
4174 * This function returns the amount of data that was read (this could be less
4175 * than @nbytes if the end of the file was reached) or a negative error value.
4178 lpfc_idiag_queacc_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
4181 struct lpfc_debug
*debug
= file
->private_data
;
4182 uint32_t last_index
, index
, count
;
4183 struct lpfc_queue
*pque
= NULL
;
4187 /* This is a user read operation */
4188 debug
->op
= LPFC_IDIAG_OP_RD
;
4191 debug
->buffer
= kmalloc(LPFC_QUE_ACC_BUF_SIZE
, GFP_KERNEL
);
4194 pbuffer
= debug
->buffer
;
4199 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_RD
) {
4200 index
= idiag
.cmd
.data
[IDIAG_QUEACC_INDEX_INDX
];
4201 count
= idiag
.cmd
.data
[IDIAG_QUEACC_COUNT_INDX
];
4202 pque
= (struct lpfc_queue
*)idiag
.ptr_private
;
4206 /* Browse the queue starting from index */
4207 if (count
== LPFC_QUE_ACC_BROWSE
)
4210 /* Read a single entry from the queue */
4211 len
= lpfc_idiag_queacc_read_qe(pbuffer
, len
, pque
, index
);
4213 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
4217 /* Browse all entries from the queue */
4218 last_index
= idiag
.offset
.last_rd
;
4221 while (len
< LPFC_QUE_ACC_SIZE
- pque
->entry_size
) {
4222 len
= lpfc_idiag_queacc_read_qe(pbuffer
, len
, pque
, index
);
4224 if (index
> pque
->entry_count
- 1)
4228 /* Set up the offset for next portion of pci cfg read */
4229 if (index
> pque
->entry_count
- 1)
4231 idiag
.offset
.last_rd
= index
;
4233 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
4237 * lpfc_idiag_queacc_write - Syntax check and set up idiag queacc commands
4238 * @file: The file pointer to read from.
4239 * @buf: The buffer to copy the user data from.
4240 * @nbytes: The number of bytes to get.
4241 * @ppos: The position in the file to start reading from.
4243 * This routine get the debugfs idiag command struct from user space and then
4244 * perform the syntax check for port queue read (dump) or write (set) command
4245 * accordingly. In the case of port queue read command, it sets up the command
4246 * in the idiag command struct for the following debugfs read operation. In
4247 * the case of port queue write operation, it executes the write operation
4248 * into the port queue entry accordingly.
4250 * It returns the @nbytges passing in from debugfs user space when successful.
4251 * In case of error conditions, it returns proper error code back to the user
4255 lpfc_idiag_queacc_write(struct file
*file
, const char __user
*buf
,
4256 size_t nbytes
, loff_t
*ppos
)
4258 struct lpfc_debug
*debug
= file
->private_data
;
4259 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
4260 uint32_t qidx
, quetp
, queid
, index
, count
, offset
, value
;
4262 struct lpfc_queue
*pque
, *qp
;
4265 /* This is a user write operation */
4266 debug
->op
= LPFC_IDIAG_OP_WR
;
4268 rc
= lpfc_idiag_cmd_get(buf
, nbytes
, &idiag
.cmd
);
4272 /* Get and sanity check on command feilds */
4273 quetp
= idiag
.cmd
.data
[IDIAG_QUEACC_QUETP_INDX
];
4274 queid
= idiag
.cmd
.data
[IDIAG_QUEACC_QUEID_INDX
];
4275 index
= idiag
.cmd
.data
[IDIAG_QUEACC_INDEX_INDX
];
4276 count
= idiag
.cmd
.data
[IDIAG_QUEACC_COUNT_INDX
];
4277 offset
= idiag
.cmd
.data
[IDIAG_QUEACC_OFFST_INDX
];
4278 value
= idiag
.cmd
.data
[IDIAG_QUEACC_VALUE_INDX
];
4280 /* Sanity check on command line arguments */
4281 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_WR
||
4282 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_ST
||
4283 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_CL
) {
4284 if (rc
!= LPFC_QUE_ACC_WR_CMD_ARG
)
4288 } else if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_RD
) {
4289 if (rc
!= LPFC_QUE_ACC_RD_CMD_ARG
)
4296 /* HBA event queue */
4297 if (phba
->sli4_hba
.hdwq
) {
4298 for (qidx
= 0; qidx
< phba
->cfg_hdw_queue
; qidx
++) {
4299 qp
= phba
->sli4_hba
.hdwq
[qidx
].hba_eq
;
4300 if (qp
&& qp
->queue_id
== queid
) {
4302 rc
= lpfc_idiag_que_param_check(qp
,
4306 idiag
.ptr_private
= qp
;
4314 /* MBX complete queue */
4315 if (phba
->sli4_hba
.mbx_cq
&&
4316 phba
->sli4_hba
.mbx_cq
->queue_id
== queid
) {
4318 rc
= lpfc_idiag_que_param_check(
4319 phba
->sli4_hba
.mbx_cq
, index
, count
);
4322 idiag
.ptr_private
= phba
->sli4_hba
.mbx_cq
;
4325 /* ELS complete queue */
4326 if (phba
->sli4_hba
.els_cq
&&
4327 phba
->sli4_hba
.els_cq
->queue_id
== queid
) {
4329 rc
= lpfc_idiag_que_param_check(
4330 phba
->sli4_hba
.els_cq
, index
, count
);
4333 idiag
.ptr_private
= phba
->sli4_hba
.els_cq
;
4336 /* NVME LS complete queue */
4337 if (phba
->sli4_hba
.nvmels_cq
&&
4338 phba
->sli4_hba
.nvmels_cq
->queue_id
== queid
) {
4340 rc
= lpfc_idiag_que_param_check(
4341 phba
->sli4_hba
.nvmels_cq
, index
, count
);
4344 idiag
.ptr_private
= phba
->sli4_hba
.nvmels_cq
;
4347 /* FCP complete queue */
4348 if (phba
->sli4_hba
.hdwq
) {
4349 for (qidx
= 0; qidx
< phba
->cfg_hdw_queue
;
4351 qp
= phba
->sli4_hba
.hdwq
[qidx
].fcp_cq
;
4352 if (qp
&& qp
->queue_id
== queid
) {
4354 rc
= lpfc_idiag_que_param_check(
4358 idiag
.ptr_private
= qp
;
4363 /* NVME complete queue */
4364 if (phba
->sli4_hba
.hdwq
) {
4367 qp
= phba
->sli4_hba
.hdwq
[qidx
].nvme_cq
;
4368 if (qp
&& qp
->queue_id
== queid
) {
4370 rc
= lpfc_idiag_que_param_check(
4374 idiag
.ptr_private
= qp
;
4377 } while (++qidx
< phba
->cfg_hdw_queue
);
4382 /* MBX work queue */
4383 if (phba
->sli4_hba
.mbx_wq
&&
4384 phba
->sli4_hba
.mbx_wq
->queue_id
== queid
) {
4386 rc
= lpfc_idiag_que_param_check(
4387 phba
->sli4_hba
.mbx_wq
, index
, count
);
4390 idiag
.ptr_private
= phba
->sli4_hba
.mbx_wq
;
4396 /* ELS work queue */
4397 if (phba
->sli4_hba
.els_wq
&&
4398 phba
->sli4_hba
.els_wq
->queue_id
== queid
) {
4400 rc
= lpfc_idiag_que_param_check(
4401 phba
->sli4_hba
.els_wq
, index
, count
);
4404 idiag
.ptr_private
= phba
->sli4_hba
.els_wq
;
4407 /* NVME LS work queue */
4408 if (phba
->sli4_hba
.nvmels_wq
&&
4409 phba
->sli4_hba
.nvmels_wq
->queue_id
== queid
) {
4411 rc
= lpfc_idiag_que_param_check(
4412 phba
->sli4_hba
.nvmels_wq
, index
, count
);
4415 idiag
.ptr_private
= phba
->sli4_hba
.nvmels_wq
;
4419 if (phba
->sli4_hba
.hdwq
) {
4420 /* FCP/SCSI work queue */
4421 for (qidx
= 0; qidx
< phba
->cfg_hdw_queue
; qidx
++) {
4422 qp
= phba
->sli4_hba
.hdwq
[qidx
].fcp_wq
;
4423 if (qp
&& qp
->queue_id
== queid
) {
4425 rc
= lpfc_idiag_que_param_check(
4429 idiag
.ptr_private
= qp
;
4433 /* NVME work queue */
4434 for (qidx
= 0; qidx
< phba
->cfg_hdw_queue
; qidx
++) {
4435 qp
= phba
->sli4_hba
.hdwq
[qidx
].nvme_wq
;
4436 if (qp
&& qp
->queue_id
== queid
) {
4438 rc
= lpfc_idiag_que_param_check(
4442 idiag
.ptr_private
= qp
;
4452 if (phba
->sli4_hba
.hdr_rq
&&
4453 phba
->sli4_hba
.hdr_rq
->queue_id
== queid
) {
4455 rc
= lpfc_idiag_que_param_check(
4456 phba
->sli4_hba
.hdr_rq
, index
, count
);
4459 idiag
.ptr_private
= phba
->sli4_hba
.hdr_rq
;
4463 if (phba
->sli4_hba
.dat_rq
&&
4464 phba
->sli4_hba
.dat_rq
->queue_id
== queid
) {
4466 rc
= lpfc_idiag_que_param_check(
4467 phba
->sli4_hba
.dat_rq
, index
, count
);
4470 idiag
.ptr_private
= phba
->sli4_hba
.dat_rq
;
4482 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_RD
) {
4483 if (count
== LPFC_QUE_ACC_BROWSE
)
4484 idiag
.offset
.last_rd
= index
;
4487 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_WR
||
4488 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_ST
||
4489 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_CL
) {
4490 /* Additional sanity checks on write operation */
4491 pque
= (struct lpfc_queue
*)idiag
.ptr_private
;
4492 if (offset
> pque
->entry_size
/sizeof(uint32_t) - 1)
4494 pentry
= lpfc_sli4_qe(pque
, index
);
4496 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_WR
)
4498 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_ST
)
4500 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_CL
)
4506 /* Clean out command structure on command error out */
4507 memset(&idiag
, 0, sizeof(idiag
));
4512 * lpfc_idiag_drbacc_read_reg - idiag debugfs read a doorbell register
4513 * @phba: The pointer to hba structure.
4514 * @pbuffer: The pointer to the buffer to copy the data to.
4515 * @len: The length of bytes to copied.
4516 * @drbregid: The id to doorbell registers.
4519 * This routine reads a doorbell register and copies its content to the
4520 * user buffer pointed to by @pbuffer.
4523 * This function returns the amount of data that was copied into @pbuffer.
4526 lpfc_idiag_drbacc_read_reg(struct lpfc_hba
*phba
, char *pbuffer
,
4527 int len
, uint32_t drbregid
)
4535 len
+= scnprintf(pbuffer
+ len
, LPFC_DRB_ACC_BUF_SIZE
-len
,
4536 "EQ-DRB-REG: 0x%08x\n",
4537 readl(phba
->sli4_hba
.EQDBregaddr
));
4540 len
+= scnprintf(pbuffer
+ len
, LPFC_DRB_ACC_BUF_SIZE
- len
,
4541 "CQ-DRB-REG: 0x%08x\n",
4542 readl(phba
->sli4_hba
.CQDBregaddr
));
4545 len
+= scnprintf(pbuffer
+len
, LPFC_DRB_ACC_BUF_SIZE
-len
,
4546 "MQ-DRB-REG: 0x%08x\n",
4547 readl(phba
->sli4_hba
.MQDBregaddr
));
4550 len
+= scnprintf(pbuffer
+len
, LPFC_DRB_ACC_BUF_SIZE
-len
,
4551 "WQ-DRB-REG: 0x%08x\n",
4552 readl(phba
->sli4_hba
.WQDBregaddr
));
4555 len
+= scnprintf(pbuffer
+len
, LPFC_DRB_ACC_BUF_SIZE
-len
,
4556 "RQ-DRB-REG: 0x%08x\n",
4557 readl(phba
->sli4_hba
.RQDBregaddr
));
4567 * lpfc_idiag_drbacc_read - idiag debugfs read port doorbell
4568 * @file: The file pointer to read from.
4569 * @buf: The buffer to copy the data to.
4570 * @nbytes: The number of bytes to read.
4571 * @ppos: The position in the file to start reading from.
4574 * This routine reads data from the @phba device doorbell register according
4575 * to the idiag command, and copies to user @buf. Depending on the doorbell
4576 * register read command setup, it does either a single doorbell register
4577 * read or dump all doorbell registers.
4580 * This function returns the amount of data that was read (this could be less
4581 * than @nbytes if the end of the file was reached) or a negative error value.
4584 lpfc_idiag_drbacc_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
4587 struct lpfc_debug
*debug
= file
->private_data
;
4588 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
4589 uint32_t drb_reg_id
, i
;
4593 /* This is a user read operation */
4594 debug
->op
= LPFC_IDIAG_OP_RD
;
4597 debug
->buffer
= kmalloc(LPFC_DRB_ACC_BUF_SIZE
, GFP_KERNEL
);
4600 pbuffer
= debug
->buffer
;
4605 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_RD
)
4606 drb_reg_id
= idiag
.cmd
.data
[IDIAG_DRBACC_REGID_INDX
];
4610 if (drb_reg_id
== LPFC_DRB_ACC_ALL
)
4611 for (i
= 1; i
<= LPFC_DRB_MAX
; i
++)
4612 len
= lpfc_idiag_drbacc_read_reg(phba
,
4615 len
= lpfc_idiag_drbacc_read_reg(phba
,
4616 pbuffer
, len
, drb_reg_id
);
4618 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
4622 * lpfc_idiag_drbacc_write - Syntax check and set up idiag drbacc commands
4623 * @file: The file pointer to read from.
4624 * @buf: The buffer to copy the user data from.
4625 * @nbytes: The number of bytes to get.
4626 * @ppos: The position in the file to start reading from.
4628 * This routine get the debugfs idiag command struct from user space and then
4629 * perform the syntax check for port doorbell register read (dump) or write
4630 * (set) command accordingly. In the case of port queue read command, it sets
4631 * up the command in the idiag command struct for the following debugfs read
4632 * operation. In the case of port doorbell register write operation, it
4633 * executes the write operation into the port doorbell register accordingly.
4635 * It returns the @nbytges passing in from debugfs user space when successful.
4636 * In case of error conditions, it returns proper error code back to the user
4640 lpfc_idiag_drbacc_write(struct file
*file
, const char __user
*buf
,
4641 size_t nbytes
, loff_t
*ppos
)
4643 struct lpfc_debug
*debug
= file
->private_data
;
4644 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
4645 uint32_t drb_reg_id
, value
, reg_val
= 0;
4646 void __iomem
*drb_reg
;
4649 /* This is a user write operation */
4650 debug
->op
= LPFC_IDIAG_OP_WR
;
4652 rc
= lpfc_idiag_cmd_get(buf
, nbytes
, &idiag
.cmd
);
4656 /* Sanity check on command line arguments */
4657 drb_reg_id
= idiag
.cmd
.data
[IDIAG_DRBACC_REGID_INDX
];
4658 value
= idiag
.cmd
.data
[IDIAG_DRBACC_VALUE_INDX
];
4660 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_WR
||
4661 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_ST
||
4662 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_CL
) {
4663 if (rc
!= LPFC_DRB_ACC_WR_CMD_ARG
)
4665 if (drb_reg_id
> LPFC_DRB_MAX
)
4667 } else if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_RD
) {
4668 if (rc
!= LPFC_DRB_ACC_RD_CMD_ARG
)
4670 if ((drb_reg_id
> LPFC_DRB_MAX
) &&
4671 (drb_reg_id
!= LPFC_DRB_ACC_ALL
))
4676 /* Perform the write access operation */
4677 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_WR
||
4678 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_ST
||
4679 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_CL
) {
4680 switch (drb_reg_id
) {
4682 drb_reg
= phba
->sli4_hba
.EQDBregaddr
;
4685 drb_reg
= phba
->sli4_hba
.CQDBregaddr
;
4688 drb_reg
= phba
->sli4_hba
.MQDBregaddr
;
4691 drb_reg
= phba
->sli4_hba
.WQDBregaddr
;
4694 drb_reg
= phba
->sli4_hba
.RQDBregaddr
;
4700 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_WR
)
4702 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_ST
) {
4703 reg_val
= readl(drb_reg
);
4706 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_CL
) {
4707 reg_val
= readl(drb_reg
);
4710 writel(reg_val
, drb_reg
);
4711 readl(drb_reg
); /* flush */
4716 /* Clean out command structure on command error out */
4717 memset(&idiag
, 0, sizeof(idiag
));
4722 * lpfc_idiag_ctlacc_read_reg - idiag debugfs read a control registers
4723 * @phba: The pointer to hba structure.
4724 * @pbuffer: The pointer to the buffer to copy the data to.
4725 * @len: The length of bytes to copied.
4726 * @drbregid: The id to doorbell registers.
4729 * This routine reads a control register and copies its content to the
4730 * user buffer pointed to by @pbuffer.
4733 * This function returns the amount of data that was copied into @pbuffer.
4736 lpfc_idiag_ctlacc_read_reg(struct lpfc_hba
*phba
, char *pbuffer
,
4737 int len
, uint32_t ctlregid
)
4744 case LPFC_CTL_PORT_SEM
:
4745 len
+= scnprintf(pbuffer
+len
, LPFC_CTL_ACC_BUF_SIZE
-len
,
4746 "Port SemReg: 0x%08x\n",
4747 readl(phba
->sli4_hba
.conf_regs_memmap_p
+
4748 LPFC_CTL_PORT_SEM_OFFSET
));
4750 case LPFC_CTL_PORT_STA
:
4751 len
+= scnprintf(pbuffer
+len
, LPFC_CTL_ACC_BUF_SIZE
-len
,
4752 "Port StaReg: 0x%08x\n",
4753 readl(phba
->sli4_hba
.conf_regs_memmap_p
+
4754 LPFC_CTL_PORT_STA_OFFSET
));
4756 case LPFC_CTL_PORT_CTL
:
4757 len
+= scnprintf(pbuffer
+len
, LPFC_CTL_ACC_BUF_SIZE
-len
,
4758 "Port CtlReg: 0x%08x\n",
4759 readl(phba
->sli4_hba
.conf_regs_memmap_p
+
4760 LPFC_CTL_PORT_CTL_OFFSET
));
4762 case LPFC_CTL_PORT_ER1
:
4763 len
+= scnprintf(pbuffer
+len
, LPFC_CTL_ACC_BUF_SIZE
-len
,
4764 "Port Er1Reg: 0x%08x\n",
4765 readl(phba
->sli4_hba
.conf_regs_memmap_p
+
4766 LPFC_CTL_PORT_ER1_OFFSET
));
4768 case LPFC_CTL_PORT_ER2
:
4769 len
+= scnprintf(pbuffer
+len
, LPFC_CTL_ACC_BUF_SIZE
-len
,
4770 "Port Er2Reg: 0x%08x\n",
4771 readl(phba
->sli4_hba
.conf_regs_memmap_p
+
4772 LPFC_CTL_PORT_ER2_OFFSET
));
4774 case LPFC_CTL_PDEV_CTL
:
4775 len
+= scnprintf(pbuffer
+len
, LPFC_CTL_ACC_BUF_SIZE
-len
,
4776 "PDev CtlReg: 0x%08x\n",
4777 readl(phba
->sli4_hba
.conf_regs_memmap_p
+
4778 LPFC_CTL_PDEV_CTL_OFFSET
));
4787 * lpfc_idiag_ctlacc_read - idiag debugfs read port and device control register
4788 * @file: The file pointer to read from.
4789 * @buf: The buffer to copy the data to.
4790 * @nbytes: The number of bytes to read.
4791 * @ppos: The position in the file to start reading from.
4794 * This routine reads data from the @phba port and device registers according
4795 * to the idiag command, and copies to user @buf.
4798 * This function returns the amount of data that was read (this could be less
4799 * than @nbytes if the end of the file was reached) or a negative error value.
4802 lpfc_idiag_ctlacc_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
4805 struct lpfc_debug
*debug
= file
->private_data
;
4806 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
4807 uint32_t ctl_reg_id
, i
;
4811 /* This is a user read operation */
4812 debug
->op
= LPFC_IDIAG_OP_RD
;
4815 debug
->buffer
= kmalloc(LPFC_CTL_ACC_BUF_SIZE
, GFP_KERNEL
);
4818 pbuffer
= debug
->buffer
;
4823 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_RD
)
4824 ctl_reg_id
= idiag
.cmd
.data
[IDIAG_CTLACC_REGID_INDX
];
4828 if (ctl_reg_id
== LPFC_CTL_ACC_ALL
)
4829 for (i
= 1; i
<= LPFC_CTL_MAX
; i
++)
4830 len
= lpfc_idiag_ctlacc_read_reg(phba
,
4833 len
= lpfc_idiag_ctlacc_read_reg(phba
,
4834 pbuffer
, len
, ctl_reg_id
);
4836 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
4840 * lpfc_idiag_ctlacc_write - Syntax check and set up idiag ctlacc commands
4841 * @file: The file pointer to read from.
4842 * @buf: The buffer to copy the user data from.
4843 * @nbytes: The number of bytes to get.
4844 * @ppos: The position in the file to start reading from.
4846 * This routine get the debugfs idiag command struct from user space and then
4847 * perform the syntax check for port and device control register read (dump)
4848 * or write (set) command accordingly.
4850 * It returns the @nbytges passing in from debugfs user space when successful.
4851 * In case of error conditions, it returns proper error code back to the user
4855 lpfc_idiag_ctlacc_write(struct file
*file
, const char __user
*buf
,
4856 size_t nbytes
, loff_t
*ppos
)
4858 struct lpfc_debug
*debug
= file
->private_data
;
4859 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
4860 uint32_t ctl_reg_id
, value
, reg_val
= 0;
4861 void __iomem
*ctl_reg
;
4864 /* This is a user write operation */
4865 debug
->op
= LPFC_IDIAG_OP_WR
;
4867 rc
= lpfc_idiag_cmd_get(buf
, nbytes
, &idiag
.cmd
);
4871 /* Sanity check on command line arguments */
4872 ctl_reg_id
= idiag
.cmd
.data
[IDIAG_CTLACC_REGID_INDX
];
4873 value
= idiag
.cmd
.data
[IDIAG_CTLACC_VALUE_INDX
];
4875 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_WR
||
4876 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_ST
||
4877 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_CL
) {
4878 if (rc
!= LPFC_CTL_ACC_WR_CMD_ARG
)
4880 if (ctl_reg_id
> LPFC_CTL_MAX
)
4882 } else if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_RD
) {
4883 if (rc
!= LPFC_CTL_ACC_RD_CMD_ARG
)
4885 if ((ctl_reg_id
> LPFC_CTL_MAX
) &&
4886 (ctl_reg_id
!= LPFC_CTL_ACC_ALL
))
4891 /* Perform the write access operation */
4892 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_WR
||
4893 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_ST
||
4894 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_CL
) {
4895 switch (ctl_reg_id
) {
4896 case LPFC_CTL_PORT_SEM
:
4897 ctl_reg
= phba
->sli4_hba
.conf_regs_memmap_p
+
4898 LPFC_CTL_PORT_SEM_OFFSET
;
4900 case LPFC_CTL_PORT_STA
:
4901 ctl_reg
= phba
->sli4_hba
.conf_regs_memmap_p
+
4902 LPFC_CTL_PORT_STA_OFFSET
;
4904 case LPFC_CTL_PORT_CTL
:
4905 ctl_reg
= phba
->sli4_hba
.conf_regs_memmap_p
+
4906 LPFC_CTL_PORT_CTL_OFFSET
;
4908 case LPFC_CTL_PORT_ER1
:
4909 ctl_reg
= phba
->sli4_hba
.conf_regs_memmap_p
+
4910 LPFC_CTL_PORT_ER1_OFFSET
;
4912 case LPFC_CTL_PORT_ER2
:
4913 ctl_reg
= phba
->sli4_hba
.conf_regs_memmap_p
+
4914 LPFC_CTL_PORT_ER2_OFFSET
;
4916 case LPFC_CTL_PDEV_CTL
:
4917 ctl_reg
= phba
->sli4_hba
.conf_regs_memmap_p
+
4918 LPFC_CTL_PDEV_CTL_OFFSET
;
4924 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_WR
)
4926 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_ST
) {
4927 reg_val
= readl(ctl_reg
);
4930 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_CL
) {
4931 reg_val
= readl(ctl_reg
);
4934 writel(reg_val
, ctl_reg
);
4935 readl(ctl_reg
); /* flush */
4940 /* Clean out command structure on command error out */
4941 memset(&idiag
, 0, sizeof(idiag
));
4946 * lpfc_idiag_mbxacc_get_setup - idiag debugfs get mailbox access setup
4947 * @phba: Pointer to HBA context object.
4948 * @pbuffer: Pointer to data buffer.
4951 * This routine gets the driver mailbox access debugfs setup information.
4954 * This function returns the amount of data that was read (this could be less
4955 * than @nbytes if the end of the file was reached) or a negative error value.
4958 lpfc_idiag_mbxacc_get_setup(struct lpfc_hba
*phba
, char *pbuffer
)
4960 uint32_t mbx_dump_map
, mbx_dump_cnt
, mbx_word_cnt
, mbx_mbox_cmd
;
4963 mbx_mbox_cmd
= idiag
.cmd
.data
[IDIAG_MBXACC_MBCMD_INDX
];
4964 mbx_dump_map
= idiag
.cmd
.data
[IDIAG_MBXACC_DPMAP_INDX
];
4965 mbx_dump_cnt
= idiag
.cmd
.data
[IDIAG_MBXACC_DPCNT_INDX
];
4966 mbx_word_cnt
= idiag
.cmd
.data
[IDIAG_MBXACC_WDCNT_INDX
];
4968 len
+= scnprintf(pbuffer
+len
, LPFC_MBX_ACC_BUF_SIZE
-len
,
4969 "mbx_dump_map: 0x%08x\n", mbx_dump_map
);
4970 len
+= scnprintf(pbuffer
+len
, LPFC_MBX_ACC_BUF_SIZE
-len
,
4971 "mbx_dump_cnt: %04d\n", mbx_dump_cnt
);
4972 len
+= scnprintf(pbuffer
+len
, LPFC_MBX_ACC_BUF_SIZE
-len
,
4973 "mbx_word_cnt: %04d\n", mbx_word_cnt
);
4974 len
+= scnprintf(pbuffer
+len
, LPFC_MBX_ACC_BUF_SIZE
-len
,
4975 "mbx_mbox_cmd: 0x%02x\n", mbx_mbox_cmd
);
4981 * lpfc_idiag_mbxacc_read - idiag debugfs read on mailbox access
4982 * @file: The file pointer to read from.
4983 * @buf: The buffer to copy the data to.
4984 * @nbytes: The number of bytes to read.
4985 * @ppos: The position in the file to start reading from.
4988 * This routine reads data from the @phba driver mailbox access debugfs setup
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_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
4999 struct lpfc_debug
*debug
= file
->private_data
;
5000 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
5004 /* This is a user read operation */
5005 debug
->op
= LPFC_IDIAG_OP_RD
;
5008 debug
->buffer
= kmalloc(LPFC_MBX_ACC_BUF_SIZE
, GFP_KERNEL
);
5011 pbuffer
= debug
->buffer
;
5016 if ((idiag
.cmd
.opcode
!= LPFC_IDIAG_CMD_MBXACC_DP
) &&
5017 (idiag
.cmd
.opcode
!= LPFC_IDIAG_BSG_MBXACC_DP
))
5020 len
= lpfc_idiag_mbxacc_get_setup(phba
, pbuffer
);
5022 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
5026 * lpfc_idiag_mbxacc_write - Syntax check and set up idiag mbxacc commands
5027 * @file: The file pointer to read from.
5028 * @buf: The buffer to copy the user data from.
5029 * @nbytes: The number of bytes to get.
5030 * @ppos: The position in the file to start reading from.
5032 * This routine get the debugfs idiag command struct from user space and then
5033 * perform the syntax check for driver mailbox command (dump) and sets up the
5034 * necessary states in the idiag command struct accordingly.
5036 * It returns the @nbytges passing in from debugfs user space when successful.
5037 * In case of error conditions, it returns proper error code back to the user
5041 lpfc_idiag_mbxacc_write(struct file
*file
, const char __user
*buf
,
5042 size_t nbytes
, loff_t
*ppos
)
5044 struct lpfc_debug
*debug
= file
->private_data
;
5045 uint32_t mbx_dump_map
, mbx_dump_cnt
, mbx_word_cnt
, mbx_mbox_cmd
;
5048 /* This is a user write operation */
5049 debug
->op
= LPFC_IDIAG_OP_WR
;
5051 rc
= lpfc_idiag_cmd_get(buf
, nbytes
, &idiag
.cmd
);
5055 /* Sanity check on command line arguments */
5056 mbx_mbox_cmd
= idiag
.cmd
.data
[IDIAG_MBXACC_MBCMD_INDX
];
5057 mbx_dump_map
= idiag
.cmd
.data
[IDIAG_MBXACC_DPMAP_INDX
];
5058 mbx_dump_cnt
= idiag
.cmd
.data
[IDIAG_MBXACC_DPCNT_INDX
];
5059 mbx_word_cnt
= idiag
.cmd
.data
[IDIAG_MBXACC_WDCNT_INDX
];
5061 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_MBXACC_DP
) {
5062 if (!(mbx_dump_map
& LPFC_MBX_DMP_MBX_ALL
))
5064 if ((mbx_dump_map
& ~LPFC_MBX_DMP_MBX_ALL
) &&
5065 (mbx_dump_map
!= LPFC_MBX_DMP_ALL
))
5067 if (mbx_word_cnt
> sizeof(MAILBOX_t
))
5069 } else if (idiag
.cmd
.opcode
== LPFC_IDIAG_BSG_MBXACC_DP
) {
5070 if (!(mbx_dump_map
& LPFC_BSG_DMP_MBX_ALL
))
5072 if ((mbx_dump_map
& ~LPFC_BSG_DMP_MBX_ALL
) &&
5073 (mbx_dump_map
!= LPFC_MBX_DMP_ALL
))
5075 if (mbx_word_cnt
> (BSG_MBOX_SIZE
)/4)
5077 if (mbx_mbox_cmd
!= 0x9b)
5082 if (mbx_word_cnt
== 0)
5084 if (rc
!= LPFC_MBX_DMP_ARG
)
5086 if (mbx_mbox_cmd
& ~0xff)
5089 /* condition for stop mailbox dump */
5090 if (mbx_dump_cnt
== 0)
5096 /* Clean out command structure on command error out */
5097 memset(&idiag
, 0, sizeof(idiag
));
5101 /* Clean out command structure on command error out */
5102 memset(&idiag
, 0, sizeof(idiag
));
5107 * lpfc_idiag_extacc_avail_get - get the available extents information
5108 * @phba: pointer to lpfc hba data structure.
5109 * @pbuffer: pointer to internal buffer.
5110 * @len: length into the internal buffer data has been copied.
5113 * This routine is to get the available extent information.
5116 * overall lenth of the data read into the internal buffer.
5119 lpfc_idiag_extacc_avail_get(struct lpfc_hba
*phba
, char *pbuffer
, int len
)
5121 uint16_t ext_cnt
, ext_size
;
5123 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
5124 "\nAvailable Extents Information:\n");
5126 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
5127 "\tPort Available VPI extents: ");
5128 lpfc_sli4_get_avail_extnt_rsrc(phba
, LPFC_RSC_TYPE_FCOE_VPI
,
5129 &ext_cnt
, &ext_size
);
5130 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
5131 "Count %3d, Size %3d\n", ext_cnt
, ext_size
);
5133 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
5134 "\tPort Available VFI extents: ");
5135 lpfc_sli4_get_avail_extnt_rsrc(phba
, LPFC_RSC_TYPE_FCOE_VFI
,
5136 &ext_cnt
, &ext_size
);
5137 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
5138 "Count %3d, Size %3d\n", ext_cnt
, ext_size
);
5140 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
5141 "\tPort Available RPI extents: ");
5142 lpfc_sli4_get_avail_extnt_rsrc(phba
, LPFC_RSC_TYPE_FCOE_RPI
,
5143 &ext_cnt
, &ext_size
);
5144 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
5145 "Count %3d, Size %3d\n", ext_cnt
, ext_size
);
5147 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
5148 "\tPort Available XRI extents: ");
5149 lpfc_sli4_get_avail_extnt_rsrc(phba
, LPFC_RSC_TYPE_FCOE_XRI
,
5150 &ext_cnt
, &ext_size
);
5151 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
5152 "Count %3d, Size %3d\n", ext_cnt
, ext_size
);
5158 * lpfc_idiag_extacc_alloc_get - get the allocated extents information
5159 * @phba: pointer to lpfc hba data structure.
5160 * @pbuffer: pointer to internal buffer.
5161 * @len: length into the internal buffer data has been copied.
5164 * This routine is to get the allocated extent information.
5167 * overall lenth of the data read into the internal buffer.
5170 lpfc_idiag_extacc_alloc_get(struct lpfc_hba
*phba
, char *pbuffer
, int len
)
5172 uint16_t ext_cnt
, ext_size
;
5175 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
5176 "\nAllocated Extents Information:\n");
5178 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
5179 "\tHost Allocated VPI extents: ");
5180 rc
= lpfc_sli4_get_allocated_extnts(phba
, LPFC_RSC_TYPE_FCOE_VPI
,
5181 &ext_cnt
, &ext_size
);
5183 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
5184 "Port %d Extent %3d, Size %3d\n",
5185 phba
->brd_no
, ext_cnt
, ext_size
);
5187 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
5190 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
5191 "\tHost Allocated VFI extents: ");
5192 rc
= lpfc_sli4_get_allocated_extnts(phba
, LPFC_RSC_TYPE_FCOE_VFI
,
5193 &ext_cnt
, &ext_size
);
5195 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
5196 "Port %d Extent %3d, Size %3d\n",
5197 phba
->brd_no
, ext_cnt
, ext_size
);
5199 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
5202 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
5203 "\tHost Allocated RPI extents: ");
5204 rc
= lpfc_sli4_get_allocated_extnts(phba
, LPFC_RSC_TYPE_FCOE_RPI
,
5205 &ext_cnt
, &ext_size
);
5207 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
5208 "Port %d Extent %3d, Size %3d\n",
5209 phba
->brd_no
, ext_cnt
, ext_size
);
5211 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
5214 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
5215 "\tHost Allocated XRI extents: ");
5216 rc
= lpfc_sli4_get_allocated_extnts(phba
, LPFC_RSC_TYPE_FCOE_XRI
,
5217 &ext_cnt
, &ext_size
);
5219 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
5220 "Port %d Extent %3d, Size %3d\n",
5221 phba
->brd_no
, ext_cnt
, ext_size
);
5223 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
5230 * lpfc_idiag_extacc_drivr_get - get driver extent information
5231 * @phba: pointer to lpfc hba data structure.
5232 * @pbuffer: pointer to internal buffer.
5233 * @len: length into the internal buffer data has been copied.
5236 * This routine is to get the driver extent information.
5239 * overall lenth of the data read into the internal buffer.
5242 lpfc_idiag_extacc_drivr_get(struct lpfc_hba
*phba
, char *pbuffer
, int len
)
5244 struct lpfc_rsrc_blks
*rsrc_blks
;
5247 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
5248 "\nDriver Extents Information:\n");
5250 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
5251 "\tVPI extents:\n");
5253 list_for_each_entry(rsrc_blks
, &phba
->lpfc_vpi_blk_list
, list
) {
5254 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
5255 "\t\tBlock %3d: Start %4d, Count %4d\n",
5256 index
, rsrc_blks
->rsrc_start
,
5257 rsrc_blks
->rsrc_size
);
5260 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
5261 "\tVFI extents:\n");
5263 list_for_each_entry(rsrc_blks
, &phba
->sli4_hba
.lpfc_vfi_blk_list
,
5265 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
5266 "\t\tBlock %3d: Start %4d, Count %4d\n",
5267 index
, rsrc_blks
->rsrc_start
,
5268 rsrc_blks
->rsrc_size
);
5272 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
5273 "\tRPI extents:\n");
5275 list_for_each_entry(rsrc_blks
, &phba
->sli4_hba
.lpfc_rpi_blk_list
,
5277 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
5278 "\t\tBlock %3d: Start %4d, Count %4d\n",
5279 index
, rsrc_blks
->rsrc_start
,
5280 rsrc_blks
->rsrc_size
);
5284 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
5285 "\tXRI extents:\n");
5287 list_for_each_entry(rsrc_blks
, &phba
->sli4_hba
.lpfc_xri_blk_list
,
5289 len
+= scnprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
5290 "\t\tBlock %3d: Start %4d, Count %4d\n",
5291 index
, rsrc_blks
->rsrc_start
,
5292 rsrc_blks
->rsrc_size
);
5300 * lpfc_idiag_extacc_write - Syntax check and set up idiag extacc commands
5301 * @file: The file pointer to read from.
5302 * @buf: The buffer to copy the user data from.
5303 * @nbytes: The number of bytes to get.
5304 * @ppos: The position in the file to start reading from.
5306 * This routine get the debugfs idiag command struct from user space and then
5307 * perform the syntax check for extent information access commands and sets
5308 * up the necessary states in the idiag command struct accordingly.
5310 * It returns the @nbytges passing in from debugfs user space when successful.
5311 * In case of error conditions, it returns proper error code back to the user
5315 lpfc_idiag_extacc_write(struct file
*file
, const char __user
*buf
,
5316 size_t nbytes
, loff_t
*ppos
)
5318 struct lpfc_debug
*debug
= file
->private_data
;
5322 /* This is a user write operation */
5323 debug
->op
= LPFC_IDIAG_OP_WR
;
5325 rc
= lpfc_idiag_cmd_get(buf
, nbytes
, &idiag
.cmd
);
5329 ext_map
= idiag
.cmd
.data
[IDIAG_EXTACC_EXMAP_INDX
];
5331 if (idiag
.cmd
.opcode
!= LPFC_IDIAG_CMD_EXTACC_RD
)
5333 if (rc
!= LPFC_EXT_ACC_CMD_ARG
)
5335 if (!(ext_map
& LPFC_EXT_ACC_ALL
))
5340 /* Clean out command structure on command error out */
5341 memset(&idiag
, 0, sizeof(idiag
));
5346 * lpfc_idiag_extacc_read - idiag debugfs read access to extent information
5347 * @file: The file pointer to read from.
5348 * @buf: The buffer to copy the data to.
5349 * @nbytes: The number of bytes to read.
5350 * @ppos: The position in the file to start reading from.
5353 * This routine reads data from the proper extent information according to
5354 * the idiag command, and copies to user @buf.
5357 * This function returns the amount of data that was read (this could be less
5358 * than @nbytes if the end of the file was reached) or a negative error value.
5361 lpfc_idiag_extacc_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
5364 struct lpfc_debug
*debug
= file
->private_data
;
5365 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
5370 /* This is a user read operation */
5371 debug
->op
= LPFC_IDIAG_OP_RD
;
5374 debug
->buffer
= kmalloc(LPFC_EXT_ACC_BUF_SIZE
, GFP_KERNEL
);
5377 pbuffer
= debug
->buffer
;
5380 if (idiag
.cmd
.opcode
!= LPFC_IDIAG_CMD_EXTACC_RD
)
5383 ext_map
= idiag
.cmd
.data
[IDIAG_EXTACC_EXMAP_INDX
];
5384 if (ext_map
& LPFC_EXT_ACC_AVAIL
)
5385 len
= lpfc_idiag_extacc_avail_get(phba
, pbuffer
, len
);
5386 if (ext_map
& LPFC_EXT_ACC_ALLOC
)
5387 len
= lpfc_idiag_extacc_alloc_get(phba
, pbuffer
, len
);
5388 if (ext_map
& LPFC_EXT_ACC_DRIVR
)
5389 len
= lpfc_idiag_extacc_drivr_get(phba
, pbuffer
, len
);
5391 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
5394 #undef lpfc_debugfs_op_disc_trc
5395 static const struct file_operations lpfc_debugfs_op_disc_trc
= {
5396 .owner
= THIS_MODULE
,
5397 .open
= lpfc_debugfs_disc_trc_open
,
5398 .llseek
= lpfc_debugfs_lseek
,
5399 .read
= lpfc_debugfs_read
,
5400 .release
= lpfc_debugfs_release
,
5403 #undef lpfc_debugfs_op_nodelist
5404 static const struct file_operations lpfc_debugfs_op_nodelist
= {
5405 .owner
= THIS_MODULE
,
5406 .open
= lpfc_debugfs_nodelist_open
,
5407 .llseek
= lpfc_debugfs_lseek
,
5408 .read
= lpfc_debugfs_read
,
5409 .release
= lpfc_debugfs_release
,
5412 #undef lpfc_debugfs_op_multixripools
5413 static const struct file_operations lpfc_debugfs_op_multixripools
= {
5414 .owner
= THIS_MODULE
,
5415 .open
= lpfc_debugfs_multixripools_open
,
5416 .llseek
= lpfc_debugfs_lseek
,
5417 .read
= lpfc_debugfs_read
,
5418 .write
= lpfc_debugfs_multixripools_write
,
5419 .release
= lpfc_debugfs_release
,
5422 #undef lpfc_debugfs_op_hbqinfo
5423 static const struct file_operations lpfc_debugfs_op_hbqinfo
= {
5424 .owner
= THIS_MODULE
,
5425 .open
= lpfc_debugfs_hbqinfo_open
,
5426 .llseek
= lpfc_debugfs_lseek
,
5427 .read
= lpfc_debugfs_read
,
5428 .release
= lpfc_debugfs_release
,
5431 #ifdef LPFC_HDWQ_LOCK_STAT
5432 #undef lpfc_debugfs_op_lockstat
5433 static const struct file_operations lpfc_debugfs_op_lockstat
= {
5434 .owner
= THIS_MODULE
,
5435 .open
= lpfc_debugfs_lockstat_open
,
5436 .llseek
= lpfc_debugfs_lseek
,
5437 .read
= lpfc_debugfs_read
,
5438 .write
= lpfc_debugfs_lockstat_write
,
5439 .release
= lpfc_debugfs_release
,
5443 #undef lpfc_debugfs_op_dumpHBASlim
5444 static const struct file_operations lpfc_debugfs_op_dumpHBASlim
= {
5445 .owner
= THIS_MODULE
,
5446 .open
= lpfc_debugfs_dumpHBASlim_open
,
5447 .llseek
= lpfc_debugfs_lseek
,
5448 .read
= lpfc_debugfs_read
,
5449 .release
= lpfc_debugfs_release
,
5452 #undef lpfc_debugfs_op_dumpHostSlim
5453 static const struct file_operations lpfc_debugfs_op_dumpHostSlim
= {
5454 .owner
= THIS_MODULE
,
5455 .open
= lpfc_debugfs_dumpHostSlim_open
,
5456 .llseek
= lpfc_debugfs_lseek
,
5457 .read
= lpfc_debugfs_read
,
5458 .release
= lpfc_debugfs_release
,
5461 #undef lpfc_debugfs_op_nvmestat
5462 static const struct file_operations lpfc_debugfs_op_nvmestat
= {
5463 .owner
= THIS_MODULE
,
5464 .open
= lpfc_debugfs_nvmestat_open
,
5465 .llseek
= lpfc_debugfs_lseek
,
5466 .read
= lpfc_debugfs_read
,
5467 .write
= lpfc_debugfs_nvmestat_write
,
5468 .release
= lpfc_debugfs_release
,
5471 #undef lpfc_debugfs_op_scsistat
5472 static const struct file_operations lpfc_debugfs_op_scsistat
= {
5473 .owner
= THIS_MODULE
,
5474 .open
= lpfc_debugfs_scsistat_open
,
5475 .llseek
= lpfc_debugfs_lseek
,
5476 .read
= lpfc_debugfs_read
,
5477 .write
= lpfc_debugfs_scsistat_write
,
5478 .release
= lpfc_debugfs_release
,
5481 #undef lpfc_debugfs_op_nvmektime
5482 static const struct file_operations lpfc_debugfs_op_nvmektime
= {
5483 .owner
= THIS_MODULE
,
5484 .open
= lpfc_debugfs_nvmektime_open
,
5485 .llseek
= lpfc_debugfs_lseek
,
5486 .read
= lpfc_debugfs_read
,
5487 .write
= lpfc_debugfs_nvmektime_write
,
5488 .release
= lpfc_debugfs_release
,
5491 #undef lpfc_debugfs_op_nvmeio_trc
5492 static const struct file_operations lpfc_debugfs_op_nvmeio_trc
= {
5493 .owner
= THIS_MODULE
,
5494 .open
= lpfc_debugfs_nvmeio_trc_open
,
5495 .llseek
= lpfc_debugfs_lseek
,
5496 .read
= lpfc_debugfs_read
,
5497 .write
= lpfc_debugfs_nvmeio_trc_write
,
5498 .release
= lpfc_debugfs_release
,
5501 #undef lpfc_debugfs_op_cpucheck
5502 static const struct file_operations lpfc_debugfs_op_cpucheck
= {
5503 .owner
= THIS_MODULE
,
5504 .open
= lpfc_debugfs_cpucheck_open
,
5505 .llseek
= lpfc_debugfs_lseek
,
5506 .read
= lpfc_debugfs_read
,
5507 .write
= lpfc_debugfs_cpucheck_write
,
5508 .release
= lpfc_debugfs_release
,
5511 #undef lpfc_debugfs_op_dumpData
5512 static const struct file_operations lpfc_debugfs_op_dumpData
= {
5513 .owner
= THIS_MODULE
,
5514 .open
= lpfc_debugfs_dumpData_open
,
5515 .llseek
= lpfc_debugfs_lseek
,
5516 .read
= lpfc_debugfs_read
,
5517 .write
= lpfc_debugfs_dumpDataDif_write
,
5518 .release
= lpfc_debugfs_dumpDataDif_release
,
5521 #undef lpfc_debugfs_op_dumpDif
5522 static const struct file_operations lpfc_debugfs_op_dumpDif
= {
5523 .owner
= THIS_MODULE
,
5524 .open
= lpfc_debugfs_dumpDif_open
,
5525 .llseek
= lpfc_debugfs_lseek
,
5526 .read
= lpfc_debugfs_read
,
5527 .write
= lpfc_debugfs_dumpDataDif_write
,
5528 .release
= lpfc_debugfs_dumpDataDif_release
,
5531 #undef lpfc_debugfs_op_dif_err
5532 static const struct file_operations lpfc_debugfs_op_dif_err
= {
5533 .owner
= THIS_MODULE
,
5534 .open
= simple_open
,
5535 .llseek
= lpfc_debugfs_lseek
,
5536 .read
= lpfc_debugfs_dif_err_read
,
5537 .write
= lpfc_debugfs_dif_err_write
,
5538 .release
= lpfc_debugfs_dif_err_release
,
5541 #undef lpfc_debugfs_op_slow_ring_trc
5542 static const struct file_operations lpfc_debugfs_op_slow_ring_trc
= {
5543 .owner
= THIS_MODULE
,
5544 .open
= lpfc_debugfs_slow_ring_trc_open
,
5545 .llseek
= lpfc_debugfs_lseek
,
5546 .read
= lpfc_debugfs_read
,
5547 .release
= lpfc_debugfs_release
,
5550 static struct dentry
*lpfc_debugfs_root
= NULL
;
5551 static atomic_t lpfc_debugfs_hba_count
;
5554 * File operations for the iDiag debugfs
5556 #undef lpfc_idiag_op_pciCfg
5557 static const struct file_operations lpfc_idiag_op_pciCfg
= {
5558 .owner
= THIS_MODULE
,
5559 .open
= lpfc_idiag_open
,
5560 .llseek
= lpfc_debugfs_lseek
,
5561 .read
= lpfc_idiag_pcicfg_read
,
5562 .write
= lpfc_idiag_pcicfg_write
,
5563 .release
= lpfc_idiag_cmd_release
,
5566 #undef lpfc_idiag_op_barAcc
5567 static const struct file_operations lpfc_idiag_op_barAcc
= {
5568 .owner
= THIS_MODULE
,
5569 .open
= lpfc_idiag_open
,
5570 .llseek
= lpfc_debugfs_lseek
,
5571 .read
= lpfc_idiag_baracc_read
,
5572 .write
= lpfc_idiag_baracc_write
,
5573 .release
= lpfc_idiag_cmd_release
,
5576 #undef lpfc_idiag_op_queInfo
5577 static const struct file_operations lpfc_idiag_op_queInfo
= {
5578 .owner
= THIS_MODULE
,
5579 .open
= lpfc_idiag_open
,
5580 .read
= lpfc_idiag_queinfo_read
,
5581 .release
= lpfc_idiag_release
,
5584 #undef lpfc_idiag_op_queAcc
5585 static const struct file_operations lpfc_idiag_op_queAcc
= {
5586 .owner
= THIS_MODULE
,
5587 .open
= lpfc_idiag_open
,
5588 .llseek
= lpfc_debugfs_lseek
,
5589 .read
= lpfc_idiag_queacc_read
,
5590 .write
= lpfc_idiag_queacc_write
,
5591 .release
= lpfc_idiag_cmd_release
,
5594 #undef lpfc_idiag_op_drbAcc
5595 static const struct file_operations lpfc_idiag_op_drbAcc
= {
5596 .owner
= THIS_MODULE
,
5597 .open
= lpfc_idiag_open
,
5598 .llseek
= lpfc_debugfs_lseek
,
5599 .read
= lpfc_idiag_drbacc_read
,
5600 .write
= lpfc_idiag_drbacc_write
,
5601 .release
= lpfc_idiag_cmd_release
,
5604 #undef lpfc_idiag_op_ctlAcc
5605 static const struct file_operations lpfc_idiag_op_ctlAcc
= {
5606 .owner
= THIS_MODULE
,
5607 .open
= lpfc_idiag_open
,
5608 .llseek
= lpfc_debugfs_lseek
,
5609 .read
= lpfc_idiag_ctlacc_read
,
5610 .write
= lpfc_idiag_ctlacc_write
,
5611 .release
= lpfc_idiag_cmd_release
,
5614 #undef lpfc_idiag_op_mbxAcc
5615 static const struct file_operations lpfc_idiag_op_mbxAcc
= {
5616 .owner
= THIS_MODULE
,
5617 .open
= lpfc_idiag_open
,
5618 .llseek
= lpfc_debugfs_lseek
,
5619 .read
= lpfc_idiag_mbxacc_read
,
5620 .write
= lpfc_idiag_mbxacc_write
,
5621 .release
= lpfc_idiag_cmd_release
,
5624 #undef lpfc_idiag_op_extAcc
5625 static const struct file_operations lpfc_idiag_op_extAcc
= {
5626 .owner
= THIS_MODULE
,
5627 .open
= lpfc_idiag_open
,
5628 .llseek
= lpfc_debugfs_lseek
,
5629 .read
= lpfc_idiag_extacc_read
,
5630 .write
= lpfc_idiag_extacc_write
,
5631 .release
= lpfc_idiag_cmd_release
,
5636 /* lpfc_idiag_mbxacc_dump_bsg_mbox - idiag debugfs dump bsg mailbox command
5637 * @phba: Pointer to HBA context object.
5638 * @dmabuf: Pointer to a DMA buffer descriptor.
5641 * This routine dump a bsg pass-through non-embedded mailbox command with
5645 lpfc_idiag_mbxacc_dump_bsg_mbox(struct lpfc_hba
*phba
, enum nemb_type nemb_tp
,
5646 enum mbox_type mbox_tp
, enum dma_type dma_tp
,
5647 enum sta_type sta_tp
,
5648 struct lpfc_dmabuf
*dmabuf
, uint32_t ext_buf
)
5650 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
5651 uint32_t *mbx_mbox_cmd
, *mbx_dump_map
, *mbx_dump_cnt
, *mbx_word_cnt
;
5652 char line_buf
[LPFC_MBX_ACC_LBUF_SZ
];
5654 uint32_t do_dump
= 0;
5658 if (idiag
.cmd
.opcode
!= LPFC_IDIAG_BSG_MBXACC_DP
)
5661 mbx_mbox_cmd
= &idiag
.cmd
.data
[IDIAG_MBXACC_MBCMD_INDX
];
5662 mbx_dump_map
= &idiag
.cmd
.data
[IDIAG_MBXACC_DPMAP_INDX
];
5663 mbx_dump_cnt
= &idiag
.cmd
.data
[IDIAG_MBXACC_DPCNT_INDX
];
5664 mbx_word_cnt
= &idiag
.cmd
.data
[IDIAG_MBXACC_WDCNT_INDX
];
5666 if (!(*mbx_dump_map
& LPFC_MBX_DMP_ALL
) ||
5667 (*mbx_dump_cnt
== 0) ||
5668 (*mbx_word_cnt
== 0))
5671 if (*mbx_mbox_cmd
!= 0x9B)
5674 if ((mbox_tp
== mbox_rd
) && (dma_tp
== dma_mbox
)) {
5675 if (*mbx_dump_map
& LPFC_BSG_DMP_MBX_RD_MBX
) {
5676 do_dump
|= LPFC_BSG_DMP_MBX_RD_MBX
;
5677 pr_err("\nRead mbox command (x%x), "
5678 "nemb:0x%x, extbuf_cnt:%d:\n",
5679 sta_tp
, nemb_tp
, ext_buf
);
5682 if ((mbox_tp
== mbox_rd
) && (dma_tp
== dma_ebuf
)) {
5683 if (*mbx_dump_map
& LPFC_BSG_DMP_MBX_RD_BUF
) {
5684 do_dump
|= LPFC_BSG_DMP_MBX_RD_BUF
;
5685 pr_err("\nRead mbox buffer (x%x), "
5686 "nemb:0x%x, extbuf_seq:%d:\n",
5687 sta_tp
, nemb_tp
, ext_buf
);
5690 if ((mbox_tp
== mbox_wr
) && (dma_tp
== dma_mbox
)) {
5691 if (*mbx_dump_map
& LPFC_BSG_DMP_MBX_WR_MBX
) {
5692 do_dump
|= LPFC_BSG_DMP_MBX_WR_MBX
;
5693 pr_err("\nWrite mbox command (x%x), "
5694 "nemb:0x%x, extbuf_cnt:%d:\n",
5695 sta_tp
, nemb_tp
, ext_buf
);
5698 if ((mbox_tp
== mbox_wr
) && (dma_tp
== dma_ebuf
)) {
5699 if (*mbx_dump_map
& LPFC_BSG_DMP_MBX_WR_BUF
) {
5700 do_dump
|= LPFC_BSG_DMP_MBX_WR_BUF
;
5701 pr_err("\nWrite mbox buffer (x%x), "
5702 "nemb:0x%x, extbuf_seq:%d:\n",
5703 sta_tp
, nemb_tp
, ext_buf
);
5707 /* dump buffer content */
5709 pword
= (uint32_t *)dmabuf
->virt
;
5710 for (i
= 0; i
< *mbx_word_cnt
; i
++) {
5713 pr_err("%s\n", line_buf
);
5715 len
+= scnprintf(line_buf
+len
,
5716 LPFC_MBX_ACC_LBUF_SZ
-len
,
5719 len
+= scnprintf(line_buf
+len
, LPFC_MBX_ACC_LBUF_SZ
-len
,
5720 "%08x ", (uint32_t)*pword
);
5724 pr_err("%s\n", line_buf
);
5728 /* Clean out command structure on reaching dump count */
5729 if (*mbx_dump_cnt
== 0)
5730 memset(&idiag
, 0, sizeof(idiag
));
5735 /* lpfc_idiag_mbxacc_dump_issue_mbox - idiag debugfs dump issue mailbox command
5736 * @phba: Pointer to HBA context object.
5737 * @dmabuf: Pointer to a DMA buffer descriptor.
5740 * This routine dump a pass-through non-embedded mailbox command from issue
5744 lpfc_idiag_mbxacc_dump_issue_mbox(struct lpfc_hba
*phba
, MAILBOX_t
*pmbox
)
5746 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
5747 uint32_t *mbx_dump_map
, *mbx_dump_cnt
, *mbx_word_cnt
, *mbx_mbox_cmd
;
5748 char line_buf
[LPFC_MBX_ACC_LBUF_SZ
];
5754 if (idiag
.cmd
.opcode
!= LPFC_IDIAG_CMD_MBXACC_DP
)
5757 mbx_mbox_cmd
= &idiag
.cmd
.data
[IDIAG_MBXACC_MBCMD_INDX
];
5758 mbx_dump_map
= &idiag
.cmd
.data
[IDIAG_MBXACC_DPMAP_INDX
];
5759 mbx_dump_cnt
= &idiag
.cmd
.data
[IDIAG_MBXACC_DPCNT_INDX
];
5760 mbx_word_cnt
= &idiag
.cmd
.data
[IDIAG_MBXACC_WDCNT_INDX
];
5762 if (!(*mbx_dump_map
& LPFC_MBX_DMP_MBX_ALL
) ||
5763 (*mbx_dump_cnt
== 0) ||
5764 (*mbx_word_cnt
== 0))
5767 if ((*mbx_mbox_cmd
!= LPFC_MBX_ALL_CMD
) &&
5768 (*mbx_mbox_cmd
!= pmbox
->mbxCommand
))
5771 /* dump buffer content */
5772 if (*mbx_dump_map
& LPFC_MBX_DMP_MBX_WORD
) {
5773 pr_err("Mailbox command:0x%x dump by word:\n",
5775 pword
= (uint32_t *)pmbox
;
5776 for (i
= 0; i
< *mbx_word_cnt
; i
++) {
5779 pr_err("%s\n", line_buf
);
5781 memset(line_buf
, 0, LPFC_MBX_ACC_LBUF_SZ
);
5782 len
+= scnprintf(line_buf
+len
,
5783 LPFC_MBX_ACC_LBUF_SZ
-len
,
5786 len
+= scnprintf(line_buf
+len
, LPFC_MBX_ACC_LBUF_SZ
-len
,
5788 ((uint32_t)*pword
) & 0xffffffff);
5792 pr_err("%s\n", line_buf
);
5795 if (*mbx_dump_map
& LPFC_MBX_DMP_MBX_BYTE
) {
5796 pr_err("Mailbox command:0x%x dump by byte:\n",
5798 pbyte
= (uint8_t *)pmbox
;
5799 for (i
= 0; i
< *mbx_word_cnt
; i
++) {
5802 pr_err("%s\n", line_buf
);
5804 memset(line_buf
, 0, LPFC_MBX_ACC_LBUF_SZ
);
5805 len
+= scnprintf(line_buf
+len
,
5806 LPFC_MBX_ACC_LBUF_SZ
-len
,
5809 for (j
= 0; j
< 4; j
++) {
5810 len
+= scnprintf(line_buf
+len
,
5811 LPFC_MBX_ACC_LBUF_SZ
-len
,
5813 ((uint8_t)*pbyte
) & 0xff);
5816 len
+= scnprintf(line_buf
+len
,
5817 LPFC_MBX_ACC_LBUF_SZ
-len
, " ");
5820 pr_err("%s\n", line_buf
);
5825 /* Clean out command structure on reaching dump count */
5826 if (*mbx_dump_cnt
== 0)
5827 memset(&idiag
, 0, sizeof(idiag
));
5833 * lpfc_debugfs_initialize - Initialize debugfs for a vport
5834 * @vport: The vport pointer to initialize.
5837 * When Debugfs is configured this routine sets up the lpfc debugfs file system.
5838 * If not already created, this routine will create the lpfc directory, and
5839 * lpfcX directory (for this HBA), and vportX directory for this vport. It will
5840 * also create each file used to access lpfc specific debugfs information.
5843 lpfc_debugfs_initialize(struct lpfc_vport
*vport
)
5845 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
5846 struct lpfc_hba
*phba
= vport
->phba
;
5849 bool pport_setup
= false;
5851 if (!lpfc_debugfs_enable
)
5854 /* Setup lpfc root directory */
5855 if (!lpfc_debugfs_root
) {
5856 lpfc_debugfs_root
= debugfs_create_dir("lpfc", NULL
);
5857 atomic_set(&lpfc_debugfs_hba_count
, 0);
5859 if (!lpfc_debugfs_start_time
)
5860 lpfc_debugfs_start_time
= jiffies
;
5862 /* Setup funcX directory for specific HBA PCI function */
5863 snprintf(name
, sizeof(name
), "fn%d", phba
->brd_no
);
5864 if (!phba
->hba_debugfs_root
) {
5866 phba
->hba_debugfs_root
=
5867 debugfs_create_dir(name
, lpfc_debugfs_root
);
5868 atomic_inc(&lpfc_debugfs_hba_count
);
5869 atomic_set(&phba
->debugfs_vport_count
, 0);
5871 /* Multi-XRI pools */
5872 snprintf(name
, sizeof(name
), "multixripools");
5873 phba
->debug_multixri_pools
=
5874 debugfs_create_file(name
, S_IFREG
| 0644,
5875 phba
->hba_debugfs_root
,
5877 &lpfc_debugfs_op_multixripools
);
5878 if (!phba
->debug_multixri_pools
) {
5879 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5880 "0527 Cannot create debugfs multixripools\n");
5885 snprintf(name
, sizeof(name
), "hbqinfo");
5886 phba
->debug_hbqinfo
=
5887 debugfs_create_file(name
, S_IFREG
| 0644,
5888 phba
->hba_debugfs_root
,
5889 phba
, &lpfc_debugfs_op_hbqinfo
);
5891 #ifdef LPFC_HDWQ_LOCK_STAT
5892 /* Setup lockstat */
5893 snprintf(name
, sizeof(name
), "lockstat");
5894 phba
->debug_lockstat
=
5895 debugfs_create_file(name
, S_IFREG
| 0644,
5896 phba
->hba_debugfs_root
,
5897 phba
, &lpfc_debugfs_op_lockstat
);
5898 if (!phba
->debug_lockstat
) {
5899 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
5900 "4610 Cant create debugfs lockstat\n");
5905 /* Setup dumpHBASlim */
5906 if (phba
->sli_rev
< LPFC_SLI_REV4
) {
5907 snprintf(name
, sizeof(name
), "dumpHBASlim");
5908 phba
->debug_dumpHBASlim
=
5909 debugfs_create_file(name
,
5910 S_IFREG
|S_IRUGO
|S_IWUSR
,
5911 phba
->hba_debugfs_root
,
5912 phba
, &lpfc_debugfs_op_dumpHBASlim
);
5914 phba
->debug_dumpHBASlim
= NULL
;
5916 /* Setup dumpHostSlim */
5917 if (phba
->sli_rev
< LPFC_SLI_REV4
) {
5918 snprintf(name
, sizeof(name
), "dumpHostSlim");
5919 phba
->debug_dumpHostSlim
=
5920 debugfs_create_file(name
,
5921 S_IFREG
|S_IRUGO
|S_IWUSR
,
5922 phba
->hba_debugfs_root
,
5923 phba
, &lpfc_debugfs_op_dumpHostSlim
);
5925 phba
->debug_dumpHostSlim
= NULL
;
5927 /* Setup dumpData */
5928 snprintf(name
, sizeof(name
), "dumpData");
5929 phba
->debug_dumpData
=
5930 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5931 phba
->hba_debugfs_root
,
5932 phba
, &lpfc_debugfs_op_dumpData
);
5935 snprintf(name
, sizeof(name
), "dumpDif");
5936 phba
->debug_dumpDif
=
5937 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5938 phba
->hba_debugfs_root
,
5939 phba
, &lpfc_debugfs_op_dumpDif
);
5941 /* Setup DIF Error Injections */
5942 snprintf(name
, sizeof(name
), "InjErrLBA");
5943 phba
->debug_InjErrLBA
=
5944 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5945 phba
->hba_debugfs_root
,
5946 phba
, &lpfc_debugfs_op_dif_err
);
5947 phba
->lpfc_injerr_lba
= LPFC_INJERR_LBA_OFF
;
5949 snprintf(name
, sizeof(name
), "InjErrNPortID");
5950 phba
->debug_InjErrNPortID
=
5951 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5952 phba
->hba_debugfs_root
,
5953 phba
, &lpfc_debugfs_op_dif_err
);
5955 snprintf(name
, sizeof(name
), "InjErrWWPN");
5956 phba
->debug_InjErrWWPN
=
5957 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5958 phba
->hba_debugfs_root
,
5959 phba
, &lpfc_debugfs_op_dif_err
);
5961 snprintf(name
, sizeof(name
), "writeGuardInjErr");
5962 phba
->debug_writeGuard
=
5963 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5964 phba
->hba_debugfs_root
,
5965 phba
, &lpfc_debugfs_op_dif_err
);
5967 snprintf(name
, sizeof(name
), "writeAppInjErr");
5968 phba
->debug_writeApp
=
5969 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5970 phba
->hba_debugfs_root
,
5971 phba
, &lpfc_debugfs_op_dif_err
);
5973 snprintf(name
, sizeof(name
), "writeRefInjErr");
5974 phba
->debug_writeRef
=
5975 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5976 phba
->hba_debugfs_root
,
5977 phba
, &lpfc_debugfs_op_dif_err
);
5979 snprintf(name
, sizeof(name
), "readGuardInjErr");
5980 phba
->debug_readGuard
=
5981 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5982 phba
->hba_debugfs_root
,
5983 phba
, &lpfc_debugfs_op_dif_err
);
5985 snprintf(name
, sizeof(name
), "readAppInjErr");
5986 phba
->debug_readApp
=
5987 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5988 phba
->hba_debugfs_root
,
5989 phba
, &lpfc_debugfs_op_dif_err
);
5991 snprintf(name
, sizeof(name
), "readRefInjErr");
5992 phba
->debug_readRef
=
5993 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
5994 phba
->hba_debugfs_root
,
5995 phba
, &lpfc_debugfs_op_dif_err
);
5997 /* Setup slow ring trace */
5998 if (lpfc_debugfs_max_slow_ring_trc
) {
5999 num
= lpfc_debugfs_max_slow_ring_trc
- 1;
6000 if (num
& lpfc_debugfs_max_slow_ring_trc
) {
6001 /* Change to be a power of 2 */
6002 num
= lpfc_debugfs_max_slow_ring_trc
;
6008 lpfc_debugfs_max_slow_ring_trc
= (1 << i
);
6009 pr_err("lpfc_debugfs_max_disc_trc changed to "
6010 "%d\n", lpfc_debugfs_max_disc_trc
);
6014 snprintf(name
, sizeof(name
), "slow_ring_trace");
6015 phba
->debug_slow_ring_trc
=
6016 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
6017 phba
->hba_debugfs_root
,
6018 phba
, &lpfc_debugfs_op_slow_ring_trc
);
6019 if (!phba
->slow_ring_trc
) {
6020 phba
->slow_ring_trc
= kmalloc(
6021 (sizeof(struct lpfc_debugfs_trc
) *
6022 lpfc_debugfs_max_slow_ring_trc
),
6024 if (!phba
->slow_ring_trc
) {
6025 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
6026 "0416 Cannot create debugfs "
6027 "slow_ring buffer\n");
6030 atomic_set(&phba
->slow_ring_trc_cnt
, 0);
6031 memset(phba
->slow_ring_trc
, 0,
6032 (sizeof(struct lpfc_debugfs_trc
) *
6033 lpfc_debugfs_max_slow_ring_trc
));
6036 snprintf(name
, sizeof(name
), "nvmeio_trc");
6037 phba
->debug_nvmeio_trc
=
6038 debugfs_create_file(name
, 0644,
6039 phba
->hba_debugfs_root
,
6040 phba
, &lpfc_debugfs_op_nvmeio_trc
);
6042 atomic_set(&phba
->nvmeio_trc_cnt
, 0);
6043 if (lpfc_debugfs_max_nvmeio_trc
) {
6044 num
= lpfc_debugfs_max_nvmeio_trc
- 1;
6045 if (num
& lpfc_debugfs_max_disc_trc
) {
6046 /* Change to be a power of 2 */
6047 num
= lpfc_debugfs_max_nvmeio_trc
;
6053 lpfc_debugfs_max_nvmeio_trc
= (1 << i
);
6054 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
6055 "0575 lpfc_debugfs_max_nvmeio_trc "
6057 lpfc_debugfs_max_nvmeio_trc
);
6059 phba
->nvmeio_trc_size
= lpfc_debugfs_max_nvmeio_trc
;
6061 /* Allocate trace buffer and initialize */
6062 phba
->nvmeio_trc
= kzalloc(
6063 (sizeof(struct lpfc_debugfs_nvmeio_trc
) *
6064 phba
->nvmeio_trc_size
), GFP_KERNEL
);
6066 if (!phba
->nvmeio_trc
) {
6067 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
6068 "0576 Cannot create debugfs "
6069 "nvmeio_trc buffer\n");
6072 phba
->nvmeio_trc_on
= 1;
6073 phba
->nvmeio_trc_output_idx
= 0;
6074 phba
->nvmeio_trc
= NULL
;
6077 phba
->nvmeio_trc_size
= 0;
6078 phba
->nvmeio_trc_on
= 0;
6079 phba
->nvmeio_trc_output_idx
= 0;
6080 phba
->nvmeio_trc
= NULL
;
6084 snprintf(name
, sizeof(name
), "vport%d", vport
->vpi
);
6085 if (!vport
->vport_debugfs_root
) {
6086 vport
->vport_debugfs_root
=
6087 debugfs_create_dir(name
, phba
->hba_debugfs_root
);
6088 atomic_inc(&phba
->debugfs_vport_count
);
6091 if (lpfc_debugfs_max_disc_trc
) {
6092 num
= lpfc_debugfs_max_disc_trc
- 1;
6093 if (num
& lpfc_debugfs_max_disc_trc
) {
6094 /* Change to be a power of 2 */
6095 num
= lpfc_debugfs_max_disc_trc
;
6101 lpfc_debugfs_max_disc_trc
= (1 << i
);
6102 pr_err("lpfc_debugfs_max_disc_trc changed to %d\n",
6103 lpfc_debugfs_max_disc_trc
);
6107 vport
->disc_trc
= kzalloc(
6108 (sizeof(struct lpfc_debugfs_trc
) * lpfc_debugfs_max_disc_trc
),
6111 if (!vport
->disc_trc
) {
6112 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
6113 "0418 Cannot create debugfs disc trace "
6117 atomic_set(&vport
->disc_trc_cnt
, 0);
6119 snprintf(name
, sizeof(name
), "discovery_trace");
6120 vport
->debug_disc_trc
=
6121 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
6122 vport
->vport_debugfs_root
,
6123 vport
, &lpfc_debugfs_op_disc_trc
);
6124 snprintf(name
, sizeof(name
), "nodelist");
6125 vport
->debug_nodelist
=
6126 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
6127 vport
->vport_debugfs_root
,
6128 vport
, &lpfc_debugfs_op_nodelist
);
6130 snprintf(name
, sizeof(name
), "nvmestat");
6131 vport
->debug_nvmestat
=
6132 debugfs_create_file(name
, 0644,
6133 vport
->vport_debugfs_root
,
6134 vport
, &lpfc_debugfs_op_nvmestat
);
6136 snprintf(name
, sizeof(name
), "scsistat");
6137 vport
->debug_scsistat
=
6138 debugfs_create_file(name
, 0644,
6139 vport
->vport_debugfs_root
,
6140 vport
, &lpfc_debugfs_op_scsistat
);
6141 if (!vport
->debug_scsistat
) {
6142 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
6143 "4611 Cannot create debugfs scsistat\n");
6147 snprintf(name
, sizeof(name
), "nvmektime");
6148 vport
->debug_nvmektime
=
6149 debugfs_create_file(name
, 0644,
6150 vport
->vport_debugfs_root
,
6151 vport
, &lpfc_debugfs_op_nvmektime
);
6153 snprintf(name
, sizeof(name
), "cpucheck");
6154 vport
->debug_cpucheck
=
6155 debugfs_create_file(name
, 0644,
6156 vport
->vport_debugfs_root
,
6157 vport
, &lpfc_debugfs_op_cpucheck
);
6160 * The following section is for additional directories/files for the
6168 * iDiag debugfs root entry points for SLI4 device only
6170 if (phba
->sli_rev
< LPFC_SLI_REV4
)
6173 snprintf(name
, sizeof(name
), "iDiag");
6174 if (!phba
->idiag_root
) {
6176 debugfs_create_dir(name
, phba
->hba_debugfs_root
);
6177 /* Initialize iDiag data structure */
6178 memset(&idiag
, 0, sizeof(idiag
));
6181 /* iDiag read PCI config space */
6182 snprintf(name
, sizeof(name
), "pciCfg");
6183 if (!phba
->idiag_pci_cfg
) {
6184 phba
->idiag_pci_cfg
=
6185 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
6186 phba
->idiag_root
, phba
, &lpfc_idiag_op_pciCfg
);
6187 idiag
.offset
.last_rd
= 0;
6190 /* iDiag PCI BAR access */
6191 snprintf(name
, sizeof(name
), "barAcc");
6192 if (!phba
->idiag_bar_acc
) {
6193 phba
->idiag_bar_acc
=
6194 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
6195 phba
->idiag_root
, phba
, &lpfc_idiag_op_barAcc
);
6196 idiag
.offset
.last_rd
= 0;
6199 /* iDiag get PCI function queue information */
6200 snprintf(name
, sizeof(name
), "queInfo");
6201 if (!phba
->idiag_que_info
) {
6202 phba
->idiag_que_info
=
6203 debugfs_create_file(name
, S_IFREG
|S_IRUGO
,
6204 phba
->idiag_root
, phba
, &lpfc_idiag_op_queInfo
);
6207 /* iDiag access PCI function queue */
6208 snprintf(name
, sizeof(name
), "queAcc");
6209 if (!phba
->idiag_que_acc
) {
6210 phba
->idiag_que_acc
=
6211 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
6212 phba
->idiag_root
, phba
, &lpfc_idiag_op_queAcc
);
6215 /* iDiag access PCI function doorbell registers */
6216 snprintf(name
, sizeof(name
), "drbAcc");
6217 if (!phba
->idiag_drb_acc
) {
6218 phba
->idiag_drb_acc
=
6219 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
6220 phba
->idiag_root
, phba
, &lpfc_idiag_op_drbAcc
);
6223 /* iDiag access PCI function control registers */
6224 snprintf(name
, sizeof(name
), "ctlAcc");
6225 if (!phba
->idiag_ctl_acc
) {
6226 phba
->idiag_ctl_acc
=
6227 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
6228 phba
->idiag_root
, phba
, &lpfc_idiag_op_ctlAcc
);
6231 /* iDiag access mbox commands */
6232 snprintf(name
, sizeof(name
), "mbxAcc");
6233 if (!phba
->idiag_mbx_acc
) {
6234 phba
->idiag_mbx_acc
=
6235 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
6236 phba
->idiag_root
, phba
, &lpfc_idiag_op_mbxAcc
);
6239 /* iDiag extents access commands */
6240 if (phba
->sli4_hba
.extents_in_use
) {
6241 snprintf(name
, sizeof(name
), "extAcc");
6242 if (!phba
->idiag_ext_acc
) {
6243 phba
->idiag_ext_acc
=
6244 debugfs_create_file(name
,
6245 S_IFREG
|S_IRUGO
|S_IWUSR
,
6246 phba
->idiag_root
, phba
,
6247 &lpfc_idiag_op_extAcc
);
6257 * lpfc_debugfs_terminate - Tear down debugfs infrastructure for this vport
6258 * @vport: The vport pointer to remove from debugfs.
6261 * When Debugfs is configured this routine removes debugfs file system elements
6262 * that are specific to this vport. It also checks to see if there are any
6263 * users left for the debugfs directories associated with the HBA and driver. If
6264 * this is the last user of the HBA directory or driver directory then it will
6265 * remove those from the debugfs infrastructure as well.
6268 lpfc_debugfs_terminate(struct lpfc_vport
*vport
)
6270 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
6271 struct lpfc_hba
*phba
= vport
->phba
;
6273 kfree(vport
->disc_trc
);
6274 vport
->disc_trc
= NULL
;
6276 debugfs_remove(vport
->debug_disc_trc
); /* discovery_trace */
6277 vport
->debug_disc_trc
= NULL
;
6279 debugfs_remove(vport
->debug_nodelist
); /* nodelist */
6280 vport
->debug_nodelist
= NULL
;
6282 debugfs_remove(vport
->debug_nvmestat
); /* nvmestat */
6283 vport
->debug_nvmestat
= NULL
;
6285 debugfs_remove(vport
->debug_scsistat
); /* scsistat */
6286 vport
->debug_scsistat
= NULL
;
6288 debugfs_remove(vport
->debug_nvmektime
); /* nvmektime */
6289 vport
->debug_nvmektime
= NULL
;
6291 debugfs_remove(vport
->debug_cpucheck
); /* cpucheck */
6292 vport
->debug_cpucheck
= NULL
;
6294 if (vport
->vport_debugfs_root
) {
6295 debugfs_remove(vport
->vport_debugfs_root
); /* vportX */
6296 vport
->vport_debugfs_root
= NULL
;
6297 atomic_dec(&phba
->debugfs_vport_count
);
6300 if (atomic_read(&phba
->debugfs_vport_count
) == 0) {
6302 debugfs_remove(phba
->debug_multixri_pools
); /* multixripools*/
6303 phba
->debug_multixri_pools
= NULL
;
6305 debugfs_remove(phba
->debug_hbqinfo
); /* hbqinfo */
6306 phba
->debug_hbqinfo
= NULL
;
6308 #ifdef LPFC_HDWQ_LOCK_STAT
6309 debugfs_remove(phba
->debug_lockstat
); /* lockstat */
6310 phba
->debug_lockstat
= NULL
;
6312 debugfs_remove(phba
->debug_dumpHBASlim
); /* HBASlim */
6313 phba
->debug_dumpHBASlim
= NULL
;
6315 debugfs_remove(phba
->debug_dumpHostSlim
); /* HostSlim */
6316 phba
->debug_dumpHostSlim
= NULL
;
6318 debugfs_remove(phba
->debug_dumpData
); /* dumpData */
6319 phba
->debug_dumpData
= NULL
;
6321 debugfs_remove(phba
->debug_dumpDif
); /* dumpDif */
6322 phba
->debug_dumpDif
= NULL
;
6324 debugfs_remove(phba
->debug_InjErrLBA
); /* InjErrLBA */
6325 phba
->debug_InjErrLBA
= NULL
;
6327 debugfs_remove(phba
->debug_InjErrNPortID
);
6328 phba
->debug_InjErrNPortID
= NULL
;
6330 debugfs_remove(phba
->debug_InjErrWWPN
); /* InjErrWWPN */
6331 phba
->debug_InjErrWWPN
= NULL
;
6333 debugfs_remove(phba
->debug_writeGuard
); /* writeGuard */
6334 phba
->debug_writeGuard
= NULL
;
6336 debugfs_remove(phba
->debug_writeApp
); /* writeApp */
6337 phba
->debug_writeApp
= NULL
;
6339 debugfs_remove(phba
->debug_writeRef
); /* writeRef */
6340 phba
->debug_writeRef
= NULL
;
6342 debugfs_remove(phba
->debug_readGuard
); /* readGuard */
6343 phba
->debug_readGuard
= NULL
;
6345 debugfs_remove(phba
->debug_readApp
); /* readApp */
6346 phba
->debug_readApp
= NULL
;
6348 debugfs_remove(phba
->debug_readRef
); /* readRef */
6349 phba
->debug_readRef
= NULL
;
6351 kfree(phba
->slow_ring_trc
);
6352 phba
->slow_ring_trc
= NULL
;
6354 /* slow_ring_trace */
6355 debugfs_remove(phba
->debug_slow_ring_trc
);
6356 phba
->debug_slow_ring_trc
= NULL
;
6358 debugfs_remove(phba
->debug_nvmeio_trc
);
6359 phba
->debug_nvmeio_trc
= NULL
;
6361 kfree(phba
->nvmeio_trc
);
6362 phba
->nvmeio_trc
= NULL
;
6367 if (phba
->sli_rev
== LPFC_SLI_REV4
) {
6369 debugfs_remove(phba
->idiag_ext_acc
);
6370 phba
->idiag_ext_acc
= NULL
;
6373 debugfs_remove(phba
->idiag_mbx_acc
);
6374 phba
->idiag_mbx_acc
= NULL
;
6377 debugfs_remove(phba
->idiag_ctl_acc
);
6378 phba
->idiag_ctl_acc
= NULL
;
6381 debugfs_remove(phba
->idiag_drb_acc
);
6382 phba
->idiag_drb_acc
= NULL
;
6385 debugfs_remove(phba
->idiag_que_acc
);
6386 phba
->idiag_que_acc
= NULL
;
6389 debugfs_remove(phba
->idiag_que_info
);
6390 phba
->idiag_que_info
= NULL
;
6393 debugfs_remove(phba
->idiag_bar_acc
);
6394 phba
->idiag_bar_acc
= NULL
;
6397 debugfs_remove(phba
->idiag_pci_cfg
);
6398 phba
->idiag_pci_cfg
= NULL
;
6400 /* Finally remove the iDiag debugfs root */
6401 debugfs_remove(phba
->idiag_root
);
6402 phba
->idiag_root
= NULL
;
6405 if (phba
->hba_debugfs_root
) {
6406 debugfs_remove(phba
->hba_debugfs_root
); /* fnX */
6407 phba
->hba_debugfs_root
= NULL
;
6408 atomic_dec(&lpfc_debugfs_hba_count
);
6411 if (atomic_read(&lpfc_debugfs_hba_count
) == 0) {
6412 debugfs_remove(lpfc_debugfs_root
); /* lpfc */
6413 lpfc_debugfs_root
= NULL
;
6421 * Driver debug utility routines outside of debugfs. The debug utility
6422 * routines implemented here is intended to be used in the instrumented
6423 * debug driver for debugging host or port issues.
6427 * lpfc_debug_dump_all_queues - dump all the queues with a hba
6428 * @phba: Pointer to HBA context object.
6430 * This function dumps entries of all the queues asociated with the @phba.
6433 lpfc_debug_dump_all_queues(struct lpfc_hba
*phba
)
6438 * Dump Work Queues (WQs)
6440 lpfc_debug_dump_wq(phba
, DUMP_MBX
, 0);
6441 lpfc_debug_dump_wq(phba
, DUMP_ELS
, 0);
6442 lpfc_debug_dump_wq(phba
, DUMP_NVMELS
, 0);
6444 for (idx
= 0; idx
< phba
->cfg_hdw_queue
; idx
++)
6445 lpfc_debug_dump_wq(phba
, DUMP_FCP
, idx
);
6447 if (phba
->cfg_enable_fc4_type
& LPFC_ENABLE_NVME
) {
6448 for (idx
= 0; idx
< phba
->cfg_hdw_queue
; idx
++)
6449 lpfc_debug_dump_wq(phba
, DUMP_NVME
, idx
);
6452 lpfc_debug_dump_hdr_rq(phba
);
6453 lpfc_debug_dump_dat_rq(phba
);
6455 * Dump Complete Queues (CQs)
6457 lpfc_debug_dump_cq(phba
, DUMP_MBX
, 0);
6458 lpfc_debug_dump_cq(phba
, DUMP_ELS
, 0);
6459 lpfc_debug_dump_cq(phba
, DUMP_NVMELS
, 0);
6461 for (idx
= 0; idx
< phba
->cfg_hdw_queue
; idx
++)
6462 lpfc_debug_dump_cq(phba
, DUMP_FCP
, idx
);
6464 if (phba
->cfg_enable_fc4_type
& LPFC_ENABLE_NVME
) {
6465 for (idx
= 0; idx
< phba
->cfg_hdw_queue
; idx
++)
6466 lpfc_debug_dump_cq(phba
, DUMP_NVME
, idx
);
6470 * Dump Event Queues (EQs)
6472 for (idx
= 0; idx
< phba
->cfg_hdw_queue
; idx
++)
6473 lpfc_debug_dump_hba_eq(phba
, idx
);