/******************************************************************* * This file is part of the Emulex Linux Device Driver for * * Fibre Channel Host Bus Adapters. * * Copyright (C) 2017-2025 Broadcom. All Rights Reserved. The term * * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. * * Copyright (C) 2007-2015 Emulex. All rights reserved. * * EMULEX and SLI are trademarks of Emulex. * * www.broadcom.com * * * * This program is free software; you can redistribute it and/or * * modify it under the terms of version 2 of the GNU General * * Public License as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful. * * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND * * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, * * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE * * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD * * TO BE LEGALLY INVALID. See the GNU General Public License for * * more details, a copy of which can be found in the file COPYING * * included with this package. *
*******************************************************************/
#ifdef CONFIG_SCSI_LPFC_DEBUG_FS /* * debugfs interface * * To access this interface the user should: * # mount -t debugfs none /sys/kernel/debug * * The lpfc debugfs directory hierarchy is: * /sys/kernel/debug/lpfc/fnX/vportY * where X is the lpfc hba function unique_id * where Y is the vport VPI on that hba * * Debugging services available per vport: * discovery_trace * This is an ACSII readable file that contains a trace of the last * lpfc_debugfs_max_disc_trc events that happened on a specific vport. * See lpfc_debugfs.h for different categories of discovery events. * To enable the discovery trace, the following module parameters must be set: * lpfc_debugfs_enable=1 Turns on lpfc debugfs filesystem support * lpfc_debugfs_max_disc_trc=X Where X is the event trace depth for * EACH vport. X MUST also be a power of 2. * lpfc_debugfs_mask_disc_trc=Y Where Y is an event mask as defined in * lpfc_debugfs.h . * * slow_ring_trace * This is an ACSII readable file that contains a trace of the last * lpfc_debugfs_max_slow_ring_trc events that happened on a specific HBA. * To enable the slow ring trace, the following module parameters must be set: * lpfc_debugfs_enable=1 Turns on lpfc debugfs filesystem support * lpfc_debugfs_max_slow_ring_trc=X Where X is the event trace depth for * the HBA. X MUST also be a power of 2.
*/ staticint lpfc_debugfs_enable = 1;
module_param(lpfc_debugfs_enable, int, S_IRUGO);
MODULE_PARM_DESC(lpfc_debugfs_enable, "Enable debugfs services");
/* This MUST be a power of 2 */ staticint lpfc_debugfs_max_disc_trc;
module_param(lpfc_debugfs_max_disc_trc, int, S_IRUGO);
MODULE_PARM_DESC(lpfc_debugfs_max_disc_trc, "Set debugfs discovery trace depth");
/* This MUST be a power of 2 */ staticint lpfc_debugfs_max_slow_ring_trc;
module_param(lpfc_debugfs_max_slow_ring_trc, int, S_IRUGO);
MODULE_PARM_DESC(lpfc_debugfs_max_slow_ring_trc, "Set debugfs slow ring trace depth");
/* This MUST be a power of 2 */ staticint lpfc_debugfs_max_nvmeio_trc;
module_param(lpfc_debugfs_max_nvmeio_trc, int, 0444);
MODULE_PARM_DESC(lpfc_debugfs_max_nvmeio_trc, "Set debugfs NVME IO trace depth");
/** * lpfc_debugfs_disc_trc_data - Dump discovery logging to a buffer * @vport: The vport to gather the log info from. * @buf: The buffer to dump log into. * @size: The maximum amount of data to process. * * Description: * This routine gathers the lpfc discovery debugfs data from the @vport and * dumps it to @buf up to @size number of bytes. It will start at the next entry * in the log and process the log until the end of the buffer. Then it will * gather from the beginning of the log and process until the current entry. * * Notes: * Discovery logging will be disabled while while this routine dumps the log. * * Return Value: * This routine returns the amount of bytes that were dumped into @buf and will * not exceed @size.
**/ staticint
lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size)
{ int i, index, len, enable;
uint32_t ms; struct lpfc_debugfs_trc *dtp; char *buffer;
buffer = kmalloc(LPFC_DEBUG_TRC_ENTRY_SIZE, GFP_KERNEL); if (!buffer) return 0;
len = 0;
index = (atomic_read(&vport->disc_trc_cnt) + 1) &
(lpfc_debugfs_max_disc_trc - 1); for (i = index; i < lpfc_debugfs_max_disc_trc; i++) {
dtp = vport->disc_trc + i; if (!dtp->fmt) continue;
ms = jiffies_to_msecs(dtp->jif - lpfc_debugfs_start_time);
snprintf(buffer,
LPFC_DEBUG_TRC_ENTRY_SIZE, "%010d:%010d ms:%s\n",
dtp->seq_cnt, ms, dtp->fmt);
len += scnprintf(buf+len, size-len, buffer,
dtp->data1, dtp->data2, dtp->data3);
} for (i = 0; i < index; i++) {
dtp = vport->disc_trc + i; if (!dtp->fmt) continue;
ms = jiffies_to_msecs(dtp->jif - lpfc_debugfs_start_time);
snprintf(buffer,
LPFC_DEBUG_TRC_ENTRY_SIZE, "%010d:%010d ms:%s\n",
dtp->seq_cnt, ms, dtp->fmt);
len += scnprintf(buf+len, size-len, buffer,
dtp->data1, dtp->data2, dtp->data3);
}
lpfc_debugfs_enable = enable;
kfree(buffer);
return len;
}
/** * lpfc_debugfs_slow_ring_trc_data - Dump slow ring logging to a buffer * @phba: The HBA to gather the log info from. * @buf: The buffer to dump log into. * @size: The maximum amount of data to process. * * Description: * This routine gathers the lpfc slow ring debugfs data from the @phba and * dumps it to @buf up to @size number of bytes. It will start at the next entry * in the log and process the log until the end of the buffer. Then it will * gather from the beginning of the log and process until the current entry. * * Notes: * Slow ring logging will be disabled while while this routine dumps the log. * * Return Value: * This routine returns the amount of bytes that were dumped into @buf and will * not exceed @size.
**/ staticint
lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba *phba, char *buf, int size)
{ int i, index, len, enable;
uint32_t ms; struct lpfc_debugfs_trc *dtp; char *buffer;
buffer = kmalloc(LPFC_DEBUG_TRC_ENTRY_SIZE, GFP_KERNEL); if (!buffer) return 0;
len = 0;
index = (atomic_read(&phba->slow_ring_trc_cnt) + 1) &
(lpfc_debugfs_max_slow_ring_trc - 1); for (i = index; i < lpfc_debugfs_max_slow_ring_trc; i++) {
dtp = phba->slow_ring_trc + i; if (!dtp->fmt) continue;
ms = jiffies_to_msecs(dtp->jif - lpfc_debugfs_start_time);
snprintf(buffer,
LPFC_DEBUG_TRC_ENTRY_SIZE, "%010d:%010d ms:%s\n",
dtp->seq_cnt, ms, dtp->fmt);
len += scnprintf(buf+len, size-len, buffer,
dtp->data1, dtp->data2, dtp->data3);
} for (i = 0; i < index; i++) {
dtp = phba->slow_ring_trc + i; if (!dtp->fmt) continue;
ms = jiffies_to_msecs(dtp->jif - lpfc_debugfs_start_time);
snprintf(buffer,
LPFC_DEBUG_TRC_ENTRY_SIZE, "%010d:%010d ms:%s\n",
dtp->seq_cnt, ms, dtp->fmt);
len += scnprintf(buf+len, size-len, buffer,
dtp->data1, dtp->data2, dtp->data3);
}
lpfc_debugfs_enable = enable;
kfree(buffer);
return len;
}
staticint lpfc_debugfs_last_hbq = -1;
/** * lpfc_debugfs_hbqinfo_data - Dump host buffer queue info to a buffer * @phba: The HBA to gather host buffer info from. * @buf: The buffer to dump log into. * @size: The maximum amount of data to process. * * Description: * This routine dumps the host buffer queue info from the @phba to @buf up to * @size number of bytes. A header that describes the current hbq state will be * dumped to @buf first and then info on each hbq entry will be dumped to @buf * until @size bytes have been dumped or all the hbq info has been dumped. * * Notes: * This routine will rotate through each configured HBQ each time called. * * Return Value: * This routine returns the amount of bytes that were dumped into @buf and will * not exceed @size.
**/ staticint
lpfc_debugfs_hbqinfo_data(struct lpfc_hba *phba, char *buf, int size)
{ int len = 0; int i, j, found, posted, low;
uint32_t phys, raw_index, getidx; struct lpfc_hbq_init *hip; struct hbq_s *hbqs; struct lpfc_hbq_entry *hbqe; struct lpfc_dmabuf *d_buf; struct hbq_dmabuf *hbq_buf;
if (phba->sli_rev != 3) return 0;
spin_lock_irq(&phba->hbalock);
/* toggle between multiple hbqs, if any */
i = lpfc_sli_hbq_count(); if (i > 1) {
lpfc_debugfs_last_hbq++; if (lpfc_debugfs_last_hbq >= i)
lpfc_debugfs_last_hbq = 0;
} else
lpfc_debugfs_last_hbq = 0;
i = lpfc_debugfs_last_hbq;
len += scnprintf(buf+len, size-len, "HBQ %d Info\n", i);
hbqe = (struct lpfc_hbq_entry *) phba->hbqs[i].hbq_virt; for (j=0; j<hbqs->entry_count; j++) {
len += scnprintf(buf+len, size-len, "%03d: %08x %04x %05x ", j,
le32_to_cpu(hbqe->bde.addrLow),
le32_to_cpu(hbqe->bde.tus.w),
le32_to_cpu(hbqe->buffer_tag));
i = 0;
found = 0;
/* First calculate if slot has an associated posted buffer */
low = hbqs->hbqPutIdx - posted; if (low >= 0) { if ((j >= hbqs->hbqPutIdx) || (j < low)) {
len += scnprintf(buf + len, size - len, "Unused\n"); goto skipit;
}
} else { if ((j >= hbqs->hbqPutIdx) &&
(j < (hbqs->entry_count+low))) {
len += scnprintf(buf + len, size - len, "Unused\n"); goto skipit;
}
}
/* Get the Buffer info for the posted buffer */
list_for_each_entry(d_buf, &hbqs->hbq_buffer_list, list) {
hbq_buf = container_of(d_buf, struct hbq_dmabuf, dbuf);
phys = ((uint64_t)hbq_buf->dbuf.phys & 0xffffffff); if (phys == le32_to_cpu(hbqe->bde.addrLow)) {
len += scnprintf(buf+len, size-len, "Buf%d: x%px %06x\n", i,
hbq_buf->dbuf.virt, hbq_buf->tag);
found = 1; break;
}
i++;
} if (!found) {
len += scnprintf(buf+len, size-len, "No DMAinfo?\n");
}
skipit:
hbqe++; if (len > LPFC_HBQINFO_SIZE - 54) break;
}
spin_unlock_irq(&phba->hbalock); return len;
}
staticint lpfc_debugfs_last_xripool;
/** * lpfc_debugfs_commonxripools_data - Dump Hardware Queue info to a buffer * @phba: The HBA to gather host buffer info from. * @buf: The buffer to dump log into. * @size: The maximum amount of data to process. * * Description: * This routine dumps the Hardware Queue info from the @phba to @buf up to * @size number of bytes. A header that describes the current hdwq state will be * dumped to @buf first and then info on each hdwq entry will be dumped to @buf * until @size bytes have been dumped or all the hdwq info has been dumped. * * Notes: * This routine will rotate through each configured Hardware Queue each * time called. * * Return Value: * This routine returns the amount of bytes that were dumped into @buf and will * not exceed @size.
**/ staticint
lpfc_debugfs_commonxripools_data(struct lpfc_hba *phba, char *buf, int size)
{ struct lpfc_sli4_hdw_queue *qp; int len = 0; int i, out; unsignedlong iflag;
for (i = 0; i < phba->cfg_hdw_queue; i++) { if (len > (LPFC_DUMP_MULTIXRIPOOL_SIZE - 80)) break;
qp = &phba->sli4_hba.hdwq[lpfc_debugfs_last_xripool];
lpfc_debugfs_last_xripool++; if (lpfc_debugfs_last_xripool >= phba->cfg_hdw_queue)
lpfc_debugfs_last_xripool = 0;
}
return len;
}
/** * lpfc_debugfs_multixripools_data - Display multi-XRI pools information * @phba: The HBA to gather host buffer info from. * @buf: The buffer to dump log into. * @size: The maximum amount of data to process. * * Description: * This routine displays current multi-XRI pools information including XRI * count in public, private and txcmplq. It also displays current high and * low watermark. * * Return Value: * This routine returns the amount of bytes that were dumped into @buf and will * not exceed @size.
**/ staticint
lpfc_debugfs_multixripools_data(struct lpfc_hba *phba, char *buf, int size)
{
u32 i;
u32 hwq_count; struct lpfc_sli4_hdw_queue *qp; struct lpfc_multixri_pool *multixri_pool; struct lpfc_pvt_pool *pvt_pool; struct lpfc_pbl_pool *pbl_pool;
u32 txcmplq_cnt; char tmp[LPFC_DEBUG_OUT_LINE_SZ] = {0};
if (phba->sli_rev != LPFC_SLI_REV4) return 0;
if (!phba->sli4_hba.hdwq) return 0;
if (!phba->cfg_xri_rebalancing) {
i = lpfc_debugfs_commonxripools_data(phba, buf, size); return i;
}
/* * Pbl: Current number of free XRIs in public pool * Pvt: Current number of free XRIs in private pool * Busy: Current number of outstanding XRIs * HWM: Current high watermark * pvt_empty: Incremented by 1 when IO submission fails (no xri) * pbl_empty: Incremented by 1 when all pbl_pool are empty during * IO submission
*/
scnprintf(tmp, sizeof(tmp), "HWQ: Pbl Pvt Busy HWM | pvt_empty pbl_empty "); if (strlcat(buf, tmp, size) >= size) return strnlen(buf, size);
#ifdef LPFC_MXP_STAT /* * MAXH: Max high watermark seen so far * above_lmt: Incremented by 1 if xri_owned > xri_limit during * IO submission * below_lmt: Incremented by 1 if xri_owned <= xri_limit during * IO submission * locPbl_hit: Incremented by 1 if successfully get a batch of XRI from * local pbl_pool * othPbl_hit: Incremented by 1 if successfully get a batch of XRI from * other pbl_pool
*/
scnprintf(tmp, sizeof(tmp), "MAXH above_lmt below_lmt locPbl_hit othPbl_hit"); if (strlcat(buf, tmp, size) >= size) return strnlen(buf, size);
/* * sPbl: snapshot of Pbl 15 sec after stat gets cleared * sPvt: snapshot of Pvt 15 sec after stat gets cleared * sBusy: snapshot of Busy 15 sec after stat gets cleared
*/
scnprintf(tmp, sizeof(tmp), " | sPbl sPvt sBusy"); if (strlcat(buf, tmp, size) >= size) return strnlen(buf, size); #endif
/** * lpfc_debugfs_lockstat_data - Dump Hardware Queue info to a buffer * @phba: The HBA to gather host buffer info from. * @buf: The buffer to dump log into. * @size: The maximum amount of data to process. * * Description: * This routine dumps the Hardware Queue info from the @phba to @buf up to * @size number of bytes. A header that describes the current hdwq state will be * dumped to @buf first and then info on each hdwq entry will be dumped to @buf * until @size bytes have been dumped or all the hdwq info has been dumped. * * Notes: * This routine will rotate through each configured Hardware Queue each * time called. * * Return Value: * This routine returns the amount of bytes that were dumped into @buf and will * not exceed @size.
**/ staticint
lpfc_debugfs_lockstat_data(struct lpfc_hba *phba, char *buf, int size)
{ struct lpfc_sli4_hdw_queue *qp; int len = 0; int i;
if (phba->sli_rev != LPFC_SLI_REV4) return 0;
if (!phba->sli4_hba.hdwq) return 0;
for (i = 0; i < phba->cfg_hdw_queue; i++) { if (len > (LPFC_HDWQINFO_SIZE - 100)) break;
qp = &phba->sli4_hba.hdwq[lpfc_debugfs_last_lock];
lpfc_debugfs_last_lock++; if (lpfc_debugfs_last_lock >= phba->cfg_hdw_queue)
lpfc_debugfs_last_lock = 0;
}
return len;
} #endif
staticint lpfc_debugfs_last_hba_slim_off;
/** * lpfc_debugfs_dumpHBASlim_data - Dump HBA SLIM info to a buffer * @phba: The HBA to gather SLIM info from. * @buf: The buffer to dump log into. * @size: The maximum amount of data to process. * * Description: * This routine dumps the current contents of HBA SLIM for the HBA associated * with @phba to @buf up to @size bytes of data. This is the raw HBA SLIM data. * * Notes: * This routine will only dump up to 1024 bytes of data each time called and * should be called multiple times to dump the entire HBA SLIM. * * Return Value: * This routine returns the amount of bytes that were dumped into @buf and will * not exceed @size.
**/ staticint
lpfc_debugfs_dumpHBASlim_data(struct lpfc_hba *phba, char *buf, int size)
{ int len = 0; int i, off;
uint32_t *ptr; char *buffer;
buffer = kmalloc(1024, GFP_KERNEL); if (!buffer) return 0;
ptr = (uint32_t *)&buffer[0];
off = lpfc_debugfs_last_hba_slim_off;
/* Set it up for the next time */
lpfc_debugfs_last_hba_slim_off += 1024; if (lpfc_debugfs_last_hba_slim_off >= 4096)
lpfc_debugfs_last_hba_slim_off = 0;
i = 1024; while (i > 0) {
len += scnprintf(buf+len, size-len, "%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n",
off, *ptr, *(ptr+1), *(ptr+2), *(ptr+3), *(ptr+4),
*(ptr+5), *(ptr+6), *(ptr+7));
ptr += 8;
i -= (8 * sizeof(uint32_t));
off += (8 * sizeof(uint32_t));
}
spin_unlock_irq(&phba->hbalock);
kfree(buffer);
return len;
}
/** * lpfc_debugfs_dumpHostSlim_data - Dump host SLIM info to a buffer * @phba: The HBA to gather Host SLIM info from. * @buf: The buffer to dump log into. * @size: The maximum amount of data to process. * * Description: * This routine dumps the current contents of host SLIM for the host associated * with @phba to @buf up to @size bytes of data. The dump will contain the * Mailbox, PCB, Rings, and Registers that are located in host memory. * * Return Value: * This routine returns the amount of bytes that were dumped into @buf and will * not exceed @size.
**/ staticint
lpfc_debugfs_dumpHostSlim_data(struct lpfc_hba *phba, char *buf, int size)
{ int len = 0; int i, off;
uint32_t word0, word1, word2, word3;
uint32_t *ptr; struct lpfc_pgp *pgpp; struct lpfc_sli *psli = &phba->sli; struct lpfc_sli_ring *pring;
off = 0;
spin_lock_irq(&phba->hbalock);
len += scnprintf(buf+len, size-len, "SLIM Mailbox\n");
ptr = (uint32_t *)phba->slim2p.virt;
i = sizeof(MAILBOX_t); while (i > 0) {
len += scnprintf(buf+len, size-len, "%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n",
off, *ptr, *(ptr+1), *(ptr+2), *(ptr+3), *(ptr+4),
*(ptr+5), *(ptr+6), *(ptr+7));
ptr += 8;
i -= (8 * sizeof(uint32_t));
off += (8 * sizeof(uint32_t));
}
len += scnprintf(buf+len, size-len, "SLIM PCB\n");
ptr = (uint32_t *)phba->pcb;
i = sizeof(PCB_t); while (i > 0) {
len += scnprintf(buf+len, size-len, "%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n",
off, *ptr, *(ptr+1), *(ptr+2), *(ptr+3), *(ptr+4),
*(ptr+5), *(ptr+6), *(ptr+7));
ptr += 8;
i -= (8 * sizeof(uint32_t));
off += (8 * sizeof(uint32_t));
}
if (phba->sli_rev <= LPFC_SLI_REV3) { for (i = 0; i < 4; i++) {
pgpp = &phba->port_gp[i];
pring = &psli->sli3_ring[i];
len += scnprintf(buf+len, size-len, "Ring %d: CMD GetInx:%d " "(Max:%d Next:%d " "Local:%d flg:x%x) " "RSP PutInx:%d Max:%d\n",
i, pgpp->cmdGetInx,
pring->sli.sli3.numCiocb,
pring->sli.sli3.next_cmdidx,
pring->sli.sli3.local_getidx,
pring->flag, pgpp->rspPutInx,
pring->sli.sli3.numRiocb);
}
/** * lpfc_debugfs_nodelist_data - Dump target node list to a buffer * @vport: The vport to gather target node info from. * @buf: The buffer to dump log into. * @size: The maximum amount of data to process. * * Description: * This routine dumps the current target node list associated with @vport to * @buf up to @size bytes of data. Each node entry in the dump will contain a * node state, DID, WWPN, WWNN, RPI, flags, type, and other useful fields. * * Return Value: * This routine returns the amount of bytes that were dumped into @buf and will * not exceed @size.
**/ staticint
lpfc_debugfs_nodelist_data(struct lpfc_vport *vport, char *buf, int size)
{ int len = 0; int i, iocnt, outio, cnt; struct lpfc_hba *phba = vport->phba; struct lpfc_nodelist *ndlp; unsignedchar *statep; unsignedlong iflags; struct nvme_fc_local_port *localport; struct nvme_fc_remote_port *nrport = NULL; struct lpfc_nvme_rport *rport;
/* Port state is only one of two values for now. */ if (phba->targetport->port_id)
statep = "REGISTERED"; else
statep = "INIT";
len += scnprintf(buf + len, size - len, "TGT WWNN x%llx WWPN x%llx State %s\n",
wwn_to_u64(vport->fc_nodename.u.wwn),
wwn_to_u64(vport->fc_portname.u.wwn),
statep);
len += scnprintf(buf + len, size - len, " Targetport DID x%06x\n",
phba->targetport->port_id); goto out_exit;
}
localport = vport->localport; if (!localport) goto out_exit;
/* Port state is only one of two values for now. */ if (localport->port_id)
statep = "ONLINE"; else
statep = "UNKNOWN ";
len += scnprintf(buf + len, size - len, "Lport DID x%06x PortState %s\n",
localport->port_id, statep);
len += scnprintf(buf + len, size - len, "\tRport List:\n");
spin_lock_irqsave(&vport->fc_nodes_list_lock, iflags);
list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { /* local short-hand pointer. */
spin_lock(&ndlp->lock);
rport = lpfc_ndlp_get_nrport(ndlp); if (rport)
nrport = rport->remoteport; else
nrport = NULL;
spin_unlock(&ndlp->lock); if (!nrport) continue;
/* Port state is only one of two values for now. */ switch (nrport->port_state) { case FC_OBJSTATE_ONLINE:
statep = "ONLINE"; break; case FC_OBJSTATE_UNKNOWN:
statep = "UNKNOWN "; break; default:
statep = "UNSUPPORTED"; break;
}
/* Tab in to show lport ownership. */
len += scnprintf(buf + len, size - len, "\t%s Port ID:x%06x ",
statep, nrport->port_id);
len += scnprintf(buf + len, size - len, "WWPN x%llx ",
nrport->port_name);
len += scnprintf(buf + len, size - len, "WWNN x%llx ",
nrport->node_name);
/* An NVME rport can have multiple roles. */ if (nrport->port_role & FC_PORT_ROLE_NVME_INITIATOR)
len += scnprintf(buf + len, size - len, "INITIATOR "); if (nrport->port_role & FC_PORT_ROLE_NVME_TARGET)
len += scnprintf(buf + len, size - len, "TARGET "); if (nrport->port_role & FC_PORT_ROLE_NVME_DISCOVERY)
len += scnprintf(buf + len, size - len, "DISCSRVC "); if (nrport->port_role & ~(FC_PORT_ROLE_NVME_INITIATOR |
FC_PORT_ROLE_NVME_TARGET |
FC_PORT_ROLE_NVME_DISCOVERY))
len += scnprintf(buf + len, size - len, "UNKNOWN ROLE x%x",
nrport->port_role); /* Terminate the string. */
len += scnprintf(buf + len, size - len, "\n");
}
spin_unlock_irqrestore(&vport->fc_nodes_list_lock, iflags);
out_exit: return len;
}
/** * lpfc_debugfs_nvmestat_data - Dump target node list to a buffer * @vport: The vport to gather target node info from. * @buf: The buffer to dump log into. * @size: The maximum amount of data to process. * * Description: * This routine dumps the NVME statistics associated with @vport * * Return Value: * This routine returns the amount of bytes that were dumped into @buf and will * not exceed @size.
**/ staticint
lpfc_debugfs_nvmestat_data(struct lpfc_vport *vport, char *buf, int size)
{ struct lpfc_hba *phba = vport->phba; struct lpfc_nvmet_tgtport *tgtp; struct lpfc_async_xchg_ctx *ctxp, *next_ctxp; struct nvme_fc_local_port *localport; struct lpfc_fc4_ctrl_stat *cstat; struct lpfc_nvme_lport *lport;
uint64_t data1, data2, data3;
uint64_t tot, totin, totout; int cnt, i; int len = 0;
if (phba->nvmet_support) { if (!phba->targetport) return len;
tgtp = (struct lpfc_nvmet_tgtport *)phba->targetport->private;
len += scnprintf(buf + len, size - len, "\nNVME Targetport Statistics\n");
len += scnprintf(buf + len, size - len, "LS: Rcv %08x Drop %08x Abort %08x\n",
atomic_read(&tgtp->rcv_ls_req_in),
atomic_read(&tgtp->rcv_ls_req_drop),
atomic_read(&tgtp->xmt_ls_abort)); if (atomic_read(&tgtp->rcv_ls_req_in) !=
atomic_read(&tgtp->rcv_ls_req_out)) {
len += scnprintf(buf + len, size - len, "Rcv LS: in %08x != out %08x\n",
atomic_read(&tgtp->rcv_ls_req_in),
atomic_read(&tgtp->rcv_ls_req_out));
}
len += scnprintf(buf + len, size - len, "LS: Xmt %08x Drop %08x Cmpl %08x\n",
atomic_read(&tgtp->xmt_ls_rsp),
atomic_read(&tgtp->xmt_ls_drop),
atomic_read(&tgtp->xmt_ls_rsp_cmpl));
/** * lpfc_debugfs_scsistat_data - Dump target node list to a buffer * @vport: The vport to gather target node info from. * @buf: The buffer to dump log into. * @size: The maximum amount of data to process. * * Description: * This routine dumps the SCSI statistics associated with @vport * * Return Value: * This routine returns the amount of bytes that were dumped into @buf and will * not exceed @size.
**/ staticint
lpfc_debugfs_scsistat_data(struct lpfc_vport *vport, char *buf, int size)
{ int len; struct lpfc_hba *phba = vport->phba; struct lpfc_fc4_ctrl_stat *cstat;
u64 data1, data2, data3;
u64 tot, totin, totout; int i; char tmp[LPFC_MAX_SCSI_INFO_TMP_LEN] = {0};
if (!(vport->cfg_enable_fc4_type & LPFC_ENABLE_FCP) ||
(phba->sli_rev != LPFC_SLI_REV4)) return 0;
scnprintf(buf, size, "SCSI HDWQ Statistics\n");
totin = 0;
totout = 0; for (i = 0; i < phba->cfg_hdw_queue; i++) {
cstat = &phba->sli4_hba.hdwq[i].scsi_cstat;
tot = cstat->io_cmpls;
totin += tot;
data1 = cstat->input_requests;
data2 = cstat->output_requests;
data3 = cstat->control_requests;
totout += (data1 + data2 + data3);
if (lpfc_cmd->ts_data_io < lpfc_cmd->ts_cmd_start) return; if (lpfc_cmd->ts_cmd_start < lpfc_cmd->ts_last_cmd) return; if (lpfc_cmd->ts_cmd_wqput < lpfc_cmd->ts_cmd_start) return; if (lpfc_cmd->ts_isr_cmpl < lpfc_cmd->ts_cmd_wqput) return; if (lpfc_cmd->ts_data_io < lpfc_cmd->ts_isr_cmpl) return; /* * Segment 1 - Time from Last FCP command cmpl is handed * off to NVME Layer to start of next command. * Segment 2 - Time from Driver receives a IO cmd start * from NVME Layer to WQ put is done on IO cmd. * Segment 3 - Time from Driver WQ put is done on IO cmd * to MSI-X ISR for IO cmpl. * Segment 4 - Time from MSI-X ISR for IO cmpl to when * cmpl is handled off to the NVME Layer.
*/
seg1 = lpfc_cmd->ts_cmd_start - lpfc_cmd->ts_last_cmd; if (seg1 > 5000000) /* 5 ms - for sequential IOs only */
seg1 = 0;
/* Calculate times relative to start of IO */
seg2 = (lpfc_cmd->ts_cmd_wqput - lpfc_cmd->ts_cmd_start);
segsum = seg2;
seg3 = lpfc_cmd->ts_isr_cmpl - lpfc_cmd->ts_cmd_start; if (segsum > seg3) return;
seg3 -= segsum;
segsum += seg3;
/** * lpfc_debugfs_ioktime_data - Dump target node list to a buffer * @vport: The vport to gather target node info from. * @buf: The buffer to dump log into. * @size: The maximum amount of data to process. * * Description: * This routine dumps the NVME statistics associated with @vport * * Return Value: * This routine returns the amount of bytes that were dumped into @buf and will * not exceed @size.
**/ staticint
lpfc_debugfs_ioktime_data(struct lpfc_vport *vport, char *buf, int size)
{ struct lpfc_hba *phba = vport->phba; int len = 0;
if (phba->nvmet_support == 0) { /* Initiator */
len += scnprintf(buf + len, PAGE_SIZE - len, "ktime %s: Total Samples: %lld\n",
(phba->ktime_on ? "Enabled" : "Disabled"),
phba->ktime_data_samples); if (phba->ktime_data_samples == 0) return len;
len += scnprintf(
buf + len, PAGE_SIZE - len, "Segment 1: Last Cmd cmpl " "done -to- Start of next Cmd (in driver)\n");
len += scnprintf(
buf + len, PAGE_SIZE - len, "avg:%08lld min:%08lld max %08lld\n",
div_u64(phba->ktime_seg1_total,
phba->ktime_data_samples),
phba->ktime_seg1_min,
phba->ktime_seg1_max);
len += scnprintf(
buf + len, PAGE_SIZE - len, "Segment 2: Driver start of Cmd " "-to- Firmware WQ doorbell\n");
len += scnprintf(
buf + len, PAGE_SIZE - len, "avg:%08lld min:%08lld max %08lld\n",
div_u64(phba->ktime_seg2_total,
phba->ktime_data_samples),
phba->ktime_seg2_min,
phba->ktime_seg2_max);
len += scnprintf(
buf + len, PAGE_SIZE - len, "Segment 3: Firmware WQ doorbell -to- " "MSI-X ISR cmpl\n");
len += scnprintf(
buf + len, PAGE_SIZE - len, "avg:%08lld min:%08lld max %08lld\n",
div_u64(phba->ktime_seg3_total,
phba->ktime_data_samples),
phba->ktime_seg3_min,
phba->ktime_seg3_max);
len += scnprintf(
buf + len, PAGE_SIZE - len, "Segment 4: MSI-X ISR cmpl -to- " "Cmd cmpl done\n");
len += scnprintf(
buf + len, PAGE_SIZE - len, "avg:%08lld min:%08lld max %08lld\n",
div_u64(phba->ktime_seg4_total,
phba->ktime_data_samples),
phba->ktime_seg4_min,
phba->ktime_seg4_max);
len += scnprintf(
buf + len, PAGE_SIZE - len, "Total IO avg time: %08lld\n",
div_u64(phba->ktime_seg1_total +
phba->ktime_seg2_total +
phba->ktime_seg3_total +
phba->ktime_seg4_total,
phba->ktime_data_samples)); return len;
}
/* NVME Target */
len += scnprintf(buf + len, PAGE_SIZE-len, "ktime %s: Total Samples: %lld %lld\n",
(phba->ktime_on ? "Enabled" : "Disabled"),
phba->ktime_data_samples,
phba->ktime_status_samples); if (phba->ktime_data_samples == 0) return len;
len += scnprintf(buf + len, PAGE_SIZE-len, "Segment 1: MSI-X ISR Rcv cmd -to- " "cmd pass to NVME Layer\n");
len += scnprintf(buf + len, PAGE_SIZE-len, "avg:%08lld min:%08lld max %08lld\n",
div_u64(phba->ktime_seg1_total,
phba->ktime_data_samples),
phba->ktime_seg1_min,
phba->ktime_seg1_max);
len += scnprintf(buf + len, PAGE_SIZE-len, "Segment 2: cmd pass to NVME Layer- " "-to- Driver rcv cmd OP (action)\n");
len += scnprintf(buf + len, PAGE_SIZE-len, "avg:%08lld min:%08lld max %08lld\n",
div_u64(phba->ktime_seg2_total,
phba->ktime_data_samples),
phba->ktime_seg2_min,
phba->ktime_seg2_max);
len += scnprintf(buf + len, PAGE_SIZE-len, "Segment 3: Driver rcv cmd OP -to- " "Firmware WQ doorbell: cmd\n");
len += scnprintf(buf + len, PAGE_SIZE-len, "avg:%08lld min:%08lld max %08lld\n",
div_u64(phba->ktime_seg3_total,
phba->ktime_data_samples),
phba->ktime_seg3_min,
phba->ktime_seg3_max);
len += scnprintf(buf + len, PAGE_SIZE-len, "Segment 4: Firmware WQ doorbell: cmd " "-to- MSI-X ISR for cmd cmpl\n");
len += scnprintf(buf + len, PAGE_SIZE-len, "avg:%08lld min:%08lld max %08lld\n",
div_u64(phba->ktime_seg4_total,
phba->ktime_data_samples),
phba->ktime_seg4_min,
phba->ktime_seg4_max);
len += scnprintf(buf + len, PAGE_SIZE-len, "Segment 5: MSI-X ISR for cmd cmpl " "-to- NVME layer passed cmd done\n");
len += scnprintf(buf + len, PAGE_SIZE-len, "avg:%08lld min:%08lld max %08lld\n",
div_u64(phba->ktime_seg5_total,
phba->ktime_data_samples),
phba->ktime_seg5_min,
phba->ktime_seg5_max);
if (phba->ktime_status_samples == 0) {
len += scnprintf(buf + len, PAGE_SIZE-len, "Total: cmd received by MSI-X ISR " "-to- cmd completed on wire\n");
len += scnprintf(buf + len, PAGE_SIZE-len, "avg:%08lld min:%08lld " "max %08lld\n",
div_u64(phba->ktime_seg10_total,
phba->ktime_data_samples),
phba->ktime_seg10_min,
phba->ktime_seg10_max); return len;
}
len += scnprintf(buf + len, PAGE_SIZE-len, "Segment 6: NVME layer passed cmd done " "-to- Driver rcv rsp status OP\n");
len += scnprintf(buf + len, PAGE_SIZE-len, "avg:%08lld min:%08lld max %08lld\n",
div_u64(phba->ktime_seg6_total,
phba->ktime_status_samples),
phba->ktime_seg6_min,
phba->ktime_seg6_max);
len += scnprintf(buf + len, PAGE_SIZE-len, "Segment 7: Driver rcv rsp status OP " "-to- Firmware WQ doorbell: status\n");
len += scnprintf(buf + len, PAGE_SIZE-len, "avg:%08lld min:%08lld max %08lld\n",
div_u64(phba->ktime_seg7_total,
phba->ktime_status_samples),
phba->ktime_seg7_min,
phba->ktime_seg7_max);
len += scnprintf(buf + len, PAGE_SIZE-len, "Segment 8: Firmware WQ doorbell: status" " -to- MSI-X ISR for status cmpl\n");
len += scnprintf(buf + len, PAGE_SIZE-len, "avg:%08lld min:%08lld max %08lld\n",
div_u64(phba->ktime_seg8_total,
phba->ktime_status_samples),
phba->ktime_seg8_min,
phba->ktime_seg8_max);
len += scnprintf(buf + len, PAGE_SIZE-len, "Segment 9: MSI-X ISR for status cmpl " "-to- NVME layer passed status done\n");
len += scnprintf(buf + len, PAGE_SIZE-len, "avg:%08lld min:%08lld max %08lld\n",
div_u64(phba->ktime_seg9_total,
phba->ktime_status_samples),
phba->ktime_seg9_min,
phba->ktime_seg9_max);
len += scnprintf(buf + len, PAGE_SIZE-len, "Total: cmd received by MSI-X ISR -to- " "cmd completed on wire\n");
len += scnprintf(buf + len, PAGE_SIZE-len, "avg:%08lld min:%08lld max %08lld\n",
div_u64(phba->ktime_seg10_total,
phba->ktime_status_samples),
phba->ktime_seg10_min,
phba->ktime_seg10_max); return len;
}
/** * lpfc_debugfs_nvmeio_trc_data - Dump NVME IO trace list to a buffer * @phba: The phba to gather target node info from. * @buf: The buffer to dump log into. * @size: The maximum amount of data to process. * * Description: * This routine dumps the NVME IO trace associated with @phba * * Return Value: * This routine returns the amount of bytes that were dumped into @buf and will * not exceed @size.
**/ staticint
lpfc_debugfs_nvmeio_trc_data(struct lpfc_hba *phba, char *buf, int size)
{ struct lpfc_debugfs_nvmeio_trc *dtp; int i, state, index, skip; int len = 0;
/** * lpfc_debugfs_hdwqstat_data - Dump I/O stats to a buffer * @vport: The vport to gather target node info from. * @buf: The buffer to dump log into. * @size: The maximum amount of data to process. * * Description: * This routine dumps the NVME + SCSI statistics associated with @vport * * Return Value: * This routine returns the amount of bytes that were dumped into @buf and will * not exceed @size.
**/ staticint
lpfc_debugfs_hdwqstat_data(struct lpfc_vport *vport, char *buf, int size)
{ struct lpfc_hba *phba = vport->phba; struct lpfc_hdwq_stat *c_stat; int i, j, len;
uint32_t tot_xmt;
uint32_t tot_rcv;
uint32_t tot_cmpl; char tmp[LPFC_MAX_SCSI_INFO_TMP_LEN] = {0};
/* Only display for this HDWQ */ if (i != c_stat->hdwq_no) continue;
/* Only display non-zero counters */ if (!c_stat->xmt_io && !c_stat->cmpl_io &&
!c_stat->rcv_io) continue;
if (!tot_xmt && !tot_cmpl && !tot_rcv) { /* Print HDWQ string only the first time */
scnprintf(tmp, sizeof(tmp), "[HDWQ %d]:\t", i); if (strlcat(buf, tmp, size) >= size) goto buffer_done;
}
buffer_done:
len = strnlen(buf, size); return len;
}
#endif
/** * lpfc_debugfs_disc_trc - Store discovery trace log * @vport: The vport to associate this trace string with for retrieval. * @mask: Log entry classification. * @fmt: Format string to be displayed when dumping the log. * @data1: 1st data parameter to be applied to @fmt. * @data2: 2nd data parameter to be applied to @fmt. * @data3: 3rd data parameter to be applied to @fmt. * * Description: * This routine is used by the driver code to add a debugfs log entry to the * discovery trace buffer associated with @vport. Only entries with a @mask that * match the current debugfs discovery mask will be saved. Entries that do not * match will be thrown away. @fmt, @data1, @data2, and @data3 are used like * printf when displaying the log.
**/ inlinevoid
lpfc_debugfs_disc_trc(struct lpfc_vport *vport, int mask, char *fmt,
uint32_t data1, uint32_t data2, uint32_t data3)
{ #ifdef CONFIG_SCSI_LPFC_DEBUG_FS struct lpfc_debugfs_trc *dtp; int index;
if (!(lpfc_debugfs_mask_disc_trc & mask)) return;
if (!lpfc_debugfs_enable || !lpfc_debugfs_max_disc_trc ||
!vport || !vport->disc_trc) return;
/** * lpfc_debugfs_slow_ring_trc - Store slow ring trace log * @phba: The phba to associate this trace string with for retrieval. * @fmt: Format string to be displayed when dumping the log. * @data1: 1st data parameter to be applied to @fmt. * @data2: 2nd data parameter to be applied to @fmt. * @data3: 3rd data parameter to be applied to @fmt. * * Description: * This routine is used by the driver code to add a debugfs log entry to the * discovery trace buffer associated with @vport. @fmt, @data1, @data2, and * @data3 are used like printf when displaying the log.
**/ inlinevoid
lpfc_debugfs_slow_ring_trc(struct lpfc_hba *phba, char *fmt,
uint32_t data1, uint32_t data2, uint32_t data3)
{ #ifdef CONFIG_SCSI_LPFC_DEBUG_FS struct lpfc_debugfs_trc *dtp; int index;
if (!lpfc_debugfs_enable || !lpfc_debugfs_max_slow_ring_trc ||
!phba || !phba->slow_ring_trc) return;
/** * lpfc_debugfs_nvme_trc - Store NVME/NVMET trace log * @phba: The phba to associate this trace string with for retrieval. * @fmt: Format string to be displayed when dumping the log. * @data1: 1st data parameter to be applied to @fmt. * @data2: 2nd data parameter to be applied to @fmt. * @data3: 3rd data parameter to be applied to @fmt. * * Description: * This routine is used by the driver code to add a debugfs log entry to the * nvme trace buffer associated with @phba. @fmt, @data1, @data2, and * @data3 are used like printf when displaying the log.
**/ inlinevoid
lpfc_debugfs_nvme_trc(struct lpfc_hba *phba, char *fmt,
uint16_t data1, uint16_t data2, uint32_t data3)
{ #ifdef CONFIG_SCSI_LPFC_DEBUG_FS struct lpfc_debugfs_nvmeio_trc *dtp; int index;
if (!phba->nvmeio_trc_on || !phba->nvmeio_trc) return;
#ifdef CONFIG_SCSI_LPFC_DEBUG_FS /** * lpfc_debugfs_disc_trc_open - Open the discovery trace log * @inode: The inode pointer that contains a vport pointer. * @file: The file pointer to attach the log output. * * Description: * This routine is the entry point for the debugfs open file operation. It gets * the vport from the i_private field in @inode, allocates the necessary buffer * for the log, fills the buffer from the in-memory log for this vport, and then * returns a pointer to that log in the private_data field in @file. * * Returns: * This function returns zero if successful. On error it will return a negative * error value.
**/ staticint
lpfc_debugfs_disc_trc_open(struct inode *inode, struct file *file)
{ struct lpfc_vport *vport = inode->i_private; struct lpfc_debug *debug; int size; int rc = -ENOMEM;
if (!lpfc_debugfs_max_disc_trc) {
rc = -ENOSPC; goto out;
}
debug = kmalloc(sizeof(*debug), GFP_KERNEL); if (!debug) goto out;
/** * lpfc_debugfs_slow_ring_trc_open - Open the Slow Ring trace log * @inode: The inode pointer that contains a vport pointer. * @file: The file pointer to attach the log output. * * Description: * This routine is the entry point for the debugfs open file operation. It gets * the vport from the i_private field in @inode, allocates the necessary buffer * for the log, fills the buffer from the in-memory log for this vport, and then * returns a pointer to that log in the private_data field in @file. * * Returns: * This function returns zero if successful. On error it will return a negative * error value.
**/ staticint
lpfc_debugfs_slow_ring_trc_open(struct inode *inode, struct file *file)
{ struct lpfc_hba *phba = inode->i_private; struct lpfc_debug *debug; int size; int rc = -ENOMEM;
if (!lpfc_debugfs_max_slow_ring_trc) {
rc = -ENOSPC; goto out;
}
debug = kmalloc(sizeof(*debug), GFP_KERNEL); if (!debug) goto out;
/** * lpfc_debugfs_hbqinfo_open - Open the hbqinfo debugfs buffer * @inode: The inode pointer that contains a vport pointer. * @file: The file pointer to attach the log output. * * Description: * This routine is the entry point for the debugfs open file operation. It gets * the vport from the i_private field in @inode, allocates the necessary buffer * for the log, fills the buffer from the in-memory log for this vport, and then * returns a pointer to that log in the private_data field in @file. * * Returns: * This function returns zero if successful. On error it will return a negative * error value.
**/ staticint
lpfc_debugfs_hbqinfo_open(struct inode *inode, struct file *file)
{ struct lpfc_hba *phba = inode->i_private; struct lpfc_debug *debug; int rc = -ENOMEM;
debug = kmalloc(sizeof(*debug), GFP_KERNEL); if (!debug) goto out;
/* Round to page boundary */
debug->buffer = kmalloc(LPFC_HBQINFO_SIZE, GFP_KERNEL); if (!debug->buffer) {
kfree(debug); goto out;
}
/** * lpfc_debugfs_multixripools_open - Open the multixripool debugfs buffer * @inode: The inode pointer that contains a hba pointer. * @file: The file pointer to attach the log output. * * Description: * This routine is the entry point for the debugfs open file operation. It gets * the hba from the i_private field in @inode, allocates the necessary buffer * for the log, fills the buffer from the in-memory log for this hba, and then * returns a pointer to that log in the private_data field in @file. * * Returns: * This function returns zero if successful. On error it will return a negative * error value.
**/ staticint
lpfc_debugfs_multixripools_open(struct inode *inode, struct file *file)
{ struct lpfc_hba *phba = inode->i_private; struct lpfc_debug *debug; int rc = -ENOMEM;
debug = kmalloc(sizeof(*debug), GFP_KERNEL); if (!debug) goto out;
/* Round to page boundary */
debug->buffer = kzalloc(LPFC_DUMP_MULTIXRIPOOL_SIZE, GFP_KERNEL); if (!debug->buffer) {
kfree(debug); goto out;
}
#ifdef LPFC_HDWQ_LOCK_STAT /** * lpfc_debugfs_lockstat_open - Open the lockstat debugfs buffer * @inode: The inode pointer that contains a vport pointer. * @file: The file pointer to attach the log output. * * Description: * This routine is the entry point for the debugfs open file operation. It gets * the vport from the i_private field in @inode, allocates the necessary buffer * for the log, fills the buffer from the in-memory log for this vport, and then * returns a pointer to that log in the private_data field in @file. * * Returns: * This function returns zero if successful. On error it will return a negative * error value.
**/ staticint
lpfc_debugfs_lockstat_open(struct inode *inode, struct file *file)
{ struct lpfc_hba *phba = inode->i_private; struct lpfc_debug *debug; int rc = -ENOMEM;
debug = kmalloc(sizeof(*debug), GFP_KERNEL); if (!debug) goto out;
/* Round to page boundary */
debug->buffer = kmalloc(LPFC_HDWQINFO_SIZE, GFP_KERNEL); if (!debug->buffer) {
kfree(debug); goto out;
}
/** * lpfc_debugfs_ras_log_open - Open the RAS log debugfs buffer * @inode: The inode pointer that contains a vport pointer. * @file: The file pointer to attach the log output. * * Description: * This routine is the entry point for the debugfs open file operation. It gets * the vport from the i_private field in @inode, allocates the necessary buffer * for the log, fills the buffer from the in-memory log for this vport, and then * returns a pointer to that log in the private_data field in @file. * * Returns: * This function returns zero if successful. On error it will return a negative * error value.
**/ staticint
lpfc_debugfs_ras_log_open(struct inode *inode, struct file *file)
{ struct lpfc_hba *phba = inode->i_private; struct lpfc_debug *debug; int size; int rc = -ENOMEM;
/** * lpfc_debugfs_dumpHBASlim_open - Open the Dump HBA SLIM debugfs buffer * @inode: The inode pointer that contains a vport pointer. * @file: The file pointer to attach the log output. * * Description: * This routine is the entry point for the debugfs open file operation. It gets * the vport from the i_private field in @inode, allocates the necessary buffer * for the log, fills the buffer from the in-memory log for this vport, and then * returns a pointer to that log in the private_data field in @file. * * Returns: * This function returns zero if successful. On error it will return a negative * error value.
**/ staticint
lpfc_debugfs_dumpHBASlim_open(struct inode *inode, struct file *file)
{ struct lpfc_hba *phba = inode->i_private; struct lpfc_debug *debug; int rc = -ENOMEM;
debug = kmalloc(sizeof(*debug), GFP_KERNEL); if (!debug) goto out;
/* Round to page boundary */
debug->buffer = kmalloc(LPFC_DUMPHBASLIM_SIZE, GFP_KERNEL); if (!debug->buffer) {
kfree(debug); goto out;
}
/** * lpfc_debugfs_dumpHostSlim_open - Open the Dump Host SLIM debugfs buffer * @inode: The inode pointer that contains a vport pointer. * @file: The file pointer to attach the log output. * * Description: * This routine is the entry point for the debugfs open file operation. It gets * the vport from the i_private field in @inode, allocates the necessary buffer * for the log, fills the buffer from the in-memory log for this vport, and then * returns a pointer to that log in the private_data field in @file. * * Returns: * This function returns zero if successful. On error it will return a negative * error value.
**/ staticint
lpfc_debugfs_dumpHostSlim_open(struct inode *inode, struct file *file)
{ struct lpfc_hba *phba = inode->i_private; struct lpfc_debug *debug; int rc = -ENOMEM;
debug = kmalloc(sizeof(*debug), GFP_KERNEL); if (!debug) goto out;
/* Round to page boundary */
debug->buffer = kmalloc(LPFC_DUMPHOSTSLIM_SIZE, GFP_KERNEL); if (!debug->buffer) {
kfree(debug); goto out;
}
/** * lpfc_debugfs_nodelist_open - Open the nodelist debugfs file * @inode: The inode pointer that contains a vport pointer. * @file: The file pointer to attach the log output. * * Description: * This routine is the entry point for the debugfs open file operation. It gets * the vport from the i_private field in @inode, allocates the necessary buffer * for the log, fills the buffer from the in-memory log for this vport, and then * returns a pointer to that log in the private_data field in @file. * * Returns: * This function returns zero if successful. On error it will return a negative * error value.
**/ staticint
lpfc_debugfs_nodelist_open(struct inode *inode, struct file *file)
{ struct lpfc_vport *vport = inode->i_private; struct lpfc_debug *debug; int rc = -ENOMEM;
debug = kmalloc(sizeof(*debug), GFP_KERNEL); if (!debug) goto out;
/* Round to page boundary */
debug->buffer = kmalloc(LPFC_NODELIST_SIZE, GFP_KERNEL); if (!debug->buffer) {
kfree(debug); goto out;
}
/** * lpfc_debugfs_lseek - Seek through a debugfs file * @file: The file pointer to seek through. * @off: The offset to seek to or the amount to seek by. * @whence: Indicates how to seek. * * Description: * This routine is the entry point for the debugfs lseek file operation. The * @whence parameter indicates whether @off is the offset to directly seek to, * or if it is a value to seek forward or reverse by. This function figures out * what the new offset of the debugfs file will be and assigns that value to the * f_pos field of @file. * * Returns: * This function returns the new offset if successful and returns a negative * error if unable to process the seek.
**/ static loff_t
lpfc_debugfs_lseek(struct file *file, loff_t off, int whence)
{ struct lpfc_debug *debug = file->private_data; return fixed_size_llseek(file, off, whence, debug->len);
}
/** * lpfc_debugfs_read - Read a debugfs file * @file: The file pointer to read from. * @buf: The buffer to copy the data to. * @nbytes: The number of bytes to read. * @ppos: The position in the file to start reading from. * * Description: * This routine reads data from from the buffer indicated in the private_data * field of @file. It will start reading at @ppos and copy up to @nbytes of * data to @buf. * * Returns: * This function returns the amount of data that was read (this could be less * than @nbytes if the end of the file was reached) or a negative error value.
**/ static ssize_t
lpfc_debugfs_read(struct file *file, char __user *buf,
size_t nbytes, loff_t *ppos)
{ struct lpfc_debug *debug = file->private_data;
/** * lpfc_debugfs_release - Release the buffer used to store debugfs file data * @inode: The inode pointer that contains a vport pointer. (unused) * @file: The file pointer that contains the buffer to release. * * Description: * This routine frees the buffer that was allocated when the debugfs file was * opened. * * Returns: * This function returns zero.
**/ staticint
lpfc_debugfs_release(struct inode *inode, struct file *file)
{ struct lpfc_debug *debug = file->private_data;
kfree(debug->buffer);
kfree(debug);
return 0;
}
/** * lpfc_debugfs_multixripools_write - Clear multi-XRI pools statistics * @file: The file pointer to read from. * @buf: The buffer to copy the user data from. * @nbytes: The number of bytes to get. * @ppos: The position in the file to start reading from. * * Description: * This routine clears multi-XRI pools statistics when buf contains "clear". * * Return Value: * It returns the @nbytges passing in from debugfs user space when successful. * In case of error conditions, it returns proper error code back to the user * space.
**/ static ssize_t
lpfc_debugfs_multixripools_write(struct file *file, constchar __user *buf,
size_t nbytes, loff_t *ppos)
{ struct lpfc_debug *debug = file->private_data; struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private; char mybuf[64]; char *pbuf;
u32 i;
u32 hwq_count; struct lpfc_sli4_hdw_queue *qp; struct lpfc_multixri_pool *multixri_pool;
/* We must be off to allocate the trace buffer */ if (phba->nvmeio_trc_on != 0) return -EINVAL;
/* If not on or off, the parameter is the trace buffer size */
i = kstrtoul(pbuf, 0, &sz); if (i) return -EINVAL;
phba->nvmeio_trc_size = (uint32_t)sz;
/* It must be a power of 2 - round down */
i = 0; while (sz > 1) {
sz = sz >> 1;
i++;
}
sz = (1 << i); if (phba->nvmeio_trc_size != sz)
lpfc_printf_log(phba, KERN_ERR, LOG_INIT, "0572 nvmeio_trc_size changed to %ld\n",
sz);
phba->nvmeio_trc_size = (uint32_t)sz;
/* If one previously exists, free it */
kfree(phba->nvmeio_trc);
/* * --------------------------------- * iDiag debugfs file access methods * --------------------------------- * * All access methods are through the proper SLI4 PCI function's debugfs * iDiag directory: * * /sys/kernel/debug/lpfc/fn<#>/iDiag
*/
/** * lpfc_idiag_cmd_get - Get and parse idiag debugfs comands from user space * @buf: The pointer to the user space buffer. * @nbytes: The number of bytes in the user space buffer. * @idiag_cmd: pointer to the idiag command struct. * * This routine reads data from debugfs user space buffer and parses the * buffer for getting the idiag command and arguments. The while space in * between the set of data is used as the parsing separator. * * This routine returns 0 when successful, it returns proper error code * back to the user space in error conditions.
*/ staticint lpfc_idiag_cmd_get(constchar __user *buf, size_t nbytes, struct lpfc_idiag_cmd *idiag_cmd)
{ char mybuf[64]; char *pbuf, *step_str; int i;
size_t bsize;
for (i = 0; i < LPFC_IDIAG_CMD_DATA_SIZE; i++) {
step_str = strsep(&pbuf, "\t "); if (!step_str) return i;
idiag_cmd->data[i] = simple_strtol(step_str, NULL, 0);
} return i;
}
/** * lpfc_idiag_open - idiag open debugfs * @inode: The inode pointer that contains a pointer to phba. * @file: The file pointer to attach the file operation. * * Description: * This routine is the entry point for the debugfs open file operation. It * gets the reference to phba from the i_private field in @inode, it then * allocates buffer for the file operation, performs the necessary PCI config * space read into the allocated buffer according to the idiag user command * setup, and then returns a pointer to buffer in the private_data field in * @file. * * Returns: * This function returns zero if successful. On error it will return an * negative error value.
**/ staticint
lpfc_idiag_open(struct inode *inode, struct file *file)
{ struct lpfc_debug *debug;
debug = kmalloc(sizeof(*debug), GFP_KERNEL); if (!debug) return -ENOMEM;
/** * lpfc_idiag_release - Release idiag access file operation * @inode: The inode pointer that contains a vport pointer. (unused) * @file: The file pointer that contains the buffer to release. * * Description: * This routine is the generic release routine for the idiag access file * operation, it frees the buffer that was allocated when the debugfs file * was opened. * * Returns: * This function returns zero.
**/ staticint
lpfc_idiag_release(struct inode *inode, struct file *file)
{ struct lpfc_debug *debug = file->private_data;
/* Free the buffers to the file operation */
kfree(debug->buffer);
kfree(debug);
return 0;
}
/** * lpfc_idiag_cmd_release - Release idiag cmd access file operation * @inode: The inode pointer that contains a vport pointer. (unused) * @file: The file pointer that contains the buffer to release. * * Description: * This routine frees the buffer that was allocated when the debugfs file * was opened. It also reset the fields in the idiag command struct in the * case of command for write operation. * * Returns: * This function returns zero.
**/ staticint
lpfc_idiag_cmd_release(struct inode *inode, struct file *file)
{ struct lpfc_debug *debug = file->private_data;
if (debug->op == LPFC_IDIAG_OP_WR) { switch (idiag.cmd.opcode) { case LPFC_IDIAG_CMD_PCICFG_WR: case LPFC_IDIAG_CMD_PCICFG_ST: case LPFC_IDIAG_CMD_PCICFG_CL: case LPFC_IDIAG_CMD_QUEACC_WR: case LPFC_IDIAG_CMD_QUEACC_ST: case LPFC_IDIAG_CMD_QUEACC_CL:
memset(&idiag, 0, sizeof(idiag)); break; default: break;
}
}
/* Free the buffers to the file operation */
kfree(debug->buffer);
kfree(debug);
return 0;
}
/** * lpfc_idiag_pcicfg_read - idiag debugfs read pcicfg * @file: The file pointer to read from. * @buf: The buffer to copy the data to. * @nbytes: The number of bytes to read. * @ppos: The position in the file to start reading from. * * Description: * This routine reads data from the @phba pci config space according to the * idiag command, and copies to user @buf. Depending on the PCI config space * read command setup, it does either a single register read of a byte * (8 bits), a word (16 bits), or a dword (32 bits) or browsing through all * registers from the 4K extended PCI config space. * * Returns: * This function returns the amount of data that was read (this could be less * than @nbytes if the end of the file was reached) or a negative error value.
**/ static ssize_t
lpfc_idiag_pcicfg_read(struct file *file, char __user *buf, size_t nbytes,
loff_t *ppos)
{ struct lpfc_debug *debug = file->private_data; struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private; int offset_label, offset, len = 0, index = LPFC_PCI_CFG_RD_SIZE; int where, count; char *pbuffer; struct pci_dev *pdev;
uint32_t u32val;
uint16_t u16val;
uint8_t u8val;
pdev = phba->pcidev; if (!pdev) return 0;
/* This is a user read operation */
debug->op = LPFC_IDIAG_OP_RD;
if (!debug->buffer)
debug->buffer = kmalloc(LPFC_PCI_CFG_SIZE, GFP_KERNEL); if (!debug->buffer) return 0;
pbuffer = debug->buffer;
if (*ppos) return 0;
if (idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_RD) {
where = idiag.cmd.data[IDIAG_PCICFG_WHERE_INDX];
count = idiag.cmd.data[IDIAG_PCICFG_COUNT_INDX];
} else return 0;
/* Read single PCI config space register */ switch (count) { case SIZE_U8: /* byte (8 bits) */
pci_read_config_byte(pdev, where, &u8val);
len += scnprintf(pbuffer+len, LPFC_PCI_CFG_SIZE-len, "%03x: %02x\n", where, u8val); break; case SIZE_U16: /* word (16 bits) */
pci_read_config_word(pdev, where, &u16val);
len += scnprintf(pbuffer+len, LPFC_PCI_CFG_SIZE-len, "%03x: %04x\n", where, u16val); break; case SIZE_U32: /* double word (32 bits) */
pci_read_config_dword(pdev, where, &u32val);
len += scnprintf(pbuffer+len, LPFC_PCI_CFG_SIZE-len, "%03x: %08x\n", where, u32val); break; case LPFC_PCI_CFG_BROWSE: /* browse all */ goto pcicfg_browse; default: /* illegal count */
len = 0; break;
} return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len);
pcicfg_browse:
/* Browse all PCI config space registers */
offset_label = idiag.offset.last_rd;
offset = offset_label;
/* Read PCI config space */
len += scnprintf(pbuffer+len, LPFC_PCI_CFG_SIZE-len, "%03x: ", offset_label); while (index > 0) {
pci_read_config_dword(pdev, offset, &u32val);
len += scnprintf(pbuffer+len, LPFC_PCI_CFG_SIZE-len, "%08x ", u32val);
offset += sizeof(uint32_t); if (offset >= LPFC_PCI_CFG_SIZE) {
len += scnprintf(pbuffer+len,
LPFC_PCI_CFG_SIZE-len, "\n"); break;
}
index -= sizeof(uint32_t); if (!index)
len += scnprintf(pbuffer+len, LPFC_PCI_CFG_SIZE-len, "\n"); elseif (!(index % (8 * sizeof(uint32_t)))) {
offset_label += (8 * sizeof(uint32_t));
len += scnprintf(pbuffer+len, LPFC_PCI_CFG_SIZE-len, "\n%03x: ", offset_label);
}
}
/* Set up the offset for next portion of pci cfg read */ if (index == 0) {
idiag.offset.last_rd += LPFC_PCI_CFG_RD_SIZE; if (idiag.offset.last_rd >= LPFC_PCI_CFG_SIZE)
idiag.offset.last_rd = 0;
} else
idiag.offset.last_rd = 0;
/** * lpfc_idiag_pcicfg_write - Syntax check and set up idiag pcicfg commands * @file: The file pointer to read from. * @buf: The buffer to copy the user data from. * @nbytes: The number of bytes to get. * @ppos: The position in the file to start reading from. * * This routine get the debugfs idiag command struct from user space and * then perform the syntax check for PCI config space read or write command * accordingly. In the case of PCI config space read command, it sets up * the command in the idiag command struct for the debugfs read operation. * In the case of PCI config space write operation, it executes the write * operation into the PCI config space accordingly. * * It returns the @nbytges passing in from debugfs user space when successful. * In case of error conditions, it returns proper error code back to the user * space.
*/ static ssize_t
lpfc_idiag_pcicfg_write(struct file *file, constchar __user *buf,
size_t nbytes, loff_t *ppos)
{ struct lpfc_debug *debug = file->private_data; struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
uint32_t where, value, count;
uint32_t u32val;
uint16_t u16val;
uint8_t u8val; struct pci_dev *pdev; int rc;
pdev = phba->pcidev; if (!pdev) return -EFAULT;
/* This is a user write operation */
debug->op = LPFC_IDIAG_OP_WR;
/** * lpfc_idiag_baracc_read - idiag debugfs pci bar access read * @file: The file pointer to read from. * @buf: The buffer to copy the data to. * @nbytes: The number of bytes to read. * @ppos: The position in the file to start reading from. * * Description: * This routine reads data from the @phba pci bar memory mapped space * according to the idiag command, and copies to user @buf. * * Returns: * This function returns the amount of data that was read (this could be less * than @nbytes if the end of the file was reached) or a negative error value.
**/ static ssize_t
lpfc_idiag_baracc_read(struct file *file, char __user *buf, size_t nbytes,
loff_t *ppos)
{ struct lpfc_debug *debug = file->private_data; struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private; int offset_label, offset, offset_run, len = 0, index; int bar_num, acc_range, bar_size; char *pbuffer; void __iomem *mem_mapped_bar;
uint32_t if_type; struct pci_dev *pdev;
uint32_t u32val;
pdev = phba->pcidev; if (!pdev) return 0;
/* This is a user read operation */
debug->op = LPFC_IDIAG_OP_RD;
if (!debug->buffer)
debug->buffer = kmalloc(LPFC_PCI_BAR_RD_BUF_SIZE, GFP_KERNEL); if (!debug->buffer) return 0;
pbuffer = debug->buffer;
/** * lpfc_idiag_baracc_write - Syntax check and set up idiag bar access commands * @file: The file pointer to read from. * @buf: The buffer to copy the user data from. * @nbytes: The number of bytes to get. * @ppos: The position in the file to start reading from. * * This routine get the debugfs idiag command struct from user space and * then perform the syntax check for PCI bar memory mapped space read or * write command accordingly. In the case of PCI bar memory mapped space * read command, it sets up the command in the idiag command struct for * the debugfs read operation. In the case of PCI bar memorpy mapped space * write operation, it executes the write operation into the PCI bar memory * mapped space accordingly. * * It returns the @nbytges passing in from debugfs user space when successful. * In case of error conditions, it returns proper error code back to the user * space.
*/ static ssize_t
lpfc_idiag_baracc_write(struct file *file, constchar __user *buf,
size_t nbytes, loff_t *ppos)
{ struct lpfc_debug *debug = file->private_data; struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
uint32_t bar_num, bar_size, offset, value, acc_range; struct pci_dev *pdev; void __iomem *mem_mapped_bar;
uint32_t if_type;
uint32_t u32val; int rc;
pdev = phba->pcidev; if (!pdev) return -EFAULT;
/* This is a user write operation */
debug->op = LPFC_IDIAG_OP_WR;
staticint
lpfc_idiag_wqs_for_cq(struct lpfc_hba *phba, char *wqtype, char *pbuffer, int *len, int max_cnt, int cq_id)
{ struct lpfc_queue *qp; int qidx;
/** * lpfc_idiag_queinfo_read - idiag debugfs read queue information * @file: The file pointer to read from. * @buf: The buffer to copy the data to. * @nbytes: The number of bytes to read. * @ppos: The position in the file to start reading from. * * Description: * This routine reads data from the @phba SLI4 PCI function queue information, * and copies to user @buf. * This routine only returns 1 EQs worth of information. It remembers the last * EQ read and jumps to the next EQ. Thus subsequent calls to queInfo will * retrieve all EQs allocated for the phba. * * Returns: * This function returns the amount of data that was read (this could be less * than @nbytes if the end of the file was reached) or a negative error value.
**/ static ssize_t
lpfc_idiag_queinfo_read(struct file *file, char __user *buf, size_t nbytes,
loff_t *ppos)
{ struct lpfc_debug *debug = file->private_data; struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private; char *pbuffer; int max_cnt, rc, x, len = 0; struct lpfc_queue *qp = NULL;
if (!debug->buffer)
debug->buffer = kmalloc(LPFC_QUE_INFO_GET_BUF_SIZE, GFP_KERNEL); if (!debug->buffer) return 0;
pbuffer = debug->buffer;
max_cnt = LPFC_QUE_INFO_GET_BUF_SIZE - 256;
if (*ppos) return 0;
spin_lock_irq(&phba->hbalock);
/* Fast-path event queue */ if (phba->sli4_hba.hdwq && phba->cfg_hdw_queue) {
x = phba->lpfc_idiag_last_eq;
phba->lpfc_idiag_last_eq++; if (phba->lpfc_idiag_last_eq >= phba->cfg_hdw_queue)
phba->lpfc_idiag_last_eq = 0;
len += scnprintf(pbuffer + len,
LPFC_QUE_INFO_GET_BUF_SIZE - len, "HDWQ %d out of %d HBA HDWQs\n",
x, phba->cfg_hdw_queue);
/** * lpfc_idiag_que_param_check - queue access command parameter sanity check * @q: The pointer to queue structure. * @index: The index into a queue entry. * @count: The number of queue entries to access. * * Description: * The routine performs sanity check on device queue access method commands. * * Returns: * This function returns -EINVAL when fails the sanity check, otherwise, it * returns 0.
**/ staticint
lpfc_idiag_que_param_check(struct lpfc_queue *q, int index, int count)
{ /* Only support single entry read or browsing */ if ((count != 1) && (count != LPFC_QUE_ACC_BROWSE)) return -EINVAL; if (index > q->entry_count - 1) return -EINVAL; return 0;
}
/** * lpfc_idiag_queacc_read_qe - read a single entry from the given queue index * @pbuffer: The pointer to buffer to copy the read data into. * @len: Length of the buffer. * @pque: The pointer to the queue to be read. * @index: The index into the queue entry. * * Description: * This routine reads out a single entry from the given queue's index location * and copies it into the buffer provided. * * Returns: * This function returns 0 when it fails, otherwise, it returns the length of * the data read into the buffer provided.
**/ staticint
lpfc_idiag_queacc_read_qe(char *pbuffer, int len, struct lpfc_queue *pque,
uint32_t index)
{ int offset, esize;
uint32_t *pentry;
if (!pbuffer || !pque) return 0;
esize = pque->entry_size;
len += scnprintf(pbuffer+len, LPFC_QUE_ACC_BUF_SIZE-len, "QE-INDEX[%04d]:\n", index);
offset = 0;
pentry = lpfc_sli4_qe(pque, index); while (esize > 0) {
len += scnprintf(pbuffer+len, LPFC_QUE_ACC_BUF_SIZE-len, "%08x ", *pentry);
pentry++;
offset += sizeof(uint32_t);
esize -= sizeof(uint32_t); if (esize > 0 && !(offset % (4 * sizeof(uint32_t))))
len += scnprintf(pbuffer+len,
LPFC_QUE_ACC_BUF_SIZE-len, "\n");
}
len += scnprintf(pbuffer+len, LPFC_QUE_ACC_BUF_SIZE-len, "\n");
return len;
}
/** * lpfc_idiag_queacc_read - idiag debugfs read port queue * @file: The file pointer to read from. * @buf: The buffer to copy the data to. * @nbytes: The number of bytes to read. * @ppos: The position in the file to start reading from. * * Description: * This routine reads data from the @phba device queue memory according to the * idiag command, and copies to user @buf. Depending on the queue dump read * command setup, it does either a single queue entry read or browing through * all entries of the queue. * * Returns: * This function returns the amount of data that was read (this could be less * than @nbytes if the end of the file was reached) or a negative error value.
**/ static ssize_t
lpfc_idiag_queacc_read(struct file *file, char __user *buf, size_t nbytes,
loff_t *ppos)
{ struct lpfc_debug *debug = file->private_data;
uint32_t last_index, index, count; struct lpfc_queue *pque = NULL; char *pbuffer; int len = 0;
/* This is a user read operation */
debug->op = LPFC_IDIAG_OP_RD;
if (!debug->buffer)
debug->buffer = kmalloc(LPFC_QUE_ACC_BUF_SIZE, GFP_KERNEL); if (!debug->buffer) return 0;
pbuffer = debug->buffer;
if (*ppos) return 0;
if (idiag.cmd.opcode == LPFC_IDIAG_CMD_QUEACC_RD) {
index = idiag.cmd.data[IDIAG_QUEACC_INDEX_INDX];
count = idiag.cmd.data[IDIAG_QUEACC_COUNT_INDX];
pque = (struct lpfc_queue *)idiag.ptr_private;
} else return 0;
/* Browse the queue starting from index */ if (count == LPFC_QUE_ACC_BROWSE) goto que_browse;
/* Read a single entry from the queue */
len = lpfc_idiag_queacc_read_qe(pbuffer, len, pque, index);
/** * lpfc_idiag_queacc_write - Syntax check and set up idiag queacc commands * @file: The file pointer to read from. * @buf: The buffer to copy the user data from. * @nbytes: The number of bytes to get. * @ppos: The position in the file to start reading from. * * This routine get the debugfs idiag command struct from user space and then * perform the syntax check for port queue read (dump) or write (set) command * accordingly. In the case of port queue read command, it sets up the command * in the idiag command struct for the following debugfs read operation. In * the case of port queue write operation, it executes the write operation * into the port queue entry accordingly. * * It returns the @nbytges passing in from debugfs user space when successful. * In case of error conditions, it returns proper error code back to the user * space.
**/ static ssize_t
lpfc_idiag_queacc_write(struct file *file, constchar __user *buf,
size_t nbytes, loff_t *ppos)
{ struct lpfc_debug *debug = file->private_data; struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
uint32_t qidx, quetp, queid, index, count, offset, value;
uint32_t *pentry; struct lpfc_queue *pque, *qp; int rc;
/* This is a user write operation */
debug->op = LPFC_IDIAG_OP_WR;
error_out: /* Clean out command structure on command error out */
memset(&idiag, 0, sizeof(idiag)); return -EINVAL;
}
/** * lpfc_idiag_drbacc_read_reg - idiag debugfs read a doorbell register * @phba: The pointer to hba structure. * @pbuffer: The pointer to the buffer to copy the data to. * @len: The length of bytes to copied. * @drbregid: The id to doorbell registers. * * Description: * This routine reads a doorbell register and copies its content to the * user buffer pointed to by @pbuffer. * * Returns: * This function returns the amount of data that was copied into @pbuffer.
**/ staticint
lpfc_idiag_drbacc_read_reg(struct lpfc_hba *phba, char *pbuffer, int len, uint32_t drbregid)
{
if (!pbuffer) return 0;
switch (drbregid) { case LPFC_DRB_EQ:
len += scnprintf(pbuffer + len, LPFC_DRB_ACC_BUF_SIZE-len, "EQ-DRB-REG: 0x%08x\n",
readl(phba->sli4_hba.EQDBregaddr)); break; case LPFC_DRB_CQ:
len += scnprintf(pbuffer + len, LPFC_DRB_ACC_BUF_SIZE - len, "CQ-DRB-REG: 0x%08x\n",
readl(phba->sli4_hba.CQDBregaddr)); break; case LPFC_DRB_MQ:
len += scnprintf(pbuffer+len, LPFC_DRB_ACC_BUF_SIZE-len, "MQ-DRB-REG: 0x%08x\n",
readl(phba->sli4_hba.MQDBregaddr)); break; case LPFC_DRB_WQ:
len += scnprintf(pbuffer+len, LPFC_DRB_ACC_BUF_SIZE-len, "WQ-DRB-REG: 0x%08x\n",
readl(phba->sli4_hba.WQDBregaddr)); break; case LPFC_DRB_RQ:
len += scnprintf(pbuffer+len, LPFC_DRB_ACC_BUF_SIZE-len, "RQ-DRB-REG: 0x%08x\n",
readl(phba->sli4_hba.RQDBregaddr)); break; default: break;
}
return len;
}
/** * lpfc_idiag_drbacc_read - idiag debugfs read port doorbell * @file: The file pointer to read from. * @buf: The buffer to copy the data to. * @nbytes: The number of bytes to read. * @ppos: The position in the file to start reading from. * * Description: * This routine reads data from the @phba device doorbell register according * to the idiag command, and copies to user @buf. Depending on the doorbell * register read command setup, it does either a single doorbell register * read or dump all doorbell registers. * * Returns: * This function returns the amount of data that was read (this could be less * than @nbytes if the end of the file was reached) or a negative error value.
**/ static ssize_t
lpfc_idiag_drbacc_read(struct file *file, char __user *buf, size_t nbytes,
loff_t *ppos)
{ struct lpfc_debug *debug = file->private_data; struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
uint32_t drb_reg_id, i; char *pbuffer; int len = 0;
/* This is a user read operation */
debug->op = LPFC_IDIAG_OP_RD;
if (!debug->buffer)
debug->buffer = kmalloc(LPFC_DRB_ACC_BUF_SIZE, GFP_KERNEL); if (!debug->buffer) return 0;
pbuffer = debug->buffer;
if (*ppos) return 0;
if (idiag.cmd.opcode == LPFC_IDIAG_CMD_DRBACC_RD)
drb_reg_id = idiag.cmd.data[IDIAG_DRBACC_REGID_INDX]; else return 0;
if (drb_reg_id == LPFC_DRB_ACC_ALL) for (i = 1; i <= LPFC_DRB_MAX; i++)
len = lpfc_idiag_drbacc_read_reg(phba,
pbuffer, len, i); else
len = lpfc_idiag_drbacc_read_reg(phba,
pbuffer, len, drb_reg_id);
/** * lpfc_idiag_drbacc_write - Syntax check and set up idiag drbacc commands * @file: The file pointer to read from. * @buf: The buffer to copy the user data from. * @nbytes: The number of bytes to get. * @ppos: The position in the file to start reading from. * * This routine get the debugfs idiag command struct from user space and then * perform the syntax check for port doorbell register read (dump) or write * (set) command accordingly. In the case of port queue read command, it sets * up the command in the idiag command struct for the following debugfs read * operation. In the case of port doorbell register write operation, it * executes the write operation into the port doorbell register accordingly. * * It returns the @nbytges passing in from debugfs user space when successful. * In case of error conditions, it returns proper error code back to the user * space.
**/ static ssize_t
lpfc_idiag_drbacc_write(struct file *file, constchar __user *buf,
size_t nbytes, loff_t *ppos)
{ struct lpfc_debug *debug = file->private_data; struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
uint32_t drb_reg_id, value, reg_val = 0; void __iomem *drb_reg; int rc;
/* This is a user write operation */
debug->op = LPFC_IDIAG_OP_WR;
error_out: /* Clean out command structure on command error out */
memset(&idiag, 0, sizeof(idiag)); return -EINVAL;
}
/** * lpfc_idiag_ctlacc_read_reg - idiag debugfs read a control registers * @phba: The pointer to hba structure. * @pbuffer: The pointer to the buffer to copy the data to. * @len: The length of bytes to copied. * @ctlregid: The id to doorbell registers. * * Description: * This routine reads a control register and copies its content to the * user buffer pointed to by @pbuffer. * * Returns: * This function returns the amount of data that was copied into @pbuffer.
**/ staticint
lpfc_idiag_ctlacc_read_reg(struct lpfc_hba *phba, char *pbuffer, int len, uint32_t ctlregid)
{
if (!pbuffer) return 0;
switch (ctlregid) { case LPFC_CTL_PORT_SEM:
len += scnprintf(pbuffer+len, LPFC_CTL_ACC_BUF_SIZE-len, "Port SemReg: 0x%08x\n",
readl(phba->sli4_hba.conf_regs_memmap_p +
LPFC_CTL_PORT_SEM_OFFSET)); break; case LPFC_CTL_PORT_STA:
len += scnprintf(pbuffer+len, LPFC_CTL_ACC_BUF_SIZE-len, "Port StaReg: 0x%08x\n",
readl(phba->sli4_hba.conf_regs_memmap_p +
LPFC_CTL_PORT_STA_OFFSET)); break; case LPFC_CTL_PORT_CTL:
len += scnprintf(pbuffer+len, LPFC_CTL_ACC_BUF_SIZE-len, "Port CtlReg: 0x%08x\n",
readl(phba->sli4_hba.conf_regs_memmap_p +
LPFC_CTL_PORT_CTL_OFFSET)); break; case LPFC_CTL_PORT_ER1:
len += scnprintf(pbuffer+len, LPFC_CTL_ACC_BUF_SIZE-len, "Port Er1Reg: 0x%08x\n",
readl(phba->sli4_hba.conf_regs_memmap_p +
LPFC_CTL_PORT_ER1_OFFSET)); break; case LPFC_CTL_PORT_ER2:
len += scnprintf(pbuffer+len, LPFC_CTL_ACC_BUF_SIZE-len, "Port Er2Reg: 0x%08x\n",
readl(phba->sli4_hba.conf_regs_memmap_p +
LPFC_CTL_PORT_ER2_OFFSET)); break; case LPFC_CTL_PDEV_CTL:
len += scnprintf(pbuffer+len, LPFC_CTL_ACC_BUF_SIZE-len, "PDev CtlReg: 0x%08x\n",
readl(phba->sli4_hba.conf_regs_memmap_p +
LPFC_CTL_PDEV_CTL_OFFSET)); break; default: break;
} return len;
}
/** * lpfc_idiag_ctlacc_read - idiag debugfs read port and device control register * @file: The file pointer to read from. * @buf: The buffer to copy the data to. * @nbytes: The number of bytes to read. * @ppos: The position in the file to start reading from. * * Description: * This routine reads data from the @phba port and device registers according * to the idiag command, and copies to user @buf. * * Returns: * This function returns the amount of data that was read (this could be less * than @nbytes if the end of the file was reached) or a negative error value.
**/ static ssize_t
lpfc_idiag_ctlacc_read(struct file *file, char __user *buf, size_t nbytes,
loff_t *ppos)
{ struct lpfc_debug *debug = file->private_data; struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
uint32_t ctl_reg_id, i; char *pbuffer; int len = 0;
/* This is a user read operation */
debug->op = LPFC_IDIAG_OP_RD;
if (!debug->buffer)
debug->buffer = kmalloc(LPFC_CTL_ACC_BUF_SIZE, GFP_KERNEL); if (!debug->buffer) return 0;
pbuffer = debug->buffer;
if (*ppos) return 0;
if (idiag.cmd.opcode == LPFC_IDIAG_CMD_CTLACC_RD)
ctl_reg_id = idiag.cmd.data[IDIAG_CTLACC_REGID_INDX]; else return 0;
if (ctl_reg_id == LPFC_CTL_ACC_ALL) for (i = 1; i <= LPFC_CTL_MAX; i++)
len = lpfc_idiag_ctlacc_read_reg(phba,
pbuffer, len, i); else
len = lpfc_idiag_ctlacc_read_reg(phba,
pbuffer, len, ctl_reg_id);
/** * lpfc_idiag_ctlacc_write - Syntax check and set up idiag ctlacc commands * @file: The file pointer to read from. * @buf: The buffer to copy the user data from. * @nbytes: The number of bytes to get. * @ppos: The position in the file to start reading from. * * This routine get the debugfs idiag command struct from user space and then * perform the syntax check for port and device control register read (dump) * or write (set) command accordingly. * * It returns the @nbytges passing in from debugfs user space when successful. * In case of error conditions, it returns proper error code back to the user * space.
**/ static ssize_t
lpfc_idiag_ctlacc_write(struct file *file, constchar __user *buf,
size_t nbytes, loff_t *ppos)
{ struct lpfc_debug *debug = file->private_data; struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
uint32_t ctl_reg_id, value, reg_val = 0; void __iomem *ctl_reg; int rc;
/* This is a user write operation */
debug->op = LPFC_IDIAG_OP_WR;
error_out: /* Clean out command structure on command error out */
memset(&idiag, 0, sizeof(idiag)); return -EINVAL;
}
/** * lpfc_idiag_mbxacc_get_setup - idiag debugfs get mailbox access setup * @phba: Pointer to HBA context object. * @pbuffer: Pointer to data buffer. * * Description: * This routine gets the driver mailbox access debugfs setup information. * * Returns: * This function returns the amount of data that was read (this could be less * than @nbytes if the end of the file was reached) or a negative error value.
**/ staticint
lpfc_idiag_mbxacc_get_setup(struct lpfc_hba *phba, char *pbuffer)
{
uint32_t mbx_dump_map, mbx_dump_cnt, mbx_word_cnt, mbx_mbox_cmd; int len = 0;
len += scnprintf(pbuffer+len, LPFC_MBX_ACC_BUF_SIZE-len, "mbx_dump_map: 0x%08x\n", mbx_dump_map);
len += scnprintf(pbuffer+len, LPFC_MBX_ACC_BUF_SIZE-len, "mbx_dump_cnt: %04d\n", mbx_dump_cnt);
len += scnprintf(pbuffer+len, LPFC_MBX_ACC_BUF_SIZE-len, "mbx_word_cnt: %04d\n", mbx_word_cnt);
len += scnprintf(pbuffer+len, LPFC_MBX_ACC_BUF_SIZE-len, "mbx_mbox_cmd: 0x%02x\n", mbx_mbox_cmd);
return len;
}
/** * lpfc_idiag_mbxacc_read - idiag debugfs read on mailbox access * @file: The file pointer to read from. * @buf: The buffer to copy the data to. * @nbytes: The number of bytes to read. * @ppos: The position in the file to start reading from. * * Description: * This routine reads data from the @phba driver mailbox access debugfs setup * information. * * Returns: * This function returns the amount of data that was read (this could be less * than @nbytes if the end of the file was reached) or a negative error value.
**/ static ssize_t
lpfc_idiag_mbxacc_read(struct file *file, char __user *buf, size_t nbytes,
loff_t *ppos)
{ struct lpfc_debug *debug = file->private_data; struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private; char *pbuffer; int len = 0;
/* This is a user read operation */
debug->op = LPFC_IDIAG_OP_RD;
if (!debug->buffer)
debug->buffer = kmalloc(LPFC_MBX_ACC_BUF_SIZE, GFP_KERNEL); if (!debug->buffer) return 0;
pbuffer = debug->buffer;
if (*ppos) return 0;
if ((idiag.cmd.opcode != LPFC_IDIAG_CMD_MBXACC_DP) &&
(idiag.cmd.opcode != LPFC_IDIAG_BSG_MBXACC_DP)) return 0;
/** * lpfc_idiag_mbxacc_write - Syntax check and set up idiag mbxacc commands * @file: The file pointer to read from. * @buf: The buffer to copy the user data from. * @nbytes: The number of bytes to get. * @ppos: The position in the file to start reading from. * * This routine get the debugfs idiag command struct from user space and then * perform the syntax check for driver mailbox command (dump) and sets up the * necessary states in the idiag command struct accordingly. * * It returns the @nbytges passing in from debugfs user space when successful. * In case of error conditions, it returns proper error code back to the user * space.
**/ static ssize_t
lpfc_idiag_mbxacc_write(struct file *file, constchar __user *buf,
size_t nbytes, loff_t *ppos)
{ struct lpfc_debug *debug = file->private_data;
uint32_t mbx_dump_map, mbx_dump_cnt, mbx_word_cnt, mbx_mbox_cmd; int rc;
/* This is a user write operation */
debug->op = LPFC_IDIAG_OP_WR;
/* Sanity check on command line arguments */
mbx_mbox_cmd = idiag.cmd.data[IDIAG_MBXACC_MBCMD_INDX];
mbx_dump_map = idiag.cmd.data[IDIAG_MBXACC_DPMAP_INDX];
mbx_dump_cnt = idiag.cmd.data[IDIAG_MBXACC_DPCNT_INDX];
mbx_word_cnt = idiag.cmd.data[IDIAG_MBXACC_WDCNT_INDX];
if (idiag.cmd.opcode == LPFC_IDIAG_CMD_MBXACC_DP) { if (!(mbx_dump_map & LPFC_MBX_DMP_MBX_ALL)) goto error_out; if ((mbx_dump_map & ~LPFC_MBX_DMP_MBX_ALL) &&
(mbx_dump_map != LPFC_MBX_DMP_ALL)) goto error_out; if (mbx_word_cnt > sizeof(MAILBOX_t)) goto error_out;
} elseif (idiag.cmd.opcode == LPFC_IDIAG_BSG_MBXACC_DP) { if (!(mbx_dump_map & LPFC_BSG_DMP_MBX_ALL)) goto error_out; if ((mbx_dump_map & ~LPFC_BSG_DMP_MBX_ALL) &&
(mbx_dump_map != LPFC_MBX_DMP_ALL)) goto error_out; if (mbx_word_cnt > (BSG_MBOX_SIZE)/4) goto error_out; if (mbx_mbox_cmd != 0x9b) goto error_out;
} else goto error_out;
if (mbx_word_cnt == 0) goto error_out; if (rc != LPFC_MBX_DMP_ARG) goto error_out; if (mbx_mbox_cmd & ~0xff) goto error_out;
/* condition for stop mailbox dump */ if (mbx_dump_cnt == 0) goto reset_out;
return nbytes;
reset_out: /* Clean out command structure on command error out */
memset(&idiag, 0, sizeof(idiag)); return nbytes;
error_out: /* Clean out command structure on command error out */
memset(&idiag, 0, sizeof(idiag)); return -EINVAL;
}
/** * lpfc_idiag_extacc_avail_get - get the available extents information * @phba: pointer to lpfc hba data structure. * @pbuffer: pointer to internal buffer. * @len: length into the internal buffer data has been copied. * * Description: * This routine is to get the available extent information. * * Returns: * overall length of the data read into the internal buffer.
**/ staticint
lpfc_idiag_extacc_avail_get(struct lpfc_hba *phba, char *pbuffer, int len)
{
uint16_t ext_cnt = 0, ext_size = 0;
len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, "\nAvailable Extents Information:\n");
len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, "\tPort Available VPI extents: ");
lpfc_sli4_get_avail_extnt_rsrc(phba, LPFC_RSC_TYPE_FCOE_VPI,
&ext_cnt, &ext_size);
len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, "Count %3d, Size %3d\n", ext_cnt, ext_size);
len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, "\tPort Available VFI extents: ");
lpfc_sli4_get_avail_extnt_rsrc(phba, LPFC_RSC_TYPE_FCOE_VFI,
&ext_cnt, &ext_size);
len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, "Count %3d, Size %3d\n", ext_cnt, ext_size);
len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, "\tPort Available RPI extents: ");
lpfc_sli4_get_avail_extnt_rsrc(phba, LPFC_RSC_TYPE_FCOE_RPI,
&ext_cnt, &ext_size);
len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, "Count %3d, Size %3d\n", ext_cnt, ext_size);
len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, "\tPort Available XRI extents: ");
lpfc_sli4_get_avail_extnt_rsrc(phba, LPFC_RSC_TYPE_FCOE_XRI,
&ext_cnt, &ext_size);
len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, "Count %3d, Size %3d\n", ext_cnt, ext_size);
return len;
}
/** * lpfc_idiag_extacc_alloc_get - get the allocated extents information * @phba: pointer to lpfc hba data structure. * @pbuffer: pointer to internal buffer. * @len: length into the internal buffer data has been copied. * * Description: * This routine is to get the allocated extent information. * * Returns: * overall length of the data read into the internal buffer.
**/ staticint
lpfc_idiag_extacc_alloc_get(struct lpfc_hba *phba, char *pbuffer, int len)
{
uint16_t ext_cnt, ext_size; int rc;
len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, "\nAllocated Extents Information:\n");
len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, "\tHost Allocated VPI extents: ");
rc = lpfc_sli4_get_allocated_extnts(phba, LPFC_RSC_TYPE_FCOE_VPI,
&ext_cnt, &ext_size); if (!rc)
len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, "Port %d Extent %3d, Size %3d\n",
phba->brd_no, ext_cnt, ext_size); else
len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, "N/A\n");
len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, "\tHost Allocated VFI extents: ");
rc = lpfc_sli4_get_allocated_extnts(phba, LPFC_RSC_TYPE_FCOE_VFI,
&ext_cnt, &ext_size); if (!rc)
len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, "Port %d Extent %3d, Size %3d\n",
phba->brd_no, ext_cnt, ext_size); else
len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, "N/A\n");
len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, "\tHost Allocated RPI extents: ");
rc = lpfc_sli4_get_allocated_extnts(phba, LPFC_RSC_TYPE_FCOE_RPI,
&ext_cnt, &ext_size); if (!rc)
len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, "Port %d Extent %3d, Size %3d\n",
phba->brd_no, ext_cnt, ext_size); else
len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, "N/A\n");
len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, "\tHost Allocated XRI extents: ");
rc = lpfc_sli4_get_allocated_extnts(phba, LPFC_RSC_TYPE_FCOE_XRI,
&ext_cnt, &ext_size); if (!rc)
len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, "Port %d Extent %3d, Size %3d\n",
phba->brd_no, ext_cnt, ext_size); else
len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, "N/A\n");
return len;
}
/** * lpfc_idiag_extacc_drivr_get - get driver extent information * @phba: pointer to lpfc hba data structure. * @pbuffer: pointer to internal buffer. * @len: length into the internal buffer data has been copied. * * Description: * This routine is to get the driver extent information. * * Returns: * overall length of the data read into the internal buffer.
**/ staticint
lpfc_idiag_extacc_drivr_get(struct lpfc_hba *phba, char *pbuffer, int len)
{ struct lpfc_rsrc_blks *rsrc_blks; int index;
len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, "\nDriver Extents Information:\n");
len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, "\tVPI extents:\n");
index = 0;
list_for_each_entry(rsrc_blks, &phba->lpfc_vpi_blk_list, list) {
len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, "\t\tBlock %3d: Start %4d, Count %4d\n",
index, rsrc_blks->rsrc_start,
rsrc_blks->rsrc_size);
index++;
}
len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, "\tVFI extents:\n");
index = 0;
list_for_each_entry(rsrc_blks, &phba->sli4_hba.lpfc_vfi_blk_list,
list) {
len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, "\t\tBlock %3d: Start %4d, Count %4d\n",
index, rsrc_blks->rsrc_start,
rsrc_blks->rsrc_size);
index++;
}
len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, "\tRPI extents:\n");
index = 0;
list_for_each_entry(rsrc_blks, &phba->sli4_hba.lpfc_rpi_blk_list,
list) {
len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, "\t\tBlock %3d: Start %4d, Count %4d\n",
index, rsrc_blks->rsrc_start,
rsrc_blks->rsrc_size);
index++;
}
len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, "\tXRI extents:\n");
index = 0;
list_for_each_entry(rsrc_blks, &phba->sli4_hba.lpfc_xri_blk_list,
list) {
len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, "\t\tBlock %3d: Start %4d, Count %4d\n",
index, rsrc_blks->rsrc_start,
rsrc_blks->rsrc_size);
index++;
}
return len;
}
/** * lpfc_idiag_extacc_write - Syntax check and set up idiag extacc commands * @file: The file pointer to read from. * @buf: The buffer to copy the user data from. * @nbytes: The number of bytes to get. * @ppos: The position in the file to start reading from. * * This routine get the debugfs idiag command struct from user space and then * perform the syntax check for extent information access commands and sets * up the necessary states in the idiag command struct accordingly. * * It returns the @nbytges passing in from debugfs user space when successful. * In case of error conditions, it returns proper error code back to the user * space.
**/ static ssize_t
lpfc_idiag_extacc_write(struct file *file, constchar __user *buf,
size_t nbytes, loff_t *ppos)
{ struct lpfc_debug *debug = file->private_data;
uint32_t ext_map; int rc;
/* This is a user write operation */
debug->op = LPFC_IDIAG_OP_WR;
if (idiag.cmd.opcode != LPFC_IDIAG_CMD_EXTACC_RD) goto error_out; if (rc != LPFC_EXT_ACC_CMD_ARG) goto error_out; if (!(ext_map & LPFC_EXT_ACC_ALL)) goto error_out;
return nbytes;
error_out: /* Clean out command structure on command error out */
memset(&idiag, 0, sizeof(idiag)); return -EINVAL;
}
/** * lpfc_idiag_extacc_read - idiag debugfs read access to extent information * @file: The file pointer to read from. * @buf: The buffer to copy the data to. * @nbytes: The number of bytes to read. * @ppos: The position in the file to start reading from. * * Description: * This routine reads data from the proper extent information according to * the idiag command, and copies to user @buf. * * Returns: * This function returns the amount of data that was read (this could be less * than @nbytes if the end of the file was reached) or a negative error value.
**/ static ssize_t
lpfc_idiag_extacc_read(struct file *file, char __user *buf, size_t nbytes,
loff_t *ppos)
{ struct lpfc_debug *debug = file->private_data; struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private; char *pbuffer;
uint32_t ext_map; int len = 0;
/* This is a user read operation */
debug->op = LPFC_IDIAG_OP_RD;
if (!debug->buffer)
debug->buffer = kmalloc(LPFC_EXT_ACC_BUF_SIZE, GFP_KERNEL); if (!debug->buffer) return 0;
pbuffer = debug->buffer; if (*ppos) return 0; if (idiag.cmd.opcode != LPFC_IDIAG_CMD_EXTACC_RD) return 0;
ext_map = idiag.cmd.data[IDIAG_EXTACC_EXMAP_INDX]; if (ext_map & LPFC_EXT_ACC_AVAIL)
len = lpfc_idiag_extacc_avail_get(phba, pbuffer, len); if (ext_map & LPFC_EXT_ACC_ALLOC)
len = lpfc_idiag_extacc_alloc_get(phba, pbuffer, len); if (ext_map & LPFC_EXT_ACC_DRIVR)
len = lpfc_idiag_extacc_drivr_get(phba, pbuffer, len);
if ((*mbx_mbox_cmd != LPFC_MBX_ALL_CMD) &&
(*mbx_mbox_cmd != pmbox->mbxCommand)) return;
/* dump buffer content */ if (*mbx_dump_map & LPFC_MBX_DMP_MBX_WORD) {
pr_err("Mailbox command:0x%x dump by word:\n",
pmbox->mbxCommand);
pword = (uint32_t *)pmbox; for (i = 0; i < *mbx_word_cnt; i++) { if (!(i % 8)) { if (i != 0)
pr_err("%s\n", line_buf);
len = 0;
memset(line_buf, 0, LPFC_MBX_ACC_LBUF_SZ);
len += scnprintf(line_buf+len,
LPFC_MBX_ACC_LBUF_SZ-len, "%03d: ", i);
}
len += scnprintf(line_buf+len, LPFC_MBX_ACC_LBUF_SZ-len, "%08x ",
((uint32_t)*pword) & 0xffffffff);
pword++;
} if ((i - 1) % 8)
pr_err("%s\n", line_buf);
pr_err("\n");
} if (*mbx_dump_map & LPFC_MBX_DMP_MBX_BYTE) {
pr_err("Mailbox command:0x%x dump by byte:\n",
pmbox->mbxCommand);
pbyte = (uint8_t *)pmbox; for (i = 0; i < *mbx_word_cnt; i++) { if (!(i % 8)) { if (i != 0)
pr_err("%s\n", line_buf);
len = 0;
memset(line_buf, 0, LPFC_MBX_ACC_LBUF_SZ);
len += scnprintf(line_buf+len,
LPFC_MBX_ACC_LBUF_SZ-len, "%03d: ", i);
} for (j = 0; j < 4; j++) {
len += scnprintf(line_buf+len,
LPFC_MBX_ACC_LBUF_SZ-len, "%02x",
((uint8_t)*pbyte) & 0xff);
pbyte++;
}
len += scnprintf(line_buf+len,
LPFC_MBX_ACC_LBUF_SZ-len, " ");
} if ((i - 1) % 8)
pr_err("%s\n", line_buf);
pr_err("\n");
}
(*mbx_dump_cnt)--;
/* Clean out command structure on reaching dump count */ if (*mbx_dump_cnt == 0)
memset(&idiag, 0, sizeof(idiag)); return; #endif
}
/** * lpfc_debugfs_initialize - Initialize debugfs for a vport * @vport: The vport pointer to initialize. * * Description: * When Debugfs is configured this routine sets up the lpfc debugfs file system. * If not already created, this routine will create the lpfc directory, and * lpfcX directory (for this HBA), and vportX directory for this vport. It will * also create each file used to access lpfc specific debugfs information.
**/ inlinevoid
lpfc_debugfs_initialize(struct lpfc_vport *vport)
{ #ifdef CONFIG_SCSI_LPFC_DEBUG_FS struct lpfc_hba *phba = vport->phba; char name[64];
uint32_t num, i; bool pport_setup = false;
/* Setup slow ring trace */ if (lpfc_debugfs_max_slow_ring_trc) {
num = lpfc_debugfs_max_slow_ring_trc - 1; if (num & lpfc_debugfs_max_slow_ring_trc) { /* Change to be a power of 2 */
num = lpfc_debugfs_max_slow_ring_trc;
i = 0; while (num > 1) {
num = num >> 1;
i++;
}
lpfc_debugfs_max_slow_ring_trc = (1 << i);
pr_info("lpfc_debugfs_max_slow_ring_trc " "changed to %d\n",
lpfc_debugfs_max_slow_ring_trc);
}
}
atomic_set(&phba->nvmeio_trc_cnt, 0); if (lpfc_debugfs_max_nvmeio_trc) {
num = lpfc_debugfs_max_nvmeio_trc - 1; if (num & lpfc_debugfs_max_nvmeio_trc) { /* Change to be a power of 2 */
num = lpfc_debugfs_max_nvmeio_trc;
i = 0; while (num > 1) {
num = num >> 1;
i++;
}
lpfc_debugfs_max_nvmeio_trc = (1 << i);
pr_info("lpfc_debugfs_max_nvmeio_trc changed " "to %d\n",
lpfc_debugfs_max_nvmeio_trc);
}
phba->nvmeio_trc_size = lpfc_debugfs_max_nvmeio_trc;
if (lpfc_debugfs_max_disc_trc) {
num = lpfc_debugfs_max_disc_trc - 1; if (num & lpfc_debugfs_max_disc_trc) { /* Change to be a power of 2 */
num = lpfc_debugfs_max_disc_trc;
i = 0; while (num > 1) {
num = num >> 1;
i++;
}
lpfc_debugfs_max_disc_trc = (1 << i);
pr_info("lpfc_debugfs_max_disc_trc changed to %d\n",
lpfc_debugfs_max_disc_trc);
}
}
/** * lpfc_debugfs_terminate - Tear down debugfs infrastructure for this vport * @vport: The vport pointer to remove from debugfs. * * Description: * When Debugfs is configured this routine removes debugfs file system elements * that are specific to this vport. It also checks to see if there are any * users left for the debugfs directories associated with the HBA and driver. If * this is the last user of the HBA directory or driver directory then it will * remove those from the debugfs infrastructure as well.
**/ inlinevoid
lpfc_debugfs_terminate(struct lpfc_vport *vport)
{ #ifdef CONFIG_SCSI_LPFC_DEBUG_FS struct lpfc_hba *phba = vport->phba;
/* * Driver debug utility routines outside of debugfs. The debug utility * routines implemented here is intended to be used in the instrumented * debug driver for debugging host or port issues.
*/
/** * lpfc_debug_dump_all_queues - dump all the queues with a hba * @phba: Pointer to HBA context object. * * This function dumps entries of all the queues asociated with the @phba.
**/ void
lpfc_debug_dump_all_queues(struct lpfc_hba *phba)
{ int idx;
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.121Bemerkung:
(vorverarbeitet am 2026-04-29)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.