1 /*******************************************************************
2 * This file is part of the Emulex Linux Device Driver for *
3 * Fibre Channel Host Bus Adapters. *
4 * Copyright (C) 2007-2012 Emulex. All rights reserved. *
5 * EMULEX and SLI are trademarks of Emulex. *
8 * This program is free software; you can redistribute it and/or *
9 * modify it under the terms of version 2 of the GNU General *
10 * Public License as published by the Free Software Foundation. *
11 * This program is distributed in the hope that it will be useful. *
12 * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND *
13 * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, *
14 * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE *
15 * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD *
16 * TO BE LEGALLY INVALID. See the GNU General Public License for *
17 * more details, a copy of which can be found in the file COPYING *
18 * included with this package. *
19 *******************************************************************/
21 #include <linux/blkdev.h>
22 #include <linux/delay.h>
23 #include <linux/module.h>
24 #include <linux/dma-mapping.h>
25 #include <linux/idr.h>
26 #include <linux/interrupt.h>
27 #include <linux/kthread.h>
28 #include <linux/slab.h>
29 #include <linux/pci.h>
30 #include <linux/spinlock.h>
31 #include <linux/ctype.h>
33 #include <scsi/scsi.h>
34 #include <scsi/scsi_device.h>
35 #include <scsi/scsi_host.h>
36 #include <scsi/scsi_transport_fc.h>
41 #include "lpfc_sli4.h"
43 #include "lpfc_disc.h"
44 #include "lpfc_scsi.h"
46 #include "lpfc_logmsg.h"
47 #include "lpfc_crtn.h"
48 #include "lpfc_vport.h"
49 #include "lpfc_version.h"
50 #include "lpfc_compat.h"
51 #include "lpfc_debugfs.h"
54 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
58 * To access this interface the user should:
59 * # mount -t debugfs none /sys/kernel/debug
61 * The lpfc debugfs directory hierarchy is:
62 * /sys/kernel/debug/lpfc/fnX/vportY
63 * where X is the lpfc hba function unique_id
64 * where Y is the vport VPI on that hba
66 * Debugging services available per vport:
68 * This is an ACSII readable file that contains a trace of the last
69 * lpfc_debugfs_max_disc_trc events that happened on a specific vport.
70 * See lpfc_debugfs.h for different categories of discovery events.
71 * To enable the discovery trace, the following module parameters must be set:
72 * lpfc_debugfs_enable=1 Turns on lpfc debugfs filesystem support
73 * lpfc_debugfs_max_disc_trc=X Where X is the event trace depth for
74 * EACH vport. X MUST also be a power of 2.
75 * lpfc_debugfs_mask_disc_trc=Y Where Y is an event mask as defined in
79 * This is an ACSII readable file that contains a trace of the last
80 * lpfc_debugfs_max_slow_ring_trc events that happened on a specific HBA.
81 * To enable the slow ring trace, the following module parameters must be set:
82 * lpfc_debugfs_enable=1 Turns on lpfc debugfs filesystem support
83 * lpfc_debugfs_max_slow_ring_trc=X Where X is the event trace depth for
84 * the HBA. X MUST also be a power of 2.
86 static int lpfc_debugfs_enable
= 1;
87 module_param(lpfc_debugfs_enable
, int, S_IRUGO
);
88 MODULE_PARM_DESC(lpfc_debugfs_enable
, "Enable debugfs services");
90 /* This MUST be a power of 2 */
91 static int lpfc_debugfs_max_disc_trc
;
92 module_param(lpfc_debugfs_max_disc_trc
, int, S_IRUGO
);
93 MODULE_PARM_DESC(lpfc_debugfs_max_disc_trc
,
94 "Set debugfs discovery trace depth");
96 /* This MUST be a power of 2 */
97 static int lpfc_debugfs_max_slow_ring_trc
;
98 module_param(lpfc_debugfs_max_slow_ring_trc
, int, S_IRUGO
);
99 MODULE_PARM_DESC(lpfc_debugfs_max_slow_ring_trc
,
100 "Set debugfs slow ring trace depth");
102 static int lpfc_debugfs_mask_disc_trc
;
103 module_param(lpfc_debugfs_mask_disc_trc
, int, S_IRUGO
);
104 MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc
,
105 "Set debugfs discovery trace mask");
107 #include <linux/debugfs.h>
109 static atomic_t lpfc_debugfs_seq_trc_cnt
= ATOMIC_INIT(0);
110 static unsigned long lpfc_debugfs_start_time
= 0L;
113 static struct lpfc_idiag idiag
;
116 * lpfc_debugfs_disc_trc_data - Dump discovery logging to a buffer
117 * @vport: The vport to gather the log info from.
118 * @buf: The buffer to dump log into.
119 * @size: The maximum amount of data to process.
122 * This routine gathers the lpfc discovery debugfs data from the @vport and
123 * dumps it to @buf up to @size number of bytes. It will start at the next entry
124 * in the log and process the log until the end of the buffer. Then it will
125 * gather from the beginning of the log and process until the current entry.
128 * Discovery logging will be disabled while while this routine dumps the log.
131 * This routine returns the amount of bytes that were dumped into @buf and will
135 lpfc_debugfs_disc_trc_data(struct lpfc_vport
*vport
, char *buf
, int size
)
137 int i
, index
, len
, enable
;
139 struct lpfc_debugfs_trc
*dtp
;
142 buffer
= kmalloc(LPFC_DEBUG_TRC_ENTRY_SIZE
, GFP_KERNEL
);
146 enable
= lpfc_debugfs_enable
;
147 lpfc_debugfs_enable
= 0;
150 index
= (atomic_read(&vport
->disc_trc_cnt
) + 1) &
151 (lpfc_debugfs_max_disc_trc
- 1);
152 for (i
= index
; i
< lpfc_debugfs_max_disc_trc
; i
++) {
153 dtp
= vport
->disc_trc
+ i
;
156 ms
= jiffies_to_msecs(dtp
->jif
- lpfc_debugfs_start_time
);
158 LPFC_DEBUG_TRC_ENTRY_SIZE
, "%010d:%010d ms:%s\n",
159 dtp
->seq_cnt
, ms
, dtp
->fmt
);
160 len
+= snprintf(buf
+len
, size
-len
, buffer
,
161 dtp
->data1
, dtp
->data2
, dtp
->data3
);
163 for (i
= 0; i
< index
; i
++) {
164 dtp
= vport
->disc_trc
+ i
;
167 ms
= jiffies_to_msecs(dtp
->jif
- lpfc_debugfs_start_time
);
169 LPFC_DEBUG_TRC_ENTRY_SIZE
, "%010d:%010d ms:%s\n",
170 dtp
->seq_cnt
, ms
, dtp
->fmt
);
171 len
+= snprintf(buf
+len
, size
-len
, buffer
,
172 dtp
->data1
, dtp
->data2
, dtp
->data3
);
175 lpfc_debugfs_enable
= enable
;
182 * lpfc_debugfs_slow_ring_trc_data - Dump slow ring logging to a buffer
183 * @phba: The HBA to gather the log info from.
184 * @buf: The buffer to dump log into.
185 * @size: The maximum amount of data to process.
188 * This routine gathers the lpfc slow ring debugfs data from the @phba and
189 * dumps it to @buf up to @size number of bytes. It will start at the next entry
190 * in the log and process the log until the end of the buffer. Then it will
191 * gather from the beginning of the log and process until the current entry.
194 * Slow ring logging will be disabled while while this routine dumps the log.
197 * This routine returns the amount of bytes that were dumped into @buf and will
201 lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba
*phba
, char *buf
, int size
)
203 int i
, index
, len
, enable
;
205 struct lpfc_debugfs_trc
*dtp
;
208 buffer
= kmalloc(LPFC_DEBUG_TRC_ENTRY_SIZE
, GFP_KERNEL
);
212 enable
= lpfc_debugfs_enable
;
213 lpfc_debugfs_enable
= 0;
216 index
= (atomic_read(&phba
->slow_ring_trc_cnt
) + 1) &
217 (lpfc_debugfs_max_slow_ring_trc
- 1);
218 for (i
= index
; i
< lpfc_debugfs_max_slow_ring_trc
; i
++) {
219 dtp
= phba
->slow_ring_trc
+ i
;
222 ms
= jiffies_to_msecs(dtp
->jif
- lpfc_debugfs_start_time
);
224 LPFC_DEBUG_TRC_ENTRY_SIZE
, "%010d:%010d ms:%s\n",
225 dtp
->seq_cnt
, ms
, dtp
->fmt
);
226 len
+= snprintf(buf
+len
, size
-len
, buffer
,
227 dtp
->data1
, dtp
->data2
, dtp
->data3
);
229 for (i
= 0; i
< index
; i
++) {
230 dtp
= phba
->slow_ring_trc
+ i
;
233 ms
= jiffies_to_msecs(dtp
->jif
- lpfc_debugfs_start_time
);
235 LPFC_DEBUG_TRC_ENTRY_SIZE
, "%010d:%010d ms:%s\n",
236 dtp
->seq_cnt
, ms
, dtp
->fmt
);
237 len
+= snprintf(buf
+len
, size
-len
, buffer
,
238 dtp
->data1
, dtp
->data2
, dtp
->data3
);
241 lpfc_debugfs_enable
= enable
;
247 static int lpfc_debugfs_last_hbq
= -1;
250 * lpfc_debugfs_hbqinfo_data - Dump host buffer queue info to a buffer
251 * @phba: The HBA to gather host buffer info from.
252 * @buf: The buffer to dump log into.
253 * @size: The maximum amount of data to process.
256 * This routine dumps the host buffer queue info from the @phba to @buf up to
257 * @size number of bytes. A header that describes the current hbq state will be
258 * dumped to @buf first and then info on each hbq entry will be dumped to @buf
259 * until @size bytes have been dumped or all the hbq info has been dumped.
262 * This routine will rotate through each configured HBQ each time called.
265 * This routine returns the amount of bytes that were dumped into @buf and will
269 lpfc_debugfs_hbqinfo_data(struct lpfc_hba
*phba
, char *buf
, int size
)
272 int cnt
, i
, j
, found
, posted
, low
;
273 uint32_t phys
, raw_index
, getidx
;
274 struct lpfc_hbq_init
*hip
;
276 struct lpfc_hbq_entry
*hbqe
;
277 struct lpfc_dmabuf
*d_buf
;
278 struct hbq_dmabuf
*hbq_buf
;
280 if (phba
->sli_rev
!= 3)
282 cnt
= LPFC_HBQINFO_SIZE
;
283 spin_lock_irq(&phba
->hbalock
);
285 /* toggle between multiple hbqs, if any */
286 i
= lpfc_sli_hbq_count();
288 lpfc_debugfs_last_hbq
++;
289 if (lpfc_debugfs_last_hbq
>= i
)
290 lpfc_debugfs_last_hbq
= 0;
293 lpfc_debugfs_last_hbq
= 0;
295 i
= lpfc_debugfs_last_hbq
;
297 len
+= snprintf(buf
+len
, size
-len
, "HBQ %d Info\n", i
);
299 hbqs
= &phba
->hbqs
[i
];
301 list_for_each_entry(d_buf
, &hbqs
->hbq_buffer_list
, list
)
304 hip
= lpfc_hbq_defs
[i
];
305 len
+= snprintf(buf
+len
, size
-len
,
306 "idx:%d prof:%d rn:%d bufcnt:%d icnt:%d acnt:%d posted %d\n",
307 hip
->hbq_index
, hip
->profile
, hip
->rn
,
308 hip
->buffer_count
, hip
->init_count
, hip
->add_count
, posted
);
310 raw_index
= phba
->hbq_get
[i
];
311 getidx
= le32_to_cpu(raw_index
);
312 len
+= snprintf(buf
+len
, size
-len
,
313 "entrys:%d bufcnt:%d Put:%d nPut:%d localGet:%d hbaGet:%d\n",
314 hbqs
->entry_count
, hbqs
->buffer_count
, hbqs
->hbqPutIdx
,
315 hbqs
->next_hbqPutIdx
, hbqs
->local_hbqGetIdx
, getidx
);
317 hbqe
= (struct lpfc_hbq_entry
*) phba
->hbqs
[i
].hbq_virt
;
318 for (j
=0; j
<hbqs
->entry_count
; j
++) {
319 len
+= snprintf(buf
+len
, size
-len
,
320 "%03d: %08x %04x %05x ", j
,
321 le32_to_cpu(hbqe
->bde
.addrLow
),
322 le32_to_cpu(hbqe
->bde
.tus
.w
),
323 le32_to_cpu(hbqe
->buffer_tag
));
327 /* First calculate if slot has an associated posted buffer */
328 low
= hbqs
->hbqPutIdx
- posted
;
330 if ((j
>= hbqs
->hbqPutIdx
) || (j
< low
)) {
331 len
+= snprintf(buf
+len
, size
-len
, "Unused\n");
336 if ((j
>= hbqs
->hbqPutIdx
) &&
337 (j
< (hbqs
->entry_count
+low
))) {
338 len
+= snprintf(buf
+len
, size
-len
, "Unused\n");
343 /* Get the Buffer info for the posted buffer */
344 list_for_each_entry(d_buf
, &hbqs
->hbq_buffer_list
, list
) {
345 hbq_buf
= container_of(d_buf
, struct hbq_dmabuf
, dbuf
);
346 phys
= ((uint64_t)hbq_buf
->dbuf
.phys
& 0xffffffff);
347 if (phys
== le32_to_cpu(hbqe
->bde
.addrLow
)) {
348 len
+= snprintf(buf
+len
, size
-len
,
349 "Buf%d: %p %06x\n", i
,
350 hbq_buf
->dbuf
.virt
, hbq_buf
->tag
);
357 len
+= snprintf(buf
+len
, size
-len
, "No DMAinfo?\n");
361 if (len
> LPFC_HBQINFO_SIZE
- 54)
364 spin_unlock_irq(&phba
->hbalock
);
368 static int lpfc_debugfs_last_hba_slim_off
;
371 * lpfc_debugfs_dumpHBASlim_data - Dump HBA SLIM info to a buffer
372 * @phba: The HBA to gather SLIM info from.
373 * @buf: The buffer to dump log into.
374 * @size: The maximum amount of data to process.
377 * This routine dumps the current contents of HBA SLIM for the HBA associated
378 * with @phba to @buf up to @size bytes of data. This is the raw HBA SLIM data.
381 * This routine will only dump up to 1024 bytes of data each time called and
382 * should be called multiple times to dump the entire HBA SLIM.
385 * This routine returns the amount of bytes that were dumped into @buf and will
389 lpfc_debugfs_dumpHBASlim_data(struct lpfc_hba
*phba
, char *buf
, int size
)
396 buffer
= kmalloc(1024, GFP_KERNEL
);
401 spin_lock_irq(&phba
->hbalock
);
403 len
+= snprintf(buf
+len
, size
-len
, "HBA SLIM\n");
404 lpfc_memcpy_from_slim(buffer
,
405 phba
->MBslimaddr
+ lpfc_debugfs_last_hba_slim_off
, 1024);
407 ptr
= (uint32_t *)&buffer
[0];
408 off
= lpfc_debugfs_last_hba_slim_off
;
410 /* Set it up for the next time */
411 lpfc_debugfs_last_hba_slim_off
+= 1024;
412 if (lpfc_debugfs_last_hba_slim_off
>= 4096)
413 lpfc_debugfs_last_hba_slim_off
= 0;
417 len
+= snprintf(buf
+len
, size
-len
,
418 "%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n",
419 off
, *ptr
, *(ptr
+1), *(ptr
+2), *(ptr
+3), *(ptr
+4),
420 *(ptr
+5), *(ptr
+6), *(ptr
+7));
422 i
-= (8 * sizeof(uint32_t));
423 off
+= (8 * sizeof(uint32_t));
426 spin_unlock_irq(&phba
->hbalock
);
433 * lpfc_debugfs_dumpHostSlim_data - Dump host SLIM info to a buffer
434 * @phba: The HBA to gather Host SLIM info from.
435 * @buf: The buffer to dump log into.
436 * @size: The maximum amount of data to process.
439 * This routine dumps the current contents of host SLIM for the host associated
440 * with @phba to @buf up to @size bytes of data. The dump will contain the
441 * Mailbox, PCB, Rings, and Registers that are located in host memory.
444 * This routine returns the amount of bytes that were dumped into @buf and will
448 lpfc_debugfs_dumpHostSlim_data(struct lpfc_hba
*phba
, char *buf
, int size
)
452 uint32_t word0
, word1
, word2
, word3
;
454 struct lpfc_pgp
*pgpp
;
455 struct lpfc_sli
*psli
= &phba
->sli
;
456 struct lpfc_sli_ring
*pring
;
459 spin_lock_irq(&phba
->hbalock
);
461 len
+= snprintf(buf
+len
, size
-len
, "SLIM Mailbox\n");
462 ptr
= (uint32_t *)phba
->slim2p
.virt
;
463 i
= sizeof(MAILBOX_t
);
465 len
+= snprintf(buf
+len
, size
-len
,
466 "%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n",
467 off
, *ptr
, *(ptr
+1), *(ptr
+2), *(ptr
+3), *(ptr
+4),
468 *(ptr
+5), *(ptr
+6), *(ptr
+7));
470 i
-= (8 * sizeof(uint32_t));
471 off
+= (8 * sizeof(uint32_t));
474 len
+= snprintf(buf
+len
, size
-len
, "SLIM PCB\n");
475 ptr
= (uint32_t *)phba
->pcb
;
478 len
+= snprintf(buf
+len
, size
-len
,
479 "%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n",
480 off
, *ptr
, *(ptr
+1), *(ptr
+2), *(ptr
+3), *(ptr
+4),
481 *(ptr
+5), *(ptr
+6), *(ptr
+7));
483 i
-= (8 * sizeof(uint32_t));
484 off
+= (8 * sizeof(uint32_t));
487 for (i
= 0; i
< 4; i
++) {
488 pgpp
= &phba
->port_gp
[i
];
489 pring
= &psli
->ring
[i
];
490 len
+= snprintf(buf
+len
, size
-len
,
491 "Ring %d: CMD GetInx:%d (Max:%d Next:%d "
492 "Local:%d flg:x%x) RSP PutInx:%d Max:%d\n",
493 i
, pgpp
->cmdGetInx
, pring
->numCiocb
,
494 pring
->next_cmdidx
, pring
->local_getidx
,
495 pring
->flag
, pgpp
->rspPutInx
, pring
->numRiocb
);
498 if (phba
->sli_rev
<= LPFC_SLI_REV3
) {
499 word0
= readl(phba
->HAregaddr
);
500 word1
= readl(phba
->CAregaddr
);
501 word2
= readl(phba
->HSregaddr
);
502 word3
= readl(phba
->HCregaddr
);
503 len
+= snprintf(buf
+len
, size
-len
, "HA:%08x CA:%08x HS:%08x "
504 "HC:%08x\n", word0
, word1
, word2
, word3
);
506 spin_unlock_irq(&phba
->hbalock
);
511 * lpfc_debugfs_nodelist_data - Dump target node list to a buffer
512 * @vport: The vport to gather target node info from.
513 * @buf: The buffer to dump log into.
514 * @size: The maximum amount of data to process.
517 * This routine dumps the current target node list associated with @vport to
518 * @buf up to @size bytes of data. Each node entry in the dump will contain a
519 * node state, DID, WWPN, WWNN, RPI, flags, type, and other useful fields.
522 * This routine returns the amount of bytes that were dumped into @buf and will
526 lpfc_debugfs_nodelist_data(struct lpfc_vport
*vport
, char *buf
, int size
)
530 struct Scsi_Host
*shost
= lpfc_shost_from_vport(vport
);
531 struct lpfc_nodelist
*ndlp
;
532 unsigned char *statep
, *name
;
534 cnt
= (LPFC_NODELIST_SIZE
/ LPFC_NODELIST_ENTRY_SIZE
);
536 spin_lock_irq(shost
->host_lock
);
537 list_for_each_entry(ndlp
, &vport
->fc_nodes
, nlp_listp
) {
539 len
+= snprintf(buf
+len
, size
-len
,
540 "Missing Nodelist Entries\n");
544 switch (ndlp
->nlp_state
) {
545 case NLP_STE_UNUSED_NODE
:
548 case NLP_STE_PLOGI_ISSUE
:
551 case NLP_STE_ADISC_ISSUE
:
554 case NLP_STE_REG_LOGIN_ISSUE
:
557 case NLP_STE_PRLI_ISSUE
:
560 case NLP_STE_UNMAPPED_NODE
:
563 case NLP_STE_MAPPED_NODE
:
566 case NLP_STE_NPR_NODE
:
572 len
+= snprintf(buf
+len
, size
-len
, "%s DID:x%06x ",
573 statep
, ndlp
->nlp_DID
);
574 name
= (unsigned char *)&ndlp
->nlp_portname
;
575 len
+= snprintf(buf
+len
, size
-len
,
576 "WWPN %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x ",
577 *name
, *(name
+1), *(name
+2), *(name
+3),
578 *(name
+4), *(name
+5), *(name
+6), *(name
+7));
579 name
= (unsigned char *)&ndlp
->nlp_nodename
;
580 len
+= snprintf(buf
+len
, size
-len
,
581 "WWNN %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x ",
582 *name
, *(name
+1), *(name
+2), *(name
+3),
583 *(name
+4), *(name
+5), *(name
+6), *(name
+7));
584 len
+= snprintf(buf
+len
, size
-len
, "RPI:%03d flag:x%08x ",
585 ndlp
->nlp_rpi
, ndlp
->nlp_flag
);
587 len
+= snprintf(buf
+len
, size
-len
, "UNKNOWN_TYPE ");
588 if (ndlp
->nlp_type
& NLP_FC_NODE
)
589 len
+= snprintf(buf
+len
, size
-len
, "FC_NODE ");
590 if (ndlp
->nlp_type
& NLP_FABRIC
)
591 len
+= snprintf(buf
+len
, size
-len
, "FABRIC ");
592 if (ndlp
->nlp_type
& NLP_FCP_TARGET
)
593 len
+= snprintf(buf
+len
, size
-len
, "FCP_TGT sid:%d ",
595 if (ndlp
->nlp_type
& NLP_FCP_INITIATOR
)
596 len
+= snprintf(buf
+len
, size
-len
, "FCP_INITIATOR ");
597 len
+= snprintf(buf
+len
, size
-len
, "usgmap:%x ",
599 len
+= snprintf(buf
+len
, size
-len
, "refcnt:%x",
600 atomic_read(&ndlp
->kref
.refcount
));
601 len
+= snprintf(buf
+len
, size
-len
, "\n");
603 spin_unlock_irq(shost
->host_lock
);
609 * lpfc_debugfs_disc_trc - Store discovery trace log
610 * @vport: The vport to associate this trace string with for retrieval.
611 * @mask: Log entry classification.
612 * @fmt: Format string to be displayed when dumping the log.
613 * @data1: 1st data parameter to be applied to @fmt.
614 * @data2: 2nd data parameter to be applied to @fmt.
615 * @data3: 3rd data parameter to be applied to @fmt.
618 * This routine is used by the driver code to add a debugfs log entry to the
619 * discovery trace buffer associated with @vport. Only entries with a @mask that
620 * match the current debugfs discovery mask will be saved. Entries that do not
621 * match will be thrown away. @fmt, @data1, @data2, and @data3 are used like
622 * printf when displaying the log.
625 lpfc_debugfs_disc_trc(struct lpfc_vport
*vport
, int mask
, char *fmt
,
626 uint32_t data1
, uint32_t data2
, uint32_t data3
)
628 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
629 struct lpfc_debugfs_trc
*dtp
;
632 if (!(lpfc_debugfs_mask_disc_trc
& mask
))
635 if (!lpfc_debugfs_enable
|| !lpfc_debugfs_max_disc_trc
||
636 !vport
|| !vport
->disc_trc
)
639 index
= atomic_inc_return(&vport
->disc_trc_cnt
) &
640 (lpfc_debugfs_max_disc_trc
- 1);
641 dtp
= vport
->disc_trc
+ index
;
646 dtp
->seq_cnt
= atomic_inc_return(&lpfc_debugfs_seq_trc_cnt
);
653 * lpfc_debugfs_slow_ring_trc - Store slow ring trace log
654 * @phba: The phba to associate this trace string with for retrieval.
655 * @fmt: Format string to be displayed when dumping the log.
656 * @data1: 1st data parameter to be applied to @fmt.
657 * @data2: 2nd data parameter to be applied to @fmt.
658 * @data3: 3rd data parameter to be applied to @fmt.
661 * This routine is used by the driver code to add a debugfs log entry to the
662 * discovery trace buffer associated with @vport. @fmt, @data1, @data2, and
663 * @data3 are used like printf when displaying the log.
666 lpfc_debugfs_slow_ring_trc(struct lpfc_hba
*phba
, char *fmt
,
667 uint32_t data1
, uint32_t data2
, uint32_t data3
)
669 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
670 struct lpfc_debugfs_trc
*dtp
;
673 if (!lpfc_debugfs_enable
|| !lpfc_debugfs_max_slow_ring_trc
||
674 !phba
|| !phba
->slow_ring_trc
)
677 index
= atomic_inc_return(&phba
->slow_ring_trc_cnt
) &
678 (lpfc_debugfs_max_slow_ring_trc
- 1);
679 dtp
= phba
->slow_ring_trc
+ index
;
684 dtp
->seq_cnt
= atomic_inc_return(&lpfc_debugfs_seq_trc_cnt
);
690 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
692 * lpfc_debugfs_disc_trc_open - Open the discovery trace log
693 * @inode: The inode pointer that contains a vport pointer.
694 * @file: The file pointer to attach the log output.
697 * This routine is the entry point for the debugfs open file operation. It gets
698 * the vport from the i_private field in @inode, allocates the necessary buffer
699 * for the log, fills the buffer from the in-memory log for this vport, and then
700 * returns a pointer to that log in the private_data field in @file.
703 * This function returns zero if successful. On error it will return an negative
707 lpfc_debugfs_disc_trc_open(struct inode
*inode
, struct file
*file
)
709 struct lpfc_vport
*vport
= inode
->i_private
;
710 struct lpfc_debug
*debug
;
714 if (!lpfc_debugfs_max_disc_trc
) {
719 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
723 /* Round to page boundary */
724 size
= (lpfc_debugfs_max_disc_trc
* LPFC_DEBUG_TRC_ENTRY_SIZE
);
725 size
= PAGE_ALIGN(size
);
727 debug
->buffer
= kmalloc(size
, GFP_KERNEL
);
728 if (!debug
->buffer
) {
733 debug
->len
= lpfc_debugfs_disc_trc_data(vport
, debug
->buffer
, size
);
734 file
->private_data
= debug
;
742 * lpfc_debugfs_slow_ring_trc_open - Open the Slow Ring trace log
743 * @inode: The inode pointer that contains a vport pointer.
744 * @file: The file pointer to attach the log output.
747 * This routine is the entry point for the debugfs open file operation. It gets
748 * the vport from the i_private field in @inode, allocates the necessary buffer
749 * for the log, fills the buffer from the in-memory log for this vport, and then
750 * returns a pointer to that log in the private_data field in @file.
753 * This function returns zero if successful. On error it will return an negative
757 lpfc_debugfs_slow_ring_trc_open(struct inode
*inode
, struct file
*file
)
759 struct lpfc_hba
*phba
= inode
->i_private
;
760 struct lpfc_debug
*debug
;
764 if (!lpfc_debugfs_max_slow_ring_trc
) {
769 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
773 /* Round to page boundary */
774 size
= (lpfc_debugfs_max_slow_ring_trc
* LPFC_DEBUG_TRC_ENTRY_SIZE
);
775 size
= PAGE_ALIGN(size
);
777 debug
->buffer
= kmalloc(size
, GFP_KERNEL
);
778 if (!debug
->buffer
) {
783 debug
->len
= lpfc_debugfs_slow_ring_trc_data(phba
, debug
->buffer
, size
);
784 file
->private_data
= debug
;
792 * lpfc_debugfs_hbqinfo_open - Open the hbqinfo debugfs buffer
793 * @inode: The inode pointer that contains a vport pointer.
794 * @file: The file pointer to attach the log output.
797 * This routine is the entry point for the debugfs open file operation. It gets
798 * the vport from the i_private field in @inode, allocates the necessary buffer
799 * for the log, fills the buffer from the in-memory log for this vport, and then
800 * returns a pointer to that log in the private_data field in @file.
803 * This function returns zero if successful. On error it will return an negative
807 lpfc_debugfs_hbqinfo_open(struct inode
*inode
, struct file
*file
)
809 struct lpfc_hba
*phba
= inode
->i_private
;
810 struct lpfc_debug
*debug
;
813 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
817 /* Round to page boundary */
818 debug
->buffer
= kmalloc(LPFC_HBQINFO_SIZE
, GFP_KERNEL
);
819 if (!debug
->buffer
) {
824 debug
->len
= lpfc_debugfs_hbqinfo_data(phba
, debug
->buffer
,
826 file
->private_data
= debug
;
834 * lpfc_debugfs_dumpHBASlim_open - Open the Dump HBA SLIM debugfs buffer
835 * @inode: The inode pointer that contains a vport pointer.
836 * @file: The file pointer to attach the log output.
839 * This routine is the entry point for the debugfs open file operation. It gets
840 * the vport from the i_private field in @inode, allocates the necessary buffer
841 * for the log, fills the buffer from the in-memory log for this vport, and then
842 * returns a pointer to that log in the private_data field in @file.
845 * This function returns zero if successful. On error it will return an negative
849 lpfc_debugfs_dumpHBASlim_open(struct inode
*inode
, struct file
*file
)
851 struct lpfc_hba
*phba
= inode
->i_private
;
852 struct lpfc_debug
*debug
;
855 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
859 /* Round to page boundary */
860 debug
->buffer
= kmalloc(LPFC_DUMPHBASLIM_SIZE
, GFP_KERNEL
);
861 if (!debug
->buffer
) {
866 debug
->len
= lpfc_debugfs_dumpHBASlim_data(phba
, debug
->buffer
,
867 LPFC_DUMPHBASLIM_SIZE
);
868 file
->private_data
= debug
;
876 * lpfc_debugfs_dumpHostSlim_open - Open the Dump Host SLIM debugfs buffer
877 * @inode: The inode pointer that contains a vport pointer.
878 * @file: The file pointer to attach the log output.
881 * This routine is the entry point for the debugfs open file operation. It gets
882 * the vport from the i_private field in @inode, allocates the necessary buffer
883 * for the log, fills the buffer from the in-memory log for this vport, and then
884 * returns a pointer to that log in the private_data field in @file.
887 * This function returns zero if successful. On error it will return an negative
891 lpfc_debugfs_dumpHostSlim_open(struct inode
*inode
, struct file
*file
)
893 struct lpfc_hba
*phba
= inode
->i_private
;
894 struct lpfc_debug
*debug
;
897 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
901 /* Round to page boundary */
902 debug
->buffer
= kmalloc(LPFC_DUMPHOSTSLIM_SIZE
, GFP_KERNEL
);
903 if (!debug
->buffer
) {
908 debug
->len
= lpfc_debugfs_dumpHostSlim_data(phba
, debug
->buffer
,
909 LPFC_DUMPHOSTSLIM_SIZE
);
910 file
->private_data
= debug
;
918 lpfc_debugfs_dumpData_open(struct inode
*inode
, struct file
*file
)
920 struct lpfc_debug
*debug
;
926 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
930 /* Round to page boundary */
931 printk(KERN_ERR
"9059 BLKGRD: %s: _dump_buf_data=0x%p\n",
932 __func__
, _dump_buf_data
);
933 debug
->buffer
= _dump_buf_data
;
934 if (!debug
->buffer
) {
939 debug
->len
= (1 << _dump_buf_data_order
) << PAGE_SHIFT
;
940 file
->private_data
= debug
;
948 lpfc_debugfs_dumpDif_open(struct inode
*inode
, struct file
*file
)
950 struct lpfc_debug
*debug
;
956 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
960 /* Round to page boundary */
961 printk(KERN_ERR
"9060 BLKGRD: %s: _dump_buf_dif=0x%p file=%s\n",
962 __func__
, _dump_buf_dif
, file
->f_dentry
->d_name
.name
);
963 debug
->buffer
= _dump_buf_dif
;
964 if (!debug
->buffer
) {
969 debug
->len
= (1 << _dump_buf_dif_order
) << PAGE_SHIFT
;
970 file
->private_data
= debug
;
978 lpfc_debugfs_dumpDataDif_write(struct file
*file
, const char __user
*buf
,
979 size_t nbytes
, loff_t
*ppos
)
982 * The Data/DIF buffers only save one failing IO
983 * The write op is used as a reset mechanism after an IO has
984 * already been saved to the next one can be saved
986 spin_lock(&_dump_buf_lock
);
988 memset((void *)_dump_buf_data
, 0,
989 ((1 << PAGE_SHIFT
) << _dump_buf_data_order
));
990 memset((void *)_dump_buf_dif
, 0,
991 ((1 << PAGE_SHIFT
) << _dump_buf_dif_order
));
995 spin_unlock(&_dump_buf_lock
);
1001 lpfc_debugfs_dif_err_read(struct file
*file
, char __user
*buf
,
1002 size_t nbytes
, loff_t
*ppos
)
1004 struct dentry
*dent
= file
->f_dentry
;
1005 struct lpfc_hba
*phba
= file
->private_data
;
1010 if (dent
== phba
->debug_writeGuard
)
1011 cnt
= snprintf(cbuf
, 32, "%u\n", phba
->lpfc_injerr_wgrd_cnt
);
1012 else if (dent
== phba
->debug_writeApp
)
1013 cnt
= snprintf(cbuf
, 32, "%u\n", phba
->lpfc_injerr_wapp_cnt
);
1014 else if (dent
== phba
->debug_writeRef
)
1015 cnt
= snprintf(cbuf
, 32, "%u\n", phba
->lpfc_injerr_wref_cnt
);
1016 else if (dent
== phba
->debug_readGuard
)
1017 cnt
= snprintf(cbuf
, 32, "%u\n", phba
->lpfc_injerr_rgrd_cnt
);
1018 else if (dent
== phba
->debug_readApp
)
1019 cnt
= snprintf(cbuf
, 32, "%u\n", phba
->lpfc_injerr_rapp_cnt
);
1020 else if (dent
== phba
->debug_readRef
)
1021 cnt
= snprintf(cbuf
, 32, "%u\n", phba
->lpfc_injerr_rref_cnt
);
1022 else if (dent
== phba
->debug_InjErrNPortID
)
1023 cnt
= snprintf(cbuf
, 32, "0x%06x\n", phba
->lpfc_injerr_nportid
);
1024 else if (dent
== phba
->debug_InjErrWWPN
) {
1025 memcpy(&tmp
, &phba
->lpfc_injerr_wwpn
, sizeof(struct lpfc_name
));
1026 tmp
= cpu_to_be64(tmp
);
1027 cnt
= snprintf(cbuf
, 32, "0x%016llx\n", tmp
);
1028 } else if (dent
== phba
->debug_InjErrLBA
) {
1029 if (phba
->lpfc_injerr_lba
== (sector_t
)(-1))
1030 cnt
= snprintf(cbuf
, 32, "off\n");
1032 cnt
= snprintf(cbuf
, 32, "0x%llx\n",
1033 (uint64_t) phba
->lpfc_injerr_lba
);
1035 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
1036 "0547 Unknown debugfs error injection entry\n");
1038 return simple_read_from_buffer(buf
, nbytes
, ppos
, &cbuf
, cnt
);
1042 lpfc_debugfs_dif_err_write(struct file
*file
, const char __user
*buf
,
1043 size_t nbytes
, loff_t
*ppos
)
1045 struct dentry
*dent
= file
->f_dentry
;
1046 struct lpfc_hba
*phba
= file
->private_data
;
1051 memset(dstbuf
, 0, 32);
1052 size
= (nbytes
< 32) ? nbytes
: 32;
1053 if (copy_from_user(dstbuf
, buf
, size
))
1056 if (dent
== phba
->debug_InjErrLBA
) {
1057 if ((buf
[0] == 'o') && (buf
[1] == 'f') && (buf
[2] == 'f'))
1058 tmp
= (uint64_t)(-1);
1061 if ((tmp
== 0) && (kstrtoull(dstbuf
, 0, &tmp
)))
1064 if (dent
== phba
->debug_writeGuard
)
1065 phba
->lpfc_injerr_wgrd_cnt
= (uint32_t)tmp
;
1066 else if (dent
== phba
->debug_writeApp
)
1067 phba
->lpfc_injerr_wapp_cnt
= (uint32_t)tmp
;
1068 else if (dent
== phba
->debug_writeRef
)
1069 phba
->lpfc_injerr_wref_cnt
= (uint32_t)tmp
;
1070 else if (dent
== phba
->debug_readGuard
)
1071 phba
->lpfc_injerr_rgrd_cnt
= (uint32_t)tmp
;
1072 else if (dent
== phba
->debug_readApp
)
1073 phba
->lpfc_injerr_rapp_cnt
= (uint32_t)tmp
;
1074 else if (dent
== phba
->debug_readRef
)
1075 phba
->lpfc_injerr_rref_cnt
= (uint32_t)tmp
;
1076 else if (dent
== phba
->debug_InjErrLBA
)
1077 phba
->lpfc_injerr_lba
= (sector_t
)tmp
;
1078 else if (dent
== phba
->debug_InjErrNPortID
)
1079 phba
->lpfc_injerr_nportid
= (uint32_t)(tmp
& Mask_DID
);
1080 else if (dent
== phba
->debug_InjErrWWPN
) {
1081 tmp
= cpu_to_be64(tmp
);
1082 memcpy(&phba
->lpfc_injerr_wwpn
, &tmp
, sizeof(struct lpfc_name
));
1084 lpfc_printf_log(phba
, KERN_ERR
, LOG_INIT
,
1085 "0548 Unknown debugfs error injection entry\n");
1091 lpfc_debugfs_dif_err_release(struct inode
*inode
, struct file
*file
)
1097 * lpfc_debugfs_nodelist_open - Open the nodelist debugfs file
1098 * @inode: The inode pointer that contains a vport pointer.
1099 * @file: The file pointer to attach the log output.
1102 * This routine is the entry point for the debugfs open file operation. It gets
1103 * the vport from the i_private field in @inode, allocates the necessary buffer
1104 * for the log, fills the buffer from the in-memory log for this vport, and then
1105 * returns a pointer to that log in the private_data field in @file.
1108 * This function returns zero if successful. On error it will return an negative
1112 lpfc_debugfs_nodelist_open(struct inode
*inode
, struct file
*file
)
1114 struct lpfc_vport
*vport
= inode
->i_private
;
1115 struct lpfc_debug
*debug
;
1118 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
1122 /* Round to page boundary */
1123 debug
->buffer
= kmalloc(LPFC_NODELIST_SIZE
, GFP_KERNEL
);
1124 if (!debug
->buffer
) {
1129 debug
->len
= lpfc_debugfs_nodelist_data(vport
, debug
->buffer
,
1130 LPFC_NODELIST_SIZE
);
1131 file
->private_data
= debug
;
1139 * lpfc_debugfs_lseek - Seek through a debugfs file
1140 * @file: The file pointer to seek through.
1141 * @off: The offset to seek to or the amount to seek by.
1142 * @whence: Indicates how to seek.
1145 * This routine is the entry point for the debugfs lseek file operation. The
1146 * @whence parameter indicates whether @off is the offset to directly seek to,
1147 * or if it is a value to seek forward or reverse by. This function figures out
1148 * what the new offset of the debugfs file will be and assigns that value to the
1149 * f_pos field of @file.
1152 * This function returns the new offset if successful and returns a negative
1153 * error if unable to process the seek.
1156 lpfc_debugfs_lseek(struct file
*file
, loff_t off
, int whence
)
1158 struct lpfc_debug
*debug
;
1161 debug
= file
->private_data
;
1168 pos
= file
->f_pos
+ off
;
1171 pos
= debug
->len
- off
;
1173 return (pos
< 0 || pos
> debug
->len
) ? -EINVAL
: (file
->f_pos
= pos
);
1177 * lpfc_debugfs_read - Read a debugfs file
1178 * @file: The file pointer to read from.
1179 * @buf: The buffer to copy the data to.
1180 * @nbytes: The number of bytes to read.
1181 * @ppos: The position in the file to start reading from.
1184 * This routine reads data from from the buffer indicated in the private_data
1185 * field of @file. It will start reading at @ppos and copy up to @nbytes of
1189 * This function returns the amount of data that was read (this could be less
1190 * than @nbytes if the end of the file was reached) or a negative error value.
1193 lpfc_debugfs_read(struct file
*file
, char __user
*buf
,
1194 size_t nbytes
, loff_t
*ppos
)
1196 struct lpfc_debug
*debug
= file
->private_data
;
1198 return simple_read_from_buffer(buf
, nbytes
, ppos
, debug
->buffer
,
1203 * lpfc_debugfs_release - Release the buffer used to store debugfs file data
1204 * @inode: The inode pointer that contains a vport pointer. (unused)
1205 * @file: The file pointer that contains the buffer to release.
1208 * This routine frees the buffer that was allocated when the debugfs file was
1212 * This function returns zero.
1215 lpfc_debugfs_release(struct inode
*inode
, struct file
*file
)
1217 struct lpfc_debug
*debug
= file
->private_data
;
1219 kfree(debug
->buffer
);
1226 lpfc_debugfs_dumpDataDif_release(struct inode
*inode
, struct file
*file
)
1228 struct lpfc_debug
*debug
= file
->private_data
;
1230 debug
->buffer
= NULL
;
1237 * ---------------------------------
1238 * iDiag debugfs file access methods
1239 * ---------------------------------
1241 * All access methods are through the proper SLI4 PCI function's debugfs
1244 * /sys/kernel/debug/lpfc/fn<#>/iDiag
1248 * lpfc_idiag_cmd_get - Get and parse idiag debugfs comands from user space
1249 * @buf: The pointer to the user space buffer.
1250 * @nbytes: The number of bytes in the user space buffer.
1251 * @idiag_cmd: pointer to the idiag command struct.
1253 * This routine reads data from debugfs user space buffer and parses the
1254 * buffer for getting the idiag command and arguments. The while space in
1255 * between the set of data is used as the parsing separator.
1257 * This routine returns 0 when successful, it returns proper error code
1258 * back to the user space in error conditions.
1260 static int lpfc_idiag_cmd_get(const char __user
*buf
, size_t nbytes
,
1261 struct lpfc_idiag_cmd
*idiag_cmd
)
1264 char *pbuf
, *step_str
;
1268 /* Protect copy from user */
1269 if (!access_ok(VERIFY_READ
, buf
, nbytes
))
1272 memset(mybuf
, 0, sizeof(mybuf
));
1273 memset(idiag_cmd
, 0, sizeof(*idiag_cmd
));
1274 bsize
= min(nbytes
, (sizeof(mybuf
)-1));
1276 if (copy_from_user(mybuf
, buf
, bsize
))
1279 step_str
= strsep(&pbuf
, "\t ");
1281 /* The opcode must present */
1285 idiag_cmd
->opcode
= simple_strtol(step_str
, NULL
, 0);
1286 if (idiag_cmd
->opcode
== 0)
1289 for (i
= 0; i
< LPFC_IDIAG_CMD_DATA_SIZE
; i
++) {
1290 step_str
= strsep(&pbuf
, "\t ");
1293 idiag_cmd
->data
[i
] = simple_strtol(step_str
, NULL
, 0);
1299 * lpfc_idiag_open - idiag open debugfs
1300 * @inode: The inode pointer that contains a pointer to phba.
1301 * @file: The file pointer to attach the file operation.
1304 * This routine is the entry point for the debugfs open file operation. It
1305 * gets the reference to phba from the i_private field in @inode, it then
1306 * allocates buffer for the file operation, performs the necessary PCI config
1307 * space read into the allocated buffer according to the idiag user command
1308 * setup, and then returns a pointer to buffer in the private_data field in
1312 * This function returns zero if successful. On error it will return an
1313 * negative error value.
1316 lpfc_idiag_open(struct inode
*inode
, struct file
*file
)
1318 struct lpfc_debug
*debug
;
1320 debug
= kmalloc(sizeof(*debug
), GFP_KERNEL
);
1324 debug
->i_private
= inode
->i_private
;
1325 debug
->buffer
= NULL
;
1326 file
->private_data
= debug
;
1332 * lpfc_idiag_release - Release idiag access file operation
1333 * @inode: The inode pointer that contains a vport pointer. (unused)
1334 * @file: The file pointer that contains the buffer to release.
1337 * This routine is the generic release routine for the idiag access file
1338 * operation, it frees the buffer that was allocated when the debugfs file
1342 * This function returns zero.
1345 lpfc_idiag_release(struct inode
*inode
, struct file
*file
)
1347 struct lpfc_debug
*debug
= file
->private_data
;
1349 /* Free the buffers to the file operation */
1350 kfree(debug
->buffer
);
1357 * lpfc_idiag_cmd_release - Release idiag cmd access file operation
1358 * @inode: The inode pointer that contains a vport pointer. (unused)
1359 * @file: The file pointer that contains the buffer to release.
1362 * This routine frees the buffer that was allocated when the debugfs file
1363 * was opened. It also reset the fields in the idiag command struct in the
1364 * case of command for write operation.
1367 * This function returns zero.
1370 lpfc_idiag_cmd_release(struct inode
*inode
, struct file
*file
)
1372 struct lpfc_debug
*debug
= file
->private_data
;
1374 if (debug
->op
== LPFC_IDIAG_OP_WR
) {
1375 switch (idiag
.cmd
.opcode
) {
1376 case LPFC_IDIAG_CMD_PCICFG_WR
:
1377 case LPFC_IDIAG_CMD_PCICFG_ST
:
1378 case LPFC_IDIAG_CMD_PCICFG_CL
:
1379 case LPFC_IDIAG_CMD_QUEACC_WR
:
1380 case LPFC_IDIAG_CMD_QUEACC_ST
:
1381 case LPFC_IDIAG_CMD_QUEACC_CL
:
1382 memset(&idiag
, 0, sizeof(idiag
));
1389 /* Free the buffers to the file operation */
1390 kfree(debug
->buffer
);
1397 * lpfc_idiag_pcicfg_read - idiag debugfs read pcicfg
1398 * @file: The file pointer to read from.
1399 * @buf: The buffer to copy the data to.
1400 * @nbytes: The number of bytes to read.
1401 * @ppos: The position in the file to start reading from.
1404 * This routine reads data from the @phba pci config space according to the
1405 * idiag command, and copies to user @buf. Depending on the PCI config space
1406 * read command setup, it does either a single register read of a byte
1407 * (8 bits), a word (16 bits), or a dword (32 bits) or browsing through all
1408 * registers from the 4K extended PCI config space.
1411 * This function returns the amount of data that was read (this could be less
1412 * than @nbytes if the end of the file was reached) or a negative error value.
1415 lpfc_idiag_pcicfg_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
1418 struct lpfc_debug
*debug
= file
->private_data
;
1419 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
1420 int offset_label
, offset
, len
= 0, index
= LPFC_PCI_CFG_RD_SIZE
;
1423 struct pci_dev
*pdev
;
1428 pdev
= phba
->pcidev
;
1432 /* This is a user read operation */
1433 debug
->op
= LPFC_IDIAG_OP_RD
;
1436 debug
->buffer
= kmalloc(LPFC_PCI_CFG_SIZE
, GFP_KERNEL
);
1439 pbuffer
= debug
->buffer
;
1444 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_RD
) {
1445 where
= idiag
.cmd
.data
[IDIAG_PCICFG_WHERE_INDX
];
1446 count
= idiag
.cmd
.data
[IDIAG_PCICFG_COUNT_INDX
];
1450 /* Read single PCI config space register */
1452 case SIZE_U8
: /* byte (8 bits) */
1453 pci_read_config_byte(pdev
, where
, &u8val
);
1454 len
+= snprintf(pbuffer
+len
, LPFC_PCI_CFG_SIZE
-len
,
1455 "%03x: %02x\n", where
, u8val
);
1457 case SIZE_U16
: /* word (16 bits) */
1458 pci_read_config_word(pdev
, where
, &u16val
);
1459 len
+= snprintf(pbuffer
+len
, LPFC_PCI_CFG_SIZE
-len
,
1460 "%03x: %04x\n", where
, u16val
);
1462 case SIZE_U32
: /* double word (32 bits) */
1463 pci_read_config_dword(pdev
, where
, &u32val
);
1464 len
+= snprintf(pbuffer
+len
, LPFC_PCI_CFG_SIZE
-len
,
1465 "%03x: %08x\n", where
, u32val
);
1467 case LPFC_PCI_CFG_BROWSE
: /* browse all */
1475 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
1479 /* Browse all PCI config space registers */
1480 offset_label
= idiag
.offset
.last_rd
;
1481 offset
= offset_label
;
1483 /* Read PCI config space */
1484 len
+= snprintf(pbuffer
+len
, LPFC_PCI_CFG_SIZE
-len
,
1485 "%03x: ", offset_label
);
1487 pci_read_config_dword(pdev
, offset
, &u32val
);
1488 len
+= snprintf(pbuffer
+len
, LPFC_PCI_CFG_SIZE
-len
,
1490 offset
+= sizeof(uint32_t);
1491 if (offset
>= LPFC_PCI_CFG_SIZE
) {
1492 len
+= snprintf(pbuffer
+len
,
1493 LPFC_PCI_CFG_SIZE
-len
, "\n");
1496 index
-= sizeof(uint32_t);
1498 len
+= snprintf(pbuffer
+len
, LPFC_PCI_CFG_SIZE
-len
,
1500 else if (!(index
% (8 * sizeof(uint32_t)))) {
1501 offset_label
+= (8 * sizeof(uint32_t));
1502 len
+= snprintf(pbuffer
+len
, LPFC_PCI_CFG_SIZE
-len
,
1503 "\n%03x: ", offset_label
);
1507 /* Set up the offset for next portion of pci cfg read */
1509 idiag
.offset
.last_rd
+= LPFC_PCI_CFG_RD_SIZE
;
1510 if (idiag
.offset
.last_rd
>= LPFC_PCI_CFG_SIZE
)
1511 idiag
.offset
.last_rd
= 0;
1513 idiag
.offset
.last_rd
= 0;
1515 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
1519 * lpfc_idiag_pcicfg_write - Syntax check and set up idiag pcicfg commands
1520 * @file: The file pointer to read from.
1521 * @buf: The buffer to copy the user data from.
1522 * @nbytes: The number of bytes to get.
1523 * @ppos: The position in the file to start reading from.
1525 * This routine get the debugfs idiag command struct from user space and
1526 * then perform the syntax check for PCI config space read or write command
1527 * accordingly. In the case of PCI config space read command, it sets up
1528 * the command in the idiag command struct for the debugfs read operation.
1529 * In the case of PCI config space write operation, it executes the write
1530 * operation into the PCI config space accordingly.
1532 * It returns the @nbytges passing in from debugfs user space when successful.
1533 * In case of error conditions, it returns proper error code back to the user
1537 lpfc_idiag_pcicfg_write(struct file
*file
, const char __user
*buf
,
1538 size_t nbytes
, loff_t
*ppos
)
1540 struct lpfc_debug
*debug
= file
->private_data
;
1541 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
1542 uint32_t where
, value
, count
;
1546 struct pci_dev
*pdev
;
1549 pdev
= phba
->pcidev
;
1553 /* This is a user write operation */
1554 debug
->op
= LPFC_IDIAG_OP_WR
;
1556 rc
= lpfc_idiag_cmd_get(buf
, nbytes
, &idiag
.cmd
);
1560 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_RD
) {
1561 /* Sanity check on PCI config read command line arguments */
1562 if (rc
!= LPFC_PCI_CFG_RD_CMD_ARG
)
1564 /* Read command from PCI config space, set up command fields */
1565 where
= idiag
.cmd
.data
[IDIAG_PCICFG_WHERE_INDX
];
1566 count
= idiag
.cmd
.data
[IDIAG_PCICFG_COUNT_INDX
];
1567 if (count
== LPFC_PCI_CFG_BROWSE
) {
1568 if (where
% sizeof(uint32_t))
1570 /* Starting offset to browse */
1571 idiag
.offset
.last_rd
= where
;
1572 } else if ((count
!= sizeof(uint8_t)) &&
1573 (count
!= sizeof(uint16_t)) &&
1574 (count
!= sizeof(uint32_t)))
1576 if (count
== sizeof(uint8_t)) {
1577 if (where
> LPFC_PCI_CFG_SIZE
- sizeof(uint8_t))
1579 if (where
% sizeof(uint8_t))
1582 if (count
== sizeof(uint16_t)) {
1583 if (where
> LPFC_PCI_CFG_SIZE
- sizeof(uint16_t))
1585 if (where
% sizeof(uint16_t))
1588 if (count
== sizeof(uint32_t)) {
1589 if (where
> LPFC_PCI_CFG_SIZE
- sizeof(uint32_t))
1591 if (where
% sizeof(uint32_t))
1594 } else if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_WR
||
1595 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_ST
||
1596 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_CL
) {
1597 /* Sanity check on PCI config write command line arguments */
1598 if (rc
!= LPFC_PCI_CFG_WR_CMD_ARG
)
1600 /* Write command to PCI config space, read-modify-write */
1601 where
= idiag
.cmd
.data
[IDIAG_PCICFG_WHERE_INDX
];
1602 count
= idiag
.cmd
.data
[IDIAG_PCICFG_COUNT_INDX
];
1603 value
= idiag
.cmd
.data
[IDIAG_PCICFG_VALUE_INDX
];
1605 if ((count
!= sizeof(uint8_t)) &&
1606 (count
!= sizeof(uint16_t)) &&
1607 (count
!= sizeof(uint32_t)))
1609 if (count
== sizeof(uint8_t)) {
1610 if (where
> LPFC_PCI_CFG_SIZE
- sizeof(uint8_t))
1612 if (where
% sizeof(uint8_t))
1614 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_WR
)
1615 pci_write_config_byte(pdev
, where
,
1617 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_ST
) {
1618 rc
= pci_read_config_byte(pdev
, where
, &u8val
);
1620 u8val
|= (uint8_t)value
;
1621 pci_write_config_byte(pdev
, where
,
1625 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_CL
) {
1626 rc
= pci_read_config_byte(pdev
, where
, &u8val
);
1628 u8val
&= (uint8_t)(~value
);
1629 pci_write_config_byte(pdev
, where
,
1634 if (count
== sizeof(uint16_t)) {
1635 if (where
> LPFC_PCI_CFG_SIZE
- sizeof(uint16_t))
1637 if (where
% sizeof(uint16_t))
1639 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_WR
)
1640 pci_write_config_word(pdev
, where
,
1642 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_ST
) {
1643 rc
= pci_read_config_word(pdev
, where
, &u16val
);
1645 u16val
|= (uint16_t)value
;
1646 pci_write_config_word(pdev
, where
,
1650 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_CL
) {
1651 rc
= pci_read_config_word(pdev
, where
, &u16val
);
1653 u16val
&= (uint16_t)(~value
);
1654 pci_write_config_word(pdev
, where
,
1659 if (count
== sizeof(uint32_t)) {
1660 if (where
> LPFC_PCI_CFG_SIZE
- sizeof(uint32_t))
1662 if (where
% sizeof(uint32_t))
1664 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_WR
)
1665 pci_write_config_dword(pdev
, where
, value
);
1666 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_ST
) {
1667 rc
= pci_read_config_dword(pdev
, where
,
1671 pci_write_config_dword(pdev
, where
,
1675 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_PCICFG_CL
) {
1676 rc
= pci_read_config_dword(pdev
, where
,
1680 pci_write_config_dword(pdev
, where
,
1686 /* All other opecodes are illegal for now */
1691 memset(&idiag
, 0, sizeof(idiag
));
1696 * lpfc_idiag_baracc_read - idiag debugfs pci bar access read
1697 * @file: The file pointer to read from.
1698 * @buf: The buffer to copy the data to.
1699 * @nbytes: The number of bytes to read.
1700 * @ppos: The position in the file to start reading from.
1703 * This routine reads data from the @phba pci bar memory mapped space
1704 * according to the idiag command, and copies to user @buf.
1707 * This function returns the amount of data that was read (this could be less
1708 * than @nbytes if the end of the file was reached) or a negative error value.
1711 lpfc_idiag_baracc_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
1714 struct lpfc_debug
*debug
= file
->private_data
;
1715 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
1716 int offset_label
, offset
, offset_run
, len
= 0, index
;
1717 int bar_num
, acc_range
, bar_size
;
1719 void __iomem
*mem_mapped_bar
;
1721 struct pci_dev
*pdev
;
1724 pdev
= phba
->pcidev
;
1728 /* This is a user read operation */
1729 debug
->op
= LPFC_IDIAG_OP_RD
;
1732 debug
->buffer
= kmalloc(LPFC_PCI_BAR_RD_BUF_SIZE
, GFP_KERNEL
);
1735 pbuffer
= debug
->buffer
;
1740 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_RD
) {
1741 bar_num
= idiag
.cmd
.data
[IDIAG_BARACC_BAR_NUM_INDX
];
1742 offset
= idiag
.cmd
.data
[IDIAG_BARACC_OFF_SET_INDX
];
1743 acc_range
= idiag
.cmd
.data
[IDIAG_BARACC_ACC_MOD_INDX
];
1744 bar_size
= idiag
.cmd
.data
[IDIAG_BARACC_BAR_SZE_INDX
];
1751 if_type
= bf_get(lpfc_sli_intf_if_type
, &phba
->sli4_hba
.sli_intf
);
1752 if (if_type
== LPFC_SLI_INTF_IF_TYPE_0
) {
1753 if (bar_num
== IDIAG_BARACC_BAR_0
)
1754 mem_mapped_bar
= phba
->sli4_hba
.conf_regs_memmap_p
;
1755 else if (bar_num
== IDIAG_BARACC_BAR_1
)
1756 mem_mapped_bar
= phba
->sli4_hba
.ctrl_regs_memmap_p
;
1757 else if (bar_num
== IDIAG_BARACC_BAR_2
)
1758 mem_mapped_bar
= phba
->sli4_hba
.drbl_regs_memmap_p
;
1761 } else if (if_type
== LPFC_SLI_INTF_IF_TYPE_2
) {
1762 if (bar_num
== IDIAG_BARACC_BAR_0
)
1763 mem_mapped_bar
= phba
->sli4_hba
.conf_regs_memmap_p
;
1769 /* Read single PCI bar space register */
1770 if (acc_range
== SINGLE_WORD
) {
1771 offset_run
= offset
;
1772 u32val
= readl(mem_mapped_bar
+ offset_run
);
1773 len
+= snprintf(pbuffer
+len
, LPFC_PCI_BAR_RD_BUF_SIZE
-len
,
1774 "%05x: %08x\n", offset_run
, u32val
);
1778 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
1782 /* Browse all PCI bar space registers */
1783 offset_label
= idiag
.offset
.last_rd
;
1784 offset_run
= offset_label
;
1786 /* Read PCI bar memory mapped space */
1787 len
+= snprintf(pbuffer
+len
, LPFC_PCI_BAR_RD_BUF_SIZE
-len
,
1788 "%05x: ", offset_label
);
1789 index
= LPFC_PCI_BAR_RD_SIZE
;
1791 u32val
= readl(mem_mapped_bar
+ offset_run
);
1792 len
+= snprintf(pbuffer
+len
, LPFC_PCI_BAR_RD_BUF_SIZE
-len
,
1794 offset_run
+= sizeof(uint32_t);
1795 if (acc_range
== LPFC_PCI_BAR_BROWSE
) {
1796 if (offset_run
>= bar_size
) {
1797 len
+= snprintf(pbuffer
+len
,
1798 LPFC_PCI_BAR_RD_BUF_SIZE
-len
, "\n");
1802 if (offset_run
>= offset
+
1803 (acc_range
* sizeof(uint32_t))) {
1804 len
+= snprintf(pbuffer
+len
,
1805 LPFC_PCI_BAR_RD_BUF_SIZE
-len
, "\n");
1809 index
-= sizeof(uint32_t);
1811 len
+= snprintf(pbuffer
+len
,
1812 LPFC_PCI_BAR_RD_BUF_SIZE
-len
, "\n");
1813 else if (!(index
% (8 * sizeof(uint32_t)))) {
1814 offset_label
+= (8 * sizeof(uint32_t));
1815 len
+= snprintf(pbuffer
+len
,
1816 LPFC_PCI_BAR_RD_BUF_SIZE
-len
,
1817 "\n%05x: ", offset_label
);
1821 /* Set up the offset for next portion of pci bar read */
1823 idiag
.offset
.last_rd
+= LPFC_PCI_BAR_RD_SIZE
;
1824 if (acc_range
== LPFC_PCI_BAR_BROWSE
) {
1825 if (idiag
.offset
.last_rd
>= bar_size
)
1826 idiag
.offset
.last_rd
= 0;
1828 if (offset_run
>= offset
+
1829 (acc_range
* sizeof(uint32_t)))
1830 idiag
.offset
.last_rd
= offset
;
1833 if (acc_range
== LPFC_PCI_BAR_BROWSE
)
1834 idiag
.offset
.last_rd
= 0;
1836 idiag
.offset
.last_rd
= offset
;
1839 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
1843 * lpfc_idiag_baracc_write - Syntax check and set up idiag bar access commands
1844 * @file: The file pointer to read from.
1845 * @buf: The buffer to copy the user data from.
1846 * @nbytes: The number of bytes to get.
1847 * @ppos: The position in the file to start reading from.
1849 * This routine get the debugfs idiag command struct from user space and
1850 * then perform the syntax check for PCI bar memory mapped space read or
1851 * write command accordingly. In the case of PCI bar memory mapped space
1852 * read command, it sets up the command in the idiag command struct for
1853 * the debugfs read operation. In the case of PCI bar memorpy mapped space
1854 * write operation, it executes the write operation into the PCI bar memory
1855 * mapped space accordingly.
1857 * It returns the @nbytges passing in from debugfs user space when successful.
1858 * In case of error conditions, it returns proper error code back to the user
1862 lpfc_idiag_baracc_write(struct file
*file
, const char __user
*buf
,
1863 size_t nbytes
, loff_t
*ppos
)
1865 struct lpfc_debug
*debug
= file
->private_data
;
1866 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
1867 uint32_t bar_num
, bar_size
, offset
, value
, acc_range
;
1868 struct pci_dev
*pdev
;
1869 void __iomem
*mem_mapped_bar
;
1874 pdev
= phba
->pcidev
;
1878 /* This is a user write operation */
1879 debug
->op
= LPFC_IDIAG_OP_WR
;
1881 rc
= lpfc_idiag_cmd_get(buf
, nbytes
, &idiag
.cmd
);
1885 if_type
= bf_get(lpfc_sli_intf_if_type
, &phba
->sli4_hba
.sli_intf
);
1886 bar_num
= idiag
.cmd
.data
[IDIAG_BARACC_BAR_NUM_INDX
];
1888 if (if_type
== LPFC_SLI_INTF_IF_TYPE_0
) {
1889 if ((bar_num
!= IDIAG_BARACC_BAR_0
) &&
1890 (bar_num
!= IDIAG_BARACC_BAR_1
) &&
1891 (bar_num
!= IDIAG_BARACC_BAR_2
))
1893 } else if (if_type
== LPFC_SLI_INTF_IF_TYPE_2
) {
1894 if (bar_num
!= IDIAG_BARACC_BAR_0
)
1899 if (if_type
== LPFC_SLI_INTF_IF_TYPE_0
) {
1900 if (bar_num
== IDIAG_BARACC_BAR_0
) {
1901 idiag
.cmd
.data
[IDIAG_BARACC_BAR_SZE_INDX
] =
1902 LPFC_PCI_IF0_BAR0_SIZE
;
1903 mem_mapped_bar
= phba
->sli4_hba
.conf_regs_memmap_p
;
1904 } else if (bar_num
== IDIAG_BARACC_BAR_1
) {
1905 idiag
.cmd
.data
[IDIAG_BARACC_BAR_SZE_INDX
] =
1906 LPFC_PCI_IF0_BAR1_SIZE
;
1907 mem_mapped_bar
= phba
->sli4_hba
.ctrl_regs_memmap_p
;
1908 } else if (bar_num
== IDIAG_BARACC_BAR_2
) {
1909 idiag
.cmd
.data
[IDIAG_BARACC_BAR_SZE_INDX
] =
1910 LPFC_PCI_IF0_BAR2_SIZE
;
1911 mem_mapped_bar
= phba
->sli4_hba
.drbl_regs_memmap_p
;
1914 } else if (if_type
== LPFC_SLI_INTF_IF_TYPE_2
) {
1915 if (bar_num
== IDIAG_BARACC_BAR_0
) {
1916 idiag
.cmd
.data
[IDIAG_BARACC_BAR_SZE_INDX
] =
1917 LPFC_PCI_IF2_BAR0_SIZE
;
1918 mem_mapped_bar
= phba
->sli4_hba
.conf_regs_memmap_p
;
1924 offset
= idiag
.cmd
.data
[IDIAG_BARACC_OFF_SET_INDX
];
1925 if (offset
% sizeof(uint32_t))
1928 bar_size
= idiag
.cmd
.data
[IDIAG_BARACC_BAR_SZE_INDX
];
1929 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_RD
) {
1930 /* Sanity check on PCI config read command line arguments */
1931 if (rc
!= LPFC_PCI_BAR_RD_CMD_ARG
)
1933 acc_range
= idiag
.cmd
.data
[IDIAG_BARACC_ACC_MOD_INDX
];
1934 if (acc_range
== LPFC_PCI_BAR_BROWSE
) {
1935 if (offset
> bar_size
- sizeof(uint32_t))
1937 /* Starting offset to browse */
1938 idiag
.offset
.last_rd
= offset
;
1939 } else if (acc_range
> SINGLE_WORD
) {
1940 if (offset
+ acc_range
* sizeof(uint32_t) > bar_size
)
1942 /* Starting offset to browse */
1943 idiag
.offset
.last_rd
= offset
;
1944 } else if (acc_range
!= SINGLE_WORD
)
1946 } else if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_WR
||
1947 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_ST
||
1948 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_CL
) {
1949 /* Sanity check on PCI bar write command line arguments */
1950 if (rc
!= LPFC_PCI_BAR_WR_CMD_ARG
)
1952 /* Write command to PCI bar space, read-modify-write */
1953 acc_range
= SINGLE_WORD
;
1954 value
= idiag
.cmd
.data
[IDIAG_BARACC_REG_VAL_INDX
];
1955 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_WR
) {
1956 writel(value
, mem_mapped_bar
+ offset
);
1957 readl(mem_mapped_bar
+ offset
);
1959 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_ST
) {
1960 u32val
= readl(mem_mapped_bar
+ offset
);
1962 writel(u32val
, mem_mapped_bar
+ offset
);
1963 readl(mem_mapped_bar
+ offset
);
1965 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_BARACC_CL
) {
1966 u32val
= readl(mem_mapped_bar
+ offset
);
1968 writel(u32val
, mem_mapped_bar
+ offset
);
1969 readl(mem_mapped_bar
+ offset
);
1972 /* All other opecodes are illegal for now */
1977 memset(&idiag
, 0, sizeof(idiag
));
1982 * lpfc_idiag_queinfo_read - idiag debugfs read queue information
1983 * @file: The file pointer to read from.
1984 * @buf: The buffer to copy the data to.
1985 * @nbytes: The number of bytes to read.
1986 * @ppos: The position in the file to start reading from.
1989 * This routine reads data from the @phba SLI4 PCI function queue information,
1990 * and copies to user @buf.
1993 * This function returns the amount of data that was read (this could be less
1994 * than @nbytes if the end of the file was reached) or a negative error value.
1997 lpfc_idiag_queinfo_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
2000 struct lpfc_debug
*debug
= file
->private_data
;
2001 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
2002 int len
= 0, fcp_qidx
;
2006 debug
->buffer
= kmalloc(LPFC_QUE_INFO_GET_BUF_SIZE
, GFP_KERNEL
);
2009 pbuffer
= debug
->buffer
;
2014 /* Get slow-path event queue information */
2015 len
+= snprintf(pbuffer
+len
, LPFC_QUE_INFO_GET_BUF_SIZE
-len
,
2016 "Slow-path EQ information:\n");
2017 if (phba
->sli4_hba
.sp_eq
) {
2018 len
+= snprintf(pbuffer
+len
, LPFC_QUE_INFO_GET_BUF_SIZE
-len
,
2020 "QE-COUNT[%04d], QE-SIZE[%04d], "
2021 "HOST-INDEX[%04d], PORT-INDEX[%04d]\n\n",
2022 phba
->sli4_hba
.sp_eq
->queue_id
,
2023 phba
->sli4_hba
.sp_eq
->entry_count
,
2024 phba
->sli4_hba
.sp_eq
->entry_size
,
2025 phba
->sli4_hba
.sp_eq
->host_index
,
2026 phba
->sli4_hba
.sp_eq
->hba_index
);
2029 /* Get fast-path event queue information */
2030 len
+= snprintf(pbuffer
+len
, LPFC_QUE_INFO_GET_BUF_SIZE
-len
,
2031 "Fast-path EQ information:\n");
2032 if (phba
->sli4_hba
.fp_eq
) {
2033 for (fcp_qidx
= 0; fcp_qidx
< phba
->cfg_fcp_eq_count
;
2035 if (phba
->sli4_hba
.fp_eq
[fcp_qidx
]) {
2036 len
+= snprintf(pbuffer
+len
,
2037 LPFC_QUE_INFO_GET_BUF_SIZE
-len
,
2039 "QE-COUNT[%04d], QE-SIZE[%04d], "
2040 "HOST-INDEX[%04d], PORT-INDEX[%04d]\n",
2041 phba
->sli4_hba
.fp_eq
[fcp_qidx
]->queue_id
,
2042 phba
->sli4_hba
.fp_eq
[fcp_qidx
]->entry_count
,
2043 phba
->sli4_hba
.fp_eq
[fcp_qidx
]->entry_size
,
2044 phba
->sli4_hba
.fp_eq
[fcp_qidx
]->host_index
,
2045 phba
->sli4_hba
.fp_eq
[fcp_qidx
]->hba_index
);
2049 len
+= snprintf(pbuffer
+len
, LPFC_QUE_INFO_GET_BUF_SIZE
-len
, "\n");
2051 /* Get mailbox complete queue information */
2052 len
+= snprintf(pbuffer
+len
, LPFC_QUE_INFO_GET_BUF_SIZE
-len
,
2053 "Slow-path MBX CQ information:\n");
2054 if (phba
->sli4_hba
.mbx_cq
) {
2055 len
+= snprintf(pbuffer
+len
, LPFC_QUE_INFO_GET_BUF_SIZE
-len
,
2056 "Associated EQID[%02d]:\n",
2057 phba
->sli4_hba
.mbx_cq
->assoc_qid
);
2058 len
+= snprintf(pbuffer
+len
, LPFC_QUE_INFO_GET_BUF_SIZE
-len
,
2060 "QE-COUNT[%04d], QE-SIZE[%04d], "
2061 "HOST-INDEX[%04d], PORT-INDEX[%04d]\n\n",
2062 phba
->sli4_hba
.mbx_cq
->queue_id
,
2063 phba
->sli4_hba
.mbx_cq
->entry_count
,
2064 phba
->sli4_hba
.mbx_cq
->entry_size
,
2065 phba
->sli4_hba
.mbx_cq
->host_index
,
2066 phba
->sli4_hba
.mbx_cq
->hba_index
);
2069 /* Get slow-path complete queue information */
2070 len
+= snprintf(pbuffer
+len
, LPFC_QUE_INFO_GET_BUF_SIZE
-len
,
2071 "Slow-path ELS CQ information:\n");
2072 if (phba
->sli4_hba
.els_cq
) {
2073 len
+= snprintf(pbuffer
+len
, LPFC_QUE_INFO_GET_BUF_SIZE
-len
,
2074 "Associated EQID[%02d]:\n",
2075 phba
->sli4_hba
.els_cq
->assoc_qid
);
2076 len
+= snprintf(pbuffer
+len
, LPFC_QUE_INFO_GET_BUF_SIZE
-len
,
2078 "QE-COUNT[%04d], QE-SIZE[%04d], "
2079 "HOST-INDEX[%04d], PORT-INDEX[%04d]\n\n",
2080 phba
->sli4_hba
.els_cq
->queue_id
,
2081 phba
->sli4_hba
.els_cq
->entry_count
,
2082 phba
->sli4_hba
.els_cq
->entry_size
,
2083 phba
->sli4_hba
.els_cq
->host_index
,
2084 phba
->sli4_hba
.els_cq
->hba_index
);
2087 /* Get fast-path complete queue information */
2088 len
+= snprintf(pbuffer
+len
, LPFC_QUE_INFO_GET_BUF_SIZE
-len
,
2089 "Fast-path FCP CQ information:\n");
2091 if (phba
->sli4_hba
.fcp_cq
) {
2093 if (phba
->sli4_hba
.fcp_cq
[fcp_qidx
]) {
2094 len
+= snprintf(pbuffer
+len
,
2095 LPFC_QUE_INFO_GET_BUF_SIZE
-len
,
2096 "Associated EQID[%02d]:\n",
2097 phba
->sli4_hba
.fcp_cq
[fcp_qidx
]->assoc_qid
);
2098 len
+= snprintf(pbuffer
+len
,
2099 LPFC_QUE_INFO_GET_BUF_SIZE
-len
,
2101 "QE-COUNT[%04d], QE-SIZE[%04d], "
2102 "HOST-INDEX[%04d], PORT-INDEX[%04d]\n",
2103 phba
->sli4_hba
.fcp_cq
[fcp_qidx
]->queue_id
,
2104 phba
->sli4_hba
.fcp_cq
[fcp_qidx
]->entry_count
,
2105 phba
->sli4_hba
.fcp_cq
[fcp_qidx
]->entry_size
,
2106 phba
->sli4_hba
.fcp_cq
[fcp_qidx
]->host_index
,
2107 phba
->sli4_hba
.fcp_cq
[fcp_qidx
]->hba_index
);
2109 } while (++fcp_qidx
< phba
->cfg_fcp_eq_count
);
2110 len
+= snprintf(pbuffer
+len
,
2111 LPFC_QUE_INFO_GET_BUF_SIZE
-len
, "\n");
2114 /* Get mailbox queue information */
2115 len
+= snprintf(pbuffer
+len
, LPFC_QUE_INFO_GET_BUF_SIZE
-len
,
2116 "Slow-path MBX MQ information:\n");
2117 if (phba
->sli4_hba
.mbx_wq
) {
2118 len
+= snprintf(pbuffer
+len
, LPFC_QUE_INFO_GET_BUF_SIZE
-len
,
2119 "Associated CQID[%02d]:\n",
2120 phba
->sli4_hba
.mbx_wq
->assoc_qid
);
2121 len
+= snprintf(pbuffer
+len
, LPFC_QUE_INFO_GET_BUF_SIZE
-len
,
2123 "QE-COUNT[%04d], QE-SIZE[%04d], "
2124 "HOST-INDEX[%04d], PORT-INDEX[%04d]\n\n",
2125 phba
->sli4_hba
.mbx_wq
->queue_id
,
2126 phba
->sli4_hba
.mbx_wq
->entry_count
,
2127 phba
->sli4_hba
.mbx_wq
->entry_size
,
2128 phba
->sli4_hba
.mbx_wq
->host_index
,
2129 phba
->sli4_hba
.mbx_wq
->hba_index
);
2132 /* Get slow-path work queue information */
2133 len
+= snprintf(pbuffer
+len
, LPFC_QUE_INFO_GET_BUF_SIZE
-len
,
2134 "Slow-path ELS WQ information:\n");
2135 if (phba
->sli4_hba
.els_wq
) {
2136 len
+= snprintf(pbuffer
+len
, LPFC_QUE_INFO_GET_BUF_SIZE
-len
,
2137 "Associated CQID[%02d]:\n",
2138 phba
->sli4_hba
.els_wq
->assoc_qid
);
2139 len
+= snprintf(pbuffer
+len
, LPFC_QUE_INFO_GET_BUF_SIZE
-len
,
2141 "QE-COUNT[%04d], QE-SIZE[%04d], "
2142 "HOST-INDEX[%04d], PORT-INDEX[%04d]\n\n",
2143 phba
->sli4_hba
.els_wq
->queue_id
,
2144 phba
->sli4_hba
.els_wq
->entry_count
,
2145 phba
->sli4_hba
.els_wq
->entry_size
,
2146 phba
->sli4_hba
.els_wq
->host_index
,
2147 phba
->sli4_hba
.els_wq
->hba_index
);
2150 /* Get fast-path work queue information */
2151 len
+= snprintf(pbuffer
+len
, LPFC_QUE_INFO_GET_BUF_SIZE
-len
,
2152 "Fast-path FCP WQ information:\n");
2153 if (phba
->sli4_hba
.fcp_wq
) {
2154 for (fcp_qidx
= 0; fcp_qidx
< phba
->cfg_fcp_wq_count
;
2156 if (!phba
->sli4_hba
.fcp_wq
[fcp_qidx
])
2158 len
+= snprintf(pbuffer
+len
,
2159 LPFC_QUE_INFO_GET_BUF_SIZE
-len
,
2160 "Associated CQID[%02d]:\n",
2161 phba
->sli4_hba
.fcp_wq
[fcp_qidx
]->assoc_qid
);
2162 len
+= snprintf(pbuffer
+len
,
2163 LPFC_QUE_INFO_GET_BUF_SIZE
-len
,
2165 "QE-COUNT[%04d], WQE-SIZE[%04d], "
2166 "HOST-INDEX[%04d], PORT-INDEX[%04d]\n",
2167 phba
->sli4_hba
.fcp_wq
[fcp_qidx
]->queue_id
,
2168 phba
->sli4_hba
.fcp_wq
[fcp_qidx
]->entry_count
,
2169 phba
->sli4_hba
.fcp_wq
[fcp_qidx
]->entry_size
,
2170 phba
->sli4_hba
.fcp_wq
[fcp_qidx
]->host_index
,
2171 phba
->sli4_hba
.fcp_wq
[fcp_qidx
]->hba_index
);
2173 len
+= snprintf(pbuffer
+len
,
2174 LPFC_QUE_INFO_GET_BUF_SIZE
-len
, "\n");
2177 /* Get receive queue information */
2178 len
+= snprintf(pbuffer
+len
, LPFC_QUE_INFO_GET_BUF_SIZE
-len
,
2179 "Slow-path RQ information:\n");
2180 if (phba
->sli4_hba
.hdr_rq
&& phba
->sli4_hba
.dat_rq
) {
2181 len
+= snprintf(pbuffer
+len
, LPFC_QUE_INFO_GET_BUF_SIZE
-len
,
2182 "Associated CQID[%02d]:\n",
2183 phba
->sli4_hba
.hdr_rq
->assoc_qid
);
2184 len
+= snprintf(pbuffer
+len
, LPFC_QUE_INFO_GET_BUF_SIZE
-len
,
2186 "QE-COUNT[%04d], QE-SIZE[%04d], "
2187 "HOST-INDEX[%04d], PORT-INDEX[%04d]\n",
2188 phba
->sli4_hba
.hdr_rq
->queue_id
,
2189 phba
->sli4_hba
.hdr_rq
->entry_count
,
2190 phba
->sli4_hba
.hdr_rq
->entry_size
,
2191 phba
->sli4_hba
.hdr_rq
->host_index
,
2192 phba
->sli4_hba
.hdr_rq
->hba_index
);
2193 len
+= snprintf(pbuffer
+len
, LPFC_QUE_INFO_GET_BUF_SIZE
-len
,
2195 "QE-COUNT[%04d], QE-SIZE[%04d], "
2196 "HOST-INDEX[%04d], PORT-INDEX[%04d]\n",
2197 phba
->sli4_hba
.dat_rq
->queue_id
,
2198 phba
->sli4_hba
.dat_rq
->entry_count
,
2199 phba
->sli4_hba
.dat_rq
->entry_size
,
2200 phba
->sli4_hba
.dat_rq
->host_index
,
2201 phba
->sli4_hba
.dat_rq
->hba_index
);
2203 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
2207 * lpfc_idiag_que_param_check - queue access command parameter sanity check
2208 * @q: The pointer to queue structure.
2209 * @index: The index into a queue entry.
2210 * @count: The number of queue entries to access.
2213 * The routine performs sanity check on device queue access method commands.
2216 * This function returns -EINVAL when fails the sanity check, otherwise, it
2220 lpfc_idiag_que_param_check(struct lpfc_queue
*q
, int index
, int count
)
2222 /* Only support single entry read or browsing */
2223 if ((count
!= 1) && (count
!= LPFC_QUE_ACC_BROWSE
))
2225 if (index
> q
->entry_count
- 1)
2231 * lpfc_idiag_queacc_read_qe - read a single entry from the given queue index
2232 * @pbuffer: The pointer to buffer to copy the read data into.
2233 * @pque: The pointer to the queue to be read.
2234 * @index: The index into the queue entry.
2237 * This routine reads out a single entry from the given queue's index location
2238 * and copies it into the buffer provided.
2241 * This function returns 0 when it fails, otherwise, it returns the length of
2242 * the data read into the buffer provided.
2245 lpfc_idiag_queacc_read_qe(char *pbuffer
, int len
, struct lpfc_queue
*pque
,
2251 if (!pbuffer
|| !pque
)
2254 esize
= pque
->entry_size
;
2255 len
+= snprintf(pbuffer
+len
, LPFC_QUE_ACC_BUF_SIZE
-len
,
2256 "QE-INDEX[%04d]:\n", index
);
2259 pentry
= pque
->qe
[index
].address
;
2261 len
+= snprintf(pbuffer
+len
, LPFC_QUE_ACC_BUF_SIZE
-len
,
2264 offset
+= sizeof(uint32_t);
2265 esize
-= sizeof(uint32_t);
2266 if (esize
> 0 && !(offset
% (4 * sizeof(uint32_t))))
2267 len
+= snprintf(pbuffer
+len
,
2268 LPFC_QUE_ACC_BUF_SIZE
-len
, "\n");
2270 len
+= snprintf(pbuffer
+len
, LPFC_QUE_ACC_BUF_SIZE
-len
, "\n");
2276 * lpfc_idiag_queacc_read - idiag debugfs read port queue
2277 * @file: The file pointer to read from.
2278 * @buf: The buffer to copy the data to.
2279 * @nbytes: The number of bytes to read.
2280 * @ppos: The position in the file to start reading from.
2283 * This routine reads data from the @phba device queue memory according to the
2284 * idiag command, and copies to user @buf. Depending on the queue dump read
2285 * command setup, it does either a single queue entry read or browing through
2286 * all entries of the queue.
2289 * This function returns the amount of data that was read (this could be less
2290 * than @nbytes if the end of the file was reached) or a negative error value.
2293 lpfc_idiag_queacc_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
2296 struct lpfc_debug
*debug
= file
->private_data
;
2297 uint32_t last_index
, index
, count
;
2298 struct lpfc_queue
*pque
= NULL
;
2302 /* This is a user read operation */
2303 debug
->op
= LPFC_IDIAG_OP_RD
;
2306 debug
->buffer
= kmalloc(LPFC_QUE_ACC_BUF_SIZE
, GFP_KERNEL
);
2309 pbuffer
= debug
->buffer
;
2314 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_RD
) {
2315 index
= idiag
.cmd
.data
[IDIAG_QUEACC_INDEX_INDX
];
2316 count
= idiag
.cmd
.data
[IDIAG_QUEACC_COUNT_INDX
];
2317 pque
= (struct lpfc_queue
*)idiag
.ptr_private
;
2321 /* Browse the queue starting from index */
2322 if (count
== LPFC_QUE_ACC_BROWSE
)
2325 /* Read a single entry from the queue */
2326 len
= lpfc_idiag_queacc_read_qe(pbuffer
, len
, pque
, index
);
2328 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
2332 /* Browse all entries from the queue */
2333 last_index
= idiag
.offset
.last_rd
;
2336 while (len
< LPFC_QUE_ACC_SIZE
- pque
->entry_size
) {
2337 len
= lpfc_idiag_queacc_read_qe(pbuffer
, len
, pque
, index
);
2339 if (index
> pque
->entry_count
- 1)
2343 /* Set up the offset for next portion of pci cfg read */
2344 if (index
> pque
->entry_count
- 1)
2346 idiag
.offset
.last_rd
= index
;
2348 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
2352 * lpfc_idiag_queacc_write - Syntax check and set up idiag queacc commands
2353 * @file: The file pointer to read from.
2354 * @buf: The buffer to copy the user data from.
2355 * @nbytes: The number of bytes to get.
2356 * @ppos: The position in the file to start reading from.
2358 * This routine get the debugfs idiag command struct from user space and then
2359 * perform the syntax check for port queue read (dump) or write (set) command
2360 * accordingly. In the case of port queue read command, it sets up the command
2361 * in the idiag command struct for the following debugfs read operation. In
2362 * the case of port queue write operation, it executes the write operation
2363 * into the port queue entry accordingly.
2365 * It returns the @nbytges passing in from debugfs user space when successful.
2366 * In case of error conditions, it returns proper error code back to the user
2370 lpfc_idiag_queacc_write(struct file
*file
, const char __user
*buf
,
2371 size_t nbytes
, loff_t
*ppos
)
2373 struct lpfc_debug
*debug
= file
->private_data
;
2374 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
2375 uint32_t qidx
, quetp
, queid
, index
, count
, offset
, value
;
2377 struct lpfc_queue
*pque
;
2380 /* This is a user write operation */
2381 debug
->op
= LPFC_IDIAG_OP_WR
;
2383 rc
= lpfc_idiag_cmd_get(buf
, nbytes
, &idiag
.cmd
);
2387 /* Get and sanity check on command feilds */
2388 quetp
= idiag
.cmd
.data
[IDIAG_QUEACC_QUETP_INDX
];
2389 queid
= idiag
.cmd
.data
[IDIAG_QUEACC_QUEID_INDX
];
2390 index
= idiag
.cmd
.data
[IDIAG_QUEACC_INDEX_INDX
];
2391 count
= idiag
.cmd
.data
[IDIAG_QUEACC_COUNT_INDX
];
2392 offset
= idiag
.cmd
.data
[IDIAG_QUEACC_OFFST_INDX
];
2393 value
= idiag
.cmd
.data
[IDIAG_QUEACC_VALUE_INDX
];
2395 /* Sanity check on command line arguments */
2396 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_WR
||
2397 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_ST
||
2398 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_CL
) {
2399 if (rc
!= LPFC_QUE_ACC_WR_CMD_ARG
)
2403 } else if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_RD
) {
2404 if (rc
!= LPFC_QUE_ACC_RD_CMD_ARG
)
2411 /* Slow-path event queue */
2412 if (phba
->sli4_hba
.sp_eq
&&
2413 phba
->sli4_hba
.sp_eq
->queue_id
== queid
) {
2415 rc
= lpfc_idiag_que_param_check(
2416 phba
->sli4_hba
.sp_eq
, index
, count
);
2419 idiag
.ptr_private
= phba
->sli4_hba
.sp_eq
;
2422 /* Fast-path event queue */
2423 if (phba
->sli4_hba
.fp_eq
) {
2424 for (qidx
= 0; qidx
< phba
->cfg_fcp_eq_count
; qidx
++) {
2425 if (phba
->sli4_hba
.fp_eq
[qidx
] &&
2426 phba
->sli4_hba
.fp_eq
[qidx
]->queue_id
==
2429 rc
= lpfc_idiag_que_param_check(
2430 phba
->sli4_hba
.fp_eq
[qidx
],
2435 phba
->sli4_hba
.fp_eq
[qidx
];
2443 /* MBX complete queue */
2444 if (phba
->sli4_hba
.mbx_cq
&&
2445 phba
->sli4_hba
.mbx_cq
->queue_id
== queid
) {
2447 rc
= lpfc_idiag_que_param_check(
2448 phba
->sli4_hba
.mbx_cq
, index
, count
);
2451 idiag
.ptr_private
= phba
->sli4_hba
.mbx_cq
;
2454 /* ELS complete queue */
2455 if (phba
->sli4_hba
.els_cq
&&
2456 phba
->sli4_hba
.els_cq
->queue_id
== queid
) {
2458 rc
= lpfc_idiag_que_param_check(
2459 phba
->sli4_hba
.els_cq
, index
, count
);
2462 idiag
.ptr_private
= phba
->sli4_hba
.els_cq
;
2465 /* FCP complete queue */
2466 if (phba
->sli4_hba
.fcp_cq
) {
2469 if (phba
->sli4_hba
.fcp_cq
[qidx
] &&
2470 phba
->sli4_hba
.fcp_cq
[qidx
]->queue_id
==
2473 rc
= lpfc_idiag_que_param_check(
2474 phba
->sli4_hba
.fcp_cq
[qidx
],
2479 phba
->sli4_hba
.fcp_cq
[qidx
];
2482 } while (++qidx
< phba
->cfg_fcp_eq_count
);
2487 /* MBX work queue */
2488 if (phba
->sli4_hba
.mbx_wq
&&
2489 phba
->sli4_hba
.mbx_wq
->queue_id
== queid
) {
2491 rc
= lpfc_idiag_que_param_check(
2492 phba
->sli4_hba
.mbx_wq
, index
, count
);
2495 idiag
.ptr_private
= phba
->sli4_hba
.mbx_wq
;
2501 /* ELS work queue */
2502 if (phba
->sli4_hba
.els_wq
&&
2503 phba
->sli4_hba
.els_wq
->queue_id
== queid
) {
2505 rc
= lpfc_idiag_que_param_check(
2506 phba
->sli4_hba
.els_wq
, index
, count
);
2509 idiag
.ptr_private
= phba
->sli4_hba
.els_wq
;
2512 /* FCP work queue */
2513 if (phba
->sli4_hba
.fcp_wq
) {
2514 for (qidx
= 0; qidx
< phba
->cfg_fcp_wq_count
; qidx
++) {
2515 if (!phba
->sli4_hba
.fcp_wq
[qidx
])
2517 if (phba
->sli4_hba
.fcp_wq
[qidx
]->queue_id
==
2520 rc
= lpfc_idiag_que_param_check(
2521 phba
->sli4_hba
.fcp_wq
[qidx
],
2526 phba
->sli4_hba
.fcp_wq
[qidx
];
2535 if (phba
->sli4_hba
.hdr_rq
&&
2536 phba
->sli4_hba
.hdr_rq
->queue_id
== queid
) {
2538 rc
= lpfc_idiag_que_param_check(
2539 phba
->sli4_hba
.hdr_rq
, index
, count
);
2542 idiag
.ptr_private
= phba
->sli4_hba
.hdr_rq
;
2546 if (phba
->sli4_hba
.dat_rq
&&
2547 phba
->sli4_hba
.dat_rq
->queue_id
== queid
) {
2549 rc
= lpfc_idiag_que_param_check(
2550 phba
->sli4_hba
.dat_rq
, index
, count
);
2553 idiag
.ptr_private
= phba
->sli4_hba
.dat_rq
;
2565 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_RD
) {
2566 if (count
== LPFC_QUE_ACC_BROWSE
)
2567 idiag
.offset
.last_rd
= index
;
2570 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_WR
||
2571 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_ST
||
2572 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_CL
) {
2573 /* Additional sanity checks on write operation */
2574 pque
= (struct lpfc_queue
*)idiag
.ptr_private
;
2575 if (offset
> pque
->entry_size
/sizeof(uint32_t) - 1)
2577 pentry
= pque
->qe
[index
].address
;
2579 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_WR
)
2581 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_ST
)
2583 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_QUEACC_CL
)
2589 /* Clean out command structure on command error out */
2590 memset(&idiag
, 0, sizeof(idiag
));
2595 * lpfc_idiag_drbacc_read_reg - idiag debugfs read a doorbell register
2596 * @phba: The pointer to hba structure.
2597 * @pbuffer: The pointer to the buffer to copy the data to.
2598 * @len: The lenght of bytes to copied.
2599 * @drbregid: The id to doorbell registers.
2602 * This routine reads a doorbell register and copies its content to the
2603 * user buffer pointed to by @pbuffer.
2606 * This function returns the amount of data that was copied into @pbuffer.
2609 lpfc_idiag_drbacc_read_reg(struct lpfc_hba
*phba
, char *pbuffer
,
2610 int len
, uint32_t drbregid
)
2618 len
+= snprintf(pbuffer
+len
, LPFC_DRB_ACC_BUF_SIZE
-len
,
2619 "EQCQ-DRB-REG: 0x%08x\n",
2620 readl(phba
->sli4_hba
.EQCQDBregaddr
));
2623 len
+= snprintf(pbuffer
+len
, LPFC_DRB_ACC_BUF_SIZE
-len
,
2624 "MQ-DRB-REG: 0x%08x\n",
2625 readl(phba
->sli4_hba
.MQDBregaddr
));
2628 len
+= snprintf(pbuffer
+len
, LPFC_DRB_ACC_BUF_SIZE
-len
,
2629 "WQ-DRB-REG: 0x%08x\n",
2630 readl(phba
->sli4_hba
.WQDBregaddr
));
2633 len
+= snprintf(pbuffer
+len
, LPFC_DRB_ACC_BUF_SIZE
-len
,
2634 "RQ-DRB-REG: 0x%08x\n",
2635 readl(phba
->sli4_hba
.RQDBregaddr
));
2645 * lpfc_idiag_drbacc_read - idiag debugfs read port doorbell
2646 * @file: The file pointer to read from.
2647 * @buf: The buffer to copy the data to.
2648 * @nbytes: The number of bytes to read.
2649 * @ppos: The position in the file to start reading from.
2652 * This routine reads data from the @phba device doorbell register according
2653 * to the idiag command, and copies to user @buf. Depending on the doorbell
2654 * register read command setup, it does either a single doorbell register
2655 * read or dump all doorbell registers.
2658 * This function returns the amount of data that was read (this could be less
2659 * than @nbytes if the end of the file was reached) or a negative error value.
2662 lpfc_idiag_drbacc_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
2665 struct lpfc_debug
*debug
= file
->private_data
;
2666 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
2667 uint32_t drb_reg_id
, i
;
2671 /* This is a user read operation */
2672 debug
->op
= LPFC_IDIAG_OP_RD
;
2675 debug
->buffer
= kmalloc(LPFC_DRB_ACC_BUF_SIZE
, GFP_KERNEL
);
2678 pbuffer
= debug
->buffer
;
2683 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_RD
)
2684 drb_reg_id
= idiag
.cmd
.data
[IDIAG_DRBACC_REGID_INDX
];
2688 if (drb_reg_id
== LPFC_DRB_ACC_ALL
)
2689 for (i
= 1; i
<= LPFC_DRB_MAX
; i
++)
2690 len
= lpfc_idiag_drbacc_read_reg(phba
,
2693 len
= lpfc_idiag_drbacc_read_reg(phba
,
2694 pbuffer
, len
, drb_reg_id
);
2696 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
2700 * lpfc_idiag_drbacc_write - Syntax check and set up idiag drbacc commands
2701 * @file: The file pointer to read from.
2702 * @buf: The buffer to copy the user data from.
2703 * @nbytes: The number of bytes to get.
2704 * @ppos: The position in the file to start reading from.
2706 * This routine get the debugfs idiag command struct from user space and then
2707 * perform the syntax check for port doorbell register read (dump) or write
2708 * (set) command accordingly. In the case of port queue read command, it sets
2709 * up the command in the idiag command struct for the following debugfs read
2710 * operation. In the case of port doorbell register write operation, it
2711 * executes the write operation into the port doorbell register accordingly.
2713 * It returns the @nbytges passing in from debugfs user space when successful.
2714 * In case of error conditions, it returns proper error code back to the user
2718 lpfc_idiag_drbacc_write(struct file
*file
, const char __user
*buf
,
2719 size_t nbytes
, loff_t
*ppos
)
2721 struct lpfc_debug
*debug
= file
->private_data
;
2722 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
2723 uint32_t drb_reg_id
, value
, reg_val
= 0;
2724 void __iomem
*drb_reg
;
2727 /* This is a user write operation */
2728 debug
->op
= LPFC_IDIAG_OP_WR
;
2730 rc
= lpfc_idiag_cmd_get(buf
, nbytes
, &idiag
.cmd
);
2734 /* Sanity check on command line arguments */
2735 drb_reg_id
= idiag
.cmd
.data
[IDIAG_DRBACC_REGID_INDX
];
2736 value
= idiag
.cmd
.data
[IDIAG_DRBACC_VALUE_INDX
];
2738 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_WR
||
2739 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_ST
||
2740 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_CL
) {
2741 if (rc
!= LPFC_DRB_ACC_WR_CMD_ARG
)
2743 if (drb_reg_id
> LPFC_DRB_MAX
)
2745 } else if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_RD
) {
2746 if (rc
!= LPFC_DRB_ACC_RD_CMD_ARG
)
2748 if ((drb_reg_id
> LPFC_DRB_MAX
) &&
2749 (drb_reg_id
!= LPFC_DRB_ACC_ALL
))
2754 /* Perform the write access operation */
2755 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_WR
||
2756 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_ST
||
2757 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_CL
) {
2758 switch (drb_reg_id
) {
2760 drb_reg
= phba
->sli4_hba
.EQCQDBregaddr
;
2763 drb_reg
= phba
->sli4_hba
.MQDBregaddr
;
2766 drb_reg
= phba
->sli4_hba
.WQDBregaddr
;
2769 drb_reg
= phba
->sli4_hba
.RQDBregaddr
;
2775 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_WR
)
2777 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_ST
) {
2778 reg_val
= readl(drb_reg
);
2781 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_DRBACC_CL
) {
2782 reg_val
= readl(drb_reg
);
2785 writel(reg_val
, drb_reg
);
2786 readl(drb_reg
); /* flush */
2791 /* Clean out command structure on command error out */
2792 memset(&idiag
, 0, sizeof(idiag
));
2797 * lpfc_idiag_ctlacc_read_reg - idiag debugfs read a control registers
2798 * @phba: The pointer to hba structure.
2799 * @pbuffer: The pointer to the buffer to copy the data to.
2800 * @len: The lenght of bytes to copied.
2801 * @drbregid: The id to doorbell registers.
2804 * This routine reads a control register and copies its content to the
2805 * user buffer pointed to by @pbuffer.
2808 * This function returns the amount of data that was copied into @pbuffer.
2811 lpfc_idiag_ctlacc_read_reg(struct lpfc_hba
*phba
, char *pbuffer
,
2812 int len
, uint32_t ctlregid
)
2819 case LPFC_CTL_PORT_SEM
:
2820 len
+= snprintf(pbuffer
+len
, LPFC_CTL_ACC_BUF_SIZE
-len
,
2821 "Port SemReg: 0x%08x\n",
2822 readl(phba
->sli4_hba
.conf_regs_memmap_p
+
2823 LPFC_CTL_PORT_SEM_OFFSET
));
2825 case LPFC_CTL_PORT_STA
:
2826 len
+= snprintf(pbuffer
+len
, LPFC_CTL_ACC_BUF_SIZE
-len
,
2827 "Port StaReg: 0x%08x\n",
2828 readl(phba
->sli4_hba
.conf_regs_memmap_p
+
2829 LPFC_CTL_PORT_STA_OFFSET
));
2831 case LPFC_CTL_PORT_CTL
:
2832 len
+= snprintf(pbuffer
+len
, LPFC_CTL_ACC_BUF_SIZE
-len
,
2833 "Port CtlReg: 0x%08x\n",
2834 readl(phba
->sli4_hba
.conf_regs_memmap_p
+
2835 LPFC_CTL_PORT_CTL_OFFSET
));
2837 case LPFC_CTL_PORT_ER1
:
2838 len
+= snprintf(pbuffer
+len
, LPFC_CTL_ACC_BUF_SIZE
-len
,
2839 "Port Er1Reg: 0x%08x\n",
2840 readl(phba
->sli4_hba
.conf_regs_memmap_p
+
2841 LPFC_CTL_PORT_ER1_OFFSET
));
2843 case LPFC_CTL_PORT_ER2
:
2844 len
+= snprintf(pbuffer
+len
, LPFC_CTL_ACC_BUF_SIZE
-len
,
2845 "Port Er2Reg: 0x%08x\n",
2846 readl(phba
->sli4_hba
.conf_regs_memmap_p
+
2847 LPFC_CTL_PORT_ER2_OFFSET
));
2849 case LPFC_CTL_PDEV_CTL
:
2850 len
+= snprintf(pbuffer
+len
, LPFC_CTL_ACC_BUF_SIZE
-len
,
2851 "PDev CtlReg: 0x%08x\n",
2852 readl(phba
->sli4_hba
.conf_regs_memmap_p
+
2853 LPFC_CTL_PDEV_CTL_OFFSET
));
2862 * lpfc_idiag_ctlacc_read - idiag debugfs read port and device control register
2863 * @file: The file pointer to read from.
2864 * @buf: The buffer to copy the data to.
2865 * @nbytes: The number of bytes to read.
2866 * @ppos: The position in the file to start reading from.
2869 * This routine reads data from the @phba port and device registers according
2870 * to the idiag command, and copies to user @buf.
2873 * This function returns the amount of data that was read (this could be less
2874 * than @nbytes if the end of the file was reached) or a negative error value.
2877 lpfc_idiag_ctlacc_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
2880 struct lpfc_debug
*debug
= file
->private_data
;
2881 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
2882 uint32_t ctl_reg_id
, i
;
2886 /* This is a user read operation */
2887 debug
->op
= LPFC_IDIAG_OP_RD
;
2890 debug
->buffer
= kmalloc(LPFC_CTL_ACC_BUF_SIZE
, GFP_KERNEL
);
2893 pbuffer
= debug
->buffer
;
2898 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_RD
)
2899 ctl_reg_id
= idiag
.cmd
.data
[IDIAG_CTLACC_REGID_INDX
];
2903 if (ctl_reg_id
== LPFC_CTL_ACC_ALL
)
2904 for (i
= 1; i
<= LPFC_CTL_MAX
; i
++)
2905 len
= lpfc_idiag_ctlacc_read_reg(phba
,
2908 len
= lpfc_idiag_ctlacc_read_reg(phba
,
2909 pbuffer
, len
, ctl_reg_id
);
2911 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
2915 * lpfc_idiag_ctlacc_write - Syntax check and set up idiag ctlacc commands
2916 * @file: The file pointer to read from.
2917 * @buf: The buffer to copy the user data from.
2918 * @nbytes: The number of bytes to get.
2919 * @ppos: The position in the file to start reading from.
2921 * This routine get the debugfs idiag command struct from user space and then
2922 * perform the syntax check for port and device control register read (dump)
2923 * or write (set) command accordingly.
2925 * It returns the @nbytges passing in from debugfs user space when successful.
2926 * In case of error conditions, it returns proper error code back to the user
2930 lpfc_idiag_ctlacc_write(struct file
*file
, const char __user
*buf
,
2931 size_t nbytes
, loff_t
*ppos
)
2933 struct lpfc_debug
*debug
= file
->private_data
;
2934 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
2935 uint32_t ctl_reg_id
, value
, reg_val
= 0;
2936 void __iomem
*ctl_reg
;
2939 /* This is a user write operation */
2940 debug
->op
= LPFC_IDIAG_OP_WR
;
2942 rc
= lpfc_idiag_cmd_get(buf
, nbytes
, &idiag
.cmd
);
2946 /* Sanity check on command line arguments */
2947 ctl_reg_id
= idiag
.cmd
.data
[IDIAG_CTLACC_REGID_INDX
];
2948 value
= idiag
.cmd
.data
[IDIAG_CTLACC_VALUE_INDX
];
2950 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_WR
||
2951 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_ST
||
2952 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_CL
) {
2953 if (rc
!= LPFC_CTL_ACC_WR_CMD_ARG
)
2955 if (ctl_reg_id
> LPFC_CTL_MAX
)
2957 } else if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_RD
) {
2958 if (rc
!= LPFC_CTL_ACC_RD_CMD_ARG
)
2960 if ((ctl_reg_id
> LPFC_CTL_MAX
) &&
2961 (ctl_reg_id
!= LPFC_CTL_ACC_ALL
))
2966 /* Perform the write access operation */
2967 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_WR
||
2968 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_ST
||
2969 idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_CL
) {
2970 switch (ctl_reg_id
) {
2971 case LPFC_CTL_PORT_SEM
:
2972 ctl_reg
= phba
->sli4_hba
.conf_regs_memmap_p
+
2973 LPFC_CTL_PORT_SEM_OFFSET
;
2975 case LPFC_CTL_PORT_STA
:
2976 ctl_reg
= phba
->sli4_hba
.conf_regs_memmap_p
+
2977 LPFC_CTL_PORT_STA_OFFSET
;
2979 case LPFC_CTL_PORT_CTL
:
2980 ctl_reg
= phba
->sli4_hba
.conf_regs_memmap_p
+
2981 LPFC_CTL_PORT_CTL_OFFSET
;
2983 case LPFC_CTL_PORT_ER1
:
2984 ctl_reg
= phba
->sli4_hba
.conf_regs_memmap_p
+
2985 LPFC_CTL_PORT_ER1_OFFSET
;
2987 case LPFC_CTL_PORT_ER2
:
2988 ctl_reg
= phba
->sli4_hba
.conf_regs_memmap_p
+
2989 LPFC_CTL_PORT_ER2_OFFSET
;
2991 case LPFC_CTL_PDEV_CTL
:
2992 ctl_reg
= phba
->sli4_hba
.conf_regs_memmap_p
+
2993 LPFC_CTL_PDEV_CTL_OFFSET
;
2999 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_WR
)
3001 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_ST
) {
3002 reg_val
= readl(ctl_reg
);
3005 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_CTLACC_CL
) {
3006 reg_val
= readl(ctl_reg
);
3009 writel(reg_val
, ctl_reg
);
3010 readl(ctl_reg
); /* flush */
3015 /* Clean out command structure on command error out */
3016 memset(&idiag
, 0, sizeof(idiag
));
3021 * lpfc_idiag_mbxacc_get_setup - idiag debugfs get mailbox access setup
3022 * @phba: Pointer to HBA context object.
3023 * @pbuffer: Pointer to data buffer.
3026 * This routine gets the driver mailbox access debugfs setup information.
3029 * This function returns the amount of data that was read (this could be less
3030 * than @nbytes if the end of the file was reached) or a negative error value.
3033 lpfc_idiag_mbxacc_get_setup(struct lpfc_hba
*phba
, char *pbuffer
)
3035 uint32_t mbx_dump_map
, mbx_dump_cnt
, mbx_word_cnt
, mbx_mbox_cmd
;
3038 mbx_mbox_cmd
= idiag
.cmd
.data
[IDIAG_MBXACC_MBCMD_INDX
];
3039 mbx_dump_map
= idiag
.cmd
.data
[IDIAG_MBXACC_DPMAP_INDX
];
3040 mbx_dump_cnt
= idiag
.cmd
.data
[IDIAG_MBXACC_DPCNT_INDX
];
3041 mbx_word_cnt
= idiag
.cmd
.data
[IDIAG_MBXACC_WDCNT_INDX
];
3043 len
+= snprintf(pbuffer
+len
, LPFC_MBX_ACC_BUF_SIZE
-len
,
3044 "mbx_dump_map: 0x%08x\n", mbx_dump_map
);
3045 len
+= snprintf(pbuffer
+len
, LPFC_MBX_ACC_BUF_SIZE
-len
,
3046 "mbx_dump_cnt: %04d\n", mbx_dump_cnt
);
3047 len
+= snprintf(pbuffer
+len
, LPFC_MBX_ACC_BUF_SIZE
-len
,
3048 "mbx_word_cnt: %04d\n", mbx_word_cnt
);
3049 len
+= snprintf(pbuffer
+len
, LPFC_MBX_ACC_BUF_SIZE
-len
,
3050 "mbx_mbox_cmd: 0x%02x\n", mbx_mbox_cmd
);
3056 * lpfc_idiag_mbxacc_read - idiag debugfs read on mailbox access
3057 * @file: The file pointer to read from.
3058 * @buf: The buffer to copy the data to.
3059 * @nbytes: The number of bytes to read.
3060 * @ppos: The position in the file to start reading from.
3063 * This routine reads data from the @phba driver mailbox access debugfs setup
3067 * This function returns the amount of data that was read (this could be less
3068 * than @nbytes if the end of the file was reached) or a negative error value.
3071 lpfc_idiag_mbxacc_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
3074 struct lpfc_debug
*debug
= file
->private_data
;
3075 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
3079 /* This is a user read operation */
3080 debug
->op
= LPFC_IDIAG_OP_RD
;
3083 debug
->buffer
= kmalloc(LPFC_MBX_ACC_BUF_SIZE
, GFP_KERNEL
);
3086 pbuffer
= debug
->buffer
;
3091 if ((idiag
.cmd
.opcode
!= LPFC_IDIAG_CMD_MBXACC_DP
) &&
3092 (idiag
.cmd
.opcode
!= LPFC_IDIAG_BSG_MBXACC_DP
))
3095 len
= lpfc_idiag_mbxacc_get_setup(phba
, pbuffer
);
3097 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
3101 * lpfc_idiag_mbxacc_write - Syntax check and set up idiag mbxacc commands
3102 * @file: The file pointer to read from.
3103 * @buf: The buffer to copy the user data from.
3104 * @nbytes: The number of bytes to get.
3105 * @ppos: The position in the file to start reading from.
3107 * This routine get the debugfs idiag command struct from user space and then
3108 * perform the syntax check for driver mailbox command (dump) and sets up the
3109 * necessary states in the idiag command struct accordingly.
3111 * It returns the @nbytges passing in from debugfs user space when successful.
3112 * In case of error conditions, it returns proper error code back to the user
3116 lpfc_idiag_mbxacc_write(struct file
*file
, const char __user
*buf
,
3117 size_t nbytes
, loff_t
*ppos
)
3119 struct lpfc_debug
*debug
= file
->private_data
;
3120 uint32_t mbx_dump_map
, mbx_dump_cnt
, mbx_word_cnt
, mbx_mbox_cmd
;
3123 /* This is a user write operation */
3124 debug
->op
= LPFC_IDIAG_OP_WR
;
3126 rc
= lpfc_idiag_cmd_get(buf
, nbytes
, &idiag
.cmd
);
3130 /* Sanity check on command line arguments */
3131 mbx_mbox_cmd
= idiag
.cmd
.data
[IDIAG_MBXACC_MBCMD_INDX
];
3132 mbx_dump_map
= idiag
.cmd
.data
[IDIAG_MBXACC_DPMAP_INDX
];
3133 mbx_dump_cnt
= idiag
.cmd
.data
[IDIAG_MBXACC_DPCNT_INDX
];
3134 mbx_word_cnt
= idiag
.cmd
.data
[IDIAG_MBXACC_WDCNT_INDX
];
3136 if (idiag
.cmd
.opcode
== LPFC_IDIAG_CMD_MBXACC_DP
) {
3137 if (!(mbx_dump_map
& LPFC_MBX_DMP_MBX_ALL
))
3139 if ((mbx_dump_map
& ~LPFC_MBX_DMP_MBX_ALL
) &&
3140 (mbx_dump_map
!= LPFC_MBX_DMP_ALL
))
3142 if (mbx_word_cnt
> sizeof(MAILBOX_t
))
3144 } else if (idiag
.cmd
.opcode
== LPFC_IDIAG_BSG_MBXACC_DP
) {
3145 if (!(mbx_dump_map
& LPFC_BSG_DMP_MBX_ALL
))
3147 if ((mbx_dump_map
& ~LPFC_BSG_DMP_MBX_ALL
) &&
3148 (mbx_dump_map
!= LPFC_MBX_DMP_ALL
))
3150 if (mbx_word_cnt
> (BSG_MBOX_SIZE
)/4)
3152 if (mbx_mbox_cmd
!= 0x9b)
3157 if (mbx_word_cnt
== 0)
3159 if (rc
!= LPFC_MBX_DMP_ARG
)
3161 if (mbx_mbox_cmd
& ~0xff)
3164 /* condition for stop mailbox dump */
3165 if (mbx_dump_cnt
== 0)
3171 /* Clean out command structure on command error out */
3172 memset(&idiag
, 0, sizeof(idiag
));
3176 /* Clean out command structure on command error out */
3177 memset(&idiag
, 0, sizeof(idiag
));
3182 * lpfc_idiag_extacc_avail_get - get the available extents information
3183 * @phba: pointer to lpfc hba data structure.
3184 * @pbuffer: pointer to internal buffer.
3185 * @len: length into the internal buffer data has been copied.
3188 * This routine is to get the available extent information.
3191 * overall lenth of the data read into the internal buffer.
3194 lpfc_idiag_extacc_avail_get(struct lpfc_hba
*phba
, char *pbuffer
, int len
)
3196 uint16_t ext_cnt
, ext_size
;
3198 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
3199 "\nAvailable Extents Information:\n");
3201 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
3202 "\tPort Available VPI extents: ");
3203 lpfc_sli4_get_avail_extnt_rsrc(phba
, LPFC_RSC_TYPE_FCOE_VPI
,
3204 &ext_cnt
, &ext_size
);
3205 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
3206 "Count %3d, Size %3d\n", ext_cnt
, ext_size
);
3208 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
3209 "\tPort Available VFI extents: ");
3210 lpfc_sli4_get_avail_extnt_rsrc(phba
, LPFC_RSC_TYPE_FCOE_VFI
,
3211 &ext_cnt
, &ext_size
);
3212 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
3213 "Count %3d, Size %3d\n", ext_cnt
, ext_size
);
3215 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
3216 "\tPort Available RPI extents: ");
3217 lpfc_sli4_get_avail_extnt_rsrc(phba
, LPFC_RSC_TYPE_FCOE_RPI
,
3218 &ext_cnt
, &ext_size
);
3219 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
3220 "Count %3d, Size %3d\n", ext_cnt
, ext_size
);
3222 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
3223 "\tPort Available XRI extents: ");
3224 lpfc_sli4_get_avail_extnt_rsrc(phba
, LPFC_RSC_TYPE_FCOE_XRI
,
3225 &ext_cnt
, &ext_size
);
3226 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
3227 "Count %3d, Size %3d\n", ext_cnt
, ext_size
);
3233 * lpfc_idiag_extacc_alloc_get - get the allocated extents information
3234 * @phba: pointer to lpfc hba data structure.
3235 * @pbuffer: pointer to internal buffer.
3236 * @len: length into the internal buffer data has been copied.
3239 * This routine is to get the allocated extent information.
3242 * overall lenth of the data read into the internal buffer.
3245 lpfc_idiag_extacc_alloc_get(struct lpfc_hba
*phba
, char *pbuffer
, int len
)
3247 uint16_t ext_cnt
, ext_size
;
3250 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
3251 "\nAllocated Extents Information:\n");
3253 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
3254 "\tHost Allocated VPI extents: ");
3255 rc
= lpfc_sli4_get_allocated_extnts(phba
, LPFC_RSC_TYPE_FCOE_VPI
,
3256 &ext_cnt
, &ext_size
);
3258 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
3259 "Port %d Extent %3d, Size %3d\n",
3260 phba
->brd_no
, ext_cnt
, ext_size
);
3262 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
3265 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
3266 "\tHost Allocated VFI extents: ");
3267 rc
= lpfc_sli4_get_allocated_extnts(phba
, LPFC_RSC_TYPE_FCOE_VFI
,
3268 &ext_cnt
, &ext_size
);
3270 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
3271 "Port %d Extent %3d, Size %3d\n",
3272 phba
->brd_no
, ext_cnt
, ext_size
);
3274 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
3277 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
3278 "\tHost Allocated RPI extents: ");
3279 rc
= lpfc_sli4_get_allocated_extnts(phba
, LPFC_RSC_TYPE_FCOE_RPI
,
3280 &ext_cnt
, &ext_size
);
3282 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
3283 "Port %d Extent %3d, Size %3d\n",
3284 phba
->brd_no
, ext_cnt
, ext_size
);
3286 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
3289 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
3290 "\tHost Allocated XRI extents: ");
3291 rc
= lpfc_sli4_get_allocated_extnts(phba
, LPFC_RSC_TYPE_FCOE_XRI
,
3292 &ext_cnt
, &ext_size
);
3294 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
3295 "Port %d Extent %3d, Size %3d\n",
3296 phba
->brd_no
, ext_cnt
, ext_size
);
3298 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
3305 * lpfc_idiag_extacc_drivr_get - get driver extent information
3306 * @phba: pointer to lpfc hba data structure.
3307 * @pbuffer: pointer to internal buffer.
3308 * @len: length into the internal buffer data has been copied.
3311 * This routine is to get the driver extent information.
3314 * overall lenth of the data read into the internal buffer.
3317 lpfc_idiag_extacc_drivr_get(struct lpfc_hba
*phba
, char *pbuffer
, int len
)
3319 struct lpfc_rsrc_blks
*rsrc_blks
;
3322 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
3323 "\nDriver Extents Information:\n");
3325 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
3326 "\tVPI extents:\n");
3328 list_for_each_entry(rsrc_blks
, &phba
->lpfc_vpi_blk_list
, list
) {
3329 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
3330 "\t\tBlock %3d: Start %4d, Count %4d\n",
3331 index
, rsrc_blks
->rsrc_start
,
3332 rsrc_blks
->rsrc_size
);
3335 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
3336 "\tVFI extents:\n");
3338 list_for_each_entry(rsrc_blks
, &phba
->sli4_hba
.lpfc_vfi_blk_list
,
3340 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
3341 "\t\tBlock %3d: Start %4d, Count %4d\n",
3342 index
, rsrc_blks
->rsrc_start
,
3343 rsrc_blks
->rsrc_size
);
3347 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
3348 "\tRPI extents:\n");
3350 list_for_each_entry(rsrc_blks
, &phba
->sli4_hba
.lpfc_rpi_blk_list
,
3352 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
3353 "\t\tBlock %3d: Start %4d, Count %4d\n",
3354 index
, rsrc_blks
->rsrc_start
,
3355 rsrc_blks
->rsrc_size
);
3359 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
3360 "\tXRI extents:\n");
3362 list_for_each_entry(rsrc_blks
, &phba
->sli4_hba
.lpfc_xri_blk_list
,
3364 len
+= snprintf(pbuffer
+len
, LPFC_EXT_ACC_BUF_SIZE
-len
,
3365 "\t\tBlock %3d: Start %4d, Count %4d\n",
3366 index
, rsrc_blks
->rsrc_start
,
3367 rsrc_blks
->rsrc_size
);
3375 * lpfc_idiag_extacc_write - Syntax check and set up idiag extacc commands
3376 * @file: The file pointer to read from.
3377 * @buf: The buffer to copy the user data from.
3378 * @nbytes: The number of bytes to get.
3379 * @ppos: The position in the file to start reading from.
3381 * This routine get the debugfs idiag command struct from user space and then
3382 * perform the syntax check for extent information access commands and sets
3383 * up the necessary states in the idiag command struct accordingly.
3385 * It returns the @nbytges passing in from debugfs user space when successful.
3386 * In case of error conditions, it returns proper error code back to the user
3390 lpfc_idiag_extacc_write(struct file
*file
, const char __user
*buf
,
3391 size_t nbytes
, loff_t
*ppos
)
3393 struct lpfc_debug
*debug
= file
->private_data
;
3397 /* This is a user write operation */
3398 debug
->op
= LPFC_IDIAG_OP_WR
;
3400 rc
= lpfc_idiag_cmd_get(buf
, nbytes
, &idiag
.cmd
);
3404 ext_map
= idiag
.cmd
.data
[IDIAG_EXTACC_EXMAP_INDX
];
3406 if (idiag
.cmd
.opcode
!= LPFC_IDIAG_CMD_EXTACC_RD
)
3408 if (rc
!= LPFC_EXT_ACC_CMD_ARG
)
3410 if (!(ext_map
& LPFC_EXT_ACC_ALL
))
3415 /* Clean out command structure on command error out */
3416 memset(&idiag
, 0, sizeof(idiag
));
3421 * lpfc_idiag_extacc_read - idiag debugfs read access to extent information
3422 * @file: The file pointer to read from.
3423 * @buf: The buffer to copy the data to.
3424 * @nbytes: The number of bytes to read.
3425 * @ppos: The position in the file to start reading from.
3428 * This routine reads data from the proper extent information according to
3429 * the idiag command, and copies to user @buf.
3432 * This function returns the amount of data that was read (this could be less
3433 * than @nbytes if the end of the file was reached) or a negative error value.
3436 lpfc_idiag_extacc_read(struct file
*file
, char __user
*buf
, size_t nbytes
,
3439 struct lpfc_debug
*debug
= file
->private_data
;
3440 struct lpfc_hba
*phba
= (struct lpfc_hba
*)debug
->i_private
;
3445 /* This is a user read operation */
3446 debug
->op
= LPFC_IDIAG_OP_RD
;
3449 debug
->buffer
= kmalloc(LPFC_EXT_ACC_BUF_SIZE
, GFP_KERNEL
);
3452 pbuffer
= debug
->buffer
;
3455 if (idiag
.cmd
.opcode
!= LPFC_IDIAG_CMD_EXTACC_RD
)
3458 ext_map
= idiag
.cmd
.data
[IDIAG_EXTACC_EXMAP_INDX
];
3459 if (ext_map
& LPFC_EXT_ACC_AVAIL
)
3460 len
= lpfc_idiag_extacc_avail_get(phba
, pbuffer
, len
);
3461 if (ext_map
& LPFC_EXT_ACC_ALLOC
)
3462 len
= lpfc_idiag_extacc_alloc_get(phba
, pbuffer
, len
);
3463 if (ext_map
& LPFC_EXT_ACC_DRIVR
)
3464 len
= lpfc_idiag_extacc_drivr_get(phba
, pbuffer
, len
);
3466 return simple_read_from_buffer(buf
, nbytes
, ppos
, pbuffer
, len
);
3469 #undef lpfc_debugfs_op_disc_trc
3470 static const struct file_operations lpfc_debugfs_op_disc_trc
= {
3471 .owner
= THIS_MODULE
,
3472 .open
= lpfc_debugfs_disc_trc_open
,
3473 .llseek
= lpfc_debugfs_lseek
,
3474 .read
= lpfc_debugfs_read
,
3475 .release
= lpfc_debugfs_release
,
3478 #undef lpfc_debugfs_op_nodelist
3479 static const struct file_operations lpfc_debugfs_op_nodelist
= {
3480 .owner
= THIS_MODULE
,
3481 .open
= lpfc_debugfs_nodelist_open
,
3482 .llseek
= lpfc_debugfs_lseek
,
3483 .read
= lpfc_debugfs_read
,
3484 .release
= lpfc_debugfs_release
,
3487 #undef lpfc_debugfs_op_hbqinfo
3488 static const struct file_operations lpfc_debugfs_op_hbqinfo
= {
3489 .owner
= THIS_MODULE
,
3490 .open
= lpfc_debugfs_hbqinfo_open
,
3491 .llseek
= lpfc_debugfs_lseek
,
3492 .read
= lpfc_debugfs_read
,
3493 .release
= lpfc_debugfs_release
,
3496 #undef lpfc_debugfs_op_dumpHBASlim
3497 static const struct file_operations lpfc_debugfs_op_dumpHBASlim
= {
3498 .owner
= THIS_MODULE
,
3499 .open
= lpfc_debugfs_dumpHBASlim_open
,
3500 .llseek
= lpfc_debugfs_lseek
,
3501 .read
= lpfc_debugfs_read
,
3502 .release
= lpfc_debugfs_release
,
3505 #undef lpfc_debugfs_op_dumpHostSlim
3506 static const struct file_operations lpfc_debugfs_op_dumpHostSlim
= {
3507 .owner
= THIS_MODULE
,
3508 .open
= lpfc_debugfs_dumpHostSlim_open
,
3509 .llseek
= lpfc_debugfs_lseek
,
3510 .read
= lpfc_debugfs_read
,
3511 .release
= lpfc_debugfs_release
,
3514 #undef lpfc_debugfs_op_dumpData
3515 static const struct file_operations lpfc_debugfs_op_dumpData
= {
3516 .owner
= THIS_MODULE
,
3517 .open
= lpfc_debugfs_dumpData_open
,
3518 .llseek
= lpfc_debugfs_lseek
,
3519 .read
= lpfc_debugfs_read
,
3520 .write
= lpfc_debugfs_dumpDataDif_write
,
3521 .release
= lpfc_debugfs_dumpDataDif_release
,
3524 #undef lpfc_debugfs_op_dumpDif
3525 static const struct file_operations lpfc_debugfs_op_dumpDif
= {
3526 .owner
= THIS_MODULE
,
3527 .open
= lpfc_debugfs_dumpDif_open
,
3528 .llseek
= lpfc_debugfs_lseek
,
3529 .read
= lpfc_debugfs_read
,
3530 .write
= lpfc_debugfs_dumpDataDif_write
,
3531 .release
= lpfc_debugfs_dumpDataDif_release
,
3534 #undef lpfc_debugfs_op_dif_err
3535 static const struct file_operations lpfc_debugfs_op_dif_err
= {
3536 .owner
= THIS_MODULE
,
3537 .open
= simple_open
,
3538 .llseek
= lpfc_debugfs_lseek
,
3539 .read
= lpfc_debugfs_dif_err_read
,
3540 .write
= lpfc_debugfs_dif_err_write
,
3541 .release
= lpfc_debugfs_dif_err_release
,
3544 #undef lpfc_debugfs_op_slow_ring_trc
3545 static const struct file_operations lpfc_debugfs_op_slow_ring_trc
= {
3546 .owner
= THIS_MODULE
,
3547 .open
= lpfc_debugfs_slow_ring_trc_open
,
3548 .llseek
= lpfc_debugfs_lseek
,
3549 .read
= lpfc_debugfs_read
,
3550 .release
= lpfc_debugfs_release
,
3553 static struct dentry
*lpfc_debugfs_root
= NULL
;
3554 static atomic_t lpfc_debugfs_hba_count
;
3557 * File operations for the iDiag debugfs
3559 #undef lpfc_idiag_op_pciCfg
3560 static const struct file_operations lpfc_idiag_op_pciCfg
= {
3561 .owner
= THIS_MODULE
,
3562 .open
= lpfc_idiag_open
,
3563 .llseek
= lpfc_debugfs_lseek
,
3564 .read
= lpfc_idiag_pcicfg_read
,
3565 .write
= lpfc_idiag_pcicfg_write
,
3566 .release
= lpfc_idiag_cmd_release
,
3569 #undef lpfc_idiag_op_barAcc
3570 static const struct file_operations lpfc_idiag_op_barAcc
= {
3571 .owner
= THIS_MODULE
,
3572 .open
= lpfc_idiag_open
,
3573 .llseek
= lpfc_debugfs_lseek
,
3574 .read
= lpfc_idiag_baracc_read
,
3575 .write
= lpfc_idiag_baracc_write
,
3576 .release
= lpfc_idiag_cmd_release
,
3579 #undef lpfc_idiag_op_queInfo
3580 static const struct file_operations lpfc_idiag_op_queInfo
= {
3581 .owner
= THIS_MODULE
,
3582 .open
= lpfc_idiag_open
,
3583 .read
= lpfc_idiag_queinfo_read
,
3584 .release
= lpfc_idiag_release
,
3587 #undef lpfc_idiag_op_queAcc
3588 static const struct file_operations lpfc_idiag_op_queAcc
= {
3589 .owner
= THIS_MODULE
,
3590 .open
= lpfc_idiag_open
,
3591 .llseek
= lpfc_debugfs_lseek
,
3592 .read
= lpfc_idiag_queacc_read
,
3593 .write
= lpfc_idiag_queacc_write
,
3594 .release
= lpfc_idiag_cmd_release
,
3597 #undef lpfc_idiag_op_drbAcc
3598 static const struct file_operations lpfc_idiag_op_drbAcc
= {
3599 .owner
= THIS_MODULE
,
3600 .open
= lpfc_idiag_open
,
3601 .llseek
= lpfc_debugfs_lseek
,
3602 .read
= lpfc_idiag_drbacc_read
,
3603 .write
= lpfc_idiag_drbacc_write
,
3604 .release
= lpfc_idiag_cmd_release
,
3607 #undef lpfc_idiag_op_ctlAcc
3608 static const struct file_operations lpfc_idiag_op_ctlAcc
= {
3609 .owner
= THIS_MODULE
,
3610 .open
= lpfc_idiag_open
,
3611 .llseek
= lpfc_debugfs_lseek
,
3612 .read
= lpfc_idiag_ctlacc_read
,
3613 .write
= lpfc_idiag_ctlacc_write
,
3614 .release
= lpfc_idiag_cmd_release
,
3617 #undef lpfc_idiag_op_mbxAcc
3618 static const struct file_operations lpfc_idiag_op_mbxAcc
= {
3619 .owner
= THIS_MODULE
,
3620 .open
= lpfc_idiag_open
,
3621 .llseek
= lpfc_debugfs_lseek
,
3622 .read
= lpfc_idiag_mbxacc_read
,
3623 .write
= lpfc_idiag_mbxacc_write
,
3624 .release
= lpfc_idiag_cmd_release
,
3627 #undef lpfc_idiag_op_extAcc
3628 static const struct file_operations lpfc_idiag_op_extAcc
= {
3629 .owner
= THIS_MODULE
,
3630 .open
= lpfc_idiag_open
,
3631 .llseek
= lpfc_debugfs_lseek
,
3632 .read
= lpfc_idiag_extacc_read
,
3633 .write
= lpfc_idiag_extacc_write
,
3634 .release
= lpfc_idiag_cmd_release
,
3639 /* lpfc_idiag_mbxacc_dump_bsg_mbox - idiag debugfs dump bsg mailbox command
3640 * @phba: Pointer to HBA context object.
3641 * @dmabuf: Pointer to a DMA buffer descriptor.
3644 * This routine dump a bsg pass-through non-embedded mailbox command with
3648 lpfc_idiag_mbxacc_dump_bsg_mbox(struct lpfc_hba
*phba
, enum nemb_type nemb_tp
,
3649 enum mbox_type mbox_tp
, enum dma_type dma_tp
,
3650 enum sta_type sta_tp
,
3651 struct lpfc_dmabuf
*dmabuf
, uint32_t ext_buf
)
3653 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
3654 uint32_t *mbx_mbox_cmd
, *mbx_dump_map
, *mbx_dump_cnt
, *mbx_word_cnt
;
3655 char line_buf
[LPFC_MBX_ACC_LBUF_SZ
];
3657 uint32_t do_dump
= 0;
3661 if (idiag
.cmd
.opcode
!= LPFC_IDIAG_BSG_MBXACC_DP
)
3664 mbx_mbox_cmd
= &idiag
.cmd
.data
[IDIAG_MBXACC_MBCMD_INDX
];
3665 mbx_dump_map
= &idiag
.cmd
.data
[IDIAG_MBXACC_DPMAP_INDX
];
3666 mbx_dump_cnt
= &idiag
.cmd
.data
[IDIAG_MBXACC_DPCNT_INDX
];
3667 mbx_word_cnt
= &idiag
.cmd
.data
[IDIAG_MBXACC_WDCNT_INDX
];
3669 if (!(*mbx_dump_map
& LPFC_MBX_DMP_ALL
) ||
3670 (*mbx_dump_cnt
== 0) ||
3671 (*mbx_word_cnt
== 0))
3674 if (*mbx_mbox_cmd
!= 0x9B)
3677 if ((mbox_tp
== mbox_rd
) && (dma_tp
== dma_mbox
)) {
3678 if (*mbx_dump_map
& LPFC_BSG_DMP_MBX_RD_MBX
) {
3679 do_dump
|= LPFC_BSG_DMP_MBX_RD_MBX
;
3680 printk(KERN_ERR
"\nRead mbox command (x%x), "
3681 "nemb:0x%x, extbuf_cnt:%d:\n",
3682 sta_tp
, nemb_tp
, ext_buf
);
3685 if ((mbox_tp
== mbox_rd
) && (dma_tp
== dma_ebuf
)) {
3686 if (*mbx_dump_map
& LPFC_BSG_DMP_MBX_RD_BUF
) {
3687 do_dump
|= LPFC_BSG_DMP_MBX_RD_BUF
;
3688 printk(KERN_ERR
"\nRead mbox buffer (x%x), "
3689 "nemb:0x%x, extbuf_seq:%d:\n",
3690 sta_tp
, nemb_tp
, ext_buf
);
3693 if ((mbox_tp
== mbox_wr
) && (dma_tp
== dma_mbox
)) {
3694 if (*mbx_dump_map
& LPFC_BSG_DMP_MBX_WR_MBX
) {
3695 do_dump
|= LPFC_BSG_DMP_MBX_WR_MBX
;
3696 printk(KERN_ERR
"\nWrite mbox command (x%x), "
3697 "nemb:0x%x, extbuf_cnt:%d:\n",
3698 sta_tp
, nemb_tp
, ext_buf
);
3701 if ((mbox_tp
== mbox_wr
) && (dma_tp
== dma_ebuf
)) {
3702 if (*mbx_dump_map
& LPFC_BSG_DMP_MBX_WR_BUF
) {
3703 do_dump
|= LPFC_BSG_DMP_MBX_WR_BUF
;
3704 printk(KERN_ERR
"\nWrite mbox buffer (x%x), "
3705 "nemb:0x%x, extbuf_seq:%d:\n",
3706 sta_tp
, nemb_tp
, ext_buf
);
3710 /* dump buffer content */
3712 pword
= (uint32_t *)dmabuf
->virt
;
3713 for (i
= 0; i
< *mbx_word_cnt
; i
++) {
3716 printk(KERN_ERR
"%s\n", line_buf
);
3718 len
+= snprintf(line_buf
+len
,
3719 LPFC_MBX_ACC_LBUF_SZ
-len
,
3722 len
+= snprintf(line_buf
+len
, LPFC_MBX_ACC_LBUF_SZ
-len
,
3723 "%08x ", (uint32_t)*pword
);
3727 printk(KERN_ERR
"%s\n", line_buf
);
3731 /* Clean out command structure on reaching dump count */
3732 if (*mbx_dump_cnt
== 0)
3733 memset(&idiag
, 0, sizeof(idiag
));
3738 /* lpfc_idiag_mbxacc_dump_issue_mbox - idiag debugfs dump issue mailbox command
3739 * @phba: Pointer to HBA context object.
3740 * @dmabuf: Pointer to a DMA buffer descriptor.
3743 * This routine dump a pass-through non-embedded mailbox command from issue
3747 lpfc_idiag_mbxacc_dump_issue_mbox(struct lpfc_hba
*phba
, MAILBOX_t
*pmbox
)
3749 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
3750 uint32_t *mbx_dump_map
, *mbx_dump_cnt
, *mbx_word_cnt
, *mbx_mbox_cmd
;
3751 char line_buf
[LPFC_MBX_ACC_LBUF_SZ
];
3757 if (idiag
.cmd
.opcode
!= LPFC_IDIAG_CMD_MBXACC_DP
)
3760 mbx_mbox_cmd
= &idiag
.cmd
.data
[IDIAG_MBXACC_MBCMD_INDX
];
3761 mbx_dump_map
= &idiag
.cmd
.data
[IDIAG_MBXACC_DPMAP_INDX
];
3762 mbx_dump_cnt
= &idiag
.cmd
.data
[IDIAG_MBXACC_DPCNT_INDX
];
3763 mbx_word_cnt
= &idiag
.cmd
.data
[IDIAG_MBXACC_WDCNT_INDX
];
3765 if (!(*mbx_dump_map
& LPFC_MBX_DMP_MBX_ALL
) ||
3766 (*mbx_dump_cnt
== 0) ||
3767 (*mbx_word_cnt
== 0))
3770 if ((*mbx_mbox_cmd
!= LPFC_MBX_ALL_CMD
) &&
3771 (*mbx_mbox_cmd
!= pmbox
->mbxCommand
))
3774 /* dump buffer content */
3775 if (*mbx_dump_map
& LPFC_MBX_DMP_MBX_WORD
) {
3776 printk(KERN_ERR
"Mailbox command:0x%x dump by word:\n",
3778 pword
= (uint32_t *)pmbox
;
3779 for (i
= 0; i
< *mbx_word_cnt
; i
++) {
3782 printk(KERN_ERR
"%s\n", line_buf
);
3784 memset(line_buf
, 0, LPFC_MBX_ACC_LBUF_SZ
);
3785 len
+= snprintf(line_buf
+len
,
3786 LPFC_MBX_ACC_LBUF_SZ
-len
,
3789 len
+= snprintf(line_buf
+len
, LPFC_MBX_ACC_LBUF_SZ
-len
,
3791 ((uint32_t)*pword
) & 0xffffffff);
3795 printk(KERN_ERR
"%s\n", line_buf
);
3796 printk(KERN_ERR
"\n");
3798 if (*mbx_dump_map
& LPFC_MBX_DMP_MBX_BYTE
) {
3799 printk(KERN_ERR
"Mailbox command:0x%x dump by byte:\n",
3801 pbyte
= (uint8_t *)pmbox
;
3802 for (i
= 0; i
< *mbx_word_cnt
; i
++) {
3805 printk(KERN_ERR
"%s\n", line_buf
);
3807 memset(line_buf
, 0, LPFC_MBX_ACC_LBUF_SZ
);
3808 len
+= snprintf(line_buf
+len
,
3809 LPFC_MBX_ACC_LBUF_SZ
-len
,
3812 for (j
= 0; j
< 4; j
++) {
3813 len
+= snprintf(line_buf
+len
,
3814 LPFC_MBX_ACC_LBUF_SZ
-len
,
3816 ((uint8_t)*pbyte
) & 0xff);
3819 len
+= snprintf(line_buf
+len
,
3820 LPFC_MBX_ACC_LBUF_SZ
-len
, " ");
3823 printk(KERN_ERR
"%s\n", line_buf
);
3824 printk(KERN_ERR
"\n");
3828 /* Clean out command structure on reaching dump count */
3829 if (*mbx_dump_cnt
== 0)
3830 memset(&idiag
, 0, sizeof(idiag
));
3836 * lpfc_debugfs_initialize - Initialize debugfs for a vport
3837 * @vport: The vport pointer to initialize.
3840 * When Debugfs is configured this routine sets up the lpfc debugfs file system.
3841 * If not already created, this routine will create the lpfc directory, and
3842 * lpfcX directory (for this HBA), and vportX directory for this vport. It will
3843 * also create each file used to access lpfc specific debugfs information.
3846 lpfc_debugfs_initialize(struct lpfc_vport
*vport
)
3848 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
3849 struct lpfc_hba
*phba
= vport
->phba
;
3853 if (!lpfc_debugfs_enable
)
3856 /* Setup lpfc root directory */
3857 if (!lpfc_debugfs_root
) {
3858 lpfc_debugfs_root
= debugfs_create_dir("lpfc", NULL
);
3859 atomic_set(&lpfc_debugfs_hba_count
, 0);
3860 if (!lpfc_debugfs_root
) {
3861 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3862 "0408 Cannot create debugfs root\n");
3866 if (!lpfc_debugfs_start_time
)
3867 lpfc_debugfs_start_time
= jiffies
;
3869 /* Setup funcX directory for specific HBA PCI function */
3870 snprintf(name
, sizeof(name
), "fn%d", phba
->brd_no
);
3871 if (!phba
->hba_debugfs_root
) {
3872 phba
->hba_debugfs_root
=
3873 debugfs_create_dir(name
, lpfc_debugfs_root
);
3874 if (!phba
->hba_debugfs_root
) {
3875 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3876 "0412 Cannot create debugfs hba\n");
3879 atomic_inc(&lpfc_debugfs_hba_count
);
3880 atomic_set(&phba
->debugfs_vport_count
, 0);
3883 snprintf(name
, sizeof(name
), "hbqinfo");
3884 phba
->debug_hbqinfo
=
3885 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
3886 phba
->hba_debugfs_root
,
3887 phba
, &lpfc_debugfs_op_hbqinfo
);
3888 if (!phba
->debug_hbqinfo
) {
3889 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3890 "0411 Cannot create debugfs hbqinfo\n");
3894 /* Setup dumpHBASlim */
3895 if (phba
->sli_rev
< LPFC_SLI_REV4
) {
3896 snprintf(name
, sizeof(name
), "dumpHBASlim");
3897 phba
->debug_dumpHBASlim
=
3898 debugfs_create_file(name
,
3899 S_IFREG
|S_IRUGO
|S_IWUSR
,
3900 phba
->hba_debugfs_root
,
3901 phba
, &lpfc_debugfs_op_dumpHBASlim
);
3902 if (!phba
->debug_dumpHBASlim
) {
3903 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3904 "0413 Cannot create debugfs "
3909 phba
->debug_dumpHBASlim
= NULL
;
3911 /* Setup dumpHostSlim */
3912 if (phba
->sli_rev
< LPFC_SLI_REV4
) {
3913 snprintf(name
, sizeof(name
), "dumpHostSlim");
3914 phba
->debug_dumpHostSlim
=
3915 debugfs_create_file(name
,
3916 S_IFREG
|S_IRUGO
|S_IWUSR
,
3917 phba
->hba_debugfs_root
,
3918 phba
, &lpfc_debugfs_op_dumpHostSlim
);
3919 if (!phba
->debug_dumpHostSlim
) {
3920 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3921 "0414 Cannot create debugfs "
3926 phba
->debug_dumpHBASlim
= NULL
;
3928 /* Setup dumpData */
3929 snprintf(name
, sizeof(name
), "dumpData");
3930 phba
->debug_dumpData
=
3931 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
3932 phba
->hba_debugfs_root
,
3933 phba
, &lpfc_debugfs_op_dumpData
);
3934 if (!phba
->debug_dumpData
) {
3935 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3936 "0800 Cannot create debugfs dumpData\n");
3941 snprintf(name
, sizeof(name
), "dumpDif");
3942 phba
->debug_dumpDif
=
3943 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
3944 phba
->hba_debugfs_root
,
3945 phba
, &lpfc_debugfs_op_dumpDif
);
3946 if (!phba
->debug_dumpDif
) {
3947 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3948 "0801 Cannot create debugfs dumpDif\n");
3952 /* Setup DIF Error Injections */
3953 snprintf(name
, sizeof(name
), "InjErrLBA");
3954 phba
->debug_InjErrLBA
=
3955 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
3956 phba
->hba_debugfs_root
,
3957 phba
, &lpfc_debugfs_op_dif_err
);
3958 if (!phba
->debug_InjErrLBA
) {
3959 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3960 "0807 Cannot create debugfs InjErrLBA\n");
3963 phba
->lpfc_injerr_lba
= LPFC_INJERR_LBA_OFF
;
3965 snprintf(name
, sizeof(name
), "InjErrNPortID");
3966 phba
->debug_InjErrNPortID
=
3967 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
3968 phba
->hba_debugfs_root
,
3969 phba
, &lpfc_debugfs_op_dif_err
);
3970 if (!phba
->debug_InjErrNPortID
) {
3971 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3972 "0809 Cannot create debugfs InjErrNPortID\n");
3976 snprintf(name
, sizeof(name
), "InjErrWWPN");
3977 phba
->debug_InjErrWWPN
=
3978 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
3979 phba
->hba_debugfs_root
,
3980 phba
, &lpfc_debugfs_op_dif_err
);
3981 if (!phba
->debug_InjErrWWPN
) {
3982 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3983 "0810 Cannot create debugfs InjErrWWPN\n");
3987 snprintf(name
, sizeof(name
), "writeGuardInjErr");
3988 phba
->debug_writeGuard
=
3989 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
3990 phba
->hba_debugfs_root
,
3991 phba
, &lpfc_debugfs_op_dif_err
);
3992 if (!phba
->debug_writeGuard
) {
3993 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
3994 "0802 Cannot create debugfs writeGuard\n");
3998 snprintf(name
, sizeof(name
), "writeAppInjErr");
3999 phba
->debug_writeApp
=
4000 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
4001 phba
->hba_debugfs_root
,
4002 phba
, &lpfc_debugfs_op_dif_err
);
4003 if (!phba
->debug_writeApp
) {
4004 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
4005 "0803 Cannot create debugfs writeApp\n");
4009 snprintf(name
, sizeof(name
), "writeRefInjErr");
4010 phba
->debug_writeRef
=
4011 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
4012 phba
->hba_debugfs_root
,
4013 phba
, &lpfc_debugfs_op_dif_err
);
4014 if (!phba
->debug_writeRef
) {
4015 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
4016 "0804 Cannot create debugfs writeRef\n");
4020 snprintf(name
, sizeof(name
), "readGuardInjErr");
4021 phba
->debug_readGuard
=
4022 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
4023 phba
->hba_debugfs_root
,
4024 phba
, &lpfc_debugfs_op_dif_err
);
4025 if (!phba
->debug_readGuard
) {
4026 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
4027 "0808 Cannot create debugfs readGuard\n");
4031 snprintf(name
, sizeof(name
), "readAppInjErr");
4032 phba
->debug_readApp
=
4033 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
4034 phba
->hba_debugfs_root
,
4035 phba
, &lpfc_debugfs_op_dif_err
);
4036 if (!phba
->debug_readApp
) {
4037 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
4038 "0805 Cannot create debugfs readApp\n");
4042 snprintf(name
, sizeof(name
), "readRefInjErr");
4043 phba
->debug_readRef
=
4044 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
4045 phba
->hba_debugfs_root
,
4046 phba
, &lpfc_debugfs_op_dif_err
);
4047 if (!phba
->debug_readRef
) {
4048 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
4049 "0806 Cannot create debugfs readApp\n");
4053 /* Setup slow ring trace */
4054 if (lpfc_debugfs_max_slow_ring_trc
) {
4055 num
= lpfc_debugfs_max_slow_ring_trc
- 1;
4056 if (num
& lpfc_debugfs_max_slow_ring_trc
) {
4057 /* Change to be a power of 2 */
4058 num
= lpfc_debugfs_max_slow_ring_trc
;
4064 lpfc_debugfs_max_slow_ring_trc
= (1 << i
);
4066 "lpfc_debugfs_max_disc_trc changed to "
4067 "%d\n", lpfc_debugfs_max_disc_trc
);
4071 snprintf(name
, sizeof(name
), "slow_ring_trace");
4072 phba
->debug_slow_ring_trc
=
4073 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
4074 phba
->hba_debugfs_root
,
4075 phba
, &lpfc_debugfs_op_slow_ring_trc
);
4076 if (!phba
->debug_slow_ring_trc
) {
4077 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
4078 "0415 Cannot create debugfs "
4079 "slow_ring_trace\n");
4082 if (!phba
->slow_ring_trc
) {
4083 phba
->slow_ring_trc
= kmalloc(
4084 (sizeof(struct lpfc_debugfs_trc
) *
4085 lpfc_debugfs_max_slow_ring_trc
),
4087 if (!phba
->slow_ring_trc
) {
4088 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
4089 "0416 Cannot create debugfs "
4090 "slow_ring buffer\n");
4093 atomic_set(&phba
->slow_ring_trc_cnt
, 0);
4094 memset(phba
->slow_ring_trc
, 0,
4095 (sizeof(struct lpfc_debugfs_trc
) *
4096 lpfc_debugfs_max_slow_ring_trc
));
4100 snprintf(name
, sizeof(name
), "vport%d", vport
->vpi
);
4101 if (!vport
->vport_debugfs_root
) {
4102 vport
->vport_debugfs_root
=
4103 debugfs_create_dir(name
, phba
->hba_debugfs_root
);
4104 if (!vport
->vport_debugfs_root
) {
4105 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
4106 "0417 Can't create debugfs\n");
4109 atomic_inc(&phba
->debugfs_vport_count
);
4112 if (lpfc_debugfs_max_disc_trc
) {
4113 num
= lpfc_debugfs_max_disc_trc
- 1;
4114 if (num
& lpfc_debugfs_max_disc_trc
) {
4115 /* Change to be a power of 2 */
4116 num
= lpfc_debugfs_max_disc_trc
;
4122 lpfc_debugfs_max_disc_trc
= (1 << i
);
4124 "lpfc_debugfs_max_disc_trc changed to %d\n",
4125 lpfc_debugfs_max_disc_trc
);
4129 vport
->disc_trc
= kzalloc(
4130 (sizeof(struct lpfc_debugfs_trc
) * lpfc_debugfs_max_disc_trc
),
4133 if (!vport
->disc_trc
) {
4134 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
4135 "0418 Cannot create debugfs disc trace "
4139 atomic_set(&vport
->disc_trc_cnt
, 0);
4141 snprintf(name
, sizeof(name
), "discovery_trace");
4142 vport
->debug_disc_trc
=
4143 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
4144 vport
->vport_debugfs_root
,
4145 vport
, &lpfc_debugfs_op_disc_trc
);
4146 if (!vport
->debug_disc_trc
) {
4147 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
4148 "0419 Cannot create debugfs "
4149 "discovery_trace\n");
4152 snprintf(name
, sizeof(name
), "nodelist");
4153 vport
->debug_nodelist
=
4154 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
4155 vport
->vport_debugfs_root
,
4156 vport
, &lpfc_debugfs_op_nodelist
);
4157 if (!vport
->debug_nodelist
) {
4158 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
4159 "2985 Can't create debugfs nodelist\n");
4164 * iDiag debugfs root entry points for SLI4 device only
4166 if (phba
->sli_rev
< LPFC_SLI_REV4
)
4169 snprintf(name
, sizeof(name
), "iDiag");
4170 if (!phba
->idiag_root
) {
4172 debugfs_create_dir(name
, phba
->hba_debugfs_root
);
4173 if (!phba
->idiag_root
) {
4174 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
4175 "2922 Can't create idiag debugfs\n");
4178 /* Initialize iDiag data structure */
4179 memset(&idiag
, 0, sizeof(idiag
));
4182 /* iDiag read PCI config space */
4183 snprintf(name
, sizeof(name
), "pciCfg");
4184 if (!phba
->idiag_pci_cfg
) {
4185 phba
->idiag_pci_cfg
=
4186 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
4187 phba
->idiag_root
, phba
, &lpfc_idiag_op_pciCfg
);
4188 if (!phba
->idiag_pci_cfg
) {
4189 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
4190 "2923 Can't create idiag debugfs\n");
4193 idiag
.offset
.last_rd
= 0;
4196 /* iDiag PCI BAR access */
4197 snprintf(name
, sizeof(name
), "barAcc");
4198 if (!phba
->idiag_bar_acc
) {
4199 phba
->idiag_bar_acc
=
4200 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
4201 phba
->idiag_root
, phba
, &lpfc_idiag_op_barAcc
);
4202 if (!phba
->idiag_bar_acc
) {
4203 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
4204 "3056 Can't create idiag debugfs\n");
4207 idiag
.offset
.last_rd
= 0;
4210 /* iDiag get PCI function queue information */
4211 snprintf(name
, sizeof(name
), "queInfo");
4212 if (!phba
->idiag_que_info
) {
4213 phba
->idiag_que_info
=
4214 debugfs_create_file(name
, S_IFREG
|S_IRUGO
,
4215 phba
->idiag_root
, phba
, &lpfc_idiag_op_queInfo
);
4216 if (!phba
->idiag_que_info
) {
4217 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
4218 "2924 Can't create idiag debugfs\n");
4223 /* iDiag access PCI function queue */
4224 snprintf(name
, sizeof(name
), "queAcc");
4225 if (!phba
->idiag_que_acc
) {
4226 phba
->idiag_que_acc
=
4227 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
4228 phba
->idiag_root
, phba
, &lpfc_idiag_op_queAcc
);
4229 if (!phba
->idiag_que_acc
) {
4230 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
4231 "2926 Can't create idiag debugfs\n");
4236 /* iDiag access PCI function doorbell registers */
4237 snprintf(name
, sizeof(name
), "drbAcc");
4238 if (!phba
->idiag_drb_acc
) {
4239 phba
->idiag_drb_acc
=
4240 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
4241 phba
->idiag_root
, phba
, &lpfc_idiag_op_drbAcc
);
4242 if (!phba
->idiag_drb_acc
) {
4243 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
4244 "2927 Can't create idiag debugfs\n");
4249 /* iDiag access PCI function control registers */
4250 snprintf(name
, sizeof(name
), "ctlAcc");
4251 if (!phba
->idiag_ctl_acc
) {
4252 phba
->idiag_ctl_acc
=
4253 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
4254 phba
->idiag_root
, phba
, &lpfc_idiag_op_ctlAcc
);
4255 if (!phba
->idiag_ctl_acc
) {
4256 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
4257 "2981 Can't create idiag debugfs\n");
4262 /* iDiag access mbox commands */
4263 snprintf(name
, sizeof(name
), "mbxAcc");
4264 if (!phba
->idiag_mbx_acc
) {
4265 phba
->idiag_mbx_acc
=
4266 debugfs_create_file(name
, S_IFREG
|S_IRUGO
|S_IWUSR
,
4267 phba
->idiag_root
, phba
, &lpfc_idiag_op_mbxAcc
);
4268 if (!phba
->idiag_mbx_acc
) {
4269 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
4270 "2980 Can't create idiag debugfs\n");
4275 /* iDiag extents access commands */
4276 if (phba
->sli4_hba
.extents_in_use
) {
4277 snprintf(name
, sizeof(name
), "extAcc");
4278 if (!phba
->idiag_ext_acc
) {
4279 phba
->idiag_ext_acc
=
4280 debugfs_create_file(name
,
4281 S_IFREG
|S_IRUGO
|S_IWUSR
,
4282 phba
->idiag_root
, phba
,
4283 &lpfc_idiag_op_extAcc
);
4284 if (!phba
->idiag_ext_acc
) {
4285 lpfc_printf_vlog(vport
, KERN_ERR
, LOG_INIT
,
4299 * lpfc_debugfs_terminate - Tear down debugfs infrastructure for this vport
4300 * @vport: The vport pointer to remove from debugfs.
4303 * When Debugfs is configured this routine removes debugfs file system elements
4304 * that are specific to this vport. It also checks to see if there are any
4305 * users left for the debugfs directories associated with the HBA and driver. If
4306 * this is the last user of the HBA directory or driver directory then it will
4307 * remove those from the debugfs infrastructure as well.
4310 lpfc_debugfs_terminate(struct lpfc_vport
*vport
)
4312 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
4313 struct lpfc_hba
*phba
= vport
->phba
;
4315 if (vport
->disc_trc
) {
4316 kfree(vport
->disc_trc
);
4317 vport
->disc_trc
= NULL
;
4319 if (vport
->debug_disc_trc
) {
4320 debugfs_remove(vport
->debug_disc_trc
); /* discovery_trace */
4321 vport
->debug_disc_trc
= NULL
;
4323 if (vport
->debug_nodelist
) {
4324 debugfs_remove(vport
->debug_nodelist
); /* nodelist */
4325 vport
->debug_nodelist
= NULL
;
4327 if (vport
->vport_debugfs_root
) {
4328 debugfs_remove(vport
->vport_debugfs_root
); /* vportX */
4329 vport
->vport_debugfs_root
= NULL
;
4330 atomic_dec(&phba
->debugfs_vport_count
);
4332 if (atomic_read(&phba
->debugfs_vport_count
) == 0) {
4334 if (phba
->debug_hbqinfo
) {
4335 debugfs_remove(phba
->debug_hbqinfo
); /* hbqinfo */
4336 phba
->debug_hbqinfo
= NULL
;
4338 if (phba
->debug_dumpHBASlim
) {
4339 debugfs_remove(phba
->debug_dumpHBASlim
); /* HBASlim */
4340 phba
->debug_dumpHBASlim
= NULL
;
4342 if (phba
->debug_dumpHostSlim
) {
4343 debugfs_remove(phba
->debug_dumpHostSlim
); /* HostSlim */
4344 phba
->debug_dumpHostSlim
= NULL
;
4346 if (phba
->debug_dumpData
) {
4347 debugfs_remove(phba
->debug_dumpData
); /* dumpData */
4348 phba
->debug_dumpData
= NULL
;
4351 if (phba
->debug_dumpDif
) {
4352 debugfs_remove(phba
->debug_dumpDif
); /* dumpDif */
4353 phba
->debug_dumpDif
= NULL
;
4355 if (phba
->debug_InjErrLBA
) {
4356 debugfs_remove(phba
->debug_InjErrLBA
); /* InjErrLBA */
4357 phba
->debug_InjErrLBA
= NULL
;
4359 if (phba
->debug_InjErrNPortID
) { /* InjErrNPortID */
4360 debugfs_remove(phba
->debug_InjErrNPortID
);
4361 phba
->debug_InjErrNPortID
= NULL
;
4363 if (phba
->debug_InjErrWWPN
) {
4364 debugfs_remove(phba
->debug_InjErrWWPN
); /* InjErrWWPN */
4365 phba
->debug_InjErrWWPN
= NULL
;
4367 if (phba
->debug_writeGuard
) {
4368 debugfs_remove(phba
->debug_writeGuard
); /* writeGuard */
4369 phba
->debug_writeGuard
= NULL
;
4371 if (phba
->debug_writeApp
) {
4372 debugfs_remove(phba
->debug_writeApp
); /* writeApp */
4373 phba
->debug_writeApp
= NULL
;
4375 if (phba
->debug_writeRef
) {
4376 debugfs_remove(phba
->debug_writeRef
); /* writeRef */
4377 phba
->debug_writeRef
= NULL
;
4379 if (phba
->debug_readGuard
) {
4380 debugfs_remove(phba
->debug_readGuard
); /* readGuard */
4381 phba
->debug_readGuard
= NULL
;
4383 if (phba
->debug_readApp
) {
4384 debugfs_remove(phba
->debug_readApp
); /* readApp */
4385 phba
->debug_readApp
= NULL
;
4387 if (phba
->debug_readRef
) {
4388 debugfs_remove(phba
->debug_readRef
); /* readRef */
4389 phba
->debug_readRef
= NULL
;
4392 if (phba
->slow_ring_trc
) {
4393 kfree(phba
->slow_ring_trc
);
4394 phba
->slow_ring_trc
= NULL
;
4396 if (phba
->debug_slow_ring_trc
) {
4397 /* slow_ring_trace */
4398 debugfs_remove(phba
->debug_slow_ring_trc
);
4399 phba
->debug_slow_ring_trc
= NULL
;
4405 if (phba
->sli_rev
== LPFC_SLI_REV4
) {
4406 if (phba
->idiag_ext_acc
) {
4408 debugfs_remove(phba
->idiag_ext_acc
);
4409 phba
->idiag_ext_acc
= NULL
;
4411 if (phba
->idiag_mbx_acc
) {
4413 debugfs_remove(phba
->idiag_mbx_acc
);
4414 phba
->idiag_mbx_acc
= NULL
;
4416 if (phba
->idiag_ctl_acc
) {
4418 debugfs_remove(phba
->idiag_ctl_acc
);
4419 phba
->idiag_ctl_acc
= NULL
;
4421 if (phba
->idiag_drb_acc
) {
4423 debugfs_remove(phba
->idiag_drb_acc
);
4424 phba
->idiag_drb_acc
= NULL
;
4426 if (phba
->idiag_que_acc
) {
4428 debugfs_remove(phba
->idiag_que_acc
);
4429 phba
->idiag_que_acc
= NULL
;
4431 if (phba
->idiag_que_info
) {
4433 debugfs_remove(phba
->idiag_que_info
);
4434 phba
->idiag_que_info
= NULL
;
4436 if (phba
->idiag_bar_acc
) {
4438 debugfs_remove(phba
->idiag_bar_acc
);
4439 phba
->idiag_bar_acc
= NULL
;
4441 if (phba
->idiag_pci_cfg
) {
4443 debugfs_remove(phba
->idiag_pci_cfg
);
4444 phba
->idiag_pci_cfg
= NULL
;
4447 /* Finally remove the iDiag debugfs root */
4448 if (phba
->idiag_root
) {
4450 debugfs_remove(phba
->idiag_root
);
4451 phba
->idiag_root
= NULL
;
4455 if (phba
->hba_debugfs_root
) {
4456 debugfs_remove(phba
->hba_debugfs_root
); /* fnX */
4457 phba
->hba_debugfs_root
= NULL
;
4458 atomic_dec(&lpfc_debugfs_hba_count
);
4461 if (atomic_read(&lpfc_debugfs_hba_count
) == 0) {
4462 debugfs_remove(lpfc_debugfs_root
); /* lpfc */
4463 lpfc_debugfs_root
= NULL
;
4471 * Driver debug utility routines outside of debugfs. The debug utility
4472 * routines implemented here is intended to be used in the instrumented
4473 * debug driver for debugging host or port issues.
4477 * lpfc_debug_dump_all_queues - dump all the queues with a hba
4478 * @phba: Pointer to HBA context object.
4480 * This function dumps entries of all the queues asociated with the @phba.
4483 lpfc_debug_dump_all_queues(struct lpfc_hba
*phba
)
4488 * Dump Work Queues (WQs)
4490 lpfc_debug_dump_mbx_wq(phba
);
4491 lpfc_debug_dump_els_wq(phba
);
4493 for (fcp_wqidx
= 0; fcp_wqidx
< phba
->cfg_fcp_wq_count
; fcp_wqidx
++)
4494 lpfc_debug_dump_fcp_wq(phba
, fcp_wqidx
);
4496 lpfc_debug_dump_hdr_rq(phba
);
4497 lpfc_debug_dump_dat_rq(phba
);
4499 * Dump Complete Queues (CQs)
4501 lpfc_debug_dump_mbx_cq(phba
);
4502 lpfc_debug_dump_els_cq(phba
);
4504 for (fcp_wqidx
= 0; fcp_wqidx
< phba
->cfg_fcp_wq_count
; fcp_wqidx
++)
4505 lpfc_debug_dump_fcp_cq(phba
, fcp_wqidx
);
4508 * Dump Event Queues (EQs)
4510 lpfc_debug_dump_sp_eq(phba
);
4512 for (fcp_wqidx
= 0; fcp_wqidx
< phba
->cfg_fcp_wq_count
; fcp_wqidx
++)
4513 lpfc_debug_dump_fcp_eq(phba
, fcp_wqidx
);