Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    1) /*******************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    2)  * This file is part of the Emulex Linux Device Driver for         *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    3)  * Fibre Channel Host Bus Adapters.                                *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    4)  * Copyright (C) 2017-2019 Broadcom. All Rights Reserved. The term *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    5)  * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries.  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    6)  * Copyright (C) 2007-2015 Emulex.  All rights reserved.           *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    7)  * EMULEX and SLI are trademarks of Emulex.                        *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    8)  * www.broadcom.com                                                *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    9)  *                                                                 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   10)  * This program is free software; you can redistribute it and/or   *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   11)  * modify it under the terms of version 2 of the GNU General       *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   12)  * Public License as published by the Free Software Foundation.    *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   13)  * This program is distributed in the hope that it will be useful. *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   14)  * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND          *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   15)  * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   16)  * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE      *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   17)  * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   18)  * TO BE LEGALLY INVALID.  See the GNU General Public License for  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   19)  * more details, a copy of which can be found in the file COPYING  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   20)  * included with this package.                                     *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   21)  *******************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   23) #include <linux/blkdev.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   24) #include <linux/delay.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   25) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   26) #include <linux/dma-mapping.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   27) #include <linux/idr.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   28) #include <linux/interrupt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   29) #include <linux/kthread.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   30) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   31) #include <linux/pci.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   32) #include <linux/spinlock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   33) #include <linux/ctype.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   34) #include <linux/vmalloc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   35) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   36) #include <scsi/scsi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   37) #include <scsi/scsi_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   38) #include <scsi/scsi_host.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   39) #include <scsi/scsi_transport_fc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   40) #include <scsi/fc/fc_fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   42) #include "lpfc_hw4.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   43) #include "lpfc_hw.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   44) #include "lpfc_sli.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   45) #include "lpfc_sli4.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   46) #include "lpfc_nl.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   47) #include "lpfc_disc.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   48) #include "lpfc.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   49) #include "lpfc_scsi.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   50) #include "lpfc_nvme.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   51) #include "lpfc_logmsg.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   52) #include "lpfc_crtn.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   53) #include "lpfc_vport.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   54) #include "lpfc_version.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   55) #include "lpfc_compat.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   56) #include "lpfc_debugfs.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   57) #include "lpfc_bsg.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   59) #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   60) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   61)  * debugfs interface
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   62)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   63)  * To access this interface the user should:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   64)  * # mount -t debugfs none /sys/kernel/debug
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   65)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   66)  * The lpfc debugfs directory hierarchy is:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   67)  * /sys/kernel/debug/lpfc/fnX/vportY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   68)  * where X is the lpfc hba function unique_id
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   69)  * where Y is the vport VPI on that hba
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   70)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   71)  * Debugging services available per vport:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   72)  * discovery_trace
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   73)  * This is an ACSII readable file that contains a trace of the last
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   74)  * lpfc_debugfs_max_disc_trc events that happened on a specific vport.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   75)  * See lpfc_debugfs.h for different categories of  discovery events.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   76)  * To enable the discovery trace, the following module parameters must be set:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   77)  * lpfc_debugfs_enable=1         Turns on lpfc debugfs filesystem support
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   78)  * lpfc_debugfs_max_disc_trc=X   Where X is the event trace depth for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   79)  *                               EACH vport. X MUST also be a power of 2.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   80)  * lpfc_debugfs_mask_disc_trc=Y  Where Y is an event mask as defined in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   81)  *                               lpfc_debugfs.h .
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   82)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   83)  * slow_ring_trace
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   84)  * This is an ACSII readable file that contains a trace of the last
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   85)  * lpfc_debugfs_max_slow_ring_trc events that happened on a specific HBA.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   86)  * To enable the slow ring trace, the following module parameters must be set:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   87)  * lpfc_debugfs_enable=1         Turns on lpfc debugfs filesystem support
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   88)  * lpfc_debugfs_max_slow_ring_trc=X   Where X is the event trace depth for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   89)  *                               the HBA. X MUST also be a power of 2.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   90)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   91) static int lpfc_debugfs_enable = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   92) module_param(lpfc_debugfs_enable, int, S_IRUGO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   93) MODULE_PARM_DESC(lpfc_debugfs_enable, "Enable debugfs services");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   94) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   95) /* This MUST be a power of 2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   96) static int lpfc_debugfs_max_disc_trc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   97) module_param(lpfc_debugfs_max_disc_trc, int, S_IRUGO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   98) MODULE_PARM_DESC(lpfc_debugfs_max_disc_trc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   99) 	"Set debugfs discovery trace depth");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  100) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  101) /* This MUST be a power of 2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  102) static int lpfc_debugfs_max_slow_ring_trc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  103) module_param(lpfc_debugfs_max_slow_ring_trc, int, S_IRUGO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  104) MODULE_PARM_DESC(lpfc_debugfs_max_slow_ring_trc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  105) 	"Set debugfs slow ring trace depth");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  106) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  107) /* This MUST be a power of 2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  108) static int lpfc_debugfs_max_nvmeio_trc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  109) module_param(lpfc_debugfs_max_nvmeio_trc, int, 0444);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  110) MODULE_PARM_DESC(lpfc_debugfs_max_nvmeio_trc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  111) 		 "Set debugfs NVME IO trace depth");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  112) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  113) static int lpfc_debugfs_mask_disc_trc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  114) module_param(lpfc_debugfs_mask_disc_trc, int, S_IRUGO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  115) MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  116) 	"Set debugfs discovery trace mask");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  117) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  118) #include <linux/debugfs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  119) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  120) static atomic_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  121) static unsigned long lpfc_debugfs_start_time = 0L;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  122) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  123) /* iDiag */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  124) static struct lpfc_idiag idiag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  125) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  126) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  127)  * lpfc_debugfs_disc_trc_data - Dump discovery logging to a buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  128)  * @vport: The vport to gather the log info from.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  129)  * @buf: The buffer to dump log into.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  130)  * @size: The maximum amount of data to process.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  131)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  132)  * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  133)  * This routine gathers the lpfc discovery debugfs data from the @vport and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  134)  * dumps it to @buf up to @size number of bytes. It will start at the next entry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  135)  * in the log and process the log until the end of the buffer. Then it will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  136)  * gather from the beginning of the log and process until the current entry.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  137)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  138)  * Notes:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  139)  * Discovery logging will be disabled while while this routine dumps the log.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  140)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  141)  * Return Value:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  142)  * This routine returns the amount of bytes that were dumped into @buf and will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  143)  * not exceed @size.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  144)  **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  145) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  146) lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  147) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  148) 	int i, index, len, enable;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  149) 	uint32_t ms;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  150) 	struct lpfc_debugfs_trc *dtp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  151) 	char *buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  152) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  153) 	buffer = kmalloc(LPFC_DEBUG_TRC_ENTRY_SIZE, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  154) 	if (!buffer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  155) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  156) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  157) 	enable = lpfc_debugfs_enable;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  158) 	lpfc_debugfs_enable = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  159) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  160) 	len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  161) 	index = (atomic_read(&vport->disc_trc_cnt) + 1) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  162) 		(lpfc_debugfs_max_disc_trc - 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  163) 	for (i = index; i < lpfc_debugfs_max_disc_trc; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  164) 		dtp = vport->disc_trc + i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  165) 		if (!dtp->fmt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  166) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  167) 		ms = jiffies_to_msecs(dtp->jif - lpfc_debugfs_start_time);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  168) 		snprintf(buffer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  169) 			LPFC_DEBUG_TRC_ENTRY_SIZE, "%010d:%010d ms:%s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  170) 			dtp->seq_cnt, ms, dtp->fmt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  171) 		len +=  scnprintf(buf+len, size-len, buffer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  172) 			dtp->data1, dtp->data2, dtp->data3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  173) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  174) 	for (i = 0; i < index; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  175) 		dtp = vport->disc_trc + i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  176) 		if (!dtp->fmt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  177) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  178) 		ms = jiffies_to_msecs(dtp->jif - lpfc_debugfs_start_time);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  179) 		snprintf(buffer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  180) 			LPFC_DEBUG_TRC_ENTRY_SIZE, "%010d:%010d ms:%s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  181) 			dtp->seq_cnt, ms, dtp->fmt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  182) 		len +=  scnprintf(buf+len, size-len, buffer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  183) 			dtp->data1, dtp->data2, dtp->data3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  184) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  185) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  186) 	lpfc_debugfs_enable = enable;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  187) 	kfree(buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  188) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  189) 	return len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  190) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  191) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  192) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  193)  * lpfc_debugfs_slow_ring_trc_data - Dump slow ring logging to a buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  194)  * @phba: The HBA to gather the log info from.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  195)  * @buf: The buffer to dump log into.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  196)  * @size: The maximum amount of data to process.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  197)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  198)  * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  199)  * This routine gathers the lpfc slow ring debugfs data from the @phba and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  200)  * dumps it to @buf up to @size number of bytes. It will start at the next entry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  201)  * in the log and process the log until the end of the buffer. Then it will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  202)  * gather from the beginning of the log and process until the current entry.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  203)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  204)  * Notes:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  205)  * Slow ring logging will be disabled while while this routine dumps the log.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  206)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  207)  * Return Value:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  208)  * This routine returns the amount of bytes that were dumped into @buf and will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  209)  * not exceed @size.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  210)  **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  211) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  212) lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba *phba, char *buf, int size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  213) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  214) 	int i, index, len, enable;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  215) 	uint32_t ms;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  216) 	struct lpfc_debugfs_trc *dtp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  217) 	char *buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  218) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  219) 	buffer = kmalloc(LPFC_DEBUG_TRC_ENTRY_SIZE, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  220) 	if (!buffer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  221) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  222) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  223) 	enable = lpfc_debugfs_enable;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  224) 	lpfc_debugfs_enable = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  225) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  226) 	len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  227) 	index = (atomic_read(&phba->slow_ring_trc_cnt) + 1) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  228) 		(lpfc_debugfs_max_slow_ring_trc - 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  229) 	for (i = index; i < lpfc_debugfs_max_slow_ring_trc; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  230) 		dtp = phba->slow_ring_trc + i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  231) 		if (!dtp->fmt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  232) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  233) 		ms = jiffies_to_msecs(dtp->jif - lpfc_debugfs_start_time);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  234) 		snprintf(buffer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  235) 			LPFC_DEBUG_TRC_ENTRY_SIZE, "%010d:%010d ms:%s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  236) 			dtp->seq_cnt, ms, dtp->fmt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  237) 		len +=  scnprintf(buf+len, size-len, buffer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  238) 			dtp->data1, dtp->data2, dtp->data3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  239) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  240) 	for (i = 0; i < index; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  241) 		dtp = phba->slow_ring_trc + i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  242) 		if (!dtp->fmt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  243) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  244) 		ms = jiffies_to_msecs(dtp->jif - lpfc_debugfs_start_time);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  245) 		snprintf(buffer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  246) 			LPFC_DEBUG_TRC_ENTRY_SIZE, "%010d:%010d ms:%s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  247) 			dtp->seq_cnt, ms, dtp->fmt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  248) 		len +=  scnprintf(buf+len, size-len, buffer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  249) 			dtp->data1, dtp->data2, dtp->data3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  250) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  251) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  252) 	lpfc_debugfs_enable = enable;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  253) 	kfree(buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  254) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  255) 	return len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  256) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  257) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  258) static int lpfc_debugfs_last_hbq = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  259) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  260) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  261)  * lpfc_debugfs_hbqinfo_data - Dump host buffer queue info to a buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  262)  * @phba: The HBA to gather host buffer info from.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  263)  * @buf: The buffer to dump log into.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  264)  * @size: The maximum amount of data to process.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  265)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  266)  * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  267)  * This routine dumps the host buffer queue info from the @phba to @buf up to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  268)  * @size number of bytes. A header that describes the current hbq state will be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  269)  * dumped to @buf first and then info on each hbq entry will be dumped to @buf
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  270)  * until @size bytes have been dumped or all the hbq info has been dumped.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  271)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  272)  * Notes:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  273)  * This routine will rotate through each configured HBQ each time called.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  274)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  275)  * Return Value:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  276)  * This routine returns the amount of bytes that were dumped into @buf and will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  277)  * not exceed @size.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  278)  **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  279) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  280) lpfc_debugfs_hbqinfo_data(struct lpfc_hba *phba, char *buf, int size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  281) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  282) 	int len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  283) 	int i, j, found, posted, low;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  284) 	uint32_t phys, raw_index, getidx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  285) 	struct lpfc_hbq_init *hip;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  286) 	struct hbq_s *hbqs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  287) 	struct lpfc_hbq_entry *hbqe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  288) 	struct lpfc_dmabuf *d_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  289) 	struct hbq_dmabuf *hbq_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  290) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  291) 	if (phba->sli_rev != 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  292) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  293) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  294) 	spin_lock_irq(&phba->hbalock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  295) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  296) 	/* toggle between multiple hbqs, if any */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  297) 	i = lpfc_sli_hbq_count();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  298) 	if (i > 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  299) 		 lpfc_debugfs_last_hbq++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  300) 		 if (lpfc_debugfs_last_hbq >= i)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  301) 			lpfc_debugfs_last_hbq = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  302) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  303) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  304) 		lpfc_debugfs_last_hbq = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  305) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  306) 	i = lpfc_debugfs_last_hbq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  307) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  308) 	len +=  scnprintf(buf+len, size-len, "HBQ %d Info\n", i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  309) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  310) 	hbqs =  &phba->hbqs[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  311) 	posted = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  312) 	list_for_each_entry(d_buf, &hbqs->hbq_buffer_list, list)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  313) 		posted++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  314) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  315) 	hip =  lpfc_hbq_defs[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  316) 	len +=  scnprintf(buf+len, size-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  317) 		"idx:%d prof:%d rn:%d bufcnt:%d icnt:%d acnt:%d posted %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  318) 		hip->hbq_index, hip->profile, hip->rn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  319) 		hip->buffer_count, hip->init_count, hip->add_count, posted);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  320) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  321) 	raw_index = phba->hbq_get[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  322) 	getidx = le32_to_cpu(raw_index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  323) 	len +=  scnprintf(buf+len, size-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  324) 		"entries:%d bufcnt:%d Put:%d nPut:%d localGet:%d hbaGet:%d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  325) 		hbqs->entry_count, hbqs->buffer_count, hbqs->hbqPutIdx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  326) 		hbqs->next_hbqPutIdx, hbqs->local_hbqGetIdx, getidx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  327) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  328) 	hbqe = (struct lpfc_hbq_entry *) phba->hbqs[i].hbq_virt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  329) 	for (j=0; j<hbqs->entry_count; j++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  330) 		len +=  scnprintf(buf+len, size-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  331) 			"%03d: %08x %04x %05x ", j,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  332) 			le32_to_cpu(hbqe->bde.addrLow),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  333) 			le32_to_cpu(hbqe->bde.tus.w),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  334) 			le32_to_cpu(hbqe->buffer_tag));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  335) 		i = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  336) 		found = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  337) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  338) 		/* First calculate if slot has an associated posted buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  339) 		low = hbqs->hbqPutIdx - posted;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  340) 		if (low >= 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  341) 			if ((j >= hbqs->hbqPutIdx) || (j < low)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  342) 				len +=  scnprintf(buf + len, size - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  343) 						"Unused\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  344) 				goto skipit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  345) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  346) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  347) 		else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  348) 			if ((j >= hbqs->hbqPutIdx) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  349) 				(j < (hbqs->entry_count+low))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  350) 				len +=  scnprintf(buf + len, size - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  351) 						"Unused\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  352) 				goto skipit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  353) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  354) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  355) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  356) 		/* Get the Buffer info for the posted buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  357) 		list_for_each_entry(d_buf, &hbqs->hbq_buffer_list, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  358) 			hbq_buf = container_of(d_buf, struct hbq_dmabuf, dbuf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  359) 			phys = ((uint64_t)hbq_buf->dbuf.phys & 0xffffffff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  360) 			if (phys == le32_to_cpu(hbqe->bde.addrLow)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  361) 				len +=  scnprintf(buf+len, size-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  362) 					"Buf%d: x%px %06x\n", i,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  363) 					hbq_buf->dbuf.virt, hbq_buf->tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  364) 				found = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  365) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  366) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  367) 			i++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  368) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  369) 		if (!found) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  370) 			len +=  scnprintf(buf+len, size-len, "No DMAinfo?\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  371) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  372) skipit:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  373) 		hbqe++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  374) 		if (len > LPFC_HBQINFO_SIZE - 54)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  375) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  376) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  377) 	spin_unlock_irq(&phba->hbalock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  378) 	return len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  379) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  380) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  381) static int lpfc_debugfs_last_xripool;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  382) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  383) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  384)  * lpfc_debugfs_common_xri_data - Dump Hardware Queue info to a buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  385)  * @phba: The HBA to gather host buffer info from.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  386)  * @buf: The buffer to dump log into.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  387)  * @size: The maximum amount of data to process.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  388)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  389)  * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  390)  * This routine dumps the Hardware Queue info from the @phba to @buf up to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  391)  * @size number of bytes. A header that describes the current hdwq state will be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  392)  * dumped to @buf first and then info on each hdwq entry will be dumped to @buf
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  393)  * until @size bytes have been dumped or all the hdwq info has been dumped.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  394)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  395)  * Notes:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  396)  * This routine will rotate through each configured Hardware Queue each
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  397)  * time called.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  398)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  399)  * Return Value:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  400)  * This routine returns the amount of bytes that were dumped into @buf and will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  401)  * not exceed @size.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  402)  **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  403) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  404) lpfc_debugfs_commonxripools_data(struct lpfc_hba *phba, char *buf, int size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  405) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  406) 	struct lpfc_sli4_hdw_queue *qp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  407) 	int len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  408) 	int i, out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  409) 	unsigned long iflag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  410) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  411) 	for (i = 0; i < phba->cfg_hdw_queue; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  412) 		if (len > (LPFC_DUMP_MULTIXRIPOOL_SIZE - 80))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  413) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  414) 		qp = &phba->sli4_hba.hdwq[lpfc_debugfs_last_xripool];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  415) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  416) 		len += scnprintf(buf + len, size - len, "HdwQ %d Info ", i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  417) 		spin_lock_irqsave(&qp->abts_io_buf_list_lock, iflag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  418) 		spin_lock(&qp->io_buf_list_get_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  419) 		spin_lock(&qp->io_buf_list_put_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  420) 		out = qp->total_io_bufs - (qp->get_io_bufs + qp->put_io_bufs +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  421) 			qp->abts_scsi_io_bufs + qp->abts_nvme_io_bufs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  422) 		len += scnprintf(buf + len, size - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  423) 				 "tot:%d get:%d put:%d mt:%d "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  424) 				 "ABTS scsi:%d nvme:%d Out:%d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  425) 			qp->total_io_bufs, qp->get_io_bufs, qp->put_io_bufs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  426) 			qp->empty_io_bufs, qp->abts_scsi_io_bufs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  427) 			qp->abts_nvme_io_bufs, out);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  428) 		spin_unlock(&qp->io_buf_list_put_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  429) 		spin_unlock(&qp->io_buf_list_get_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  430) 		spin_unlock_irqrestore(&qp->abts_io_buf_list_lock, iflag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  431) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  432) 		lpfc_debugfs_last_xripool++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  433) 		if (lpfc_debugfs_last_xripool >= phba->cfg_hdw_queue)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  434) 			lpfc_debugfs_last_xripool = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  435) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  436) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  437) 	return len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  438) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  439) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  440) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  441)  * lpfc_debugfs_multixripools_data - Display multi-XRI pools information
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  442)  * @phba: The HBA to gather host buffer info from.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  443)  * @buf: The buffer to dump log into.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  444)  * @size: The maximum amount of data to process.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  445)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  446)  * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  447)  * This routine displays current multi-XRI pools information including XRI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  448)  * count in public, private and txcmplq. It also displays current high and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  449)  * low watermark.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  450)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  451)  * Return Value:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  452)  * This routine returns the amount of bytes that were dumped into @buf and will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  453)  * not exceed @size.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  454)  **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  455) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  456) lpfc_debugfs_multixripools_data(struct lpfc_hba *phba, char *buf, int size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  457) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  458) 	u32 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  459) 	u32 hwq_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  460) 	struct lpfc_sli4_hdw_queue *qp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  461) 	struct lpfc_multixri_pool *multixri_pool;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  462) 	struct lpfc_pvt_pool *pvt_pool;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  463) 	struct lpfc_pbl_pool *pbl_pool;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  464) 	u32 txcmplq_cnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  465) 	char tmp[LPFC_DEBUG_OUT_LINE_SZ] = {0};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  466) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  467) 	if (phba->sli_rev != LPFC_SLI_REV4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  468) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  469) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  470) 	if (!phba->sli4_hba.hdwq)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  471) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  472) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  473) 	if (!phba->cfg_xri_rebalancing) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  474) 		i = lpfc_debugfs_commonxripools_data(phba, buf, size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  475) 		return i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  476) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  477) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  478) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  479) 	 * Pbl: Current number of free XRIs in public pool
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  480) 	 * Pvt: Current number of free XRIs in private pool
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  481) 	 * Busy: Current number of outstanding XRIs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  482) 	 * HWM: Current high watermark
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  483) 	 * pvt_empty: Incremented by 1 when IO submission fails (no xri)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  484) 	 * pbl_empty: Incremented by 1 when all pbl_pool are empty during
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  485) 	 *            IO submission
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  486) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  487) 	scnprintf(tmp, sizeof(tmp),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  488) 		  "HWQ:  Pbl  Pvt Busy  HWM |  pvt_empty  pbl_empty ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  489) 	if (strlcat(buf, tmp, size) >= size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  490) 		return strnlen(buf, size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  491) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  492) #ifdef LPFC_MXP_STAT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  493) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  494) 	 * MAXH: Max high watermark seen so far
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  495) 	 * above_lmt: Incremented by 1 if xri_owned > xri_limit during
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  496) 	 *            IO submission
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  497) 	 * below_lmt: Incremented by 1 if xri_owned <= xri_limit  during
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  498) 	 *            IO submission
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  499) 	 * locPbl_hit: Incremented by 1 if successfully get a batch of XRI from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  500) 	 *             local pbl_pool
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  501) 	 * othPbl_hit: Incremented by 1 if successfully get a batch of XRI from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  502) 	 *             other pbl_pool
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  503) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  504) 	scnprintf(tmp, sizeof(tmp),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  505) 		  "MAXH  above_lmt  below_lmt locPbl_hit othPbl_hit");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  506) 	if (strlcat(buf, tmp, size) >= size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  507) 		return strnlen(buf, size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  508) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  509) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  510) 	 * sPbl: snapshot of Pbl 15 sec after stat gets cleared
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  511) 	 * sPvt: snapshot of Pvt 15 sec after stat gets cleared
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  512) 	 * sBusy: snapshot of Busy 15 sec after stat gets cleared
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  513) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  514) 	scnprintf(tmp, sizeof(tmp),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  515) 		  " | sPbl sPvt sBusy");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  516) 	if (strlcat(buf, tmp, size) >= size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  517) 		return strnlen(buf, size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  518) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  519) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  520) 	scnprintf(tmp, sizeof(tmp), "\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  521) 	if (strlcat(buf, tmp, size) >= size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  522) 		return strnlen(buf, size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  523) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  524) 	hwq_count = phba->cfg_hdw_queue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  525) 	for (i = 0; i < hwq_count; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  526) 		qp = &phba->sli4_hba.hdwq[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  527) 		multixri_pool = qp->p_multixri_pool;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  528) 		if (!multixri_pool)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  529) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  530) 		pbl_pool = &multixri_pool->pbl_pool;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  531) 		pvt_pool = &multixri_pool->pvt_pool;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  532) 		txcmplq_cnt = qp->io_wq->pring->txcmplq_cnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  533) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  534) 		scnprintf(tmp, sizeof(tmp),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  535) 			  "%03d: %4d %4d %4d %4d | %10d %10d ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  536) 			  i, pbl_pool->count, pvt_pool->count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  537) 			  txcmplq_cnt, pvt_pool->high_watermark,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  538) 			  qp->empty_io_bufs, multixri_pool->pbl_empty_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  539) 		if (strlcat(buf, tmp, size) >= size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  540) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  541) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  542) #ifdef LPFC_MXP_STAT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  543) 		scnprintf(tmp, sizeof(tmp),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  544) 			  "%4d %10d %10d %10d %10d",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  545) 			  multixri_pool->stat_max_hwm,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  546) 			  multixri_pool->above_limit_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  547) 			  multixri_pool->below_limit_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  548) 			  multixri_pool->local_pbl_hit_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  549) 			  multixri_pool->other_pbl_hit_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  550) 		if (strlcat(buf, tmp, size) >= size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  551) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  552) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  553) 		scnprintf(tmp, sizeof(tmp),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  554) 			  " | %4d %4d %5d",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  555) 			  multixri_pool->stat_pbl_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  556) 			  multixri_pool->stat_pvt_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  557) 			  multixri_pool->stat_busy_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  558) 		if (strlcat(buf, tmp, size) >= size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  559) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  560) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  561) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  562) 		scnprintf(tmp, sizeof(tmp), "\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  563) 		if (strlcat(buf, tmp, size) >= size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  564) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  565) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  566) 	return strnlen(buf, size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  567) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  568) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  569) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  570) #ifdef LPFC_HDWQ_LOCK_STAT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  571) static int lpfc_debugfs_last_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  572) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  573) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  574)  * lpfc_debugfs_lockstat_data - Dump Hardware Queue info to a buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  575)  * @phba: The HBA to gather host buffer info from.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  576)  * @buf: The buffer to dump log into.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  577)  * @size: The maximum amount of data to process.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  578)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  579)  * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  580)  * This routine dumps the Hardware Queue info from the @phba to @buf up to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  581)  * @size number of bytes. A header that describes the current hdwq state will be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  582)  * dumped to @buf first and then info on each hdwq entry will be dumped to @buf
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  583)  * until @size bytes have been dumped or all the hdwq info has been dumped.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  584)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  585)  * Notes:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  586)  * This routine will rotate through each configured Hardware Queue each
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  587)  * time called.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  588)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  589)  * Return Value:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  590)  * This routine returns the amount of bytes that were dumped into @buf and will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  591)  * not exceed @size.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  592)  **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  593) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  594) lpfc_debugfs_lockstat_data(struct lpfc_hba *phba, char *buf, int size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  595) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  596) 	struct lpfc_sli4_hdw_queue *qp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  597) 	int len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  598) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  599) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  600) 	if (phba->sli_rev != LPFC_SLI_REV4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  601) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  602) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  603) 	if (!phba->sli4_hba.hdwq)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  604) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  605) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  606) 	for (i = 0; i < phba->cfg_hdw_queue; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  607) 		if (len > (LPFC_HDWQINFO_SIZE - 100))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  608) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  609) 		qp = &phba->sli4_hba.hdwq[lpfc_debugfs_last_lock];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  610) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  611) 		len += scnprintf(buf + len, size - len, "HdwQ %03d Lock ", i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  612) 		if (phba->cfg_xri_rebalancing) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  613) 			len += scnprintf(buf + len, size - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  614) 					 "get_pvt:%d mv_pvt:%d "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  615) 					 "mv2pub:%d mv2pvt:%d "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  616) 					 "put_pvt:%d put_pub:%d wq:%d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  617) 					 qp->lock_conflict.alloc_pvt_pool,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  618) 					 qp->lock_conflict.mv_from_pvt_pool,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  619) 					 qp->lock_conflict.mv_to_pub_pool,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  620) 					 qp->lock_conflict.mv_to_pvt_pool,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  621) 					 qp->lock_conflict.free_pvt_pool,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  622) 					 qp->lock_conflict.free_pub_pool,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  623) 					 qp->lock_conflict.wq_access);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  624) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  625) 			len += scnprintf(buf + len, size - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  626) 					 "get:%d put:%d free:%d wq:%d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  627) 					 qp->lock_conflict.alloc_xri_get,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  628) 					 qp->lock_conflict.alloc_xri_put,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  629) 					 qp->lock_conflict.free_xri,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  630) 					 qp->lock_conflict.wq_access);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  631) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  632) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  633) 		lpfc_debugfs_last_lock++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  634) 		if (lpfc_debugfs_last_lock >= phba->cfg_hdw_queue)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  635) 			lpfc_debugfs_last_lock = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  636) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  637) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  638) 	return len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  639) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  640) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  641) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  642) static int lpfc_debugfs_last_hba_slim_off;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  643) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  644) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  645)  * lpfc_debugfs_dumpHBASlim_data - Dump HBA SLIM info to a buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  646)  * @phba: The HBA to gather SLIM info from.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  647)  * @buf: The buffer to dump log into.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  648)  * @size: The maximum amount of data to process.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  649)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  650)  * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  651)  * This routine dumps the current contents of HBA SLIM for the HBA associated
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  652)  * with @phba to @buf up to @size bytes of data. This is the raw HBA SLIM data.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  653)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  654)  * Notes:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  655)  * This routine will only dump up to 1024 bytes of data each time called and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  656)  * should be called multiple times to dump the entire HBA SLIM.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  657)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  658)  * Return Value:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  659)  * This routine returns the amount of bytes that were dumped into @buf and will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  660)  * not exceed @size.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  661)  **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  662) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  663) lpfc_debugfs_dumpHBASlim_data(struct lpfc_hba *phba, char *buf, int size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  664) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  665) 	int len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  666) 	int i, off;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  667) 	uint32_t *ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  668) 	char *buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  669) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  670) 	buffer = kmalloc(1024, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  671) 	if (!buffer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  672) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  673) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  674) 	off = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  675) 	spin_lock_irq(&phba->hbalock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  676) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  677) 	len +=  scnprintf(buf+len, size-len, "HBA SLIM\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  678) 	lpfc_memcpy_from_slim(buffer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  679) 		phba->MBslimaddr + lpfc_debugfs_last_hba_slim_off, 1024);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  680) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  681) 	ptr = (uint32_t *)&buffer[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  682) 	off = lpfc_debugfs_last_hba_slim_off;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  683) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  684) 	/* Set it up for the next time */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  685) 	lpfc_debugfs_last_hba_slim_off += 1024;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  686) 	if (lpfc_debugfs_last_hba_slim_off >= 4096)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  687) 		lpfc_debugfs_last_hba_slim_off = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  688) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  689) 	i = 1024;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  690) 	while (i > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  691) 		len +=  scnprintf(buf+len, size-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  692) 		"%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  693) 		off, *ptr, *(ptr+1), *(ptr+2), *(ptr+3), *(ptr+4),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  694) 		*(ptr+5), *(ptr+6), *(ptr+7));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  695) 		ptr += 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  696) 		i -= (8 * sizeof(uint32_t));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  697) 		off += (8 * sizeof(uint32_t));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  698) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  699) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  700) 	spin_unlock_irq(&phba->hbalock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  701) 	kfree(buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  702) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  703) 	return len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  704) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  705) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  706) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  707)  * lpfc_debugfs_dumpHostSlim_data - Dump host SLIM info to a buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  708)  * @phba: The HBA to gather Host SLIM info from.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  709)  * @buf: The buffer to dump log into.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  710)  * @size: The maximum amount of data to process.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  711)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  712)  * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  713)  * This routine dumps the current contents of host SLIM for the host associated
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  714)  * with @phba to @buf up to @size bytes of data. The dump will contain the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  715)  * Mailbox, PCB, Rings, and Registers that are located in host memory.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  716)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  717)  * Return Value:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  718)  * This routine returns the amount of bytes that were dumped into @buf and will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  719)  * not exceed @size.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  720)  **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  721) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  722) lpfc_debugfs_dumpHostSlim_data(struct lpfc_hba *phba, char *buf, int size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  723) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  724) 	int len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  725) 	int i, off;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  726) 	uint32_t word0, word1, word2, word3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  727) 	uint32_t *ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  728) 	struct lpfc_pgp *pgpp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  729) 	struct lpfc_sli *psli = &phba->sli;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  730) 	struct lpfc_sli_ring *pring;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  731) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  732) 	off = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  733) 	spin_lock_irq(&phba->hbalock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  734) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  735) 	len +=  scnprintf(buf+len, size-len, "SLIM Mailbox\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  736) 	ptr = (uint32_t *)phba->slim2p.virt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  737) 	i = sizeof(MAILBOX_t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  738) 	while (i > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  739) 		len +=  scnprintf(buf+len, size-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  740) 		"%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  741) 		off, *ptr, *(ptr+1), *(ptr+2), *(ptr+3), *(ptr+4),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  742) 		*(ptr+5), *(ptr+6), *(ptr+7));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  743) 		ptr += 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  744) 		i -= (8 * sizeof(uint32_t));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  745) 		off += (8 * sizeof(uint32_t));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  746) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  747) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  748) 	len +=  scnprintf(buf+len, size-len, "SLIM PCB\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  749) 	ptr = (uint32_t *)phba->pcb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  750) 	i = sizeof(PCB_t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  751) 	while (i > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  752) 		len +=  scnprintf(buf+len, size-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  753) 		"%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  754) 		off, *ptr, *(ptr+1), *(ptr+2), *(ptr+3), *(ptr+4),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  755) 		*(ptr+5), *(ptr+6), *(ptr+7));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  756) 		ptr += 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  757) 		i -= (8 * sizeof(uint32_t));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  758) 		off += (8 * sizeof(uint32_t));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  759) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  760) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  761) 	if (phba->sli_rev <= LPFC_SLI_REV3) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  762) 		for (i = 0; i < 4; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  763) 			pgpp = &phba->port_gp[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  764) 			pring = &psli->sli3_ring[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  765) 			len +=  scnprintf(buf+len, size-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  766) 					 "Ring %d: CMD GetInx:%d "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  767) 					 "(Max:%d Next:%d "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  768) 					 "Local:%d flg:x%x)  "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  769) 					 "RSP PutInx:%d Max:%d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  770) 					 i, pgpp->cmdGetInx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  771) 					 pring->sli.sli3.numCiocb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  772) 					 pring->sli.sli3.next_cmdidx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  773) 					 pring->sli.sli3.local_getidx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  774) 					 pring->flag, pgpp->rspPutInx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  775) 					 pring->sli.sli3.numRiocb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  776) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  777) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  778) 		word0 = readl(phba->HAregaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  779) 		word1 = readl(phba->CAregaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  780) 		word2 = readl(phba->HSregaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  781) 		word3 = readl(phba->HCregaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  782) 		len +=  scnprintf(buf+len, size-len, "HA:%08x CA:%08x HS:%08x "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  783) 				 "HC:%08x\n", word0, word1, word2, word3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  784) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  785) 	spin_unlock_irq(&phba->hbalock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  786) 	return len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  787) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  788) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  789) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  790)  * lpfc_debugfs_nodelist_data - Dump target node list to a buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  791)  * @vport: The vport to gather target node info from.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  792)  * @buf: The buffer to dump log into.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  793)  * @size: The maximum amount of data to process.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  794)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  795)  * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  796)  * This routine dumps the current target node list associated with @vport to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  797)  * @buf up to @size bytes of data. Each node entry in the dump will contain a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  798)  * node state, DID, WWPN, WWNN, RPI, flags, type, and other useful fields.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  799)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  800)  * Return Value:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  801)  * This routine returns the amount of bytes that were dumped into @buf and will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  802)  * not exceed @size.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  803)  **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  804) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  805) lpfc_debugfs_nodelist_data(struct lpfc_vport *vport, char *buf, int size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  806) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  807) 	int len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  808) 	int i, iocnt, outio, cnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  809) 	struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  810) 	struct lpfc_hba  *phba = vport->phba;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  811) 	struct lpfc_nodelist *ndlp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  812) 	unsigned char *statep;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  813) 	struct nvme_fc_local_port *localport;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  814) 	struct nvme_fc_remote_port *nrport = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  815) 	struct lpfc_nvme_rport *rport;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  816) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  817) 	cnt = (LPFC_NODELIST_SIZE / LPFC_NODELIST_ENTRY_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  818) 	outio = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  819) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  820) 	len += scnprintf(buf+len, size-len, "\nFCP Nodelist Entries ...\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  821) 	spin_lock_irq(shost->host_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  822) 	list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  823) 		iocnt = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  824) 		if (!cnt) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  825) 			len +=  scnprintf(buf+len, size-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  826) 				"Missing Nodelist Entries\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  827) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  828) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  829) 		cnt--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  830) 		switch (ndlp->nlp_state) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  831) 		case NLP_STE_UNUSED_NODE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  832) 			statep = "UNUSED";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  833) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  834) 		case NLP_STE_PLOGI_ISSUE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  835) 			statep = "PLOGI ";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  836) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  837) 		case NLP_STE_ADISC_ISSUE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  838) 			statep = "ADISC ";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  839) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  840) 		case NLP_STE_REG_LOGIN_ISSUE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  841) 			statep = "REGLOG";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  842) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  843) 		case NLP_STE_PRLI_ISSUE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  844) 			statep = "PRLI  ";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  845) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  846) 		case NLP_STE_LOGO_ISSUE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  847) 			statep = "LOGO  ";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  848) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  849) 		case NLP_STE_UNMAPPED_NODE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  850) 			statep = "UNMAP ";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  851) 			iocnt = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  852) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  853) 		case NLP_STE_MAPPED_NODE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  854) 			statep = "MAPPED";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  855) 			iocnt = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  856) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  857) 		case NLP_STE_NPR_NODE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  858) 			statep = "NPR   ";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  859) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  860) 		default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  861) 			statep = "UNKNOWN";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  862) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  863) 		len += scnprintf(buf+len, size-len, "%s DID:x%06x ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  864) 				statep, ndlp->nlp_DID);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  865) 		len += scnprintf(buf+len, size-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  866) 				"WWPN x%llx ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  867) 				wwn_to_u64(ndlp->nlp_portname.u.wwn));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  868) 		len += scnprintf(buf+len, size-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  869) 				"WWNN x%llx ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  870) 				wwn_to_u64(ndlp->nlp_nodename.u.wwn));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  871) 		if (ndlp->nlp_flag & NLP_RPI_REGISTERED)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  872) 			len += scnprintf(buf+len, size-len, "RPI:%03d ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  873) 					ndlp->nlp_rpi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  874) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  875) 			len += scnprintf(buf+len, size-len, "RPI:none ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  876) 		len +=  scnprintf(buf+len, size-len, "flag:x%08x ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  877) 			ndlp->nlp_flag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  878) 		if (!ndlp->nlp_type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  879) 			len += scnprintf(buf+len, size-len, "UNKNOWN_TYPE ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  880) 		if (ndlp->nlp_type & NLP_FC_NODE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  881) 			len += scnprintf(buf+len, size-len, "FC_NODE ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  882) 		if (ndlp->nlp_type & NLP_FABRIC) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  883) 			len += scnprintf(buf+len, size-len, "FABRIC ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  884) 			iocnt = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  885) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  886) 		if (ndlp->nlp_type & NLP_FCP_TARGET)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  887) 			len += scnprintf(buf+len, size-len, "FCP_TGT sid:%d ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  888) 				ndlp->nlp_sid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  889) 		if (ndlp->nlp_type & NLP_FCP_INITIATOR)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  890) 			len += scnprintf(buf+len, size-len, "FCP_INITIATOR ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  891) 		if (ndlp->nlp_type & NLP_NVME_TARGET)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  892) 			len += scnprintf(buf + len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  893) 					size - len, "NVME_TGT sid:%d ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  894) 					NLP_NO_SID);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  895) 		if (ndlp->nlp_type & NLP_NVME_INITIATOR)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  896) 			len += scnprintf(buf + len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  897) 					size - len, "NVME_INITIATOR ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  898) 		len += scnprintf(buf+len, size-len, "usgmap:%x ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  899) 			ndlp->nlp_usg_map);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  900) 		len += scnprintf(buf+len, size-len, "refcnt:%x",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  901) 			kref_read(&ndlp->kref));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  902) 		if (iocnt) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  903) 			i = atomic_read(&ndlp->cmd_pending);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  904) 			len += scnprintf(buf + len, size - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  905) 					" OutIO:x%x Qdepth x%x",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  906) 					i, ndlp->cmd_qdepth);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  907) 			outio += i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  908) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  909) 		len += scnprintf(buf + len, size - len, "defer:%x ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  910) 			ndlp->nlp_defer_did);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  911) 		len +=  scnprintf(buf+len, size-len, "\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  912) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  913) 	spin_unlock_irq(shost->host_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  914) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  915) 	len += scnprintf(buf + len, size - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  916) 			"\nOutstanding IO x%x\n",  outio);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  917) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  918) 	if (phba->nvmet_support && phba->targetport && (vport == phba->pport)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  919) 		len += scnprintf(buf + len, size - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  920) 				"\nNVME Targetport Entry ...\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  921) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  922) 		/* Port state is only one of two values for now. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  923) 		if (phba->targetport->port_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  924) 			statep = "REGISTERED";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  925) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  926) 			statep = "INIT";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  927) 		len += scnprintf(buf + len, size - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  928) 				"TGT WWNN x%llx WWPN x%llx State %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  929) 				wwn_to_u64(vport->fc_nodename.u.wwn),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  930) 				wwn_to_u64(vport->fc_portname.u.wwn),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  931) 				statep);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  932) 		len += scnprintf(buf + len, size - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  933) 				"    Targetport DID x%06x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  934) 				phba->targetport->port_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  935) 		goto out_exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  936) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  937) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  938) 	len += scnprintf(buf + len, size - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  939) 				"\nNVME Lport/Rport Entries ...\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  940) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  941) 	localport = vport->localport;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  942) 	if (!localport)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  943) 		goto out_exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  944) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  945) 	spin_lock_irq(shost->host_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  946) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  947) 	/* Port state is only one of two values for now. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  948) 	if (localport->port_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  949) 		statep = "ONLINE";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  950) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  951) 		statep = "UNKNOWN ";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  952) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  953) 	len += scnprintf(buf + len, size - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  954) 			"Lport DID x%06x PortState %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  955) 			localport->port_id, statep);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  956) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  957) 	len += scnprintf(buf + len, size - len, "\tRport List:\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  958) 	list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  959) 		/* local short-hand pointer. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  960) 		spin_lock(&phba->hbalock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  961) 		rport = lpfc_ndlp_get_nrport(ndlp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  962) 		if (rport)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  963) 			nrport = rport->remoteport;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  964) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  965) 			nrport = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  966) 		spin_unlock(&phba->hbalock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  967) 		if (!nrport)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  968) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  969) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  970) 		/* Port state is only one of two values for now. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  971) 		switch (nrport->port_state) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  972) 		case FC_OBJSTATE_ONLINE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  973) 			statep = "ONLINE";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  974) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  975) 		case FC_OBJSTATE_UNKNOWN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  976) 			statep = "UNKNOWN ";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  977) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  978) 		default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  979) 			statep = "UNSUPPORTED";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  980) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  981) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  982) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  983) 		/* Tab in to show lport ownership. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  984) 		len += scnprintf(buf + len, size - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  985) 				"\t%s Port ID:x%06x ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  986) 				statep, nrport->port_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  987) 		len += scnprintf(buf + len, size - len, "WWPN x%llx ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  988) 				nrport->port_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  989) 		len += scnprintf(buf + len, size - len, "WWNN x%llx ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  990) 				nrport->node_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  991) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  992) 		/* An NVME rport can have multiple roles. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  993) 		if (nrport->port_role & FC_PORT_ROLE_NVME_INITIATOR)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  994) 			len +=  scnprintf(buf + len, size - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  995) 					 "INITIATOR ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  996) 		if (nrport->port_role & FC_PORT_ROLE_NVME_TARGET)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  997) 			len +=  scnprintf(buf + len, size - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  998) 					 "TARGET ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  999) 		if (nrport->port_role & FC_PORT_ROLE_NVME_DISCOVERY)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1000) 			len +=  scnprintf(buf + len, size - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1001) 					 "DISCSRVC ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1002) 		if (nrport->port_role & ~(FC_PORT_ROLE_NVME_INITIATOR |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1003) 					  FC_PORT_ROLE_NVME_TARGET |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1004) 					  FC_PORT_ROLE_NVME_DISCOVERY))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1005) 			len +=  scnprintf(buf + len, size - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1006) 					 "UNKNOWN ROLE x%x",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1007) 					 nrport->port_role);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1008) 		/* Terminate the string. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1009) 		len +=  scnprintf(buf + len, size - len, "\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1010) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1011) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1012) 	spin_unlock_irq(shost->host_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1013)  out_exit:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1014) 	return len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1015) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1016) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1017) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1018)  * lpfc_debugfs_nvmestat_data - Dump target node list to a buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1019)  * @vport: The vport to gather target node info from.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1020)  * @buf: The buffer to dump log into.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1021)  * @size: The maximum amount of data to process.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1022)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1023)  * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1024)  * This routine dumps the NVME statistics associated with @vport
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1025)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1026)  * Return Value:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1027)  * This routine returns the amount of bytes that were dumped into @buf and will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1028)  * not exceed @size.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1029)  **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1030) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1031) lpfc_debugfs_nvmestat_data(struct lpfc_vport *vport, char *buf, int size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1032) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1033) 	struct lpfc_hba   *phba = vport->phba;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1034) 	struct lpfc_nvmet_tgtport *tgtp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1035) 	struct lpfc_async_xchg_ctx *ctxp, *next_ctxp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1036) 	struct nvme_fc_local_port *localport;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1037) 	struct lpfc_fc4_ctrl_stat *cstat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1038) 	struct lpfc_nvme_lport *lport;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1039) 	uint64_t data1, data2, data3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1040) 	uint64_t tot, totin, totout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1041) 	int cnt, i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1042) 	int len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1043) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1044) 	if (phba->nvmet_support) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1045) 		if (!phba->targetport)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1046) 			return len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1047) 		tgtp = (struct lpfc_nvmet_tgtport *)phba->targetport->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1048) 		len += scnprintf(buf + len, size - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1049) 				"\nNVME Targetport Statistics\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1050) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1051) 		len += scnprintf(buf + len, size - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1052) 				"LS: Rcv %08x Drop %08x Abort %08x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1053) 				atomic_read(&tgtp->rcv_ls_req_in),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1054) 				atomic_read(&tgtp->rcv_ls_req_drop),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1055) 				atomic_read(&tgtp->xmt_ls_abort));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1056) 		if (atomic_read(&tgtp->rcv_ls_req_in) !=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1057) 		    atomic_read(&tgtp->rcv_ls_req_out)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1058) 			len += scnprintf(buf + len, size - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1059) 					"Rcv LS: in %08x != out %08x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1060) 					atomic_read(&tgtp->rcv_ls_req_in),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1061) 					atomic_read(&tgtp->rcv_ls_req_out));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1062) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1063) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1064) 		len += scnprintf(buf + len, size - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1065) 				"LS: Xmt %08x Drop %08x Cmpl %08x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1066) 				atomic_read(&tgtp->xmt_ls_rsp),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1067) 				atomic_read(&tgtp->xmt_ls_drop),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1068) 				atomic_read(&tgtp->xmt_ls_rsp_cmpl));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1069) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1070) 		len += scnprintf(buf + len, size - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1071) 				"LS: RSP Abort %08x xb %08x Err %08x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1072) 				atomic_read(&tgtp->xmt_ls_rsp_aborted),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1073) 				atomic_read(&tgtp->xmt_ls_rsp_xb_set),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1074) 				atomic_read(&tgtp->xmt_ls_rsp_error));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1075) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1076) 		len += scnprintf(buf + len, size - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1077) 				"FCP: Rcv %08x Defer %08x Release %08x "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1078) 				"Drop %08x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1079) 				atomic_read(&tgtp->rcv_fcp_cmd_in),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1080) 				atomic_read(&tgtp->rcv_fcp_cmd_defer),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1081) 				atomic_read(&tgtp->xmt_fcp_release),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1082) 				atomic_read(&tgtp->rcv_fcp_cmd_drop));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1083) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1084) 		if (atomic_read(&tgtp->rcv_fcp_cmd_in) !=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1085) 		    atomic_read(&tgtp->rcv_fcp_cmd_out)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1086) 			len += scnprintf(buf + len, size - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1087) 					"Rcv FCP: in %08x != out %08x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1088) 					atomic_read(&tgtp->rcv_fcp_cmd_in),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1089) 					atomic_read(&tgtp->rcv_fcp_cmd_out));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1090) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1091) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1092) 		len += scnprintf(buf + len, size - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1093) 				"FCP Rsp: read %08x readrsp %08x "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1094) 				"write %08x rsp %08x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1095) 				atomic_read(&tgtp->xmt_fcp_read),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1096) 				atomic_read(&tgtp->xmt_fcp_read_rsp),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1097) 				atomic_read(&tgtp->xmt_fcp_write),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1098) 				atomic_read(&tgtp->xmt_fcp_rsp));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1099) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1100) 		len += scnprintf(buf + len, size - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1101) 				"FCP Rsp Cmpl: %08x err %08x drop %08x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1102) 				atomic_read(&tgtp->xmt_fcp_rsp_cmpl),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1103) 				atomic_read(&tgtp->xmt_fcp_rsp_error),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1104) 				atomic_read(&tgtp->xmt_fcp_rsp_drop));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1105) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1106) 		len += scnprintf(buf + len, size - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1107) 				"FCP Rsp Abort: %08x xb %08x xricqe  %08x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1108) 				atomic_read(&tgtp->xmt_fcp_rsp_aborted),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1109) 				atomic_read(&tgtp->xmt_fcp_rsp_xb_set),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1110) 				atomic_read(&tgtp->xmt_fcp_xri_abort_cqe));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1111) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1112) 		len += scnprintf(buf + len, size - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1113) 				"ABORT: Xmt %08x Cmpl %08x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1114) 				atomic_read(&tgtp->xmt_fcp_abort),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1115) 				atomic_read(&tgtp->xmt_fcp_abort_cmpl));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1116) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1117) 		len += scnprintf(buf + len, size - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1118) 				"ABORT: Sol %08x  Usol %08x Err %08x Cmpl %08x",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1119) 				atomic_read(&tgtp->xmt_abort_sol),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1120) 				atomic_read(&tgtp->xmt_abort_unsol),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1121) 				atomic_read(&tgtp->xmt_abort_rsp),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1122) 				atomic_read(&tgtp->xmt_abort_rsp_error));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1123) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1124) 		len +=  scnprintf(buf + len, size - len, "\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1125) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1126) 		cnt = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1127) 		spin_lock(&phba->sli4_hba.abts_nvmet_buf_list_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1128) 		list_for_each_entry_safe(ctxp, next_ctxp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1129) 				&phba->sli4_hba.lpfc_abts_nvmet_ctx_list,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1130) 				list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1131) 			cnt++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1132) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1133) 		spin_unlock(&phba->sli4_hba.abts_nvmet_buf_list_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1134) 		if (cnt) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1135) 			len += scnprintf(buf + len, size - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1136) 					"ABORT: %d ctx entries\n", cnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1137) 			spin_lock(&phba->sli4_hba.abts_nvmet_buf_list_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1138) 			list_for_each_entry_safe(ctxp, next_ctxp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1139) 				    &phba->sli4_hba.lpfc_abts_nvmet_ctx_list,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1140) 				    list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1141) 				if (len >= (size - LPFC_DEBUG_OUT_LINE_SZ))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1142) 					break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1143) 				len += scnprintf(buf + len, size - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1144) 						"Entry: oxid %x state %x "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1145) 						"flag %x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1146) 						ctxp->oxid, ctxp->state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1147) 						ctxp->flag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1148) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1149) 			spin_unlock(&phba->sli4_hba.abts_nvmet_buf_list_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1150) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1151) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1152) 		/* Calculate outstanding IOs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1153) 		tot = atomic_read(&tgtp->rcv_fcp_cmd_drop);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1154) 		tot += atomic_read(&tgtp->xmt_fcp_release);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1155) 		tot = atomic_read(&tgtp->rcv_fcp_cmd_in) - tot;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1156) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1157) 		len += scnprintf(buf + len, size - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1158) 				"IO_CTX: %08x  WAIT: cur %08x tot %08x\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1159) 				"CTX Outstanding %08llx\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1160) 				phba->sli4_hba.nvmet_xri_cnt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1161) 				phba->sli4_hba.nvmet_io_wait_cnt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1162) 				phba->sli4_hba.nvmet_io_wait_total,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1163) 				tot);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1164) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1165) 		if (!(vport->cfg_enable_fc4_type & LPFC_ENABLE_NVME))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1166) 			return len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1167) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1168) 		localport = vport->localport;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1169) 		if (!localport)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1170) 			return len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1171) 		lport = (struct lpfc_nvme_lport *)localport->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1172) 		if (!lport)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1173) 			return len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1174) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1175) 		len += scnprintf(buf + len, size - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1176) 				"\nNVME HDWQ Statistics\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1177) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1178) 		len += scnprintf(buf + len, size - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1179) 				"LS: Xmt %016x Cmpl %016x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1180) 				atomic_read(&lport->fc4NvmeLsRequests),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1181) 				atomic_read(&lport->fc4NvmeLsCmpls));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1182) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1183) 		totin = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1184) 		totout = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1185) 		for (i = 0; i < phba->cfg_hdw_queue; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1186) 			cstat = &phba->sli4_hba.hdwq[i].nvme_cstat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1187) 			tot = cstat->io_cmpls;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1188) 			totin += tot;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1189) 			data1 = cstat->input_requests;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1190) 			data2 = cstat->output_requests;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1191) 			data3 = cstat->control_requests;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1192) 			totout += (data1 + data2 + data3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1193) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1194) 			/* Limit to 32, debugfs display buffer limitation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1195) 			if (i >= 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1196) 				continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1197) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1198) 			len += scnprintf(buf + len, PAGE_SIZE - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1199) 					"HDWQ (%d): Rd %016llx Wr %016llx "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1200) 					"IO %016llx ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1201) 					i, data1, data2, data3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1202) 			len += scnprintf(buf + len, PAGE_SIZE - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1203) 					"Cmpl %016llx OutIO %016llx\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1204) 					tot, ((data1 + data2 + data3) - tot));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1205) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1206) 		len += scnprintf(buf + len, PAGE_SIZE - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1207) 				"Total FCP Cmpl %016llx Issue %016llx "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1208) 				"OutIO %016llx\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1209) 				totin, totout, totout - totin);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1210) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1211) 		len += scnprintf(buf + len, size - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1212) 				"LS Xmt Err: Abrt %08x Err %08x  "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1213) 				"Cmpl Err: xb %08x Err %08x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1214) 				atomic_read(&lport->xmt_ls_abort),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1215) 				atomic_read(&lport->xmt_ls_err),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1216) 				atomic_read(&lport->cmpl_ls_xb),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1217) 				atomic_read(&lport->cmpl_ls_err));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1218) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1219) 		len += scnprintf(buf + len, size - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1220) 				"FCP Xmt Err: noxri %06x nondlp %06x "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1221) 				"qdepth %06x wqerr %06x err %06x Abrt %06x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1222) 				atomic_read(&lport->xmt_fcp_noxri),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1223) 				atomic_read(&lport->xmt_fcp_bad_ndlp),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1224) 				atomic_read(&lport->xmt_fcp_qdepth),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1225) 				atomic_read(&lport->xmt_fcp_wqerr),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1226) 				atomic_read(&lport->xmt_fcp_err),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1227) 				atomic_read(&lport->xmt_fcp_abort));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1228) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1229) 		len += scnprintf(buf + len, size - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1230) 				"FCP Cmpl Err: xb %08x Err %08x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1231) 				atomic_read(&lport->cmpl_fcp_xb),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1232) 				atomic_read(&lport->cmpl_fcp_err));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1233) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1234) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1235) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1236) 	return len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1237) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1238) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1239) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1240)  * lpfc_debugfs_scsistat_data - Dump target node list to a buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1241)  * @vport: The vport to gather target node info from.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1242)  * @buf: The buffer to dump log into.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1243)  * @size: The maximum amount of data to process.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1244)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1245)  * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1246)  * This routine dumps the SCSI statistics associated with @vport
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1247)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1248)  * Return Value:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1249)  * This routine returns the amount of bytes that were dumped into @buf and will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1250)  * not exceed @size.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1251)  **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1252) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1253) lpfc_debugfs_scsistat_data(struct lpfc_vport *vport, char *buf, int size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1254) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1255) 	int len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1256) 	struct lpfc_hba *phba = vport->phba;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1257) 	struct lpfc_fc4_ctrl_stat *cstat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1258) 	u64 data1, data2, data3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1259) 	u64 tot, totin, totout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1260) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1261) 	char tmp[LPFC_MAX_SCSI_INFO_TMP_LEN] = {0};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1262) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1263) 	if (!(vport->cfg_enable_fc4_type & LPFC_ENABLE_FCP) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1264) 	    (phba->sli_rev != LPFC_SLI_REV4))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1265) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1266) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1267) 	scnprintf(buf, size, "SCSI HDWQ Statistics\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1268) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1269) 	totin = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1270) 	totout = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1271) 	for (i = 0; i < phba->cfg_hdw_queue; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1272) 		cstat = &phba->sli4_hba.hdwq[i].scsi_cstat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1273) 		tot = cstat->io_cmpls;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1274) 		totin += tot;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1275) 		data1 = cstat->input_requests;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1276) 		data2 = cstat->output_requests;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1277) 		data3 = cstat->control_requests;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1278) 		totout += (data1 + data2 + data3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1279) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1280) 		scnprintf(tmp, sizeof(tmp), "HDWQ (%d): Rd %016llx Wr %016llx "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1281) 			  "IO %016llx ", i, data1, data2, data3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1282) 		if (strlcat(buf, tmp, size) >= size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1283) 			goto buffer_done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1284) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1285) 		scnprintf(tmp, sizeof(tmp), "Cmpl %016llx OutIO %016llx\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1286) 			  tot, ((data1 + data2 + data3) - tot));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1287) 		if (strlcat(buf, tmp, size) >= size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1288) 			goto buffer_done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1289) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1290) 	scnprintf(tmp, sizeof(tmp), "Total FCP Cmpl %016llx Issue %016llx "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1291) 		  "OutIO %016llx\n", totin, totout, totout - totin);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1292) 	strlcat(buf, tmp, size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1293) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1294) buffer_done:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1295) 	len = strnlen(buf, size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1296) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1297) 	return len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1298) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1299) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1300) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1301) lpfc_io_ktime(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1302) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1303) 	uint64_t seg1, seg2, seg3, seg4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1304) 	uint64_t segsum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1305) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1306) 	if (!lpfc_cmd->ts_last_cmd ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1307) 	    !lpfc_cmd->ts_cmd_start ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1308) 	    !lpfc_cmd->ts_cmd_wqput ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1309) 	    !lpfc_cmd->ts_isr_cmpl ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1310) 	    !lpfc_cmd->ts_data_io)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1311) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1312) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1313) 	if (lpfc_cmd->ts_data_io < lpfc_cmd->ts_cmd_start)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1314) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1315) 	if (lpfc_cmd->ts_cmd_start < lpfc_cmd->ts_last_cmd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1316) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1317) 	if (lpfc_cmd->ts_cmd_wqput < lpfc_cmd->ts_cmd_start)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1318) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1319) 	if (lpfc_cmd->ts_isr_cmpl < lpfc_cmd->ts_cmd_wqput)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1320) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1321) 	if (lpfc_cmd->ts_data_io < lpfc_cmd->ts_isr_cmpl)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1322) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1323) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1324) 	 * Segment 1 - Time from Last FCP command cmpl is handed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1325) 	 * off to NVME Layer to start of next command.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1326) 	 * Segment 2 - Time from Driver receives a IO cmd start
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1327) 	 * from NVME Layer to WQ put is done on IO cmd.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1328) 	 * Segment 3 - Time from Driver WQ put is done on IO cmd
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1329) 	 * to MSI-X ISR for IO cmpl.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1330) 	 * Segment 4 - Time from MSI-X ISR for IO cmpl to when
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1331) 	 * cmpl is handled off to the NVME Layer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1332) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1333) 	seg1 = lpfc_cmd->ts_cmd_start - lpfc_cmd->ts_last_cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1334) 	if (seg1 > 5000000)  /* 5 ms - for sequential IOs only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1335) 		seg1 = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1336) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1337) 	/* Calculate times relative to start of IO */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1338) 	seg2 = (lpfc_cmd->ts_cmd_wqput - lpfc_cmd->ts_cmd_start);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1339) 	segsum = seg2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1340) 	seg3 = lpfc_cmd->ts_isr_cmpl - lpfc_cmd->ts_cmd_start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1341) 	if (segsum > seg3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1342) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1343) 	seg3 -= segsum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1344) 	segsum += seg3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1345) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1346) 	seg4 = lpfc_cmd->ts_data_io - lpfc_cmd->ts_cmd_start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1347) 	if (segsum > seg4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1348) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1349) 	seg4 -= segsum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1350) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1351) 	phba->ktime_data_samples++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1352) 	phba->ktime_seg1_total += seg1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1353) 	if (seg1 < phba->ktime_seg1_min)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1354) 		phba->ktime_seg1_min = seg1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1355) 	else if (seg1 > phba->ktime_seg1_max)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1356) 		phba->ktime_seg1_max = seg1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1357) 	phba->ktime_seg2_total += seg2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1358) 	if (seg2 < phba->ktime_seg2_min)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1359) 		phba->ktime_seg2_min = seg2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1360) 	else if (seg2 > phba->ktime_seg2_max)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1361) 		phba->ktime_seg2_max = seg2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1362) 	phba->ktime_seg3_total += seg3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1363) 	if (seg3 < phba->ktime_seg3_min)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1364) 		phba->ktime_seg3_min = seg3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1365) 	else if (seg3 > phba->ktime_seg3_max)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1366) 		phba->ktime_seg3_max = seg3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1367) 	phba->ktime_seg4_total += seg4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1368) 	if (seg4 < phba->ktime_seg4_min)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1369) 		phba->ktime_seg4_min = seg4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1370) 	else if (seg4 > phba->ktime_seg4_max)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1371) 		phba->ktime_seg4_max = seg4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1372) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1373) 	lpfc_cmd->ts_last_cmd = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1374) 	lpfc_cmd->ts_cmd_start = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1375) 	lpfc_cmd->ts_cmd_wqput  = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1376) 	lpfc_cmd->ts_isr_cmpl = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1377) 	lpfc_cmd->ts_data_io = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1378) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1379) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1380) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1381)  * lpfc_debugfs_ioktime_data - Dump target node list to a buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1382)  * @vport: The vport to gather target node info from.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1383)  * @buf: The buffer to dump log into.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1384)  * @size: The maximum amount of data to process.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1385)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1386)  * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1387)  * This routine dumps the NVME statistics associated with @vport
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1388)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1389)  * Return Value:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1390)  * This routine returns the amount of bytes that were dumped into @buf and will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1391)  * not exceed @size.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1392)  **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1393) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1394) lpfc_debugfs_ioktime_data(struct lpfc_vport *vport, char *buf, int size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1395) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1396) 	struct lpfc_hba   *phba = vport->phba;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1397) 	int len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1398) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1399) 	if (phba->nvmet_support == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1400) 		/* Initiator */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1401) 		len += scnprintf(buf + len, PAGE_SIZE - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1402) 				"ktime %s: Total Samples: %lld\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1403) 				(phba->ktime_on ?  "Enabled" : "Disabled"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1404) 				phba->ktime_data_samples);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1405) 		if (phba->ktime_data_samples == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1406) 			return len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1407) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1408) 		len += scnprintf(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1409) 			buf + len, PAGE_SIZE - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1410) 			"Segment 1: Last Cmd cmpl "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1411) 			"done -to- Start of next Cmd (in driver)\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1412) 		len += scnprintf(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1413) 			buf + len, PAGE_SIZE - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1414) 			"avg:%08lld min:%08lld max %08lld\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1415) 			div_u64(phba->ktime_seg1_total,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1416) 				phba->ktime_data_samples),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1417) 			phba->ktime_seg1_min,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1418) 			phba->ktime_seg1_max);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1419) 		len += scnprintf(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1420) 			buf + len, PAGE_SIZE - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1421) 			"Segment 2: Driver start of Cmd "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1422) 			"-to- Firmware WQ doorbell\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1423) 		len += scnprintf(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1424) 			buf + len, PAGE_SIZE - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1425) 			"avg:%08lld min:%08lld max %08lld\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1426) 			div_u64(phba->ktime_seg2_total,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1427) 				phba->ktime_data_samples),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1428) 			phba->ktime_seg2_min,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1429) 			phba->ktime_seg2_max);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1430) 		len += scnprintf(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1431) 			buf + len, PAGE_SIZE - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1432) 			"Segment 3: Firmware WQ doorbell -to- "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1433) 			"MSI-X ISR cmpl\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1434) 		len += scnprintf(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1435) 			buf + len, PAGE_SIZE - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1436) 			"avg:%08lld min:%08lld max %08lld\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1437) 			div_u64(phba->ktime_seg3_total,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1438) 				phba->ktime_data_samples),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1439) 			phba->ktime_seg3_min,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1440) 			phba->ktime_seg3_max);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1441) 		len += scnprintf(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1442) 			buf + len, PAGE_SIZE - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1443) 			"Segment 4: MSI-X ISR cmpl -to- "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1444) 			"Cmd cmpl done\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1445) 		len += scnprintf(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1446) 			buf + len, PAGE_SIZE - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1447) 			"avg:%08lld min:%08lld max %08lld\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1448) 			div_u64(phba->ktime_seg4_total,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1449) 				phba->ktime_data_samples),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1450) 			phba->ktime_seg4_min,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1451) 			phba->ktime_seg4_max);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1452) 		len += scnprintf(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1453) 			buf + len, PAGE_SIZE - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1454) 			"Total IO avg time: %08lld\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1455) 			div_u64(phba->ktime_seg1_total +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1456) 			phba->ktime_seg2_total  +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1457) 			phba->ktime_seg3_total +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1458) 			phba->ktime_seg4_total,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1459) 			phba->ktime_data_samples));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1460) 		return len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1461) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1462) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1463) 	/* NVME Target */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1464) 	len += scnprintf(buf + len, PAGE_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1465) 			"ktime %s: Total Samples: %lld %lld\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1466) 			(phba->ktime_on ? "Enabled" : "Disabled"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1467) 			phba->ktime_data_samples,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1468) 			phba->ktime_status_samples);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1469) 	if (phba->ktime_data_samples == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1470) 		return len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1471) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1472) 	len += scnprintf(buf + len, PAGE_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1473) 			"Segment 1: MSI-X ISR Rcv cmd -to- "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1474) 			"cmd pass to NVME Layer\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1475) 	len += scnprintf(buf + len, PAGE_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1476) 			"avg:%08lld min:%08lld max %08lld\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1477) 			div_u64(phba->ktime_seg1_total,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1478) 				phba->ktime_data_samples),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1479) 			phba->ktime_seg1_min,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1480) 			phba->ktime_seg1_max);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1481) 	len += scnprintf(buf + len, PAGE_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1482) 			"Segment 2: cmd pass to NVME Layer- "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1483) 			"-to- Driver rcv cmd OP (action)\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1484) 	len += scnprintf(buf + len, PAGE_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1485) 			"avg:%08lld min:%08lld max %08lld\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1486) 			div_u64(phba->ktime_seg2_total,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1487) 				phba->ktime_data_samples),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1488) 			phba->ktime_seg2_min,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1489) 			phba->ktime_seg2_max);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1490) 	len += scnprintf(buf + len, PAGE_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1491) 			"Segment 3: Driver rcv cmd OP -to- "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1492) 			"Firmware WQ doorbell: cmd\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1493) 	len += scnprintf(buf + len, PAGE_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1494) 			"avg:%08lld min:%08lld max %08lld\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1495) 			div_u64(phba->ktime_seg3_total,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1496) 				phba->ktime_data_samples),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1497) 			phba->ktime_seg3_min,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1498) 			phba->ktime_seg3_max);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1499) 	len += scnprintf(buf + len, PAGE_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1500) 			"Segment 4: Firmware WQ doorbell: cmd "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1501) 			"-to- MSI-X ISR for cmd cmpl\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1502) 	len += scnprintf(buf + len, PAGE_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1503) 			"avg:%08lld min:%08lld max %08lld\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1504) 			div_u64(phba->ktime_seg4_total,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1505) 				phba->ktime_data_samples),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1506) 			phba->ktime_seg4_min,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1507) 			phba->ktime_seg4_max);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1508) 	len += scnprintf(buf + len, PAGE_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1509) 			"Segment 5: MSI-X ISR for cmd cmpl "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1510) 			"-to- NVME layer passed cmd done\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1511) 	len += scnprintf(buf + len, PAGE_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1512) 			"avg:%08lld min:%08lld max %08lld\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1513) 			div_u64(phba->ktime_seg5_total,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1514) 				phba->ktime_data_samples),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1515) 			phba->ktime_seg5_min,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1516) 			phba->ktime_seg5_max);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1517) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1518) 	if (phba->ktime_status_samples == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1519) 		len += scnprintf(buf + len, PAGE_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1520) 				"Total: cmd received by MSI-X ISR "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1521) 				"-to- cmd completed on wire\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1522) 		len += scnprintf(buf + len, PAGE_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1523) 				"avg:%08lld min:%08lld "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1524) 				"max %08lld\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1525) 				div_u64(phba->ktime_seg10_total,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1526) 					phba->ktime_data_samples),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1527) 				phba->ktime_seg10_min,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1528) 				phba->ktime_seg10_max);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1529) 		return len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1530) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1531) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1532) 	len += scnprintf(buf + len, PAGE_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1533) 			"Segment 6: NVME layer passed cmd done "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1534) 			"-to- Driver rcv rsp status OP\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1535) 	len += scnprintf(buf + len, PAGE_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1536) 			"avg:%08lld min:%08lld max %08lld\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1537) 			div_u64(phba->ktime_seg6_total,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1538) 				phba->ktime_status_samples),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1539) 			phba->ktime_seg6_min,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1540) 			phba->ktime_seg6_max);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1541) 	len += scnprintf(buf + len, PAGE_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1542) 			"Segment 7: Driver rcv rsp status OP "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1543) 			"-to- Firmware WQ doorbell: status\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1544) 	len += scnprintf(buf + len, PAGE_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1545) 			"avg:%08lld min:%08lld max %08lld\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1546) 			div_u64(phba->ktime_seg7_total,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1547) 				phba->ktime_status_samples),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1548) 			phba->ktime_seg7_min,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1549) 			phba->ktime_seg7_max);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1550) 	len += scnprintf(buf + len, PAGE_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1551) 			"Segment 8: Firmware WQ doorbell: status"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1552) 			" -to- MSI-X ISR for status cmpl\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1553) 	len += scnprintf(buf + len, PAGE_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1554) 			"avg:%08lld min:%08lld max %08lld\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1555) 			div_u64(phba->ktime_seg8_total,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1556) 				phba->ktime_status_samples),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1557) 			phba->ktime_seg8_min,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1558) 			phba->ktime_seg8_max);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1559) 	len += scnprintf(buf + len, PAGE_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1560) 			"Segment 9: MSI-X ISR for status cmpl  "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1561) 			"-to- NVME layer passed status done\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1562) 	len += scnprintf(buf + len, PAGE_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1563) 			"avg:%08lld min:%08lld max %08lld\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1564) 			div_u64(phba->ktime_seg9_total,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1565) 				phba->ktime_status_samples),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1566) 			phba->ktime_seg9_min,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1567) 			phba->ktime_seg9_max);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1568) 	len += scnprintf(buf + len, PAGE_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1569) 			"Total: cmd received by MSI-X ISR -to- "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1570) 			"cmd completed on wire\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1571) 	len += scnprintf(buf + len, PAGE_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1572) 			"avg:%08lld min:%08lld max %08lld\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1573) 			div_u64(phba->ktime_seg10_total,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1574) 				phba->ktime_status_samples),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1575) 			phba->ktime_seg10_min,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1576) 			phba->ktime_seg10_max);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1577) 	return len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1578) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1579) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1580) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1581)  * lpfc_debugfs_nvmeio_trc_data - Dump NVME IO trace list to a buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1582)  * @phba: The phba to gather target node info from.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1583)  * @buf: The buffer to dump log into.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1584)  * @size: The maximum amount of data to process.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1585)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1586)  * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1587)  * This routine dumps the NVME IO trace associated with @phba
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1588)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1589)  * Return Value:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1590)  * This routine returns the amount of bytes that were dumped into @buf and will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1591)  * not exceed @size.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1592)  **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1593) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1594) lpfc_debugfs_nvmeio_trc_data(struct lpfc_hba *phba, char *buf, int size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1595) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1596) 	struct lpfc_debugfs_nvmeio_trc *dtp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1597) 	int i, state, index, skip;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1598) 	int len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1599) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1600) 	state = phba->nvmeio_trc_on;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1601) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1602) 	index = (atomic_read(&phba->nvmeio_trc_cnt) + 1) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1603) 		(phba->nvmeio_trc_size - 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1604) 	skip = phba->nvmeio_trc_output_idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1605) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1606) 	len += scnprintf(buf + len, size - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1607) 			"%s IO Trace %s: next_idx %d skip %d size %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1608) 			(phba->nvmet_support ? "NVME" : "NVMET"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1609) 			(state ? "Enabled" : "Disabled"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1610) 			index, skip, phba->nvmeio_trc_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1611) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1612) 	if (!phba->nvmeio_trc || state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1613) 		return len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1614) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1615) 	/* trace MUST bhe off to continue */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1616) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1617) 	for (i = index; i < phba->nvmeio_trc_size; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1618) 		if (skip) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1619) 			skip--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1620) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1621) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1622) 		dtp = phba->nvmeio_trc + i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1623) 		phba->nvmeio_trc_output_idx++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1624) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1625) 		if (!dtp->fmt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1626) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1627) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1628) 		len +=  scnprintf(buf + len, size - len, dtp->fmt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1629) 			dtp->data1, dtp->data2, dtp->data3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1630) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1631) 		if (phba->nvmeio_trc_output_idx >= phba->nvmeio_trc_size) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1632) 			phba->nvmeio_trc_output_idx = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1633) 			len += scnprintf(buf + len, size - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1634) 					"Trace Complete\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1635) 			goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1636) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1637) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1638) 		if (len >= (size - LPFC_DEBUG_OUT_LINE_SZ)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1639) 			len += scnprintf(buf + len, size - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1640) 					"Trace Continue (%d of %d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1641) 					phba->nvmeio_trc_output_idx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1642) 					phba->nvmeio_trc_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1643) 			goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1644) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1645) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1646) 	for (i = 0; i < index; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1647) 		if (skip) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1648) 			skip--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1649) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1650) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1651) 		dtp = phba->nvmeio_trc + i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1652) 		phba->nvmeio_trc_output_idx++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1653) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1654) 		if (!dtp->fmt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1655) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1656) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1657) 		len +=  scnprintf(buf + len, size - len, dtp->fmt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1658) 			dtp->data1, dtp->data2, dtp->data3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1659) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1660) 		if (phba->nvmeio_trc_output_idx >= phba->nvmeio_trc_size) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1661) 			phba->nvmeio_trc_output_idx = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1662) 			len += scnprintf(buf + len, size - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1663) 					"Trace Complete\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1664) 			goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1665) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1666) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1667) 		if (len >= (size - LPFC_DEBUG_OUT_LINE_SZ)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1668) 			len += scnprintf(buf + len, size - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1669) 					"Trace Continue (%d of %d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1670) 					phba->nvmeio_trc_output_idx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1671) 					phba->nvmeio_trc_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1672) 			goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1673) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1674) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1675) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1676) 	len += scnprintf(buf + len, size - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1677) 			"Trace Done\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1678) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1679) 	return len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1680) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1681) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1682) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1683)  * lpfc_debugfs_hdwqstat_data - Dump I/O stats to a buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1684)  * @vport: The vport to gather target node info from.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1685)  * @buf: The buffer to dump log into.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1686)  * @size: The maximum amount of data to process.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1687)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1688)  * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1689)  * This routine dumps the NVME + SCSI statistics associated with @vport
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1690)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1691)  * Return Value:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1692)  * This routine returns the amount of bytes that were dumped into @buf and will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1693)  * not exceed @size.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1694)  **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1695) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1696) lpfc_debugfs_hdwqstat_data(struct lpfc_vport *vport, char *buf, int size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1697) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1698) 	struct lpfc_hba   *phba = vport->phba;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1699) 	struct lpfc_hdwq_stat *c_stat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1700) 	int i, j, len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1701) 	uint32_t tot_xmt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1702) 	uint32_t tot_rcv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1703) 	uint32_t tot_cmpl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1704) 	char tmp[LPFC_MAX_SCSI_INFO_TMP_LEN] = {0};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1705) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1706) 	scnprintf(tmp, sizeof(tmp), "HDWQ Stats:\n\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1707) 	if (strlcat(buf, tmp, size) >= size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1708) 		goto buffer_done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1709) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1710) 	scnprintf(tmp, sizeof(tmp), "(NVME Accounting: %s) ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1711) 		  (phba->hdwqstat_on &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1712) 		  (LPFC_CHECK_NVME_IO | LPFC_CHECK_NVMET_IO) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1713) 		  "Enabled" : "Disabled"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1714) 	if (strlcat(buf, tmp, size) >= size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1715) 		goto buffer_done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1716) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1717) 	scnprintf(tmp, sizeof(tmp), "(SCSI Accounting: %s) ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1718) 		  (phba->hdwqstat_on & LPFC_CHECK_SCSI_IO ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1719) 		  "Enabled" : "Disabled"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1720) 	if (strlcat(buf, tmp, size) >= size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1721) 		goto buffer_done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1722) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1723) 	scnprintf(tmp, sizeof(tmp), "\n\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1724) 	if (strlcat(buf, tmp, size) >= size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1725) 		goto buffer_done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1726) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1727) 	for (i = 0; i < phba->cfg_hdw_queue; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1728) 		tot_rcv = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1729) 		tot_xmt = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1730) 		tot_cmpl = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1731) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1732) 		for_each_present_cpu(j) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1733) 			c_stat = per_cpu_ptr(phba->sli4_hba.c_stat, j);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1734) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1735) 			/* Only display for this HDWQ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1736) 			if (i != c_stat->hdwq_no)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1737) 				continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1738) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1739) 			/* Only display non-zero counters */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1740) 			if (!c_stat->xmt_io && !c_stat->cmpl_io &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1741) 			    !c_stat->rcv_io)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1742) 				continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1743) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1744) 			if (!tot_xmt && !tot_cmpl && !tot_rcv) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1745) 				/* Print HDWQ string only the first time */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1746) 				scnprintf(tmp, sizeof(tmp), "[HDWQ %d]:\t", i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1747) 				if (strlcat(buf, tmp, size) >= size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1748) 					goto buffer_done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1749) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1750) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1751) 			tot_xmt += c_stat->xmt_io;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1752) 			tot_cmpl += c_stat->cmpl_io;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1753) 			if (phba->nvmet_support)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1754) 				tot_rcv += c_stat->rcv_io;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1755) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1756) 			scnprintf(tmp, sizeof(tmp), "| [CPU %d]: ", j);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1757) 			if (strlcat(buf, tmp, size) >= size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1758) 				goto buffer_done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1759) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1760) 			if (phba->nvmet_support) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1761) 				scnprintf(tmp, sizeof(tmp),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1762) 					  "XMT 0x%x CMPL 0x%x RCV 0x%x |",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1763) 					  c_stat->xmt_io, c_stat->cmpl_io,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1764) 					  c_stat->rcv_io);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1765) 				if (strlcat(buf, tmp, size) >= size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1766) 					goto buffer_done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1767) 			} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1768) 				scnprintf(tmp, sizeof(tmp),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1769) 					  "XMT 0x%x CMPL 0x%x |",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1770) 					  c_stat->xmt_io, c_stat->cmpl_io);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1771) 				if (strlcat(buf, tmp, size) >= size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1772) 					goto buffer_done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1773) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1774) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1775) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1776) 		/* Check if nothing to display */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1777) 		if (!tot_xmt && !tot_cmpl && !tot_rcv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1778) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1779) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1780) 		scnprintf(tmp, sizeof(tmp), "\t->\t[HDWQ Total: ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1781) 		if (strlcat(buf, tmp, size) >= size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1782) 			goto buffer_done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1783) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1784) 		if (phba->nvmet_support) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1785) 			scnprintf(tmp, sizeof(tmp),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1786) 				  "XMT 0x%x CMPL 0x%x RCV 0x%x]\n\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1787) 				  tot_xmt, tot_cmpl, tot_rcv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1788) 			if (strlcat(buf, tmp, size) >= size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1789) 				goto buffer_done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1790) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1791) 			scnprintf(tmp, sizeof(tmp),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1792) 				  "XMT 0x%x CMPL 0x%x]\n\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1793) 				  tot_xmt, tot_cmpl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1794) 			if (strlcat(buf, tmp, size) >= size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1795) 				goto buffer_done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1796) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1797) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1798) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1799) buffer_done:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1800) 	len = strnlen(buf, size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1801) 	return len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1802) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1803) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1804) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1805) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1806) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1807)  * lpfc_debugfs_disc_trc - Store discovery trace log
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1808)  * @vport: The vport to associate this trace string with for retrieval.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1809)  * @mask: Log entry classification.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1810)  * @fmt: Format string to be displayed when dumping the log.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1811)  * @data1: 1st data parameter to be applied to @fmt.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1812)  * @data2: 2nd data parameter to be applied to @fmt.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1813)  * @data3: 3rd data parameter to be applied to @fmt.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1814)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1815)  * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1816)  * This routine is used by the driver code to add a debugfs log entry to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1817)  * discovery trace buffer associated with @vport. Only entries with a @mask that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1818)  * match the current debugfs discovery mask will be saved. Entries that do not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1819)  * match will be thrown away. @fmt, @data1, @data2, and @data3 are used like
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1820)  * printf when displaying the log.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1821)  **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1822) inline void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1823) lpfc_debugfs_disc_trc(struct lpfc_vport *vport, int mask, char *fmt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1824) 	uint32_t data1, uint32_t data2, uint32_t data3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1825) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1826) #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1827) 	struct lpfc_debugfs_trc *dtp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1828) 	int index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1829) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1830) 	if (!(lpfc_debugfs_mask_disc_trc & mask))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1831) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1832) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1833) 	if (!lpfc_debugfs_enable || !lpfc_debugfs_max_disc_trc ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1834) 		!vport || !vport->disc_trc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1835) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1836) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1837) 	index = atomic_inc_return(&vport->disc_trc_cnt) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1838) 		(lpfc_debugfs_max_disc_trc - 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1839) 	dtp = vport->disc_trc + index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1840) 	dtp->fmt = fmt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1841) 	dtp->data1 = data1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1842) 	dtp->data2 = data2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1843) 	dtp->data3 = data3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1844) 	dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1845) 	dtp->jif = jiffies;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1846) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1847) 	return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1848) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1849) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1850) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1851)  * lpfc_debugfs_slow_ring_trc - Store slow ring trace log
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1852)  * @phba: The phba to associate this trace string with for retrieval.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1853)  * @fmt: Format string to be displayed when dumping the log.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1854)  * @data1: 1st data parameter to be applied to @fmt.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1855)  * @data2: 2nd data parameter to be applied to @fmt.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1856)  * @data3: 3rd data parameter to be applied to @fmt.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1857)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1858)  * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1859)  * This routine is used by the driver code to add a debugfs log entry to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1860)  * discovery trace buffer associated with @vport. @fmt, @data1, @data2, and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1861)  * @data3 are used like printf when displaying the log.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1862)  **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1863) inline void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1864) lpfc_debugfs_slow_ring_trc(struct lpfc_hba *phba, char *fmt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1865) 	uint32_t data1, uint32_t data2, uint32_t data3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1866) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1867) #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1868) 	struct lpfc_debugfs_trc *dtp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1869) 	int index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1870) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1871) 	if (!lpfc_debugfs_enable || !lpfc_debugfs_max_slow_ring_trc ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1872) 		!phba || !phba->slow_ring_trc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1873) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1874) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1875) 	index = atomic_inc_return(&phba->slow_ring_trc_cnt) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1876) 		(lpfc_debugfs_max_slow_ring_trc - 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1877) 	dtp = phba->slow_ring_trc + index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1878) 	dtp->fmt = fmt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1879) 	dtp->data1 = data1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1880) 	dtp->data2 = data2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1881) 	dtp->data3 = data3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1882) 	dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1883) 	dtp->jif = jiffies;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1884) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1885) 	return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1886) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1887) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1888) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1889)  * lpfc_debugfs_nvme_trc - Store NVME/NVMET trace log
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1890)  * @phba: The phba to associate this trace string with for retrieval.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1891)  * @fmt: Format string to be displayed when dumping the log.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1892)  * @data1: 1st data parameter to be applied to @fmt.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1893)  * @data2: 2nd data parameter to be applied to @fmt.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1894)  * @data3: 3rd data parameter to be applied to @fmt.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1895)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1896)  * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1897)  * This routine is used by the driver code to add a debugfs log entry to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1898)  * nvme trace buffer associated with @phba. @fmt, @data1, @data2, and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1899)  * @data3 are used like printf when displaying the log.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1900)  **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1901) inline void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1902) lpfc_debugfs_nvme_trc(struct lpfc_hba *phba, char *fmt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1903) 		      uint16_t data1, uint16_t data2, uint32_t data3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1904) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1905) #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1906) 	struct lpfc_debugfs_nvmeio_trc *dtp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1907) 	int index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1908) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1909) 	if (!phba->nvmeio_trc_on || !phba->nvmeio_trc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1910) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1911) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1912) 	index = atomic_inc_return(&phba->nvmeio_trc_cnt) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1913) 		(phba->nvmeio_trc_size - 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1914) 	dtp = phba->nvmeio_trc + index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1915) 	dtp->fmt = fmt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1916) 	dtp->data1 = data1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1917) 	dtp->data2 = data2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1918) 	dtp->data3 = data3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1919) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1920) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1921) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1922) #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1923) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1924)  * lpfc_debugfs_disc_trc_open - Open the discovery trace log
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1925)  * @inode: The inode pointer that contains a vport pointer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1926)  * @file: The file pointer to attach the log output.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1927)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1928)  * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1929)  * This routine is the entry point for the debugfs open file operation. It gets
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1930)  * the vport from the i_private field in @inode, allocates the necessary buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1931)  * for the log, fills the buffer from the in-memory log for this vport, and then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1932)  * returns a pointer to that log in the private_data field in @file.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1933)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1934)  * Returns:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1935)  * This function returns zero if successful. On error it will return a negative
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1936)  * error value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1937)  **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1938) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1939) lpfc_debugfs_disc_trc_open(struct inode *inode, struct file *file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1940) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1941) 	struct lpfc_vport *vport = inode->i_private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1942) 	struct lpfc_debug *debug;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1943) 	int size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1944) 	int rc = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1945) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1946) 	if (!lpfc_debugfs_max_disc_trc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1947) 		rc = -ENOSPC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1948) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1949) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1950) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1951) 	debug = kmalloc(sizeof(*debug), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1952) 	if (!debug)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1953) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1954) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1955) 	/* Round to page boundary */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1956) 	size =  (lpfc_debugfs_max_disc_trc * LPFC_DEBUG_TRC_ENTRY_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1957) 	size = PAGE_ALIGN(size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1958) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1959) 	debug->buffer = kmalloc(size, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1960) 	if (!debug->buffer) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1961) 		kfree(debug);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1962) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1963) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1964) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1965) 	debug->len = lpfc_debugfs_disc_trc_data(vport, debug->buffer, size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1966) 	file->private_data = debug;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1967) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1968) 	rc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1969) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1970) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1971) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1972) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1973) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1974)  * lpfc_debugfs_slow_ring_trc_open - Open the Slow Ring trace log
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1975)  * @inode: The inode pointer that contains a vport pointer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1976)  * @file: The file pointer to attach the log output.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1977)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1978)  * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1979)  * This routine is the entry point for the debugfs open file operation. It gets
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1980)  * the vport from the i_private field in @inode, allocates the necessary buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1981)  * for the log, fills the buffer from the in-memory log for this vport, and then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1982)  * returns a pointer to that log in the private_data field in @file.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1983)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1984)  * Returns:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1985)  * This function returns zero if successful. On error it will return a negative
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1986)  * error value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1987)  **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1988) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1989) lpfc_debugfs_slow_ring_trc_open(struct inode *inode, struct file *file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1990) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1991) 	struct lpfc_hba *phba = inode->i_private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1992) 	struct lpfc_debug *debug;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1993) 	int size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1994) 	int rc = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1995) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1996) 	if (!lpfc_debugfs_max_slow_ring_trc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1997) 		rc = -ENOSPC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1998) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1999) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2000) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2001) 	debug = kmalloc(sizeof(*debug), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2002) 	if (!debug)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2003) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2004) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2005) 	/* Round to page boundary */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2006) 	size =  (lpfc_debugfs_max_slow_ring_trc * LPFC_DEBUG_TRC_ENTRY_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2007) 	size = PAGE_ALIGN(size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2008) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2009) 	debug->buffer = kmalloc(size, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2010) 	if (!debug->buffer) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2011) 		kfree(debug);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2012) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2013) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2014) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2015) 	debug->len = lpfc_debugfs_slow_ring_trc_data(phba, debug->buffer, size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2016) 	file->private_data = debug;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2017) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2018) 	rc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2019) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2020) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2021) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2022) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2023) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2024)  * lpfc_debugfs_hbqinfo_open - Open the hbqinfo debugfs buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2025)  * @inode: The inode pointer that contains a vport pointer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2026)  * @file: The file pointer to attach the log output.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2027)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2028)  * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2029)  * This routine is the entry point for the debugfs open file operation. It gets
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2030)  * the vport from the i_private field in @inode, allocates the necessary buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2031)  * for the log, fills the buffer from the in-memory log for this vport, and then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2032)  * returns a pointer to that log in the private_data field in @file.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2033)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2034)  * Returns:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2035)  * This function returns zero if successful. On error it will return a negative
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2036)  * error value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2037)  **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2038) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2039) lpfc_debugfs_hbqinfo_open(struct inode *inode, struct file *file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2040) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2041) 	struct lpfc_hba *phba = inode->i_private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2042) 	struct lpfc_debug *debug;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2043) 	int rc = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2044) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2045) 	debug = kmalloc(sizeof(*debug), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2046) 	if (!debug)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2047) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2048) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2049) 	/* Round to page boundary */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2050) 	debug->buffer = kmalloc(LPFC_HBQINFO_SIZE, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2051) 	if (!debug->buffer) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2052) 		kfree(debug);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2053) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2054) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2055) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2056) 	debug->len = lpfc_debugfs_hbqinfo_data(phba, debug->buffer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2057) 		LPFC_HBQINFO_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2058) 	file->private_data = debug;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2059) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2060) 	rc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2061) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2062) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2063) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2064) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2065) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2066)  * lpfc_debugfs_multixripools_open - Open the multixripool debugfs buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2067)  * @inode: The inode pointer that contains a hba pointer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2068)  * @file: The file pointer to attach the log output.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2069)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2070)  * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2071)  * This routine is the entry point for the debugfs open file operation. It gets
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2072)  * the hba from the i_private field in @inode, allocates the necessary buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2073)  * for the log, fills the buffer from the in-memory log for this hba, and then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2074)  * returns a pointer to that log in the private_data field in @file.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2075)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2076)  * Returns:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2077)  * This function returns zero if successful. On error it will return a negative
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2078)  * error value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2079)  **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2080) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2081) lpfc_debugfs_multixripools_open(struct inode *inode, struct file *file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2082) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2083) 	struct lpfc_hba *phba = inode->i_private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2084) 	struct lpfc_debug *debug;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2085) 	int rc = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2086) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2087) 	debug = kmalloc(sizeof(*debug), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2088) 	if (!debug)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2089) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2090) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2091) 	/* Round to page boundary */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2092) 	debug->buffer = kzalloc(LPFC_DUMP_MULTIXRIPOOL_SIZE, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2093) 	if (!debug->buffer) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2094) 		kfree(debug);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2095) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2096) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2097) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2098) 	debug->len = lpfc_debugfs_multixripools_data(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2099) 		phba, debug->buffer, LPFC_DUMP_MULTIXRIPOOL_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2100) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2101) 	debug->i_private = inode->i_private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2102) 	file->private_data = debug;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2103) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2104) 	rc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2105) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2106) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2107) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2108) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2109) #ifdef LPFC_HDWQ_LOCK_STAT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2110) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2111)  * lpfc_debugfs_lockstat_open - Open the lockstat debugfs buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2112)  * @inode: The inode pointer that contains a vport pointer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2113)  * @file: The file pointer to attach the log output.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2114)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2115)  * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2116)  * This routine is the entry point for the debugfs open file operation. It gets
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2117)  * the vport from the i_private field in @inode, allocates the necessary buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2118)  * for the log, fills the buffer from the in-memory log for this vport, and then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2119)  * returns a pointer to that log in the private_data field in @file.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2120)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2121)  * Returns:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2122)  * This function returns zero if successful. On error it will return a negative
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2123)  * error value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2124)  **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2125) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2126) lpfc_debugfs_lockstat_open(struct inode *inode, struct file *file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2127) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2128) 	struct lpfc_hba *phba = inode->i_private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2129) 	struct lpfc_debug *debug;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2130) 	int rc = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2131) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2132) 	debug = kmalloc(sizeof(*debug), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2133) 	if (!debug)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2134) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2135) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2136) 	/* Round to page boundary */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2137) 	debug->buffer = kmalloc(LPFC_HDWQINFO_SIZE, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2138) 	if (!debug->buffer) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2139) 		kfree(debug);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2140) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2141) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2142) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2143) 	debug->len = lpfc_debugfs_lockstat_data(phba, debug->buffer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2144) 		LPFC_HBQINFO_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2145) 	file->private_data = debug;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2146) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2147) 	rc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2148) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2149) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2150) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2151) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2152) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2153) lpfc_debugfs_lockstat_write(struct file *file, const char __user *buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2154) 			    size_t nbytes, loff_t *ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2155) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2156) 	struct lpfc_debug *debug = file->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2157) 	struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2158) 	struct lpfc_sli4_hdw_queue *qp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2159) 	char mybuf[64];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2160) 	char *pbuf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2161) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2162) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2163) 	memset(mybuf, 0, sizeof(mybuf));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2164) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2165) 	if (copy_from_user(mybuf, buf, nbytes))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2166) 		return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2167) 	pbuf = &mybuf[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2168) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2169) 	if ((strncmp(pbuf, "reset", strlen("reset")) == 0) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2170) 	    (strncmp(pbuf, "zero", strlen("zero")) == 0)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2171) 		for (i = 0; i < phba->cfg_hdw_queue; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2172) 			qp = &phba->sli4_hba.hdwq[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2173) 			qp->lock_conflict.alloc_xri_get = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2174) 			qp->lock_conflict.alloc_xri_put = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2175) 			qp->lock_conflict.free_xri = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2176) 			qp->lock_conflict.wq_access = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2177) 			qp->lock_conflict.alloc_pvt_pool = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2178) 			qp->lock_conflict.mv_from_pvt_pool = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2179) 			qp->lock_conflict.mv_to_pub_pool = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2180) 			qp->lock_conflict.mv_to_pvt_pool = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2181) 			qp->lock_conflict.free_pvt_pool = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2182) 			qp->lock_conflict.free_pub_pool = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2183) 			qp->lock_conflict.wq_access = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2184) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2185) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2186) 	return nbytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2187) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2188) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2189) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2190) static int lpfc_debugfs_ras_log_data(struct lpfc_hba *phba,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2191) 				     char *buffer, int size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2192) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2193) 	int copied = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2194) 	struct lpfc_dmabuf *dmabuf, *next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2195) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2196) 	memset(buffer, 0, size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2197) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2198) 	spin_lock_irq(&phba->hbalock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2199) 	if (phba->ras_fwlog.state != ACTIVE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2200) 		spin_unlock_irq(&phba->hbalock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2201) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2202) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2203) 	spin_unlock_irq(&phba->hbalock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2204) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2205) 	list_for_each_entry_safe(dmabuf, next,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2206) 				 &phba->ras_fwlog.fwlog_buff_list, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2207) 		/* Check if copying will go over size and a '\0' char */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2208) 		if ((copied + LPFC_RAS_MAX_ENTRY_SIZE) >= (size - 1)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2209) 			memcpy(buffer + copied, dmabuf->virt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2210) 			       size - copied - 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2211) 			copied += size - copied - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2212) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2213) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2214) 		memcpy(buffer + copied, dmabuf->virt, LPFC_RAS_MAX_ENTRY_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2215) 		copied += LPFC_RAS_MAX_ENTRY_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2216) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2217) 	return copied;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2218) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2219) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2220) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2221) lpfc_debugfs_ras_log_release(struct inode *inode, struct file *file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2222) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2223) 	struct lpfc_debug *debug = file->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2224) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2225) 	vfree(debug->buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2226) 	kfree(debug);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2227) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2228) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2229) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2230) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2231) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2232)  * lpfc_debugfs_ras_log_open - Open the RAS log debugfs buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2233)  * @inode: The inode pointer that contains a vport pointer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2234)  * @file: The file pointer to attach the log output.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2235)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2236)  * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2237)  * This routine is the entry point for the debugfs open file operation. It gets
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2238)  * the vport from the i_private field in @inode, allocates the necessary buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2239)  * for the log, fills the buffer from the in-memory log for this vport, and then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2240)  * returns a pointer to that log in the private_data field in @file.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2241)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2242)  * Returns:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2243)  * This function returns zero if successful. On error it will return a negative
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2244)  * error value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2245)  **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2246) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2247) lpfc_debugfs_ras_log_open(struct inode *inode, struct file *file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2248) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2249) 	struct lpfc_hba *phba = inode->i_private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2250) 	struct lpfc_debug *debug;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2251) 	int size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2252) 	int rc = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2253) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2254) 	spin_lock_irq(&phba->hbalock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2255) 	if (phba->ras_fwlog.state != ACTIVE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2256) 		spin_unlock_irq(&phba->hbalock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2257) 		rc = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2258) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2259) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2260) 	spin_unlock_irq(&phba->hbalock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2261) 	debug = kmalloc(sizeof(*debug), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2262) 	if (!debug)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2263) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2264) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2265) 	size = LPFC_RAS_MIN_BUFF_POST_SIZE * phba->cfg_ras_fwlog_buffsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2266) 	debug->buffer = vmalloc(size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2267) 	if (!debug->buffer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2268) 		goto free_debug;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2269) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2270) 	debug->len = lpfc_debugfs_ras_log_data(phba, debug->buffer, size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2271) 	if (debug->len < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2272) 		rc = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2273) 		goto free_buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2274) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2275) 	file->private_data = debug;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2276) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2277) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2278) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2279) free_buffer:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2280) 	vfree(debug->buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2281) free_debug:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2282) 	kfree(debug);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2283) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2284) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2285) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2286) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2287) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2288)  * lpfc_debugfs_dumpHBASlim_open - Open the Dump HBA SLIM debugfs buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2289)  * @inode: The inode pointer that contains a vport pointer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2290)  * @file: The file pointer to attach the log output.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2291)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2292)  * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2293)  * This routine is the entry point for the debugfs open file operation. It gets
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2294)  * the vport from the i_private field in @inode, allocates the necessary buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2295)  * for the log, fills the buffer from the in-memory log for this vport, and then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2296)  * returns a pointer to that log in the private_data field in @file.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2297)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2298)  * Returns:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2299)  * This function returns zero if successful. On error it will return a negative
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2300)  * error value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2301)  **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2302) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2303) lpfc_debugfs_dumpHBASlim_open(struct inode *inode, struct file *file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2304) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2305) 	struct lpfc_hba *phba = inode->i_private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2306) 	struct lpfc_debug *debug;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2307) 	int rc = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2308) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2309) 	debug = kmalloc(sizeof(*debug), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2310) 	if (!debug)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2311) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2312) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2313) 	/* Round to page boundary */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2314) 	debug->buffer = kmalloc(LPFC_DUMPHBASLIM_SIZE, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2315) 	if (!debug->buffer) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2316) 		kfree(debug);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2317) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2318) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2319) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2320) 	debug->len = lpfc_debugfs_dumpHBASlim_data(phba, debug->buffer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2321) 		LPFC_DUMPHBASLIM_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2322) 	file->private_data = debug;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2323) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2324) 	rc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2325) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2326) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2327) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2328) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2329) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2330)  * lpfc_debugfs_dumpHostSlim_open - Open the Dump Host SLIM debugfs buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2331)  * @inode: The inode pointer that contains a vport pointer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2332)  * @file: The file pointer to attach the log output.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2333)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2334)  * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2335)  * This routine is the entry point for the debugfs open file operation. It gets
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2336)  * the vport from the i_private field in @inode, allocates the necessary buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2337)  * for the log, fills the buffer from the in-memory log for this vport, and then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2338)  * returns a pointer to that log in the private_data field in @file.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2339)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2340)  * Returns:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2341)  * This function returns zero if successful. On error it will return a negative
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2342)  * error value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2343)  **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2344) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2345) lpfc_debugfs_dumpHostSlim_open(struct inode *inode, struct file *file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2346) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2347) 	struct lpfc_hba *phba = inode->i_private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2348) 	struct lpfc_debug *debug;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2349) 	int rc = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2350) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2351) 	debug = kmalloc(sizeof(*debug), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2352) 	if (!debug)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2353) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2354) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2355) 	/* Round to page boundary */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2356) 	debug->buffer = kmalloc(LPFC_DUMPHOSTSLIM_SIZE, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2357) 	if (!debug->buffer) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2358) 		kfree(debug);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2359) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2360) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2361) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2362) 	debug->len = lpfc_debugfs_dumpHostSlim_data(phba, debug->buffer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2363) 		LPFC_DUMPHOSTSLIM_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2364) 	file->private_data = debug;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2365) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2366) 	rc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2367) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2368) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2369) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2370) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2371) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2372) lpfc_debugfs_dif_err_read(struct file *file, char __user *buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2373) 	size_t nbytes, loff_t *ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2374) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2375) 	struct dentry *dent = file->f_path.dentry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2376) 	struct lpfc_hba *phba = file->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2377) 	char cbuf[32];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2378) 	uint64_t tmp = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2379) 	int cnt = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2380) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2381) 	if (dent == phba->debug_writeGuard)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2382) 		cnt = scnprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_wgrd_cnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2383) 	else if (dent == phba->debug_writeApp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2384) 		cnt = scnprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_wapp_cnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2385) 	else if (dent == phba->debug_writeRef)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2386) 		cnt = scnprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_wref_cnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2387) 	else if (dent == phba->debug_readGuard)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2388) 		cnt = scnprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_rgrd_cnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2389) 	else if (dent == phba->debug_readApp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2390) 		cnt = scnprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_rapp_cnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2391) 	else if (dent == phba->debug_readRef)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2392) 		cnt = scnprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_rref_cnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2393) 	else if (dent == phba->debug_InjErrNPortID)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2394) 		cnt = scnprintf(cbuf, 32, "0x%06x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2395) 				phba->lpfc_injerr_nportid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2396) 	else if (dent == phba->debug_InjErrWWPN) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2397) 		memcpy(&tmp, &phba->lpfc_injerr_wwpn, sizeof(struct lpfc_name));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2398) 		tmp = cpu_to_be64(tmp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2399) 		cnt = scnprintf(cbuf, 32, "0x%016llx\n", tmp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2400) 	} else if (dent == phba->debug_InjErrLBA) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2401) 		if (phba->lpfc_injerr_lba == (sector_t)(-1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2402) 			cnt = scnprintf(cbuf, 32, "off\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2403) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2404) 			cnt = scnprintf(cbuf, 32, "0x%llx\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2405) 				 (uint64_t) phba->lpfc_injerr_lba);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2406) 	} else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2407) 		lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2408) 			 "0547 Unknown debugfs error injection entry\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2409) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2410) 	return simple_read_from_buffer(buf, nbytes, ppos, &cbuf, cnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2411) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2412) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2413) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2414) lpfc_debugfs_dif_err_write(struct file *file, const char __user *buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2415) 	size_t nbytes, loff_t *ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2416) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2417) 	struct dentry *dent = file->f_path.dentry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2418) 	struct lpfc_hba *phba = file->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2419) 	char dstbuf[33];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2420) 	uint64_t tmp = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2421) 	int size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2422) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2423) 	memset(dstbuf, 0, 33);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2424) 	size = (nbytes < 32) ? nbytes : 32;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2425) 	if (copy_from_user(dstbuf, buf, size))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2426) 		return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2427) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2428) 	if (dent == phba->debug_InjErrLBA) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2429) 		if ((dstbuf[0] == 'o') && (dstbuf[1] == 'f') &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2430) 		    (dstbuf[2] == 'f'))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2431) 			tmp = (uint64_t)(-1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2432) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2433) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2434) 	if ((tmp == 0) && (kstrtoull(dstbuf, 0, &tmp)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2435) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2436) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2437) 	if (dent == phba->debug_writeGuard)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2438) 		phba->lpfc_injerr_wgrd_cnt = (uint32_t)tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2439) 	else if (dent == phba->debug_writeApp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2440) 		phba->lpfc_injerr_wapp_cnt = (uint32_t)tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2441) 	else if (dent == phba->debug_writeRef)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2442) 		phba->lpfc_injerr_wref_cnt = (uint32_t)tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2443) 	else if (dent == phba->debug_readGuard)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2444) 		phba->lpfc_injerr_rgrd_cnt = (uint32_t)tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2445) 	else if (dent == phba->debug_readApp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2446) 		phba->lpfc_injerr_rapp_cnt = (uint32_t)tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2447) 	else if (dent == phba->debug_readRef)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2448) 		phba->lpfc_injerr_rref_cnt = (uint32_t)tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2449) 	else if (dent == phba->debug_InjErrLBA)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2450) 		phba->lpfc_injerr_lba = (sector_t)tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2451) 	else if (dent == phba->debug_InjErrNPortID)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2452) 		phba->lpfc_injerr_nportid = (uint32_t)(tmp & Mask_DID);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2453) 	else if (dent == phba->debug_InjErrWWPN) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2454) 		tmp = cpu_to_be64(tmp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2455) 		memcpy(&phba->lpfc_injerr_wwpn, &tmp, sizeof(struct lpfc_name));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2456) 	} else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2457) 		lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2458) 			 "0548 Unknown debugfs error injection entry\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2459) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2460) 	return nbytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2461) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2462) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2463) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2464) lpfc_debugfs_dif_err_release(struct inode *inode, struct file *file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2465) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2466) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2467) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2468) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2469) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2470)  * lpfc_debugfs_nodelist_open - Open the nodelist debugfs file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2471)  * @inode: The inode pointer that contains a vport pointer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2472)  * @file: The file pointer to attach the log output.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2473)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2474)  * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2475)  * This routine is the entry point for the debugfs open file operation. It gets
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2476)  * the vport from the i_private field in @inode, allocates the necessary buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2477)  * for the log, fills the buffer from the in-memory log for this vport, and then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2478)  * returns a pointer to that log in the private_data field in @file.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2479)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2480)  * Returns:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2481)  * This function returns zero if successful. On error it will return a negative
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2482)  * error value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2483)  **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2484) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2485) lpfc_debugfs_nodelist_open(struct inode *inode, struct file *file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2486) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2487) 	struct lpfc_vport *vport = inode->i_private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2488) 	struct lpfc_debug *debug;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2489) 	int rc = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2490) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2491) 	debug = kmalloc(sizeof(*debug), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2492) 	if (!debug)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2493) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2494) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2495) 	/* Round to page boundary */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2496) 	debug->buffer = kmalloc(LPFC_NODELIST_SIZE, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2497) 	if (!debug->buffer) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2498) 		kfree(debug);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2499) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2500) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2501) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2502) 	debug->len = lpfc_debugfs_nodelist_data(vport, debug->buffer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2503) 		LPFC_NODELIST_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2504) 	file->private_data = debug;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2505) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2506) 	rc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2507) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2508) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2509) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2510) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2511) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2512)  * lpfc_debugfs_lseek - Seek through a debugfs file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2513)  * @file: The file pointer to seek through.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2514)  * @off: The offset to seek to or the amount to seek by.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2515)  * @whence: Indicates how to seek.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2516)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2517)  * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2518)  * This routine is the entry point for the debugfs lseek file operation. The
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2519)  * @whence parameter indicates whether @off is the offset to directly seek to,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2520)  * or if it is a value to seek forward or reverse by. This function figures out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2521)  * what the new offset of the debugfs file will be and assigns that value to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2522)  * f_pos field of @file.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2523)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2524)  * Returns:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2525)  * This function returns the new offset if successful and returns a negative
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2526)  * error if unable to process the seek.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2527)  **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2528) static loff_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2529) lpfc_debugfs_lseek(struct file *file, loff_t off, int whence)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2530) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2531) 	struct lpfc_debug *debug = file->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2532) 	return fixed_size_llseek(file, off, whence, debug->len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2533) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2534) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2535) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2536)  * lpfc_debugfs_read - Read a debugfs file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2537)  * @file: The file pointer to read from.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2538)  * @buf: The buffer to copy the data to.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2539)  * @nbytes: The number of bytes to read.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2540)  * @ppos: The position in the file to start reading from.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2541)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2542)  * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2543)  * This routine reads data from from the buffer indicated in the private_data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2544)  * field of @file. It will start reading at @ppos and copy up to @nbytes of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2545)  * data to @buf.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2546)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2547)  * Returns:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2548)  * This function returns the amount of data that was read (this could be less
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2549)  * than @nbytes if the end of the file was reached) or a negative error value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2550)  **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2551) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2552) lpfc_debugfs_read(struct file *file, char __user *buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2553) 		  size_t nbytes, loff_t *ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2554) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2555) 	struct lpfc_debug *debug = file->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2556) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2557) 	return simple_read_from_buffer(buf, nbytes, ppos, debug->buffer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2558) 				       debug->len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2559) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2560) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2561) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2562)  * lpfc_debugfs_release - Release the buffer used to store debugfs file data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2563)  * @inode: The inode pointer that contains a vport pointer. (unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2564)  * @file: The file pointer that contains the buffer to release.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2565)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2566)  * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2567)  * This routine frees the buffer that was allocated when the debugfs file was
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2568)  * opened.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2569)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2570)  * Returns:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2571)  * This function returns zero.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2572)  **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2573) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2574) lpfc_debugfs_release(struct inode *inode, struct file *file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2575) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2576) 	struct lpfc_debug *debug = file->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2577) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2578) 	kfree(debug->buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2579) 	kfree(debug);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2580) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2581) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2582) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2583) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2584) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2585)  * lpfc_debugfs_multixripools_write - Clear multi-XRI pools statistics
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2586)  * @file: The file pointer to read from.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2587)  * @buf: The buffer to copy the user data from.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2588)  * @nbytes: The number of bytes to get.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2589)  * @ppos: The position in the file to start reading from.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2590)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2591)  * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2592)  * This routine clears multi-XRI pools statistics when buf contains "clear".
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2593)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2594)  * Return Value:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2595)  * It returns the @nbytges passing in from debugfs user space when successful.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2596)  * In case of error conditions, it returns proper error code back to the user
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2597)  * space.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2598)  **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2599) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2600) lpfc_debugfs_multixripools_write(struct file *file, const char __user *buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2601) 				 size_t nbytes, loff_t *ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2602) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2603) 	struct lpfc_debug *debug = file->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2604) 	struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2605) 	char mybuf[64];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2606) 	char *pbuf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2607) 	u32 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2608) 	u32 hwq_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2609) 	struct lpfc_sli4_hdw_queue *qp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2610) 	struct lpfc_multixri_pool *multixri_pool;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2611) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2612) 	if (nbytes > 64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2613) 		nbytes = 64;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2614) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2615) 	memset(mybuf, 0, sizeof(mybuf));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2616) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2617) 	if (copy_from_user(mybuf, buf, nbytes))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2618) 		return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2619) 	pbuf = &mybuf[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2620) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2621) 	if ((strncmp(pbuf, "clear", strlen("clear"))) == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2622) 		hwq_count = phba->cfg_hdw_queue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2623) 		for (i = 0; i < hwq_count; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2624) 			qp = &phba->sli4_hba.hdwq[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2625) 			multixri_pool = qp->p_multixri_pool;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2626) 			if (!multixri_pool)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2627) 				continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2628) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2629) 			qp->empty_io_bufs = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2630) 			multixri_pool->pbl_empty_count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2631) #ifdef LPFC_MXP_STAT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2632) 			multixri_pool->above_limit_count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2633) 			multixri_pool->below_limit_count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2634) 			multixri_pool->stat_max_hwm = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2635) 			multixri_pool->local_pbl_hit_count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2636) 			multixri_pool->other_pbl_hit_count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2637) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2638) 			multixri_pool->stat_pbl_count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2639) 			multixri_pool->stat_pvt_count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2640) 			multixri_pool->stat_busy_count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2641) 			multixri_pool->stat_snapshot_taken = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2642) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2643) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2644) 		return strlen(pbuf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2645) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2646) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2647) 	return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2648) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2649) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2650) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2651) lpfc_debugfs_nvmestat_open(struct inode *inode, struct file *file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2652) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2653) 	struct lpfc_vport *vport = inode->i_private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2654) 	struct lpfc_debug *debug;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2655) 	int rc = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2656) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2657) 	debug = kmalloc(sizeof(*debug), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2658) 	if (!debug)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2659) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2660) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2661) 	 /* Round to page boundary */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2662) 	debug->buffer = kmalloc(LPFC_NVMESTAT_SIZE, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2663) 	if (!debug->buffer) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2664) 		kfree(debug);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2665) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2666) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2667) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2668) 	debug->len = lpfc_debugfs_nvmestat_data(vport, debug->buffer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2669) 		LPFC_NVMESTAT_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2670) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2671) 	debug->i_private = inode->i_private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2672) 	file->private_data = debug;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2673) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2674) 	rc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2675) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2676) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2677) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2678) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2679) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2680) lpfc_debugfs_nvmestat_write(struct file *file, const char __user *buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2681) 			    size_t nbytes, loff_t *ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2682) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2683) 	struct lpfc_debug *debug = file->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2684) 	struct lpfc_vport *vport = (struct lpfc_vport *)debug->i_private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2685) 	struct lpfc_hba   *phba = vport->phba;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2686) 	struct lpfc_nvmet_tgtport *tgtp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2687) 	char mybuf[64];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2688) 	char *pbuf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2689) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2690) 	if (!phba->targetport)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2691) 		return -ENXIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2692) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2693) 	if (nbytes > 64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2694) 		nbytes = 64;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2695) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2696) 	memset(mybuf, 0, sizeof(mybuf));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2697) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2698) 	if (copy_from_user(mybuf, buf, nbytes))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2699) 		return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2700) 	pbuf = &mybuf[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2701) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2702) 	tgtp = (struct lpfc_nvmet_tgtport *)phba->targetport->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2703) 	if ((strncmp(pbuf, "reset", strlen("reset")) == 0) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2704) 	    (strncmp(pbuf, "zero", strlen("zero")) == 0)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2705) 		atomic_set(&tgtp->rcv_ls_req_in, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2706) 		atomic_set(&tgtp->rcv_ls_req_out, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2707) 		atomic_set(&tgtp->rcv_ls_req_drop, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2708) 		atomic_set(&tgtp->xmt_ls_abort, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2709) 		atomic_set(&tgtp->xmt_ls_abort_cmpl, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2710) 		atomic_set(&tgtp->xmt_ls_rsp, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2711) 		atomic_set(&tgtp->xmt_ls_drop, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2712) 		atomic_set(&tgtp->xmt_ls_rsp_error, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2713) 		atomic_set(&tgtp->xmt_ls_rsp_cmpl, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2714) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2715) 		atomic_set(&tgtp->rcv_fcp_cmd_in, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2716) 		atomic_set(&tgtp->rcv_fcp_cmd_out, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2717) 		atomic_set(&tgtp->rcv_fcp_cmd_drop, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2718) 		atomic_set(&tgtp->xmt_fcp_drop, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2719) 		atomic_set(&tgtp->xmt_fcp_read_rsp, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2720) 		atomic_set(&tgtp->xmt_fcp_read, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2721) 		atomic_set(&tgtp->xmt_fcp_write, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2722) 		atomic_set(&tgtp->xmt_fcp_rsp, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2723) 		atomic_set(&tgtp->xmt_fcp_release, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2724) 		atomic_set(&tgtp->xmt_fcp_rsp_cmpl, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2725) 		atomic_set(&tgtp->xmt_fcp_rsp_error, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2726) 		atomic_set(&tgtp->xmt_fcp_rsp_drop, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2727) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2728) 		atomic_set(&tgtp->xmt_fcp_abort, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2729) 		atomic_set(&tgtp->xmt_fcp_abort_cmpl, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2730) 		atomic_set(&tgtp->xmt_abort_sol, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2731) 		atomic_set(&tgtp->xmt_abort_unsol, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2732) 		atomic_set(&tgtp->xmt_abort_rsp, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2733) 		atomic_set(&tgtp->xmt_abort_rsp_error, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2734) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2735) 	return nbytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2736) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2737) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2738) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2739) lpfc_debugfs_scsistat_open(struct inode *inode, struct file *file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2740) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2741) 	struct lpfc_vport *vport = inode->i_private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2742) 	struct lpfc_debug *debug;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2743) 	int rc = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2744) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2745) 	debug = kmalloc(sizeof(*debug), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2746) 	if (!debug)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2747) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2748) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2749) 	 /* Round to page boundary */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2750) 	debug->buffer = kzalloc(LPFC_SCSISTAT_SIZE, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2751) 	if (!debug->buffer) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2752) 		kfree(debug);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2753) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2754) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2755) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2756) 	debug->len = lpfc_debugfs_scsistat_data(vport, debug->buffer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2757) 		LPFC_SCSISTAT_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2758) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2759) 	debug->i_private = inode->i_private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2760) 	file->private_data = debug;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2761) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2762) 	rc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2763) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2764) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2765) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2766) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2767) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2768) lpfc_debugfs_scsistat_write(struct file *file, const char __user *buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2769) 			    size_t nbytes, loff_t *ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2770) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2771) 	struct lpfc_debug *debug = file->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2772) 	struct lpfc_vport *vport = (struct lpfc_vport *)debug->i_private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2773) 	struct lpfc_hba *phba = vport->phba;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2774) 	char mybuf[6] = {0};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2775) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2776) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2777) 	if (copy_from_user(mybuf, buf, (nbytes >= sizeof(mybuf)) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2778) 				       (sizeof(mybuf) - 1) : nbytes))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2779) 		return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2780) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2781) 	if ((strncmp(&mybuf[0], "reset", strlen("reset")) == 0) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2782) 	    (strncmp(&mybuf[0], "zero", strlen("zero")) == 0)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2783) 		for (i = 0; i < phba->cfg_hdw_queue; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2784) 			memset(&phba->sli4_hba.hdwq[i].scsi_cstat, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2785) 			       sizeof(phba->sli4_hba.hdwq[i].scsi_cstat));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2786) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2787) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2788) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2789) 	return nbytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2790) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2791) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2792) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2793) lpfc_debugfs_ioktime_open(struct inode *inode, struct file *file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2794) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2795) 	struct lpfc_vport *vport = inode->i_private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2796) 	struct lpfc_debug *debug;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2797) 	int rc = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2798) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2799) 	debug = kmalloc(sizeof(*debug), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2800) 	if (!debug)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2801) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2802) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2803) 	 /* Round to page boundary */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2804) 	debug->buffer = kmalloc(LPFC_IOKTIME_SIZE, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2805) 	if (!debug->buffer) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2806) 		kfree(debug);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2807) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2808) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2809) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2810) 	debug->len = lpfc_debugfs_ioktime_data(vport, debug->buffer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2811) 		LPFC_IOKTIME_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2812) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2813) 	debug->i_private = inode->i_private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2814) 	file->private_data = debug;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2815) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2816) 	rc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2817) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2818) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2819) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2820) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2821) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2822) lpfc_debugfs_ioktime_write(struct file *file, const char __user *buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2823) 			   size_t nbytes, loff_t *ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2824) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2825) 	struct lpfc_debug *debug = file->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2826) 	struct lpfc_vport *vport = (struct lpfc_vport *)debug->i_private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2827) 	struct lpfc_hba   *phba = vport->phba;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2828) 	char mybuf[64];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2829) 	char *pbuf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2830) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2831) 	if (nbytes > 64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2832) 		nbytes = 64;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2833) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2834) 	memset(mybuf, 0, sizeof(mybuf));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2835) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2836) 	if (copy_from_user(mybuf, buf, nbytes))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2837) 		return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2838) 	pbuf = &mybuf[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2839) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2840) 	if ((strncmp(pbuf, "on", sizeof("on") - 1) == 0)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2841) 		phba->ktime_data_samples = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2842) 		phba->ktime_status_samples = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2843) 		phba->ktime_seg1_total = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2844) 		phba->ktime_seg1_max = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2845) 		phba->ktime_seg1_min = 0xffffffff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2846) 		phba->ktime_seg2_total = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2847) 		phba->ktime_seg2_max = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2848) 		phba->ktime_seg2_min = 0xffffffff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2849) 		phba->ktime_seg3_total = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2850) 		phba->ktime_seg3_max = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2851) 		phba->ktime_seg3_min = 0xffffffff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2852) 		phba->ktime_seg4_total = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2853) 		phba->ktime_seg4_max = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2854) 		phba->ktime_seg4_min = 0xffffffff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2855) 		phba->ktime_seg5_total = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2856) 		phba->ktime_seg5_max = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2857) 		phba->ktime_seg5_min = 0xffffffff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2858) 		phba->ktime_seg6_total = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2859) 		phba->ktime_seg6_max = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2860) 		phba->ktime_seg6_min = 0xffffffff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2861) 		phba->ktime_seg7_total = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2862) 		phba->ktime_seg7_max = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2863) 		phba->ktime_seg7_min = 0xffffffff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2864) 		phba->ktime_seg8_total = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2865) 		phba->ktime_seg8_max = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2866) 		phba->ktime_seg8_min = 0xffffffff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2867) 		phba->ktime_seg9_total = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2868) 		phba->ktime_seg9_max = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2869) 		phba->ktime_seg9_min = 0xffffffff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2870) 		phba->ktime_seg10_total = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2871) 		phba->ktime_seg10_max = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2872) 		phba->ktime_seg10_min = 0xffffffff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2873) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2874) 		phba->ktime_on = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2875) 		return strlen(pbuf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2876) 	} else if ((strncmp(pbuf, "off",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2877) 		   sizeof("off") - 1) == 0)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2878) 		phba->ktime_on = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2879) 		return strlen(pbuf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2880) 	} else if ((strncmp(pbuf, "zero",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2881) 		   sizeof("zero") - 1) == 0)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2882) 		phba->ktime_data_samples = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2883) 		phba->ktime_status_samples = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2884) 		phba->ktime_seg1_total = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2885) 		phba->ktime_seg1_max = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2886) 		phba->ktime_seg1_min = 0xffffffff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2887) 		phba->ktime_seg2_total = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2888) 		phba->ktime_seg2_max = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2889) 		phba->ktime_seg2_min = 0xffffffff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2890) 		phba->ktime_seg3_total = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2891) 		phba->ktime_seg3_max = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2892) 		phba->ktime_seg3_min = 0xffffffff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2893) 		phba->ktime_seg4_total = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2894) 		phba->ktime_seg4_max = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2895) 		phba->ktime_seg4_min = 0xffffffff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2896) 		phba->ktime_seg5_total = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2897) 		phba->ktime_seg5_max = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2898) 		phba->ktime_seg5_min = 0xffffffff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2899) 		phba->ktime_seg6_total = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2900) 		phba->ktime_seg6_max = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2901) 		phba->ktime_seg6_min = 0xffffffff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2902) 		phba->ktime_seg7_total = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2903) 		phba->ktime_seg7_max = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2904) 		phba->ktime_seg7_min = 0xffffffff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2905) 		phba->ktime_seg8_total = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2906) 		phba->ktime_seg8_max = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2907) 		phba->ktime_seg8_min = 0xffffffff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2908) 		phba->ktime_seg9_total = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2909) 		phba->ktime_seg9_max = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2910) 		phba->ktime_seg9_min = 0xffffffff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2911) 		phba->ktime_seg10_total = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2912) 		phba->ktime_seg10_max = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2913) 		phba->ktime_seg10_min = 0xffffffff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2914) 		return strlen(pbuf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2915) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2916) 	return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2917) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2918) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2919) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2920) lpfc_debugfs_nvmeio_trc_open(struct inode *inode, struct file *file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2921) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2922) 	struct lpfc_hba *phba = inode->i_private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2923) 	struct lpfc_debug *debug;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2924) 	int rc = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2925) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2926) 	debug = kmalloc(sizeof(*debug), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2927) 	if (!debug)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2928) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2929) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2930) 	 /* Round to page boundary */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2931) 	debug->buffer = kmalloc(LPFC_NVMEIO_TRC_SIZE, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2932) 	if (!debug->buffer) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2933) 		kfree(debug);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2934) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2935) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2936) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2937) 	debug->len = lpfc_debugfs_nvmeio_trc_data(phba, debug->buffer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2938) 		LPFC_NVMEIO_TRC_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2939) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2940) 	debug->i_private = inode->i_private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2941) 	file->private_data = debug;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2942) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2943) 	rc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2944) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2945) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2946) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2947) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2948) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2949) lpfc_debugfs_nvmeio_trc_write(struct file *file, const char __user *buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2950) 			      size_t nbytes, loff_t *ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2951) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2952) 	struct lpfc_debug *debug = file->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2953) 	struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2954) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2955) 	unsigned long sz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2956) 	char mybuf[64];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2957) 	char *pbuf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2958) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2959) 	if (nbytes > 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2960) 		nbytes = 63;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2961) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2962) 	memset(mybuf, 0, sizeof(mybuf));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2963) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2964) 	if (copy_from_user(mybuf, buf, nbytes))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2965) 		return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2966) 	pbuf = &mybuf[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2967) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2968) 	if ((strncmp(pbuf, "off", sizeof("off") - 1) == 0)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2969) 		lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2970) 				"0570 nvmeio_trc_off\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2971) 		phba->nvmeio_trc_output_idx = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2972) 		phba->nvmeio_trc_on = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2973) 		return strlen(pbuf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2974) 	} else if ((strncmp(pbuf, "on", sizeof("on") - 1) == 0)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2975) 		lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2976) 				"0571 nvmeio_trc_on\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2977) 		phba->nvmeio_trc_output_idx = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2978) 		phba->nvmeio_trc_on = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2979) 		return strlen(pbuf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2980) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2981) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2982) 	/* We must be off to allocate the trace buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2983) 	if (phba->nvmeio_trc_on != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2984) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2985) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2986) 	/* If not on or off, the parameter is the trace buffer size */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2987) 	i = kstrtoul(pbuf, 0, &sz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2988) 	if (i)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2989) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2990) 	phba->nvmeio_trc_size = (uint32_t)sz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2991) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2992) 	/* It must be a power of 2 - round down */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2993) 	i = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2994) 	while (sz > 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2995) 		sz = sz >> 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2996) 		i++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2997) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2998) 	sz = (1 << i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2999) 	if (phba->nvmeio_trc_size != sz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3000) 		lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3001) 				"0572 nvmeio_trc_size changed to %ld\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3002) 				sz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3003) 	phba->nvmeio_trc_size = (uint32_t)sz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3004) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3005) 	/* If one previously exists, free it */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3006) 	kfree(phba->nvmeio_trc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3007) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3008) 	/* Allocate new trace buffer and initialize */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3009) 	phba->nvmeio_trc = kzalloc((sizeof(struct lpfc_debugfs_nvmeio_trc) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3010) 				    sz), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3011) 	if (!phba->nvmeio_trc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3012) 		lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3013) 				"0573 Cannot create debugfs "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3014) 				"nvmeio_trc buffer\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3015) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3016) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3017) 	atomic_set(&phba->nvmeio_trc_cnt, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3018) 	phba->nvmeio_trc_on = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3019) 	phba->nvmeio_trc_output_idx = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3020) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3021) 	return strlen(pbuf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3022) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3023) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3024) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3025) lpfc_debugfs_hdwqstat_open(struct inode *inode, struct file *file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3026) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3027) 	struct lpfc_vport *vport = inode->i_private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3028) 	struct lpfc_debug *debug;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3029) 	int rc = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3030) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3031) 	debug = kmalloc(sizeof(*debug), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3032) 	if (!debug)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3033) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3034) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3035) 	 /* Round to page boundary */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3036) 	debug->buffer = kcalloc(1, LPFC_SCSISTAT_SIZE, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3037) 	if (!debug->buffer) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3038) 		kfree(debug);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3039) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3040) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3041) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3042) 	debug->len = lpfc_debugfs_hdwqstat_data(vport, debug->buffer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3043) 						LPFC_SCSISTAT_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3044) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3045) 	debug->i_private = inode->i_private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3046) 	file->private_data = debug;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3047) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3048) 	rc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3049) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3050) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3051) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3052) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3053) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3054) lpfc_debugfs_hdwqstat_write(struct file *file, const char __user *buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3055) 			    size_t nbytes, loff_t *ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3056) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3057) 	struct lpfc_debug *debug = file->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3058) 	struct lpfc_vport *vport = (struct lpfc_vport *)debug->i_private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3059) 	struct lpfc_hba   *phba = vport->phba;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3060) 	struct lpfc_hdwq_stat *c_stat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3061) 	char mybuf[64];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3062) 	char *pbuf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3063) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3064) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3065) 	if (nbytes > 64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3066) 		nbytes = 64;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3067) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3068) 	memset(mybuf, 0, sizeof(mybuf));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3069) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3070) 	if (copy_from_user(mybuf, buf, nbytes))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3071) 		return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3072) 	pbuf = &mybuf[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3073) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3074) 	if ((strncmp(pbuf, "on", sizeof("on") - 1) == 0)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3075) 		if (phba->nvmet_support)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3076) 			phba->hdwqstat_on |= LPFC_CHECK_NVMET_IO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3077) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3078) 			phba->hdwqstat_on |= (LPFC_CHECK_NVME_IO |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3079) 				LPFC_CHECK_SCSI_IO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3080) 		return strlen(pbuf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3081) 	} else if ((strncmp(pbuf, "nvme_on", sizeof("nvme_on") - 1) == 0)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3082) 		if (phba->nvmet_support)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3083) 			phba->hdwqstat_on |= LPFC_CHECK_NVMET_IO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3084) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3085) 			phba->hdwqstat_on |= LPFC_CHECK_NVME_IO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3086) 		return strlen(pbuf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3087) 	} else if ((strncmp(pbuf, "scsi_on", sizeof("scsi_on") - 1) == 0)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3088) 		if (!phba->nvmet_support)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3089) 			phba->hdwqstat_on |= LPFC_CHECK_SCSI_IO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3090) 		return strlen(pbuf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3091) 	} else if ((strncmp(pbuf, "nvme_off", sizeof("nvme_off") - 1) == 0)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3092) 		phba->hdwqstat_on &= ~(LPFC_CHECK_NVME_IO |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3093) 				       LPFC_CHECK_NVMET_IO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3094) 		return strlen(pbuf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3095) 	} else if ((strncmp(pbuf, "scsi_off", sizeof("scsi_off") - 1) == 0)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3096) 		phba->hdwqstat_on &= ~LPFC_CHECK_SCSI_IO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3097) 		return strlen(pbuf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3098) 	} else if ((strncmp(pbuf, "off",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3099) 		   sizeof("off") - 1) == 0)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3100) 		phba->hdwqstat_on = LPFC_CHECK_OFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3101) 		return strlen(pbuf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3102) 	} else if ((strncmp(pbuf, "zero",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3103) 		   sizeof("zero") - 1) == 0)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3104) 		for_each_present_cpu(i) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3105) 			c_stat = per_cpu_ptr(phba->sli4_hba.c_stat, i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3106) 			c_stat->xmt_io = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3107) 			c_stat->cmpl_io = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3108) 			c_stat->rcv_io = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3109) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3110) 		return strlen(pbuf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3111) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3112) 	return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3113) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3114) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3115) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3116)  * ---------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3117)  * iDiag debugfs file access methods
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3118)  * ---------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3119)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3120)  * All access methods are through the proper SLI4 PCI function's debugfs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3121)  * iDiag directory:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3122)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3123)  *     /sys/kernel/debug/lpfc/fn<#>/iDiag
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3124)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3125) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3126) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3127)  * lpfc_idiag_cmd_get - Get and parse idiag debugfs comands from user space
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3128)  * @buf: The pointer to the user space buffer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3129)  * @nbytes: The number of bytes in the user space buffer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3130)  * @idiag_cmd: pointer to the idiag command struct.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3131)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3132)  * This routine reads data from debugfs user space buffer and parses the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3133)  * buffer for getting the idiag command and arguments. The while space in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3134)  * between the set of data is used as the parsing separator.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3135)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3136)  * This routine returns 0 when successful, it returns proper error code
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3137)  * back to the user space in error conditions.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3138)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3139) static int lpfc_idiag_cmd_get(const char __user *buf, size_t nbytes,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3140) 			      struct lpfc_idiag_cmd *idiag_cmd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3141) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3142) 	char mybuf[64];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3143) 	char *pbuf, *step_str;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3144) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3145) 	size_t bsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3146) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3147) 	memset(mybuf, 0, sizeof(mybuf));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3148) 	memset(idiag_cmd, 0, sizeof(*idiag_cmd));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3149) 	bsize = min(nbytes, (sizeof(mybuf)-1));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3150) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3151) 	if (copy_from_user(mybuf, buf, bsize))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3152) 		return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3153) 	pbuf = &mybuf[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3154) 	step_str = strsep(&pbuf, "\t ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3155) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3156) 	/* The opcode must present */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3157) 	if (!step_str)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3158) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3159) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3160) 	idiag_cmd->opcode = simple_strtol(step_str, NULL, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3161) 	if (idiag_cmd->opcode == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3162) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3163) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3164) 	for (i = 0; i < LPFC_IDIAG_CMD_DATA_SIZE; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3165) 		step_str = strsep(&pbuf, "\t ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3166) 		if (!step_str)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3167) 			return i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3168) 		idiag_cmd->data[i] = simple_strtol(step_str, NULL, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3169) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3170) 	return i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3171) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3172) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3173) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3174)  * lpfc_idiag_open - idiag open debugfs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3175)  * @inode: The inode pointer that contains a pointer to phba.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3176)  * @file: The file pointer to attach the file operation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3177)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3178)  * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3179)  * This routine is the entry point for the debugfs open file operation. It
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3180)  * gets the reference to phba from the i_private field in @inode, it then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3181)  * allocates buffer for the file operation, performs the necessary PCI config
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3182)  * space read into the allocated buffer according to the idiag user command
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3183)  * setup, and then returns a pointer to buffer in the private_data field in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3184)  * @file.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3185)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3186)  * Returns:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3187)  * This function returns zero if successful. On error it will return an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3188)  * negative error value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3189)  **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3190) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3191) lpfc_idiag_open(struct inode *inode, struct file *file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3192) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3193) 	struct lpfc_debug *debug;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3194) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3195) 	debug = kmalloc(sizeof(*debug), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3196) 	if (!debug)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3197) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3198) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3199) 	debug->i_private = inode->i_private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3200) 	debug->buffer = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3201) 	file->private_data = debug;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3202) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3203) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3204) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3205) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3206) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3207)  * lpfc_idiag_release - Release idiag access file operation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3208)  * @inode: The inode pointer that contains a vport pointer. (unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3209)  * @file: The file pointer that contains the buffer to release.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3210)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3211)  * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3212)  * This routine is the generic release routine for the idiag access file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3213)  * operation, it frees the buffer that was allocated when the debugfs file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3214)  * was opened.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3215)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3216)  * Returns:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3217)  * This function returns zero.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3218)  **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3219) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3220) lpfc_idiag_release(struct inode *inode, struct file *file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3221) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3222) 	struct lpfc_debug *debug = file->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3223) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3224) 	/* Free the buffers to the file operation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3225) 	kfree(debug->buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3226) 	kfree(debug);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3227) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3228) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3229) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3230) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3231) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3232)  * lpfc_idiag_cmd_release - Release idiag cmd access file operation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3233)  * @inode: The inode pointer that contains a vport pointer. (unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3234)  * @file: The file pointer that contains the buffer to release.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3235)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3236)  * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3237)  * This routine frees the buffer that was allocated when the debugfs file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3238)  * was opened. It also reset the fields in the idiag command struct in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3239)  * case of command for write operation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3240)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3241)  * Returns:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3242)  * This function returns zero.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3243)  **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3244) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3245) lpfc_idiag_cmd_release(struct inode *inode, struct file *file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3246) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3247) 	struct lpfc_debug *debug = file->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3248) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3249) 	if (debug->op == LPFC_IDIAG_OP_WR) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3250) 		switch (idiag.cmd.opcode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3251) 		case LPFC_IDIAG_CMD_PCICFG_WR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3252) 		case LPFC_IDIAG_CMD_PCICFG_ST:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3253) 		case LPFC_IDIAG_CMD_PCICFG_CL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3254) 		case LPFC_IDIAG_CMD_QUEACC_WR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3255) 		case LPFC_IDIAG_CMD_QUEACC_ST:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3256) 		case LPFC_IDIAG_CMD_QUEACC_CL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3257) 			memset(&idiag, 0, sizeof(idiag));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3258) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3259) 		default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3260) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3261) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3262) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3263) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3264) 	/* Free the buffers to the file operation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3265) 	kfree(debug->buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3266) 	kfree(debug);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3267) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3268) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3269) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3270) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3271) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3272)  * lpfc_idiag_pcicfg_read - idiag debugfs read pcicfg
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3273)  * @file: The file pointer to read from.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3274)  * @buf: The buffer to copy the data to.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3275)  * @nbytes: The number of bytes to read.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3276)  * @ppos: The position in the file to start reading from.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3277)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3278)  * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3279)  * This routine reads data from the @phba pci config space according to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3280)  * idiag command, and copies to user @buf. Depending on the PCI config space
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3281)  * read command setup, it does either a single register read of a byte
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3282)  * (8 bits), a word (16 bits), or a dword (32 bits) or browsing through all
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3283)  * registers from the 4K extended PCI config space.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3284)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3285)  * Returns:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3286)  * This function returns the amount of data that was read (this could be less
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3287)  * than @nbytes if the end of the file was reached) or a negative error value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3288)  **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3289) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3290) lpfc_idiag_pcicfg_read(struct file *file, char __user *buf, size_t nbytes,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3291) 		       loff_t *ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3292) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3293) 	struct lpfc_debug *debug = file->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3294) 	struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3295) 	int offset_label, offset, len = 0, index = LPFC_PCI_CFG_RD_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3296) 	int where, count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3297) 	char *pbuffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3298) 	struct pci_dev *pdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3299) 	uint32_t u32val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3300) 	uint16_t u16val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3301) 	uint8_t u8val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3302) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3303) 	pdev = phba->pcidev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3304) 	if (!pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3305) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3306) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3307) 	/* This is a user read operation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3308) 	debug->op = LPFC_IDIAG_OP_RD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3309) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3310) 	if (!debug->buffer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3311) 		debug->buffer = kmalloc(LPFC_PCI_CFG_SIZE, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3312) 	if (!debug->buffer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3313) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3314) 	pbuffer = debug->buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3315) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3316) 	if (*ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3317) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3318) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3319) 	if (idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_RD) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3320) 		where = idiag.cmd.data[IDIAG_PCICFG_WHERE_INDX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3321) 		count = idiag.cmd.data[IDIAG_PCICFG_COUNT_INDX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3322) 	} else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3323) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3324) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3325) 	/* Read single PCI config space register */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3326) 	switch (count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3327) 	case SIZE_U8: /* byte (8 bits) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3328) 		pci_read_config_byte(pdev, where, &u8val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3329) 		len += scnprintf(pbuffer+len, LPFC_PCI_CFG_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3330) 				"%03x: %02x\n", where, u8val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3331) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3332) 	case SIZE_U16: /* word (16 bits) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3333) 		pci_read_config_word(pdev, where, &u16val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3334) 		len += scnprintf(pbuffer+len, LPFC_PCI_CFG_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3335) 				"%03x: %04x\n", where, u16val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3336) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3337) 	case SIZE_U32: /* double word (32 bits) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3338) 		pci_read_config_dword(pdev, where, &u32val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3339) 		len += scnprintf(pbuffer+len, LPFC_PCI_CFG_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3340) 				"%03x: %08x\n", where, u32val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3341) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3342) 	case LPFC_PCI_CFG_BROWSE: /* browse all */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3343) 		goto pcicfg_browse;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3344) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3345) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3346) 		/* illegal count */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3347) 		len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3348) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3349) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3350) 	return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3351) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3352) pcicfg_browse:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3353) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3354) 	/* Browse all PCI config space registers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3355) 	offset_label = idiag.offset.last_rd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3356) 	offset = offset_label;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3357) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3358) 	/* Read PCI config space */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3359) 	len += scnprintf(pbuffer+len, LPFC_PCI_CFG_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3360) 			"%03x: ", offset_label);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3361) 	while (index > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3362) 		pci_read_config_dword(pdev, offset, &u32val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3363) 		len += scnprintf(pbuffer+len, LPFC_PCI_CFG_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3364) 				"%08x ", u32val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3365) 		offset += sizeof(uint32_t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3366) 		if (offset >= LPFC_PCI_CFG_SIZE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3367) 			len += scnprintf(pbuffer+len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3368) 					LPFC_PCI_CFG_SIZE-len, "\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3369) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3370) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3371) 		index -= sizeof(uint32_t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3372) 		if (!index)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3373) 			len += scnprintf(pbuffer+len, LPFC_PCI_CFG_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3374) 					"\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3375) 		else if (!(index % (8 * sizeof(uint32_t)))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3376) 			offset_label += (8 * sizeof(uint32_t));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3377) 			len += scnprintf(pbuffer+len, LPFC_PCI_CFG_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3378) 					"\n%03x: ", offset_label);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3379) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3380) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3381) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3382) 	/* Set up the offset for next portion of pci cfg read */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3383) 	if (index == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3384) 		idiag.offset.last_rd += LPFC_PCI_CFG_RD_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3385) 		if (idiag.offset.last_rd >= LPFC_PCI_CFG_SIZE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3386) 			idiag.offset.last_rd = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3387) 	} else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3388) 		idiag.offset.last_rd = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3389) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3390) 	return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3391) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3392) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3393) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3394)  * lpfc_idiag_pcicfg_write - Syntax check and set up idiag pcicfg commands
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3395)  * @file: The file pointer to read from.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3396)  * @buf: The buffer to copy the user data from.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3397)  * @nbytes: The number of bytes to get.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3398)  * @ppos: The position in the file to start reading from.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3399)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3400)  * This routine get the debugfs idiag command struct from user space and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3401)  * then perform the syntax check for PCI config space read or write command
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3402)  * accordingly. In the case of PCI config space read command, it sets up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3403)  * the command in the idiag command struct for the debugfs read operation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3404)  * In the case of PCI config space write operation, it executes the write
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3405)  * operation into the PCI config space accordingly.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3406)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3407)  * It returns the @nbytges passing in from debugfs user space when successful.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3408)  * In case of error conditions, it returns proper error code back to the user
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3409)  * space.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3410)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3411) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3412) lpfc_idiag_pcicfg_write(struct file *file, const char __user *buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3413) 			size_t nbytes, loff_t *ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3414) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3415) 	struct lpfc_debug *debug = file->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3416) 	struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3417) 	uint32_t where, value, count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3418) 	uint32_t u32val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3419) 	uint16_t u16val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3420) 	uint8_t u8val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3421) 	struct pci_dev *pdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3422) 	int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3423) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3424) 	pdev = phba->pcidev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3425) 	if (!pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3426) 		return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3427) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3428) 	/* This is a user write operation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3429) 	debug->op = LPFC_IDIAG_OP_WR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3430) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3431) 	rc = lpfc_idiag_cmd_get(buf, nbytes, &idiag.cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3432) 	if (rc < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3433) 		return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3434) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3435) 	if (idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_RD) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3436) 		/* Sanity check on PCI config read command line arguments */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3437) 		if (rc != LPFC_PCI_CFG_RD_CMD_ARG)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3438) 			goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3439) 		/* Read command from PCI config space, set up command fields */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3440) 		where = idiag.cmd.data[IDIAG_PCICFG_WHERE_INDX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3441) 		count = idiag.cmd.data[IDIAG_PCICFG_COUNT_INDX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3442) 		if (count == LPFC_PCI_CFG_BROWSE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3443) 			if (where % sizeof(uint32_t))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3444) 				goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3445) 			/* Starting offset to browse */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3446) 			idiag.offset.last_rd = where;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3447) 		} else if ((count != sizeof(uint8_t)) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3448) 			   (count != sizeof(uint16_t)) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3449) 			   (count != sizeof(uint32_t)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3450) 			goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3451) 		if (count == sizeof(uint8_t)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3452) 			if (where > LPFC_PCI_CFG_SIZE - sizeof(uint8_t))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3453) 				goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3454) 			if (where % sizeof(uint8_t))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3455) 				goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3456) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3457) 		if (count == sizeof(uint16_t)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3458) 			if (where > LPFC_PCI_CFG_SIZE - sizeof(uint16_t))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3459) 				goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3460) 			if (where % sizeof(uint16_t))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3461) 				goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3462) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3463) 		if (count == sizeof(uint32_t)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3464) 			if (where > LPFC_PCI_CFG_SIZE - sizeof(uint32_t))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3465) 				goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3466) 			if (where % sizeof(uint32_t))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3467) 				goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3468) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3469) 	} else if (idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_WR ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3470) 		   idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_ST ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3471) 		   idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_CL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3472) 		/* Sanity check on PCI config write command line arguments */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3473) 		if (rc != LPFC_PCI_CFG_WR_CMD_ARG)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3474) 			goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3475) 		/* Write command to PCI config space, read-modify-write */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3476) 		where = idiag.cmd.data[IDIAG_PCICFG_WHERE_INDX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3477) 		count = idiag.cmd.data[IDIAG_PCICFG_COUNT_INDX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3478) 		value = idiag.cmd.data[IDIAG_PCICFG_VALUE_INDX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3479) 		/* Sanity checks */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3480) 		if ((count != sizeof(uint8_t)) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3481) 		    (count != sizeof(uint16_t)) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3482) 		    (count != sizeof(uint32_t)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3483) 			goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3484) 		if (count == sizeof(uint8_t)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3485) 			if (where > LPFC_PCI_CFG_SIZE - sizeof(uint8_t))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3486) 				goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3487) 			if (where % sizeof(uint8_t))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3488) 				goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3489) 			if (idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_WR)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3490) 				pci_write_config_byte(pdev, where,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3491) 						      (uint8_t)value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3492) 			if (idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_ST) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3493) 				rc = pci_read_config_byte(pdev, where, &u8val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3494) 				if (!rc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3495) 					u8val |= (uint8_t)value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3496) 					pci_write_config_byte(pdev, where,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3497) 							      u8val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3498) 				}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3499) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3500) 			if (idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_CL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3501) 				rc = pci_read_config_byte(pdev, where, &u8val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3502) 				if (!rc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3503) 					u8val &= (uint8_t)(~value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3504) 					pci_write_config_byte(pdev, where,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3505) 							      u8val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3506) 				}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3507) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3508) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3509) 		if (count == sizeof(uint16_t)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3510) 			if (where > LPFC_PCI_CFG_SIZE - sizeof(uint16_t))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3511) 				goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3512) 			if (where % sizeof(uint16_t))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3513) 				goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3514) 			if (idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_WR)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3515) 				pci_write_config_word(pdev, where,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3516) 						      (uint16_t)value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3517) 			if (idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_ST) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3518) 				rc = pci_read_config_word(pdev, where, &u16val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3519) 				if (!rc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3520) 					u16val |= (uint16_t)value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3521) 					pci_write_config_word(pdev, where,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3522) 							      u16val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3523) 				}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3524) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3525) 			if (idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_CL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3526) 				rc = pci_read_config_word(pdev, where, &u16val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3527) 				if (!rc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3528) 					u16val &= (uint16_t)(~value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3529) 					pci_write_config_word(pdev, where,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3530) 							      u16val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3531) 				}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3532) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3533) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3534) 		if (count == sizeof(uint32_t)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3535) 			if (where > LPFC_PCI_CFG_SIZE - sizeof(uint32_t))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3536) 				goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3537) 			if (where % sizeof(uint32_t))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3538) 				goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3539) 			if (idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_WR)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3540) 				pci_write_config_dword(pdev, where, value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3541) 			if (idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_ST) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3542) 				rc = pci_read_config_dword(pdev, where,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3543) 							   &u32val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3544) 				if (!rc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3545) 					u32val |= value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3546) 					pci_write_config_dword(pdev, where,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3547) 							       u32val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3548) 				}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3549) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3550) 			if (idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_CL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3551) 				rc = pci_read_config_dword(pdev, where,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3552) 							   &u32val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3553) 				if (!rc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3554) 					u32val &= ~value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3555) 					pci_write_config_dword(pdev, where,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3556) 							       u32val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3557) 				}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3558) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3559) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3560) 	} else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3561) 		/* All other opecodes are illegal for now */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3562) 		goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3563) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3564) 	return nbytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3565) error_out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3566) 	memset(&idiag, 0, sizeof(idiag));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3567) 	return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3568) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3569) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3570) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3571)  * lpfc_idiag_baracc_read - idiag debugfs pci bar access read
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3572)  * @file: The file pointer to read from.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3573)  * @buf: The buffer to copy the data to.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3574)  * @nbytes: The number of bytes to read.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3575)  * @ppos: The position in the file to start reading from.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3576)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3577)  * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3578)  * This routine reads data from the @phba pci bar memory mapped space
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3579)  * according to the idiag command, and copies to user @buf.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3580)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3581)  * Returns:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3582)  * This function returns the amount of data that was read (this could be less
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3583)  * than @nbytes if the end of the file was reached) or a negative error value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3584)  **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3585) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3586) lpfc_idiag_baracc_read(struct file *file, char __user *buf, size_t nbytes,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3587) 		       loff_t *ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3588) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3589) 	struct lpfc_debug *debug = file->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3590) 	struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3591) 	int offset_label, offset, offset_run, len = 0, index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3592) 	int bar_num, acc_range, bar_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3593) 	char *pbuffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3594) 	void __iomem *mem_mapped_bar;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3595) 	uint32_t if_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3596) 	struct pci_dev *pdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3597) 	uint32_t u32val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3598) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3599) 	pdev = phba->pcidev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3600) 	if (!pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3601) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3602) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3603) 	/* This is a user read operation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3604) 	debug->op = LPFC_IDIAG_OP_RD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3605) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3606) 	if (!debug->buffer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3607) 		debug->buffer = kmalloc(LPFC_PCI_BAR_RD_BUF_SIZE, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3608) 	if (!debug->buffer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3609) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3610) 	pbuffer = debug->buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3611) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3612) 	if (*ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3613) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3614) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3615) 	if (idiag.cmd.opcode == LPFC_IDIAG_CMD_BARACC_RD) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3616) 		bar_num   = idiag.cmd.data[IDIAG_BARACC_BAR_NUM_INDX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3617) 		offset    = idiag.cmd.data[IDIAG_BARACC_OFF_SET_INDX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3618) 		acc_range = idiag.cmd.data[IDIAG_BARACC_ACC_MOD_INDX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3619) 		bar_size = idiag.cmd.data[IDIAG_BARACC_BAR_SZE_INDX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3620) 	} else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3621) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3622) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3623) 	if (acc_range == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3624) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3625) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3626) 	if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3627) 	if (if_type == LPFC_SLI_INTF_IF_TYPE_0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3628) 		if (bar_num == IDIAG_BARACC_BAR_0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3629) 			mem_mapped_bar = phba->sli4_hba.conf_regs_memmap_p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3630) 		else if (bar_num == IDIAG_BARACC_BAR_1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3631) 			mem_mapped_bar = phba->sli4_hba.ctrl_regs_memmap_p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3632) 		else if (bar_num == IDIAG_BARACC_BAR_2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3633) 			mem_mapped_bar = phba->sli4_hba.drbl_regs_memmap_p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3634) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3635) 			return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3636) 	} else if (if_type == LPFC_SLI_INTF_IF_TYPE_2) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3637) 		if (bar_num == IDIAG_BARACC_BAR_0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3638) 			mem_mapped_bar = phba->sli4_hba.conf_regs_memmap_p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3639) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3640) 			return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3641) 	} else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3642) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3643) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3644) 	/* Read single PCI bar space register */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3645) 	if (acc_range == SINGLE_WORD) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3646) 		offset_run = offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3647) 		u32val = readl(mem_mapped_bar + offset_run);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3648) 		len += scnprintf(pbuffer+len, LPFC_PCI_BAR_RD_BUF_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3649) 				"%05x: %08x\n", offset_run, u32val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3650) 	} else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3651) 		goto baracc_browse;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3652) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3653) 	return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3654) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3655) baracc_browse:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3656) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3657) 	/* Browse all PCI bar space registers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3658) 	offset_label = idiag.offset.last_rd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3659) 	offset_run = offset_label;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3660) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3661) 	/* Read PCI bar memory mapped space */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3662) 	len += scnprintf(pbuffer+len, LPFC_PCI_BAR_RD_BUF_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3663) 			"%05x: ", offset_label);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3664) 	index = LPFC_PCI_BAR_RD_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3665) 	while (index > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3666) 		u32val = readl(mem_mapped_bar + offset_run);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3667) 		len += scnprintf(pbuffer+len, LPFC_PCI_BAR_RD_BUF_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3668) 				"%08x ", u32val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3669) 		offset_run += sizeof(uint32_t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3670) 		if (acc_range == LPFC_PCI_BAR_BROWSE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3671) 			if (offset_run >= bar_size) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3672) 				len += scnprintf(pbuffer+len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3673) 					LPFC_PCI_BAR_RD_BUF_SIZE-len, "\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3674) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3675) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3676) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3677) 			if (offset_run >= offset +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3678) 			    (acc_range * sizeof(uint32_t))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3679) 				len += scnprintf(pbuffer+len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3680) 					LPFC_PCI_BAR_RD_BUF_SIZE-len, "\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3681) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3682) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3683) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3684) 		index -= sizeof(uint32_t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3685) 		if (!index)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3686) 			len += scnprintf(pbuffer+len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3687) 					LPFC_PCI_BAR_RD_BUF_SIZE-len, "\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3688) 		else if (!(index % (8 * sizeof(uint32_t)))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3689) 			offset_label += (8 * sizeof(uint32_t));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3690) 			len += scnprintf(pbuffer+len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3691) 					LPFC_PCI_BAR_RD_BUF_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3692) 					"\n%05x: ", offset_label);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3693) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3694) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3695) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3696) 	/* Set up the offset for next portion of pci bar read */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3697) 	if (index == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3698) 		idiag.offset.last_rd += LPFC_PCI_BAR_RD_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3699) 		if (acc_range == LPFC_PCI_BAR_BROWSE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3700) 			if (idiag.offset.last_rd >= bar_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3701) 				idiag.offset.last_rd = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3702) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3703) 			if (offset_run >= offset +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3704) 			    (acc_range * sizeof(uint32_t)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3705) 				idiag.offset.last_rd = offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3706) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3707) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3708) 		if (acc_range == LPFC_PCI_BAR_BROWSE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3709) 			idiag.offset.last_rd = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3710) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3711) 			idiag.offset.last_rd = offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3712) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3713) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3714) 	return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3715) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3716) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3717) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3718)  * lpfc_idiag_baracc_write - Syntax check and set up idiag bar access commands
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3719)  * @file: The file pointer to read from.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3720)  * @buf: The buffer to copy the user data from.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3721)  * @nbytes: The number of bytes to get.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3722)  * @ppos: The position in the file to start reading from.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3723)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3724)  * This routine get the debugfs idiag command struct from user space and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3725)  * then perform the syntax check for PCI bar memory mapped space read or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3726)  * write command accordingly. In the case of PCI bar memory mapped space
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3727)  * read command, it sets up the command in the idiag command struct for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3728)  * the debugfs read operation. In the case of PCI bar memorpy mapped space
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3729)  * write operation, it executes the write operation into the PCI bar memory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3730)  * mapped space accordingly.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3731)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3732)  * It returns the @nbytges passing in from debugfs user space when successful.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3733)  * In case of error conditions, it returns proper error code back to the user
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3734)  * space.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3735)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3736) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3737) lpfc_idiag_baracc_write(struct file *file, const char __user *buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3738) 			size_t nbytes, loff_t *ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3739) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3740) 	struct lpfc_debug *debug = file->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3741) 	struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3742) 	uint32_t bar_num, bar_size, offset, value, acc_range;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3743) 	struct pci_dev *pdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3744) 	void __iomem *mem_mapped_bar;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3745) 	uint32_t if_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3746) 	uint32_t u32val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3747) 	int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3748) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3749) 	pdev = phba->pcidev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3750) 	if (!pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3751) 		return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3752) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3753) 	/* This is a user write operation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3754) 	debug->op = LPFC_IDIAG_OP_WR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3755) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3756) 	rc = lpfc_idiag_cmd_get(buf, nbytes, &idiag.cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3757) 	if (rc < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3758) 		return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3759) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3760) 	if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3761) 	bar_num = idiag.cmd.data[IDIAG_BARACC_BAR_NUM_INDX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3762) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3763) 	if (if_type == LPFC_SLI_INTF_IF_TYPE_0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3764) 		if ((bar_num != IDIAG_BARACC_BAR_0) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3765) 		    (bar_num != IDIAG_BARACC_BAR_1) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3766) 		    (bar_num != IDIAG_BARACC_BAR_2))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3767) 			goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3768) 	} else if (if_type == LPFC_SLI_INTF_IF_TYPE_2) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3769) 		if (bar_num != IDIAG_BARACC_BAR_0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3770) 			goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3771) 	} else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3772) 		goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3773) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3774) 	if (if_type == LPFC_SLI_INTF_IF_TYPE_0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3775) 		if (bar_num == IDIAG_BARACC_BAR_0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3776) 			idiag.cmd.data[IDIAG_BARACC_BAR_SZE_INDX] =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3777) 				LPFC_PCI_IF0_BAR0_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3778) 			mem_mapped_bar = phba->sli4_hba.conf_regs_memmap_p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3779) 		} else if (bar_num == IDIAG_BARACC_BAR_1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3780) 			idiag.cmd.data[IDIAG_BARACC_BAR_SZE_INDX] =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3781) 				LPFC_PCI_IF0_BAR1_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3782) 			mem_mapped_bar = phba->sli4_hba.ctrl_regs_memmap_p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3783) 		} else if (bar_num == IDIAG_BARACC_BAR_2) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3784) 			idiag.cmd.data[IDIAG_BARACC_BAR_SZE_INDX] =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3785) 				LPFC_PCI_IF0_BAR2_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3786) 			mem_mapped_bar = phba->sli4_hba.drbl_regs_memmap_p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3787) 		} else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3788) 			goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3789) 	} else if (if_type == LPFC_SLI_INTF_IF_TYPE_2) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3790) 		if (bar_num == IDIAG_BARACC_BAR_0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3791) 			idiag.cmd.data[IDIAG_BARACC_BAR_SZE_INDX] =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3792) 				LPFC_PCI_IF2_BAR0_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3793) 			mem_mapped_bar = phba->sli4_hba.conf_regs_memmap_p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3794) 		} else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3795) 			goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3796) 	} else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3797) 		goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3798) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3799) 	offset = idiag.cmd.data[IDIAG_BARACC_OFF_SET_INDX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3800) 	if (offset % sizeof(uint32_t))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3801) 		goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3802) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3803) 	bar_size = idiag.cmd.data[IDIAG_BARACC_BAR_SZE_INDX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3804) 	if (idiag.cmd.opcode == LPFC_IDIAG_CMD_BARACC_RD) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3805) 		/* Sanity check on PCI config read command line arguments */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3806) 		if (rc != LPFC_PCI_BAR_RD_CMD_ARG)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3807) 			goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3808) 		acc_range = idiag.cmd.data[IDIAG_BARACC_ACC_MOD_INDX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3809) 		if (acc_range == LPFC_PCI_BAR_BROWSE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3810) 			if (offset > bar_size - sizeof(uint32_t))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3811) 				goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3812) 			/* Starting offset to browse */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3813) 			idiag.offset.last_rd = offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3814) 		} else if (acc_range > SINGLE_WORD) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3815) 			if (offset + acc_range * sizeof(uint32_t) > bar_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3816) 				goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3817) 			/* Starting offset to browse */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3818) 			idiag.offset.last_rd = offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3819) 		} else if (acc_range != SINGLE_WORD)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3820) 			goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3821) 	} else if (idiag.cmd.opcode == LPFC_IDIAG_CMD_BARACC_WR ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3822) 		   idiag.cmd.opcode == LPFC_IDIAG_CMD_BARACC_ST ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3823) 		   idiag.cmd.opcode == LPFC_IDIAG_CMD_BARACC_CL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3824) 		/* Sanity check on PCI bar write command line arguments */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3825) 		if (rc != LPFC_PCI_BAR_WR_CMD_ARG)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3826) 			goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3827) 		/* Write command to PCI bar space, read-modify-write */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3828) 		acc_range = SINGLE_WORD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3829) 		value = idiag.cmd.data[IDIAG_BARACC_REG_VAL_INDX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3830) 		if (idiag.cmd.opcode == LPFC_IDIAG_CMD_BARACC_WR) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3831) 			writel(value, mem_mapped_bar + offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3832) 			readl(mem_mapped_bar + offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3833) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3834) 		if (idiag.cmd.opcode == LPFC_IDIAG_CMD_BARACC_ST) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3835) 			u32val = readl(mem_mapped_bar + offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3836) 			u32val |= value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3837) 			writel(u32val, mem_mapped_bar + offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3838) 			readl(mem_mapped_bar + offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3839) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3840) 		if (idiag.cmd.opcode == LPFC_IDIAG_CMD_BARACC_CL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3841) 			u32val = readl(mem_mapped_bar + offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3842) 			u32val &= ~value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3843) 			writel(u32val, mem_mapped_bar + offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3844) 			readl(mem_mapped_bar + offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3845) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3846) 	} else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3847) 		/* All other opecodes are illegal for now */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3848) 		goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3849) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3850) 	return nbytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3851) error_out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3852) 	memset(&idiag, 0, sizeof(idiag));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3853) 	return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3854) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3855) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3856) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3857) __lpfc_idiag_print_wq(struct lpfc_queue *qp, char *wqtype,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3858) 			char *pbuffer, int len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3859) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3860) 	if (!qp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3861) 		return len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3862) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3863) 	len += scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3864) 			"\t\t%s WQ info: ", wqtype);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3865) 	len += scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3866) 			"AssocCQID[%04d]: WQ-STAT[oflow:x%x posted:x%llx]\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3867) 			qp->assoc_qid, qp->q_cnt_1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3868) 			(unsigned long long)qp->q_cnt_4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3869) 	len += scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3870) 			"\t\tWQID[%02d], QE-CNT[%04d], QE-SZ[%04d], "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3871) 			"HST-IDX[%04d], PRT-IDX[%04d], NTFI[%03d]",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3872) 			qp->queue_id, qp->entry_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3873) 			qp->entry_size, qp->host_index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3874) 			qp->hba_index, qp->notify_interval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3875) 	len +=  scnprintf(pbuffer + len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3876) 			LPFC_QUE_INFO_GET_BUF_SIZE - len, "\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3877) 	return len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3878) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3879) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3880) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3881) lpfc_idiag_wqs_for_cq(struct lpfc_hba *phba, char *wqtype, char *pbuffer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3882) 		int *len, int max_cnt, int cq_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3883) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3884) 	struct lpfc_queue *qp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3885) 	int qidx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3886) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3887) 	for (qidx = 0; qidx < phba->cfg_hdw_queue; qidx++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3888) 		qp = phba->sli4_hba.hdwq[qidx].io_wq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3889) 		if (qp->assoc_qid != cq_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3890) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3891) 		*len = __lpfc_idiag_print_wq(qp, wqtype, pbuffer, *len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3892) 		if (*len >= max_cnt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3893) 			return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3894) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3895) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3896) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3897) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3898) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3899) __lpfc_idiag_print_cq(struct lpfc_queue *qp, char *cqtype,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3900) 			char *pbuffer, int len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3901) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3902) 	if (!qp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3903) 		return len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3904) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3905) 	len += scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3906) 			"\t%s CQ info: ", cqtype);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3907) 	len += scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3908) 			"AssocEQID[%02d]: CQ STAT[max:x%x relw:x%x "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3909) 			"xabt:x%x wq:x%llx]\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3910) 			qp->assoc_qid, qp->q_cnt_1, qp->q_cnt_2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3911) 			qp->q_cnt_3, (unsigned long long)qp->q_cnt_4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3912) 	len += scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3913) 			"\tCQID[%02d], QE-CNT[%04d], QE-SZ[%04d], "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3914) 			"HST-IDX[%04d], NTFI[%03d], PLMT[%03d]",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3915) 			qp->queue_id, qp->entry_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3916) 			qp->entry_size, qp->host_index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3917) 			qp->notify_interval, qp->max_proc_limit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3918) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3919) 	len +=  scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3920) 			"\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3921) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3922) 	return len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3923) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3924) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3925) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3926) __lpfc_idiag_print_rqpair(struct lpfc_queue *qp, struct lpfc_queue *datqp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3927) 			char *rqtype, char *pbuffer, int len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3928) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3929) 	if (!qp || !datqp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3930) 		return len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3931) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3932) 	len += scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3933) 			"\t\t%s RQ info: ", rqtype);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3934) 	len += scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3935) 			"AssocCQID[%02d]: RQ-STAT[nopost:x%x nobuf:x%x "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3936) 			"posted:x%x rcv:x%llx]\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3937) 			qp->assoc_qid, qp->q_cnt_1, qp->q_cnt_2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3938) 			qp->q_cnt_3, (unsigned long long)qp->q_cnt_4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3939) 	len += scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3940) 			"\t\tHQID[%02d], QE-CNT[%04d], QE-SZ[%04d], "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3941) 			"HST-IDX[%04d], PRT-IDX[%04d], NTFI[%03d]\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3942) 			qp->queue_id, qp->entry_count, qp->entry_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3943) 			qp->host_index, qp->hba_index, qp->notify_interval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3944) 	len += scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3945) 			"\t\tDQID[%02d], QE-CNT[%04d], QE-SZ[%04d], "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3946) 			"HST-IDX[%04d], PRT-IDX[%04d], NTFI[%03d]\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3947) 			datqp->queue_id, datqp->entry_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3948) 			datqp->entry_size, datqp->host_index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3949) 			datqp->hba_index, datqp->notify_interval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3950) 	return len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3951) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3952) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3953) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3954) lpfc_idiag_cqs_for_eq(struct lpfc_hba *phba, char *pbuffer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3955) 		int *len, int max_cnt, int eqidx, int eq_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3956) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3957) 	struct lpfc_queue *qp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3958) 	int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3959) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3960) 	qp = phba->sli4_hba.hdwq[eqidx].io_cq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3961) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3962) 	*len = __lpfc_idiag_print_cq(qp, "IO", pbuffer, *len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3963) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3964) 	/* Reset max counter */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3965) 	qp->CQ_max_cqe = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3966) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3967) 	if (*len >= max_cnt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3968) 		return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3969) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3970) 	rc = lpfc_idiag_wqs_for_cq(phba, "IO", pbuffer, len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3971) 				   max_cnt, qp->queue_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3972) 	if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3973) 		return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3974) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3975) 	if ((eqidx < phba->cfg_nvmet_mrq) && phba->nvmet_support) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3976) 		/* NVMET CQset */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3977) 		qp = phba->sli4_hba.nvmet_cqset[eqidx];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3978) 		*len = __lpfc_idiag_print_cq(qp, "NVMET CQset", pbuffer, *len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3979) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3980) 		/* Reset max counter */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3981) 		qp->CQ_max_cqe = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3982) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3983) 		if (*len >= max_cnt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3984) 			return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3985) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3986) 		/* RQ header */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3987) 		qp = phba->sli4_hba.nvmet_mrq_hdr[eqidx];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3988) 		*len = __lpfc_idiag_print_rqpair(qp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3989) 				phba->sli4_hba.nvmet_mrq_data[eqidx],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3990) 				"NVMET MRQ", pbuffer, *len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3991) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3992) 		if (*len >= max_cnt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3993) 			return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3994) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3995) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3996) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3997) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3998) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3999) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4000) __lpfc_idiag_print_eq(struct lpfc_queue *qp, char *eqtype,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4001) 			char *pbuffer, int len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4002) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4003) 	if (!qp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4004) 		return len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4005) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4006) 	len += scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4007) 			"\n%s EQ info: EQ-STAT[max:x%x noE:x%x "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4008) 			"cqe_proc:x%x eqe_proc:x%llx eqd %d]\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4009) 			eqtype, qp->q_cnt_1, qp->q_cnt_2, qp->q_cnt_3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4010) 			(unsigned long long)qp->q_cnt_4, qp->q_mode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4011) 	len += scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4012) 			"EQID[%02d], QE-CNT[%04d], QE-SZ[%04d], "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4013) 			"HST-IDX[%04d], NTFI[%03d], PLMT[%03d], AFFIN[%03d]",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4014) 			qp->queue_id, qp->entry_count, qp->entry_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4015) 			qp->host_index, qp->notify_interval,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4016) 			qp->max_proc_limit, qp->chann);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4017) 	len +=  scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4018) 			"\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4019) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4020) 	return len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4021) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4022) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4023) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4024)  * lpfc_idiag_queinfo_read - idiag debugfs read queue information
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4025)  * @file: The file pointer to read from.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4026)  * @buf: The buffer to copy the data to.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4027)  * @nbytes: The number of bytes to read.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4028)  * @ppos: The position in the file to start reading from.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4029)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4030)  * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4031)  * This routine reads data from the @phba SLI4 PCI function queue information,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4032)  * and copies to user @buf.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4033)  * This routine only returns 1 EQs worth of information. It remembers the last
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4034)  * EQ read and jumps to the next EQ. Thus subsequent calls to queInfo will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4035)  * retrieve all EQs allocated for the phba.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4036)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4037)  * Returns:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4038)  * This function returns the amount of data that was read (this could be less
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4039)  * than @nbytes if the end of the file was reached) or a negative error value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4040)  **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4041) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4042) lpfc_idiag_queinfo_read(struct file *file, char __user *buf, size_t nbytes,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4043) 			loff_t *ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4044) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4045) 	struct lpfc_debug *debug = file->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4046) 	struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4047) 	char *pbuffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4048) 	int max_cnt, rc, x, len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4049) 	struct lpfc_queue *qp = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4050) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4051) 	if (!debug->buffer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4052) 		debug->buffer = kmalloc(LPFC_QUE_INFO_GET_BUF_SIZE, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4053) 	if (!debug->buffer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4054) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4055) 	pbuffer = debug->buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4056) 	max_cnt = LPFC_QUE_INFO_GET_BUF_SIZE - 256;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4057) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4058) 	if (*ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4059) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4060) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4061) 	spin_lock_irq(&phba->hbalock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4062) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4063) 	/* Fast-path event queue */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4064) 	if (phba->sli4_hba.hdwq && phba->cfg_hdw_queue) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4065) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4066) 		x = phba->lpfc_idiag_last_eq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4067) 		phba->lpfc_idiag_last_eq++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4068) 		if (phba->lpfc_idiag_last_eq >= phba->cfg_hdw_queue)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4069) 			phba->lpfc_idiag_last_eq = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4070) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4071) 		len += scnprintf(pbuffer + len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4072) 				 LPFC_QUE_INFO_GET_BUF_SIZE - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4073) 				 "HDWQ %d out of %d HBA HDWQs\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4074) 				 x, phba->cfg_hdw_queue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4075) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4076) 		/* Fast-path EQ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4077) 		qp = phba->sli4_hba.hdwq[x].hba_eq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4078) 		if (!qp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4079) 			goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4080) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4081) 		len = __lpfc_idiag_print_eq(qp, "HBA", pbuffer, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4082) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4083) 		/* Reset max counter */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4084) 		qp->EQ_max_eqe = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4085) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4086) 		if (len >= max_cnt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4087) 			goto too_big;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4088) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4089) 		/* will dump both fcp and nvme cqs/wqs for the eq */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4090) 		rc = lpfc_idiag_cqs_for_eq(phba, pbuffer, &len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4091) 			max_cnt, x, qp->queue_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4092) 		if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4093) 			goto too_big;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4094) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4095) 		/* Only EQ 0 has slow path CQs configured */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4096) 		if (x)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4097) 			goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4098) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4099) 		/* Slow-path mailbox CQ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4100) 		qp = phba->sli4_hba.mbx_cq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4101) 		len = __lpfc_idiag_print_cq(qp, "MBX", pbuffer, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4102) 		if (len >= max_cnt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4103) 			goto too_big;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4104) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4105) 		/* Slow-path MBOX MQ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4106) 		qp = phba->sli4_hba.mbx_wq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4107) 		len = __lpfc_idiag_print_wq(qp, "MBX", pbuffer, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4108) 		if (len >= max_cnt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4109) 			goto too_big;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4110) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4111) 		/* Slow-path ELS response CQ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4112) 		qp = phba->sli4_hba.els_cq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4113) 		len = __lpfc_idiag_print_cq(qp, "ELS", pbuffer, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4114) 		/* Reset max counter */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4115) 		if (qp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4116) 			qp->CQ_max_cqe = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4117) 		if (len >= max_cnt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4118) 			goto too_big;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4119) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4120) 		/* Slow-path ELS WQ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4121) 		qp = phba->sli4_hba.els_wq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4122) 		len = __lpfc_idiag_print_wq(qp, "ELS", pbuffer, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4123) 		if (len >= max_cnt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4124) 			goto too_big;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4125) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4126) 		qp = phba->sli4_hba.hdr_rq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4127) 		len = __lpfc_idiag_print_rqpair(qp, phba->sli4_hba.dat_rq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4128) 						"ELS RQpair", pbuffer, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4129) 		if (len >= max_cnt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4130) 			goto too_big;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4131) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4132) 		/* Slow-path NVME LS response CQ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4133) 		qp = phba->sli4_hba.nvmels_cq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4134) 		len = __lpfc_idiag_print_cq(qp, "NVME LS",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4135) 						pbuffer, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4136) 		/* Reset max counter */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4137) 		if (qp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4138) 			qp->CQ_max_cqe = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4139) 		if (len >= max_cnt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4140) 			goto too_big;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4141) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4142) 		/* Slow-path NVME LS WQ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4143) 		qp = phba->sli4_hba.nvmels_wq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4144) 		len = __lpfc_idiag_print_wq(qp, "NVME LS",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4145) 						pbuffer, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4146) 		if (len >= max_cnt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4147) 			goto too_big;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4148) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4149) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4150) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4151) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4152) 	spin_unlock_irq(&phba->hbalock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4153) 	return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4154) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4155) too_big:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4156) 	len +=  scnprintf(pbuffer + len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4157) 		LPFC_QUE_INFO_GET_BUF_SIZE - len, "Truncated ...\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4158) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4159) 	spin_unlock_irq(&phba->hbalock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4160) 	return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4161) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4162) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4163) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4164)  * lpfc_idiag_que_param_check - queue access command parameter sanity check
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4165)  * @q: The pointer to queue structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4166)  * @index: The index into a queue entry.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4167)  * @count: The number of queue entries to access.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4168)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4169)  * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4170)  * The routine performs sanity check on device queue access method commands.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4171)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4172)  * Returns:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4173)  * This function returns -EINVAL when fails the sanity check, otherwise, it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4174)  * returns 0.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4175)  **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4176) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4177) lpfc_idiag_que_param_check(struct lpfc_queue *q, int index, int count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4178) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4179) 	/* Only support single entry read or browsing */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4180) 	if ((count != 1) && (count != LPFC_QUE_ACC_BROWSE))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4181) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4182) 	if (index > q->entry_count - 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4183) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4184) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4185) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4186) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4187) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4188)  * lpfc_idiag_queacc_read_qe - read a single entry from the given queue index
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4189)  * @pbuffer: The pointer to buffer to copy the read data into.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4190)  * @pque: The pointer to the queue to be read.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4191)  * @index: The index into the queue entry.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4192)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4193)  * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4194)  * This routine reads out a single entry from the given queue's index location
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4195)  * and copies it into the buffer provided.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4196)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4197)  * Returns:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4198)  * This function returns 0 when it fails, otherwise, it returns the length of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4199)  * the data read into the buffer provided.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4200)  **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4201) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4202) lpfc_idiag_queacc_read_qe(char *pbuffer, int len, struct lpfc_queue *pque,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4203) 			  uint32_t index)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4204) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4205) 	int offset, esize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4206) 	uint32_t *pentry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4207) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4208) 	if (!pbuffer || !pque)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4209) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4210) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4211) 	esize = pque->entry_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4212) 	len += scnprintf(pbuffer+len, LPFC_QUE_ACC_BUF_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4213) 			"QE-INDEX[%04d]:\n", index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4214) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4215) 	offset = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4216) 	pentry = lpfc_sli4_qe(pque, index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4217) 	while (esize > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4218) 		len += scnprintf(pbuffer+len, LPFC_QUE_ACC_BUF_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4219) 				"%08x ", *pentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4220) 		pentry++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4221) 		offset += sizeof(uint32_t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4222) 		esize -= sizeof(uint32_t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4223) 		if (esize > 0 && !(offset % (4 * sizeof(uint32_t))))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4224) 			len += scnprintf(pbuffer+len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4225) 					LPFC_QUE_ACC_BUF_SIZE-len, "\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4226) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4227) 	len += scnprintf(pbuffer+len, LPFC_QUE_ACC_BUF_SIZE-len, "\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4228) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4229) 	return len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4230) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4231) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4232) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4233)  * lpfc_idiag_queacc_read - idiag debugfs read port queue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4234)  * @file: The file pointer to read from.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4235)  * @buf: The buffer to copy the data to.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4236)  * @nbytes: The number of bytes to read.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4237)  * @ppos: The position in the file to start reading from.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4238)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4239)  * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4240)  * This routine reads data from the @phba device queue memory according to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4241)  * idiag command, and copies to user @buf. Depending on the queue dump read
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4242)  * command setup, it does either a single queue entry read or browing through
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4243)  * all entries of the queue.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4244)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4245)  * Returns:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4246)  * This function returns the amount of data that was read (this could be less
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4247)  * than @nbytes if the end of the file was reached) or a negative error value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4248)  **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4249) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4250) lpfc_idiag_queacc_read(struct file *file, char __user *buf, size_t nbytes,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4251) 		       loff_t *ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4252) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4253) 	struct lpfc_debug *debug = file->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4254) 	uint32_t last_index, index, count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4255) 	struct lpfc_queue *pque = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4256) 	char *pbuffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4257) 	int len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4258) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4259) 	/* This is a user read operation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4260) 	debug->op = LPFC_IDIAG_OP_RD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4261) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4262) 	if (!debug->buffer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4263) 		debug->buffer = kmalloc(LPFC_QUE_ACC_BUF_SIZE, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4264) 	if (!debug->buffer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4265) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4266) 	pbuffer = debug->buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4267) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4268) 	if (*ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4269) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4270) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4271) 	if (idiag.cmd.opcode == LPFC_IDIAG_CMD_QUEACC_RD) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4272) 		index = idiag.cmd.data[IDIAG_QUEACC_INDEX_INDX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4273) 		count = idiag.cmd.data[IDIAG_QUEACC_COUNT_INDX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4274) 		pque = (struct lpfc_queue *)idiag.ptr_private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4275) 	} else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4276) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4277) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4278) 	/* Browse the queue starting from index */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4279) 	if (count == LPFC_QUE_ACC_BROWSE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4280) 		goto que_browse;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4281) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4282) 	/* Read a single entry from the queue */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4283) 	len = lpfc_idiag_queacc_read_qe(pbuffer, len, pque, index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4284) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4285) 	return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4286) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4287) que_browse:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4288) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4289) 	/* Browse all entries from the queue */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4290) 	last_index = idiag.offset.last_rd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4291) 	index = last_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4292) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4293) 	while (len < LPFC_QUE_ACC_SIZE - pque->entry_size) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4294) 		len = lpfc_idiag_queacc_read_qe(pbuffer, len, pque, index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4295) 		index++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4296) 		if (index > pque->entry_count - 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4297) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4298) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4299) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4300) 	/* Set up the offset for next portion of pci cfg read */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4301) 	if (index > pque->entry_count - 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4302) 		index = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4303) 	idiag.offset.last_rd = index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4304) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4305) 	return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4306) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4307) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4308) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4309)  * lpfc_idiag_queacc_write - Syntax check and set up idiag queacc commands
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4310)  * @file: The file pointer to read from.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4311)  * @buf: The buffer to copy the user data from.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4312)  * @nbytes: The number of bytes to get.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4313)  * @ppos: The position in the file to start reading from.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4314)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4315)  * This routine get the debugfs idiag command struct from user space and then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4316)  * perform the syntax check for port queue read (dump) or write (set) command
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4317)  * accordingly. In the case of port queue read command, it sets up the command
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4318)  * in the idiag command struct for the following debugfs read operation. In
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4319)  * the case of port queue write operation, it executes the write operation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4320)  * into the port queue entry accordingly.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4321)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4322)  * It returns the @nbytges passing in from debugfs user space when successful.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4323)  * In case of error conditions, it returns proper error code back to the user
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4324)  * space.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4325)  **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4326) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4327) lpfc_idiag_queacc_write(struct file *file, const char __user *buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4328) 			size_t nbytes, loff_t *ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4329) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4330) 	struct lpfc_debug *debug = file->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4331) 	struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4332) 	uint32_t qidx, quetp, queid, index, count, offset, value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4333) 	uint32_t *pentry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4334) 	struct lpfc_queue *pque, *qp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4335) 	int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4336) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4337) 	/* This is a user write operation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4338) 	debug->op = LPFC_IDIAG_OP_WR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4339) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4340) 	rc = lpfc_idiag_cmd_get(buf, nbytes, &idiag.cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4341) 	if (rc < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4342) 		return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4343) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4344) 	/* Get and sanity check on command feilds */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4345) 	quetp  = idiag.cmd.data[IDIAG_QUEACC_QUETP_INDX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4346) 	queid  = idiag.cmd.data[IDIAG_QUEACC_QUEID_INDX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4347) 	index  = idiag.cmd.data[IDIAG_QUEACC_INDEX_INDX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4348) 	count  = idiag.cmd.data[IDIAG_QUEACC_COUNT_INDX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4349) 	offset = idiag.cmd.data[IDIAG_QUEACC_OFFST_INDX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4350) 	value  = idiag.cmd.data[IDIAG_QUEACC_VALUE_INDX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4351) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4352) 	/* Sanity check on command line arguments */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4353) 	if (idiag.cmd.opcode == LPFC_IDIAG_CMD_QUEACC_WR ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4354) 	    idiag.cmd.opcode == LPFC_IDIAG_CMD_QUEACC_ST ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4355) 	    idiag.cmd.opcode == LPFC_IDIAG_CMD_QUEACC_CL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4356) 		if (rc != LPFC_QUE_ACC_WR_CMD_ARG)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4357) 			goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4358) 		if (count != 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4359) 			goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4360) 	} else if (idiag.cmd.opcode == LPFC_IDIAG_CMD_QUEACC_RD) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4361) 		if (rc != LPFC_QUE_ACC_RD_CMD_ARG)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4362) 			goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4363) 	} else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4364) 		goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4365) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4366) 	switch (quetp) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4367) 	case LPFC_IDIAG_EQ:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4368) 		/* HBA event queue */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4369) 		if (phba->sli4_hba.hdwq) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4370) 			for (qidx = 0; qidx < phba->cfg_hdw_queue; qidx++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4371) 				qp = phba->sli4_hba.hdwq[qidx].hba_eq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4372) 				if (qp && qp->queue_id == queid) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4373) 					/* Sanity check */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4374) 					rc = lpfc_idiag_que_param_check(qp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4375) 						index, count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4376) 					if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4377) 						goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4378) 					idiag.ptr_private = qp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4379) 					goto pass_check;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4380) 				}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4381) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4382) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4383) 		goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4384) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4385) 	case LPFC_IDIAG_CQ:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4386) 		/* MBX complete queue */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4387) 		if (phba->sli4_hba.mbx_cq &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4388) 		    phba->sli4_hba.mbx_cq->queue_id == queid) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4389) 			/* Sanity check */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4390) 			rc = lpfc_idiag_que_param_check(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4391) 					phba->sli4_hba.mbx_cq, index, count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4392) 			if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4393) 				goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4394) 			idiag.ptr_private = phba->sli4_hba.mbx_cq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4395) 			goto pass_check;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4396) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4397) 		/* ELS complete queue */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4398) 		if (phba->sli4_hba.els_cq &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4399) 		    phba->sli4_hba.els_cq->queue_id == queid) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4400) 			/* Sanity check */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4401) 			rc = lpfc_idiag_que_param_check(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4402) 					phba->sli4_hba.els_cq, index, count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4403) 			if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4404) 				goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4405) 			idiag.ptr_private = phba->sli4_hba.els_cq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4406) 			goto pass_check;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4407) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4408) 		/* NVME LS complete queue */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4409) 		if (phba->sli4_hba.nvmels_cq &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4410) 		    phba->sli4_hba.nvmels_cq->queue_id == queid) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4411) 			/* Sanity check */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4412) 			rc = lpfc_idiag_que_param_check(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4413) 					phba->sli4_hba.nvmels_cq, index, count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4414) 			if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4415) 				goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4416) 			idiag.ptr_private = phba->sli4_hba.nvmels_cq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4417) 			goto pass_check;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4418) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4419) 		/* FCP complete queue */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4420) 		if (phba->sli4_hba.hdwq) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4421) 			for (qidx = 0; qidx < phba->cfg_hdw_queue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4422) 								qidx++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4423) 				qp = phba->sli4_hba.hdwq[qidx].io_cq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4424) 				if (qp && qp->queue_id == queid) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4425) 					/* Sanity check */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4426) 					rc = lpfc_idiag_que_param_check(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4427) 						qp, index, count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4428) 					if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4429) 						goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4430) 					idiag.ptr_private = qp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4431) 					goto pass_check;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4432) 				}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4433) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4434) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4435) 		goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4436) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4437) 	case LPFC_IDIAG_MQ:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4438) 		/* MBX work queue */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4439) 		if (phba->sli4_hba.mbx_wq &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4440) 		    phba->sli4_hba.mbx_wq->queue_id == queid) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4441) 			/* Sanity check */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4442) 			rc = lpfc_idiag_que_param_check(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4443) 					phba->sli4_hba.mbx_wq, index, count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4444) 			if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4445) 				goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4446) 			idiag.ptr_private = phba->sli4_hba.mbx_wq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4447) 			goto pass_check;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4448) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4449) 		goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4450) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4451) 	case LPFC_IDIAG_WQ:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4452) 		/* ELS work queue */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4453) 		if (phba->sli4_hba.els_wq &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4454) 		    phba->sli4_hba.els_wq->queue_id == queid) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4455) 			/* Sanity check */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4456) 			rc = lpfc_idiag_que_param_check(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4457) 					phba->sli4_hba.els_wq, index, count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4458) 			if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4459) 				goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4460) 			idiag.ptr_private = phba->sli4_hba.els_wq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4461) 			goto pass_check;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4462) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4463) 		/* NVME LS work queue */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4464) 		if (phba->sli4_hba.nvmels_wq &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4465) 		    phba->sli4_hba.nvmels_wq->queue_id == queid) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4466) 			/* Sanity check */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4467) 			rc = lpfc_idiag_que_param_check(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4468) 					phba->sli4_hba.nvmels_wq, index, count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4469) 			if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4470) 				goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4471) 			idiag.ptr_private = phba->sli4_hba.nvmels_wq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4472) 			goto pass_check;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4473) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4474) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4475) 		if (phba->sli4_hba.hdwq) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4476) 			/* FCP/SCSI work queue */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4477) 			for (qidx = 0; qidx < phba->cfg_hdw_queue; qidx++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4478) 				qp = phba->sli4_hba.hdwq[qidx].io_wq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4479) 				if (qp && qp->queue_id == queid) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4480) 					/* Sanity check */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4481) 					rc = lpfc_idiag_que_param_check(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4482) 						qp, index, count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4483) 					if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4484) 						goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4485) 					idiag.ptr_private = qp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4486) 					goto pass_check;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4487) 				}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4488) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4489) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4490) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4491) 		goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4492) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4493) 	case LPFC_IDIAG_RQ:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4494) 		/* HDR queue */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4495) 		if (phba->sli4_hba.hdr_rq &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4496) 		    phba->sli4_hba.hdr_rq->queue_id == queid) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4497) 			/* Sanity check */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4498) 			rc = lpfc_idiag_que_param_check(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4499) 					phba->sli4_hba.hdr_rq, index, count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4500) 			if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4501) 				goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4502) 			idiag.ptr_private = phba->sli4_hba.hdr_rq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4503) 			goto pass_check;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4504) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4505) 		/* DAT queue */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4506) 		if (phba->sli4_hba.dat_rq &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4507) 		    phba->sli4_hba.dat_rq->queue_id == queid) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4508) 			/* Sanity check */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4509) 			rc = lpfc_idiag_que_param_check(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4510) 					phba->sli4_hba.dat_rq, index, count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4511) 			if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4512) 				goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4513) 			idiag.ptr_private = phba->sli4_hba.dat_rq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4514) 			goto pass_check;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4515) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4516) 		goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4517) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4518) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4519) 		goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4520) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4521) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4522) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4523) pass_check:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4524) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4525) 	if (idiag.cmd.opcode == LPFC_IDIAG_CMD_QUEACC_RD) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4526) 		if (count == LPFC_QUE_ACC_BROWSE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4527) 			idiag.offset.last_rd = index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4528) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4529) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4530) 	if (idiag.cmd.opcode == LPFC_IDIAG_CMD_QUEACC_WR ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4531) 	    idiag.cmd.opcode == LPFC_IDIAG_CMD_QUEACC_ST ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4532) 	    idiag.cmd.opcode == LPFC_IDIAG_CMD_QUEACC_CL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4533) 		/* Additional sanity checks on write operation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4534) 		pque = (struct lpfc_queue *)idiag.ptr_private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4535) 		if (offset > pque->entry_size/sizeof(uint32_t) - 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4536) 			goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4537) 		pentry = lpfc_sli4_qe(pque, index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4538) 		pentry += offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4539) 		if (idiag.cmd.opcode == LPFC_IDIAG_CMD_QUEACC_WR)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4540) 			*pentry = value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4541) 		if (idiag.cmd.opcode == LPFC_IDIAG_CMD_QUEACC_ST)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4542) 			*pentry |= value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4543) 		if (idiag.cmd.opcode == LPFC_IDIAG_CMD_QUEACC_CL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4544) 			*pentry &= ~value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4545) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4546) 	return nbytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4547) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4548) error_out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4549) 	/* Clean out command structure on command error out */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4550) 	memset(&idiag, 0, sizeof(idiag));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4551) 	return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4552) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4553) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4554) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4555)  * lpfc_idiag_drbacc_read_reg - idiag debugfs read a doorbell register
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4556)  * @phba: The pointer to hba structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4557)  * @pbuffer: The pointer to the buffer to copy the data to.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4558)  * @len: The length of bytes to copied.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4559)  * @drbregid: The id to doorbell registers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4560)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4561)  * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4562)  * This routine reads a doorbell register and copies its content to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4563)  * user buffer pointed to by @pbuffer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4564)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4565)  * Returns:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4566)  * This function returns the amount of data that was copied into @pbuffer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4567)  **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4568) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4569) lpfc_idiag_drbacc_read_reg(struct lpfc_hba *phba, char *pbuffer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4570) 			   int len, uint32_t drbregid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4571) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4572) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4573) 	if (!pbuffer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4574) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4575) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4576) 	switch (drbregid) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4577) 	case LPFC_DRB_EQ:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4578) 		len += scnprintf(pbuffer + len, LPFC_DRB_ACC_BUF_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4579) 				"EQ-DRB-REG: 0x%08x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4580) 				readl(phba->sli4_hba.EQDBregaddr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4581) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4582) 	case LPFC_DRB_CQ:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4583) 		len += scnprintf(pbuffer + len, LPFC_DRB_ACC_BUF_SIZE - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4584) 				"CQ-DRB-REG: 0x%08x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4585) 				readl(phba->sli4_hba.CQDBregaddr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4586) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4587) 	case LPFC_DRB_MQ:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4588) 		len += scnprintf(pbuffer+len, LPFC_DRB_ACC_BUF_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4589) 				"MQ-DRB-REG:   0x%08x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4590) 				readl(phba->sli4_hba.MQDBregaddr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4591) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4592) 	case LPFC_DRB_WQ:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4593) 		len += scnprintf(pbuffer+len, LPFC_DRB_ACC_BUF_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4594) 				"WQ-DRB-REG:   0x%08x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4595) 				readl(phba->sli4_hba.WQDBregaddr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4596) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4597) 	case LPFC_DRB_RQ:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4598) 		len += scnprintf(pbuffer+len, LPFC_DRB_ACC_BUF_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4599) 				"RQ-DRB-REG:   0x%08x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4600) 				readl(phba->sli4_hba.RQDBregaddr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4601) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4602) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4603) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4604) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4605) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4606) 	return len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4607) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4608) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4609) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4610)  * lpfc_idiag_drbacc_read - idiag debugfs read port doorbell
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4611)  * @file: The file pointer to read from.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4612)  * @buf: The buffer to copy the data to.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4613)  * @nbytes: The number of bytes to read.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4614)  * @ppos: The position in the file to start reading from.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4615)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4616)  * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4617)  * This routine reads data from the @phba device doorbell register according
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4618)  * to the idiag command, and copies to user @buf. Depending on the doorbell
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4619)  * register read command setup, it does either a single doorbell register
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4620)  * read or dump all doorbell registers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4621)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4622)  * Returns:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4623)  * This function returns the amount of data that was read (this could be less
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4624)  * than @nbytes if the end of the file was reached) or a negative error value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4625)  **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4626) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4627) lpfc_idiag_drbacc_read(struct file *file, char __user *buf, size_t nbytes,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4628) 		       loff_t *ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4629) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4630) 	struct lpfc_debug *debug = file->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4631) 	struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4632) 	uint32_t drb_reg_id, i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4633) 	char *pbuffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4634) 	int len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4635) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4636) 	/* This is a user read operation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4637) 	debug->op = LPFC_IDIAG_OP_RD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4638) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4639) 	if (!debug->buffer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4640) 		debug->buffer = kmalloc(LPFC_DRB_ACC_BUF_SIZE, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4641) 	if (!debug->buffer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4642) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4643) 	pbuffer = debug->buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4644) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4645) 	if (*ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4646) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4647) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4648) 	if (idiag.cmd.opcode == LPFC_IDIAG_CMD_DRBACC_RD)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4649) 		drb_reg_id = idiag.cmd.data[IDIAG_DRBACC_REGID_INDX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4650) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4651) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4652) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4653) 	if (drb_reg_id == LPFC_DRB_ACC_ALL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4654) 		for (i = 1; i <= LPFC_DRB_MAX; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4655) 			len = lpfc_idiag_drbacc_read_reg(phba,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4656) 							 pbuffer, len, i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4657) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4658) 		len = lpfc_idiag_drbacc_read_reg(phba,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4659) 						 pbuffer, len, drb_reg_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4660) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4661) 	return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4662) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4663) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4664) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4665)  * lpfc_idiag_drbacc_write - Syntax check and set up idiag drbacc commands
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4666)  * @file: The file pointer to read from.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4667)  * @buf: The buffer to copy the user data from.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4668)  * @nbytes: The number of bytes to get.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4669)  * @ppos: The position in the file to start reading from.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4670)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4671)  * This routine get the debugfs idiag command struct from user space and then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4672)  * perform the syntax check for port doorbell register read (dump) or write
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4673)  * (set) command accordingly. In the case of port queue read command, it sets
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4674)  * up the command in the idiag command struct for the following debugfs read
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4675)  * operation. In the case of port doorbell register write operation, it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4676)  * executes the write operation into the port doorbell register accordingly.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4677)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4678)  * It returns the @nbytges passing in from debugfs user space when successful.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4679)  * In case of error conditions, it returns proper error code back to the user
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4680)  * space.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4681)  **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4682) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4683) lpfc_idiag_drbacc_write(struct file *file, const char __user *buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4684) 			size_t nbytes, loff_t *ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4685) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4686) 	struct lpfc_debug *debug = file->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4687) 	struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4688) 	uint32_t drb_reg_id, value, reg_val = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4689) 	void __iomem *drb_reg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4690) 	int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4691) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4692) 	/* This is a user write operation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4693) 	debug->op = LPFC_IDIAG_OP_WR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4694) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4695) 	rc = lpfc_idiag_cmd_get(buf, nbytes, &idiag.cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4696) 	if (rc < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4697) 		return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4698) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4699) 	/* Sanity check on command line arguments */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4700) 	drb_reg_id = idiag.cmd.data[IDIAG_DRBACC_REGID_INDX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4701) 	value = idiag.cmd.data[IDIAG_DRBACC_VALUE_INDX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4702) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4703) 	if (idiag.cmd.opcode == LPFC_IDIAG_CMD_DRBACC_WR ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4704) 	    idiag.cmd.opcode == LPFC_IDIAG_CMD_DRBACC_ST ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4705) 	    idiag.cmd.opcode == LPFC_IDIAG_CMD_DRBACC_CL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4706) 		if (rc != LPFC_DRB_ACC_WR_CMD_ARG)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4707) 			goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4708) 		if (drb_reg_id > LPFC_DRB_MAX)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4709) 			goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4710) 	} else if (idiag.cmd.opcode == LPFC_IDIAG_CMD_DRBACC_RD) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4711) 		if (rc != LPFC_DRB_ACC_RD_CMD_ARG)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4712) 			goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4713) 		if ((drb_reg_id > LPFC_DRB_MAX) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4714) 		    (drb_reg_id != LPFC_DRB_ACC_ALL))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4715) 			goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4716) 	} else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4717) 		goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4718) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4719) 	/* Perform the write access operation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4720) 	if (idiag.cmd.opcode == LPFC_IDIAG_CMD_DRBACC_WR ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4721) 	    idiag.cmd.opcode == LPFC_IDIAG_CMD_DRBACC_ST ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4722) 	    idiag.cmd.opcode == LPFC_IDIAG_CMD_DRBACC_CL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4723) 		switch (drb_reg_id) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4724) 		case LPFC_DRB_EQ:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4725) 			drb_reg = phba->sli4_hba.EQDBregaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4726) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4727) 		case LPFC_DRB_CQ:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4728) 			drb_reg = phba->sli4_hba.CQDBregaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4729) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4730) 		case LPFC_DRB_MQ:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4731) 			drb_reg = phba->sli4_hba.MQDBregaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4732) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4733) 		case LPFC_DRB_WQ:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4734) 			drb_reg = phba->sli4_hba.WQDBregaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4735) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4736) 		case LPFC_DRB_RQ:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4737) 			drb_reg = phba->sli4_hba.RQDBregaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4738) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4739) 		default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4740) 			goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4741) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4742) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4743) 		if (idiag.cmd.opcode == LPFC_IDIAG_CMD_DRBACC_WR)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4744) 			reg_val = value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4745) 		if (idiag.cmd.opcode == LPFC_IDIAG_CMD_DRBACC_ST) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4746) 			reg_val = readl(drb_reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4747) 			reg_val |= value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4748) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4749) 		if (idiag.cmd.opcode == LPFC_IDIAG_CMD_DRBACC_CL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4750) 			reg_val = readl(drb_reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4751) 			reg_val &= ~value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4752) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4753) 		writel(reg_val, drb_reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4754) 		readl(drb_reg); /* flush */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4755) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4756) 	return nbytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4757) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4758) error_out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4759) 	/* Clean out command structure on command error out */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4760) 	memset(&idiag, 0, sizeof(idiag));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4761) 	return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4762) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4763) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4764) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4765)  * lpfc_idiag_ctlacc_read_reg - idiag debugfs read a control registers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4766)  * @phba: The pointer to hba structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4767)  * @pbuffer: The pointer to the buffer to copy the data to.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4768)  * @len: The length of bytes to copied.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4769)  * @drbregid: The id to doorbell registers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4770)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4771)  * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4772)  * This routine reads a control register and copies its content to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4773)  * user buffer pointed to by @pbuffer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4774)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4775)  * Returns:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4776)  * This function returns the amount of data that was copied into @pbuffer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4777)  **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4778) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4779) lpfc_idiag_ctlacc_read_reg(struct lpfc_hba *phba, char *pbuffer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4780) 			   int len, uint32_t ctlregid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4781) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4782) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4783) 	if (!pbuffer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4784) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4785) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4786) 	switch (ctlregid) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4787) 	case LPFC_CTL_PORT_SEM:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4788) 		len += scnprintf(pbuffer+len, LPFC_CTL_ACC_BUF_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4789) 				"Port SemReg:   0x%08x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4790) 				readl(phba->sli4_hba.conf_regs_memmap_p +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4791) 				      LPFC_CTL_PORT_SEM_OFFSET));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4792) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4793) 	case LPFC_CTL_PORT_STA:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4794) 		len += scnprintf(pbuffer+len, LPFC_CTL_ACC_BUF_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4795) 				"Port StaReg:   0x%08x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4796) 				readl(phba->sli4_hba.conf_regs_memmap_p +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4797) 				      LPFC_CTL_PORT_STA_OFFSET));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4798) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4799) 	case LPFC_CTL_PORT_CTL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4800) 		len += scnprintf(pbuffer+len, LPFC_CTL_ACC_BUF_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4801) 				"Port CtlReg:   0x%08x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4802) 				readl(phba->sli4_hba.conf_regs_memmap_p +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4803) 				      LPFC_CTL_PORT_CTL_OFFSET));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4804) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4805) 	case LPFC_CTL_PORT_ER1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4806) 		len += scnprintf(pbuffer+len, LPFC_CTL_ACC_BUF_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4807) 				"Port Er1Reg:   0x%08x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4808) 				readl(phba->sli4_hba.conf_regs_memmap_p +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4809) 				      LPFC_CTL_PORT_ER1_OFFSET));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4810) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4811) 	case LPFC_CTL_PORT_ER2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4812) 		len += scnprintf(pbuffer+len, LPFC_CTL_ACC_BUF_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4813) 				"Port Er2Reg:   0x%08x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4814) 				readl(phba->sli4_hba.conf_regs_memmap_p +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4815) 				      LPFC_CTL_PORT_ER2_OFFSET));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4816) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4817) 	case LPFC_CTL_PDEV_CTL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4818) 		len += scnprintf(pbuffer+len, LPFC_CTL_ACC_BUF_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4819) 				"PDev CtlReg:   0x%08x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4820) 				readl(phba->sli4_hba.conf_regs_memmap_p +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4821) 				      LPFC_CTL_PDEV_CTL_OFFSET));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4822) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4823) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4824) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4825) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4826) 	return len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4827) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4828) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4829) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4830)  * lpfc_idiag_ctlacc_read - idiag debugfs read port and device control register
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4831)  * @file: The file pointer to read from.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4832)  * @buf: The buffer to copy the data to.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4833)  * @nbytes: The number of bytes to read.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4834)  * @ppos: The position in the file to start reading from.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4835)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4836)  * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4837)  * This routine reads data from the @phba port and device registers according
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4838)  * to the idiag command, and copies to user @buf.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4839)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4840)  * Returns:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4841)  * This function returns the amount of data that was read (this could be less
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4842)  * than @nbytes if the end of the file was reached) or a negative error value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4843)  **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4844) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4845) lpfc_idiag_ctlacc_read(struct file *file, char __user *buf, size_t nbytes,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4846) 		       loff_t *ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4847) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4848) 	struct lpfc_debug *debug = file->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4849) 	struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4850) 	uint32_t ctl_reg_id, i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4851) 	char *pbuffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4852) 	int len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4853) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4854) 	/* This is a user read operation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4855) 	debug->op = LPFC_IDIAG_OP_RD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4856) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4857) 	if (!debug->buffer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4858) 		debug->buffer = kmalloc(LPFC_CTL_ACC_BUF_SIZE, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4859) 	if (!debug->buffer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4860) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4861) 	pbuffer = debug->buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4862) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4863) 	if (*ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4864) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4865) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4866) 	if (idiag.cmd.opcode == LPFC_IDIAG_CMD_CTLACC_RD)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4867) 		ctl_reg_id = idiag.cmd.data[IDIAG_CTLACC_REGID_INDX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4868) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4869) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4870) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4871) 	if (ctl_reg_id == LPFC_CTL_ACC_ALL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4872) 		for (i = 1; i <= LPFC_CTL_MAX; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4873) 			len = lpfc_idiag_ctlacc_read_reg(phba,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4874) 							 pbuffer, len, i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4875) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4876) 		len = lpfc_idiag_ctlacc_read_reg(phba,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4877) 						 pbuffer, len, ctl_reg_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4878) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4879) 	return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4880) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4881) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4882) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4883)  * lpfc_idiag_ctlacc_write - Syntax check and set up idiag ctlacc commands
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4884)  * @file: The file pointer to read from.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4885)  * @buf: The buffer to copy the user data from.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4886)  * @nbytes: The number of bytes to get.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4887)  * @ppos: The position in the file to start reading from.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4888)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4889)  * This routine get the debugfs idiag command struct from user space and then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4890)  * perform the syntax check for port and device control register read (dump)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4891)  * or write (set) command accordingly.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4892)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4893)  * It returns the @nbytges passing in from debugfs user space when successful.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4894)  * In case of error conditions, it returns proper error code back to the user
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4895)  * space.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4896)  **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4897) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4898) lpfc_idiag_ctlacc_write(struct file *file, const char __user *buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4899) 			size_t nbytes, loff_t *ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4900) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4901) 	struct lpfc_debug *debug = file->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4902) 	struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4903) 	uint32_t ctl_reg_id, value, reg_val = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4904) 	void __iomem *ctl_reg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4905) 	int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4906) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4907) 	/* This is a user write operation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4908) 	debug->op = LPFC_IDIAG_OP_WR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4909) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4910) 	rc = lpfc_idiag_cmd_get(buf, nbytes, &idiag.cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4911) 	if (rc < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4912) 		return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4913) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4914) 	/* Sanity check on command line arguments */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4915) 	ctl_reg_id = idiag.cmd.data[IDIAG_CTLACC_REGID_INDX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4916) 	value = idiag.cmd.data[IDIAG_CTLACC_VALUE_INDX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4917) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4918) 	if (idiag.cmd.opcode == LPFC_IDIAG_CMD_CTLACC_WR ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4919) 	    idiag.cmd.opcode == LPFC_IDIAG_CMD_CTLACC_ST ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4920) 	    idiag.cmd.opcode == LPFC_IDIAG_CMD_CTLACC_CL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4921) 		if (rc != LPFC_CTL_ACC_WR_CMD_ARG)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4922) 			goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4923) 		if (ctl_reg_id > LPFC_CTL_MAX)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4924) 			goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4925) 	} else if (idiag.cmd.opcode == LPFC_IDIAG_CMD_CTLACC_RD) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4926) 		if (rc != LPFC_CTL_ACC_RD_CMD_ARG)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4927) 			goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4928) 		if ((ctl_reg_id > LPFC_CTL_MAX) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4929) 		    (ctl_reg_id != LPFC_CTL_ACC_ALL))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4930) 			goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4931) 	} else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4932) 		goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4933) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4934) 	/* Perform the write access operation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4935) 	if (idiag.cmd.opcode == LPFC_IDIAG_CMD_CTLACC_WR ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4936) 	    idiag.cmd.opcode == LPFC_IDIAG_CMD_CTLACC_ST ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4937) 	    idiag.cmd.opcode == LPFC_IDIAG_CMD_CTLACC_CL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4938) 		switch (ctl_reg_id) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4939) 		case LPFC_CTL_PORT_SEM:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4940) 			ctl_reg = phba->sli4_hba.conf_regs_memmap_p +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4941) 					LPFC_CTL_PORT_SEM_OFFSET;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4942) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4943) 		case LPFC_CTL_PORT_STA:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4944) 			ctl_reg = phba->sli4_hba.conf_regs_memmap_p +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4945) 					LPFC_CTL_PORT_STA_OFFSET;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4946) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4947) 		case LPFC_CTL_PORT_CTL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4948) 			ctl_reg = phba->sli4_hba.conf_regs_memmap_p +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4949) 					LPFC_CTL_PORT_CTL_OFFSET;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4950) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4951) 		case LPFC_CTL_PORT_ER1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4952) 			ctl_reg = phba->sli4_hba.conf_regs_memmap_p +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4953) 					LPFC_CTL_PORT_ER1_OFFSET;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4954) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4955) 		case LPFC_CTL_PORT_ER2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4956) 			ctl_reg = phba->sli4_hba.conf_regs_memmap_p +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4957) 					LPFC_CTL_PORT_ER2_OFFSET;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4958) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4959) 		case LPFC_CTL_PDEV_CTL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4960) 			ctl_reg = phba->sli4_hba.conf_regs_memmap_p +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4961) 					LPFC_CTL_PDEV_CTL_OFFSET;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4962) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4963) 		default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4964) 			goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4965) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4966) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4967) 		if (idiag.cmd.opcode == LPFC_IDIAG_CMD_CTLACC_WR)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4968) 			reg_val = value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4969) 		if (idiag.cmd.opcode == LPFC_IDIAG_CMD_CTLACC_ST) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4970) 			reg_val = readl(ctl_reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4971) 			reg_val |= value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4972) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4973) 		if (idiag.cmd.opcode == LPFC_IDIAG_CMD_CTLACC_CL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4974) 			reg_val = readl(ctl_reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4975) 			reg_val &= ~value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4976) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4977) 		writel(reg_val, ctl_reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4978) 		readl(ctl_reg); /* flush */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4979) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4980) 	return nbytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4981) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4982) error_out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4983) 	/* Clean out command structure on command error out */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4984) 	memset(&idiag, 0, sizeof(idiag));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4985) 	return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4986) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4987) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4988) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4989)  * lpfc_idiag_mbxacc_get_setup - idiag debugfs get mailbox access setup
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4990)  * @phba: Pointer to HBA context object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4991)  * @pbuffer: Pointer to data buffer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4992)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4993)  * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4994)  * This routine gets the driver mailbox access debugfs setup information.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4995)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4996)  * Returns:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4997)  * This function returns the amount of data that was read (this could be less
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4998)  * than @nbytes if the end of the file was reached) or a negative error value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4999)  **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5000) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5001) lpfc_idiag_mbxacc_get_setup(struct lpfc_hba *phba, char *pbuffer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5002) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5003) 	uint32_t mbx_dump_map, mbx_dump_cnt, mbx_word_cnt, mbx_mbox_cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5004) 	int len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5005) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5006) 	mbx_mbox_cmd = idiag.cmd.data[IDIAG_MBXACC_MBCMD_INDX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5007) 	mbx_dump_map = idiag.cmd.data[IDIAG_MBXACC_DPMAP_INDX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5008) 	mbx_dump_cnt = idiag.cmd.data[IDIAG_MBXACC_DPCNT_INDX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5009) 	mbx_word_cnt = idiag.cmd.data[IDIAG_MBXACC_WDCNT_INDX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5010) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5011) 	len += scnprintf(pbuffer+len, LPFC_MBX_ACC_BUF_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5012) 			"mbx_dump_map: 0x%08x\n", mbx_dump_map);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5013) 	len += scnprintf(pbuffer+len, LPFC_MBX_ACC_BUF_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5014) 			"mbx_dump_cnt: %04d\n", mbx_dump_cnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5015) 	len += scnprintf(pbuffer+len, LPFC_MBX_ACC_BUF_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5016) 			"mbx_word_cnt: %04d\n", mbx_word_cnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5017) 	len += scnprintf(pbuffer+len, LPFC_MBX_ACC_BUF_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5018) 			"mbx_mbox_cmd: 0x%02x\n", mbx_mbox_cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5019) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5020) 	return len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5021) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5022) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5023) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5024)  * lpfc_idiag_mbxacc_read - idiag debugfs read on mailbox access
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5025)  * @file: The file pointer to read from.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5026)  * @buf: The buffer to copy the data to.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5027)  * @nbytes: The number of bytes to read.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5028)  * @ppos: The position in the file to start reading from.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5029)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5030)  * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5031)  * This routine reads data from the @phba driver mailbox access debugfs setup
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5032)  * information.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5033)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5034)  * Returns:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5035)  * This function returns the amount of data that was read (this could be less
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5036)  * than @nbytes if the end of the file was reached) or a negative error value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5037)  **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5038) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5039) lpfc_idiag_mbxacc_read(struct file *file, char __user *buf, size_t nbytes,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5040) 		       loff_t *ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5041) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5042) 	struct lpfc_debug *debug = file->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5043) 	struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5044) 	char *pbuffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5045) 	int len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5046) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5047) 	/* This is a user read operation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5048) 	debug->op = LPFC_IDIAG_OP_RD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5049) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5050) 	if (!debug->buffer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5051) 		debug->buffer = kmalloc(LPFC_MBX_ACC_BUF_SIZE, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5052) 	if (!debug->buffer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5053) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5054) 	pbuffer = debug->buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5055) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5056) 	if (*ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5057) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5058) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5059) 	if ((idiag.cmd.opcode != LPFC_IDIAG_CMD_MBXACC_DP) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5060) 	    (idiag.cmd.opcode != LPFC_IDIAG_BSG_MBXACC_DP))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5061) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5062) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5063) 	len = lpfc_idiag_mbxacc_get_setup(phba, pbuffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5064) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5065) 	return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5066) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5067) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5068) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5069)  * lpfc_idiag_mbxacc_write - Syntax check and set up idiag mbxacc commands
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5070)  * @file: The file pointer to read from.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5071)  * @buf: The buffer to copy the user data from.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5072)  * @nbytes: The number of bytes to get.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5073)  * @ppos: The position in the file to start reading from.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5074)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5075)  * This routine get the debugfs idiag command struct from user space and then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5076)  * perform the syntax check for driver mailbox command (dump) and sets up the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5077)  * necessary states in the idiag command struct accordingly.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5078)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5079)  * It returns the @nbytges passing in from debugfs user space when successful.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5080)  * In case of error conditions, it returns proper error code back to the user
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5081)  * space.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5082)  **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5083) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5084) lpfc_idiag_mbxacc_write(struct file *file, const char __user *buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5085) 			size_t nbytes, loff_t *ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5086) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5087) 	struct lpfc_debug *debug = file->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5088) 	uint32_t mbx_dump_map, mbx_dump_cnt, mbx_word_cnt, mbx_mbox_cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5089) 	int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5090) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5091) 	/* This is a user write operation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5092) 	debug->op = LPFC_IDIAG_OP_WR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5093) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5094) 	rc = lpfc_idiag_cmd_get(buf, nbytes, &idiag.cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5095) 	if (rc < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5096) 		return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5097) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5098) 	/* Sanity check on command line arguments */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5099) 	mbx_mbox_cmd = idiag.cmd.data[IDIAG_MBXACC_MBCMD_INDX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5100) 	mbx_dump_map = idiag.cmd.data[IDIAG_MBXACC_DPMAP_INDX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5101) 	mbx_dump_cnt = idiag.cmd.data[IDIAG_MBXACC_DPCNT_INDX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5102) 	mbx_word_cnt = idiag.cmd.data[IDIAG_MBXACC_WDCNT_INDX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5103) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5104) 	if (idiag.cmd.opcode == LPFC_IDIAG_CMD_MBXACC_DP) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5105) 		if (!(mbx_dump_map & LPFC_MBX_DMP_MBX_ALL))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5106) 			goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5107) 		if ((mbx_dump_map & ~LPFC_MBX_DMP_MBX_ALL) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5108) 		    (mbx_dump_map != LPFC_MBX_DMP_ALL))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5109) 			goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5110) 		if (mbx_word_cnt > sizeof(MAILBOX_t))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5111) 			goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5112) 	} else if (idiag.cmd.opcode == LPFC_IDIAG_BSG_MBXACC_DP) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5113) 		if (!(mbx_dump_map & LPFC_BSG_DMP_MBX_ALL))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5114) 			goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5115) 		if ((mbx_dump_map & ~LPFC_BSG_DMP_MBX_ALL) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5116) 		    (mbx_dump_map != LPFC_MBX_DMP_ALL))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5117) 			goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5118) 		if (mbx_word_cnt > (BSG_MBOX_SIZE)/4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5119) 			goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5120) 		if (mbx_mbox_cmd != 0x9b)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5121) 			goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5122) 	} else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5123) 		goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5124) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5125) 	if (mbx_word_cnt == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5126) 		goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5127) 	if (rc != LPFC_MBX_DMP_ARG)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5128) 		goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5129) 	if (mbx_mbox_cmd & ~0xff)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5130) 		goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5131) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5132) 	/* condition for stop mailbox dump */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5133) 	if (mbx_dump_cnt == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5134) 		goto reset_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5135) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5136) 	return nbytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5137) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5138) reset_out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5139) 	/* Clean out command structure on command error out */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5140) 	memset(&idiag, 0, sizeof(idiag));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5141) 	return nbytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5142) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5143) error_out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5144) 	/* Clean out command structure on command error out */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5145) 	memset(&idiag, 0, sizeof(idiag));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5146) 	return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5147) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5148) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5149) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5150)  * lpfc_idiag_extacc_avail_get - get the available extents information
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5151)  * @phba: pointer to lpfc hba data structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5152)  * @pbuffer: pointer to internal buffer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5153)  * @len: length into the internal buffer data has been copied.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5154)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5155)  * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5156)  * This routine is to get the available extent information.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5157)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5158)  * Returns:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5159)  * overall lenth of the data read into the internal buffer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5160)  **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5161) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5162) lpfc_idiag_extacc_avail_get(struct lpfc_hba *phba, char *pbuffer, int len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5163) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5164) 	uint16_t ext_cnt, ext_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5165) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5166) 	len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5167) 			"\nAvailable Extents Information:\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5168) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5169) 	len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5170) 			"\tPort Available VPI extents: ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5171) 	lpfc_sli4_get_avail_extnt_rsrc(phba, LPFC_RSC_TYPE_FCOE_VPI,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5172) 				       &ext_cnt, &ext_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5173) 	len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5174) 			"Count %3d, Size %3d\n", ext_cnt, ext_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5175) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5176) 	len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5177) 			"\tPort Available VFI extents: ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5178) 	lpfc_sli4_get_avail_extnt_rsrc(phba, LPFC_RSC_TYPE_FCOE_VFI,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5179) 				       &ext_cnt, &ext_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5180) 	len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5181) 			"Count %3d, Size %3d\n", ext_cnt, ext_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5182) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5183) 	len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5184) 			"\tPort Available RPI extents: ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5185) 	lpfc_sli4_get_avail_extnt_rsrc(phba, LPFC_RSC_TYPE_FCOE_RPI,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5186) 				       &ext_cnt, &ext_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5187) 	len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5188) 			"Count %3d, Size %3d\n", ext_cnt, ext_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5189) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5190) 	len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5191) 			"\tPort Available XRI extents: ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5192) 	lpfc_sli4_get_avail_extnt_rsrc(phba, LPFC_RSC_TYPE_FCOE_XRI,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5193) 				       &ext_cnt, &ext_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5194) 	len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5195) 			"Count %3d, Size %3d\n", ext_cnt, ext_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5196) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5197) 	return len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5198) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5199) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5200) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5201)  * lpfc_idiag_extacc_alloc_get - get the allocated extents information
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5202)  * @phba: pointer to lpfc hba data structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5203)  * @pbuffer: pointer to internal buffer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5204)  * @len: length into the internal buffer data has been copied.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5205)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5206)  * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5207)  * This routine is to get the allocated extent information.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5208)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5209)  * Returns:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5210)  * overall lenth of the data read into the internal buffer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5211)  **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5212) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5213) lpfc_idiag_extacc_alloc_get(struct lpfc_hba *phba, char *pbuffer, int len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5214) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5215) 	uint16_t ext_cnt, ext_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5216) 	int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5217) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5218) 	len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5219) 			"\nAllocated Extents Information:\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5220) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5221) 	len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5222) 			"\tHost Allocated VPI extents: ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5223) 	rc = lpfc_sli4_get_allocated_extnts(phba, LPFC_RSC_TYPE_FCOE_VPI,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5224) 					    &ext_cnt, &ext_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5225) 	if (!rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5226) 		len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5227) 				"Port %d Extent %3d, Size %3d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5228) 				phba->brd_no, ext_cnt, ext_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5229) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5230) 		len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5231) 				"N/A\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5232) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5233) 	len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5234) 			"\tHost Allocated VFI extents: ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5235) 	rc = lpfc_sli4_get_allocated_extnts(phba, LPFC_RSC_TYPE_FCOE_VFI,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5236) 					    &ext_cnt, &ext_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5237) 	if (!rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5238) 		len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5239) 				"Port %d Extent %3d, Size %3d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5240) 				phba->brd_no, ext_cnt, ext_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5241) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5242) 		len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5243) 				"N/A\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5244) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5245) 	len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5246) 			"\tHost Allocated RPI extents: ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5247) 	rc = lpfc_sli4_get_allocated_extnts(phba, LPFC_RSC_TYPE_FCOE_RPI,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5248) 					    &ext_cnt, &ext_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5249) 	if (!rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5250) 		len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5251) 				"Port %d Extent %3d, Size %3d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5252) 				phba->brd_no, ext_cnt, ext_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5253) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5254) 		len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5255) 				"N/A\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5256) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5257) 	len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5258) 			"\tHost Allocated XRI extents: ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5259) 	rc = lpfc_sli4_get_allocated_extnts(phba, LPFC_RSC_TYPE_FCOE_XRI,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5260) 					    &ext_cnt, &ext_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5261) 	if (!rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5262) 		len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5263) 				"Port %d Extent %3d, Size %3d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5264) 				phba->brd_no, ext_cnt, ext_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5265) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5266) 		len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5267) 				"N/A\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5268) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5269) 	return len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5270) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5271) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5272) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5273)  * lpfc_idiag_extacc_drivr_get - get driver extent information
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5274)  * @phba: pointer to lpfc hba data structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5275)  * @pbuffer: pointer to internal buffer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5276)  * @len: length into the internal buffer data has been copied.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5277)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5278)  * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5279)  * This routine is to get the driver extent information.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5280)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5281)  * Returns:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5282)  * overall lenth of the data read into the internal buffer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5283)  **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5284) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5285) lpfc_idiag_extacc_drivr_get(struct lpfc_hba *phba, char *pbuffer, int len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5286) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5287) 	struct lpfc_rsrc_blks *rsrc_blks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5288) 	int index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5289) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5290) 	len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5291) 			"\nDriver Extents Information:\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5292) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5293) 	len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5294) 			"\tVPI extents:\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5295) 	index = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5296) 	list_for_each_entry(rsrc_blks, &phba->lpfc_vpi_blk_list, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5297) 		len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5298) 				"\t\tBlock %3d: Start %4d, Count %4d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5299) 				index, rsrc_blks->rsrc_start,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5300) 				rsrc_blks->rsrc_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5301) 		index++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5302) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5303) 	len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5304) 			"\tVFI extents:\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5305) 	index = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5306) 	list_for_each_entry(rsrc_blks, &phba->sli4_hba.lpfc_vfi_blk_list,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5307) 			    list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5308) 		len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5309) 				"\t\tBlock %3d: Start %4d, Count %4d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5310) 				index, rsrc_blks->rsrc_start,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5311) 				rsrc_blks->rsrc_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5312) 		index++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5313) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5314) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5315) 	len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5316) 			"\tRPI extents:\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5317) 	index = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5318) 	list_for_each_entry(rsrc_blks, &phba->sli4_hba.lpfc_rpi_blk_list,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5319) 			    list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5320) 		len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5321) 				"\t\tBlock %3d: Start %4d, Count %4d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5322) 				index, rsrc_blks->rsrc_start,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5323) 				rsrc_blks->rsrc_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5324) 		index++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5325) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5326) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5327) 	len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5328) 			"\tXRI extents:\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5329) 	index = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5330) 	list_for_each_entry(rsrc_blks, &phba->sli4_hba.lpfc_xri_blk_list,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5331) 			    list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5332) 		len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5333) 				"\t\tBlock %3d: Start %4d, Count %4d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5334) 				index, rsrc_blks->rsrc_start,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5335) 				rsrc_blks->rsrc_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5336) 		index++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5337) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5338) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5339) 	return len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5340) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5341) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5342) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5343)  * lpfc_idiag_extacc_write - Syntax check and set up idiag extacc commands
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5344)  * @file: The file pointer to read from.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5345)  * @buf: The buffer to copy the user data from.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5346)  * @nbytes: The number of bytes to get.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5347)  * @ppos: The position in the file to start reading from.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5348)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5349)  * This routine get the debugfs idiag command struct from user space and then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5350)  * perform the syntax check for extent information access commands and sets
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5351)  * up the necessary states in the idiag command struct accordingly.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5352)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5353)  * It returns the @nbytges passing in from debugfs user space when successful.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5354)  * In case of error conditions, it returns proper error code back to the user
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5355)  * space.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5356)  **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5357) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5358) lpfc_idiag_extacc_write(struct file *file, const char __user *buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5359) 			size_t nbytes, loff_t *ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5360) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5361) 	struct lpfc_debug *debug = file->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5362) 	uint32_t ext_map;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5363) 	int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5364) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5365) 	/* This is a user write operation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5366) 	debug->op = LPFC_IDIAG_OP_WR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5367) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5368) 	rc = lpfc_idiag_cmd_get(buf, nbytes, &idiag.cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5369) 	if (rc < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5370) 		return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5371) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5372) 	ext_map = idiag.cmd.data[IDIAG_EXTACC_EXMAP_INDX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5373) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5374) 	if (idiag.cmd.opcode != LPFC_IDIAG_CMD_EXTACC_RD)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5375) 		goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5376) 	if (rc != LPFC_EXT_ACC_CMD_ARG)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5377) 		goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5378) 	if (!(ext_map & LPFC_EXT_ACC_ALL))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5379) 		goto error_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5380) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5381) 	return nbytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5382) error_out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5383) 	/* Clean out command structure on command error out */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5384) 	memset(&idiag, 0, sizeof(idiag));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5385) 	return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5386) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5387) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5388) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5389)  * lpfc_idiag_extacc_read - idiag debugfs read access to extent information
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5390)  * @file: The file pointer to read from.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5391)  * @buf: The buffer to copy the data to.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5392)  * @nbytes: The number of bytes to read.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5393)  * @ppos: The position in the file to start reading from.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5394)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5395)  * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5396)  * This routine reads data from the proper extent information according to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5397)  * the idiag command, and copies to user @buf.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5398)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5399)  * Returns:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5400)  * This function returns the amount of data that was read (this could be less
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5401)  * than @nbytes if the end of the file was reached) or a negative error value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5402)  **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5403) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5404) lpfc_idiag_extacc_read(struct file *file, char __user *buf, size_t nbytes,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5405) 		       loff_t *ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5406) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5407) 	struct lpfc_debug *debug = file->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5408) 	struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5409) 	char *pbuffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5410) 	uint32_t ext_map;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5411) 	int len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5412) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5413) 	/* This is a user read operation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5414) 	debug->op = LPFC_IDIAG_OP_RD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5415) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5416) 	if (!debug->buffer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5417) 		debug->buffer = kmalloc(LPFC_EXT_ACC_BUF_SIZE, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5418) 	if (!debug->buffer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5419) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5420) 	pbuffer = debug->buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5421) 	if (*ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5422) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5423) 	if (idiag.cmd.opcode != LPFC_IDIAG_CMD_EXTACC_RD)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5424) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5425) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5426) 	ext_map = idiag.cmd.data[IDIAG_EXTACC_EXMAP_INDX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5427) 	if (ext_map & LPFC_EXT_ACC_AVAIL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5428) 		len = lpfc_idiag_extacc_avail_get(phba, pbuffer, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5429) 	if (ext_map & LPFC_EXT_ACC_ALLOC)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5430) 		len = lpfc_idiag_extacc_alloc_get(phba, pbuffer, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5431) 	if (ext_map & LPFC_EXT_ACC_DRIVR)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5432) 		len = lpfc_idiag_extacc_drivr_get(phba, pbuffer, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5433) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5434) 	return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5435) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5436) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5437) #undef lpfc_debugfs_op_disc_trc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5438) static const struct file_operations lpfc_debugfs_op_disc_trc = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5439) 	.owner =        THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5440) 	.open =         lpfc_debugfs_disc_trc_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5441) 	.llseek =       lpfc_debugfs_lseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5442) 	.read =         lpfc_debugfs_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5443) 	.release =      lpfc_debugfs_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5444) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5445) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5446) #undef lpfc_debugfs_op_nodelist
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5447) static const struct file_operations lpfc_debugfs_op_nodelist = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5448) 	.owner =        THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5449) 	.open =         lpfc_debugfs_nodelist_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5450) 	.llseek =       lpfc_debugfs_lseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5451) 	.read =         lpfc_debugfs_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5452) 	.release =      lpfc_debugfs_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5453) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5454) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5455) #undef lpfc_debugfs_op_multixripools
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5456) static const struct file_operations lpfc_debugfs_op_multixripools = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5457) 	.owner =        THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5458) 	.open =         lpfc_debugfs_multixripools_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5459) 	.llseek =       lpfc_debugfs_lseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5460) 	.read =         lpfc_debugfs_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5461) 	.write =	lpfc_debugfs_multixripools_write,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5462) 	.release =      lpfc_debugfs_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5463) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5464) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5465) #undef lpfc_debugfs_op_hbqinfo
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5466) static const struct file_operations lpfc_debugfs_op_hbqinfo = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5467) 	.owner =        THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5468) 	.open =         lpfc_debugfs_hbqinfo_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5469) 	.llseek =       lpfc_debugfs_lseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5470) 	.read =         lpfc_debugfs_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5471) 	.release =      lpfc_debugfs_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5472) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5473) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5474) #ifdef LPFC_HDWQ_LOCK_STAT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5475) #undef lpfc_debugfs_op_lockstat
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5476) static const struct file_operations lpfc_debugfs_op_lockstat = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5477) 	.owner =        THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5478) 	.open =         lpfc_debugfs_lockstat_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5479) 	.llseek =       lpfc_debugfs_lseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5480) 	.read =         lpfc_debugfs_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5481) 	.write =        lpfc_debugfs_lockstat_write,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5482) 	.release =      lpfc_debugfs_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5483) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5484) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5485) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5486) #undef lpfc_debugfs_ras_log
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5487) static const struct file_operations lpfc_debugfs_ras_log = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5488) 	.owner =        THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5489) 	.open =         lpfc_debugfs_ras_log_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5490) 	.llseek =       lpfc_debugfs_lseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5491) 	.read =         lpfc_debugfs_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5492) 	.release =      lpfc_debugfs_ras_log_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5493) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5494) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5495) #undef lpfc_debugfs_op_dumpHBASlim
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5496) static const struct file_operations lpfc_debugfs_op_dumpHBASlim = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5497) 	.owner =        THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5498) 	.open =         lpfc_debugfs_dumpHBASlim_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5499) 	.llseek =       lpfc_debugfs_lseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5500) 	.read =         lpfc_debugfs_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5501) 	.release =      lpfc_debugfs_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5502) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5503) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5504) #undef lpfc_debugfs_op_dumpHostSlim
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5505) static const struct file_operations lpfc_debugfs_op_dumpHostSlim = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5506) 	.owner =        THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5507) 	.open =         lpfc_debugfs_dumpHostSlim_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5508) 	.llseek =       lpfc_debugfs_lseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5509) 	.read =         lpfc_debugfs_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5510) 	.release =      lpfc_debugfs_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5511) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5512) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5513) #undef lpfc_debugfs_op_nvmestat
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5514) static const struct file_operations lpfc_debugfs_op_nvmestat = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5515) 	.owner =        THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5516) 	.open =         lpfc_debugfs_nvmestat_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5517) 	.llseek =       lpfc_debugfs_lseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5518) 	.read =         lpfc_debugfs_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5519) 	.write =	lpfc_debugfs_nvmestat_write,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5520) 	.release =      lpfc_debugfs_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5521) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5522) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5523) #undef lpfc_debugfs_op_scsistat
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5524) static const struct file_operations lpfc_debugfs_op_scsistat = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5525) 	.owner =        THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5526) 	.open =         lpfc_debugfs_scsistat_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5527) 	.llseek =       lpfc_debugfs_lseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5528) 	.read =         lpfc_debugfs_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5529) 	.write =	lpfc_debugfs_scsistat_write,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5530) 	.release =      lpfc_debugfs_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5531) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5532) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5533) #undef lpfc_debugfs_op_ioktime
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5534) static const struct file_operations lpfc_debugfs_op_ioktime = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5535) 	.owner =        THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5536) 	.open =         lpfc_debugfs_ioktime_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5537) 	.llseek =       lpfc_debugfs_lseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5538) 	.read =         lpfc_debugfs_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5539) 	.write =	lpfc_debugfs_ioktime_write,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5540) 	.release =      lpfc_debugfs_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5541) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5542) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5543) #undef lpfc_debugfs_op_nvmeio_trc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5544) static const struct file_operations lpfc_debugfs_op_nvmeio_trc = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5545) 	.owner =        THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5546) 	.open =         lpfc_debugfs_nvmeio_trc_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5547) 	.llseek =       lpfc_debugfs_lseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5548) 	.read =         lpfc_debugfs_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5549) 	.write =	lpfc_debugfs_nvmeio_trc_write,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5550) 	.release =      lpfc_debugfs_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5551) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5552) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5553) #undef lpfc_debugfs_op_hdwqstat
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5554) static const struct file_operations lpfc_debugfs_op_hdwqstat = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5555) 	.owner =        THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5556) 	.open =         lpfc_debugfs_hdwqstat_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5557) 	.llseek =       lpfc_debugfs_lseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5558) 	.read =         lpfc_debugfs_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5559) 	.write =	lpfc_debugfs_hdwqstat_write,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5560) 	.release =      lpfc_debugfs_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5561) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5562) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5563) #undef lpfc_debugfs_op_dif_err
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5564) static const struct file_operations lpfc_debugfs_op_dif_err = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5565) 	.owner =	THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5566) 	.open =		simple_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5567) 	.llseek =	lpfc_debugfs_lseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5568) 	.read =		lpfc_debugfs_dif_err_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5569) 	.write =	lpfc_debugfs_dif_err_write,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5570) 	.release =	lpfc_debugfs_dif_err_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5571) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5572) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5573) #undef lpfc_debugfs_op_slow_ring_trc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5574) static const struct file_operations lpfc_debugfs_op_slow_ring_trc = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5575) 	.owner =        THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5576) 	.open =         lpfc_debugfs_slow_ring_trc_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5577) 	.llseek =       lpfc_debugfs_lseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5578) 	.read =         lpfc_debugfs_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5579) 	.release =      lpfc_debugfs_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5580) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5581) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5582) static struct dentry *lpfc_debugfs_root = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5583) static atomic_t lpfc_debugfs_hba_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5584) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5585) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5586)  * File operations for the iDiag debugfs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5587)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5588) #undef lpfc_idiag_op_pciCfg
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5589) static const struct file_operations lpfc_idiag_op_pciCfg = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5590) 	.owner =        THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5591) 	.open =         lpfc_idiag_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5592) 	.llseek =       lpfc_debugfs_lseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5593) 	.read =         lpfc_idiag_pcicfg_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5594) 	.write =        lpfc_idiag_pcicfg_write,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5595) 	.release =      lpfc_idiag_cmd_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5596) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5597) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5598) #undef lpfc_idiag_op_barAcc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5599) static const struct file_operations lpfc_idiag_op_barAcc = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5600) 	.owner =        THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5601) 	.open =         lpfc_idiag_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5602) 	.llseek =       lpfc_debugfs_lseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5603) 	.read =         lpfc_idiag_baracc_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5604) 	.write =        lpfc_idiag_baracc_write,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5605) 	.release =      lpfc_idiag_cmd_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5606) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5607) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5608) #undef lpfc_idiag_op_queInfo
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5609) static const struct file_operations lpfc_idiag_op_queInfo = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5610) 	.owner =        THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5611) 	.open =         lpfc_idiag_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5612) 	.read =         lpfc_idiag_queinfo_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5613) 	.release =      lpfc_idiag_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5614) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5615) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5616) #undef lpfc_idiag_op_queAcc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5617) static const struct file_operations lpfc_idiag_op_queAcc = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5618) 	.owner =        THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5619) 	.open =         lpfc_idiag_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5620) 	.llseek =       lpfc_debugfs_lseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5621) 	.read =         lpfc_idiag_queacc_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5622) 	.write =        lpfc_idiag_queacc_write,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5623) 	.release =      lpfc_idiag_cmd_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5624) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5625) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5626) #undef lpfc_idiag_op_drbAcc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5627) static const struct file_operations lpfc_idiag_op_drbAcc = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5628) 	.owner =        THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5629) 	.open =         lpfc_idiag_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5630) 	.llseek =       lpfc_debugfs_lseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5631) 	.read =         lpfc_idiag_drbacc_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5632) 	.write =        lpfc_idiag_drbacc_write,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5633) 	.release =      lpfc_idiag_cmd_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5634) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5635) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5636) #undef lpfc_idiag_op_ctlAcc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5637) static const struct file_operations lpfc_idiag_op_ctlAcc = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5638) 	.owner =        THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5639) 	.open =         lpfc_idiag_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5640) 	.llseek =       lpfc_debugfs_lseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5641) 	.read =         lpfc_idiag_ctlacc_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5642) 	.write =        lpfc_idiag_ctlacc_write,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5643) 	.release =      lpfc_idiag_cmd_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5644) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5645) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5646) #undef lpfc_idiag_op_mbxAcc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5647) static const struct file_operations lpfc_idiag_op_mbxAcc = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5648) 	.owner =        THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5649) 	.open =         lpfc_idiag_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5650) 	.llseek =       lpfc_debugfs_lseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5651) 	.read =         lpfc_idiag_mbxacc_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5652) 	.write =        lpfc_idiag_mbxacc_write,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5653) 	.release =      lpfc_idiag_cmd_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5654) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5655) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5656) #undef lpfc_idiag_op_extAcc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5657) static const struct file_operations lpfc_idiag_op_extAcc = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5658) 	.owner =        THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5659) 	.open =         lpfc_idiag_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5660) 	.llseek =       lpfc_debugfs_lseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5661) 	.read =         lpfc_idiag_extacc_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5662) 	.write =        lpfc_idiag_extacc_write,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5663) 	.release =      lpfc_idiag_cmd_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5664) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5665) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5666) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5667) /* lpfc_idiag_mbxacc_dump_bsg_mbox - idiag debugfs dump bsg mailbox command
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5668)  * @phba: Pointer to HBA context object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5669)  * @dmabuf: Pointer to a DMA buffer descriptor.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5670)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5671)  * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5672)  * This routine dump a bsg pass-through non-embedded mailbox command with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5673)  * external buffer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5674)  **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5675) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5676) lpfc_idiag_mbxacc_dump_bsg_mbox(struct lpfc_hba *phba, enum nemb_type nemb_tp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5677) 				enum mbox_type mbox_tp, enum dma_type dma_tp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5678) 				enum sta_type sta_tp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5679) 				struct lpfc_dmabuf *dmabuf, uint32_t ext_buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5680) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5681) #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5682) 	uint32_t *mbx_mbox_cmd, *mbx_dump_map, *mbx_dump_cnt, *mbx_word_cnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5683) 	char line_buf[LPFC_MBX_ACC_LBUF_SZ];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5684) 	int len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5685) 	uint32_t do_dump = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5686) 	uint32_t *pword;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5687) 	uint32_t i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5688) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5689) 	if (idiag.cmd.opcode != LPFC_IDIAG_BSG_MBXACC_DP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5690) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5691) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5692) 	mbx_mbox_cmd = &idiag.cmd.data[IDIAG_MBXACC_MBCMD_INDX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5693) 	mbx_dump_map = &idiag.cmd.data[IDIAG_MBXACC_DPMAP_INDX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5694) 	mbx_dump_cnt = &idiag.cmd.data[IDIAG_MBXACC_DPCNT_INDX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5695) 	mbx_word_cnt = &idiag.cmd.data[IDIAG_MBXACC_WDCNT_INDX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5696) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5697) 	if (!(*mbx_dump_map & LPFC_MBX_DMP_ALL) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5698) 	    (*mbx_dump_cnt == 0) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5699) 	    (*mbx_word_cnt == 0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5700) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5701) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5702) 	if (*mbx_mbox_cmd != 0x9B)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5703) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5704) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5705) 	if ((mbox_tp == mbox_rd) && (dma_tp == dma_mbox)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5706) 		if (*mbx_dump_map & LPFC_BSG_DMP_MBX_RD_MBX) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5707) 			do_dump |= LPFC_BSG_DMP_MBX_RD_MBX;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5708) 			pr_err("\nRead mbox command (x%x), "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5709) 			       "nemb:0x%x, extbuf_cnt:%d:\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5710) 			       sta_tp, nemb_tp, ext_buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5711) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5712) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5713) 	if ((mbox_tp == mbox_rd) && (dma_tp == dma_ebuf)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5714) 		if (*mbx_dump_map & LPFC_BSG_DMP_MBX_RD_BUF) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5715) 			do_dump |= LPFC_BSG_DMP_MBX_RD_BUF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5716) 			pr_err("\nRead mbox buffer (x%x), "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5717) 			       "nemb:0x%x, extbuf_seq:%d:\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5718) 			       sta_tp, nemb_tp, ext_buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5719) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5720) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5721) 	if ((mbox_tp == mbox_wr) && (dma_tp == dma_mbox)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5722) 		if (*mbx_dump_map & LPFC_BSG_DMP_MBX_WR_MBX) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5723) 			do_dump |= LPFC_BSG_DMP_MBX_WR_MBX;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5724) 			pr_err("\nWrite mbox command (x%x), "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5725) 			       "nemb:0x%x, extbuf_cnt:%d:\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5726) 			       sta_tp, nemb_tp, ext_buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5727) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5728) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5729) 	if ((mbox_tp == mbox_wr) && (dma_tp == dma_ebuf)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5730) 		if (*mbx_dump_map & LPFC_BSG_DMP_MBX_WR_BUF) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5731) 			do_dump |= LPFC_BSG_DMP_MBX_WR_BUF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5732) 			pr_err("\nWrite mbox buffer (x%x), "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5733) 			       "nemb:0x%x, extbuf_seq:%d:\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5734) 			       sta_tp, nemb_tp, ext_buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5735) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5736) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5737) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5738) 	/* dump buffer content */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5739) 	if (do_dump) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5740) 		pword = (uint32_t *)dmabuf->virt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5741) 		for (i = 0; i < *mbx_word_cnt; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5742) 			if (!(i % 8)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5743) 				if (i != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5744) 					pr_err("%s\n", line_buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5745) 				len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5746) 				len += scnprintf(line_buf+len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5747) 						LPFC_MBX_ACC_LBUF_SZ-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5748) 						"%03d: ", i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5749) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5750) 			len += scnprintf(line_buf+len, LPFC_MBX_ACC_LBUF_SZ-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5751) 					"%08x ", (uint32_t)*pword);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5752) 			pword++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5753) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5754) 		if ((i - 1) % 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5755) 			pr_err("%s\n", line_buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5756) 		(*mbx_dump_cnt)--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5757) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5758) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5759) 	/* Clean out command structure on reaching dump count */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5760) 	if (*mbx_dump_cnt == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5761) 		memset(&idiag, 0, sizeof(idiag));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5762) 	return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5763) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5764) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5765) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5766) /* lpfc_idiag_mbxacc_dump_issue_mbox - idiag debugfs dump issue mailbox command
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5767)  * @phba: Pointer to HBA context object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5768)  * @dmabuf: Pointer to a DMA buffer descriptor.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5769)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5770)  * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5771)  * This routine dump a pass-through non-embedded mailbox command from issue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5772)  * mailbox command.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5773)  **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5774) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5775) lpfc_idiag_mbxacc_dump_issue_mbox(struct lpfc_hba *phba, MAILBOX_t *pmbox)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5776) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5777) #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5778) 	uint32_t *mbx_dump_map, *mbx_dump_cnt, *mbx_word_cnt, *mbx_mbox_cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5779) 	char line_buf[LPFC_MBX_ACC_LBUF_SZ];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5780) 	int len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5781) 	uint32_t *pword;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5782) 	uint8_t *pbyte;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5783) 	uint32_t i, j;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5784) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5785) 	if (idiag.cmd.opcode != LPFC_IDIAG_CMD_MBXACC_DP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5786) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5787) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5788) 	mbx_mbox_cmd = &idiag.cmd.data[IDIAG_MBXACC_MBCMD_INDX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5789) 	mbx_dump_map = &idiag.cmd.data[IDIAG_MBXACC_DPMAP_INDX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5790) 	mbx_dump_cnt = &idiag.cmd.data[IDIAG_MBXACC_DPCNT_INDX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5791) 	mbx_word_cnt = &idiag.cmd.data[IDIAG_MBXACC_WDCNT_INDX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5792) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5793) 	if (!(*mbx_dump_map & LPFC_MBX_DMP_MBX_ALL) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5794) 	    (*mbx_dump_cnt == 0) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5795) 	    (*mbx_word_cnt == 0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5796) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5797) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5798) 	if ((*mbx_mbox_cmd != LPFC_MBX_ALL_CMD) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5799) 	    (*mbx_mbox_cmd != pmbox->mbxCommand))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5800) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5801) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5802) 	/* dump buffer content */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5803) 	if (*mbx_dump_map & LPFC_MBX_DMP_MBX_WORD) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5804) 		pr_err("Mailbox command:0x%x dump by word:\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5805) 		       pmbox->mbxCommand);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5806) 		pword = (uint32_t *)pmbox;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5807) 		for (i = 0; i < *mbx_word_cnt; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5808) 			if (!(i % 8)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5809) 				if (i != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5810) 					pr_err("%s\n", line_buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5811) 				len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5812) 				memset(line_buf, 0, LPFC_MBX_ACC_LBUF_SZ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5813) 				len += scnprintf(line_buf+len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5814) 						LPFC_MBX_ACC_LBUF_SZ-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5815) 						"%03d: ", i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5816) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5817) 			len += scnprintf(line_buf+len, LPFC_MBX_ACC_LBUF_SZ-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5818) 					"%08x ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5819) 					((uint32_t)*pword) & 0xffffffff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5820) 			pword++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5821) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5822) 		if ((i - 1) % 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5823) 			pr_err("%s\n", line_buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5824) 		pr_err("\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5825) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5826) 	if (*mbx_dump_map & LPFC_MBX_DMP_MBX_BYTE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5827) 		pr_err("Mailbox command:0x%x dump by byte:\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5828) 		       pmbox->mbxCommand);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5829) 		pbyte = (uint8_t *)pmbox;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5830) 		for (i = 0; i < *mbx_word_cnt; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5831) 			if (!(i % 8)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5832) 				if (i != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5833) 					pr_err("%s\n", line_buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5834) 				len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5835) 				memset(line_buf, 0, LPFC_MBX_ACC_LBUF_SZ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5836) 				len += scnprintf(line_buf+len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5837) 						LPFC_MBX_ACC_LBUF_SZ-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5838) 						"%03d: ", i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5839) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5840) 			for (j = 0; j < 4; j++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5841) 				len += scnprintf(line_buf+len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5842) 						LPFC_MBX_ACC_LBUF_SZ-len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5843) 						"%02x",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5844) 						((uint8_t)*pbyte) & 0xff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5845) 				pbyte++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5846) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5847) 			len += scnprintf(line_buf+len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5848) 					LPFC_MBX_ACC_LBUF_SZ-len, " ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5849) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5850) 		if ((i - 1) % 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5851) 			pr_err("%s\n", line_buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5852) 		pr_err("\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5853) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5854) 	(*mbx_dump_cnt)--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5855) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5856) 	/* Clean out command structure on reaching dump count */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5857) 	if (*mbx_dump_cnt == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5858) 		memset(&idiag, 0, sizeof(idiag));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5859) 	return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5860) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5861) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5862) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5863) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5864)  * lpfc_debugfs_initialize - Initialize debugfs for a vport
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5865)  * @vport: The vport pointer to initialize.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5866)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5867)  * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5868)  * When Debugfs is configured this routine sets up the lpfc debugfs file system.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5869)  * If not already created, this routine will create the lpfc directory, and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5870)  * lpfcX directory (for this HBA), and vportX directory for this vport. It will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5871)  * also create each file used to access lpfc specific debugfs information.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5872)  **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5873) inline void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5874) lpfc_debugfs_initialize(struct lpfc_vport *vport)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5875) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5876) #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5877) 	struct lpfc_hba   *phba = vport->phba;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5878) 	char name[64];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5879) 	uint32_t num, i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5880) 	bool pport_setup = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5881) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5882) 	if (!lpfc_debugfs_enable)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5883) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5884) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5885) 	/* Setup lpfc root directory */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5886) 	if (!lpfc_debugfs_root) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5887) 		lpfc_debugfs_root = debugfs_create_dir("lpfc", NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5888) 		atomic_set(&lpfc_debugfs_hba_count, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5889) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5890) 	if (!lpfc_debugfs_start_time)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5891) 		lpfc_debugfs_start_time = jiffies;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5892) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5893) 	/* Setup funcX directory for specific HBA PCI function */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5894) 	snprintf(name, sizeof(name), "fn%d", phba->brd_no);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5895) 	if (!phba->hba_debugfs_root) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5896) 		pport_setup = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5897) 		phba->hba_debugfs_root =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5898) 			debugfs_create_dir(name, lpfc_debugfs_root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5899) 		atomic_inc(&lpfc_debugfs_hba_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5900) 		atomic_set(&phba->debugfs_vport_count, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5901) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5902) 		/* Multi-XRI pools */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5903) 		snprintf(name, sizeof(name), "multixripools");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5904) 		phba->debug_multixri_pools =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5905) 			debugfs_create_file(name, S_IFREG | 0644,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5906) 					    phba->hba_debugfs_root,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5907) 					    phba,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5908) 					    &lpfc_debugfs_op_multixripools);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5909) 		if (!phba->debug_multixri_pools) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5910) 			lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5911) 					 "0527 Cannot create debugfs multixripools\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5912) 			goto debug_failed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5913) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5914) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5915) 		/* RAS log */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5916) 		snprintf(name, sizeof(name), "ras_log");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5917) 		phba->debug_ras_log =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5918) 			debugfs_create_file(name, 0644,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5919) 					    phba->hba_debugfs_root,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5920) 					    phba, &lpfc_debugfs_ras_log);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5921) 		if (!phba->debug_ras_log) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5922) 			lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5923) 					 "6148 Cannot create debugfs"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5924) 					 " ras_log\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5925) 			goto debug_failed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5926) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5927) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5928) 		/* Setup hbqinfo */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5929) 		snprintf(name, sizeof(name), "hbqinfo");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5930) 		phba->debug_hbqinfo =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5931) 			debugfs_create_file(name, S_IFREG | 0644,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5932) 					    phba->hba_debugfs_root,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5933) 					    phba, &lpfc_debugfs_op_hbqinfo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5934) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5935) #ifdef LPFC_HDWQ_LOCK_STAT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5936) 		/* Setup lockstat */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5937) 		snprintf(name, sizeof(name), "lockstat");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5938) 		phba->debug_lockstat =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5939) 			debugfs_create_file(name, S_IFREG | 0644,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5940) 					    phba->hba_debugfs_root,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5941) 					    phba, &lpfc_debugfs_op_lockstat);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5942) 		if (!phba->debug_lockstat) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5943) 			lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5944) 					 "4610 Can't create debugfs lockstat\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5945) 			goto debug_failed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5946) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5947) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5948) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5949) 		/* Setup dumpHBASlim */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5950) 		if (phba->sli_rev < LPFC_SLI_REV4) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5951) 			snprintf(name, sizeof(name), "dumpHBASlim");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5952) 			phba->debug_dumpHBASlim =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5953) 				debugfs_create_file(name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5954) 					S_IFREG|S_IRUGO|S_IWUSR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5955) 					phba->hba_debugfs_root,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5956) 					phba, &lpfc_debugfs_op_dumpHBASlim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5957) 		} else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5958) 			phba->debug_dumpHBASlim = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5959) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5960) 		/* Setup dumpHostSlim */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5961) 		if (phba->sli_rev < LPFC_SLI_REV4) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5962) 			snprintf(name, sizeof(name), "dumpHostSlim");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5963) 			phba->debug_dumpHostSlim =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5964) 				debugfs_create_file(name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5965) 					S_IFREG|S_IRUGO|S_IWUSR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5966) 					phba->hba_debugfs_root,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5967) 					phba, &lpfc_debugfs_op_dumpHostSlim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5968) 		} else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5969) 			phba->debug_dumpHostSlim = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5970) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5971) 		/* Setup DIF Error Injections */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5972) 		snprintf(name, sizeof(name), "InjErrLBA");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5973) 		phba->debug_InjErrLBA =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5974) 			debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5975) 			phba->hba_debugfs_root,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5976) 			phba, &lpfc_debugfs_op_dif_err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5977) 		phba->lpfc_injerr_lba = LPFC_INJERR_LBA_OFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5978) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5979) 		snprintf(name, sizeof(name), "InjErrNPortID");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5980) 		phba->debug_InjErrNPortID =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5981) 			debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5982) 			phba->hba_debugfs_root,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5983) 			phba, &lpfc_debugfs_op_dif_err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5984) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5985) 		snprintf(name, sizeof(name), "InjErrWWPN");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5986) 		phba->debug_InjErrWWPN =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5987) 			debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5988) 			phba->hba_debugfs_root,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5989) 			phba, &lpfc_debugfs_op_dif_err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5990) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5991) 		snprintf(name, sizeof(name), "writeGuardInjErr");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5992) 		phba->debug_writeGuard =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5993) 			debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5994) 			phba->hba_debugfs_root,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5995) 			phba, &lpfc_debugfs_op_dif_err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5996) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5997) 		snprintf(name, sizeof(name), "writeAppInjErr");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5998) 		phba->debug_writeApp =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5999) 			debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6000) 			phba->hba_debugfs_root,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6001) 			phba, &lpfc_debugfs_op_dif_err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6002) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6003) 		snprintf(name, sizeof(name), "writeRefInjErr");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6004) 		phba->debug_writeRef =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6005) 			debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6006) 			phba->hba_debugfs_root,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6007) 			phba, &lpfc_debugfs_op_dif_err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6008) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6009) 		snprintf(name, sizeof(name), "readGuardInjErr");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6010) 		phba->debug_readGuard =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6011) 			debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6012) 			phba->hba_debugfs_root,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6013) 			phba, &lpfc_debugfs_op_dif_err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6014) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6015) 		snprintf(name, sizeof(name), "readAppInjErr");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6016) 		phba->debug_readApp =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6017) 			debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6018) 			phba->hba_debugfs_root,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6019) 			phba, &lpfc_debugfs_op_dif_err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6020) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6021) 		snprintf(name, sizeof(name), "readRefInjErr");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6022) 		phba->debug_readRef =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6023) 			debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6024) 			phba->hba_debugfs_root,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6025) 			phba, &lpfc_debugfs_op_dif_err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6026) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6027) 		/* Setup slow ring trace */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6028) 		if (lpfc_debugfs_max_slow_ring_trc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6029) 			num = lpfc_debugfs_max_slow_ring_trc - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6030) 			if (num & lpfc_debugfs_max_slow_ring_trc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6031) 				/* Change to be a power of 2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6032) 				num = lpfc_debugfs_max_slow_ring_trc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6033) 				i = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6034) 				while (num > 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6035) 					num = num >> 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6036) 					i++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6037) 				}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6038) 				lpfc_debugfs_max_slow_ring_trc = (1 << i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6039) 				pr_err("lpfc_debugfs_max_disc_trc changed to "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6040) 				       "%d\n", lpfc_debugfs_max_disc_trc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6041) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6042) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6043) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6044) 		snprintf(name, sizeof(name), "slow_ring_trace");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6045) 		phba->debug_slow_ring_trc =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6046) 			debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6047) 				 phba->hba_debugfs_root,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6048) 				 phba, &lpfc_debugfs_op_slow_ring_trc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6049) 		if (!phba->slow_ring_trc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6050) 			phba->slow_ring_trc = kmalloc(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6051) 				(sizeof(struct lpfc_debugfs_trc) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6052) 				lpfc_debugfs_max_slow_ring_trc),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6053) 				GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6054) 			if (!phba->slow_ring_trc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6055) 				lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6056) 						 "0416 Cannot create debugfs "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6057) 						 "slow_ring buffer\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6058) 				goto debug_failed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6059) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6060) 			atomic_set(&phba->slow_ring_trc_cnt, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6061) 			memset(phba->slow_ring_trc, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6062) 				(sizeof(struct lpfc_debugfs_trc) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6063) 				lpfc_debugfs_max_slow_ring_trc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6064) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6065) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6066) 		snprintf(name, sizeof(name), "nvmeio_trc");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6067) 		phba->debug_nvmeio_trc =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6068) 			debugfs_create_file(name, 0644,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6069) 					    phba->hba_debugfs_root,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6070) 					    phba, &lpfc_debugfs_op_nvmeio_trc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6071) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6072) 		atomic_set(&phba->nvmeio_trc_cnt, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6073) 		if (lpfc_debugfs_max_nvmeio_trc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6074) 			num = lpfc_debugfs_max_nvmeio_trc - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6075) 			if (num & lpfc_debugfs_max_disc_trc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6076) 				/* Change to be a power of 2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6077) 				num = lpfc_debugfs_max_nvmeio_trc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6078) 				i = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6079) 				while (num > 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6080) 					num = num >> 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6081) 					i++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6082) 				}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6083) 				lpfc_debugfs_max_nvmeio_trc = (1 << i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6084) 				lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6085) 						"0575 lpfc_debugfs_max_nvmeio_trc "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6086) 						"changed to %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6087) 						lpfc_debugfs_max_nvmeio_trc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6088) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6089) 			phba->nvmeio_trc_size = lpfc_debugfs_max_nvmeio_trc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6090) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6091) 			/* Allocate trace buffer and initialize */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6092) 			phba->nvmeio_trc = kzalloc(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6093) 				(sizeof(struct lpfc_debugfs_nvmeio_trc) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6094) 				phba->nvmeio_trc_size), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6095) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6096) 			if (!phba->nvmeio_trc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6097) 				lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6098) 						"0576 Cannot create debugfs "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6099) 						"nvmeio_trc buffer\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6100) 				goto nvmeio_off;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6101) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6102) 			phba->nvmeio_trc_on = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6103) 			phba->nvmeio_trc_output_idx = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6104) 			phba->nvmeio_trc = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6105) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6106) nvmeio_off:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6107) 			phba->nvmeio_trc_size = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6108) 			phba->nvmeio_trc_on = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6109) 			phba->nvmeio_trc_output_idx = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6110) 			phba->nvmeio_trc = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6111) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6112) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6113) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6114) 	snprintf(name, sizeof(name), "vport%d", vport->vpi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6115) 	if (!vport->vport_debugfs_root) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6116) 		vport->vport_debugfs_root =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6117) 			debugfs_create_dir(name, phba->hba_debugfs_root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6118) 		atomic_inc(&phba->debugfs_vport_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6119) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6120) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6121) 	if (lpfc_debugfs_max_disc_trc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6122) 		num = lpfc_debugfs_max_disc_trc - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6123) 		if (num & lpfc_debugfs_max_disc_trc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6124) 			/* Change to be a power of 2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6125) 			num = lpfc_debugfs_max_disc_trc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6126) 			i = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6127) 			while (num > 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6128) 				num = num >> 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6129) 				i++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6130) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6131) 			lpfc_debugfs_max_disc_trc = (1 << i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6132) 			pr_err("lpfc_debugfs_max_disc_trc changed to %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6133) 			       lpfc_debugfs_max_disc_trc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6134) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6135) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6136) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6137) 	vport->disc_trc = kzalloc(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6138) 		(sizeof(struct lpfc_debugfs_trc) * lpfc_debugfs_max_disc_trc),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6139) 		GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6140) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6141) 	if (!vport->disc_trc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6142) 		lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6143) 				 "0418 Cannot create debugfs disc trace "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6144) 				 "buffer\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6145) 		goto debug_failed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6146) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6147) 	atomic_set(&vport->disc_trc_cnt, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6148) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6149) 	snprintf(name, sizeof(name), "discovery_trace");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6150) 	vport->debug_disc_trc =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6151) 		debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6152) 				 vport->vport_debugfs_root,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6153) 				 vport, &lpfc_debugfs_op_disc_trc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6154) 	snprintf(name, sizeof(name), "nodelist");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6155) 	vport->debug_nodelist =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6156) 		debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6157) 				 vport->vport_debugfs_root,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6158) 				 vport, &lpfc_debugfs_op_nodelist);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6159) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6160) 	snprintf(name, sizeof(name), "nvmestat");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6161) 	vport->debug_nvmestat =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6162) 		debugfs_create_file(name, 0644,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6163) 				    vport->vport_debugfs_root,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6164) 				    vport, &lpfc_debugfs_op_nvmestat);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6165) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6166) 	snprintf(name, sizeof(name), "scsistat");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6167) 	vport->debug_scsistat =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6168) 		debugfs_create_file(name, 0644,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6169) 				    vport->vport_debugfs_root,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6170) 				    vport, &lpfc_debugfs_op_scsistat);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6171) 	if (!vport->debug_scsistat) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6172) 		lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6173) 				 "4611 Cannot create debugfs scsistat\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6174) 		goto debug_failed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6175) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6176) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6177) 	snprintf(name, sizeof(name), "ioktime");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6178) 	vport->debug_ioktime =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6179) 		debugfs_create_file(name, 0644,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6180) 				    vport->vport_debugfs_root,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6181) 				    vport, &lpfc_debugfs_op_ioktime);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6182) 	if (!vport->debug_ioktime) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6183) 		lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6184) 				 "0815 Cannot create debugfs ioktime\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6185) 		goto debug_failed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6186) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6187) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6188) 	snprintf(name, sizeof(name), "hdwqstat");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6189) 	vport->debug_hdwqstat =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6190) 		debugfs_create_file(name, 0644,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6191) 				    vport->vport_debugfs_root,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6192) 				    vport, &lpfc_debugfs_op_hdwqstat);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6193) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6194) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6195) 	 * The following section is for additional directories/files for the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6196) 	 * physical port.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6197) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6198) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6199) 	if (!pport_setup)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6200) 		goto debug_failed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6201) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6202) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6203) 	 * iDiag debugfs root entry points for SLI4 device only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6204) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6205) 	if (phba->sli_rev < LPFC_SLI_REV4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6206) 		goto debug_failed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6207) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6208) 	snprintf(name, sizeof(name), "iDiag");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6209) 	if (!phba->idiag_root) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6210) 		phba->idiag_root =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6211) 			debugfs_create_dir(name, phba->hba_debugfs_root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6212) 		/* Initialize iDiag data structure */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6213) 		memset(&idiag, 0, sizeof(idiag));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6214) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6215) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6216) 	/* iDiag read PCI config space */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6217) 	snprintf(name, sizeof(name), "pciCfg");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6218) 	if (!phba->idiag_pci_cfg) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6219) 		phba->idiag_pci_cfg =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6220) 			debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6221) 				phba->idiag_root, phba, &lpfc_idiag_op_pciCfg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6222) 		idiag.offset.last_rd = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6223) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6224) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6225) 	/* iDiag PCI BAR access */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6226) 	snprintf(name, sizeof(name), "barAcc");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6227) 	if (!phba->idiag_bar_acc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6228) 		phba->idiag_bar_acc =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6229) 			debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6230) 				phba->idiag_root, phba, &lpfc_idiag_op_barAcc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6231) 		idiag.offset.last_rd = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6232) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6233) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6234) 	/* iDiag get PCI function queue information */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6235) 	snprintf(name, sizeof(name), "queInfo");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6236) 	if (!phba->idiag_que_info) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6237) 		phba->idiag_que_info =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6238) 			debugfs_create_file(name, S_IFREG|S_IRUGO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6239) 			phba->idiag_root, phba, &lpfc_idiag_op_queInfo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6240) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6241) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6242) 	/* iDiag access PCI function queue */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6243) 	snprintf(name, sizeof(name), "queAcc");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6244) 	if (!phba->idiag_que_acc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6245) 		phba->idiag_que_acc =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6246) 			debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6247) 				phba->idiag_root, phba, &lpfc_idiag_op_queAcc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6248) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6249) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6250) 	/* iDiag access PCI function doorbell registers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6251) 	snprintf(name, sizeof(name), "drbAcc");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6252) 	if (!phba->idiag_drb_acc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6253) 		phba->idiag_drb_acc =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6254) 			debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6255) 				phba->idiag_root, phba, &lpfc_idiag_op_drbAcc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6256) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6257) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6258) 	/* iDiag access PCI function control registers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6259) 	snprintf(name, sizeof(name), "ctlAcc");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6260) 	if (!phba->idiag_ctl_acc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6261) 		phba->idiag_ctl_acc =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6262) 			debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6263) 				phba->idiag_root, phba, &lpfc_idiag_op_ctlAcc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6264) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6265) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6266) 	/* iDiag access mbox commands */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6267) 	snprintf(name, sizeof(name), "mbxAcc");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6268) 	if (!phba->idiag_mbx_acc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6269) 		phba->idiag_mbx_acc =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6270) 			debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6271) 				phba->idiag_root, phba, &lpfc_idiag_op_mbxAcc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6272) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6273) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6274) 	/* iDiag extents access commands */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6275) 	if (phba->sli4_hba.extents_in_use) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6276) 		snprintf(name, sizeof(name), "extAcc");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6277) 		if (!phba->idiag_ext_acc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6278) 			phba->idiag_ext_acc =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6279) 				debugfs_create_file(name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6280) 						    S_IFREG|S_IRUGO|S_IWUSR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6281) 						    phba->idiag_root, phba,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6282) 						    &lpfc_idiag_op_extAcc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6283) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6284) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6285) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6286) debug_failed:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6287) 	return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6288) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6289) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6290) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6291) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6292)  * lpfc_debugfs_terminate -  Tear down debugfs infrastructure for this vport
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6293)  * @vport: The vport pointer to remove from debugfs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6294)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6295)  * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6296)  * When Debugfs is configured this routine removes debugfs file system elements
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6297)  * that are specific to this vport. It also checks to see if there are any
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6298)  * users left for the debugfs directories associated with the HBA and driver. If
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6299)  * this is the last user of the HBA directory or driver directory then it will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6300)  * remove those from the debugfs infrastructure as well.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6301)  **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6302) inline void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6303) lpfc_debugfs_terminate(struct lpfc_vport *vport)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6304) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6305) #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6306) 	struct lpfc_hba   *phba = vport->phba;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6307) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6308) 	kfree(vport->disc_trc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6309) 	vport->disc_trc = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6310) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6311) 	debugfs_remove(vport->debug_disc_trc); /* discovery_trace */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6312) 	vport->debug_disc_trc = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6313) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6314) 	debugfs_remove(vport->debug_nodelist); /* nodelist */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6315) 	vport->debug_nodelist = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6316) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6317) 	debugfs_remove(vport->debug_nvmestat); /* nvmestat */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6318) 	vport->debug_nvmestat = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6319) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6320) 	debugfs_remove(vport->debug_scsistat); /* scsistat */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6321) 	vport->debug_scsistat = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6322) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6323) 	debugfs_remove(vport->debug_ioktime); /* ioktime */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6324) 	vport->debug_ioktime = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6325) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6326) 	debugfs_remove(vport->debug_hdwqstat); /* hdwqstat */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6327) 	vport->debug_hdwqstat = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6328) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6329) 	if (vport->vport_debugfs_root) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6330) 		debugfs_remove(vport->vport_debugfs_root); /* vportX */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6331) 		vport->vport_debugfs_root = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6332) 		atomic_dec(&phba->debugfs_vport_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6333) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6334) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6335) 	if (atomic_read(&phba->debugfs_vport_count) == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6336) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6337) 		debugfs_remove(phba->debug_multixri_pools); /* multixripools*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6338) 		phba->debug_multixri_pools = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6339) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6340) 		debugfs_remove(phba->debug_hbqinfo); /* hbqinfo */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6341) 		phba->debug_hbqinfo = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6342) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6343) 		debugfs_remove(phba->debug_ras_log);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6344) 		phba->debug_ras_log = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6345) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6346) #ifdef LPFC_HDWQ_LOCK_STAT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6347) 		debugfs_remove(phba->debug_lockstat); /* lockstat */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6348) 		phba->debug_lockstat = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6349) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6350) 		debugfs_remove(phba->debug_dumpHBASlim); /* HBASlim */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6351) 		phba->debug_dumpHBASlim = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6352) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6353) 		debugfs_remove(phba->debug_dumpHostSlim); /* HostSlim */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6354) 		phba->debug_dumpHostSlim = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6355) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6356) 		debugfs_remove(phba->debug_InjErrLBA); /* InjErrLBA */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6357) 		phba->debug_InjErrLBA = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6358) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6359) 		debugfs_remove(phba->debug_InjErrNPortID);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6360) 		phba->debug_InjErrNPortID = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6361) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6362) 		debugfs_remove(phba->debug_InjErrWWPN); /* InjErrWWPN */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6363) 		phba->debug_InjErrWWPN = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6364) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6365) 		debugfs_remove(phba->debug_writeGuard); /* writeGuard */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6366) 		phba->debug_writeGuard = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6367) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6368) 		debugfs_remove(phba->debug_writeApp); /* writeApp */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6369) 		phba->debug_writeApp = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6370) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6371) 		debugfs_remove(phba->debug_writeRef); /* writeRef */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6372) 		phba->debug_writeRef = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6373) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6374) 		debugfs_remove(phba->debug_readGuard); /* readGuard */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6375) 		phba->debug_readGuard = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6376) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6377) 		debugfs_remove(phba->debug_readApp); /* readApp */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6378) 		phba->debug_readApp = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6379) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6380) 		debugfs_remove(phba->debug_readRef); /* readRef */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6381) 		phba->debug_readRef = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6382) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6383) 		kfree(phba->slow_ring_trc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6384) 		phba->slow_ring_trc = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6385) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6386) 		/* slow_ring_trace */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6387) 		debugfs_remove(phba->debug_slow_ring_trc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6388) 		phba->debug_slow_ring_trc = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6389) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6390) 		debugfs_remove(phba->debug_nvmeio_trc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6391) 		phba->debug_nvmeio_trc = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6392) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6393) 		kfree(phba->nvmeio_trc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6394) 		phba->nvmeio_trc = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6395) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6396) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6397) 		 * iDiag release
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6398) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6399) 		if (phba->sli_rev == LPFC_SLI_REV4) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6400) 			/* iDiag extAcc */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6401) 			debugfs_remove(phba->idiag_ext_acc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6402) 			phba->idiag_ext_acc = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6403) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6404) 			/* iDiag mbxAcc */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6405) 			debugfs_remove(phba->idiag_mbx_acc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6406) 			phba->idiag_mbx_acc = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6407) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6408) 			/* iDiag ctlAcc */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6409) 			debugfs_remove(phba->idiag_ctl_acc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6410) 			phba->idiag_ctl_acc = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6411) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6412) 			/* iDiag drbAcc */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6413) 			debugfs_remove(phba->idiag_drb_acc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6414) 			phba->idiag_drb_acc = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6415) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6416) 			/* iDiag queAcc */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6417) 			debugfs_remove(phba->idiag_que_acc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6418) 			phba->idiag_que_acc = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6419) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6420) 			/* iDiag queInfo */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6421) 			debugfs_remove(phba->idiag_que_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6422) 			phba->idiag_que_info = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6423) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6424) 			/* iDiag barAcc */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6425) 			debugfs_remove(phba->idiag_bar_acc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6426) 			phba->idiag_bar_acc = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6427) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6428) 			/* iDiag pciCfg */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6429) 			debugfs_remove(phba->idiag_pci_cfg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6430) 			phba->idiag_pci_cfg = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6431) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6432) 			/* Finally remove the iDiag debugfs root */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6433) 			debugfs_remove(phba->idiag_root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6434) 			phba->idiag_root = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6435) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6436) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6437) 		if (phba->hba_debugfs_root) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6438) 			debugfs_remove(phba->hba_debugfs_root); /* fnX */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6439) 			phba->hba_debugfs_root = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6440) 			atomic_dec(&lpfc_debugfs_hba_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6441) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6442) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6443) 		if (atomic_read(&lpfc_debugfs_hba_count) == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6444) 			debugfs_remove(lpfc_debugfs_root); /* lpfc */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6445) 			lpfc_debugfs_root = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6446) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6447) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6448) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6449) 	return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6450) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6451) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6452) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6453)  * Driver debug utility routines outside of debugfs. The debug utility
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6454)  * routines implemented here is intended to be used in the instrumented
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6455)  * debug driver for debugging host or port issues.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6456)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6457) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6458) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6459)  * lpfc_debug_dump_all_queues - dump all the queues with a hba
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6460)  * @phba: Pointer to HBA context object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6461)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6462)  * This function dumps entries of all the queues asociated with the @phba.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6463)  **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6464) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6465) lpfc_debug_dump_all_queues(struct lpfc_hba *phba)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6466) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6467) 	int idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6468) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6469) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6470) 	 * Dump Work Queues (WQs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6471) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6472) 	lpfc_debug_dump_wq(phba, DUMP_MBX, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6473) 	lpfc_debug_dump_wq(phba, DUMP_ELS, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6474) 	lpfc_debug_dump_wq(phba, DUMP_NVMELS, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6475) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6476) 	for (idx = 0; idx < phba->cfg_hdw_queue; idx++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6477) 		lpfc_debug_dump_wq(phba, DUMP_IO, idx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6478) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6479) 	lpfc_debug_dump_hdr_rq(phba);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6480) 	lpfc_debug_dump_dat_rq(phba);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6481) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6482) 	 * Dump Complete Queues (CQs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6483) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6484) 	lpfc_debug_dump_cq(phba, DUMP_MBX, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6485) 	lpfc_debug_dump_cq(phba, DUMP_ELS, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6486) 	lpfc_debug_dump_cq(phba, DUMP_NVMELS, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6487) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6488) 	for (idx = 0; idx < phba->cfg_hdw_queue; idx++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6489) 		lpfc_debug_dump_cq(phba, DUMP_IO, idx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6490) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6491) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6492) 	 * Dump Event Queues (EQs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6493) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6494) 	for (idx = 0; idx < phba->cfg_hdw_queue; idx++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6495) 		lpfc_debug_dump_hba_eq(phba, idx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6496) }