James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1 | /******************************************************************* |
| 2 | * This file is part of the Emulex Linux Device Driver for * |
| 3 | * Fibre Channel Host Bus Adapters. * |
James Smart | 0d04121 | 2019-01-28 11:14:41 -0800 | [diff] [blame] | 4 | * Copyright (C) 2017-2019 Broadcom. All Rights Reserved. The term * |
James Smart | 3e21d1c | 2018-05-04 20:37:59 -0700 | [diff] [blame] | 5 | * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. * |
James Smart | f25e8e7 | 2015-04-07 15:07:28 -0400 | [diff] [blame] | 6 | * Copyright (C) 2007-2015 Emulex. All rights reserved. * |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 7 | * EMULEX and SLI are trademarks of Emulex. * |
James Smart | d080abe | 2017-02-12 13:52:39 -0800 | [diff] [blame] | 8 | * www.broadcom.com * |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 9 | * * |
| 10 | * This program is free software; you can redistribute it and/or * |
| 11 | * modify it under the terms of version 2 of the GNU General * |
| 12 | * Public License as published by the Free Software Foundation. * |
| 13 | * This program is distributed in the hope that it will be useful. * |
| 14 | * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND * |
| 15 | * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, * |
| 16 | * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE * |
| 17 | * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD * |
| 18 | * TO BE LEGALLY INVALID. See the GNU General Public License for * |
| 19 | * more details, a copy of which can be found in the file COPYING * |
| 20 | * included with this package. * |
| 21 | *******************************************************************/ |
| 22 | |
| 23 | #include <linux/blkdev.h> |
| 24 | #include <linux/delay.h> |
Paul Gortmaker | acf3368f | 2011-05-27 09:47:43 -0400 | [diff] [blame] | 25 | #include <linux/module.h> |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 26 | #include <linux/dma-mapping.h> |
| 27 | #include <linux/idr.h> |
| 28 | #include <linux/interrupt.h> |
| 29 | #include <linux/kthread.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 30 | #include <linux/slab.h> |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 31 | #include <linux/pci.h> |
| 32 | #include <linux/spinlock.h> |
| 33 | #include <linux/ctype.h> |
James Smart | 9e2edb4 | 2019-10-25 11:25:30 -0700 | [diff] [blame] | 34 | #include <linux/vmalloc.h> |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 35 | |
| 36 | #include <scsi/scsi.h> |
| 37 | #include <scsi/scsi_device.h> |
| 38 | #include <scsi/scsi_host.h> |
| 39 | #include <scsi/scsi_transport_fc.h> |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 40 | #include <scsi/fc/fc_fs.h> |
| 41 | |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 42 | #include "lpfc_hw4.h" |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 43 | #include "lpfc_hw.h" |
| 44 | #include "lpfc_sli.h" |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 45 | #include "lpfc_sli4.h" |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 46 | #include "lpfc_nl.h" |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 47 | #include "lpfc_disc.h" |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 48 | #include "lpfc.h" |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 49 | #include "lpfc_scsi.h" |
| 50 | #include "lpfc_nvme.h" |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 51 | #include "lpfc_logmsg.h" |
| 52 | #include "lpfc_crtn.h" |
| 53 | #include "lpfc_vport.h" |
| 54 | #include "lpfc_version.h" |
James Smart | c95d6c6 | 2008-01-11 01:53:23 -0500 | [diff] [blame] | 55 | #include "lpfc_compat.h" |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 56 | #include "lpfc_debugfs.h" |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 57 | #include "lpfc_bsg.h" |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 58 | |
James Smart | 923e4b6 | 2008-12-04 22:40:07 -0500 | [diff] [blame] | 59 | #ifdef CONFIG_SCSI_LPFC_DEBUG_FS |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 60 | /* |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 61 | * debugfs interface |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 62 | * |
| 63 | * To access this interface the user should: |
GeunSik Lim | 156f5a7 | 2009-06-02 15:01:37 +0900 | [diff] [blame] | 64 | * # mount -t debugfs none /sys/kernel/debug |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 65 | * |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 66 | * The lpfc debugfs directory hierarchy is: |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 67 | * /sys/kernel/debug/lpfc/fnX/vportY |
| 68 | * where X is the lpfc hba function unique_id |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 69 | * where Y is the vport VPI on that hba |
| 70 | * |
| 71 | * Debugging services available per vport: |
| 72 | * discovery_trace |
| 73 | * This is an ACSII readable file that contains a trace of the last |
| 74 | * lpfc_debugfs_max_disc_trc events that happened on a specific vport. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 75 | * See lpfc_debugfs.h for different categories of discovery events. |
| 76 | * To enable the discovery trace, the following module parameters must be set: |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 77 | * lpfc_debugfs_enable=1 Turns on lpfc debugfs filesystem support |
| 78 | * lpfc_debugfs_max_disc_trc=X Where X is the event trace depth for |
| 79 | * EACH vport. X MUST also be a power of 2. |
| 80 | * lpfc_debugfs_mask_disc_trc=Y Where Y is an event mask as defined in |
| 81 | * lpfc_debugfs.h . |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 82 | * |
| 83 | * slow_ring_trace |
| 84 | * This is an ACSII readable file that contains a trace of the last |
| 85 | * lpfc_debugfs_max_slow_ring_trc events that happened on a specific HBA. |
| 86 | * To enable the slow ring trace, the following module parameters must be set: |
| 87 | * lpfc_debugfs_enable=1 Turns on lpfc debugfs filesystem support |
| 88 | * lpfc_debugfs_max_slow_ring_trc=X Where X is the event trace depth for |
| 89 | * the HBA. X MUST also be a power of 2. |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 90 | */ |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 91 | static int lpfc_debugfs_enable = 1; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 92 | module_param(lpfc_debugfs_enable, int, S_IRUGO); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 93 | MODULE_PARM_DESC(lpfc_debugfs_enable, "Enable debugfs services"); |
| 94 | |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 95 | /* This MUST be a power of 2 */ |
James Smart | c95d6c6 | 2008-01-11 01:53:23 -0500 | [diff] [blame] | 96 | static int lpfc_debugfs_max_disc_trc; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 97 | module_param(lpfc_debugfs_max_disc_trc, int, S_IRUGO); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 98 | MODULE_PARM_DESC(lpfc_debugfs_max_disc_trc, |
| 99 | "Set debugfs discovery trace depth"); |
| 100 | |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 101 | /* This MUST be a power of 2 */ |
James Smart | c95d6c6 | 2008-01-11 01:53:23 -0500 | [diff] [blame] | 102 | static int lpfc_debugfs_max_slow_ring_trc; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 103 | module_param(lpfc_debugfs_max_slow_ring_trc, int, S_IRUGO); |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 104 | MODULE_PARM_DESC(lpfc_debugfs_max_slow_ring_trc, |
| 105 | "Set debugfs slow ring trace depth"); |
| 106 | |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 107 | /* This MUST be a power of 2 */ |
| 108 | static int lpfc_debugfs_max_nvmeio_trc; |
| 109 | module_param(lpfc_debugfs_max_nvmeio_trc, int, 0444); |
| 110 | MODULE_PARM_DESC(lpfc_debugfs_max_nvmeio_trc, |
| 111 | "Set debugfs NVME IO trace depth"); |
| 112 | |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 113 | static int lpfc_debugfs_mask_disc_trc; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 114 | module_param(lpfc_debugfs_mask_disc_trc, int, S_IRUGO); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 115 | MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc, |
| 116 | "Set debugfs discovery trace mask"); |
| 117 | |
| 118 | #include <linux/debugfs.h> |
| 119 | |
James Smart | 311464e | 2007-08-02 11:10:37 -0400 | [diff] [blame] | 120 | static atomic_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0); |
| 121 | static unsigned long lpfc_debugfs_start_time = 0L; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 122 | |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 123 | /* iDiag */ |
| 124 | static struct lpfc_idiag idiag; |
| 125 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 126 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 127 | * lpfc_debugfs_disc_trc_data - Dump discovery logging to a buffer |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 128 | * @vport: The vport to gather the log info from. |
| 129 | * @buf: The buffer to dump log into. |
| 130 | * @size: The maximum amount of data to process. |
| 131 | * |
| 132 | * Description: |
| 133 | * This routine gathers the lpfc discovery debugfs data from the @vport and |
| 134 | * dumps it to @buf up to @size number of bytes. It will start at the next entry |
| 135 | * in the log and process the log until the end of the buffer. Then it will |
| 136 | * gather from the beginning of the log and process until the current entry. |
| 137 | * |
| 138 | * Notes: |
| 139 | * Discovery logging will be disabled while while this routine dumps the log. |
| 140 | * |
| 141 | * Return Value: |
| 142 | * This routine returns the amount of bytes that were dumped into @buf and will |
| 143 | * not exceed @size. |
| 144 | **/ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 145 | static int |
| 146 | lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size) |
| 147 | { |
| 148 | int i, index, len, enable; |
| 149 | uint32_t ms; |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 150 | struct lpfc_debugfs_trc *dtp; |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 151 | char *buffer; |
| 152 | |
| 153 | buffer = kmalloc(LPFC_DEBUG_TRC_ENTRY_SIZE, GFP_KERNEL); |
| 154 | if (!buffer) |
| 155 | return 0; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 156 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 157 | enable = lpfc_debugfs_enable; |
| 158 | lpfc_debugfs_enable = 0; |
| 159 | |
| 160 | len = 0; |
| 161 | index = (atomic_read(&vport->disc_trc_cnt) + 1) & |
| 162 | (lpfc_debugfs_max_disc_trc - 1); |
| 163 | for (i = index; i < lpfc_debugfs_max_disc_trc; i++) { |
| 164 | dtp = vport->disc_trc + i; |
| 165 | if (!dtp->fmt) |
| 166 | continue; |
| 167 | ms = jiffies_to_msecs(dtp->jif - lpfc_debugfs_start_time); |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 168 | snprintf(buffer, |
| 169 | LPFC_DEBUG_TRC_ENTRY_SIZE, "%010d:%010d ms:%s\n", |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 170 | dtp->seq_cnt, ms, dtp->fmt); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 171 | len += scnprintf(buf+len, size-len, buffer, |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 172 | dtp->data1, dtp->data2, dtp->data3); |
| 173 | } |
| 174 | for (i = 0; i < index; i++) { |
| 175 | dtp = vport->disc_trc + i; |
| 176 | if (!dtp->fmt) |
| 177 | continue; |
| 178 | ms = jiffies_to_msecs(dtp->jif - lpfc_debugfs_start_time); |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 179 | snprintf(buffer, |
| 180 | LPFC_DEBUG_TRC_ENTRY_SIZE, "%010d:%010d ms:%s\n", |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 181 | dtp->seq_cnt, ms, dtp->fmt); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 182 | len += scnprintf(buf+len, size-len, buffer, |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 183 | dtp->data1, dtp->data2, dtp->data3); |
| 184 | } |
| 185 | |
| 186 | lpfc_debugfs_enable = enable; |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 187 | kfree(buffer); |
| 188 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 189 | return len; |
| 190 | } |
| 191 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 192 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 193 | * lpfc_debugfs_slow_ring_trc_data - Dump slow ring logging to a buffer |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 194 | * @phba: The HBA to gather the log info from. |
| 195 | * @buf: The buffer to dump log into. |
| 196 | * @size: The maximum amount of data to process. |
| 197 | * |
| 198 | * Description: |
| 199 | * This routine gathers the lpfc slow ring debugfs data from the @phba and |
| 200 | * dumps it to @buf up to @size number of bytes. It will start at the next entry |
| 201 | * in the log and process the log until the end of the buffer. Then it will |
| 202 | * gather from the beginning of the log and process until the current entry. |
| 203 | * |
| 204 | * Notes: |
| 205 | * Slow ring logging will be disabled while while this routine dumps the log. |
| 206 | * |
| 207 | * Return Value: |
| 208 | * This routine returns the amount of bytes that were dumped into @buf and will |
| 209 | * not exceed @size. |
| 210 | **/ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 211 | static int |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 212 | lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba *phba, char *buf, int size) |
| 213 | { |
| 214 | int i, index, len, enable; |
| 215 | uint32_t ms; |
| 216 | struct lpfc_debugfs_trc *dtp; |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 217 | char *buffer; |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 218 | |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 219 | buffer = kmalloc(LPFC_DEBUG_TRC_ENTRY_SIZE, GFP_KERNEL); |
| 220 | if (!buffer) |
| 221 | return 0; |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 222 | |
| 223 | enable = lpfc_debugfs_enable; |
| 224 | lpfc_debugfs_enable = 0; |
| 225 | |
| 226 | len = 0; |
| 227 | index = (atomic_read(&phba->slow_ring_trc_cnt) + 1) & |
| 228 | (lpfc_debugfs_max_slow_ring_trc - 1); |
| 229 | for (i = index; i < lpfc_debugfs_max_slow_ring_trc; i++) { |
| 230 | dtp = phba->slow_ring_trc + i; |
| 231 | if (!dtp->fmt) |
| 232 | continue; |
| 233 | ms = jiffies_to_msecs(dtp->jif - lpfc_debugfs_start_time); |
| 234 | snprintf(buffer, |
| 235 | LPFC_DEBUG_TRC_ENTRY_SIZE, "%010d:%010d ms:%s\n", |
| 236 | dtp->seq_cnt, ms, dtp->fmt); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 237 | len += scnprintf(buf+len, size-len, buffer, |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 238 | dtp->data1, dtp->data2, dtp->data3); |
| 239 | } |
| 240 | for (i = 0; i < index; i++) { |
| 241 | dtp = phba->slow_ring_trc + i; |
| 242 | if (!dtp->fmt) |
| 243 | continue; |
| 244 | ms = jiffies_to_msecs(dtp->jif - lpfc_debugfs_start_time); |
| 245 | snprintf(buffer, |
| 246 | LPFC_DEBUG_TRC_ENTRY_SIZE, "%010d:%010d ms:%s\n", |
| 247 | dtp->seq_cnt, ms, dtp->fmt); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 248 | len += scnprintf(buf+len, size-len, buffer, |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 249 | dtp->data1, dtp->data2, dtp->data3); |
| 250 | } |
| 251 | |
| 252 | lpfc_debugfs_enable = enable; |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 253 | kfree(buffer); |
| 254 | |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 255 | return len; |
| 256 | } |
| 257 | |
James Smart | 311464e | 2007-08-02 11:10:37 -0400 | [diff] [blame] | 258 | static int lpfc_debugfs_last_hbq = -1; |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 259 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 260 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 261 | * lpfc_debugfs_hbqinfo_data - Dump host buffer queue info to a buffer |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 262 | * @phba: The HBA to gather host buffer info from. |
| 263 | * @buf: The buffer to dump log into. |
| 264 | * @size: The maximum amount of data to process. |
| 265 | * |
| 266 | * Description: |
| 267 | * This routine dumps the host buffer queue info from the @phba to @buf up to |
| 268 | * @size number of bytes. A header that describes the current hbq state will be |
| 269 | * dumped to @buf first and then info on each hbq entry will be dumped to @buf |
| 270 | * until @size bytes have been dumped or all the hbq info has been dumped. |
| 271 | * |
| 272 | * Notes: |
| 273 | * This routine will rotate through each configured HBQ each time called. |
| 274 | * |
| 275 | * Return Value: |
| 276 | * This routine returns the amount of bytes that were dumped into @buf and will |
| 277 | * not exceed @size. |
| 278 | **/ |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 279 | static int |
| 280 | lpfc_debugfs_hbqinfo_data(struct lpfc_hba *phba, char *buf, int size) |
| 281 | { |
| 282 | int len = 0; |
James Smart | eb01656 | 2014-09-03 12:58:06 -0400 | [diff] [blame] | 283 | int i, j, found, posted, low; |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 284 | uint32_t phys, raw_index, getidx; |
| 285 | struct lpfc_hbq_init *hip; |
| 286 | struct hbq_s *hbqs; |
| 287 | struct lpfc_hbq_entry *hbqe; |
| 288 | struct lpfc_dmabuf *d_buf; |
| 289 | struct hbq_dmabuf *hbq_buf; |
| 290 | |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 291 | if (phba->sli_rev != 3) |
| 292 | return 0; |
James Smart | eb01656 | 2014-09-03 12:58:06 -0400 | [diff] [blame] | 293 | |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 294 | spin_lock_irq(&phba->hbalock); |
| 295 | |
| 296 | /* toggle between multiple hbqs, if any */ |
| 297 | i = lpfc_sli_hbq_count(); |
| 298 | if (i > 1) { |
| 299 | lpfc_debugfs_last_hbq++; |
| 300 | if (lpfc_debugfs_last_hbq >= i) |
| 301 | lpfc_debugfs_last_hbq = 0; |
| 302 | } |
| 303 | else |
| 304 | lpfc_debugfs_last_hbq = 0; |
| 305 | |
| 306 | i = lpfc_debugfs_last_hbq; |
| 307 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 308 | len += scnprintf(buf+len, size-len, "HBQ %d Info\n", i); |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 309 | |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 310 | hbqs = &phba->hbqs[i]; |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 311 | posted = 0; |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 312 | list_for_each_entry(d_buf, &hbqs->hbq_buffer_list, list) |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 313 | posted++; |
| 314 | |
| 315 | hip = lpfc_hbq_defs[i]; |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 316 | len += scnprintf(buf+len, size-len, |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 317 | "idx:%d prof:%d rn:%d bufcnt:%d icnt:%d acnt:%d posted %d\n", |
| 318 | hip->hbq_index, hip->profile, hip->rn, |
| 319 | hip->buffer_count, hip->init_count, hip->add_count, posted); |
| 320 | |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 321 | raw_index = phba->hbq_get[i]; |
| 322 | getidx = le32_to_cpu(raw_index); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 323 | len += scnprintf(buf+len, size-len, |
Colin Ian King | 1ab6207 | 2017-05-26 11:11:37 +0100 | [diff] [blame] | 324 | "entries:%d bufcnt:%d Put:%d nPut:%d localGet:%d hbaGet:%d\n", |
James Smart | a8adb83 | 2007-10-27 13:37:53 -0400 | [diff] [blame] | 325 | hbqs->entry_count, hbqs->buffer_count, hbqs->hbqPutIdx, |
| 326 | hbqs->next_hbqPutIdx, hbqs->local_hbqGetIdx, getidx); |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 327 | |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 328 | hbqe = (struct lpfc_hbq_entry *) phba->hbqs[i].hbq_virt; |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 329 | for (j=0; j<hbqs->entry_count; j++) { |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 330 | len += scnprintf(buf+len, size-len, |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 331 | "%03d: %08x %04x %05x ", j, |
James Smart | a8adb83 | 2007-10-27 13:37:53 -0400 | [diff] [blame] | 332 | le32_to_cpu(hbqe->bde.addrLow), |
| 333 | le32_to_cpu(hbqe->bde.tus.w), |
| 334 | le32_to_cpu(hbqe->buffer_tag)); |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 335 | i = 0; |
| 336 | found = 0; |
| 337 | |
| 338 | /* First calculate if slot has an associated posted buffer */ |
| 339 | low = hbqs->hbqPutIdx - posted; |
| 340 | if (low >= 0) { |
| 341 | if ((j >= hbqs->hbqPutIdx) || (j < low)) { |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 342 | len += scnprintf(buf + len, size - len, |
| 343 | "Unused\n"); |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 344 | goto skipit; |
| 345 | } |
| 346 | } |
| 347 | else { |
| 348 | if ((j >= hbqs->hbqPutIdx) && |
| 349 | (j < (hbqs->entry_count+low))) { |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 350 | len += scnprintf(buf + len, size - len, |
| 351 | "Unused\n"); |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 352 | goto skipit; |
| 353 | } |
| 354 | } |
| 355 | |
| 356 | /* Get the Buffer info for the posted buffer */ |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 357 | list_for_each_entry(d_buf, &hbqs->hbq_buffer_list, list) { |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 358 | hbq_buf = container_of(d_buf, struct hbq_dmabuf, dbuf); |
| 359 | phys = ((uint64_t)hbq_buf->dbuf.phys & 0xffffffff); |
James Smart | a8adb83 | 2007-10-27 13:37:53 -0400 | [diff] [blame] | 360 | if (phys == le32_to_cpu(hbqe->bde.addrLow)) { |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 361 | len += scnprintf(buf+len, size-len, |
James Smart | 3235066 | 2019-08-14 16:57:06 -0700 | [diff] [blame] | 362 | "Buf%d: x%px %06x\n", i, |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 363 | hbq_buf->dbuf.virt, hbq_buf->tag); |
| 364 | found = 1; |
| 365 | break; |
| 366 | } |
| 367 | i++; |
| 368 | } |
| 369 | if (!found) { |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 370 | len += scnprintf(buf+len, size-len, "No DMAinfo?\n"); |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 371 | } |
| 372 | skipit: |
| 373 | hbqe++; |
| 374 | if (len > LPFC_HBQINFO_SIZE - 54) |
| 375 | break; |
| 376 | } |
| 377 | spin_unlock_irq(&phba->hbalock); |
| 378 | return len; |
| 379 | } |
| 380 | |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 381 | static int lpfc_debugfs_last_xripool; |
| 382 | |
| 383 | /** |
| 384 | * lpfc_debugfs_common_xri_data - Dump Hardware Queue info to a buffer |
| 385 | * @phba: The HBA to gather host buffer info from. |
| 386 | * @buf: The buffer to dump log into. |
| 387 | * @size: The maximum amount of data to process. |
| 388 | * |
| 389 | * Description: |
| 390 | * This routine dumps the Hardware Queue info from the @phba to @buf up to |
| 391 | * @size number of bytes. A header that describes the current hdwq state will be |
| 392 | * dumped to @buf first and then info on each hdwq entry will be dumped to @buf |
| 393 | * until @size bytes have been dumped or all the hdwq info has been dumped. |
| 394 | * |
| 395 | * Notes: |
| 396 | * This routine will rotate through each configured Hardware Queue each |
| 397 | * time called. |
| 398 | * |
| 399 | * Return Value: |
| 400 | * This routine returns the amount of bytes that were dumped into @buf and will |
| 401 | * not exceed @size. |
| 402 | **/ |
| 403 | static int |
| 404 | lpfc_debugfs_commonxripools_data(struct lpfc_hba *phba, char *buf, int size) |
| 405 | { |
| 406 | struct lpfc_sli4_hdw_queue *qp; |
| 407 | int len = 0; |
| 408 | int i, out; |
| 409 | unsigned long iflag; |
| 410 | |
| 411 | for (i = 0; i < phba->cfg_hdw_queue; i++) { |
| 412 | if (len > (LPFC_DUMP_MULTIXRIPOOL_SIZE - 80)) |
| 413 | break; |
| 414 | qp = &phba->sli4_hba.hdwq[lpfc_debugfs_last_xripool]; |
| 415 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 416 | len += scnprintf(buf + len, size - len, "HdwQ %d Info ", i); |
James Smart | c00f62e | 2019-08-14 16:57:11 -0700 | [diff] [blame] | 417 | spin_lock_irqsave(&qp->abts_io_buf_list_lock, iflag); |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 418 | spin_lock(&qp->io_buf_list_get_lock); |
| 419 | spin_lock(&qp->io_buf_list_put_lock); |
| 420 | out = qp->total_io_bufs - (qp->get_io_bufs + qp->put_io_bufs + |
| 421 | qp->abts_scsi_io_bufs + qp->abts_nvme_io_bufs); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 422 | len += scnprintf(buf + len, size - len, |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 423 | "tot:%d get:%d put:%d mt:%d " |
| 424 | "ABTS scsi:%d nvme:%d Out:%d\n", |
| 425 | qp->total_io_bufs, qp->get_io_bufs, qp->put_io_bufs, |
| 426 | qp->empty_io_bufs, qp->abts_scsi_io_bufs, |
| 427 | qp->abts_nvme_io_bufs, out); |
| 428 | spin_unlock(&qp->io_buf_list_put_lock); |
| 429 | spin_unlock(&qp->io_buf_list_get_lock); |
James Smart | c00f62e | 2019-08-14 16:57:11 -0700 | [diff] [blame] | 430 | spin_unlock_irqrestore(&qp->abts_io_buf_list_lock, iflag); |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 431 | |
| 432 | lpfc_debugfs_last_xripool++; |
| 433 | if (lpfc_debugfs_last_xripool >= phba->cfg_hdw_queue) |
| 434 | lpfc_debugfs_last_xripool = 0; |
| 435 | } |
| 436 | |
| 437 | return len; |
| 438 | } |
| 439 | |
James Smart | c490850 | 2019-01-28 11:14:28 -0800 | [diff] [blame] | 440 | /** |
| 441 | * lpfc_debugfs_multixripools_data - Display multi-XRI pools information |
| 442 | * @phba: The HBA to gather host buffer info from. |
| 443 | * @buf: The buffer to dump log into. |
| 444 | * @size: The maximum amount of data to process. |
| 445 | * |
| 446 | * Description: |
| 447 | * This routine displays current multi-XRI pools information including XRI |
| 448 | * count in public, private and txcmplq. It also displays current high and |
| 449 | * low watermark. |
| 450 | * |
| 451 | * Return Value: |
| 452 | * This routine returns the amount of bytes that were dumped into @buf and will |
| 453 | * not exceed @size. |
| 454 | **/ |
| 455 | static int |
| 456 | lpfc_debugfs_multixripools_data(struct lpfc_hba *phba, char *buf, int size) |
| 457 | { |
| 458 | u32 i; |
| 459 | u32 hwq_count; |
| 460 | struct lpfc_sli4_hdw_queue *qp; |
| 461 | struct lpfc_multixri_pool *multixri_pool; |
| 462 | struct lpfc_pvt_pool *pvt_pool; |
| 463 | struct lpfc_pbl_pool *pbl_pool; |
| 464 | u32 txcmplq_cnt; |
| 465 | char tmp[LPFC_DEBUG_OUT_LINE_SZ] = {0}; |
| 466 | |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 467 | if (phba->sli_rev != LPFC_SLI_REV4) |
| 468 | return 0; |
| 469 | |
| 470 | if (!phba->sli4_hba.hdwq) |
| 471 | return 0; |
| 472 | |
| 473 | if (!phba->cfg_xri_rebalancing) { |
| 474 | i = lpfc_debugfs_commonxripools_data(phba, buf, size); |
| 475 | return i; |
| 476 | } |
| 477 | |
James Smart | c490850 | 2019-01-28 11:14:28 -0800 | [diff] [blame] | 478 | /* |
| 479 | * Pbl: Current number of free XRIs in public pool |
| 480 | * Pvt: Current number of free XRIs in private pool |
| 481 | * Busy: Current number of outstanding XRIs |
| 482 | * HWM: Current high watermark |
| 483 | * pvt_empty: Incremented by 1 when IO submission fails (no xri) |
| 484 | * pbl_empty: Incremented by 1 when all pbl_pool are empty during |
| 485 | * IO submission |
| 486 | */ |
| 487 | scnprintf(tmp, sizeof(tmp), |
| 488 | "HWQ: Pbl Pvt Busy HWM | pvt_empty pbl_empty "); |
| 489 | if (strlcat(buf, tmp, size) >= size) |
| 490 | return strnlen(buf, size); |
| 491 | |
| 492 | #ifdef LPFC_MXP_STAT |
| 493 | /* |
| 494 | * MAXH: Max high watermark seen so far |
| 495 | * above_lmt: Incremented by 1 if xri_owned > xri_limit during |
| 496 | * IO submission |
| 497 | * below_lmt: Incremented by 1 if xri_owned <= xri_limit during |
| 498 | * IO submission |
| 499 | * locPbl_hit: Incremented by 1 if successfully get a batch of XRI from |
| 500 | * local pbl_pool |
| 501 | * othPbl_hit: Incremented by 1 if successfully get a batch of XRI from |
| 502 | * other pbl_pool |
| 503 | */ |
| 504 | scnprintf(tmp, sizeof(tmp), |
| 505 | "MAXH above_lmt below_lmt locPbl_hit othPbl_hit"); |
| 506 | if (strlcat(buf, tmp, size) >= size) |
| 507 | return strnlen(buf, size); |
| 508 | |
| 509 | /* |
| 510 | * sPbl: snapshot of Pbl 15 sec after stat gets cleared |
| 511 | * sPvt: snapshot of Pvt 15 sec after stat gets cleared |
| 512 | * sBusy: snapshot of Busy 15 sec after stat gets cleared |
| 513 | */ |
| 514 | scnprintf(tmp, sizeof(tmp), |
| 515 | " | sPbl sPvt sBusy"); |
| 516 | if (strlcat(buf, tmp, size) >= size) |
| 517 | return strnlen(buf, size); |
| 518 | #endif |
| 519 | |
| 520 | scnprintf(tmp, sizeof(tmp), "\n"); |
| 521 | if (strlcat(buf, tmp, size) >= size) |
| 522 | return strnlen(buf, size); |
| 523 | |
| 524 | hwq_count = phba->cfg_hdw_queue; |
| 525 | for (i = 0; i < hwq_count; i++) { |
| 526 | qp = &phba->sli4_hba.hdwq[i]; |
| 527 | multixri_pool = qp->p_multixri_pool; |
| 528 | if (!multixri_pool) |
| 529 | continue; |
| 530 | pbl_pool = &multixri_pool->pbl_pool; |
| 531 | pvt_pool = &multixri_pool->pvt_pool; |
James Smart | c00f62e | 2019-08-14 16:57:11 -0700 | [diff] [blame] | 532 | txcmplq_cnt = qp->io_wq->pring->txcmplq_cnt; |
James Smart | c490850 | 2019-01-28 11:14:28 -0800 | [diff] [blame] | 533 | |
| 534 | scnprintf(tmp, sizeof(tmp), |
| 535 | "%03d: %4d %4d %4d %4d | %10d %10d ", |
| 536 | i, pbl_pool->count, pvt_pool->count, |
| 537 | txcmplq_cnt, pvt_pool->high_watermark, |
| 538 | qp->empty_io_bufs, multixri_pool->pbl_empty_count); |
| 539 | if (strlcat(buf, tmp, size) >= size) |
| 540 | break; |
| 541 | |
| 542 | #ifdef LPFC_MXP_STAT |
| 543 | scnprintf(tmp, sizeof(tmp), |
| 544 | "%4d %10d %10d %10d %10d", |
| 545 | multixri_pool->stat_max_hwm, |
| 546 | multixri_pool->above_limit_count, |
| 547 | multixri_pool->below_limit_count, |
| 548 | multixri_pool->local_pbl_hit_count, |
| 549 | multixri_pool->other_pbl_hit_count); |
| 550 | if (strlcat(buf, tmp, size) >= size) |
| 551 | break; |
| 552 | |
| 553 | scnprintf(tmp, sizeof(tmp), |
| 554 | " | %4d %4d %5d", |
| 555 | multixri_pool->stat_pbl_count, |
| 556 | multixri_pool->stat_pvt_count, |
| 557 | multixri_pool->stat_busy_count); |
| 558 | if (strlcat(buf, tmp, size) >= size) |
| 559 | break; |
| 560 | #endif |
| 561 | |
| 562 | scnprintf(tmp, sizeof(tmp), "\n"); |
| 563 | if (strlcat(buf, tmp, size) >= size) |
| 564 | break; |
| 565 | } |
| 566 | return strnlen(buf, size); |
| 567 | } |
| 568 | |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 569 | |
| 570 | #ifdef LPFC_HDWQ_LOCK_STAT |
| 571 | static int lpfc_debugfs_last_lock; |
James Smart | 5e5b511 | 2019-01-28 11:14:22 -0800 | [diff] [blame] | 572 | |
| 573 | /** |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 574 | * lpfc_debugfs_lockstat_data - Dump Hardware Queue info to a buffer |
James Smart | 5e5b511 | 2019-01-28 11:14:22 -0800 | [diff] [blame] | 575 | * @phba: The HBA to gather host buffer info from. |
| 576 | * @buf: The buffer to dump log into. |
| 577 | * @size: The maximum amount of data to process. |
| 578 | * |
| 579 | * Description: |
| 580 | * This routine dumps the Hardware Queue info from the @phba to @buf up to |
| 581 | * @size number of bytes. A header that describes the current hdwq state will be |
| 582 | * dumped to @buf first and then info on each hdwq entry will be dumped to @buf |
| 583 | * until @size bytes have been dumped or all the hdwq info has been dumped. |
| 584 | * |
| 585 | * Notes: |
| 586 | * This routine will rotate through each configured Hardware Queue each |
| 587 | * time called. |
| 588 | * |
| 589 | * Return Value: |
| 590 | * This routine returns the amount of bytes that were dumped into @buf and will |
| 591 | * not exceed @size. |
| 592 | **/ |
| 593 | static int |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 594 | lpfc_debugfs_lockstat_data(struct lpfc_hba *phba, char *buf, int size) |
James Smart | 5e5b511 | 2019-01-28 11:14:22 -0800 | [diff] [blame] | 595 | { |
| 596 | struct lpfc_sli4_hdw_queue *qp; |
| 597 | int len = 0; |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 598 | int i; |
James Smart | 5e5b511 | 2019-01-28 11:14:22 -0800 | [diff] [blame] | 599 | |
| 600 | if (phba->sli_rev != LPFC_SLI_REV4) |
| 601 | return 0; |
| 602 | |
| 603 | if (!phba->sli4_hba.hdwq) |
| 604 | return 0; |
| 605 | |
| 606 | for (i = 0; i < phba->cfg_hdw_queue; i++) { |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 607 | if (len > (LPFC_HDWQINFO_SIZE - 100)) |
James Smart | 5e5b511 | 2019-01-28 11:14:22 -0800 | [diff] [blame] | 608 | break; |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 609 | qp = &phba->sli4_hba.hdwq[lpfc_debugfs_last_lock]; |
James Smart | 5e5b511 | 2019-01-28 11:14:22 -0800 | [diff] [blame] | 610 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 611 | len += scnprintf(buf + len, size - len, "HdwQ %03d Lock ", i); |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 612 | if (phba->cfg_xri_rebalancing) { |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 613 | len += scnprintf(buf + len, size - len, |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 614 | "get_pvt:%d mv_pvt:%d " |
| 615 | "mv2pub:%d mv2pvt:%d " |
| 616 | "put_pvt:%d put_pub:%d wq:%d\n", |
| 617 | qp->lock_conflict.alloc_pvt_pool, |
| 618 | qp->lock_conflict.mv_from_pvt_pool, |
| 619 | qp->lock_conflict.mv_to_pub_pool, |
| 620 | qp->lock_conflict.mv_to_pvt_pool, |
| 621 | qp->lock_conflict.free_pvt_pool, |
| 622 | qp->lock_conflict.free_pub_pool, |
| 623 | qp->lock_conflict.wq_access); |
| 624 | } else { |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 625 | len += scnprintf(buf + len, size - len, |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 626 | "get:%d put:%d free:%d wq:%d\n", |
| 627 | qp->lock_conflict.alloc_xri_get, |
| 628 | qp->lock_conflict.alloc_xri_put, |
| 629 | qp->lock_conflict.free_xri, |
| 630 | qp->lock_conflict.wq_access); |
| 631 | } |
James Smart | 5e5b511 | 2019-01-28 11:14:22 -0800 | [diff] [blame] | 632 | |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 633 | lpfc_debugfs_last_lock++; |
| 634 | if (lpfc_debugfs_last_lock >= phba->cfg_hdw_queue) |
| 635 | lpfc_debugfs_last_lock = 0; |
James Smart | 5e5b511 | 2019-01-28 11:14:22 -0800 | [diff] [blame] | 636 | } |
| 637 | |
| 638 | return len; |
| 639 | } |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 640 | #endif |
James Smart | 5e5b511 | 2019-01-28 11:14:22 -0800 | [diff] [blame] | 641 | |
James Smart | c95d6c6 | 2008-01-11 01:53:23 -0500 | [diff] [blame] | 642 | static int lpfc_debugfs_last_hba_slim_off; |
| 643 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 644 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 645 | * lpfc_debugfs_dumpHBASlim_data - Dump HBA SLIM info to a buffer |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 646 | * @phba: The HBA to gather SLIM info from. |
| 647 | * @buf: The buffer to dump log into. |
| 648 | * @size: The maximum amount of data to process. |
| 649 | * |
| 650 | * Description: |
| 651 | * This routine dumps the current contents of HBA SLIM for the HBA associated |
| 652 | * with @phba to @buf up to @size bytes of data. This is the raw HBA SLIM data. |
| 653 | * |
| 654 | * Notes: |
| 655 | * This routine will only dump up to 1024 bytes of data each time called and |
| 656 | * should be called multiple times to dump the entire HBA SLIM. |
| 657 | * |
| 658 | * Return Value: |
| 659 | * This routine returns the amount of bytes that were dumped into @buf and will |
| 660 | * not exceed @size. |
| 661 | **/ |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 662 | static int |
James Smart | c95d6c6 | 2008-01-11 01:53:23 -0500 | [diff] [blame] | 663 | lpfc_debugfs_dumpHBASlim_data(struct lpfc_hba *phba, char *buf, int size) |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 664 | { |
| 665 | int len = 0; |
James Smart | c95d6c6 | 2008-01-11 01:53:23 -0500 | [diff] [blame] | 666 | int i, off; |
| 667 | uint32_t *ptr; |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 668 | char *buffer; |
| 669 | |
| 670 | buffer = kmalloc(1024, GFP_KERNEL); |
| 671 | if (!buffer) |
| 672 | return 0; |
James Smart | c95d6c6 | 2008-01-11 01:53:23 -0500 | [diff] [blame] | 673 | |
| 674 | off = 0; |
| 675 | spin_lock_irq(&phba->hbalock); |
| 676 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 677 | len += scnprintf(buf+len, size-len, "HBA SLIM\n"); |
James Smart | c95d6c6 | 2008-01-11 01:53:23 -0500 | [diff] [blame] | 678 | lpfc_memcpy_from_slim(buffer, |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 679 | phba->MBslimaddr + lpfc_debugfs_last_hba_slim_off, 1024); |
James Smart | c95d6c6 | 2008-01-11 01:53:23 -0500 | [diff] [blame] | 680 | |
| 681 | ptr = (uint32_t *)&buffer[0]; |
| 682 | off = lpfc_debugfs_last_hba_slim_off; |
| 683 | |
| 684 | /* Set it up for the next time */ |
| 685 | lpfc_debugfs_last_hba_slim_off += 1024; |
| 686 | if (lpfc_debugfs_last_hba_slim_off >= 4096) |
| 687 | lpfc_debugfs_last_hba_slim_off = 0; |
| 688 | |
| 689 | i = 1024; |
| 690 | while (i > 0) { |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 691 | len += scnprintf(buf+len, size-len, |
James Smart | c95d6c6 | 2008-01-11 01:53:23 -0500 | [diff] [blame] | 692 | "%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n", |
| 693 | off, *ptr, *(ptr+1), *(ptr+2), *(ptr+3), *(ptr+4), |
| 694 | *(ptr+5), *(ptr+6), *(ptr+7)); |
| 695 | ptr += 8; |
| 696 | i -= (8 * sizeof(uint32_t)); |
| 697 | off += (8 * sizeof(uint32_t)); |
| 698 | } |
| 699 | |
| 700 | spin_unlock_irq(&phba->hbalock); |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 701 | kfree(buffer); |
| 702 | |
James Smart | c95d6c6 | 2008-01-11 01:53:23 -0500 | [diff] [blame] | 703 | return len; |
| 704 | } |
| 705 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 706 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 707 | * lpfc_debugfs_dumpHostSlim_data - Dump host SLIM info to a buffer |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 708 | * @phba: The HBA to gather Host SLIM info from. |
| 709 | * @buf: The buffer to dump log into. |
| 710 | * @size: The maximum amount of data to process. |
| 711 | * |
| 712 | * Description: |
| 713 | * This routine dumps the current contents of host SLIM for the host associated |
| 714 | * with @phba to @buf up to @size bytes of data. The dump will contain the |
| 715 | * Mailbox, PCB, Rings, and Registers that are located in host memory. |
| 716 | * |
| 717 | * Return Value: |
| 718 | * This routine returns the amount of bytes that were dumped into @buf and will |
| 719 | * not exceed @size. |
| 720 | **/ |
James Smart | c95d6c6 | 2008-01-11 01:53:23 -0500 | [diff] [blame] | 721 | static int |
| 722 | lpfc_debugfs_dumpHostSlim_data(struct lpfc_hba *phba, char *buf, int size) |
| 723 | { |
| 724 | int len = 0; |
| 725 | int i, off; |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 726 | uint32_t word0, word1, word2, word3; |
| 727 | uint32_t *ptr; |
| 728 | struct lpfc_pgp *pgpp; |
| 729 | struct lpfc_sli *psli = &phba->sli; |
| 730 | struct lpfc_sli_ring *pring; |
| 731 | |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 732 | off = 0; |
| 733 | spin_lock_irq(&phba->hbalock); |
| 734 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 735 | len += scnprintf(buf+len, size-len, "SLIM Mailbox\n"); |
James Smart | 34b02dc | 2008-08-24 21:49:55 -0400 | [diff] [blame] | 736 | ptr = (uint32_t *)phba->slim2p.virt; |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 737 | i = sizeof(MAILBOX_t); |
| 738 | while (i > 0) { |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 739 | len += scnprintf(buf+len, size-len, |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 740 | "%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n", |
| 741 | off, *ptr, *(ptr+1), *(ptr+2), *(ptr+3), *(ptr+4), |
| 742 | *(ptr+5), *(ptr+6), *(ptr+7)); |
| 743 | ptr += 8; |
| 744 | i -= (8 * sizeof(uint32_t)); |
| 745 | off += (8 * sizeof(uint32_t)); |
| 746 | } |
| 747 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 748 | len += scnprintf(buf+len, size-len, "SLIM PCB\n"); |
James Smart | 34b02dc | 2008-08-24 21:49:55 -0400 | [diff] [blame] | 749 | ptr = (uint32_t *)phba->pcb; |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 750 | i = sizeof(PCB_t); |
| 751 | while (i > 0) { |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 752 | len += scnprintf(buf+len, size-len, |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 753 | "%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n", |
| 754 | off, *ptr, *(ptr+1), *(ptr+2), *(ptr+3), *(ptr+4), |
| 755 | *(ptr+5), *(ptr+6), *(ptr+7)); |
| 756 | ptr += 8; |
| 757 | i -= (8 * sizeof(uint32_t)); |
| 758 | off += (8 * sizeof(uint32_t)); |
| 759 | } |
| 760 | |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 761 | if (phba->sli_rev <= LPFC_SLI_REV3) { |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 762 | for (i = 0; i < 4; i++) { |
| 763 | pgpp = &phba->port_gp[i]; |
| 764 | pring = &psli->sli3_ring[i]; |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 765 | len += scnprintf(buf+len, size-len, |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 766 | "Ring %d: CMD GetInx:%d " |
| 767 | "(Max:%d Next:%d " |
| 768 | "Local:%d flg:x%x) " |
| 769 | "RSP PutInx:%d Max:%d\n", |
| 770 | i, pgpp->cmdGetInx, |
| 771 | pring->sli.sli3.numCiocb, |
| 772 | pring->sli.sli3.next_cmdidx, |
| 773 | pring->sli.sli3.local_getidx, |
| 774 | pring->flag, pgpp->rspPutInx, |
| 775 | pring->sli.sli3.numRiocb); |
| 776 | } |
| 777 | |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 778 | word0 = readl(phba->HAregaddr); |
| 779 | word1 = readl(phba->CAregaddr); |
| 780 | word2 = readl(phba->HSregaddr); |
| 781 | word3 = readl(phba->HCregaddr); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 782 | len += scnprintf(buf+len, size-len, "HA:%08x CA:%08x HS:%08x " |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 783 | "HC:%08x\n", word0, word1, word2, word3); |
| 784 | } |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 785 | spin_unlock_irq(&phba->hbalock); |
| 786 | return len; |
| 787 | } |
| 788 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 789 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 790 | * lpfc_debugfs_nodelist_data - Dump target node list to a buffer |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 791 | * @vport: The vport to gather target node info from. |
| 792 | * @buf: The buffer to dump log into. |
| 793 | * @size: The maximum amount of data to process. |
| 794 | * |
| 795 | * Description: |
| 796 | * This routine dumps the current target node list associated with @vport to |
| 797 | * @buf up to @size bytes of data. Each node entry in the dump will contain a |
| 798 | * node state, DID, WWPN, WWNN, RPI, flags, type, and other useful fields. |
| 799 | * |
| 800 | * Return Value: |
| 801 | * This routine returns the amount of bytes that were dumped into @buf and will |
| 802 | * not exceed @size. |
| 803 | **/ |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 804 | static int |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 805 | lpfc_debugfs_nodelist_data(struct lpfc_vport *vport, char *buf, int size) |
| 806 | { |
| 807 | int len = 0; |
James Smart | f91bc59 | 2018-04-09 14:24:22 -0700 | [diff] [blame] | 808 | int i, iocnt, outio, cnt; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 809 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
James Smart | 2b65e18 | 2017-02-12 13:52:38 -0800 | [diff] [blame] | 810 | struct lpfc_hba *phba = vport->phba; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 811 | struct lpfc_nodelist *ndlp; |
James Smart | 2ea259e | 2017-02-12 13:52:27 -0800 | [diff] [blame] | 812 | unsigned char *statep; |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 813 | struct nvme_fc_local_port *localport; |
James Smart | 9e21017 | 2018-09-13 15:41:10 -0700 | [diff] [blame] | 814 | struct nvme_fc_remote_port *nrport = NULL; |
James Smart | 0146602 | 2018-04-09 14:24:27 -0700 | [diff] [blame] | 815 | struct lpfc_nvme_rport *rport; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 816 | |
| 817 | cnt = (LPFC_NODELIST_SIZE / LPFC_NODELIST_ENTRY_SIZE); |
James Smart | f91bc59 | 2018-04-09 14:24:22 -0700 | [diff] [blame] | 818 | outio = 0; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 819 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 820 | len += scnprintf(buf+len, size-len, "\nFCP Nodelist Entries ...\n"); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 821 | spin_lock_irq(shost->host_lock); |
| 822 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { |
James Smart | f91bc59 | 2018-04-09 14:24:22 -0700 | [diff] [blame] | 823 | iocnt = 0; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 824 | if (!cnt) { |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 825 | len += scnprintf(buf+len, size-len, |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 826 | "Missing Nodelist Entries\n"); |
| 827 | break; |
| 828 | } |
| 829 | cnt--; |
| 830 | switch (ndlp->nlp_state) { |
| 831 | case NLP_STE_UNUSED_NODE: |
| 832 | statep = "UNUSED"; |
| 833 | break; |
| 834 | case NLP_STE_PLOGI_ISSUE: |
| 835 | statep = "PLOGI "; |
| 836 | break; |
| 837 | case NLP_STE_ADISC_ISSUE: |
| 838 | statep = "ADISC "; |
| 839 | break; |
| 840 | case NLP_STE_REG_LOGIN_ISSUE: |
| 841 | statep = "REGLOG"; |
| 842 | break; |
| 843 | case NLP_STE_PRLI_ISSUE: |
| 844 | statep = "PRLI "; |
| 845 | break; |
James Smart | 086a345 | 2012-08-14 14:25:21 -0400 | [diff] [blame] | 846 | case NLP_STE_LOGO_ISSUE: |
| 847 | statep = "LOGO "; |
| 848 | break; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 849 | case NLP_STE_UNMAPPED_NODE: |
| 850 | statep = "UNMAP "; |
James Smart | f91bc59 | 2018-04-09 14:24:22 -0700 | [diff] [blame] | 851 | iocnt = 1; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 852 | break; |
| 853 | case NLP_STE_MAPPED_NODE: |
| 854 | statep = "MAPPED"; |
James Smart | f91bc59 | 2018-04-09 14:24:22 -0700 | [diff] [blame] | 855 | iocnt = 1; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 856 | break; |
| 857 | case NLP_STE_NPR_NODE: |
| 858 | statep = "NPR "; |
| 859 | break; |
| 860 | default: |
| 861 | statep = "UNKNOWN"; |
| 862 | } |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 863 | len += scnprintf(buf+len, size-len, "%s DID:x%06x ", |
James Smart | 2ea259e | 2017-02-12 13:52:27 -0800 | [diff] [blame] | 864 | statep, ndlp->nlp_DID); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 865 | len += scnprintf(buf+len, size-len, |
James Smart | 2ea259e | 2017-02-12 13:52:27 -0800 | [diff] [blame] | 866 | "WWPN x%llx ", |
| 867 | wwn_to_u64(ndlp->nlp_portname.u.wwn)); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 868 | len += scnprintf(buf+len, size-len, |
James Smart | 2ea259e | 2017-02-12 13:52:27 -0800 | [diff] [blame] | 869 | "WWNN x%llx ", |
| 870 | wwn_to_u64(ndlp->nlp_nodename.u.wwn)); |
James Smart | 086a345 | 2012-08-14 14:25:21 -0400 | [diff] [blame] | 871 | if (ndlp->nlp_flag & NLP_RPI_REGISTERED) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 872 | len += scnprintf(buf+len, size-len, "RPI:%03d ", |
James Smart | 2ea259e | 2017-02-12 13:52:27 -0800 | [diff] [blame] | 873 | ndlp->nlp_rpi); |
James Smart | 086a345 | 2012-08-14 14:25:21 -0400 | [diff] [blame] | 874 | else |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 875 | len += scnprintf(buf+len, size-len, "RPI:none "); |
| 876 | len += scnprintf(buf+len, size-len, "flag:x%08x ", |
James Smart | 086a345 | 2012-08-14 14:25:21 -0400 | [diff] [blame] | 877 | ndlp->nlp_flag); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 878 | if (!ndlp->nlp_type) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 879 | len += scnprintf(buf+len, size-len, "UNKNOWN_TYPE "); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 880 | if (ndlp->nlp_type & NLP_FC_NODE) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 881 | len += scnprintf(buf+len, size-len, "FC_NODE "); |
James Smart | f91bc59 | 2018-04-09 14:24:22 -0700 | [diff] [blame] | 882 | if (ndlp->nlp_type & NLP_FABRIC) { |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 883 | len += scnprintf(buf+len, size-len, "FABRIC "); |
James Smart | f91bc59 | 2018-04-09 14:24:22 -0700 | [diff] [blame] | 884 | iocnt = 0; |
| 885 | } |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 886 | if (ndlp->nlp_type & NLP_FCP_TARGET) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 887 | len += scnprintf(buf+len, size-len, "FCP_TGT sid:%d ", |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 888 | ndlp->nlp_sid); |
| 889 | if (ndlp->nlp_type & NLP_FCP_INITIATOR) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 890 | len += scnprintf(buf+len, size-len, "FCP_INITIATOR "); |
James Smart | 7d790f0 | 2017-06-01 21:06:57 -0700 | [diff] [blame] | 891 | if (ndlp->nlp_type & NLP_NVME_TARGET) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 892 | len += scnprintf(buf + len, |
James Smart | 7d790f0 | 2017-06-01 21:06:57 -0700 | [diff] [blame] | 893 | size - len, "NVME_TGT sid:%d ", |
| 894 | NLP_NO_SID); |
| 895 | if (ndlp->nlp_type & NLP_NVME_INITIATOR) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 896 | len += scnprintf(buf + len, |
James Smart | 7d790f0 | 2017-06-01 21:06:57 -0700 | [diff] [blame] | 897 | size - len, "NVME_INITIATOR "); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 898 | len += scnprintf(buf+len, size-len, "usgmap:%x ", |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 899 | ndlp->nlp_usg_map); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 900 | len += scnprintf(buf+len, size-len, "refcnt:%x", |
Peter Zijlstra | 2c935bc | 2016-11-14 17:29:48 +0100 | [diff] [blame] | 901 | kref_read(&ndlp->kref)); |
James Smart | f91bc59 | 2018-04-09 14:24:22 -0700 | [diff] [blame] | 902 | if (iocnt) { |
| 903 | i = atomic_read(&ndlp->cmd_pending); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 904 | len += scnprintf(buf + len, size - len, |
James Smart | f91bc59 | 2018-04-09 14:24:22 -0700 | [diff] [blame] | 905 | " OutIO:x%x Qdepth x%x", |
| 906 | i, ndlp->cmd_qdepth); |
| 907 | outio += i; |
| 908 | } |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 909 | len += scnprintf(buf + len, size - len, "defer:%x ", |
James Smart | dea16bd | 2018-11-29 16:09:30 -0800 | [diff] [blame] | 910 | ndlp->nlp_defer_did); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 911 | len += scnprintf(buf+len, size-len, "\n"); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 912 | } |
| 913 | spin_unlock_irq(shost->host_lock); |
James Smart | 2ea259e | 2017-02-12 13:52:27 -0800 | [diff] [blame] | 914 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 915 | len += scnprintf(buf + len, size - len, |
James Smart | f91bc59 | 2018-04-09 14:24:22 -0700 | [diff] [blame] | 916 | "\nOutstanding IO x%x\n", outio); |
| 917 | |
James Smart | 2b65e18 | 2017-02-12 13:52:38 -0800 | [diff] [blame] | 918 | if (phba->nvmet_support && phba->targetport && (vport == phba->pport)) { |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 919 | len += scnprintf(buf + len, size - len, |
James Smart | 2b65e18 | 2017-02-12 13:52:38 -0800 | [diff] [blame] | 920 | "\nNVME Targetport Entry ...\n"); |
| 921 | |
| 922 | /* Port state is only one of two values for now. */ |
| 923 | if (phba->targetport->port_id) |
| 924 | statep = "REGISTERED"; |
| 925 | else |
| 926 | statep = "INIT"; |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 927 | len += scnprintf(buf + len, size - len, |
James Smart | 2b65e18 | 2017-02-12 13:52:38 -0800 | [diff] [blame] | 928 | "TGT WWNN x%llx WWPN x%llx State %s\n", |
| 929 | wwn_to_u64(vport->fc_nodename.u.wwn), |
| 930 | wwn_to_u64(vport->fc_portname.u.wwn), |
| 931 | statep); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 932 | len += scnprintf(buf + len, size - len, |
James Smart | 2b65e18 | 2017-02-12 13:52:38 -0800 | [diff] [blame] | 933 | " Targetport DID x%06x\n", |
| 934 | phba->targetport->port_id); |
| 935 | goto out_exit; |
| 936 | } |
| 937 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 938 | len += scnprintf(buf + len, size - len, |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 939 | "\nNVME Lport/Rport Entries ...\n"); |
| 940 | |
| 941 | localport = vport->localport; |
| 942 | if (!localport) |
| 943 | goto out_exit; |
| 944 | |
| 945 | spin_lock_irq(shost->host_lock); |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 946 | |
| 947 | /* Port state is only one of two values for now. */ |
| 948 | if (localport->port_id) |
| 949 | statep = "ONLINE"; |
| 950 | else |
| 951 | statep = "UNKNOWN "; |
| 952 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 953 | len += scnprintf(buf + len, size - len, |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 954 | "Lport DID x%06x PortState %s\n", |
| 955 | localport->port_id, statep); |
| 956 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 957 | len += scnprintf(buf + len, size - len, "\tRport List:\n"); |
James Smart | 80cc004 | 2017-06-01 21:06:56 -0700 | [diff] [blame] | 958 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 959 | /* local short-hand pointer. */ |
James Smart | 9e21017 | 2018-09-13 15:41:10 -0700 | [diff] [blame] | 960 | spin_lock(&phba->hbalock); |
James Smart | 0146602 | 2018-04-09 14:24:27 -0700 | [diff] [blame] | 961 | rport = lpfc_ndlp_get_nrport(ndlp); |
James Smart | 9e21017 | 2018-09-13 15:41:10 -0700 | [diff] [blame] | 962 | if (rport) |
| 963 | nrport = rport->remoteport; |
Arnd Bergmann | f8d2943 | 2018-11-02 16:35:48 +0100 | [diff] [blame] | 964 | else |
| 965 | nrport = NULL; |
James Smart | 9e21017 | 2018-09-13 15:41:10 -0700 | [diff] [blame] | 966 | spin_unlock(&phba->hbalock); |
James Smart | 0146602 | 2018-04-09 14:24:27 -0700 | [diff] [blame] | 967 | if (!nrport) |
| 968 | continue; |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 969 | |
| 970 | /* Port state is only one of two values for now. */ |
| 971 | switch (nrport->port_state) { |
| 972 | case FC_OBJSTATE_ONLINE: |
| 973 | statep = "ONLINE"; |
| 974 | break; |
| 975 | case FC_OBJSTATE_UNKNOWN: |
| 976 | statep = "UNKNOWN "; |
| 977 | break; |
| 978 | default: |
| 979 | statep = "UNSUPPORTED"; |
| 980 | break; |
| 981 | } |
| 982 | |
| 983 | /* Tab in to show lport ownership. */ |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 984 | len += scnprintf(buf + len, size - len, |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 985 | "\t%s Port ID:x%06x ", |
| 986 | statep, nrport->port_id); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 987 | len += scnprintf(buf + len, size - len, "WWPN x%llx ", |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 988 | nrport->port_name); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 989 | len += scnprintf(buf + len, size - len, "WWNN x%llx ", |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 990 | nrport->node_name); |
James Smart | 7d790f0 | 2017-06-01 21:06:57 -0700 | [diff] [blame] | 991 | |
| 992 | /* An NVME rport can have multiple roles. */ |
| 993 | if (nrport->port_role & FC_PORT_ROLE_NVME_INITIATOR) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 994 | len += scnprintf(buf + len, size - len, |
James Smart | 7d790f0 | 2017-06-01 21:06:57 -0700 | [diff] [blame] | 995 | "INITIATOR "); |
| 996 | if (nrport->port_role & FC_PORT_ROLE_NVME_TARGET) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 997 | len += scnprintf(buf + len, size - len, |
James Smart | 7d790f0 | 2017-06-01 21:06:57 -0700 | [diff] [blame] | 998 | "TARGET "); |
| 999 | if (nrport->port_role & FC_PORT_ROLE_NVME_DISCOVERY) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1000 | len += scnprintf(buf + len, size - len, |
James Smart | 7d790f0 | 2017-06-01 21:06:57 -0700 | [diff] [blame] | 1001 | "DISCSRVC "); |
| 1002 | if (nrport->port_role & ~(FC_PORT_ROLE_NVME_INITIATOR | |
| 1003 | FC_PORT_ROLE_NVME_TARGET | |
| 1004 | FC_PORT_ROLE_NVME_DISCOVERY)) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1005 | len += scnprintf(buf + len, size - len, |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 1006 | "UNKNOWN ROLE x%x", |
| 1007 | nrport->port_role); |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 1008 | /* Terminate the string. */ |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1009 | len += scnprintf(buf + len, size - len, "\n"); |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 1010 | } |
| 1011 | |
| 1012 | spin_unlock_irq(shost->host_lock); |
| 1013 | out_exit: |
| 1014 | return len; |
| 1015 | } |
| 1016 | |
| 1017 | /** |
| 1018 | * lpfc_debugfs_nvmestat_data - Dump target node list to a buffer |
| 1019 | * @vport: The vport to gather target node info from. |
| 1020 | * @buf: The buffer to dump log into. |
| 1021 | * @size: The maximum amount of data to process. |
| 1022 | * |
| 1023 | * Description: |
| 1024 | * This routine dumps the NVME statistics associated with @vport |
| 1025 | * |
| 1026 | * Return Value: |
| 1027 | * This routine returns the amount of bytes that were dumped into @buf and will |
| 1028 | * not exceed @size. |
| 1029 | **/ |
| 1030 | static int |
| 1031 | lpfc_debugfs_nvmestat_data(struct lpfc_vport *vport, char *buf, int size) |
| 1032 | { |
| 1033 | struct lpfc_hba *phba = vport->phba; |
James Smart | 2b65e18 | 2017-02-12 13:52:38 -0800 | [diff] [blame] | 1034 | struct lpfc_nvmet_tgtport *tgtp; |
James Smart | 7cacae2 | 2020-03-31 09:50:03 -0700 | [diff] [blame] | 1035 | struct lpfc_async_xchg_ctx *ctxp, *next_ctxp; |
James Smart | 4b05668 | 2017-12-08 17:18:10 -0800 | [diff] [blame] | 1036 | struct nvme_fc_local_port *localport; |
James Smart | 4c47efc | 2019-01-28 11:14:25 -0800 | [diff] [blame] | 1037 | struct lpfc_fc4_ctrl_stat *cstat; |
James Smart | 4b05668 | 2017-12-08 17:18:10 -0800 | [diff] [blame] | 1038 | struct lpfc_nvme_lport *lport; |
James Smart | 66a210f | 2018-04-09 14:24:23 -0700 | [diff] [blame] | 1039 | uint64_t data1, data2, data3; |
| 1040 | uint64_t tot, totin, totout; |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 1041 | int cnt, i; |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 1042 | int len = 0; |
| 1043 | |
James Smart | 2b65e18 | 2017-02-12 13:52:38 -0800 | [diff] [blame] | 1044 | if (phba->nvmet_support) { |
| 1045 | if (!phba->targetport) |
| 1046 | return len; |
| 1047 | tgtp = (struct lpfc_nvmet_tgtport *)phba->targetport->private; |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1048 | len += scnprintf(buf + len, size - len, |
James Smart | 2b65e18 | 2017-02-12 13:52:38 -0800 | [diff] [blame] | 1049 | "\nNVME Targetport Statistics\n"); |
| 1050 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1051 | len += scnprintf(buf + len, size - len, |
James Smart | 2b65e18 | 2017-02-12 13:52:38 -0800 | [diff] [blame] | 1052 | "LS: Rcv %08x Drop %08x Abort %08x\n", |
| 1053 | atomic_read(&tgtp->rcv_ls_req_in), |
| 1054 | atomic_read(&tgtp->rcv_ls_req_drop), |
| 1055 | atomic_read(&tgtp->xmt_ls_abort)); |
| 1056 | if (atomic_read(&tgtp->rcv_ls_req_in) != |
| 1057 | atomic_read(&tgtp->rcv_ls_req_out)) { |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1058 | len += scnprintf(buf + len, size - len, |
James Smart | 2b65e18 | 2017-02-12 13:52:38 -0800 | [diff] [blame] | 1059 | "Rcv LS: in %08x != out %08x\n", |
| 1060 | atomic_read(&tgtp->rcv_ls_req_in), |
| 1061 | atomic_read(&tgtp->rcv_ls_req_out)); |
| 1062 | } |
| 1063 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1064 | len += scnprintf(buf + len, size - len, |
James Smart | 4b05668 | 2017-12-08 17:18:10 -0800 | [diff] [blame] | 1065 | "LS: Xmt %08x Drop %08x Cmpl %08x\n", |
James Smart | 2b65e18 | 2017-02-12 13:52:38 -0800 | [diff] [blame] | 1066 | atomic_read(&tgtp->xmt_ls_rsp), |
| 1067 | atomic_read(&tgtp->xmt_ls_drop), |
James Smart | 4b05668 | 2017-12-08 17:18:10 -0800 | [diff] [blame] | 1068 | atomic_read(&tgtp->xmt_ls_rsp_cmpl)); |
| 1069 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1070 | len += scnprintf(buf + len, size - len, |
James Smart | 4b05668 | 2017-12-08 17:18:10 -0800 | [diff] [blame] | 1071 | "LS: RSP Abort %08x xb %08x Err %08x\n", |
| 1072 | atomic_read(&tgtp->xmt_ls_rsp_aborted), |
| 1073 | atomic_read(&tgtp->xmt_ls_rsp_xb_set), |
James Smart | 2b65e18 | 2017-02-12 13:52:38 -0800 | [diff] [blame] | 1074 | atomic_read(&tgtp->xmt_ls_rsp_error)); |
| 1075 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1076 | len += scnprintf(buf + len, size - len, |
James Smart | 5073842 | 2017-08-01 15:12:40 -0700 | [diff] [blame] | 1077 | "FCP: Rcv %08x Defer %08x Release %08x " |
| 1078 | "Drop %08x\n", |
James Smart | 2b65e18 | 2017-02-12 13:52:38 -0800 | [diff] [blame] | 1079 | atomic_read(&tgtp->rcv_fcp_cmd_in), |
James Smart | 5073842 | 2017-08-01 15:12:40 -0700 | [diff] [blame] | 1080 | atomic_read(&tgtp->rcv_fcp_cmd_defer), |
| 1081 | atomic_read(&tgtp->xmt_fcp_release), |
James Smart | 2b65e18 | 2017-02-12 13:52:38 -0800 | [diff] [blame] | 1082 | atomic_read(&tgtp->rcv_fcp_cmd_drop)); |
| 1083 | |
| 1084 | if (atomic_read(&tgtp->rcv_fcp_cmd_in) != |
| 1085 | atomic_read(&tgtp->rcv_fcp_cmd_out)) { |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1086 | len += scnprintf(buf + len, size - len, |
James Smart | 2b65e18 | 2017-02-12 13:52:38 -0800 | [diff] [blame] | 1087 | "Rcv FCP: in %08x != out %08x\n", |
| 1088 | atomic_read(&tgtp->rcv_fcp_cmd_in), |
| 1089 | atomic_read(&tgtp->rcv_fcp_cmd_out)); |
| 1090 | } |
| 1091 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1092 | len += scnprintf(buf + len, size - len, |
James Smart | 86c6737 | 2017-04-21 16:05:04 -0700 | [diff] [blame] | 1093 | "FCP Rsp: read %08x readrsp %08x " |
| 1094 | "write %08x rsp %08x\n", |
James Smart | 2b65e18 | 2017-02-12 13:52:38 -0800 | [diff] [blame] | 1095 | atomic_read(&tgtp->xmt_fcp_read), |
| 1096 | atomic_read(&tgtp->xmt_fcp_read_rsp), |
| 1097 | atomic_read(&tgtp->xmt_fcp_write), |
| 1098 | atomic_read(&tgtp->xmt_fcp_rsp)); |
| 1099 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1100 | len += scnprintf(buf + len, size - len, |
James Smart | 2b65e18 | 2017-02-12 13:52:38 -0800 | [diff] [blame] | 1101 | "FCP Rsp Cmpl: %08x err %08x drop %08x\n", |
| 1102 | atomic_read(&tgtp->xmt_fcp_rsp_cmpl), |
| 1103 | atomic_read(&tgtp->xmt_fcp_rsp_error), |
| 1104 | atomic_read(&tgtp->xmt_fcp_rsp_drop)); |
| 1105 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1106 | len += scnprintf(buf + len, size - len, |
James Smart | 4b05668 | 2017-12-08 17:18:10 -0800 | [diff] [blame] | 1107 | "FCP Rsp Abort: %08x xb %08x xricqe %08x\n", |
| 1108 | atomic_read(&tgtp->xmt_fcp_rsp_aborted), |
| 1109 | atomic_read(&tgtp->xmt_fcp_rsp_xb_set), |
| 1110 | atomic_read(&tgtp->xmt_fcp_xri_abort_cqe)); |
| 1111 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1112 | len += scnprintf(buf + len, size - len, |
James Smart | 547077a | 2017-05-15 15:20:40 -0700 | [diff] [blame] | 1113 | "ABORT: Xmt %08x Cmpl %08x\n", |
| 1114 | atomic_read(&tgtp->xmt_fcp_abort), |
| 1115 | atomic_read(&tgtp->xmt_fcp_abort_cmpl)); |
| 1116 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1117 | len += scnprintf(buf + len, size - len, |
James Smart | 547077a | 2017-05-15 15:20:40 -0700 | [diff] [blame] | 1118 | "ABORT: Sol %08x Usol %08x Err %08x Cmpl %08x", |
| 1119 | atomic_read(&tgtp->xmt_abort_sol), |
| 1120 | atomic_read(&tgtp->xmt_abort_unsol), |
James Smart | 2b65e18 | 2017-02-12 13:52:38 -0800 | [diff] [blame] | 1121 | atomic_read(&tgtp->xmt_abort_rsp), |
James Smart | 547077a | 2017-05-15 15:20:40 -0700 | [diff] [blame] | 1122 | atomic_read(&tgtp->xmt_abort_rsp_error)); |
James Smart | 2b65e18 | 2017-02-12 13:52:38 -0800 | [diff] [blame] | 1123 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1124 | len += scnprintf(buf + len, size - len, "\n"); |
James Smart | 86c6737 | 2017-04-21 16:05:04 -0700 | [diff] [blame] | 1125 | |
| 1126 | cnt = 0; |
James Smart | 5e5b511 | 2019-01-28 11:14:22 -0800 | [diff] [blame] | 1127 | spin_lock(&phba->sli4_hba.abts_nvmet_buf_list_lock); |
James Smart | 86c6737 | 2017-04-21 16:05:04 -0700 | [diff] [blame] | 1128 | list_for_each_entry_safe(ctxp, next_ctxp, |
| 1129 | &phba->sli4_hba.lpfc_abts_nvmet_ctx_list, |
| 1130 | list) { |
| 1131 | cnt++; |
| 1132 | } |
James Smart | 5e5b511 | 2019-01-28 11:14:22 -0800 | [diff] [blame] | 1133 | spin_unlock(&phba->sli4_hba.abts_nvmet_buf_list_lock); |
James Smart | 86c6737 | 2017-04-21 16:05:04 -0700 | [diff] [blame] | 1134 | if (cnt) { |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1135 | len += scnprintf(buf + len, size - len, |
James Smart | 86c6737 | 2017-04-21 16:05:04 -0700 | [diff] [blame] | 1136 | "ABORT: %d ctx entries\n", cnt); |
James Smart | 5e5b511 | 2019-01-28 11:14:22 -0800 | [diff] [blame] | 1137 | spin_lock(&phba->sli4_hba.abts_nvmet_buf_list_lock); |
James Smart | 86c6737 | 2017-04-21 16:05:04 -0700 | [diff] [blame] | 1138 | list_for_each_entry_safe(ctxp, next_ctxp, |
| 1139 | &phba->sli4_hba.lpfc_abts_nvmet_ctx_list, |
| 1140 | list) { |
| 1141 | if (len >= (size - LPFC_DEBUG_OUT_LINE_SZ)) |
| 1142 | break; |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1143 | len += scnprintf(buf + len, size - len, |
James Smart | 86c6737 | 2017-04-21 16:05:04 -0700 | [diff] [blame] | 1144 | "Entry: oxid %x state %x " |
| 1145 | "flag %x\n", |
| 1146 | ctxp->oxid, ctxp->state, |
| 1147 | ctxp->flag); |
| 1148 | } |
James Smart | 5e5b511 | 2019-01-28 11:14:22 -0800 | [diff] [blame] | 1149 | spin_unlock(&phba->sli4_hba.abts_nvmet_buf_list_lock); |
James Smart | 86c6737 | 2017-04-21 16:05:04 -0700 | [diff] [blame] | 1150 | } |
James Smart | a8cf5df | 2017-05-15 15:20:46 -0700 | [diff] [blame] | 1151 | |
Dick Kennedy | 66d7ce9 | 2017-08-23 16:55:42 -0700 | [diff] [blame] | 1152 | /* Calculate outstanding IOs */ |
| 1153 | tot = atomic_read(&tgtp->rcv_fcp_cmd_drop); |
| 1154 | tot += atomic_read(&tgtp->xmt_fcp_release); |
| 1155 | tot = atomic_read(&tgtp->rcv_fcp_cmd_in) - tot; |
James Smart | 2cee780 | 2017-06-01 21:07:02 -0700 | [diff] [blame] | 1156 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1157 | len += scnprintf(buf + len, size - len, |
James Smart | 2cee780 | 2017-06-01 21:07:02 -0700 | [diff] [blame] | 1158 | "IO_CTX: %08x WAIT: cur %08x tot %08x\n" |
| 1159 | "CTX Outstanding %08llx\n", |
James Smart | 966bb5b | 2017-06-15 22:56:45 -0700 | [diff] [blame] | 1160 | phba->sli4_hba.nvmet_xri_cnt, |
James Smart | a8cf5df | 2017-05-15 15:20:46 -0700 | [diff] [blame] | 1161 | phba->sli4_hba.nvmet_io_wait_cnt, |
James Smart | 2cee780 | 2017-06-01 21:07:02 -0700 | [diff] [blame] | 1162 | phba->sli4_hba.nvmet_io_wait_total, |
| 1163 | tot); |
James Smart | 2b65e18 | 2017-02-12 13:52:38 -0800 | [diff] [blame] | 1164 | } else { |
James Smart | f6e8479 | 2019-01-28 11:14:38 -0800 | [diff] [blame] | 1165 | if (!(vport->cfg_enable_fc4_type & LPFC_ENABLE_NVME)) |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 1166 | return len; |
| 1167 | |
James Smart | 4b05668 | 2017-12-08 17:18:10 -0800 | [diff] [blame] | 1168 | localport = vport->localport; |
| 1169 | if (!localport) |
| 1170 | return len; |
| 1171 | lport = (struct lpfc_nvme_lport *)localport->private; |
| 1172 | if (!lport) |
| 1173 | return len; |
| 1174 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1175 | len += scnprintf(buf + len, size - len, |
James Smart | 4c47efc | 2019-01-28 11:14:25 -0800 | [diff] [blame] | 1176 | "\nNVME HDWQ Statistics\n"); |
James Smart | 66a210f | 2018-04-09 14:24:23 -0700 | [diff] [blame] | 1177 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1178 | len += scnprintf(buf + len, size - len, |
James Smart | 66a210f | 2018-04-09 14:24:23 -0700 | [diff] [blame] | 1179 | "LS: Xmt %016x Cmpl %016x\n", |
| 1180 | atomic_read(&lport->fc4NvmeLsRequests), |
| 1181 | atomic_read(&lport->fc4NvmeLsCmpls)); |
| 1182 | |
James Smart | 66a210f | 2018-04-09 14:24:23 -0700 | [diff] [blame] | 1183 | totin = 0; |
| 1184 | totout = 0; |
James Smart | cdb42be | 2019-01-28 11:14:21 -0800 | [diff] [blame] | 1185 | for (i = 0; i < phba->cfg_hdw_queue; i++) { |
James Smart | 4c47efc | 2019-01-28 11:14:25 -0800 | [diff] [blame] | 1186 | cstat = &phba->sli4_hba.hdwq[i].nvme_cstat; |
| 1187 | tot = cstat->io_cmpls; |
James Smart | 66a210f | 2018-04-09 14:24:23 -0700 | [diff] [blame] | 1188 | totin += tot; |
James Smart | 4c47efc | 2019-01-28 11:14:25 -0800 | [diff] [blame] | 1189 | data1 = cstat->input_requests; |
| 1190 | data2 = cstat->output_requests; |
| 1191 | data3 = cstat->control_requests; |
James Smart | 66a210f | 2018-04-09 14:24:23 -0700 | [diff] [blame] | 1192 | totout += (data1 + data2 + data3); |
| 1193 | |
| 1194 | /* Limit to 32, debugfs display buffer limitation */ |
| 1195 | if (i >= 32) |
| 1196 | continue; |
| 1197 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1198 | len += scnprintf(buf + len, PAGE_SIZE - len, |
James Smart | 4c47efc | 2019-01-28 11:14:25 -0800 | [diff] [blame] | 1199 | "HDWQ (%d): Rd %016llx Wr %016llx " |
James Smart | 66a210f | 2018-04-09 14:24:23 -0700 | [diff] [blame] | 1200 | "IO %016llx ", |
| 1201 | i, data1, data2, data3); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1202 | len += scnprintf(buf + len, PAGE_SIZE - len, |
James Smart | 66a210f | 2018-04-09 14:24:23 -0700 | [diff] [blame] | 1203 | "Cmpl %016llx OutIO %016llx\n", |
| 1204 | tot, ((data1 + data2 + data3) - tot)); |
| 1205 | } |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1206 | len += scnprintf(buf + len, PAGE_SIZE - len, |
James Smart | 66a210f | 2018-04-09 14:24:23 -0700 | [diff] [blame] | 1207 | "Total FCP Cmpl %016llx Issue %016llx " |
| 1208 | "OutIO %016llx\n", |
| 1209 | totin, totout, totout - totin); |
| 1210 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1211 | len += scnprintf(buf + len, size - len, |
James Smart | 4b05668 | 2017-12-08 17:18:10 -0800 | [diff] [blame] | 1212 | "LS Xmt Err: Abrt %08x Err %08x " |
| 1213 | "Cmpl Err: xb %08x Err %08x\n", |
| 1214 | atomic_read(&lport->xmt_ls_abort), |
| 1215 | atomic_read(&lport->xmt_ls_err), |
| 1216 | atomic_read(&lport->cmpl_ls_xb), |
| 1217 | atomic_read(&lport->cmpl_ls_err)); |
| 1218 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1219 | len += scnprintf(buf + len, size - len, |
James Smart | 4b05668 | 2017-12-08 17:18:10 -0800 | [diff] [blame] | 1220 | "FCP Xmt Err: noxri %06x nondlp %06x " |
James Smart | 44c2757 | 2018-05-04 20:37:56 -0700 | [diff] [blame] | 1221 | "qdepth %06x wqerr %06x err %06x Abrt %06x\n", |
James Smart | 4b05668 | 2017-12-08 17:18:10 -0800 | [diff] [blame] | 1222 | atomic_read(&lport->xmt_fcp_noxri), |
| 1223 | atomic_read(&lport->xmt_fcp_bad_ndlp), |
| 1224 | atomic_read(&lport->xmt_fcp_qdepth), |
| 1225 | atomic_read(&lport->xmt_fcp_wqerr), |
James Smart | 44c2757 | 2018-05-04 20:37:56 -0700 | [diff] [blame] | 1226 | atomic_read(&lport->xmt_fcp_err), |
James Smart | 4b05668 | 2017-12-08 17:18:10 -0800 | [diff] [blame] | 1227 | atomic_read(&lport->xmt_fcp_abort)); |
| 1228 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1229 | len += scnprintf(buf + len, size - len, |
James Smart | 4b05668 | 2017-12-08 17:18:10 -0800 | [diff] [blame] | 1230 | "FCP Cmpl Err: xb %08x Err %08x\n", |
| 1231 | atomic_read(&lport->cmpl_fcp_xb), |
| 1232 | atomic_read(&lport->cmpl_fcp_err)); |
| 1233 | |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 1234 | } |
| 1235 | |
| 1236 | return len; |
| 1237 | } |
| 1238 | |
James Smart | 4c47efc | 2019-01-28 11:14:25 -0800 | [diff] [blame] | 1239 | /** |
| 1240 | * lpfc_debugfs_scsistat_data - Dump target node list to a buffer |
| 1241 | * @vport: The vport to gather target node info from. |
| 1242 | * @buf: The buffer to dump log into. |
| 1243 | * @size: The maximum amount of data to process. |
| 1244 | * |
| 1245 | * Description: |
| 1246 | * This routine dumps the SCSI statistics associated with @vport |
| 1247 | * |
| 1248 | * Return Value: |
| 1249 | * This routine returns the amount of bytes that were dumped into @buf and will |
| 1250 | * not exceed @size. |
| 1251 | **/ |
| 1252 | static int |
| 1253 | lpfc_debugfs_scsistat_data(struct lpfc_vport *vport, char *buf, int size) |
| 1254 | { |
| 1255 | int len; |
| 1256 | struct lpfc_hba *phba = vport->phba; |
| 1257 | struct lpfc_fc4_ctrl_stat *cstat; |
| 1258 | u64 data1, data2, data3; |
| 1259 | u64 tot, totin, totout; |
| 1260 | int i; |
| 1261 | char tmp[LPFC_MAX_SCSI_INFO_TMP_LEN] = {0}; |
| 1262 | |
James Smart | f6e8479 | 2019-01-28 11:14:38 -0800 | [diff] [blame] | 1263 | if (!(vport->cfg_enable_fc4_type & LPFC_ENABLE_FCP) || |
James Smart | 4c47efc | 2019-01-28 11:14:25 -0800 | [diff] [blame] | 1264 | (phba->sli_rev != LPFC_SLI_REV4)) |
| 1265 | return 0; |
| 1266 | |
| 1267 | scnprintf(buf, size, "SCSI HDWQ Statistics\n"); |
| 1268 | |
| 1269 | totin = 0; |
| 1270 | totout = 0; |
| 1271 | for (i = 0; i < phba->cfg_hdw_queue; i++) { |
| 1272 | cstat = &phba->sli4_hba.hdwq[i].scsi_cstat; |
| 1273 | tot = cstat->io_cmpls; |
| 1274 | totin += tot; |
| 1275 | data1 = cstat->input_requests; |
| 1276 | data2 = cstat->output_requests; |
| 1277 | data3 = cstat->control_requests; |
| 1278 | totout += (data1 + data2 + data3); |
| 1279 | |
| 1280 | scnprintf(tmp, sizeof(tmp), "HDWQ (%d): Rd %016llx Wr %016llx " |
| 1281 | "IO %016llx ", i, data1, data2, data3); |
| 1282 | if (strlcat(buf, tmp, size) >= size) |
| 1283 | goto buffer_done; |
| 1284 | |
| 1285 | scnprintf(tmp, sizeof(tmp), "Cmpl %016llx OutIO %016llx\n", |
| 1286 | tot, ((data1 + data2 + data3) - tot)); |
| 1287 | if (strlcat(buf, tmp, size) >= size) |
| 1288 | goto buffer_done; |
| 1289 | } |
| 1290 | scnprintf(tmp, sizeof(tmp), "Total FCP Cmpl %016llx Issue %016llx " |
| 1291 | "OutIO %016llx\n", totin, totout, totout - totin); |
| 1292 | strlcat(buf, tmp, size); |
| 1293 | |
| 1294 | buffer_done: |
| 1295 | len = strnlen(buf, size); |
| 1296 | |
| 1297 | return len; |
| 1298 | } |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 1299 | |
James Smart | 2fcbc56 | 2020-03-22 11:13:02 -0700 | [diff] [blame] | 1300 | void |
| 1301 | lpfc_io_ktime(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd) |
| 1302 | { |
| 1303 | uint64_t seg1, seg2, seg3, seg4; |
| 1304 | uint64_t segsum; |
| 1305 | |
| 1306 | if (!lpfc_cmd->ts_last_cmd || |
| 1307 | !lpfc_cmd->ts_cmd_start || |
| 1308 | !lpfc_cmd->ts_cmd_wqput || |
| 1309 | !lpfc_cmd->ts_isr_cmpl || |
| 1310 | !lpfc_cmd->ts_data_io) |
| 1311 | return; |
| 1312 | |
| 1313 | if (lpfc_cmd->ts_data_io < lpfc_cmd->ts_cmd_start) |
| 1314 | return; |
| 1315 | if (lpfc_cmd->ts_cmd_start < lpfc_cmd->ts_last_cmd) |
| 1316 | return; |
| 1317 | if (lpfc_cmd->ts_cmd_wqput < lpfc_cmd->ts_cmd_start) |
| 1318 | return; |
| 1319 | if (lpfc_cmd->ts_isr_cmpl < lpfc_cmd->ts_cmd_wqput) |
| 1320 | return; |
| 1321 | if (lpfc_cmd->ts_data_io < lpfc_cmd->ts_isr_cmpl) |
| 1322 | return; |
| 1323 | /* |
| 1324 | * Segment 1 - Time from Last FCP command cmpl is handed |
| 1325 | * off to NVME Layer to start of next command. |
| 1326 | * Segment 2 - Time from Driver receives a IO cmd start |
| 1327 | * from NVME Layer to WQ put is done on IO cmd. |
| 1328 | * Segment 3 - Time from Driver WQ put is done on IO cmd |
| 1329 | * to MSI-X ISR for IO cmpl. |
| 1330 | * Segment 4 - Time from MSI-X ISR for IO cmpl to when |
| 1331 | * cmpl is handled off to the NVME Layer. |
| 1332 | */ |
| 1333 | seg1 = lpfc_cmd->ts_cmd_start - lpfc_cmd->ts_last_cmd; |
| 1334 | if (seg1 > 5000000) /* 5 ms - for sequential IOs only */ |
| 1335 | seg1 = 0; |
| 1336 | |
| 1337 | /* Calculate times relative to start of IO */ |
| 1338 | seg2 = (lpfc_cmd->ts_cmd_wqput - lpfc_cmd->ts_cmd_start); |
| 1339 | segsum = seg2; |
| 1340 | seg3 = lpfc_cmd->ts_isr_cmpl - lpfc_cmd->ts_cmd_start; |
| 1341 | if (segsum > seg3) |
| 1342 | return; |
| 1343 | seg3 -= segsum; |
| 1344 | segsum += seg3; |
| 1345 | |
| 1346 | seg4 = lpfc_cmd->ts_data_io - lpfc_cmd->ts_cmd_start; |
| 1347 | if (segsum > seg4) |
| 1348 | return; |
| 1349 | seg4 -= segsum; |
| 1350 | |
| 1351 | phba->ktime_data_samples++; |
| 1352 | phba->ktime_seg1_total += seg1; |
| 1353 | if (seg1 < phba->ktime_seg1_min) |
| 1354 | phba->ktime_seg1_min = seg1; |
| 1355 | else if (seg1 > phba->ktime_seg1_max) |
| 1356 | phba->ktime_seg1_max = seg1; |
| 1357 | phba->ktime_seg2_total += seg2; |
| 1358 | if (seg2 < phba->ktime_seg2_min) |
| 1359 | phba->ktime_seg2_min = seg2; |
| 1360 | else if (seg2 > phba->ktime_seg2_max) |
| 1361 | phba->ktime_seg2_max = seg2; |
| 1362 | phba->ktime_seg3_total += seg3; |
| 1363 | if (seg3 < phba->ktime_seg3_min) |
| 1364 | phba->ktime_seg3_min = seg3; |
| 1365 | else if (seg3 > phba->ktime_seg3_max) |
| 1366 | phba->ktime_seg3_max = seg3; |
| 1367 | phba->ktime_seg4_total += seg4; |
| 1368 | if (seg4 < phba->ktime_seg4_min) |
| 1369 | phba->ktime_seg4_min = seg4; |
| 1370 | else if (seg4 > phba->ktime_seg4_max) |
| 1371 | phba->ktime_seg4_max = seg4; |
| 1372 | |
| 1373 | lpfc_cmd->ts_last_cmd = 0; |
| 1374 | lpfc_cmd->ts_cmd_start = 0; |
| 1375 | lpfc_cmd->ts_cmd_wqput = 0; |
| 1376 | lpfc_cmd->ts_isr_cmpl = 0; |
| 1377 | lpfc_cmd->ts_data_io = 0; |
| 1378 | } |
| 1379 | |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 1380 | /** |
James Smart | 2fcbc56 | 2020-03-22 11:13:02 -0700 | [diff] [blame] | 1381 | * lpfc_debugfs_ioktime_data - Dump target node list to a buffer |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 1382 | * @vport: The vport to gather target node info from. |
| 1383 | * @buf: The buffer to dump log into. |
| 1384 | * @size: The maximum amount of data to process. |
| 1385 | * |
| 1386 | * Description: |
| 1387 | * This routine dumps the NVME statistics associated with @vport |
| 1388 | * |
| 1389 | * Return Value: |
| 1390 | * This routine returns the amount of bytes that were dumped into @buf and will |
| 1391 | * not exceed @size. |
| 1392 | **/ |
| 1393 | static int |
James Smart | 2fcbc56 | 2020-03-22 11:13:02 -0700 | [diff] [blame] | 1394 | lpfc_debugfs_ioktime_data(struct lpfc_vport *vport, char *buf, int size) |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 1395 | { |
| 1396 | struct lpfc_hba *phba = vport->phba; |
| 1397 | int len = 0; |
| 1398 | |
| 1399 | if (phba->nvmet_support == 0) { |
James Smart | 2fcbc56 | 2020-03-22 11:13:02 -0700 | [diff] [blame] | 1400 | /* Initiator */ |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1401 | len += scnprintf(buf + len, PAGE_SIZE - len, |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 1402 | "ktime %s: Total Samples: %lld\n", |
| 1403 | (phba->ktime_on ? "Enabled" : "Disabled"), |
| 1404 | phba->ktime_data_samples); |
| 1405 | if (phba->ktime_data_samples == 0) |
| 1406 | return len; |
| 1407 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1408 | len += scnprintf( |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 1409 | buf + len, PAGE_SIZE - len, |
James Smart | 2fcbc56 | 2020-03-22 11:13:02 -0700 | [diff] [blame] | 1410 | "Segment 1: Last Cmd cmpl " |
| 1411 | "done -to- Start of next Cmd (in driver)\n"); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1412 | len += scnprintf( |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 1413 | buf + len, PAGE_SIZE - len, |
| 1414 | "avg:%08lld min:%08lld max %08lld\n", |
Arnd Bergmann | 90ec7c9 | 2017-02-27 21:31:43 +0100 | [diff] [blame] | 1415 | div_u64(phba->ktime_seg1_total, |
| 1416 | phba->ktime_data_samples), |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 1417 | phba->ktime_seg1_min, |
| 1418 | phba->ktime_seg1_max); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1419 | len += scnprintf( |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 1420 | buf + len, PAGE_SIZE - len, |
James Smart | 2fcbc56 | 2020-03-22 11:13:02 -0700 | [diff] [blame] | 1421 | "Segment 2: Driver start of Cmd " |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 1422 | "-to- Firmware WQ doorbell\n"); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1423 | len += scnprintf( |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 1424 | buf + len, PAGE_SIZE - len, |
| 1425 | "avg:%08lld min:%08lld max %08lld\n", |
Arnd Bergmann | 90ec7c9 | 2017-02-27 21:31:43 +0100 | [diff] [blame] | 1426 | div_u64(phba->ktime_seg2_total, |
| 1427 | phba->ktime_data_samples), |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 1428 | phba->ktime_seg2_min, |
| 1429 | phba->ktime_seg2_max); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1430 | len += scnprintf( |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 1431 | buf + len, PAGE_SIZE - len, |
| 1432 | "Segment 3: Firmware WQ doorbell -to- " |
| 1433 | "MSI-X ISR cmpl\n"); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1434 | len += scnprintf( |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 1435 | buf + len, PAGE_SIZE - len, |
| 1436 | "avg:%08lld min:%08lld max %08lld\n", |
Arnd Bergmann | 90ec7c9 | 2017-02-27 21:31:43 +0100 | [diff] [blame] | 1437 | div_u64(phba->ktime_seg3_total, |
| 1438 | phba->ktime_data_samples), |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 1439 | phba->ktime_seg3_min, |
| 1440 | phba->ktime_seg3_max); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1441 | len += scnprintf( |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 1442 | buf + len, PAGE_SIZE - len, |
| 1443 | "Segment 4: MSI-X ISR cmpl -to- " |
James Smart | 2fcbc56 | 2020-03-22 11:13:02 -0700 | [diff] [blame] | 1444 | "Cmd cmpl done\n"); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1445 | len += scnprintf( |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 1446 | buf + len, PAGE_SIZE - len, |
| 1447 | "avg:%08lld min:%08lld max %08lld\n", |
Arnd Bergmann | 90ec7c9 | 2017-02-27 21:31:43 +0100 | [diff] [blame] | 1448 | div_u64(phba->ktime_seg4_total, |
| 1449 | phba->ktime_data_samples), |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 1450 | phba->ktime_seg4_min, |
| 1451 | phba->ktime_seg4_max); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1452 | len += scnprintf( |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 1453 | buf + len, PAGE_SIZE - len, |
| 1454 | "Total IO avg time: %08lld\n", |
Arnd Bergmann | 90ec7c9 | 2017-02-27 21:31:43 +0100 | [diff] [blame] | 1455 | div_u64(phba->ktime_seg1_total + |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 1456 | phba->ktime_seg2_total + |
| 1457 | phba->ktime_seg3_total + |
Arnd Bergmann | 90ec7c9 | 2017-02-27 21:31:43 +0100 | [diff] [blame] | 1458 | phba->ktime_seg4_total, |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 1459 | phba->ktime_data_samples)); |
| 1460 | return len; |
| 1461 | } |
James Smart | 2b65e18 | 2017-02-12 13:52:38 -0800 | [diff] [blame] | 1462 | |
| 1463 | /* NVME Target */ |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1464 | len += scnprintf(buf + len, PAGE_SIZE-len, |
James Smart | 2b65e18 | 2017-02-12 13:52:38 -0800 | [diff] [blame] | 1465 | "ktime %s: Total Samples: %lld %lld\n", |
| 1466 | (phba->ktime_on ? "Enabled" : "Disabled"), |
| 1467 | phba->ktime_data_samples, |
| 1468 | phba->ktime_status_samples); |
| 1469 | if (phba->ktime_data_samples == 0) |
| 1470 | return len; |
| 1471 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1472 | len += scnprintf(buf + len, PAGE_SIZE-len, |
James Smart | 2b65e18 | 2017-02-12 13:52:38 -0800 | [diff] [blame] | 1473 | "Segment 1: MSI-X ISR Rcv cmd -to- " |
| 1474 | "cmd pass to NVME Layer\n"); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1475 | len += scnprintf(buf + len, PAGE_SIZE-len, |
James Smart | 2b65e18 | 2017-02-12 13:52:38 -0800 | [diff] [blame] | 1476 | "avg:%08lld min:%08lld max %08lld\n", |
Arnd Bergmann | 90ec7c9 | 2017-02-27 21:31:43 +0100 | [diff] [blame] | 1477 | div_u64(phba->ktime_seg1_total, |
| 1478 | phba->ktime_data_samples), |
James Smart | 2b65e18 | 2017-02-12 13:52:38 -0800 | [diff] [blame] | 1479 | phba->ktime_seg1_min, |
| 1480 | phba->ktime_seg1_max); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1481 | len += scnprintf(buf + len, PAGE_SIZE-len, |
James Smart | 2b65e18 | 2017-02-12 13:52:38 -0800 | [diff] [blame] | 1482 | "Segment 2: cmd pass to NVME Layer- " |
| 1483 | "-to- Driver rcv cmd OP (action)\n"); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1484 | len += scnprintf(buf + len, PAGE_SIZE-len, |
James Smart | 2b65e18 | 2017-02-12 13:52:38 -0800 | [diff] [blame] | 1485 | "avg:%08lld min:%08lld max %08lld\n", |
Arnd Bergmann | 90ec7c9 | 2017-02-27 21:31:43 +0100 | [diff] [blame] | 1486 | div_u64(phba->ktime_seg2_total, |
| 1487 | phba->ktime_data_samples), |
James Smart | 2b65e18 | 2017-02-12 13:52:38 -0800 | [diff] [blame] | 1488 | phba->ktime_seg2_min, |
| 1489 | phba->ktime_seg2_max); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1490 | len += scnprintf(buf + len, PAGE_SIZE-len, |
James Smart | 2b65e18 | 2017-02-12 13:52:38 -0800 | [diff] [blame] | 1491 | "Segment 3: Driver rcv cmd OP -to- " |
| 1492 | "Firmware WQ doorbell: cmd\n"); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1493 | len += scnprintf(buf + len, PAGE_SIZE-len, |
James Smart | 2b65e18 | 2017-02-12 13:52:38 -0800 | [diff] [blame] | 1494 | "avg:%08lld min:%08lld max %08lld\n", |
Arnd Bergmann | 90ec7c9 | 2017-02-27 21:31:43 +0100 | [diff] [blame] | 1495 | div_u64(phba->ktime_seg3_total, |
| 1496 | phba->ktime_data_samples), |
James Smart | 2b65e18 | 2017-02-12 13:52:38 -0800 | [diff] [blame] | 1497 | phba->ktime_seg3_min, |
| 1498 | phba->ktime_seg3_max); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1499 | len += scnprintf(buf + len, PAGE_SIZE-len, |
James Smart | 2b65e18 | 2017-02-12 13:52:38 -0800 | [diff] [blame] | 1500 | "Segment 4: Firmware WQ doorbell: cmd " |
| 1501 | "-to- MSI-X ISR for cmd cmpl\n"); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1502 | len += scnprintf(buf + len, PAGE_SIZE-len, |
James Smart | 2b65e18 | 2017-02-12 13:52:38 -0800 | [diff] [blame] | 1503 | "avg:%08lld min:%08lld max %08lld\n", |
Arnd Bergmann | 90ec7c9 | 2017-02-27 21:31:43 +0100 | [diff] [blame] | 1504 | div_u64(phba->ktime_seg4_total, |
| 1505 | phba->ktime_data_samples), |
James Smart | 2b65e18 | 2017-02-12 13:52:38 -0800 | [diff] [blame] | 1506 | phba->ktime_seg4_min, |
| 1507 | phba->ktime_seg4_max); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1508 | len += scnprintf(buf + len, PAGE_SIZE-len, |
James Smart | 2b65e18 | 2017-02-12 13:52:38 -0800 | [diff] [blame] | 1509 | "Segment 5: MSI-X ISR for cmd cmpl " |
| 1510 | "-to- NVME layer passed cmd done\n"); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1511 | len += scnprintf(buf + len, PAGE_SIZE-len, |
James Smart | 2b65e18 | 2017-02-12 13:52:38 -0800 | [diff] [blame] | 1512 | "avg:%08lld min:%08lld max %08lld\n", |
Arnd Bergmann | 90ec7c9 | 2017-02-27 21:31:43 +0100 | [diff] [blame] | 1513 | div_u64(phba->ktime_seg5_total, |
| 1514 | phba->ktime_data_samples), |
James Smart | 2b65e18 | 2017-02-12 13:52:38 -0800 | [diff] [blame] | 1515 | phba->ktime_seg5_min, |
| 1516 | phba->ktime_seg5_max); |
| 1517 | |
| 1518 | if (phba->ktime_status_samples == 0) { |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1519 | len += scnprintf(buf + len, PAGE_SIZE-len, |
James Smart | 2b65e18 | 2017-02-12 13:52:38 -0800 | [diff] [blame] | 1520 | "Total: cmd received by MSI-X ISR " |
| 1521 | "-to- cmd completed on wire\n"); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1522 | len += scnprintf(buf + len, PAGE_SIZE-len, |
James Smart | 2b65e18 | 2017-02-12 13:52:38 -0800 | [diff] [blame] | 1523 | "avg:%08lld min:%08lld " |
| 1524 | "max %08lld\n", |
Arnd Bergmann | 90ec7c9 | 2017-02-27 21:31:43 +0100 | [diff] [blame] | 1525 | div_u64(phba->ktime_seg10_total, |
| 1526 | phba->ktime_data_samples), |
James Smart | 2b65e18 | 2017-02-12 13:52:38 -0800 | [diff] [blame] | 1527 | phba->ktime_seg10_min, |
| 1528 | phba->ktime_seg10_max); |
| 1529 | return len; |
| 1530 | } |
| 1531 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1532 | len += scnprintf(buf + len, PAGE_SIZE-len, |
James Smart | 2b65e18 | 2017-02-12 13:52:38 -0800 | [diff] [blame] | 1533 | "Segment 6: NVME layer passed cmd done " |
| 1534 | "-to- Driver rcv rsp status OP\n"); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1535 | len += scnprintf(buf + len, PAGE_SIZE-len, |
James Smart | 2b65e18 | 2017-02-12 13:52:38 -0800 | [diff] [blame] | 1536 | "avg:%08lld min:%08lld max %08lld\n", |
Arnd Bergmann | 90ec7c9 | 2017-02-27 21:31:43 +0100 | [diff] [blame] | 1537 | div_u64(phba->ktime_seg6_total, |
| 1538 | phba->ktime_status_samples), |
James Smart | 2b65e18 | 2017-02-12 13:52:38 -0800 | [diff] [blame] | 1539 | phba->ktime_seg6_min, |
| 1540 | phba->ktime_seg6_max); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1541 | len += scnprintf(buf + len, PAGE_SIZE-len, |
James Smart | 2b65e18 | 2017-02-12 13:52:38 -0800 | [diff] [blame] | 1542 | "Segment 7: Driver rcv rsp status OP " |
| 1543 | "-to- Firmware WQ doorbell: status\n"); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1544 | len += scnprintf(buf + len, PAGE_SIZE-len, |
James Smart | 2b65e18 | 2017-02-12 13:52:38 -0800 | [diff] [blame] | 1545 | "avg:%08lld min:%08lld max %08lld\n", |
Arnd Bergmann | 90ec7c9 | 2017-02-27 21:31:43 +0100 | [diff] [blame] | 1546 | div_u64(phba->ktime_seg7_total, |
| 1547 | phba->ktime_status_samples), |
James Smart | 2b65e18 | 2017-02-12 13:52:38 -0800 | [diff] [blame] | 1548 | phba->ktime_seg7_min, |
| 1549 | phba->ktime_seg7_max); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1550 | len += scnprintf(buf + len, PAGE_SIZE-len, |
James Smart | 2b65e18 | 2017-02-12 13:52:38 -0800 | [diff] [blame] | 1551 | "Segment 8: Firmware WQ doorbell: status" |
| 1552 | " -to- MSI-X ISR for status cmpl\n"); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1553 | len += scnprintf(buf + len, PAGE_SIZE-len, |
James Smart | 2b65e18 | 2017-02-12 13:52:38 -0800 | [diff] [blame] | 1554 | "avg:%08lld min:%08lld max %08lld\n", |
Arnd Bergmann | 90ec7c9 | 2017-02-27 21:31:43 +0100 | [diff] [blame] | 1555 | div_u64(phba->ktime_seg8_total, |
| 1556 | phba->ktime_status_samples), |
James Smart | 2b65e18 | 2017-02-12 13:52:38 -0800 | [diff] [blame] | 1557 | phba->ktime_seg8_min, |
| 1558 | phba->ktime_seg8_max); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1559 | len += scnprintf(buf + len, PAGE_SIZE-len, |
James Smart | 2b65e18 | 2017-02-12 13:52:38 -0800 | [diff] [blame] | 1560 | "Segment 9: MSI-X ISR for status cmpl " |
| 1561 | "-to- NVME layer passed status done\n"); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1562 | len += scnprintf(buf + len, PAGE_SIZE-len, |
James Smart | 2b65e18 | 2017-02-12 13:52:38 -0800 | [diff] [blame] | 1563 | "avg:%08lld min:%08lld max %08lld\n", |
Arnd Bergmann | 90ec7c9 | 2017-02-27 21:31:43 +0100 | [diff] [blame] | 1564 | div_u64(phba->ktime_seg9_total, |
| 1565 | phba->ktime_status_samples), |
James Smart | 2b65e18 | 2017-02-12 13:52:38 -0800 | [diff] [blame] | 1566 | phba->ktime_seg9_min, |
| 1567 | phba->ktime_seg9_max); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1568 | len += scnprintf(buf + len, PAGE_SIZE-len, |
James Smart | 2b65e18 | 2017-02-12 13:52:38 -0800 | [diff] [blame] | 1569 | "Total: cmd received by MSI-X ISR -to- " |
| 1570 | "cmd completed on wire\n"); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1571 | len += scnprintf(buf + len, PAGE_SIZE-len, |
James Smart | 2b65e18 | 2017-02-12 13:52:38 -0800 | [diff] [blame] | 1572 | "avg:%08lld min:%08lld max %08lld\n", |
Arnd Bergmann | 90ec7c9 | 2017-02-27 21:31:43 +0100 | [diff] [blame] | 1573 | div_u64(phba->ktime_seg10_total, |
| 1574 | phba->ktime_status_samples), |
James Smart | 2b65e18 | 2017-02-12 13:52:38 -0800 | [diff] [blame] | 1575 | phba->ktime_seg10_min, |
| 1576 | phba->ktime_seg10_max); |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 1577 | return len; |
| 1578 | } |
| 1579 | |
| 1580 | /** |
| 1581 | * lpfc_debugfs_nvmeio_trc_data - Dump NVME IO trace list to a buffer |
| 1582 | * @phba: The phba to gather target node info from. |
| 1583 | * @buf: The buffer to dump log into. |
| 1584 | * @size: The maximum amount of data to process. |
| 1585 | * |
| 1586 | * Description: |
| 1587 | * This routine dumps the NVME IO trace associated with @phba |
| 1588 | * |
| 1589 | * Return Value: |
| 1590 | * This routine returns the amount of bytes that were dumped into @buf and will |
| 1591 | * not exceed @size. |
| 1592 | **/ |
| 1593 | static int |
| 1594 | lpfc_debugfs_nvmeio_trc_data(struct lpfc_hba *phba, char *buf, int size) |
| 1595 | { |
| 1596 | struct lpfc_debugfs_nvmeio_trc *dtp; |
| 1597 | int i, state, index, skip; |
| 1598 | int len = 0; |
| 1599 | |
| 1600 | state = phba->nvmeio_trc_on; |
| 1601 | |
| 1602 | index = (atomic_read(&phba->nvmeio_trc_cnt) + 1) & |
| 1603 | (phba->nvmeio_trc_size - 1); |
| 1604 | skip = phba->nvmeio_trc_output_idx; |
| 1605 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1606 | len += scnprintf(buf + len, size - len, |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 1607 | "%s IO Trace %s: next_idx %d skip %d size %d\n", |
| 1608 | (phba->nvmet_support ? "NVME" : "NVMET"), |
| 1609 | (state ? "Enabled" : "Disabled"), |
| 1610 | index, skip, phba->nvmeio_trc_size); |
| 1611 | |
| 1612 | if (!phba->nvmeio_trc || state) |
| 1613 | return len; |
| 1614 | |
| 1615 | /* trace MUST bhe off to continue */ |
| 1616 | |
| 1617 | for (i = index; i < phba->nvmeio_trc_size; i++) { |
| 1618 | if (skip) { |
| 1619 | skip--; |
| 1620 | continue; |
| 1621 | } |
| 1622 | dtp = phba->nvmeio_trc + i; |
| 1623 | phba->nvmeio_trc_output_idx++; |
| 1624 | |
| 1625 | if (!dtp->fmt) |
| 1626 | continue; |
| 1627 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1628 | len += scnprintf(buf + len, size - len, dtp->fmt, |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 1629 | dtp->data1, dtp->data2, dtp->data3); |
| 1630 | |
| 1631 | if (phba->nvmeio_trc_output_idx >= phba->nvmeio_trc_size) { |
| 1632 | phba->nvmeio_trc_output_idx = 0; |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1633 | len += scnprintf(buf + len, size - len, |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 1634 | "Trace Complete\n"); |
| 1635 | goto out; |
| 1636 | } |
| 1637 | |
| 1638 | if (len >= (size - LPFC_DEBUG_OUT_LINE_SZ)) { |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1639 | len += scnprintf(buf + len, size - len, |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 1640 | "Trace Continue (%d of %d)\n", |
| 1641 | phba->nvmeio_trc_output_idx, |
| 1642 | phba->nvmeio_trc_size); |
| 1643 | goto out; |
| 1644 | } |
| 1645 | } |
| 1646 | for (i = 0; i < index; i++) { |
| 1647 | if (skip) { |
| 1648 | skip--; |
| 1649 | continue; |
| 1650 | } |
| 1651 | dtp = phba->nvmeio_trc + i; |
| 1652 | phba->nvmeio_trc_output_idx++; |
| 1653 | |
| 1654 | if (!dtp->fmt) |
| 1655 | continue; |
| 1656 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1657 | len += scnprintf(buf + len, size - len, dtp->fmt, |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 1658 | dtp->data1, dtp->data2, dtp->data3); |
| 1659 | |
| 1660 | if (phba->nvmeio_trc_output_idx >= phba->nvmeio_trc_size) { |
| 1661 | phba->nvmeio_trc_output_idx = 0; |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1662 | len += scnprintf(buf + len, size - len, |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 1663 | "Trace Complete\n"); |
| 1664 | goto out; |
| 1665 | } |
| 1666 | |
| 1667 | if (len >= (size - LPFC_DEBUG_OUT_LINE_SZ)) { |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1668 | len += scnprintf(buf + len, size - len, |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 1669 | "Trace Continue (%d of %d)\n", |
| 1670 | phba->nvmeio_trc_output_idx, |
| 1671 | phba->nvmeio_trc_size); |
| 1672 | goto out; |
| 1673 | } |
| 1674 | } |
| 1675 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 1676 | len += scnprintf(buf + len, size - len, |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 1677 | "Trace Done\n"); |
| 1678 | out: |
| 1679 | return len; |
| 1680 | } |
| 1681 | |
| 1682 | /** |
James Smart | 840eda9 | 2020-03-22 11:13:00 -0700 | [diff] [blame] | 1683 | * lpfc_debugfs_hdwqstat_data - Dump I/O stats to a buffer |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 1684 | * @vport: The vport to gather target node info from. |
| 1685 | * @buf: The buffer to dump log into. |
| 1686 | * @size: The maximum amount of data to process. |
| 1687 | * |
| 1688 | * Description: |
James Smart | 840eda9 | 2020-03-22 11:13:00 -0700 | [diff] [blame] | 1689 | * This routine dumps the NVME + SCSI statistics associated with @vport |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 1690 | * |
| 1691 | * Return Value: |
| 1692 | * This routine returns the amount of bytes that were dumped into @buf and will |
| 1693 | * not exceed @size. |
| 1694 | **/ |
| 1695 | static int |
James Smart | 840eda9 | 2020-03-22 11:13:00 -0700 | [diff] [blame] | 1696 | lpfc_debugfs_hdwqstat_data(struct lpfc_vport *vport, char *buf, int size) |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 1697 | { |
| 1698 | struct lpfc_hba *phba = vport->phba; |
James Smart | 840eda9 | 2020-03-22 11:13:00 -0700 | [diff] [blame] | 1699 | struct lpfc_hdwq_stat *c_stat; |
| 1700 | int i, j, len; |
James Smart | 63df6d6 | 2019-01-28 11:14:24 -0800 | [diff] [blame] | 1701 | uint32_t tot_xmt; |
| 1702 | uint32_t tot_rcv; |
| 1703 | uint32_t tot_cmpl; |
James Smart | 840eda9 | 2020-03-22 11:13:00 -0700 | [diff] [blame] | 1704 | char tmp[LPFC_MAX_SCSI_INFO_TMP_LEN] = {0}; |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 1705 | |
James Smart | 840eda9 | 2020-03-22 11:13:00 -0700 | [diff] [blame] | 1706 | scnprintf(tmp, sizeof(tmp), "HDWQ Stats:\n\n"); |
| 1707 | if (strlcat(buf, tmp, size) >= size) |
| 1708 | goto buffer_done; |
| 1709 | |
| 1710 | scnprintf(tmp, sizeof(tmp), "(NVME Accounting: %s) ", |
| 1711 | (phba->hdwqstat_on & |
| 1712 | (LPFC_CHECK_NVME_IO | LPFC_CHECK_NVMET_IO) ? |
| 1713 | "Enabled" : "Disabled")); |
| 1714 | if (strlcat(buf, tmp, size) >= size) |
| 1715 | goto buffer_done; |
| 1716 | |
| 1717 | scnprintf(tmp, sizeof(tmp), "(SCSI Accounting: %s) ", |
| 1718 | (phba->hdwqstat_on & LPFC_CHECK_SCSI_IO ? |
| 1719 | "Enabled" : "Disabled")); |
| 1720 | if (strlcat(buf, tmp, size) >= size) |
| 1721 | goto buffer_done; |
| 1722 | |
| 1723 | scnprintf(tmp, sizeof(tmp), "\n\n"); |
| 1724 | if (strlcat(buf, tmp, size) >= size) |
| 1725 | goto buffer_done; |
James Smart | 63df6d6 | 2019-01-28 11:14:24 -0800 | [diff] [blame] | 1726 | |
| 1727 | for (i = 0; i < phba->cfg_hdw_queue; i++) { |
James Smart | 63df6d6 | 2019-01-28 11:14:24 -0800 | [diff] [blame] | 1728 | tot_rcv = 0; |
| 1729 | tot_xmt = 0; |
| 1730 | tot_cmpl = 0; |
James Smart | 840eda9 | 2020-03-22 11:13:00 -0700 | [diff] [blame] | 1731 | |
| 1732 | for_each_present_cpu(j) { |
| 1733 | c_stat = per_cpu_ptr(phba->sli4_hba.c_stat, j); |
| 1734 | |
| 1735 | /* Only display for this HDWQ */ |
| 1736 | if (i != c_stat->hdwq_no) |
| 1737 | continue; |
| 1738 | |
| 1739 | /* Only display non-zero counters */ |
| 1740 | if (!c_stat->xmt_io && !c_stat->cmpl_io && |
| 1741 | !c_stat->rcv_io) |
| 1742 | continue; |
| 1743 | |
| 1744 | if (!tot_xmt && !tot_cmpl && !tot_rcv) { |
| 1745 | /* Print HDWQ string only the first time */ |
| 1746 | scnprintf(tmp, sizeof(tmp), "[HDWQ %d]:\t", i); |
| 1747 | if (strlcat(buf, tmp, size) >= size) |
| 1748 | goto buffer_done; |
| 1749 | } |
| 1750 | |
| 1751 | tot_xmt += c_stat->xmt_io; |
| 1752 | tot_cmpl += c_stat->cmpl_io; |
James Smart | 63df6d6 | 2019-01-28 11:14:24 -0800 | [diff] [blame] | 1753 | if (phba->nvmet_support) |
James Smart | 840eda9 | 2020-03-22 11:13:00 -0700 | [diff] [blame] | 1754 | tot_rcv += c_stat->rcv_io; |
| 1755 | |
| 1756 | scnprintf(tmp, sizeof(tmp), "| [CPU %d]: ", j); |
| 1757 | if (strlcat(buf, tmp, size) >= size) |
| 1758 | goto buffer_done; |
| 1759 | |
| 1760 | if (phba->nvmet_support) { |
| 1761 | scnprintf(tmp, sizeof(tmp), |
| 1762 | "XMT 0x%x CMPL 0x%x RCV 0x%x |", |
| 1763 | c_stat->xmt_io, c_stat->cmpl_io, |
| 1764 | c_stat->rcv_io); |
| 1765 | if (strlcat(buf, tmp, size) >= size) |
| 1766 | goto buffer_done; |
| 1767 | } else { |
| 1768 | scnprintf(tmp, sizeof(tmp), |
| 1769 | "XMT 0x%x CMPL 0x%x |", |
| 1770 | c_stat->xmt_io, c_stat->cmpl_io); |
| 1771 | if (strlcat(buf, tmp, size) >= size) |
| 1772 | goto buffer_done; |
| 1773 | } |
James Smart | 63df6d6 | 2019-01-28 11:14:24 -0800 | [diff] [blame] | 1774 | } |
| 1775 | |
James Smart | 840eda9 | 2020-03-22 11:13:00 -0700 | [diff] [blame] | 1776 | /* Check if nothing to display */ |
James Smart | 63df6d6 | 2019-01-28 11:14:24 -0800 | [diff] [blame] | 1777 | if (!tot_xmt && !tot_cmpl && !tot_rcv) |
| 1778 | continue; |
| 1779 | |
James Smart | 840eda9 | 2020-03-22 11:13:00 -0700 | [diff] [blame] | 1780 | scnprintf(tmp, sizeof(tmp), "\t->\t[HDWQ Total: "); |
| 1781 | if (strlcat(buf, tmp, size) >= size) |
| 1782 | goto buffer_done; |
| 1783 | |
| 1784 | if (phba->nvmet_support) { |
| 1785 | scnprintf(tmp, sizeof(tmp), |
| 1786 | "XMT 0x%x CMPL 0x%x RCV 0x%x]\n\n", |
| 1787 | tot_xmt, tot_cmpl, tot_rcv); |
| 1788 | if (strlcat(buf, tmp, size) >= size) |
| 1789 | goto buffer_done; |
| 1790 | } else { |
| 1791 | scnprintf(tmp, sizeof(tmp), |
| 1792 | "XMT 0x%x CMPL 0x%x]\n\n", |
| 1793 | tot_xmt, tot_cmpl); |
| 1794 | if (strlcat(buf, tmp, size) >= size) |
| 1795 | goto buffer_done; |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 1796 | } |
James Smart | 63df6d6 | 2019-01-28 11:14:24 -0800 | [diff] [blame] | 1797 | } |
James Smart | 840eda9 | 2020-03-22 11:13:00 -0700 | [diff] [blame] | 1798 | |
| 1799 | buffer_done: |
| 1800 | len = strnlen(buf, size); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1801 | return len; |
| 1802 | } |
James Smart | 2ea259e | 2017-02-12 13:52:27 -0800 | [diff] [blame] | 1803 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1804 | #endif |
| 1805 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1806 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1807 | * lpfc_debugfs_disc_trc - Store discovery trace log |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1808 | * @vport: The vport to associate this trace string with for retrieval. |
| 1809 | * @mask: Log entry classification. |
| 1810 | * @fmt: Format string to be displayed when dumping the log. |
| 1811 | * @data1: 1st data parameter to be applied to @fmt. |
| 1812 | * @data2: 2nd data parameter to be applied to @fmt. |
| 1813 | * @data3: 3rd data parameter to be applied to @fmt. |
| 1814 | * |
| 1815 | * Description: |
| 1816 | * This routine is used by the driver code to add a debugfs log entry to the |
| 1817 | * discovery trace buffer associated with @vport. Only entries with a @mask that |
| 1818 | * match the current debugfs discovery mask will be saved. Entries that do not |
| 1819 | * match will be thrown away. @fmt, @data1, @data2, and @data3 are used like |
| 1820 | * printf when displaying the log. |
| 1821 | **/ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1822 | inline void |
| 1823 | lpfc_debugfs_disc_trc(struct lpfc_vport *vport, int mask, char *fmt, |
| 1824 | uint32_t data1, uint32_t data2, uint32_t data3) |
| 1825 | { |
James Smart | 923e4b6 | 2008-12-04 22:40:07 -0500 | [diff] [blame] | 1826 | #ifdef CONFIG_SCSI_LPFC_DEBUG_FS |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 1827 | struct lpfc_debugfs_trc *dtp; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1828 | int index; |
| 1829 | |
| 1830 | if (!(lpfc_debugfs_mask_disc_trc & mask)) |
| 1831 | return; |
| 1832 | |
| 1833 | if (!lpfc_debugfs_enable || !lpfc_debugfs_max_disc_trc || |
| 1834 | !vport || !vport->disc_trc) |
| 1835 | return; |
| 1836 | |
| 1837 | index = atomic_inc_return(&vport->disc_trc_cnt) & |
| 1838 | (lpfc_debugfs_max_disc_trc - 1); |
| 1839 | dtp = vport->disc_trc + index; |
| 1840 | dtp->fmt = fmt; |
| 1841 | dtp->data1 = data1; |
| 1842 | dtp->data2 = data2; |
| 1843 | dtp->data3 = data3; |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 1844 | dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt); |
| 1845 | dtp->jif = jiffies; |
| 1846 | #endif |
| 1847 | return; |
| 1848 | } |
| 1849 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1850 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1851 | * lpfc_debugfs_slow_ring_trc - Store slow ring trace log |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1852 | * @phba: The phba to associate this trace string with for retrieval. |
| 1853 | * @fmt: Format string to be displayed when dumping the log. |
| 1854 | * @data1: 1st data parameter to be applied to @fmt. |
| 1855 | * @data2: 2nd data parameter to be applied to @fmt. |
| 1856 | * @data3: 3rd data parameter to be applied to @fmt. |
| 1857 | * |
| 1858 | * Description: |
| 1859 | * This routine is used by the driver code to add a debugfs log entry to the |
| 1860 | * discovery trace buffer associated with @vport. @fmt, @data1, @data2, and |
| 1861 | * @data3 are used like printf when displaying the log. |
| 1862 | **/ |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 1863 | inline void |
| 1864 | lpfc_debugfs_slow_ring_trc(struct lpfc_hba *phba, char *fmt, |
| 1865 | uint32_t data1, uint32_t data2, uint32_t data3) |
| 1866 | { |
James Smart | 923e4b6 | 2008-12-04 22:40:07 -0500 | [diff] [blame] | 1867 | #ifdef CONFIG_SCSI_LPFC_DEBUG_FS |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 1868 | struct lpfc_debugfs_trc *dtp; |
| 1869 | int index; |
| 1870 | |
| 1871 | if (!lpfc_debugfs_enable || !lpfc_debugfs_max_slow_ring_trc || |
| 1872 | !phba || !phba->slow_ring_trc) |
| 1873 | return; |
| 1874 | |
| 1875 | index = atomic_inc_return(&phba->slow_ring_trc_cnt) & |
| 1876 | (lpfc_debugfs_max_slow_ring_trc - 1); |
| 1877 | dtp = phba->slow_ring_trc + index; |
| 1878 | dtp->fmt = fmt; |
| 1879 | dtp->data1 = data1; |
| 1880 | dtp->data2 = data2; |
| 1881 | dtp->data3 = data3; |
| 1882 | dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1883 | dtp->jif = jiffies; |
| 1884 | #endif |
| 1885 | return; |
| 1886 | } |
| 1887 | |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 1888 | /** |
| 1889 | * lpfc_debugfs_nvme_trc - Store NVME/NVMET trace log |
| 1890 | * @phba: The phba to associate this trace string with for retrieval. |
| 1891 | * @fmt: Format string to be displayed when dumping the log. |
| 1892 | * @data1: 1st data parameter to be applied to @fmt. |
| 1893 | * @data2: 2nd data parameter to be applied to @fmt. |
| 1894 | * @data3: 3rd data parameter to be applied to @fmt. |
| 1895 | * |
| 1896 | * Description: |
| 1897 | * This routine is used by the driver code to add a debugfs log entry to the |
| 1898 | * nvme trace buffer associated with @phba. @fmt, @data1, @data2, and |
| 1899 | * @data3 are used like printf when displaying the log. |
| 1900 | **/ |
| 1901 | inline void |
| 1902 | lpfc_debugfs_nvme_trc(struct lpfc_hba *phba, char *fmt, |
| 1903 | uint16_t data1, uint16_t data2, uint32_t data3) |
| 1904 | { |
| 1905 | #ifdef CONFIG_SCSI_LPFC_DEBUG_FS |
| 1906 | struct lpfc_debugfs_nvmeio_trc *dtp; |
| 1907 | int index; |
| 1908 | |
| 1909 | if (!phba->nvmeio_trc_on || !phba->nvmeio_trc) |
| 1910 | return; |
| 1911 | |
| 1912 | index = atomic_inc_return(&phba->nvmeio_trc_cnt) & |
| 1913 | (phba->nvmeio_trc_size - 1); |
| 1914 | dtp = phba->nvmeio_trc + index; |
| 1915 | dtp->fmt = fmt; |
| 1916 | dtp->data1 = data1; |
| 1917 | dtp->data2 = data2; |
| 1918 | dtp->data3 = data3; |
| 1919 | #endif |
| 1920 | } |
| 1921 | |
James Smart | 923e4b6 | 2008-12-04 22:40:07 -0500 | [diff] [blame] | 1922 | #ifdef CONFIG_SCSI_LPFC_DEBUG_FS |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1923 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1924 | * lpfc_debugfs_disc_trc_open - Open the discovery trace log |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1925 | * @inode: The inode pointer that contains a vport pointer. |
| 1926 | * @file: The file pointer to attach the log output. |
| 1927 | * |
| 1928 | * Description: |
| 1929 | * This routine is the entry point for the debugfs open file operation. It gets |
| 1930 | * the vport from the i_private field in @inode, allocates the necessary buffer |
| 1931 | * for the log, fills the buffer from the in-memory log for this vport, and then |
| 1932 | * returns a pointer to that log in the private_data field in @file. |
| 1933 | * |
| 1934 | * Returns: |
Geert Uytterhoeven | 79ce48d | 2015-05-21 14:11:33 +0200 | [diff] [blame] | 1935 | * This function returns zero if successful. On error it will return a negative |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1936 | * error value. |
| 1937 | **/ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1938 | static int |
| 1939 | lpfc_debugfs_disc_trc_open(struct inode *inode, struct file *file) |
| 1940 | { |
| 1941 | struct lpfc_vport *vport = inode->i_private; |
| 1942 | struct lpfc_debug *debug; |
| 1943 | int size; |
| 1944 | int rc = -ENOMEM; |
| 1945 | |
| 1946 | if (!lpfc_debugfs_max_disc_trc) { |
Colin Ian King | 258f84f | 2019-02-12 15:29:45 +0000 | [diff] [blame] | 1947 | rc = -ENOSPC; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1948 | goto out; |
| 1949 | } |
| 1950 | |
| 1951 | debug = kmalloc(sizeof(*debug), GFP_KERNEL); |
| 1952 | if (!debug) |
| 1953 | goto out; |
| 1954 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1955 | /* Round to page boundary */ |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 1956 | size = (lpfc_debugfs_max_disc_trc * LPFC_DEBUG_TRC_ENTRY_SIZE); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1957 | size = PAGE_ALIGN(size); |
| 1958 | |
| 1959 | debug->buffer = kmalloc(size, GFP_KERNEL); |
| 1960 | if (!debug->buffer) { |
| 1961 | kfree(debug); |
| 1962 | goto out; |
| 1963 | } |
| 1964 | |
| 1965 | debug->len = lpfc_debugfs_disc_trc_data(vport, debug->buffer, size); |
| 1966 | file->private_data = debug; |
| 1967 | |
| 1968 | rc = 0; |
| 1969 | out: |
| 1970 | return rc; |
| 1971 | } |
| 1972 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1973 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1974 | * lpfc_debugfs_slow_ring_trc_open - Open the Slow Ring trace log |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1975 | * @inode: The inode pointer that contains a vport pointer. |
| 1976 | * @file: The file pointer to attach the log output. |
| 1977 | * |
| 1978 | * Description: |
| 1979 | * This routine is the entry point for the debugfs open file operation. It gets |
| 1980 | * the vport from the i_private field in @inode, allocates the necessary buffer |
| 1981 | * for the log, fills the buffer from the in-memory log for this vport, and then |
| 1982 | * returns a pointer to that log in the private_data field in @file. |
| 1983 | * |
| 1984 | * Returns: |
Geert Uytterhoeven | 79ce48d | 2015-05-21 14:11:33 +0200 | [diff] [blame] | 1985 | * This function returns zero if successful. On error it will return a negative |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1986 | * error value. |
| 1987 | **/ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1988 | static int |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 1989 | lpfc_debugfs_slow_ring_trc_open(struct inode *inode, struct file *file) |
| 1990 | { |
| 1991 | struct lpfc_hba *phba = inode->i_private; |
| 1992 | struct lpfc_debug *debug; |
| 1993 | int size; |
| 1994 | int rc = -ENOMEM; |
| 1995 | |
| 1996 | if (!lpfc_debugfs_max_slow_ring_trc) { |
Colin Ian King | 258f84f | 2019-02-12 15:29:45 +0000 | [diff] [blame] | 1997 | rc = -ENOSPC; |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 1998 | goto out; |
| 1999 | } |
| 2000 | |
| 2001 | debug = kmalloc(sizeof(*debug), GFP_KERNEL); |
| 2002 | if (!debug) |
| 2003 | goto out; |
| 2004 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2005 | /* Round to page boundary */ |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 2006 | size = (lpfc_debugfs_max_slow_ring_trc * LPFC_DEBUG_TRC_ENTRY_SIZE); |
| 2007 | size = PAGE_ALIGN(size); |
| 2008 | |
| 2009 | debug->buffer = kmalloc(size, GFP_KERNEL); |
| 2010 | if (!debug->buffer) { |
| 2011 | kfree(debug); |
| 2012 | goto out; |
| 2013 | } |
| 2014 | |
| 2015 | debug->len = lpfc_debugfs_slow_ring_trc_data(phba, debug->buffer, size); |
| 2016 | file->private_data = debug; |
| 2017 | |
| 2018 | rc = 0; |
| 2019 | out: |
| 2020 | return rc; |
| 2021 | } |
| 2022 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2023 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2024 | * lpfc_debugfs_hbqinfo_open - Open the hbqinfo debugfs buffer |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2025 | * @inode: The inode pointer that contains a vport pointer. |
| 2026 | * @file: The file pointer to attach the log output. |
| 2027 | * |
| 2028 | * Description: |
| 2029 | * This routine is the entry point for the debugfs open file operation. It gets |
| 2030 | * the vport from the i_private field in @inode, allocates the necessary buffer |
| 2031 | * for the log, fills the buffer from the in-memory log for this vport, and then |
| 2032 | * returns a pointer to that log in the private_data field in @file. |
| 2033 | * |
| 2034 | * Returns: |
Geert Uytterhoeven | 79ce48d | 2015-05-21 14:11:33 +0200 | [diff] [blame] | 2035 | * This function returns zero if successful. On error it will return a negative |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2036 | * error value. |
| 2037 | **/ |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 2038 | static int |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 2039 | lpfc_debugfs_hbqinfo_open(struct inode *inode, struct file *file) |
| 2040 | { |
| 2041 | struct lpfc_hba *phba = inode->i_private; |
| 2042 | struct lpfc_debug *debug; |
| 2043 | int rc = -ENOMEM; |
| 2044 | |
| 2045 | debug = kmalloc(sizeof(*debug), GFP_KERNEL); |
| 2046 | if (!debug) |
| 2047 | goto out; |
| 2048 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2049 | /* Round to page boundary */ |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 2050 | debug->buffer = kmalloc(LPFC_HBQINFO_SIZE, GFP_KERNEL); |
| 2051 | if (!debug->buffer) { |
| 2052 | kfree(debug); |
| 2053 | goto out; |
| 2054 | } |
| 2055 | |
| 2056 | debug->len = lpfc_debugfs_hbqinfo_data(phba, debug->buffer, |
| 2057 | LPFC_HBQINFO_SIZE); |
| 2058 | file->private_data = debug; |
| 2059 | |
| 2060 | rc = 0; |
| 2061 | out: |
| 2062 | return rc; |
| 2063 | } |
| 2064 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2065 | /** |
James Smart | c490850 | 2019-01-28 11:14:28 -0800 | [diff] [blame] | 2066 | * lpfc_debugfs_multixripools_open - Open the multixripool debugfs buffer |
| 2067 | * @inode: The inode pointer that contains a hba pointer. |
| 2068 | * @file: The file pointer to attach the log output. |
| 2069 | * |
| 2070 | * Description: |
| 2071 | * This routine is the entry point for the debugfs open file operation. It gets |
| 2072 | * the hba from the i_private field in @inode, allocates the necessary buffer |
| 2073 | * for the log, fills the buffer from the in-memory log for this hba, and then |
| 2074 | * returns a pointer to that log in the private_data field in @file. |
| 2075 | * |
| 2076 | * Returns: |
| 2077 | * This function returns zero if successful. On error it will return a negative |
| 2078 | * error value. |
| 2079 | **/ |
| 2080 | static int |
| 2081 | lpfc_debugfs_multixripools_open(struct inode *inode, struct file *file) |
| 2082 | { |
| 2083 | struct lpfc_hba *phba = inode->i_private; |
| 2084 | struct lpfc_debug *debug; |
| 2085 | int rc = -ENOMEM; |
| 2086 | |
| 2087 | debug = kmalloc(sizeof(*debug), GFP_KERNEL); |
| 2088 | if (!debug) |
| 2089 | goto out; |
| 2090 | |
| 2091 | /* Round to page boundary */ |
| 2092 | debug->buffer = kzalloc(LPFC_DUMP_MULTIXRIPOOL_SIZE, GFP_KERNEL); |
| 2093 | if (!debug->buffer) { |
| 2094 | kfree(debug); |
| 2095 | goto out; |
| 2096 | } |
| 2097 | |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 2098 | debug->len = lpfc_debugfs_multixripools_data( |
| 2099 | phba, debug->buffer, LPFC_DUMP_MULTIXRIPOOL_SIZE); |
James Smart | c490850 | 2019-01-28 11:14:28 -0800 | [diff] [blame] | 2100 | |
| 2101 | debug->i_private = inode->i_private; |
| 2102 | file->private_data = debug; |
| 2103 | |
| 2104 | rc = 0; |
| 2105 | out: |
| 2106 | return rc; |
| 2107 | } |
| 2108 | |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 2109 | #ifdef LPFC_HDWQ_LOCK_STAT |
James Smart | c490850 | 2019-01-28 11:14:28 -0800 | [diff] [blame] | 2110 | /** |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 2111 | * lpfc_debugfs_lockstat_open - Open the lockstat debugfs buffer |
James Smart | 5e5b511 | 2019-01-28 11:14:22 -0800 | [diff] [blame] | 2112 | * @inode: The inode pointer that contains a vport pointer. |
| 2113 | * @file: The file pointer to attach the log output. |
| 2114 | * |
| 2115 | * Description: |
| 2116 | * This routine is the entry point for the debugfs open file operation. It gets |
| 2117 | * the vport from the i_private field in @inode, allocates the necessary buffer |
| 2118 | * for the log, fills the buffer from the in-memory log for this vport, and then |
| 2119 | * returns a pointer to that log in the private_data field in @file. |
| 2120 | * |
| 2121 | * Returns: |
| 2122 | * This function returns zero if successful. On error it will return a negative |
| 2123 | * error value. |
| 2124 | **/ |
| 2125 | static int |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 2126 | lpfc_debugfs_lockstat_open(struct inode *inode, struct file *file) |
James Smart | 5e5b511 | 2019-01-28 11:14:22 -0800 | [diff] [blame] | 2127 | { |
| 2128 | struct lpfc_hba *phba = inode->i_private; |
| 2129 | struct lpfc_debug *debug; |
| 2130 | int rc = -ENOMEM; |
| 2131 | |
| 2132 | debug = kmalloc(sizeof(*debug), GFP_KERNEL); |
| 2133 | if (!debug) |
| 2134 | goto out; |
| 2135 | |
| 2136 | /* Round to page boundary */ |
| 2137 | debug->buffer = kmalloc(LPFC_HDWQINFO_SIZE, GFP_KERNEL); |
| 2138 | if (!debug->buffer) { |
| 2139 | kfree(debug); |
| 2140 | goto out; |
| 2141 | } |
| 2142 | |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 2143 | debug->len = lpfc_debugfs_lockstat_data(phba, debug->buffer, |
James Smart | 5e5b511 | 2019-01-28 11:14:22 -0800 | [diff] [blame] | 2144 | LPFC_HBQINFO_SIZE); |
| 2145 | file->private_data = debug; |
| 2146 | |
| 2147 | rc = 0; |
| 2148 | out: |
| 2149 | return rc; |
| 2150 | } |
| 2151 | |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 2152 | static ssize_t |
| 2153 | lpfc_debugfs_lockstat_write(struct file *file, const char __user *buf, |
| 2154 | size_t nbytes, loff_t *ppos) |
| 2155 | { |
| 2156 | struct lpfc_debug *debug = file->private_data; |
| 2157 | struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private; |
| 2158 | struct lpfc_sli4_hdw_queue *qp; |
| 2159 | char mybuf[64]; |
| 2160 | char *pbuf; |
| 2161 | int i; |
| 2162 | |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 2163 | memset(mybuf, 0, sizeof(mybuf)); |
| 2164 | |
| 2165 | if (copy_from_user(mybuf, buf, nbytes)) |
| 2166 | return -EFAULT; |
| 2167 | pbuf = &mybuf[0]; |
| 2168 | |
| 2169 | if ((strncmp(pbuf, "reset", strlen("reset")) == 0) || |
| 2170 | (strncmp(pbuf, "zero", strlen("zero")) == 0)) { |
| 2171 | for (i = 0; i < phba->cfg_hdw_queue; i++) { |
| 2172 | qp = &phba->sli4_hba.hdwq[i]; |
| 2173 | qp->lock_conflict.alloc_xri_get = 0; |
| 2174 | qp->lock_conflict.alloc_xri_put = 0; |
| 2175 | qp->lock_conflict.free_xri = 0; |
| 2176 | qp->lock_conflict.wq_access = 0; |
| 2177 | qp->lock_conflict.alloc_pvt_pool = 0; |
| 2178 | qp->lock_conflict.mv_from_pvt_pool = 0; |
| 2179 | qp->lock_conflict.mv_to_pub_pool = 0; |
| 2180 | qp->lock_conflict.mv_to_pvt_pool = 0; |
| 2181 | qp->lock_conflict.free_pvt_pool = 0; |
| 2182 | qp->lock_conflict.free_pub_pool = 0; |
| 2183 | qp->lock_conflict.wq_access = 0; |
| 2184 | } |
| 2185 | } |
| 2186 | return nbytes; |
| 2187 | } |
| 2188 | #endif |
| 2189 | |
YueHaibing | 7b10db5 | 2019-10-28 21:25:56 +0800 | [diff] [blame] | 2190 | static int lpfc_debugfs_ras_log_data(struct lpfc_hba *phba, |
| 2191 | char *buffer, int size) |
James Smart | 95bfc6d | 2019-10-18 14:18:27 -0700 | [diff] [blame] | 2192 | { |
| 2193 | int copied = 0; |
| 2194 | struct lpfc_dmabuf *dmabuf, *next; |
| 2195 | |
James Smart | 9a20cc1 | 2019-12-18 15:58:03 -0800 | [diff] [blame] | 2196 | memset(buffer, 0, size); |
| 2197 | |
James Smart | 95bfc6d | 2019-10-18 14:18:27 -0700 | [diff] [blame] | 2198 | spin_lock_irq(&phba->hbalock); |
| 2199 | if (phba->ras_fwlog.state != ACTIVE) { |
| 2200 | spin_unlock_irq(&phba->hbalock); |
| 2201 | return -EINVAL; |
| 2202 | } |
| 2203 | spin_unlock_irq(&phba->hbalock); |
| 2204 | |
| 2205 | list_for_each_entry_safe(dmabuf, next, |
| 2206 | &phba->ras_fwlog.fwlog_buff_list, list) { |
James Smart | 9a20cc1 | 2019-12-18 15:58:03 -0800 | [diff] [blame] | 2207 | /* Check if copying will go over size and a '\0' char */ |
| 2208 | if ((copied + LPFC_RAS_MAX_ENTRY_SIZE) >= (size - 1)) { |
| 2209 | memcpy(buffer + copied, dmabuf->virt, |
| 2210 | size - copied - 1); |
| 2211 | copied += size - copied - 1; |
| 2212 | break; |
| 2213 | } |
James Smart | 95bfc6d | 2019-10-18 14:18:27 -0700 | [diff] [blame] | 2214 | memcpy(buffer + copied, dmabuf->virt, LPFC_RAS_MAX_ENTRY_SIZE); |
| 2215 | copied += LPFC_RAS_MAX_ENTRY_SIZE; |
James Smart | 95bfc6d | 2019-10-18 14:18:27 -0700 | [diff] [blame] | 2216 | } |
| 2217 | return copied; |
| 2218 | } |
| 2219 | |
| 2220 | static int |
| 2221 | lpfc_debugfs_ras_log_release(struct inode *inode, struct file *file) |
| 2222 | { |
| 2223 | struct lpfc_debug *debug = file->private_data; |
| 2224 | |
| 2225 | vfree(debug->buffer); |
| 2226 | kfree(debug); |
| 2227 | |
| 2228 | return 0; |
| 2229 | } |
| 2230 | |
| 2231 | /** |
| 2232 | * lpfc_debugfs_ras_log_open - Open the RAS log debugfs buffer |
| 2233 | * @inode: The inode pointer that contains a vport pointer. |
| 2234 | * @file: The file pointer to attach the log output. |
| 2235 | * |
| 2236 | * Description: |
| 2237 | * This routine is the entry point for the debugfs open file operation. It gets |
| 2238 | * the vport from the i_private field in @inode, allocates the necessary buffer |
| 2239 | * for the log, fills the buffer from the in-memory log for this vport, and then |
| 2240 | * returns a pointer to that log in the private_data field in @file. |
| 2241 | * |
| 2242 | * Returns: |
| 2243 | * This function returns zero if successful. On error it will return a negative |
| 2244 | * error value. |
| 2245 | **/ |
| 2246 | static int |
| 2247 | lpfc_debugfs_ras_log_open(struct inode *inode, struct file *file) |
| 2248 | { |
| 2249 | struct lpfc_hba *phba = inode->i_private; |
| 2250 | struct lpfc_debug *debug; |
| 2251 | int size; |
| 2252 | int rc = -ENOMEM; |
| 2253 | |
| 2254 | spin_lock_irq(&phba->hbalock); |
| 2255 | if (phba->ras_fwlog.state != ACTIVE) { |
| 2256 | spin_unlock_irq(&phba->hbalock); |
| 2257 | rc = -EINVAL; |
| 2258 | goto out; |
| 2259 | } |
| 2260 | spin_unlock_irq(&phba->hbalock); |
| 2261 | debug = kmalloc(sizeof(*debug), GFP_KERNEL); |
| 2262 | if (!debug) |
| 2263 | goto out; |
| 2264 | |
| 2265 | size = LPFC_RAS_MIN_BUFF_POST_SIZE * phba->cfg_ras_fwlog_buffsize; |
| 2266 | debug->buffer = vmalloc(size); |
| 2267 | if (!debug->buffer) |
| 2268 | goto free_debug; |
| 2269 | |
| 2270 | debug->len = lpfc_debugfs_ras_log_data(phba, debug->buffer, size); |
| 2271 | if (debug->len < 0) { |
| 2272 | rc = -EINVAL; |
| 2273 | goto free_buffer; |
| 2274 | } |
| 2275 | file->private_data = debug; |
| 2276 | |
| 2277 | return 0; |
| 2278 | |
| 2279 | free_buffer: |
| 2280 | vfree(debug->buffer); |
| 2281 | free_debug: |
| 2282 | kfree(debug); |
| 2283 | out: |
| 2284 | return rc; |
| 2285 | } |
| 2286 | |
James Smart | 5e5b511 | 2019-01-28 11:14:22 -0800 | [diff] [blame] | 2287 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2288 | * lpfc_debugfs_dumpHBASlim_open - Open the Dump HBA SLIM debugfs buffer |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2289 | * @inode: The inode pointer that contains a vport pointer. |
| 2290 | * @file: The file pointer to attach the log output. |
| 2291 | * |
| 2292 | * Description: |
| 2293 | * This routine is the entry point for the debugfs open file operation. It gets |
| 2294 | * the vport from the i_private field in @inode, allocates the necessary buffer |
| 2295 | * for the log, fills the buffer from the in-memory log for this vport, and then |
| 2296 | * returns a pointer to that log in the private_data field in @file. |
| 2297 | * |
| 2298 | * Returns: |
Geert Uytterhoeven | 79ce48d | 2015-05-21 14:11:33 +0200 | [diff] [blame] | 2299 | * This function returns zero if successful. On error it will return a negative |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2300 | * error value. |
| 2301 | **/ |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 2302 | static int |
James Smart | c95d6c6 | 2008-01-11 01:53:23 -0500 | [diff] [blame] | 2303 | lpfc_debugfs_dumpHBASlim_open(struct inode *inode, struct file *file) |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 2304 | { |
| 2305 | struct lpfc_hba *phba = inode->i_private; |
| 2306 | struct lpfc_debug *debug; |
| 2307 | int rc = -ENOMEM; |
| 2308 | |
| 2309 | debug = kmalloc(sizeof(*debug), GFP_KERNEL); |
| 2310 | if (!debug) |
| 2311 | goto out; |
| 2312 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2313 | /* Round to page boundary */ |
James Smart | c95d6c6 | 2008-01-11 01:53:23 -0500 | [diff] [blame] | 2314 | debug->buffer = kmalloc(LPFC_DUMPHBASLIM_SIZE, GFP_KERNEL); |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 2315 | if (!debug->buffer) { |
| 2316 | kfree(debug); |
| 2317 | goto out; |
| 2318 | } |
| 2319 | |
James Smart | c95d6c6 | 2008-01-11 01:53:23 -0500 | [diff] [blame] | 2320 | debug->len = lpfc_debugfs_dumpHBASlim_data(phba, debug->buffer, |
| 2321 | LPFC_DUMPHBASLIM_SIZE); |
| 2322 | file->private_data = debug; |
| 2323 | |
| 2324 | rc = 0; |
| 2325 | out: |
| 2326 | return rc; |
| 2327 | } |
| 2328 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2329 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2330 | * lpfc_debugfs_dumpHostSlim_open - Open the Dump Host SLIM debugfs buffer |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2331 | * @inode: The inode pointer that contains a vport pointer. |
| 2332 | * @file: The file pointer to attach the log output. |
| 2333 | * |
| 2334 | * Description: |
| 2335 | * This routine is the entry point for the debugfs open file operation. It gets |
| 2336 | * the vport from the i_private field in @inode, allocates the necessary buffer |
| 2337 | * for the log, fills the buffer from the in-memory log for this vport, and then |
| 2338 | * returns a pointer to that log in the private_data field in @file. |
| 2339 | * |
| 2340 | * Returns: |
Geert Uytterhoeven | 79ce48d | 2015-05-21 14:11:33 +0200 | [diff] [blame] | 2341 | * This function returns zero if successful. On error it will return a negative |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2342 | * error value. |
| 2343 | **/ |
James Smart | c95d6c6 | 2008-01-11 01:53:23 -0500 | [diff] [blame] | 2344 | static int |
| 2345 | lpfc_debugfs_dumpHostSlim_open(struct inode *inode, struct file *file) |
| 2346 | { |
| 2347 | struct lpfc_hba *phba = inode->i_private; |
| 2348 | struct lpfc_debug *debug; |
| 2349 | int rc = -ENOMEM; |
| 2350 | |
| 2351 | debug = kmalloc(sizeof(*debug), GFP_KERNEL); |
| 2352 | if (!debug) |
| 2353 | goto out; |
| 2354 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2355 | /* Round to page boundary */ |
James Smart | c95d6c6 | 2008-01-11 01:53:23 -0500 | [diff] [blame] | 2356 | debug->buffer = kmalloc(LPFC_DUMPHOSTSLIM_SIZE, GFP_KERNEL); |
| 2357 | if (!debug->buffer) { |
| 2358 | kfree(debug); |
| 2359 | goto out; |
| 2360 | } |
| 2361 | |
| 2362 | debug->len = lpfc_debugfs_dumpHostSlim_data(phba, debug->buffer, |
| 2363 | LPFC_DUMPHOSTSLIM_SIZE); |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 2364 | file->private_data = debug; |
| 2365 | |
| 2366 | rc = 0; |
| 2367 | out: |
| 2368 | return rc; |
| 2369 | } |
| 2370 | |
James Smart | f9bb2da | 2011-10-10 21:34:11 -0400 | [diff] [blame] | 2371 | static ssize_t |
| 2372 | lpfc_debugfs_dif_err_read(struct file *file, char __user *buf, |
| 2373 | size_t nbytes, loff_t *ppos) |
| 2374 | { |
Al Viro | b583043 | 2014-10-31 01:22:04 -0400 | [diff] [blame] | 2375 | struct dentry *dent = file->f_path.dentry; |
James Smart | f9bb2da | 2011-10-10 21:34:11 -0400 | [diff] [blame] | 2376 | struct lpfc_hba *phba = file->private_data; |
James Smart | 9a6b09c | 2012-03-01 22:37:42 -0500 | [diff] [blame] | 2377 | char cbuf[32]; |
James Smart | 4ac9b22 | 2012-03-01 22:38:29 -0500 | [diff] [blame] | 2378 | uint64_t tmp = 0; |
James Smart | f9bb2da | 2011-10-10 21:34:11 -0400 | [diff] [blame] | 2379 | int cnt = 0; |
| 2380 | |
| 2381 | if (dent == phba->debug_writeGuard) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 2382 | cnt = scnprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_wgrd_cnt); |
James Smart | f9bb2da | 2011-10-10 21:34:11 -0400 | [diff] [blame] | 2383 | else if (dent == phba->debug_writeApp) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 2384 | cnt = scnprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_wapp_cnt); |
James Smart | f9bb2da | 2011-10-10 21:34:11 -0400 | [diff] [blame] | 2385 | else if (dent == phba->debug_writeRef) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 2386 | cnt = scnprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_wref_cnt); |
James Smart | acd6859 | 2012-01-18 16:25:09 -0500 | [diff] [blame] | 2387 | else if (dent == phba->debug_readGuard) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 2388 | cnt = scnprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_rgrd_cnt); |
James Smart | f9bb2da | 2011-10-10 21:34:11 -0400 | [diff] [blame] | 2389 | else if (dent == phba->debug_readApp) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 2390 | cnt = scnprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_rapp_cnt); |
James Smart | f9bb2da | 2011-10-10 21:34:11 -0400 | [diff] [blame] | 2391 | else if (dent == phba->debug_readRef) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 2392 | cnt = scnprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_rref_cnt); |
James Smart | 4ac9b22 | 2012-03-01 22:38:29 -0500 | [diff] [blame] | 2393 | else if (dent == phba->debug_InjErrNPortID) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 2394 | cnt = scnprintf(cbuf, 32, "0x%06x\n", |
| 2395 | phba->lpfc_injerr_nportid); |
James Smart | 4ac9b22 | 2012-03-01 22:38:29 -0500 | [diff] [blame] | 2396 | else if (dent == phba->debug_InjErrWWPN) { |
| 2397 | memcpy(&tmp, &phba->lpfc_injerr_wwpn, sizeof(struct lpfc_name)); |
| 2398 | tmp = cpu_to_be64(tmp); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 2399 | cnt = scnprintf(cbuf, 32, "0x%016llx\n", tmp); |
James Smart | 4ac9b22 | 2012-03-01 22:38:29 -0500 | [diff] [blame] | 2400 | } else if (dent == phba->debug_InjErrLBA) { |
| 2401 | if (phba->lpfc_injerr_lba == (sector_t)(-1)) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 2402 | cnt = scnprintf(cbuf, 32, "off\n"); |
James Smart | 9a6b09c | 2012-03-01 22:37:42 -0500 | [diff] [blame] | 2403 | else |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 2404 | cnt = scnprintf(cbuf, 32, "0x%llx\n", |
James Smart | 4ac9b22 | 2012-03-01 22:38:29 -0500 | [diff] [blame] | 2405 | (uint64_t) phba->lpfc_injerr_lba); |
James Smart | 9a6b09c | 2012-03-01 22:37:42 -0500 | [diff] [blame] | 2406 | } else |
James Smart | f9bb2da | 2011-10-10 21:34:11 -0400 | [diff] [blame] | 2407 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 2408 | "0547 Unknown debugfs error injection entry\n"); |
| 2409 | |
| 2410 | return simple_read_from_buffer(buf, nbytes, ppos, &cbuf, cnt); |
| 2411 | } |
| 2412 | |
| 2413 | static ssize_t |
| 2414 | lpfc_debugfs_dif_err_write(struct file *file, const char __user *buf, |
| 2415 | size_t nbytes, loff_t *ppos) |
| 2416 | { |
Al Viro | b583043 | 2014-10-31 01:22:04 -0400 | [diff] [blame] | 2417 | struct dentry *dent = file->f_path.dentry; |
James Smart | f9bb2da | 2011-10-10 21:34:11 -0400 | [diff] [blame] | 2418 | struct lpfc_hba *phba = file->private_data; |
Alan | 0872774d | 2016-02-15 19:11:56 +0000 | [diff] [blame] | 2419 | char dstbuf[33]; |
James Smart | 4ac9b22 | 2012-03-01 22:38:29 -0500 | [diff] [blame] | 2420 | uint64_t tmp = 0; |
James Smart | f9bb2da | 2011-10-10 21:34:11 -0400 | [diff] [blame] | 2421 | int size; |
| 2422 | |
Alan | 0872774d | 2016-02-15 19:11:56 +0000 | [diff] [blame] | 2423 | memset(dstbuf, 0, 33); |
James Smart | f9bb2da | 2011-10-10 21:34:11 -0400 | [diff] [blame] | 2424 | size = (nbytes < 32) ? nbytes : 32; |
| 2425 | if (copy_from_user(dstbuf, buf, size)) |
| 2426 | return 0; |
| 2427 | |
James Smart | 9a6b09c | 2012-03-01 22:37:42 -0500 | [diff] [blame] | 2428 | if (dent == phba->debug_InjErrLBA) { |
Dick Kennedy | a7fc071 | 2020-05-01 14:43:08 -0700 | [diff] [blame] | 2429 | if ((dstbuf[0] == 'o') && (dstbuf[1] == 'f') && |
| 2430 | (dstbuf[2] == 'f')) |
James Smart | 4ac9b22 | 2012-03-01 22:38:29 -0500 | [diff] [blame] | 2431 | tmp = (uint64_t)(-1); |
James Smart | 9a6b09c | 2012-03-01 22:37:42 -0500 | [diff] [blame] | 2432 | } |
| 2433 | |
James Smart | 4ac9b22 | 2012-03-01 22:38:29 -0500 | [diff] [blame] | 2434 | if ((tmp == 0) && (kstrtoull(dstbuf, 0, &tmp))) |
James Smart | f9bb2da | 2011-10-10 21:34:11 -0400 | [diff] [blame] | 2435 | return 0; |
| 2436 | |
| 2437 | if (dent == phba->debug_writeGuard) |
| 2438 | phba->lpfc_injerr_wgrd_cnt = (uint32_t)tmp; |
| 2439 | else if (dent == phba->debug_writeApp) |
| 2440 | phba->lpfc_injerr_wapp_cnt = (uint32_t)tmp; |
| 2441 | else if (dent == phba->debug_writeRef) |
| 2442 | phba->lpfc_injerr_wref_cnt = (uint32_t)tmp; |
James Smart | acd6859 | 2012-01-18 16:25:09 -0500 | [diff] [blame] | 2443 | else if (dent == phba->debug_readGuard) |
| 2444 | phba->lpfc_injerr_rgrd_cnt = (uint32_t)tmp; |
James Smart | f9bb2da | 2011-10-10 21:34:11 -0400 | [diff] [blame] | 2445 | else if (dent == phba->debug_readApp) |
| 2446 | phba->lpfc_injerr_rapp_cnt = (uint32_t)tmp; |
| 2447 | else if (dent == phba->debug_readRef) |
| 2448 | phba->lpfc_injerr_rref_cnt = (uint32_t)tmp; |
| 2449 | else if (dent == phba->debug_InjErrLBA) |
| 2450 | phba->lpfc_injerr_lba = (sector_t)tmp; |
James Smart | 4ac9b22 | 2012-03-01 22:38:29 -0500 | [diff] [blame] | 2451 | else if (dent == phba->debug_InjErrNPortID) |
| 2452 | phba->lpfc_injerr_nportid = (uint32_t)(tmp & Mask_DID); |
| 2453 | else if (dent == phba->debug_InjErrWWPN) { |
| 2454 | tmp = cpu_to_be64(tmp); |
| 2455 | memcpy(&phba->lpfc_injerr_wwpn, &tmp, sizeof(struct lpfc_name)); |
| 2456 | } else |
James Smart | f9bb2da | 2011-10-10 21:34:11 -0400 | [diff] [blame] | 2457 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 2458 | "0548 Unknown debugfs error injection entry\n"); |
| 2459 | |
| 2460 | return nbytes; |
| 2461 | } |
| 2462 | |
| 2463 | static int |
| 2464 | lpfc_debugfs_dif_err_release(struct inode *inode, struct file *file) |
| 2465 | { |
| 2466 | return 0; |
| 2467 | } |
| 2468 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2469 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2470 | * lpfc_debugfs_nodelist_open - Open the nodelist debugfs file |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2471 | * @inode: The inode pointer that contains a vport pointer. |
| 2472 | * @file: The file pointer to attach the log output. |
| 2473 | * |
| 2474 | * Description: |
| 2475 | * This routine is the entry point for the debugfs open file operation. It gets |
| 2476 | * the vport from the i_private field in @inode, allocates the necessary buffer |
| 2477 | * for the log, fills the buffer from the in-memory log for this vport, and then |
| 2478 | * returns a pointer to that log in the private_data field in @file. |
| 2479 | * |
| 2480 | * Returns: |
Geert Uytterhoeven | 79ce48d | 2015-05-21 14:11:33 +0200 | [diff] [blame] | 2481 | * This function returns zero if successful. On error it will return a negative |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2482 | * error value. |
| 2483 | **/ |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 2484 | static int |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2485 | lpfc_debugfs_nodelist_open(struct inode *inode, struct file *file) |
| 2486 | { |
| 2487 | struct lpfc_vport *vport = inode->i_private; |
| 2488 | struct lpfc_debug *debug; |
| 2489 | int rc = -ENOMEM; |
| 2490 | |
| 2491 | debug = kmalloc(sizeof(*debug), GFP_KERNEL); |
| 2492 | if (!debug) |
| 2493 | goto out; |
| 2494 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2495 | /* Round to page boundary */ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2496 | debug->buffer = kmalloc(LPFC_NODELIST_SIZE, GFP_KERNEL); |
| 2497 | if (!debug->buffer) { |
| 2498 | kfree(debug); |
| 2499 | goto out; |
| 2500 | } |
| 2501 | |
| 2502 | debug->len = lpfc_debugfs_nodelist_data(vport, debug->buffer, |
| 2503 | LPFC_NODELIST_SIZE); |
| 2504 | file->private_data = debug; |
| 2505 | |
| 2506 | rc = 0; |
| 2507 | out: |
| 2508 | return rc; |
| 2509 | } |
| 2510 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2511 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2512 | * lpfc_debugfs_lseek - Seek through a debugfs file |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2513 | * @file: The file pointer to seek through. |
| 2514 | * @off: The offset to seek to or the amount to seek by. |
| 2515 | * @whence: Indicates how to seek. |
| 2516 | * |
| 2517 | * Description: |
| 2518 | * This routine is the entry point for the debugfs lseek file operation. The |
| 2519 | * @whence parameter indicates whether @off is the offset to directly seek to, |
| 2520 | * or if it is a value to seek forward or reverse by. This function figures out |
| 2521 | * what the new offset of the debugfs file will be and assigns that value to the |
| 2522 | * f_pos field of @file. |
| 2523 | * |
| 2524 | * Returns: |
| 2525 | * This function returns the new offset if successful and returns a negative |
| 2526 | * error if unable to process the seek. |
| 2527 | **/ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2528 | static loff_t |
| 2529 | lpfc_debugfs_lseek(struct file *file, loff_t off, int whence) |
| 2530 | { |
Al Viro | 7233c77 | 2013-06-23 12:08:05 +0400 | [diff] [blame] | 2531 | struct lpfc_debug *debug = file->private_data; |
| 2532 | return fixed_size_llseek(file, off, whence, debug->len); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2533 | } |
| 2534 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2535 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2536 | * lpfc_debugfs_read - Read a debugfs file |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2537 | * @file: The file pointer to read from. |
| 2538 | * @buf: The buffer to copy the data to. |
| 2539 | * @nbytes: The number of bytes to read. |
| 2540 | * @ppos: The position in the file to start reading from. |
| 2541 | * |
| 2542 | * Description: |
| 2543 | * This routine reads data from from the buffer indicated in the private_data |
| 2544 | * field of @file. It will start reading at @ppos and copy up to @nbytes of |
| 2545 | * data to @buf. |
| 2546 | * |
| 2547 | * Returns: |
| 2548 | * This function returns the amount of data that was read (this could be less |
| 2549 | * than @nbytes if the end of the file was reached) or a negative error value. |
| 2550 | **/ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2551 | static ssize_t |
| 2552 | lpfc_debugfs_read(struct file *file, char __user *buf, |
| 2553 | size_t nbytes, loff_t *ppos) |
| 2554 | { |
| 2555 | struct lpfc_debug *debug = file->private_data; |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 2556 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2557 | return simple_read_from_buffer(buf, nbytes, ppos, debug->buffer, |
| 2558 | debug->len); |
| 2559 | } |
| 2560 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2561 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2562 | * lpfc_debugfs_release - Release the buffer used to store debugfs file data |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2563 | * @inode: The inode pointer that contains a vport pointer. (unused) |
| 2564 | * @file: The file pointer that contains the buffer to release. |
| 2565 | * |
| 2566 | * Description: |
| 2567 | * This routine frees the buffer that was allocated when the debugfs file was |
| 2568 | * opened. |
| 2569 | * |
| 2570 | * Returns: |
| 2571 | * This function returns zero. |
| 2572 | **/ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2573 | static int |
| 2574 | lpfc_debugfs_release(struct inode *inode, struct file *file) |
| 2575 | { |
| 2576 | struct lpfc_debug *debug = file->private_data; |
| 2577 | |
| 2578 | kfree(debug->buffer); |
| 2579 | kfree(debug); |
| 2580 | |
| 2581 | return 0; |
| 2582 | } |
| 2583 | |
James Smart | c490850 | 2019-01-28 11:14:28 -0800 | [diff] [blame] | 2584 | /** |
| 2585 | * lpfc_debugfs_multixripools_write - Clear multi-XRI pools statistics |
| 2586 | * @file: The file pointer to read from. |
| 2587 | * @buf: The buffer to copy the user data from. |
| 2588 | * @nbytes: The number of bytes to get. |
| 2589 | * @ppos: The position in the file to start reading from. |
| 2590 | * |
| 2591 | * Description: |
| 2592 | * This routine clears multi-XRI pools statistics when buf contains "clear". |
| 2593 | * |
| 2594 | * Return Value: |
| 2595 | * It returns the @nbytges passing in from debugfs user space when successful. |
| 2596 | * In case of error conditions, it returns proper error code back to the user |
| 2597 | * space. |
| 2598 | **/ |
| 2599 | static ssize_t |
| 2600 | lpfc_debugfs_multixripools_write(struct file *file, const char __user *buf, |
| 2601 | size_t nbytes, loff_t *ppos) |
| 2602 | { |
| 2603 | struct lpfc_debug *debug = file->private_data; |
| 2604 | struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private; |
| 2605 | char mybuf[64]; |
| 2606 | char *pbuf; |
| 2607 | u32 i; |
| 2608 | u32 hwq_count; |
| 2609 | struct lpfc_sli4_hdw_queue *qp; |
| 2610 | struct lpfc_multixri_pool *multixri_pool; |
| 2611 | |
| 2612 | if (nbytes > 64) |
| 2613 | nbytes = 64; |
| 2614 | |
James Smart | c490850 | 2019-01-28 11:14:28 -0800 | [diff] [blame] | 2615 | memset(mybuf, 0, sizeof(mybuf)); |
| 2616 | |
| 2617 | if (copy_from_user(mybuf, buf, nbytes)) |
| 2618 | return -EFAULT; |
| 2619 | pbuf = &mybuf[0]; |
| 2620 | |
| 2621 | if ((strncmp(pbuf, "clear", strlen("clear"))) == 0) { |
| 2622 | hwq_count = phba->cfg_hdw_queue; |
| 2623 | for (i = 0; i < hwq_count; i++) { |
| 2624 | qp = &phba->sli4_hba.hdwq[i]; |
| 2625 | multixri_pool = qp->p_multixri_pool; |
| 2626 | if (!multixri_pool) |
| 2627 | continue; |
| 2628 | |
| 2629 | qp->empty_io_bufs = 0; |
| 2630 | multixri_pool->pbl_empty_count = 0; |
| 2631 | #ifdef LPFC_MXP_STAT |
| 2632 | multixri_pool->above_limit_count = 0; |
| 2633 | multixri_pool->below_limit_count = 0; |
| 2634 | multixri_pool->stat_max_hwm = 0; |
| 2635 | multixri_pool->local_pbl_hit_count = 0; |
| 2636 | multixri_pool->other_pbl_hit_count = 0; |
| 2637 | |
| 2638 | multixri_pool->stat_pbl_count = 0; |
| 2639 | multixri_pool->stat_pvt_count = 0; |
| 2640 | multixri_pool->stat_busy_count = 0; |
| 2641 | multixri_pool->stat_snapshot_taken = 0; |
| 2642 | #endif |
| 2643 | } |
| 2644 | return strlen(pbuf); |
| 2645 | } |
| 2646 | |
| 2647 | return -EINVAL; |
| 2648 | } |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 2649 | |
| 2650 | static int |
| 2651 | lpfc_debugfs_nvmestat_open(struct inode *inode, struct file *file) |
| 2652 | { |
| 2653 | struct lpfc_vport *vport = inode->i_private; |
| 2654 | struct lpfc_debug *debug; |
| 2655 | int rc = -ENOMEM; |
| 2656 | |
| 2657 | debug = kmalloc(sizeof(*debug), GFP_KERNEL); |
| 2658 | if (!debug) |
| 2659 | goto out; |
| 2660 | |
| 2661 | /* Round to page boundary */ |
| 2662 | debug->buffer = kmalloc(LPFC_NVMESTAT_SIZE, GFP_KERNEL); |
| 2663 | if (!debug->buffer) { |
| 2664 | kfree(debug); |
| 2665 | goto out; |
| 2666 | } |
| 2667 | |
| 2668 | debug->len = lpfc_debugfs_nvmestat_data(vport, debug->buffer, |
| 2669 | LPFC_NVMESTAT_SIZE); |
| 2670 | |
| 2671 | debug->i_private = inode->i_private; |
| 2672 | file->private_data = debug; |
| 2673 | |
| 2674 | rc = 0; |
| 2675 | out: |
| 2676 | return rc; |
| 2677 | } |
| 2678 | |
James Smart | 2b65e18 | 2017-02-12 13:52:38 -0800 | [diff] [blame] | 2679 | static ssize_t |
| 2680 | lpfc_debugfs_nvmestat_write(struct file *file, const char __user *buf, |
| 2681 | size_t nbytes, loff_t *ppos) |
| 2682 | { |
| 2683 | struct lpfc_debug *debug = file->private_data; |
| 2684 | struct lpfc_vport *vport = (struct lpfc_vport *)debug->i_private; |
| 2685 | struct lpfc_hba *phba = vport->phba; |
| 2686 | struct lpfc_nvmet_tgtport *tgtp; |
| 2687 | char mybuf[64]; |
| 2688 | char *pbuf; |
| 2689 | |
| 2690 | if (!phba->targetport) |
| 2691 | return -ENXIO; |
| 2692 | |
| 2693 | if (nbytes > 64) |
| 2694 | nbytes = 64; |
| 2695 | |
James Smart | 2b65e18 | 2017-02-12 13:52:38 -0800 | [diff] [blame] | 2696 | memset(mybuf, 0, sizeof(mybuf)); |
| 2697 | |
| 2698 | if (copy_from_user(mybuf, buf, nbytes)) |
| 2699 | return -EFAULT; |
| 2700 | pbuf = &mybuf[0]; |
| 2701 | |
| 2702 | tgtp = (struct lpfc_nvmet_tgtport *)phba->targetport->private; |
| 2703 | if ((strncmp(pbuf, "reset", strlen("reset")) == 0) || |
| 2704 | (strncmp(pbuf, "zero", strlen("zero")) == 0)) { |
| 2705 | atomic_set(&tgtp->rcv_ls_req_in, 0); |
| 2706 | atomic_set(&tgtp->rcv_ls_req_out, 0); |
| 2707 | atomic_set(&tgtp->rcv_ls_req_drop, 0); |
| 2708 | atomic_set(&tgtp->xmt_ls_abort, 0); |
James Smart | 547077a | 2017-05-15 15:20:40 -0700 | [diff] [blame] | 2709 | atomic_set(&tgtp->xmt_ls_abort_cmpl, 0); |
James Smart | 2b65e18 | 2017-02-12 13:52:38 -0800 | [diff] [blame] | 2710 | atomic_set(&tgtp->xmt_ls_rsp, 0); |
| 2711 | atomic_set(&tgtp->xmt_ls_drop, 0); |
| 2712 | atomic_set(&tgtp->xmt_ls_rsp_error, 0); |
| 2713 | atomic_set(&tgtp->xmt_ls_rsp_cmpl, 0); |
| 2714 | |
| 2715 | atomic_set(&tgtp->rcv_fcp_cmd_in, 0); |
| 2716 | atomic_set(&tgtp->rcv_fcp_cmd_out, 0); |
| 2717 | atomic_set(&tgtp->rcv_fcp_cmd_drop, 0); |
James Smart | 2b65e18 | 2017-02-12 13:52:38 -0800 | [diff] [blame] | 2718 | atomic_set(&tgtp->xmt_fcp_drop, 0); |
| 2719 | atomic_set(&tgtp->xmt_fcp_read_rsp, 0); |
| 2720 | atomic_set(&tgtp->xmt_fcp_read, 0); |
| 2721 | atomic_set(&tgtp->xmt_fcp_write, 0); |
| 2722 | atomic_set(&tgtp->xmt_fcp_rsp, 0); |
James Smart | 547077a | 2017-05-15 15:20:40 -0700 | [diff] [blame] | 2723 | atomic_set(&tgtp->xmt_fcp_release, 0); |
James Smart | 2b65e18 | 2017-02-12 13:52:38 -0800 | [diff] [blame] | 2724 | atomic_set(&tgtp->xmt_fcp_rsp_cmpl, 0); |
| 2725 | atomic_set(&tgtp->xmt_fcp_rsp_error, 0); |
| 2726 | atomic_set(&tgtp->xmt_fcp_rsp_drop, 0); |
| 2727 | |
James Smart | 547077a | 2017-05-15 15:20:40 -0700 | [diff] [blame] | 2728 | atomic_set(&tgtp->xmt_fcp_abort, 0); |
| 2729 | atomic_set(&tgtp->xmt_fcp_abort_cmpl, 0); |
| 2730 | atomic_set(&tgtp->xmt_abort_sol, 0); |
| 2731 | atomic_set(&tgtp->xmt_abort_unsol, 0); |
James Smart | 2b65e18 | 2017-02-12 13:52:38 -0800 | [diff] [blame] | 2732 | atomic_set(&tgtp->xmt_abort_rsp, 0); |
| 2733 | atomic_set(&tgtp->xmt_abort_rsp_error, 0); |
James Smart | 2b65e18 | 2017-02-12 13:52:38 -0800 | [diff] [blame] | 2734 | } |
| 2735 | return nbytes; |
| 2736 | } |
| 2737 | |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 2738 | static int |
James Smart | 4c47efc | 2019-01-28 11:14:25 -0800 | [diff] [blame] | 2739 | lpfc_debugfs_scsistat_open(struct inode *inode, struct file *file) |
| 2740 | { |
| 2741 | struct lpfc_vport *vport = inode->i_private; |
| 2742 | struct lpfc_debug *debug; |
| 2743 | int rc = -ENOMEM; |
| 2744 | |
| 2745 | debug = kmalloc(sizeof(*debug), GFP_KERNEL); |
| 2746 | if (!debug) |
| 2747 | goto out; |
| 2748 | |
| 2749 | /* Round to page boundary */ |
| 2750 | debug->buffer = kzalloc(LPFC_SCSISTAT_SIZE, GFP_KERNEL); |
| 2751 | if (!debug->buffer) { |
| 2752 | kfree(debug); |
| 2753 | goto out; |
| 2754 | } |
| 2755 | |
| 2756 | debug->len = lpfc_debugfs_scsistat_data(vport, debug->buffer, |
| 2757 | LPFC_SCSISTAT_SIZE); |
| 2758 | |
| 2759 | debug->i_private = inode->i_private; |
| 2760 | file->private_data = debug; |
| 2761 | |
| 2762 | rc = 0; |
| 2763 | out: |
| 2764 | return rc; |
| 2765 | } |
| 2766 | |
| 2767 | static ssize_t |
| 2768 | lpfc_debugfs_scsistat_write(struct file *file, const char __user *buf, |
| 2769 | size_t nbytes, loff_t *ppos) |
| 2770 | { |
| 2771 | struct lpfc_debug *debug = file->private_data; |
| 2772 | struct lpfc_vport *vport = (struct lpfc_vport *)debug->i_private; |
| 2773 | struct lpfc_hba *phba = vport->phba; |
| 2774 | char mybuf[6] = {0}; |
| 2775 | int i; |
| 2776 | |
James Smart | 4c47efc | 2019-01-28 11:14:25 -0800 | [diff] [blame] | 2777 | if (copy_from_user(mybuf, buf, (nbytes >= sizeof(mybuf)) ? |
| 2778 | (sizeof(mybuf) - 1) : nbytes)) |
| 2779 | return -EFAULT; |
| 2780 | |
| 2781 | if ((strncmp(&mybuf[0], "reset", strlen("reset")) == 0) || |
| 2782 | (strncmp(&mybuf[0], "zero", strlen("zero")) == 0)) { |
| 2783 | for (i = 0; i < phba->cfg_hdw_queue; i++) { |
| 2784 | memset(&phba->sli4_hba.hdwq[i].scsi_cstat, 0, |
| 2785 | sizeof(phba->sli4_hba.hdwq[i].scsi_cstat)); |
| 2786 | } |
| 2787 | } |
| 2788 | |
| 2789 | return nbytes; |
| 2790 | } |
| 2791 | |
| 2792 | static int |
James Smart | 2fcbc56 | 2020-03-22 11:13:02 -0700 | [diff] [blame] | 2793 | lpfc_debugfs_ioktime_open(struct inode *inode, struct file *file) |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 2794 | { |
| 2795 | struct lpfc_vport *vport = inode->i_private; |
| 2796 | struct lpfc_debug *debug; |
| 2797 | int rc = -ENOMEM; |
| 2798 | |
| 2799 | debug = kmalloc(sizeof(*debug), GFP_KERNEL); |
| 2800 | if (!debug) |
| 2801 | goto out; |
| 2802 | |
| 2803 | /* Round to page boundary */ |
James Smart | 2fcbc56 | 2020-03-22 11:13:02 -0700 | [diff] [blame] | 2804 | debug->buffer = kmalloc(LPFC_IOKTIME_SIZE, GFP_KERNEL); |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 2805 | if (!debug->buffer) { |
| 2806 | kfree(debug); |
| 2807 | goto out; |
| 2808 | } |
| 2809 | |
James Smart | 2fcbc56 | 2020-03-22 11:13:02 -0700 | [diff] [blame] | 2810 | debug->len = lpfc_debugfs_ioktime_data(vport, debug->buffer, |
| 2811 | LPFC_IOKTIME_SIZE); |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 2812 | |
| 2813 | debug->i_private = inode->i_private; |
| 2814 | file->private_data = debug; |
| 2815 | |
| 2816 | rc = 0; |
| 2817 | out: |
| 2818 | return rc; |
| 2819 | } |
| 2820 | |
| 2821 | static ssize_t |
James Smart | 2fcbc56 | 2020-03-22 11:13:02 -0700 | [diff] [blame] | 2822 | lpfc_debugfs_ioktime_write(struct file *file, const char __user *buf, |
| 2823 | size_t nbytes, loff_t *ppos) |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 2824 | { |
| 2825 | struct lpfc_debug *debug = file->private_data; |
| 2826 | struct lpfc_vport *vport = (struct lpfc_vport *)debug->i_private; |
| 2827 | struct lpfc_hba *phba = vport->phba; |
| 2828 | char mybuf[64]; |
| 2829 | char *pbuf; |
| 2830 | |
| 2831 | if (nbytes > 64) |
| 2832 | nbytes = 64; |
| 2833 | |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 2834 | memset(mybuf, 0, sizeof(mybuf)); |
| 2835 | |
| 2836 | if (copy_from_user(mybuf, buf, nbytes)) |
| 2837 | return -EFAULT; |
| 2838 | pbuf = &mybuf[0]; |
| 2839 | |
| 2840 | if ((strncmp(pbuf, "on", sizeof("on") - 1) == 0)) { |
| 2841 | phba->ktime_data_samples = 0; |
| 2842 | phba->ktime_status_samples = 0; |
| 2843 | phba->ktime_seg1_total = 0; |
| 2844 | phba->ktime_seg1_max = 0; |
| 2845 | phba->ktime_seg1_min = 0xffffffff; |
| 2846 | phba->ktime_seg2_total = 0; |
| 2847 | phba->ktime_seg2_max = 0; |
| 2848 | phba->ktime_seg2_min = 0xffffffff; |
| 2849 | phba->ktime_seg3_total = 0; |
| 2850 | phba->ktime_seg3_max = 0; |
| 2851 | phba->ktime_seg3_min = 0xffffffff; |
| 2852 | phba->ktime_seg4_total = 0; |
| 2853 | phba->ktime_seg4_max = 0; |
| 2854 | phba->ktime_seg4_min = 0xffffffff; |
| 2855 | phba->ktime_seg5_total = 0; |
| 2856 | phba->ktime_seg5_max = 0; |
| 2857 | phba->ktime_seg5_min = 0xffffffff; |
| 2858 | phba->ktime_seg6_total = 0; |
| 2859 | phba->ktime_seg6_max = 0; |
| 2860 | phba->ktime_seg6_min = 0xffffffff; |
| 2861 | phba->ktime_seg7_total = 0; |
| 2862 | phba->ktime_seg7_max = 0; |
| 2863 | phba->ktime_seg7_min = 0xffffffff; |
| 2864 | phba->ktime_seg8_total = 0; |
| 2865 | phba->ktime_seg8_max = 0; |
| 2866 | phba->ktime_seg8_min = 0xffffffff; |
| 2867 | phba->ktime_seg9_total = 0; |
| 2868 | phba->ktime_seg9_max = 0; |
| 2869 | phba->ktime_seg9_min = 0xffffffff; |
| 2870 | phba->ktime_seg10_total = 0; |
| 2871 | phba->ktime_seg10_max = 0; |
| 2872 | phba->ktime_seg10_min = 0xffffffff; |
| 2873 | |
| 2874 | phba->ktime_on = 1; |
| 2875 | return strlen(pbuf); |
| 2876 | } else if ((strncmp(pbuf, "off", |
| 2877 | sizeof("off") - 1) == 0)) { |
| 2878 | phba->ktime_on = 0; |
| 2879 | return strlen(pbuf); |
| 2880 | } else if ((strncmp(pbuf, "zero", |
| 2881 | sizeof("zero") - 1) == 0)) { |
| 2882 | phba->ktime_data_samples = 0; |
| 2883 | phba->ktime_status_samples = 0; |
| 2884 | phba->ktime_seg1_total = 0; |
| 2885 | phba->ktime_seg1_max = 0; |
| 2886 | phba->ktime_seg1_min = 0xffffffff; |
| 2887 | phba->ktime_seg2_total = 0; |
| 2888 | phba->ktime_seg2_max = 0; |
| 2889 | phba->ktime_seg2_min = 0xffffffff; |
| 2890 | phba->ktime_seg3_total = 0; |
| 2891 | phba->ktime_seg3_max = 0; |
| 2892 | phba->ktime_seg3_min = 0xffffffff; |
| 2893 | phba->ktime_seg4_total = 0; |
| 2894 | phba->ktime_seg4_max = 0; |
| 2895 | phba->ktime_seg4_min = 0xffffffff; |
| 2896 | phba->ktime_seg5_total = 0; |
| 2897 | phba->ktime_seg5_max = 0; |
| 2898 | phba->ktime_seg5_min = 0xffffffff; |
| 2899 | phba->ktime_seg6_total = 0; |
| 2900 | phba->ktime_seg6_max = 0; |
| 2901 | phba->ktime_seg6_min = 0xffffffff; |
| 2902 | phba->ktime_seg7_total = 0; |
| 2903 | phba->ktime_seg7_max = 0; |
| 2904 | phba->ktime_seg7_min = 0xffffffff; |
| 2905 | phba->ktime_seg8_total = 0; |
| 2906 | phba->ktime_seg8_max = 0; |
| 2907 | phba->ktime_seg8_min = 0xffffffff; |
| 2908 | phba->ktime_seg9_total = 0; |
| 2909 | phba->ktime_seg9_max = 0; |
| 2910 | phba->ktime_seg9_min = 0xffffffff; |
| 2911 | phba->ktime_seg10_total = 0; |
| 2912 | phba->ktime_seg10_max = 0; |
| 2913 | phba->ktime_seg10_min = 0xffffffff; |
| 2914 | return strlen(pbuf); |
| 2915 | } |
| 2916 | return -EINVAL; |
| 2917 | } |
| 2918 | |
| 2919 | static int |
| 2920 | lpfc_debugfs_nvmeio_trc_open(struct inode *inode, struct file *file) |
| 2921 | { |
| 2922 | struct lpfc_hba *phba = inode->i_private; |
| 2923 | struct lpfc_debug *debug; |
| 2924 | int rc = -ENOMEM; |
| 2925 | |
| 2926 | debug = kmalloc(sizeof(*debug), GFP_KERNEL); |
| 2927 | if (!debug) |
| 2928 | goto out; |
| 2929 | |
| 2930 | /* Round to page boundary */ |
| 2931 | debug->buffer = kmalloc(LPFC_NVMEIO_TRC_SIZE, GFP_KERNEL); |
| 2932 | if (!debug->buffer) { |
| 2933 | kfree(debug); |
| 2934 | goto out; |
| 2935 | } |
| 2936 | |
| 2937 | debug->len = lpfc_debugfs_nvmeio_trc_data(phba, debug->buffer, |
| 2938 | LPFC_NVMEIO_TRC_SIZE); |
| 2939 | |
| 2940 | debug->i_private = inode->i_private; |
| 2941 | file->private_data = debug; |
| 2942 | |
| 2943 | rc = 0; |
| 2944 | out: |
| 2945 | return rc; |
| 2946 | } |
| 2947 | |
| 2948 | static ssize_t |
| 2949 | lpfc_debugfs_nvmeio_trc_write(struct file *file, const char __user *buf, |
| 2950 | size_t nbytes, loff_t *ppos) |
| 2951 | { |
| 2952 | struct lpfc_debug *debug = file->private_data; |
| 2953 | struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private; |
| 2954 | int i; |
| 2955 | unsigned long sz; |
| 2956 | char mybuf[64]; |
| 2957 | char *pbuf; |
| 2958 | |
| 2959 | if (nbytes > 64) |
| 2960 | nbytes = 64; |
| 2961 | |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 2962 | memset(mybuf, 0, sizeof(mybuf)); |
| 2963 | |
| 2964 | if (copy_from_user(mybuf, buf, nbytes)) |
| 2965 | return -EFAULT; |
| 2966 | pbuf = &mybuf[0]; |
| 2967 | |
| 2968 | if ((strncmp(pbuf, "off", sizeof("off") - 1) == 0)) { |
| 2969 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 2970 | "0570 nvmeio_trc_off\n"); |
| 2971 | phba->nvmeio_trc_output_idx = 0; |
| 2972 | phba->nvmeio_trc_on = 0; |
| 2973 | return strlen(pbuf); |
| 2974 | } else if ((strncmp(pbuf, "on", sizeof("on") - 1) == 0)) { |
| 2975 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 2976 | "0571 nvmeio_trc_on\n"); |
| 2977 | phba->nvmeio_trc_output_idx = 0; |
| 2978 | phba->nvmeio_trc_on = 1; |
| 2979 | return strlen(pbuf); |
| 2980 | } |
| 2981 | |
| 2982 | /* We must be off to allocate the trace buffer */ |
| 2983 | if (phba->nvmeio_trc_on != 0) |
| 2984 | return -EINVAL; |
| 2985 | |
| 2986 | /* If not on or off, the parameter is the trace buffer size */ |
| 2987 | i = kstrtoul(pbuf, 0, &sz); |
| 2988 | if (i) |
| 2989 | return -EINVAL; |
| 2990 | phba->nvmeio_trc_size = (uint32_t)sz; |
| 2991 | |
| 2992 | /* It must be a power of 2 - round down */ |
| 2993 | i = 0; |
| 2994 | while (sz > 1) { |
| 2995 | sz = sz >> 1; |
| 2996 | i++; |
| 2997 | } |
| 2998 | sz = (1 << i); |
| 2999 | if (phba->nvmeio_trc_size != sz) |
| 3000 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 3001 | "0572 nvmeio_trc_size changed to %ld\n", |
| 3002 | sz); |
| 3003 | phba->nvmeio_trc_size = (uint32_t)sz; |
| 3004 | |
| 3005 | /* If one previously exists, free it */ |
| 3006 | kfree(phba->nvmeio_trc); |
| 3007 | |
| 3008 | /* Allocate new trace buffer and initialize */ |
Vasyl Gomonovych | 1c356ec | 2017-10-11 21:42:41 +0200 | [diff] [blame] | 3009 | phba->nvmeio_trc = kzalloc((sizeof(struct lpfc_debugfs_nvmeio_trc) * |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 3010 | sz), GFP_KERNEL); |
| 3011 | if (!phba->nvmeio_trc) { |
| 3012 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 3013 | "0573 Cannot create debugfs " |
| 3014 | "nvmeio_trc buffer\n"); |
| 3015 | return -ENOMEM; |
| 3016 | } |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 3017 | atomic_set(&phba->nvmeio_trc_cnt, 0); |
| 3018 | phba->nvmeio_trc_on = 0; |
| 3019 | phba->nvmeio_trc_output_idx = 0; |
| 3020 | |
| 3021 | return strlen(pbuf); |
| 3022 | } |
| 3023 | |
| 3024 | static int |
James Smart | 840eda9 | 2020-03-22 11:13:00 -0700 | [diff] [blame] | 3025 | lpfc_debugfs_hdwqstat_open(struct inode *inode, struct file *file) |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 3026 | { |
| 3027 | struct lpfc_vport *vport = inode->i_private; |
| 3028 | struct lpfc_debug *debug; |
| 3029 | int rc = -ENOMEM; |
| 3030 | |
| 3031 | debug = kmalloc(sizeof(*debug), GFP_KERNEL); |
| 3032 | if (!debug) |
| 3033 | goto out; |
| 3034 | |
| 3035 | /* Round to page boundary */ |
James Smart | 840eda9 | 2020-03-22 11:13:00 -0700 | [diff] [blame] | 3036 | debug->buffer = kcalloc(1, LPFC_SCSISTAT_SIZE, GFP_KERNEL); |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 3037 | if (!debug->buffer) { |
| 3038 | kfree(debug); |
| 3039 | goto out; |
| 3040 | } |
| 3041 | |
James Smart | 840eda9 | 2020-03-22 11:13:00 -0700 | [diff] [blame] | 3042 | debug->len = lpfc_debugfs_hdwqstat_data(vport, debug->buffer, |
| 3043 | LPFC_SCSISTAT_SIZE); |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 3044 | |
| 3045 | debug->i_private = inode->i_private; |
| 3046 | file->private_data = debug; |
| 3047 | |
| 3048 | rc = 0; |
| 3049 | out: |
| 3050 | return rc; |
| 3051 | } |
| 3052 | |
| 3053 | static ssize_t |
James Smart | 840eda9 | 2020-03-22 11:13:00 -0700 | [diff] [blame] | 3054 | lpfc_debugfs_hdwqstat_write(struct file *file, const char __user *buf, |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 3055 | size_t nbytes, loff_t *ppos) |
| 3056 | { |
| 3057 | struct lpfc_debug *debug = file->private_data; |
| 3058 | struct lpfc_vport *vport = (struct lpfc_vport *)debug->i_private; |
| 3059 | struct lpfc_hba *phba = vport->phba; |
James Smart | 840eda9 | 2020-03-22 11:13:00 -0700 | [diff] [blame] | 3060 | struct lpfc_hdwq_stat *c_stat; |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 3061 | char mybuf[64]; |
| 3062 | char *pbuf; |
James Smart | 840eda9 | 2020-03-22 11:13:00 -0700 | [diff] [blame] | 3063 | int i; |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 3064 | |
| 3065 | if (nbytes > 64) |
| 3066 | nbytes = 64; |
| 3067 | |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 3068 | memset(mybuf, 0, sizeof(mybuf)); |
| 3069 | |
| 3070 | if (copy_from_user(mybuf, buf, nbytes)) |
| 3071 | return -EFAULT; |
| 3072 | pbuf = &mybuf[0]; |
| 3073 | |
| 3074 | if ((strncmp(pbuf, "on", sizeof("on") - 1) == 0)) { |
James Smart | 2b65e18 | 2017-02-12 13:52:38 -0800 | [diff] [blame] | 3075 | if (phba->nvmet_support) |
James Smart | 840eda9 | 2020-03-22 11:13:00 -0700 | [diff] [blame] | 3076 | phba->hdwqstat_on |= LPFC_CHECK_NVMET_IO; |
James Smart | 2b65e18 | 2017-02-12 13:52:38 -0800 | [diff] [blame] | 3077 | else |
James Smart | 840eda9 | 2020-03-22 11:13:00 -0700 | [diff] [blame] | 3078 | phba->hdwqstat_on |= (LPFC_CHECK_NVME_IO | |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 3079 | LPFC_CHECK_SCSI_IO); |
| 3080 | return strlen(pbuf); |
| 3081 | } else if ((strncmp(pbuf, "nvme_on", sizeof("nvme_on") - 1) == 0)) { |
| 3082 | if (phba->nvmet_support) |
James Smart | 840eda9 | 2020-03-22 11:13:00 -0700 | [diff] [blame] | 3083 | phba->hdwqstat_on |= LPFC_CHECK_NVMET_IO; |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 3084 | else |
James Smart | 840eda9 | 2020-03-22 11:13:00 -0700 | [diff] [blame] | 3085 | phba->hdwqstat_on |= LPFC_CHECK_NVME_IO; |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 3086 | return strlen(pbuf); |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 3087 | } else if ((strncmp(pbuf, "scsi_on", sizeof("scsi_on") - 1) == 0)) { |
James Smart | 840eda9 | 2020-03-22 11:13:00 -0700 | [diff] [blame] | 3088 | if (!phba->nvmet_support) |
| 3089 | phba->hdwqstat_on |= LPFC_CHECK_SCSI_IO; |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 3090 | return strlen(pbuf); |
James Smart | 840eda9 | 2020-03-22 11:13:00 -0700 | [diff] [blame] | 3091 | } else if ((strncmp(pbuf, "nvme_off", sizeof("nvme_off") - 1) == 0)) { |
| 3092 | phba->hdwqstat_on &= ~(LPFC_CHECK_NVME_IO | |
| 3093 | LPFC_CHECK_NVMET_IO); |
| 3094 | return strlen(pbuf); |
| 3095 | } else if ((strncmp(pbuf, "scsi_off", sizeof("scsi_off") - 1) == 0)) { |
| 3096 | phba->hdwqstat_on &= ~LPFC_CHECK_SCSI_IO; |
James Smart | f358dd0 | 2017-02-12 13:52:34 -0800 | [diff] [blame] | 3097 | return strlen(pbuf); |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 3098 | } else if ((strncmp(pbuf, "off", |
| 3099 | sizeof("off") - 1) == 0)) { |
James Smart | 840eda9 | 2020-03-22 11:13:00 -0700 | [diff] [blame] | 3100 | phba->hdwqstat_on = LPFC_CHECK_OFF; |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 3101 | return strlen(pbuf); |
| 3102 | } else if ((strncmp(pbuf, "zero", |
| 3103 | sizeof("zero") - 1) == 0)) { |
James Smart | 840eda9 | 2020-03-22 11:13:00 -0700 | [diff] [blame] | 3104 | for_each_present_cpu(i) { |
| 3105 | c_stat = per_cpu_ptr(phba->sli4_hba.c_stat, i); |
| 3106 | c_stat->xmt_io = 0; |
| 3107 | c_stat->cmpl_io = 0; |
| 3108 | c_stat->rcv_io = 0; |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 3109 | } |
| 3110 | return strlen(pbuf); |
| 3111 | } |
| 3112 | return -EINVAL; |
| 3113 | } |
| 3114 | |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 3115 | /* |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 3116 | * --------------------------------- |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 3117 | * iDiag debugfs file access methods |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 3118 | * --------------------------------- |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 3119 | * |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 3120 | * All access methods are through the proper SLI4 PCI function's debugfs |
| 3121 | * iDiag directory: |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 3122 | * |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 3123 | * /sys/kernel/debug/lpfc/fn<#>/iDiag |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 3124 | */ |
| 3125 | |
| 3126 | /** |
| 3127 | * lpfc_idiag_cmd_get - Get and parse idiag debugfs comands from user space |
| 3128 | * @buf: The pointer to the user space buffer. |
| 3129 | * @nbytes: The number of bytes in the user space buffer. |
| 3130 | * @idiag_cmd: pointer to the idiag command struct. |
| 3131 | * |
| 3132 | * This routine reads data from debugfs user space buffer and parses the |
| 3133 | * buffer for getting the idiag command and arguments. The while space in |
| 3134 | * between the set of data is used as the parsing separator. |
| 3135 | * |
| 3136 | * This routine returns 0 when successful, it returns proper error code |
| 3137 | * back to the user space in error conditions. |
| 3138 | */ |
| 3139 | static int lpfc_idiag_cmd_get(const char __user *buf, size_t nbytes, |
| 3140 | struct lpfc_idiag_cmd *idiag_cmd) |
| 3141 | { |
| 3142 | char mybuf[64]; |
| 3143 | char *pbuf, *step_str; |
Stephen Boyd | b11d48e | 2011-05-12 16:50:06 -0700 | [diff] [blame] | 3144 | int i; |
| 3145 | size_t bsize; |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 3146 | |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 3147 | memset(mybuf, 0, sizeof(mybuf)); |
| 3148 | memset(idiag_cmd, 0, sizeof(*idiag_cmd)); |
| 3149 | bsize = min(nbytes, (sizeof(mybuf)-1)); |
| 3150 | |
| 3151 | if (copy_from_user(mybuf, buf, bsize)) |
| 3152 | return -EFAULT; |
| 3153 | pbuf = &mybuf[0]; |
| 3154 | step_str = strsep(&pbuf, "\t "); |
| 3155 | |
| 3156 | /* The opcode must present */ |
| 3157 | if (!step_str) |
| 3158 | return -EINVAL; |
| 3159 | |
| 3160 | idiag_cmd->opcode = simple_strtol(step_str, NULL, 0); |
| 3161 | if (idiag_cmd->opcode == 0) |
| 3162 | return -EINVAL; |
| 3163 | |
| 3164 | for (i = 0; i < LPFC_IDIAG_CMD_DATA_SIZE; i++) { |
| 3165 | step_str = strsep(&pbuf, "\t "); |
| 3166 | if (!step_str) |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 3167 | return i; |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 3168 | idiag_cmd->data[i] = simple_strtol(step_str, NULL, 0); |
| 3169 | } |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 3170 | return i; |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 3171 | } |
| 3172 | |
| 3173 | /** |
| 3174 | * lpfc_idiag_open - idiag open debugfs |
| 3175 | * @inode: The inode pointer that contains a pointer to phba. |
| 3176 | * @file: The file pointer to attach the file operation. |
| 3177 | * |
| 3178 | * Description: |
| 3179 | * This routine is the entry point for the debugfs open file operation. It |
| 3180 | * gets the reference to phba from the i_private field in @inode, it then |
| 3181 | * allocates buffer for the file operation, performs the necessary PCI config |
| 3182 | * space read into the allocated buffer according to the idiag user command |
| 3183 | * setup, and then returns a pointer to buffer in the private_data field in |
| 3184 | * @file. |
| 3185 | * |
| 3186 | * Returns: |
| 3187 | * This function returns zero if successful. On error it will return an |
| 3188 | * negative error value. |
| 3189 | **/ |
| 3190 | static int |
| 3191 | lpfc_idiag_open(struct inode *inode, struct file *file) |
| 3192 | { |
| 3193 | struct lpfc_debug *debug; |
| 3194 | |
| 3195 | debug = kmalloc(sizeof(*debug), GFP_KERNEL); |
| 3196 | if (!debug) |
| 3197 | return -ENOMEM; |
| 3198 | |
| 3199 | debug->i_private = inode->i_private; |
| 3200 | debug->buffer = NULL; |
| 3201 | file->private_data = debug; |
| 3202 | |
| 3203 | return 0; |
| 3204 | } |
| 3205 | |
| 3206 | /** |
| 3207 | * lpfc_idiag_release - Release idiag access file operation |
| 3208 | * @inode: The inode pointer that contains a vport pointer. (unused) |
| 3209 | * @file: The file pointer that contains the buffer to release. |
| 3210 | * |
| 3211 | * Description: |
| 3212 | * This routine is the generic release routine for the idiag access file |
| 3213 | * operation, it frees the buffer that was allocated when the debugfs file |
| 3214 | * was opened. |
| 3215 | * |
| 3216 | * Returns: |
| 3217 | * This function returns zero. |
| 3218 | **/ |
| 3219 | static int |
| 3220 | lpfc_idiag_release(struct inode *inode, struct file *file) |
| 3221 | { |
| 3222 | struct lpfc_debug *debug = file->private_data; |
| 3223 | |
| 3224 | /* Free the buffers to the file operation */ |
| 3225 | kfree(debug->buffer); |
| 3226 | kfree(debug); |
| 3227 | |
| 3228 | return 0; |
| 3229 | } |
| 3230 | |
| 3231 | /** |
| 3232 | * lpfc_idiag_cmd_release - Release idiag cmd access file operation |
| 3233 | * @inode: The inode pointer that contains a vport pointer. (unused) |
| 3234 | * @file: The file pointer that contains the buffer to release. |
| 3235 | * |
| 3236 | * Description: |
| 3237 | * This routine frees the buffer that was allocated when the debugfs file |
| 3238 | * was opened. It also reset the fields in the idiag command struct in the |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 3239 | * case of command for write operation. |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 3240 | * |
| 3241 | * Returns: |
| 3242 | * This function returns zero. |
| 3243 | **/ |
| 3244 | static int |
| 3245 | lpfc_idiag_cmd_release(struct inode *inode, struct file *file) |
| 3246 | { |
| 3247 | struct lpfc_debug *debug = file->private_data; |
| 3248 | |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 3249 | if (debug->op == LPFC_IDIAG_OP_WR) { |
| 3250 | switch (idiag.cmd.opcode) { |
| 3251 | case LPFC_IDIAG_CMD_PCICFG_WR: |
| 3252 | case LPFC_IDIAG_CMD_PCICFG_ST: |
| 3253 | case LPFC_IDIAG_CMD_PCICFG_CL: |
| 3254 | case LPFC_IDIAG_CMD_QUEACC_WR: |
| 3255 | case LPFC_IDIAG_CMD_QUEACC_ST: |
| 3256 | case LPFC_IDIAG_CMD_QUEACC_CL: |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 3257 | memset(&idiag, 0, sizeof(idiag)); |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 3258 | break; |
| 3259 | default: |
| 3260 | break; |
| 3261 | } |
| 3262 | } |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 3263 | |
| 3264 | /* Free the buffers to the file operation */ |
| 3265 | kfree(debug->buffer); |
| 3266 | kfree(debug); |
| 3267 | |
| 3268 | return 0; |
| 3269 | } |
| 3270 | |
| 3271 | /** |
| 3272 | * lpfc_idiag_pcicfg_read - idiag debugfs read pcicfg |
| 3273 | * @file: The file pointer to read from. |
| 3274 | * @buf: The buffer to copy the data to. |
| 3275 | * @nbytes: The number of bytes to read. |
| 3276 | * @ppos: The position in the file to start reading from. |
| 3277 | * |
| 3278 | * Description: |
| 3279 | * This routine reads data from the @phba pci config space according to the |
| 3280 | * idiag command, and copies to user @buf. Depending on the PCI config space |
| 3281 | * read command setup, it does either a single register read of a byte |
| 3282 | * (8 bits), a word (16 bits), or a dword (32 bits) or browsing through all |
| 3283 | * registers from the 4K extended PCI config space. |
| 3284 | * |
| 3285 | * Returns: |
| 3286 | * This function returns the amount of data that was read (this could be less |
| 3287 | * than @nbytes if the end of the file was reached) or a negative error value. |
| 3288 | **/ |
| 3289 | static ssize_t |
| 3290 | lpfc_idiag_pcicfg_read(struct file *file, char __user *buf, size_t nbytes, |
| 3291 | loff_t *ppos) |
| 3292 | { |
| 3293 | struct lpfc_debug *debug = file->private_data; |
| 3294 | struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private; |
| 3295 | int offset_label, offset, len = 0, index = LPFC_PCI_CFG_RD_SIZE; |
| 3296 | int where, count; |
| 3297 | char *pbuffer; |
| 3298 | struct pci_dev *pdev; |
| 3299 | uint32_t u32val; |
| 3300 | uint16_t u16val; |
| 3301 | uint8_t u8val; |
| 3302 | |
| 3303 | pdev = phba->pcidev; |
| 3304 | if (!pdev) |
| 3305 | return 0; |
| 3306 | |
| 3307 | /* This is a user read operation */ |
| 3308 | debug->op = LPFC_IDIAG_OP_RD; |
| 3309 | |
| 3310 | if (!debug->buffer) |
| 3311 | debug->buffer = kmalloc(LPFC_PCI_CFG_SIZE, GFP_KERNEL); |
| 3312 | if (!debug->buffer) |
| 3313 | return 0; |
| 3314 | pbuffer = debug->buffer; |
| 3315 | |
| 3316 | if (*ppos) |
| 3317 | return 0; |
| 3318 | |
| 3319 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_RD) { |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 3320 | where = idiag.cmd.data[IDIAG_PCICFG_WHERE_INDX]; |
| 3321 | count = idiag.cmd.data[IDIAG_PCICFG_COUNT_INDX]; |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 3322 | } else |
| 3323 | return 0; |
| 3324 | |
| 3325 | /* Read single PCI config space register */ |
| 3326 | switch (count) { |
| 3327 | case SIZE_U8: /* byte (8 bits) */ |
| 3328 | pci_read_config_byte(pdev, where, &u8val); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 3329 | len += scnprintf(pbuffer+len, LPFC_PCI_CFG_SIZE-len, |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 3330 | "%03x: %02x\n", where, u8val); |
| 3331 | break; |
| 3332 | case SIZE_U16: /* word (16 bits) */ |
| 3333 | pci_read_config_word(pdev, where, &u16val); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 3334 | len += scnprintf(pbuffer+len, LPFC_PCI_CFG_SIZE-len, |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 3335 | "%03x: %04x\n", where, u16val); |
| 3336 | break; |
| 3337 | case SIZE_U32: /* double word (32 bits) */ |
| 3338 | pci_read_config_dword(pdev, where, &u32val); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 3339 | len += scnprintf(pbuffer+len, LPFC_PCI_CFG_SIZE-len, |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 3340 | "%03x: %08x\n", where, u32val); |
| 3341 | break; |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 3342 | case LPFC_PCI_CFG_BROWSE: /* browse all */ |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 3343 | goto pcicfg_browse; |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 3344 | default: |
| 3345 | /* illegal count */ |
| 3346 | len = 0; |
| 3347 | break; |
| 3348 | } |
| 3349 | return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len); |
| 3350 | |
| 3351 | pcicfg_browse: |
| 3352 | |
| 3353 | /* Browse all PCI config space registers */ |
| 3354 | offset_label = idiag.offset.last_rd; |
| 3355 | offset = offset_label; |
| 3356 | |
| 3357 | /* Read PCI config space */ |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 3358 | len += scnprintf(pbuffer+len, LPFC_PCI_CFG_SIZE-len, |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 3359 | "%03x: ", offset_label); |
| 3360 | while (index > 0) { |
| 3361 | pci_read_config_dword(pdev, offset, &u32val); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 3362 | len += scnprintf(pbuffer+len, LPFC_PCI_CFG_SIZE-len, |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 3363 | "%08x ", u32val); |
| 3364 | offset += sizeof(uint32_t); |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 3365 | if (offset >= LPFC_PCI_CFG_SIZE) { |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 3366 | len += scnprintf(pbuffer+len, |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 3367 | LPFC_PCI_CFG_SIZE-len, "\n"); |
| 3368 | break; |
| 3369 | } |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 3370 | index -= sizeof(uint32_t); |
| 3371 | if (!index) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 3372 | len += scnprintf(pbuffer+len, LPFC_PCI_CFG_SIZE-len, |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 3373 | "\n"); |
| 3374 | else if (!(index % (8 * sizeof(uint32_t)))) { |
| 3375 | offset_label += (8 * sizeof(uint32_t)); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 3376 | len += scnprintf(pbuffer+len, LPFC_PCI_CFG_SIZE-len, |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 3377 | "\n%03x: ", offset_label); |
| 3378 | } |
| 3379 | } |
| 3380 | |
| 3381 | /* Set up the offset for next portion of pci cfg read */ |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 3382 | if (index == 0) { |
| 3383 | idiag.offset.last_rd += LPFC_PCI_CFG_RD_SIZE; |
| 3384 | if (idiag.offset.last_rd >= LPFC_PCI_CFG_SIZE) |
| 3385 | idiag.offset.last_rd = 0; |
| 3386 | } else |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 3387 | idiag.offset.last_rd = 0; |
| 3388 | |
| 3389 | return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len); |
| 3390 | } |
| 3391 | |
| 3392 | /** |
| 3393 | * lpfc_idiag_pcicfg_write - Syntax check and set up idiag pcicfg commands |
| 3394 | * @file: The file pointer to read from. |
| 3395 | * @buf: The buffer to copy the user data from. |
| 3396 | * @nbytes: The number of bytes to get. |
| 3397 | * @ppos: The position in the file to start reading from. |
| 3398 | * |
| 3399 | * This routine get the debugfs idiag command struct from user space and |
| 3400 | * then perform the syntax check for PCI config space read or write command |
| 3401 | * accordingly. In the case of PCI config space read command, it sets up |
| 3402 | * the command in the idiag command struct for the debugfs read operation. |
| 3403 | * In the case of PCI config space write operation, it executes the write |
| 3404 | * operation into the PCI config space accordingly. |
| 3405 | * |
| 3406 | * It returns the @nbytges passing in from debugfs user space when successful. |
| 3407 | * In case of error conditions, it returns proper error code back to the user |
| 3408 | * space. |
| 3409 | */ |
| 3410 | static ssize_t |
| 3411 | lpfc_idiag_pcicfg_write(struct file *file, const char __user *buf, |
| 3412 | size_t nbytes, loff_t *ppos) |
| 3413 | { |
| 3414 | struct lpfc_debug *debug = file->private_data; |
| 3415 | struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private; |
| 3416 | uint32_t where, value, count; |
| 3417 | uint32_t u32val; |
| 3418 | uint16_t u16val; |
| 3419 | uint8_t u8val; |
| 3420 | struct pci_dev *pdev; |
| 3421 | int rc; |
| 3422 | |
| 3423 | pdev = phba->pcidev; |
| 3424 | if (!pdev) |
| 3425 | return -EFAULT; |
| 3426 | |
| 3427 | /* This is a user write operation */ |
| 3428 | debug->op = LPFC_IDIAG_OP_WR; |
| 3429 | |
| 3430 | rc = lpfc_idiag_cmd_get(buf, nbytes, &idiag.cmd); |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 3431 | if (rc < 0) |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 3432 | return rc; |
| 3433 | |
| 3434 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_RD) { |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 3435 | /* Sanity check on PCI config read command line arguments */ |
| 3436 | if (rc != LPFC_PCI_CFG_RD_CMD_ARG) |
| 3437 | goto error_out; |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 3438 | /* Read command from PCI config space, set up command fields */ |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 3439 | where = idiag.cmd.data[IDIAG_PCICFG_WHERE_INDX]; |
| 3440 | count = idiag.cmd.data[IDIAG_PCICFG_COUNT_INDX]; |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 3441 | if (count == LPFC_PCI_CFG_BROWSE) { |
| 3442 | if (where % sizeof(uint32_t)) |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 3443 | goto error_out; |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 3444 | /* Starting offset to browse */ |
| 3445 | idiag.offset.last_rd = where; |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 3446 | } else if ((count != sizeof(uint8_t)) && |
| 3447 | (count != sizeof(uint16_t)) && |
| 3448 | (count != sizeof(uint32_t))) |
| 3449 | goto error_out; |
| 3450 | if (count == sizeof(uint8_t)) { |
| 3451 | if (where > LPFC_PCI_CFG_SIZE - sizeof(uint8_t)) |
| 3452 | goto error_out; |
| 3453 | if (where % sizeof(uint8_t)) |
| 3454 | goto error_out; |
| 3455 | } |
| 3456 | if (count == sizeof(uint16_t)) { |
| 3457 | if (where > LPFC_PCI_CFG_SIZE - sizeof(uint16_t)) |
| 3458 | goto error_out; |
| 3459 | if (where % sizeof(uint16_t)) |
| 3460 | goto error_out; |
| 3461 | } |
| 3462 | if (count == sizeof(uint32_t)) { |
| 3463 | if (where > LPFC_PCI_CFG_SIZE - sizeof(uint32_t)) |
| 3464 | goto error_out; |
| 3465 | if (where % sizeof(uint32_t)) |
| 3466 | goto error_out; |
| 3467 | } |
| 3468 | } else if (idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_WR || |
| 3469 | idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_ST || |
| 3470 | idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_CL) { |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 3471 | /* Sanity check on PCI config write command line arguments */ |
| 3472 | if (rc != LPFC_PCI_CFG_WR_CMD_ARG) |
| 3473 | goto error_out; |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 3474 | /* Write command to PCI config space, read-modify-write */ |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 3475 | where = idiag.cmd.data[IDIAG_PCICFG_WHERE_INDX]; |
| 3476 | count = idiag.cmd.data[IDIAG_PCICFG_COUNT_INDX]; |
| 3477 | value = idiag.cmd.data[IDIAG_PCICFG_VALUE_INDX]; |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 3478 | /* Sanity checks */ |
| 3479 | if ((count != sizeof(uint8_t)) && |
| 3480 | (count != sizeof(uint16_t)) && |
| 3481 | (count != sizeof(uint32_t))) |
| 3482 | goto error_out; |
| 3483 | if (count == sizeof(uint8_t)) { |
| 3484 | if (where > LPFC_PCI_CFG_SIZE - sizeof(uint8_t)) |
| 3485 | goto error_out; |
| 3486 | if (where % sizeof(uint8_t)) |
| 3487 | goto error_out; |
| 3488 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_WR) |
| 3489 | pci_write_config_byte(pdev, where, |
| 3490 | (uint8_t)value); |
| 3491 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_ST) { |
| 3492 | rc = pci_read_config_byte(pdev, where, &u8val); |
| 3493 | if (!rc) { |
| 3494 | u8val |= (uint8_t)value; |
| 3495 | pci_write_config_byte(pdev, where, |
| 3496 | u8val); |
| 3497 | } |
| 3498 | } |
| 3499 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_CL) { |
| 3500 | rc = pci_read_config_byte(pdev, where, &u8val); |
| 3501 | if (!rc) { |
| 3502 | u8val &= (uint8_t)(~value); |
| 3503 | pci_write_config_byte(pdev, where, |
| 3504 | u8val); |
| 3505 | } |
| 3506 | } |
| 3507 | } |
| 3508 | if (count == sizeof(uint16_t)) { |
| 3509 | if (where > LPFC_PCI_CFG_SIZE - sizeof(uint16_t)) |
| 3510 | goto error_out; |
| 3511 | if (where % sizeof(uint16_t)) |
| 3512 | goto error_out; |
| 3513 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_WR) |
| 3514 | pci_write_config_word(pdev, where, |
| 3515 | (uint16_t)value); |
| 3516 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_ST) { |
| 3517 | rc = pci_read_config_word(pdev, where, &u16val); |
| 3518 | if (!rc) { |
| 3519 | u16val |= (uint16_t)value; |
| 3520 | pci_write_config_word(pdev, where, |
| 3521 | u16val); |
| 3522 | } |
| 3523 | } |
| 3524 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_CL) { |
| 3525 | rc = pci_read_config_word(pdev, where, &u16val); |
| 3526 | if (!rc) { |
| 3527 | u16val &= (uint16_t)(~value); |
| 3528 | pci_write_config_word(pdev, where, |
| 3529 | u16val); |
| 3530 | } |
| 3531 | } |
| 3532 | } |
| 3533 | if (count == sizeof(uint32_t)) { |
| 3534 | if (where > LPFC_PCI_CFG_SIZE - sizeof(uint32_t)) |
| 3535 | goto error_out; |
| 3536 | if (where % sizeof(uint32_t)) |
| 3537 | goto error_out; |
| 3538 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_WR) |
| 3539 | pci_write_config_dword(pdev, where, value); |
| 3540 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_ST) { |
| 3541 | rc = pci_read_config_dword(pdev, where, |
| 3542 | &u32val); |
| 3543 | if (!rc) { |
| 3544 | u32val |= value; |
| 3545 | pci_write_config_dword(pdev, where, |
| 3546 | u32val); |
| 3547 | } |
| 3548 | } |
| 3549 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_CL) { |
| 3550 | rc = pci_read_config_dword(pdev, where, |
| 3551 | &u32val); |
| 3552 | if (!rc) { |
| 3553 | u32val &= ~value; |
| 3554 | pci_write_config_dword(pdev, where, |
| 3555 | u32val); |
| 3556 | } |
| 3557 | } |
| 3558 | } |
| 3559 | } else |
| 3560 | /* All other opecodes are illegal for now */ |
| 3561 | goto error_out; |
| 3562 | |
| 3563 | return nbytes; |
| 3564 | error_out: |
| 3565 | memset(&idiag, 0, sizeof(idiag)); |
| 3566 | return -EINVAL; |
| 3567 | } |
| 3568 | |
| 3569 | /** |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 3570 | * lpfc_idiag_baracc_read - idiag debugfs pci bar access read |
| 3571 | * @file: The file pointer to read from. |
| 3572 | * @buf: The buffer to copy the data to. |
| 3573 | * @nbytes: The number of bytes to read. |
| 3574 | * @ppos: The position in the file to start reading from. |
| 3575 | * |
| 3576 | * Description: |
| 3577 | * This routine reads data from the @phba pci bar memory mapped space |
| 3578 | * according to the idiag command, and copies to user @buf. |
| 3579 | * |
| 3580 | * Returns: |
| 3581 | * This function returns the amount of data that was read (this could be less |
| 3582 | * than @nbytes if the end of the file was reached) or a negative error value. |
| 3583 | **/ |
| 3584 | static ssize_t |
| 3585 | lpfc_idiag_baracc_read(struct file *file, char __user *buf, size_t nbytes, |
| 3586 | loff_t *ppos) |
| 3587 | { |
| 3588 | struct lpfc_debug *debug = file->private_data; |
| 3589 | struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private; |
| 3590 | int offset_label, offset, offset_run, len = 0, index; |
| 3591 | int bar_num, acc_range, bar_size; |
| 3592 | char *pbuffer; |
| 3593 | void __iomem *mem_mapped_bar; |
| 3594 | uint32_t if_type; |
| 3595 | struct pci_dev *pdev; |
| 3596 | uint32_t u32val; |
| 3597 | |
| 3598 | pdev = phba->pcidev; |
| 3599 | if (!pdev) |
| 3600 | return 0; |
| 3601 | |
| 3602 | /* This is a user read operation */ |
| 3603 | debug->op = LPFC_IDIAG_OP_RD; |
| 3604 | |
| 3605 | if (!debug->buffer) |
| 3606 | debug->buffer = kmalloc(LPFC_PCI_BAR_RD_BUF_SIZE, GFP_KERNEL); |
| 3607 | if (!debug->buffer) |
| 3608 | return 0; |
| 3609 | pbuffer = debug->buffer; |
| 3610 | |
| 3611 | if (*ppos) |
| 3612 | return 0; |
| 3613 | |
| 3614 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_BARACC_RD) { |
| 3615 | bar_num = idiag.cmd.data[IDIAG_BARACC_BAR_NUM_INDX]; |
| 3616 | offset = idiag.cmd.data[IDIAG_BARACC_OFF_SET_INDX]; |
| 3617 | acc_range = idiag.cmd.data[IDIAG_BARACC_ACC_MOD_INDX]; |
| 3618 | bar_size = idiag.cmd.data[IDIAG_BARACC_BAR_SZE_INDX]; |
| 3619 | } else |
| 3620 | return 0; |
| 3621 | |
| 3622 | if (acc_range == 0) |
| 3623 | return 0; |
| 3624 | |
| 3625 | if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); |
| 3626 | if (if_type == LPFC_SLI_INTF_IF_TYPE_0) { |
| 3627 | if (bar_num == IDIAG_BARACC_BAR_0) |
| 3628 | mem_mapped_bar = phba->sli4_hba.conf_regs_memmap_p; |
| 3629 | else if (bar_num == IDIAG_BARACC_BAR_1) |
| 3630 | mem_mapped_bar = phba->sli4_hba.ctrl_regs_memmap_p; |
| 3631 | else if (bar_num == IDIAG_BARACC_BAR_2) |
| 3632 | mem_mapped_bar = phba->sli4_hba.drbl_regs_memmap_p; |
| 3633 | else |
| 3634 | return 0; |
| 3635 | } else if (if_type == LPFC_SLI_INTF_IF_TYPE_2) { |
| 3636 | if (bar_num == IDIAG_BARACC_BAR_0) |
| 3637 | mem_mapped_bar = phba->sli4_hba.conf_regs_memmap_p; |
| 3638 | else |
| 3639 | return 0; |
| 3640 | } else |
| 3641 | return 0; |
| 3642 | |
| 3643 | /* Read single PCI bar space register */ |
| 3644 | if (acc_range == SINGLE_WORD) { |
| 3645 | offset_run = offset; |
| 3646 | u32val = readl(mem_mapped_bar + offset_run); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 3647 | len += scnprintf(pbuffer+len, LPFC_PCI_BAR_RD_BUF_SIZE-len, |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 3648 | "%05x: %08x\n", offset_run, u32val); |
| 3649 | } else |
| 3650 | goto baracc_browse; |
| 3651 | |
| 3652 | return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len); |
| 3653 | |
| 3654 | baracc_browse: |
| 3655 | |
| 3656 | /* Browse all PCI bar space registers */ |
| 3657 | offset_label = idiag.offset.last_rd; |
| 3658 | offset_run = offset_label; |
| 3659 | |
| 3660 | /* Read PCI bar memory mapped space */ |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 3661 | len += scnprintf(pbuffer+len, LPFC_PCI_BAR_RD_BUF_SIZE-len, |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 3662 | "%05x: ", offset_label); |
| 3663 | index = LPFC_PCI_BAR_RD_SIZE; |
| 3664 | while (index > 0) { |
| 3665 | u32val = readl(mem_mapped_bar + offset_run); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 3666 | len += scnprintf(pbuffer+len, LPFC_PCI_BAR_RD_BUF_SIZE-len, |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 3667 | "%08x ", u32val); |
| 3668 | offset_run += sizeof(uint32_t); |
| 3669 | if (acc_range == LPFC_PCI_BAR_BROWSE) { |
| 3670 | if (offset_run >= bar_size) { |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 3671 | len += scnprintf(pbuffer+len, |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 3672 | LPFC_PCI_BAR_RD_BUF_SIZE-len, "\n"); |
| 3673 | break; |
| 3674 | } |
| 3675 | } else { |
| 3676 | if (offset_run >= offset + |
| 3677 | (acc_range * sizeof(uint32_t))) { |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 3678 | len += scnprintf(pbuffer+len, |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 3679 | LPFC_PCI_BAR_RD_BUF_SIZE-len, "\n"); |
| 3680 | break; |
| 3681 | } |
| 3682 | } |
| 3683 | index -= sizeof(uint32_t); |
| 3684 | if (!index) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 3685 | len += scnprintf(pbuffer+len, |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 3686 | LPFC_PCI_BAR_RD_BUF_SIZE-len, "\n"); |
| 3687 | else if (!(index % (8 * sizeof(uint32_t)))) { |
| 3688 | offset_label += (8 * sizeof(uint32_t)); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 3689 | len += scnprintf(pbuffer+len, |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 3690 | LPFC_PCI_BAR_RD_BUF_SIZE-len, |
| 3691 | "\n%05x: ", offset_label); |
| 3692 | } |
| 3693 | } |
| 3694 | |
| 3695 | /* Set up the offset for next portion of pci bar read */ |
| 3696 | if (index == 0) { |
| 3697 | idiag.offset.last_rd += LPFC_PCI_BAR_RD_SIZE; |
| 3698 | if (acc_range == LPFC_PCI_BAR_BROWSE) { |
| 3699 | if (idiag.offset.last_rd >= bar_size) |
| 3700 | idiag.offset.last_rd = 0; |
| 3701 | } else { |
| 3702 | if (offset_run >= offset + |
| 3703 | (acc_range * sizeof(uint32_t))) |
| 3704 | idiag.offset.last_rd = offset; |
| 3705 | } |
| 3706 | } else { |
| 3707 | if (acc_range == LPFC_PCI_BAR_BROWSE) |
| 3708 | idiag.offset.last_rd = 0; |
| 3709 | else |
| 3710 | idiag.offset.last_rd = offset; |
| 3711 | } |
| 3712 | |
| 3713 | return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len); |
| 3714 | } |
| 3715 | |
| 3716 | /** |
| 3717 | * lpfc_idiag_baracc_write - Syntax check and set up idiag bar access commands |
| 3718 | * @file: The file pointer to read from. |
| 3719 | * @buf: The buffer to copy the user data from. |
| 3720 | * @nbytes: The number of bytes to get. |
| 3721 | * @ppos: The position in the file to start reading from. |
| 3722 | * |
| 3723 | * This routine get the debugfs idiag command struct from user space and |
| 3724 | * then perform the syntax check for PCI bar memory mapped space read or |
| 3725 | * write command accordingly. In the case of PCI bar memory mapped space |
| 3726 | * read command, it sets up the command in the idiag command struct for |
| 3727 | * the debugfs read operation. In the case of PCI bar memorpy mapped space |
| 3728 | * write operation, it executes the write operation into the PCI bar memory |
| 3729 | * mapped space accordingly. |
| 3730 | * |
| 3731 | * It returns the @nbytges passing in from debugfs user space when successful. |
| 3732 | * In case of error conditions, it returns proper error code back to the user |
| 3733 | * space. |
| 3734 | */ |
| 3735 | static ssize_t |
| 3736 | lpfc_idiag_baracc_write(struct file *file, const char __user *buf, |
| 3737 | size_t nbytes, loff_t *ppos) |
| 3738 | { |
| 3739 | struct lpfc_debug *debug = file->private_data; |
| 3740 | struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private; |
| 3741 | uint32_t bar_num, bar_size, offset, value, acc_range; |
| 3742 | struct pci_dev *pdev; |
| 3743 | void __iomem *mem_mapped_bar; |
| 3744 | uint32_t if_type; |
| 3745 | uint32_t u32val; |
| 3746 | int rc; |
| 3747 | |
| 3748 | pdev = phba->pcidev; |
| 3749 | if (!pdev) |
| 3750 | return -EFAULT; |
| 3751 | |
| 3752 | /* This is a user write operation */ |
| 3753 | debug->op = LPFC_IDIAG_OP_WR; |
| 3754 | |
| 3755 | rc = lpfc_idiag_cmd_get(buf, nbytes, &idiag.cmd); |
| 3756 | if (rc < 0) |
| 3757 | return rc; |
| 3758 | |
| 3759 | if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); |
| 3760 | bar_num = idiag.cmd.data[IDIAG_BARACC_BAR_NUM_INDX]; |
| 3761 | |
| 3762 | if (if_type == LPFC_SLI_INTF_IF_TYPE_0) { |
| 3763 | if ((bar_num != IDIAG_BARACC_BAR_0) && |
| 3764 | (bar_num != IDIAG_BARACC_BAR_1) && |
| 3765 | (bar_num != IDIAG_BARACC_BAR_2)) |
| 3766 | goto error_out; |
| 3767 | } else if (if_type == LPFC_SLI_INTF_IF_TYPE_2) { |
| 3768 | if (bar_num != IDIAG_BARACC_BAR_0) |
| 3769 | goto error_out; |
| 3770 | } else |
| 3771 | goto error_out; |
| 3772 | |
| 3773 | if (if_type == LPFC_SLI_INTF_IF_TYPE_0) { |
| 3774 | if (bar_num == IDIAG_BARACC_BAR_0) { |
| 3775 | idiag.cmd.data[IDIAG_BARACC_BAR_SZE_INDX] = |
| 3776 | LPFC_PCI_IF0_BAR0_SIZE; |
| 3777 | mem_mapped_bar = phba->sli4_hba.conf_regs_memmap_p; |
| 3778 | } else if (bar_num == IDIAG_BARACC_BAR_1) { |
| 3779 | idiag.cmd.data[IDIAG_BARACC_BAR_SZE_INDX] = |
| 3780 | LPFC_PCI_IF0_BAR1_SIZE; |
| 3781 | mem_mapped_bar = phba->sli4_hba.ctrl_regs_memmap_p; |
| 3782 | } else if (bar_num == IDIAG_BARACC_BAR_2) { |
| 3783 | idiag.cmd.data[IDIAG_BARACC_BAR_SZE_INDX] = |
| 3784 | LPFC_PCI_IF0_BAR2_SIZE; |
| 3785 | mem_mapped_bar = phba->sli4_hba.drbl_regs_memmap_p; |
| 3786 | } else |
| 3787 | goto error_out; |
| 3788 | } else if (if_type == LPFC_SLI_INTF_IF_TYPE_2) { |
| 3789 | if (bar_num == IDIAG_BARACC_BAR_0) { |
| 3790 | idiag.cmd.data[IDIAG_BARACC_BAR_SZE_INDX] = |
| 3791 | LPFC_PCI_IF2_BAR0_SIZE; |
| 3792 | mem_mapped_bar = phba->sli4_hba.conf_regs_memmap_p; |
| 3793 | } else |
| 3794 | goto error_out; |
| 3795 | } else |
| 3796 | goto error_out; |
| 3797 | |
| 3798 | offset = idiag.cmd.data[IDIAG_BARACC_OFF_SET_INDX]; |
| 3799 | if (offset % sizeof(uint32_t)) |
| 3800 | goto error_out; |
| 3801 | |
| 3802 | bar_size = idiag.cmd.data[IDIAG_BARACC_BAR_SZE_INDX]; |
| 3803 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_BARACC_RD) { |
| 3804 | /* Sanity check on PCI config read command line arguments */ |
| 3805 | if (rc != LPFC_PCI_BAR_RD_CMD_ARG) |
| 3806 | goto error_out; |
| 3807 | acc_range = idiag.cmd.data[IDIAG_BARACC_ACC_MOD_INDX]; |
| 3808 | if (acc_range == LPFC_PCI_BAR_BROWSE) { |
| 3809 | if (offset > bar_size - sizeof(uint32_t)) |
| 3810 | goto error_out; |
| 3811 | /* Starting offset to browse */ |
| 3812 | idiag.offset.last_rd = offset; |
| 3813 | } else if (acc_range > SINGLE_WORD) { |
| 3814 | if (offset + acc_range * sizeof(uint32_t) > bar_size) |
| 3815 | goto error_out; |
| 3816 | /* Starting offset to browse */ |
| 3817 | idiag.offset.last_rd = offset; |
| 3818 | } else if (acc_range != SINGLE_WORD) |
| 3819 | goto error_out; |
| 3820 | } else if (idiag.cmd.opcode == LPFC_IDIAG_CMD_BARACC_WR || |
| 3821 | idiag.cmd.opcode == LPFC_IDIAG_CMD_BARACC_ST || |
| 3822 | idiag.cmd.opcode == LPFC_IDIAG_CMD_BARACC_CL) { |
| 3823 | /* Sanity check on PCI bar write command line arguments */ |
| 3824 | if (rc != LPFC_PCI_BAR_WR_CMD_ARG) |
| 3825 | goto error_out; |
| 3826 | /* Write command to PCI bar space, read-modify-write */ |
| 3827 | acc_range = SINGLE_WORD; |
| 3828 | value = idiag.cmd.data[IDIAG_BARACC_REG_VAL_INDX]; |
| 3829 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_BARACC_WR) { |
| 3830 | writel(value, mem_mapped_bar + offset); |
| 3831 | readl(mem_mapped_bar + offset); |
| 3832 | } |
| 3833 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_BARACC_ST) { |
| 3834 | u32val = readl(mem_mapped_bar + offset); |
| 3835 | u32val |= value; |
| 3836 | writel(u32val, mem_mapped_bar + offset); |
| 3837 | readl(mem_mapped_bar + offset); |
| 3838 | } |
| 3839 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_BARACC_CL) { |
| 3840 | u32val = readl(mem_mapped_bar + offset); |
| 3841 | u32val &= ~value; |
| 3842 | writel(u32val, mem_mapped_bar + offset); |
| 3843 | readl(mem_mapped_bar + offset); |
| 3844 | } |
| 3845 | } else |
| 3846 | /* All other opecodes are illegal for now */ |
| 3847 | goto error_out; |
| 3848 | |
| 3849 | return nbytes; |
| 3850 | error_out: |
| 3851 | memset(&idiag, 0, sizeof(idiag)); |
| 3852 | return -EINVAL; |
| 3853 | } |
| 3854 | |
James Smart | 07bcd98 | 2017-02-12 13:52:28 -0800 | [diff] [blame] | 3855 | static int |
| 3856 | __lpfc_idiag_print_wq(struct lpfc_queue *qp, char *wqtype, |
| 3857 | char *pbuffer, int len) |
| 3858 | { |
| 3859 | if (!qp) |
| 3860 | return len; |
| 3861 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 3862 | len += scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len, |
James Smart | 07bcd98 | 2017-02-12 13:52:28 -0800 | [diff] [blame] | 3863 | "\t\t%s WQ info: ", wqtype); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 3864 | len += scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len, |
James Smart | 07bcd98 | 2017-02-12 13:52:28 -0800 | [diff] [blame] | 3865 | "AssocCQID[%04d]: WQ-STAT[oflow:x%x posted:x%llx]\n", |
| 3866 | qp->assoc_qid, qp->q_cnt_1, |
| 3867 | (unsigned long long)qp->q_cnt_4); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 3868 | len += scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len, |
James Smart | 7869da1 | 2017-05-15 15:20:43 -0700 | [diff] [blame] | 3869 | "\t\tWQID[%02d], QE-CNT[%04d], QE-SZ[%04d], " |
James Smart | 32517fc | 2019-01-28 11:14:33 -0800 | [diff] [blame] | 3870 | "HST-IDX[%04d], PRT-IDX[%04d], NTFI[%03d]", |
James Smart | 07bcd98 | 2017-02-12 13:52:28 -0800 | [diff] [blame] | 3871 | qp->queue_id, qp->entry_count, |
| 3872 | qp->entry_size, qp->host_index, |
James Smart | 32517fc | 2019-01-28 11:14:33 -0800 | [diff] [blame] | 3873 | qp->hba_index, qp->notify_interval); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 3874 | len += scnprintf(pbuffer + len, |
James Smart | 07bcd98 | 2017-02-12 13:52:28 -0800 | [diff] [blame] | 3875 | LPFC_QUE_INFO_GET_BUF_SIZE - len, "\n"); |
| 3876 | return len; |
| 3877 | } |
| 3878 | |
| 3879 | static int |
| 3880 | lpfc_idiag_wqs_for_cq(struct lpfc_hba *phba, char *wqtype, char *pbuffer, |
| 3881 | int *len, int max_cnt, int cq_id) |
| 3882 | { |
| 3883 | struct lpfc_queue *qp; |
| 3884 | int qidx; |
| 3885 | |
James Smart | cdb42be | 2019-01-28 11:14:21 -0800 | [diff] [blame] | 3886 | for (qidx = 0; qidx < phba->cfg_hdw_queue; qidx++) { |
James Smart | c00f62e | 2019-08-14 16:57:11 -0700 | [diff] [blame] | 3887 | qp = phba->sli4_hba.hdwq[qidx].io_wq; |
James Smart | 07bcd98 | 2017-02-12 13:52:28 -0800 | [diff] [blame] | 3888 | if (qp->assoc_qid != cq_id) |
| 3889 | continue; |
| 3890 | *len = __lpfc_idiag_print_wq(qp, wqtype, pbuffer, *len); |
| 3891 | if (*len >= max_cnt) |
| 3892 | return 1; |
| 3893 | } |
| 3894 | return 0; |
| 3895 | } |
| 3896 | |
| 3897 | static int |
| 3898 | __lpfc_idiag_print_cq(struct lpfc_queue *qp, char *cqtype, |
| 3899 | char *pbuffer, int len) |
| 3900 | { |
| 3901 | if (!qp) |
| 3902 | return len; |
| 3903 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 3904 | len += scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len, |
James Smart | 07bcd98 | 2017-02-12 13:52:28 -0800 | [diff] [blame] | 3905 | "\t%s CQ info: ", cqtype); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 3906 | len += scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len, |
James Smart | 07bcd98 | 2017-02-12 13:52:28 -0800 | [diff] [blame] | 3907 | "AssocEQID[%02d]: CQ STAT[max:x%x relw:x%x " |
| 3908 | "xabt:x%x wq:x%llx]\n", |
| 3909 | qp->assoc_qid, qp->q_cnt_1, qp->q_cnt_2, |
| 3910 | qp->q_cnt_3, (unsigned long long)qp->q_cnt_4); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 3911 | len += scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len, |
James Smart | 7869da1 | 2017-05-15 15:20:43 -0700 | [diff] [blame] | 3912 | "\tCQID[%02d], QE-CNT[%04d], QE-SZ[%04d], " |
James Smart | 32517fc | 2019-01-28 11:14:33 -0800 | [diff] [blame] | 3913 | "HST-IDX[%04d], NTFI[%03d], PLMT[%03d]", |
James Smart | 07bcd98 | 2017-02-12 13:52:28 -0800 | [diff] [blame] | 3914 | qp->queue_id, qp->entry_count, |
| 3915 | qp->entry_size, qp->host_index, |
James Smart | 32517fc | 2019-01-28 11:14:33 -0800 | [diff] [blame] | 3916 | qp->notify_interval, qp->max_proc_limit); |
James Smart | 07bcd98 | 2017-02-12 13:52:28 -0800 | [diff] [blame] | 3917 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 3918 | len += scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len, |
| 3919 | "\n"); |
James Smart | 07bcd98 | 2017-02-12 13:52:28 -0800 | [diff] [blame] | 3920 | |
| 3921 | return len; |
| 3922 | } |
| 3923 | |
| 3924 | static int |
| 3925 | __lpfc_idiag_print_rqpair(struct lpfc_queue *qp, struct lpfc_queue *datqp, |
| 3926 | char *rqtype, char *pbuffer, int len) |
| 3927 | { |
| 3928 | if (!qp || !datqp) |
| 3929 | return len; |
| 3930 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 3931 | len += scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len, |
James Smart | 07bcd98 | 2017-02-12 13:52:28 -0800 | [diff] [blame] | 3932 | "\t\t%s RQ info: ", rqtype); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 3933 | len += scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len, |
James Smart | 07bcd98 | 2017-02-12 13:52:28 -0800 | [diff] [blame] | 3934 | "AssocCQID[%02d]: RQ-STAT[nopost:x%x nobuf:x%x " |
James Smart | 547077a | 2017-05-15 15:20:40 -0700 | [diff] [blame] | 3935 | "posted:x%x rcv:x%llx]\n", |
James Smart | 07bcd98 | 2017-02-12 13:52:28 -0800 | [diff] [blame] | 3936 | qp->assoc_qid, qp->q_cnt_1, qp->q_cnt_2, |
| 3937 | qp->q_cnt_3, (unsigned long long)qp->q_cnt_4); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 3938 | len += scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len, |
James Smart | 7869da1 | 2017-05-15 15:20:43 -0700 | [diff] [blame] | 3939 | "\t\tHQID[%02d], QE-CNT[%04d], QE-SZ[%04d], " |
James Smart | 32517fc | 2019-01-28 11:14:33 -0800 | [diff] [blame] | 3940 | "HST-IDX[%04d], PRT-IDX[%04d], NTFI[%03d]\n", |
James Smart | 07bcd98 | 2017-02-12 13:52:28 -0800 | [diff] [blame] | 3941 | qp->queue_id, qp->entry_count, qp->entry_size, |
James Smart | 32517fc | 2019-01-28 11:14:33 -0800 | [diff] [blame] | 3942 | qp->host_index, qp->hba_index, qp->notify_interval); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 3943 | len += scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len, |
James Smart | 7869da1 | 2017-05-15 15:20:43 -0700 | [diff] [blame] | 3944 | "\t\tDQID[%02d], QE-CNT[%04d], QE-SZ[%04d], " |
James Smart | 32517fc | 2019-01-28 11:14:33 -0800 | [diff] [blame] | 3945 | "HST-IDX[%04d], PRT-IDX[%04d], NTFI[%03d]\n", |
James Smart | 07bcd98 | 2017-02-12 13:52:28 -0800 | [diff] [blame] | 3946 | datqp->queue_id, datqp->entry_count, |
| 3947 | datqp->entry_size, datqp->host_index, |
James Smart | 32517fc | 2019-01-28 11:14:33 -0800 | [diff] [blame] | 3948 | datqp->hba_index, datqp->notify_interval); |
James Smart | 07bcd98 | 2017-02-12 13:52:28 -0800 | [diff] [blame] | 3949 | return len; |
| 3950 | } |
| 3951 | |
| 3952 | static int |
| 3953 | lpfc_idiag_cqs_for_eq(struct lpfc_hba *phba, char *pbuffer, |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 3954 | int *len, int max_cnt, int eqidx, int eq_id) |
James Smart | 07bcd98 | 2017-02-12 13:52:28 -0800 | [diff] [blame] | 3955 | { |
| 3956 | struct lpfc_queue *qp; |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 3957 | int rc; |
James Smart | 07bcd98 | 2017-02-12 13:52:28 -0800 | [diff] [blame] | 3958 | |
James Smart | c00f62e | 2019-08-14 16:57:11 -0700 | [diff] [blame] | 3959 | qp = phba->sli4_hba.hdwq[eqidx].io_cq; |
James Smart | 07bcd98 | 2017-02-12 13:52:28 -0800 | [diff] [blame] | 3960 | |
James Smart | c00f62e | 2019-08-14 16:57:11 -0700 | [diff] [blame] | 3961 | *len = __lpfc_idiag_print_cq(qp, "IO", pbuffer, *len); |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 3962 | |
| 3963 | /* Reset max counter */ |
| 3964 | qp->CQ_max_cqe = 0; |
| 3965 | |
| 3966 | if (*len >= max_cnt) |
| 3967 | return 1; |
| 3968 | |
James Smart | c00f62e | 2019-08-14 16:57:11 -0700 | [diff] [blame] | 3969 | rc = lpfc_idiag_wqs_for_cq(phba, "IO", pbuffer, len, |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 3970 | max_cnt, qp->queue_id); |
| 3971 | if (rc) |
| 3972 | return 1; |
| 3973 | |
James Smart | bcb24f6 | 2017-11-20 16:00:36 -0800 | [diff] [blame] | 3974 | if ((eqidx < phba->cfg_nvmet_mrq) && phba->nvmet_support) { |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 3975 | /* NVMET CQset */ |
| 3976 | qp = phba->sli4_hba.nvmet_cqset[eqidx]; |
| 3977 | *len = __lpfc_idiag_print_cq(qp, "NVMET CQset", pbuffer, *len); |
| 3978 | |
| 3979 | /* Reset max counter */ |
| 3980 | qp->CQ_max_cqe = 0; |
| 3981 | |
| 3982 | if (*len >= max_cnt) |
| 3983 | return 1; |
| 3984 | |
| 3985 | /* RQ header */ |
| 3986 | qp = phba->sli4_hba.nvmet_mrq_hdr[eqidx]; |
| 3987 | *len = __lpfc_idiag_print_rqpair(qp, |
| 3988 | phba->sli4_hba.nvmet_mrq_data[eqidx], |
| 3989 | "NVMET MRQ", pbuffer, *len); |
| 3990 | |
| 3991 | if (*len >= max_cnt) |
| 3992 | return 1; |
| 3993 | } |
| 3994 | |
James Smart | 07bcd98 | 2017-02-12 13:52:28 -0800 | [diff] [blame] | 3995 | return 0; |
| 3996 | } |
| 3997 | |
| 3998 | static int |
| 3999 | __lpfc_idiag_print_eq(struct lpfc_queue *qp, char *eqtype, |
| 4000 | char *pbuffer, int len) |
| 4001 | { |
| 4002 | if (!qp) |
| 4003 | return len; |
| 4004 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 4005 | len += scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len, |
James Smart | 07bcd98 | 2017-02-12 13:52:28 -0800 | [diff] [blame] | 4006 | "\n%s EQ info: EQ-STAT[max:x%x noE:x%x " |
James Smart | 07d494f | 2017-11-20 16:00:35 -0800 | [diff] [blame] | 4007 | "cqe_proc:x%x eqe_proc:x%llx eqd %d]\n", |
James Smart | 07bcd98 | 2017-02-12 13:52:28 -0800 | [diff] [blame] | 4008 | eqtype, qp->q_cnt_1, qp->q_cnt_2, qp->q_cnt_3, |
James Smart | 0cf07f84 | 2017-06-01 21:07:10 -0700 | [diff] [blame] | 4009 | (unsigned long long)qp->q_cnt_4, qp->q_mode); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 4010 | len += scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len, |
James Smart | 7869da1 | 2017-05-15 15:20:43 -0700 | [diff] [blame] | 4011 | "EQID[%02d], QE-CNT[%04d], QE-SZ[%04d], " |
James Smart | 32517fc | 2019-01-28 11:14:33 -0800 | [diff] [blame] | 4012 | "HST-IDX[%04d], NTFI[%03d], PLMT[%03d], AFFIN[%03d]", |
James Smart | 07bcd98 | 2017-02-12 13:52:28 -0800 | [diff] [blame] | 4013 | qp->queue_id, qp->entry_count, qp->entry_size, |
James Smart | 32517fc | 2019-01-28 11:14:33 -0800 | [diff] [blame] | 4014 | qp->host_index, qp->notify_interval, |
| 4015 | qp->max_proc_limit, qp->chann); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 4016 | len += scnprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len, |
| 4017 | "\n"); |
James Smart | 07bcd98 | 2017-02-12 13:52:28 -0800 | [diff] [blame] | 4018 | |
| 4019 | return len; |
| 4020 | } |
| 4021 | |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 4022 | /** |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 4023 | * lpfc_idiag_queinfo_read - idiag debugfs read queue information |
| 4024 | * @file: The file pointer to read from. |
| 4025 | * @buf: The buffer to copy the data to. |
| 4026 | * @nbytes: The number of bytes to read. |
| 4027 | * @ppos: The position in the file to start reading from. |
| 4028 | * |
| 4029 | * Description: |
| 4030 | * This routine reads data from the @phba SLI4 PCI function queue information, |
| 4031 | * and copies to user @buf. |
James Smart | 07bcd98 | 2017-02-12 13:52:28 -0800 | [diff] [blame] | 4032 | * This routine only returns 1 EQs worth of information. It remembers the last |
| 4033 | * EQ read and jumps to the next EQ. Thus subsequent calls to queInfo will |
| 4034 | * retrieve all EQs allocated for the phba. |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 4035 | * |
| 4036 | * Returns: |
| 4037 | * This function returns the amount of data that was read (this could be less |
| 4038 | * than @nbytes if the end of the file was reached) or a negative error value. |
| 4039 | **/ |
| 4040 | static ssize_t |
| 4041 | lpfc_idiag_queinfo_read(struct file *file, char __user *buf, size_t nbytes, |
| 4042 | loff_t *ppos) |
| 4043 | { |
| 4044 | struct lpfc_debug *debug = file->private_data; |
| 4045 | struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private; |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 4046 | char *pbuffer; |
James Smart | 07bcd98 | 2017-02-12 13:52:28 -0800 | [diff] [blame] | 4047 | int max_cnt, rc, x, len = 0; |
James Smart | c85a65a | 2012-08-03 12:37:00 -0400 | [diff] [blame] | 4048 | struct lpfc_queue *qp = NULL; |
| 4049 | |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 4050 | if (!debug->buffer) |
| 4051 | debug->buffer = kmalloc(LPFC_QUE_INFO_GET_BUF_SIZE, GFP_KERNEL); |
| 4052 | if (!debug->buffer) |
| 4053 | return 0; |
| 4054 | pbuffer = debug->buffer; |
James Smart | 07bcd98 | 2017-02-12 13:52:28 -0800 | [diff] [blame] | 4055 | max_cnt = LPFC_QUE_INFO_GET_BUF_SIZE - 256; |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 4056 | |
| 4057 | if (*ppos) |
| 4058 | return 0; |
| 4059 | |
James Smart | c85a65a | 2012-08-03 12:37:00 -0400 | [diff] [blame] | 4060 | spin_lock_irq(&phba->hbalock); |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 4061 | |
James Smart | c85a65a | 2012-08-03 12:37:00 -0400 | [diff] [blame] | 4062 | /* Fast-path event queue */ |
James Smart | cdb42be | 2019-01-28 11:14:21 -0800 | [diff] [blame] | 4063 | if (phba->sli4_hba.hdwq && phba->cfg_hdw_queue) { |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 4064 | |
James Smart | 07bcd98 | 2017-02-12 13:52:28 -0800 | [diff] [blame] | 4065 | x = phba->lpfc_idiag_last_eq; |
James Smart | 07bcd98 | 2017-02-12 13:52:28 -0800 | [diff] [blame] | 4066 | phba->lpfc_idiag_last_eq++; |
James Smart | cdb42be | 2019-01-28 11:14:21 -0800 | [diff] [blame] | 4067 | if (phba->lpfc_idiag_last_eq >= phba->cfg_hdw_queue) |
James Smart | 7370d10 | 2019-01-28 11:14:20 -0800 | [diff] [blame] | 4068 | phba->lpfc_idiag_last_eq = 0; |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 4069 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 4070 | len += scnprintf(pbuffer + len, |
| 4071 | LPFC_QUE_INFO_GET_BUF_SIZE - len, |
| 4072 | "HDWQ %d out of %d HBA HDWQs\n", |
| 4073 | x, phba->cfg_hdw_queue); |
James Smart | 07bcd98 | 2017-02-12 13:52:28 -0800 | [diff] [blame] | 4074 | |
| 4075 | /* Fast-path EQ */ |
James Smart | cdb42be | 2019-01-28 11:14:21 -0800 | [diff] [blame] | 4076 | qp = phba->sli4_hba.hdwq[x].hba_eq; |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 4077 | if (!qp) |
| 4078 | goto out; |
| 4079 | |
James Smart | 07bcd98 | 2017-02-12 13:52:28 -0800 | [diff] [blame] | 4080 | len = __lpfc_idiag_print_eq(qp, "HBA", pbuffer, len); |
James Smart | 1ba981f | 2014-02-20 09:56:45 -0500 | [diff] [blame] | 4081 | |
| 4082 | /* Reset max counter */ |
| 4083 | qp->EQ_max_eqe = 0; |
| 4084 | |
James Smart | 07bcd98 | 2017-02-12 13:52:28 -0800 | [diff] [blame] | 4085 | if (len >= max_cnt) |
| 4086 | goto too_big; |
| 4087 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 4088 | /* will dump both fcp and nvme cqs/wqs for the eq */ |
James Smart | 07bcd98 | 2017-02-12 13:52:28 -0800 | [diff] [blame] | 4089 | rc = lpfc_idiag_cqs_for_eq(phba, pbuffer, &len, |
James Smart | 2d7dbc4 | 2017-02-12 13:52:35 -0800 | [diff] [blame] | 4090 | max_cnt, x, qp->queue_id); |
James Smart | 07bcd98 | 2017-02-12 13:52:28 -0800 | [diff] [blame] | 4091 | if (rc) |
| 4092 | goto too_big; |
| 4093 | |
| 4094 | /* Only EQ 0 has slow path CQs configured */ |
| 4095 | if (x) |
| 4096 | goto out; |
| 4097 | |
| 4098 | /* Slow-path mailbox CQ */ |
| 4099 | qp = phba->sli4_hba.mbx_cq; |
| 4100 | len = __lpfc_idiag_print_cq(qp, "MBX", pbuffer, len); |
| 4101 | if (len >= max_cnt) |
| 4102 | goto too_big; |
| 4103 | |
| 4104 | /* Slow-path MBOX MQ */ |
| 4105 | qp = phba->sli4_hba.mbx_wq; |
| 4106 | len = __lpfc_idiag_print_wq(qp, "MBX", pbuffer, len); |
| 4107 | if (len >= max_cnt) |
| 4108 | goto too_big; |
| 4109 | |
| 4110 | /* Slow-path ELS response CQ */ |
| 4111 | qp = phba->sli4_hba.els_cq; |
| 4112 | len = __lpfc_idiag_print_cq(qp, "ELS", pbuffer, len); |
| 4113 | /* Reset max counter */ |
| 4114 | if (qp) |
| 4115 | qp->CQ_max_cqe = 0; |
| 4116 | if (len >= max_cnt) |
| 4117 | goto too_big; |
| 4118 | |
| 4119 | /* Slow-path ELS WQ */ |
| 4120 | qp = phba->sli4_hba.els_wq; |
| 4121 | len = __lpfc_idiag_print_wq(qp, "ELS", pbuffer, len); |
| 4122 | if (len >= max_cnt) |
| 4123 | goto too_big; |
| 4124 | |
James Smart | 07d494f | 2017-11-20 16:00:35 -0800 | [diff] [blame] | 4125 | qp = phba->sli4_hba.hdr_rq; |
| 4126 | len = __lpfc_idiag_print_rqpair(qp, phba->sli4_hba.dat_rq, |
| 4127 | "ELS RQpair", pbuffer, len); |
| 4128 | if (len >= max_cnt) |
| 4129 | goto too_big; |
| 4130 | |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 4131 | /* Slow-path NVME LS response CQ */ |
| 4132 | qp = phba->sli4_hba.nvmels_cq; |
| 4133 | len = __lpfc_idiag_print_cq(qp, "NVME LS", |
| 4134 | pbuffer, len); |
| 4135 | /* Reset max counter */ |
| 4136 | if (qp) |
| 4137 | qp->CQ_max_cqe = 0; |
| 4138 | if (len >= max_cnt) |
| 4139 | goto too_big; |
| 4140 | |
| 4141 | /* Slow-path NVME LS WQ */ |
| 4142 | qp = phba->sli4_hba.nvmels_wq; |
| 4143 | len = __lpfc_idiag_print_wq(qp, "NVME LS", |
| 4144 | pbuffer, len); |
| 4145 | if (len >= max_cnt) |
| 4146 | goto too_big; |
| 4147 | |
James Smart | 07bcd98 | 2017-02-12 13:52:28 -0800 | [diff] [blame] | 4148 | goto out; |
| 4149 | } |
| 4150 | |
James Smart | c85a65a | 2012-08-03 12:37:00 -0400 | [diff] [blame] | 4151 | spin_unlock_irq(&phba->hbalock); |
| 4152 | return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len); |
| 4153 | |
| 4154 | too_big: |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 4155 | len += scnprintf(pbuffer + len, |
James Smart | 07bcd98 | 2017-02-12 13:52:28 -0800 | [diff] [blame] | 4156 | LPFC_QUE_INFO_GET_BUF_SIZE - len, "Truncated ...\n"); |
| 4157 | out: |
James Smart | c85a65a | 2012-08-03 12:37:00 -0400 | [diff] [blame] | 4158 | spin_unlock_irq(&phba->hbalock); |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 4159 | return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len); |
| 4160 | } |
| 4161 | |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 4162 | /** |
| 4163 | * lpfc_idiag_que_param_check - queue access command parameter sanity check |
| 4164 | * @q: The pointer to queue structure. |
| 4165 | * @index: The index into a queue entry. |
| 4166 | * @count: The number of queue entries to access. |
| 4167 | * |
| 4168 | * Description: |
| 4169 | * The routine performs sanity check on device queue access method commands. |
| 4170 | * |
| 4171 | * Returns: |
| 4172 | * This function returns -EINVAL when fails the sanity check, otherwise, it |
| 4173 | * returns 0. |
| 4174 | **/ |
| 4175 | static int |
| 4176 | lpfc_idiag_que_param_check(struct lpfc_queue *q, int index, int count) |
| 4177 | { |
| 4178 | /* Only support single entry read or browsing */ |
| 4179 | if ((count != 1) && (count != LPFC_QUE_ACC_BROWSE)) |
| 4180 | return -EINVAL; |
| 4181 | if (index > q->entry_count - 1) |
| 4182 | return -EINVAL; |
| 4183 | return 0; |
| 4184 | } |
| 4185 | |
| 4186 | /** |
| 4187 | * lpfc_idiag_queacc_read_qe - read a single entry from the given queue index |
| 4188 | * @pbuffer: The pointer to buffer to copy the read data into. |
| 4189 | * @pque: The pointer to the queue to be read. |
| 4190 | * @index: The index into the queue entry. |
| 4191 | * |
| 4192 | * Description: |
| 4193 | * This routine reads out a single entry from the given queue's index location |
| 4194 | * and copies it into the buffer provided. |
| 4195 | * |
| 4196 | * Returns: |
| 4197 | * This function returns 0 when it fails, otherwise, it returns the length of |
| 4198 | * the data read into the buffer provided. |
| 4199 | **/ |
| 4200 | static int |
| 4201 | lpfc_idiag_queacc_read_qe(char *pbuffer, int len, struct lpfc_queue *pque, |
| 4202 | uint32_t index) |
| 4203 | { |
| 4204 | int offset, esize; |
| 4205 | uint32_t *pentry; |
| 4206 | |
| 4207 | if (!pbuffer || !pque) |
| 4208 | return 0; |
| 4209 | |
| 4210 | esize = pque->entry_size; |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 4211 | len += scnprintf(pbuffer+len, LPFC_QUE_ACC_BUF_SIZE-len, |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 4212 | "QE-INDEX[%04d]:\n", index); |
| 4213 | |
| 4214 | offset = 0; |
James Smart | 9afbee3 | 2019-03-12 16:30:28 -0700 | [diff] [blame] | 4215 | pentry = lpfc_sli4_qe(pque, index); |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 4216 | while (esize > 0) { |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 4217 | len += scnprintf(pbuffer+len, LPFC_QUE_ACC_BUF_SIZE-len, |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 4218 | "%08x ", *pentry); |
| 4219 | pentry++; |
| 4220 | offset += sizeof(uint32_t); |
| 4221 | esize -= sizeof(uint32_t); |
| 4222 | if (esize > 0 && !(offset % (4 * sizeof(uint32_t)))) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 4223 | len += scnprintf(pbuffer+len, |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 4224 | LPFC_QUE_ACC_BUF_SIZE-len, "\n"); |
| 4225 | } |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 4226 | len += scnprintf(pbuffer+len, LPFC_QUE_ACC_BUF_SIZE-len, "\n"); |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 4227 | |
| 4228 | return len; |
| 4229 | } |
| 4230 | |
| 4231 | /** |
| 4232 | * lpfc_idiag_queacc_read - idiag debugfs read port queue |
| 4233 | * @file: The file pointer to read from. |
| 4234 | * @buf: The buffer to copy the data to. |
| 4235 | * @nbytes: The number of bytes to read. |
| 4236 | * @ppos: The position in the file to start reading from. |
| 4237 | * |
| 4238 | * Description: |
| 4239 | * This routine reads data from the @phba device queue memory according to the |
| 4240 | * idiag command, and copies to user @buf. Depending on the queue dump read |
| 4241 | * command setup, it does either a single queue entry read or browing through |
| 4242 | * all entries of the queue. |
| 4243 | * |
| 4244 | * Returns: |
| 4245 | * This function returns the amount of data that was read (this could be less |
| 4246 | * than @nbytes if the end of the file was reached) or a negative error value. |
| 4247 | **/ |
| 4248 | static ssize_t |
| 4249 | lpfc_idiag_queacc_read(struct file *file, char __user *buf, size_t nbytes, |
| 4250 | loff_t *ppos) |
| 4251 | { |
| 4252 | struct lpfc_debug *debug = file->private_data; |
| 4253 | uint32_t last_index, index, count; |
| 4254 | struct lpfc_queue *pque = NULL; |
| 4255 | char *pbuffer; |
| 4256 | int len = 0; |
| 4257 | |
| 4258 | /* This is a user read operation */ |
| 4259 | debug->op = LPFC_IDIAG_OP_RD; |
| 4260 | |
| 4261 | if (!debug->buffer) |
| 4262 | debug->buffer = kmalloc(LPFC_QUE_ACC_BUF_SIZE, GFP_KERNEL); |
| 4263 | if (!debug->buffer) |
| 4264 | return 0; |
| 4265 | pbuffer = debug->buffer; |
| 4266 | |
| 4267 | if (*ppos) |
| 4268 | return 0; |
| 4269 | |
| 4270 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_QUEACC_RD) { |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 4271 | index = idiag.cmd.data[IDIAG_QUEACC_INDEX_INDX]; |
| 4272 | count = idiag.cmd.data[IDIAG_QUEACC_COUNT_INDX]; |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 4273 | pque = (struct lpfc_queue *)idiag.ptr_private; |
| 4274 | } else |
| 4275 | return 0; |
| 4276 | |
| 4277 | /* Browse the queue starting from index */ |
| 4278 | if (count == LPFC_QUE_ACC_BROWSE) |
| 4279 | goto que_browse; |
| 4280 | |
| 4281 | /* Read a single entry from the queue */ |
| 4282 | len = lpfc_idiag_queacc_read_qe(pbuffer, len, pque, index); |
| 4283 | |
| 4284 | return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len); |
| 4285 | |
| 4286 | que_browse: |
| 4287 | |
| 4288 | /* Browse all entries from the queue */ |
| 4289 | last_index = idiag.offset.last_rd; |
| 4290 | index = last_index; |
| 4291 | |
| 4292 | while (len < LPFC_QUE_ACC_SIZE - pque->entry_size) { |
| 4293 | len = lpfc_idiag_queacc_read_qe(pbuffer, len, pque, index); |
| 4294 | index++; |
| 4295 | if (index > pque->entry_count - 1) |
| 4296 | break; |
| 4297 | } |
| 4298 | |
| 4299 | /* Set up the offset for next portion of pci cfg read */ |
| 4300 | if (index > pque->entry_count - 1) |
| 4301 | index = 0; |
| 4302 | idiag.offset.last_rd = index; |
| 4303 | |
| 4304 | return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len); |
| 4305 | } |
| 4306 | |
| 4307 | /** |
| 4308 | * lpfc_idiag_queacc_write - Syntax check and set up idiag queacc commands |
| 4309 | * @file: The file pointer to read from. |
| 4310 | * @buf: The buffer to copy the user data from. |
| 4311 | * @nbytes: The number of bytes to get. |
| 4312 | * @ppos: The position in the file to start reading from. |
| 4313 | * |
| 4314 | * This routine get the debugfs idiag command struct from user space and then |
| 4315 | * perform the syntax check for port queue read (dump) or write (set) command |
| 4316 | * accordingly. In the case of port queue read command, it sets up the command |
| 4317 | * in the idiag command struct for the following debugfs read operation. In |
| 4318 | * the case of port queue write operation, it executes the write operation |
| 4319 | * into the port queue entry accordingly. |
| 4320 | * |
| 4321 | * It returns the @nbytges passing in from debugfs user space when successful. |
| 4322 | * In case of error conditions, it returns proper error code back to the user |
| 4323 | * space. |
| 4324 | **/ |
| 4325 | static ssize_t |
| 4326 | lpfc_idiag_queacc_write(struct file *file, const char __user *buf, |
| 4327 | size_t nbytes, loff_t *ppos) |
| 4328 | { |
| 4329 | struct lpfc_debug *debug = file->private_data; |
| 4330 | struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private; |
| 4331 | uint32_t qidx, quetp, queid, index, count, offset, value; |
| 4332 | uint32_t *pentry; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 4333 | struct lpfc_queue *pque, *qp; |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 4334 | int rc; |
| 4335 | |
| 4336 | /* This is a user write operation */ |
| 4337 | debug->op = LPFC_IDIAG_OP_WR; |
| 4338 | |
| 4339 | rc = lpfc_idiag_cmd_get(buf, nbytes, &idiag.cmd); |
| 4340 | if (rc < 0) |
| 4341 | return rc; |
| 4342 | |
| 4343 | /* Get and sanity check on command feilds */ |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 4344 | quetp = idiag.cmd.data[IDIAG_QUEACC_QUETP_INDX]; |
| 4345 | queid = idiag.cmd.data[IDIAG_QUEACC_QUEID_INDX]; |
| 4346 | index = idiag.cmd.data[IDIAG_QUEACC_INDEX_INDX]; |
| 4347 | count = idiag.cmd.data[IDIAG_QUEACC_COUNT_INDX]; |
| 4348 | offset = idiag.cmd.data[IDIAG_QUEACC_OFFST_INDX]; |
| 4349 | value = idiag.cmd.data[IDIAG_QUEACC_VALUE_INDX]; |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 4350 | |
| 4351 | /* Sanity check on command line arguments */ |
| 4352 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_QUEACC_WR || |
| 4353 | idiag.cmd.opcode == LPFC_IDIAG_CMD_QUEACC_ST || |
| 4354 | idiag.cmd.opcode == LPFC_IDIAG_CMD_QUEACC_CL) { |
| 4355 | if (rc != LPFC_QUE_ACC_WR_CMD_ARG) |
| 4356 | goto error_out; |
| 4357 | if (count != 1) |
| 4358 | goto error_out; |
| 4359 | } else if (idiag.cmd.opcode == LPFC_IDIAG_CMD_QUEACC_RD) { |
| 4360 | if (rc != LPFC_QUE_ACC_RD_CMD_ARG) |
| 4361 | goto error_out; |
| 4362 | } else |
| 4363 | goto error_out; |
| 4364 | |
| 4365 | switch (quetp) { |
| 4366 | case LPFC_IDIAG_EQ: |
James Smart | 67d1273 | 2012-08-03 12:36:13 -0400 | [diff] [blame] | 4367 | /* HBA event queue */ |
James Smart | cdb42be | 2019-01-28 11:14:21 -0800 | [diff] [blame] | 4368 | if (phba->sli4_hba.hdwq) { |
| 4369 | for (qidx = 0; qidx < phba->cfg_hdw_queue; qidx++) { |
| 4370 | qp = phba->sli4_hba.hdwq[qidx].hba_eq; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 4371 | if (qp && qp->queue_id == queid) { |
James Smart | 2e90f4b | 2011-12-13 13:22:37 -0500 | [diff] [blame] | 4372 | /* Sanity check */ |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 4373 | rc = lpfc_idiag_que_param_check(qp, |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 4374 | index, count); |
James Smart | 2e90f4b | 2011-12-13 13:22:37 -0500 | [diff] [blame] | 4375 | if (rc) |
| 4376 | goto error_out; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 4377 | idiag.ptr_private = qp; |
James Smart | 2e90f4b | 2011-12-13 13:22:37 -0500 | [diff] [blame] | 4378 | goto pass_check; |
| 4379 | } |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 4380 | } |
| 4381 | } |
| 4382 | goto error_out; |
Tom Rix | 170b7d2 | 2020-10-19 07:23:33 -0700 | [diff] [blame^] | 4383 | |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 4384 | case LPFC_IDIAG_CQ: |
| 4385 | /* MBX complete queue */ |
James Smart | 2e90f4b | 2011-12-13 13:22:37 -0500 | [diff] [blame] | 4386 | if (phba->sli4_hba.mbx_cq && |
| 4387 | phba->sli4_hba.mbx_cq->queue_id == queid) { |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 4388 | /* Sanity check */ |
| 4389 | rc = lpfc_idiag_que_param_check( |
| 4390 | phba->sli4_hba.mbx_cq, index, count); |
| 4391 | if (rc) |
| 4392 | goto error_out; |
| 4393 | idiag.ptr_private = phba->sli4_hba.mbx_cq; |
| 4394 | goto pass_check; |
| 4395 | } |
| 4396 | /* ELS complete queue */ |
James Smart | 2e90f4b | 2011-12-13 13:22:37 -0500 | [diff] [blame] | 4397 | if (phba->sli4_hba.els_cq && |
| 4398 | phba->sli4_hba.els_cq->queue_id == queid) { |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 4399 | /* Sanity check */ |
| 4400 | rc = lpfc_idiag_que_param_check( |
| 4401 | phba->sli4_hba.els_cq, index, count); |
| 4402 | if (rc) |
| 4403 | goto error_out; |
| 4404 | idiag.ptr_private = phba->sli4_hba.els_cq; |
| 4405 | goto pass_check; |
| 4406 | } |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 4407 | /* NVME LS complete queue */ |
| 4408 | if (phba->sli4_hba.nvmels_cq && |
| 4409 | phba->sli4_hba.nvmels_cq->queue_id == queid) { |
| 4410 | /* Sanity check */ |
| 4411 | rc = lpfc_idiag_que_param_check( |
| 4412 | phba->sli4_hba.nvmels_cq, index, count); |
| 4413 | if (rc) |
| 4414 | goto error_out; |
| 4415 | idiag.ptr_private = phba->sli4_hba.nvmels_cq; |
| 4416 | goto pass_check; |
| 4417 | } |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 4418 | /* FCP complete queue */ |
James Smart | cdb42be | 2019-01-28 11:14:21 -0800 | [diff] [blame] | 4419 | if (phba->sli4_hba.hdwq) { |
| 4420 | for (qidx = 0; qidx < phba->cfg_hdw_queue; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 4421 | qidx++) { |
James Smart | c00f62e | 2019-08-14 16:57:11 -0700 | [diff] [blame] | 4422 | qp = phba->sli4_hba.hdwq[qidx].io_cq; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 4423 | if (qp && qp->queue_id == queid) { |
James Smart | 2e90f4b | 2011-12-13 13:22:37 -0500 | [diff] [blame] | 4424 | /* Sanity check */ |
| 4425 | rc = lpfc_idiag_que_param_check( |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 4426 | qp, index, count); |
James Smart | 2e90f4b | 2011-12-13 13:22:37 -0500 | [diff] [blame] | 4427 | if (rc) |
| 4428 | goto error_out; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 4429 | idiag.ptr_private = qp; |
James Smart | 2e90f4b | 2011-12-13 13:22:37 -0500 | [diff] [blame] | 4430 | goto pass_check; |
| 4431 | } |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 4432 | } |
James Smart | 2e90f4b | 2011-12-13 13:22:37 -0500 | [diff] [blame] | 4433 | } |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 4434 | goto error_out; |
Tom Rix | 170b7d2 | 2020-10-19 07:23:33 -0700 | [diff] [blame^] | 4435 | |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 4436 | case LPFC_IDIAG_MQ: |
| 4437 | /* MBX work queue */ |
James Smart | 2e90f4b | 2011-12-13 13:22:37 -0500 | [diff] [blame] | 4438 | if (phba->sli4_hba.mbx_wq && |
| 4439 | phba->sli4_hba.mbx_wq->queue_id == queid) { |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 4440 | /* Sanity check */ |
| 4441 | rc = lpfc_idiag_que_param_check( |
| 4442 | phba->sli4_hba.mbx_wq, index, count); |
| 4443 | if (rc) |
| 4444 | goto error_out; |
| 4445 | idiag.ptr_private = phba->sli4_hba.mbx_wq; |
| 4446 | goto pass_check; |
| 4447 | } |
James Smart | 2e90f4b | 2011-12-13 13:22:37 -0500 | [diff] [blame] | 4448 | goto error_out; |
Tom Rix | 170b7d2 | 2020-10-19 07:23:33 -0700 | [diff] [blame^] | 4449 | |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 4450 | case LPFC_IDIAG_WQ: |
| 4451 | /* ELS work queue */ |
James Smart | 2e90f4b | 2011-12-13 13:22:37 -0500 | [diff] [blame] | 4452 | if (phba->sli4_hba.els_wq && |
| 4453 | phba->sli4_hba.els_wq->queue_id == queid) { |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 4454 | /* Sanity check */ |
| 4455 | rc = lpfc_idiag_que_param_check( |
| 4456 | phba->sli4_hba.els_wq, index, count); |
| 4457 | if (rc) |
| 4458 | goto error_out; |
| 4459 | idiag.ptr_private = phba->sli4_hba.els_wq; |
| 4460 | goto pass_check; |
| 4461 | } |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 4462 | /* NVME LS work queue */ |
| 4463 | if (phba->sli4_hba.nvmels_wq && |
| 4464 | phba->sli4_hba.nvmels_wq->queue_id == queid) { |
| 4465 | /* Sanity check */ |
| 4466 | rc = lpfc_idiag_que_param_check( |
| 4467 | phba->sli4_hba.nvmels_wq, index, count); |
| 4468 | if (rc) |
| 4469 | goto error_out; |
| 4470 | idiag.ptr_private = phba->sli4_hba.nvmels_wq; |
| 4471 | goto pass_check; |
| 4472 | } |
James Smart | cdb42be | 2019-01-28 11:14:21 -0800 | [diff] [blame] | 4473 | |
| 4474 | if (phba->sli4_hba.hdwq) { |
| 4475 | /* FCP/SCSI work queue */ |
| 4476 | for (qidx = 0; qidx < phba->cfg_hdw_queue; qidx++) { |
James Smart | c00f62e | 2019-08-14 16:57:11 -0700 | [diff] [blame] | 4477 | qp = phba->sli4_hba.hdwq[qidx].io_wq; |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 4478 | if (qp && qp->queue_id == queid) { |
| 4479 | /* Sanity check */ |
| 4480 | rc = lpfc_idiag_que_param_check( |
| 4481 | qp, index, count); |
| 4482 | if (rc) |
| 4483 | goto error_out; |
| 4484 | idiag.ptr_private = qp; |
James Smart | 2e90f4b | 2011-12-13 13:22:37 -0500 | [diff] [blame] | 4485 | goto pass_check; |
| 4486 | } |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 4487 | } |
| 4488 | } |
| 4489 | goto error_out; |
Tom Rix | 170b7d2 | 2020-10-19 07:23:33 -0700 | [diff] [blame^] | 4490 | |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 4491 | case LPFC_IDIAG_RQ: |
| 4492 | /* HDR queue */ |
James Smart | 2e90f4b | 2011-12-13 13:22:37 -0500 | [diff] [blame] | 4493 | if (phba->sli4_hba.hdr_rq && |
| 4494 | phba->sli4_hba.hdr_rq->queue_id == queid) { |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 4495 | /* Sanity check */ |
| 4496 | rc = lpfc_idiag_que_param_check( |
| 4497 | phba->sli4_hba.hdr_rq, index, count); |
| 4498 | if (rc) |
| 4499 | goto error_out; |
| 4500 | idiag.ptr_private = phba->sli4_hba.hdr_rq; |
| 4501 | goto pass_check; |
| 4502 | } |
| 4503 | /* DAT queue */ |
James Smart | 2e90f4b | 2011-12-13 13:22:37 -0500 | [diff] [blame] | 4504 | if (phba->sli4_hba.dat_rq && |
| 4505 | phba->sli4_hba.dat_rq->queue_id == queid) { |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 4506 | /* Sanity check */ |
| 4507 | rc = lpfc_idiag_que_param_check( |
| 4508 | phba->sli4_hba.dat_rq, index, count); |
| 4509 | if (rc) |
| 4510 | goto error_out; |
| 4511 | idiag.ptr_private = phba->sli4_hba.dat_rq; |
| 4512 | goto pass_check; |
| 4513 | } |
| 4514 | goto error_out; |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 4515 | default: |
| 4516 | goto error_out; |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 4517 | } |
| 4518 | |
| 4519 | pass_check: |
| 4520 | |
| 4521 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_QUEACC_RD) { |
| 4522 | if (count == LPFC_QUE_ACC_BROWSE) |
| 4523 | idiag.offset.last_rd = index; |
| 4524 | } |
| 4525 | |
| 4526 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_QUEACC_WR || |
| 4527 | idiag.cmd.opcode == LPFC_IDIAG_CMD_QUEACC_ST || |
| 4528 | idiag.cmd.opcode == LPFC_IDIAG_CMD_QUEACC_CL) { |
| 4529 | /* Additional sanity checks on write operation */ |
| 4530 | pque = (struct lpfc_queue *)idiag.ptr_private; |
| 4531 | if (offset > pque->entry_size/sizeof(uint32_t) - 1) |
| 4532 | goto error_out; |
James Smart | 9afbee3 | 2019-03-12 16:30:28 -0700 | [diff] [blame] | 4533 | pentry = lpfc_sli4_qe(pque, index); |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 4534 | pentry += offset; |
| 4535 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_QUEACC_WR) |
| 4536 | *pentry = value; |
| 4537 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_QUEACC_ST) |
| 4538 | *pentry |= value; |
| 4539 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_QUEACC_CL) |
| 4540 | *pentry &= ~value; |
| 4541 | } |
| 4542 | return nbytes; |
| 4543 | |
| 4544 | error_out: |
| 4545 | /* Clean out command structure on command error out */ |
| 4546 | memset(&idiag, 0, sizeof(idiag)); |
| 4547 | return -EINVAL; |
| 4548 | } |
| 4549 | |
| 4550 | /** |
| 4551 | * lpfc_idiag_drbacc_read_reg - idiag debugfs read a doorbell register |
| 4552 | * @phba: The pointer to hba structure. |
| 4553 | * @pbuffer: The pointer to the buffer to copy the data to. |
Matteo Croce | 92684bf | 2019-01-04 22:38:54 +0100 | [diff] [blame] | 4554 | * @len: The length of bytes to copied. |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 4555 | * @drbregid: The id to doorbell registers. |
| 4556 | * |
| 4557 | * Description: |
| 4558 | * This routine reads a doorbell register and copies its content to the |
| 4559 | * user buffer pointed to by @pbuffer. |
| 4560 | * |
| 4561 | * Returns: |
| 4562 | * This function returns the amount of data that was copied into @pbuffer. |
| 4563 | **/ |
| 4564 | static int |
| 4565 | lpfc_idiag_drbacc_read_reg(struct lpfc_hba *phba, char *pbuffer, |
| 4566 | int len, uint32_t drbregid) |
| 4567 | { |
| 4568 | |
| 4569 | if (!pbuffer) |
| 4570 | return 0; |
| 4571 | |
| 4572 | switch (drbregid) { |
James Smart | 9dd3542 | 2018-02-22 08:18:41 -0800 | [diff] [blame] | 4573 | case LPFC_DRB_EQ: |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 4574 | len += scnprintf(pbuffer + len, LPFC_DRB_ACC_BUF_SIZE-len, |
James Smart | 9dd3542 | 2018-02-22 08:18:41 -0800 | [diff] [blame] | 4575 | "EQ-DRB-REG: 0x%08x\n", |
| 4576 | readl(phba->sli4_hba.EQDBregaddr)); |
| 4577 | break; |
| 4578 | case LPFC_DRB_CQ: |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 4579 | len += scnprintf(pbuffer + len, LPFC_DRB_ACC_BUF_SIZE - len, |
James Smart | 9dd3542 | 2018-02-22 08:18:41 -0800 | [diff] [blame] | 4580 | "CQ-DRB-REG: 0x%08x\n", |
| 4581 | readl(phba->sli4_hba.CQDBregaddr)); |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 4582 | break; |
| 4583 | case LPFC_DRB_MQ: |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 4584 | len += scnprintf(pbuffer+len, LPFC_DRB_ACC_BUF_SIZE-len, |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 4585 | "MQ-DRB-REG: 0x%08x\n", |
| 4586 | readl(phba->sli4_hba.MQDBregaddr)); |
| 4587 | break; |
| 4588 | case LPFC_DRB_WQ: |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 4589 | len += scnprintf(pbuffer+len, LPFC_DRB_ACC_BUF_SIZE-len, |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 4590 | "WQ-DRB-REG: 0x%08x\n", |
| 4591 | readl(phba->sli4_hba.WQDBregaddr)); |
| 4592 | break; |
| 4593 | case LPFC_DRB_RQ: |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 4594 | len += scnprintf(pbuffer+len, LPFC_DRB_ACC_BUF_SIZE-len, |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 4595 | "RQ-DRB-REG: 0x%08x\n", |
| 4596 | readl(phba->sli4_hba.RQDBregaddr)); |
| 4597 | break; |
| 4598 | default: |
| 4599 | break; |
| 4600 | } |
| 4601 | |
| 4602 | return len; |
| 4603 | } |
| 4604 | |
| 4605 | /** |
| 4606 | * lpfc_idiag_drbacc_read - idiag debugfs read port doorbell |
| 4607 | * @file: The file pointer to read from. |
| 4608 | * @buf: The buffer to copy the data to. |
| 4609 | * @nbytes: The number of bytes to read. |
| 4610 | * @ppos: The position in the file to start reading from. |
| 4611 | * |
| 4612 | * Description: |
| 4613 | * This routine reads data from the @phba device doorbell register according |
| 4614 | * to the idiag command, and copies to user @buf. Depending on the doorbell |
| 4615 | * register read command setup, it does either a single doorbell register |
| 4616 | * read or dump all doorbell registers. |
| 4617 | * |
| 4618 | * Returns: |
| 4619 | * This function returns the amount of data that was read (this could be less |
| 4620 | * than @nbytes if the end of the file was reached) or a negative error value. |
| 4621 | **/ |
| 4622 | static ssize_t |
| 4623 | lpfc_idiag_drbacc_read(struct file *file, char __user *buf, size_t nbytes, |
| 4624 | loff_t *ppos) |
| 4625 | { |
| 4626 | struct lpfc_debug *debug = file->private_data; |
| 4627 | struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private; |
| 4628 | uint32_t drb_reg_id, i; |
| 4629 | char *pbuffer; |
| 4630 | int len = 0; |
| 4631 | |
| 4632 | /* This is a user read operation */ |
| 4633 | debug->op = LPFC_IDIAG_OP_RD; |
| 4634 | |
| 4635 | if (!debug->buffer) |
| 4636 | debug->buffer = kmalloc(LPFC_DRB_ACC_BUF_SIZE, GFP_KERNEL); |
| 4637 | if (!debug->buffer) |
| 4638 | return 0; |
| 4639 | pbuffer = debug->buffer; |
| 4640 | |
| 4641 | if (*ppos) |
| 4642 | return 0; |
| 4643 | |
| 4644 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_DRBACC_RD) |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 4645 | drb_reg_id = idiag.cmd.data[IDIAG_DRBACC_REGID_INDX]; |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 4646 | else |
| 4647 | return 0; |
| 4648 | |
| 4649 | if (drb_reg_id == LPFC_DRB_ACC_ALL) |
| 4650 | for (i = 1; i <= LPFC_DRB_MAX; i++) |
| 4651 | len = lpfc_idiag_drbacc_read_reg(phba, |
| 4652 | pbuffer, len, i); |
| 4653 | else |
| 4654 | len = lpfc_idiag_drbacc_read_reg(phba, |
| 4655 | pbuffer, len, drb_reg_id); |
| 4656 | |
| 4657 | return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len); |
| 4658 | } |
| 4659 | |
| 4660 | /** |
| 4661 | * lpfc_idiag_drbacc_write - Syntax check and set up idiag drbacc commands |
| 4662 | * @file: The file pointer to read from. |
| 4663 | * @buf: The buffer to copy the user data from. |
| 4664 | * @nbytes: The number of bytes to get. |
| 4665 | * @ppos: The position in the file to start reading from. |
| 4666 | * |
| 4667 | * This routine get the debugfs idiag command struct from user space and then |
| 4668 | * perform the syntax check for port doorbell register read (dump) or write |
| 4669 | * (set) command accordingly. In the case of port queue read command, it sets |
| 4670 | * up the command in the idiag command struct for the following debugfs read |
| 4671 | * operation. In the case of port doorbell register write operation, it |
| 4672 | * executes the write operation into the port doorbell register accordingly. |
| 4673 | * |
| 4674 | * It returns the @nbytges passing in from debugfs user space when successful. |
| 4675 | * In case of error conditions, it returns proper error code back to the user |
| 4676 | * space. |
| 4677 | **/ |
| 4678 | static ssize_t |
| 4679 | lpfc_idiag_drbacc_write(struct file *file, const char __user *buf, |
| 4680 | size_t nbytes, loff_t *ppos) |
| 4681 | { |
| 4682 | struct lpfc_debug *debug = file->private_data; |
| 4683 | struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private; |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 4684 | uint32_t drb_reg_id, value, reg_val = 0; |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 4685 | void __iomem *drb_reg; |
| 4686 | int rc; |
| 4687 | |
| 4688 | /* This is a user write operation */ |
| 4689 | debug->op = LPFC_IDIAG_OP_WR; |
| 4690 | |
| 4691 | rc = lpfc_idiag_cmd_get(buf, nbytes, &idiag.cmd); |
| 4692 | if (rc < 0) |
| 4693 | return rc; |
| 4694 | |
| 4695 | /* Sanity check on command line arguments */ |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 4696 | drb_reg_id = idiag.cmd.data[IDIAG_DRBACC_REGID_INDX]; |
| 4697 | value = idiag.cmd.data[IDIAG_DRBACC_VALUE_INDX]; |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 4698 | |
| 4699 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_DRBACC_WR || |
| 4700 | idiag.cmd.opcode == LPFC_IDIAG_CMD_DRBACC_ST || |
| 4701 | idiag.cmd.opcode == LPFC_IDIAG_CMD_DRBACC_CL) { |
| 4702 | if (rc != LPFC_DRB_ACC_WR_CMD_ARG) |
| 4703 | goto error_out; |
| 4704 | if (drb_reg_id > LPFC_DRB_MAX) |
| 4705 | goto error_out; |
| 4706 | } else if (idiag.cmd.opcode == LPFC_IDIAG_CMD_DRBACC_RD) { |
| 4707 | if (rc != LPFC_DRB_ACC_RD_CMD_ARG) |
| 4708 | goto error_out; |
| 4709 | if ((drb_reg_id > LPFC_DRB_MAX) && |
| 4710 | (drb_reg_id != LPFC_DRB_ACC_ALL)) |
| 4711 | goto error_out; |
| 4712 | } else |
| 4713 | goto error_out; |
| 4714 | |
| 4715 | /* Perform the write access operation */ |
| 4716 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_DRBACC_WR || |
| 4717 | idiag.cmd.opcode == LPFC_IDIAG_CMD_DRBACC_ST || |
| 4718 | idiag.cmd.opcode == LPFC_IDIAG_CMD_DRBACC_CL) { |
| 4719 | switch (drb_reg_id) { |
James Smart | 9dd3542 | 2018-02-22 08:18:41 -0800 | [diff] [blame] | 4720 | case LPFC_DRB_EQ: |
| 4721 | drb_reg = phba->sli4_hba.EQDBregaddr; |
| 4722 | break; |
| 4723 | case LPFC_DRB_CQ: |
| 4724 | drb_reg = phba->sli4_hba.CQDBregaddr; |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 4725 | break; |
| 4726 | case LPFC_DRB_MQ: |
| 4727 | drb_reg = phba->sli4_hba.MQDBregaddr; |
| 4728 | break; |
| 4729 | case LPFC_DRB_WQ: |
| 4730 | drb_reg = phba->sli4_hba.WQDBregaddr; |
| 4731 | break; |
| 4732 | case LPFC_DRB_RQ: |
| 4733 | drb_reg = phba->sli4_hba.RQDBregaddr; |
| 4734 | break; |
| 4735 | default: |
| 4736 | goto error_out; |
| 4737 | } |
| 4738 | |
| 4739 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_DRBACC_WR) |
| 4740 | reg_val = value; |
| 4741 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_DRBACC_ST) { |
| 4742 | reg_val = readl(drb_reg); |
| 4743 | reg_val |= value; |
| 4744 | } |
| 4745 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_DRBACC_CL) { |
| 4746 | reg_val = readl(drb_reg); |
| 4747 | reg_val &= ~value; |
| 4748 | } |
| 4749 | writel(reg_val, drb_reg); |
| 4750 | readl(drb_reg); /* flush */ |
| 4751 | } |
| 4752 | return nbytes; |
| 4753 | |
| 4754 | error_out: |
| 4755 | /* Clean out command structure on command error out */ |
| 4756 | memset(&idiag, 0, sizeof(idiag)); |
| 4757 | return -EINVAL; |
| 4758 | } |
| 4759 | |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 4760 | /** |
| 4761 | * lpfc_idiag_ctlacc_read_reg - idiag debugfs read a control registers |
| 4762 | * @phba: The pointer to hba structure. |
| 4763 | * @pbuffer: The pointer to the buffer to copy the data to. |
Matteo Croce | 92684bf | 2019-01-04 22:38:54 +0100 | [diff] [blame] | 4764 | * @len: The length of bytes to copied. |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 4765 | * @drbregid: The id to doorbell registers. |
| 4766 | * |
| 4767 | * Description: |
| 4768 | * This routine reads a control register and copies its content to the |
| 4769 | * user buffer pointed to by @pbuffer. |
| 4770 | * |
| 4771 | * Returns: |
| 4772 | * This function returns the amount of data that was copied into @pbuffer. |
| 4773 | **/ |
| 4774 | static int |
| 4775 | lpfc_idiag_ctlacc_read_reg(struct lpfc_hba *phba, char *pbuffer, |
| 4776 | int len, uint32_t ctlregid) |
| 4777 | { |
| 4778 | |
| 4779 | if (!pbuffer) |
| 4780 | return 0; |
| 4781 | |
| 4782 | switch (ctlregid) { |
| 4783 | case LPFC_CTL_PORT_SEM: |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 4784 | len += scnprintf(pbuffer+len, LPFC_CTL_ACC_BUF_SIZE-len, |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 4785 | "Port SemReg: 0x%08x\n", |
| 4786 | readl(phba->sli4_hba.conf_regs_memmap_p + |
| 4787 | LPFC_CTL_PORT_SEM_OFFSET)); |
| 4788 | break; |
| 4789 | case LPFC_CTL_PORT_STA: |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 4790 | len += scnprintf(pbuffer+len, LPFC_CTL_ACC_BUF_SIZE-len, |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 4791 | "Port StaReg: 0x%08x\n", |
| 4792 | readl(phba->sli4_hba.conf_regs_memmap_p + |
| 4793 | LPFC_CTL_PORT_STA_OFFSET)); |
| 4794 | break; |
| 4795 | case LPFC_CTL_PORT_CTL: |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 4796 | len += scnprintf(pbuffer+len, LPFC_CTL_ACC_BUF_SIZE-len, |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 4797 | "Port CtlReg: 0x%08x\n", |
| 4798 | readl(phba->sli4_hba.conf_regs_memmap_p + |
| 4799 | LPFC_CTL_PORT_CTL_OFFSET)); |
| 4800 | break; |
| 4801 | case LPFC_CTL_PORT_ER1: |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 4802 | len += scnprintf(pbuffer+len, LPFC_CTL_ACC_BUF_SIZE-len, |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 4803 | "Port Er1Reg: 0x%08x\n", |
| 4804 | readl(phba->sli4_hba.conf_regs_memmap_p + |
| 4805 | LPFC_CTL_PORT_ER1_OFFSET)); |
| 4806 | break; |
| 4807 | case LPFC_CTL_PORT_ER2: |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 4808 | len += scnprintf(pbuffer+len, LPFC_CTL_ACC_BUF_SIZE-len, |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 4809 | "Port Er2Reg: 0x%08x\n", |
| 4810 | readl(phba->sli4_hba.conf_regs_memmap_p + |
| 4811 | LPFC_CTL_PORT_ER2_OFFSET)); |
| 4812 | break; |
| 4813 | case LPFC_CTL_PDEV_CTL: |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 4814 | len += scnprintf(pbuffer+len, LPFC_CTL_ACC_BUF_SIZE-len, |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 4815 | "PDev CtlReg: 0x%08x\n", |
| 4816 | readl(phba->sli4_hba.conf_regs_memmap_p + |
| 4817 | LPFC_CTL_PDEV_CTL_OFFSET)); |
| 4818 | break; |
| 4819 | default: |
| 4820 | break; |
| 4821 | } |
| 4822 | return len; |
| 4823 | } |
| 4824 | |
| 4825 | /** |
| 4826 | * lpfc_idiag_ctlacc_read - idiag debugfs read port and device control register |
| 4827 | * @file: The file pointer to read from. |
| 4828 | * @buf: The buffer to copy the data to. |
| 4829 | * @nbytes: The number of bytes to read. |
| 4830 | * @ppos: The position in the file to start reading from. |
| 4831 | * |
| 4832 | * Description: |
| 4833 | * This routine reads data from the @phba port and device registers according |
| 4834 | * to the idiag command, and copies to user @buf. |
| 4835 | * |
| 4836 | * Returns: |
| 4837 | * This function returns the amount of data that was read (this could be less |
| 4838 | * than @nbytes if the end of the file was reached) or a negative error value. |
| 4839 | **/ |
| 4840 | static ssize_t |
| 4841 | lpfc_idiag_ctlacc_read(struct file *file, char __user *buf, size_t nbytes, |
| 4842 | loff_t *ppos) |
| 4843 | { |
| 4844 | struct lpfc_debug *debug = file->private_data; |
| 4845 | struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private; |
| 4846 | uint32_t ctl_reg_id, i; |
| 4847 | char *pbuffer; |
| 4848 | int len = 0; |
| 4849 | |
| 4850 | /* This is a user read operation */ |
| 4851 | debug->op = LPFC_IDIAG_OP_RD; |
| 4852 | |
| 4853 | if (!debug->buffer) |
| 4854 | debug->buffer = kmalloc(LPFC_CTL_ACC_BUF_SIZE, GFP_KERNEL); |
| 4855 | if (!debug->buffer) |
| 4856 | return 0; |
| 4857 | pbuffer = debug->buffer; |
| 4858 | |
| 4859 | if (*ppos) |
| 4860 | return 0; |
| 4861 | |
| 4862 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_CTLACC_RD) |
| 4863 | ctl_reg_id = idiag.cmd.data[IDIAG_CTLACC_REGID_INDX]; |
| 4864 | else |
| 4865 | return 0; |
| 4866 | |
| 4867 | if (ctl_reg_id == LPFC_CTL_ACC_ALL) |
| 4868 | for (i = 1; i <= LPFC_CTL_MAX; i++) |
| 4869 | len = lpfc_idiag_ctlacc_read_reg(phba, |
| 4870 | pbuffer, len, i); |
| 4871 | else |
| 4872 | len = lpfc_idiag_ctlacc_read_reg(phba, |
| 4873 | pbuffer, len, ctl_reg_id); |
| 4874 | |
| 4875 | return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len); |
| 4876 | } |
| 4877 | |
| 4878 | /** |
| 4879 | * lpfc_idiag_ctlacc_write - Syntax check and set up idiag ctlacc commands |
| 4880 | * @file: The file pointer to read from. |
| 4881 | * @buf: The buffer to copy the user data from. |
| 4882 | * @nbytes: The number of bytes to get. |
| 4883 | * @ppos: The position in the file to start reading from. |
| 4884 | * |
| 4885 | * This routine get the debugfs idiag command struct from user space and then |
| 4886 | * perform the syntax check for port and device control register read (dump) |
| 4887 | * or write (set) command accordingly. |
| 4888 | * |
| 4889 | * It returns the @nbytges passing in from debugfs user space when successful. |
| 4890 | * In case of error conditions, it returns proper error code back to the user |
| 4891 | * space. |
| 4892 | **/ |
| 4893 | static ssize_t |
| 4894 | lpfc_idiag_ctlacc_write(struct file *file, const char __user *buf, |
| 4895 | size_t nbytes, loff_t *ppos) |
| 4896 | { |
| 4897 | struct lpfc_debug *debug = file->private_data; |
| 4898 | struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private; |
| 4899 | uint32_t ctl_reg_id, value, reg_val = 0; |
| 4900 | void __iomem *ctl_reg; |
| 4901 | int rc; |
| 4902 | |
| 4903 | /* This is a user write operation */ |
| 4904 | debug->op = LPFC_IDIAG_OP_WR; |
| 4905 | |
| 4906 | rc = lpfc_idiag_cmd_get(buf, nbytes, &idiag.cmd); |
| 4907 | if (rc < 0) |
| 4908 | return rc; |
| 4909 | |
| 4910 | /* Sanity check on command line arguments */ |
| 4911 | ctl_reg_id = idiag.cmd.data[IDIAG_CTLACC_REGID_INDX]; |
| 4912 | value = idiag.cmd.data[IDIAG_CTLACC_VALUE_INDX]; |
| 4913 | |
| 4914 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_CTLACC_WR || |
| 4915 | idiag.cmd.opcode == LPFC_IDIAG_CMD_CTLACC_ST || |
| 4916 | idiag.cmd.opcode == LPFC_IDIAG_CMD_CTLACC_CL) { |
| 4917 | if (rc != LPFC_CTL_ACC_WR_CMD_ARG) |
| 4918 | goto error_out; |
| 4919 | if (ctl_reg_id > LPFC_CTL_MAX) |
| 4920 | goto error_out; |
| 4921 | } else if (idiag.cmd.opcode == LPFC_IDIAG_CMD_CTLACC_RD) { |
| 4922 | if (rc != LPFC_CTL_ACC_RD_CMD_ARG) |
| 4923 | goto error_out; |
| 4924 | if ((ctl_reg_id > LPFC_CTL_MAX) && |
| 4925 | (ctl_reg_id != LPFC_CTL_ACC_ALL)) |
| 4926 | goto error_out; |
| 4927 | } else |
| 4928 | goto error_out; |
| 4929 | |
| 4930 | /* Perform the write access operation */ |
| 4931 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_CTLACC_WR || |
| 4932 | idiag.cmd.opcode == LPFC_IDIAG_CMD_CTLACC_ST || |
| 4933 | idiag.cmd.opcode == LPFC_IDIAG_CMD_CTLACC_CL) { |
| 4934 | switch (ctl_reg_id) { |
| 4935 | case LPFC_CTL_PORT_SEM: |
| 4936 | ctl_reg = phba->sli4_hba.conf_regs_memmap_p + |
| 4937 | LPFC_CTL_PORT_SEM_OFFSET; |
| 4938 | break; |
| 4939 | case LPFC_CTL_PORT_STA: |
| 4940 | ctl_reg = phba->sli4_hba.conf_regs_memmap_p + |
| 4941 | LPFC_CTL_PORT_STA_OFFSET; |
| 4942 | break; |
| 4943 | case LPFC_CTL_PORT_CTL: |
| 4944 | ctl_reg = phba->sli4_hba.conf_regs_memmap_p + |
| 4945 | LPFC_CTL_PORT_CTL_OFFSET; |
| 4946 | break; |
| 4947 | case LPFC_CTL_PORT_ER1: |
| 4948 | ctl_reg = phba->sli4_hba.conf_regs_memmap_p + |
| 4949 | LPFC_CTL_PORT_ER1_OFFSET; |
| 4950 | break; |
| 4951 | case LPFC_CTL_PORT_ER2: |
| 4952 | ctl_reg = phba->sli4_hba.conf_regs_memmap_p + |
| 4953 | LPFC_CTL_PORT_ER2_OFFSET; |
| 4954 | break; |
| 4955 | case LPFC_CTL_PDEV_CTL: |
| 4956 | ctl_reg = phba->sli4_hba.conf_regs_memmap_p + |
| 4957 | LPFC_CTL_PDEV_CTL_OFFSET; |
| 4958 | break; |
| 4959 | default: |
| 4960 | goto error_out; |
| 4961 | } |
| 4962 | |
| 4963 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_CTLACC_WR) |
| 4964 | reg_val = value; |
| 4965 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_CTLACC_ST) { |
| 4966 | reg_val = readl(ctl_reg); |
| 4967 | reg_val |= value; |
| 4968 | } |
| 4969 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_CTLACC_CL) { |
| 4970 | reg_val = readl(ctl_reg); |
| 4971 | reg_val &= ~value; |
| 4972 | } |
| 4973 | writel(reg_val, ctl_reg); |
| 4974 | readl(ctl_reg); /* flush */ |
| 4975 | } |
| 4976 | return nbytes; |
| 4977 | |
| 4978 | error_out: |
| 4979 | /* Clean out command structure on command error out */ |
| 4980 | memset(&idiag, 0, sizeof(idiag)); |
| 4981 | return -EINVAL; |
| 4982 | } |
| 4983 | |
| 4984 | /** |
| 4985 | * lpfc_idiag_mbxacc_get_setup - idiag debugfs get mailbox access setup |
| 4986 | * @phba: Pointer to HBA context object. |
| 4987 | * @pbuffer: Pointer to data buffer. |
| 4988 | * |
| 4989 | * Description: |
| 4990 | * This routine gets the driver mailbox access debugfs setup information. |
| 4991 | * |
| 4992 | * Returns: |
| 4993 | * This function returns the amount of data that was read (this could be less |
| 4994 | * than @nbytes if the end of the file was reached) or a negative error value. |
| 4995 | **/ |
| 4996 | static int |
| 4997 | lpfc_idiag_mbxacc_get_setup(struct lpfc_hba *phba, char *pbuffer) |
| 4998 | { |
| 4999 | uint32_t mbx_dump_map, mbx_dump_cnt, mbx_word_cnt, mbx_mbox_cmd; |
| 5000 | int len = 0; |
| 5001 | |
| 5002 | mbx_mbox_cmd = idiag.cmd.data[IDIAG_MBXACC_MBCMD_INDX]; |
| 5003 | mbx_dump_map = idiag.cmd.data[IDIAG_MBXACC_DPMAP_INDX]; |
| 5004 | mbx_dump_cnt = idiag.cmd.data[IDIAG_MBXACC_DPCNT_INDX]; |
| 5005 | mbx_word_cnt = idiag.cmd.data[IDIAG_MBXACC_WDCNT_INDX]; |
| 5006 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 5007 | len += scnprintf(pbuffer+len, LPFC_MBX_ACC_BUF_SIZE-len, |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 5008 | "mbx_dump_map: 0x%08x\n", mbx_dump_map); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 5009 | len += scnprintf(pbuffer+len, LPFC_MBX_ACC_BUF_SIZE-len, |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 5010 | "mbx_dump_cnt: %04d\n", mbx_dump_cnt); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 5011 | len += scnprintf(pbuffer+len, LPFC_MBX_ACC_BUF_SIZE-len, |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 5012 | "mbx_word_cnt: %04d\n", mbx_word_cnt); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 5013 | len += scnprintf(pbuffer+len, LPFC_MBX_ACC_BUF_SIZE-len, |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 5014 | "mbx_mbox_cmd: 0x%02x\n", mbx_mbox_cmd); |
| 5015 | |
| 5016 | return len; |
| 5017 | } |
| 5018 | |
| 5019 | /** |
| 5020 | * lpfc_idiag_mbxacc_read - idiag debugfs read on mailbox access |
| 5021 | * @file: The file pointer to read from. |
| 5022 | * @buf: The buffer to copy the data to. |
| 5023 | * @nbytes: The number of bytes to read. |
| 5024 | * @ppos: The position in the file to start reading from. |
| 5025 | * |
| 5026 | * Description: |
| 5027 | * This routine reads data from the @phba driver mailbox access debugfs setup |
| 5028 | * information. |
| 5029 | * |
| 5030 | * Returns: |
| 5031 | * This function returns the amount of data that was read (this could be less |
| 5032 | * than @nbytes if the end of the file was reached) or a negative error value. |
| 5033 | **/ |
| 5034 | static ssize_t |
| 5035 | lpfc_idiag_mbxacc_read(struct file *file, char __user *buf, size_t nbytes, |
| 5036 | loff_t *ppos) |
| 5037 | { |
| 5038 | struct lpfc_debug *debug = file->private_data; |
| 5039 | struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private; |
| 5040 | char *pbuffer; |
| 5041 | int len = 0; |
| 5042 | |
| 5043 | /* This is a user read operation */ |
| 5044 | debug->op = LPFC_IDIAG_OP_RD; |
| 5045 | |
| 5046 | if (!debug->buffer) |
| 5047 | debug->buffer = kmalloc(LPFC_MBX_ACC_BUF_SIZE, GFP_KERNEL); |
| 5048 | if (!debug->buffer) |
| 5049 | return 0; |
| 5050 | pbuffer = debug->buffer; |
| 5051 | |
| 5052 | if (*ppos) |
| 5053 | return 0; |
| 5054 | |
| 5055 | if ((idiag.cmd.opcode != LPFC_IDIAG_CMD_MBXACC_DP) && |
| 5056 | (idiag.cmd.opcode != LPFC_IDIAG_BSG_MBXACC_DP)) |
| 5057 | return 0; |
| 5058 | |
| 5059 | len = lpfc_idiag_mbxacc_get_setup(phba, pbuffer); |
| 5060 | |
| 5061 | return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len); |
| 5062 | } |
| 5063 | |
| 5064 | /** |
| 5065 | * lpfc_idiag_mbxacc_write - Syntax check and set up idiag mbxacc commands |
| 5066 | * @file: The file pointer to read from. |
| 5067 | * @buf: The buffer to copy the user data from. |
| 5068 | * @nbytes: The number of bytes to get. |
| 5069 | * @ppos: The position in the file to start reading from. |
| 5070 | * |
| 5071 | * This routine get the debugfs idiag command struct from user space and then |
| 5072 | * perform the syntax check for driver mailbox command (dump) and sets up the |
| 5073 | * necessary states in the idiag command struct accordingly. |
| 5074 | * |
| 5075 | * It returns the @nbytges passing in from debugfs user space when successful. |
| 5076 | * In case of error conditions, it returns proper error code back to the user |
| 5077 | * space. |
| 5078 | **/ |
| 5079 | static ssize_t |
| 5080 | lpfc_idiag_mbxacc_write(struct file *file, const char __user *buf, |
| 5081 | size_t nbytes, loff_t *ppos) |
| 5082 | { |
| 5083 | struct lpfc_debug *debug = file->private_data; |
| 5084 | uint32_t mbx_dump_map, mbx_dump_cnt, mbx_word_cnt, mbx_mbox_cmd; |
| 5085 | int rc; |
| 5086 | |
| 5087 | /* This is a user write operation */ |
| 5088 | debug->op = LPFC_IDIAG_OP_WR; |
| 5089 | |
| 5090 | rc = lpfc_idiag_cmd_get(buf, nbytes, &idiag.cmd); |
| 5091 | if (rc < 0) |
| 5092 | return rc; |
| 5093 | |
| 5094 | /* Sanity check on command line arguments */ |
| 5095 | mbx_mbox_cmd = idiag.cmd.data[IDIAG_MBXACC_MBCMD_INDX]; |
| 5096 | mbx_dump_map = idiag.cmd.data[IDIAG_MBXACC_DPMAP_INDX]; |
| 5097 | mbx_dump_cnt = idiag.cmd.data[IDIAG_MBXACC_DPCNT_INDX]; |
| 5098 | mbx_word_cnt = idiag.cmd.data[IDIAG_MBXACC_WDCNT_INDX]; |
| 5099 | |
| 5100 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_MBXACC_DP) { |
| 5101 | if (!(mbx_dump_map & LPFC_MBX_DMP_MBX_ALL)) |
| 5102 | goto error_out; |
| 5103 | if ((mbx_dump_map & ~LPFC_MBX_DMP_MBX_ALL) && |
| 5104 | (mbx_dump_map != LPFC_MBX_DMP_ALL)) |
| 5105 | goto error_out; |
| 5106 | if (mbx_word_cnt > sizeof(MAILBOX_t)) |
| 5107 | goto error_out; |
| 5108 | } else if (idiag.cmd.opcode == LPFC_IDIAG_BSG_MBXACC_DP) { |
| 5109 | if (!(mbx_dump_map & LPFC_BSG_DMP_MBX_ALL)) |
| 5110 | goto error_out; |
| 5111 | if ((mbx_dump_map & ~LPFC_BSG_DMP_MBX_ALL) && |
| 5112 | (mbx_dump_map != LPFC_MBX_DMP_ALL)) |
| 5113 | goto error_out; |
| 5114 | if (mbx_word_cnt > (BSG_MBOX_SIZE)/4) |
| 5115 | goto error_out; |
| 5116 | if (mbx_mbox_cmd != 0x9b) |
| 5117 | goto error_out; |
| 5118 | } else |
| 5119 | goto error_out; |
| 5120 | |
| 5121 | if (mbx_word_cnt == 0) |
| 5122 | goto error_out; |
| 5123 | if (rc != LPFC_MBX_DMP_ARG) |
| 5124 | goto error_out; |
| 5125 | if (mbx_mbox_cmd & ~0xff) |
| 5126 | goto error_out; |
| 5127 | |
| 5128 | /* condition for stop mailbox dump */ |
| 5129 | if (mbx_dump_cnt == 0) |
| 5130 | goto reset_out; |
| 5131 | |
| 5132 | return nbytes; |
| 5133 | |
| 5134 | reset_out: |
| 5135 | /* Clean out command structure on command error out */ |
| 5136 | memset(&idiag, 0, sizeof(idiag)); |
| 5137 | return nbytes; |
| 5138 | |
| 5139 | error_out: |
| 5140 | /* Clean out command structure on command error out */ |
| 5141 | memset(&idiag, 0, sizeof(idiag)); |
| 5142 | return -EINVAL; |
| 5143 | } |
| 5144 | |
| 5145 | /** |
| 5146 | * lpfc_idiag_extacc_avail_get - get the available extents information |
| 5147 | * @phba: pointer to lpfc hba data structure. |
| 5148 | * @pbuffer: pointer to internal buffer. |
| 5149 | * @len: length into the internal buffer data has been copied. |
| 5150 | * |
| 5151 | * Description: |
| 5152 | * This routine is to get the available extent information. |
| 5153 | * |
| 5154 | * Returns: |
| 5155 | * overall lenth of the data read into the internal buffer. |
| 5156 | **/ |
| 5157 | static int |
| 5158 | lpfc_idiag_extacc_avail_get(struct lpfc_hba *phba, char *pbuffer, int len) |
| 5159 | { |
| 5160 | uint16_t ext_cnt, ext_size; |
| 5161 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 5162 | len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 5163 | "\nAvailable Extents Information:\n"); |
| 5164 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 5165 | len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 5166 | "\tPort Available VPI extents: "); |
| 5167 | lpfc_sli4_get_avail_extnt_rsrc(phba, LPFC_RSC_TYPE_FCOE_VPI, |
| 5168 | &ext_cnt, &ext_size); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 5169 | len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 5170 | "Count %3d, Size %3d\n", ext_cnt, ext_size); |
| 5171 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 5172 | len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 5173 | "\tPort Available VFI extents: "); |
| 5174 | lpfc_sli4_get_avail_extnt_rsrc(phba, LPFC_RSC_TYPE_FCOE_VFI, |
| 5175 | &ext_cnt, &ext_size); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 5176 | len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 5177 | "Count %3d, Size %3d\n", ext_cnt, ext_size); |
| 5178 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 5179 | len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 5180 | "\tPort Available RPI extents: "); |
| 5181 | lpfc_sli4_get_avail_extnt_rsrc(phba, LPFC_RSC_TYPE_FCOE_RPI, |
| 5182 | &ext_cnt, &ext_size); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 5183 | len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 5184 | "Count %3d, Size %3d\n", ext_cnt, ext_size); |
| 5185 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 5186 | len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 5187 | "\tPort Available XRI extents: "); |
| 5188 | lpfc_sli4_get_avail_extnt_rsrc(phba, LPFC_RSC_TYPE_FCOE_XRI, |
| 5189 | &ext_cnt, &ext_size); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 5190 | len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 5191 | "Count %3d, Size %3d\n", ext_cnt, ext_size); |
| 5192 | |
| 5193 | return len; |
| 5194 | } |
| 5195 | |
| 5196 | /** |
| 5197 | * lpfc_idiag_extacc_alloc_get - get the allocated extents information |
| 5198 | * @phba: pointer to lpfc hba data structure. |
| 5199 | * @pbuffer: pointer to internal buffer. |
| 5200 | * @len: length into the internal buffer data has been copied. |
| 5201 | * |
| 5202 | * Description: |
| 5203 | * This routine is to get the allocated extent information. |
| 5204 | * |
| 5205 | * Returns: |
| 5206 | * overall lenth of the data read into the internal buffer. |
| 5207 | **/ |
| 5208 | static int |
| 5209 | lpfc_idiag_extacc_alloc_get(struct lpfc_hba *phba, char *pbuffer, int len) |
| 5210 | { |
| 5211 | uint16_t ext_cnt, ext_size; |
| 5212 | int rc; |
| 5213 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 5214 | len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 5215 | "\nAllocated Extents Information:\n"); |
| 5216 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 5217 | len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 5218 | "\tHost Allocated VPI extents: "); |
| 5219 | rc = lpfc_sli4_get_allocated_extnts(phba, LPFC_RSC_TYPE_FCOE_VPI, |
| 5220 | &ext_cnt, &ext_size); |
| 5221 | if (!rc) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 5222 | len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 5223 | "Port %d Extent %3d, Size %3d\n", |
| 5224 | phba->brd_no, ext_cnt, ext_size); |
| 5225 | else |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 5226 | len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 5227 | "N/A\n"); |
| 5228 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 5229 | len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 5230 | "\tHost Allocated VFI extents: "); |
| 5231 | rc = lpfc_sli4_get_allocated_extnts(phba, LPFC_RSC_TYPE_FCOE_VFI, |
| 5232 | &ext_cnt, &ext_size); |
| 5233 | if (!rc) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 5234 | len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 5235 | "Port %d Extent %3d, Size %3d\n", |
| 5236 | phba->brd_no, ext_cnt, ext_size); |
| 5237 | else |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 5238 | len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 5239 | "N/A\n"); |
| 5240 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 5241 | len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 5242 | "\tHost Allocated RPI extents: "); |
| 5243 | rc = lpfc_sli4_get_allocated_extnts(phba, LPFC_RSC_TYPE_FCOE_RPI, |
| 5244 | &ext_cnt, &ext_size); |
| 5245 | if (!rc) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 5246 | len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 5247 | "Port %d Extent %3d, Size %3d\n", |
| 5248 | phba->brd_no, ext_cnt, ext_size); |
| 5249 | else |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 5250 | len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 5251 | "N/A\n"); |
| 5252 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 5253 | len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 5254 | "\tHost Allocated XRI extents: "); |
| 5255 | rc = lpfc_sli4_get_allocated_extnts(phba, LPFC_RSC_TYPE_FCOE_XRI, |
| 5256 | &ext_cnt, &ext_size); |
| 5257 | if (!rc) |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 5258 | len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 5259 | "Port %d Extent %3d, Size %3d\n", |
| 5260 | phba->brd_no, ext_cnt, ext_size); |
| 5261 | else |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 5262 | len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 5263 | "N/A\n"); |
| 5264 | |
| 5265 | return len; |
| 5266 | } |
| 5267 | |
| 5268 | /** |
| 5269 | * lpfc_idiag_extacc_drivr_get - get driver extent information |
| 5270 | * @phba: pointer to lpfc hba data structure. |
| 5271 | * @pbuffer: pointer to internal buffer. |
| 5272 | * @len: length into the internal buffer data has been copied. |
| 5273 | * |
| 5274 | * Description: |
| 5275 | * This routine is to get the driver extent information. |
| 5276 | * |
| 5277 | * Returns: |
| 5278 | * overall lenth of the data read into the internal buffer. |
| 5279 | **/ |
| 5280 | static int |
| 5281 | lpfc_idiag_extacc_drivr_get(struct lpfc_hba *phba, char *pbuffer, int len) |
| 5282 | { |
| 5283 | struct lpfc_rsrc_blks *rsrc_blks; |
| 5284 | int index; |
| 5285 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 5286 | len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 5287 | "\nDriver Extents Information:\n"); |
| 5288 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 5289 | len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 5290 | "\tVPI extents:\n"); |
| 5291 | index = 0; |
| 5292 | list_for_each_entry(rsrc_blks, &phba->lpfc_vpi_blk_list, list) { |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 5293 | len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 5294 | "\t\tBlock %3d: Start %4d, Count %4d\n", |
| 5295 | index, rsrc_blks->rsrc_start, |
| 5296 | rsrc_blks->rsrc_size); |
| 5297 | index++; |
| 5298 | } |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 5299 | len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 5300 | "\tVFI extents:\n"); |
| 5301 | index = 0; |
| 5302 | list_for_each_entry(rsrc_blks, &phba->sli4_hba.lpfc_vfi_blk_list, |
| 5303 | list) { |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 5304 | len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 5305 | "\t\tBlock %3d: Start %4d, Count %4d\n", |
| 5306 | index, rsrc_blks->rsrc_start, |
| 5307 | rsrc_blks->rsrc_size); |
| 5308 | index++; |
| 5309 | } |
| 5310 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 5311 | len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 5312 | "\tRPI extents:\n"); |
| 5313 | index = 0; |
| 5314 | list_for_each_entry(rsrc_blks, &phba->sli4_hba.lpfc_rpi_blk_list, |
| 5315 | list) { |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 5316 | len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 5317 | "\t\tBlock %3d: Start %4d, Count %4d\n", |
| 5318 | index, rsrc_blks->rsrc_start, |
| 5319 | rsrc_blks->rsrc_size); |
| 5320 | index++; |
| 5321 | } |
| 5322 | |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 5323 | len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 5324 | "\tXRI extents:\n"); |
| 5325 | index = 0; |
| 5326 | list_for_each_entry(rsrc_blks, &phba->sli4_hba.lpfc_xri_blk_list, |
| 5327 | list) { |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 5328 | len += scnprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 5329 | "\t\tBlock %3d: Start %4d, Count %4d\n", |
| 5330 | index, rsrc_blks->rsrc_start, |
| 5331 | rsrc_blks->rsrc_size); |
| 5332 | index++; |
| 5333 | } |
| 5334 | |
| 5335 | return len; |
| 5336 | } |
| 5337 | |
| 5338 | /** |
| 5339 | * lpfc_idiag_extacc_write - Syntax check and set up idiag extacc commands |
| 5340 | * @file: The file pointer to read from. |
| 5341 | * @buf: The buffer to copy the user data from. |
| 5342 | * @nbytes: The number of bytes to get. |
| 5343 | * @ppos: The position in the file to start reading from. |
| 5344 | * |
| 5345 | * This routine get the debugfs idiag command struct from user space and then |
| 5346 | * perform the syntax check for extent information access commands and sets |
| 5347 | * up the necessary states in the idiag command struct accordingly. |
| 5348 | * |
| 5349 | * It returns the @nbytges passing in from debugfs user space when successful. |
| 5350 | * In case of error conditions, it returns proper error code back to the user |
| 5351 | * space. |
| 5352 | **/ |
| 5353 | static ssize_t |
| 5354 | lpfc_idiag_extacc_write(struct file *file, const char __user *buf, |
| 5355 | size_t nbytes, loff_t *ppos) |
| 5356 | { |
| 5357 | struct lpfc_debug *debug = file->private_data; |
| 5358 | uint32_t ext_map; |
| 5359 | int rc; |
| 5360 | |
| 5361 | /* This is a user write operation */ |
| 5362 | debug->op = LPFC_IDIAG_OP_WR; |
| 5363 | |
| 5364 | rc = lpfc_idiag_cmd_get(buf, nbytes, &idiag.cmd); |
| 5365 | if (rc < 0) |
| 5366 | return rc; |
| 5367 | |
| 5368 | ext_map = idiag.cmd.data[IDIAG_EXTACC_EXMAP_INDX]; |
| 5369 | |
| 5370 | if (idiag.cmd.opcode != LPFC_IDIAG_CMD_EXTACC_RD) |
| 5371 | goto error_out; |
| 5372 | if (rc != LPFC_EXT_ACC_CMD_ARG) |
| 5373 | goto error_out; |
| 5374 | if (!(ext_map & LPFC_EXT_ACC_ALL)) |
| 5375 | goto error_out; |
| 5376 | |
| 5377 | return nbytes; |
| 5378 | error_out: |
| 5379 | /* Clean out command structure on command error out */ |
| 5380 | memset(&idiag, 0, sizeof(idiag)); |
| 5381 | return -EINVAL; |
| 5382 | } |
| 5383 | |
| 5384 | /** |
| 5385 | * lpfc_idiag_extacc_read - idiag debugfs read access to extent information |
| 5386 | * @file: The file pointer to read from. |
| 5387 | * @buf: The buffer to copy the data to. |
| 5388 | * @nbytes: The number of bytes to read. |
| 5389 | * @ppos: The position in the file to start reading from. |
| 5390 | * |
| 5391 | * Description: |
| 5392 | * This routine reads data from the proper extent information according to |
| 5393 | * the idiag command, and copies to user @buf. |
| 5394 | * |
| 5395 | * Returns: |
| 5396 | * This function returns the amount of data that was read (this could be less |
| 5397 | * than @nbytes if the end of the file was reached) or a negative error value. |
| 5398 | **/ |
| 5399 | static ssize_t |
| 5400 | lpfc_idiag_extacc_read(struct file *file, char __user *buf, size_t nbytes, |
| 5401 | loff_t *ppos) |
| 5402 | { |
| 5403 | struct lpfc_debug *debug = file->private_data; |
| 5404 | struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private; |
| 5405 | char *pbuffer; |
| 5406 | uint32_t ext_map; |
| 5407 | int len = 0; |
| 5408 | |
| 5409 | /* This is a user read operation */ |
| 5410 | debug->op = LPFC_IDIAG_OP_RD; |
| 5411 | |
| 5412 | if (!debug->buffer) |
| 5413 | debug->buffer = kmalloc(LPFC_EXT_ACC_BUF_SIZE, GFP_KERNEL); |
| 5414 | if (!debug->buffer) |
| 5415 | return 0; |
| 5416 | pbuffer = debug->buffer; |
| 5417 | if (*ppos) |
| 5418 | return 0; |
| 5419 | if (idiag.cmd.opcode != LPFC_IDIAG_CMD_EXTACC_RD) |
| 5420 | return 0; |
| 5421 | |
| 5422 | ext_map = idiag.cmd.data[IDIAG_EXTACC_EXMAP_INDX]; |
| 5423 | if (ext_map & LPFC_EXT_ACC_AVAIL) |
| 5424 | len = lpfc_idiag_extacc_avail_get(phba, pbuffer, len); |
| 5425 | if (ext_map & LPFC_EXT_ACC_ALLOC) |
| 5426 | len = lpfc_idiag_extacc_alloc_get(phba, pbuffer, len); |
| 5427 | if (ext_map & LPFC_EXT_ACC_DRIVR) |
| 5428 | len = lpfc_idiag_extacc_drivr_get(phba, pbuffer, len); |
| 5429 | |
| 5430 | return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len); |
| 5431 | } |
| 5432 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5433 | #undef lpfc_debugfs_op_disc_trc |
Jan Engelhardt | 71fa742 | 2009-01-11 10:38:59 +0100 | [diff] [blame] | 5434 | static const struct file_operations lpfc_debugfs_op_disc_trc = { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5435 | .owner = THIS_MODULE, |
| 5436 | .open = lpfc_debugfs_disc_trc_open, |
| 5437 | .llseek = lpfc_debugfs_lseek, |
| 5438 | .read = lpfc_debugfs_read, |
| 5439 | .release = lpfc_debugfs_release, |
| 5440 | }; |
| 5441 | |
| 5442 | #undef lpfc_debugfs_op_nodelist |
Jan Engelhardt | 71fa742 | 2009-01-11 10:38:59 +0100 | [diff] [blame] | 5443 | static const struct file_operations lpfc_debugfs_op_nodelist = { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5444 | .owner = THIS_MODULE, |
| 5445 | .open = lpfc_debugfs_nodelist_open, |
| 5446 | .llseek = lpfc_debugfs_lseek, |
| 5447 | .read = lpfc_debugfs_read, |
| 5448 | .release = lpfc_debugfs_release, |
| 5449 | }; |
| 5450 | |
James Smart | c490850 | 2019-01-28 11:14:28 -0800 | [diff] [blame] | 5451 | #undef lpfc_debugfs_op_multixripools |
| 5452 | static const struct file_operations lpfc_debugfs_op_multixripools = { |
| 5453 | .owner = THIS_MODULE, |
| 5454 | .open = lpfc_debugfs_multixripools_open, |
| 5455 | .llseek = lpfc_debugfs_lseek, |
| 5456 | .read = lpfc_debugfs_read, |
| 5457 | .write = lpfc_debugfs_multixripools_write, |
| 5458 | .release = lpfc_debugfs_release, |
| 5459 | }; |
| 5460 | |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 5461 | #undef lpfc_debugfs_op_hbqinfo |
Jan Engelhardt | 71fa742 | 2009-01-11 10:38:59 +0100 | [diff] [blame] | 5462 | static const struct file_operations lpfc_debugfs_op_hbqinfo = { |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 5463 | .owner = THIS_MODULE, |
| 5464 | .open = lpfc_debugfs_hbqinfo_open, |
| 5465 | .llseek = lpfc_debugfs_lseek, |
| 5466 | .read = lpfc_debugfs_read, |
| 5467 | .release = lpfc_debugfs_release, |
| 5468 | }; |
| 5469 | |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 5470 | #ifdef LPFC_HDWQ_LOCK_STAT |
| 5471 | #undef lpfc_debugfs_op_lockstat |
| 5472 | static const struct file_operations lpfc_debugfs_op_lockstat = { |
James Smart | 5e5b511 | 2019-01-28 11:14:22 -0800 | [diff] [blame] | 5473 | .owner = THIS_MODULE, |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 5474 | .open = lpfc_debugfs_lockstat_open, |
James Smart | 5e5b511 | 2019-01-28 11:14:22 -0800 | [diff] [blame] | 5475 | .llseek = lpfc_debugfs_lseek, |
| 5476 | .read = lpfc_debugfs_read, |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 5477 | .write = lpfc_debugfs_lockstat_write, |
James Smart | 5e5b511 | 2019-01-28 11:14:22 -0800 | [diff] [blame] | 5478 | .release = lpfc_debugfs_release, |
| 5479 | }; |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 5480 | #endif |
James Smart | 5e5b511 | 2019-01-28 11:14:22 -0800 | [diff] [blame] | 5481 | |
James Smart | 95bfc6d | 2019-10-18 14:18:27 -0700 | [diff] [blame] | 5482 | #undef lpfc_debugfs_ras_log |
| 5483 | static const struct file_operations lpfc_debugfs_ras_log = { |
| 5484 | .owner = THIS_MODULE, |
| 5485 | .open = lpfc_debugfs_ras_log_open, |
| 5486 | .llseek = lpfc_debugfs_lseek, |
| 5487 | .read = lpfc_debugfs_read, |
| 5488 | .release = lpfc_debugfs_ras_log_release, |
| 5489 | }; |
James Smart | 95bfc6d | 2019-10-18 14:18:27 -0700 | [diff] [blame] | 5490 | |
James Smart | c95d6c6 | 2008-01-11 01:53:23 -0500 | [diff] [blame] | 5491 | #undef lpfc_debugfs_op_dumpHBASlim |
Jan Engelhardt | 71fa742 | 2009-01-11 10:38:59 +0100 | [diff] [blame] | 5492 | static const struct file_operations lpfc_debugfs_op_dumpHBASlim = { |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 5493 | .owner = THIS_MODULE, |
James Smart | c95d6c6 | 2008-01-11 01:53:23 -0500 | [diff] [blame] | 5494 | .open = lpfc_debugfs_dumpHBASlim_open, |
| 5495 | .llseek = lpfc_debugfs_lseek, |
| 5496 | .read = lpfc_debugfs_read, |
| 5497 | .release = lpfc_debugfs_release, |
| 5498 | }; |
| 5499 | |
| 5500 | #undef lpfc_debugfs_op_dumpHostSlim |
Jan Engelhardt | 71fa742 | 2009-01-11 10:38:59 +0100 | [diff] [blame] | 5501 | static const struct file_operations lpfc_debugfs_op_dumpHostSlim = { |
James Smart | c95d6c6 | 2008-01-11 01:53:23 -0500 | [diff] [blame] | 5502 | .owner = THIS_MODULE, |
| 5503 | .open = lpfc_debugfs_dumpHostSlim_open, |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 5504 | .llseek = lpfc_debugfs_lseek, |
| 5505 | .read = lpfc_debugfs_read, |
| 5506 | .release = lpfc_debugfs_release, |
| 5507 | }; |
| 5508 | |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 5509 | #undef lpfc_debugfs_op_nvmestat |
| 5510 | static const struct file_operations lpfc_debugfs_op_nvmestat = { |
| 5511 | .owner = THIS_MODULE, |
| 5512 | .open = lpfc_debugfs_nvmestat_open, |
| 5513 | .llseek = lpfc_debugfs_lseek, |
| 5514 | .read = lpfc_debugfs_read, |
James Smart | 2b65e18 | 2017-02-12 13:52:38 -0800 | [diff] [blame] | 5515 | .write = lpfc_debugfs_nvmestat_write, |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 5516 | .release = lpfc_debugfs_release, |
| 5517 | }; |
| 5518 | |
James Smart | 4c47efc | 2019-01-28 11:14:25 -0800 | [diff] [blame] | 5519 | #undef lpfc_debugfs_op_scsistat |
| 5520 | static const struct file_operations lpfc_debugfs_op_scsistat = { |
| 5521 | .owner = THIS_MODULE, |
| 5522 | .open = lpfc_debugfs_scsistat_open, |
| 5523 | .llseek = lpfc_debugfs_lseek, |
| 5524 | .read = lpfc_debugfs_read, |
| 5525 | .write = lpfc_debugfs_scsistat_write, |
| 5526 | .release = lpfc_debugfs_release, |
| 5527 | }; |
| 5528 | |
James Smart | 2fcbc56 | 2020-03-22 11:13:02 -0700 | [diff] [blame] | 5529 | #undef lpfc_debugfs_op_ioktime |
| 5530 | static const struct file_operations lpfc_debugfs_op_ioktime = { |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 5531 | .owner = THIS_MODULE, |
James Smart | 2fcbc56 | 2020-03-22 11:13:02 -0700 | [diff] [blame] | 5532 | .open = lpfc_debugfs_ioktime_open, |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 5533 | .llseek = lpfc_debugfs_lseek, |
| 5534 | .read = lpfc_debugfs_read, |
James Smart | 2fcbc56 | 2020-03-22 11:13:02 -0700 | [diff] [blame] | 5535 | .write = lpfc_debugfs_ioktime_write, |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 5536 | .release = lpfc_debugfs_release, |
| 5537 | }; |
| 5538 | |
| 5539 | #undef lpfc_debugfs_op_nvmeio_trc |
| 5540 | static const struct file_operations lpfc_debugfs_op_nvmeio_trc = { |
| 5541 | .owner = THIS_MODULE, |
| 5542 | .open = lpfc_debugfs_nvmeio_trc_open, |
| 5543 | .llseek = lpfc_debugfs_lseek, |
| 5544 | .read = lpfc_debugfs_read, |
| 5545 | .write = lpfc_debugfs_nvmeio_trc_write, |
| 5546 | .release = lpfc_debugfs_release, |
| 5547 | }; |
| 5548 | |
James Smart | 840eda9 | 2020-03-22 11:13:00 -0700 | [diff] [blame] | 5549 | #undef lpfc_debugfs_op_hdwqstat |
| 5550 | static const struct file_operations lpfc_debugfs_op_hdwqstat = { |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 5551 | .owner = THIS_MODULE, |
James Smart | 840eda9 | 2020-03-22 11:13:00 -0700 | [diff] [blame] | 5552 | .open = lpfc_debugfs_hdwqstat_open, |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 5553 | .llseek = lpfc_debugfs_lseek, |
| 5554 | .read = lpfc_debugfs_read, |
James Smart | 840eda9 | 2020-03-22 11:13:00 -0700 | [diff] [blame] | 5555 | .write = lpfc_debugfs_hdwqstat_write, |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 5556 | .release = lpfc_debugfs_release, |
| 5557 | }; |
| 5558 | |
James Smart | f9bb2da | 2011-10-10 21:34:11 -0400 | [diff] [blame] | 5559 | #undef lpfc_debugfs_op_dif_err |
| 5560 | static const struct file_operations lpfc_debugfs_op_dif_err = { |
| 5561 | .owner = THIS_MODULE, |
Stephen Boyd | 234e340 | 2012-04-05 14:25:11 -0700 | [diff] [blame] | 5562 | .open = simple_open, |
James Smart | f9bb2da | 2011-10-10 21:34:11 -0400 | [diff] [blame] | 5563 | .llseek = lpfc_debugfs_lseek, |
| 5564 | .read = lpfc_debugfs_dif_err_read, |
| 5565 | .write = lpfc_debugfs_dif_err_write, |
| 5566 | .release = lpfc_debugfs_dif_err_release, |
| 5567 | }; |
| 5568 | |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 5569 | #undef lpfc_debugfs_op_slow_ring_trc |
Jan Engelhardt | 71fa742 | 2009-01-11 10:38:59 +0100 | [diff] [blame] | 5570 | static const struct file_operations lpfc_debugfs_op_slow_ring_trc = { |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 5571 | .owner = THIS_MODULE, |
| 5572 | .open = lpfc_debugfs_slow_ring_trc_open, |
| 5573 | .llseek = lpfc_debugfs_lseek, |
| 5574 | .read = lpfc_debugfs_read, |
| 5575 | .release = lpfc_debugfs_release, |
| 5576 | }; |
| 5577 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5578 | static struct dentry *lpfc_debugfs_root = NULL; |
| 5579 | static atomic_t lpfc_debugfs_hba_count; |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 5580 | |
| 5581 | /* |
| 5582 | * File operations for the iDiag debugfs |
| 5583 | */ |
| 5584 | #undef lpfc_idiag_op_pciCfg |
| 5585 | static const struct file_operations lpfc_idiag_op_pciCfg = { |
| 5586 | .owner = THIS_MODULE, |
| 5587 | .open = lpfc_idiag_open, |
| 5588 | .llseek = lpfc_debugfs_lseek, |
| 5589 | .read = lpfc_idiag_pcicfg_read, |
| 5590 | .write = lpfc_idiag_pcicfg_write, |
| 5591 | .release = lpfc_idiag_cmd_release, |
| 5592 | }; |
| 5593 | |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 5594 | #undef lpfc_idiag_op_barAcc |
| 5595 | static const struct file_operations lpfc_idiag_op_barAcc = { |
| 5596 | .owner = THIS_MODULE, |
| 5597 | .open = lpfc_idiag_open, |
| 5598 | .llseek = lpfc_debugfs_lseek, |
| 5599 | .read = lpfc_idiag_baracc_read, |
| 5600 | .write = lpfc_idiag_baracc_write, |
| 5601 | .release = lpfc_idiag_cmd_release, |
| 5602 | }; |
| 5603 | |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 5604 | #undef lpfc_idiag_op_queInfo |
| 5605 | static const struct file_operations lpfc_idiag_op_queInfo = { |
| 5606 | .owner = THIS_MODULE, |
| 5607 | .open = lpfc_idiag_open, |
| 5608 | .read = lpfc_idiag_queinfo_read, |
| 5609 | .release = lpfc_idiag_release, |
| 5610 | }; |
| 5611 | |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 5612 | #undef lpfc_idiag_op_queAcc |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 5613 | static const struct file_operations lpfc_idiag_op_queAcc = { |
| 5614 | .owner = THIS_MODULE, |
| 5615 | .open = lpfc_idiag_open, |
| 5616 | .llseek = lpfc_debugfs_lseek, |
| 5617 | .read = lpfc_idiag_queacc_read, |
| 5618 | .write = lpfc_idiag_queacc_write, |
| 5619 | .release = lpfc_idiag_cmd_release, |
| 5620 | }; |
| 5621 | |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 5622 | #undef lpfc_idiag_op_drbAcc |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 5623 | static const struct file_operations lpfc_idiag_op_drbAcc = { |
| 5624 | .owner = THIS_MODULE, |
| 5625 | .open = lpfc_idiag_open, |
| 5626 | .llseek = lpfc_debugfs_lseek, |
| 5627 | .read = lpfc_idiag_drbacc_read, |
| 5628 | .write = lpfc_idiag_drbacc_write, |
| 5629 | .release = lpfc_idiag_cmd_release, |
| 5630 | }; |
| 5631 | |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 5632 | #undef lpfc_idiag_op_ctlAcc |
| 5633 | static const struct file_operations lpfc_idiag_op_ctlAcc = { |
| 5634 | .owner = THIS_MODULE, |
| 5635 | .open = lpfc_idiag_open, |
| 5636 | .llseek = lpfc_debugfs_lseek, |
| 5637 | .read = lpfc_idiag_ctlacc_read, |
| 5638 | .write = lpfc_idiag_ctlacc_write, |
| 5639 | .release = lpfc_idiag_cmd_release, |
| 5640 | }; |
| 5641 | |
| 5642 | #undef lpfc_idiag_op_mbxAcc |
| 5643 | static const struct file_operations lpfc_idiag_op_mbxAcc = { |
| 5644 | .owner = THIS_MODULE, |
| 5645 | .open = lpfc_idiag_open, |
| 5646 | .llseek = lpfc_debugfs_lseek, |
| 5647 | .read = lpfc_idiag_mbxacc_read, |
| 5648 | .write = lpfc_idiag_mbxacc_write, |
| 5649 | .release = lpfc_idiag_cmd_release, |
| 5650 | }; |
| 5651 | |
| 5652 | #undef lpfc_idiag_op_extAcc |
| 5653 | static const struct file_operations lpfc_idiag_op_extAcc = { |
| 5654 | .owner = THIS_MODULE, |
| 5655 | .open = lpfc_idiag_open, |
| 5656 | .llseek = lpfc_debugfs_lseek, |
| 5657 | .read = lpfc_idiag_extacc_read, |
| 5658 | .write = lpfc_idiag_extacc_write, |
| 5659 | .release = lpfc_idiag_cmd_release, |
| 5660 | }; |
Arnd Bergmann | 201743b | 2019-12-16 14:16:49 +0100 | [diff] [blame] | 5661 | #endif |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5662 | |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 5663 | /* lpfc_idiag_mbxacc_dump_bsg_mbox - idiag debugfs dump bsg mailbox command |
| 5664 | * @phba: Pointer to HBA context object. |
| 5665 | * @dmabuf: Pointer to a DMA buffer descriptor. |
| 5666 | * |
| 5667 | * Description: |
| 5668 | * This routine dump a bsg pass-through non-embedded mailbox command with |
| 5669 | * external buffer. |
| 5670 | **/ |
| 5671 | void |
| 5672 | lpfc_idiag_mbxacc_dump_bsg_mbox(struct lpfc_hba *phba, enum nemb_type nemb_tp, |
| 5673 | enum mbox_type mbox_tp, enum dma_type dma_tp, |
| 5674 | enum sta_type sta_tp, |
| 5675 | struct lpfc_dmabuf *dmabuf, uint32_t ext_buf) |
| 5676 | { |
| 5677 | #ifdef CONFIG_SCSI_LPFC_DEBUG_FS |
| 5678 | uint32_t *mbx_mbox_cmd, *mbx_dump_map, *mbx_dump_cnt, *mbx_word_cnt; |
| 5679 | char line_buf[LPFC_MBX_ACC_LBUF_SZ]; |
| 5680 | int len = 0; |
| 5681 | uint32_t do_dump = 0; |
| 5682 | uint32_t *pword; |
| 5683 | uint32_t i; |
| 5684 | |
| 5685 | if (idiag.cmd.opcode != LPFC_IDIAG_BSG_MBXACC_DP) |
| 5686 | return; |
| 5687 | |
| 5688 | mbx_mbox_cmd = &idiag.cmd.data[IDIAG_MBXACC_MBCMD_INDX]; |
| 5689 | mbx_dump_map = &idiag.cmd.data[IDIAG_MBXACC_DPMAP_INDX]; |
| 5690 | mbx_dump_cnt = &idiag.cmd.data[IDIAG_MBXACC_DPCNT_INDX]; |
| 5691 | mbx_word_cnt = &idiag.cmd.data[IDIAG_MBXACC_WDCNT_INDX]; |
| 5692 | |
| 5693 | if (!(*mbx_dump_map & LPFC_MBX_DMP_ALL) || |
| 5694 | (*mbx_dump_cnt == 0) || |
| 5695 | (*mbx_word_cnt == 0)) |
| 5696 | return; |
| 5697 | |
| 5698 | if (*mbx_mbox_cmd != 0x9B) |
| 5699 | return; |
| 5700 | |
| 5701 | if ((mbox_tp == mbox_rd) && (dma_tp == dma_mbox)) { |
| 5702 | if (*mbx_dump_map & LPFC_BSG_DMP_MBX_RD_MBX) { |
| 5703 | do_dump |= LPFC_BSG_DMP_MBX_RD_MBX; |
James Smart | 2ea259e | 2017-02-12 13:52:27 -0800 | [diff] [blame] | 5704 | pr_err("\nRead mbox command (x%x), " |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 5705 | "nemb:0x%x, extbuf_cnt:%d:\n", |
| 5706 | sta_tp, nemb_tp, ext_buf); |
| 5707 | } |
| 5708 | } |
| 5709 | if ((mbox_tp == mbox_rd) && (dma_tp == dma_ebuf)) { |
| 5710 | if (*mbx_dump_map & LPFC_BSG_DMP_MBX_RD_BUF) { |
| 5711 | do_dump |= LPFC_BSG_DMP_MBX_RD_BUF; |
James Smart | 2ea259e | 2017-02-12 13:52:27 -0800 | [diff] [blame] | 5712 | pr_err("\nRead mbox buffer (x%x), " |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 5713 | "nemb:0x%x, extbuf_seq:%d:\n", |
| 5714 | sta_tp, nemb_tp, ext_buf); |
| 5715 | } |
| 5716 | } |
| 5717 | if ((mbox_tp == mbox_wr) && (dma_tp == dma_mbox)) { |
| 5718 | if (*mbx_dump_map & LPFC_BSG_DMP_MBX_WR_MBX) { |
| 5719 | do_dump |= LPFC_BSG_DMP_MBX_WR_MBX; |
James Smart | 2ea259e | 2017-02-12 13:52:27 -0800 | [diff] [blame] | 5720 | pr_err("\nWrite mbox command (x%x), " |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 5721 | "nemb:0x%x, extbuf_cnt:%d:\n", |
| 5722 | sta_tp, nemb_tp, ext_buf); |
| 5723 | } |
| 5724 | } |
| 5725 | if ((mbox_tp == mbox_wr) && (dma_tp == dma_ebuf)) { |
| 5726 | if (*mbx_dump_map & LPFC_BSG_DMP_MBX_WR_BUF) { |
| 5727 | do_dump |= LPFC_BSG_DMP_MBX_WR_BUF; |
James Smart | 2ea259e | 2017-02-12 13:52:27 -0800 | [diff] [blame] | 5728 | pr_err("\nWrite mbox buffer (x%x), " |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 5729 | "nemb:0x%x, extbuf_seq:%d:\n", |
| 5730 | sta_tp, nemb_tp, ext_buf); |
| 5731 | } |
| 5732 | } |
| 5733 | |
| 5734 | /* dump buffer content */ |
| 5735 | if (do_dump) { |
| 5736 | pword = (uint32_t *)dmabuf->virt; |
| 5737 | for (i = 0; i < *mbx_word_cnt; i++) { |
| 5738 | if (!(i % 8)) { |
| 5739 | if (i != 0) |
James Smart | 2ea259e | 2017-02-12 13:52:27 -0800 | [diff] [blame] | 5740 | pr_err("%s\n", line_buf); |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 5741 | len = 0; |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 5742 | len += scnprintf(line_buf+len, |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 5743 | LPFC_MBX_ACC_LBUF_SZ-len, |
| 5744 | "%03d: ", i); |
| 5745 | } |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 5746 | len += scnprintf(line_buf+len, LPFC_MBX_ACC_LBUF_SZ-len, |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 5747 | "%08x ", (uint32_t)*pword); |
| 5748 | pword++; |
| 5749 | } |
| 5750 | if ((i - 1) % 8) |
James Smart | 2ea259e | 2017-02-12 13:52:27 -0800 | [diff] [blame] | 5751 | pr_err("%s\n", line_buf); |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 5752 | (*mbx_dump_cnt)--; |
| 5753 | } |
| 5754 | |
| 5755 | /* Clean out command structure on reaching dump count */ |
| 5756 | if (*mbx_dump_cnt == 0) |
| 5757 | memset(&idiag, 0, sizeof(idiag)); |
| 5758 | return; |
| 5759 | #endif |
| 5760 | } |
| 5761 | |
| 5762 | /* lpfc_idiag_mbxacc_dump_issue_mbox - idiag debugfs dump issue mailbox command |
| 5763 | * @phba: Pointer to HBA context object. |
| 5764 | * @dmabuf: Pointer to a DMA buffer descriptor. |
| 5765 | * |
| 5766 | * Description: |
| 5767 | * This routine dump a pass-through non-embedded mailbox command from issue |
| 5768 | * mailbox command. |
| 5769 | **/ |
| 5770 | void |
| 5771 | lpfc_idiag_mbxacc_dump_issue_mbox(struct lpfc_hba *phba, MAILBOX_t *pmbox) |
| 5772 | { |
| 5773 | #ifdef CONFIG_SCSI_LPFC_DEBUG_FS |
| 5774 | uint32_t *mbx_dump_map, *mbx_dump_cnt, *mbx_word_cnt, *mbx_mbox_cmd; |
| 5775 | char line_buf[LPFC_MBX_ACC_LBUF_SZ]; |
| 5776 | int len = 0; |
| 5777 | uint32_t *pword; |
| 5778 | uint8_t *pbyte; |
| 5779 | uint32_t i, j; |
| 5780 | |
| 5781 | if (idiag.cmd.opcode != LPFC_IDIAG_CMD_MBXACC_DP) |
| 5782 | return; |
| 5783 | |
| 5784 | mbx_mbox_cmd = &idiag.cmd.data[IDIAG_MBXACC_MBCMD_INDX]; |
| 5785 | mbx_dump_map = &idiag.cmd.data[IDIAG_MBXACC_DPMAP_INDX]; |
| 5786 | mbx_dump_cnt = &idiag.cmd.data[IDIAG_MBXACC_DPCNT_INDX]; |
| 5787 | mbx_word_cnt = &idiag.cmd.data[IDIAG_MBXACC_WDCNT_INDX]; |
| 5788 | |
| 5789 | if (!(*mbx_dump_map & LPFC_MBX_DMP_MBX_ALL) || |
| 5790 | (*mbx_dump_cnt == 0) || |
| 5791 | (*mbx_word_cnt == 0)) |
| 5792 | return; |
| 5793 | |
| 5794 | if ((*mbx_mbox_cmd != LPFC_MBX_ALL_CMD) && |
| 5795 | (*mbx_mbox_cmd != pmbox->mbxCommand)) |
| 5796 | return; |
| 5797 | |
| 5798 | /* dump buffer content */ |
| 5799 | if (*mbx_dump_map & LPFC_MBX_DMP_MBX_WORD) { |
James Smart | 2ea259e | 2017-02-12 13:52:27 -0800 | [diff] [blame] | 5800 | pr_err("Mailbox command:0x%x dump by word:\n", |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 5801 | pmbox->mbxCommand); |
| 5802 | pword = (uint32_t *)pmbox; |
| 5803 | for (i = 0; i < *mbx_word_cnt; i++) { |
| 5804 | if (!(i % 8)) { |
| 5805 | if (i != 0) |
James Smart | 2ea259e | 2017-02-12 13:52:27 -0800 | [diff] [blame] | 5806 | pr_err("%s\n", line_buf); |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 5807 | len = 0; |
| 5808 | memset(line_buf, 0, LPFC_MBX_ACC_LBUF_SZ); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 5809 | len += scnprintf(line_buf+len, |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 5810 | LPFC_MBX_ACC_LBUF_SZ-len, |
| 5811 | "%03d: ", i); |
| 5812 | } |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 5813 | len += scnprintf(line_buf+len, LPFC_MBX_ACC_LBUF_SZ-len, |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 5814 | "%08x ", |
| 5815 | ((uint32_t)*pword) & 0xffffffff); |
| 5816 | pword++; |
| 5817 | } |
| 5818 | if ((i - 1) % 8) |
James Smart | 2ea259e | 2017-02-12 13:52:27 -0800 | [diff] [blame] | 5819 | pr_err("%s\n", line_buf); |
| 5820 | pr_err("\n"); |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 5821 | } |
| 5822 | if (*mbx_dump_map & LPFC_MBX_DMP_MBX_BYTE) { |
James Smart | 2ea259e | 2017-02-12 13:52:27 -0800 | [diff] [blame] | 5823 | pr_err("Mailbox command:0x%x dump by byte:\n", |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 5824 | pmbox->mbxCommand); |
| 5825 | pbyte = (uint8_t *)pmbox; |
| 5826 | for (i = 0; i < *mbx_word_cnt; i++) { |
| 5827 | if (!(i % 8)) { |
| 5828 | if (i != 0) |
James Smart | 2ea259e | 2017-02-12 13:52:27 -0800 | [diff] [blame] | 5829 | pr_err("%s\n", line_buf); |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 5830 | len = 0; |
| 5831 | memset(line_buf, 0, LPFC_MBX_ACC_LBUF_SZ); |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 5832 | len += scnprintf(line_buf+len, |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 5833 | LPFC_MBX_ACC_LBUF_SZ-len, |
| 5834 | "%03d: ", i); |
| 5835 | } |
| 5836 | for (j = 0; j < 4; j++) { |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 5837 | len += scnprintf(line_buf+len, |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 5838 | LPFC_MBX_ACC_LBUF_SZ-len, |
| 5839 | "%02x", |
| 5840 | ((uint8_t)*pbyte) & 0xff); |
| 5841 | pbyte++; |
| 5842 | } |
Silvio Cesare | e7f7b6f | 2019-03-21 09:44:32 -0700 | [diff] [blame] | 5843 | len += scnprintf(line_buf+len, |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 5844 | LPFC_MBX_ACC_LBUF_SZ-len, " "); |
| 5845 | } |
| 5846 | if ((i - 1) % 8) |
James Smart | 2ea259e | 2017-02-12 13:52:27 -0800 | [diff] [blame] | 5847 | pr_err("%s\n", line_buf); |
| 5848 | pr_err("\n"); |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 5849 | } |
| 5850 | (*mbx_dump_cnt)--; |
| 5851 | |
| 5852 | /* Clean out command structure on reaching dump count */ |
| 5853 | if (*mbx_dump_cnt == 0) |
| 5854 | memset(&idiag, 0, sizeof(idiag)); |
| 5855 | return; |
| 5856 | #endif |
| 5857 | } |
| 5858 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5859 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5860 | * lpfc_debugfs_initialize - Initialize debugfs for a vport |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5861 | * @vport: The vport pointer to initialize. |
| 5862 | * |
| 5863 | * Description: |
| 5864 | * When Debugfs is configured this routine sets up the lpfc debugfs file system. |
| 5865 | * If not already created, this routine will create the lpfc directory, and |
| 5866 | * lpfcX directory (for this HBA), and vportX directory for this vport. It will |
| 5867 | * also create each file used to access lpfc specific debugfs information. |
| 5868 | **/ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5869 | inline void |
| 5870 | lpfc_debugfs_initialize(struct lpfc_vport *vport) |
| 5871 | { |
James Smart | 923e4b6 | 2008-12-04 22:40:07 -0500 | [diff] [blame] | 5872 | #ifdef CONFIG_SCSI_LPFC_DEBUG_FS |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5873 | struct lpfc_hba *phba = vport->phba; |
| 5874 | char name[64]; |
| 5875 | uint32_t num, i; |
James Smart | f6c3bdf | 2013-12-17 20:29:59 -0500 | [diff] [blame] | 5876 | bool pport_setup = false; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5877 | |
| 5878 | if (!lpfc_debugfs_enable) |
| 5879 | return; |
| 5880 | |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 5881 | /* Setup lpfc root directory */ |
| 5882 | if (!lpfc_debugfs_root) { |
| 5883 | lpfc_debugfs_root = debugfs_create_dir("lpfc", NULL); |
| 5884 | atomic_set(&lpfc_debugfs_hba_count, 0); |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 5885 | } |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 5886 | if (!lpfc_debugfs_start_time) |
| 5887 | lpfc_debugfs_start_time = jiffies; |
| 5888 | |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 5889 | /* Setup funcX directory for specific HBA PCI function */ |
| 5890 | snprintf(name, sizeof(name), "fn%d", phba->brd_no); |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 5891 | if (!phba->hba_debugfs_root) { |
James Smart | f6c3bdf | 2013-12-17 20:29:59 -0500 | [diff] [blame] | 5892 | pport_setup = true; |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 5893 | phba->hba_debugfs_root = |
| 5894 | debugfs_create_dir(name, lpfc_debugfs_root); |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 5895 | atomic_inc(&lpfc_debugfs_hba_count); |
| 5896 | atomic_set(&phba->debugfs_vport_count, 0); |
| 5897 | |
James Smart | c490850 | 2019-01-28 11:14:28 -0800 | [diff] [blame] | 5898 | /* Multi-XRI pools */ |
| 5899 | snprintf(name, sizeof(name), "multixripools"); |
| 5900 | phba->debug_multixri_pools = |
| 5901 | debugfs_create_file(name, S_IFREG | 0644, |
| 5902 | phba->hba_debugfs_root, |
| 5903 | phba, |
| 5904 | &lpfc_debugfs_op_multixripools); |
| 5905 | if (!phba->debug_multixri_pools) { |
| 5906 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 5907 | "0527 Cannot create debugfs multixripools\n"); |
| 5908 | goto debug_failed; |
| 5909 | } |
| 5910 | |
James Smart | 95bfc6d | 2019-10-18 14:18:27 -0700 | [diff] [blame] | 5911 | /* RAS log */ |
| 5912 | snprintf(name, sizeof(name), "ras_log"); |
| 5913 | phba->debug_ras_log = |
| 5914 | debugfs_create_file(name, 0644, |
| 5915 | phba->hba_debugfs_root, |
| 5916 | phba, &lpfc_debugfs_ras_log); |
| 5917 | if (!phba->debug_ras_log) { |
| 5918 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 5919 | "6148 Cannot create debugfs" |
| 5920 | " ras_log\n"); |
| 5921 | goto debug_failed; |
| 5922 | } |
| 5923 | |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 5924 | /* Setup hbqinfo */ |
| 5925 | snprintf(name, sizeof(name), "hbqinfo"); |
| 5926 | phba->debug_hbqinfo = |
James Smart | 63df6d6 | 2019-01-28 11:14:24 -0800 | [diff] [blame] | 5927 | debugfs_create_file(name, S_IFREG | 0644, |
| 5928 | phba->hba_debugfs_root, |
| 5929 | phba, &lpfc_debugfs_op_hbqinfo); |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 5930 | |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 5931 | #ifdef LPFC_HDWQ_LOCK_STAT |
| 5932 | /* Setup lockstat */ |
| 5933 | snprintf(name, sizeof(name), "lockstat"); |
| 5934 | phba->debug_lockstat = |
James Smart | 5e5b511 | 2019-01-28 11:14:22 -0800 | [diff] [blame] | 5935 | debugfs_create_file(name, S_IFREG | 0644, |
| 5936 | phba->hba_debugfs_root, |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 5937 | phba, &lpfc_debugfs_op_lockstat); |
| 5938 | if (!phba->debug_lockstat) { |
James Smart | 5e5b511 | 2019-01-28 11:14:22 -0800 | [diff] [blame] | 5939 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
Colin Ian King | a9b8398 | 2020-08-10 11:12:38 +0100 | [diff] [blame] | 5940 | "4610 Can't create debugfs lockstat\n"); |
James Smart | 5e5b511 | 2019-01-28 11:14:22 -0800 | [diff] [blame] | 5941 | goto debug_failed; |
| 5942 | } |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 5943 | #endif |
James Smart | 5e5b511 | 2019-01-28 11:14:22 -0800 | [diff] [blame] | 5944 | |
James Smart | c95d6c6 | 2008-01-11 01:53:23 -0500 | [diff] [blame] | 5945 | /* Setup dumpHBASlim */ |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 5946 | if (phba->sli_rev < LPFC_SLI_REV4) { |
| 5947 | snprintf(name, sizeof(name), "dumpHBASlim"); |
| 5948 | phba->debug_dumpHBASlim = |
| 5949 | debugfs_create_file(name, |
| 5950 | S_IFREG|S_IRUGO|S_IWUSR, |
| 5951 | phba->hba_debugfs_root, |
| 5952 | phba, &lpfc_debugfs_op_dumpHBASlim); |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 5953 | } else |
| 5954 | phba->debug_dumpHBASlim = NULL; |
James Smart | c95d6c6 | 2008-01-11 01:53:23 -0500 | [diff] [blame] | 5955 | |
| 5956 | /* Setup dumpHostSlim */ |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 5957 | if (phba->sli_rev < LPFC_SLI_REV4) { |
| 5958 | snprintf(name, sizeof(name), "dumpHostSlim"); |
| 5959 | phba->debug_dumpHostSlim = |
| 5960 | debugfs_create_file(name, |
| 5961 | S_IFREG|S_IRUGO|S_IWUSR, |
| 5962 | phba->hba_debugfs_root, |
| 5963 | phba, &lpfc_debugfs_op_dumpHostSlim); |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 5964 | } else |
Felipe Pena | b28d108 | 2013-10-18 20:15:37 -0300 | [diff] [blame] | 5965 | phba->debug_dumpHostSlim = NULL; |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 5966 | |
James Smart | f9bb2da | 2011-10-10 21:34:11 -0400 | [diff] [blame] | 5967 | /* Setup DIF Error Injections */ |
| 5968 | snprintf(name, sizeof(name), "InjErrLBA"); |
| 5969 | phba->debug_InjErrLBA = |
| 5970 | debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR, |
| 5971 | phba->hba_debugfs_root, |
| 5972 | phba, &lpfc_debugfs_op_dif_err); |
James Smart | f9bb2da | 2011-10-10 21:34:11 -0400 | [diff] [blame] | 5973 | phba->lpfc_injerr_lba = LPFC_INJERR_LBA_OFF; |
| 5974 | |
James Smart | 4ac9b22 | 2012-03-01 22:38:29 -0500 | [diff] [blame] | 5975 | snprintf(name, sizeof(name), "InjErrNPortID"); |
| 5976 | phba->debug_InjErrNPortID = |
| 5977 | debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR, |
| 5978 | phba->hba_debugfs_root, |
| 5979 | phba, &lpfc_debugfs_op_dif_err); |
James Smart | 4ac9b22 | 2012-03-01 22:38:29 -0500 | [diff] [blame] | 5980 | |
| 5981 | snprintf(name, sizeof(name), "InjErrWWPN"); |
| 5982 | phba->debug_InjErrWWPN = |
| 5983 | debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR, |
| 5984 | phba->hba_debugfs_root, |
| 5985 | phba, &lpfc_debugfs_op_dif_err); |
James Smart | 4ac9b22 | 2012-03-01 22:38:29 -0500 | [diff] [blame] | 5986 | |
James Smart | f9bb2da | 2011-10-10 21:34:11 -0400 | [diff] [blame] | 5987 | snprintf(name, sizeof(name), "writeGuardInjErr"); |
| 5988 | phba->debug_writeGuard = |
| 5989 | debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR, |
| 5990 | phba->hba_debugfs_root, |
| 5991 | phba, &lpfc_debugfs_op_dif_err); |
James Smart | f9bb2da | 2011-10-10 21:34:11 -0400 | [diff] [blame] | 5992 | |
| 5993 | snprintf(name, sizeof(name), "writeAppInjErr"); |
| 5994 | phba->debug_writeApp = |
| 5995 | debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR, |
| 5996 | phba->hba_debugfs_root, |
| 5997 | phba, &lpfc_debugfs_op_dif_err); |
James Smart | f9bb2da | 2011-10-10 21:34:11 -0400 | [diff] [blame] | 5998 | |
| 5999 | snprintf(name, sizeof(name), "writeRefInjErr"); |
| 6000 | phba->debug_writeRef = |
| 6001 | debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR, |
| 6002 | phba->hba_debugfs_root, |
| 6003 | phba, &lpfc_debugfs_op_dif_err); |
James Smart | f9bb2da | 2011-10-10 21:34:11 -0400 | [diff] [blame] | 6004 | |
James Smart | acd6859 | 2012-01-18 16:25:09 -0500 | [diff] [blame] | 6005 | snprintf(name, sizeof(name), "readGuardInjErr"); |
| 6006 | phba->debug_readGuard = |
| 6007 | debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR, |
| 6008 | phba->hba_debugfs_root, |
| 6009 | phba, &lpfc_debugfs_op_dif_err); |
James Smart | acd6859 | 2012-01-18 16:25:09 -0500 | [diff] [blame] | 6010 | |
James Smart | f9bb2da | 2011-10-10 21:34:11 -0400 | [diff] [blame] | 6011 | snprintf(name, sizeof(name), "readAppInjErr"); |
| 6012 | phba->debug_readApp = |
| 6013 | debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR, |
| 6014 | phba->hba_debugfs_root, |
| 6015 | phba, &lpfc_debugfs_op_dif_err); |
James Smart | f9bb2da | 2011-10-10 21:34:11 -0400 | [diff] [blame] | 6016 | |
| 6017 | snprintf(name, sizeof(name), "readRefInjErr"); |
| 6018 | phba->debug_readRef = |
| 6019 | debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR, |
| 6020 | phba->hba_debugfs_root, |
| 6021 | phba, &lpfc_debugfs_op_dif_err); |
James Smart | f9bb2da | 2011-10-10 21:34:11 -0400 | [diff] [blame] | 6022 | |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 6023 | /* Setup slow ring trace */ |
| 6024 | if (lpfc_debugfs_max_slow_ring_trc) { |
| 6025 | num = lpfc_debugfs_max_slow_ring_trc - 1; |
| 6026 | if (num & lpfc_debugfs_max_slow_ring_trc) { |
| 6027 | /* Change to be a power of 2 */ |
| 6028 | num = lpfc_debugfs_max_slow_ring_trc; |
| 6029 | i = 0; |
| 6030 | while (num > 1) { |
| 6031 | num = num >> 1; |
| 6032 | i++; |
| 6033 | } |
| 6034 | lpfc_debugfs_max_slow_ring_trc = (1 << i); |
James Smart | 2ea259e | 2017-02-12 13:52:27 -0800 | [diff] [blame] | 6035 | pr_err("lpfc_debugfs_max_disc_trc changed to " |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 6036 | "%d\n", lpfc_debugfs_max_disc_trc); |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 6037 | } |
| 6038 | } |
| 6039 | |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 6040 | snprintf(name, sizeof(name), "slow_ring_trace"); |
| 6041 | phba->debug_slow_ring_trc = |
| 6042 | debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR, |
| 6043 | phba->hba_debugfs_root, |
| 6044 | phba, &lpfc_debugfs_op_slow_ring_trc); |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 6045 | if (!phba->slow_ring_trc) { |
| 6046 | phba->slow_ring_trc = kmalloc( |
| 6047 | (sizeof(struct lpfc_debugfs_trc) * |
| 6048 | lpfc_debugfs_max_slow_ring_trc), |
| 6049 | GFP_KERNEL); |
| 6050 | if (!phba->slow_ring_trc) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 6051 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 6052 | "0416 Cannot create debugfs " |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 6053 | "slow_ring buffer\n"); |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 6054 | goto debug_failed; |
| 6055 | } |
| 6056 | atomic_set(&phba->slow_ring_trc_cnt, 0); |
| 6057 | memset(phba->slow_ring_trc, 0, |
| 6058 | (sizeof(struct lpfc_debugfs_trc) * |
| 6059 | lpfc_debugfs_max_slow_ring_trc)); |
| 6060 | } |
James Smart | 2ea259e | 2017-02-12 13:52:27 -0800 | [diff] [blame] | 6061 | |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 6062 | snprintf(name, sizeof(name), "nvmeio_trc"); |
| 6063 | phba->debug_nvmeio_trc = |
| 6064 | debugfs_create_file(name, 0644, |
| 6065 | phba->hba_debugfs_root, |
| 6066 | phba, &lpfc_debugfs_op_nvmeio_trc); |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 6067 | |
| 6068 | atomic_set(&phba->nvmeio_trc_cnt, 0); |
| 6069 | if (lpfc_debugfs_max_nvmeio_trc) { |
| 6070 | num = lpfc_debugfs_max_nvmeio_trc - 1; |
| 6071 | if (num & lpfc_debugfs_max_disc_trc) { |
| 6072 | /* Change to be a power of 2 */ |
| 6073 | num = lpfc_debugfs_max_nvmeio_trc; |
| 6074 | i = 0; |
| 6075 | while (num > 1) { |
| 6076 | num = num >> 1; |
| 6077 | i++; |
| 6078 | } |
| 6079 | lpfc_debugfs_max_nvmeio_trc = (1 << i); |
| 6080 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 6081 | "0575 lpfc_debugfs_max_nvmeio_trc " |
| 6082 | "changed to %d\n", |
| 6083 | lpfc_debugfs_max_nvmeio_trc); |
| 6084 | } |
| 6085 | phba->nvmeio_trc_size = lpfc_debugfs_max_nvmeio_trc; |
| 6086 | |
| 6087 | /* Allocate trace buffer and initialize */ |
Vasyl Gomonovych | 1c356ec | 2017-10-11 21:42:41 +0200 | [diff] [blame] | 6088 | phba->nvmeio_trc = kzalloc( |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 6089 | (sizeof(struct lpfc_debugfs_nvmeio_trc) * |
| 6090 | phba->nvmeio_trc_size), GFP_KERNEL); |
| 6091 | |
| 6092 | if (!phba->nvmeio_trc) { |
| 6093 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 6094 | "0576 Cannot create debugfs " |
| 6095 | "nvmeio_trc buffer\n"); |
| 6096 | goto nvmeio_off; |
| 6097 | } |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 6098 | phba->nvmeio_trc_on = 1; |
| 6099 | phba->nvmeio_trc_output_idx = 0; |
| 6100 | phba->nvmeio_trc = NULL; |
| 6101 | } else { |
| 6102 | nvmeio_off: |
| 6103 | phba->nvmeio_trc_size = 0; |
| 6104 | phba->nvmeio_trc_on = 0; |
| 6105 | phba->nvmeio_trc_output_idx = 0; |
| 6106 | phba->nvmeio_trc = NULL; |
| 6107 | } |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 6108 | } |
| 6109 | |
| 6110 | snprintf(name, sizeof(name), "vport%d", vport->vpi); |
| 6111 | if (!vport->vport_debugfs_root) { |
| 6112 | vport->vport_debugfs_root = |
| 6113 | debugfs_create_dir(name, phba->hba_debugfs_root); |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 6114 | atomic_inc(&phba->debugfs_vport_count); |
| 6115 | } |
| 6116 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6117 | if (lpfc_debugfs_max_disc_trc) { |
| 6118 | num = lpfc_debugfs_max_disc_trc - 1; |
| 6119 | if (num & lpfc_debugfs_max_disc_trc) { |
| 6120 | /* Change to be a power of 2 */ |
| 6121 | num = lpfc_debugfs_max_disc_trc; |
| 6122 | i = 0; |
| 6123 | while (num > 1) { |
| 6124 | num = num >> 1; |
| 6125 | i++; |
| 6126 | } |
| 6127 | lpfc_debugfs_max_disc_trc = (1 << i); |
James Smart | 2ea259e | 2017-02-12 13:52:27 -0800 | [diff] [blame] | 6128 | pr_err("lpfc_debugfs_max_disc_trc changed to %d\n", |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 6129 | lpfc_debugfs_max_disc_trc); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6130 | } |
| 6131 | } |
| 6132 | |
Adrian Bunk | ff86ba5 | 2007-10-18 12:52:37 +0200 | [diff] [blame] | 6133 | vport->disc_trc = kzalloc( |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 6134 | (sizeof(struct lpfc_debugfs_trc) * lpfc_debugfs_max_disc_trc), |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6135 | GFP_KERNEL); |
| 6136 | |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 6137 | if (!vport->disc_trc) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 6138 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 6139 | "0418 Cannot create debugfs disc trace " |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 6140 | "buffer\n"); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6141 | goto debug_failed; |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 6142 | } |
| 6143 | atomic_set(&vport->disc_trc_cnt, 0); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6144 | |
| 6145 | snprintf(name, sizeof(name), "discovery_trace"); |
| 6146 | vport->debug_disc_trc = |
| 6147 | debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR, |
| 6148 | vport->vport_debugfs_root, |
| 6149 | vport, &lpfc_debugfs_op_disc_trc); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6150 | snprintf(name, sizeof(name), "nodelist"); |
| 6151 | vport->debug_nodelist = |
| 6152 | debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR, |
| 6153 | vport->vport_debugfs_root, |
| 6154 | vport, &lpfc_debugfs_op_nodelist); |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 6155 | |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 6156 | snprintf(name, sizeof(name), "nvmestat"); |
| 6157 | vport->debug_nvmestat = |
| 6158 | debugfs_create_file(name, 0644, |
| 6159 | vport->vport_debugfs_root, |
| 6160 | vport, &lpfc_debugfs_op_nvmestat); |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 6161 | |
James Smart | 4c47efc | 2019-01-28 11:14:25 -0800 | [diff] [blame] | 6162 | snprintf(name, sizeof(name), "scsistat"); |
| 6163 | vport->debug_scsistat = |
| 6164 | debugfs_create_file(name, 0644, |
| 6165 | vport->vport_debugfs_root, |
| 6166 | vport, &lpfc_debugfs_op_scsistat); |
| 6167 | if (!vport->debug_scsistat) { |
| 6168 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | c835c08 | 2019-03-12 16:30:30 -0700 | [diff] [blame] | 6169 | "4611 Cannot create debugfs scsistat\n"); |
James Smart | 4c47efc | 2019-01-28 11:14:25 -0800 | [diff] [blame] | 6170 | goto debug_failed; |
| 6171 | } |
| 6172 | |
James Smart | 2fcbc56 | 2020-03-22 11:13:02 -0700 | [diff] [blame] | 6173 | snprintf(name, sizeof(name), "ioktime"); |
| 6174 | vport->debug_ioktime = |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 6175 | debugfs_create_file(name, 0644, |
| 6176 | vport->vport_debugfs_root, |
James Smart | 2fcbc56 | 2020-03-22 11:13:02 -0700 | [diff] [blame] | 6177 | vport, &lpfc_debugfs_op_ioktime); |
| 6178 | if (!vport->debug_ioktime) { |
| 6179 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 6180 | "0815 Cannot create debugfs ioktime\n"); |
| 6181 | goto debug_failed; |
| 6182 | } |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 6183 | |
James Smart | 840eda9 | 2020-03-22 11:13:00 -0700 | [diff] [blame] | 6184 | snprintf(name, sizeof(name), "hdwqstat"); |
| 6185 | vport->debug_hdwqstat = |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 6186 | debugfs_create_file(name, 0644, |
| 6187 | vport->vport_debugfs_root, |
James Smart | 840eda9 | 2020-03-22 11:13:00 -0700 | [diff] [blame] | 6188 | vport, &lpfc_debugfs_op_hdwqstat); |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 6189 | |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 6190 | /* |
James Smart | f6c3bdf | 2013-12-17 20:29:59 -0500 | [diff] [blame] | 6191 | * The following section is for additional directories/files for the |
| 6192 | * physical port. |
| 6193 | */ |
| 6194 | |
| 6195 | if (!pport_setup) |
| 6196 | goto debug_failed; |
| 6197 | |
| 6198 | /* |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 6199 | * iDiag debugfs root entry points for SLI4 device only |
| 6200 | */ |
| 6201 | if (phba->sli_rev < LPFC_SLI_REV4) |
| 6202 | goto debug_failed; |
| 6203 | |
| 6204 | snprintf(name, sizeof(name), "iDiag"); |
| 6205 | if (!phba->idiag_root) { |
| 6206 | phba->idiag_root = |
| 6207 | debugfs_create_dir(name, phba->hba_debugfs_root); |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 6208 | /* Initialize iDiag data structure */ |
| 6209 | memset(&idiag, 0, sizeof(idiag)); |
| 6210 | } |
| 6211 | |
| 6212 | /* iDiag read PCI config space */ |
| 6213 | snprintf(name, sizeof(name), "pciCfg"); |
| 6214 | if (!phba->idiag_pci_cfg) { |
| 6215 | phba->idiag_pci_cfg = |
| 6216 | debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR, |
| 6217 | phba->idiag_root, phba, &lpfc_idiag_op_pciCfg); |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 6218 | idiag.offset.last_rd = 0; |
| 6219 | } |
| 6220 | |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 6221 | /* iDiag PCI BAR access */ |
| 6222 | snprintf(name, sizeof(name), "barAcc"); |
| 6223 | if (!phba->idiag_bar_acc) { |
| 6224 | phba->idiag_bar_acc = |
| 6225 | debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR, |
| 6226 | phba->idiag_root, phba, &lpfc_idiag_op_barAcc); |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 6227 | idiag.offset.last_rd = 0; |
| 6228 | } |
| 6229 | |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 6230 | /* iDiag get PCI function queue information */ |
| 6231 | snprintf(name, sizeof(name), "queInfo"); |
| 6232 | if (!phba->idiag_que_info) { |
| 6233 | phba->idiag_que_info = |
| 6234 | debugfs_create_file(name, S_IFREG|S_IRUGO, |
| 6235 | phba->idiag_root, phba, &lpfc_idiag_op_queInfo); |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 6236 | } |
| 6237 | |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 6238 | /* iDiag access PCI function queue */ |
| 6239 | snprintf(name, sizeof(name), "queAcc"); |
| 6240 | if (!phba->idiag_que_acc) { |
| 6241 | phba->idiag_que_acc = |
| 6242 | debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR, |
| 6243 | phba->idiag_root, phba, &lpfc_idiag_op_queAcc); |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 6244 | } |
| 6245 | |
| 6246 | /* iDiag access PCI function doorbell registers */ |
| 6247 | snprintf(name, sizeof(name), "drbAcc"); |
| 6248 | if (!phba->idiag_drb_acc) { |
| 6249 | phba->idiag_drb_acc = |
| 6250 | debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR, |
| 6251 | phba->idiag_root, phba, &lpfc_idiag_op_drbAcc); |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 6252 | } |
| 6253 | |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 6254 | /* iDiag access PCI function control registers */ |
| 6255 | snprintf(name, sizeof(name), "ctlAcc"); |
| 6256 | if (!phba->idiag_ctl_acc) { |
| 6257 | phba->idiag_ctl_acc = |
| 6258 | debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR, |
| 6259 | phba->idiag_root, phba, &lpfc_idiag_op_ctlAcc); |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 6260 | } |
| 6261 | |
| 6262 | /* iDiag access mbox commands */ |
| 6263 | snprintf(name, sizeof(name), "mbxAcc"); |
| 6264 | if (!phba->idiag_mbx_acc) { |
| 6265 | phba->idiag_mbx_acc = |
| 6266 | debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR, |
| 6267 | phba->idiag_root, phba, &lpfc_idiag_op_mbxAcc); |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 6268 | } |
| 6269 | |
| 6270 | /* iDiag extents access commands */ |
| 6271 | if (phba->sli4_hba.extents_in_use) { |
| 6272 | snprintf(name, sizeof(name), "extAcc"); |
| 6273 | if (!phba->idiag_ext_acc) { |
| 6274 | phba->idiag_ext_acc = |
| 6275 | debugfs_create_file(name, |
| 6276 | S_IFREG|S_IRUGO|S_IWUSR, |
| 6277 | phba->idiag_root, phba, |
| 6278 | &lpfc_idiag_op_extAcc); |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 6279 | } |
| 6280 | } |
| 6281 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6282 | debug_failed: |
| 6283 | return; |
| 6284 | #endif |
| 6285 | } |
| 6286 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6287 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6288 | * lpfc_debugfs_terminate - Tear down debugfs infrastructure for this vport |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6289 | * @vport: The vport pointer to remove from debugfs. |
| 6290 | * |
| 6291 | * Description: |
| 6292 | * When Debugfs is configured this routine removes debugfs file system elements |
| 6293 | * that are specific to this vport. It also checks to see if there are any |
| 6294 | * users left for the debugfs directories associated with the HBA and driver. If |
| 6295 | * this is the last user of the HBA directory or driver directory then it will |
| 6296 | * remove those from the debugfs infrastructure as well. |
| 6297 | **/ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6298 | inline void |
| 6299 | lpfc_debugfs_terminate(struct lpfc_vport *vport) |
| 6300 | { |
James Smart | 923e4b6 | 2008-12-04 22:40:07 -0500 | [diff] [blame] | 6301 | #ifdef CONFIG_SCSI_LPFC_DEBUG_FS |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6302 | struct lpfc_hba *phba = vport->phba; |
| 6303 | |
James Smart | eafe89f | 2017-04-21 16:04:52 -0700 | [diff] [blame] | 6304 | kfree(vport->disc_trc); |
| 6305 | vport->disc_trc = NULL; |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 6306 | |
| 6307 | debugfs_remove(vport->debug_disc_trc); /* discovery_trace */ |
| 6308 | vport->debug_disc_trc = NULL; |
| 6309 | |
| 6310 | debugfs_remove(vport->debug_nodelist); /* nodelist */ |
| 6311 | vport->debug_nodelist = NULL; |
| 6312 | |
| 6313 | debugfs_remove(vport->debug_nvmestat); /* nvmestat */ |
| 6314 | vport->debug_nvmestat = NULL; |
| 6315 | |
James Smart | 4c47efc | 2019-01-28 11:14:25 -0800 | [diff] [blame] | 6316 | debugfs_remove(vport->debug_scsistat); /* scsistat */ |
| 6317 | vport->debug_scsistat = NULL; |
| 6318 | |
James Smart | 2fcbc56 | 2020-03-22 11:13:02 -0700 | [diff] [blame] | 6319 | debugfs_remove(vport->debug_ioktime); /* ioktime */ |
| 6320 | vport->debug_ioktime = NULL; |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 6321 | |
James Smart | 840eda9 | 2020-03-22 11:13:00 -0700 | [diff] [blame] | 6322 | debugfs_remove(vport->debug_hdwqstat); /* hdwqstat */ |
| 6323 | vport->debug_hdwqstat = NULL; |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 6324 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6325 | if (vport->vport_debugfs_root) { |
| 6326 | debugfs_remove(vport->vport_debugfs_root); /* vportX */ |
| 6327 | vport->vport_debugfs_root = NULL; |
| 6328 | atomic_dec(&phba->debugfs_vport_count); |
| 6329 | } |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 6330 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6331 | if (atomic_read(&phba->debugfs_vport_count) == 0) { |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 6332 | |
James Smart | c490850 | 2019-01-28 11:14:28 -0800 | [diff] [blame] | 6333 | debugfs_remove(phba->debug_multixri_pools); /* multixripools*/ |
| 6334 | phba->debug_multixri_pools = NULL; |
| 6335 | |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 6336 | debugfs_remove(phba->debug_hbqinfo); /* hbqinfo */ |
| 6337 | phba->debug_hbqinfo = NULL; |
James Smart | e2a0a9d | 2008-12-04 22:40:02 -0500 | [diff] [blame] | 6338 | |
James Smart | 95bfc6d | 2019-10-18 14:18:27 -0700 | [diff] [blame] | 6339 | debugfs_remove(phba->debug_ras_log); |
| 6340 | phba->debug_ras_log = NULL; |
| 6341 | |
James Smart | 6a828b0 | 2019-01-28 11:14:31 -0800 | [diff] [blame] | 6342 | #ifdef LPFC_HDWQ_LOCK_STAT |
| 6343 | debugfs_remove(phba->debug_lockstat); /* lockstat */ |
| 6344 | phba->debug_lockstat = NULL; |
| 6345 | #endif |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 6346 | debugfs_remove(phba->debug_dumpHBASlim); /* HBASlim */ |
| 6347 | phba->debug_dumpHBASlim = NULL; |
| 6348 | |
| 6349 | debugfs_remove(phba->debug_dumpHostSlim); /* HostSlim */ |
| 6350 | phba->debug_dumpHostSlim = NULL; |
| 6351 | |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 6352 | debugfs_remove(phba->debug_InjErrLBA); /* InjErrLBA */ |
| 6353 | phba->debug_InjErrLBA = NULL; |
| 6354 | |
| 6355 | debugfs_remove(phba->debug_InjErrNPortID); |
| 6356 | phba->debug_InjErrNPortID = NULL; |
| 6357 | |
| 6358 | debugfs_remove(phba->debug_InjErrWWPN); /* InjErrWWPN */ |
| 6359 | phba->debug_InjErrWWPN = NULL; |
| 6360 | |
| 6361 | debugfs_remove(phba->debug_writeGuard); /* writeGuard */ |
| 6362 | phba->debug_writeGuard = NULL; |
| 6363 | |
| 6364 | debugfs_remove(phba->debug_writeApp); /* writeApp */ |
| 6365 | phba->debug_writeApp = NULL; |
| 6366 | |
| 6367 | debugfs_remove(phba->debug_writeRef); /* writeRef */ |
| 6368 | phba->debug_writeRef = NULL; |
| 6369 | |
| 6370 | debugfs_remove(phba->debug_readGuard); /* readGuard */ |
| 6371 | phba->debug_readGuard = NULL; |
| 6372 | |
| 6373 | debugfs_remove(phba->debug_readApp); /* readApp */ |
| 6374 | phba->debug_readApp = NULL; |
| 6375 | |
| 6376 | debugfs_remove(phba->debug_readRef); /* readRef */ |
| 6377 | phba->debug_readRef = NULL; |
James Smart | e2a0a9d | 2008-12-04 22:40:02 -0500 | [diff] [blame] | 6378 | |
James Smart | eafe89f | 2017-04-21 16:04:52 -0700 | [diff] [blame] | 6379 | kfree(phba->slow_ring_trc); |
| 6380 | phba->slow_ring_trc = NULL; |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 6381 | |
| 6382 | /* slow_ring_trace */ |
| 6383 | debugfs_remove(phba->debug_slow_ring_trc); |
| 6384 | phba->debug_slow_ring_trc = NULL; |
| 6385 | |
| 6386 | debugfs_remove(phba->debug_nvmeio_trc); |
| 6387 | phba->debug_nvmeio_trc = NULL; |
| 6388 | |
| 6389 | kfree(phba->nvmeio_trc); |
| 6390 | phba->nvmeio_trc = NULL; |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 6391 | |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 6392 | /* |
| 6393 | * iDiag release |
| 6394 | */ |
| 6395 | if (phba->sli_rev == LPFC_SLI_REV4) { |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 6396 | /* iDiag extAcc */ |
| 6397 | debugfs_remove(phba->idiag_ext_acc); |
| 6398 | phba->idiag_ext_acc = NULL; |
| 6399 | |
| 6400 | /* iDiag mbxAcc */ |
| 6401 | debugfs_remove(phba->idiag_mbx_acc); |
| 6402 | phba->idiag_mbx_acc = NULL; |
| 6403 | |
| 6404 | /* iDiag ctlAcc */ |
| 6405 | debugfs_remove(phba->idiag_ctl_acc); |
| 6406 | phba->idiag_ctl_acc = NULL; |
| 6407 | |
| 6408 | /* iDiag drbAcc */ |
| 6409 | debugfs_remove(phba->idiag_drb_acc); |
| 6410 | phba->idiag_drb_acc = NULL; |
| 6411 | |
| 6412 | /* iDiag queAcc */ |
| 6413 | debugfs_remove(phba->idiag_que_acc); |
| 6414 | phba->idiag_que_acc = NULL; |
| 6415 | |
| 6416 | /* iDiag queInfo */ |
| 6417 | debugfs_remove(phba->idiag_que_info); |
| 6418 | phba->idiag_que_info = NULL; |
| 6419 | |
| 6420 | /* iDiag barAcc */ |
| 6421 | debugfs_remove(phba->idiag_bar_acc); |
| 6422 | phba->idiag_bar_acc = NULL; |
| 6423 | |
| 6424 | /* iDiag pciCfg */ |
| 6425 | debugfs_remove(phba->idiag_pci_cfg); |
| 6426 | phba->idiag_pci_cfg = NULL; |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 6427 | |
| 6428 | /* Finally remove the iDiag debugfs root */ |
James Smart | bd2cdd5 | 2017-02-12 13:52:33 -0800 | [diff] [blame] | 6429 | debugfs_remove(phba->idiag_root); |
| 6430 | phba->idiag_root = NULL; |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 6431 | } |
| 6432 | |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 6433 | if (phba->hba_debugfs_root) { |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 6434 | debugfs_remove(phba->hba_debugfs_root); /* fnX */ |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 6435 | phba->hba_debugfs_root = NULL; |
| 6436 | atomic_dec(&lpfc_debugfs_hba_count); |
| 6437 | } |
| 6438 | |
James Smart | 667a766 | 2017-05-15 15:20:48 -0700 | [diff] [blame] | 6439 | if (atomic_read(&lpfc_debugfs_hba_count) == 0) { |
| 6440 | debugfs_remove(lpfc_debugfs_root); /* lpfc */ |
| 6441 | lpfc_debugfs_root = NULL; |
| 6442 | } |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6443 | } |
| 6444 | #endif |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 6445 | return; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6446 | } |
James Smart | 809c753 | 2012-05-09 21:19:25 -0400 | [diff] [blame] | 6447 | |
| 6448 | /* |
| 6449 | * Driver debug utility routines outside of debugfs. The debug utility |
| 6450 | * routines implemented here is intended to be used in the instrumented |
| 6451 | * debug driver for debugging host or port issues. |
| 6452 | */ |
| 6453 | |
| 6454 | /** |
| 6455 | * lpfc_debug_dump_all_queues - dump all the queues with a hba |
| 6456 | * @phba: Pointer to HBA context object. |
| 6457 | * |
| 6458 | * This function dumps entries of all the queues asociated with the @phba. |
| 6459 | **/ |
| 6460 | void |
| 6461 | lpfc_debug_dump_all_queues(struct lpfc_hba *phba) |
| 6462 | { |
James Smart | 1d9d5a9 | 2017-02-12 13:52:29 -0800 | [diff] [blame] | 6463 | int idx; |
James Smart | 809c753 | 2012-05-09 21:19:25 -0400 | [diff] [blame] | 6464 | |
| 6465 | /* |
| 6466 | * Dump Work Queues (WQs) |
| 6467 | */ |
James Smart | 1d9d5a9 | 2017-02-12 13:52:29 -0800 | [diff] [blame] | 6468 | lpfc_debug_dump_wq(phba, DUMP_MBX, 0); |
| 6469 | lpfc_debug_dump_wq(phba, DUMP_ELS, 0); |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6470 | lpfc_debug_dump_wq(phba, DUMP_NVMELS, 0); |
James Smart | 809c753 | 2012-05-09 21:19:25 -0400 | [diff] [blame] | 6471 | |
James Smart | cdb42be | 2019-01-28 11:14:21 -0800 | [diff] [blame] | 6472 | for (idx = 0; idx < phba->cfg_hdw_queue; idx++) |
James Smart | c00f62e | 2019-08-14 16:57:11 -0700 | [diff] [blame] | 6473 | lpfc_debug_dump_wq(phba, DUMP_IO, idx); |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6474 | |
James Smart | 809c753 | 2012-05-09 21:19:25 -0400 | [diff] [blame] | 6475 | lpfc_debug_dump_hdr_rq(phba); |
| 6476 | lpfc_debug_dump_dat_rq(phba); |
| 6477 | /* |
| 6478 | * Dump Complete Queues (CQs) |
| 6479 | */ |
James Smart | 1d9d5a9 | 2017-02-12 13:52:29 -0800 | [diff] [blame] | 6480 | lpfc_debug_dump_cq(phba, DUMP_MBX, 0); |
| 6481 | lpfc_debug_dump_cq(phba, DUMP_ELS, 0); |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6482 | lpfc_debug_dump_cq(phba, DUMP_NVMELS, 0); |
James Smart | 809c753 | 2012-05-09 21:19:25 -0400 | [diff] [blame] | 6483 | |
James Smart | cdb42be | 2019-01-28 11:14:21 -0800 | [diff] [blame] | 6484 | for (idx = 0; idx < phba->cfg_hdw_queue; idx++) |
James Smart | c00f62e | 2019-08-14 16:57:11 -0700 | [diff] [blame] | 6485 | lpfc_debug_dump_cq(phba, DUMP_IO, idx); |
James Smart | 895427b | 2017-02-12 13:52:30 -0800 | [diff] [blame] | 6486 | |
James Smart | 809c753 | 2012-05-09 21:19:25 -0400 | [diff] [blame] | 6487 | /* |
| 6488 | * Dump Event Queues (EQs) |
| 6489 | */ |
James Smart | cdb42be | 2019-01-28 11:14:21 -0800 | [diff] [blame] | 6490 | for (idx = 0; idx < phba->cfg_hdw_queue; idx++) |
James Smart | 1d9d5a9 | 2017-02-12 13:52:29 -0800 | [diff] [blame] | 6491 | lpfc_debug_dump_hba_eq(phba, idx); |
James Smart | 809c753 | 2012-05-09 21:19:25 -0400 | [diff] [blame] | 6492 | } |