23 #include <linux/module.h>
28 #include <linux/slab.h>
29 #include <linux/pci.h>
31 #include <linux/ctype.h>
33 #include <scsi/scsi.h>
54 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
86 static int lpfc_debugfs_enable = 1;
91 static int lpfc_debugfs_max_disc_trc;
94 "Set debugfs discovery trace depth");
97 static int lpfc_debugfs_max_slow_ring_trc;
100 "Set debugfs slow ring trace depth");
102 static int lpfc_debugfs_mask_disc_trc;
105 "Set debugfs discovery trace mask");
110 static unsigned long lpfc_debugfs_start_time = 0
L;
113 static struct lpfc_idiag idiag;
139 struct lpfc_debugfs_trc *dtp;
146 enable = lpfc_debugfs_enable;
147 lpfc_debugfs_enable = 0;
151 (lpfc_debugfs_max_disc_trc - 1);
152 for (i = index; i < lpfc_debugfs_max_disc_trc; i++) {
153 dtp = vport->disc_trc +
i;
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;
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;
201 lpfc_debugfs_slow_ring_trc_data(
struct lpfc_hba *phba,
char *buf,
int size)
205 struct lpfc_debugfs_trc *dtp;
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;
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;
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;
269 lpfc_debugfs_hbqinfo_data(
struct lpfc_hba *phba,
char *buf,
int size)
282 cnt = LPFC_HBQINFO_SIZE;
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];
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];
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);
318 for (j=0; j<hbqs->entry_count; j++) {
320 "%03d: %08x %04x %05x ", j,
330 if ((j >= hbqs->
hbqPutIdx) || (j < low)) {
331 len +=
snprintf(buf+len, size-len,
"Unused\n");
338 len +=
snprintf(buf+len, size-len,
"Unused\n");
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;
389 lpfc_debugfs_dumpHBASlim_data(
struct lpfc_hba *phba,
char *buf,
int size)
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);
408 off = lpfc_debugfs_last_hba_slim_off;
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;
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));
426 spin_unlock_irq(&phba->
hbalock);
448 lpfc_debugfs_dumpHostSlim_data(
struct lpfc_hba *phba,
char *buf,
int size)
452 uint32_t word0, word1, word2, word3;
461 len +=
snprintf(buf+len, size-len,
"SLIM Mailbox\n");
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));
474 len +=
snprintf(buf+len, size-len,
"SLIM PCB\n");
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));
487 for (i = 0; i < 4; i++) {
489 pring = &psli->
ring[
i];
491 "Ring %d: CMD GetInx:%d (Max:%d Next:%d "
492 "Local:%d flg:x%x) RSP PutInx:%d Max:%d\n",
505 len +=
snprintf(buf+len, size-len,
"HA:%08x CA:%08x HS:%08x "
506 "HC:%08x\n", word0, word1, word2, word3);
508 spin_unlock_irq(&phba->
hbalock);
528 lpfc_debugfs_nodelist_data(
struct lpfc_vport *vport,
char *buf,
int size)
534 unsigned char *statep, *
name;
536 cnt = (LPFC_NODELIST_SIZE / LPFC_NODELIST_ENTRY_SIZE);
542 "Missing Nodelist Entries\n");
577 len +=
snprintf(buf+len, size-len,
"%s DID:x%06x ",
581 "WWPN %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));
586 "WWNN %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x ",
587 *name, *(name+1), *(name+2), *(name+3),
588 *(name+4), *(name+5), *(name+6), *(name+7));
590 len +=
snprintf(buf+len, size-len,
"RPI:%03d ",
593 len +=
snprintf(buf+len, size-len,
"RPI:none ");
594 len +=
snprintf(buf+len, size-len,
"flag:x%08x ",
597 len +=
snprintf(buf+len, size-len,
"UNKNOWN_TYPE ");
599 len +=
snprintf(buf+len, size-len,
"FC_NODE ");
601 len +=
snprintf(buf+len, size-len,
"FABRIC ");
603 len +=
snprintf(buf+len, size-len,
"FCP_TGT sid:%d ",
606 len +=
snprintf(buf+len, size-len,
"FCP_INITIATOR ");
607 len +=
snprintf(buf+len, size-len,
"usgmap:%x ",
609 len +=
snprintf(buf+len, size-len,
"refcnt:%x",
611 len +=
snprintf(buf+len, size-len,
"\n");
638 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
639 struct lpfc_debugfs_trc *dtp;
642 if (!(lpfc_debugfs_mask_disc_trc & mask))
645 if (!lpfc_debugfs_enable || !lpfc_debugfs_max_disc_trc ||
646 !vport || !vport->disc_trc)
650 (lpfc_debugfs_max_disc_trc - 1);
651 dtp = vport->disc_trc +
index;
679 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
680 struct lpfc_debugfs_trc *dtp;
683 if (!lpfc_debugfs_enable || !lpfc_debugfs_max_slow_ring_trc ||
684 !phba || !phba->slow_ring_trc)
688 (lpfc_debugfs_max_slow_ring_trc - 1);
689 dtp = phba->slow_ring_trc +
index;
700 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
720 struct lpfc_debug *
debug;
724 if (!lpfc_debugfs_max_disc_trc) {
734 size = (lpfc_debugfs_max_disc_trc * LPFC_DEBUG_TRC_ENTRY_SIZE);
738 if (!debug->buffer) {
743 debug->len = lpfc_debugfs_disc_trc_data(vport, debug->buffer, size);
767 lpfc_debugfs_slow_ring_trc_open(
struct inode *inode,
struct file *file)
770 struct lpfc_debug *
debug;
774 if (!lpfc_debugfs_max_slow_ring_trc) {
784 size = (lpfc_debugfs_max_slow_ring_trc * LPFC_DEBUG_TRC_ENTRY_SIZE);
788 if (!debug->buffer) {
793 debug->len = lpfc_debugfs_slow_ring_trc_data(phba, debug->buffer, size);
817 lpfc_debugfs_hbqinfo_open(
struct inode *inode,
struct file *file)
820 struct lpfc_debug *
debug;
829 if (!debug->buffer) {
834 debug->len = lpfc_debugfs_hbqinfo_data(phba, debug->buffer,
859 lpfc_debugfs_dumpHBASlim_open(
struct inode *inode,
struct file *file)
862 struct lpfc_debug *
debug;
871 if (!debug->buffer) {
876 debug->len = lpfc_debugfs_dumpHBASlim_data(phba, debug->buffer,
877 LPFC_DUMPHBASLIM_SIZE);
901 lpfc_debugfs_dumpHostSlim_open(
struct inode *inode,
struct file *file)
904 struct lpfc_debug *
debug;
913 if (!debug->buffer) {
918 debug->len = lpfc_debugfs_dumpHostSlim_data(phba, debug->buffer,
919 LPFC_DUMPHOSTSLIM_SIZE);
928 lpfc_debugfs_dumpData_open(
struct inode *inode,
struct file *file)
930 struct lpfc_debug *
debug;
944 if (!debug->buffer) {
958 lpfc_debugfs_dumpDif_open(
struct inode *inode,
struct file *file)
960 struct lpfc_debug *
debug;
974 if (!debug->buffer) {
988 lpfc_debugfs_dumpDataDif_write(
struct file *file,
const char __user *buf,
989 size_t nbytes, loff_t *ppos)
1011 lpfc_debugfs_dif_err_read(
struct file *file,
char __user *buf,
1012 size_t nbytes, loff_t *ppos)
1014 struct dentry *dent = file->f_dentry;
1020 if (dent == phba->debug_writeGuard)
1021 cnt =
snprintf(cbuf, 32,
"%u\n", phba->lpfc_injerr_wgrd_cnt);
1022 else if (dent == phba->debug_writeApp)
1023 cnt =
snprintf(cbuf, 32,
"%u\n", phba->lpfc_injerr_wapp_cnt);
1024 else if (dent == phba->debug_writeRef)
1025 cnt =
snprintf(cbuf, 32,
"%u\n", phba->lpfc_injerr_wref_cnt);
1026 else if (dent == phba->debug_readGuard)
1027 cnt =
snprintf(cbuf, 32,
"%u\n", phba->lpfc_injerr_rgrd_cnt);
1028 else if (dent == phba->debug_readApp)
1029 cnt =
snprintf(cbuf, 32,
"%u\n", phba->lpfc_injerr_rapp_cnt);
1030 else if (dent == phba->debug_readRef)
1031 cnt =
snprintf(cbuf, 32,
"%u\n", phba->lpfc_injerr_rref_cnt);
1032 else if (dent == phba->debug_InjErrNPortID)
1033 cnt =
snprintf(cbuf, 32,
"0x%06x\n", phba->lpfc_injerr_nportid);
1034 else if (dent == phba->debug_InjErrWWPN) {
1037 cnt =
snprintf(cbuf, 32,
"0x%016llx\n", tmp);
1038 }
else if (dent == phba->debug_InjErrLBA) {
1039 if (phba->lpfc_injerr_lba == (
sector_t)(-1))
1042 cnt =
snprintf(cbuf, 32,
"0x%llx\n",
1046 "0547 Unknown debugfs error injection entry\n");
1052 lpfc_debugfs_dif_err_write(
struct file *file,
const char __user *buf,
1053 size_t nbytes, loff_t *ppos)
1055 struct dentry *dent = file->f_dentry;
1062 size = (nbytes < 32) ? nbytes : 32;
1066 if (dent == phba->debug_InjErrLBA) {
1067 if ((buf[0] ==
'o') && (buf[1] ==
'f') && (buf[2] ==
'f'))
1071 if ((tmp == 0) && (
kstrtoull(dstbuf, 0, &tmp)))
1074 if (dent == phba->debug_writeGuard)
1075 phba->lpfc_injerr_wgrd_cnt = (
uint32_t)tmp;
1076 else if (dent == phba->debug_writeApp)
1077 phba->lpfc_injerr_wapp_cnt = (
uint32_t)tmp;
1078 else if (dent == phba->debug_writeRef)
1079 phba->lpfc_injerr_wref_cnt = (
uint32_t)tmp;
1080 else if (dent == phba->debug_readGuard)
1081 phba->lpfc_injerr_rgrd_cnt = (
uint32_t)tmp;
1082 else if (dent == phba->debug_readApp)
1083 phba->lpfc_injerr_rapp_cnt = (
uint32_t)tmp;
1084 else if (dent == phba->debug_readRef)
1085 phba->lpfc_injerr_rref_cnt = (
uint32_t)tmp;
1086 else if (dent == phba->debug_InjErrLBA)
1087 phba->lpfc_injerr_lba = (
sector_t)tmp;
1088 else if (dent == phba->debug_InjErrNPortID)
1090 else if (dent == phba->debug_InjErrWWPN) {
1095 "0548 Unknown debugfs error injection entry\n");
1101 lpfc_debugfs_dif_err_release(
struct inode *inode,
struct file *file)
1122 lpfc_debugfs_nodelist_open(
struct inode *inode,
struct file *file)
1125 struct lpfc_debug *
debug;
1134 if (!debug->buffer) {
1139 debug->len = lpfc_debugfs_nodelist_data(vport, debug->buffer,
1140 LPFC_NODELIST_SIZE);
1166 lpfc_debugfs_lseek(
struct file *file, loff_t off,
int whence)
1168 struct lpfc_debug *
debug;
1178 pos = file->
f_pos + off;
1181 pos = debug->len - off;
1183 return (pos < 0 || pos > debug->len) ? -
EINVAL : (file->
f_pos =
pos);
1203 lpfc_debugfs_read(
struct file *file,
char __user *buf,
1204 size_t nbytes, loff_t *ppos)
1225 lpfc_debugfs_release(
struct inode *inode,
struct file *file)
1229 kfree(debug->buffer);
1236 lpfc_debugfs_dumpDataDif_release(
struct inode *inode,
struct file *file)
1240 debug->buffer =
NULL;
1270 static int lpfc_idiag_cmd_get(
const char __user *buf,
size_t nbytes,
1271 struct lpfc_idiag_cmd *idiag_cmd)
1274 char *pbuf, *step_str;
1282 memset(mybuf, 0,
sizeof(mybuf));
1283 memset(idiag_cmd, 0,
sizeof(*idiag_cmd));
1284 bsize =
min(nbytes, (
sizeof(mybuf)-1));
1289 step_str =
strsep(&pbuf,
"\t ");
1296 if (idiag_cmd->opcode == 0)
1299 for (i = 0; i < LPFC_IDIAG_CMD_DATA_SIZE; i++) {
1300 step_str =
strsep(&pbuf,
"\t ");
1326 lpfc_idiag_open(
struct inode *inode,
struct file *file)
1328 struct lpfc_debug *
debug;
1335 debug->buffer =
NULL;
1355 lpfc_idiag_release(
struct inode *inode,
struct file *file)
1360 kfree(debug->buffer);
1380 lpfc_idiag_cmd_release(
struct inode *inode,
struct file *file)
1384 if (debug->op == LPFC_IDIAG_OP_WR) {
1385 switch (idiag.cmd.opcode) {
1386 case LPFC_IDIAG_CMD_PCICFG_WR:
1387 case LPFC_IDIAG_CMD_PCICFG_ST:
1388 case LPFC_IDIAG_CMD_PCICFG_CL:
1389 case LPFC_IDIAG_CMD_QUEACC_WR:
1390 case LPFC_IDIAG_CMD_QUEACC_ST:
1391 case LPFC_IDIAG_CMD_QUEACC_CL:
1392 memset(&idiag, 0,
sizeof(idiag));
1400 kfree(debug->buffer);
1425 lpfc_idiag_pcicfg_read(
struct file *file,
char __user *buf,
size_t nbytes,
1430 int offset_label,
offset, len = 0, index = LPFC_PCI_CFG_RD_SIZE;
1443 debug->op = LPFC_IDIAG_OP_RD;
1449 pbuffer = debug->buffer;
1454 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_RD) {
1455 where = idiag.cmd.data[IDIAG_PCICFG_WHERE_INDX];
1456 count = idiag.cmd.data[IDIAG_PCICFG_COUNT_INDX];
1463 pci_read_config_byte(pdev, where, &u8val);
1464 len +=
snprintf(pbuffer+len, LPFC_PCI_CFG_SIZE-len,
1465 "%03x: %02x\n", where, u8val);
1468 pci_read_config_word(pdev, where, &u16val);
1469 len +=
snprintf(pbuffer+len, LPFC_PCI_CFG_SIZE-len,
1470 "%03x: %04x\n", where, u16val);
1473 pci_read_config_dword(pdev, where, &u32val);
1474 len +=
snprintf(pbuffer+len, LPFC_PCI_CFG_SIZE-len,
1475 "%03x: %08x\n", where, u32val);
1477 case LPFC_PCI_CFG_BROWSE:
1490 offset_label = idiag.offset.last_rd;
1494 len +=
snprintf(pbuffer+len, LPFC_PCI_CFG_SIZE-len,
1495 "%03x: ", offset_label);
1497 pci_read_config_dword(pdev,
offset, &u32val);
1498 len +=
snprintf(pbuffer+len, LPFC_PCI_CFG_SIZE-len,
1501 if (
offset >= LPFC_PCI_CFG_SIZE) {
1503 LPFC_PCI_CFG_SIZE-len,
"\n");
1508 len +=
snprintf(pbuffer+len, LPFC_PCI_CFG_SIZE-len,
1510 else if (!(index % (8 *
sizeof(
uint32_t)))) {
1511 offset_label += (8 *
sizeof(
uint32_t));
1512 len +=
snprintf(pbuffer+len, LPFC_PCI_CFG_SIZE-len,
1513 "\n%03x: ", offset_label);
1519 idiag.offset.last_rd += LPFC_PCI_CFG_RD_SIZE;
1520 if (idiag.offset.last_rd >= LPFC_PCI_CFG_SIZE)
1521 idiag.offset.last_rd = 0;
1523 idiag.offset.last_rd = 0;
1547 lpfc_idiag_pcicfg_write(
struct file *file,
const char __user *buf,
1548 size_t nbytes, loff_t *ppos)
1564 debug->op = LPFC_IDIAG_OP_WR;
1566 rc = lpfc_idiag_cmd_get(buf, nbytes, &idiag.cmd);
1570 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_RD) {
1572 if (rc != LPFC_PCI_CFG_RD_CMD_ARG)
1575 where = idiag.cmd.data[IDIAG_PCICFG_WHERE_INDX];
1576 count = idiag.cmd.data[IDIAG_PCICFG_COUNT_INDX];
1577 if (
count == LPFC_PCI_CFG_BROWSE) {
1581 idiag.offset.last_rd = where;
1587 if (where > LPFC_PCI_CFG_SIZE -
sizeof(
uint8_t))
1593 if (where > LPFC_PCI_CFG_SIZE -
sizeof(
uint16_t))
1599 if (where > LPFC_PCI_CFG_SIZE -
sizeof(
uint32_t))
1604 }
else if (idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_WR ||
1605 idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_ST ||
1606 idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_CL) {
1608 if (rc != LPFC_PCI_CFG_WR_CMD_ARG)
1611 where = idiag.cmd.data[IDIAG_PCICFG_WHERE_INDX];
1612 count = idiag.cmd.data[IDIAG_PCICFG_COUNT_INDX];
1613 value = idiag.cmd.data[IDIAG_PCICFG_VALUE_INDX];
1620 if (where > LPFC_PCI_CFG_SIZE -
sizeof(
uint8_t))
1624 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_WR)
1625 pci_write_config_byte(pdev, where,
1627 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_ST) {
1628 rc = pci_read_config_byte(pdev, where, &u8val);
1631 pci_write_config_byte(pdev, where,
1635 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_CL) {
1636 rc = pci_read_config_byte(pdev, where, &u8val);
1639 pci_write_config_byte(pdev, where,
1645 if (where > LPFC_PCI_CFG_SIZE -
sizeof(
uint16_t))
1649 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_WR)
1650 pci_write_config_word(pdev, where,
1652 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_ST) {
1653 rc = pci_read_config_word(pdev, where, &u16val);
1656 pci_write_config_word(pdev, where,
1660 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_CL) {
1661 rc = pci_read_config_word(pdev, where, &u16val);
1664 pci_write_config_word(pdev, where,
1670 if (where > LPFC_PCI_CFG_SIZE -
sizeof(
uint32_t))
1674 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_WR)
1675 pci_write_config_dword(pdev, where,
value);
1676 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_ST) {
1677 rc = pci_read_config_dword(pdev, where,
1681 pci_write_config_dword(pdev, where,
1685 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_CL) {
1686 rc = pci_read_config_dword(pdev, where,
1690 pci_write_config_dword(pdev, where,
1701 memset(&idiag, 0,
sizeof(idiag));
1721 lpfc_idiag_baracc_read(
struct file *file,
char __user *buf,
size_t nbytes,
1726 int offset_label,
offset, offset_run, len = 0, index;
1727 int bar_num, acc_range, bar_size;
1739 debug->op = LPFC_IDIAG_OP_RD;
1745 pbuffer = debug->buffer;
1750 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_BARACC_RD) {
1751 bar_num = idiag.cmd.data[IDIAG_BARACC_BAR_NUM_INDX];
1752 offset = idiag.cmd.data[IDIAG_BARACC_OFF_SET_INDX];
1753 acc_range = idiag.cmd.data[IDIAG_BARACC_ACC_MOD_INDX];
1754 bar_size = idiag.cmd.data[IDIAG_BARACC_BAR_SZE_INDX];
1761 if_type =
bf_get(lpfc_sli_intf_if_type, &phba->
sli4_hba.sli_intf);
1763 if (bar_num == IDIAG_BARACC_BAR_0)
1764 mem_mapped_bar = phba->
sli4_hba.conf_regs_memmap_p;
1765 else if (bar_num == IDIAG_BARACC_BAR_1)
1766 mem_mapped_bar = phba->
sli4_hba.ctrl_regs_memmap_p;
1767 else if (bar_num == IDIAG_BARACC_BAR_2)
1768 mem_mapped_bar = phba->
sli4_hba.drbl_regs_memmap_p;
1772 if (bar_num == IDIAG_BARACC_BAR_0)
1773 mem_mapped_bar = phba->
sli4_hba.conf_regs_memmap_p;
1780 if (acc_range == SINGLE_WORD) {
1782 u32val =
readl(mem_mapped_bar + offset_run);
1783 len +=
snprintf(pbuffer+len, LPFC_PCI_BAR_RD_BUF_SIZE-len,
1784 "%05x: %08x\n", offset_run, u32val);
1793 offset_label = idiag.offset.last_rd;
1794 offset_run = offset_label;
1797 len +=
snprintf(pbuffer+len, LPFC_PCI_BAR_RD_BUF_SIZE-len,
1798 "%05x: ", offset_label);
1799 index = LPFC_PCI_BAR_RD_SIZE;
1801 u32val =
readl(mem_mapped_bar + offset_run);
1802 len +=
snprintf(pbuffer+len, LPFC_PCI_BAR_RD_BUF_SIZE-len,
1805 if (acc_range == LPFC_PCI_BAR_BROWSE) {
1806 if (offset_run >= bar_size) {
1808 LPFC_PCI_BAR_RD_BUF_SIZE-len,
"\n");
1812 if (offset_run >=
offset +
1815 LPFC_PCI_BAR_RD_BUF_SIZE-len,
"\n");
1822 LPFC_PCI_BAR_RD_BUF_SIZE-len,
"\n");
1823 else if (!(index % (8 *
sizeof(
uint32_t)))) {
1824 offset_label += (8 *
sizeof(
uint32_t));
1826 LPFC_PCI_BAR_RD_BUF_SIZE-len,
1827 "\n%05x: ", offset_label);
1833 idiag.offset.last_rd += LPFC_PCI_BAR_RD_SIZE;
1834 if (acc_range == LPFC_PCI_BAR_BROWSE) {
1835 if (idiag.offset.last_rd >= bar_size)
1836 idiag.offset.last_rd = 0;
1838 if (offset_run >=
offset +
1840 idiag.offset.last_rd =
offset;
1843 if (acc_range == LPFC_PCI_BAR_BROWSE)
1844 idiag.offset.last_rd = 0;
1846 idiag.offset.last_rd =
offset;
1872 lpfc_idiag_baracc_write(
struct file *file,
const char __user *buf,
1873 size_t nbytes, loff_t *ppos)
1889 debug->op = LPFC_IDIAG_OP_WR;
1891 rc = lpfc_idiag_cmd_get(buf, nbytes, &idiag.cmd);
1895 if_type =
bf_get(lpfc_sli_intf_if_type, &phba->
sli4_hba.sli_intf);
1896 bar_num = idiag.cmd.data[IDIAG_BARACC_BAR_NUM_INDX];
1899 if ((bar_num != IDIAG_BARACC_BAR_0) &&
1900 (bar_num != IDIAG_BARACC_BAR_1) &&
1901 (bar_num != IDIAG_BARACC_BAR_2))
1904 if (bar_num != IDIAG_BARACC_BAR_0)
1910 if (bar_num == IDIAG_BARACC_BAR_0) {
1911 idiag.cmd.data[IDIAG_BARACC_BAR_SZE_INDX] =
1912 LPFC_PCI_IF0_BAR0_SIZE;
1913 mem_mapped_bar = phba->
sli4_hba.conf_regs_memmap_p;
1914 }
else if (bar_num == IDIAG_BARACC_BAR_1) {
1915 idiag.cmd.data[IDIAG_BARACC_BAR_SZE_INDX] =
1916 LPFC_PCI_IF0_BAR1_SIZE;
1917 mem_mapped_bar = phba->
sli4_hba.ctrl_regs_memmap_p;
1918 }
else if (bar_num == IDIAG_BARACC_BAR_2) {
1919 idiag.cmd.data[IDIAG_BARACC_BAR_SZE_INDX] =
1920 LPFC_PCI_IF0_BAR2_SIZE;
1921 mem_mapped_bar = phba->
sli4_hba.drbl_regs_memmap_p;
1925 if (bar_num == IDIAG_BARACC_BAR_0) {
1926 idiag.cmd.data[IDIAG_BARACC_BAR_SZE_INDX] =
1927 LPFC_PCI_IF2_BAR0_SIZE;
1928 mem_mapped_bar = phba->
sli4_hba.conf_regs_memmap_p;
1934 offset = idiag.cmd.data[IDIAG_BARACC_OFF_SET_INDX];
1938 bar_size = idiag.cmd.data[IDIAG_BARACC_BAR_SZE_INDX];
1939 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_BARACC_RD) {
1941 if (rc != LPFC_PCI_BAR_RD_CMD_ARG)
1943 acc_range = idiag.cmd.data[IDIAG_BARACC_ACC_MOD_INDX];
1944 if (acc_range == LPFC_PCI_BAR_BROWSE) {
1949 }
else if (acc_range > SINGLE_WORD) {
1953 idiag.offset.last_rd =
offset;
1954 }
else if (acc_range != SINGLE_WORD)
1956 }
else if (idiag.cmd.opcode == LPFC_IDIAG_CMD_BARACC_WR ||
1957 idiag.cmd.opcode == LPFC_IDIAG_CMD_BARACC_ST ||
1958 idiag.cmd.opcode == LPFC_IDIAG_CMD_BARACC_CL) {
1960 if (rc != LPFC_PCI_BAR_WR_CMD_ARG)
1963 acc_range = SINGLE_WORD;
1964 value = idiag.cmd.data[IDIAG_BARACC_REG_VAL_INDX];
1965 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_BARACC_WR) {
1969 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_BARACC_ST) {
1975 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_BARACC_CL) {
1987 memset(&idiag, 0,
sizeof(idiag));
2007 lpfc_idiag_queinfo_read(
struct file *file,
char __user *buf,
size_t nbytes,
2023 pbuffer = debug->buffer;
2024 max_cnt = LPFC_QUE_INFO_GET_BUF_SIZE - 128;
2029 spin_lock_irq(&phba->
hbalock);
2035 for (x = 0; x <
cnt; x++) {
2043 LPFC_QUE_INFO_GET_BUF_SIZE-len,
2045 "EQ-STAT[max:x%x noE:x%x "
2046 "bs:x%x proc:x%llx]\n",
2047 qp->q_cnt_1, qp->q_cnt_2,
2048 qp->q_cnt_3, (
unsigned long long)qp->q_cnt_4);
2051 LPFC_QUE_INFO_GET_BUF_SIZE-len,
2053 "QE-CNT[%04d], QE-SIZE[%04d], "
2054 "HOST-IDX[%04d], PORT-IDX[%04d]",
2066 LPFC_QUE_INFO_GET_BUF_SIZE-len,
"\n");
2073 LPFC_QUE_INFO_GET_BUF_SIZE-len,
2076 LPFC_QUE_INFO_GET_BUF_SIZE-len,
2078 "CQ STAT[max:x%x relw:x%x "
2079 "xabt:x%x wq:x%llx]\n",
2081 qp->q_cnt_1, qp->q_cnt_2,
2082 qp->q_cnt_3, (
unsigned long long)qp->q_cnt_4);
2084 LPFC_QUE_INFO_GET_BUF_SIZE-len,
2086 "QE-CNT[%04d], QE-SIZE[%04d], "
2087 "HOST-IDX[%04d], PORT-IDX[%04d]",
2088 qp->queue_id, qp->entry_count,
2089 qp->entry_size, qp->host_index,
2097 LPFC_QUE_INFO_GET_BUF_SIZE-len,
"\n");
2105 LPFC_QUE_INFO_GET_BUF_SIZE-len,
2106 "\t\tFCP WQ info: ");
2108 LPFC_QUE_INFO_GET_BUF_SIZE-len,
2110 "WQ-STAT[oflow:x%x posted:x%llx]\n",
2112 qp->q_cnt_1, (
unsigned long long)qp->q_cnt_4);
2114 LPFC_QUE_INFO_GET_BUF_SIZE-len,
2116 "QE-CNT[%04d], QE-SIZE[%04d], "
2117 "HOST-IDX[%04d], PORT-IDX[%04d]",
2125 LPFC_QUE_INFO_GET_BUF_SIZE-len,
"\n");
2138 LPFC_QUE_INFO_GET_BUF_SIZE-len,
2141 LPFC_QUE_INFO_GET_BUF_SIZE-len,
2143 "CQ-STAT[mbox:x%x relw:x%x "
2144 "xabt:x%x wq:x%llx]\n",
2146 qp->q_cnt_1, qp->q_cnt_2,
2148 (
unsigned long long)qp->q_cnt_4);
2150 LPFC_QUE_INFO_GET_BUF_SIZE-len,
2152 "QE-CNT[%04d], QE-SIZE[%04d], "
2153 "HOST-IDX[%04d], PORT-IDX[%04d]",
2154 qp->queue_id, qp->entry_count,
2155 qp->entry_size, qp->host_index,
2159 LPFC_QUE_INFO_GET_BUF_SIZE-len,
"\n");
2168 LPFC_QUE_INFO_GET_BUF_SIZE-len,
2169 "\t\tMBX MQ info: ");
2171 LPFC_QUE_INFO_GET_BUF_SIZE-len,
2172 "AssocCQID[%02d]:\n",
2175 LPFC_QUE_INFO_GET_BUF_SIZE-len,
2177 "QE-CNT[%04d], QE-SIZE[%04d], "
2178 "HOST-IDX[%04d], PORT-IDX[%04d]",
2179 qp->queue_id, qp->entry_count,
2180 qp->entry_size, qp->host_index,
2184 LPFC_QUE_INFO_GET_BUF_SIZE-len,
"\n");
2193 LPFC_QUE_INFO_GET_BUF_SIZE-len,
2196 LPFC_QUE_INFO_GET_BUF_SIZE-len,
2198 "CQ-STAT[max:x%x relw:x%x "
2199 "xabt:x%x wq:x%llx]\n",
2201 qp->q_cnt_1, qp->q_cnt_2,
2203 (
unsigned long long)qp->q_cnt_4);
2205 LPFC_QUE_INFO_GET_BUF_SIZE-len,
2207 "QE-CNT[%04d], QE-SIZE[%04d], "
2208 "HOST-IDX[%04d], PORT-IDX[%04d]",
2209 qp->queue_id, qp->entry_count,
2210 qp->entry_size, qp->host_index,
2217 LPFC_QUE_INFO_GET_BUF_SIZE-len,
"\n");
2226 LPFC_QUE_INFO_GET_BUF_SIZE-len,
2227 "\t\tELS WQ info: ");
2229 LPFC_QUE_INFO_GET_BUF_SIZE-len,
2231 " WQ-STAT[oflow:x%x "
2235 (
unsigned long long)qp->q_cnt_4);
2237 LPFC_QUE_INFO_GET_BUF_SIZE-len,
2239 "QE-CNT[%04d], QE-SIZE[%04d], "
2240 "HOST-IDX[%04d], PORT-IDX[%04d]",
2241 qp->queue_id, qp->entry_count,
2242 qp->entry_size, qp->host_index,
2246 LPFC_QUE_INFO_GET_BUF_SIZE-len,
"\n");
2256 LPFC_QUE_INFO_GET_BUF_SIZE-len,
2259 LPFC_QUE_INFO_GET_BUF_SIZE-len,
2261 "RQ-STAT[nopost:x%x nobuf:x%x "
2262 "trunc:x%x rcv:x%llx]\n",
2264 qp->q_cnt_1, qp->q_cnt_2,
2266 (
unsigned long long)qp->q_cnt_4);
2268 LPFC_QUE_INFO_GET_BUF_SIZE-len,
2270 "QE-CNT[%04d], QE-SIZE[%04d], "
2271 "HOST-IDX[%04d], PORT-IDX[%04d]\n",
2281 LPFC_QUE_INFO_GET_BUF_SIZE-len,
2283 "QE-CNT[%04d], QE-SIZE[%04d], "
2284 "HOST-IDX[%04d], PORT-IDX[%04d]\n",
2292 LPFC_QUE_INFO_GET_BUF_SIZE-len,
"\n");
2297 spin_unlock_irq(&phba->
hbalock);
2302 LPFC_QUE_INFO_GET_BUF_SIZE-len,
"Truncated ...\n");
2303 spin_unlock_irq(&phba->
hbalock);
2324 if ((count != 1) && (count != LPFC_QUE_ACC_BROWSE))
2346 lpfc_idiag_queacc_read_qe(
char *pbuffer,
int len,
struct lpfc_queue *pque,
2352 if (!pbuffer || !pque)
2356 len +=
snprintf(pbuffer+len, LPFC_QUE_ACC_BUF_SIZE-len,
2357 "QE-INDEX[%04d]:\n", index);
2362 len +=
snprintf(pbuffer+len, LPFC_QUE_ACC_BUF_SIZE-len,
2367 if (esize > 0 && !(offset % (4 *
sizeof(
uint32_t))))
2369 LPFC_QUE_ACC_BUF_SIZE-len,
"\n");
2371 len +=
snprintf(pbuffer+len, LPFC_QUE_ACC_BUF_SIZE-len,
"\n");
2394 lpfc_idiag_queacc_read(
struct file *file,
char __user *buf,
size_t nbytes,
2404 debug->op = LPFC_IDIAG_OP_RD;
2410 pbuffer = debug->buffer;
2415 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_QUEACC_RD) {
2416 index = idiag.cmd.data[IDIAG_QUEACC_INDEX_INDX];
2417 count = idiag.cmd.data[IDIAG_QUEACC_COUNT_INDX];
2418 pque = (
struct lpfc_queue *)idiag.ptr_private;
2423 if (count == LPFC_QUE_ACC_BROWSE)
2427 len = lpfc_idiag_queacc_read_qe(pbuffer, len, pque, index);
2434 last_index = idiag.offset.last_rd;
2437 while (len < LPFC_QUE_ACC_SIZE - pque->
entry_size) {
2438 len = lpfc_idiag_queacc_read_qe(pbuffer, len, pque, index);
2447 idiag.offset.last_rd =
index;
2471 lpfc_idiag_queacc_write(
struct file *file,
const char __user *buf,
2472 size_t nbytes, loff_t *ppos)
2482 debug->op = LPFC_IDIAG_OP_WR;
2484 rc = lpfc_idiag_cmd_get(buf, nbytes, &idiag.cmd);
2489 quetp = idiag.cmd.data[IDIAG_QUEACC_QUETP_INDX];
2490 queid = idiag.cmd.data[IDIAG_QUEACC_QUEID_INDX];
2491 index = idiag.cmd.data[IDIAG_QUEACC_INDEX_INDX];
2492 count = idiag.cmd.data[IDIAG_QUEACC_COUNT_INDX];
2493 offset = idiag.cmd.data[IDIAG_QUEACC_OFFST_INDX];
2494 value = idiag.cmd.data[IDIAG_QUEACC_VALUE_INDX];
2497 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_QUEACC_WR ||
2498 idiag.cmd.opcode == LPFC_IDIAG_CMD_QUEACC_ST ||
2499 idiag.cmd.opcode == LPFC_IDIAG_CMD_QUEACC_CL) {
2500 if (rc != LPFC_QUE_ACC_WR_CMD_ARG)
2504 }
else if (idiag.cmd.opcode == LPFC_IDIAG_CMD_QUEACC_RD) {
2505 if (rc != LPFC_QUE_ACC_RD_CMD_ARG)
2517 phba->
sli4_hba.hba_eq[qidx]->queue_id ==
2520 rc = lpfc_idiag_que_param_check(
2536 phba->
sli4_hba.mbx_cq->queue_id == queid) {
2538 rc = lpfc_idiag_que_param_check(
2539 phba->
sli4_hba.mbx_cq, index, count);
2542 idiag.ptr_private = phba->
sli4_hba.mbx_cq;
2547 phba->
sli4_hba.els_cq->queue_id == queid) {
2549 rc = lpfc_idiag_que_param_check(
2550 phba->
sli4_hba.els_cq, index, count);
2553 idiag.ptr_private = phba->
sli4_hba.els_cq;
2561 phba->
sli4_hba.fcp_cq[qidx]->queue_id ==
2564 rc = lpfc_idiag_que_param_check(
2580 phba->
sli4_hba.mbx_wq->queue_id == queid) {
2582 rc = lpfc_idiag_que_param_check(
2583 phba->
sli4_hba.mbx_wq, index, count);
2586 idiag.ptr_private = phba->
sli4_hba.mbx_wq;
2594 phba->
sli4_hba.els_wq->queue_id == queid) {
2596 rc = lpfc_idiag_que_param_check(
2597 phba->
sli4_hba.els_wq, index, count);
2600 idiag.ptr_private = phba->
sli4_hba.els_wq;
2609 if (phba->
sli4_hba.fcp_wq[qidx]->queue_id ==
2612 rc = lpfc_idiag_que_param_check(
2628 phba->
sli4_hba.hdr_rq->queue_id == queid) {
2630 rc = lpfc_idiag_que_param_check(
2631 phba->
sli4_hba.hdr_rq, index, count);
2634 idiag.ptr_private = phba->
sli4_hba.hdr_rq;
2639 phba->
sli4_hba.dat_rq->queue_id == queid) {
2641 rc = lpfc_idiag_que_param_check(
2642 phba->
sli4_hba.dat_rq, index, count);
2645 idiag.ptr_private = phba->
sli4_hba.dat_rq;
2657 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_QUEACC_RD) {
2658 if (count == LPFC_QUE_ACC_BROWSE)
2659 idiag.offset.last_rd =
index;
2662 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_QUEACC_WR ||
2663 idiag.cmd.opcode == LPFC_IDIAG_CMD_QUEACC_ST ||
2664 idiag.cmd.opcode == LPFC_IDIAG_CMD_QUEACC_CL) {
2666 pque = (
struct lpfc_queue *)idiag.ptr_private;
2671 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_QUEACC_WR)
2673 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_QUEACC_ST)
2675 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_QUEACC_CL)
2682 memset(&idiag, 0,
sizeof(idiag));
2701 lpfc_idiag_drbacc_read_reg(
struct lpfc_hba *phba,
char *pbuffer,
2710 len +=
snprintf(pbuffer+len, LPFC_DRB_ACC_BUF_SIZE-len,
2711 "EQCQ-DRB-REG: 0x%08x\n",
2715 len +=
snprintf(pbuffer+len, LPFC_DRB_ACC_BUF_SIZE-len,
2716 "MQ-DRB-REG: 0x%08x\n",
2720 len +=
snprintf(pbuffer+len, LPFC_DRB_ACC_BUF_SIZE-len,
2721 "WQ-DRB-REG: 0x%08x\n",
2725 len +=
snprintf(pbuffer+len, LPFC_DRB_ACC_BUF_SIZE-len,
2726 "RQ-DRB-REG: 0x%08x\n",
2754 lpfc_idiag_drbacc_read(
struct file *file,
char __user *buf,
size_t nbytes,
2764 debug->op = LPFC_IDIAG_OP_RD;
2770 pbuffer = debug->buffer;
2775 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_DRBACC_RD)
2776 drb_reg_id = idiag.cmd.data[IDIAG_DRBACC_REGID_INDX];
2780 if (drb_reg_id == LPFC_DRB_ACC_ALL)
2781 for (i = 1; i <= LPFC_DRB_MAX; i++)
2782 len = lpfc_idiag_drbacc_read_reg(phba,
2785 len = lpfc_idiag_drbacc_read_reg(phba,
2786 pbuffer, len, drb_reg_id);
2810 lpfc_idiag_drbacc_write(
struct file *file,
const char __user *buf,
2811 size_t nbytes, loff_t *ppos)
2820 debug->op = LPFC_IDIAG_OP_WR;
2822 rc = lpfc_idiag_cmd_get(buf, nbytes, &idiag.cmd);
2827 drb_reg_id = idiag.cmd.data[IDIAG_DRBACC_REGID_INDX];
2828 value = idiag.cmd.data[IDIAG_DRBACC_VALUE_INDX];
2830 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_DRBACC_WR ||
2831 idiag.cmd.opcode == LPFC_IDIAG_CMD_DRBACC_ST ||
2832 idiag.cmd.opcode == LPFC_IDIAG_CMD_DRBACC_CL) {
2833 if (rc != LPFC_DRB_ACC_WR_CMD_ARG)
2835 if (drb_reg_id > LPFC_DRB_MAX)
2837 }
else if (idiag.cmd.opcode == LPFC_IDIAG_CMD_DRBACC_RD) {
2838 if (rc != LPFC_DRB_ACC_RD_CMD_ARG)
2840 if ((drb_reg_id > LPFC_DRB_MAX) &&
2841 (drb_reg_id != LPFC_DRB_ACC_ALL))
2847 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_DRBACC_WR ||
2848 idiag.cmd.opcode == LPFC_IDIAG_CMD_DRBACC_ST ||
2849 idiag.cmd.opcode == LPFC_IDIAG_CMD_DRBACC_CL) {
2850 switch (drb_reg_id) {
2852 drb_reg = phba->
sli4_hba.EQCQDBregaddr;
2855 drb_reg = phba->
sli4_hba.MQDBregaddr;
2858 drb_reg = phba->
sli4_hba.WQDBregaddr;
2861 drb_reg = phba->
sli4_hba.RQDBregaddr;
2867 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_DRBACC_WR)
2869 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_DRBACC_ST) {
2873 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_DRBACC_CL) {
2884 memset(&idiag, 0,
sizeof(idiag));
2903 lpfc_idiag_ctlacc_read_reg(
struct lpfc_hba *phba,
char *pbuffer,
2911 case LPFC_CTL_PORT_SEM:
2912 len +=
snprintf(pbuffer+len, LPFC_CTL_ACC_BUF_SIZE-len,
2913 "Port SemReg: 0x%08x\n",
2917 case LPFC_CTL_PORT_STA:
2918 len +=
snprintf(pbuffer+len, LPFC_CTL_ACC_BUF_SIZE-len,
2919 "Port StaReg: 0x%08x\n",
2923 case LPFC_CTL_PORT_CTL:
2924 len +=
snprintf(pbuffer+len, LPFC_CTL_ACC_BUF_SIZE-len,
2925 "Port CtlReg: 0x%08x\n",
2929 case LPFC_CTL_PORT_ER1:
2930 len +=
snprintf(pbuffer+len, LPFC_CTL_ACC_BUF_SIZE-len,
2931 "Port Er1Reg: 0x%08x\n",
2935 case LPFC_CTL_PORT_ER2:
2936 len +=
snprintf(pbuffer+len, LPFC_CTL_ACC_BUF_SIZE-len,
2937 "Port Er2Reg: 0x%08x\n",
2941 case LPFC_CTL_PDEV_CTL:
2942 len +=
snprintf(pbuffer+len, LPFC_CTL_ACC_BUF_SIZE-len,
2943 "PDev CtlReg: 0x%08x\n",
2969 lpfc_idiag_ctlacc_read(
struct file *file,
char __user *buf,
size_t nbytes,
2979 debug->op = LPFC_IDIAG_OP_RD;
2985 pbuffer = debug->buffer;
2990 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_CTLACC_RD)
2991 ctl_reg_id = idiag.cmd.data[IDIAG_CTLACC_REGID_INDX];
2995 if (ctl_reg_id == LPFC_CTL_ACC_ALL)
2996 for (i = 1; i <= LPFC_CTL_MAX; i++)
2997 len = lpfc_idiag_ctlacc_read_reg(phba,
3000 len = lpfc_idiag_ctlacc_read_reg(phba,
3001 pbuffer, len, ctl_reg_id);
3022 lpfc_idiag_ctlacc_write(
struct file *file,
const char __user *buf,
3023 size_t nbytes, loff_t *ppos)
3032 debug->op = LPFC_IDIAG_OP_WR;
3034 rc = lpfc_idiag_cmd_get(buf, nbytes, &idiag.cmd);
3039 ctl_reg_id = idiag.cmd.data[IDIAG_CTLACC_REGID_INDX];
3040 value = idiag.cmd.data[IDIAG_CTLACC_VALUE_INDX];
3042 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_CTLACC_WR ||
3043 idiag.cmd.opcode == LPFC_IDIAG_CMD_CTLACC_ST ||
3044 idiag.cmd.opcode == LPFC_IDIAG_CMD_CTLACC_CL) {
3045 if (rc != LPFC_CTL_ACC_WR_CMD_ARG)
3047 if (ctl_reg_id > LPFC_CTL_MAX)
3049 }
else if (idiag.cmd.opcode == LPFC_IDIAG_CMD_CTLACC_RD) {
3050 if (rc != LPFC_CTL_ACC_RD_CMD_ARG)
3052 if ((ctl_reg_id > LPFC_CTL_MAX) &&
3053 (ctl_reg_id != LPFC_CTL_ACC_ALL))
3059 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_CTLACC_WR ||
3060 idiag.cmd.opcode == LPFC_IDIAG_CMD_CTLACC_ST ||
3061 idiag.cmd.opcode == LPFC_IDIAG_CMD_CTLACC_CL) {
3062 switch (ctl_reg_id) {
3063 case LPFC_CTL_PORT_SEM:
3064 ctl_reg = phba->
sli4_hba.conf_regs_memmap_p +
3067 case LPFC_CTL_PORT_STA:
3068 ctl_reg = phba->
sli4_hba.conf_regs_memmap_p +
3071 case LPFC_CTL_PORT_CTL:
3072 ctl_reg = phba->
sli4_hba.conf_regs_memmap_p +
3075 case LPFC_CTL_PORT_ER1:
3076 ctl_reg = phba->
sli4_hba.conf_regs_memmap_p +
3079 case LPFC_CTL_PORT_ER2:
3080 ctl_reg = phba->
sli4_hba.conf_regs_memmap_p +
3083 case LPFC_CTL_PDEV_CTL:
3084 ctl_reg = phba->
sli4_hba.conf_regs_memmap_p +
3091 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_CTLACC_WR)
3093 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_CTLACC_ST) {
3097 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_CTLACC_CL) {
3108 memset(&idiag, 0,
sizeof(idiag));
3125 lpfc_idiag_mbxacc_get_setup(
struct lpfc_hba *phba,
char *pbuffer)
3127 uint32_t mbx_dump_map, mbx_dump_cnt, mbx_word_cnt, mbx_mbox_cmd;
3130 mbx_mbox_cmd = idiag.cmd.data[IDIAG_MBXACC_MBCMD_INDX];
3131 mbx_dump_map = idiag.cmd.data[IDIAG_MBXACC_DPMAP_INDX];
3132 mbx_dump_cnt = idiag.cmd.data[IDIAG_MBXACC_DPCNT_INDX];
3133 mbx_word_cnt = idiag.cmd.data[IDIAG_MBXACC_WDCNT_INDX];
3135 len +=
snprintf(pbuffer+len, LPFC_MBX_ACC_BUF_SIZE-len,
3136 "mbx_dump_map: 0x%08x\n", mbx_dump_map);
3137 len +=
snprintf(pbuffer+len, LPFC_MBX_ACC_BUF_SIZE-len,
3138 "mbx_dump_cnt: %04d\n", mbx_dump_cnt);
3139 len +=
snprintf(pbuffer+len, LPFC_MBX_ACC_BUF_SIZE-len,
3140 "mbx_word_cnt: %04d\n", mbx_word_cnt);
3141 len +=
snprintf(pbuffer+len, LPFC_MBX_ACC_BUF_SIZE-len,
3142 "mbx_mbox_cmd: 0x%02x\n", mbx_mbox_cmd);
3163 lpfc_idiag_mbxacc_read(
struct file *file,
char __user *buf,
size_t nbytes,
3172 debug->op = LPFC_IDIAG_OP_RD;
3178 pbuffer = debug->buffer;
3183 if ((idiag.cmd.opcode != LPFC_IDIAG_CMD_MBXACC_DP) &&
3184 (idiag.cmd.opcode != LPFC_IDIAG_BSG_MBXACC_DP))
3187 len = lpfc_idiag_mbxacc_get_setup(phba, pbuffer);
3208 lpfc_idiag_mbxacc_write(
struct file *file,
const char __user *buf,
3209 size_t nbytes, loff_t *ppos)
3212 uint32_t mbx_dump_map, mbx_dump_cnt, mbx_word_cnt, mbx_mbox_cmd;
3216 debug->op = LPFC_IDIAG_OP_WR;
3218 rc = lpfc_idiag_cmd_get(buf, nbytes, &idiag.cmd);
3223 mbx_mbox_cmd = idiag.cmd.data[IDIAG_MBXACC_MBCMD_INDX];
3224 mbx_dump_map = idiag.cmd.data[IDIAG_MBXACC_DPMAP_INDX];
3225 mbx_dump_cnt = idiag.cmd.data[IDIAG_MBXACC_DPCNT_INDX];
3226 mbx_word_cnt = idiag.cmd.data[IDIAG_MBXACC_WDCNT_INDX];
3228 if (idiag.cmd.opcode == LPFC_IDIAG_CMD_MBXACC_DP) {
3229 if (!(mbx_dump_map & LPFC_MBX_DMP_MBX_ALL))
3231 if ((mbx_dump_map & ~LPFC_MBX_DMP_MBX_ALL) &&
3232 (mbx_dump_map != LPFC_MBX_DMP_ALL))
3236 }
else if (idiag.cmd.opcode == LPFC_IDIAG_BSG_MBXACC_DP) {
3237 if (!(mbx_dump_map & LPFC_BSG_DMP_MBX_ALL))
3239 if ((mbx_dump_map & ~LPFC_BSG_DMP_MBX_ALL) &&
3240 (mbx_dump_map != LPFC_MBX_DMP_ALL))
3244 if (mbx_mbox_cmd != 0x9b)
3249 if (mbx_word_cnt == 0)
3251 if (rc != LPFC_MBX_DMP_ARG)
3253 if (mbx_mbox_cmd & ~0xff)
3257 if (mbx_dump_cnt == 0)
3264 memset(&idiag, 0,
sizeof(idiag));
3269 memset(&idiag, 0,
sizeof(idiag));
3286 lpfc_idiag_extacc_avail_get(
struct lpfc_hba *phba,
char *pbuffer,
int len)
3290 len +=
snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
3291 "\nAvailable Extents Information:\n");
3293 len +=
snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
3294 "\tPort Available VPI extents: ");
3296 &ext_cnt, &ext_size);
3297 len +=
snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
3298 "Count %3d, Size %3d\n", ext_cnt, ext_size);
3300 len +=
snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
3301 "\tPort Available VFI extents: ");
3303 &ext_cnt, &ext_size);
3304 len +=
snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
3305 "Count %3d, Size %3d\n", ext_cnt, ext_size);
3307 len +=
snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
3308 "\tPort Available RPI extents: ");
3310 &ext_cnt, &ext_size);
3311 len +=
snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
3312 "Count %3d, Size %3d\n", ext_cnt, ext_size);
3314 len +=
snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
3315 "\tPort Available XRI extents: ");
3317 &ext_cnt, &ext_size);
3318 len +=
snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
3319 "Count %3d, Size %3d\n", ext_cnt, ext_size);
3337 lpfc_idiag_extacc_alloc_get(
struct lpfc_hba *phba,
char *pbuffer,
int len)
3342 len +=
snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
3343 "\nAllocated Extents Information:\n");
3345 len +=
snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
3346 "\tHost Allocated VPI extents: ");
3348 &ext_cnt, &ext_size);
3350 len +=
snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
3351 "Port %d Extent %3d, Size %3d\n",
3352 phba->
brd_no, ext_cnt, ext_size);
3354 len +=
snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
3357 len +=
snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
3358 "\tHost Allocated VFI extents: ");
3360 &ext_cnt, &ext_size);
3362 len +=
snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
3363 "Port %d Extent %3d, Size %3d\n",
3364 phba->
brd_no, ext_cnt, ext_size);
3366 len +=
snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
3369 len +=
snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
3370 "\tHost Allocated RPI extents: ");
3372 &ext_cnt, &ext_size);
3374 len +=
snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
3375 "Port %d Extent %3d, Size %3d\n",
3376 phba->
brd_no, ext_cnt, ext_size);
3378 len +=
snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
3381 len +=
snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
3382 "\tHost Allocated XRI extents: ");
3384 &ext_cnt, &ext_size);
3386 len +=
snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
3387 "Port %d Extent %3d, Size %3d\n",
3388 phba->
brd_no, ext_cnt, ext_size);
3390 len +=
snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
3409 lpfc_idiag_extacc_drivr_get(
struct lpfc_hba *phba,
char *pbuffer,
int len)
3414 len +=
snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
3415 "\nDriver Extents Information:\n");
3417 len +=
snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
3418 "\tVPI extents:\n");
3421 len +=
snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
3422 "\t\tBlock %3d: Start %4d, Count %4d\n",
3427 len +=
snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
3428 "\tVFI extents:\n");
3432 len +=
snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
3433 "\t\tBlock %3d: Start %4d, Count %4d\n",
3439 len +=
snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
3440 "\tRPI extents:\n");
3444 len +=
snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
3445 "\t\tBlock %3d: Start %4d, Count %4d\n",
3451 len +=
snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
3452 "\tXRI extents:\n");
3456 len +=
snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
3457 "\t\tBlock %3d: Start %4d, Count %4d\n",
3482 lpfc_idiag_extacc_write(
struct file *file,
const char __user *buf,
3483 size_t nbytes, loff_t *ppos)
3490 debug->op = LPFC_IDIAG_OP_WR;
3492 rc = lpfc_idiag_cmd_get(buf, nbytes, &idiag.cmd);
3496 ext_map = idiag.cmd.data[IDIAG_EXTACC_EXMAP_INDX];
3498 if (idiag.cmd.opcode != LPFC_IDIAG_CMD_EXTACC_RD)
3500 if (rc != LPFC_EXT_ACC_CMD_ARG)
3502 if (!(ext_map & LPFC_EXT_ACC_ALL))
3508 memset(&idiag, 0,
sizeof(idiag));
3528 lpfc_idiag_extacc_read(
struct file *file,
char __user *buf,
size_t nbytes,
3538 debug->op = LPFC_IDIAG_OP_RD;
3544 pbuffer = debug->buffer;
3547 if (idiag.cmd.opcode != LPFC_IDIAG_CMD_EXTACC_RD)
3550 ext_map = idiag.cmd.data[IDIAG_EXTACC_EXMAP_INDX];
3551 if (ext_map & LPFC_EXT_ACC_AVAIL)
3552 len = lpfc_idiag_extacc_avail_get(phba, pbuffer, len);
3553 if (ext_map & LPFC_EXT_ACC_ALLOC)
3554 len = lpfc_idiag_extacc_alloc_get(phba, pbuffer, len);
3555 if (ext_map & LPFC_EXT_ACC_DRIVR)
3556 len = lpfc_idiag_extacc_drivr_get(phba, pbuffer, len);
3561 #undef lpfc_debugfs_op_disc_trc
3564 .open = lpfc_debugfs_disc_trc_open,
3565 .llseek = lpfc_debugfs_lseek,
3566 .read = lpfc_debugfs_read,
3567 .release = lpfc_debugfs_release,
3570 #undef lpfc_debugfs_op_nodelist
3573 .open = lpfc_debugfs_nodelist_open,
3574 .llseek = lpfc_debugfs_lseek,
3575 .read = lpfc_debugfs_read,
3576 .release = lpfc_debugfs_release,
3579 #undef lpfc_debugfs_op_hbqinfo
3582 .open = lpfc_debugfs_hbqinfo_open,
3583 .llseek = lpfc_debugfs_lseek,
3584 .read = lpfc_debugfs_read,
3585 .release = lpfc_debugfs_release,
3588 #undef lpfc_debugfs_op_dumpHBASlim
3591 .open = lpfc_debugfs_dumpHBASlim_open,
3592 .llseek = lpfc_debugfs_lseek,
3593 .read = lpfc_debugfs_read,
3594 .release = lpfc_debugfs_release,
3597 #undef lpfc_debugfs_op_dumpHostSlim
3600 .open = lpfc_debugfs_dumpHostSlim_open,
3601 .llseek = lpfc_debugfs_lseek,
3602 .read = lpfc_debugfs_read,
3603 .release = lpfc_debugfs_release,
3606 #undef lpfc_debugfs_op_dumpData
3609 .open = lpfc_debugfs_dumpData_open,
3610 .llseek = lpfc_debugfs_lseek,
3611 .read = lpfc_debugfs_read,
3612 .write = lpfc_debugfs_dumpDataDif_write,
3613 .release = lpfc_debugfs_dumpDataDif_release,
3616 #undef lpfc_debugfs_op_dumpDif
3619 .open = lpfc_debugfs_dumpDif_open,
3620 .llseek = lpfc_debugfs_lseek,
3621 .read = lpfc_debugfs_read,
3622 .write = lpfc_debugfs_dumpDataDif_write,
3623 .release = lpfc_debugfs_dumpDataDif_release,
3626 #undef lpfc_debugfs_op_dif_err
3630 .llseek = lpfc_debugfs_lseek,
3631 .read = lpfc_debugfs_dif_err_read,
3632 .write = lpfc_debugfs_dif_err_write,
3633 .release = lpfc_debugfs_dif_err_release,
3636 #undef lpfc_debugfs_op_slow_ring_trc
3639 .open = lpfc_debugfs_slow_ring_trc_open,
3640 .llseek = lpfc_debugfs_lseek,
3641 .read = lpfc_debugfs_read,
3642 .release = lpfc_debugfs_release,
3645 static struct dentry *lpfc_debugfs_root =
NULL;
3646 static atomic_t lpfc_debugfs_hba_count;
3651 #undef lpfc_idiag_op_pciCfg
3654 .open = lpfc_idiag_open,
3655 .llseek = lpfc_debugfs_lseek,
3656 .read = lpfc_idiag_pcicfg_read,
3657 .write = lpfc_idiag_pcicfg_write,
3658 .release = lpfc_idiag_cmd_release,
3661 #undef lpfc_idiag_op_barAcc
3664 .open = lpfc_idiag_open,
3665 .llseek = lpfc_debugfs_lseek,
3666 .read = lpfc_idiag_baracc_read,
3667 .write = lpfc_idiag_baracc_write,
3668 .release = lpfc_idiag_cmd_release,
3671 #undef lpfc_idiag_op_queInfo
3674 .open = lpfc_idiag_open,
3675 .read = lpfc_idiag_queinfo_read,
3676 .release = lpfc_idiag_release,
3679 #undef lpfc_idiag_op_queAcc
3682 .open = lpfc_idiag_open,
3683 .llseek = lpfc_debugfs_lseek,
3684 .read = lpfc_idiag_queacc_read,
3685 .write = lpfc_idiag_queacc_write,
3686 .release = lpfc_idiag_cmd_release,
3689 #undef lpfc_idiag_op_drbAcc
3692 .open = lpfc_idiag_open,
3693 .llseek = lpfc_debugfs_lseek,
3694 .read = lpfc_idiag_drbacc_read,
3695 .write = lpfc_idiag_drbacc_write,
3696 .release = lpfc_idiag_cmd_release,
3699 #undef lpfc_idiag_op_ctlAcc
3702 .open = lpfc_idiag_open,
3703 .llseek = lpfc_debugfs_lseek,
3704 .read = lpfc_idiag_ctlacc_read,
3705 .write = lpfc_idiag_ctlacc_write,
3706 .release = lpfc_idiag_cmd_release,
3709 #undef lpfc_idiag_op_mbxAcc
3712 .open = lpfc_idiag_open,
3713 .llseek = lpfc_debugfs_lseek,
3714 .read = lpfc_idiag_mbxacc_read,
3715 .write = lpfc_idiag_mbxacc_write,
3716 .release = lpfc_idiag_cmd_release,
3719 #undef lpfc_idiag_op_extAcc
3722 .open = lpfc_idiag_open,
3723 .llseek = lpfc_debugfs_lseek,
3724 .read = lpfc_idiag_extacc_read,
3725 .write = lpfc_idiag_extacc_write,
3726 .release = lpfc_idiag_cmd_release,
3745 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
3746 uint32_t *mbx_mbox_cmd, *mbx_dump_map, *mbx_dump_cnt, *mbx_word_cnt;
3747 char line_buf[LPFC_MBX_ACC_LBUF_SZ];
3753 if (idiag.cmd.opcode != LPFC_IDIAG_BSG_MBXACC_DP)
3756 mbx_mbox_cmd = &idiag.cmd.data[IDIAG_MBXACC_MBCMD_INDX];
3757 mbx_dump_map = &idiag.cmd.data[IDIAG_MBXACC_DPMAP_INDX];
3758 mbx_dump_cnt = &idiag.cmd.data[IDIAG_MBXACC_DPCNT_INDX];
3759 mbx_word_cnt = &idiag.cmd.data[IDIAG_MBXACC_WDCNT_INDX];
3761 if (!(*mbx_dump_map & LPFC_MBX_DMP_ALL) ||
3762 (*mbx_dump_cnt == 0) ||
3763 (*mbx_word_cnt == 0))
3766 if (*mbx_mbox_cmd != 0x9B)
3770 if (*mbx_dump_map & LPFC_BSG_DMP_MBX_RD_MBX) {
3771 do_dump |= LPFC_BSG_DMP_MBX_RD_MBX;
3773 "nemb:0x%x, extbuf_cnt:%d:\n",
3774 sta_tp, nemb_tp, ext_buf);
3778 if (*mbx_dump_map & LPFC_BSG_DMP_MBX_RD_BUF) {
3779 do_dump |= LPFC_BSG_DMP_MBX_RD_BUF;
3781 "nemb:0x%x, extbuf_seq:%d:\n",
3782 sta_tp, nemb_tp, ext_buf);
3786 if (*mbx_dump_map & LPFC_BSG_DMP_MBX_WR_MBX) {
3787 do_dump |= LPFC_BSG_DMP_MBX_WR_MBX;
3789 "nemb:0x%x, extbuf_cnt:%d:\n",
3790 sta_tp, nemb_tp, ext_buf);
3794 if (*mbx_dump_map & LPFC_BSG_DMP_MBX_WR_BUF) {
3795 do_dump |= LPFC_BSG_DMP_MBX_WR_BUF;
3797 "nemb:0x%x, extbuf_seq:%d:\n",
3798 sta_tp, nemb_tp, ext_buf);
3805 for (i = 0; i < *mbx_word_cnt; i++) {
3811 LPFC_MBX_ACC_LBUF_SZ-len,
3814 len +=
snprintf(line_buf+len, LPFC_MBX_ACC_LBUF_SZ-len,
3824 if (*mbx_dump_cnt == 0)
3825 memset(&idiag, 0,
sizeof(idiag));
3841 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
3842 uint32_t *mbx_dump_map, *mbx_dump_cnt, *mbx_word_cnt, *mbx_mbox_cmd;
3843 char line_buf[LPFC_MBX_ACC_LBUF_SZ];
3849 if (idiag.cmd.opcode != LPFC_IDIAG_CMD_MBXACC_DP)
3852 mbx_mbox_cmd = &idiag.cmd.data[IDIAG_MBXACC_MBCMD_INDX];
3853 mbx_dump_map = &idiag.cmd.data[IDIAG_MBXACC_DPMAP_INDX];
3854 mbx_dump_cnt = &idiag.cmd.data[IDIAG_MBXACC_DPCNT_INDX];
3855 mbx_word_cnt = &idiag.cmd.data[IDIAG_MBXACC_WDCNT_INDX];
3857 if (!(*mbx_dump_map & LPFC_MBX_DMP_MBX_ALL) ||
3858 (*mbx_dump_cnt == 0) ||
3859 (*mbx_word_cnt == 0))
3862 if ((*mbx_mbox_cmd != LPFC_MBX_ALL_CMD) &&
3867 if (*mbx_dump_map & LPFC_MBX_DMP_MBX_WORD) {
3871 for (i = 0; i < *mbx_word_cnt; i++) {
3876 memset(line_buf, 0, LPFC_MBX_ACC_LBUF_SZ);
3878 LPFC_MBX_ACC_LBUF_SZ-len,
3881 len +=
snprintf(line_buf+len, LPFC_MBX_ACC_LBUF_SZ-len,
3890 if (*mbx_dump_map & LPFC_MBX_DMP_MBX_BYTE) {
3894 for (i = 0; i < *mbx_word_cnt; i++) {
3899 memset(line_buf, 0, LPFC_MBX_ACC_LBUF_SZ);
3901 LPFC_MBX_ACC_LBUF_SZ-len,
3904 for (j = 0; j < 4; j++) {
3906 LPFC_MBX_ACC_LBUF_SZ-len,
3912 LPFC_MBX_ACC_LBUF_SZ-len,
" ");
3921 if (*mbx_dump_cnt == 0)
3922 memset(&idiag, 0,
sizeof(idiag));
3940 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
3945 if (!lpfc_debugfs_enable)
3949 if (!lpfc_debugfs_root) {
3952 if (!lpfc_debugfs_root) {
3954 "0408 Cannot create debugfs root\n");
3958 if (!lpfc_debugfs_start_time)
3959 lpfc_debugfs_start_time =
jiffies;
3963 if (!phba->hba_debugfs_root) {
3964 phba->hba_debugfs_root =
3966 if (!phba->hba_debugfs_root) {
3968 "0412 Cannot create debugfs hba\n");
3975 snprintf(name,
sizeof(name),
"hbqinfo");
3976 phba->debug_hbqinfo =
3978 phba->hba_debugfs_root,
3979 phba, &lpfc_debugfs_op_hbqinfo);
3980 if (!phba->debug_hbqinfo) {
3982 "0411 Cannot create debugfs hbqinfo\n");
3988 snprintf(name,
sizeof(name),
"dumpHBASlim");
3989 phba->debug_dumpHBASlim =
3992 phba->hba_debugfs_root,
3993 phba, &lpfc_debugfs_op_dumpHBASlim);
3994 if (!phba->debug_dumpHBASlim) {
3996 "0413 Cannot create debugfs "
4001 phba->debug_dumpHBASlim =
NULL;
4005 snprintf(name,
sizeof(name),
"dumpHostSlim");
4006 phba->debug_dumpHostSlim =
4009 phba->hba_debugfs_root,
4010 phba, &lpfc_debugfs_op_dumpHostSlim);
4011 if (!phba->debug_dumpHostSlim) {
4013 "0414 Cannot create debugfs "
4018 phba->debug_dumpHBASlim =
NULL;
4021 snprintf(name,
sizeof(name),
"dumpData");
4022 phba->debug_dumpData =
4024 phba->hba_debugfs_root,
4025 phba, &lpfc_debugfs_op_dumpData);
4026 if (!phba->debug_dumpData) {
4028 "0800 Cannot create debugfs dumpData\n");
4033 snprintf(name,
sizeof(name),
"dumpDif");
4034 phba->debug_dumpDif =
4036 phba->hba_debugfs_root,
4037 phba, &lpfc_debugfs_op_dumpDif);
4038 if (!phba->debug_dumpDif) {
4040 "0801 Cannot create debugfs dumpDif\n");
4045 snprintf(name,
sizeof(name),
"InjErrLBA");
4046 phba->debug_InjErrLBA =
4048 phba->hba_debugfs_root,
4049 phba, &lpfc_debugfs_op_dif_err);
4050 if (!phba->debug_InjErrLBA) {
4052 "0807 Cannot create debugfs InjErrLBA\n");
4055 phba->lpfc_injerr_lba = LPFC_INJERR_LBA_OFF;
4057 snprintf(name,
sizeof(name),
"InjErrNPortID");
4058 phba->debug_InjErrNPortID =
4060 phba->hba_debugfs_root,
4061 phba, &lpfc_debugfs_op_dif_err);
4062 if (!phba->debug_InjErrNPortID) {
4064 "0809 Cannot create debugfs InjErrNPortID\n");
4068 snprintf(name,
sizeof(name),
"InjErrWWPN");
4069 phba->debug_InjErrWWPN =
4071 phba->hba_debugfs_root,
4072 phba, &lpfc_debugfs_op_dif_err);
4073 if (!phba->debug_InjErrWWPN) {
4075 "0810 Cannot create debugfs InjErrWWPN\n");
4079 snprintf(name,
sizeof(name),
"writeGuardInjErr");
4080 phba->debug_writeGuard =
4082 phba->hba_debugfs_root,
4083 phba, &lpfc_debugfs_op_dif_err);
4084 if (!phba->debug_writeGuard) {
4086 "0802 Cannot create debugfs writeGuard\n");
4090 snprintf(name,
sizeof(name),
"writeAppInjErr");
4091 phba->debug_writeApp =
4093 phba->hba_debugfs_root,
4094 phba, &lpfc_debugfs_op_dif_err);
4095 if (!phba->debug_writeApp) {
4097 "0803 Cannot create debugfs writeApp\n");
4101 snprintf(name,
sizeof(name),
"writeRefInjErr");
4102 phba->debug_writeRef =
4104 phba->hba_debugfs_root,
4105 phba, &lpfc_debugfs_op_dif_err);
4106 if (!phba->debug_writeRef) {
4108 "0804 Cannot create debugfs writeRef\n");
4112 snprintf(name,
sizeof(name),
"readGuardInjErr");
4113 phba->debug_readGuard =
4115 phba->hba_debugfs_root,
4116 phba, &lpfc_debugfs_op_dif_err);
4117 if (!phba->debug_readGuard) {
4119 "0808 Cannot create debugfs readGuard\n");
4123 snprintf(name,
sizeof(name),
"readAppInjErr");
4124 phba->debug_readApp =
4126 phba->hba_debugfs_root,
4127 phba, &lpfc_debugfs_op_dif_err);
4128 if (!phba->debug_readApp) {
4130 "0805 Cannot create debugfs readApp\n");
4134 snprintf(name,
sizeof(name),
"readRefInjErr");
4135 phba->debug_readRef =
4137 phba->hba_debugfs_root,
4138 phba, &lpfc_debugfs_op_dif_err);
4139 if (!phba->debug_readRef) {
4141 "0806 Cannot create debugfs readApp\n");
4146 if (lpfc_debugfs_max_slow_ring_trc) {
4147 num = lpfc_debugfs_max_slow_ring_trc - 1;
4148 if (num & lpfc_debugfs_max_slow_ring_trc) {
4150 num = lpfc_debugfs_max_slow_ring_trc;
4156 lpfc_debugfs_max_slow_ring_trc = (1 <<
i);
4158 "lpfc_debugfs_max_disc_trc changed to "
4159 "%d\n", lpfc_debugfs_max_disc_trc);
4163 snprintf(name,
sizeof(name),
"slow_ring_trace");
4164 phba->debug_slow_ring_trc =
4166 phba->hba_debugfs_root,
4167 phba, &lpfc_debugfs_op_slow_ring_trc);
4168 if (!phba->debug_slow_ring_trc) {
4170 "0415 Cannot create debugfs "
4171 "slow_ring_trace\n");
4174 if (!phba->slow_ring_trc) {
4175 phba->slow_ring_trc =
kmalloc(
4176 (
sizeof(
struct lpfc_debugfs_trc) *
4177 lpfc_debugfs_max_slow_ring_trc),
4179 if (!phba->slow_ring_trc) {
4181 "0416 Cannot create debugfs "
4182 "slow_ring buffer\n");
4186 memset(phba->slow_ring_trc, 0,
4187 (
sizeof(
struct lpfc_debugfs_trc) *
4188 lpfc_debugfs_max_slow_ring_trc));
4192 snprintf(name,
sizeof(name),
"vport%d", vport->
vpi);
4193 if (!vport->vport_debugfs_root) {
4194 vport->vport_debugfs_root =
4196 if (!vport->vport_debugfs_root) {
4198 "0417 Can't create debugfs\n");
4204 if (lpfc_debugfs_max_disc_trc) {
4205 num = lpfc_debugfs_max_disc_trc - 1;
4206 if (num & lpfc_debugfs_max_disc_trc) {
4208 num = lpfc_debugfs_max_disc_trc;
4214 lpfc_debugfs_max_disc_trc = (1 <<
i);
4216 "lpfc_debugfs_max_disc_trc changed to %d\n",
4217 lpfc_debugfs_max_disc_trc);
4221 vport->disc_trc = kzalloc(
4222 (
sizeof(
struct lpfc_debugfs_trc) * lpfc_debugfs_max_disc_trc),
4225 if (!vport->disc_trc) {
4227 "0418 Cannot create debugfs disc trace "
4233 snprintf(name,
sizeof(name),
"discovery_trace");
4234 vport->debug_disc_trc =
4236 vport->vport_debugfs_root,
4237 vport, &lpfc_debugfs_op_disc_trc);
4238 if (!vport->debug_disc_trc) {
4240 "0419 Cannot create debugfs "
4241 "discovery_trace\n");
4244 snprintf(name,
sizeof(name),
"nodelist");
4245 vport->debug_nodelist =
4247 vport->vport_debugfs_root,
4248 vport, &lpfc_debugfs_op_nodelist);
4249 if (!vport->debug_nodelist) {
4251 "2985 Can't create debugfs nodelist\n");
4261 snprintf(name,
sizeof(name),
"iDiag");
4262 if (!phba->idiag_root) {
4265 if (!phba->idiag_root) {
4267 "2922 Can't create idiag debugfs\n");
4271 memset(&idiag, 0,
sizeof(idiag));
4275 snprintf(name,
sizeof(name),
"pciCfg");
4276 if (!phba->idiag_pci_cfg) {
4277 phba->idiag_pci_cfg =
4279 phba->idiag_root, phba, &lpfc_idiag_op_pciCfg);
4280 if (!phba->idiag_pci_cfg) {
4282 "2923 Can't create idiag debugfs\n");
4285 idiag.offset.last_rd = 0;
4289 snprintf(name,
sizeof(name),
"barAcc");
4290 if (!phba->idiag_bar_acc) {
4291 phba->idiag_bar_acc =
4293 phba->idiag_root, phba, &lpfc_idiag_op_barAcc);
4294 if (!phba->idiag_bar_acc) {
4296 "3056 Can't create idiag debugfs\n");
4299 idiag.offset.last_rd = 0;
4303 snprintf(name,
sizeof(name),
"queInfo");
4304 if (!phba->idiag_que_info) {
4305 phba->idiag_que_info =
4307 phba->idiag_root, phba, &lpfc_idiag_op_queInfo);
4308 if (!phba->idiag_que_info) {
4310 "2924 Can't create idiag debugfs\n");
4316 snprintf(name,
sizeof(name),
"queAcc");
4317 if (!phba->idiag_que_acc) {
4318 phba->idiag_que_acc =
4320 phba->idiag_root, phba, &lpfc_idiag_op_queAcc);
4321 if (!phba->idiag_que_acc) {
4323 "2926 Can't create idiag debugfs\n");
4329 snprintf(name,
sizeof(name),
"drbAcc");
4330 if (!phba->idiag_drb_acc) {
4331 phba->idiag_drb_acc =
4333 phba->idiag_root, phba, &lpfc_idiag_op_drbAcc);
4334 if (!phba->idiag_drb_acc) {
4336 "2927 Can't create idiag debugfs\n");
4342 snprintf(name,
sizeof(name),
"ctlAcc");
4343 if (!phba->idiag_ctl_acc) {
4344 phba->idiag_ctl_acc =
4346 phba->idiag_root, phba, &lpfc_idiag_op_ctlAcc);
4347 if (!phba->idiag_ctl_acc) {
4349 "2981 Can't create idiag debugfs\n");
4355 snprintf(name,
sizeof(name),
"mbxAcc");
4356 if (!phba->idiag_mbx_acc) {
4357 phba->idiag_mbx_acc =
4359 phba->idiag_root, phba, &lpfc_idiag_op_mbxAcc);
4360 if (!phba->idiag_mbx_acc) {
4362 "2980 Can't create idiag debugfs\n");
4368 if (phba->
sli4_hba.extents_in_use) {
4369 snprintf(name,
sizeof(name),
"extAcc");
4370 if (!phba->idiag_ext_acc) {
4371 phba->idiag_ext_acc =
4374 phba->idiag_root, phba,
4375 &lpfc_idiag_op_extAcc);
4376 if (!phba->idiag_ext_acc) {
4404 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
4407 if (vport->disc_trc) {
4408 kfree(vport->disc_trc);
4409 vport->disc_trc =
NULL;
4411 if (vport->debug_disc_trc) {
4413 vport->debug_disc_trc =
NULL;
4415 if (vport->debug_nodelist) {
4417 vport->debug_nodelist =
NULL;
4419 if (vport->vport_debugfs_root) {
4421 vport->vport_debugfs_root =
NULL;
4424 if (
atomic_read(&phba->debugfs_vport_count) == 0) {
4426 if (phba->debug_hbqinfo) {
4428 phba->debug_hbqinfo =
NULL;
4430 if (phba->debug_dumpHBASlim) {
4432 phba->debug_dumpHBASlim =
NULL;
4434 if (phba->debug_dumpHostSlim) {
4436 phba->debug_dumpHostSlim =
NULL;
4438 if (phba->debug_dumpData) {
4440 phba->debug_dumpData =
NULL;
4443 if (phba->debug_dumpDif) {
4445 phba->debug_dumpDif =
NULL;
4447 if (phba->debug_InjErrLBA) {
4449 phba->debug_InjErrLBA =
NULL;
4451 if (phba->debug_InjErrNPortID) {
4453 phba->debug_InjErrNPortID =
NULL;
4455 if (phba->debug_InjErrWWPN) {
4457 phba->debug_InjErrWWPN =
NULL;
4459 if (phba->debug_writeGuard) {
4461 phba->debug_writeGuard =
NULL;
4463 if (phba->debug_writeApp) {
4465 phba->debug_writeApp =
NULL;
4467 if (phba->debug_writeRef) {
4469 phba->debug_writeRef =
NULL;
4471 if (phba->debug_readGuard) {
4473 phba->debug_readGuard =
NULL;
4475 if (phba->debug_readApp) {
4477 phba->debug_readApp =
NULL;
4479 if (phba->debug_readRef) {
4481 phba->debug_readRef =
NULL;
4484 if (phba->slow_ring_trc) {
4485 kfree(phba->slow_ring_trc);
4486 phba->slow_ring_trc =
NULL;
4488 if (phba->debug_slow_ring_trc) {
4491 phba->debug_slow_ring_trc =
NULL;
4498 if (phba->idiag_ext_acc) {
4501 phba->idiag_ext_acc =
NULL;
4503 if (phba->idiag_mbx_acc) {
4506 phba->idiag_mbx_acc =
NULL;
4508 if (phba->idiag_ctl_acc) {
4511 phba->idiag_ctl_acc =
NULL;
4513 if (phba->idiag_drb_acc) {
4516 phba->idiag_drb_acc =
NULL;
4518 if (phba->idiag_que_acc) {
4521 phba->idiag_que_acc =
NULL;
4523 if (phba->idiag_que_info) {
4526 phba->idiag_que_info =
NULL;
4528 if (phba->idiag_bar_acc) {
4531 phba->idiag_bar_acc =
NULL;
4533 if (phba->idiag_pci_cfg) {
4536 phba->idiag_pci_cfg =
NULL;
4540 if (phba->idiag_root) {
4543 phba->idiag_root =
NULL;
4547 if (phba->hba_debugfs_root) {
4549 phba->hba_debugfs_root =
NULL;
4555 lpfc_debugfs_root =
NULL;
4582 lpfc_debug_dump_mbx_wq(phba);
4583 lpfc_debug_dump_els_wq(phba);
4586 lpfc_debug_dump_fcp_wq(phba, fcp_wqidx);
4588 lpfc_debug_dump_hdr_rq(phba);
4589 lpfc_debug_dump_dat_rq(phba);
4593 lpfc_debug_dump_mbx_cq(phba);
4594 lpfc_debug_dump_els_cq(phba);
4597 lpfc_debug_dump_fcp_cq(phba, fcp_wqidx);
4603 lpfc_debug_dump_hba_eq(phba, fcp_wqidx);