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>
34 #include <linux/vmalloc.h>
36 #include <scsi/scsi.h>
37 #include <scsi/scsi_device.h>
38 #include <scsi/scsi_host.h>
39 #include <scsi/scsi_transport_fc.h>
40 #include <scsi/fc/fc_fs.h>
42 #include <linux/nvme-fc-driver.h>
47 #include "lpfc_sli4.h"
49 #include "lpfc_disc.h"
51 #include "lpfc_scsi.h"
52 #include "lpfc_nvme.h"
53 #include "lpfc_nvmet.h"
54 #include "lpfc_logmsg.h"
55 #include "lpfc_crtn.h"
56 #include "lpfc_vport.h"
57 #include "lpfc_version.h"
58 #include "lpfc_compat.h"
59 #include "lpfc_debugfs.h"
62 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
66 * To access this interface the user should:
67 * # mount -t debugfs none /sys/kernel/debug
69 * The lpfc debugfs directory hierarchy is:
70 * /sys/kernel/debug/lpfc/fnX/vportY
71 * where X is the lpfc hba function unique_id
72 * where Y is the vport VPI on that hba
74 * Debugging services available per vport:
76 * This is an ACSII readable file that contains a trace of the last
77 * lpfc_debugfs_max_disc_trc events that happened on a specific vport.
78 * See lpfc_debugfs.h for different categories of discovery events.
79 * To enable the discovery trace, the following module parameters must be set:
80 * lpfc_debugfs_enable=1 Turns on lpfc debugfs filesystem support
81 * lpfc_debugfs_max_disc_trc=X Where X is the event trace depth for
82 * EACH vport. X MUST also be a power of 2.
83 * lpfc_debugfs_mask_disc_trc=Y Where Y is an event mask as defined in
87 * This is an ACSII readable file that contains a trace of the last
88 * lpfc_debugfs_max_slow_ring_trc events that happened on a specific HBA.
89 * To enable the slow ring trace, the following module parameters must be set:
90 * lpfc_debugfs_enable=1 Turns on lpfc debugfs filesystem support
91 * lpfc_debugfs_max_slow_ring_trc=X Where X is the event trace depth for
92 * the HBA. X MUST also be a power of 2.
94 static int lpfc_debugfs_enable = 1;
95 module_param(lpfc_debugfs_enable, int, S_IRUGO);
96 MODULE_PARM_DESC(lpfc_debugfs_enable, "Enable debugfs services");
98 /* This MUST be a power of 2 */
99 static int lpfc_debugfs_max_disc_trc;
100 module_param(lpfc_debugfs_max_disc_trc, int, S_IRUGO);
101 MODULE_PARM_DESC(lpfc_debugfs_max_disc_trc,
102 "Set debugfs discovery trace depth");
104 /* This MUST be a power of 2 */
105 static int lpfc_debugfs_max_slow_ring_trc;
106 module_param(lpfc_debugfs_max_slow_ring_trc, int, S_IRUGO);
107 MODULE_PARM_DESC(lpfc_debugfs_max_slow_ring_trc,
108 "Set debugfs slow ring trace depth");
110 /* This MUST be a power of 2 */
111 static int lpfc_debugfs_max_nvmeio_trc;
112 module_param(lpfc_debugfs_max_nvmeio_trc, int, 0444);
113 MODULE_PARM_DESC(lpfc_debugfs_max_nvmeio_trc,
114 "Set debugfs NVME IO trace depth");
116 static int lpfc_debugfs_mask_disc_trc;
117 module_param(lpfc_debugfs_mask_disc_trc, int, S_IRUGO);
118 MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc,
119 "Set debugfs discovery trace mask");
121 #include <linux/debugfs.h>
123 static atomic_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
124 static unsigned long lpfc_debugfs_start_time = 0L;
127 static struct lpfc_idiag idiag;
130 * lpfc_debugfs_disc_trc_data - Dump discovery logging to a buffer
131 * @vport: The vport to gather the log info from.
132 * @buf: The buffer to dump log into.
133 * @size: The maximum amount of data to process.
136 * This routine gathers the lpfc discovery debugfs data from the @vport and
137 * dumps it to @buf up to @size number of bytes. It will start at the next entry
138 * in the log and process the log until the end of the buffer. Then it will
139 * gather from the beginning of the log and process until the current entry.
142 * Discovery logging will be disabled while while this routine dumps the log.
145 * This routine returns the amount of bytes that were dumped into @buf and will
149 lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size)
151 int i, index, len, enable;
153 struct lpfc_debugfs_trc *dtp;
156 buffer = kmalloc(LPFC_DEBUG_TRC_ENTRY_SIZE, GFP_KERNEL);
160 enable = lpfc_debugfs_enable;
161 lpfc_debugfs_enable = 0;
164 index = (atomic_read(&vport->disc_trc_cnt) + 1) &
165 (lpfc_debugfs_max_disc_trc - 1);
166 for (i = index; i < lpfc_debugfs_max_disc_trc; i++) {
167 dtp = vport->disc_trc + i;
170 ms = jiffies_to_msecs(dtp->jif - lpfc_debugfs_start_time);
172 LPFC_DEBUG_TRC_ENTRY_SIZE, "%010d:%010d ms:%s\n",
173 dtp->seq_cnt, ms, dtp->fmt);
174 len += scnprintf(buf+len, size-len, buffer,
175 dtp->data1, dtp->data2, dtp->data3);
177 for (i = 0; i < index; i++) {
178 dtp = vport->disc_trc + i;
181 ms = jiffies_to_msecs(dtp->jif - lpfc_debugfs_start_time);
183 LPFC_DEBUG_TRC_ENTRY_SIZE, "%010d:%010d ms:%s\n",
184 dtp->seq_cnt, ms, dtp->fmt);
185 len += scnprintf(buf+len, size-len, buffer,
186 dtp->data1, dtp->data2, dtp->data3);
189 lpfc_debugfs_enable = enable;
196 * lpfc_debugfs_slow_ring_trc_data - Dump slow ring logging to a buffer
197 * @phba: The HBA to gather the log info from.
198 * @buf: The buffer to dump log into.
199 * @size: The maximum amount of data to process.
202 * This routine gathers the lpfc slow ring debugfs data from the @phba and
203 * dumps it to @buf up to @size number of bytes. It will start at the next entry
204 * in the log and process the log until the end of the buffer. Then it will
205 * gather from the beginning of the log and process until the current entry.
208 * Slow ring logging will be disabled while while this routine dumps the log.
211 * This routine returns the amount of bytes that were dumped into @buf and will
215 lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba *phba, char *buf, int size)
217 int i, index, len, enable;
219 struct lpfc_debugfs_trc *dtp;
222 buffer = kmalloc(LPFC_DEBUG_TRC_ENTRY_SIZE, GFP_KERNEL);
226 enable = lpfc_debugfs_enable;
227 lpfc_debugfs_enable = 0;
230 index = (atomic_read(&phba->slow_ring_trc_cnt) + 1) &
231 (lpfc_debugfs_max_slow_ring_trc - 1);
232 for (i = index; i < lpfc_debugfs_max_slow_ring_trc; i++) {
233 dtp = phba->slow_ring_trc + i;
236 ms = jiffies_to_msecs(dtp->jif - lpfc_debugfs_start_time);
238 LPFC_DEBUG_TRC_ENTRY_SIZE, "%010d:%010d ms:%s\n",
239 dtp->seq_cnt, ms, dtp->fmt);
240 len += scnprintf(buf+len, size-len, buffer,
241 dtp->data1, dtp->data2, dtp->data3);
243 for (i = 0; i < index; i++) {
244 dtp = phba->slow_ring_trc + i;
247 ms = jiffies_to_msecs(dtp->jif - lpfc_debugfs_start_time);
249 LPFC_DEBUG_TRC_ENTRY_SIZE, "%010d:%010d ms:%s\n",
250 dtp->seq_cnt, ms, dtp->fmt);
251 len += scnprintf(buf+len, size-len, buffer,
252 dtp->data1, dtp->data2, dtp->data3);
255 lpfc_debugfs_enable = enable;
261 static int lpfc_debugfs_last_hbq = -1;
264 * lpfc_debugfs_hbqinfo_data - Dump host buffer queue info to a buffer
265 * @phba: The HBA to gather host buffer info from.
266 * @buf: The buffer to dump log into.
267 * @size: The maximum amount of data to process.
270 * This routine dumps the host buffer queue info from the @phba to @buf up to
271 * @size number of bytes. A header that describes the current hbq state will be
272 * dumped to @buf first and then info on each hbq entry will be dumped to @buf
273 * until @size bytes have been dumped or all the hbq info has been dumped.
276 * This routine will rotate through each configured HBQ each time called.
279 * This routine returns the amount of bytes that were dumped into @buf and will
283 lpfc_debugfs_hbqinfo_data(struct lpfc_hba *phba, char *buf, int size)
286 int i, j, found, posted, low;
287 uint32_t phys, raw_index, getidx;
288 struct lpfc_hbq_init *hip;
290 struct lpfc_hbq_entry *hbqe;
291 struct lpfc_dmabuf *d_buf;
292 struct hbq_dmabuf *hbq_buf;
294 if (phba->sli_rev != 3)
297 spin_lock_irq(&phba->hbalock);
299 /* toggle between multiple hbqs, if any */
300 i = lpfc_sli_hbq_count();
302 lpfc_debugfs_last_hbq++;
303 if (lpfc_debugfs_last_hbq >= i)
304 lpfc_debugfs_last_hbq = 0;
307 lpfc_debugfs_last_hbq = 0;
309 i = lpfc_debugfs_last_hbq;
311 len += scnprintf(buf+len, size-len, "HBQ %d Info\n", i);
313 hbqs = &phba->hbqs[i];
315 list_for_each_entry(d_buf, &hbqs->hbq_buffer_list, list)
318 hip = lpfc_hbq_defs[i];
319 len += scnprintf(buf+len, size-len,
320 "idx:%d prof:%d rn:%d bufcnt:%d icnt:%d acnt:%d posted %d\n",
321 hip->hbq_index, hip->profile, hip->rn,
322 hip->buffer_count, hip->init_count, hip->add_count, posted);
324 raw_index = phba->hbq_get[i];
325 getidx = le32_to_cpu(raw_index);
326 len += scnprintf(buf+len, size-len,
327 "entries:%d bufcnt:%d Put:%d nPut:%d localGet:%d hbaGet:%d\n",
328 hbqs->entry_count, hbqs->buffer_count, hbqs->hbqPutIdx,
329 hbqs->next_hbqPutIdx, hbqs->local_hbqGetIdx, getidx);
331 hbqe = (struct lpfc_hbq_entry *) phba->hbqs[i].hbq_virt;
332 for (j=0; j<hbqs->entry_count; j++) {
333 len += scnprintf(buf+len, size-len,
334 "%03d: %08x %04x %05x ", j,
335 le32_to_cpu(hbqe->bde.addrLow),
336 le32_to_cpu(hbqe->bde.tus.w),
337 le32_to_cpu(hbqe->buffer_tag));
341 /* First calculate if slot has an associated posted buffer */
342 low = hbqs->hbqPutIdx - posted;
344 if ((j >= hbqs->hbqPutIdx) || (j < low)) {
345 len += scnprintf(buf + len, size - len,
351 if ((j >= hbqs->hbqPutIdx) &&
352 (j < (hbqs->entry_count+low))) {
353 len += scnprintf(buf + len, size - len,
359 /* Get the Buffer info for the posted buffer */
360 list_for_each_entry(d_buf, &hbqs->hbq_buffer_list, list) {
361 hbq_buf = container_of(d_buf, struct hbq_dmabuf, dbuf);
362 phys = ((uint64_t)hbq_buf->dbuf.phys & 0xffffffff);
363 if (phys == le32_to_cpu(hbqe->bde.addrLow)) {
364 len += scnprintf(buf+len, size-len,
365 "Buf%d: x%px %06x\n", i,
366 hbq_buf->dbuf.virt, hbq_buf->tag);
373 len += scnprintf(buf+len, size-len, "No DMAinfo?\n");
377 if (len > LPFC_HBQINFO_SIZE - 54)
380 spin_unlock_irq(&phba->hbalock);
384 static int lpfc_debugfs_last_xripool;
387 * lpfc_debugfs_common_xri_data - Dump Hardware Queue info to a buffer
388 * @phba: The HBA to gather host buffer info from.
389 * @buf: The buffer to dump log into.
390 * @size: The maximum amount of data to process.
393 * This routine dumps the Hardware Queue info from the @phba to @buf up to
394 * @size number of bytes. A header that describes the current hdwq state will be
395 * dumped to @buf first and then info on each hdwq entry will be dumped to @buf
396 * until @size bytes have been dumped or all the hdwq info has been dumped.
399 * This routine will rotate through each configured Hardware Queue each
403 * This routine returns the amount of bytes that were dumped into @buf and will
407 lpfc_debugfs_commonxripools_data(struct lpfc_hba *phba, char *buf, int size)
409 struct lpfc_sli4_hdw_queue *qp;
414 for (i = 0; i < phba->cfg_hdw_queue; i++) {
415 if (len > (LPFC_DUMP_MULTIXRIPOOL_SIZE - 80))
417 qp = &phba->sli4_hba.hdwq[lpfc_debugfs_last_xripool];
419 len += scnprintf(buf + len, size - len, "HdwQ %d Info ", i);
420 spin_lock_irqsave(&qp->abts_io_buf_list_lock, iflag);
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_irqrestore(&qp->abts_io_buf_list_lock, iflag);
435 lpfc_debugfs_last_xripool++;
436 if (lpfc_debugfs_last_xripool >= phba->cfg_hdw_queue)
437 lpfc_debugfs_last_xripool = 0;
444 * lpfc_debugfs_multixripools_data - Display multi-XRI pools information
445 * @phba: The HBA to gather host buffer info from.
446 * @buf: The buffer to dump log into.
447 * @size: The maximum amount of data to process.
450 * This routine displays current multi-XRI pools information including XRI
451 * count in public, private and txcmplq. It also displays current high and
455 * This routine returns the amount of bytes that were dumped into @buf and will
459 lpfc_debugfs_multixripools_data(struct lpfc_hba *phba, char *buf, int size)
463 struct lpfc_sli4_hdw_queue *qp;
464 struct lpfc_multixri_pool *multixri_pool;
465 struct lpfc_pvt_pool *pvt_pool;
466 struct lpfc_pbl_pool *pbl_pool;
468 char tmp[LPFC_DEBUG_OUT_LINE_SZ] = {0};
470 if (phba->sli_rev != LPFC_SLI_REV4)
473 if (!phba->sli4_hba.hdwq)
476 if (!phba->cfg_xri_rebalancing) {
477 i = lpfc_debugfs_commonxripools_data(phba, buf, size);
482 * Pbl: Current number of free XRIs in public pool
483 * Pvt: Current number of free XRIs in private pool
484 * Busy: Current number of outstanding XRIs
485 * HWM: Current high watermark
486 * pvt_empty: Incremented by 1 when IO submission fails (no xri)
487 * pbl_empty: Incremented by 1 when all pbl_pool are empty during
490 scnprintf(tmp, sizeof(tmp),
491 "HWQ: Pbl Pvt Busy HWM | pvt_empty pbl_empty ");
492 if (strlcat(buf, tmp, size) >= size)
493 return strnlen(buf, size);
497 * MAXH: Max high watermark seen so far
498 * above_lmt: Incremented by 1 if xri_owned > xri_limit during
500 * below_lmt: Incremented by 1 if xri_owned <= xri_limit during
502 * locPbl_hit: Incremented by 1 if successfully get a batch of XRI from
504 * othPbl_hit: Incremented by 1 if successfully get a batch of XRI from
507 scnprintf(tmp, sizeof(tmp),
508 "MAXH above_lmt below_lmt locPbl_hit othPbl_hit");
509 if (strlcat(buf, tmp, size) >= size)
510 return strnlen(buf, size);
513 * sPbl: snapshot of Pbl 15 sec after stat gets cleared
514 * sPvt: snapshot of Pvt 15 sec after stat gets cleared
515 * sBusy: snapshot of Busy 15 sec after stat gets cleared
517 scnprintf(tmp, sizeof(tmp),
518 " | sPbl sPvt sBusy");
519 if (strlcat(buf, tmp, size) >= size)
520 return strnlen(buf, size);
523 scnprintf(tmp, sizeof(tmp), "\n");
524 if (strlcat(buf, tmp, size) >= size)
525 return strnlen(buf, size);
527 hwq_count = phba->cfg_hdw_queue;
528 for (i = 0; i < hwq_count; i++) {
529 qp = &phba->sli4_hba.hdwq[i];
530 multixri_pool = qp->p_multixri_pool;
533 pbl_pool = &multixri_pool->pbl_pool;
534 pvt_pool = &multixri_pool->pvt_pool;
535 txcmplq_cnt = qp->io_wq->pring->txcmplq_cnt;
537 scnprintf(tmp, sizeof(tmp),
538 "%03d: %4d %4d %4d %4d | %10d %10d ",
539 i, pbl_pool->count, pvt_pool->count,
540 txcmplq_cnt, pvt_pool->high_watermark,
541 qp->empty_io_bufs, multixri_pool->pbl_empty_count);
542 if (strlcat(buf, tmp, size) >= size)
546 scnprintf(tmp, sizeof(tmp),
547 "%4d %10d %10d %10d %10d",
548 multixri_pool->stat_max_hwm,
549 multixri_pool->above_limit_count,
550 multixri_pool->below_limit_count,
551 multixri_pool->local_pbl_hit_count,
552 multixri_pool->other_pbl_hit_count);
553 if (strlcat(buf, tmp, size) >= size)
556 scnprintf(tmp, sizeof(tmp),
558 multixri_pool->stat_pbl_count,
559 multixri_pool->stat_pvt_count,
560 multixri_pool->stat_busy_count);
561 if (strlcat(buf, tmp, size) >= size)
565 scnprintf(tmp, sizeof(tmp), "\n");
566 if (strlcat(buf, tmp, size) >= size)
569 return strnlen(buf, size);
573 #ifdef LPFC_HDWQ_LOCK_STAT
574 static int lpfc_debugfs_last_lock;
577 * lpfc_debugfs_lockstat_data - Dump Hardware Queue info to a buffer
578 * @phba: The HBA to gather host buffer info from.
579 * @buf: The buffer to dump log into.
580 * @size: The maximum amount of data to process.
583 * This routine dumps the Hardware Queue info from the @phba to @buf up to
584 * @size number of bytes. A header that describes the current hdwq state will be
585 * dumped to @buf first and then info on each hdwq entry will be dumped to @buf
586 * until @size bytes have been dumped or all the hdwq info has been dumped.
589 * This routine will rotate through each configured Hardware Queue each
593 * This routine returns the amount of bytes that were dumped into @buf and will
597 lpfc_debugfs_lockstat_data(struct lpfc_hba *phba, char *buf, int size)
599 struct lpfc_sli4_hdw_queue *qp;
603 if (phba->sli_rev != LPFC_SLI_REV4)
606 if (!phba->sli4_hba.hdwq)
609 for (i = 0; i < phba->cfg_hdw_queue; i++) {
610 if (len > (LPFC_HDWQINFO_SIZE - 100))
612 qp = &phba->sli4_hba.hdwq[lpfc_debugfs_last_lock];
614 len += scnprintf(buf + len, size - len, "HdwQ %03d Lock ", i);
615 if (phba->cfg_xri_rebalancing) {
616 len += scnprintf(buf + len, size - len,
617 "get_pvt:%d mv_pvt:%d "
618 "mv2pub:%d mv2pvt:%d "
619 "put_pvt:%d put_pub:%d wq:%d\n",
620 qp->lock_conflict.alloc_pvt_pool,
621 qp->lock_conflict.mv_from_pvt_pool,
622 qp->lock_conflict.mv_to_pub_pool,
623 qp->lock_conflict.mv_to_pvt_pool,
624 qp->lock_conflict.free_pvt_pool,
625 qp->lock_conflict.free_pub_pool,
626 qp->lock_conflict.wq_access);
628 len += scnprintf(buf + len, size - len,
629 "get:%d put:%d free:%d wq:%d\n",
630 qp->lock_conflict.alloc_xri_get,
631 qp->lock_conflict.alloc_xri_put,
632 qp->lock_conflict.free_xri,
633 qp->lock_conflict.wq_access);
636 lpfc_debugfs_last_lock++;
637 if (lpfc_debugfs_last_lock >= phba->cfg_hdw_queue)
638 lpfc_debugfs_last_lock = 0;
645 static int lpfc_debugfs_last_hba_slim_off;
648 * lpfc_debugfs_dumpHBASlim_data - Dump HBA SLIM info to a buffer
649 * @phba: The HBA to gather SLIM info from.
650 * @buf: The buffer to dump log into.
651 * @size: The maximum amount of data to process.
654 * This routine dumps the current contents of HBA SLIM for the HBA associated
655 * with @phba to @buf up to @size bytes of data. This is the raw HBA SLIM data.
658 * This routine will only dump up to 1024 bytes of data each time called and
659 * should be called multiple times to dump the entire HBA SLIM.
662 * This routine returns the amount of bytes that were dumped into @buf and will
666 lpfc_debugfs_dumpHBASlim_data(struct lpfc_hba *phba, char *buf, int size)
673 buffer = kmalloc(1024, GFP_KERNEL);
678 spin_lock_irq(&phba->hbalock);
680 len += scnprintf(buf+len, size-len, "HBA SLIM\n");
681 lpfc_memcpy_from_slim(buffer,
682 phba->MBslimaddr + lpfc_debugfs_last_hba_slim_off, 1024);
684 ptr = (uint32_t *)&buffer[0];
685 off = lpfc_debugfs_last_hba_slim_off;
687 /* Set it up for the next time */
688 lpfc_debugfs_last_hba_slim_off += 1024;
689 if (lpfc_debugfs_last_hba_slim_off >= 4096)
690 lpfc_debugfs_last_hba_slim_off = 0;
694 len += scnprintf(buf+len, size-len,
695 "%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n",
696 off, *ptr, *(ptr+1), *(ptr+2), *(ptr+3), *(ptr+4),
697 *(ptr+5), *(ptr+6), *(ptr+7));
699 i -= (8 * sizeof(uint32_t));
700 off += (8 * sizeof(uint32_t));
703 spin_unlock_irq(&phba->hbalock);
710 * lpfc_debugfs_dumpHostSlim_data - Dump host SLIM info to a buffer
711 * @phba: The HBA to gather Host SLIM info from.
712 * @buf: The buffer to dump log into.
713 * @size: The maximum amount of data to process.
716 * This routine dumps the current contents of host SLIM for the host associated
717 * with @phba to @buf up to @size bytes of data. The dump will contain the
718 * Mailbox, PCB, Rings, and Registers that are located in host memory.
721 * This routine returns the amount of bytes that were dumped into @buf and will
725 lpfc_debugfs_dumpHostSlim_data(struct lpfc_hba *phba, char *buf, int size)
729 uint32_t word0, word1, word2, word3;
731 struct lpfc_pgp *pgpp;
732 struct lpfc_sli *psli = &phba->sli;
733 struct lpfc_sli_ring *pring;
736 spin_lock_irq(&phba->hbalock);
738 len += scnprintf(buf+len, size-len, "SLIM Mailbox\n");
739 ptr = (uint32_t *)phba->slim2p.virt;
740 i = sizeof(MAILBOX_t);
742 len += scnprintf(buf+len, size-len,
743 "%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n",
744 off, *ptr, *(ptr+1), *(ptr+2), *(ptr+3), *(ptr+4),
745 *(ptr+5), *(ptr+6), *(ptr+7));
747 i -= (8 * sizeof(uint32_t));
748 off += (8 * sizeof(uint32_t));
751 len += scnprintf(buf+len, size-len, "SLIM PCB\n");
752 ptr = (uint32_t *)phba->pcb;
755 len += scnprintf(buf+len, size-len,
756 "%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n",
757 off, *ptr, *(ptr+1), *(ptr+2), *(ptr+3), *(ptr+4),
758 *(ptr+5), *(ptr+6), *(ptr+7));
760 i -= (8 * sizeof(uint32_t));
761 off += (8 * sizeof(uint32_t));
764 if (phba->sli_rev <= LPFC_SLI_REV3) {
765 for (i = 0; i < 4; i++) {
766 pgpp = &phba->port_gp[i];
767 pring = &psli->sli3_ring[i];
768 len += scnprintf(buf+len, size-len,
769 "Ring %d: CMD GetInx:%d "
772 "RSP PutInx:%d Max:%d\n",
774 pring->sli.sli3.numCiocb,
775 pring->sli.sli3.next_cmdidx,
776 pring->sli.sli3.local_getidx,
777 pring->flag, pgpp->rspPutInx,
778 pring->sli.sli3.numRiocb);
781 word0 = readl(phba->HAregaddr);
782 word1 = readl(phba->CAregaddr);
783 word2 = readl(phba->HSregaddr);
784 word3 = readl(phba->HCregaddr);
785 len += scnprintf(buf+len, size-len, "HA:%08x CA:%08x HS:%08x "
786 "HC:%08x\n", word0, word1, word2, word3);
788 spin_unlock_irq(&phba->hbalock);
793 * lpfc_debugfs_nodelist_data - Dump target node list to a buffer
794 * @vport: The vport to gather target node info from.
795 * @buf: The buffer to dump log into.
796 * @size: The maximum amount of data to process.
799 * This routine dumps the current target node list associated with @vport to
800 * @buf up to @size bytes of data. Each node entry in the dump will contain a
801 * node state, DID, WWPN, WWNN, RPI, flags, type, and other useful fields.
804 * This routine returns the amount of bytes that were dumped into @buf and will
808 lpfc_debugfs_nodelist_data(struct lpfc_vport *vport, char *buf, int size)
811 int i, iocnt, outio, cnt;
812 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
813 struct lpfc_hba *phba = vport->phba;
814 struct lpfc_nodelist *ndlp;
815 unsigned char *statep;
816 struct nvme_fc_local_port *localport;
817 struct nvme_fc_remote_port *nrport = NULL;
818 struct lpfc_nvme_rport *rport;
820 cnt = (LPFC_NODELIST_SIZE / LPFC_NODELIST_ENTRY_SIZE);
823 len += scnprintf(buf+len, size-len, "\nFCP Nodelist Entries ...\n");
824 spin_lock_irq(shost->host_lock);
825 list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) {
828 len += scnprintf(buf+len, size-len,
829 "Missing Nodelist Entries\n");
833 switch (ndlp->nlp_state) {
834 case NLP_STE_UNUSED_NODE:
837 case NLP_STE_PLOGI_ISSUE:
840 case NLP_STE_ADISC_ISSUE:
843 case NLP_STE_REG_LOGIN_ISSUE:
846 case NLP_STE_PRLI_ISSUE:
849 case NLP_STE_LOGO_ISSUE:
852 case NLP_STE_UNMAPPED_NODE:
856 case NLP_STE_MAPPED_NODE:
860 case NLP_STE_NPR_NODE:
866 len += scnprintf(buf+len, size-len, "%s DID:x%06x ",
867 statep, ndlp->nlp_DID);
868 len += scnprintf(buf+len, size-len,
870 wwn_to_u64(ndlp->nlp_portname.u.wwn));
871 len += scnprintf(buf+len, size-len,
873 wwn_to_u64(ndlp->nlp_nodename.u.wwn));
874 if (ndlp->nlp_flag & NLP_RPI_REGISTERED)
875 len += scnprintf(buf+len, size-len, "RPI:%03d ",
878 len += scnprintf(buf+len, size-len, "RPI:none ");
879 len += scnprintf(buf+len, size-len, "flag:x%08x ",
882 len += scnprintf(buf+len, size-len, "UNKNOWN_TYPE ");
883 if (ndlp->nlp_type & NLP_FC_NODE)
884 len += scnprintf(buf+len, size-len, "FC_NODE ");
885 if (ndlp->nlp_type & NLP_FABRIC) {
886 len += scnprintf(buf+len, size-len, "FABRIC ");
889 if (ndlp->nlp_type & NLP_FCP_TARGET)
890 len += scnprintf(buf+len, size-len, "FCP_TGT sid:%d ",
892 if (ndlp->nlp_type & NLP_FCP_INITIATOR)
893 len += scnprintf(buf+len, size-len, "FCP_INITIATOR ");
894 if (ndlp->nlp_type & NLP_NVME_TARGET)
895 len += scnprintf(buf + len,
896 size - len, "NVME_TGT sid:%d ",
898 if (ndlp->nlp_type & NLP_NVME_INITIATOR)
899 len += scnprintf(buf + len,
900 size - len, "NVME_INITIATOR ");
901 len += scnprintf(buf+len, size-len, "usgmap:%x ",
903 len += scnprintf(buf+len, size-len, "refcnt:%x",
904 kref_read(&ndlp->kref));
906 i = atomic_read(&ndlp->cmd_pending);
907 len += scnprintf(buf + len, size - len,
908 " OutIO:x%x Qdepth x%x",
909 i, ndlp->cmd_qdepth);
912 len += scnprintf(buf + len, size - len, "defer:%x ",
913 ndlp->nlp_defer_did);
914 len += scnprintf(buf+len, size-len, "\n");
916 spin_unlock_irq(shost->host_lock);
918 len += scnprintf(buf + len, size - len,
919 "\nOutstanding IO x%x\n", outio);
921 if (phba->nvmet_support && phba->targetport && (vport == phba->pport)) {
922 len += scnprintf(buf + len, size - len,
923 "\nNVME Targetport Entry ...\n");
925 /* Port state is only one of two values for now. */
926 if (phba->targetport->port_id)
927 statep = "REGISTERED";
930 len += scnprintf(buf + len, size - len,
931 "TGT WWNN x%llx WWPN x%llx State %s\n",
932 wwn_to_u64(vport->fc_nodename.u.wwn),
933 wwn_to_u64(vport->fc_portname.u.wwn),
935 len += scnprintf(buf + len, size - len,
936 " Targetport DID x%06x\n",
937 phba->targetport->port_id);
941 len += scnprintf(buf + len, size - len,
942 "\nNVME Lport/Rport Entries ...\n");
944 localport = vport->localport;
948 spin_lock_irq(shost->host_lock);
950 /* Port state is only one of two values for now. */
951 if (localport->port_id)
956 len += scnprintf(buf + len, size - len,
957 "Lport DID x%06x PortState %s\n",
958 localport->port_id, statep);
960 len += scnprintf(buf + len, size - len, "\tRport List:\n");
961 list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) {
962 /* local short-hand pointer. */
963 spin_lock(&phba->hbalock);
964 rport = lpfc_ndlp_get_nrport(ndlp);
966 nrport = rport->remoteport;
969 spin_unlock(&phba->hbalock);
973 /* Port state is only one of two values for now. */
974 switch (nrport->port_state) {
975 case FC_OBJSTATE_ONLINE:
978 case FC_OBJSTATE_UNKNOWN:
982 statep = "UNSUPPORTED";
986 /* Tab in to show lport ownership. */
987 len += scnprintf(buf + len, size - len,
988 "\t%s Port ID:x%06x ",
989 statep, nrport->port_id);
990 len += scnprintf(buf + len, size - len, "WWPN x%llx ",
992 len += scnprintf(buf + len, size - len, "WWNN x%llx ",
995 /* An NVME rport can have multiple roles. */
996 if (nrport->port_role & FC_PORT_ROLE_NVME_INITIATOR)
997 len += scnprintf(buf + len, size - len,
999 if (nrport->port_role & FC_PORT_ROLE_NVME_TARGET)
1000 len += scnprintf(buf + len, size - len,
1002 if (nrport->port_role & FC_PORT_ROLE_NVME_DISCOVERY)
1003 len += scnprintf(buf + len, size - len,
1005 if (nrport->port_role & ~(FC_PORT_ROLE_NVME_INITIATOR |
1006 FC_PORT_ROLE_NVME_TARGET |
1007 FC_PORT_ROLE_NVME_DISCOVERY))
1008 len += scnprintf(buf + len, size - len,
1011 /* Terminate the string. */
1012 len += scnprintf(buf + len, size - len, "\n");
1015 spin_unlock_irq(shost->host_lock);
1021 * lpfc_debugfs_nvmestat_data - Dump target node list to a buffer
1022 * @vport: The vport to gather target node info from.
1023 * @buf: The buffer to dump log into.
1024 * @size: The maximum amount of data to process.
1027 * This routine dumps the NVME statistics associated with @vport
1030 * This routine returns the amount of bytes that were dumped into @buf and will
1034 lpfc_debugfs_nvmestat_data(struct lpfc_vport *vport, char *buf, int size)
1036 struct lpfc_hba *phba = vport->phba;
1037 struct lpfc_nvmet_tgtport *tgtp;
1038 struct lpfc_nvmet_rcv_ctx *ctxp, *next_ctxp;
1039 struct nvme_fc_local_port *localport;
1040 struct lpfc_fc4_ctrl_stat *cstat;
1041 struct lpfc_nvme_lport *lport;
1042 uint64_t data1, data2, data3;
1043 uint64_t tot, totin, totout;
1047 if (phba->nvmet_support) {
1048 if (!phba->targetport)
1050 tgtp = (struct lpfc_nvmet_tgtport *)phba->targetport->private;
1051 len += scnprintf(buf + len, size - len,
1052 "\nNVME Targetport Statistics\n");
1054 len += scnprintf(buf + len, size - len,
1055 "LS: Rcv %08x Drop %08x Abort %08x\n",
1056 atomic_read(&tgtp->rcv_ls_req_in),
1057 atomic_read(&tgtp->rcv_ls_req_drop),
1058 atomic_read(&tgtp->xmt_ls_abort));
1059 if (atomic_read(&tgtp->rcv_ls_req_in) !=
1060 atomic_read(&tgtp->rcv_ls_req_out)) {
1061 len += scnprintf(buf + len, size - len,
1062 "Rcv LS: in %08x != out %08x\n",
1063 atomic_read(&tgtp->rcv_ls_req_in),
1064 atomic_read(&tgtp->rcv_ls_req_out));
1067 len += scnprintf(buf + len, size - len,
1068 "LS: Xmt %08x Drop %08x Cmpl %08x\n",
1069 atomic_read(&tgtp->xmt_ls_rsp),
1070 atomic_read(&tgtp->xmt_ls_drop),
1071 atomic_read(&tgtp->xmt_ls_rsp_cmpl));
1073 len += scnprintf(buf + len, size - len,
1074 "LS: RSP Abort %08x xb %08x Err %08x\n",
1075 atomic_read(&tgtp->xmt_ls_rsp_aborted),
1076 atomic_read(&tgtp->xmt_ls_rsp_xb_set),
1077 atomic_read(&tgtp->xmt_ls_rsp_error));
1079 len += scnprintf(buf + len, size - len,
1080 "FCP: Rcv %08x Defer %08x Release %08x "
1082 atomic_read(&tgtp->rcv_fcp_cmd_in),
1083 atomic_read(&tgtp->rcv_fcp_cmd_defer),
1084 atomic_read(&tgtp->xmt_fcp_release),
1085 atomic_read(&tgtp->rcv_fcp_cmd_drop));
1087 if (atomic_read(&tgtp->rcv_fcp_cmd_in) !=
1088 atomic_read(&tgtp->rcv_fcp_cmd_out)) {
1089 len += scnprintf(buf + len, size - len,
1090 "Rcv FCP: in %08x != out %08x\n",
1091 atomic_read(&tgtp->rcv_fcp_cmd_in),
1092 atomic_read(&tgtp->rcv_fcp_cmd_out));
1095 len += scnprintf(buf + len, size - len,
1096 "FCP Rsp: read %08x readrsp %08x "
1097 "write %08x rsp %08x\n",
1098 atomic_read(&tgtp->xmt_fcp_read),
1099 atomic_read(&tgtp->xmt_fcp_read_rsp),
1100 atomic_read(&tgtp->xmt_fcp_write),
1101 atomic_read(&tgtp->xmt_fcp_rsp));
1103 len += scnprintf(buf + len, size - len,
1104 "FCP Rsp Cmpl: %08x err %08x drop %08x\n",
1105 atomic_read(&tgtp->xmt_fcp_rsp_cmpl),
1106 atomic_read(&tgtp->xmt_fcp_rsp_error),
1107 atomic_read(&tgtp->xmt_fcp_rsp_drop));
1109 len += scnprintf(buf + len, size - len,
1110 "FCP Rsp Abort: %08x xb %08x xricqe %08x\n",
1111 atomic_read(&tgtp->xmt_fcp_rsp_aborted),
1112 atomic_read(&tgtp->xmt_fcp_rsp_xb_set),
1113 atomic_read(&tgtp->xmt_fcp_xri_abort_cqe));
1115 len += scnprintf(buf + len, size - len,
1116 "ABORT: Xmt %08x Cmpl %08x\n",
1117 atomic_read(&tgtp->xmt_fcp_abort),
1118 atomic_read(&tgtp->xmt_fcp_abort_cmpl));
1120 len += scnprintf(buf + len, size - len,
1121 "ABORT: Sol %08x Usol %08x Err %08x Cmpl %08x",
1122 atomic_read(&tgtp->xmt_abort_sol),
1123 atomic_read(&tgtp->xmt_abort_unsol),
1124 atomic_read(&tgtp->xmt_abort_rsp),
1125 atomic_read(&tgtp->xmt_abort_rsp_error));
1127 len += scnprintf(buf + len, size - len, "\n");
1130 spin_lock(&phba->sli4_hba.abts_nvmet_buf_list_lock);
1131 list_for_each_entry_safe(ctxp, next_ctxp,
1132 &phba->sli4_hba.lpfc_abts_nvmet_ctx_list,
1136 spin_unlock(&phba->sli4_hba.abts_nvmet_buf_list_lock);
1138 len += scnprintf(buf + len, size - len,
1139 "ABORT: %d ctx entries\n", cnt);
1140 spin_lock(&phba->sli4_hba.abts_nvmet_buf_list_lock);
1141 list_for_each_entry_safe(ctxp, next_ctxp,
1142 &phba->sli4_hba.lpfc_abts_nvmet_ctx_list,
1144 if (len >= (size - LPFC_DEBUG_OUT_LINE_SZ))
1146 len += scnprintf(buf + len, size - len,
1147 "Entry: oxid %x state %x "
1149 ctxp->oxid, ctxp->state,
1152 spin_unlock(&phba->sli4_hba.abts_nvmet_buf_list_lock);
1155 /* Calculate outstanding IOs */
1156 tot = atomic_read(&tgtp->rcv_fcp_cmd_drop);
1157 tot += atomic_read(&tgtp->xmt_fcp_release);
1158 tot = atomic_read(&tgtp->rcv_fcp_cmd_in) - tot;
1160 len += scnprintf(buf + len, size - len,
1161 "IO_CTX: %08x WAIT: cur %08x tot %08x\n"
1162 "CTX Outstanding %08llx\n",
1163 phba->sli4_hba.nvmet_xri_cnt,
1164 phba->sli4_hba.nvmet_io_wait_cnt,
1165 phba->sli4_hba.nvmet_io_wait_total,
1168 if (!(vport->cfg_enable_fc4_type & LPFC_ENABLE_NVME))
1171 localport = vport->localport;
1174 lport = (struct lpfc_nvme_lport *)localport->private;
1178 len += scnprintf(buf + len, size - len,
1179 "\nNVME HDWQ Statistics\n");
1181 len += scnprintf(buf + len, size - len,
1182 "LS: Xmt %016x Cmpl %016x\n",
1183 atomic_read(&lport->fc4NvmeLsRequests),
1184 atomic_read(&lport->fc4NvmeLsCmpls));
1188 for (i = 0; i < phba->cfg_hdw_queue; i++) {
1189 cstat = &phba->sli4_hba.hdwq[i].nvme_cstat;
1190 tot = cstat->io_cmpls;
1192 data1 = cstat->input_requests;
1193 data2 = cstat->output_requests;
1194 data3 = cstat->control_requests;
1195 totout += (data1 + data2 + data3);
1197 /* Limit to 32, debugfs display buffer limitation */
1201 len += scnprintf(buf + len, PAGE_SIZE - len,
1202 "HDWQ (%d): Rd %016llx Wr %016llx "
1204 i, data1, data2, data3);
1205 len += scnprintf(buf + len, PAGE_SIZE - len,
1206 "Cmpl %016llx OutIO %016llx\n",
1207 tot, ((data1 + data2 + data3) - tot));
1209 len += scnprintf(buf + len, PAGE_SIZE - len,
1210 "Total FCP Cmpl %016llx Issue %016llx "
1212 totin, totout, totout - totin);
1214 len += scnprintf(buf + len, size - len,
1215 "LS Xmt Err: Abrt %08x Err %08x "
1216 "Cmpl Err: xb %08x Err %08x\n",
1217 atomic_read(&lport->xmt_ls_abort),
1218 atomic_read(&lport->xmt_ls_err),
1219 atomic_read(&lport->cmpl_ls_xb),
1220 atomic_read(&lport->cmpl_ls_err));
1222 len += scnprintf(buf + len, size - len,
1223 "FCP Xmt Err: noxri %06x nondlp %06x "
1224 "qdepth %06x wqerr %06x err %06x Abrt %06x\n",
1225 atomic_read(&lport->xmt_fcp_noxri),
1226 atomic_read(&lport->xmt_fcp_bad_ndlp),
1227 atomic_read(&lport->xmt_fcp_qdepth),
1228 atomic_read(&lport->xmt_fcp_wqerr),
1229 atomic_read(&lport->xmt_fcp_err),
1230 atomic_read(&lport->xmt_fcp_abort));
1232 len += scnprintf(buf + len, size - len,
1233 "FCP Cmpl Err: xb %08x Err %08x\n",
1234 atomic_read(&lport->cmpl_fcp_xb),
1235 atomic_read(&lport->cmpl_fcp_err));
1243 * lpfc_debugfs_scsistat_data - Dump target node list to a buffer
1244 * @vport: The vport to gather target node info from.
1245 * @buf: The buffer to dump log into.
1246 * @size: The maximum amount of data to process.
1249 * This routine dumps the SCSI statistics associated with @vport
1252 * This routine returns the amount of bytes that were dumped into @buf and will
1256 lpfc_debugfs_scsistat_data(struct lpfc_vport *vport, char *buf, int size)
1259 struct lpfc_hba *phba = vport->phba;
1260 struct lpfc_fc4_ctrl_stat *cstat;
1261 u64 data1, data2, data3;
1262 u64 tot, totin, totout;
1264 char tmp[LPFC_MAX_SCSI_INFO_TMP_LEN] = {0};
1266 if (!(vport->cfg_enable_fc4_type & LPFC_ENABLE_FCP) ||
1267 (phba->sli_rev != LPFC_SLI_REV4))
1270 scnprintf(buf, size, "SCSI HDWQ Statistics\n");
1274 for (i = 0; i < phba->cfg_hdw_queue; i++) {
1275 cstat = &phba->sli4_hba.hdwq[i].scsi_cstat;
1276 tot = cstat->io_cmpls;
1278 data1 = cstat->input_requests;
1279 data2 = cstat->output_requests;
1280 data3 = cstat->control_requests;
1281 totout += (data1 + data2 + data3);
1283 scnprintf(tmp, sizeof(tmp), "HDWQ (%d): Rd %016llx Wr %016llx "
1284 "IO %016llx ", i, data1, data2, data3);
1285 if (strlcat(buf, tmp, size) >= size)
1288 scnprintf(tmp, sizeof(tmp), "Cmpl %016llx OutIO %016llx\n",
1289 tot, ((data1 + data2 + data3) - tot));
1290 if (strlcat(buf, tmp, size) >= size)
1293 scnprintf(tmp, sizeof(tmp), "Total FCP Cmpl %016llx Issue %016llx "
1294 "OutIO %016llx\n", totin, totout, totout - totin);
1295 strlcat(buf, tmp, size);
1298 len = strnlen(buf, size);
1304 * lpfc_debugfs_nvmektime_data - Dump target node list to a buffer
1305 * @vport: The vport to gather target node info from.
1306 * @buf: The buffer to dump log into.
1307 * @size: The maximum amount of data to process.
1310 * This routine dumps the NVME statistics associated with @vport
1313 * This routine returns the amount of bytes that were dumped into @buf and will
1317 lpfc_debugfs_nvmektime_data(struct lpfc_vport *vport, char *buf, int size)
1319 struct lpfc_hba *phba = vport->phba;
1322 if (phba->nvmet_support == 0) {
1323 /* NVME Initiator */
1324 len += scnprintf(buf + len, PAGE_SIZE - len,
1325 "ktime %s: Total Samples: %lld\n",
1326 (phba->ktime_on ? "Enabled" : "Disabled"),
1327 phba->ktime_data_samples);
1328 if (phba->ktime_data_samples == 0)
1332 buf + len, PAGE_SIZE - len,
1333 "Segment 1: Last NVME Cmd cmpl "
1334 "done -to- Start of next NVME cnd (in driver)\n");
1336 buf + len, PAGE_SIZE - len,
1337 "avg:%08lld min:%08lld max %08lld\n",
1338 div_u64(phba->ktime_seg1_total,
1339 phba->ktime_data_samples),
1340 phba->ktime_seg1_min,
1341 phba->ktime_seg1_max);
1343 buf + len, PAGE_SIZE - len,
1344 "Segment 2: Driver start of NVME cmd "
1345 "-to- Firmware WQ doorbell\n");
1347 buf + len, PAGE_SIZE - len,
1348 "avg:%08lld min:%08lld max %08lld\n",
1349 div_u64(phba->ktime_seg2_total,
1350 phba->ktime_data_samples),
1351 phba->ktime_seg2_min,
1352 phba->ktime_seg2_max);
1354 buf + len, PAGE_SIZE - len,
1355 "Segment 3: Firmware WQ doorbell -to- "
1356 "MSI-X ISR cmpl\n");
1358 buf + len, PAGE_SIZE - len,
1359 "avg:%08lld min:%08lld max %08lld\n",
1360 div_u64(phba->ktime_seg3_total,
1361 phba->ktime_data_samples),
1362 phba->ktime_seg3_min,
1363 phba->ktime_seg3_max);
1365 buf + len, PAGE_SIZE - len,
1366 "Segment 4: MSI-X ISR cmpl -to- "
1367 "NVME cmpl done\n");
1369 buf + len, PAGE_SIZE - len,
1370 "avg:%08lld min:%08lld max %08lld\n",
1371 div_u64(phba->ktime_seg4_total,
1372 phba->ktime_data_samples),
1373 phba->ktime_seg4_min,
1374 phba->ktime_seg4_max);
1376 buf + len, PAGE_SIZE - len,
1377 "Total IO avg time: %08lld\n",
1378 div_u64(phba->ktime_seg1_total +
1379 phba->ktime_seg2_total +
1380 phba->ktime_seg3_total +
1381 phba->ktime_seg4_total,
1382 phba->ktime_data_samples));
1387 len += scnprintf(buf + len, PAGE_SIZE-len,
1388 "ktime %s: Total Samples: %lld %lld\n",
1389 (phba->ktime_on ? "Enabled" : "Disabled"),
1390 phba->ktime_data_samples,
1391 phba->ktime_status_samples);
1392 if (phba->ktime_data_samples == 0)
1395 len += scnprintf(buf + len, PAGE_SIZE-len,
1396 "Segment 1: MSI-X ISR Rcv cmd -to- "
1397 "cmd pass to NVME Layer\n");
1398 len += scnprintf(buf + len, PAGE_SIZE-len,
1399 "avg:%08lld min:%08lld max %08lld\n",
1400 div_u64(phba->ktime_seg1_total,
1401 phba->ktime_data_samples),
1402 phba->ktime_seg1_min,
1403 phba->ktime_seg1_max);
1404 len += scnprintf(buf + len, PAGE_SIZE-len,
1405 "Segment 2: cmd pass to NVME Layer- "
1406 "-to- Driver rcv cmd OP (action)\n");
1407 len += scnprintf(buf + len, PAGE_SIZE-len,
1408 "avg:%08lld min:%08lld max %08lld\n",
1409 div_u64(phba->ktime_seg2_total,
1410 phba->ktime_data_samples),
1411 phba->ktime_seg2_min,
1412 phba->ktime_seg2_max);
1413 len += scnprintf(buf + len, PAGE_SIZE-len,
1414 "Segment 3: Driver rcv cmd OP -to- "
1415 "Firmware WQ doorbell: cmd\n");
1416 len += scnprintf(buf + len, PAGE_SIZE-len,
1417 "avg:%08lld min:%08lld max %08lld\n",
1418 div_u64(phba->ktime_seg3_total,
1419 phba->ktime_data_samples),
1420 phba->ktime_seg3_min,
1421 phba->ktime_seg3_max);
1422 len += scnprintf(buf + len, PAGE_SIZE-len,
1423 "Segment 4: Firmware WQ doorbell: cmd "
1424 "-to- MSI-X ISR for cmd cmpl\n");
1425 len += scnprintf(buf + len, PAGE_SIZE-len,
1426 "avg:%08lld min:%08lld max %08lld\n",
1427 div_u64(phba->ktime_seg4_total,
1428 phba->ktime_data_samples),
1429 phba->ktime_seg4_min,
1430 phba->ktime_seg4_max);
1431 len += scnprintf(buf + len, PAGE_SIZE-len,
1432 "Segment 5: MSI-X ISR for cmd cmpl "
1433 "-to- NVME layer passed cmd done\n");
1434 len += scnprintf(buf + len, PAGE_SIZE-len,
1435 "avg:%08lld min:%08lld max %08lld\n",
1436 div_u64(phba->ktime_seg5_total,
1437 phba->ktime_data_samples),
1438 phba->ktime_seg5_min,
1439 phba->ktime_seg5_max);
1441 if (phba->ktime_status_samples == 0) {
1442 len += scnprintf(buf + len, PAGE_SIZE-len,
1443 "Total: cmd received by MSI-X ISR "
1444 "-to- cmd completed on wire\n");
1445 len += scnprintf(buf + len, PAGE_SIZE-len,
1446 "avg:%08lld min:%08lld "
1448 div_u64(phba->ktime_seg10_total,
1449 phba->ktime_data_samples),
1450 phba->ktime_seg10_min,
1451 phba->ktime_seg10_max);
1455 len += scnprintf(buf + len, PAGE_SIZE-len,
1456 "Segment 6: NVME layer passed cmd done "
1457 "-to- Driver rcv rsp status OP\n");
1458 len += scnprintf(buf + len, PAGE_SIZE-len,
1459 "avg:%08lld min:%08lld max %08lld\n",
1460 div_u64(phba->ktime_seg6_total,
1461 phba->ktime_status_samples),
1462 phba->ktime_seg6_min,
1463 phba->ktime_seg6_max);
1464 len += scnprintf(buf + len, PAGE_SIZE-len,
1465 "Segment 7: Driver rcv rsp status OP "
1466 "-to- Firmware WQ doorbell: status\n");
1467 len += scnprintf(buf + len, PAGE_SIZE-len,
1468 "avg:%08lld min:%08lld max %08lld\n",
1469 div_u64(phba->ktime_seg7_total,
1470 phba->ktime_status_samples),
1471 phba->ktime_seg7_min,
1472 phba->ktime_seg7_max);
1473 len += scnprintf(buf + len, PAGE_SIZE-len,
1474 "Segment 8: Firmware WQ doorbell: status"
1475 " -to- MSI-X ISR for status cmpl\n");
1476 len += scnprintf(buf + len, PAGE_SIZE-len,
1477 "avg:%08lld min:%08lld max %08lld\n",
1478 div_u64(phba->ktime_seg8_total,
1479 phba->ktime_status_samples),
1480 phba->ktime_seg8_min,
1481 phba->ktime_seg8_max);
1482 len += scnprintf(buf + len, PAGE_SIZE-len,
1483 "Segment 9: MSI-X ISR for status cmpl "
1484 "-to- NVME layer passed status done\n");
1485 len += scnprintf(buf + len, PAGE_SIZE-len,
1486 "avg:%08lld min:%08lld max %08lld\n",
1487 div_u64(phba->ktime_seg9_total,
1488 phba->ktime_status_samples),
1489 phba->ktime_seg9_min,
1490 phba->ktime_seg9_max);
1491 len += scnprintf(buf + len, PAGE_SIZE-len,
1492 "Total: cmd received by MSI-X ISR -to- "
1493 "cmd completed on wire\n");
1494 len += scnprintf(buf + len, PAGE_SIZE-len,
1495 "avg:%08lld min:%08lld max %08lld\n",
1496 div_u64(phba->ktime_seg10_total,
1497 phba->ktime_status_samples),
1498 phba->ktime_seg10_min,
1499 phba->ktime_seg10_max);
1504 * lpfc_debugfs_nvmeio_trc_data - Dump NVME IO trace list to a buffer
1505 * @phba: The phba to gather target node info from.
1506 * @buf: The buffer to dump log into.
1507 * @size: The maximum amount of data to process.
1510 * This routine dumps the NVME IO trace associated with @phba
1513 * This routine returns the amount of bytes that were dumped into @buf and will
1517 lpfc_debugfs_nvmeio_trc_data(struct lpfc_hba *phba, char *buf, int size)
1519 struct lpfc_debugfs_nvmeio_trc *dtp;
1520 int i, state, index, skip;
1523 state = phba->nvmeio_trc_on;
1525 index = (atomic_read(&phba->nvmeio_trc_cnt) + 1) &
1526 (phba->nvmeio_trc_size - 1);
1527 skip = phba->nvmeio_trc_output_idx;
1529 len += scnprintf(buf + len, size - len,
1530 "%s IO Trace %s: next_idx %d skip %d size %d\n",
1531 (phba->nvmet_support ? "NVME" : "NVMET"),
1532 (state ? "Enabled" : "Disabled"),
1533 index, skip, phba->nvmeio_trc_size);
1535 if (!phba->nvmeio_trc || state)
1538 /* trace MUST bhe off to continue */
1540 for (i = index; i < phba->nvmeio_trc_size; i++) {
1545 dtp = phba->nvmeio_trc + i;
1546 phba->nvmeio_trc_output_idx++;
1551 len += scnprintf(buf + len, size - len, dtp->fmt,
1552 dtp->data1, dtp->data2, dtp->data3);
1554 if (phba->nvmeio_trc_output_idx >= phba->nvmeio_trc_size) {
1555 phba->nvmeio_trc_output_idx = 0;
1556 len += scnprintf(buf + len, size - len,
1557 "Trace Complete\n");
1561 if (len >= (size - LPFC_DEBUG_OUT_LINE_SZ)) {
1562 len += scnprintf(buf + len, size - len,
1563 "Trace Continue (%d of %d)\n",
1564 phba->nvmeio_trc_output_idx,
1565 phba->nvmeio_trc_size);
1569 for (i = 0; i < index; i++) {
1574 dtp = phba->nvmeio_trc + i;
1575 phba->nvmeio_trc_output_idx++;
1580 len += scnprintf(buf + len, size - len, dtp->fmt,
1581 dtp->data1, dtp->data2, dtp->data3);
1583 if (phba->nvmeio_trc_output_idx >= phba->nvmeio_trc_size) {
1584 phba->nvmeio_trc_output_idx = 0;
1585 len += scnprintf(buf + len, size - len,
1586 "Trace Complete\n");
1590 if (len >= (size - LPFC_DEBUG_OUT_LINE_SZ)) {
1591 len += scnprintf(buf + len, size - len,
1592 "Trace Continue (%d of %d)\n",
1593 phba->nvmeio_trc_output_idx,
1594 phba->nvmeio_trc_size);
1599 len += scnprintf(buf + len, size - len,
1606 * lpfc_debugfs_cpucheck_data - Dump target node list to a buffer
1607 * @vport: The vport to gather target node info from.
1608 * @buf: The buffer to dump log into.
1609 * @size: The maximum amount of data to process.
1612 * This routine dumps the NVME statistics associated with @vport
1615 * This routine returns the amount of bytes that were dumped into @buf and will
1619 lpfc_debugfs_cpucheck_data(struct lpfc_vport *vport, char *buf, int size)
1621 struct lpfc_hba *phba = vport->phba;
1622 struct lpfc_sli4_hdw_queue *qp;
1629 len += scnprintf(buf + len, PAGE_SIZE - len,
1631 (phba->cpucheck_on & LPFC_CHECK_NVME_IO ?
1632 "Enabled" : "Disabled"));
1633 if (phba->nvmet_support) {
1634 len += scnprintf(buf + len, PAGE_SIZE - len,
1636 (phba->cpucheck_on & LPFC_CHECK_NVMET_RCV ?
1637 "Rcv Enabled\n" : "Rcv Disabled\n"));
1639 len += scnprintf(buf + len, PAGE_SIZE - len, "\n");
1641 max_cnt = size - LPFC_DEBUG_OUT_LINE_SZ;
1643 for (i = 0; i < phba->cfg_hdw_queue; i++) {
1644 qp = &phba->sli4_hba.hdwq[i];
1649 for (j = 0; j < LPFC_CHECK_CPU_CNT; j++) {
1650 tot_xmt += qp->cpucheck_xmt_io[j];
1651 tot_cmpl += qp->cpucheck_cmpl_io[j];
1652 if (phba->nvmet_support)
1653 tot_rcv += qp->cpucheck_rcv_io[j];
1656 /* Only display Hardware Qs with something */
1657 if (!tot_xmt && !tot_cmpl && !tot_rcv)
1660 len += scnprintf(buf + len, PAGE_SIZE - len,
1662 for (j = 0; j < LPFC_CHECK_CPU_CNT; j++) {
1663 /* Only display non-zero counters */
1664 if (!qp->cpucheck_xmt_io[j] &&
1665 !qp->cpucheck_cmpl_io[j] &&
1666 !qp->cpucheck_rcv_io[j])
1668 if (phba->nvmet_support) {
1669 len += scnprintf(buf + len, PAGE_SIZE - len,
1670 "CPU %03d: %x/%x/%x ", j,
1671 qp->cpucheck_rcv_io[j],
1672 qp->cpucheck_xmt_io[j],
1673 qp->cpucheck_cmpl_io[j]);
1675 len += scnprintf(buf + len, PAGE_SIZE - len,
1676 "CPU %03d: %x/%x ", j,
1677 qp->cpucheck_xmt_io[j],
1678 qp->cpucheck_cmpl_io[j]);
1681 len += scnprintf(buf + len, PAGE_SIZE - len,
1682 "Total: %x\n", tot_xmt);
1683 if (len >= max_cnt) {
1684 len += scnprintf(buf + len, PAGE_SIZE - len,
1695 * lpfc_debugfs_disc_trc - Store discovery trace log
1696 * @vport: The vport to associate this trace string with for retrieval.
1697 * @mask: Log entry classification.
1698 * @fmt: Format string to be displayed when dumping the log.
1699 * @data1: 1st data parameter to be applied to @fmt.
1700 * @data2: 2nd data parameter to be applied to @fmt.
1701 * @data3: 3rd data parameter to be applied to @fmt.
1704 * This routine is used by the driver code to add a debugfs log entry to the
1705 * discovery trace buffer associated with @vport. Only entries with a @mask that
1706 * match the current debugfs discovery mask will be saved. Entries that do not
1707 * match will be thrown away. @fmt, @data1, @data2, and @data3 are used like
1708 * printf when displaying the log.
1711 lpfc_debugfs_disc_trc(struct lpfc_vport *vport, int mask, char *fmt,
1712 uint32_t data1, uint32_t data2, uint32_t data3)
1714 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
1715 struct lpfc_debugfs_trc *dtp;
1718 if (!(lpfc_debugfs_mask_disc_trc & mask))
1721 if (!lpfc_debugfs_enable || !lpfc_debugfs_max_disc_trc ||
1722 !vport || !vport->disc_trc)
1725 index = atomic_inc_return(&vport->disc_trc_cnt) &
1726 (lpfc_debugfs_max_disc_trc - 1);
1727 dtp = vport->disc_trc + index;
1732 dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
1739 * lpfc_debugfs_slow_ring_trc - Store slow ring trace log
1740 * @phba: The phba to associate this trace string with for retrieval.
1741 * @fmt: Format string to be displayed when dumping the log.
1742 * @data1: 1st data parameter to be applied to @fmt.
1743 * @data2: 2nd data parameter to be applied to @fmt.
1744 * @data3: 3rd data parameter to be applied to @fmt.
1747 * This routine is used by the driver code to add a debugfs log entry to the
1748 * discovery trace buffer associated with @vport. @fmt, @data1, @data2, and
1749 * @data3 are used like printf when displaying the log.
1752 lpfc_debugfs_slow_ring_trc(struct lpfc_hba *phba, char *fmt,
1753 uint32_t data1, uint32_t data2, uint32_t data3)
1755 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
1756 struct lpfc_debugfs_trc *dtp;
1759 if (!lpfc_debugfs_enable || !lpfc_debugfs_max_slow_ring_trc ||
1760 !phba || !phba->slow_ring_trc)
1763 index = atomic_inc_return(&phba->slow_ring_trc_cnt) &
1764 (lpfc_debugfs_max_slow_ring_trc - 1);
1765 dtp = phba->slow_ring_trc + index;
1770 dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
1777 * lpfc_debugfs_nvme_trc - Store NVME/NVMET trace log
1778 * @phba: The phba to associate this trace string with for retrieval.
1779 * @fmt: Format string to be displayed when dumping the log.
1780 * @data1: 1st data parameter to be applied to @fmt.
1781 * @data2: 2nd data parameter to be applied to @fmt.
1782 * @data3: 3rd data parameter to be applied to @fmt.
1785 * This routine is used by the driver code to add a debugfs log entry to the
1786 * nvme trace buffer associated with @phba. @fmt, @data1, @data2, and
1787 * @data3 are used like printf when displaying the log.
1790 lpfc_debugfs_nvme_trc(struct lpfc_hba *phba, char *fmt,
1791 uint16_t data1, uint16_t data2, uint32_t data3)
1793 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
1794 struct lpfc_debugfs_nvmeio_trc *dtp;
1797 if (!phba->nvmeio_trc_on || !phba->nvmeio_trc)
1800 index = atomic_inc_return(&phba->nvmeio_trc_cnt) &
1801 (phba->nvmeio_trc_size - 1);
1802 dtp = phba->nvmeio_trc + index;
1810 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
1812 * lpfc_debugfs_disc_trc_open - Open the discovery trace log
1813 * @inode: The inode pointer that contains a vport pointer.
1814 * @file: The file pointer to attach the log output.
1817 * This routine is the entry point for the debugfs open file operation. It gets
1818 * the vport from the i_private field in @inode, allocates the necessary buffer
1819 * for the log, fills the buffer from the in-memory log for this vport, and then
1820 * returns a pointer to that log in the private_data field in @file.
1823 * This function returns zero if successful. On error it will return a negative
1827 lpfc_debugfs_disc_trc_open(struct inode *inode, struct file *file)
1829 struct lpfc_vport *vport = inode->i_private;
1830 struct lpfc_debug *debug;
1834 if (!lpfc_debugfs_max_disc_trc) {
1839 debug = kmalloc(sizeof(*debug), GFP_KERNEL);
1843 /* Round to page boundary */
1844 size = (lpfc_debugfs_max_disc_trc * LPFC_DEBUG_TRC_ENTRY_SIZE);
1845 size = PAGE_ALIGN(size);
1847 debug->buffer = kmalloc(size, GFP_KERNEL);
1848 if (!debug->buffer) {
1853 debug->len = lpfc_debugfs_disc_trc_data(vport, debug->buffer, size);
1854 file->private_data = debug;
1862 * lpfc_debugfs_slow_ring_trc_open - Open the Slow Ring trace log
1863 * @inode: The inode pointer that contains a vport pointer.
1864 * @file: The file pointer to attach the log output.
1867 * This routine is the entry point for the debugfs open file operation. It gets
1868 * the vport from the i_private field in @inode, allocates the necessary buffer
1869 * for the log, fills the buffer from the in-memory log for this vport, and then
1870 * returns a pointer to that log in the private_data field in @file.
1873 * This function returns zero if successful. On error it will return a negative
1877 lpfc_debugfs_slow_ring_trc_open(struct inode *inode, struct file *file)
1879 struct lpfc_hba *phba = inode->i_private;
1880 struct lpfc_debug *debug;
1884 if (!lpfc_debugfs_max_slow_ring_trc) {
1889 debug = kmalloc(sizeof(*debug), GFP_KERNEL);
1893 /* Round to page boundary */
1894 size = (lpfc_debugfs_max_slow_ring_trc * LPFC_DEBUG_TRC_ENTRY_SIZE);
1895 size = PAGE_ALIGN(size);
1897 debug->buffer = kmalloc(size, GFP_KERNEL);
1898 if (!debug->buffer) {
1903 debug->len = lpfc_debugfs_slow_ring_trc_data(phba, debug->buffer, size);
1904 file->private_data = debug;
1912 * lpfc_debugfs_hbqinfo_open - Open the hbqinfo debugfs buffer
1913 * @inode: The inode pointer that contains a vport pointer.
1914 * @file: The file pointer to attach the log output.
1917 * This routine is the entry point for the debugfs open file operation. It gets
1918 * the vport from the i_private field in @inode, allocates the necessary buffer
1919 * for the log, fills the buffer from the in-memory log for this vport, and then
1920 * returns a pointer to that log in the private_data field in @file.
1923 * This function returns zero if successful. On error it will return a negative
1927 lpfc_debugfs_hbqinfo_open(struct inode *inode, struct file *file)
1929 struct lpfc_hba *phba = inode->i_private;
1930 struct lpfc_debug *debug;
1933 debug = kmalloc(sizeof(*debug), GFP_KERNEL);
1937 /* Round to page boundary */
1938 debug->buffer = kmalloc(LPFC_HBQINFO_SIZE, GFP_KERNEL);
1939 if (!debug->buffer) {
1944 debug->len = lpfc_debugfs_hbqinfo_data(phba, debug->buffer,
1946 file->private_data = debug;
1954 * lpfc_debugfs_multixripools_open - Open the multixripool debugfs buffer
1955 * @inode: The inode pointer that contains a hba pointer.
1956 * @file: The file pointer to attach the log output.
1959 * This routine is the entry point for the debugfs open file operation. It gets
1960 * the hba from the i_private field in @inode, allocates the necessary buffer
1961 * for the log, fills the buffer from the in-memory log for this hba, and then
1962 * returns a pointer to that log in the private_data field in @file.
1965 * This function returns zero if successful. On error it will return a negative
1969 lpfc_debugfs_multixripools_open(struct inode *inode, struct file *file)
1971 struct lpfc_hba *phba = inode->i_private;
1972 struct lpfc_debug *debug;
1975 debug = kmalloc(sizeof(*debug), GFP_KERNEL);
1979 /* Round to page boundary */
1980 debug->buffer = kzalloc(LPFC_DUMP_MULTIXRIPOOL_SIZE, GFP_KERNEL);
1981 if (!debug->buffer) {
1986 debug->len = lpfc_debugfs_multixripools_data(
1987 phba, debug->buffer, LPFC_DUMP_MULTIXRIPOOL_SIZE);
1989 debug->i_private = inode->i_private;
1990 file->private_data = debug;
1997 #ifdef LPFC_HDWQ_LOCK_STAT
1999 * lpfc_debugfs_lockstat_open - Open the lockstat debugfs buffer
2000 * @inode: The inode pointer that contains a vport pointer.
2001 * @file: The file pointer to attach the log output.
2004 * This routine is the entry point for the debugfs open file operation. It gets
2005 * the vport from the i_private field in @inode, allocates the necessary buffer
2006 * for the log, fills the buffer from the in-memory log for this vport, and then
2007 * returns a pointer to that log in the private_data field in @file.
2010 * This function returns zero if successful. On error it will return a negative
2014 lpfc_debugfs_lockstat_open(struct inode *inode, struct file *file)
2016 struct lpfc_hba *phba = inode->i_private;
2017 struct lpfc_debug *debug;
2020 debug = kmalloc(sizeof(*debug), GFP_KERNEL);
2024 /* Round to page boundary */
2025 debug->buffer = kmalloc(LPFC_HDWQINFO_SIZE, GFP_KERNEL);
2026 if (!debug->buffer) {
2031 debug->len = lpfc_debugfs_lockstat_data(phba, debug->buffer,
2033 file->private_data = debug;
2041 lpfc_debugfs_lockstat_write(struct file *file, const char __user *buf,
2042 size_t nbytes, loff_t *ppos)
2044 struct lpfc_debug *debug = file->private_data;
2045 struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
2046 struct lpfc_sli4_hdw_queue *qp;
2051 /* Protect copy from user */
2052 if (!access_ok(buf, nbytes))
2055 memset(mybuf, 0, sizeof(mybuf));
2057 if (copy_from_user(mybuf, buf, nbytes))
2061 if ((strncmp(pbuf, "reset", strlen("reset")) == 0) ||
2062 (strncmp(pbuf, "zero", strlen("zero")) == 0)) {
2063 for (i = 0; i < phba->cfg_hdw_queue; i++) {
2064 qp = &phba->sli4_hba.hdwq[i];
2065 qp->lock_conflict.alloc_xri_get = 0;
2066 qp->lock_conflict.alloc_xri_put = 0;
2067 qp->lock_conflict.free_xri = 0;
2068 qp->lock_conflict.wq_access = 0;
2069 qp->lock_conflict.alloc_pvt_pool = 0;
2070 qp->lock_conflict.mv_from_pvt_pool = 0;
2071 qp->lock_conflict.mv_to_pub_pool = 0;
2072 qp->lock_conflict.mv_to_pvt_pool = 0;
2073 qp->lock_conflict.free_pvt_pool = 0;
2074 qp->lock_conflict.free_pub_pool = 0;
2075 qp->lock_conflict.wq_access = 0;
2082 static int lpfc_debugfs_ras_log_data(struct lpfc_hba *phba,
2083 char *buffer, int size)
2086 struct lpfc_dmabuf *dmabuf, *next;
2088 spin_lock_irq(&phba->hbalock);
2089 if (phba->ras_fwlog.state != ACTIVE) {
2090 spin_unlock_irq(&phba->hbalock);
2093 spin_unlock_irq(&phba->hbalock);
2095 list_for_each_entry_safe(dmabuf, next,
2096 &phba->ras_fwlog.fwlog_buff_list, list) {
2097 memcpy(buffer + copied, dmabuf->virt, LPFC_RAS_MAX_ENTRY_SIZE);
2098 copied += LPFC_RAS_MAX_ENTRY_SIZE;
2106 lpfc_debugfs_ras_log_release(struct inode *inode, struct file *file)
2108 struct lpfc_debug *debug = file->private_data;
2110 vfree(debug->buffer);
2117 * lpfc_debugfs_ras_log_open - Open the RAS log debugfs buffer
2118 * @inode: The inode pointer that contains a vport pointer.
2119 * @file: The file pointer to attach the log output.
2122 * This routine is the entry point for the debugfs open file operation. It gets
2123 * the vport from the i_private field in @inode, allocates the necessary buffer
2124 * for the log, fills the buffer from the in-memory log for this vport, and then
2125 * returns a pointer to that log in the private_data field in @file.
2128 * This function returns zero if successful. On error it will return a negative
2132 lpfc_debugfs_ras_log_open(struct inode *inode, struct file *file)
2134 struct lpfc_hba *phba = inode->i_private;
2135 struct lpfc_debug *debug;
2139 spin_lock_irq(&phba->hbalock);
2140 if (phba->ras_fwlog.state != ACTIVE) {
2141 spin_unlock_irq(&phba->hbalock);
2145 spin_unlock_irq(&phba->hbalock);
2146 debug = kmalloc(sizeof(*debug), GFP_KERNEL);
2150 size = LPFC_RAS_MIN_BUFF_POST_SIZE * phba->cfg_ras_fwlog_buffsize;
2151 debug->buffer = vmalloc(size);
2155 debug->len = lpfc_debugfs_ras_log_data(phba, debug->buffer, size);
2156 if (debug->len < 0) {
2160 file->private_data = debug;
2165 vfree(debug->buffer);
2173 * lpfc_debugfs_dumpHBASlim_open - Open the Dump HBA SLIM debugfs buffer
2174 * @inode: The inode pointer that contains a vport pointer.
2175 * @file: The file pointer to attach the log output.
2178 * This routine is the entry point for the debugfs open file operation. It gets
2179 * the vport from the i_private field in @inode, allocates the necessary buffer
2180 * for the log, fills the buffer from the in-memory log for this vport, and then
2181 * returns a pointer to that log in the private_data field in @file.
2184 * This function returns zero if successful. On error it will return a negative
2188 lpfc_debugfs_dumpHBASlim_open(struct inode *inode, struct file *file)
2190 struct lpfc_hba *phba = inode->i_private;
2191 struct lpfc_debug *debug;
2194 debug = kmalloc(sizeof(*debug), GFP_KERNEL);
2198 /* Round to page boundary */
2199 debug->buffer = kmalloc(LPFC_DUMPHBASLIM_SIZE, GFP_KERNEL);
2200 if (!debug->buffer) {
2205 debug->len = lpfc_debugfs_dumpHBASlim_data(phba, debug->buffer,
2206 LPFC_DUMPHBASLIM_SIZE);
2207 file->private_data = debug;
2215 * lpfc_debugfs_dumpHostSlim_open - Open the Dump Host SLIM debugfs buffer
2216 * @inode: The inode pointer that contains a vport pointer.
2217 * @file: The file pointer to attach the log output.
2220 * This routine is the entry point for the debugfs open file operation. It gets
2221 * the vport from the i_private field in @inode, allocates the necessary buffer
2222 * for the log, fills the buffer from the in-memory log for this vport, and then
2223 * returns a pointer to that log in the private_data field in @file.
2226 * This function returns zero if successful. On error it will return a negative
2230 lpfc_debugfs_dumpHostSlim_open(struct inode *inode, struct file *file)
2232 struct lpfc_hba *phba = inode->i_private;
2233 struct lpfc_debug *debug;
2236 debug = kmalloc(sizeof(*debug), GFP_KERNEL);
2240 /* Round to page boundary */
2241 debug->buffer = kmalloc(LPFC_DUMPHOSTSLIM_SIZE, GFP_KERNEL);
2242 if (!debug->buffer) {
2247 debug->len = lpfc_debugfs_dumpHostSlim_data(phba, debug->buffer,
2248 LPFC_DUMPHOSTSLIM_SIZE);
2249 file->private_data = debug;
2257 lpfc_debugfs_dif_err_read(struct file *file, char __user *buf,
2258 size_t nbytes, loff_t *ppos)
2260 struct dentry *dent = file->f_path.dentry;
2261 struct lpfc_hba *phba = file->private_data;
2266 if (dent == phba->debug_writeGuard)
2267 cnt = scnprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_wgrd_cnt);
2268 else if (dent == phba->debug_writeApp)
2269 cnt = scnprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_wapp_cnt);
2270 else if (dent == phba->debug_writeRef)
2271 cnt = scnprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_wref_cnt);
2272 else if (dent == phba->debug_readGuard)
2273 cnt = scnprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_rgrd_cnt);
2274 else if (dent == phba->debug_readApp)
2275 cnt = scnprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_rapp_cnt);
2276 else if (dent == phba->debug_readRef)
2277 cnt = scnprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_rref_cnt);
2278 else if (dent == phba->debug_InjErrNPortID)
2279 cnt = scnprintf(cbuf, 32, "0x%06x\n",
2280 phba->lpfc_injerr_nportid);
2281 else if (dent == phba->debug_InjErrWWPN) {
2282 memcpy(&tmp, &phba->lpfc_injerr_wwpn, sizeof(struct lpfc_name));
2283 tmp = cpu_to_be64(tmp);
2284 cnt = scnprintf(cbuf, 32, "0x%016llx\n", tmp);
2285 } else if (dent == phba->debug_InjErrLBA) {
2286 if (phba->lpfc_injerr_lba == (sector_t)(-1))
2287 cnt = scnprintf(cbuf, 32, "off\n");
2289 cnt = scnprintf(cbuf, 32, "0x%llx\n",
2290 (uint64_t) phba->lpfc_injerr_lba);
2292 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
2293 "0547 Unknown debugfs error injection entry\n");
2295 return simple_read_from_buffer(buf, nbytes, ppos, &cbuf, cnt);
2299 lpfc_debugfs_dif_err_write(struct file *file, const char __user *buf,
2300 size_t nbytes, loff_t *ppos)
2302 struct dentry *dent = file->f_path.dentry;
2303 struct lpfc_hba *phba = file->private_data;
2308 memset(dstbuf, 0, 33);
2309 size = (nbytes < 32) ? nbytes : 32;
2310 if (copy_from_user(dstbuf, buf, size))
2313 if (dent == phba->debug_InjErrLBA) {
2314 if ((buf[0] == 'o') && (buf[1] == 'f') && (buf[2] == 'f'))
2315 tmp = (uint64_t)(-1);
2318 if ((tmp == 0) && (kstrtoull(dstbuf, 0, &tmp)))
2321 if (dent == phba->debug_writeGuard)
2322 phba->lpfc_injerr_wgrd_cnt = (uint32_t)tmp;
2323 else if (dent == phba->debug_writeApp)
2324 phba->lpfc_injerr_wapp_cnt = (uint32_t)tmp;
2325 else if (dent == phba->debug_writeRef)
2326 phba->lpfc_injerr_wref_cnt = (uint32_t)tmp;
2327 else if (dent == phba->debug_readGuard)
2328 phba->lpfc_injerr_rgrd_cnt = (uint32_t)tmp;
2329 else if (dent == phba->debug_readApp)
2330 phba->lpfc_injerr_rapp_cnt = (uint32_t)tmp;
2331 else if (dent == phba->debug_readRef)
2332 phba->lpfc_injerr_rref_cnt = (uint32_t)tmp;
2333 else if (dent == phba->debug_InjErrLBA)
2334 phba->lpfc_injerr_lba = (sector_t)tmp;
2335 else if (dent == phba->debug_InjErrNPortID)
2336 phba->lpfc_injerr_nportid = (uint32_t)(tmp & Mask_DID);
2337 else if (dent == phba->debug_InjErrWWPN) {
2338 tmp = cpu_to_be64(tmp);
2339 memcpy(&phba->lpfc_injerr_wwpn, &tmp, sizeof(struct lpfc_name));
2341 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
2342 "0548 Unknown debugfs error injection entry\n");
2348 lpfc_debugfs_dif_err_release(struct inode *inode, struct file *file)
2354 * lpfc_debugfs_nodelist_open - Open the nodelist debugfs file
2355 * @inode: The inode pointer that contains a vport pointer.
2356 * @file: The file pointer to attach the log output.
2359 * This routine is the entry point for the debugfs open file operation. It gets
2360 * the vport from the i_private field in @inode, allocates the necessary buffer
2361 * for the log, fills the buffer from the in-memory log for this vport, and then
2362 * returns a pointer to that log in the private_data field in @file.
2365 * This function returns zero if successful. On error it will return a negative
2369 lpfc_debugfs_nodelist_open(struct inode *inode, struct file *file)
2371 struct lpfc_vport *vport = inode->i_private;
2372 struct lpfc_debug *debug;
2375 debug = kmalloc(sizeof(*debug), GFP_KERNEL);
2379 /* Round to page boundary */
2380 debug->buffer = kmalloc(LPFC_NODELIST_SIZE, GFP_KERNEL);
2381 if (!debug->buffer) {
2386 debug->len = lpfc_debugfs_nodelist_data(vport, debug->buffer,
2387 LPFC_NODELIST_SIZE);
2388 file->private_data = debug;
2396 * lpfc_debugfs_lseek - Seek through a debugfs file
2397 * @file: The file pointer to seek through.
2398 * @off: The offset to seek to or the amount to seek by.
2399 * @whence: Indicates how to seek.
2402 * This routine is the entry point for the debugfs lseek file operation. The
2403 * @whence parameter indicates whether @off is the offset to directly seek to,
2404 * or if it is a value to seek forward or reverse by. This function figures out
2405 * what the new offset of the debugfs file will be and assigns that value to the
2406 * f_pos field of @file.
2409 * This function returns the new offset if successful and returns a negative
2410 * error if unable to process the seek.
2413 lpfc_debugfs_lseek(struct file *file, loff_t off, int whence)
2415 struct lpfc_debug *debug = file->private_data;
2416 return fixed_size_llseek(file, off, whence, debug->len);
2420 * lpfc_debugfs_read - Read a debugfs file
2421 * @file: The file pointer to read from.
2422 * @buf: The buffer to copy the data to.
2423 * @nbytes: The number of bytes to read.
2424 * @ppos: The position in the file to start reading from.
2427 * This routine reads data from from the buffer indicated in the private_data
2428 * field of @file. It will start reading at @ppos and copy up to @nbytes of
2432 * This function returns the amount of data that was read (this could be less
2433 * than @nbytes if the end of the file was reached) or a negative error value.
2436 lpfc_debugfs_read(struct file *file, char __user *buf,
2437 size_t nbytes, loff_t *ppos)
2439 struct lpfc_debug *debug = file->private_data;
2441 return simple_read_from_buffer(buf, nbytes, ppos, debug->buffer,
2446 * lpfc_debugfs_release - Release the buffer used to store debugfs file data
2447 * @inode: The inode pointer that contains a vport pointer. (unused)
2448 * @file: The file pointer that contains the buffer to release.
2451 * This routine frees the buffer that was allocated when the debugfs file was
2455 * This function returns zero.
2458 lpfc_debugfs_release(struct inode *inode, struct file *file)
2460 struct lpfc_debug *debug = file->private_data;
2462 kfree(debug->buffer);
2469 * lpfc_debugfs_multixripools_write - Clear multi-XRI pools statistics
2470 * @file: The file pointer to read from.
2471 * @buf: The buffer to copy the user data from.
2472 * @nbytes: The number of bytes to get.
2473 * @ppos: The position in the file to start reading from.
2476 * This routine clears multi-XRI pools statistics when buf contains "clear".
2479 * It returns the @nbytges passing in from debugfs user space when successful.
2480 * In case of error conditions, it returns proper error code back to the user
2484 lpfc_debugfs_multixripools_write(struct file *file, const char __user *buf,
2485 size_t nbytes, loff_t *ppos)
2487 struct lpfc_debug *debug = file->private_data;
2488 struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
2493 struct lpfc_sli4_hdw_queue *qp;
2494 struct lpfc_multixri_pool *multixri_pool;
2499 /* Protect copy from user */
2500 if (!access_ok(buf, nbytes))
2503 memset(mybuf, 0, sizeof(mybuf));
2505 if (copy_from_user(mybuf, buf, nbytes))
2509 if ((strncmp(pbuf, "clear", strlen("clear"))) == 0) {
2510 hwq_count = phba->cfg_hdw_queue;
2511 for (i = 0; i < hwq_count; i++) {
2512 qp = &phba->sli4_hba.hdwq[i];
2513 multixri_pool = qp->p_multixri_pool;
2517 qp->empty_io_bufs = 0;
2518 multixri_pool->pbl_empty_count = 0;
2519 #ifdef LPFC_MXP_STAT
2520 multixri_pool->above_limit_count = 0;
2521 multixri_pool->below_limit_count = 0;
2522 multixri_pool->stat_max_hwm = 0;
2523 multixri_pool->local_pbl_hit_count = 0;
2524 multixri_pool->other_pbl_hit_count = 0;
2526 multixri_pool->stat_pbl_count = 0;
2527 multixri_pool->stat_pvt_count = 0;
2528 multixri_pool->stat_busy_count = 0;
2529 multixri_pool->stat_snapshot_taken = 0;
2532 return strlen(pbuf);
2539 lpfc_debugfs_nvmestat_open(struct inode *inode, struct file *file)
2541 struct lpfc_vport *vport = inode->i_private;
2542 struct lpfc_debug *debug;
2545 debug = kmalloc(sizeof(*debug), GFP_KERNEL);
2549 /* Round to page boundary */
2550 debug->buffer = kmalloc(LPFC_NVMESTAT_SIZE, GFP_KERNEL);
2551 if (!debug->buffer) {
2556 debug->len = lpfc_debugfs_nvmestat_data(vport, debug->buffer,
2557 LPFC_NVMESTAT_SIZE);
2559 debug->i_private = inode->i_private;
2560 file->private_data = debug;
2568 lpfc_debugfs_nvmestat_write(struct file *file, const char __user *buf,
2569 size_t nbytes, loff_t *ppos)
2571 struct lpfc_debug *debug = file->private_data;
2572 struct lpfc_vport *vport = (struct lpfc_vport *)debug->i_private;
2573 struct lpfc_hba *phba = vport->phba;
2574 struct lpfc_nvmet_tgtport *tgtp;
2578 if (!phba->targetport)
2584 memset(mybuf, 0, sizeof(mybuf));
2586 if (copy_from_user(mybuf, buf, nbytes))
2590 tgtp = (struct lpfc_nvmet_tgtport *)phba->targetport->private;
2591 if ((strncmp(pbuf, "reset", strlen("reset")) == 0) ||
2592 (strncmp(pbuf, "zero", strlen("zero")) == 0)) {
2593 atomic_set(&tgtp->rcv_ls_req_in, 0);
2594 atomic_set(&tgtp->rcv_ls_req_out, 0);
2595 atomic_set(&tgtp->rcv_ls_req_drop, 0);
2596 atomic_set(&tgtp->xmt_ls_abort, 0);
2597 atomic_set(&tgtp->xmt_ls_abort_cmpl, 0);
2598 atomic_set(&tgtp->xmt_ls_rsp, 0);
2599 atomic_set(&tgtp->xmt_ls_drop, 0);
2600 atomic_set(&tgtp->xmt_ls_rsp_error, 0);
2601 atomic_set(&tgtp->xmt_ls_rsp_cmpl, 0);
2603 atomic_set(&tgtp->rcv_fcp_cmd_in, 0);
2604 atomic_set(&tgtp->rcv_fcp_cmd_out, 0);
2605 atomic_set(&tgtp->rcv_fcp_cmd_drop, 0);
2606 atomic_set(&tgtp->xmt_fcp_drop, 0);
2607 atomic_set(&tgtp->xmt_fcp_read_rsp, 0);
2608 atomic_set(&tgtp->xmt_fcp_read, 0);
2609 atomic_set(&tgtp->xmt_fcp_write, 0);
2610 atomic_set(&tgtp->xmt_fcp_rsp, 0);
2611 atomic_set(&tgtp->xmt_fcp_release, 0);
2612 atomic_set(&tgtp->xmt_fcp_rsp_cmpl, 0);
2613 atomic_set(&tgtp->xmt_fcp_rsp_error, 0);
2614 atomic_set(&tgtp->xmt_fcp_rsp_drop, 0);
2616 atomic_set(&tgtp->xmt_fcp_abort, 0);
2617 atomic_set(&tgtp->xmt_fcp_abort_cmpl, 0);
2618 atomic_set(&tgtp->xmt_abort_sol, 0);
2619 atomic_set(&tgtp->xmt_abort_unsol, 0);
2620 atomic_set(&tgtp->xmt_abort_rsp, 0);
2621 atomic_set(&tgtp->xmt_abort_rsp_error, 0);
2627 lpfc_debugfs_scsistat_open(struct inode *inode, struct file *file)
2629 struct lpfc_vport *vport = inode->i_private;
2630 struct lpfc_debug *debug;
2633 debug = kmalloc(sizeof(*debug), GFP_KERNEL);
2637 /* Round to page boundary */
2638 debug->buffer = kzalloc(LPFC_SCSISTAT_SIZE, GFP_KERNEL);
2639 if (!debug->buffer) {
2644 debug->len = lpfc_debugfs_scsistat_data(vport, debug->buffer,
2645 LPFC_SCSISTAT_SIZE);
2647 debug->i_private = inode->i_private;
2648 file->private_data = debug;
2656 lpfc_debugfs_scsistat_write(struct file *file, const char __user *buf,
2657 size_t nbytes, loff_t *ppos)
2659 struct lpfc_debug *debug = file->private_data;
2660 struct lpfc_vport *vport = (struct lpfc_vport *)debug->i_private;
2661 struct lpfc_hba *phba = vport->phba;
2662 char mybuf[6] = {0};
2665 /* Protect copy from user */
2666 if (!access_ok(buf, nbytes))
2669 if (copy_from_user(mybuf, buf, (nbytes >= sizeof(mybuf)) ?
2670 (sizeof(mybuf) - 1) : nbytes))
2673 if ((strncmp(&mybuf[0], "reset", strlen("reset")) == 0) ||
2674 (strncmp(&mybuf[0], "zero", strlen("zero")) == 0)) {
2675 for (i = 0; i < phba->cfg_hdw_queue; i++) {
2676 memset(&phba->sli4_hba.hdwq[i].scsi_cstat, 0,
2677 sizeof(phba->sli4_hba.hdwq[i].scsi_cstat));
2685 lpfc_debugfs_nvmektime_open(struct inode *inode, struct file *file)
2687 struct lpfc_vport *vport = inode->i_private;
2688 struct lpfc_debug *debug;
2691 debug = kmalloc(sizeof(*debug), GFP_KERNEL);
2695 /* Round to page boundary */
2696 debug->buffer = kmalloc(LPFC_NVMEKTIME_SIZE, GFP_KERNEL);
2697 if (!debug->buffer) {
2702 debug->len = lpfc_debugfs_nvmektime_data(vport, debug->buffer,
2703 LPFC_NVMEKTIME_SIZE);
2705 debug->i_private = inode->i_private;
2706 file->private_data = debug;
2714 lpfc_debugfs_nvmektime_write(struct file *file, const char __user *buf,
2715 size_t nbytes, loff_t *ppos)
2717 struct lpfc_debug *debug = file->private_data;
2718 struct lpfc_vport *vport = (struct lpfc_vport *)debug->i_private;
2719 struct lpfc_hba *phba = vport->phba;
2726 memset(mybuf, 0, sizeof(mybuf));
2728 if (copy_from_user(mybuf, buf, nbytes))
2732 if ((strncmp(pbuf, "on", sizeof("on") - 1) == 0)) {
2733 phba->ktime_data_samples = 0;
2734 phba->ktime_status_samples = 0;
2735 phba->ktime_seg1_total = 0;
2736 phba->ktime_seg1_max = 0;
2737 phba->ktime_seg1_min = 0xffffffff;
2738 phba->ktime_seg2_total = 0;
2739 phba->ktime_seg2_max = 0;
2740 phba->ktime_seg2_min = 0xffffffff;
2741 phba->ktime_seg3_total = 0;
2742 phba->ktime_seg3_max = 0;
2743 phba->ktime_seg3_min = 0xffffffff;
2744 phba->ktime_seg4_total = 0;
2745 phba->ktime_seg4_max = 0;
2746 phba->ktime_seg4_min = 0xffffffff;
2747 phba->ktime_seg5_total = 0;
2748 phba->ktime_seg5_max = 0;
2749 phba->ktime_seg5_min = 0xffffffff;
2750 phba->ktime_seg6_total = 0;
2751 phba->ktime_seg6_max = 0;
2752 phba->ktime_seg6_min = 0xffffffff;
2753 phba->ktime_seg7_total = 0;
2754 phba->ktime_seg7_max = 0;
2755 phba->ktime_seg7_min = 0xffffffff;
2756 phba->ktime_seg8_total = 0;
2757 phba->ktime_seg8_max = 0;
2758 phba->ktime_seg8_min = 0xffffffff;
2759 phba->ktime_seg9_total = 0;
2760 phba->ktime_seg9_max = 0;
2761 phba->ktime_seg9_min = 0xffffffff;
2762 phba->ktime_seg10_total = 0;
2763 phba->ktime_seg10_max = 0;
2764 phba->ktime_seg10_min = 0xffffffff;
2767 return strlen(pbuf);
2768 } else if ((strncmp(pbuf, "off",
2769 sizeof("off") - 1) == 0)) {
2771 return strlen(pbuf);
2772 } else if ((strncmp(pbuf, "zero",
2773 sizeof("zero") - 1) == 0)) {
2774 phba->ktime_data_samples = 0;
2775 phba->ktime_status_samples = 0;
2776 phba->ktime_seg1_total = 0;
2777 phba->ktime_seg1_max = 0;
2778 phba->ktime_seg1_min = 0xffffffff;
2779 phba->ktime_seg2_total = 0;
2780 phba->ktime_seg2_max = 0;
2781 phba->ktime_seg2_min = 0xffffffff;
2782 phba->ktime_seg3_total = 0;
2783 phba->ktime_seg3_max = 0;
2784 phba->ktime_seg3_min = 0xffffffff;
2785 phba->ktime_seg4_total = 0;
2786 phba->ktime_seg4_max = 0;
2787 phba->ktime_seg4_min = 0xffffffff;
2788 phba->ktime_seg5_total = 0;
2789 phba->ktime_seg5_max = 0;
2790 phba->ktime_seg5_min = 0xffffffff;
2791 phba->ktime_seg6_total = 0;
2792 phba->ktime_seg6_max = 0;
2793 phba->ktime_seg6_min = 0xffffffff;
2794 phba->ktime_seg7_total = 0;
2795 phba->ktime_seg7_max = 0;
2796 phba->ktime_seg7_min = 0xffffffff;
2797 phba->ktime_seg8_total = 0;
2798 phba->ktime_seg8_max = 0;
2799 phba->ktime_seg8_min = 0xffffffff;
2800 phba->ktime_seg9_total = 0;
2801 phba->ktime_seg9_max = 0;
2802 phba->ktime_seg9_min = 0xffffffff;
2803 phba->ktime_seg10_total = 0;
2804 phba->ktime_seg10_max = 0;
2805 phba->ktime_seg10_min = 0xffffffff;
2806 return strlen(pbuf);
2812 lpfc_debugfs_nvmeio_trc_open(struct inode *inode, struct file *file)
2814 struct lpfc_hba *phba = inode->i_private;
2815 struct lpfc_debug *debug;
2818 debug = kmalloc(sizeof(*debug), GFP_KERNEL);
2822 /* Round to page boundary */
2823 debug->buffer = kmalloc(LPFC_NVMEIO_TRC_SIZE, GFP_KERNEL);
2824 if (!debug->buffer) {
2829 debug->len = lpfc_debugfs_nvmeio_trc_data(phba, debug->buffer,
2830 LPFC_NVMEIO_TRC_SIZE);
2832 debug->i_private = inode->i_private;
2833 file->private_data = debug;
2841 lpfc_debugfs_nvmeio_trc_write(struct file *file, const char __user *buf,
2842 size_t nbytes, loff_t *ppos)
2844 struct lpfc_debug *debug = file->private_data;
2845 struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
2854 memset(mybuf, 0, sizeof(mybuf));
2856 if (copy_from_user(mybuf, buf, nbytes))
2860 if ((strncmp(pbuf, "off", sizeof("off") - 1) == 0)) {
2861 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
2862 "0570 nvmeio_trc_off\n");
2863 phba->nvmeio_trc_output_idx = 0;
2864 phba->nvmeio_trc_on = 0;
2865 return strlen(pbuf);
2866 } else if ((strncmp(pbuf, "on", sizeof("on") - 1) == 0)) {
2867 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
2868 "0571 nvmeio_trc_on\n");
2869 phba->nvmeio_trc_output_idx = 0;
2870 phba->nvmeio_trc_on = 1;
2871 return strlen(pbuf);
2874 /* We must be off to allocate the trace buffer */
2875 if (phba->nvmeio_trc_on != 0)
2878 /* If not on or off, the parameter is the trace buffer size */
2879 i = kstrtoul(pbuf, 0, &sz);
2882 phba->nvmeio_trc_size = (uint32_t)sz;
2884 /* It must be a power of 2 - round down */
2891 if (phba->nvmeio_trc_size != sz)
2892 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
2893 "0572 nvmeio_trc_size changed to %ld\n",
2895 phba->nvmeio_trc_size = (uint32_t)sz;
2897 /* If one previously exists, free it */
2898 kfree(phba->nvmeio_trc);
2900 /* Allocate new trace buffer and initialize */
2901 phba->nvmeio_trc = kzalloc((sizeof(struct lpfc_debugfs_nvmeio_trc) *
2903 if (!phba->nvmeio_trc) {
2904 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
2905 "0573 Cannot create debugfs "
2906 "nvmeio_trc buffer\n");
2909 atomic_set(&phba->nvmeio_trc_cnt, 0);
2910 phba->nvmeio_trc_on = 0;
2911 phba->nvmeio_trc_output_idx = 0;
2913 return strlen(pbuf);
2917 lpfc_debugfs_cpucheck_open(struct inode *inode, struct file *file)
2919 struct lpfc_vport *vport = inode->i_private;
2920 struct lpfc_debug *debug;
2923 debug = kmalloc(sizeof(*debug), GFP_KERNEL);
2927 /* Round to page boundary */
2928 debug->buffer = kmalloc(LPFC_CPUCHECK_SIZE, GFP_KERNEL);
2929 if (!debug->buffer) {
2934 debug->len = lpfc_debugfs_cpucheck_data(vport, debug->buffer,
2935 LPFC_CPUCHECK_SIZE);
2937 debug->i_private = inode->i_private;
2938 file->private_data = debug;
2946 lpfc_debugfs_cpucheck_write(struct file *file, const char __user *buf,
2947 size_t nbytes, loff_t *ppos)
2949 struct lpfc_debug *debug = file->private_data;
2950 struct lpfc_vport *vport = (struct lpfc_vport *)debug->i_private;
2951 struct lpfc_hba *phba = vport->phba;
2952 struct lpfc_sli4_hdw_queue *qp;
2960 memset(mybuf, 0, sizeof(mybuf));
2962 if (copy_from_user(mybuf, buf, nbytes))
2966 if ((strncmp(pbuf, "on", sizeof("on") - 1) == 0)) {
2967 if (phba->nvmet_support)
2968 phba->cpucheck_on |= LPFC_CHECK_NVMET_IO;
2970 phba->cpucheck_on |= (LPFC_CHECK_NVME_IO |
2971 LPFC_CHECK_SCSI_IO);
2972 return strlen(pbuf);
2973 } else if ((strncmp(pbuf, "nvme_on", sizeof("nvme_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 return strlen(pbuf);
2979 } else if ((strncmp(pbuf, "scsi_on", sizeof("scsi_on") - 1) == 0)) {
2980 phba->cpucheck_on |= LPFC_CHECK_SCSI_IO;
2981 return strlen(pbuf);
2982 } else if ((strncmp(pbuf, "rcv",
2983 sizeof("rcv") - 1) == 0)) {
2984 if (phba->nvmet_support)
2985 phba->cpucheck_on |= LPFC_CHECK_NVMET_RCV;
2988 return strlen(pbuf);
2989 } else if ((strncmp(pbuf, "off",
2990 sizeof("off") - 1) == 0)) {
2991 phba->cpucheck_on = LPFC_CHECK_OFF;
2992 return strlen(pbuf);
2993 } else if ((strncmp(pbuf, "zero",
2994 sizeof("zero") - 1) == 0)) {
2995 for (i = 0; i < phba->cfg_hdw_queue; i++) {
2996 qp = &phba->sli4_hba.hdwq[i];
2998 for (j = 0; j < LPFC_CHECK_CPU_CNT; j++) {
2999 qp->cpucheck_rcv_io[j] = 0;
3000 qp->cpucheck_xmt_io[j] = 0;
3001 qp->cpucheck_cmpl_io[j] = 0;
3004 return strlen(pbuf);
3010 * ---------------------------------
3011 * iDiag debugfs file access methods
3012 * ---------------------------------
3014 * All access methods are through the proper SLI4 PCI function's debugfs
3017 * /sys/kernel/debug/lpfc/fn<#>/iDiag
3021 * lpfc_idiag_cmd_get - Get and parse idiag debugfs comands from user space
3022 * @buf: The pointer to the user space buffer.
3023 * @nbytes: The number of bytes in the user space buffer.
3024 * @idiag_cmd: pointer to the idiag command struct.
3026 * This routine reads data from debugfs user space buffer and parses the
3027 * buffer for getting the idiag command and arguments. The while space in
3028 * between the set of data is used as the parsing separator.
3030 * This routine returns 0 when successful, it returns proper error code
3031 * back to the user space in error conditions.
3033 static int lpfc_idiag_cmd_get(const char __user *buf, size_t nbytes,
3034 struct lpfc_idiag_cmd *idiag_cmd)
3037 char *pbuf, *step_str;
3041 memset(mybuf, 0, sizeof(mybuf));
3042 memset(idiag_cmd, 0, sizeof(*idiag_cmd));
3043 bsize = min(nbytes, (sizeof(mybuf)-1));
3045 if (copy_from_user(mybuf, buf, bsize))
3048 step_str = strsep(&pbuf, "\t ");
3050 /* The opcode must present */
3054 idiag_cmd->opcode = simple_strtol(step_str, NULL, 0);
3055 if (idiag_cmd->opcode == 0)
3058 for (i = 0; i < LPFC_IDIAG_CMD_DATA_SIZE; i++) {
3059 step_str = strsep(&pbuf, "\t ");
3062 idiag_cmd->data[i] = simple_strtol(step_str, NULL, 0);
3068 * lpfc_idiag_open - idiag open debugfs
3069 * @inode: The inode pointer that contains a pointer to phba.
3070 * @file: The file pointer to attach the file operation.
3073 * This routine is the entry point for the debugfs open file operation. It
3074 * gets the reference to phba from the i_private field in @inode, it then
3075 * allocates buffer for the file operation, performs the necessary PCI config
3076 * space read into the allocated buffer according to the idiag user command
3077 * setup, and then returns a pointer to buffer in the private_data field in
3081 * This function returns zero if successful. On error it will return an
3082 * negative error value.
3085 lpfc_idiag_open(struct inode *inode, struct file *file)
3087 struct lpfc_debug *debug;
3089 debug = kmalloc(sizeof(*debug), GFP_KERNEL);
3093 debug->i_private = inode->i_private;
3094 debug->buffer = NULL;
3095 file->private_data = debug;
3101 * lpfc_idiag_release - Release idiag access file operation
3102 * @inode: The inode pointer that contains a vport pointer. (unused)
3103 * @file: The file pointer that contains the buffer to release.
3106 * This routine is the generic release routine for the idiag access file
3107 * operation, it frees the buffer that was allocated when the debugfs file
3111 * This function returns zero.
3114 lpfc_idiag_release(struct inode *inode, struct file *file)
3116 struct lpfc_debug *debug = file->private_data;
3118 /* Free the buffers to the file operation */
3119 kfree(debug->buffer);
3126 * lpfc_idiag_cmd_release - Release idiag cmd access file operation
3127 * @inode: The inode pointer that contains a vport pointer. (unused)
3128 * @file: The file pointer that contains the buffer to release.
3131 * This routine frees the buffer that was allocated when the debugfs file
3132 * was opened. It also reset the fields in the idiag command struct in the
3133 * case of command for write operation.
3136 * This function returns zero.
3139 lpfc_idiag_cmd_release(struct inode *inode, struct file *file)
3141 struct lpfc_debug *debug = file->private_data;
3143 if (debug->op == LPFC_IDIAG_OP_WR) {
3144 switch (idiag.cmd.opcode) {
3145 case LPFC_IDIAG_CMD_PCICFG_WR:
3146 case LPFC_IDIAG_CMD_PCICFG_ST:
3147 case LPFC_IDIAG_CMD_PCICFG_CL:
3148 case LPFC_IDIAG_CMD_QUEACC_WR:
3149 case LPFC_IDIAG_CMD_QUEACC_ST:
3150 case LPFC_IDIAG_CMD_QUEACC_CL:
3151 memset(&idiag, 0, sizeof(idiag));
3158 /* Free the buffers to the file operation */
3159 kfree(debug->buffer);
3166 * lpfc_idiag_pcicfg_read - idiag debugfs read pcicfg
3167 * @file: The file pointer to read from.
3168 * @buf: The buffer to copy the data to.
3169 * @nbytes: The number of bytes to read.
3170 * @ppos: The position in the file to start reading from.
3173 * This routine reads data from the @phba pci config space according to the
3174 * idiag command, and copies to user @buf. Depending on the PCI config space
3175 * read command setup, it does either a single register read of a byte
3176 * (8 bits), a word (16 bits), or a dword (32 bits) or browsing through all
3177 * registers from the 4K extended PCI config space.
3180 * This function returns the amount of data that was read (this could be less
3181 * than @nbytes if the end of the file was reached) or a negative error value.
3184 lpfc_idiag_pcicfg_read(struct file *file, char __user *buf, size_t nbytes,
3187 struct lpfc_debug *debug = file->private_data;
3188 struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
3189 int offset_label, offset, len = 0, index = LPFC_PCI_CFG_RD_SIZE;
3192 struct pci_dev *pdev;
3197 pdev = phba->pcidev;
3201 /* This is a user read operation */
3202 debug->op = LPFC_IDIAG_OP_RD;
3205 debug->buffer = kmalloc(LPFC_PCI_CFG_SIZE, GFP_KERNEL);
3208 pbuffer = debug->buffer;
3213 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_RD) {
3214 where = idiag.cmd.data[IDIAG_PCICFG_WHERE_INDX];
3215 count = idiag.cmd.data[IDIAG_PCICFG_COUNT_INDX];
3219 /* Read single PCI config space register */
3221 case SIZE_U8: /* byte (8 bits) */
3222 pci_read_config_byte(pdev, where, &u8val);
3223 len += scnprintf(pbuffer+len, LPFC_PCI_CFG_SIZE-len,
3224 "%03x: %02x\n", where, u8val);
3226 case SIZE_U16: /* word (16 bits) */
3227 pci_read_config_word(pdev, where, &u16val);
3228 len += scnprintf(pbuffer+len, LPFC_PCI_CFG_SIZE-len,
3229 "%03x: %04x\n", where, u16val);
3231 case SIZE_U32: /* double word (32 bits) */
3232 pci_read_config_dword(pdev, where, &u32val);
3233 len += scnprintf(pbuffer+len, LPFC_PCI_CFG_SIZE-len,
3234 "%03x: %08x\n", where, u32val);
3236 case LPFC_PCI_CFG_BROWSE: /* browse all */
3244 return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len);
3248 /* Browse all PCI config space registers */
3249 offset_label = idiag.offset.last_rd;
3250 offset = offset_label;
3252 /* Read PCI config space */
3253 len += scnprintf(pbuffer+len, LPFC_PCI_CFG_SIZE-len,
3254 "%03x: ", offset_label);
3256 pci_read_config_dword(pdev, offset, &u32val);
3257 len += scnprintf(pbuffer+len, LPFC_PCI_CFG_SIZE-len,
3259 offset += sizeof(uint32_t);
3260 if (offset >= LPFC_PCI_CFG_SIZE) {
3261 len += scnprintf(pbuffer+len,
3262 LPFC_PCI_CFG_SIZE-len, "\n");
3265 index -= sizeof(uint32_t);
3267 len += scnprintf(pbuffer+len, LPFC_PCI_CFG_SIZE-len,
3269 else if (!(index % (8 * sizeof(uint32_t)))) {
3270 offset_label += (8 * sizeof(uint32_t));
3271 len += scnprintf(pbuffer+len, LPFC_PCI_CFG_SIZE-len,
3272 "\n%03x: ", offset_label);
3276 /* Set up the offset for next portion of pci cfg read */
3278 idiag.offset.last_rd += LPFC_PCI_CFG_RD_SIZE;
3279 if (idiag.offset.last_rd >= LPFC_PCI_CFG_SIZE)
3280 idiag.offset.last_rd = 0;
3282 idiag.offset.last_rd = 0;
3284 return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len);
3288 * lpfc_idiag_pcicfg_write - Syntax check and set up idiag pcicfg commands
3289 * @file: The file pointer to read from.
3290 * @buf: The buffer to copy the user data from.
3291 * @nbytes: The number of bytes to get.
3292 * @ppos: The position in the file to start reading from.
3294 * This routine get the debugfs idiag command struct from user space and
3295 * then perform the syntax check for PCI config space read or write command
3296 * accordingly. In the case of PCI config space read command, it sets up
3297 * the command in the idiag command struct for the debugfs read operation.
3298 * In the case of PCI config space write operation, it executes the write
3299 * operation into the PCI config space accordingly.
3301 * It returns the @nbytges passing in from debugfs user space when successful.
3302 * In case of error conditions, it returns proper error code back to the user
3306 lpfc_idiag_pcicfg_write(struct file *file, const char __user *buf,
3307 size_t nbytes, loff_t *ppos)
3309 struct lpfc_debug *debug = file->private_data;
3310 struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
3311 uint32_t where, value, count;
3315 struct pci_dev *pdev;
3318 pdev = phba->pcidev;
3322 /* This is a user write operation */
3323 debug->op = LPFC_IDIAG_OP_WR;
3325 rc = lpfc_idiag_cmd_get(buf, nbytes, &idiag.cmd);
3329 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_RD) {
3330 /* Sanity check on PCI config read command line arguments */
3331 if (rc != LPFC_PCI_CFG_RD_CMD_ARG)
3333 /* Read command from PCI config space, set up command fields */
3334 where = idiag.cmd.data[IDIAG_PCICFG_WHERE_INDX];
3335 count = idiag.cmd.data[IDIAG_PCICFG_COUNT_INDX];
3336 if (count == LPFC_PCI_CFG_BROWSE) {
3337 if (where % sizeof(uint32_t))
3339 /* Starting offset to browse */
3340 idiag.offset.last_rd = where;
3341 } else if ((count != sizeof(uint8_t)) &&
3342 (count != sizeof(uint16_t)) &&
3343 (count != sizeof(uint32_t)))
3345 if (count == sizeof(uint8_t)) {
3346 if (where > LPFC_PCI_CFG_SIZE - sizeof(uint8_t))
3348 if (where % sizeof(uint8_t))
3351 if (count == sizeof(uint16_t)) {
3352 if (where > LPFC_PCI_CFG_SIZE - sizeof(uint16_t))
3354 if (where % sizeof(uint16_t))
3357 if (count == sizeof(uint32_t)) {
3358 if (where > LPFC_PCI_CFG_SIZE - sizeof(uint32_t))
3360 if (where % sizeof(uint32_t))
3363 } else if (idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_WR ||
3364 idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_ST ||
3365 idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_CL) {
3366 /* Sanity check on PCI config write command line arguments */
3367 if (rc != LPFC_PCI_CFG_WR_CMD_ARG)
3369 /* Write command to PCI config space, read-modify-write */
3370 where = idiag.cmd.data[IDIAG_PCICFG_WHERE_INDX];
3371 count = idiag.cmd.data[IDIAG_PCICFG_COUNT_INDX];
3372 value = idiag.cmd.data[IDIAG_PCICFG_VALUE_INDX];
3374 if ((count != sizeof(uint8_t)) &&
3375 (count != sizeof(uint16_t)) &&
3376 (count != sizeof(uint32_t)))
3378 if (count == sizeof(uint8_t)) {
3379 if (where > LPFC_PCI_CFG_SIZE - sizeof(uint8_t))
3381 if (where % sizeof(uint8_t))
3383 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_WR)
3384 pci_write_config_byte(pdev, where,
3386 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_ST) {
3387 rc = pci_read_config_byte(pdev, where, &u8val);
3389 u8val |= (uint8_t)value;
3390 pci_write_config_byte(pdev, where,
3394 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_CL) {
3395 rc = pci_read_config_byte(pdev, where, &u8val);
3397 u8val &= (uint8_t)(~value);
3398 pci_write_config_byte(pdev, where,
3403 if (count == sizeof(uint16_t)) {
3404 if (where > LPFC_PCI_CFG_SIZE - sizeof(uint16_t))
3406 if (where % sizeof(uint16_t))
3408 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_WR)
3409 pci_write_config_word(pdev, where,
3411 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_ST) {
3412 rc = pci_read_config_word(pdev, where, &u16val);
3414 u16val |= (uint16_t)value;
3415 pci_write_config_word(pdev, where,
3419 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_CL) {
3420 rc = pci_read_config_word(pdev, where, &u16val);
3422 u16val &= (uint16_t)(~value);
3423 pci_write_config_word(pdev, where,
3428 if (count == sizeof(uint32_t)) {
3429 if (where > LPFC_PCI_CFG_SIZE - sizeof(uint32_t))
3431 if (where % sizeof(uint32_t))
3433 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_WR)
3434 pci_write_config_dword(pdev, where, value);
3435 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_ST) {
3436 rc = pci_read_config_dword(pdev, where,
3440 pci_write_config_dword(pdev, where,
3444 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_CL) {
3445 rc = pci_read_config_dword(pdev, where,
3449 pci_write_config_dword(pdev, where,
3455 /* All other opecodes are illegal for now */
3460 memset(&idiag, 0, sizeof(idiag));
3465 * lpfc_idiag_baracc_read - idiag debugfs pci bar access read
3466 * @file: The file pointer to read from.
3467 * @buf: The buffer to copy the data to.
3468 * @nbytes: The number of bytes to read.
3469 * @ppos: The position in the file to start reading from.
3472 * This routine reads data from the @phba pci bar memory mapped space
3473 * according to the idiag command, and copies to user @buf.
3476 * This function returns the amount of data that was read (this could be less
3477 * than @nbytes if the end of the file was reached) or a negative error value.
3480 lpfc_idiag_baracc_read(struct file *file, char __user *buf, size_t nbytes,
3483 struct lpfc_debug *debug = file->private_data;
3484 struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
3485 int offset_label, offset, offset_run, len = 0, index;
3486 int bar_num, acc_range, bar_size;
3488 void __iomem *mem_mapped_bar;
3490 struct pci_dev *pdev;
3493 pdev = phba->pcidev;
3497 /* This is a user read operation */
3498 debug->op = LPFC_IDIAG_OP_RD;
3501 debug->buffer = kmalloc(LPFC_PCI_BAR_RD_BUF_SIZE, GFP_KERNEL);
3504 pbuffer = debug->buffer;
3509 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_BARACC_RD) {
3510 bar_num = idiag.cmd.data[IDIAG_BARACC_BAR_NUM_INDX];
3511 offset = idiag.cmd.data[IDIAG_BARACC_OFF_SET_INDX];
3512 acc_range = idiag.cmd.data[IDIAG_BARACC_ACC_MOD_INDX];
3513 bar_size = idiag.cmd.data[IDIAG_BARACC_BAR_SZE_INDX];
3520 if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf);
3521 if (if_type == LPFC_SLI_INTF_IF_TYPE_0) {
3522 if (bar_num == IDIAG_BARACC_BAR_0)
3523 mem_mapped_bar = phba->sli4_hba.conf_regs_memmap_p;
3524 else if (bar_num == IDIAG_BARACC_BAR_1)
3525 mem_mapped_bar = phba->sli4_hba.ctrl_regs_memmap_p;
3526 else if (bar_num == IDIAG_BARACC_BAR_2)
3527 mem_mapped_bar = phba->sli4_hba.drbl_regs_memmap_p;
3530 } else if (if_type == LPFC_SLI_INTF_IF_TYPE_2) {
3531 if (bar_num == IDIAG_BARACC_BAR_0)
3532 mem_mapped_bar = phba->sli4_hba.conf_regs_memmap_p;
3538 /* Read single PCI bar space register */
3539 if (acc_range == SINGLE_WORD) {
3540 offset_run = offset;
3541 u32val = readl(mem_mapped_bar + offset_run);
3542 len += scnprintf(pbuffer+len, LPFC_PCI_BAR_RD_BUF_SIZE-len,
3543 "%05x: %08x\n", offset_run, u32val);
3547 return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len);
3551 /* Browse all PCI bar space registers */
3552 offset_label = idiag.offset.last_rd;
3553 offset_run = offset_label;
3555 /* Read PCI bar memory mapped space */
3556 len += scnprintf(pbuffer+len, LPFC_PCI_BAR_RD_BUF_SIZE-len,
3557 "%05x: ", offset_label);
3558 index = LPFC_PCI_BAR_RD_SIZE;
3560 u32val = readl(mem_mapped_bar + offset_run);
3561 len += scnprintf(pbuffer+len, LPFC_PCI_BAR_RD_BUF_SIZE-len,
3563 offset_run += sizeof(uint32_t);
3564 if (acc_range == LPFC_PCI_BAR_BROWSE) {
3565 if (offset_run >= bar_size) {
3566 len += scnprintf(pbuffer+len,
3567 LPFC_PCI_BAR_RD_BUF_SIZE-len, "\n");
3571 if (offset_run >= offset +
3572 (acc_range * sizeof(uint32_t))) {
3573 len += scnprintf(pbuffer+len,
3574 LPFC_PCI_BAR_RD_BUF_SIZE-len, "\n");
3578 index -= sizeof(uint32_t);
3580 len += scnprintf(pbuffer+len,
3581 LPFC_PCI_BAR_RD_BUF_SIZE-len, "\n");
3582 else if (!(index % (8 * sizeof(uint32_t)))) {
3583 offset_label += (8 * sizeof(uint32_t));
3584 len += scnprintf(pbuffer+len,
3585 LPFC_PCI_BAR_RD_BUF_SIZE-len,
3586 "\n%05x: ", offset_label);
3590 /* Set up the offset for next portion of pci bar read */
3592 idiag.offset.last_rd += LPFC_PCI_BAR_RD_SIZE;
3593 if (acc_range == LPFC_PCI_BAR_BROWSE) {
3594 if (idiag.offset.last_rd >= bar_size)
3595 idiag.offset.last_rd = 0;
3597 if (offset_run >= offset +
3598 (acc_range * sizeof(uint32_t)))
3599 idiag.offset.last_rd = offset;
3602 if (acc_range == LPFC_PCI_BAR_BROWSE)
3603 idiag.offset.last_rd = 0;
3605 idiag.offset.last_rd = offset;
3608 return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len);
3612 * lpfc_idiag_baracc_write - Syntax check and set up idiag bar access commands
3613 * @file: The file pointer to read from.
3614 * @buf: The buffer to copy the user data from.
3615 * @nbytes: The number of bytes to get.
3616 * @ppos: The position in the file to start reading from.
3618 * This routine get the debugfs idiag command struct from user space and
3619 * then perform the syntax check for PCI bar memory mapped space read or
3620 * write command accordingly. In the case of PCI bar memory mapped space
3621 * read command, it sets up the command in the idiag command struct for
3622 * the debugfs read operation. In the case of PCI bar memorpy mapped space
3623 * write operation, it executes the write operation into the PCI bar memory
3624 * mapped space accordingly.
3626 * It returns the @nbytges passing in from debugfs user space when successful.
3627 * In case of error conditions, it returns proper error code back to the user
3631 lpfc_idiag_baracc_write(struct file *file, const char __user *buf,
3632 size_t nbytes, loff_t *ppos)
3634 struct lpfc_debug *debug = file->private_data;
3635 struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
3636 uint32_t bar_num, bar_size, offset, value, acc_range;
3637 struct pci_dev *pdev;
3638 void __iomem *mem_mapped_bar;
3643 pdev = phba->pcidev;
3647 /* This is a user write operation */
3648 debug->op = LPFC_IDIAG_OP_WR;
3650 rc = lpfc_idiag_cmd_get(buf, nbytes, &idiag.cmd);
3654 if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf);
3655 bar_num = idiag.cmd.data[IDIAG_BARACC_BAR_NUM_INDX];
3657 if (if_type == LPFC_SLI_INTF_IF_TYPE_0) {
3658 if ((bar_num != IDIAG_BARACC_BAR_0) &&
3659 (bar_num != IDIAG_BARACC_BAR_1) &&
3660 (bar_num != IDIAG_BARACC_BAR_2))
3662 } else if (if_type == LPFC_SLI_INTF_IF_TYPE_2) {
3663 if (bar_num != IDIAG_BARACC_BAR_0)
3668 if (if_type == LPFC_SLI_INTF_IF_TYPE_0) {
3669 if (bar_num == IDIAG_BARACC_BAR_0) {
3670 idiag.cmd.data[IDIAG_BARACC_BAR_SZE_INDX] =
3671 LPFC_PCI_IF0_BAR0_SIZE;
3672 mem_mapped_bar = phba->sli4_hba.conf_regs_memmap_p;
3673 } else if (bar_num == IDIAG_BARACC_BAR_1) {
3674 idiag.cmd.data[IDIAG_BARACC_BAR_SZE_INDX] =
3675 LPFC_PCI_IF0_BAR1_SIZE;
3676 mem_mapped_bar = phba->sli4_hba.ctrl_regs_memmap_p;
3677 } else if (bar_num == IDIAG_BARACC_BAR_2) {
3678 idiag.cmd.data[IDIAG_BARACC_BAR_SZE_INDX] =
3679 LPFC_PCI_IF0_BAR2_SIZE;
3680 mem_mapped_bar = phba->sli4_hba.drbl_regs_memmap_p;
3683 } else if (if_type == LPFC_SLI_INTF_IF_TYPE_2) {
3684 if (bar_num == IDIAG_BARACC_BAR_0) {
3685 idiag.cmd.data[IDIAG_BARACC_BAR_SZE_INDX] =
3686 LPFC_PCI_IF2_BAR0_SIZE;
3687 mem_mapped_bar = phba->sli4_hba.conf_regs_memmap_p;
3693 offset = idiag.cmd.data[IDIAG_BARACC_OFF_SET_INDX];
3694 if (offset % sizeof(uint32_t))
3697 bar_size = idiag.cmd.data[IDIAG_BARACC_BAR_SZE_INDX];
3698 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_BARACC_RD) {
3699 /* Sanity check on PCI config read command line arguments */
3700 if (rc != LPFC_PCI_BAR_RD_CMD_ARG)
3702 acc_range = idiag.cmd.data[IDIAG_BARACC_ACC_MOD_INDX];
3703 if (acc_range == LPFC_PCI_BAR_BROWSE) {
3704 if (offset > bar_size - sizeof(uint32_t))
3706 /* Starting offset to browse */
3707 idiag.offset.last_rd = offset;
3708 } else if (acc_range > SINGLE_WORD) {
3709 if (offset + acc_range * sizeof(uint32_t) > bar_size)
3711 /* Starting offset to browse */
3712 idiag.offset.last_rd = offset;
3713 } else if (acc_range != SINGLE_WORD)
3715 } else if (idiag.cmd.opcode == LPFC_IDIAG_CMD_BARACC_WR ||
3716 idiag.cmd.opcode == LPFC_IDIAG_CMD_BARACC_ST ||
3717 idiag.cmd.opcode == LPFC_IDIAG_CMD_BARACC_CL) {
3718 /* Sanity check on PCI bar write command line arguments */
3719 if (rc != LPFC_PCI_BAR_WR_CMD_ARG)
3721 /* Write command to PCI bar space, read-modify-write */
3722 acc_range = SINGLE_WORD;
3723 value = idiag.cmd.data[IDIAG_BARACC_REG_VAL_INDX];
3724 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_BARACC_WR) {
3725 writel(value, mem_mapped_bar + offset);
3726 readl(mem_mapped_bar + offset);
3728 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_BARACC_ST) {
3729 u32val = readl(mem_mapped_bar + offset);
3731 writel(u32val, mem_mapped_bar + offset);
3732 readl(mem_mapped_bar + offset);
3734 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_BARACC_CL) {
3735 u32val = readl(mem_mapped_bar + offset);
3737 writel(u32val, mem_mapped_bar + offset);
3738 readl(mem_mapped_bar + offset);
3741 /* All other opecodes are illegal for now */
3746 memset(&idiag, 0, sizeof(idiag));
3751 __lpfc_idiag_print_wq(struct lpfc_queue *qp, char *wqtype,
3752 char *pbuffer, int len)
3757 len += scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
3758 "\t\t%s WQ info: ", wqtype);
3759 len += scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
3760 "AssocCQID[%04d]: WQ-STAT[oflow:x%x posted:x%llx]\n",
3761 qp->assoc_qid, qp->q_cnt_1,
3762 (unsigned long long)qp->q_cnt_4);
3763 len += scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
3764 "\t\tWQID[%02d], QE-CNT[%04d], QE-SZ[%04d], "
3765 "HST-IDX[%04d], PRT-IDX[%04d], NTFI[%03d]",
3766 qp->queue_id, qp->entry_count,
3767 qp->entry_size, qp->host_index,
3768 qp->hba_index, qp->notify_interval);
3769 len += scnprintf(pbuffer + len,
3770 LPFC_QUE_INFO_GET_BUF_SIZE - len, "\n");
3775 lpfc_idiag_wqs_for_cq(struct lpfc_hba *phba, char *wqtype, char *pbuffer,
3776 int *len, int max_cnt, int cq_id)
3778 struct lpfc_queue *qp;
3781 for (qidx = 0; qidx < phba->cfg_hdw_queue; qidx++) {
3782 qp = phba->sli4_hba.hdwq[qidx].io_wq;
3783 if (qp->assoc_qid != cq_id)
3785 *len = __lpfc_idiag_print_wq(qp, wqtype, pbuffer, *len);
3786 if (*len >= max_cnt)
3793 __lpfc_idiag_print_cq(struct lpfc_queue *qp, char *cqtype,
3794 char *pbuffer, int len)
3799 len += scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
3800 "\t%s CQ info: ", cqtype);
3801 len += scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
3802 "AssocEQID[%02d]: CQ STAT[max:x%x relw:x%x "
3803 "xabt:x%x wq:x%llx]\n",
3804 qp->assoc_qid, qp->q_cnt_1, qp->q_cnt_2,
3805 qp->q_cnt_3, (unsigned long long)qp->q_cnt_4);
3806 len += scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
3807 "\tCQID[%02d], QE-CNT[%04d], QE-SZ[%04d], "
3808 "HST-IDX[%04d], NTFI[%03d], PLMT[%03d]",
3809 qp->queue_id, qp->entry_count,
3810 qp->entry_size, qp->host_index,
3811 qp->notify_interval, qp->max_proc_limit);
3813 len += scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
3820 __lpfc_idiag_print_rqpair(struct lpfc_queue *qp, struct lpfc_queue *datqp,
3821 char *rqtype, char *pbuffer, int len)
3826 len += scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
3827 "\t\t%s RQ info: ", rqtype);
3828 len += scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
3829 "AssocCQID[%02d]: RQ-STAT[nopost:x%x nobuf:x%x "
3830 "posted:x%x rcv:x%llx]\n",
3831 qp->assoc_qid, qp->q_cnt_1, qp->q_cnt_2,
3832 qp->q_cnt_3, (unsigned long long)qp->q_cnt_4);
3833 len += scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
3834 "\t\tHQID[%02d], QE-CNT[%04d], QE-SZ[%04d], "
3835 "HST-IDX[%04d], PRT-IDX[%04d], NTFI[%03d]\n",
3836 qp->queue_id, qp->entry_count, qp->entry_size,
3837 qp->host_index, qp->hba_index, qp->notify_interval);
3838 len += scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
3839 "\t\tDQID[%02d], QE-CNT[%04d], QE-SZ[%04d], "
3840 "HST-IDX[%04d], PRT-IDX[%04d], NTFI[%03d]\n",
3841 datqp->queue_id, datqp->entry_count,
3842 datqp->entry_size, datqp->host_index,
3843 datqp->hba_index, datqp->notify_interval);
3848 lpfc_idiag_cqs_for_eq(struct lpfc_hba *phba, char *pbuffer,
3849 int *len, int max_cnt, int eqidx, int eq_id)
3851 struct lpfc_queue *qp;
3854 qp = phba->sli4_hba.hdwq[eqidx].io_cq;
3856 *len = __lpfc_idiag_print_cq(qp, "IO", pbuffer, *len);
3858 /* Reset max counter */
3861 if (*len >= max_cnt)
3864 rc = lpfc_idiag_wqs_for_cq(phba, "IO", pbuffer, len,
3865 max_cnt, qp->queue_id);
3869 if ((eqidx < phba->cfg_nvmet_mrq) && phba->nvmet_support) {
3871 qp = phba->sli4_hba.nvmet_cqset[eqidx];
3872 *len = __lpfc_idiag_print_cq(qp, "NVMET CQset", pbuffer, *len);
3874 /* Reset max counter */
3877 if (*len >= max_cnt)
3881 qp = phba->sli4_hba.nvmet_mrq_hdr[eqidx];
3882 *len = __lpfc_idiag_print_rqpair(qp,
3883 phba->sli4_hba.nvmet_mrq_data[eqidx],
3884 "NVMET MRQ", pbuffer, *len);
3886 if (*len >= max_cnt)
3894 __lpfc_idiag_print_eq(struct lpfc_queue *qp, char *eqtype,
3895 char *pbuffer, int len)
3900 len += scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
3901 "\n%s EQ info: EQ-STAT[max:x%x noE:x%x "
3902 "cqe_proc:x%x eqe_proc:x%llx eqd %d]\n",
3903 eqtype, qp->q_cnt_1, qp->q_cnt_2, qp->q_cnt_3,
3904 (unsigned long long)qp->q_cnt_4, qp->q_mode);
3905 len += scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
3906 "EQID[%02d], QE-CNT[%04d], QE-SZ[%04d], "
3907 "HST-IDX[%04d], NTFI[%03d], PLMT[%03d], AFFIN[%03d]",
3908 qp->queue_id, qp->entry_count, qp->entry_size,
3909 qp->host_index, qp->notify_interval,
3910 qp->max_proc_limit, qp->chann);
3911 len += scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
3918 * lpfc_idiag_queinfo_read - idiag debugfs read queue information
3919 * @file: The file pointer to read from.
3920 * @buf: The buffer to copy the data to.
3921 * @nbytes: The number of bytes to read.
3922 * @ppos: The position in the file to start reading from.
3925 * This routine reads data from the @phba SLI4 PCI function queue information,
3926 * and copies to user @buf.
3927 * This routine only returns 1 EQs worth of information. It remembers the last
3928 * EQ read and jumps to the next EQ. Thus subsequent calls to queInfo will
3929 * retrieve all EQs allocated for the phba.
3932 * This function returns the amount of data that was read (this could be less
3933 * than @nbytes if the end of the file was reached) or a negative error value.
3936 lpfc_idiag_queinfo_read(struct file *file, char __user *buf, size_t nbytes,
3939 struct lpfc_debug *debug = file->private_data;
3940 struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
3942 int max_cnt, rc, x, len = 0;
3943 struct lpfc_queue *qp = NULL;
3946 debug->buffer = kmalloc(LPFC_QUE_INFO_GET_BUF_SIZE, GFP_KERNEL);
3949 pbuffer = debug->buffer;
3950 max_cnt = LPFC_QUE_INFO_GET_BUF_SIZE - 256;
3955 spin_lock_irq(&phba->hbalock);
3957 /* Fast-path event queue */
3958 if (phba->sli4_hba.hdwq && phba->cfg_hdw_queue) {
3960 x = phba->lpfc_idiag_last_eq;
3961 phba->lpfc_idiag_last_eq++;
3962 if (phba->lpfc_idiag_last_eq >= phba->cfg_hdw_queue)
3963 phba->lpfc_idiag_last_eq = 0;
3965 len += scnprintf(pbuffer + len,
3966 LPFC_QUE_INFO_GET_BUF_SIZE - len,
3967 "HDWQ %d out of %d HBA HDWQs\n",
3968 x, phba->cfg_hdw_queue);
3971 qp = phba->sli4_hba.hdwq[x].hba_eq;
3975 len = __lpfc_idiag_print_eq(qp, "HBA", pbuffer, len);
3977 /* Reset max counter */
3983 /* will dump both fcp and nvme cqs/wqs for the eq */
3984 rc = lpfc_idiag_cqs_for_eq(phba, pbuffer, &len,
3985 max_cnt, x, qp->queue_id);
3989 /* Only EQ 0 has slow path CQs configured */
3993 /* Slow-path mailbox CQ */
3994 qp = phba->sli4_hba.mbx_cq;
3995 len = __lpfc_idiag_print_cq(qp, "MBX", pbuffer, len);
3999 /* Slow-path MBOX MQ */
4000 qp = phba->sli4_hba.mbx_wq;
4001 len = __lpfc_idiag_print_wq(qp, "MBX", pbuffer, len);
4005 /* Slow-path ELS response CQ */
4006 qp = phba->sli4_hba.els_cq;
4007 len = __lpfc_idiag_print_cq(qp, "ELS", pbuffer, len);
4008 /* Reset max counter */
4014 /* Slow-path ELS WQ */
4015 qp = phba->sli4_hba.els_wq;
4016 len = __lpfc_idiag_print_wq(qp, "ELS", pbuffer, len);
4020 qp = phba->sli4_hba.hdr_rq;
4021 len = __lpfc_idiag_print_rqpair(qp, phba->sli4_hba.dat_rq,
4022 "ELS RQpair", pbuffer, len);
4026 /* Slow-path NVME LS response CQ */
4027 qp = phba->sli4_hba.nvmels_cq;
4028 len = __lpfc_idiag_print_cq(qp, "NVME LS",
4030 /* Reset max counter */
4036 /* Slow-path NVME LS WQ */
4037 qp = phba->sli4_hba.nvmels_wq;
4038 len = __lpfc_idiag_print_wq(qp, "NVME LS",
4046 spin_unlock_irq(&phba->hbalock);
4047 return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len);
4050 len += scnprintf(pbuffer + len,
4051 LPFC_QUE_INFO_GET_BUF_SIZE - len, "Truncated ...\n");
4053 spin_unlock_irq(&phba->hbalock);
4054 return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len);
4058 * lpfc_idiag_que_param_check - queue access command parameter sanity check
4059 * @q: The pointer to queue structure.
4060 * @index: The index into a queue entry.
4061 * @count: The number of queue entries to access.
4064 * The routine performs sanity check on device queue access method commands.
4067 * This function returns -EINVAL when fails the sanity check, otherwise, it
4071 lpfc_idiag_que_param_check(struct lpfc_queue *q, int index, int count)
4073 /* Only support single entry read or browsing */
4074 if ((count != 1) && (count != LPFC_QUE_ACC_BROWSE))
4076 if (index > q->entry_count - 1)
4082 * lpfc_idiag_queacc_read_qe - read a single entry from the given queue index
4083 * @pbuffer: The pointer to buffer to copy the read data into.
4084 * @pque: The pointer to the queue to be read.
4085 * @index: The index into the queue entry.
4088 * This routine reads out a single entry from the given queue's index location
4089 * and copies it into the buffer provided.
4092 * This function returns 0 when it fails, otherwise, it returns the length of
4093 * the data read into the buffer provided.
4096 lpfc_idiag_queacc_read_qe(char *pbuffer, int len, struct lpfc_queue *pque,
4102 if (!pbuffer || !pque)
4105 esize = pque->entry_size;
4106 len += scnprintf(pbuffer+len, LPFC_QUE_ACC_BUF_SIZE-len,
4107 "QE-INDEX[%04d]:\n", index);
4110 pentry = lpfc_sli4_qe(pque, index);
4112 len += scnprintf(pbuffer+len, LPFC_QUE_ACC_BUF_SIZE-len,
4115 offset += sizeof(uint32_t);
4116 esize -= sizeof(uint32_t);
4117 if (esize > 0 && !(offset % (4 * sizeof(uint32_t))))
4118 len += scnprintf(pbuffer+len,
4119 LPFC_QUE_ACC_BUF_SIZE-len, "\n");
4121 len += scnprintf(pbuffer+len, LPFC_QUE_ACC_BUF_SIZE-len, "\n");
4127 * lpfc_idiag_queacc_read - idiag debugfs read port queue
4128 * @file: The file pointer to read from.
4129 * @buf: The buffer to copy the data to.
4130 * @nbytes: The number of bytes to read.
4131 * @ppos: The position in the file to start reading from.
4134 * This routine reads data from the @phba device queue memory according to the
4135 * idiag command, and copies to user @buf. Depending on the queue dump read
4136 * command setup, it does either a single queue entry read or browing through
4137 * all entries of the queue.
4140 * This function returns the amount of data that was read (this could be less
4141 * than @nbytes if the end of the file was reached) or a negative error value.
4144 lpfc_idiag_queacc_read(struct file *file, char __user *buf, size_t nbytes,
4147 struct lpfc_debug *debug = file->private_data;
4148 uint32_t last_index, index, count;
4149 struct lpfc_queue *pque = NULL;
4153 /* This is a user read operation */
4154 debug->op = LPFC_IDIAG_OP_RD;
4157 debug->buffer = kmalloc(LPFC_QUE_ACC_BUF_SIZE, GFP_KERNEL);
4160 pbuffer = debug->buffer;
4165 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_QUEACC_RD) {
4166 index = idiag.cmd.data[IDIAG_QUEACC_INDEX_INDX];
4167 count = idiag.cmd.data[IDIAG_QUEACC_COUNT_INDX];
4168 pque = (struct lpfc_queue *)idiag.ptr_private;
4172 /* Browse the queue starting from index */
4173 if (count == LPFC_QUE_ACC_BROWSE)
4176 /* Read a single entry from the queue */
4177 len = lpfc_idiag_queacc_read_qe(pbuffer, len, pque, index);
4179 return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len);
4183 /* Browse all entries from the queue */
4184 last_index = idiag.offset.last_rd;
4187 while (len < LPFC_QUE_ACC_SIZE - pque->entry_size) {
4188 len = lpfc_idiag_queacc_read_qe(pbuffer, len, pque, index);
4190 if (index > pque->entry_count - 1)
4194 /* Set up the offset for next portion of pci cfg read */
4195 if (index > pque->entry_count - 1)
4197 idiag.offset.last_rd = index;
4199 return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len);
4203 * lpfc_idiag_queacc_write - Syntax check and set up idiag queacc commands
4204 * @file: The file pointer to read from.
4205 * @buf: The buffer to copy the user data from.
4206 * @nbytes: The number of bytes to get.
4207 * @ppos: The position in the file to start reading from.
4209 * This routine get the debugfs idiag command struct from user space and then
4210 * perform the syntax check for port queue read (dump) or write (set) command
4211 * accordingly. In the case of port queue read command, it sets up the command
4212 * in the idiag command struct for the following debugfs read operation. In
4213 * the case of port queue write operation, it executes the write operation
4214 * into the port queue entry accordingly.
4216 * It returns the @nbytges passing in from debugfs user space when successful.
4217 * In case of error conditions, it returns proper error code back to the user
4221 lpfc_idiag_queacc_write(struct file *file, const char __user *buf,
4222 size_t nbytes, loff_t *ppos)
4224 struct lpfc_debug *debug = file->private_data;
4225 struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
4226 uint32_t qidx, quetp, queid, index, count, offset, value;
4228 struct lpfc_queue *pque, *qp;
4231 /* This is a user write operation */
4232 debug->op = LPFC_IDIAG_OP_WR;
4234 rc = lpfc_idiag_cmd_get(buf, nbytes, &idiag.cmd);
4238 /* Get and sanity check on command feilds */
4239 quetp = idiag.cmd.data[IDIAG_QUEACC_QUETP_INDX];
4240 queid = idiag.cmd.data[IDIAG_QUEACC_QUEID_INDX];
4241 index = idiag.cmd.data[IDIAG_QUEACC_INDEX_INDX];
4242 count = idiag.cmd.data[IDIAG_QUEACC_COUNT_INDX];
4243 offset = idiag.cmd.data[IDIAG_QUEACC_OFFST_INDX];
4244 value = idiag.cmd.data[IDIAG_QUEACC_VALUE_INDX];
4246 /* Sanity check on command line arguments */
4247 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_QUEACC_WR ||
4248 idiag.cmd.opcode == LPFC_IDIAG_CMD_QUEACC_ST ||
4249 idiag.cmd.opcode == LPFC_IDIAG_CMD_QUEACC_CL) {
4250 if (rc != LPFC_QUE_ACC_WR_CMD_ARG)
4254 } else if (idiag.cmd.opcode == LPFC_IDIAG_CMD_QUEACC_RD) {
4255 if (rc != LPFC_QUE_ACC_RD_CMD_ARG)
4262 /* HBA event queue */
4263 if (phba->sli4_hba.hdwq) {
4264 for (qidx = 0; qidx < phba->cfg_hdw_queue; qidx++) {
4265 qp = phba->sli4_hba.hdwq[qidx].hba_eq;
4266 if (qp && qp->queue_id == queid) {
4268 rc = lpfc_idiag_que_param_check(qp,
4272 idiag.ptr_private = qp;
4280 /* MBX complete queue */
4281 if (phba->sli4_hba.mbx_cq &&
4282 phba->sli4_hba.mbx_cq->queue_id == queid) {
4284 rc = lpfc_idiag_que_param_check(
4285 phba->sli4_hba.mbx_cq, index, count);
4288 idiag.ptr_private = phba->sli4_hba.mbx_cq;
4291 /* ELS complete queue */
4292 if (phba->sli4_hba.els_cq &&
4293 phba->sli4_hba.els_cq->queue_id == queid) {
4295 rc = lpfc_idiag_que_param_check(
4296 phba->sli4_hba.els_cq, index, count);
4299 idiag.ptr_private = phba->sli4_hba.els_cq;
4302 /* NVME LS complete queue */
4303 if (phba->sli4_hba.nvmels_cq &&
4304 phba->sli4_hba.nvmels_cq->queue_id == queid) {
4306 rc = lpfc_idiag_que_param_check(
4307 phba->sli4_hba.nvmels_cq, index, count);
4310 idiag.ptr_private = phba->sli4_hba.nvmels_cq;
4313 /* FCP complete queue */
4314 if (phba->sli4_hba.hdwq) {
4315 for (qidx = 0; qidx < phba->cfg_hdw_queue;
4317 qp = phba->sli4_hba.hdwq[qidx].io_cq;
4318 if (qp && qp->queue_id == queid) {
4320 rc = lpfc_idiag_que_param_check(
4324 idiag.ptr_private = qp;
4332 /* MBX work queue */
4333 if (phba->sli4_hba.mbx_wq &&
4334 phba->sli4_hba.mbx_wq->queue_id == queid) {
4336 rc = lpfc_idiag_que_param_check(
4337 phba->sli4_hba.mbx_wq, index, count);
4340 idiag.ptr_private = phba->sli4_hba.mbx_wq;
4346 /* ELS work queue */
4347 if (phba->sli4_hba.els_wq &&
4348 phba->sli4_hba.els_wq->queue_id == queid) {
4350 rc = lpfc_idiag_que_param_check(
4351 phba->sli4_hba.els_wq, index, count);
4354 idiag.ptr_private = phba->sli4_hba.els_wq;
4357 /* NVME LS work queue */
4358 if (phba->sli4_hba.nvmels_wq &&
4359 phba->sli4_hba.nvmels_wq->queue_id == queid) {
4361 rc = lpfc_idiag_que_param_check(
4362 phba->sli4_hba.nvmels_wq, index, count);
4365 idiag.ptr_private = phba->sli4_hba.nvmels_wq;
4369 if (phba->sli4_hba.hdwq) {
4370 /* FCP/SCSI work queue */
4371 for (qidx = 0; qidx < phba->cfg_hdw_queue; qidx++) {
4372 qp = phba->sli4_hba.hdwq[qidx].io_wq;
4373 if (qp && qp->queue_id == queid) {
4375 rc = lpfc_idiag_que_param_check(
4379 idiag.ptr_private = qp;
4389 if (phba->sli4_hba.hdr_rq &&
4390 phba->sli4_hba.hdr_rq->queue_id == queid) {
4392 rc = lpfc_idiag_que_param_check(
4393 phba->sli4_hba.hdr_rq, index, count);
4396 idiag.ptr_private = phba->sli4_hba.hdr_rq;
4400 if (phba->sli4_hba.dat_rq &&
4401 phba->sli4_hba.dat_rq->queue_id == queid) {
4403 rc = lpfc_idiag_que_param_check(
4404 phba->sli4_hba.dat_rq, index, count);
4407 idiag.ptr_private = phba->sli4_hba.dat_rq;
4419 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_QUEACC_RD) {
4420 if (count == LPFC_QUE_ACC_BROWSE)
4421 idiag.offset.last_rd = index;
4424 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_QUEACC_WR ||
4425 idiag.cmd.opcode == LPFC_IDIAG_CMD_QUEACC_ST ||
4426 idiag.cmd.opcode == LPFC_IDIAG_CMD_QUEACC_CL) {
4427 /* Additional sanity checks on write operation */
4428 pque = (struct lpfc_queue *)idiag.ptr_private;
4429 if (offset > pque->entry_size/sizeof(uint32_t) - 1)
4431 pentry = lpfc_sli4_qe(pque, index);
4433 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_QUEACC_WR)
4435 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_QUEACC_ST)
4437 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_QUEACC_CL)
4443 /* Clean out command structure on command error out */
4444 memset(&idiag, 0, sizeof(idiag));
4449 * lpfc_idiag_drbacc_read_reg - idiag debugfs read a doorbell register
4450 * @phba: The pointer to hba structure.
4451 * @pbuffer: The pointer to the buffer to copy the data to.
4452 * @len: The length of bytes to copied.
4453 * @drbregid: The id to doorbell registers.
4456 * This routine reads a doorbell register and copies its content to the
4457 * user buffer pointed to by @pbuffer.
4460 * This function returns the amount of data that was copied into @pbuffer.
4463 lpfc_idiag_drbacc_read_reg(struct lpfc_hba *phba, char *pbuffer,
4464 int len, uint32_t drbregid)
4472 len += scnprintf(pbuffer + len, LPFC_DRB_ACC_BUF_SIZE-len,
4473 "EQ-DRB-REG: 0x%08x\n",
4474 readl(phba->sli4_hba.EQDBregaddr));
4477 len += scnprintf(pbuffer + len, LPFC_DRB_ACC_BUF_SIZE - len,
4478 "CQ-DRB-REG: 0x%08x\n",
4479 readl(phba->sli4_hba.CQDBregaddr));
4482 len += scnprintf(pbuffer+len, LPFC_DRB_ACC_BUF_SIZE-len,
4483 "MQ-DRB-REG: 0x%08x\n",
4484 readl(phba->sli4_hba.MQDBregaddr));
4487 len += scnprintf(pbuffer+len, LPFC_DRB_ACC_BUF_SIZE-len,
4488 "WQ-DRB-REG: 0x%08x\n",
4489 readl(phba->sli4_hba.WQDBregaddr));
4492 len += scnprintf(pbuffer+len, LPFC_DRB_ACC_BUF_SIZE-len,
4493 "RQ-DRB-REG: 0x%08x\n",
4494 readl(phba->sli4_hba.RQDBregaddr));
4504 * lpfc_idiag_drbacc_read - idiag debugfs read port doorbell
4505 * @file: The file pointer to read from.
4506 * @buf: The buffer to copy the data to.
4507 * @nbytes: The number of bytes to read.
4508 * @ppos: The position in the file to start reading from.
4511 * This routine reads data from the @phba device doorbell register according
4512 * to the idiag command, and copies to user @buf. Depending on the doorbell
4513 * register read command setup, it does either a single doorbell register
4514 * read or dump all doorbell registers.
4517 * This function returns the amount of data that was read (this could be less
4518 * than @nbytes if the end of the file was reached) or a negative error value.
4521 lpfc_idiag_drbacc_read(struct file *file, char __user *buf, size_t nbytes,
4524 struct lpfc_debug *debug = file->private_data;
4525 struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
4526 uint32_t drb_reg_id, i;
4530 /* This is a user read operation */
4531 debug->op = LPFC_IDIAG_OP_RD;
4534 debug->buffer = kmalloc(LPFC_DRB_ACC_BUF_SIZE, GFP_KERNEL);
4537 pbuffer = debug->buffer;
4542 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_DRBACC_RD)
4543 drb_reg_id = idiag.cmd.data[IDIAG_DRBACC_REGID_INDX];
4547 if (drb_reg_id == LPFC_DRB_ACC_ALL)
4548 for (i = 1; i <= LPFC_DRB_MAX; i++)
4549 len = lpfc_idiag_drbacc_read_reg(phba,
4552 len = lpfc_idiag_drbacc_read_reg(phba,
4553 pbuffer, len, drb_reg_id);
4555 return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len);
4559 * lpfc_idiag_drbacc_write - Syntax check and set up idiag drbacc commands
4560 * @file: The file pointer to read from.
4561 * @buf: The buffer to copy the user data from.
4562 * @nbytes: The number of bytes to get.
4563 * @ppos: The position in the file to start reading from.
4565 * This routine get the debugfs idiag command struct from user space and then
4566 * perform the syntax check for port doorbell register read (dump) or write
4567 * (set) command accordingly. In the case of port queue read command, it sets
4568 * up the command in the idiag command struct for the following debugfs read
4569 * operation. In the case of port doorbell register write operation, it
4570 * executes the write operation into the port doorbell register accordingly.
4572 * It returns the @nbytges passing in from debugfs user space when successful.
4573 * In case of error conditions, it returns proper error code back to the user
4577 lpfc_idiag_drbacc_write(struct file *file, const char __user *buf,
4578 size_t nbytes, loff_t *ppos)
4580 struct lpfc_debug *debug = file->private_data;
4581 struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
4582 uint32_t drb_reg_id, value, reg_val = 0;
4583 void __iomem *drb_reg;
4586 /* This is a user write operation */
4587 debug->op = LPFC_IDIAG_OP_WR;
4589 rc = lpfc_idiag_cmd_get(buf, nbytes, &idiag.cmd);
4593 /* Sanity check on command line arguments */
4594 drb_reg_id = idiag.cmd.data[IDIAG_DRBACC_REGID_INDX];
4595 value = idiag.cmd.data[IDIAG_DRBACC_VALUE_INDX];
4597 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_DRBACC_WR ||
4598 idiag.cmd.opcode == LPFC_IDIAG_CMD_DRBACC_ST ||
4599 idiag.cmd.opcode == LPFC_IDIAG_CMD_DRBACC_CL) {
4600 if (rc != LPFC_DRB_ACC_WR_CMD_ARG)
4602 if (drb_reg_id > LPFC_DRB_MAX)
4604 } else if (idiag.cmd.opcode == LPFC_IDIAG_CMD_DRBACC_RD) {
4605 if (rc != LPFC_DRB_ACC_RD_CMD_ARG)
4607 if ((drb_reg_id > LPFC_DRB_MAX) &&
4608 (drb_reg_id != LPFC_DRB_ACC_ALL))
4613 /* Perform the write access operation */
4614 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_DRBACC_WR ||
4615 idiag.cmd.opcode == LPFC_IDIAG_CMD_DRBACC_ST ||
4616 idiag.cmd.opcode == LPFC_IDIAG_CMD_DRBACC_CL) {
4617 switch (drb_reg_id) {
4619 drb_reg = phba->sli4_hba.EQDBregaddr;
4622 drb_reg = phba->sli4_hba.CQDBregaddr;
4625 drb_reg = phba->sli4_hba.MQDBregaddr;
4628 drb_reg = phba->sli4_hba.WQDBregaddr;
4631 drb_reg = phba->sli4_hba.RQDBregaddr;
4637 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_DRBACC_WR)
4639 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_DRBACC_ST) {
4640 reg_val = readl(drb_reg);
4643 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_DRBACC_CL) {
4644 reg_val = readl(drb_reg);
4647 writel(reg_val, drb_reg);
4648 readl(drb_reg); /* flush */
4653 /* Clean out command structure on command error out */
4654 memset(&idiag, 0, sizeof(idiag));
4659 * lpfc_idiag_ctlacc_read_reg - idiag debugfs read a control registers
4660 * @phba: The pointer to hba structure.
4661 * @pbuffer: The pointer to the buffer to copy the data to.
4662 * @len: The length of bytes to copied.
4663 * @drbregid: The id to doorbell registers.
4666 * This routine reads a control register and copies its content to the
4667 * user buffer pointed to by @pbuffer.
4670 * This function returns the amount of data that was copied into @pbuffer.
4673 lpfc_idiag_ctlacc_read_reg(struct lpfc_hba *phba, char *pbuffer,
4674 int len, uint32_t ctlregid)
4681 case LPFC_CTL_PORT_SEM:
4682 len += scnprintf(pbuffer+len, LPFC_CTL_ACC_BUF_SIZE-len,
4683 "Port SemReg: 0x%08x\n",
4684 readl(phba->sli4_hba.conf_regs_memmap_p +
4685 LPFC_CTL_PORT_SEM_OFFSET));
4687 case LPFC_CTL_PORT_STA:
4688 len += scnprintf(pbuffer+len, LPFC_CTL_ACC_BUF_SIZE-len,
4689 "Port StaReg: 0x%08x\n",
4690 readl(phba->sli4_hba.conf_regs_memmap_p +
4691 LPFC_CTL_PORT_STA_OFFSET));
4693 case LPFC_CTL_PORT_CTL:
4694 len += scnprintf(pbuffer+len, LPFC_CTL_ACC_BUF_SIZE-len,
4695 "Port CtlReg: 0x%08x\n",
4696 readl(phba->sli4_hba.conf_regs_memmap_p +
4697 LPFC_CTL_PORT_CTL_OFFSET));
4699 case LPFC_CTL_PORT_ER1:
4700 len += scnprintf(pbuffer+len, LPFC_CTL_ACC_BUF_SIZE-len,
4701 "Port Er1Reg: 0x%08x\n",
4702 readl(phba->sli4_hba.conf_regs_memmap_p +
4703 LPFC_CTL_PORT_ER1_OFFSET));
4705 case LPFC_CTL_PORT_ER2:
4706 len += scnprintf(pbuffer+len, LPFC_CTL_ACC_BUF_SIZE-len,
4707 "Port Er2Reg: 0x%08x\n",
4708 readl(phba->sli4_hba.conf_regs_memmap_p +
4709 LPFC_CTL_PORT_ER2_OFFSET));
4711 case LPFC_CTL_PDEV_CTL:
4712 len += scnprintf(pbuffer+len, LPFC_CTL_ACC_BUF_SIZE-len,
4713 "PDev CtlReg: 0x%08x\n",
4714 readl(phba->sli4_hba.conf_regs_memmap_p +
4715 LPFC_CTL_PDEV_CTL_OFFSET));
4724 * lpfc_idiag_ctlacc_read - idiag debugfs read port and device control register
4725 * @file: The file pointer to read from.
4726 * @buf: The buffer to copy the data to.
4727 * @nbytes: The number of bytes to read.
4728 * @ppos: The position in the file to start reading from.
4731 * This routine reads data from the @phba port and device registers according
4732 * to the idiag command, and copies to user @buf.
4735 * This function returns the amount of data that was read (this could be less
4736 * than @nbytes if the end of the file was reached) or a negative error value.
4739 lpfc_idiag_ctlacc_read(struct file *file, char __user *buf, size_t nbytes,
4742 struct lpfc_debug *debug = file->private_data;
4743 struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
4744 uint32_t ctl_reg_id, i;
4748 /* This is a user read operation */
4749 debug->op = LPFC_IDIAG_OP_RD;
4752 debug->buffer = kmalloc(LPFC_CTL_ACC_BUF_SIZE, GFP_KERNEL);
4755 pbuffer = debug->buffer;
4760 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_CTLACC_RD)
4761 ctl_reg_id = idiag.cmd.data[IDIAG_CTLACC_REGID_INDX];
4765 if (ctl_reg_id == LPFC_CTL_ACC_ALL)
4766 for (i = 1; i <= LPFC_CTL_MAX; i++)
4767 len = lpfc_idiag_ctlacc_read_reg(phba,
4770 len = lpfc_idiag_ctlacc_read_reg(phba,
4771 pbuffer, len, ctl_reg_id);
4773 return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len);
4777 * lpfc_idiag_ctlacc_write - Syntax check and set up idiag ctlacc commands
4778 * @file: The file pointer to read from.
4779 * @buf: The buffer to copy the user data from.
4780 * @nbytes: The number of bytes to get.
4781 * @ppos: The position in the file to start reading from.
4783 * This routine get the debugfs idiag command struct from user space and then
4784 * perform the syntax check for port and device control register read (dump)
4785 * or write (set) command accordingly.
4787 * It returns the @nbytges passing in from debugfs user space when successful.
4788 * In case of error conditions, it returns proper error code back to the user
4792 lpfc_idiag_ctlacc_write(struct file *file, const char __user *buf,
4793 size_t nbytes, loff_t *ppos)
4795 struct lpfc_debug *debug = file->private_data;
4796 struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
4797 uint32_t ctl_reg_id, value, reg_val = 0;
4798 void __iomem *ctl_reg;
4801 /* This is a user write operation */
4802 debug->op = LPFC_IDIAG_OP_WR;
4804 rc = lpfc_idiag_cmd_get(buf, nbytes, &idiag.cmd);
4808 /* Sanity check on command line arguments */
4809 ctl_reg_id = idiag.cmd.data[IDIAG_CTLACC_REGID_INDX];
4810 value = idiag.cmd.data[IDIAG_CTLACC_VALUE_INDX];
4812 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_CTLACC_WR ||
4813 idiag.cmd.opcode == LPFC_IDIAG_CMD_CTLACC_ST ||
4814 idiag.cmd.opcode == LPFC_IDIAG_CMD_CTLACC_CL) {
4815 if (rc != LPFC_CTL_ACC_WR_CMD_ARG)
4817 if (ctl_reg_id > LPFC_CTL_MAX)
4819 } else if (idiag.cmd.opcode == LPFC_IDIAG_CMD_CTLACC_RD) {
4820 if (rc != LPFC_CTL_ACC_RD_CMD_ARG)
4822 if ((ctl_reg_id > LPFC_CTL_MAX) &&
4823 (ctl_reg_id != LPFC_CTL_ACC_ALL))
4828 /* Perform the write access operation */
4829 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_CTLACC_WR ||
4830 idiag.cmd.opcode == LPFC_IDIAG_CMD_CTLACC_ST ||
4831 idiag.cmd.opcode == LPFC_IDIAG_CMD_CTLACC_CL) {
4832 switch (ctl_reg_id) {
4833 case LPFC_CTL_PORT_SEM:
4834 ctl_reg = phba->sli4_hba.conf_regs_memmap_p +
4835 LPFC_CTL_PORT_SEM_OFFSET;
4837 case LPFC_CTL_PORT_STA:
4838 ctl_reg = phba->sli4_hba.conf_regs_memmap_p +
4839 LPFC_CTL_PORT_STA_OFFSET;
4841 case LPFC_CTL_PORT_CTL:
4842 ctl_reg = phba->sli4_hba.conf_regs_memmap_p +
4843 LPFC_CTL_PORT_CTL_OFFSET;
4845 case LPFC_CTL_PORT_ER1:
4846 ctl_reg = phba->sli4_hba.conf_regs_memmap_p +
4847 LPFC_CTL_PORT_ER1_OFFSET;
4849 case LPFC_CTL_PORT_ER2:
4850 ctl_reg = phba->sli4_hba.conf_regs_memmap_p +
4851 LPFC_CTL_PORT_ER2_OFFSET;
4853 case LPFC_CTL_PDEV_CTL:
4854 ctl_reg = phba->sli4_hba.conf_regs_memmap_p +
4855 LPFC_CTL_PDEV_CTL_OFFSET;
4861 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_CTLACC_WR)
4863 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_CTLACC_ST) {
4864 reg_val = readl(ctl_reg);
4867 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_CTLACC_CL) {
4868 reg_val = readl(ctl_reg);
4871 writel(reg_val, ctl_reg);
4872 readl(ctl_reg); /* flush */
4877 /* Clean out command structure on command error out */
4878 memset(&idiag, 0, sizeof(idiag));
4883 * lpfc_idiag_mbxacc_get_setup - idiag debugfs get mailbox access setup
4884 * @phba: Pointer to HBA context object.
4885 * @pbuffer: Pointer to data buffer.
4888 * This routine gets the driver mailbox access debugfs setup information.
4891 * This function returns the amount of data that was read (this could be less
4892 * than @nbytes if the end of the file was reached) or a negative error value.
4895 lpfc_idiag_mbxacc_get_setup(struct lpfc_hba *phba, char *pbuffer)
4897 uint32_t mbx_dump_map, mbx_dump_cnt, mbx_word_cnt, mbx_mbox_cmd;
4900 mbx_mbox_cmd = idiag.cmd.data[IDIAG_MBXACC_MBCMD_INDX];
4901 mbx_dump_map = idiag.cmd.data[IDIAG_MBXACC_DPMAP_INDX];
4902 mbx_dump_cnt = idiag.cmd.data[IDIAG_MBXACC_DPCNT_INDX];
4903 mbx_word_cnt = idiag.cmd.data[IDIAG_MBXACC_WDCNT_INDX];
4905 len += scnprintf(pbuffer+len, LPFC_MBX_ACC_BUF_SIZE-len,
4906 "mbx_dump_map: 0x%08x\n", mbx_dump_map);
4907 len += scnprintf(pbuffer+len, LPFC_MBX_ACC_BUF_SIZE-len,
4908 "mbx_dump_cnt: %04d\n", mbx_dump_cnt);
4909 len += scnprintf(pbuffer+len, LPFC_MBX_ACC_BUF_SIZE-len,
4910 "mbx_word_cnt: %04d\n", mbx_word_cnt);
4911 len += scnprintf(pbuffer+len, LPFC_MBX_ACC_BUF_SIZE-len,
4912 "mbx_mbox_cmd: 0x%02x\n", mbx_mbox_cmd);
4918 * lpfc_idiag_mbxacc_read - idiag debugfs read on mailbox access
4919 * @file: The file pointer to read from.
4920 * @buf: The buffer to copy the data to.
4921 * @nbytes: The number of bytes to read.
4922 * @ppos: The position in the file to start reading from.
4925 * This routine reads data from the @phba driver mailbox access debugfs setup
4929 * This function returns the amount of data that was read (this could be less
4930 * than @nbytes if the end of the file was reached) or a negative error value.
4933 lpfc_idiag_mbxacc_read(struct file *file, char __user *buf, size_t nbytes,
4936 struct lpfc_debug *debug = file->private_data;
4937 struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
4941 /* This is a user read operation */
4942 debug->op = LPFC_IDIAG_OP_RD;
4945 debug->buffer = kmalloc(LPFC_MBX_ACC_BUF_SIZE, GFP_KERNEL);
4948 pbuffer = debug->buffer;
4953 if ((idiag.cmd.opcode != LPFC_IDIAG_CMD_MBXACC_DP) &&
4954 (idiag.cmd.opcode != LPFC_IDIAG_BSG_MBXACC_DP))
4957 len = lpfc_idiag_mbxacc_get_setup(phba, pbuffer);
4959 return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len);
4963 * lpfc_idiag_mbxacc_write - Syntax check and set up idiag mbxacc commands
4964 * @file: The file pointer to read from.
4965 * @buf: The buffer to copy the user data from.
4966 * @nbytes: The number of bytes to get.
4967 * @ppos: The position in the file to start reading from.
4969 * This routine get the debugfs idiag command struct from user space and then
4970 * perform the syntax check for driver mailbox command (dump) and sets up the
4971 * necessary states in the idiag command struct accordingly.
4973 * It returns the @nbytges passing in from debugfs user space when successful.
4974 * In case of error conditions, it returns proper error code back to the user
4978 lpfc_idiag_mbxacc_write(struct file *file, const char __user *buf,
4979 size_t nbytes, loff_t *ppos)
4981 struct lpfc_debug *debug = file->private_data;
4982 uint32_t mbx_dump_map, mbx_dump_cnt, mbx_word_cnt, mbx_mbox_cmd;
4985 /* This is a user write operation */
4986 debug->op = LPFC_IDIAG_OP_WR;
4988 rc = lpfc_idiag_cmd_get(buf, nbytes, &idiag.cmd);
4992 /* Sanity check on command line arguments */
4993 mbx_mbox_cmd = idiag.cmd.data[IDIAG_MBXACC_MBCMD_INDX];
4994 mbx_dump_map = idiag.cmd.data[IDIAG_MBXACC_DPMAP_INDX];
4995 mbx_dump_cnt = idiag.cmd.data[IDIAG_MBXACC_DPCNT_INDX];
4996 mbx_word_cnt = idiag.cmd.data[IDIAG_MBXACC_WDCNT_INDX];
4998 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_MBXACC_DP) {
4999 if (!(mbx_dump_map & LPFC_MBX_DMP_MBX_ALL))
5001 if ((mbx_dump_map & ~LPFC_MBX_DMP_MBX_ALL) &&
5002 (mbx_dump_map != LPFC_MBX_DMP_ALL))
5004 if (mbx_word_cnt > sizeof(MAILBOX_t))
5006 } else if (idiag.cmd.opcode == LPFC_IDIAG_BSG_MBXACC_DP) {
5007 if (!(mbx_dump_map & LPFC_BSG_DMP_MBX_ALL))
5009 if ((mbx_dump_map & ~LPFC_BSG_DMP_MBX_ALL) &&
5010 (mbx_dump_map != LPFC_MBX_DMP_ALL))
5012 if (mbx_word_cnt > (BSG_MBOX_SIZE)/4)
5014 if (mbx_mbox_cmd != 0x9b)
5019 if (mbx_word_cnt == 0)
5021 if (rc != LPFC_MBX_DMP_ARG)
5023 if (mbx_mbox_cmd & ~0xff)
5026 /* condition for stop mailbox dump */
5027 if (mbx_dump_cnt == 0)
5033 /* Clean out command structure on command error out */
5034 memset(&idiag, 0, sizeof(idiag));
5038 /* Clean out command structure on command error out */
5039 memset(&idiag, 0, sizeof(idiag));
5044 * lpfc_idiag_extacc_avail_get - get the available extents information
5045 * @phba: pointer to lpfc hba data structure.
5046 * @pbuffer: pointer to internal buffer.
5047 * @len: length into the internal buffer data has been copied.
5050 * This routine is to get the available extent information.
5053 * overall lenth of the data read into the internal buffer.
5056 lpfc_idiag_extacc_avail_get(struct lpfc_hba *phba, char *pbuffer, int len)
5058 uint16_t ext_cnt, ext_size;
5060 len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
5061 "\nAvailable Extents Information:\n");
5063 len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
5064 "\tPort Available VPI extents: ");
5065 lpfc_sli4_get_avail_extnt_rsrc(phba, LPFC_RSC_TYPE_FCOE_VPI,
5066 &ext_cnt, &ext_size);
5067 len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
5068 "Count %3d, Size %3d\n", ext_cnt, ext_size);
5070 len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
5071 "\tPort Available VFI extents: ");
5072 lpfc_sli4_get_avail_extnt_rsrc(phba, LPFC_RSC_TYPE_FCOE_VFI,
5073 &ext_cnt, &ext_size);
5074 len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
5075 "Count %3d, Size %3d\n", ext_cnt, ext_size);
5077 len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
5078 "\tPort Available RPI extents: ");
5079 lpfc_sli4_get_avail_extnt_rsrc(phba, LPFC_RSC_TYPE_FCOE_RPI,
5080 &ext_cnt, &ext_size);
5081 len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
5082 "Count %3d, Size %3d\n", ext_cnt, ext_size);
5084 len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
5085 "\tPort Available XRI extents: ");
5086 lpfc_sli4_get_avail_extnt_rsrc(phba, LPFC_RSC_TYPE_FCOE_XRI,
5087 &ext_cnt, &ext_size);
5088 len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
5089 "Count %3d, Size %3d\n", ext_cnt, ext_size);
5095 * lpfc_idiag_extacc_alloc_get - get the allocated extents information
5096 * @phba: pointer to lpfc hba data structure.
5097 * @pbuffer: pointer to internal buffer.
5098 * @len: length into the internal buffer data has been copied.
5101 * This routine is to get the allocated extent information.
5104 * overall lenth of the data read into the internal buffer.
5107 lpfc_idiag_extacc_alloc_get(struct lpfc_hba *phba, char *pbuffer, int len)
5109 uint16_t ext_cnt, ext_size;
5112 len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
5113 "\nAllocated Extents Information:\n");
5115 len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
5116 "\tHost Allocated VPI extents: ");
5117 rc = lpfc_sli4_get_allocated_extnts(phba, LPFC_RSC_TYPE_FCOE_VPI,
5118 &ext_cnt, &ext_size);
5120 len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
5121 "Port %d Extent %3d, Size %3d\n",
5122 phba->brd_no, ext_cnt, ext_size);
5124 len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
5127 len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
5128 "\tHost Allocated VFI extents: ");
5129 rc = lpfc_sli4_get_allocated_extnts(phba, LPFC_RSC_TYPE_FCOE_VFI,
5130 &ext_cnt, &ext_size);
5132 len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
5133 "Port %d Extent %3d, Size %3d\n",
5134 phba->brd_no, ext_cnt, ext_size);
5136 len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
5139 len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
5140 "\tHost Allocated RPI extents: ");
5141 rc = lpfc_sli4_get_allocated_extnts(phba, LPFC_RSC_TYPE_FCOE_RPI,
5142 &ext_cnt, &ext_size);
5144 len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
5145 "Port %d Extent %3d, Size %3d\n",
5146 phba->brd_no, ext_cnt, ext_size);
5148 len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
5151 len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
5152 "\tHost Allocated XRI extents: ");
5153 rc = lpfc_sli4_get_allocated_extnts(phba, LPFC_RSC_TYPE_FCOE_XRI,
5154 &ext_cnt, &ext_size);
5156 len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
5157 "Port %d Extent %3d, Size %3d\n",
5158 phba->brd_no, ext_cnt, ext_size);
5160 len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
5167 * lpfc_idiag_extacc_drivr_get - get driver extent information
5168 * @phba: pointer to lpfc hba data structure.
5169 * @pbuffer: pointer to internal buffer.
5170 * @len: length into the internal buffer data has been copied.
5173 * This routine is to get the driver extent information.
5176 * overall lenth of the data read into the internal buffer.
5179 lpfc_idiag_extacc_drivr_get(struct lpfc_hba *phba, char *pbuffer, int len)
5181 struct lpfc_rsrc_blks *rsrc_blks;
5184 len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
5185 "\nDriver Extents Information:\n");
5187 len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
5188 "\tVPI extents:\n");
5190 list_for_each_entry(rsrc_blks, &phba->lpfc_vpi_blk_list, list) {
5191 len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
5192 "\t\tBlock %3d: Start %4d, Count %4d\n",
5193 index, rsrc_blks->rsrc_start,
5194 rsrc_blks->rsrc_size);
5197 len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
5198 "\tVFI extents:\n");
5200 list_for_each_entry(rsrc_blks, &phba->sli4_hba.lpfc_vfi_blk_list,
5202 len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
5203 "\t\tBlock %3d: Start %4d, Count %4d\n",
5204 index, rsrc_blks->rsrc_start,
5205 rsrc_blks->rsrc_size);
5209 len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
5210 "\tRPI extents:\n");
5212 list_for_each_entry(rsrc_blks, &phba->sli4_hba.lpfc_rpi_blk_list,
5214 len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
5215 "\t\tBlock %3d: Start %4d, Count %4d\n",
5216 index, rsrc_blks->rsrc_start,
5217 rsrc_blks->rsrc_size);
5221 len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
5222 "\tXRI extents:\n");
5224 list_for_each_entry(rsrc_blks, &phba->sli4_hba.lpfc_xri_blk_list,
5226 len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
5227 "\t\tBlock %3d: Start %4d, Count %4d\n",
5228 index, rsrc_blks->rsrc_start,
5229 rsrc_blks->rsrc_size);
5237 * lpfc_idiag_extacc_write - Syntax check and set up idiag extacc commands
5238 * @file: The file pointer to read from.
5239 * @buf: The buffer to copy the user data from.
5240 * @nbytes: The number of bytes to get.
5241 * @ppos: The position in the file to start reading from.
5243 * This routine get the debugfs idiag command struct from user space and then
5244 * perform the syntax check for extent information access commands and sets
5245 * up the necessary states in the idiag command struct accordingly.
5247 * It returns the @nbytges passing in from debugfs user space when successful.
5248 * In case of error conditions, it returns proper error code back to the user
5252 lpfc_idiag_extacc_write(struct file *file, const char __user *buf,
5253 size_t nbytes, loff_t *ppos)
5255 struct lpfc_debug *debug = file->private_data;
5259 /* This is a user write operation */
5260 debug->op = LPFC_IDIAG_OP_WR;
5262 rc = lpfc_idiag_cmd_get(buf, nbytes, &idiag.cmd);
5266 ext_map = idiag.cmd.data[IDIAG_EXTACC_EXMAP_INDX];
5268 if (idiag.cmd.opcode != LPFC_IDIAG_CMD_EXTACC_RD)
5270 if (rc != LPFC_EXT_ACC_CMD_ARG)
5272 if (!(ext_map & LPFC_EXT_ACC_ALL))
5277 /* Clean out command structure on command error out */
5278 memset(&idiag, 0, sizeof(idiag));
5283 * lpfc_idiag_extacc_read - idiag debugfs read access to extent information
5284 * @file: The file pointer to read from.
5285 * @buf: The buffer to copy the data to.
5286 * @nbytes: The number of bytes to read.
5287 * @ppos: The position in the file to start reading from.
5290 * This routine reads data from the proper extent information according to
5291 * the idiag command, and copies to user @buf.
5294 * This function returns the amount of data that was read (this could be less
5295 * than @nbytes if the end of the file was reached) or a negative error value.
5298 lpfc_idiag_extacc_read(struct file *file, char __user *buf, size_t nbytes,
5301 struct lpfc_debug *debug = file->private_data;
5302 struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
5307 /* This is a user read operation */
5308 debug->op = LPFC_IDIAG_OP_RD;
5311 debug->buffer = kmalloc(LPFC_EXT_ACC_BUF_SIZE, GFP_KERNEL);
5314 pbuffer = debug->buffer;
5317 if (idiag.cmd.opcode != LPFC_IDIAG_CMD_EXTACC_RD)
5320 ext_map = idiag.cmd.data[IDIAG_EXTACC_EXMAP_INDX];
5321 if (ext_map & LPFC_EXT_ACC_AVAIL)
5322 len = lpfc_idiag_extacc_avail_get(phba, pbuffer, len);
5323 if (ext_map & LPFC_EXT_ACC_ALLOC)
5324 len = lpfc_idiag_extacc_alloc_get(phba, pbuffer, len);
5325 if (ext_map & LPFC_EXT_ACC_DRIVR)
5326 len = lpfc_idiag_extacc_drivr_get(phba, pbuffer, len);
5328 return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len);
5331 #undef lpfc_debugfs_op_disc_trc
5332 static const struct file_operations lpfc_debugfs_op_disc_trc = {
5333 .owner = THIS_MODULE,
5334 .open = lpfc_debugfs_disc_trc_open,
5335 .llseek = lpfc_debugfs_lseek,
5336 .read = lpfc_debugfs_read,
5337 .release = lpfc_debugfs_release,
5340 #undef lpfc_debugfs_op_nodelist
5341 static const struct file_operations lpfc_debugfs_op_nodelist = {
5342 .owner = THIS_MODULE,
5343 .open = lpfc_debugfs_nodelist_open,
5344 .llseek = lpfc_debugfs_lseek,
5345 .read = lpfc_debugfs_read,
5346 .release = lpfc_debugfs_release,
5349 #undef lpfc_debugfs_op_multixripools
5350 static const struct file_operations lpfc_debugfs_op_multixripools = {
5351 .owner = THIS_MODULE,
5352 .open = lpfc_debugfs_multixripools_open,
5353 .llseek = lpfc_debugfs_lseek,
5354 .read = lpfc_debugfs_read,
5355 .write = lpfc_debugfs_multixripools_write,
5356 .release = lpfc_debugfs_release,
5359 #undef lpfc_debugfs_op_hbqinfo
5360 static const struct file_operations lpfc_debugfs_op_hbqinfo = {
5361 .owner = THIS_MODULE,
5362 .open = lpfc_debugfs_hbqinfo_open,
5363 .llseek = lpfc_debugfs_lseek,
5364 .read = lpfc_debugfs_read,
5365 .release = lpfc_debugfs_release,
5368 #ifdef LPFC_HDWQ_LOCK_STAT
5369 #undef lpfc_debugfs_op_lockstat
5370 static const struct file_operations lpfc_debugfs_op_lockstat = {
5371 .owner = THIS_MODULE,
5372 .open = lpfc_debugfs_lockstat_open,
5373 .llseek = lpfc_debugfs_lseek,
5374 .read = lpfc_debugfs_read,
5375 .write = lpfc_debugfs_lockstat_write,
5376 .release = lpfc_debugfs_release,
5380 #undef lpfc_debugfs_ras_log
5381 static const struct file_operations lpfc_debugfs_ras_log = {
5382 .owner = THIS_MODULE,
5383 .open = lpfc_debugfs_ras_log_open,
5384 .llseek = lpfc_debugfs_lseek,
5385 .read = lpfc_debugfs_read,
5386 .release = lpfc_debugfs_ras_log_release,
5389 #undef lpfc_debugfs_op_dumpHBASlim
5390 static const struct file_operations lpfc_debugfs_op_dumpHBASlim = {
5391 .owner = THIS_MODULE,
5392 .open = lpfc_debugfs_dumpHBASlim_open,
5393 .llseek = lpfc_debugfs_lseek,
5394 .read = lpfc_debugfs_read,
5395 .release = lpfc_debugfs_release,
5398 #undef lpfc_debugfs_op_dumpHostSlim
5399 static const struct file_operations lpfc_debugfs_op_dumpHostSlim = {
5400 .owner = THIS_MODULE,
5401 .open = lpfc_debugfs_dumpHostSlim_open,
5402 .llseek = lpfc_debugfs_lseek,
5403 .read = lpfc_debugfs_read,
5404 .release = lpfc_debugfs_release,
5407 #undef lpfc_debugfs_op_nvmestat
5408 static const struct file_operations lpfc_debugfs_op_nvmestat = {
5409 .owner = THIS_MODULE,
5410 .open = lpfc_debugfs_nvmestat_open,
5411 .llseek = lpfc_debugfs_lseek,
5412 .read = lpfc_debugfs_read,
5413 .write = lpfc_debugfs_nvmestat_write,
5414 .release = lpfc_debugfs_release,
5417 #undef lpfc_debugfs_op_scsistat
5418 static const struct file_operations lpfc_debugfs_op_scsistat = {
5419 .owner = THIS_MODULE,
5420 .open = lpfc_debugfs_scsistat_open,
5421 .llseek = lpfc_debugfs_lseek,
5422 .read = lpfc_debugfs_read,
5423 .write = lpfc_debugfs_scsistat_write,
5424 .release = lpfc_debugfs_release,
5427 #undef lpfc_debugfs_op_nvmektime
5428 static const struct file_operations lpfc_debugfs_op_nvmektime = {
5429 .owner = THIS_MODULE,
5430 .open = lpfc_debugfs_nvmektime_open,
5431 .llseek = lpfc_debugfs_lseek,
5432 .read = lpfc_debugfs_read,
5433 .write = lpfc_debugfs_nvmektime_write,
5434 .release = lpfc_debugfs_release,
5437 #undef lpfc_debugfs_op_nvmeio_trc
5438 static const struct file_operations lpfc_debugfs_op_nvmeio_trc = {
5439 .owner = THIS_MODULE,
5440 .open = lpfc_debugfs_nvmeio_trc_open,
5441 .llseek = lpfc_debugfs_lseek,
5442 .read = lpfc_debugfs_read,
5443 .write = lpfc_debugfs_nvmeio_trc_write,
5444 .release = lpfc_debugfs_release,
5447 #undef lpfc_debugfs_op_cpucheck
5448 static const struct file_operations lpfc_debugfs_op_cpucheck = {
5449 .owner = THIS_MODULE,
5450 .open = lpfc_debugfs_cpucheck_open,
5451 .llseek = lpfc_debugfs_lseek,
5452 .read = lpfc_debugfs_read,
5453 .write = lpfc_debugfs_cpucheck_write,
5454 .release = lpfc_debugfs_release,
5457 #undef lpfc_debugfs_op_dif_err
5458 static const struct file_operations lpfc_debugfs_op_dif_err = {
5459 .owner = THIS_MODULE,
5460 .open = simple_open,
5461 .llseek = lpfc_debugfs_lseek,
5462 .read = lpfc_debugfs_dif_err_read,
5463 .write = lpfc_debugfs_dif_err_write,
5464 .release = lpfc_debugfs_dif_err_release,
5467 #undef lpfc_debugfs_op_slow_ring_trc
5468 static const struct file_operations lpfc_debugfs_op_slow_ring_trc = {
5469 .owner = THIS_MODULE,
5470 .open = lpfc_debugfs_slow_ring_trc_open,
5471 .llseek = lpfc_debugfs_lseek,
5472 .read = lpfc_debugfs_read,
5473 .release = lpfc_debugfs_release,
5476 static struct dentry *lpfc_debugfs_root = NULL;
5477 static atomic_t lpfc_debugfs_hba_count;
5480 * File operations for the iDiag debugfs
5482 #undef lpfc_idiag_op_pciCfg
5483 static const struct file_operations lpfc_idiag_op_pciCfg = {
5484 .owner = THIS_MODULE,
5485 .open = lpfc_idiag_open,
5486 .llseek = lpfc_debugfs_lseek,
5487 .read = lpfc_idiag_pcicfg_read,
5488 .write = lpfc_idiag_pcicfg_write,
5489 .release = lpfc_idiag_cmd_release,
5492 #undef lpfc_idiag_op_barAcc
5493 static const struct file_operations lpfc_idiag_op_barAcc = {
5494 .owner = THIS_MODULE,
5495 .open = lpfc_idiag_open,
5496 .llseek = lpfc_debugfs_lseek,
5497 .read = lpfc_idiag_baracc_read,
5498 .write = lpfc_idiag_baracc_write,
5499 .release = lpfc_idiag_cmd_release,
5502 #undef lpfc_idiag_op_queInfo
5503 static const struct file_operations lpfc_idiag_op_queInfo = {
5504 .owner = THIS_MODULE,
5505 .open = lpfc_idiag_open,
5506 .read = lpfc_idiag_queinfo_read,
5507 .release = lpfc_idiag_release,
5510 #undef lpfc_idiag_op_queAcc
5511 static const struct file_operations lpfc_idiag_op_queAcc = {
5512 .owner = THIS_MODULE,
5513 .open = lpfc_idiag_open,
5514 .llseek = lpfc_debugfs_lseek,
5515 .read = lpfc_idiag_queacc_read,
5516 .write = lpfc_idiag_queacc_write,
5517 .release = lpfc_idiag_cmd_release,
5520 #undef lpfc_idiag_op_drbAcc
5521 static const struct file_operations lpfc_idiag_op_drbAcc = {
5522 .owner = THIS_MODULE,
5523 .open = lpfc_idiag_open,
5524 .llseek = lpfc_debugfs_lseek,
5525 .read = lpfc_idiag_drbacc_read,
5526 .write = lpfc_idiag_drbacc_write,
5527 .release = lpfc_idiag_cmd_release,
5530 #undef lpfc_idiag_op_ctlAcc
5531 static const struct file_operations lpfc_idiag_op_ctlAcc = {
5532 .owner = THIS_MODULE,
5533 .open = lpfc_idiag_open,
5534 .llseek = lpfc_debugfs_lseek,
5535 .read = lpfc_idiag_ctlacc_read,
5536 .write = lpfc_idiag_ctlacc_write,
5537 .release = lpfc_idiag_cmd_release,
5540 #undef lpfc_idiag_op_mbxAcc
5541 static const struct file_operations lpfc_idiag_op_mbxAcc = {
5542 .owner = THIS_MODULE,
5543 .open = lpfc_idiag_open,
5544 .llseek = lpfc_debugfs_lseek,
5545 .read = lpfc_idiag_mbxacc_read,
5546 .write = lpfc_idiag_mbxacc_write,
5547 .release = lpfc_idiag_cmd_release,
5550 #undef lpfc_idiag_op_extAcc
5551 static const struct file_operations lpfc_idiag_op_extAcc = {
5552 .owner = THIS_MODULE,
5553 .open = lpfc_idiag_open,
5554 .llseek = lpfc_debugfs_lseek,
5555 .read = lpfc_idiag_extacc_read,
5556 .write = lpfc_idiag_extacc_write,
5557 .release = lpfc_idiag_cmd_release,
5561 /* lpfc_idiag_mbxacc_dump_bsg_mbox - idiag debugfs dump bsg mailbox command
5562 * @phba: Pointer to HBA context object.
5563 * @dmabuf: Pointer to a DMA buffer descriptor.
5566 * This routine dump a bsg pass-through non-embedded mailbox command with
5570 lpfc_idiag_mbxacc_dump_bsg_mbox(struct lpfc_hba *phba, enum nemb_type nemb_tp,
5571 enum mbox_type mbox_tp, enum dma_type dma_tp,
5572 enum sta_type sta_tp,
5573 struct lpfc_dmabuf *dmabuf, uint32_t ext_buf)
5575 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
5576 uint32_t *mbx_mbox_cmd, *mbx_dump_map, *mbx_dump_cnt, *mbx_word_cnt;
5577 char line_buf[LPFC_MBX_ACC_LBUF_SZ];
5579 uint32_t do_dump = 0;
5583 if (idiag.cmd.opcode != LPFC_IDIAG_BSG_MBXACC_DP)
5586 mbx_mbox_cmd = &idiag.cmd.data[IDIAG_MBXACC_MBCMD_INDX];
5587 mbx_dump_map = &idiag.cmd.data[IDIAG_MBXACC_DPMAP_INDX];
5588 mbx_dump_cnt = &idiag.cmd.data[IDIAG_MBXACC_DPCNT_INDX];
5589 mbx_word_cnt = &idiag.cmd.data[IDIAG_MBXACC_WDCNT_INDX];
5591 if (!(*mbx_dump_map & LPFC_MBX_DMP_ALL) ||
5592 (*mbx_dump_cnt == 0) ||
5593 (*mbx_word_cnt == 0))
5596 if (*mbx_mbox_cmd != 0x9B)
5599 if ((mbox_tp == mbox_rd) && (dma_tp == dma_mbox)) {
5600 if (*mbx_dump_map & LPFC_BSG_DMP_MBX_RD_MBX) {
5601 do_dump |= LPFC_BSG_DMP_MBX_RD_MBX;
5602 pr_err("\nRead mbox command (x%x), "
5603 "nemb:0x%x, extbuf_cnt:%d:\n",
5604 sta_tp, nemb_tp, ext_buf);
5607 if ((mbox_tp == mbox_rd) && (dma_tp == dma_ebuf)) {
5608 if (*mbx_dump_map & LPFC_BSG_DMP_MBX_RD_BUF) {
5609 do_dump |= LPFC_BSG_DMP_MBX_RD_BUF;
5610 pr_err("\nRead mbox buffer (x%x), "
5611 "nemb:0x%x, extbuf_seq:%d:\n",
5612 sta_tp, nemb_tp, ext_buf);
5615 if ((mbox_tp == mbox_wr) && (dma_tp == dma_mbox)) {
5616 if (*mbx_dump_map & LPFC_BSG_DMP_MBX_WR_MBX) {
5617 do_dump |= LPFC_BSG_DMP_MBX_WR_MBX;
5618 pr_err("\nWrite mbox command (x%x), "
5619 "nemb:0x%x, extbuf_cnt:%d:\n",
5620 sta_tp, nemb_tp, ext_buf);
5623 if ((mbox_tp == mbox_wr) && (dma_tp == dma_ebuf)) {
5624 if (*mbx_dump_map & LPFC_BSG_DMP_MBX_WR_BUF) {
5625 do_dump |= LPFC_BSG_DMP_MBX_WR_BUF;
5626 pr_err("\nWrite mbox buffer (x%x), "
5627 "nemb:0x%x, extbuf_seq:%d:\n",
5628 sta_tp, nemb_tp, ext_buf);
5632 /* dump buffer content */
5634 pword = (uint32_t *)dmabuf->virt;
5635 for (i = 0; i < *mbx_word_cnt; i++) {
5638 pr_err("%s\n", line_buf);
5640 len += scnprintf(line_buf+len,
5641 LPFC_MBX_ACC_LBUF_SZ-len,
5644 len += scnprintf(line_buf+len, LPFC_MBX_ACC_LBUF_SZ-len,
5645 "%08x ", (uint32_t)*pword);
5649 pr_err("%s\n", line_buf);
5653 /* Clean out command structure on reaching dump count */
5654 if (*mbx_dump_cnt == 0)
5655 memset(&idiag, 0, sizeof(idiag));
5660 /* lpfc_idiag_mbxacc_dump_issue_mbox - idiag debugfs dump issue mailbox command
5661 * @phba: Pointer to HBA context object.
5662 * @dmabuf: Pointer to a DMA buffer descriptor.
5665 * This routine dump a pass-through non-embedded mailbox command from issue
5669 lpfc_idiag_mbxacc_dump_issue_mbox(struct lpfc_hba *phba, MAILBOX_t *pmbox)
5671 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
5672 uint32_t *mbx_dump_map, *mbx_dump_cnt, *mbx_word_cnt, *mbx_mbox_cmd;
5673 char line_buf[LPFC_MBX_ACC_LBUF_SZ];
5679 if (idiag.cmd.opcode != LPFC_IDIAG_CMD_MBXACC_DP)
5682 mbx_mbox_cmd = &idiag.cmd.data[IDIAG_MBXACC_MBCMD_INDX];
5683 mbx_dump_map = &idiag.cmd.data[IDIAG_MBXACC_DPMAP_INDX];
5684 mbx_dump_cnt = &idiag.cmd.data[IDIAG_MBXACC_DPCNT_INDX];
5685 mbx_word_cnt = &idiag.cmd.data[IDIAG_MBXACC_WDCNT_INDX];
5687 if (!(*mbx_dump_map & LPFC_MBX_DMP_MBX_ALL) ||
5688 (*mbx_dump_cnt == 0) ||
5689 (*mbx_word_cnt == 0))
5692 if ((*mbx_mbox_cmd != LPFC_MBX_ALL_CMD) &&
5693 (*mbx_mbox_cmd != pmbox->mbxCommand))
5696 /* dump buffer content */
5697 if (*mbx_dump_map & LPFC_MBX_DMP_MBX_WORD) {
5698 pr_err("Mailbox command:0x%x dump by word:\n",
5700 pword = (uint32_t *)pmbox;
5701 for (i = 0; i < *mbx_word_cnt; i++) {
5704 pr_err("%s\n", line_buf);
5706 memset(line_buf, 0, LPFC_MBX_ACC_LBUF_SZ);
5707 len += scnprintf(line_buf+len,
5708 LPFC_MBX_ACC_LBUF_SZ-len,
5711 len += scnprintf(line_buf+len, LPFC_MBX_ACC_LBUF_SZ-len,
5713 ((uint32_t)*pword) & 0xffffffff);
5717 pr_err("%s\n", line_buf);
5720 if (*mbx_dump_map & LPFC_MBX_DMP_MBX_BYTE) {
5721 pr_err("Mailbox command:0x%x dump by byte:\n",
5723 pbyte = (uint8_t *)pmbox;
5724 for (i = 0; i < *mbx_word_cnt; i++) {
5727 pr_err("%s\n", line_buf);
5729 memset(line_buf, 0, LPFC_MBX_ACC_LBUF_SZ);
5730 len += scnprintf(line_buf+len,
5731 LPFC_MBX_ACC_LBUF_SZ-len,
5734 for (j = 0; j < 4; j++) {
5735 len += scnprintf(line_buf+len,
5736 LPFC_MBX_ACC_LBUF_SZ-len,
5738 ((uint8_t)*pbyte) & 0xff);
5741 len += scnprintf(line_buf+len,
5742 LPFC_MBX_ACC_LBUF_SZ-len, " ");
5745 pr_err("%s\n", line_buf);
5750 /* Clean out command structure on reaching dump count */
5751 if (*mbx_dump_cnt == 0)
5752 memset(&idiag, 0, sizeof(idiag));
5758 * lpfc_debugfs_initialize - Initialize debugfs for a vport
5759 * @vport: The vport pointer to initialize.
5762 * When Debugfs is configured this routine sets up the lpfc debugfs file system.
5763 * If not already created, this routine will create the lpfc directory, and
5764 * lpfcX directory (for this HBA), and vportX directory for this vport. It will
5765 * also create each file used to access lpfc specific debugfs information.
5768 lpfc_debugfs_initialize(struct lpfc_vport *vport)
5770 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
5771 struct lpfc_hba *phba = vport->phba;
5774 bool pport_setup = false;
5776 if (!lpfc_debugfs_enable)
5779 /* Setup lpfc root directory */
5780 if (!lpfc_debugfs_root) {
5781 lpfc_debugfs_root = debugfs_create_dir("lpfc", NULL);
5782 atomic_set(&lpfc_debugfs_hba_count, 0);
5784 if (!lpfc_debugfs_start_time)
5785 lpfc_debugfs_start_time = jiffies;
5787 /* Setup funcX directory for specific HBA PCI function */
5788 snprintf(name, sizeof(name), "fn%d", phba->brd_no);
5789 if (!phba->hba_debugfs_root) {
5791 phba->hba_debugfs_root =
5792 debugfs_create_dir(name, lpfc_debugfs_root);
5793 atomic_inc(&lpfc_debugfs_hba_count);
5794 atomic_set(&phba->debugfs_vport_count, 0);
5796 /* Multi-XRI pools */
5797 snprintf(name, sizeof(name), "multixripools");
5798 phba->debug_multixri_pools =
5799 debugfs_create_file(name, S_IFREG | 0644,
5800 phba->hba_debugfs_root,
5802 &lpfc_debugfs_op_multixripools);
5803 if (!phba->debug_multixri_pools) {
5804 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
5805 "0527 Cannot create debugfs multixripools\n");
5810 snprintf(name, sizeof(name), "ras_log");
5811 phba->debug_ras_log =
5812 debugfs_create_file(name, 0644,
5813 phba->hba_debugfs_root,
5814 phba, &lpfc_debugfs_ras_log);
5815 if (!phba->debug_ras_log) {
5816 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
5817 "6148 Cannot create debugfs"
5823 snprintf(name, sizeof(name), "hbqinfo");
5824 phba->debug_hbqinfo =
5825 debugfs_create_file(name, S_IFREG | 0644,
5826 phba->hba_debugfs_root,
5827 phba, &lpfc_debugfs_op_hbqinfo);
5829 #ifdef LPFC_HDWQ_LOCK_STAT
5830 /* Setup lockstat */
5831 snprintf(name, sizeof(name), "lockstat");
5832 phba->debug_lockstat =
5833 debugfs_create_file(name, S_IFREG | 0644,
5834 phba->hba_debugfs_root,
5835 phba, &lpfc_debugfs_op_lockstat);
5836 if (!phba->debug_lockstat) {
5837 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
5838 "4610 Cant create debugfs lockstat\n");
5843 /* Setup dumpHBASlim */
5844 if (phba->sli_rev < LPFC_SLI_REV4) {
5845 snprintf(name, sizeof(name), "dumpHBASlim");
5846 phba->debug_dumpHBASlim =
5847 debugfs_create_file(name,
5848 S_IFREG|S_IRUGO|S_IWUSR,
5849 phba->hba_debugfs_root,
5850 phba, &lpfc_debugfs_op_dumpHBASlim);
5852 phba->debug_dumpHBASlim = NULL;
5854 /* Setup dumpHostSlim */
5855 if (phba->sli_rev < LPFC_SLI_REV4) {
5856 snprintf(name, sizeof(name), "dumpHostSlim");
5857 phba->debug_dumpHostSlim =
5858 debugfs_create_file(name,
5859 S_IFREG|S_IRUGO|S_IWUSR,
5860 phba->hba_debugfs_root,
5861 phba, &lpfc_debugfs_op_dumpHostSlim);
5863 phba->debug_dumpHostSlim = NULL;
5865 /* Setup DIF Error Injections */
5866 snprintf(name, sizeof(name), "InjErrLBA");
5867 phba->debug_InjErrLBA =
5868 debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
5869 phba->hba_debugfs_root,
5870 phba, &lpfc_debugfs_op_dif_err);
5871 phba->lpfc_injerr_lba = LPFC_INJERR_LBA_OFF;
5873 snprintf(name, sizeof(name), "InjErrNPortID");
5874 phba->debug_InjErrNPortID =
5875 debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
5876 phba->hba_debugfs_root,
5877 phba, &lpfc_debugfs_op_dif_err);
5879 snprintf(name, sizeof(name), "InjErrWWPN");
5880 phba->debug_InjErrWWPN =
5881 debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
5882 phba->hba_debugfs_root,
5883 phba, &lpfc_debugfs_op_dif_err);
5885 snprintf(name, sizeof(name), "writeGuardInjErr");
5886 phba->debug_writeGuard =
5887 debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
5888 phba->hba_debugfs_root,
5889 phba, &lpfc_debugfs_op_dif_err);
5891 snprintf(name, sizeof(name), "writeAppInjErr");
5892 phba->debug_writeApp =
5893 debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
5894 phba->hba_debugfs_root,
5895 phba, &lpfc_debugfs_op_dif_err);
5897 snprintf(name, sizeof(name), "writeRefInjErr");
5898 phba->debug_writeRef =
5899 debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
5900 phba->hba_debugfs_root,
5901 phba, &lpfc_debugfs_op_dif_err);
5903 snprintf(name, sizeof(name), "readGuardInjErr");
5904 phba->debug_readGuard =
5905 debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
5906 phba->hba_debugfs_root,
5907 phba, &lpfc_debugfs_op_dif_err);
5909 snprintf(name, sizeof(name), "readAppInjErr");
5910 phba->debug_readApp =
5911 debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
5912 phba->hba_debugfs_root,
5913 phba, &lpfc_debugfs_op_dif_err);
5915 snprintf(name, sizeof(name), "readRefInjErr");
5916 phba->debug_readRef =
5917 debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
5918 phba->hba_debugfs_root,
5919 phba, &lpfc_debugfs_op_dif_err);
5921 /* Setup slow ring trace */
5922 if (lpfc_debugfs_max_slow_ring_trc) {
5923 num = lpfc_debugfs_max_slow_ring_trc - 1;
5924 if (num & lpfc_debugfs_max_slow_ring_trc) {
5925 /* Change to be a power of 2 */
5926 num = lpfc_debugfs_max_slow_ring_trc;
5932 lpfc_debugfs_max_slow_ring_trc = (1 << i);
5933 pr_err("lpfc_debugfs_max_disc_trc changed to "
5934 "%d\n", lpfc_debugfs_max_disc_trc);
5938 snprintf(name, sizeof(name), "slow_ring_trace");
5939 phba->debug_slow_ring_trc =
5940 debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
5941 phba->hba_debugfs_root,
5942 phba, &lpfc_debugfs_op_slow_ring_trc);
5943 if (!phba->slow_ring_trc) {
5944 phba->slow_ring_trc = kmalloc(
5945 (sizeof(struct lpfc_debugfs_trc) *
5946 lpfc_debugfs_max_slow_ring_trc),
5948 if (!phba->slow_ring_trc) {
5949 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
5950 "0416 Cannot create debugfs "
5951 "slow_ring buffer\n");
5954 atomic_set(&phba->slow_ring_trc_cnt, 0);
5955 memset(phba->slow_ring_trc, 0,
5956 (sizeof(struct lpfc_debugfs_trc) *
5957 lpfc_debugfs_max_slow_ring_trc));
5960 snprintf(name, sizeof(name), "nvmeio_trc");
5961 phba->debug_nvmeio_trc =
5962 debugfs_create_file(name, 0644,
5963 phba->hba_debugfs_root,
5964 phba, &lpfc_debugfs_op_nvmeio_trc);
5966 atomic_set(&phba->nvmeio_trc_cnt, 0);
5967 if (lpfc_debugfs_max_nvmeio_trc) {
5968 num = lpfc_debugfs_max_nvmeio_trc - 1;
5969 if (num & lpfc_debugfs_max_disc_trc) {
5970 /* Change to be a power of 2 */
5971 num = lpfc_debugfs_max_nvmeio_trc;
5977 lpfc_debugfs_max_nvmeio_trc = (1 << i);
5978 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
5979 "0575 lpfc_debugfs_max_nvmeio_trc "
5981 lpfc_debugfs_max_nvmeio_trc);
5983 phba->nvmeio_trc_size = lpfc_debugfs_max_nvmeio_trc;
5985 /* Allocate trace buffer and initialize */
5986 phba->nvmeio_trc = kzalloc(
5987 (sizeof(struct lpfc_debugfs_nvmeio_trc) *
5988 phba->nvmeio_trc_size), GFP_KERNEL);
5990 if (!phba->nvmeio_trc) {
5991 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
5992 "0576 Cannot create debugfs "
5993 "nvmeio_trc buffer\n");
5996 phba->nvmeio_trc_on = 1;
5997 phba->nvmeio_trc_output_idx = 0;
5998 phba->nvmeio_trc = NULL;
6001 phba->nvmeio_trc_size = 0;
6002 phba->nvmeio_trc_on = 0;
6003 phba->nvmeio_trc_output_idx = 0;
6004 phba->nvmeio_trc = NULL;
6008 snprintf(name, sizeof(name), "vport%d", vport->vpi);
6009 if (!vport->vport_debugfs_root) {
6010 vport->vport_debugfs_root =
6011 debugfs_create_dir(name, phba->hba_debugfs_root);
6012 atomic_inc(&phba->debugfs_vport_count);
6015 if (lpfc_debugfs_max_disc_trc) {
6016 num = lpfc_debugfs_max_disc_trc - 1;
6017 if (num & lpfc_debugfs_max_disc_trc) {
6018 /* Change to be a power of 2 */
6019 num = lpfc_debugfs_max_disc_trc;
6025 lpfc_debugfs_max_disc_trc = (1 << i);
6026 pr_err("lpfc_debugfs_max_disc_trc changed to %d\n",
6027 lpfc_debugfs_max_disc_trc);
6031 vport->disc_trc = kzalloc(
6032 (sizeof(struct lpfc_debugfs_trc) * lpfc_debugfs_max_disc_trc),
6035 if (!vport->disc_trc) {
6036 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
6037 "0418 Cannot create debugfs disc trace "
6041 atomic_set(&vport->disc_trc_cnt, 0);
6043 snprintf(name, sizeof(name), "discovery_trace");
6044 vport->debug_disc_trc =
6045 debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
6046 vport->vport_debugfs_root,
6047 vport, &lpfc_debugfs_op_disc_trc);
6048 snprintf(name, sizeof(name), "nodelist");
6049 vport->debug_nodelist =
6050 debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
6051 vport->vport_debugfs_root,
6052 vport, &lpfc_debugfs_op_nodelist);
6054 snprintf(name, sizeof(name), "nvmestat");
6055 vport->debug_nvmestat =
6056 debugfs_create_file(name, 0644,
6057 vport->vport_debugfs_root,
6058 vport, &lpfc_debugfs_op_nvmestat);
6060 snprintf(name, sizeof(name), "scsistat");
6061 vport->debug_scsistat =
6062 debugfs_create_file(name, 0644,
6063 vport->vport_debugfs_root,
6064 vport, &lpfc_debugfs_op_scsistat);
6065 if (!vport->debug_scsistat) {
6066 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
6067 "4611 Cannot create debugfs scsistat\n");
6071 snprintf(name, sizeof(name), "nvmektime");
6072 vport->debug_nvmektime =
6073 debugfs_create_file(name, 0644,
6074 vport->vport_debugfs_root,
6075 vport, &lpfc_debugfs_op_nvmektime);
6077 snprintf(name, sizeof(name), "cpucheck");
6078 vport->debug_cpucheck =
6079 debugfs_create_file(name, 0644,
6080 vport->vport_debugfs_root,
6081 vport, &lpfc_debugfs_op_cpucheck);
6084 * The following section is for additional directories/files for the
6092 * iDiag debugfs root entry points for SLI4 device only
6094 if (phba->sli_rev < LPFC_SLI_REV4)
6097 snprintf(name, sizeof(name), "iDiag");
6098 if (!phba->idiag_root) {
6100 debugfs_create_dir(name, phba->hba_debugfs_root);
6101 /* Initialize iDiag data structure */
6102 memset(&idiag, 0, sizeof(idiag));
6105 /* iDiag read PCI config space */
6106 snprintf(name, sizeof(name), "pciCfg");
6107 if (!phba->idiag_pci_cfg) {
6108 phba->idiag_pci_cfg =
6109 debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
6110 phba->idiag_root, phba, &lpfc_idiag_op_pciCfg);
6111 idiag.offset.last_rd = 0;
6114 /* iDiag PCI BAR access */
6115 snprintf(name, sizeof(name), "barAcc");
6116 if (!phba->idiag_bar_acc) {
6117 phba->idiag_bar_acc =
6118 debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
6119 phba->idiag_root, phba, &lpfc_idiag_op_barAcc);
6120 idiag.offset.last_rd = 0;
6123 /* iDiag get PCI function queue information */
6124 snprintf(name, sizeof(name), "queInfo");
6125 if (!phba->idiag_que_info) {
6126 phba->idiag_que_info =
6127 debugfs_create_file(name, S_IFREG|S_IRUGO,
6128 phba->idiag_root, phba, &lpfc_idiag_op_queInfo);
6131 /* iDiag access PCI function queue */
6132 snprintf(name, sizeof(name), "queAcc");
6133 if (!phba->idiag_que_acc) {
6134 phba->idiag_que_acc =
6135 debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
6136 phba->idiag_root, phba, &lpfc_idiag_op_queAcc);
6139 /* iDiag access PCI function doorbell registers */
6140 snprintf(name, sizeof(name), "drbAcc");
6141 if (!phba->idiag_drb_acc) {
6142 phba->idiag_drb_acc =
6143 debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
6144 phba->idiag_root, phba, &lpfc_idiag_op_drbAcc);
6147 /* iDiag access PCI function control registers */
6148 snprintf(name, sizeof(name), "ctlAcc");
6149 if (!phba->idiag_ctl_acc) {
6150 phba->idiag_ctl_acc =
6151 debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
6152 phba->idiag_root, phba, &lpfc_idiag_op_ctlAcc);
6155 /* iDiag access mbox commands */
6156 snprintf(name, sizeof(name), "mbxAcc");
6157 if (!phba->idiag_mbx_acc) {
6158 phba->idiag_mbx_acc =
6159 debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
6160 phba->idiag_root, phba, &lpfc_idiag_op_mbxAcc);
6163 /* iDiag extents access commands */
6164 if (phba->sli4_hba.extents_in_use) {
6165 snprintf(name, sizeof(name), "extAcc");
6166 if (!phba->idiag_ext_acc) {
6167 phba->idiag_ext_acc =
6168 debugfs_create_file(name,
6169 S_IFREG|S_IRUGO|S_IWUSR,
6170 phba->idiag_root, phba,
6171 &lpfc_idiag_op_extAcc);
6181 * lpfc_debugfs_terminate - Tear down debugfs infrastructure for this vport
6182 * @vport: The vport pointer to remove from debugfs.
6185 * When Debugfs is configured this routine removes debugfs file system elements
6186 * that are specific to this vport. It also checks to see if there are any
6187 * users left for the debugfs directories associated with the HBA and driver. If
6188 * this is the last user of the HBA directory or driver directory then it will
6189 * remove those from the debugfs infrastructure as well.
6192 lpfc_debugfs_terminate(struct lpfc_vport *vport)
6194 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
6195 struct lpfc_hba *phba = vport->phba;
6197 kfree(vport->disc_trc);
6198 vport->disc_trc = NULL;
6200 debugfs_remove(vport->debug_disc_trc); /* discovery_trace */
6201 vport->debug_disc_trc = NULL;
6203 debugfs_remove(vport->debug_nodelist); /* nodelist */
6204 vport->debug_nodelist = NULL;
6206 debugfs_remove(vport->debug_nvmestat); /* nvmestat */
6207 vport->debug_nvmestat = NULL;
6209 debugfs_remove(vport->debug_scsistat); /* scsistat */
6210 vport->debug_scsistat = NULL;
6212 debugfs_remove(vport->debug_nvmektime); /* nvmektime */
6213 vport->debug_nvmektime = NULL;
6215 debugfs_remove(vport->debug_cpucheck); /* cpucheck */
6216 vport->debug_cpucheck = NULL;
6218 if (vport->vport_debugfs_root) {
6219 debugfs_remove(vport->vport_debugfs_root); /* vportX */
6220 vport->vport_debugfs_root = NULL;
6221 atomic_dec(&phba->debugfs_vport_count);
6224 if (atomic_read(&phba->debugfs_vport_count) == 0) {
6226 debugfs_remove(phba->debug_multixri_pools); /* multixripools*/
6227 phba->debug_multixri_pools = NULL;
6229 debugfs_remove(phba->debug_hbqinfo); /* hbqinfo */
6230 phba->debug_hbqinfo = NULL;
6232 debugfs_remove(phba->debug_ras_log);
6233 phba->debug_ras_log = NULL;
6235 #ifdef LPFC_HDWQ_LOCK_STAT
6236 debugfs_remove(phba->debug_lockstat); /* lockstat */
6237 phba->debug_lockstat = NULL;
6239 debugfs_remove(phba->debug_dumpHBASlim); /* HBASlim */
6240 phba->debug_dumpHBASlim = NULL;
6242 debugfs_remove(phba->debug_dumpHostSlim); /* HostSlim */
6243 phba->debug_dumpHostSlim = NULL;
6245 debugfs_remove(phba->debug_InjErrLBA); /* InjErrLBA */
6246 phba->debug_InjErrLBA = NULL;
6248 debugfs_remove(phba->debug_InjErrNPortID);
6249 phba->debug_InjErrNPortID = NULL;
6251 debugfs_remove(phba->debug_InjErrWWPN); /* InjErrWWPN */
6252 phba->debug_InjErrWWPN = NULL;
6254 debugfs_remove(phba->debug_writeGuard); /* writeGuard */
6255 phba->debug_writeGuard = NULL;
6257 debugfs_remove(phba->debug_writeApp); /* writeApp */
6258 phba->debug_writeApp = NULL;
6260 debugfs_remove(phba->debug_writeRef); /* writeRef */
6261 phba->debug_writeRef = NULL;
6263 debugfs_remove(phba->debug_readGuard); /* readGuard */
6264 phba->debug_readGuard = NULL;
6266 debugfs_remove(phba->debug_readApp); /* readApp */
6267 phba->debug_readApp = NULL;
6269 debugfs_remove(phba->debug_readRef); /* readRef */
6270 phba->debug_readRef = NULL;
6272 kfree(phba->slow_ring_trc);
6273 phba->slow_ring_trc = NULL;
6275 /* slow_ring_trace */
6276 debugfs_remove(phba->debug_slow_ring_trc);
6277 phba->debug_slow_ring_trc = NULL;
6279 debugfs_remove(phba->debug_nvmeio_trc);
6280 phba->debug_nvmeio_trc = NULL;
6282 kfree(phba->nvmeio_trc);
6283 phba->nvmeio_trc = NULL;
6288 if (phba->sli_rev == LPFC_SLI_REV4) {
6290 debugfs_remove(phba->idiag_ext_acc);
6291 phba->idiag_ext_acc = NULL;
6294 debugfs_remove(phba->idiag_mbx_acc);
6295 phba->idiag_mbx_acc = NULL;
6298 debugfs_remove(phba->idiag_ctl_acc);
6299 phba->idiag_ctl_acc = NULL;
6302 debugfs_remove(phba->idiag_drb_acc);
6303 phba->idiag_drb_acc = NULL;
6306 debugfs_remove(phba->idiag_que_acc);
6307 phba->idiag_que_acc = NULL;
6310 debugfs_remove(phba->idiag_que_info);
6311 phba->idiag_que_info = NULL;
6314 debugfs_remove(phba->idiag_bar_acc);
6315 phba->idiag_bar_acc = NULL;
6318 debugfs_remove(phba->idiag_pci_cfg);
6319 phba->idiag_pci_cfg = NULL;
6321 /* Finally remove the iDiag debugfs root */
6322 debugfs_remove(phba->idiag_root);
6323 phba->idiag_root = NULL;
6326 if (phba->hba_debugfs_root) {
6327 debugfs_remove(phba->hba_debugfs_root); /* fnX */
6328 phba->hba_debugfs_root = NULL;
6329 atomic_dec(&lpfc_debugfs_hba_count);
6332 if (atomic_read(&lpfc_debugfs_hba_count) == 0) {
6333 debugfs_remove(lpfc_debugfs_root); /* lpfc */
6334 lpfc_debugfs_root = NULL;
6342 * Driver debug utility routines outside of debugfs. The debug utility
6343 * routines implemented here is intended to be used in the instrumented
6344 * debug driver for debugging host or port issues.
6348 * lpfc_debug_dump_all_queues - dump all the queues with a hba
6349 * @phba: Pointer to HBA context object.
6351 * This function dumps entries of all the queues asociated with the @phba.
6354 lpfc_debug_dump_all_queues(struct lpfc_hba *phba)
6359 * Dump Work Queues (WQs)
6361 lpfc_debug_dump_wq(phba, DUMP_MBX, 0);
6362 lpfc_debug_dump_wq(phba, DUMP_ELS, 0);
6363 lpfc_debug_dump_wq(phba, DUMP_NVMELS, 0);
6365 for (idx = 0; idx < phba->cfg_hdw_queue; idx++)
6366 lpfc_debug_dump_wq(phba, DUMP_IO, idx);
6368 lpfc_debug_dump_hdr_rq(phba);
6369 lpfc_debug_dump_dat_rq(phba);
6371 * Dump Complete Queues (CQs)
6373 lpfc_debug_dump_cq(phba, DUMP_MBX, 0);
6374 lpfc_debug_dump_cq(phba, DUMP_ELS, 0);
6375 lpfc_debug_dump_cq(phba, DUMP_NVMELS, 0);
6377 for (idx = 0; idx < phba->cfg_hdw_queue; idx++)
6378 lpfc_debug_dump_cq(phba, DUMP_IO, idx);
6381 * Dump Event Queues (EQs)
6383 for (idx = 0; idx < phba->cfg_hdw_queue; idx++)
6384 lpfc_debug_dump_hba_eq(phba, idx);