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 | d85296c | 2012-03-01 22:38:13 -0500 | [diff] [blame] | 4 | * Copyright (C) 2007-2012 Emulex. All rights reserved. * |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5 | * EMULEX and SLI are trademarks of Emulex. * |
| 6 | * www.emulex.com * |
| 7 | * * |
| 8 | * This program is free software; you can redistribute it and/or * |
| 9 | * modify it under the terms of version 2 of the GNU General * |
| 10 | * Public License as published by the Free Software Foundation. * |
| 11 | * This program is distributed in the hope that it will be useful. * |
| 12 | * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND * |
| 13 | * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, * |
| 14 | * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE * |
| 15 | * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD * |
| 16 | * TO BE LEGALLY INVALID. See the GNU General Public License for * |
| 17 | * more details, a copy of which can be found in the file COPYING * |
| 18 | * included with this package. * |
| 19 | *******************************************************************/ |
| 20 | |
| 21 | #include <linux/blkdev.h> |
| 22 | #include <linux/delay.h> |
Paul Gortmaker | acf3368f | 2011-05-27 09:47:43 -0400 | [diff] [blame] | 23 | #include <linux/module.h> |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 24 | #include <linux/dma-mapping.h> |
| 25 | #include <linux/idr.h> |
| 26 | #include <linux/interrupt.h> |
| 27 | #include <linux/kthread.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 28 | #include <linux/slab.h> |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 29 | #include <linux/pci.h> |
| 30 | #include <linux/spinlock.h> |
| 31 | #include <linux/ctype.h> |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 32 | |
| 33 | #include <scsi/scsi.h> |
| 34 | #include <scsi/scsi_device.h> |
| 35 | #include <scsi/scsi_host.h> |
| 36 | #include <scsi/scsi_transport_fc.h> |
| 37 | |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 38 | #include "lpfc_hw4.h" |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 39 | #include "lpfc_hw.h" |
| 40 | #include "lpfc_sli.h" |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 41 | #include "lpfc_sli4.h" |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 42 | #include "lpfc_nl.h" |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 43 | #include "lpfc_disc.h" |
| 44 | #include "lpfc_scsi.h" |
| 45 | #include "lpfc.h" |
| 46 | #include "lpfc_logmsg.h" |
| 47 | #include "lpfc_crtn.h" |
| 48 | #include "lpfc_vport.h" |
| 49 | #include "lpfc_version.h" |
James Smart | c95d6c6 | 2008-01-11 01:53:23 -0500 | [diff] [blame] | 50 | #include "lpfc_compat.h" |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 51 | #include "lpfc_debugfs.h" |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 52 | #include "lpfc_bsg.h" |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 53 | |
James Smart | 923e4b6 | 2008-12-04 22:40:07 -0500 | [diff] [blame] | 54 | #ifdef CONFIG_SCSI_LPFC_DEBUG_FS |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 55 | /* |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 56 | * debugfs interface |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 57 | * |
| 58 | * To access this interface the user should: |
GeunSik Lim | 156f5a7 | 2009-06-02 15:01:37 +0900 | [diff] [blame] | 59 | * # mount -t debugfs none /sys/kernel/debug |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 60 | * |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 61 | * The lpfc debugfs directory hierarchy is: |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 62 | * /sys/kernel/debug/lpfc/fnX/vportY |
| 63 | * where X is the lpfc hba function unique_id |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 64 | * where Y is the vport VPI on that hba |
| 65 | * |
| 66 | * Debugging services available per vport: |
| 67 | * discovery_trace |
| 68 | * This is an ACSII readable file that contains a trace of the last |
| 69 | * lpfc_debugfs_max_disc_trc events that happened on a specific vport. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 70 | * See lpfc_debugfs.h for different categories of discovery events. |
| 71 | * To enable the discovery trace, the following module parameters must be set: |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 72 | * lpfc_debugfs_enable=1 Turns on lpfc debugfs filesystem support |
| 73 | * lpfc_debugfs_max_disc_trc=X Where X is the event trace depth for |
| 74 | * EACH vport. X MUST also be a power of 2. |
| 75 | * lpfc_debugfs_mask_disc_trc=Y Where Y is an event mask as defined in |
| 76 | * lpfc_debugfs.h . |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 77 | * |
| 78 | * slow_ring_trace |
| 79 | * This is an ACSII readable file that contains a trace of the last |
| 80 | * lpfc_debugfs_max_slow_ring_trc events that happened on a specific HBA. |
| 81 | * To enable the slow ring trace, the following module parameters must be set: |
| 82 | * lpfc_debugfs_enable=1 Turns on lpfc debugfs filesystem support |
| 83 | * lpfc_debugfs_max_slow_ring_trc=X Where X is the event trace depth for |
| 84 | * the HBA. X MUST also be a power of 2. |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 85 | */ |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 86 | static int lpfc_debugfs_enable = 1; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 87 | module_param(lpfc_debugfs_enable, int, S_IRUGO); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 88 | MODULE_PARM_DESC(lpfc_debugfs_enable, "Enable debugfs services"); |
| 89 | |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 90 | /* This MUST be a power of 2 */ |
James Smart | c95d6c6 | 2008-01-11 01:53:23 -0500 | [diff] [blame] | 91 | static int lpfc_debugfs_max_disc_trc; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 92 | module_param(lpfc_debugfs_max_disc_trc, int, S_IRUGO); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 93 | MODULE_PARM_DESC(lpfc_debugfs_max_disc_trc, |
| 94 | "Set debugfs discovery trace depth"); |
| 95 | |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 96 | /* This MUST be a power of 2 */ |
James Smart | c95d6c6 | 2008-01-11 01:53:23 -0500 | [diff] [blame] | 97 | static int lpfc_debugfs_max_slow_ring_trc; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 98 | module_param(lpfc_debugfs_max_slow_ring_trc, int, S_IRUGO); |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 99 | MODULE_PARM_DESC(lpfc_debugfs_max_slow_ring_trc, |
| 100 | "Set debugfs slow ring trace depth"); |
| 101 | |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 102 | static int lpfc_debugfs_mask_disc_trc; |
James Smart | ab56dc2 | 2011-02-16 12:39:57 -0500 | [diff] [blame] | 103 | module_param(lpfc_debugfs_mask_disc_trc, int, S_IRUGO); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 104 | MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc, |
| 105 | "Set debugfs discovery trace mask"); |
| 106 | |
| 107 | #include <linux/debugfs.h> |
| 108 | |
James Smart | 311464e | 2007-08-02 11:10:37 -0400 | [diff] [blame] | 109 | static atomic_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0); |
| 110 | static unsigned long lpfc_debugfs_start_time = 0L; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 111 | |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 112 | /* iDiag */ |
| 113 | static struct lpfc_idiag idiag; |
| 114 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 115 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 116 | * lpfc_debugfs_disc_trc_data - Dump discovery logging to a buffer |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 117 | * @vport: The vport to gather the log info from. |
| 118 | * @buf: The buffer to dump log into. |
| 119 | * @size: The maximum amount of data to process. |
| 120 | * |
| 121 | * Description: |
| 122 | * This routine gathers the lpfc discovery debugfs data from the @vport and |
| 123 | * dumps it to @buf up to @size number of bytes. It will start at the next entry |
| 124 | * in the log and process the log until the end of the buffer. Then it will |
| 125 | * gather from the beginning of the log and process until the current entry. |
| 126 | * |
| 127 | * Notes: |
| 128 | * Discovery logging will be disabled while while this routine dumps the log. |
| 129 | * |
| 130 | * Return Value: |
| 131 | * This routine returns the amount of bytes that were dumped into @buf and will |
| 132 | * not exceed @size. |
| 133 | **/ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 134 | static int |
| 135 | lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size) |
| 136 | { |
| 137 | int i, index, len, enable; |
| 138 | uint32_t ms; |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 139 | struct lpfc_debugfs_trc *dtp; |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 140 | char *buffer; |
| 141 | |
| 142 | buffer = kmalloc(LPFC_DEBUG_TRC_ENTRY_SIZE, GFP_KERNEL); |
| 143 | if (!buffer) |
| 144 | return 0; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 145 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 146 | enable = lpfc_debugfs_enable; |
| 147 | lpfc_debugfs_enable = 0; |
| 148 | |
| 149 | len = 0; |
| 150 | index = (atomic_read(&vport->disc_trc_cnt) + 1) & |
| 151 | (lpfc_debugfs_max_disc_trc - 1); |
| 152 | for (i = index; i < lpfc_debugfs_max_disc_trc; i++) { |
| 153 | dtp = vport->disc_trc + i; |
| 154 | if (!dtp->fmt) |
| 155 | continue; |
| 156 | ms = jiffies_to_msecs(dtp->jif - lpfc_debugfs_start_time); |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 157 | snprintf(buffer, |
| 158 | LPFC_DEBUG_TRC_ENTRY_SIZE, "%010d:%010d ms:%s\n", |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 159 | dtp->seq_cnt, ms, dtp->fmt); |
| 160 | len += snprintf(buf+len, size-len, buffer, |
| 161 | dtp->data1, dtp->data2, dtp->data3); |
| 162 | } |
| 163 | for (i = 0; i < index; 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); |
| 171 | len += snprintf(buf+len, size-len, buffer, |
| 172 | dtp->data1, dtp->data2, dtp->data3); |
| 173 | } |
| 174 | |
| 175 | lpfc_debugfs_enable = enable; |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 176 | kfree(buffer); |
| 177 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 178 | return len; |
| 179 | } |
| 180 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 181 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 182 | * 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] | 183 | * @phba: The HBA to gather the log info from. |
| 184 | * @buf: The buffer to dump log into. |
| 185 | * @size: The maximum amount of data to process. |
| 186 | * |
| 187 | * Description: |
| 188 | * This routine gathers the lpfc slow ring debugfs data from the @phba and |
| 189 | * dumps it to @buf up to @size number of bytes. It will start at the next entry |
| 190 | * in the log and process the log until the end of the buffer. Then it will |
| 191 | * gather from the beginning of the log and process until the current entry. |
| 192 | * |
| 193 | * Notes: |
| 194 | * Slow ring logging will be disabled while while this routine dumps the log. |
| 195 | * |
| 196 | * Return Value: |
| 197 | * This routine returns the amount of bytes that were dumped into @buf and will |
| 198 | * not exceed @size. |
| 199 | **/ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 200 | static int |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 201 | lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba *phba, char *buf, int size) |
| 202 | { |
| 203 | int i, index, len, enable; |
| 204 | uint32_t ms; |
| 205 | struct lpfc_debugfs_trc *dtp; |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 206 | char *buffer; |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 207 | |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 208 | buffer = kmalloc(LPFC_DEBUG_TRC_ENTRY_SIZE, GFP_KERNEL); |
| 209 | if (!buffer) |
| 210 | return 0; |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 211 | |
| 212 | enable = lpfc_debugfs_enable; |
| 213 | lpfc_debugfs_enable = 0; |
| 214 | |
| 215 | len = 0; |
| 216 | index = (atomic_read(&phba->slow_ring_trc_cnt) + 1) & |
| 217 | (lpfc_debugfs_max_slow_ring_trc - 1); |
| 218 | for (i = index; i < lpfc_debugfs_max_slow_ring_trc; i++) { |
| 219 | dtp = phba->slow_ring_trc + i; |
| 220 | if (!dtp->fmt) |
| 221 | continue; |
| 222 | ms = jiffies_to_msecs(dtp->jif - lpfc_debugfs_start_time); |
| 223 | snprintf(buffer, |
| 224 | LPFC_DEBUG_TRC_ENTRY_SIZE, "%010d:%010d ms:%s\n", |
| 225 | dtp->seq_cnt, ms, dtp->fmt); |
| 226 | len += snprintf(buf+len, size-len, buffer, |
| 227 | dtp->data1, dtp->data2, dtp->data3); |
| 228 | } |
| 229 | for (i = 0; i < index; 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); |
| 237 | len += snprintf(buf+len, size-len, buffer, |
| 238 | dtp->data1, dtp->data2, dtp->data3); |
| 239 | } |
| 240 | |
| 241 | lpfc_debugfs_enable = enable; |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 242 | kfree(buffer); |
| 243 | |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 244 | return len; |
| 245 | } |
| 246 | |
James Smart | 311464e | 2007-08-02 11:10:37 -0400 | [diff] [blame] | 247 | static int lpfc_debugfs_last_hbq = -1; |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 248 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 249 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 250 | * lpfc_debugfs_hbqinfo_data - Dump host buffer queue info to a buffer |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 251 | * @phba: The HBA to gather host buffer info from. |
| 252 | * @buf: The buffer to dump log into. |
| 253 | * @size: The maximum amount of data to process. |
| 254 | * |
| 255 | * Description: |
| 256 | * This routine dumps the host buffer queue info from the @phba to @buf up to |
| 257 | * @size number of bytes. A header that describes the current hbq state will be |
| 258 | * dumped to @buf first and then info on each hbq entry will be dumped to @buf |
| 259 | * until @size bytes have been dumped or all the hbq info has been dumped. |
| 260 | * |
| 261 | * Notes: |
| 262 | * This routine will rotate through each configured HBQ each time called. |
| 263 | * |
| 264 | * Return Value: |
| 265 | * This routine returns the amount of bytes that were dumped into @buf and will |
| 266 | * not exceed @size. |
| 267 | **/ |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 268 | static int |
| 269 | lpfc_debugfs_hbqinfo_data(struct lpfc_hba *phba, char *buf, int size) |
| 270 | { |
| 271 | int len = 0; |
| 272 | int cnt, i, j, found, posted, low; |
| 273 | uint32_t phys, raw_index, getidx; |
| 274 | struct lpfc_hbq_init *hip; |
| 275 | struct hbq_s *hbqs; |
| 276 | struct lpfc_hbq_entry *hbqe; |
| 277 | struct lpfc_dmabuf *d_buf; |
| 278 | struct hbq_dmabuf *hbq_buf; |
| 279 | |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 280 | if (phba->sli_rev != 3) |
| 281 | return 0; |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 282 | cnt = LPFC_HBQINFO_SIZE; |
| 283 | spin_lock_irq(&phba->hbalock); |
| 284 | |
| 285 | /* toggle between multiple hbqs, if any */ |
| 286 | i = lpfc_sli_hbq_count(); |
| 287 | if (i > 1) { |
| 288 | lpfc_debugfs_last_hbq++; |
| 289 | if (lpfc_debugfs_last_hbq >= i) |
| 290 | lpfc_debugfs_last_hbq = 0; |
| 291 | } |
| 292 | else |
| 293 | lpfc_debugfs_last_hbq = 0; |
| 294 | |
| 295 | i = lpfc_debugfs_last_hbq; |
| 296 | |
| 297 | len += snprintf(buf+len, size-len, "HBQ %d Info\n", i); |
| 298 | |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 299 | hbqs = &phba->hbqs[i]; |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 300 | posted = 0; |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 301 | list_for_each_entry(d_buf, &hbqs->hbq_buffer_list, list) |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 302 | posted++; |
| 303 | |
| 304 | hip = lpfc_hbq_defs[i]; |
| 305 | len += snprintf(buf+len, size-len, |
| 306 | "idx:%d prof:%d rn:%d bufcnt:%d icnt:%d acnt:%d posted %d\n", |
| 307 | hip->hbq_index, hip->profile, hip->rn, |
| 308 | hip->buffer_count, hip->init_count, hip->add_count, posted); |
| 309 | |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 310 | raw_index = phba->hbq_get[i]; |
| 311 | getidx = le32_to_cpu(raw_index); |
| 312 | len += snprintf(buf+len, size-len, |
James Smart | a8adb83 | 2007-10-27 13:37:53 -0400 | [diff] [blame] | 313 | "entrys:%d bufcnt:%d Put:%d nPut:%d localGet:%d hbaGet:%d\n", |
| 314 | hbqs->entry_count, hbqs->buffer_count, hbqs->hbqPutIdx, |
| 315 | hbqs->next_hbqPutIdx, hbqs->local_hbqGetIdx, getidx); |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 316 | |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 317 | hbqe = (struct lpfc_hbq_entry *) phba->hbqs[i].hbq_virt; |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 318 | for (j=0; j<hbqs->entry_count; j++) { |
| 319 | len += snprintf(buf+len, size-len, |
| 320 | "%03d: %08x %04x %05x ", j, |
James Smart | a8adb83 | 2007-10-27 13:37:53 -0400 | [diff] [blame] | 321 | le32_to_cpu(hbqe->bde.addrLow), |
| 322 | le32_to_cpu(hbqe->bde.tus.w), |
| 323 | le32_to_cpu(hbqe->buffer_tag)); |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 324 | i = 0; |
| 325 | found = 0; |
| 326 | |
| 327 | /* First calculate if slot has an associated posted buffer */ |
| 328 | low = hbqs->hbqPutIdx - posted; |
| 329 | if (low >= 0) { |
| 330 | if ((j >= hbqs->hbqPutIdx) || (j < low)) { |
| 331 | len += snprintf(buf+len, size-len, "Unused\n"); |
| 332 | goto skipit; |
| 333 | } |
| 334 | } |
| 335 | else { |
| 336 | if ((j >= hbqs->hbqPutIdx) && |
| 337 | (j < (hbqs->entry_count+low))) { |
| 338 | len += snprintf(buf+len, size-len, "Unused\n"); |
| 339 | goto skipit; |
| 340 | } |
| 341 | } |
| 342 | |
| 343 | /* Get the Buffer info for the posted buffer */ |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 344 | list_for_each_entry(d_buf, &hbqs->hbq_buffer_list, list) { |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 345 | hbq_buf = container_of(d_buf, struct hbq_dmabuf, dbuf); |
| 346 | phys = ((uint64_t)hbq_buf->dbuf.phys & 0xffffffff); |
James Smart | a8adb83 | 2007-10-27 13:37:53 -0400 | [diff] [blame] | 347 | if (phys == le32_to_cpu(hbqe->bde.addrLow)) { |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 348 | len += snprintf(buf+len, size-len, |
| 349 | "Buf%d: %p %06x\n", i, |
| 350 | hbq_buf->dbuf.virt, hbq_buf->tag); |
| 351 | found = 1; |
| 352 | break; |
| 353 | } |
| 354 | i++; |
| 355 | } |
| 356 | if (!found) { |
| 357 | len += snprintf(buf+len, size-len, "No DMAinfo?\n"); |
| 358 | } |
| 359 | skipit: |
| 360 | hbqe++; |
| 361 | if (len > LPFC_HBQINFO_SIZE - 54) |
| 362 | break; |
| 363 | } |
| 364 | spin_unlock_irq(&phba->hbalock); |
| 365 | return len; |
| 366 | } |
| 367 | |
James Smart | c95d6c6 | 2008-01-11 01:53:23 -0500 | [diff] [blame] | 368 | static int lpfc_debugfs_last_hba_slim_off; |
| 369 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 370 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 371 | * lpfc_debugfs_dumpHBASlim_data - Dump HBA SLIM info to a buffer |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 372 | * @phba: The HBA to gather SLIM info from. |
| 373 | * @buf: The buffer to dump log into. |
| 374 | * @size: The maximum amount of data to process. |
| 375 | * |
| 376 | * Description: |
| 377 | * This routine dumps the current contents of HBA SLIM for the HBA associated |
| 378 | * with @phba to @buf up to @size bytes of data. This is the raw HBA SLIM data. |
| 379 | * |
| 380 | * Notes: |
| 381 | * This routine will only dump up to 1024 bytes of data each time called and |
| 382 | * should be called multiple times to dump the entire HBA SLIM. |
| 383 | * |
| 384 | * Return Value: |
| 385 | * This routine returns the amount of bytes that were dumped into @buf and will |
| 386 | * not exceed @size. |
| 387 | **/ |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 388 | static int |
James Smart | c95d6c6 | 2008-01-11 01:53:23 -0500 | [diff] [blame] | 389 | lpfc_debugfs_dumpHBASlim_data(struct lpfc_hba *phba, char *buf, int size) |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 390 | { |
| 391 | int len = 0; |
James Smart | c95d6c6 | 2008-01-11 01:53:23 -0500 | [diff] [blame] | 392 | int i, off; |
| 393 | uint32_t *ptr; |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 394 | char *buffer; |
| 395 | |
| 396 | buffer = kmalloc(1024, GFP_KERNEL); |
| 397 | if (!buffer) |
| 398 | return 0; |
James Smart | c95d6c6 | 2008-01-11 01:53:23 -0500 | [diff] [blame] | 399 | |
| 400 | off = 0; |
| 401 | spin_lock_irq(&phba->hbalock); |
| 402 | |
| 403 | len += snprintf(buf+len, size-len, "HBA SLIM\n"); |
| 404 | lpfc_memcpy_from_slim(buffer, |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 405 | phba->MBslimaddr + lpfc_debugfs_last_hba_slim_off, 1024); |
James Smart | c95d6c6 | 2008-01-11 01:53:23 -0500 | [diff] [blame] | 406 | |
| 407 | ptr = (uint32_t *)&buffer[0]; |
| 408 | off = lpfc_debugfs_last_hba_slim_off; |
| 409 | |
| 410 | /* Set it up for the next time */ |
| 411 | lpfc_debugfs_last_hba_slim_off += 1024; |
| 412 | if (lpfc_debugfs_last_hba_slim_off >= 4096) |
| 413 | lpfc_debugfs_last_hba_slim_off = 0; |
| 414 | |
| 415 | i = 1024; |
| 416 | while (i > 0) { |
| 417 | len += snprintf(buf+len, size-len, |
| 418 | "%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n", |
| 419 | off, *ptr, *(ptr+1), *(ptr+2), *(ptr+3), *(ptr+4), |
| 420 | *(ptr+5), *(ptr+6), *(ptr+7)); |
| 421 | ptr += 8; |
| 422 | i -= (8 * sizeof(uint32_t)); |
| 423 | off += (8 * sizeof(uint32_t)); |
| 424 | } |
| 425 | |
| 426 | spin_unlock_irq(&phba->hbalock); |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 427 | kfree(buffer); |
| 428 | |
James Smart | c95d6c6 | 2008-01-11 01:53:23 -0500 | [diff] [blame] | 429 | return len; |
| 430 | } |
| 431 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 432 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 433 | * lpfc_debugfs_dumpHostSlim_data - Dump host SLIM info to a buffer |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 434 | * @phba: The HBA to gather Host SLIM info from. |
| 435 | * @buf: The buffer to dump log into. |
| 436 | * @size: The maximum amount of data to process. |
| 437 | * |
| 438 | * Description: |
| 439 | * This routine dumps the current contents of host SLIM for the host associated |
| 440 | * with @phba to @buf up to @size bytes of data. The dump will contain the |
| 441 | * Mailbox, PCB, Rings, and Registers that are located in host memory. |
| 442 | * |
| 443 | * Return Value: |
| 444 | * This routine returns the amount of bytes that were dumped into @buf and will |
| 445 | * not exceed @size. |
| 446 | **/ |
James Smart | c95d6c6 | 2008-01-11 01:53:23 -0500 | [diff] [blame] | 447 | static int |
| 448 | lpfc_debugfs_dumpHostSlim_data(struct lpfc_hba *phba, char *buf, int size) |
| 449 | { |
| 450 | int len = 0; |
| 451 | int i, off; |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 452 | uint32_t word0, word1, word2, word3; |
| 453 | uint32_t *ptr; |
| 454 | struct lpfc_pgp *pgpp; |
| 455 | struct lpfc_sli *psli = &phba->sli; |
| 456 | struct lpfc_sli_ring *pring; |
| 457 | |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 458 | off = 0; |
| 459 | spin_lock_irq(&phba->hbalock); |
| 460 | |
| 461 | len += snprintf(buf+len, size-len, "SLIM Mailbox\n"); |
James Smart | 34b02dc | 2008-08-24 21:49:55 -0400 | [diff] [blame] | 462 | ptr = (uint32_t *)phba->slim2p.virt; |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 463 | i = sizeof(MAILBOX_t); |
| 464 | while (i > 0) { |
| 465 | len += snprintf(buf+len, size-len, |
| 466 | "%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n", |
| 467 | off, *ptr, *(ptr+1), *(ptr+2), *(ptr+3), *(ptr+4), |
| 468 | *(ptr+5), *(ptr+6), *(ptr+7)); |
| 469 | ptr += 8; |
| 470 | i -= (8 * sizeof(uint32_t)); |
| 471 | off += (8 * sizeof(uint32_t)); |
| 472 | } |
| 473 | |
| 474 | len += snprintf(buf+len, size-len, "SLIM PCB\n"); |
James Smart | 34b02dc | 2008-08-24 21:49:55 -0400 | [diff] [blame] | 475 | ptr = (uint32_t *)phba->pcb; |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 476 | i = sizeof(PCB_t); |
| 477 | while (i > 0) { |
| 478 | len += snprintf(buf+len, size-len, |
| 479 | "%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n", |
| 480 | off, *ptr, *(ptr+1), *(ptr+2), *(ptr+3), *(ptr+4), |
| 481 | *(ptr+5), *(ptr+6), *(ptr+7)); |
| 482 | ptr += 8; |
| 483 | i -= (8 * sizeof(uint32_t)); |
| 484 | off += (8 * sizeof(uint32_t)); |
| 485 | } |
| 486 | |
James Smart | 34b02dc | 2008-08-24 21:49:55 -0400 | [diff] [blame] | 487 | for (i = 0; i < 4; i++) { |
| 488 | pgpp = &phba->port_gp[i]; |
| 489 | pring = &psli->ring[i]; |
| 490 | len += snprintf(buf+len, size-len, |
| 491 | "Ring %d: CMD GetInx:%d (Max:%d Next:%d " |
| 492 | "Local:%d flg:x%x) RSP PutInx:%d Max:%d\n", |
James Smart | 7e56aa2 | 2012-08-03 12:35:34 -0400 | [diff] [blame] | 493 | i, pgpp->cmdGetInx, pring->sli.sli3.numCiocb, |
| 494 | pring->sli.sli3.next_cmdidx, |
| 495 | pring->sli.sli3.local_getidx, |
| 496 | pring->flag, pgpp->rspPutInx, |
| 497 | pring->sli.sli3.numRiocb); |
James Smart | 34b02dc | 2008-08-24 21:49:55 -0400 | [diff] [blame] | 498 | } |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 499 | |
| 500 | if (phba->sli_rev <= LPFC_SLI_REV3) { |
| 501 | word0 = readl(phba->HAregaddr); |
| 502 | word1 = readl(phba->CAregaddr); |
| 503 | word2 = readl(phba->HSregaddr); |
| 504 | word3 = readl(phba->HCregaddr); |
| 505 | len += snprintf(buf+len, size-len, "HA:%08x CA:%08x HS:%08x " |
| 506 | "HC:%08x\n", word0, word1, word2, word3); |
| 507 | } |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 508 | spin_unlock_irq(&phba->hbalock); |
| 509 | return len; |
| 510 | } |
| 511 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 512 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 513 | * lpfc_debugfs_nodelist_data - Dump target node list to a buffer |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 514 | * @vport: The vport to gather target node info from. |
| 515 | * @buf: The buffer to dump log into. |
| 516 | * @size: The maximum amount of data to process. |
| 517 | * |
| 518 | * Description: |
| 519 | * This routine dumps the current target node list associated with @vport to |
| 520 | * @buf up to @size bytes of data. Each node entry in the dump will contain a |
| 521 | * node state, DID, WWPN, WWNN, RPI, flags, type, and other useful fields. |
| 522 | * |
| 523 | * Return Value: |
| 524 | * This routine returns the amount of bytes that were dumped into @buf and will |
| 525 | * not exceed @size. |
| 526 | **/ |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 527 | static int |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 528 | lpfc_debugfs_nodelist_data(struct lpfc_vport *vport, char *buf, int size) |
| 529 | { |
| 530 | int len = 0; |
| 531 | int cnt; |
| 532 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 533 | struct lpfc_nodelist *ndlp; |
| 534 | unsigned char *statep, *name; |
| 535 | |
| 536 | cnt = (LPFC_NODELIST_SIZE / LPFC_NODELIST_ENTRY_SIZE); |
| 537 | |
| 538 | spin_lock_irq(shost->host_lock); |
| 539 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { |
| 540 | if (!cnt) { |
| 541 | len += snprintf(buf+len, size-len, |
| 542 | "Missing Nodelist Entries\n"); |
| 543 | break; |
| 544 | } |
| 545 | cnt--; |
| 546 | switch (ndlp->nlp_state) { |
| 547 | case NLP_STE_UNUSED_NODE: |
| 548 | statep = "UNUSED"; |
| 549 | break; |
| 550 | case NLP_STE_PLOGI_ISSUE: |
| 551 | statep = "PLOGI "; |
| 552 | break; |
| 553 | case NLP_STE_ADISC_ISSUE: |
| 554 | statep = "ADISC "; |
| 555 | break; |
| 556 | case NLP_STE_REG_LOGIN_ISSUE: |
| 557 | statep = "REGLOG"; |
| 558 | break; |
| 559 | case NLP_STE_PRLI_ISSUE: |
| 560 | statep = "PRLI "; |
| 561 | break; |
James Smart | 086a345 | 2012-08-14 14:25:21 -0400 | [diff] [blame] | 562 | case NLP_STE_LOGO_ISSUE: |
| 563 | statep = "LOGO "; |
| 564 | break; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 565 | case NLP_STE_UNMAPPED_NODE: |
| 566 | statep = "UNMAP "; |
| 567 | break; |
| 568 | case NLP_STE_MAPPED_NODE: |
| 569 | statep = "MAPPED"; |
| 570 | break; |
| 571 | case NLP_STE_NPR_NODE: |
| 572 | statep = "NPR "; |
| 573 | break; |
| 574 | default: |
| 575 | statep = "UNKNOWN"; |
| 576 | } |
| 577 | len += snprintf(buf+len, size-len, "%s DID:x%06x ", |
| 578 | statep, ndlp->nlp_DID); |
| 579 | name = (unsigned char *)&ndlp->nlp_portname; |
| 580 | len += snprintf(buf+len, size-len, |
| 581 | "WWPN %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x ", |
| 582 | *name, *(name+1), *(name+2), *(name+3), |
| 583 | *(name+4), *(name+5), *(name+6), *(name+7)); |
| 584 | name = (unsigned char *)&ndlp->nlp_nodename; |
| 585 | len += snprintf(buf+len, size-len, |
| 586 | "WWNN %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x ", |
| 587 | *name, *(name+1), *(name+2), *(name+3), |
| 588 | *(name+4), *(name+5), *(name+6), *(name+7)); |
James Smart | 086a345 | 2012-08-14 14:25:21 -0400 | [diff] [blame] | 589 | if (ndlp->nlp_flag & NLP_RPI_REGISTERED) |
| 590 | len += snprintf(buf+len, size-len, "RPI:%03d ", |
| 591 | ndlp->nlp_rpi); |
| 592 | else |
| 593 | len += snprintf(buf+len, size-len, "RPI:none "); |
| 594 | len += snprintf(buf+len, size-len, "flag:x%08x ", |
| 595 | ndlp->nlp_flag); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 596 | if (!ndlp->nlp_type) |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 597 | len += snprintf(buf+len, size-len, "UNKNOWN_TYPE "); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 598 | if (ndlp->nlp_type & NLP_FC_NODE) |
| 599 | len += snprintf(buf+len, size-len, "FC_NODE "); |
| 600 | if (ndlp->nlp_type & NLP_FABRIC) |
| 601 | len += snprintf(buf+len, size-len, "FABRIC "); |
| 602 | if (ndlp->nlp_type & NLP_FCP_TARGET) |
| 603 | len += snprintf(buf+len, size-len, "FCP_TGT sid:%d ", |
| 604 | ndlp->nlp_sid); |
| 605 | if (ndlp->nlp_type & NLP_FCP_INITIATOR) |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 606 | len += snprintf(buf+len, size-len, "FCP_INITIATOR "); |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 607 | len += snprintf(buf+len, size-len, "usgmap:%x ", |
| 608 | ndlp->nlp_usg_map); |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 609 | len += snprintf(buf+len, size-len, "refcnt:%x", |
| 610 | atomic_read(&ndlp->kref.refcount)); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 611 | len += snprintf(buf+len, size-len, "\n"); |
| 612 | } |
| 613 | spin_unlock_irq(shost->host_lock); |
| 614 | return len; |
| 615 | } |
| 616 | #endif |
| 617 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 618 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 619 | * lpfc_debugfs_disc_trc - Store discovery trace log |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 620 | * @vport: The vport to associate this trace string with for retrieval. |
| 621 | * @mask: Log entry classification. |
| 622 | * @fmt: Format string to be displayed when dumping the log. |
| 623 | * @data1: 1st data parameter to be applied to @fmt. |
| 624 | * @data2: 2nd data parameter to be applied to @fmt. |
| 625 | * @data3: 3rd data parameter to be applied to @fmt. |
| 626 | * |
| 627 | * Description: |
| 628 | * This routine is used by the driver code to add a debugfs log entry to the |
| 629 | * discovery trace buffer associated with @vport. Only entries with a @mask that |
| 630 | * match the current debugfs discovery mask will be saved. Entries that do not |
| 631 | * match will be thrown away. @fmt, @data1, @data2, and @data3 are used like |
| 632 | * printf when displaying the log. |
| 633 | **/ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 634 | inline void |
| 635 | lpfc_debugfs_disc_trc(struct lpfc_vport *vport, int mask, char *fmt, |
| 636 | uint32_t data1, uint32_t data2, uint32_t data3) |
| 637 | { |
James Smart | 923e4b6 | 2008-12-04 22:40:07 -0500 | [diff] [blame] | 638 | #ifdef CONFIG_SCSI_LPFC_DEBUG_FS |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 639 | struct lpfc_debugfs_trc *dtp; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 640 | int index; |
| 641 | |
| 642 | if (!(lpfc_debugfs_mask_disc_trc & mask)) |
| 643 | return; |
| 644 | |
| 645 | if (!lpfc_debugfs_enable || !lpfc_debugfs_max_disc_trc || |
| 646 | !vport || !vport->disc_trc) |
| 647 | return; |
| 648 | |
| 649 | index = atomic_inc_return(&vport->disc_trc_cnt) & |
| 650 | (lpfc_debugfs_max_disc_trc - 1); |
| 651 | dtp = vport->disc_trc + index; |
| 652 | dtp->fmt = fmt; |
| 653 | dtp->data1 = data1; |
| 654 | dtp->data2 = data2; |
| 655 | dtp->data3 = data3; |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 656 | dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt); |
| 657 | dtp->jif = jiffies; |
| 658 | #endif |
| 659 | return; |
| 660 | } |
| 661 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 662 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 663 | * lpfc_debugfs_slow_ring_trc - Store slow ring trace log |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 664 | * @phba: The phba to associate this trace string with for retrieval. |
| 665 | * @fmt: Format string to be displayed when dumping the log. |
| 666 | * @data1: 1st data parameter to be applied to @fmt. |
| 667 | * @data2: 2nd data parameter to be applied to @fmt. |
| 668 | * @data3: 3rd data parameter to be applied to @fmt. |
| 669 | * |
| 670 | * Description: |
| 671 | * This routine is used by the driver code to add a debugfs log entry to the |
| 672 | * discovery trace buffer associated with @vport. @fmt, @data1, @data2, and |
| 673 | * @data3 are used like printf when displaying the log. |
| 674 | **/ |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 675 | inline void |
| 676 | lpfc_debugfs_slow_ring_trc(struct lpfc_hba *phba, char *fmt, |
| 677 | uint32_t data1, uint32_t data2, uint32_t data3) |
| 678 | { |
James Smart | 923e4b6 | 2008-12-04 22:40:07 -0500 | [diff] [blame] | 679 | #ifdef CONFIG_SCSI_LPFC_DEBUG_FS |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 680 | struct lpfc_debugfs_trc *dtp; |
| 681 | int index; |
| 682 | |
| 683 | if (!lpfc_debugfs_enable || !lpfc_debugfs_max_slow_ring_trc || |
| 684 | !phba || !phba->slow_ring_trc) |
| 685 | return; |
| 686 | |
| 687 | index = atomic_inc_return(&phba->slow_ring_trc_cnt) & |
| 688 | (lpfc_debugfs_max_slow_ring_trc - 1); |
| 689 | dtp = phba->slow_ring_trc + index; |
| 690 | dtp->fmt = fmt; |
| 691 | dtp->data1 = data1; |
| 692 | dtp->data2 = data2; |
| 693 | dtp->data3 = data3; |
| 694 | dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 695 | dtp->jif = jiffies; |
| 696 | #endif |
| 697 | return; |
| 698 | } |
| 699 | |
James Smart | 923e4b6 | 2008-12-04 22:40:07 -0500 | [diff] [blame] | 700 | #ifdef CONFIG_SCSI_LPFC_DEBUG_FS |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 701 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 702 | * lpfc_debugfs_disc_trc_open - Open the discovery trace log |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 703 | * @inode: The inode pointer that contains a vport pointer. |
| 704 | * @file: The file pointer to attach the log output. |
| 705 | * |
| 706 | * Description: |
| 707 | * This routine is the entry point for the debugfs open file operation. It gets |
| 708 | * the vport from the i_private field in @inode, allocates the necessary buffer |
| 709 | * for the log, fills the buffer from the in-memory log for this vport, and then |
| 710 | * returns a pointer to that log in the private_data field in @file. |
| 711 | * |
| 712 | * Returns: |
| 713 | * This function returns zero if successful. On error it will return an negative |
| 714 | * error value. |
| 715 | **/ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 716 | static int |
| 717 | lpfc_debugfs_disc_trc_open(struct inode *inode, struct file *file) |
| 718 | { |
| 719 | struct lpfc_vport *vport = inode->i_private; |
| 720 | struct lpfc_debug *debug; |
| 721 | int size; |
| 722 | int rc = -ENOMEM; |
| 723 | |
| 724 | if (!lpfc_debugfs_max_disc_trc) { |
| 725 | rc = -ENOSPC; |
| 726 | goto out; |
| 727 | } |
| 728 | |
| 729 | debug = kmalloc(sizeof(*debug), GFP_KERNEL); |
| 730 | if (!debug) |
| 731 | goto out; |
| 732 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 733 | /* Round to page boundary */ |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 734 | size = (lpfc_debugfs_max_disc_trc * LPFC_DEBUG_TRC_ENTRY_SIZE); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 735 | size = PAGE_ALIGN(size); |
| 736 | |
| 737 | debug->buffer = kmalloc(size, GFP_KERNEL); |
| 738 | if (!debug->buffer) { |
| 739 | kfree(debug); |
| 740 | goto out; |
| 741 | } |
| 742 | |
| 743 | debug->len = lpfc_debugfs_disc_trc_data(vport, debug->buffer, size); |
| 744 | file->private_data = debug; |
| 745 | |
| 746 | rc = 0; |
| 747 | out: |
| 748 | return rc; |
| 749 | } |
| 750 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 751 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 752 | * lpfc_debugfs_slow_ring_trc_open - Open the Slow Ring trace log |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 753 | * @inode: The inode pointer that contains a vport pointer. |
| 754 | * @file: The file pointer to attach the log output. |
| 755 | * |
| 756 | * Description: |
| 757 | * This routine is the entry point for the debugfs open file operation. It gets |
| 758 | * the vport from the i_private field in @inode, allocates the necessary buffer |
| 759 | * for the log, fills the buffer from the in-memory log for this vport, and then |
| 760 | * returns a pointer to that log in the private_data field in @file. |
| 761 | * |
| 762 | * Returns: |
| 763 | * This function returns zero if successful. On error it will return an negative |
| 764 | * error value. |
| 765 | **/ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 766 | static int |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 767 | lpfc_debugfs_slow_ring_trc_open(struct inode *inode, struct file *file) |
| 768 | { |
| 769 | struct lpfc_hba *phba = inode->i_private; |
| 770 | struct lpfc_debug *debug; |
| 771 | int size; |
| 772 | int rc = -ENOMEM; |
| 773 | |
| 774 | if (!lpfc_debugfs_max_slow_ring_trc) { |
| 775 | rc = -ENOSPC; |
| 776 | goto out; |
| 777 | } |
| 778 | |
| 779 | debug = kmalloc(sizeof(*debug), GFP_KERNEL); |
| 780 | if (!debug) |
| 781 | goto out; |
| 782 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 783 | /* Round to page boundary */ |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 784 | size = (lpfc_debugfs_max_slow_ring_trc * LPFC_DEBUG_TRC_ENTRY_SIZE); |
| 785 | size = PAGE_ALIGN(size); |
| 786 | |
| 787 | debug->buffer = kmalloc(size, GFP_KERNEL); |
| 788 | if (!debug->buffer) { |
| 789 | kfree(debug); |
| 790 | goto out; |
| 791 | } |
| 792 | |
| 793 | debug->len = lpfc_debugfs_slow_ring_trc_data(phba, debug->buffer, size); |
| 794 | file->private_data = debug; |
| 795 | |
| 796 | rc = 0; |
| 797 | out: |
| 798 | return rc; |
| 799 | } |
| 800 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 801 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 802 | * lpfc_debugfs_hbqinfo_open - Open the hbqinfo debugfs buffer |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 803 | * @inode: The inode pointer that contains a vport pointer. |
| 804 | * @file: The file pointer to attach the log output. |
| 805 | * |
| 806 | * Description: |
| 807 | * This routine is the entry point for the debugfs open file operation. It gets |
| 808 | * the vport from the i_private field in @inode, allocates the necessary buffer |
| 809 | * for the log, fills the buffer from the in-memory log for this vport, and then |
| 810 | * returns a pointer to that log in the private_data field in @file. |
| 811 | * |
| 812 | * Returns: |
| 813 | * This function returns zero if successful. On error it will return an negative |
| 814 | * error value. |
| 815 | **/ |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 816 | static int |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 817 | lpfc_debugfs_hbqinfo_open(struct inode *inode, struct file *file) |
| 818 | { |
| 819 | struct lpfc_hba *phba = inode->i_private; |
| 820 | struct lpfc_debug *debug; |
| 821 | int rc = -ENOMEM; |
| 822 | |
| 823 | debug = kmalloc(sizeof(*debug), GFP_KERNEL); |
| 824 | if (!debug) |
| 825 | goto out; |
| 826 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 827 | /* Round to page boundary */ |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 828 | debug->buffer = kmalloc(LPFC_HBQINFO_SIZE, GFP_KERNEL); |
| 829 | if (!debug->buffer) { |
| 830 | kfree(debug); |
| 831 | goto out; |
| 832 | } |
| 833 | |
| 834 | debug->len = lpfc_debugfs_hbqinfo_data(phba, debug->buffer, |
| 835 | LPFC_HBQINFO_SIZE); |
| 836 | file->private_data = debug; |
| 837 | |
| 838 | rc = 0; |
| 839 | out: |
| 840 | return rc; |
| 841 | } |
| 842 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 843 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 844 | * lpfc_debugfs_dumpHBASlim_open - Open the Dump HBA SLIM debugfs buffer |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 845 | * @inode: The inode pointer that contains a vport pointer. |
| 846 | * @file: The file pointer to attach the log output. |
| 847 | * |
| 848 | * Description: |
| 849 | * This routine is the entry point for the debugfs open file operation. It gets |
| 850 | * the vport from the i_private field in @inode, allocates the necessary buffer |
| 851 | * for the log, fills the buffer from the in-memory log for this vport, and then |
| 852 | * returns a pointer to that log in the private_data field in @file. |
| 853 | * |
| 854 | * Returns: |
| 855 | * This function returns zero if successful. On error it will return an negative |
| 856 | * error value. |
| 857 | **/ |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 858 | static int |
James Smart | c95d6c6 | 2008-01-11 01:53:23 -0500 | [diff] [blame] | 859 | lpfc_debugfs_dumpHBASlim_open(struct inode *inode, struct file *file) |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 860 | { |
| 861 | struct lpfc_hba *phba = inode->i_private; |
| 862 | struct lpfc_debug *debug; |
| 863 | int rc = -ENOMEM; |
| 864 | |
| 865 | debug = kmalloc(sizeof(*debug), GFP_KERNEL); |
| 866 | if (!debug) |
| 867 | goto out; |
| 868 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 869 | /* Round to page boundary */ |
James Smart | c95d6c6 | 2008-01-11 01:53:23 -0500 | [diff] [blame] | 870 | debug->buffer = kmalloc(LPFC_DUMPHBASLIM_SIZE, GFP_KERNEL); |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 871 | if (!debug->buffer) { |
| 872 | kfree(debug); |
| 873 | goto out; |
| 874 | } |
| 875 | |
James Smart | c95d6c6 | 2008-01-11 01:53:23 -0500 | [diff] [blame] | 876 | debug->len = lpfc_debugfs_dumpHBASlim_data(phba, debug->buffer, |
| 877 | LPFC_DUMPHBASLIM_SIZE); |
| 878 | file->private_data = debug; |
| 879 | |
| 880 | rc = 0; |
| 881 | out: |
| 882 | return rc; |
| 883 | } |
| 884 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 885 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 886 | * lpfc_debugfs_dumpHostSlim_open - Open the Dump Host SLIM debugfs buffer |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 887 | * @inode: The inode pointer that contains a vport pointer. |
| 888 | * @file: The file pointer to attach the log output. |
| 889 | * |
| 890 | * Description: |
| 891 | * This routine is the entry point for the debugfs open file operation. It gets |
| 892 | * the vport from the i_private field in @inode, allocates the necessary buffer |
| 893 | * for the log, fills the buffer from the in-memory log for this vport, and then |
| 894 | * returns a pointer to that log in the private_data field in @file. |
| 895 | * |
| 896 | * Returns: |
| 897 | * This function returns zero if successful. On error it will return an negative |
| 898 | * error value. |
| 899 | **/ |
James Smart | c95d6c6 | 2008-01-11 01:53:23 -0500 | [diff] [blame] | 900 | static int |
| 901 | lpfc_debugfs_dumpHostSlim_open(struct inode *inode, struct file *file) |
| 902 | { |
| 903 | struct lpfc_hba *phba = inode->i_private; |
| 904 | struct lpfc_debug *debug; |
| 905 | int rc = -ENOMEM; |
| 906 | |
| 907 | debug = kmalloc(sizeof(*debug), GFP_KERNEL); |
| 908 | if (!debug) |
| 909 | goto out; |
| 910 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 911 | /* Round to page boundary */ |
James Smart | c95d6c6 | 2008-01-11 01:53:23 -0500 | [diff] [blame] | 912 | debug->buffer = kmalloc(LPFC_DUMPHOSTSLIM_SIZE, GFP_KERNEL); |
| 913 | if (!debug->buffer) { |
| 914 | kfree(debug); |
| 915 | goto out; |
| 916 | } |
| 917 | |
| 918 | debug->len = lpfc_debugfs_dumpHostSlim_data(phba, debug->buffer, |
| 919 | LPFC_DUMPHOSTSLIM_SIZE); |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 920 | file->private_data = debug; |
| 921 | |
| 922 | rc = 0; |
| 923 | out: |
| 924 | return rc; |
| 925 | } |
| 926 | |
James Smart | e2a0a9d | 2008-12-04 22:40:02 -0500 | [diff] [blame] | 927 | static int |
| 928 | lpfc_debugfs_dumpData_open(struct inode *inode, struct file *file) |
| 929 | { |
| 930 | struct lpfc_debug *debug; |
| 931 | int rc = -ENOMEM; |
| 932 | |
| 933 | if (!_dump_buf_data) |
| 934 | return -EBUSY; |
| 935 | |
| 936 | debug = kmalloc(sizeof(*debug), GFP_KERNEL); |
| 937 | if (!debug) |
| 938 | goto out; |
| 939 | |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 940 | /* Round to page boundary */ |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 941 | printk(KERN_ERR "9059 BLKGRD: %s: _dump_buf_data=0x%p\n", |
James Smart | e2a0a9d | 2008-12-04 22:40:02 -0500 | [diff] [blame] | 942 | __func__, _dump_buf_data); |
| 943 | debug->buffer = _dump_buf_data; |
| 944 | if (!debug->buffer) { |
| 945 | kfree(debug); |
| 946 | goto out; |
| 947 | } |
| 948 | |
| 949 | debug->len = (1 << _dump_buf_data_order) << PAGE_SHIFT; |
| 950 | file->private_data = debug; |
| 951 | |
| 952 | rc = 0; |
| 953 | out: |
| 954 | return rc; |
| 955 | } |
| 956 | |
| 957 | static int |
| 958 | lpfc_debugfs_dumpDif_open(struct inode *inode, struct file *file) |
| 959 | { |
| 960 | struct lpfc_debug *debug; |
| 961 | int rc = -ENOMEM; |
| 962 | |
| 963 | if (!_dump_buf_dif) |
| 964 | return -EBUSY; |
| 965 | |
| 966 | debug = kmalloc(sizeof(*debug), GFP_KERNEL); |
| 967 | if (!debug) |
| 968 | goto out; |
| 969 | |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 970 | /* Round to page boundary */ |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 971 | printk(KERN_ERR "9060 BLKGRD: %s: _dump_buf_dif=0x%p file=%s\n", |
| 972 | __func__, _dump_buf_dif, file->f_dentry->d_name.name); |
James Smart | e2a0a9d | 2008-12-04 22:40:02 -0500 | [diff] [blame] | 973 | debug->buffer = _dump_buf_dif; |
| 974 | if (!debug->buffer) { |
| 975 | kfree(debug); |
| 976 | goto out; |
| 977 | } |
| 978 | |
| 979 | debug->len = (1 << _dump_buf_dif_order) << PAGE_SHIFT; |
| 980 | file->private_data = debug; |
| 981 | |
| 982 | rc = 0; |
| 983 | out: |
| 984 | return rc; |
| 985 | } |
| 986 | |
| 987 | static ssize_t |
| 988 | lpfc_debugfs_dumpDataDif_write(struct file *file, const char __user *buf, |
| 989 | size_t nbytes, loff_t *ppos) |
| 990 | { |
| 991 | /* |
| 992 | * The Data/DIF buffers only save one failing IO |
| 993 | * The write op is used as a reset mechanism after an IO has |
| 994 | * already been saved to the next one can be saved |
| 995 | */ |
| 996 | spin_lock(&_dump_buf_lock); |
| 997 | |
| 998 | memset((void *)_dump_buf_data, 0, |
| 999 | ((1 << PAGE_SHIFT) << _dump_buf_data_order)); |
| 1000 | memset((void *)_dump_buf_dif, 0, |
| 1001 | ((1 << PAGE_SHIFT) << _dump_buf_dif_order)); |
| 1002 | |
| 1003 | _dump_buf_done = 0; |
| 1004 | |
| 1005 | spin_unlock(&_dump_buf_lock); |
| 1006 | |
| 1007 | return nbytes; |
| 1008 | } |
| 1009 | |
James Smart | f9bb2da | 2011-10-10 21:34:11 -0400 | [diff] [blame] | 1010 | static ssize_t |
| 1011 | lpfc_debugfs_dif_err_read(struct file *file, char __user *buf, |
| 1012 | size_t nbytes, loff_t *ppos) |
| 1013 | { |
| 1014 | struct dentry *dent = file->f_dentry; |
| 1015 | struct lpfc_hba *phba = file->private_data; |
James Smart | 9a6b09c | 2012-03-01 22:37:42 -0500 | [diff] [blame] | 1016 | char cbuf[32]; |
James Smart | 4ac9b22 | 2012-03-01 22:38:29 -0500 | [diff] [blame] | 1017 | uint64_t tmp = 0; |
James Smart | f9bb2da | 2011-10-10 21:34:11 -0400 | [diff] [blame] | 1018 | int cnt = 0; |
| 1019 | |
| 1020 | if (dent == phba->debug_writeGuard) |
James Smart | 9a6b09c | 2012-03-01 22:37:42 -0500 | [diff] [blame] | 1021 | cnt = snprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_wgrd_cnt); |
James Smart | f9bb2da | 2011-10-10 21:34:11 -0400 | [diff] [blame] | 1022 | else if (dent == phba->debug_writeApp) |
James Smart | 9a6b09c | 2012-03-01 22:37:42 -0500 | [diff] [blame] | 1023 | cnt = snprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_wapp_cnt); |
James Smart | f9bb2da | 2011-10-10 21:34:11 -0400 | [diff] [blame] | 1024 | else if (dent == phba->debug_writeRef) |
James Smart | 9a6b09c | 2012-03-01 22:37:42 -0500 | [diff] [blame] | 1025 | cnt = snprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_wref_cnt); |
James Smart | acd6859 | 2012-01-18 16:25:09 -0500 | [diff] [blame] | 1026 | else if (dent == phba->debug_readGuard) |
James Smart | 9a6b09c | 2012-03-01 22:37:42 -0500 | [diff] [blame] | 1027 | cnt = snprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_rgrd_cnt); |
James Smart | f9bb2da | 2011-10-10 21:34:11 -0400 | [diff] [blame] | 1028 | else if (dent == phba->debug_readApp) |
James Smart | 9a6b09c | 2012-03-01 22:37:42 -0500 | [diff] [blame] | 1029 | cnt = snprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_rapp_cnt); |
James Smart | f9bb2da | 2011-10-10 21:34:11 -0400 | [diff] [blame] | 1030 | else if (dent == phba->debug_readRef) |
James Smart | 9a6b09c | 2012-03-01 22:37:42 -0500 | [diff] [blame] | 1031 | cnt = snprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_rref_cnt); |
James Smart | 4ac9b22 | 2012-03-01 22:38:29 -0500 | [diff] [blame] | 1032 | else if (dent == phba->debug_InjErrNPortID) |
| 1033 | cnt = snprintf(cbuf, 32, "0x%06x\n", phba->lpfc_injerr_nportid); |
| 1034 | else if (dent == phba->debug_InjErrWWPN) { |
| 1035 | memcpy(&tmp, &phba->lpfc_injerr_wwpn, sizeof(struct lpfc_name)); |
| 1036 | tmp = cpu_to_be64(tmp); |
| 1037 | cnt = snprintf(cbuf, 32, "0x%016llx\n", tmp); |
| 1038 | } else if (dent == phba->debug_InjErrLBA) { |
| 1039 | if (phba->lpfc_injerr_lba == (sector_t)(-1)) |
James Smart | 9a6b09c | 2012-03-01 22:37:42 -0500 | [diff] [blame] | 1040 | cnt = snprintf(cbuf, 32, "off\n"); |
| 1041 | else |
James Smart | 4ac9b22 | 2012-03-01 22:38:29 -0500 | [diff] [blame] | 1042 | cnt = snprintf(cbuf, 32, "0x%llx\n", |
| 1043 | (uint64_t) phba->lpfc_injerr_lba); |
James Smart | 9a6b09c | 2012-03-01 22:37:42 -0500 | [diff] [blame] | 1044 | } else |
James Smart | f9bb2da | 2011-10-10 21:34:11 -0400 | [diff] [blame] | 1045 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 1046 | "0547 Unknown debugfs error injection entry\n"); |
| 1047 | |
| 1048 | return simple_read_from_buffer(buf, nbytes, ppos, &cbuf, cnt); |
| 1049 | } |
| 1050 | |
| 1051 | static ssize_t |
| 1052 | lpfc_debugfs_dif_err_write(struct file *file, const char __user *buf, |
| 1053 | size_t nbytes, loff_t *ppos) |
| 1054 | { |
| 1055 | struct dentry *dent = file->f_dentry; |
| 1056 | struct lpfc_hba *phba = file->private_data; |
| 1057 | char dstbuf[32]; |
James Smart | 4ac9b22 | 2012-03-01 22:38:29 -0500 | [diff] [blame] | 1058 | uint64_t tmp = 0; |
James Smart | f9bb2da | 2011-10-10 21:34:11 -0400 | [diff] [blame] | 1059 | int size; |
| 1060 | |
| 1061 | memset(dstbuf, 0, 32); |
| 1062 | size = (nbytes < 32) ? nbytes : 32; |
| 1063 | if (copy_from_user(dstbuf, buf, size)) |
| 1064 | return 0; |
| 1065 | |
James Smart | 9a6b09c | 2012-03-01 22:37:42 -0500 | [diff] [blame] | 1066 | if (dent == phba->debug_InjErrLBA) { |
| 1067 | if ((buf[0] == 'o') && (buf[1] == 'f') && (buf[2] == 'f')) |
James Smart | 4ac9b22 | 2012-03-01 22:38:29 -0500 | [diff] [blame] | 1068 | tmp = (uint64_t)(-1); |
James Smart | 9a6b09c | 2012-03-01 22:37:42 -0500 | [diff] [blame] | 1069 | } |
| 1070 | |
James Smart | 4ac9b22 | 2012-03-01 22:38:29 -0500 | [diff] [blame] | 1071 | if ((tmp == 0) && (kstrtoull(dstbuf, 0, &tmp))) |
James Smart | f9bb2da | 2011-10-10 21:34:11 -0400 | [diff] [blame] | 1072 | return 0; |
| 1073 | |
| 1074 | if (dent == phba->debug_writeGuard) |
| 1075 | phba->lpfc_injerr_wgrd_cnt = (uint32_t)tmp; |
| 1076 | else if (dent == phba->debug_writeApp) |
| 1077 | phba->lpfc_injerr_wapp_cnt = (uint32_t)tmp; |
| 1078 | else if (dent == phba->debug_writeRef) |
| 1079 | phba->lpfc_injerr_wref_cnt = (uint32_t)tmp; |
James Smart | acd6859 | 2012-01-18 16:25:09 -0500 | [diff] [blame] | 1080 | else if (dent == phba->debug_readGuard) |
| 1081 | phba->lpfc_injerr_rgrd_cnt = (uint32_t)tmp; |
James Smart | f9bb2da | 2011-10-10 21:34:11 -0400 | [diff] [blame] | 1082 | else if (dent == phba->debug_readApp) |
| 1083 | phba->lpfc_injerr_rapp_cnt = (uint32_t)tmp; |
| 1084 | else if (dent == phba->debug_readRef) |
| 1085 | phba->lpfc_injerr_rref_cnt = (uint32_t)tmp; |
| 1086 | else if (dent == phba->debug_InjErrLBA) |
| 1087 | phba->lpfc_injerr_lba = (sector_t)tmp; |
James Smart | 4ac9b22 | 2012-03-01 22:38:29 -0500 | [diff] [blame] | 1088 | else if (dent == phba->debug_InjErrNPortID) |
| 1089 | phba->lpfc_injerr_nportid = (uint32_t)(tmp & Mask_DID); |
| 1090 | else if (dent == phba->debug_InjErrWWPN) { |
| 1091 | tmp = cpu_to_be64(tmp); |
| 1092 | memcpy(&phba->lpfc_injerr_wwpn, &tmp, sizeof(struct lpfc_name)); |
| 1093 | } else |
James Smart | f9bb2da | 2011-10-10 21:34:11 -0400 | [diff] [blame] | 1094 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
| 1095 | "0548 Unknown debugfs error injection entry\n"); |
| 1096 | |
| 1097 | return nbytes; |
| 1098 | } |
| 1099 | |
| 1100 | static int |
| 1101 | lpfc_debugfs_dif_err_release(struct inode *inode, struct file *file) |
| 1102 | { |
| 1103 | return 0; |
| 1104 | } |
| 1105 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1106 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1107 | * lpfc_debugfs_nodelist_open - Open the nodelist debugfs file |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1108 | * @inode: The inode pointer that contains a vport pointer. |
| 1109 | * @file: The file pointer to attach the log output. |
| 1110 | * |
| 1111 | * Description: |
| 1112 | * This routine is the entry point for the debugfs open file operation. It gets |
| 1113 | * the vport from the i_private field in @inode, allocates the necessary buffer |
| 1114 | * for the log, fills the buffer from the in-memory log for this vport, and then |
| 1115 | * returns a pointer to that log in the private_data field in @file. |
| 1116 | * |
| 1117 | * Returns: |
| 1118 | * This function returns zero if successful. On error it will return an negative |
| 1119 | * error value. |
| 1120 | **/ |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 1121 | static int |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1122 | lpfc_debugfs_nodelist_open(struct inode *inode, struct file *file) |
| 1123 | { |
| 1124 | struct lpfc_vport *vport = inode->i_private; |
| 1125 | struct lpfc_debug *debug; |
| 1126 | int rc = -ENOMEM; |
| 1127 | |
| 1128 | debug = kmalloc(sizeof(*debug), GFP_KERNEL); |
| 1129 | if (!debug) |
| 1130 | goto out; |
| 1131 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1132 | /* Round to page boundary */ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1133 | debug->buffer = kmalloc(LPFC_NODELIST_SIZE, GFP_KERNEL); |
| 1134 | if (!debug->buffer) { |
| 1135 | kfree(debug); |
| 1136 | goto out; |
| 1137 | } |
| 1138 | |
| 1139 | debug->len = lpfc_debugfs_nodelist_data(vport, debug->buffer, |
| 1140 | LPFC_NODELIST_SIZE); |
| 1141 | file->private_data = debug; |
| 1142 | |
| 1143 | rc = 0; |
| 1144 | out: |
| 1145 | return rc; |
| 1146 | } |
| 1147 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1148 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1149 | * lpfc_debugfs_lseek - Seek through a debugfs file |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1150 | * @file: The file pointer to seek through. |
| 1151 | * @off: The offset to seek to or the amount to seek by. |
| 1152 | * @whence: Indicates how to seek. |
| 1153 | * |
| 1154 | * Description: |
| 1155 | * This routine is the entry point for the debugfs lseek file operation. The |
| 1156 | * @whence parameter indicates whether @off is the offset to directly seek to, |
| 1157 | * or if it is a value to seek forward or reverse by. This function figures out |
| 1158 | * what the new offset of the debugfs file will be and assigns that value to the |
| 1159 | * f_pos field of @file. |
| 1160 | * |
| 1161 | * Returns: |
| 1162 | * This function returns the new offset if successful and returns a negative |
| 1163 | * error if unable to process the seek. |
| 1164 | **/ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1165 | static loff_t |
| 1166 | lpfc_debugfs_lseek(struct file *file, loff_t off, int whence) |
| 1167 | { |
Al Viro | 7233c77 | 2013-06-23 12:08:05 +0400 | [diff] [blame] | 1168 | struct lpfc_debug *debug = file->private_data; |
| 1169 | return fixed_size_llseek(file, off, whence, debug->len); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1170 | } |
| 1171 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1172 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1173 | * lpfc_debugfs_read - Read a debugfs file |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1174 | * @file: The file pointer to read from. |
| 1175 | * @buf: The buffer to copy the data to. |
| 1176 | * @nbytes: The number of bytes to read. |
| 1177 | * @ppos: The position in the file to start reading from. |
| 1178 | * |
| 1179 | * Description: |
| 1180 | * This routine reads data from from the buffer indicated in the private_data |
| 1181 | * field of @file. It will start reading at @ppos and copy up to @nbytes of |
| 1182 | * data to @buf. |
| 1183 | * |
| 1184 | * Returns: |
| 1185 | * This function returns the amount of data that was read (this could be less |
| 1186 | * than @nbytes if the end of the file was reached) or a negative error value. |
| 1187 | **/ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1188 | static ssize_t |
| 1189 | lpfc_debugfs_read(struct file *file, char __user *buf, |
| 1190 | size_t nbytes, loff_t *ppos) |
| 1191 | { |
| 1192 | struct lpfc_debug *debug = file->private_data; |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 1193 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1194 | return simple_read_from_buffer(buf, nbytes, ppos, debug->buffer, |
| 1195 | debug->len); |
| 1196 | } |
| 1197 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1198 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1199 | * lpfc_debugfs_release - Release the buffer used to store debugfs file data |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1200 | * @inode: The inode pointer that contains a vport pointer. (unused) |
| 1201 | * @file: The file pointer that contains the buffer to release. |
| 1202 | * |
| 1203 | * Description: |
| 1204 | * This routine frees the buffer that was allocated when the debugfs file was |
| 1205 | * opened. |
| 1206 | * |
| 1207 | * Returns: |
| 1208 | * This function returns zero. |
| 1209 | **/ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1210 | static int |
| 1211 | lpfc_debugfs_release(struct inode *inode, struct file *file) |
| 1212 | { |
| 1213 | struct lpfc_debug *debug = file->private_data; |
| 1214 | |
| 1215 | kfree(debug->buffer); |
| 1216 | kfree(debug); |
| 1217 | |
| 1218 | return 0; |
| 1219 | } |
| 1220 | |
James Smart | e2a0a9d | 2008-12-04 22:40:02 -0500 | [diff] [blame] | 1221 | static int |
| 1222 | lpfc_debugfs_dumpDataDif_release(struct inode *inode, struct file *file) |
| 1223 | { |
| 1224 | struct lpfc_debug *debug = file->private_data; |
| 1225 | |
| 1226 | debug->buffer = NULL; |
| 1227 | kfree(debug); |
| 1228 | |
| 1229 | return 0; |
| 1230 | } |
| 1231 | |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 1232 | /* |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 1233 | * --------------------------------- |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 1234 | * iDiag debugfs file access methods |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 1235 | * --------------------------------- |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 1236 | * |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 1237 | * All access methods are through the proper SLI4 PCI function's debugfs |
| 1238 | * iDiag directory: |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 1239 | * |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 1240 | * /sys/kernel/debug/lpfc/fn<#>/iDiag |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 1241 | */ |
| 1242 | |
| 1243 | /** |
| 1244 | * lpfc_idiag_cmd_get - Get and parse idiag debugfs comands from user space |
| 1245 | * @buf: The pointer to the user space buffer. |
| 1246 | * @nbytes: The number of bytes in the user space buffer. |
| 1247 | * @idiag_cmd: pointer to the idiag command struct. |
| 1248 | * |
| 1249 | * This routine reads data from debugfs user space buffer and parses the |
| 1250 | * buffer for getting the idiag command and arguments. The while space in |
| 1251 | * between the set of data is used as the parsing separator. |
| 1252 | * |
| 1253 | * This routine returns 0 when successful, it returns proper error code |
| 1254 | * back to the user space in error conditions. |
| 1255 | */ |
| 1256 | static int lpfc_idiag_cmd_get(const char __user *buf, size_t nbytes, |
| 1257 | struct lpfc_idiag_cmd *idiag_cmd) |
| 1258 | { |
| 1259 | char mybuf[64]; |
| 1260 | char *pbuf, *step_str; |
Stephen Boyd | b11d48e | 2011-05-12 16:50:06 -0700 | [diff] [blame] | 1261 | int i; |
| 1262 | size_t bsize; |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 1263 | |
| 1264 | /* Protect copy from user */ |
| 1265 | if (!access_ok(VERIFY_READ, buf, nbytes)) |
| 1266 | return -EFAULT; |
| 1267 | |
| 1268 | memset(mybuf, 0, sizeof(mybuf)); |
| 1269 | memset(idiag_cmd, 0, sizeof(*idiag_cmd)); |
| 1270 | bsize = min(nbytes, (sizeof(mybuf)-1)); |
| 1271 | |
| 1272 | if (copy_from_user(mybuf, buf, bsize)) |
| 1273 | return -EFAULT; |
| 1274 | pbuf = &mybuf[0]; |
| 1275 | step_str = strsep(&pbuf, "\t "); |
| 1276 | |
| 1277 | /* The opcode must present */ |
| 1278 | if (!step_str) |
| 1279 | return -EINVAL; |
| 1280 | |
| 1281 | idiag_cmd->opcode = simple_strtol(step_str, NULL, 0); |
| 1282 | if (idiag_cmd->opcode == 0) |
| 1283 | return -EINVAL; |
| 1284 | |
| 1285 | for (i = 0; i < LPFC_IDIAG_CMD_DATA_SIZE; i++) { |
| 1286 | step_str = strsep(&pbuf, "\t "); |
| 1287 | if (!step_str) |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 1288 | return i; |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 1289 | idiag_cmd->data[i] = simple_strtol(step_str, NULL, 0); |
| 1290 | } |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 1291 | return i; |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 1292 | } |
| 1293 | |
| 1294 | /** |
| 1295 | * lpfc_idiag_open - idiag open debugfs |
| 1296 | * @inode: The inode pointer that contains a pointer to phba. |
| 1297 | * @file: The file pointer to attach the file operation. |
| 1298 | * |
| 1299 | * Description: |
| 1300 | * This routine is the entry point for the debugfs open file operation. It |
| 1301 | * gets the reference to phba from the i_private field in @inode, it then |
| 1302 | * allocates buffer for the file operation, performs the necessary PCI config |
| 1303 | * space read into the allocated buffer according to the idiag user command |
| 1304 | * setup, and then returns a pointer to buffer in the private_data field in |
| 1305 | * @file. |
| 1306 | * |
| 1307 | * Returns: |
| 1308 | * This function returns zero if successful. On error it will return an |
| 1309 | * negative error value. |
| 1310 | **/ |
| 1311 | static int |
| 1312 | lpfc_idiag_open(struct inode *inode, struct file *file) |
| 1313 | { |
| 1314 | struct lpfc_debug *debug; |
| 1315 | |
| 1316 | debug = kmalloc(sizeof(*debug), GFP_KERNEL); |
| 1317 | if (!debug) |
| 1318 | return -ENOMEM; |
| 1319 | |
| 1320 | debug->i_private = inode->i_private; |
| 1321 | debug->buffer = NULL; |
| 1322 | file->private_data = debug; |
| 1323 | |
| 1324 | return 0; |
| 1325 | } |
| 1326 | |
| 1327 | /** |
| 1328 | * lpfc_idiag_release - Release idiag access file operation |
| 1329 | * @inode: The inode pointer that contains a vport pointer. (unused) |
| 1330 | * @file: The file pointer that contains the buffer to release. |
| 1331 | * |
| 1332 | * Description: |
| 1333 | * This routine is the generic release routine for the idiag access file |
| 1334 | * operation, it frees the buffer that was allocated when the debugfs file |
| 1335 | * was opened. |
| 1336 | * |
| 1337 | * Returns: |
| 1338 | * This function returns zero. |
| 1339 | **/ |
| 1340 | static int |
| 1341 | lpfc_idiag_release(struct inode *inode, struct file *file) |
| 1342 | { |
| 1343 | struct lpfc_debug *debug = file->private_data; |
| 1344 | |
| 1345 | /* Free the buffers to the file operation */ |
| 1346 | kfree(debug->buffer); |
| 1347 | kfree(debug); |
| 1348 | |
| 1349 | return 0; |
| 1350 | } |
| 1351 | |
| 1352 | /** |
| 1353 | * lpfc_idiag_cmd_release - Release idiag cmd access file operation |
| 1354 | * @inode: The inode pointer that contains a vport pointer. (unused) |
| 1355 | * @file: The file pointer that contains the buffer to release. |
| 1356 | * |
| 1357 | * Description: |
| 1358 | * This routine frees the buffer that was allocated when the debugfs file |
| 1359 | * 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] | 1360 | * case of command for write operation. |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 1361 | * |
| 1362 | * Returns: |
| 1363 | * This function returns zero. |
| 1364 | **/ |
| 1365 | static int |
| 1366 | lpfc_idiag_cmd_release(struct inode *inode, struct file *file) |
| 1367 | { |
| 1368 | struct lpfc_debug *debug = file->private_data; |
| 1369 | |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 1370 | if (debug->op == LPFC_IDIAG_OP_WR) { |
| 1371 | switch (idiag.cmd.opcode) { |
| 1372 | case LPFC_IDIAG_CMD_PCICFG_WR: |
| 1373 | case LPFC_IDIAG_CMD_PCICFG_ST: |
| 1374 | case LPFC_IDIAG_CMD_PCICFG_CL: |
| 1375 | case LPFC_IDIAG_CMD_QUEACC_WR: |
| 1376 | case LPFC_IDIAG_CMD_QUEACC_ST: |
| 1377 | case LPFC_IDIAG_CMD_QUEACC_CL: |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 1378 | memset(&idiag, 0, sizeof(idiag)); |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 1379 | break; |
| 1380 | default: |
| 1381 | break; |
| 1382 | } |
| 1383 | } |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 1384 | |
| 1385 | /* Free the buffers to the file operation */ |
| 1386 | kfree(debug->buffer); |
| 1387 | kfree(debug); |
| 1388 | |
| 1389 | return 0; |
| 1390 | } |
| 1391 | |
| 1392 | /** |
| 1393 | * lpfc_idiag_pcicfg_read - idiag debugfs read pcicfg |
| 1394 | * @file: The file pointer to read from. |
| 1395 | * @buf: The buffer to copy the data to. |
| 1396 | * @nbytes: The number of bytes to read. |
| 1397 | * @ppos: The position in the file to start reading from. |
| 1398 | * |
| 1399 | * Description: |
| 1400 | * This routine reads data from the @phba pci config space according to the |
| 1401 | * idiag command, and copies to user @buf. Depending on the PCI config space |
| 1402 | * read command setup, it does either a single register read of a byte |
| 1403 | * (8 bits), a word (16 bits), or a dword (32 bits) or browsing through all |
| 1404 | * registers from the 4K extended PCI config space. |
| 1405 | * |
| 1406 | * Returns: |
| 1407 | * This function returns the amount of data that was read (this could be less |
| 1408 | * than @nbytes if the end of the file was reached) or a negative error value. |
| 1409 | **/ |
| 1410 | static ssize_t |
| 1411 | lpfc_idiag_pcicfg_read(struct file *file, char __user *buf, size_t nbytes, |
| 1412 | loff_t *ppos) |
| 1413 | { |
| 1414 | struct lpfc_debug *debug = file->private_data; |
| 1415 | struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private; |
| 1416 | int offset_label, offset, len = 0, index = LPFC_PCI_CFG_RD_SIZE; |
| 1417 | int where, count; |
| 1418 | char *pbuffer; |
| 1419 | struct pci_dev *pdev; |
| 1420 | uint32_t u32val; |
| 1421 | uint16_t u16val; |
| 1422 | uint8_t u8val; |
| 1423 | |
| 1424 | pdev = phba->pcidev; |
| 1425 | if (!pdev) |
| 1426 | return 0; |
| 1427 | |
| 1428 | /* This is a user read operation */ |
| 1429 | debug->op = LPFC_IDIAG_OP_RD; |
| 1430 | |
| 1431 | if (!debug->buffer) |
| 1432 | debug->buffer = kmalloc(LPFC_PCI_CFG_SIZE, GFP_KERNEL); |
| 1433 | if (!debug->buffer) |
| 1434 | return 0; |
| 1435 | pbuffer = debug->buffer; |
| 1436 | |
| 1437 | if (*ppos) |
| 1438 | return 0; |
| 1439 | |
| 1440 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_RD) { |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 1441 | where = idiag.cmd.data[IDIAG_PCICFG_WHERE_INDX]; |
| 1442 | count = idiag.cmd.data[IDIAG_PCICFG_COUNT_INDX]; |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 1443 | } else |
| 1444 | return 0; |
| 1445 | |
| 1446 | /* Read single PCI config space register */ |
| 1447 | switch (count) { |
| 1448 | case SIZE_U8: /* byte (8 bits) */ |
| 1449 | pci_read_config_byte(pdev, where, &u8val); |
| 1450 | len += snprintf(pbuffer+len, LPFC_PCI_CFG_SIZE-len, |
| 1451 | "%03x: %02x\n", where, u8val); |
| 1452 | break; |
| 1453 | case SIZE_U16: /* word (16 bits) */ |
| 1454 | pci_read_config_word(pdev, where, &u16val); |
| 1455 | len += snprintf(pbuffer+len, LPFC_PCI_CFG_SIZE-len, |
| 1456 | "%03x: %04x\n", where, u16val); |
| 1457 | break; |
| 1458 | case SIZE_U32: /* double word (32 bits) */ |
| 1459 | pci_read_config_dword(pdev, where, &u32val); |
| 1460 | len += snprintf(pbuffer+len, LPFC_PCI_CFG_SIZE-len, |
| 1461 | "%03x: %08x\n", where, u32val); |
| 1462 | break; |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 1463 | case LPFC_PCI_CFG_BROWSE: /* browse all */ |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 1464 | goto pcicfg_browse; |
| 1465 | break; |
| 1466 | default: |
| 1467 | /* illegal count */ |
| 1468 | len = 0; |
| 1469 | break; |
| 1470 | } |
| 1471 | return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len); |
| 1472 | |
| 1473 | pcicfg_browse: |
| 1474 | |
| 1475 | /* Browse all PCI config space registers */ |
| 1476 | offset_label = idiag.offset.last_rd; |
| 1477 | offset = offset_label; |
| 1478 | |
| 1479 | /* Read PCI config space */ |
| 1480 | len += snprintf(pbuffer+len, LPFC_PCI_CFG_SIZE-len, |
| 1481 | "%03x: ", offset_label); |
| 1482 | while (index > 0) { |
| 1483 | pci_read_config_dword(pdev, offset, &u32val); |
| 1484 | len += snprintf(pbuffer+len, LPFC_PCI_CFG_SIZE-len, |
| 1485 | "%08x ", u32val); |
| 1486 | offset += sizeof(uint32_t); |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 1487 | if (offset >= LPFC_PCI_CFG_SIZE) { |
| 1488 | len += snprintf(pbuffer+len, |
| 1489 | LPFC_PCI_CFG_SIZE-len, "\n"); |
| 1490 | break; |
| 1491 | } |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 1492 | index -= sizeof(uint32_t); |
| 1493 | if (!index) |
| 1494 | len += snprintf(pbuffer+len, LPFC_PCI_CFG_SIZE-len, |
| 1495 | "\n"); |
| 1496 | else if (!(index % (8 * sizeof(uint32_t)))) { |
| 1497 | offset_label += (8 * sizeof(uint32_t)); |
| 1498 | len += snprintf(pbuffer+len, LPFC_PCI_CFG_SIZE-len, |
| 1499 | "\n%03x: ", offset_label); |
| 1500 | } |
| 1501 | } |
| 1502 | |
| 1503 | /* Set up the offset for next portion of pci cfg read */ |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 1504 | if (index == 0) { |
| 1505 | idiag.offset.last_rd += LPFC_PCI_CFG_RD_SIZE; |
| 1506 | if (idiag.offset.last_rd >= LPFC_PCI_CFG_SIZE) |
| 1507 | idiag.offset.last_rd = 0; |
| 1508 | } else |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 1509 | idiag.offset.last_rd = 0; |
| 1510 | |
| 1511 | return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len); |
| 1512 | } |
| 1513 | |
| 1514 | /** |
| 1515 | * lpfc_idiag_pcicfg_write - Syntax check and set up idiag pcicfg commands |
| 1516 | * @file: The file pointer to read from. |
| 1517 | * @buf: The buffer to copy the user data from. |
| 1518 | * @nbytes: The number of bytes to get. |
| 1519 | * @ppos: The position in the file to start reading from. |
| 1520 | * |
| 1521 | * This routine get the debugfs idiag command struct from user space and |
| 1522 | * then perform the syntax check for PCI config space read or write command |
| 1523 | * accordingly. In the case of PCI config space read command, it sets up |
| 1524 | * the command in the idiag command struct for the debugfs read operation. |
| 1525 | * In the case of PCI config space write operation, it executes the write |
| 1526 | * operation into the PCI config space accordingly. |
| 1527 | * |
| 1528 | * It returns the @nbytges passing in from debugfs user space when successful. |
| 1529 | * In case of error conditions, it returns proper error code back to the user |
| 1530 | * space. |
| 1531 | */ |
| 1532 | static ssize_t |
| 1533 | lpfc_idiag_pcicfg_write(struct file *file, const char __user *buf, |
| 1534 | size_t nbytes, loff_t *ppos) |
| 1535 | { |
| 1536 | struct lpfc_debug *debug = file->private_data; |
| 1537 | struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private; |
| 1538 | uint32_t where, value, count; |
| 1539 | uint32_t u32val; |
| 1540 | uint16_t u16val; |
| 1541 | uint8_t u8val; |
| 1542 | struct pci_dev *pdev; |
| 1543 | int rc; |
| 1544 | |
| 1545 | pdev = phba->pcidev; |
| 1546 | if (!pdev) |
| 1547 | return -EFAULT; |
| 1548 | |
| 1549 | /* This is a user write operation */ |
| 1550 | debug->op = LPFC_IDIAG_OP_WR; |
| 1551 | |
| 1552 | rc = lpfc_idiag_cmd_get(buf, nbytes, &idiag.cmd); |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 1553 | if (rc < 0) |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 1554 | return rc; |
| 1555 | |
| 1556 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_RD) { |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 1557 | /* Sanity check on PCI config read command line arguments */ |
| 1558 | if (rc != LPFC_PCI_CFG_RD_CMD_ARG) |
| 1559 | goto error_out; |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 1560 | /* Read command from PCI config space, set up command fields */ |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 1561 | where = idiag.cmd.data[IDIAG_PCICFG_WHERE_INDX]; |
| 1562 | count = idiag.cmd.data[IDIAG_PCICFG_COUNT_INDX]; |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 1563 | if (count == LPFC_PCI_CFG_BROWSE) { |
| 1564 | if (where % sizeof(uint32_t)) |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 1565 | goto error_out; |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 1566 | /* Starting offset to browse */ |
| 1567 | idiag.offset.last_rd = where; |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 1568 | } else if ((count != sizeof(uint8_t)) && |
| 1569 | (count != sizeof(uint16_t)) && |
| 1570 | (count != sizeof(uint32_t))) |
| 1571 | goto error_out; |
| 1572 | if (count == sizeof(uint8_t)) { |
| 1573 | if (where > LPFC_PCI_CFG_SIZE - sizeof(uint8_t)) |
| 1574 | goto error_out; |
| 1575 | if (where % sizeof(uint8_t)) |
| 1576 | goto error_out; |
| 1577 | } |
| 1578 | if (count == sizeof(uint16_t)) { |
| 1579 | if (where > LPFC_PCI_CFG_SIZE - sizeof(uint16_t)) |
| 1580 | goto error_out; |
| 1581 | if (where % sizeof(uint16_t)) |
| 1582 | goto error_out; |
| 1583 | } |
| 1584 | if (count == sizeof(uint32_t)) { |
| 1585 | if (where > LPFC_PCI_CFG_SIZE - sizeof(uint32_t)) |
| 1586 | goto error_out; |
| 1587 | if (where % sizeof(uint32_t)) |
| 1588 | goto error_out; |
| 1589 | } |
| 1590 | } else if (idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_WR || |
| 1591 | idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_ST || |
| 1592 | idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_CL) { |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 1593 | /* Sanity check on PCI config write command line arguments */ |
| 1594 | if (rc != LPFC_PCI_CFG_WR_CMD_ARG) |
| 1595 | goto error_out; |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 1596 | /* Write command to PCI config space, read-modify-write */ |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 1597 | where = idiag.cmd.data[IDIAG_PCICFG_WHERE_INDX]; |
| 1598 | count = idiag.cmd.data[IDIAG_PCICFG_COUNT_INDX]; |
| 1599 | value = idiag.cmd.data[IDIAG_PCICFG_VALUE_INDX]; |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 1600 | /* Sanity checks */ |
| 1601 | if ((count != sizeof(uint8_t)) && |
| 1602 | (count != sizeof(uint16_t)) && |
| 1603 | (count != sizeof(uint32_t))) |
| 1604 | goto error_out; |
| 1605 | if (count == sizeof(uint8_t)) { |
| 1606 | if (where > LPFC_PCI_CFG_SIZE - sizeof(uint8_t)) |
| 1607 | goto error_out; |
| 1608 | if (where % sizeof(uint8_t)) |
| 1609 | goto error_out; |
| 1610 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_WR) |
| 1611 | pci_write_config_byte(pdev, where, |
| 1612 | (uint8_t)value); |
| 1613 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_ST) { |
| 1614 | rc = pci_read_config_byte(pdev, where, &u8val); |
| 1615 | if (!rc) { |
| 1616 | u8val |= (uint8_t)value; |
| 1617 | pci_write_config_byte(pdev, where, |
| 1618 | u8val); |
| 1619 | } |
| 1620 | } |
| 1621 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_CL) { |
| 1622 | rc = pci_read_config_byte(pdev, where, &u8val); |
| 1623 | if (!rc) { |
| 1624 | u8val &= (uint8_t)(~value); |
| 1625 | pci_write_config_byte(pdev, where, |
| 1626 | u8val); |
| 1627 | } |
| 1628 | } |
| 1629 | } |
| 1630 | if (count == sizeof(uint16_t)) { |
| 1631 | if (where > LPFC_PCI_CFG_SIZE - sizeof(uint16_t)) |
| 1632 | goto error_out; |
| 1633 | if (where % sizeof(uint16_t)) |
| 1634 | goto error_out; |
| 1635 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_WR) |
| 1636 | pci_write_config_word(pdev, where, |
| 1637 | (uint16_t)value); |
| 1638 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_ST) { |
| 1639 | rc = pci_read_config_word(pdev, where, &u16val); |
| 1640 | if (!rc) { |
| 1641 | u16val |= (uint16_t)value; |
| 1642 | pci_write_config_word(pdev, where, |
| 1643 | u16val); |
| 1644 | } |
| 1645 | } |
| 1646 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_CL) { |
| 1647 | rc = pci_read_config_word(pdev, where, &u16val); |
| 1648 | if (!rc) { |
| 1649 | u16val &= (uint16_t)(~value); |
| 1650 | pci_write_config_word(pdev, where, |
| 1651 | u16val); |
| 1652 | } |
| 1653 | } |
| 1654 | } |
| 1655 | if (count == sizeof(uint32_t)) { |
| 1656 | if (where > LPFC_PCI_CFG_SIZE - sizeof(uint32_t)) |
| 1657 | goto error_out; |
| 1658 | if (where % sizeof(uint32_t)) |
| 1659 | goto error_out; |
| 1660 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_WR) |
| 1661 | pci_write_config_dword(pdev, where, value); |
| 1662 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_ST) { |
| 1663 | rc = pci_read_config_dword(pdev, where, |
| 1664 | &u32val); |
| 1665 | if (!rc) { |
| 1666 | u32val |= value; |
| 1667 | pci_write_config_dword(pdev, where, |
| 1668 | u32val); |
| 1669 | } |
| 1670 | } |
| 1671 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_CL) { |
| 1672 | rc = pci_read_config_dword(pdev, where, |
| 1673 | &u32val); |
| 1674 | if (!rc) { |
| 1675 | u32val &= ~value; |
| 1676 | pci_write_config_dword(pdev, where, |
| 1677 | u32val); |
| 1678 | } |
| 1679 | } |
| 1680 | } |
| 1681 | } else |
| 1682 | /* All other opecodes are illegal for now */ |
| 1683 | goto error_out; |
| 1684 | |
| 1685 | return nbytes; |
| 1686 | error_out: |
| 1687 | memset(&idiag, 0, sizeof(idiag)); |
| 1688 | return -EINVAL; |
| 1689 | } |
| 1690 | |
| 1691 | /** |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 1692 | * lpfc_idiag_baracc_read - idiag debugfs pci bar access read |
| 1693 | * @file: The file pointer to read from. |
| 1694 | * @buf: The buffer to copy the data to. |
| 1695 | * @nbytes: The number of bytes to read. |
| 1696 | * @ppos: The position in the file to start reading from. |
| 1697 | * |
| 1698 | * Description: |
| 1699 | * This routine reads data from the @phba pci bar memory mapped space |
| 1700 | * according to the idiag command, and copies to user @buf. |
| 1701 | * |
| 1702 | * Returns: |
| 1703 | * This function returns the amount of data that was read (this could be less |
| 1704 | * than @nbytes if the end of the file was reached) or a negative error value. |
| 1705 | **/ |
| 1706 | static ssize_t |
| 1707 | lpfc_idiag_baracc_read(struct file *file, char __user *buf, size_t nbytes, |
| 1708 | loff_t *ppos) |
| 1709 | { |
| 1710 | struct lpfc_debug *debug = file->private_data; |
| 1711 | struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private; |
| 1712 | int offset_label, offset, offset_run, len = 0, index; |
| 1713 | int bar_num, acc_range, bar_size; |
| 1714 | char *pbuffer; |
| 1715 | void __iomem *mem_mapped_bar; |
| 1716 | uint32_t if_type; |
| 1717 | struct pci_dev *pdev; |
| 1718 | uint32_t u32val; |
| 1719 | |
| 1720 | pdev = phba->pcidev; |
| 1721 | if (!pdev) |
| 1722 | return 0; |
| 1723 | |
| 1724 | /* This is a user read operation */ |
| 1725 | debug->op = LPFC_IDIAG_OP_RD; |
| 1726 | |
| 1727 | if (!debug->buffer) |
| 1728 | debug->buffer = kmalloc(LPFC_PCI_BAR_RD_BUF_SIZE, GFP_KERNEL); |
| 1729 | if (!debug->buffer) |
| 1730 | return 0; |
| 1731 | pbuffer = debug->buffer; |
| 1732 | |
| 1733 | if (*ppos) |
| 1734 | return 0; |
| 1735 | |
| 1736 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_BARACC_RD) { |
| 1737 | bar_num = idiag.cmd.data[IDIAG_BARACC_BAR_NUM_INDX]; |
| 1738 | offset = idiag.cmd.data[IDIAG_BARACC_OFF_SET_INDX]; |
| 1739 | acc_range = idiag.cmd.data[IDIAG_BARACC_ACC_MOD_INDX]; |
| 1740 | bar_size = idiag.cmd.data[IDIAG_BARACC_BAR_SZE_INDX]; |
| 1741 | } else |
| 1742 | return 0; |
| 1743 | |
| 1744 | if (acc_range == 0) |
| 1745 | return 0; |
| 1746 | |
| 1747 | if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); |
| 1748 | if (if_type == LPFC_SLI_INTF_IF_TYPE_0) { |
| 1749 | if (bar_num == IDIAG_BARACC_BAR_0) |
| 1750 | mem_mapped_bar = phba->sli4_hba.conf_regs_memmap_p; |
| 1751 | else if (bar_num == IDIAG_BARACC_BAR_1) |
| 1752 | mem_mapped_bar = phba->sli4_hba.ctrl_regs_memmap_p; |
| 1753 | else if (bar_num == IDIAG_BARACC_BAR_2) |
| 1754 | mem_mapped_bar = phba->sli4_hba.drbl_regs_memmap_p; |
| 1755 | else |
| 1756 | return 0; |
| 1757 | } else if (if_type == LPFC_SLI_INTF_IF_TYPE_2) { |
| 1758 | if (bar_num == IDIAG_BARACC_BAR_0) |
| 1759 | mem_mapped_bar = phba->sli4_hba.conf_regs_memmap_p; |
| 1760 | else |
| 1761 | return 0; |
| 1762 | } else |
| 1763 | return 0; |
| 1764 | |
| 1765 | /* Read single PCI bar space register */ |
| 1766 | if (acc_range == SINGLE_WORD) { |
| 1767 | offset_run = offset; |
| 1768 | u32val = readl(mem_mapped_bar + offset_run); |
| 1769 | len += snprintf(pbuffer+len, LPFC_PCI_BAR_RD_BUF_SIZE-len, |
| 1770 | "%05x: %08x\n", offset_run, u32val); |
| 1771 | } else |
| 1772 | goto baracc_browse; |
| 1773 | |
| 1774 | return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len); |
| 1775 | |
| 1776 | baracc_browse: |
| 1777 | |
| 1778 | /* Browse all PCI bar space registers */ |
| 1779 | offset_label = idiag.offset.last_rd; |
| 1780 | offset_run = offset_label; |
| 1781 | |
| 1782 | /* Read PCI bar memory mapped space */ |
| 1783 | len += snprintf(pbuffer+len, LPFC_PCI_BAR_RD_BUF_SIZE-len, |
| 1784 | "%05x: ", offset_label); |
| 1785 | index = LPFC_PCI_BAR_RD_SIZE; |
| 1786 | while (index > 0) { |
| 1787 | u32val = readl(mem_mapped_bar + offset_run); |
| 1788 | len += snprintf(pbuffer+len, LPFC_PCI_BAR_RD_BUF_SIZE-len, |
| 1789 | "%08x ", u32val); |
| 1790 | offset_run += sizeof(uint32_t); |
| 1791 | if (acc_range == LPFC_PCI_BAR_BROWSE) { |
| 1792 | if (offset_run >= bar_size) { |
| 1793 | len += snprintf(pbuffer+len, |
| 1794 | LPFC_PCI_BAR_RD_BUF_SIZE-len, "\n"); |
| 1795 | break; |
| 1796 | } |
| 1797 | } else { |
| 1798 | if (offset_run >= offset + |
| 1799 | (acc_range * sizeof(uint32_t))) { |
| 1800 | len += snprintf(pbuffer+len, |
| 1801 | LPFC_PCI_BAR_RD_BUF_SIZE-len, "\n"); |
| 1802 | break; |
| 1803 | } |
| 1804 | } |
| 1805 | index -= sizeof(uint32_t); |
| 1806 | if (!index) |
| 1807 | len += snprintf(pbuffer+len, |
| 1808 | LPFC_PCI_BAR_RD_BUF_SIZE-len, "\n"); |
| 1809 | else if (!(index % (8 * sizeof(uint32_t)))) { |
| 1810 | offset_label += (8 * sizeof(uint32_t)); |
| 1811 | len += snprintf(pbuffer+len, |
| 1812 | LPFC_PCI_BAR_RD_BUF_SIZE-len, |
| 1813 | "\n%05x: ", offset_label); |
| 1814 | } |
| 1815 | } |
| 1816 | |
| 1817 | /* Set up the offset for next portion of pci bar read */ |
| 1818 | if (index == 0) { |
| 1819 | idiag.offset.last_rd += LPFC_PCI_BAR_RD_SIZE; |
| 1820 | if (acc_range == LPFC_PCI_BAR_BROWSE) { |
| 1821 | if (idiag.offset.last_rd >= bar_size) |
| 1822 | idiag.offset.last_rd = 0; |
| 1823 | } else { |
| 1824 | if (offset_run >= offset + |
| 1825 | (acc_range * sizeof(uint32_t))) |
| 1826 | idiag.offset.last_rd = offset; |
| 1827 | } |
| 1828 | } else { |
| 1829 | if (acc_range == LPFC_PCI_BAR_BROWSE) |
| 1830 | idiag.offset.last_rd = 0; |
| 1831 | else |
| 1832 | idiag.offset.last_rd = offset; |
| 1833 | } |
| 1834 | |
| 1835 | return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len); |
| 1836 | } |
| 1837 | |
| 1838 | /** |
| 1839 | * lpfc_idiag_baracc_write - Syntax check and set up idiag bar access commands |
| 1840 | * @file: The file pointer to read from. |
| 1841 | * @buf: The buffer to copy the user data from. |
| 1842 | * @nbytes: The number of bytes to get. |
| 1843 | * @ppos: The position in the file to start reading from. |
| 1844 | * |
| 1845 | * This routine get the debugfs idiag command struct from user space and |
| 1846 | * then perform the syntax check for PCI bar memory mapped space read or |
| 1847 | * write command accordingly. In the case of PCI bar memory mapped space |
| 1848 | * read command, it sets up the command in the idiag command struct for |
| 1849 | * the debugfs read operation. In the case of PCI bar memorpy mapped space |
| 1850 | * write operation, it executes the write operation into the PCI bar memory |
| 1851 | * mapped space accordingly. |
| 1852 | * |
| 1853 | * It returns the @nbytges passing in from debugfs user space when successful. |
| 1854 | * In case of error conditions, it returns proper error code back to the user |
| 1855 | * space. |
| 1856 | */ |
| 1857 | static ssize_t |
| 1858 | lpfc_idiag_baracc_write(struct file *file, const char __user *buf, |
| 1859 | size_t nbytes, loff_t *ppos) |
| 1860 | { |
| 1861 | struct lpfc_debug *debug = file->private_data; |
| 1862 | struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private; |
| 1863 | uint32_t bar_num, bar_size, offset, value, acc_range; |
| 1864 | struct pci_dev *pdev; |
| 1865 | void __iomem *mem_mapped_bar; |
| 1866 | uint32_t if_type; |
| 1867 | uint32_t u32val; |
| 1868 | int rc; |
| 1869 | |
| 1870 | pdev = phba->pcidev; |
| 1871 | if (!pdev) |
| 1872 | return -EFAULT; |
| 1873 | |
| 1874 | /* This is a user write operation */ |
| 1875 | debug->op = LPFC_IDIAG_OP_WR; |
| 1876 | |
| 1877 | rc = lpfc_idiag_cmd_get(buf, nbytes, &idiag.cmd); |
| 1878 | if (rc < 0) |
| 1879 | return rc; |
| 1880 | |
| 1881 | if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); |
| 1882 | bar_num = idiag.cmd.data[IDIAG_BARACC_BAR_NUM_INDX]; |
| 1883 | |
| 1884 | if (if_type == LPFC_SLI_INTF_IF_TYPE_0) { |
| 1885 | if ((bar_num != IDIAG_BARACC_BAR_0) && |
| 1886 | (bar_num != IDIAG_BARACC_BAR_1) && |
| 1887 | (bar_num != IDIAG_BARACC_BAR_2)) |
| 1888 | goto error_out; |
| 1889 | } else if (if_type == LPFC_SLI_INTF_IF_TYPE_2) { |
| 1890 | if (bar_num != IDIAG_BARACC_BAR_0) |
| 1891 | goto error_out; |
| 1892 | } else |
| 1893 | goto error_out; |
| 1894 | |
| 1895 | if (if_type == LPFC_SLI_INTF_IF_TYPE_0) { |
| 1896 | if (bar_num == IDIAG_BARACC_BAR_0) { |
| 1897 | idiag.cmd.data[IDIAG_BARACC_BAR_SZE_INDX] = |
| 1898 | LPFC_PCI_IF0_BAR0_SIZE; |
| 1899 | mem_mapped_bar = phba->sli4_hba.conf_regs_memmap_p; |
| 1900 | } else if (bar_num == IDIAG_BARACC_BAR_1) { |
| 1901 | idiag.cmd.data[IDIAG_BARACC_BAR_SZE_INDX] = |
| 1902 | LPFC_PCI_IF0_BAR1_SIZE; |
| 1903 | mem_mapped_bar = phba->sli4_hba.ctrl_regs_memmap_p; |
| 1904 | } else if (bar_num == IDIAG_BARACC_BAR_2) { |
| 1905 | idiag.cmd.data[IDIAG_BARACC_BAR_SZE_INDX] = |
| 1906 | LPFC_PCI_IF0_BAR2_SIZE; |
| 1907 | mem_mapped_bar = phba->sli4_hba.drbl_regs_memmap_p; |
| 1908 | } else |
| 1909 | goto error_out; |
| 1910 | } else if (if_type == LPFC_SLI_INTF_IF_TYPE_2) { |
| 1911 | if (bar_num == IDIAG_BARACC_BAR_0) { |
| 1912 | idiag.cmd.data[IDIAG_BARACC_BAR_SZE_INDX] = |
| 1913 | LPFC_PCI_IF2_BAR0_SIZE; |
| 1914 | mem_mapped_bar = phba->sli4_hba.conf_regs_memmap_p; |
| 1915 | } else |
| 1916 | goto error_out; |
| 1917 | } else |
| 1918 | goto error_out; |
| 1919 | |
| 1920 | offset = idiag.cmd.data[IDIAG_BARACC_OFF_SET_INDX]; |
| 1921 | if (offset % sizeof(uint32_t)) |
| 1922 | goto error_out; |
| 1923 | |
| 1924 | bar_size = idiag.cmd.data[IDIAG_BARACC_BAR_SZE_INDX]; |
| 1925 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_BARACC_RD) { |
| 1926 | /* Sanity check on PCI config read command line arguments */ |
| 1927 | if (rc != LPFC_PCI_BAR_RD_CMD_ARG) |
| 1928 | goto error_out; |
| 1929 | acc_range = idiag.cmd.data[IDIAG_BARACC_ACC_MOD_INDX]; |
| 1930 | if (acc_range == LPFC_PCI_BAR_BROWSE) { |
| 1931 | if (offset > bar_size - sizeof(uint32_t)) |
| 1932 | goto error_out; |
| 1933 | /* Starting offset to browse */ |
| 1934 | idiag.offset.last_rd = offset; |
| 1935 | } else if (acc_range > SINGLE_WORD) { |
| 1936 | if (offset + acc_range * sizeof(uint32_t) > bar_size) |
| 1937 | goto error_out; |
| 1938 | /* Starting offset to browse */ |
| 1939 | idiag.offset.last_rd = offset; |
| 1940 | } else if (acc_range != SINGLE_WORD) |
| 1941 | goto error_out; |
| 1942 | } else if (idiag.cmd.opcode == LPFC_IDIAG_CMD_BARACC_WR || |
| 1943 | idiag.cmd.opcode == LPFC_IDIAG_CMD_BARACC_ST || |
| 1944 | idiag.cmd.opcode == LPFC_IDIAG_CMD_BARACC_CL) { |
| 1945 | /* Sanity check on PCI bar write command line arguments */ |
| 1946 | if (rc != LPFC_PCI_BAR_WR_CMD_ARG) |
| 1947 | goto error_out; |
| 1948 | /* Write command to PCI bar space, read-modify-write */ |
| 1949 | acc_range = SINGLE_WORD; |
| 1950 | value = idiag.cmd.data[IDIAG_BARACC_REG_VAL_INDX]; |
| 1951 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_BARACC_WR) { |
| 1952 | writel(value, mem_mapped_bar + offset); |
| 1953 | readl(mem_mapped_bar + offset); |
| 1954 | } |
| 1955 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_BARACC_ST) { |
| 1956 | u32val = readl(mem_mapped_bar + offset); |
| 1957 | u32val |= value; |
| 1958 | writel(u32val, mem_mapped_bar + offset); |
| 1959 | readl(mem_mapped_bar + offset); |
| 1960 | } |
| 1961 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_BARACC_CL) { |
| 1962 | u32val = readl(mem_mapped_bar + offset); |
| 1963 | u32val &= ~value; |
| 1964 | writel(u32val, mem_mapped_bar + offset); |
| 1965 | readl(mem_mapped_bar + offset); |
| 1966 | } |
| 1967 | } else |
| 1968 | /* All other opecodes are illegal for now */ |
| 1969 | goto error_out; |
| 1970 | |
| 1971 | return nbytes; |
| 1972 | error_out: |
| 1973 | memset(&idiag, 0, sizeof(idiag)); |
| 1974 | return -EINVAL; |
| 1975 | } |
| 1976 | |
| 1977 | /** |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 1978 | * lpfc_idiag_queinfo_read - idiag debugfs read queue information |
| 1979 | * @file: The file pointer to read from. |
| 1980 | * @buf: The buffer to copy the data to. |
| 1981 | * @nbytes: The number of bytes to read. |
| 1982 | * @ppos: The position in the file to start reading from. |
| 1983 | * |
| 1984 | * Description: |
| 1985 | * This routine reads data from the @phba SLI4 PCI function queue information, |
| 1986 | * and copies to user @buf. |
| 1987 | * |
| 1988 | * Returns: |
| 1989 | * This function returns the amount of data that was read (this could be less |
| 1990 | * than @nbytes if the end of the file was reached) or a negative error value. |
| 1991 | **/ |
| 1992 | static ssize_t |
| 1993 | lpfc_idiag_queinfo_read(struct file *file, char __user *buf, size_t nbytes, |
| 1994 | loff_t *ppos) |
| 1995 | { |
| 1996 | struct lpfc_debug *debug = file->private_data; |
| 1997 | struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private; |
James Smart | c85a65a | 2012-08-03 12:37:00 -0400 | [diff] [blame] | 1998 | int len = 0; |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 1999 | char *pbuffer; |
James Smart | c85a65a | 2012-08-03 12:37:00 -0400 | [diff] [blame] | 2000 | int x, cnt; |
| 2001 | int max_cnt; |
| 2002 | struct lpfc_queue *qp = NULL; |
| 2003 | |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 2004 | |
| 2005 | if (!debug->buffer) |
| 2006 | debug->buffer = kmalloc(LPFC_QUE_INFO_GET_BUF_SIZE, GFP_KERNEL); |
| 2007 | if (!debug->buffer) |
| 2008 | return 0; |
| 2009 | pbuffer = debug->buffer; |
James Smart | c85a65a | 2012-08-03 12:37:00 -0400 | [diff] [blame] | 2010 | max_cnt = LPFC_QUE_INFO_GET_BUF_SIZE - 128; |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 2011 | |
| 2012 | if (*ppos) |
| 2013 | return 0; |
| 2014 | |
James Smart | c85a65a | 2012-08-03 12:37:00 -0400 | [diff] [blame] | 2015 | spin_lock_irq(&phba->hbalock); |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 2016 | |
James Smart | c85a65a | 2012-08-03 12:37:00 -0400 | [diff] [blame] | 2017 | /* Fast-path event queue */ |
| 2018 | if (phba->sli4_hba.hba_eq && phba->cfg_fcp_io_channel) { |
| 2019 | cnt = phba->cfg_fcp_io_channel; |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 2020 | |
James Smart | c85a65a | 2012-08-03 12:37:00 -0400 | [diff] [blame] | 2021 | for (x = 0; x < cnt; x++) { |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 2022 | |
James Smart | c85a65a | 2012-08-03 12:37:00 -0400 | [diff] [blame] | 2023 | /* Fast-path EQ */ |
| 2024 | qp = phba->sli4_hba.hba_eq[x]; |
| 2025 | if (!qp) |
| 2026 | goto proc_cq; |
| 2027 | |
| 2028 | len += snprintf(pbuffer+len, |
| 2029 | LPFC_QUE_INFO_GET_BUF_SIZE-len, |
| 2030 | "\nHBA EQ info: " |
| 2031 | "EQ-STAT[max:x%x noE:x%x " |
| 2032 | "bs:x%x proc:x%llx]\n", |
| 2033 | qp->q_cnt_1, qp->q_cnt_2, |
James Smart | a51a178 | 2012-08-14 14:25:59 -0400 | [diff] [blame] | 2034 | qp->q_cnt_3, (unsigned long long)qp->q_cnt_4); |
James Smart | c85a65a | 2012-08-03 12:37:00 -0400 | [diff] [blame] | 2035 | |
| 2036 | len += snprintf(pbuffer+len, |
| 2037 | LPFC_QUE_INFO_GET_BUF_SIZE-len, |
| 2038 | "EQID[%02d], " |
| 2039 | "QE-CNT[%04d], QE-SIZE[%04d], " |
| 2040 | "HOST-IDX[%04d], PORT-IDX[%04d]", |
| 2041 | qp->queue_id, |
| 2042 | qp->entry_count, |
| 2043 | qp->entry_size, |
| 2044 | qp->host_index, |
| 2045 | qp->hba_index); |
| 2046 | |
| 2047 | |
| 2048 | /* Reset max counter */ |
| 2049 | qp->EQ_max_eqe = 0; |
| 2050 | |
| 2051 | len += snprintf(pbuffer+len, |
| 2052 | LPFC_QUE_INFO_GET_BUF_SIZE-len, "\n"); |
| 2053 | if (len >= max_cnt) |
| 2054 | goto too_big; |
| 2055 | proc_cq: |
| 2056 | /* Fast-path FCP CQ */ |
| 2057 | qp = phba->sli4_hba.fcp_cq[x]; |
| 2058 | len += snprintf(pbuffer+len, |
| 2059 | LPFC_QUE_INFO_GET_BUF_SIZE-len, |
| 2060 | "\tFCP CQ info: "); |
| 2061 | len += snprintf(pbuffer+len, |
| 2062 | LPFC_QUE_INFO_GET_BUF_SIZE-len, |
| 2063 | "AssocEQID[%02d]: " |
| 2064 | "CQ STAT[max:x%x relw:x%x " |
| 2065 | "xabt:x%x wq:x%llx]\n", |
| 2066 | qp->assoc_qid, |
| 2067 | qp->q_cnt_1, qp->q_cnt_2, |
James Smart | a51a178 | 2012-08-14 14:25:59 -0400 | [diff] [blame] | 2068 | qp->q_cnt_3, (unsigned long long)qp->q_cnt_4); |
James Smart | c85a65a | 2012-08-03 12:37:00 -0400 | [diff] [blame] | 2069 | len += snprintf(pbuffer+len, |
| 2070 | LPFC_QUE_INFO_GET_BUF_SIZE-len, |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 2071 | "\tCQID[%02d], " |
James Smart | c85a65a | 2012-08-03 12:37:00 -0400 | [diff] [blame] | 2072 | "QE-CNT[%04d], QE-SIZE[%04d], " |
| 2073 | "HOST-IDX[%04d], PORT-IDX[%04d]", |
| 2074 | qp->queue_id, qp->entry_count, |
| 2075 | qp->entry_size, qp->host_index, |
| 2076 | qp->hba_index); |
| 2077 | |
| 2078 | |
| 2079 | /* Reset max counter */ |
| 2080 | qp->CQ_max_cqe = 0; |
| 2081 | |
| 2082 | len += snprintf(pbuffer+len, |
James Smart | 2e90f4b | 2011-12-13 13:22:37 -0500 | [diff] [blame] | 2083 | LPFC_QUE_INFO_GET_BUF_SIZE-len, "\n"); |
James Smart | c85a65a | 2012-08-03 12:37:00 -0400 | [diff] [blame] | 2084 | if (len >= max_cnt) |
| 2085 | goto too_big; |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 2086 | |
James Smart | c85a65a | 2012-08-03 12:37:00 -0400 | [diff] [blame] | 2087 | /* Fast-path FCP WQ */ |
| 2088 | qp = phba->sli4_hba.fcp_wq[x]; |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 2089 | |
James Smart | c85a65a | 2012-08-03 12:37:00 -0400 | [diff] [blame] | 2090 | len += snprintf(pbuffer+len, |
| 2091 | LPFC_QUE_INFO_GET_BUF_SIZE-len, |
| 2092 | "\t\tFCP WQ info: "); |
| 2093 | len += snprintf(pbuffer+len, |
| 2094 | LPFC_QUE_INFO_GET_BUF_SIZE-len, |
| 2095 | "AssocCQID[%02d]: " |
| 2096 | "WQ-STAT[oflow:x%x posted:x%llx]\n", |
| 2097 | qp->assoc_qid, |
James Smart | a51a178 | 2012-08-14 14:25:59 -0400 | [diff] [blame] | 2098 | qp->q_cnt_1, (unsigned long long)qp->q_cnt_4); |
James Smart | c85a65a | 2012-08-03 12:37:00 -0400 | [diff] [blame] | 2099 | len += snprintf(pbuffer+len, |
| 2100 | LPFC_QUE_INFO_GET_BUF_SIZE-len, |
| 2101 | "\t\tWQID[%02d], " |
| 2102 | "QE-CNT[%04d], QE-SIZE[%04d], " |
| 2103 | "HOST-IDX[%04d], PORT-IDX[%04d]", |
| 2104 | qp->queue_id, |
| 2105 | qp->entry_count, |
| 2106 | qp->entry_size, |
| 2107 | qp->host_index, |
| 2108 | qp->hba_index); |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 2109 | |
James Smart | c85a65a | 2012-08-03 12:37:00 -0400 | [diff] [blame] | 2110 | len += snprintf(pbuffer+len, |
| 2111 | LPFC_QUE_INFO_GET_BUF_SIZE-len, "\n"); |
| 2112 | if (len >= max_cnt) |
| 2113 | goto too_big; |
| 2114 | |
| 2115 | if (x) |
James Smart | 2e90f4b | 2011-12-13 13:22:37 -0500 | [diff] [blame] | 2116 | continue; |
James Smart | c85a65a | 2012-08-03 12:37:00 -0400 | [diff] [blame] | 2117 | |
| 2118 | /* Only EQ 0 has slow path CQs configured */ |
| 2119 | |
| 2120 | /* Slow-path mailbox CQ */ |
| 2121 | qp = phba->sli4_hba.mbx_cq; |
| 2122 | if (qp) { |
| 2123 | len += snprintf(pbuffer+len, |
James Smart | 2e90f4b | 2011-12-13 13:22:37 -0500 | [diff] [blame] | 2124 | LPFC_QUE_INFO_GET_BUF_SIZE-len, |
James Smart | c85a65a | 2012-08-03 12:37:00 -0400 | [diff] [blame] | 2125 | "\tMBX CQ info: "); |
| 2126 | len += snprintf(pbuffer+len, |
James Smart | 2e90f4b | 2011-12-13 13:22:37 -0500 | [diff] [blame] | 2127 | LPFC_QUE_INFO_GET_BUF_SIZE-len, |
James Smart | c85a65a | 2012-08-03 12:37:00 -0400 | [diff] [blame] | 2128 | "AssocEQID[%02d]: " |
| 2129 | "CQ-STAT[mbox:x%x relw:x%x " |
| 2130 | "xabt:x%x wq:x%llx]\n", |
| 2131 | qp->assoc_qid, |
| 2132 | qp->q_cnt_1, qp->q_cnt_2, |
James Smart | a51a178 | 2012-08-14 14:25:59 -0400 | [diff] [blame] | 2133 | qp->q_cnt_3, |
| 2134 | (unsigned long long)qp->q_cnt_4); |
James Smart | c85a65a | 2012-08-03 12:37:00 -0400 | [diff] [blame] | 2135 | len += snprintf(pbuffer+len, |
| 2136 | LPFC_QUE_INFO_GET_BUF_SIZE-len, |
| 2137 | "\tCQID[%02d], " |
| 2138 | "QE-CNT[%04d], QE-SIZE[%04d], " |
| 2139 | "HOST-IDX[%04d], PORT-IDX[%04d]", |
| 2140 | qp->queue_id, qp->entry_count, |
| 2141 | qp->entry_size, qp->host_index, |
| 2142 | qp->hba_index); |
| 2143 | |
| 2144 | len += snprintf(pbuffer+len, |
| 2145 | LPFC_QUE_INFO_GET_BUF_SIZE-len, "\n"); |
| 2146 | if (len >= max_cnt) |
| 2147 | goto too_big; |
| 2148 | } |
| 2149 | |
| 2150 | /* Slow-path MBOX MQ */ |
| 2151 | qp = phba->sli4_hba.mbx_wq; |
| 2152 | if (qp) { |
| 2153 | len += snprintf(pbuffer+len, |
| 2154 | LPFC_QUE_INFO_GET_BUF_SIZE-len, |
| 2155 | "\t\tMBX MQ info: "); |
| 2156 | len += snprintf(pbuffer+len, |
| 2157 | LPFC_QUE_INFO_GET_BUF_SIZE-len, |
| 2158 | "AssocCQID[%02d]:\n", |
| 2159 | phba->sli4_hba.mbx_wq->assoc_qid); |
| 2160 | len += snprintf(pbuffer+len, |
| 2161 | LPFC_QUE_INFO_GET_BUF_SIZE-len, |
| 2162 | "\t\tWQID[%02d], " |
| 2163 | "QE-CNT[%04d], QE-SIZE[%04d], " |
| 2164 | "HOST-IDX[%04d], PORT-IDX[%04d]", |
| 2165 | qp->queue_id, qp->entry_count, |
| 2166 | qp->entry_size, qp->host_index, |
| 2167 | qp->hba_index); |
| 2168 | |
| 2169 | len += snprintf(pbuffer+len, |
| 2170 | LPFC_QUE_INFO_GET_BUF_SIZE-len, "\n"); |
| 2171 | if (len >= max_cnt) |
| 2172 | goto too_big; |
| 2173 | } |
| 2174 | |
| 2175 | /* Slow-path ELS response CQ */ |
| 2176 | qp = phba->sli4_hba.els_cq; |
| 2177 | if (qp) { |
| 2178 | len += snprintf(pbuffer+len, |
| 2179 | LPFC_QUE_INFO_GET_BUF_SIZE-len, |
| 2180 | "\tELS CQ info: "); |
| 2181 | len += snprintf(pbuffer+len, |
| 2182 | LPFC_QUE_INFO_GET_BUF_SIZE-len, |
| 2183 | "AssocEQID[%02d]: " |
| 2184 | "CQ-STAT[max:x%x relw:x%x " |
| 2185 | "xabt:x%x wq:x%llx]\n", |
| 2186 | qp->assoc_qid, |
| 2187 | qp->q_cnt_1, qp->q_cnt_2, |
James Smart | a51a178 | 2012-08-14 14:25:59 -0400 | [diff] [blame] | 2188 | qp->q_cnt_3, |
| 2189 | (unsigned long long)qp->q_cnt_4); |
James Smart | c85a65a | 2012-08-03 12:37:00 -0400 | [diff] [blame] | 2190 | len += snprintf(pbuffer+len, |
| 2191 | LPFC_QUE_INFO_GET_BUF_SIZE-len, |
| 2192 | "\tCQID [%02d], " |
| 2193 | "QE-CNT[%04d], QE-SIZE[%04d], " |
| 2194 | "HOST-IDX[%04d], PORT-IDX[%04d]", |
| 2195 | qp->queue_id, qp->entry_count, |
| 2196 | qp->entry_size, qp->host_index, |
| 2197 | qp->hba_index); |
| 2198 | |
| 2199 | /* Reset max counter */ |
| 2200 | qp->CQ_max_cqe = 0; |
| 2201 | |
| 2202 | len += snprintf(pbuffer+len, |
| 2203 | LPFC_QUE_INFO_GET_BUF_SIZE-len, "\n"); |
| 2204 | if (len >= max_cnt) |
| 2205 | goto too_big; |
| 2206 | } |
| 2207 | |
| 2208 | /* Slow-path ELS WQ */ |
| 2209 | qp = phba->sli4_hba.els_wq; |
| 2210 | if (qp) { |
| 2211 | len += snprintf(pbuffer+len, |
| 2212 | LPFC_QUE_INFO_GET_BUF_SIZE-len, |
| 2213 | "\t\tELS WQ info: "); |
| 2214 | len += snprintf(pbuffer+len, |
| 2215 | LPFC_QUE_INFO_GET_BUF_SIZE-len, |
| 2216 | "AssocCQID[%02d]: " |
| 2217 | " WQ-STAT[oflow:x%x " |
| 2218 | "posted:x%llx]\n", |
| 2219 | qp->assoc_qid, |
James Smart | a51a178 | 2012-08-14 14:25:59 -0400 | [diff] [blame] | 2220 | qp->q_cnt_1, |
| 2221 | (unsigned long long)qp->q_cnt_4); |
James Smart | c85a65a | 2012-08-03 12:37:00 -0400 | [diff] [blame] | 2222 | len += snprintf(pbuffer+len, |
| 2223 | LPFC_QUE_INFO_GET_BUF_SIZE-len, |
| 2224 | "\t\tWQID[%02d], " |
| 2225 | "QE-CNT[%04d], QE-SIZE[%04d], " |
| 2226 | "HOST-IDX[%04d], PORT-IDX[%04d]", |
| 2227 | qp->queue_id, qp->entry_count, |
| 2228 | qp->entry_size, qp->host_index, |
| 2229 | qp->hba_index); |
| 2230 | |
| 2231 | len += snprintf(pbuffer+len, |
| 2232 | LPFC_QUE_INFO_GET_BUF_SIZE-len, "\n"); |
| 2233 | if (len >= max_cnt) |
| 2234 | goto too_big; |
| 2235 | } |
| 2236 | |
| 2237 | if (phba->sli4_hba.hdr_rq && phba->sli4_hba.dat_rq) { |
| 2238 | /* Slow-path RQ header */ |
| 2239 | qp = phba->sli4_hba.hdr_rq; |
| 2240 | |
| 2241 | len += snprintf(pbuffer+len, |
| 2242 | LPFC_QUE_INFO_GET_BUF_SIZE-len, |
| 2243 | "\t\tRQ info: "); |
| 2244 | len += snprintf(pbuffer+len, |
| 2245 | LPFC_QUE_INFO_GET_BUF_SIZE-len, |
| 2246 | "AssocCQID[%02d]: " |
| 2247 | "RQ-STAT[nopost:x%x nobuf:x%x " |
| 2248 | "trunc:x%x rcv:x%llx]\n", |
| 2249 | qp->assoc_qid, |
| 2250 | qp->q_cnt_1, qp->q_cnt_2, |
James Smart | a51a178 | 2012-08-14 14:25:59 -0400 | [diff] [blame] | 2251 | qp->q_cnt_3, |
| 2252 | (unsigned long long)qp->q_cnt_4); |
James Smart | c85a65a | 2012-08-03 12:37:00 -0400 | [diff] [blame] | 2253 | len += snprintf(pbuffer+len, |
| 2254 | LPFC_QUE_INFO_GET_BUF_SIZE-len, |
| 2255 | "\t\tHQID[%02d], " |
| 2256 | "QE-CNT[%04d], QE-SIZE[%04d], " |
| 2257 | "HOST-IDX[%04d], PORT-IDX[%04d]\n", |
| 2258 | qp->queue_id, |
| 2259 | qp->entry_count, |
| 2260 | qp->entry_size, |
| 2261 | qp->host_index, |
| 2262 | qp->hba_index); |
| 2263 | |
| 2264 | /* Slow-path RQ data */ |
| 2265 | qp = phba->sli4_hba.dat_rq; |
| 2266 | len += snprintf(pbuffer+len, |
| 2267 | LPFC_QUE_INFO_GET_BUF_SIZE-len, |
| 2268 | "\t\tDQID[%02d], " |
| 2269 | "QE-CNT[%04d], QE-SIZE[%04d], " |
| 2270 | "HOST-IDX[%04d], PORT-IDX[%04d]\n", |
| 2271 | qp->queue_id, |
| 2272 | qp->entry_count, |
| 2273 | qp->entry_size, |
| 2274 | qp->host_index, |
| 2275 | qp->hba_index); |
| 2276 | |
| 2277 | len += snprintf(pbuffer+len, |
| 2278 | LPFC_QUE_INFO_GET_BUF_SIZE-len, "\n"); |
| 2279 | } |
James Smart | 2e90f4b | 2011-12-13 13:22:37 -0500 | [diff] [blame] | 2280 | } |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 2281 | } |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 2282 | |
James Smart | c85a65a | 2012-08-03 12:37:00 -0400 | [diff] [blame] | 2283 | spin_unlock_irq(&phba->hbalock); |
| 2284 | return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len); |
| 2285 | |
| 2286 | too_big: |
| 2287 | len += snprintf(pbuffer+len, |
| 2288 | LPFC_QUE_INFO_GET_BUF_SIZE-len, "Truncated ...\n"); |
| 2289 | spin_unlock_irq(&phba->hbalock); |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 2290 | return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len); |
| 2291 | } |
| 2292 | |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 2293 | /** |
| 2294 | * lpfc_idiag_que_param_check - queue access command parameter sanity check |
| 2295 | * @q: The pointer to queue structure. |
| 2296 | * @index: The index into a queue entry. |
| 2297 | * @count: The number of queue entries to access. |
| 2298 | * |
| 2299 | * Description: |
| 2300 | * The routine performs sanity check on device queue access method commands. |
| 2301 | * |
| 2302 | * Returns: |
| 2303 | * This function returns -EINVAL when fails the sanity check, otherwise, it |
| 2304 | * returns 0. |
| 2305 | **/ |
| 2306 | static int |
| 2307 | lpfc_idiag_que_param_check(struct lpfc_queue *q, int index, int count) |
| 2308 | { |
| 2309 | /* Only support single entry read or browsing */ |
| 2310 | if ((count != 1) && (count != LPFC_QUE_ACC_BROWSE)) |
| 2311 | return -EINVAL; |
| 2312 | if (index > q->entry_count - 1) |
| 2313 | return -EINVAL; |
| 2314 | return 0; |
| 2315 | } |
| 2316 | |
| 2317 | /** |
| 2318 | * lpfc_idiag_queacc_read_qe - read a single entry from the given queue index |
| 2319 | * @pbuffer: The pointer to buffer to copy the read data into. |
| 2320 | * @pque: The pointer to the queue to be read. |
| 2321 | * @index: The index into the queue entry. |
| 2322 | * |
| 2323 | * Description: |
| 2324 | * This routine reads out a single entry from the given queue's index location |
| 2325 | * and copies it into the buffer provided. |
| 2326 | * |
| 2327 | * Returns: |
| 2328 | * This function returns 0 when it fails, otherwise, it returns the length of |
| 2329 | * the data read into the buffer provided. |
| 2330 | **/ |
| 2331 | static int |
| 2332 | lpfc_idiag_queacc_read_qe(char *pbuffer, int len, struct lpfc_queue *pque, |
| 2333 | uint32_t index) |
| 2334 | { |
| 2335 | int offset, esize; |
| 2336 | uint32_t *pentry; |
| 2337 | |
| 2338 | if (!pbuffer || !pque) |
| 2339 | return 0; |
| 2340 | |
| 2341 | esize = pque->entry_size; |
| 2342 | len += snprintf(pbuffer+len, LPFC_QUE_ACC_BUF_SIZE-len, |
| 2343 | "QE-INDEX[%04d]:\n", index); |
| 2344 | |
| 2345 | offset = 0; |
| 2346 | pentry = pque->qe[index].address; |
| 2347 | while (esize > 0) { |
| 2348 | len += snprintf(pbuffer+len, LPFC_QUE_ACC_BUF_SIZE-len, |
| 2349 | "%08x ", *pentry); |
| 2350 | pentry++; |
| 2351 | offset += sizeof(uint32_t); |
| 2352 | esize -= sizeof(uint32_t); |
| 2353 | if (esize > 0 && !(offset % (4 * sizeof(uint32_t)))) |
| 2354 | len += snprintf(pbuffer+len, |
| 2355 | LPFC_QUE_ACC_BUF_SIZE-len, "\n"); |
| 2356 | } |
| 2357 | len += snprintf(pbuffer+len, LPFC_QUE_ACC_BUF_SIZE-len, "\n"); |
| 2358 | |
| 2359 | return len; |
| 2360 | } |
| 2361 | |
| 2362 | /** |
| 2363 | * lpfc_idiag_queacc_read - idiag debugfs read port queue |
| 2364 | * @file: The file pointer to read from. |
| 2365 | * @buf: The buffer to copy the data to. |
| 2366 | * @nbytes: The number of bytes to read. |
| 2367 | * @ppos: The position in the file to start reading from. |
| 2368 | * |
| 2369 | * Description: |
| 2370 | * This routine reads data from the @phba device queue memory according to the |
| 2371 | * idiag command, and copies to user @buf. Depending on the queue dump read |
| 2372 | * command setup, it does either a single queue entry read or browing through |
| 2373 | * all entries of the queue. |
| 2374 | * |
| 2375 | * Returns: |
| 2376 | * This function returns the amount of data that was read (this could be less |
| 2377 | * than @nbytes if the end of the file was reached) or a negative error value. |
| 2378 | **/ |
| 2379 | static ssize_t |
| 2380 | lpfc_idiag_queacc_read(struct file *file, char __user *buf, size_t nbytes, |
| 2381 | loff_t *ppos) |
| 2382 | { |
| 2383 | struct lpfc_debug *debug = file->private_data; |
| 2384 | uint32_t last_index, index, count; |
| 2385 | struct lpfc_queue *pque = NULL; |
| 2386 | char *pbuffer; |
| 2387 | int len = 0; |
| 2388 | |
| 2389 | /* This is a user read operation */ |
| 2390 | debug->op = LPFC_IDIAG_OP_RD; |
| 2391 | |
| 2392 | if (!debug->buffer) |
| 2393 | debug->buffer = kmalloc(LPFC_QUE_ACC_BUF_SIZE, GFP_KERNEL); |
| 2394 | if (!debug->buffer) |
| 2395 | return 0; |
| 2396 | pbuffer = debug->buffer; |
| 2397 | |
| 2398 | if (*ppos) |
| 2399 | return 0; |
| 2400 | |
| 2401 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_QUEACC_RD) { |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 2402 | index = idiag.cmd.data[IDIAG_QUEACC_INDEX_INDX]; |
| 2403 | count = idiag.cmd.data[IDIAG_QUEACC_COUNT_INDX]; |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 2404 | pque = (struct lpfc_queue *)idiag.ptr_private; |
| 2405 | } else |
| 2406 | return 0; |
| 2407 | |
| 2408 | /* Browse the queue starting from index */ |
| 2409 | if (count == LPFC_QUE_ACC_BROWSE) |
| 2410 | goto que_browse; |
| 2411 | |
| 2412 | /* Read a single entry from the queue */ |
| 2413 | len = lpfc_idiag_queacc_read_qe(pbuffer, len, pque, index); |
| 2414 | |
| 2415 | return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len); |
| 2416 | |
| 2417 | que_browse: |
| 2418 | |
| 2419 | /* Browse all entries from the queue */ |
| 2420 | last_index = idiag.offset.last_rd; |
| 2421 | index = last_index; |
| 2422 | |
| 2423 | while (len < LPFC_QUE_ACC_SIZE - pque->entry_size) { |
| 2424 | len = lpfc_idiag_queacc_read_qe(pbuffer, len, pque, index); |
| 2425 | index++; |
| 2426 | if (index > pque->entry_count - 1) |
| 2427 | break; |
| 2428 | } |
| 2429 | |
| 2430 | /* Set up the offset for next portion of pci cfg read */ |
| 2431 | if (index > pque->entry_count - 1) |
| 2432 | index = 0; |
| 2433 | idiag.offset.last_rd = index; |
| 2434 | |
| 2435 | return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len); |
| 2436 | } |
| 2437 | |
| 2438 | /** |
| 2439 | * lpfc_idiag_queacc_write - Syntax check and set up idiag queacc commands |
| 2440 | * @file: The file pointer to read from. |
| 2441 | * @buf: The buffer to copy the user data from. |
| 2442 | * @nbytes: The number of bytes to get. |
| 2443 | * @ppos: The position in the file to start reading from. |
| 2444 | * |
| 2445 | * This routine get the debugfs idiag command struct from user space and then |
| 2446 | * perform the syntax check for port queue read (dump) or write (set) command |
| 2447 | * accordingly. In the case of port queue read command, it sets up the command |
| 2448 | * in the idiag command struct for the following debugfs read operation. In |
| 2449 | * the case of port queue write operation, it executes the write operation |
| 2450 | * into the port queue entry accordingly. |
| 2451 | * |
| 2452 | * It returns the @nbytges passing in from debugfs user space when successful. |
| 2453 | * In case of error conditions, it returns proper error code back to the user |
| 2454 | * space. |
| 2455 | **/ |
| 2456 | static ssize_t |
| 2457 | lpfc_idiag_queacc_write(struct file *file, const char __user *buf, |
| 2458 | size_t nbytes, loff_t *ppos) |
| 2459 | { |
| 2460 | struct lpfc_debug *debug = file->private_data; |
| 2461 | struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private; |
| 2462 | uint32_t qidx, quetp, queid, index, count, offset, value; |
| 2463 | uint32_t *pentry; |
| 2464 | struct lpfc_queue *pque; |
| 2465 | int rc; |
| 2466 | |
| 2467 | /* This is a user write operation */ |
| 2468 | debug->op = LPFC_IDIAG_OP_WR; |
| 2469 | |
| 2470 | rc = lpfc_idiag_cmd_get(buf, nbytes, &idiag.cmd); |
| 2471 | if (rc < 0) |
| 2472 | return rc; |
| 2473 | |
| 2474 | /* Get and sanity check on command feilds */ |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 2475 | quetp = idiag.cmd.data[IDIAG_QUEACC_QUETP_INDX]; |
| 2476 | queid = idiag.cmd.data[IDIAG_QUEACC_QUEID_INDX]; |
| 2477 | index = idiag.cmd.data[IDIAG_QUEACC_INDEX_INDX]; |
| 2478 | count = idiag.cmd.data[IDIAG_QUEACC_COUNT_INDX]; |
| 2479 | offset = idiag.cmd.data[IDIAG_QUEACC_OFFST_INDX]; |
| 2480 | value = idiag.cmd.data[IDIAG_QUEACC_VALUE_INDX]; |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 2481 | |
| 2482 | /* Sanity check on command line arguments */ |
| 2483 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_QUEACC_WR || |
| 2484 | idiag.cmd.opcode == LPFC_IDIAG_CMD_QUEACC_ST || |
| 2485 | idiag.cmd.opcode == LPFC_IDIAG_CMD_QUEACC_CL) { |
| 2486 | if (rc != LPFC_QUE_ACC_WR_CMD_ARG) |
| 2487 | goto error_out; |
| 2488 | if (count != 1) |
| 2489 | goto error_out; |
| 2490 | } else if (idiag.cmd.opcode == LPFC_IDIAG_CMD_QUEACC_RD) { |
| 2491 | if (rc != LPFC_QUE_ACC_RD_CMD_ARG) |
| 2492 | goto error_out; |
| 2493 | } else |
| 2494 | goto error_out; |
| 2495 | |
| 2496 | switch (quetp) { |
| 2497 | case LPFC_IDIAG_EQ: |
James Smart | 67d1273 | 2012-08-03 12:36:13 -0400 | [diff] [blame] | 2498 | /* HBA event queue */ |
| 2499 | if (phba->sli4_hba.hba_eq) { |
| 2500 | for (qidx = 0; qidx < phba->cfg_fcp_io_channel; |
| 2501 | qidx++) { |
| 2502 | if (phba->sli4_hba.hba_eq[qidx] && |
| 2503 | phba->sli4_hba.hba_eq[qidx]->queue_id == |
James Smart | 2e90f4b | 2011-12-13 13:22:37 -0500 | [diff] [blame] | 2504 | queid) { |
| 2505 | /* Sanity check */ |
| 2506 | rc = lpfc_idiag_que_param_check( |
James Smart | 67d1273 | 2012-08-03 12:36:13 -0400 | [diff] [blame] | 2507 | phba->sli4_hba.hba_eq[qidx], |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 2508 | index, count); |
James Smart | 2e90f4b | 2011-12-13 13:22:37 -0500 | [diff] [blame] | 2509 | if (rc) |
| 2510 | goto error_out; |
| 2511 | idiag.ptr_private = |
James Smart | 67d1273 | 2012-08-03 12:36:13 -0400 | [diff] [blame] | 2512 | phba->sli4_hba.hba_eq[qidx]; |
James Smart | 2e90f4b | 2011-12-13 13:22:37 -0500 | [diff] [blame] | 2513 | goto pass_check; |
| 2514 | } |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 2515 | } |
| 2516 | } |
| 2517 | goto error_out; |
| 2518 | break; |
| 2519 | case LPFC_IDIAG_CQ: |
| 2520 | /* MBX complete queue */ |
James Smart | 2e90f4b | 2011-12-13 13:22:37 -0500 | [diff] [blame] | 2521 | if (phba->sli4_hba.mbx_cq && |
| 2522 | phba->sli4_hba.mbx_cq->queue_id == queid) { |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 2523 | /* Sanity check */ |
| 2524 | rc = lpfc_idiag_que_param_check( |
| 2525 | phba->sli4_hba.mbx_cq, index, count); |
| 2526 | if (rc) |
| 2527 | goto error_out; |
| 2528 | idiag.ptr_private = phba->sli4_hba.mbx_cq; |
| 2529 | goto pass_check; |
| 2530 | } |
| 2531 | /* ELS complete queue */ |
James Smart | 2e90f4b | 2011-12-13 13:22:37 -0500 | [diff] [blame] | 2532 | if (phba->sli4_hba.els_cq && |
| 2533 | phba->sli4_hba.els_cq->queue_id == queid) { |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 2534 | /* Sanity check */ |
| 2535 | rc = lpfc_idiag_que_param_check( |
| 2536 | phba->sli4_hba.els_cq, index, count); |
| 2537 | if (rc) |
| 2538 | goto error_out; |
| 2539 | idiag.ptr_private = phba->sli4_hba.els_cq; |
| 2540 | goto pass_check; |
| 2541 | } |
| 2542 | /* FCP complete queue */ |
James Smart | 2e90f4b | 2011-12-13 13:22:37 -0500 | [diff] [blame] | 2543 | if (phba->sli4_hba.fcp_cq) { |
| 2544 | qidx = 0; |
| 2545 | do { |
| 2546 | if (phba->sli4_hba.fcp_cq[qidx] && |
| 2547 | phba->sli4_hba.fcp_cq[qidx]->queue_id == |
| 2548 | queid) { |
| 2549 | /* Sanity check */ |
| 2550 | rc = lpfc_idiag_que_param_check( |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 2551 | phba->sli4_hba.fcp_cq[qidx], |
| 2552 | index, count); |
James Smart | 2e90f4b | 2011-12-13 13:22:37 -0500 | [diff] [blame] | 2553 | if (rc) |
| 2554 | goto error_out; |
| 2555 | idiag.ptr_private = |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 2556 | phba->sli4_hba.fcp_cq[qidx]; |
James Smart | 2e90f4b | 2011-12-13 13:22:37 -0500 | [diff] [blame] | 2557 | goto pass_check; |
| 2558 | } |
James Smart | 67d1273 | 2012-08-03 12:36:13 -0400 | [diff] [blame] | 2559 | } while (++qidx < phba->cfg_fcp_io_channel); |
James Smart | 2e90f4b | 2011-12-13 13:22:37 -0500 | [diff] [blame] | 2560 | } |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 2561 | goto error_out; |
| 2562 | break; |
| 2563 | case LPFC_IDIAG_MQ: |
| 2564 | /* MBX work queue */ |
James Smart | 2e90f4b | 2011-12-13 13:22:37 -0500 | [diff] [blame] | 2565 | if (phba->sli4_hba.mbx_wq && |
| 2566 | phba->sli4_hba.mbx_wq->queue_id == queid) { |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 2567 | /* Sanity check */ |
| 2568 | rc = lpfc_idiag_que_param_check( |
| 2569 | phba->sli4_hba.mbx_wq, index, count); |
| 2570 | if (rc) |
| 2571 | goto error_out; |
| 2572 | idiag.ptr_private = phba->sli4_hba.mbx_wq; |
| 2573 | goto pass_check; |
| 2574 | } |
James Smart | 2e90f4b | 2011-12-13 13:22:37 -0500 | [diff] [blame] | 2575 | goto error_out; |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 2576 | break; |
| 2577 | case LPFC_IDIAG_WQ: |
| 2578 | /* ELS work queue */ |
James Smart | 2e90f4b | 2011-12-13 13:22:37 -0500 | [diff] [blame] | 2579 | if (phba->sli4_hba.els_wq && |
| 2580 | phba->sli4_hba.els_wq->queue_id == queid) { |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 2581 | /* Sanity check */ |
| 2582 | rc = lpfc_idiag_que_param_check( |
| 2583 | phba->sli4_hba.els_wq, index, count); |
| 2584 | if (rc) |
| 2585 | goto error_out; |
| 2586 | idiag.ptr_private = phba->sli4_hba.els_wq; |
| 2587 | goto pass_check; |
| 2588 | } |
| 2589 | /* FCP work queue */ |
James Smart | 2e90f4b | 2011-12-13 13:22:37 -0500 | [diff] [blame] | 2590 | if (phba->sli4_hba.fcp_wq) { |
James Smart | 67d1273 | 2012-08-03 12:36:13 -0400 | [diff] [blame] | 2591 | for (qidx = 0; qidx < phba->cfg_fcp_io_channel; |
| 2592 | qidx++) { |
James Smart | 2e90f4b | 2011-12-13 13:22:37 -0500 | [diff] [blame] | 2593 | if (!phba->sli4_hba.fcp_wq[qidx]) |
| 2594 | continue; |
| 2595 | if (phba->sli4_hba.fcp_wq[qidx]->queue_id == |
| 2596 | queid) { |
| 2597 | /* Sanity check */ |
| 2598 | rc = lpfc_idiag_que_param_check( |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 2599 | phba->sli4_hba.fcp_wq[qidx], |
| 2600 | index, count); |
James Smart | 2e90f4b | 2011-12-13 13:22:37 -0500 | [diff] [blame] | 2601 | if (rc) |
| 2602 | goto error_out; |
| 2603 | idiag.ptr_private = |
| 2604 | phba->sli4_hba.fcp_wq[qidx]; |
| 2605 | goto pass_check; |
| 2606 | } |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 2607 | } |
| 2608 | } |
| 2609 | goto error_out; |
| 2610 | break; |
| 2611 | case LPFC_IDIAG_RQ: |
| 2612 | /* HDR queue */ |
James Smart | 2e90f4b | 2011-12-13 13:22:37 -0500 | [diff] [blame] | 2613 | if (phba->sli4_hba.hdr_rq && |
| 2614 | phba->sli4_hba.hdr_rq->queue_id == queid) { |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 2615 | /* Sanity check */ |
| 2616 | rc = lpfc_idiag_que_param_check( |
| 2617 | phba->sli4_hba.hdr_rq, index, count); |
| 2618 | if (rc) |
| 2619 | goto error_out; |
| 2620 | idiag.ptr_private = phba->sli4_hba.hdr_rq; |
| 2621 | goto pass_check; |
| 2622 | } |
| 2623 | /* DAT queue */ |
James Smart | 2e90f4b | 2011-12-13 13:22:37 -0500 | [diff] [blame] | 2624 | if (phba->sli4_hba.dat_rq && |
| 2625 | phba->sli4_hba.dat_rq->queue_id == queid) { |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 2626 | /* Sanity check */ |
| 2627 | rc = lpfc_idiag_que_param_check( |
| 2628 | phba->sli4_hba.dat_rq, index, count); |
| 2629 | if (rc) |
| 2630 | goto error_out; |
| 2631 | idiag.ptr_private = phba->sli4_hba.dat_rq; |
| 2632 | goto pass_check; |
| 2633 | } |
| 2634 | goto error_out; |
| 2635 | break; |
| 2636 | default: |
| 2637 | goto error_out; |
| 2638 | break; |
| 2639 | } |
| 2640 | |
| 2641 | pass_check: |
| 2642 | |
| 2643 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_QUEACC_RD) { |
| 2644 | if (count == LPFC_QUE_ACC_BROWSE) |
| 2645 | idiag.offset.last_rd = index; |
| 2646 | } |
| 2647 | |
| 2648 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_QUEACC_WR || |
| 2649 | idiag.cmd.opcode == LPFC_IDIAG_CMD_QUEACC_ST || |
| 2650 | idiag.cmd.opcode == LPFC_IDIAG_CMD_QUEACC_CL) { |
| 2651 | /* Additional sanity checks on write operation */ |
| 2652 | pque = (struct lpfc_queue *)idiag.ptr_private; |
| 2653 | if (offset > pque->entry_size/sizeof(uint32_t) - 1) |
| 2654 | goto error_out; |
| 2655 | pentry = pque->qe[index].address; |
| 2656 | pentry += offset; |
| 2657 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_QUEACC_WR) |
| 2658 | *pentry = value; |
| 2659 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_QUEACC_ST) |
| 2660 | *pentry |= value; |
| 2661 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_QUEACC_CL) |
| 2662 | *pentry &= ~value; |
| 2663 | } |
| 2664 | return nbytes; |
| 2665 | |
| 2666 | error_out: |
| 2667 | /* Clean out command structure on command error out */ |
| 2668 | memset(&idiag, 0, sizeof(idiag)); |
| 2669 | return -EINVAL; |
| 2670 | } |
| 2671 | |
| 2672 | /** |
| 2673 | * lpfc_idiag_drbacc_read_reg - idiag debugfs read a doorbell register |
| 2674 | * @phba: The pointer to hba structure. |
| 2675 | * @pbuffer: The pointer to the buffer to copy the data to. |
| 2676 | * @len: The lenght of bytes to copied. |
| 2677 | * @drbregid: The id to doorbell registers. |
| 2678 | * |
| 2679 | * Description: |
| 2680 | * This routine reads a doorbell register and copies its content to the |
| 2681 | * user buffer pointed to by @pbuffer. |
| 2682 | * |
| 2683 | * Returns: |
| 2684 | * This function returns the amount of data that was copied into @pbuffer. |
| 2685 | **/ |
| 2686 | static int |
| 2687 | lpfc_idiag_drbacc_read_reg(struct lpfc_hba *phba, char *pbuffer, |
| 2688 | int len, uint32_t drbregid) |
| 2689 | { |
| 2690 | |
| 2691 | if (!pbuffer) |
| 2692 | return 0; |
| 2693 | |
| 2694 | switch (drbregid) { |
| 2695 | case LPFC_DRB_EQCQ: |
| 2696 | len += snprintf(pbuffer+len, LPFC_DRB_ACC_BUF_SIZE-len, |
| 2697 | "EQCQ-DRB-REG: 0x%08x\n", |
| 2698 | readl(phba->sli4_hba.EQCQDBregaddr)); |
| 2699 | break; |
| 2700 | case LPFC_DRB_MQ: |
| 2701 | len += snprintf(pbuffer+len, LPFC_DRB_ACC_BUF_SIZE-len, |
| 2702 | "MQ-DRB-REG: 0x%08x\n", |
| 2703 | readl(phba->sli4_hba.MQDBregaddr)); |
| 2704 | break; |
| 2705 | case LPFC_DRB_WQ: |
| 2706 | len += snprintf(pbuffer+len, LPFC_DRB_ACC_BUF_SIZE-len, |
| 2707 | "WQ-DRB-REG: 0x%08x\n", |
| 2708 | readl(phba->sli4_hba.WQDBregaddr)); |
| 2709 | break; |
| 2710 | case LPFC_DRB_RQ: |
| 2711 | len += snprintf(pbuffer+len, LPFC_DRB_ACC_BUF_SIZE-len, |
| 2712 | "RQ-DRB-REG: 0x%08x\n", |
| 2713 | readl(phba->sli4_hba.RQDBregaddr)); |
| 2714 | break; |
| 2715 | default: |
| 2716 | break; |
| 2717 | } |
| 2718 | |
| 2719 | return len; |
| 2720 | } |
| 2721 | |
| 2722 | /** |
| 2723 | * lpfc_idiag_drbacc_read - idiag debugfs read port doorbell |
| 2724 | * @file: The file pointer to read from. |
| 2725 | * @buf: The buffer to copy the data to. |
| 2726 | * @nbytes: The number of bytes to read. |
| 2727 | * @ppos: The position in the file to start reading from. |
| 2728 | * |
| 2729 | * Description: |
| 2730 | * This routine reads data from the @phba device doorbell register according |
| 2731 | * to the idiag command, and copies to user @buf. Depending on the doorbell |
| 2732 | * register read command setup, it does either a single doorbell register |
| 2733 | * read or dump all doorbell registers. |
| 2734 | * |
| 2735 | * Returns: |
| 2736 | * This function returns the amount of data that was read (this could be less |
| 2737 | * than @nbytes if the end of the file was reached) or a negative error value. |
| 2738 | **/ |
| 2739 | static ssize_t |
| 2740 | lpfc_idiag_drbacc_read(struct file *file, char __user *buf, size_t nbytes, |
| 2741 | loff_t *ppos) |
| 2742 | { |
| 2743 | struct lpfc_debug *debug = file->private_data; |
| 2744 | struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private; |
| 2745 | uint32_t drb_reg_id, i; |
| 2746 | char *pbuffer; |
| 2747 | int len = 0; |
| 2748 | |
| 2749 | /* This is a user read operation */ |
| 2750 | debug->op = LPFC_IDIAG_OP_RD; |
| 2751 | |
| 2752 | if (!debug->buffer) |
| 2753 | debug->buffer = kmalloc(LPFC_DRB_ACC_BUF_SIZE, GFP_KERNEL); |
| 2754 | if (!debug->buffer) |
| 2755 | return 0; |
| 2756 | pbuffer = debug->buffer; |
| 2757 | |
| 2758 | if (*ppos) |
| 2759 | return 0; |
| 2760 | |
| 2761 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_DRBACC_RD) |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 2762 | drb_reg_id = idiag.cmd.data[IDIAG_DRBACC_REGID_INDX]; |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 2763 | else |
| 2764 | return 0; |
| 2765 | |
| 2766 | if (drb_reg_id == LPFC_DRB_ACC_ALL) |
| 2767 | for (i = 1; i <= LPFC_DRB_MAX; i++) |
| 2768 | len = lpfc_idiag_drbacc_read_reg(phba, |
| 2769 | pbuffer, len, i); |
| 2770 | else |
| 2771 | len = lpfc_idiag_drbacc_read_reg(phba, |
| 2772 | pbuffer, len, drb_reg_id); |
| 2773 | |
| 2774 | return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len); |
| 2775 | } |
| 2776 | |
| 2777 | /** |
| 2778 | * lpfc_idiag_drbacc_write - Syntax check and set up idiag drbacc commands |
| 2779 | * @file: The file pointer to read from. |
| 2780 | * @buf: The buffer to copy the user data from. |
| 2781 | * @nbytes: The number of bytes to get. |
| 2782 | * @ppos: The position in the file to start reading from. |
| 2783 | * |
| 2784 | * This routine get the debugfs idiag command struct from user space and then |
| 2785 | * perform the syntax check for port doorbell register read (dump) or write |
| 2786 | * (set) command accordingly. In the case of port queue read command, it sets |
| 2787 | * up the command in the idiag command struct for the following debugfs read |
| 2788 | * operation. In the case of port doorbell register write operation, it |
| 2789 | * executes the write operation into the port doorbell register accordingly. |
| 2790 | * |
| 2791 | * It returns the @nbytges passing in from debugfs user space when successful. |
| 2792 | * In case of error conditions, it returns proper error code back to the user |
| 2793 | * space. |
| 2794 | **/ |
| 2795 | static ssize_t |
| 2796 | lpfc_idiag_drbacc_write(struct file *file, const char __user *buf, |
| 2797 | size_t nbytes, loff_t *ppos) |
| 2798 | { |
| 2799 | struct lpfc_debug *debug = file->private_data; |
| 2800 | struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private; |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 2801 | uint32_t drb_reg_id, value, reg_val = 0; |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 2802 | void __iomem *drb_reg; |
| 2803 | int rc; |
| 2804 | |
| 2805 | /* This is a user write operation */ |
| 2806 | debug->op = LPFC_IDIAG_OP_WR; |
| 2807 | |
| 2808 | rc = lpfc_idiag_cmd_get(buf, nbytes, &idiag.cmd); |
| 2809 | if (rc < 0) |
| 2810 | return rc; |
| 2811 | |
| 2812 | /* Sanity check on command line arguments */ |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 2813 | drb_reg_id = idiag.cmd.data[IDIAG_DRBACC_REGID_INDX]; |
| 2814 | value = idiag.cmd.data[IDIAG_DRBACC_VALUE_INDX]; |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 2815 | |
| 2816 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_DRBACC_WR || |
| 2817 | idiag.cmd.opcode == LPFC_IDIAG_CMD_DRBACC_ST || |
| 2818 | idiag.cmd.opcode == LPFC_IDIAG_CMD_DRBACC_CL) { |
| 2819 | if (rc != LPFC_DRB_ACC_WR_CMD_ARG) |
| 2820 | goto error_out; |
| 2821 | if (drb_reg_id > LPFC_DRB_MAX) |
| 2822 | goto error_out; |
| 2823 | } else if (idiag.cmd.opcode == LPFC_IDIAG_CMD_DRBACC_RD) { |
| 2824 | if (rc != LPFC_DRB_ACC_RD_CMD_ARG) |
| 2825 | goto error_out; |
| 2826 | if ((drb_reg_id > LPFC_DRB_MAX) && |
| 2827 | (drb_reg_id != LPFC_DRB_ACC_ALL)) |
| 2828 | goto error_out; |
| 2829 | } else |
| 2830 | goto error_out; |
| 2831 | |
| 2832 | /* Perform the write access operation */ |
| 2833 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_DRBACC_WR || |
| 2834 | idiag.cmd.opcode == LPFC_IDIAG_CMD_DRBACC_ST || |
| 2835 | idiag.cmd.opcode == LPFC_IDIAG_CMD_DRBACC_CL) { |
| 2836 | switch (drb_reg_id) { |
| 2837 | case LPFC_DRB_EQCQ: |
| 2838 | drb_reg = phba->sli4_hba.EQCQDBregaddr; |
| 2839 | break; |
| 2840 | case LPFC_DRB_MQ: |
| 2841 | drb_reg = phba->sli4_hba.MQDBregaddr; |
| 2842 | break; |
| 2843 | case LPFC_DRB_WQ: |
| 2844 | drb_reg = phba->sli4_hba.WQDBregaddr; |
| 2845 | break; |
| 2846 | case LPFC_DRB_RQ: |
| 2847 | drb_reg = phba->sli4_hba.RQDBregaddr; |
| 2848 | break; |
| 2849 | default: |
| 2850 | goto error_out; |
| 2851 | } |
| 2852 | |
| 2853 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_DRBACC_WR) |
| 2854 | reg_val = value; |
| 2855 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_DRBACC_ST) { |
| 2856 | reg_val = readl(drb_reg); |
| 2857 | reg_val |= value; |
| 2858 | } |
| 2859 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_DRBACC_CL) { |
| 2860 | reg_val = readl(drb_reg); |
| 2861 | reg_val &= ~value; |
| 2862 | } |
| 2863 | writel(reg_val, drb_reg); |
| 2864 | readl(drb_reg); /* flush */ |
| 2865 | } |
| 2866 | return nbytes; |
| 2867 | |
| 2868 | error_out: |
| 2869 | /* Clean out command structure on command error out */ |
| 2870 | memset(&idiag, 0, sizeof(idiag)); |
| 2871 | return -EINVAL; |
| 2872 | } |
| 2873 | |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 2874 | /** |
| 2875 | * lpfc_idiag_ctlacc_read_reg - idiag debugfs read a control registers |
| 2876 | * @phba: The pointer to hba structure. |
| 2877 | * @pbuffer: The pointer to the buffer to copy the data to. |
| 2878 | * @len: The lenght of bytes to copied. |
| 2879 | * @drbregid: The id to doorbell registers. |
| 2880 | * |
| 2881 | * Description: |
| 2882 | * This routine reads a control register and copies its content to the |
| 2883 | * user buffer pointed to by @pbuffer. |
| 2884 | * |
| 2885 | * Returns: |
| 2886 | * This function returns the amount of data that was copied into @pbuffer. |
| 2887 | **/ |
| 2888 | static int |
| 2889 | lpfc_idiag_ctlacc_read_reg(struct lpfc_hba *phba, char *pbuffer, |
| 2890 | int len, uint32_t ctlregid) |
| 2891 | { |
| 2892 | |
| 2893 | if (!pbuffer) |
| 2894 | return 0; |
| 2895 | |
| 2896 | switch (ctlregid) { |
| 2897 | case LPFC_CTL_PORT_SEM: |
| 2898 | len += snprintf(pbuffer+len, LPFC_CTL_ACC_BUF_SIZE-len, |
| 2899 | "Port SemReg: 0x%08x\n", |
| 2900 | readl(phba->sli4_hba.conf_regs_memmap_p + |
| 2901 | LPFC_CTL_PORT_SEM_OFFSET)); |
| 2902 | break; |
| 2903 | case LPFC_CTL_PORT_STA: |
| 2904 | len += snprintf(pbuffer+len, LPFC_CTL_ACC_BUF_SIZE-len, |
| 2905 | "Port StaReg: 0x%08x\n", |
| 2906 | readl(phba->sli4_hba.conf_regs_memmap_p + |
| 2907 | LPFC_CTL_PORT_STA_OFFSET)); |
| 2908 | break; |
| 2909 | case LPFC_CTL_PORT_CTL: |
| 2910 | len += snprintf(pbuffer+len, LPFC_CTL_ACC_BUF_SIZE-len, |
| 2911 | "Port CtlReg: 0x%08x\n", |
| 2912 | readl(phba->sli4_hba.conf_regs_memmap_p + |
| 2913 | LPFC_CTL_PORT_CTL_OFFSET)); |
| 2914 | break; |
| 2915 | case LPFC_CTL_PORT_ER1: |
| 2916 | len += snprintf(pbuffer+len, LPFC_CTL_ACC_BUF_SIZE-len, |
| 2917 | "Port Er1Reg: 0x%08x\n", |
| 2918 | readl(phba->sli4_hba.conf_regs_memmap_p + |
| 2919 | LPFC_CTL_PORT_ER1_OFFSET)); |
| 2920 | break; |
| 2921 | case LPFC_CTL_PORT_ER2: |
| 2922 | len += snprintf(pbuffer+len, LPFC_CTL_ACC_BUF_SIZE-len, |
| 2923 | "Port Er2Reg: 0x%08x\n", |
| 2924 | readl(phba->sli4_hba.conf_regs_memmap_p + |
| 2925 | LPFC_CTL_PORT_ER2_OFFSET)); |
| 2926 | break; |
| 2927 | case LPFC_CTL_PDEV_CTL: |
| 2928 | len += snprintf(pbuffer+len, LPFC_CTL_ACC_BUF_SIZE-len, |
| 2929 | "PDev CtlReg: 0x%08x\n", |
| 2930 | readl(phba->sli4_hba.conf_regs_memmap_p + |
| 2931 | LPFC_CTL_PDEV_CTL_OFFSET)); |
| 2932 | break; |
| 2933 | default: |
| 2934 | break; |
| 2935 | } |
| 2936 | return len; |
| 2937 | } |
| 2938 | |
| 2939 | /** |
| 2940 | * lpfc_idiag_ctlacc_read - idiag debugfs read port and device control register |
| 2941 | * @file: The file pointer to read from. |
| 2942 | * @buf: The buffer to copy the data to. |
| 2943 | * @nbytes: The number of bytes to read. |
| 2944 | * @ppos: The position in the file to start reading from. |
| 2945 | * |
| 2946 | * Description: |
| 2947 | * This routine reads data from the @phba port and device registers according |
| 2948 | * to the idiag command, and copies to user @buf. |
| 2949 | * |
| 2950 | * Returns: |
| 2951 | * This function returns the amount of data that was read (this could be less |
| 2952 | * than @nbytes if the end of the file was reached) or a negative error value. |
| 2953 | **/ |
| 2954 | static ssize_t |
| 2955 | lpfc_idiag_ctlacc_read(struct file *file, char __user *buf, size_t nbytes, |
| 2956 | loff_t *ppos) |
| 2957 | { |
| 2958 | struct lpfc_debug *debug = file->private_data; |
| 2959 | struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private; |
| 2960 | uint32_t ctl_reg_id, i; |
| 2961 | char *pbuffer; |
| 2962 | int len = 0; |
| 2963 | |
| 2964 | /* This is a user read operation */ |
| 2965 | debug->op = LPFC_IDIAG_OP_RD; |
| 2966 | |
| 2967 | if (!debug->buffer) |
| 2968 | debug->buffer = kmalloc(LPFC_CTL_ACC_BUF_SIZE, GFP_KERNEL); |
| 2969 | if (!debug->buffer) |
| 2970 | return 0; |
| 2971 | pbuffer = debug->buffer; |
| 2972 | |
| 2973 | if (*ppos) |
| 2974 | return 0; |
| 2975 | |
| 2976 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_CTLACC_RD) |
| 2977 | ctl_reg_id = idiag.cmd.data[IDIAG_CTLACC_REGID_INDX]; |
| 2978 | else |
| 2979 | return 0; |
| 2980 | |
| 2981 | if (ctl_reg_id == LPFC_CTL_ACC_ALL) |
| 2982 | for (i = 1; i <= LPFC_CTL_MAX; i++) |
| 2983 | len = lpfc_idiag_ctlacc_read_reg(phba, |
| 2984 | pbuffer, len, i); |
| 2985 | else |
| 2986 | len = lpfc_idiag_ctlacc_read_reg(phba, |
| 2987 | pbuffer, len, ctl_reg_id); |
| 2988 | |
| 2989 | return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len); |
| 2990 | } |
| 2991 | |
| 2992 | /** |
| 2993 | * lpfc_idiag_ctlacc_write - Syntax check and set up idiag ctlacc commands |
| 2994 | * @file: The file pointer to read from. |
| 2995 | * @buf: The buffer to copy the user data from. |
| 2996 | * @nbytes: The number of bytes to get. |
| 2997 | * @ppos: The position in the file to start reading from. |
| 2998 | * |
| 2999 | * This routine get the debugfs idiag command struct from user space and then |
| 3000 | * perform the syntax check for port and device control register read (dump) |
| 3001 | * or write (set) command accordingly. |
| 3002 | * |
| 3003 | * It returns the @nbytges passing in from debugfs user space when successful. |
| 3004 | * In case of error conditions, it returns proper error code back to the user |
| 3005 | * space. |
| 3006 | **/ |
| 3007 | static ssize_t |
| 3008 | lpfc_idiag_ctlacc_write(struct file *file, const char __user *buf, |
| 3009 | size_t nbytes, loff_t *ppos) |
| 3010 | { |
| 3011 | struct lpfc_debug *debug = file->private_data; |
| 3012 | struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private; |
| 3013 | uint32_t ctl_reg_id, value, reg_val = 0; |
| 3014 | void __iomem *ctl_reg; |
| 3015 | int rc; |
| 3016 | |
| 3017 | /* This is a user write operation */ |
| 3018 | debug->op = LPFC_IDIAG_OP_WR; |
| 3019 | |
| 3020 | rc = lpfc_idiag_cmd_get(buf, nbytes, &idiag.cmd); |
| 3021 | if (rc < 0) |
| 3022 | return rc; |
| 3023 | |
| 3024 | /* Sanity check on command line arguments */ |
| 3025 | ctl_reg_id = idiag.cmd.data[IDIAG_CTLACC_REGID_INDX]; |
| 3026 | value = idiag.cmd.data[IDIAG_CTLACC_VALUE_INDX]; |
| 3027 | |
| 3028 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_CTLACC_WR || |
| 3029 | idiag.cmd.opcode == LPFC_IDIAG_CMD_CTLACC_ST || |
| 3030 | idiag.cmd.opcode == LPFC_IDIAG_CMD_CTLACC_CL) { |
| 3031 | if (rc != LPFC_CTL_ACC_WR_CMD_ARG) |
| 3032 | goto error_out; |
| 3033 | if (ctl_reg_id > LPFC_CTL_MAX) |
| 3034 | goto error_out; |
| 3035 | } else if (idiag.cmd.opcode == LPFC_IDIAG_CMD_CTLACC_RD) { |
| 3036 | if (rc != LPFC_CTL_ACC_RD_CMD_ARG) |
| 3037 | goto error_out; |
| 3038 | if ((ctl_reg_id > LPFC_CTL_MAX) && |
| 3039 | (ctl_reg_id != LPFC_CTL_ACC_ALL)) |
| 3040 | goto error_out; |
| 3041 | } else |
| 3042 | goto error_out; |
| 3043 | |
| 3044 | /* Perform the write access operation */ |
| 3045 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_CTLACC_WR || |
| 3046 | idiag.cmd.opcode == LPFC_IDIAG_CMD_CTLACC_ST || |
| 3047 | idiag.cmd.opcode == LPFC_IDIAG_CMD_CTLACC_CL) { |
| 3048 | switch (ctl_reg_id) { |
| 3049 | case LPFC_CTL_PORT_SEM: |
| 3050 | ctl_reg = phba->sli4_hba.conf_regs_memmap_p + |
| 3051 | LPFC_CTL_PORT_SEM_OFFSET; |
| 3052 | break; |
| 3053 | case LPFC_CTL_PORT_STA: |
| 3054 | ctl_reg = phba->sli4_hba.conf_regs_memmap_p + |
| 3055 | LPFC_CTL_PORT_STA_OFFSET; |
| 3056 | break; |
| 3057 | case LPFC_CTL_PORT_CTL: |
| 3058 | ctl_reg = phba->sli4_hba.conf_regs_memmap_p + |
| 3059 | LPFC_CTL_PORT_CTL_OFFSET; |
| 3060 | break; |
| 3061 | case LPFC_CTL_PORT_ER1: |
| 3062 | ctl_reg = phba->sli4_hba.conf_regs_memmap_p + |
| 3063 | LPFC_CTL_PORT_ER1_OFFSET; |
| 3064 | break; |
| 3065 | case LPFC_CTL_PORT_ER2: |
| 3066 | ctl_reg = phba->sli4_hba.conf_regs_memmap_p + |
| 3067 | LPFC_CTL_PORT_ER2_OFFSET; |
| 3068 | break; |
| 3069 | case LPFC_CTL_PDEV_CTL: |
| 3070 | ctl_reg = phba->sli4_hba.conf_regs_memmap_p + |
| 3071 | LPFC_CTL_PDEV_CTL_OFFSET; |
| 3072 | break; |
| 3073 | default: |
| 3074 | goto error_out; |
| 3075 | } |
| 3076 | |
| 3077 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_CTLACC_WR) |
| 3078 | reg_val = value; |
| 3079 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_CTLACC_ST) { |
| 3080 | reg_val = readl(ctl_reg); |
| 3081 | reg_val |= value; |
| 3082 | } |
| 3083 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_CTLACC_CL) { |
| 3084 | reg_val = readl(ctl_reg); |
| 3085 | reg_val &= ~value; |
| 3086 | } |
| 3087 | writel(reg_val, ctl_reg); |
| 3088 | readl(ctl_reg); /* flush */ |
| 3089 | } |
| 3090 | return nbytes; |
| 3091 | |
| 3092 | error_out: |
| 3093 | /* Clean out command structure on command error out */ |
| 3094 | memset(&idiag, 0, sizeof(idiag)); |
| 3095 | return -EINVAL; |
| 3096 | } |
| 3097 | |
| 3098 | /** |
| 3099 | * lpfc_idiag_mbxacc_get_setup - idiag debugfs get mailbox access setup |
| 3100 | * @phba: Pointer to HBA context object. |
| 3101 | * @pbuffer: Pointer to data buffer. |
| 3102 | * |
| 3103 | * Description: |
| 3104 | * This routine gets the driver mailbox access debugfs setup information. |
| 3105 | * |
| 3106 | * Returns: |
| 3107 | * This function returns the amount of data that was read (this could be less |
| 3108 | * than @nbytes if the end of the file was reached) or a negative error value. |
| 3109 | **/ |
| 3110 | static int |
| 3111 | lpfc_idiag_mbxacc_get_setup(struct lpfc_hba *phba, char *pbuffer) |
| 3112 | { |
| 3113 | uint32_t mbx_dump_map, mbx_dump_cnt, mbx_word_cnt, mbx_mbox_cmd; |
| 3114 | int len = 0; |
| 3115 | |
| 3116 | mbx_mbox_cmd = idiag.cmd.data[IDIAG_MBXACC_MBCMD_INDX]; |
| 3117 | mbx_dump_map = idiag.cmd.data[IDIAG_MBXACC_DPMAP_INDX]; |
| 3118 | mbx_dump_cnt = idiag.cmd.data[IDIAG_MBXACC_DPCNT_INDX]; |
| 3119 | mbx_word_cnt = idiag.cmd.data[IDIAG_MBXACC_WDCNT_INDX]; |
| 3120 | |
| 3121 | len += snprintf(pbuffer+len, LPFC_MBX_ACC_BUF_SIZE-len, |
| 3122 | "mbx_dump_map: 0x%08x\n", mbx_dump_map); |
| 3123 | len += snprintf(pbuffer+len, LPFC_MBX_ACC_BUF_SIZE-len, |
| 3124 | "mbx_dump_cnt: %04d\n", mbx_dump_cnt); |
| 3125 | len += snprintf(pbuffer+len, LPFC_MBX_ACC_BUF_SIZE-len, |
| 3126 | "mbx_word_cnt: %04d\n", mbx_word_cnt); |
| 3127 | len += snprintf(pbuffer+len, LPFC_MBX_ACC_BUF_SIZE-len, |
| 3128 | "mbx_mbox_cmd: 0x%02x\n", mbx_mbox_cmd); |
| 3129 | |
| 3130 | return len; |
| 3131 | } |
| 3132 | |
| 3133 | /** |
| 3134 | * lpfc_idiag_mbxacc_read - idiag debugfs read on mailbox access |
| 3135 | * @file: The file pointer to read from. |
| 3136 | * @buf: The buffer to copy the data to. |
| 3137 | * @nbytes: The number of bytes to read. |
| 3138 | * @ppos: The position in the file to start reading from. |
| 3139 | * |
| 3140 | * Description: |
| 3141 | * This routine reads data from the @phba driver mailbox access debugfs setup |
| 3142 | * information. |
| 3143 | * |
| 3144 | * Returns: |
| 3145 | * This function returns the amount of data that was read (this could be less |
| 3146 | * than @nbytes if the end of the file was reached) or a negative error value. |
| 3147 | **/ |
| 3148 | static ssize_t |
| 3149 | lpfc_idiag_mbxacc_read(struct file *file, char __user *buf, size_t nbytes, |
| 3150 | loff_t *ppos) |
| 3151 | { |
| 3152 | struct lpfc_debug *debug = file->private_data; |
| 3153 | struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private; |
| 3154 | char *pbuffer; |
| 3155 | int len = 0; |
| 3156 | |
| 3157 | /* This is a user read operation */ |
| 3158 | debug->op = LPFC_IDIAG_OP_RD; |
| 3159 | |
| 3160 | if (!debug->buffer) |
| 3161 | debug->buffer = kmalloc(LPFC_MBX_ACC_BUF_SIZE, GFP_KERNEL); |
| 3162 | if (!debug->buffer) |
| 3163 | return 0; |
| 3164 | pbuffer = debug->buffer; |
| 3165 | |
| 3166 | if (*ppos) |
| 3167 | return 0; |
| 3168 | |
| 3169 | if ((idiag.cmd.opcode != LPFC_IDIAG_CMD_MBXACC_DP) && |
| 3170 | (idiag.cmd.opcode != LPFC_IDIAG_BSG_MBXACC_DP)) |
| 3171 | return 0; |
| 3172 | |
| 3173 | len = lpfc_idiag_mbxacc_get_setup(phba, pbuffer); |
| 3174 | |
| 3175 | return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len); |
| 3176 | } |
| 3177 | |
| 3178 | /** |
| 3179 | * lpfc_idiag_mbxacc_write - Syntax check and set up idiag mbxacc commands |
| 3180 | * @file: The file pointer to read from. |
| 3181 | * @buf: The buffer to copy the user data from. |
| 3182 | * @nbytes: The number of bytes to get. |
| 3183 | * @ppos: The position in the file to start reading from. |
| 3184 | * |
| 3185 | * This routine get the debugfs idiag command struct from user space and then |
| 3186 | * perform the syntax check for driver mailbox command (dump) and sets up the |
| 3187 | * necessary states in the idiag command struct accordingly. |
| 3188 | * |
| 3189 | * It returns the @nbytges passing in from debugfs user space when successful. |
| 3190 | * In case of error conditions, it returns proper error code back to the user |
| 3191 | * space. |
| 3192 | **/ |
| 3193 | static ssize_t |
| 3194 | lpfc_idiag_mbxacc_write(struct file *file, const char __user *buf, |
| 3195 | size_t nbytes, loff_t *ppos) |
| 3196 | { |
| 3197 | struct lpfc_debug *debug = file->private_data; |
| 3198 | uint32_t mbx_dump_map, mbx_dump_cnt, mbx_word_cnt, mbx_mbox_cmd; |
| 3199 | int rc; |
| 3200 | |
| 3201 | /* This is a user write operation */ |
| 3202 | debug->op = LPFC_IDIAG_OP_WR; |
| 3203 | |
| 3204 | rc = lpfc_idiag_cmd_get(buf, nbytes, &idiag.cmd); |
| 3205 | if (rc < 0) |
| 3206 | return rc; |
| 3207 | |
| 3208 | /* Sanity check on command line arguments */ |
| 3209 | mbx_mbox_cmd = idiag.cmd.data[IDIAG_MBXACC_MBCMD_INDX]; |
| 3210 | mbx_dump_map = idiag.cmd.data[IDIAG_MBXACC_DPMAP_INDX]; |
| 3211 | mbx_dump_cnt = idiag.cmd.data[IDIAG_MBXACC_DPCNT_INDX]; |
| 3212 | mbx_word_cnt = idiag.cmd.data[IDIAG_MBXACC_WDCNT_INDX]; |
| 3213 | |
| 3214 | if (idiag.cmd.opcode == LPFC_IDIAG_CMD_MBXACC_DP) { |
| 3215 | if (!(mbx_dump_map & LPFC_MBX_DMP_MBX_ALL)) |
| 3216 | goto error_out; |
| 3217 | if ((mbx_dump_map & ~LPFC_MBX_DMP_MBX_ALL) && |
| 3218 | (mbx_dump_map != LPFC_MBX_DMP_ALL)) |
| 3219 | goto error_out; |
| 3220 | if (mbx_word_cnt > sizeof(MAILBOX_t)) |
| 3221 | goto error_out; |
| 3222 | } else if (idiag.cmd.opcode == LPFC_IDIAG_BSG_MBXACC_DP) { |
| 3223 | if (!(mbx_dump_map & LPFC_BSG_DMP_MBX_ALL)) |
| 3224 | goto error_out; |
| 3225 | if ((mbx_dump_map & ~LPFC_BSG_DMP_MBX_ALL) && |
| 3226 | (mbx_dump_map != LPFC_MBX_DMP_ALL)) |
| 3227 | goto error_out; |
| 3228 | if (mbx_word_cnt > (BSG_MBOX_SIZE)/4) |
| 3229 | goto error_out; |
| 3230 | if (mbx_mbox_cmd != 0x9b) |
| 3231 | goto error_out; |
| 3232 | } else |
| 3233 | goto error_out; |
| 3234 | |
| 3235 | if (mbx_word_cnt == 0) |
| 3236 | goto error_out; |
| 3237 | if (rc != LPFC_MBX_DMP_ARG) |
| 3238 | goto error_out; |
| 3239 | if (mbx_mbox_cmd & ~0xff) |
| 3240 | goto error_out; |
| 3241 | |
| 3242 | /* condition for stop mailbox dump */ |
| 3243 | if (mbx_dump_cnt == 0) |
| 3244 | goto reset_out; |
| 3245 | |
| 3246 | return nbytes; |
| 3247 | |
| 3248 | reset_out: |
| 3249 | /* Clean out command structure on command error out */ |
| 3250 | memset(&idiag, 0, sizeof(idiag)); |
| 3251 | return nbytes; |
| 3252 | |
| 3253 | error_out: |
| 3254 | /* Clean out command structure on command error out */ |
| 3255 | memset(&idiag, 0, sizeof(idiag)); |
| 3256 | return -EINVAL; |
| 3257 | } |
| 3258 | |
| 3259 | /** |
| 3260 | * lpfc_idiag_extacc_avail_get - get the available extents information |
| 3261 | * @phba: pointer to lpfc hba data structure. |
| 3262 | * @pbuffer: pointer to internal buffer. |
| 3263 | * @len: length into the internal buffer data has been copied. |
| 3264 | * |
| 3265 | * Description: |
| 3266 | * This routine is to get the available extent information. |
| 3267 | * |
| 3268 | * Returns: |
| 3269 | * overall lenth of the data read into the internal buffer. |
| 3270 | **/ |
| 3271 | static int |
| 3272 | lpfc_idiag_extacc_avail_get(struct lpfc_hba *phba, char *pbuffer, int len) |
| 3273 | { |
| 3274 | uint16_t ext_cnt, ext_size; |
| 3275 | |
| 3276 | len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, |
| 3277 | "\nAvailable Extents Information:\n"); |
| 3278 | |
| 3279 | len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, |
| 3280 | "\tPort Available VPI extents: "); |
| 3281 | lpfc_sli4_get_avail_extnt_rsrc(phba, LPFC_RSC_TYPE_FCOE_VPI, |
| 3282 | &ext_cnt, &ext_size); |
| 3283 | len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, |
| 3284 | "Count %3d, Size %3d\n", ext_cnt, ext_size); |
| 3285 | |
| 3286 | len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, |
| 3287 | "\tPort Available VFI extents: "); |
| 3288 | lpfc_sli4_get_avail_extnt_rsrc(phba, LPFC_RSC_TYPE_FCOE_VFI, |
| 3289 | &ext_cnt, &ext_size); |
| 3290 | len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, |
| 3291 | "Count %3d, Size %3d\n", ext_cnt, ext_size); |
| 3292 | |
| 3293 | len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, |
| 3294 | "\tPort Available RPI extents: "); |
| 3295 | lpfc_sli4_get_avail_extnt_rsrc(phba, LPFC_RSC_TYPE_FCOE_RPI, |
| 3296 | &ext_cnt, &ext_size); |
| 3297 | len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, |
| 3298 | "Count %3d, Size %3d\n", ext_cnt, ext_size); |
| 3299 | |
| 3300 | len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, |
| 3301 | "\tPort Available XRI extents: "); |
| 3302 | lpfc_sli4_get_avail_extnt_rsrc(phba, LPFC_RSC_TYPE_FCOE_XRI, |
| 3303 | &ext_cnt, &ext_size); |
| 3304 | len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, |
| 3305 | "Count %3d, Size %3d\n", ext_cnt, ext_size); |
| 3306 | |
| 3307 | return len; |
| 3308 | } |
| 3309 | |
| 3310 | /** |
| 3311 | * lpfc_idiag_extacc_alloc_get - get the allocated extents information |
| 3312 | * @phba: pointer to lpfc hba data structure. |
| 3313 | * @pbuffer: pointer to internal buffer. |
| 3314 | * @len: length into the internal buffer data has been copied. |
| 3315 | * |
| 3316 | * Description: |
| 3317 | * This routine is to get the allocated extent information. |
| 3318 | * |
| 3319 | * Returns: |
| 3320 | * overall lenth of the data read into the internal buffer. |
| 3321 | **/ |
| 3322 | static int |
| 3323 | lpfc_idiag_extacc_alloc_get(struct lpfc_hba *phba, char *pbuffer, int len) |
| 3324 | { |
| 3325 | uint16_t ext_cnt, ext_size; |
| 3326 | int rc; |
| 3327 | |
| 3328 | len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, |
| 3329 | "\nAllocated Extents Information:\n"); |
| 3330 | |
| 3331 | len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, |
| 3332 | "\tHost Allocated VPI extents: "); |
| 3333 | rc = lpfc_sli4_get_allocated_extnts(phba, LPFC_RSC_TYPE_FCOE_VPI, |
| 3334 | &ext_cnt, &ext_size); |
| 3335 | if (!rc) |
| 3336 | len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, |
| 3337 | "Port %d Extent %3d, Size %3d\n", |
| 3338 | phba->brd_no, ext_cnt, ext_size); |
| 3339 | else |
| 3340 | len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, |
| 3341 | "N/A\n"); |
| 3342 | |
| 3343 | len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, |
| 3344 | "\tHost Allocated VFI extents: "); |
| 3345 | rc = lpfc_sli4_get_allocated_extnts(phba, LPFC_RSC_TYPE_FCOE_VFI, |
| 3346 | &ext_cnt, &ext_size); |
| 3347 | if (!rc) |
| 3348 | len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, |
| 3349 | "Port %d Extent %3d, Size %3d\n", |
| 3350 | phba->brd_no, ext_cnt, ext_size); |
| 3351 | else |
| 3352 | len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, |
| 3353 | "N/A\n"); |
| 3354 | |
| 3355 | len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, |
| 3356 | "\tHost Allocated RPI extents: "); |
| 3357 | rc = lpfc_sli4_get_allocated_extnts(phba, LPFC_RSC_TYPE_FCOE_RPI, |
| 3358 | &ext_cnt, &ext_size); |
| 3359 | if (!rc) |
| 3360 | len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, |
| 3361 | "Port %d Extent %3d, Size %3d\n", |
| 3362 | phba->brd_no, ext_cnt, ext_size); |
| 3363 | else |
| 3364 | len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, |
| 3365 | "N/A\n"); |
| 3366 | |
| 3367 | len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, |
| 3368 | "\tHost Allocated XRI extents: "); |
| 3369 | rc = lpfc_sli4_get_allocated_extnts(phba, LPFC_RSC_TYPE_FCOE_XRI, |
| 3370 | &ext_cnt, &ext_size); |
| 3371 | if (!rc) |
| 3372 | len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, |
| 3373 | "Port %d Extent %3d, Size %3d\n", |
| 3374 | phba->brd_no, ext_cnt, ext_size); |
| 3375 | else |
| 3376 | len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, |
| 3377 | "N/A\n"); |
| 3378 | |
| 3379 | return len; |
| 3380 | } |
| 3381 | |
| 3382 | /** |
| 3383 | * lpfc_idiag_extacc_drivr_get - get driver extent information |
| 3384 | * @phba: pointer to lpfc hba data structure. |
| 3385 | * @pbuffer: pointer to internal buffer. |
| 3386 | * @len: length into the internal buffer data has been copied. |
| 3387 | * |
| 3388 | * Description: |
| 3389 | * This routine is to get the driver extent information. |
| 3390 | * |
| 3391 | * Returns: |
| 3392 | * overall lenth of the data read into the internal buffer. |
| 3393 | **/ |
| 3394 | static int |
| 3395 | lpfc_idiag_extacc_drivr_get(struct lpfc_hba *phba, char *pbuffer, int len) |
| 3396 | { |
| 3397 | struct lpfc_rsrc_blks *rsrc_blks; |
| 3398 | int index; |
| 3399 | |
| 3400 | len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, |
| 3401 | "\nDriver Extents Information:\n"); |
| 3402 | |
| 3403 | len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, |
| 3404 | "\tVPI extents:\n"); |
| 3405 | index = 0; |
| 3406 | list_for_each_entry(rsrc_blks, &phba->lpfc_vpi_blk_list, list) { |
| 3407 | len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, |
| 3408 | "\t\tBlock %3d: Start %4d, Count %4d\n", |
| 3409 | index, rsrc_blks->rsrc_start, |
| 3410 | rsrc_blks->rsrc_size); |
| 3411 | index++; |
| 3412 | } |
| 3413 | len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, |
| 3414 | "\tVFI extents:\n"); |
| 3415 | index = 0; |
| 3416 | list_for_each_entry(rsrc_blks, &phba->sli4_hba.lpfc_vfi_blk_list, |
| 3417 | list) { |
| 3418 | len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, |
| 3419 | "\t\tBlock %3d: Start %4d, Count %4d\n", |
| 3420 | index, rsrc_blks->rsrc_start, |
| 3421 | rsrc_blks->rsrc_size); |
| 3422 | index++; |
| 3423 | } |
| 3424 | |
| 3425 | len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, |
| 3426 | "\tRPI extents:\n"); |
| 3427 | index = 0; |
| 3428 | list_for_each_entry(rsrc_blks, &phba->sli4_hba.lpfc_rpi_blk_list, |
| 3429 | list) { |
| 3430 | len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, |
| 3431 | "\t\tBlock %3d: Start %4d, Count %4d\n", |
| 3432 | index, rsrc_blks->rsrc_start, |
| 3433 | rsrc_blks->rsrc_size); |
| 3434 | index++; |
| 3435 | } |
| 3436 | |
| 3437 | len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, |
| 3438 | "\tXRI extents:\n"); |
| 3439 | index = 0; |
| 3440 | list_for_each_entry(rsrc_blks, &phba->sli4_hba.lpfc_xri_blk_list, |
| 3441 | list) { |
| 3442 | len += snprintf(pbuffer+len, LPFC_EXT_ACC_BUF_SIZE-len, |
| 3443 | "\t\tBlock %3d: Start %4d, Count %4d\n", |
| 3444 | index, rsrc_blks->rsrc_start, |
| 3445 | rsrc_blks->rsrc_size); |
| 3446 | index++; |
| 3447 | } |
| 3448 | |
| 3449 | return len; |
| 3450 | } |
| 3451 | |
| 3452 | /** |
| 3453 | * lpfc_idiag_extacc_write - Syntax check and set up idiag extacc commands |
| 3454 | * @file: The file pointer to read from. |
| 3455 | * @buf: The buffer to copy the user data from. |
| 3456 | * @nbytes: The number of bytes to get. |
| 3457 | * @ppos: The position in the file to start reading from. |
| 3458 | * |
| 3459 | * This routine get the debugfs idiag command struct from user space and then |
| 3460 | * perform the syntax check for extent information access commands and sets |
| 3461 | * up the necessary states in the idiag command struct accordingly. |
| 3462 | * |
| 3463 | * It returns the @nbytges passing in from debugfs user space when successful. |
| 3464 | * In case of error conditions, it returns proper error code back to the user |
| 3465 | * space. |
| 3466 | **/ |
| 3467 | static ssize_t |
| 3468 | lpfc_idiag_extacc_write(struct file *file, const char __user *buf, |
| 3469 | size_t nbytes, loff_t *ppos) |
| 3470 | { |
| 3471 | struct lpfc_debug *debug = file->private_data; |
| 3472 | uint32_t ext_map; |
| 3473 | int rc; |
| 3474 | |
| 3475 | /* This is a user write operation */ |
| 3476 | debug->op = LPFC_IDIAG_OP_WR; |
| 3477 | |
| 3478 | rc = lpfc_idiag_cmd_get(buf, nbytes, &idiag.cmd); |
| 3479 | if (rc < 0) |
| 3480 | return rc; |
| 3481 | |
| 3482 | ext_map = idiag.cmd.data[IDIAG_EXTACC_EXMAP_INDX]; |
| 3483 | |
| 3484 | if (idiag.cmd.opcode != LPFC_IDIAG_CMD_EXTACC_RD) |
| 3485 | goto error_out; |
| 3486 | if (rc != LPFC_EXT_ACC_CMD_ARG) |
| 3487 | goto error_out; |
| 3488 | if (!(ext_map & LPFC_EXT_ACC_ALL)) |
| 3489 | goto error_out; |
| 3490 | |
| 3491 | return nbytes; |
| 3492 | error_out: |
| 3493 | /* Clean out command structure on command error out */ |
| 3494 | memset(&idiag, 0, sizeof(idiag)); |
| 3495 | return -EINVAL; |
| 3496 | } |
| 3497 | |
| 3498 | /** |
| 3499 | * lpfc_idiag_extacc_read - idiag debugfs read access to extent information |
| 3500 | * @file: The file pointer to read from. |
| 3501 | * @buf: The buffer to copy the data to. |
| 3502 | * @nbytes: The number of bytes to read. |
| 3503 | * @ppos: The position in the file to start reading from. |
| 3504 | * |
| 3505 | * Description: |
| 3506 | * This routine reads data from the proper extent information according to |
| 3507 | * the idiag command, and copies to user @buf. |
| 3508 | * |
| 3509 | * Returns: |
| 3510 | * This function returns the amount of data that was read (this could be less |
| 3511 | * than @nbytes if the end of the file was reached) or a negative error value. |
| 3512 | **/ |
| 3513 | static ssize_t |
| 3514 | lpfc_idiag_extacc_read(struct file *file, char __user *buf, size_t nbytes, |
| 3515 | loff_t *ppos) |
| 3516 | { |
| 3517 | struct lpfc_debug *debug = file->private_data; |
| 3518 | struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private; |
| 3519 | char *pbuffer; |
| 3520 | uint32_t ext_map; |
| 3521 | int len = 0; |
| 3522 | |
| 3523 | /* This is a user read operation */ |
| 3524 | debug->op = LPFC_IDIAG_OP_RD; |
| 3525 | |
| 3526 | if (!debug->buffer) |
| 3527 | debug->buffer = kmalloc(LPFC_EXT_ACC_BUF_SIZE, GFP_KERNEL); |
| 3528 | if (!debug->buffer) |
| 3529 | return 0; |
| 3530 | pbuffer = debug->buffer; |
| 3531 | if (*ppos) |
| 3532 | return 0; |
| 3533 | if (idiag.cmd.opcode != LPFC_IDIAG_CMD_EXTACC_RD) |
| 3534 | return 0; |
| 3535 | |
| 3536 | ext_map = idiag.cmd.data[IDIAG_EXTACC_EXMAP_INDX]; |
| 3537 | if (ext_map & LPFC_EXT_ACC_AVAIL) |
| 3538 | len = lpfc_idiag_extacc_avail_get(phba, pbuffer, len); |
| 3539 | if (ext_map & LPFC_EXT_ACC_ALLOC) |
| 3540 | len = lpfc_idiag_extacc_alloc_get(phba, pbuffer, len); |
| 3541 | if (ext_map & LPFC_EXT_ACC_DRIVR) |
| 3542 | len = lpfc_idiag_extacc_drivr_get(phba, pbuffer, len); |
| 3543 | |
| 3544 | return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len); |
| 3545 | } |
| 3546 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3547 | #undef lpfc_debugfs_op_disc_trc |
Jan Engelhardt | 71fa742 | 2009-01-11 10:38:59 +0100 | [diff] [blame] | 3548 | static const struct file_operations lpfc_debugfs_op_disc_trc = { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3549 | .owner = THIS_MODULE, |
| 3550 | .open = lpfc_debugfs_disc_trc_open, |
| 3551 | .llseek = lpfc_debugfs_lseek, |
| 3552 | .read = lpfc_debugfs_read, |
| 3553 | .release = lpfc_debugfs_release, |
| 3554 | }; |
| 3555 | |
| 3556 | #undef lpfc_debugfs_op_nodelist |
Jan Engelhardt | 71fa742 | 2009-01-11 10:38:59 +0100 | [diff] [blame] | 3557 | static const struct file_operations lpfc_debugfs_op_nodelist = { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3558 | .owner = THIS_MODULE, |
| 3559 | .open = lpfc_debugfs_nodelist_open, |
| 3560 | .llseek = lpfc_debugfs_lseek, |
| 3561 | .read = lpfc_debugfs_read, |
| 3562 | .release = lpfc_debugfs_release, |
| 3563 | }; |
| 3564 | |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 3565 | #undef lpfc_debugfs_op_hbqinfo |
Jan Engelhardt | 71fa742 | 2009-01-11 10:38:59 +0100 | [diff] [blame] | 3566 | static const struct file_operations lpfc_debugfs_op_hbqinfo = { |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 3567 | .owner = THIS_MODULE, |
| 3568 | .open = lpfc_debugfs_hbqinfo_open, |
| 3569 | .llseek = lpfc_debugfs_lseek, |
| 3570 | .read = lpfc_debugfs_read, |
| 3571 | .release = lpfc_debugfs_release, |
| 3572 | }; |
| 3573 | |
James Smart | c95d6c6 | 2008-01-11 01:53:23 -0500 | [diff] [blame] | 3574 | #undef lpfc_debugfs_op_dumpHBASlim |
Jan Engelhardt | 71fa742 | 2009-01-11 10:38:59 +0100 | [diff] [blame] | 3575 | static const struct file_operations lpfc_debugfs_op_dumpHBASlim = { |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 3576 | .owner = THIS_MODULE, |
James Smart | c95d6c6 | 2008-01-11 01:53:23 -0500 | [diff] [blame] | 3577 | .open = lpfc_debugfs_dumpHBASlim_open, |
| 3578 | .llseek = lpfc_debugfs_lseek, |
| 3579 | .read = lpfc_debugfs_read, |
| 3580 | .release = lpfc_debugfs_release, |
| 3581 | }; |
| 3582 | |
| 3583 | #undef lpfc_debugfs_op_dumpHostSlim |
Jan Engelhardt | 71fa742 | 2009-01-11 10:38:59 +0100 | [diff] [blame] | 3584 | static const struct file_operations lpfc_debugfs_op_dumpHostSlim = { |
James Smart | c95d6c6 | 2008-01-11 01:53:23 -0500 | [diff] [blame] | 3585 | .owner = THIS_MODULE, |
| 3586 | .open = lpfc_debugfs_dumpHostSlim_open, |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 3587 | .llseek = lpfc_debugfs_lseek, |
| 3588 | .read = lpfc_debugfs_read, |
| 3589 | .release = lpfc_debugfs_release, |
| 3590 | }; |
| 3591 | |
James Smart | e2a0a9d | 2008-12-04 22:40:02 -0500 | [diff] [blame] | 3592 | #undef lpfc_debugfs_op_dumpData |
Jan Engelhardt | 71fa742 | 2009-01-11 10:38:59 +0100 | [diff] [blame] | 3593 | static const struct file_operations lpfc_debugfs_op_dumpData = { |
James Smart | e2a0a9d | 2008-12-04 22:40:02 -0500 | [diff] [blame] | 3594 | .owner = THIS_MODULE, |
| 3595 | .open = lpfc_debugfs_dumpData_open, |
| 3596 | .llseek = lpfc_debugfs_lseek, |
| 3597 | .read = lpfc_debugfs_read, |
| 3598 | .write = lpfc_debugfs_dumpDataDif_write, |
| 3599 | .release = lpfc_debugfs_dumpDataDif_release, |
| 3600 | }; |
| 3601 | |
| 3602 | #undef lpfc_debugfs_op_dumpDif |
Jan Engelhardt | 71fa742 | 2009-01-11 10:38:59 +0100 | [diff] [blame] | 3603 | static const struct file_operations lpfc_debugfs_op_dumpDif = { |
James Smart | e2a0a9d | 2008-12-04 22:40:02 -0500 | [diff] [blame] | 3604 | .owner = THIS_MODULE, |
| 3605 | .open = lpfc_debugfs_dumpDif_open, |
| 3606 | .llseek = lpfc_debugfs_lseek, |
| 3607 | .read = lpfc_debugfs_read, |
| 3608 | .write = lpfc_debugfs_dumpDataDif_write, |
| 3609 | .release = lpfc_debugfs_dumpDataDif_release, |
| 3610 | }; |
| 3611 | |
James Smart | f9bb2da | 2011-10-10 21:34:11 -0400 | [diff] [blame] | 3612 | #undef lpfc_debugfs_op_dif_err |
| 3613 | static const struct file_operations lpfc_debugfs_op_dif_err = { |
| 3614 | .owner = THIS_MODULE, |
Stephen Boyd | 234e340 | 2012-04-05 14:25:11 -0700 | [diff] [blame] | 3615 | .open = simple_open, |
James Smart | f9bb2da | 2011-10-10 21:34:11 -0400 | [diff] [blame] | 3616 | .llseek = lpfc_debugfs_lseek, |
| 3617 | .read = lpfc_debugfs_dif_err_read, |
| 3618 | .write = lpfc_debugfs_dif_err_write, |
| 3619 | .release = lpfc_debugfs_dif_err_release, |
| 3620 | }; |
| 3621 | |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 3622 | #undef lpfc_debugfs_op_slow_ring_trc |
Jan Engelhardt | 71fa742 | 2009-01-11 10:38:59 +0100 | [diff] [blame] | 3623 | static const struct file_operations lpfc_debugfs_op_slow_ring_trc = { |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 3624 | .owner = THIS_MODULE, |
| 3625 | .open = lpfc_debugfs_slow_ring_trc_open, |
| 3626 | .llseek = lpfc_debugfs_lseek, |
| 3627 | .read = lpfc_debugfs_read, |
| 3628 | .release = lpfc_debugfs_release, |
| 3629 | }; |
| 3630 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3631 | static struct dentry *lpfc_debugfs_root = NULL; |
| 3632 | static atomic_t lpfc_debugfs_hba_count; |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 3633 | |
| 3634 | /* |
| 3635 | * File operations for the iDiag debugfs |
| 3636 | */ |
| 3637 | #undef lpfc_idiag_op_pciCfg |
| 3638 | static const struct file_operations lpfc_idiag_op_pciCfg = { |
| 3639 | .owner = THIS_MODULE, |
| 3640 | .open = lpfc_idiag_open, |
| 3641 | .llseek = lpfc_debugfs_lseek, |
| 3642 | .read = lpfc_idiag_pcicfg_read, |
| 3643 | .write = lpfc_idiag_pcicfg_write, |
| 3644 | .release = lpfc_idiag_cmd_release, |
| 3645 | }; |
| 3646 | |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 3647 | #undef lpfc_idiag_op_barAcc |
| 3648 | static const struct file_operations lpfc_idiag_op_barAcc = { |
| 3649 | .owner = THIS_MODULE, |
| 3650 | .open = lpfc_idiag_open, |
| 3651 | .llseek = lpfc_debugfs_lseek, |
| 3652 | .read = lpfc_idiag_baracc_read, |
| 3653 | .write = lpfc_idiag_baracc_write, |
| 3654 | .release = lpfc_idiag_cmd_release, |
| 3655 | }; |
| 3656 | |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 3657 | #undef lpfc_idiag_op_queInfo |
| 3658 | static const struct file_operations lpfc_idiag_op_queInfo = { |
| 3659 | .owner = THIS_MODULE, |
| 3660 | .open = lpfc_idiag_open, |
| 3661 | .read = lpfc_idiag_queinfo_read, |
| 3662 | .release = lpfc_idiag_release, |
| 3663 | }; |
| 3664 | |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 3665 | #undef lpfc_idiag_op_queAcc |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 3666 | static const struct file_operations lpfc_idiag_op_queAcc = { |
| 3667 | .owner = THIS_MODULE, |
| 3668 | .open = lpfc_idiag_open, |
| 3669 | .llseek = lpfc_debugfs_lseek, |
| 3670 | .read = lpfc_idiag_queacc_read, |
| 3671 | .write = lpfc_idiag_queacc_write, |
| 3672 | .release = lpfc_idiag_cmd_release, |
| 3673 | }; |
| 3674 | |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 3675 | #undef lpfc_idiag_op_drbAcc |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 3676 | static const struct file_operations lpfc_idiag_op_drbAcc = { |
| 3677 | .owner = THIS_MODULE, |
| 3678 | .open = lpfc_idiag_open, |
| 3679 | .llseek = lpfc_debugfs_lseek, |
| 3680 | .read = lpfc_idiag_drbacc_read, |
| 3681 | .write = lpfc_idiag_drbacc_write, |
| 3682 | .release = lpfc_idiag_cmd_release, |
| 3683 | }; |
| 3684 | |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 3685 | #undef lpfc_idiag_op_ctlAcc |
| 3686 | static const struct file_operations lpfc_idiag_op_ctlAcc = { |
| 3687 | .owner = THIS_MODULE, |
| 3688 | .open = lpfc_idiag_open, |
| 3689 | .llseek = lpfc_debugfs_lseek, |
| 3690 | .read = lpfc_idiag_ctlacc_read, |
| 3691 | .write = lpfc_idiag_ctlacc_write, |
| 3692 | .release = lpfc_idiag_cmd_release, |
| 3693 | }; |
| 3694 | |
| 3695 | #undef lpfc_idiag_op_mbxAcc |
| 3696 | static const struct file_operations lpfc_idiag_op_mbxAcc = { |
| 3697 | .owner = THIS_MODULE, |
| 3698 | .open = lpfc_idiag_open, |
| 3699 | .llseek = lpfc_debugfs_lseek, |
| 3700 | .read = lpfc_idiag_mbxacc_read, |
| 3701 | .write = lpfc_idiag_mbxacc_write, |
| 3702 | .release = lpfc_idiag_cmd_release, |
| 3703 | }; |
| 3704 | |
| 3705 | #undef lpfc_idiag_op_extAcc |
| 3706 | static const struct file_operations lpfc_idiag_op_extAcc = { |
| 3707 | .owner = THIS_MODULE, |
| 3708 | .open = lpfc_idiag_open, |
| 3709 | .llseek = lpfc_debugfs_lseek, |
| 3710 | .read = lpfc_idiag_extacc_read, |
| 3711 | .write = lpfc_idiag_extacc_write, |
| 3712 | .release = lpfc_idiag_cmd_release, |
| 3713 | }; |
| 3714 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3715 | #endif |
| 3716 | |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 3717 | /* lpfc_idiag_mbxacc_dump_bsg_mbox - idiag debugfs dump bsg mailbox command |
| 3718 | * @phba: Pointer to HBA context object. |
| 3719 | * @dmabuf: Pointer to a DMA buffer descriptor. |
| 3720 | * |
| 3721 | * Description: |
| 3722 | * This routine dump a bsg pass-through non-embedded mailbox command with |
| 3723 | * external buffer. |
| 3724 | **/ |
| 3725 | void |
| 3726 | lpfc_idiag_mbxacc_dump_bsg_mbox(struct lpfc_hba *phba, enum nemb_type nemb_tp, |
| 3727 | enum mbox_type mbox_tp, enum dma_type dma_tp, |
| 3728 | enum sta_type sta_tp, |
| 3729 | struct lpfc_dmabuf *dmabuf, uint32_t ext_buf) |
| 3730 | { |
| 3731 | #ifdef CONFIG_SCSI_LPFC_DEBUG_FS |
| 3732 | uint32_t *mbx_mbox_cmd, *mbx_dump_map, *mbx_dump_cnt, *mbx_word_cnt; |
| 3733 | char line_buf[LPFC_MBX_ACC_LBUF_SZ]; |
| 3734 | int len = 0; |
| 3735 | uint32_t do_dump = 0; |
| 3736 | uint32_t *pword; |
| 3737 | uint32_t i; |
| 3738 | |
| 3739 | if (idiag.cmd.opcode != LPFC_IDIAG_BSG_MBXACC_DP) |
| 3740 | return; |
| 3741 | |
| 3742 | mbx_mbox_cmd = &idiag.cmd.data[IDIAG_MBXACC_MBCMD_INDX]; |
| 3743 | mbx_dump_map = &idiag.cmd.data[IDIAG_MBXACC_DPMAP_INDX]; |
| 3744 | mbx_dump_cnt = &idiag.cmd.data[IDIAG_MBXACC_DPCNT_INDX]; |
| 3745 | mbx_word_cnt = &idiag.cmd.data[IDIAG_MBXACC_WDCNT_INDX]; |
| 3746 | |
| 3747 | if (!(*mbx_dump_map & LPFC_MBX_DMP_ALL) || |
| 3748 | (*mbx_dump_cnt == 0) || |
| 3749 | (*mbx_word_cnt == 0)) |
| 3750 | return; |
| 3751 | |
| 3752 | if (*mbx_mbox_cmd != 0x9B) |
| 3753 | return; |
| 3754 | |
| 3755 | if ((mbox_tp == mbox_rd) && (dma_tp == dma_mbox)) { |
| 3756 | if (*mbx_dump_map & LPFC_BSG_DMP_MBX_RD_MBX) { |
| 3757 | do_dump |= LPFC_BSG_DMP_MBX_RD_MBX; |
| 3758 | printk(KERN_ERR "\nRead mbox command (x%x), " |
| 3759 | "nemb:0x%x, extbuf_cnt:%d:\n", |
| 3760 | sta_tp, nemb_tp, ext_buf); |
| 3761 | } |
| 3762 | } |
| 3763 | if ((mbox_tp == mbox_rd) && (dma_tp == dma_ebuf)) { |
| 3764 | if (*mbx_dump_map & LPFC_BSG_DMP_MBX_RD_BUF) { |
| 3765 | do_dump |= LPFC_BSG_DMP_MBX_RD_BUF; |
| 3766 | printk(KERN_ERR "\nRead mbox buffer (x%x), " |
| 3767 | "nemb:0x%x, extbuf_seq:%d:\n", |
| 3768 | sta_tp, nemb_tp, ext_buf); |
| 3769 | } |
| 3770 | } |
| 3771 | if ((mbox_tp == mbox_wr) && (dma_tp == dma_mbox)) { |
| 3772 | if (*mbx_dump_map & LPFC_BSG_DMP_MBX_WR_MBX) { |
| 3773 | do_dump |= LPFC_BSG_DMP_MBX_WR_MBX; |
| 3774 | printk(KERN_ERR "\nWrite mbox command (x%x), " |
| 3775 | "nemb:0x%x, extbuf_cnt:%d:\n", |
| 3776 | sta_tp, nemb_tp, ext_buf); |
| 3777 | } |
| 3778 | } |
| 3779 | if ((mbox_tp == mbox_wr) && (dma_tp == dma_ebuf)) { |
| 3780 | if (*mbx_dump_map & LPFC_BSG_DMP_MBX_WR_BUF) { |
| 3781 | do_dump |= LPFC_BSG_DMP_MBX_WR_BUF; |
| 3782 | printk(KERN_ERR "\nWrite mbox buffer (x%x), " |
| 3783 | "nemb:0x%x, extbuf_seq:%d:\n", |
| 3784 | sta_tp, nemb_tp, ext_buf); |
| 3785 | } |
| 3786 | } |
| 3787 | |
| 3788 | /* dump buffer content */ |
| 3789 | if (do_dump) { |
| 3790 | pword = (uint32_t *)dmabuf->virt; |
| 3791 | for (i = 0; i < *mbx_word_cnt; i++) { |
| 3792 | if (!(i % 8)) { |
| 3793 | if (i != 0) |
| 3794 | printk(KERN_ERR "%s\n", line_buf); |
| 3795 | len = 0; |
| 3796 | len += snprintf(line_buf+len, |
| 3797 | LPFC_MBX_ACC_LBUF_SZ-len, |
| 3798 | "%03d: ", i); |
| 3799 | } |
| 3800 | len += snprintf(line_buf+len, LPFC_MBX_ACC_LBUF_SZ-len, |
| 3801 | "%08x ", (uint32_t)*pword); |
| 3802 | pword++; |
| 3803 | } |
| 3804 | if ((i - 1) % 8) |
| 3805 | printk(KERN_ERR "%s\n", line_buf); |
| 3806 | (*mbx_dump_cnt)--; |
| 3807 | } |
| 3808 | |
| 3809 | /* Clean out command structure on reaching dump count */ |
| 3810 | if (*mbx_dump_cnt == 0) |
| 3811 | memset(&idiag, 0, sizeof(idiag)); |
| 3812 | return; |
| 3813 | #endif |
| 3814 | } |
| 3815 | |
| 3816 | /* lpfc_idiag_mbxacc_dump_issue_mbox - idiag debugfs dump issue mailbox command |
| 3817 | * @phba: Pointer to HBA context object. |
| 3818 | * @dmabuf: Pointer to a DMA buffer descriptor. |
| 3819 | * |
| 3820 | * Description: |
| 3821 | * This routine dump a pass-through non-embedded mailbox command from issue |
| 3822 | * mailbox command. |
| 3823 | **/ |
| 3824 | void |
| 3825 | lpfc_idiag_mbxacc_dump_issue_mbox(struct lpfc_hba *phba, MAILBOX_t *pmbox) |
| 3826 | { |
| 3827 | #ifdef CONFIG_SCSI_LPFC_DEBUG_FS |
| 3828 | uint32_t *mbx_dump_map, *mbx_dump_cnt, *mbx_word_cnt, *mbx_mbox_cmd; |
| 3829 | char line_buf[LPFC_MBX_ACC_LBUF_SZ]; |
| 3830 | int len = 0; |
| 3831 | uint32_t *pword; |
| 3832 | uint8_t *pbyte; |
| 3833 | uint32_t i, j; |
| 3834 | |
| 3835 | if (idiag.cmd.opcode != LPFC_IDIAG_CMD_MBXACC_DP) |
| 3836 | return; |
| 3837 | |
| 3838 | mbx_mbox_cmd = &idiag.cmd.data[IDIAG_MBXACC_MBCMD_INDX]; |
| 3839 | mbx_dump_map = &idiag.cmd.data[IDIAG_MBXACC_DPMAP_INDX]; |
| 3840 | mbx_dump_cnt = &idiag.cmd.data[IDIAG_MBXACC_DPCNT_INDX]; |
| 3841 | mbx_word_cnt = &idiag.cmd.data[IDIAG_MBXACC_WDCNT_INDX]; |
| 3842 | |
| 3843 | if (!(*mbx_dump_map & LPFC_MBX_DMP_MBX_ALL) || |
| 3844 | (*mbx_dump_cnt == 0) || |
| 3845 | (*mbx_word_cnt == 0)) |
| 3846 | return; |
| 3847 | |
| 3848 | if ((*mbx_mbox_cmd != LPFC_MBX_ALL_CMD) && |
| 3849 | (*mbx_mbox_cmd != pmbox->mbxCommand)) |
| 3850 | return; |
| 3851 | |
| 3852 | /* dump buffer content */ |
| 3853 | if (*mbx_dump_map & LPFC_MBX_DMP_MBX_WORD) { |
| 3854 | printk(KERN_ERR "Mailbox command:0x%x dump by word:\n", |
| 3855 | pmbox->mbxCommand); |
| 3856 | pword = (uint32_t *)pmbox; |
| 3857 | for (i = 0; i < *mbx_word_cnt; i++) { |
| 3858 | if (!(i % 8)) { |
| 3859 | if (i != 0) |
| 3860 | printk(KERN_ERR "%s\n", line_buf); |
| 3861 | len = 0; |
| 3862 | memset(line_buf, 0, LPFC_MBX_ACC_LBUF_SZ); |
| 3863 | len += snprintf(line_buf+len, |
| 3864 | LPFC_MBX_ACC_LBUF_SZ-len, |
| 3865 | "%03d: ", i); |
| 3866 | } |
| 3867 | len += snprintf(line_buf+len, LPFC_MBX_ACC_LBUF_SZ-len, |
| 3868 | "%08x ", |
| 3869 | ((uint32_t)*pword) & 0xffffffff); |
| 3870 | pword++; |
| 3871 | } |
| 3872 | if ((i - 1) % 8) |
| 3873 | printk(KERN_ERR "%s\n", line_buf); |
| 3874 | printk(KERN_ERR "\n"); |
| 3875 | } |
| 3876 | if (*mbx_dump_map & LPFC_MBX_DMP_MBX_BYTE) { |
| 3877 | printk(KERN_ERR "Mailbox command:0x%x dump by byte:\n", |
| 3878 | pmbox->mbxCommand); |
| 3879 | pbyte = (uint8_t *)pmbox; |
| 3880 | for (i = 0; i < *mbx_word_cnt; i++) { |
| 3881 | if (!(i % 8)) { |
| 3882 | if (i != 0) |
| 3883 | printk(KERN_ERR "%s\n", line_buf); |
| 3884 | len = 0; |
| 3885 | memset(line_buf, 0, LPFC_MBX_ACC_LBUF_SZ); |
| 3886 | len += snprintf(line_buf+len, |
| 3887 | LPFC_MBX_ACC_LBUF_SZ-len, |
| 3888 | "%03d: ", i); |
| 3889 | } |
| 3890 | for (j = 0; j < 4; j++) { |
| 3891 | len += snprintf(line_buf+len, |
| 3892 | LPFC_MBX_ACC_LBUF_SZ-len, |
| 3893 | "%02x", |
| 3894 | ((uint8_t)*pbyte) & 0xff); |
| 3895 | pbyte++; |
| 3896 | } |
| 3897 | len += snprintf(line_buf+len, |
| 3898 | LPFC_MBX_ACC_LBUF_SZ-len, " "); |
| 3899 | } |
| 3900 | if ((i - 1) % 8) |
| 3901 | printk(KERN_ERR "%s\n", line_buf); |
| 3902 | printk(KERN_ERR "\n"); |
| 3903 | } |
| 3904 | (*mbx_dump_cnt)--; |
| 3905 | |
| 3906 | /* Clean out command structure on reaching dump count */ |
| 3907 | if (*mbx_dump_cnt == 0) |
| 3908 | memset(&idiag, 0, sizeof(idiag)); |
| 3909 | return; |
| 3910 | #endif |
| 3911 | } |
| 3912 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3913 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3914 | * lpfc_debugfs_initialize - Initialize debugfs for a vport |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3915 | * @vport: The vport pointer to initialize. |
| 3916 | * |
| 3917 | * Description: |
| 3918 | * When Debugfs is configured this routine sets up the lpfc debugfs file system. |
| 3919 | * If not already created, this routine will create the lpfc directory, and |
| 3920 | * lpfcX directory (for this HBA), and vportX directory for this vport. It will |
| 3921 | * also create each file used to access lpfc specific debugfs information. |
| 3922 | **/ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3923 | inline void |
| 3924 | lpfc_debugfs_initialize(struct lpfc_vport *vport) |
| 3925 | { |
James Smart | 923e4b6 | 2008-12-04 22:40:07 -0500 | [diff] [blame] | 3926 | #ifdef CONFIG_SCSI_LPFC_DEBUG_FS |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3927 | struct lpfc_hba *phba = vport->phba; |
| 3928 | char name[64]; |
| 3929 | uint32_t num, i; |
James Smart | f6c3bdf | 2013-12-17 20:29:59 -0500 | [diff] [blame^] | 3930 | bool pport_setup = false; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3931 | |
| 3932 | if (!lpfc_debugfs_enable) |
| 3933 | return; |
| 3934 | |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 3935 | /* Setup lpfc root directory */ |
| 3936 | if (!lpfc_debugfs_root) { |
| 3937 | lpfc_debugfs_root = debugfs_create_dir("lpfc", NULL); |
| 3938 | atomic_set(&lpfc_debugfs_hba_count, 0); |
| 3939 | if (!lpfc_debugfs_root) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3940 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 3941 | "0408 Cannot create debugfs root\n"); |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 3942 | goto debug_failed; |
| 3943 | } |
| 3944 | } |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 3945 | if (!lpfc_debugfs_start_time) |
| 3946 | lpfc_debugfs_start_time = jiffies; |
| 3947 | |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 3948 | /* Setup funcX directory for specific HBA PCI function */ |
| 3949 | snprintf(name, sizeof(name), "fn%d", phba->brd_no); |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 3950 | if (!phba->hba_debugfs_root) { |
James Smart | f6c3bdf | 2013-12-17 20:29:59 -0500 | [diff] [blame^] | 3951 | pport_setup = true; |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 3952 | phba->hba_debugfs_root = |
| 3953 | debugfs_create_dir(name, lpfc_debugfs_root); |
| 3954 | if (!phba->hba_debugfs_root) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3955 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 3956 | "0412 Cannot create debugfs hba\n"); |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 3957 | goto debug_failed; |
| 3958 | } |
| 3959 | atomic_inc(&lpfc_debugfs_hba_count); |
| 3960 | atomic_set(&phba->debugfs_vport_count, 0); |
| 3961 | |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 3962 | /* Setup hbqinfo */ |
| 3963 | snprintf(name, sizeof(name), "hbqinfo"); |
| 3964 | phba->debug_hbqinfo = |
| 3965 | debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR, |
| 3966 | phba->hba_debugfs_root, |
| 3967 | phba, &lpfc_debugfs_op_hbqinfo); |
| 3968 | if (!phba->debug_hbqinfo) { |
| 3969 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 3970 | "0411 Cannot create debugfs hbqinfo\n"); |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 3971 | goto debug_failed; |
| 3972 | } |
| 3973 | |
James Smart | c95d6c6 | 2008-01-11 01:53:23 -0500 | [diff] [blame] | 3974 | /* Setup dumpHBASlim */ |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 3975 | if (phba->sli_rev < LPFC_SLI_REV4) { |
| 3976 | snprintf(name, sizeof(name), "dumpHBASlim"); |
| 3977 | phba->debug_dumpHBASlim = |
| 3978 | debugfs_create_file(name, |
| 3979 | S_IFREG|S_IRUGO|S_IWUSR, |
| 3980 | phba->hba_debugfs_root, |
| 3981 | phba, &lpfc_debugfs_op_dumpHBASlim); |
| 3982 | if (!phba->debug_dumpHBASlim) { |
| 3983 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 3984 | "0413 Cannot create debugfs " |
| 3985 | "dumpHBASlim\n"); |
| 3986 | goto debug_failed; |
| 3987 | } |
| 3988 | } else |
| 3989 | phba->debug_dumpHBASlim = NULL; |
James Smart | c95d6c6 | 2008-01-11 01:53:23 -0500 | [diff] [blame] | 3990 | |
| 3991 | /* Setup dumpHostSlim */ |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 3992 | if (phba->sli_rev < LPFC_SLI_REV4) { |
| 3993 | snprintf(name, sizeof(name), "dumpHostSlim"); |
| 3994 | phba->debug_dumpHostSlim = |
| 3995 | debugfs_create_file(name, |
| 3996 | S_IFREG|S_IRUGO|S_IWUSR, |
| 3997 | phba->hba_debugfs_root, |
| 3998 | phba, &lpfc_debugfs_op_dumpHostSlim); |
| 3999 | if (!phba->debug_dumpHostSlim) { |
| 4000 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 4001 | "0414 Cannot create debugfs " |
| 4002 | "dumpHostSlim\n"); |
| 4003 | goto debug_failed; |
| 4004 | } |
| 4005 | } else |
Felipe Pena | b28d108 | 2013-10-18 20:15:37 -0300 | [diff] [blame] | 4006 | phba->debug_dumpHostSlim = NULL; |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 4007 | |
James Smart | e2a0a9d | 2008-12-04 22:40:02 -0500 | [diff] [blame] | 4008 | /* Setup dumpData */ |
| 4009 | snprintf(name, sizeof(name), "dumpData"); |
| 4010 | phba->debug_dumpData = |
| 4011 | debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR, |
| 4012 | phba->hba_debugfs_root, |
| 4013 | phba, &lpfc_debugfs_op_dumpData); |
| 4014 | if (!phba->debug_dumpData) { |
| 4015 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 4016 | "0800 Cannot create debugfs dumpData\n"); |
| 4017 | goto debug_failed; |
| 4018 | } |
| 4019 | |
| 4020 | /* Setup dumpDif */ |
| 4021 | snprintf(name, sizeof(name), "dumpDif"); |
| 4022 | phba->debug_dumpDif = |
| 4023 | debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR, |
| 4024 | phba->hba_debugfs_root, |
| 4025 | phba, &lpfc_debugfs_op_dumpDif); |
| 4026 | if (!phba->debug_dumpDif) { |
| 4027 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 4028 | "0801 Cannot create debugfs dumpDif\n"); |
| 4029 | goto debug_failed; |
| 4030 | } |
| 4031 | |
James Smart | f9bb2da | 2011-10-10 21:34:11 -0400 | [diff] [blame] | 4032 | /* Setup DIF Error Injections */ |
| 4033 | snprintf(name, sizeof(name), "InjErrLBA"); |
| 4034 | phba->debug_InjErrLBA = |
| 4035 | debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR, |
| 4036 | phba->hba_debugfs_root, |
| 4037 | phba, &lpfc_debugfs_op_dif_err); |
| 4038 | if (!phba->debug_InjErrLBA) { |
| 4039 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 4040 | "0807 Cannot create debugfs InjErrLBA\n"); |
| 4041 | goto debug_failed; |
| 4042 | } |
| 4043 | phba->lpfc_injerr_lba = LPFC_INJERR_LBA_OFF; |
| 4044 | |
James Smart | 4ac9b22 | 2012-03-01 22:38:29 -0500 | [diff] [blame] | 4045 | snprintf(name, sizeof(name), "InjErrNPortID"); |
| 4046 | phba->debug_InjErrNPortID = |
| 4047 | debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR, |
| 4048 | phba->hba_debugfs_root, |
| 4049 | phba, &lpfc_debugfs_op_dif_err); |
| 4050 | if (!phba->debug_InjErrNPortID) { |
| 4051 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 4052 | "0809 Cannot create debugfs InjErrNPortID\n"); |
| 4053 | goto debug_failed; |
| 4054 | } |
| 4055 | |
| 4056 | snprintf(name, sizeof(name), "InjErrWWPN"); |
| 4057 | phba->debug_InjErrWWPN = |
| 4058 | debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR, |
| 4059 | phba->hba_debugfs_root, |
| 4060 | phba, &lpfc_debugfs_op_dif_err); |
| 4061 | if (!phba->debug_InjErrWWPN) { |
| 4062 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 4063 | "0810 Cannot create debugfs InjErrWWPN\n"); |
| 4064 | goto debug_failed; |
| 4065 | } |
| 4066 | |
James Smart | f9bb2da | 2011-10-10 21:34:11 -0400 | [diff] [blame] | 4067 | snprintf(name, sizeof(name), "writeGuardInjErr"); |
| 4068 | phba->debug_writeGuard = |
| 4069 | debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR, |
| 4070 | phba->hba_debugfs_root, |
| 4071 | phba, &lpfc_debugfs_op_dif_err); |
| 4072 | if (!phba->debug_writeGuard) { |
| 4073 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 4074 | "0802 Cannot create debugfs writeGuard\n"); |
| 4075 | goto debug_failed; |
| 4076 | } |
| 4077 | |
| 4078 | snprintf(name, sizeof(name), "writeAppInjErr"); |
| 4079 | phba->debug_writeApp = |
| 4080 | debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR, |
| 4081 | phba->hba_debugfs_root, |
| 4082 | phba, &lpfc_debugfs_op_dif_err); |
| 4083 | if (!phba->debug_writeApp) { |
| 4084 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 4085 | "0803 Cannot create debugfs writeApp\n"); |
| 4086 | goto debug_failed; |
| 4087 | } |
| 4088 | |
| 4089 | snprintf(name, sizeof(name), "writeRefInjErr"); |
| 4090 | phba->debug_writeRef = |
| 4091 | debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR, |
| 4092 | phba->hba_debugfs_root, |
| 4093 | phba, &lpfc_debugfs_op_dif_err); |
| 4094 | if (!phba->debug_writeRef) { |
| 4095 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 4096 | "0804 Cannot create debugfs writeRef\n"); |
| 4097 | goto debug_failed; |
| 4098 | } |
| 4099 | |
James Smart | acd6859 | 2012-01-18 16:25:09 -0500 | [diff] [blame] | 4100 | snprintf(name, sizeof(name), "readGuardInjErr"); |
| 4101 | phba->debug_readGuard = |
| 4102 | debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR, |
| 4103 | phba->hba_debugfs_root, |
| 4104 | phba, &lpfc_debugfs_op_dif_err); |
| 4105 | if (!phba->debug_readGuard) { |
| 4106 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 4107 | "0808 Cannot create debugfs readGuard\n"); |
| 4108 | goto debug_failed; |
| 4109 | } |
| 4110 | |
James Smart | f9bb2da | 2011-10-10 21:34:11 -0400 | [diff] [blame] | 4111 | snprintf(name, sizeof(name), "readAppInjErr"); |
| 4112 | phba->debug_readApp = |
| 4113 | debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR, |
| 4114 | phba->hba_debugfs_root, |
| 4115 | phba, &lpfc_debugfs_op_dif_err); |
| 4116 | if (!phba->debug_readApp) { |
| 4117 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 4118 | "0805 Cannot create debugfs readApp\n"); |
| 4119 | goto debug_failed; |
| 4120 | } |
| 4121 | |
| 4122 | snprintf(name, sizeof(name), "readRefInjErr"); |
| 4123 | phba->debug_readRef = |
| 4124 | debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR, |
| 4125 | phba->hba_debugfs_root, |
| 4126 | phba, &lpfc_debugfs_op_dif_err); |
| 4127 | if (!phba->debug_readRef) { |
| 4128 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 4129 | "0806 Cannot create debugfs readApp\n"); |
| 4130 | goto debug_failed; |
| 4131 | } |
| 4132 | |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 4133 | /* Setup slow ring trace */ |
| 4134 | if (lpfc_debugfs_max_slow_ring_trc) { |
| 4135 | num = lpfc_debugfs_max_slow_ring_trc - 1; |
| 4136 | if (num & lpfc_debugfs_max_slow_ring_trc) { |
| 4137 | /* Change to be a power of 2 */ |
| 4138 | num = lpfc_debugfs_max_slow_ring_trc; |
| 4139 | i = 0; |
| 4140 | while (num > 1) { |
| 4141 | num = num >> 1; |
| 4142 | i++; |
| 4143 | } |
| 4144 | lpfc_debugfs_max_slow_ring_trc = (1 << i); |
| 4145 | printk(KERN_ERR |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 4146 | "lpfc_debugfs_max_disc_trc changed to " |
| 4147 | "%d\n", lpfc_debugfs_max_disc_trc); |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 4148 | } |
| 4149 | } |
| 4150 | |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 4151 | snprintf(name, sizeof(name), "slow_ring_trace"); |
| 4152 | phba->debug_slow_ring_trc = |
| 4153 | debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR, |
| 4154 | phba->hba_debugfs_root, |
| 4155 | phba, &lpfc_debugfs_op_slow_ring_trc); |
| 4156 | if (!phba->debug_slow_ring_trc) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 4157 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 4158 | "0415 Cannot create debugfs " |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 4159 | "slow_ring_trace\n"); |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 4160 | goto debug_failed; |
| 4161 | } |
| 4162 | if (!phba->slow_ring_trc) { |
| 4163 | phba->slow_ring_trc = kmalloc( |
| 4164 | (sizeof(struct lpfc_debugfs_trc) * |
| 4165 | lpfc_debugfs_max_slow_ring_trc), |
| 4166 | GFP_KERNEL); |
| 4167 | if (!phba->slow_ring_trc) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 4168 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 4169 | "0416 Cannot create debugfs " |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 4170 | "slow_ring buffer\n"); |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 4171 | goto debug_failed; |
| 4172 | } |
| 4173 | atomic_set(&phba->slow_ring_trc_cnt, 0); |
| 4174 | memset(phba->slow_ring_trc, 0, |
| 4175 | (sizeof(struct lpfc_debugfs_trc) * |
| 4176 | lpfc_debugfs_max_slow_ring_trc)); |
| 4177 | } |
| 4178 | } |
| 4179 | |
| 4180 | snprintf(name, sizeof(name), "vport%d", vport->vpi); |
| 4181 | if (!vport->vport_debugfs_root) { |
| 4182 | vport->vport_debugfs_root = |
| 4183 | debugfs_create_dir(name, phba->hba_debugfs_root); |
| 4184 | if (!vport->vport_debugfs_root) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 4185 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 4186 | "0417 Can't create debugfs\n"); |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 4187 | goto debug_failed; |
| 4188 | } |
| 4189 | atomic_inc(&phba->debugfs_vport_count); |
| 4190 | } |
| 4191 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4192 | if (lpfc_debugfs_max_disc_trc) { |
| 4193 | num = lpfc_debugfs_max_disc_trc - 1; |
| 4194 | if (num & lpfc_debugfs_max_disc_trc) { |
| 4195 | /* Change to be a power of 2 */ |
| 4196 | num = lpfc_debugfs_max_disc_trc; |
| 4197 | i = 0; |
| 4198 | while (num > 1) { |
| 4199 | num = num >> 1; |
| 4200 | i++; |
| 4201 | } |
| 4202 | lpfc_debugfs_max_disc_trc = (1 << i); |
| 4203 | printk(KERN_ERR |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 4204 | "lpfc_debugfs_max_disc_trc changed to %d\n", |
| 4205 | lpfc_debugfs_max_disc_trc); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4206 | } |
| 4207 | } |
| 4208 | |
Adrian Bunk | ff86ba5 | 2007-10-18 12:52:37 +0200 | [diff] [blame] | 4209 | vport->disc_trc = kzalloc( |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 4210 | (sizeof(struct lpfc_debugfs_trc) * lpfc_debugfs_max_disc_trc), |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4211 | GFP_KERNEL); |
| 4212 | |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 4213 | if (!vport->disc_trc) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 4214 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 4215 | "0418 Cannot create debugfs disc trace " |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 4216 | "buffer\n"); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4217 | goto debug_failed; |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 4218 | } |
| 4219 | atomic_set(&vport->disc_trc_cnt, 0); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4220 | |
| 4221 | snprintf(name, sizeof(name), "discovery_trace"); |
| 4222 | vport->debug_disc_trc = |
| 4223 | debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR, |
| 4224 | vport->vport_debugfs_root, |
| 4225 | vport, &lpfc_debugfs_op_disc_trc); |
| 4226 | if (!vport->debug_disc_trc) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 4227 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 4228 | "0419 Cannot create debugfs " |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 4229 | "discovery_trace\n"); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4230 | goto debug_failed; |
| 4231 | } |
| 4232 | snprintf(name, sizeof(name), "nodelist"); |
| 4233 | vport->debug_nodelist = |
| 4234 | debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR, |
| 4235 | vport->vport_debugfs_root, |
| 4236 | vport, &lpfc_debugfs_op_nodelist); |
| 4237 | if (!vport->debug_nodelist) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 4238 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 4239 | "2985 Can't create debugfs nodelist\n"); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4240 | goto debug_failed; |
| 4241 | } |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 4242 | |
| 4243 | /* |
James Smart | f6c3bdf | 2013-12-17 20:29:59 -0500 | [diff] [blame^] | 4244 | * The following section is for additional directories/files for the |
| 4245 | * physical port. |
| 4246 | */ |
| 4247 | |
| 4248 | if (!pport_setup) |
| 4249 | goto debug_failed; |
| 4250 | |
| 4251 | /* |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 4252 | * iDiag debugfs root entry points for SLI4 device only |
| 4253 | */ |
| 4254 | if (phba->sli_rev < LPFC_SLI_REV4) |
| 4255 | goto debug_failed; |
| 4256 | |
| 4257 | snprintf(name, sizeof(name), "iDiag"); |
| 4258 | if (!phba->idiag_root) { |
| 4259 | phba->idiag_root = |
| 4260 | debugfs_create_dir(name, phba->hba_debugfs_root); |
| 4261 | if (!phba->idiag_root) { |
| 4262 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 4263 | "2922 Can't create idiag debugfs\n"); |
| 4264 | goto debug_failed; |
| 4265 | } |
| 4266 | /* Initialize iDiag data structure */ |
| 4267 | memset(&idiag, 0, sizeof(idiag)); |
| 4268 | } |
| 4269 | |
| 4270 | /* iDiag read PCI config space */ |
| 4271 | snprintf(name, sizeof(name), "pciCfg"); |
| 4272 | if (!phba->idiag_pci_cfg) { |
| 4273 | phba->idiag_pci_cfg = |
| 4274 | debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR, |
| 4275 | phba->idiag_root, phba, &lpfc_idiag_op_pciCfg); |
| 4276 | if (!phba->idiag_pci_cfg) { |
| 4277 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 4278 | "2923 Can't create idiag debugfs\n"); |
| 4279 | goto debug_failed; |
| 4280 | } |
| 4281 | idiag.offset.last_rd = 0; |
| 4282 | } |
| 4283 | |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 4284 | /* iDiag PCI BAR access */ |
| 4285 | snprintf(name, sizeof(name), "barAcc"); |
| 4286 | if (!phba->idiag_bar_acc) { |
| 4287 | phba->idiag_bar_acc = |
| 4288 | debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR, |
| 4289 | phba->idiag_root, phba, &lpfc_idiag_op_barAcc); |
| 4290 | if (!phba->idiag_bar_acc) { |
| 4291 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 4292 | "3056 Can't create idiag debugfs\n"); |
| 4293 | goto debug_failed; |
| 4294 | } |
| 4295 | idiag.offset.last_rd = 0; |
| 4296 | } |
| 4297 | |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 4298 | /* iDiag get PCI function queue information */ |
| 4299 | snprintf(name, sizeof(name), "queInfo"); |
| 4300 | if (!phba->idiag_que_info) { |
| 4301 | phba->idiag_que_info = |
| 4302 | debugfs_create_file(name, S_IFREG|S_IRUGO, |
| 4303 | phba->idiag_root, phba, &lpfc_idiag_op_queInfo); |
| 4304 | if (!phba->idiag_que_info) { |
| 4305 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 4306 | "2924 Can't create idiag debugfs\n"); |
| 4307 | goto debug_failed; |
| 4308 | } |
| 4309 | } |
| 4310 | |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 4311 | /* iDiag access PCI function queue */ |
| 4312 | snprintf(name, sizeof(name), "queAcc"); |
| 4313 | if (!phba->idiag_que_acc) { |
| 4314 | phba->idiag_que_acc = |
| 4315 | debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR, |
| 4316 | phba->idiag_root, phba, &lpfc_idiag_op_queAcc); |
| 4317 | if (!phba->idiag_que_acc) { |
| 4318 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 4319 | "2926 Can't create idiag debugfs\n"); |
| 4320 | goto debug_failed; |
| 4321 | } |
| 4322 | } |
| 4323 | |
| 4324 | /* iDiag access PCI function doorbell registers */ |
| 4325 | snprintf(name, sizeof(name), "drbAcc"); |
| 4326 | if (!phba->idiag_drb_acc) { |
| 4327 | phba->idiag_drb_acc = |
| 4328 | debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR, |
| 4329 | phba->idiag_root, phba, &lpfc_idiag_op_drbAcc); |
| 4330 | if (!phba->idiag_drb_acc) { |
| 4331 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 4332 | "2927 Can't create idiag debugfs\n"); |
| 4333 | goto debug_failed; |
| 4334 | } |
| 4335 | } |
| 4336 | |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 4337 | /* iDiag access PCI function control registers */ |
| 4338 | snprintf(name, sizeof(name), "ctlAcc"); |
| 4339 | if (!phba->idiag_ctl_acc) { |
| 4340 | phba->idiag_ctl_acc = |
| 4341 | debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR, |
| 4342 | phba->idiag_root, phba, &lpfc_idiag_op_ctlAcc); |
| 4343 | if (!phba->idiag_ctl_acc) { |
| 4344 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 4345 | "2981 Can't create idiag debugfs\n"); |
| 4346 | goto debug_failed; |
| 4347 | } |
| 4348 | } |
| 4349 | |
| 4350 | /* iDiag access mbox commands */ |
| 4351 | snprintf(name, sizeof(name), "mbxAcc"); |
| 4352 | if (!phba->idiag_mbx_acc) { |
| 4353 | phba->idiag_mbx_acc = |
| 4354 | debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR, |
| 4355 | phba->idiag_root, phba, &lpfc_idiag_op_mbxAcc); |
| 4356 | if (!phba->idiag_mbx_acc) { |
| 4357 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 4358 | "2980 Can't create idiag debugfs\n"); |
| 4359 | goto debug_failed; |
| 4360 | } |
| 4361 | } |
| 4362 | |
| 4363 | /* iDiag extents access commands */ |
| 4364 | if (phba->sli4_hba.extents_in_use) { |
| 4365 | snprintf(name, sizeof(name), "extAcc"); |
| 4366 | if (!phba->idiag_ext_acc) { |
| 4367 | phba->idiag_ext_acc = |
| 4368 | debugfs_create_file(name, |
| 4369 | S_IFREG|S_IRUGO|S_IWUSR, |
| 4370 | phba->idiag_root, phba, |
| 4371 | &lpfc_idiag_op_extAcc); |
| 4372 | if (!phba->idiag_ext_acc) { |
| 4373 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 4374 | "2986 Cant create " |
| 4375 | "idiag debugfs\n"); |
| 4376 | goto debug_failed; |
| 4377 | } |
| 4378 | } |
| 4379 | } |
| 4380 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4381 | debug_failed: |
| 4382 | return; |
| 4383 | #endif |
| 4384 | } |
| 4385 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4386 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4387 | * lpfc_debugfs_terminate - Tear down debugfs infrastructure for this vport |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4388 | * @vport: The vport pointer to remove from debugfs. |
| 4389 | * |
| 4390 | * Description: |
| 4391 | * When Debugfs is configured this routine removes debugfs file system elements |
| 4392 | * that are specific to this vport. It also checks to see if there are any |
| 4393 | * users left for the debugfs directories associated with the HBA and driver. If |
| 4394 | * this is the last user of the HBA directory or driver directory then it will |
| 4395 | * remove those from the debugfs infrastructure as well. |
| 4396 | **/ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4397 | inline void |
| 4398 | lpfc_debugfs_terminate(struct lpfc_vport *vport) |
| 4399 | { |
James Smart | 923e4b6 | 2008-12-04 22:40:07 -0500 | [diff] [blame] | 4400 | #ifdef CONFIG_SCSI_LPFC_DEBUG_FS |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4401 | struct lpfc_hba *phba = vport->phba; |
| 4402 | |
| 4403 | if (vport->disc_trc) { |
| 4404 | kfree(vport->disc_trc); |
| 4405 | vport->disc_trc = NULL; |
| 4406 | } |
| 4407 | if (vport->debug_disc_trc) { |
| 4408 | debugfs_remove(vport->debug_disc_trc); /* discovery_trace */ |
| 4409 | vport->debug_disc_trc = NULL; |
| 4410 | } |
| 4411 | if (vport->debug_nodelist) { |
| 4412 | debugfs_remove(vport->debug_nodelist); /* nodelist */ |
| 4413 | vport->debug_nodelist = NULL; |
| 4414 | } |
| 4415 | if (vport->vport_debugfs_root) { |
| 4416 | debugfs_remove(vport->vport_debugfs_root); /* vportX */ |
| 4417 | vport->vport_debugfs_root = NULL; |
| 4418 | atomic_dec(&phba->debugfs_vport_count); |
| 4419 | } |
| 4420 | if (atomic_read(&phba->debugfs_vport_count) == 0) { |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 4421 | |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 4422 | if (phba->debug_hbqinfo) { |
| 4423 | debugfs_remove(phba->debug_hbqinfo); /* hbqinfo */ |
| 4424 | phba->debug_hbqinfo = NULL; |
| 4425 | } |
James Smart | c95d6c6 | 2008-01-11 01:53:23 -0500 | [diff] [blame] | 4426 | if (phba->debug_dumpHBASlim) { |
| 4427 | debugfs_remove(phba->debug_dumpHBASlim); /* HBASlim */ |
| 4428 | phba->debug_dumpHBASlim = NULL; |
| 4429 | } |
| 4430 | if (phba->debug_dumpHostSlim) { |
| 4431 | debugfs_remove(phba->debug_dumpHostSlim); /* HostSlim */ |
| 4432 | phba->debug_dumpHostSlim = NULL; |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 4433 | } |
James Smart | e2a0a9d | 2008-12-04 22:40:02 -0500 | [diff] [blame] | 4434 | if (phba->debug_dumpData) { |
| 4435 | debugfs_remove(phba->debug_dumpData); /* dumpData */ |
| 4436 | phba->debug_dumpData = NULL; |
| 4437 | } |
| 4438 | |
| 4439 | if (phba->debug_dumpDif) { |
| 4440 | debugfs_remove(phba->debug_dumpDif); /* dumpDif */ |
| 4441 | phba->debug_dumpDif = NULL; |
| 4442 | } |
James Smart | f9bb2da | 2011-10-10 21:34:11 -0400 | [diff] [blame] | 4443 | if (phba->debug_InjErrLBA) { |
| 4444 | debugfs_remove(phba->debug_InjErrLBA); /* InjErrLBA */ |
| 4445 | phba->debug_InjErrLBA = NULL; |
| 4446 | } |
James Smart | 4ac9b22 | 2012-03-01 22:38:29 -0500 | [diff] [blame] | 4447 | if (phba->debug_InjErrNPortID) { /* InjErrNPortID */ |
| 4448 | debugfs_remove(phba->debug_InjErrNPortID); |
| 4449 | phba->debug_InjErrNPortID = NULL; |
| 4450 | } |
| 4451 | if (phba->debug_InjErrWWPN) { |
| 4452 | debugfs_remove(phba->debug_InjErrWWPN); /* InjErrWWPN */ |
| 4453 | phba->debug_InjErrWWPN = NULL; |
| 4454 | } |
James Smart | f9bb2da | 2011-10-10 21:34:11 -0400 | [diff] [blame] | 4455 | if (phba->debug_writeGuard) { |
| 4456 | debugfs_remove(phba->debug_writeGuard); /* writeGuard */ |
| 4457 | phba->debug_writeGuard = NULL; |
| 4458 | } |
| 4459 | if (phba->debug_writeApp) { |
| 4460 | debugfs_remove(phba->debug_writeApp); /* writeApp */ |
| 4461 | phba->debug_writeApp = NULL; |
| 4462 | } |
| 4463 | if (phba->debug_writeRef) { |
| 4464 | debugfs_remove(phba->debug_writeRef); /* writeRef */ |
| 4465 | phba->debug_writeRef = NULL; |
| 4466 | } |
James Smart | acd6859 | 2012-01-18 16:25:09 -0500 | [diff] [blame] | 4467 | if (phba->debug_readGuard) { |
| 4468 | debugfs_remove(phba->debug_readGuard); /* readGuard */ |
| 4469 | phba->debug_readGuard = NULL; |
| 4470 | } |
James Smart | f9bb2da | 2011-10-10 21:34:11 -0400 | [diff] [blame] | 4471 | if (phba->debug_readApp) { |
| 4472 | debugfs_remove(phba->debug_readApp); /* readApp */ |
| 4473 | phba->debug_readApp = NULL; |
| 4474 | } |
| 4475 | if (phba->debug_readRef) { |
| 4476 | debugfs_remove(phba->debug_readRef); /* readRef */ |
| 4477 | phba->debug_readRef = NULL; |
| 4478 | } |
James Smart | e2a0a9d | 2008-12-04 22:40:02 -0500 | [diff] [blame] | 4479 | |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 4480 | if (phba->slow_ring_trc) { |
| 4481 | kfree(phba->slow_ring_trc); |
| 4482 | phba->slow_ring_trc = NULL; |
| 4483 | } |
| 4484 | if (phba->debug_slow_ring_trc) { |
| 4485 | /* slow_ring_trace */ |
| 4486 | debugfs_remove(phba->debug_slow_ring_trc); |
| 4487 | phba->debug_slow_ring_trc = NULL; |
| 4488 | } |
| 4489 | |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 4490 | /* |
| 4491 | * iDiag release |
| 4492 | */ |
| 4493 | if (phba->sli_rev == LPFC_SLI_REV4) { |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 4494 | if (phba->idiag_ext_acc) { |
| 4495 | /* iDiag extAcc */ |
| 4496 | debugfs_remove(phba->idiag_ext_acc); |
| 4497 | phba->idiag_ext_acc = NULL; |
| 4498 | } |
| 4499 | if (phba->idiag_mbx_acc) { |
| 4500 | /* iDiag mbxAcc */ |
| 4501 | debugfs_remove(phba->idiag_mbx_acc); |
| 4502 | phba->idiag_mbx_acc = NULL; |
| 4503 | } |
| 4504 | if (phba->idiag_ctl_acc) { |
| 4505 | /* iDiag ctlAcc */ |
| 4506 | debugfs_remove(phba->idiag_ctl_acc); |
| 4507 | phba->idiag_ctl_acc = NULL; |
| 4508 | } |
James Smart | 86a8084 | 2011-04-16 11:03:04 -0400 | [diff] [blame] | 4509 | if (phba->idiag_drb_acc) { |
| 4510 | /* iDiag drbAcc */ |
| 4511 | debugfs_remove(phba->idiag_drb_acc); |
| 4512 | phba->idiag_drb_acc = NULL; |
| 4513 | } |
| 4514 | if (phba->idiag_que_acc) { |
| 4515 | /* iDiag queAcc */ |
| 4516 | debugfs_remove(phba->idiag_que_acc); |
| 4517 | phba->idiag_que_acc = NULL; |
| 4518 | } |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 4519 | if (phba->idiag_que_info) { |
| 4520 | /* iDiag queInfo */ |
| 4521 | debugfs_remove(phba->idiag_que_info); |
| 4522 | phba->idiag_que_info = NULL; |
| 4523 | } |
James Smart | b76f2dc | 2011-07-22 18:37:42 -0400 | [diff] [blame] | 4524 | if (phba->idiag_bar_acc) { |
| 4525 | /* iDiag barAcc */ |
| 4526 | debugfs_remove(phba->idiag_bar_acc); |
| 4527 | phba->idiag_bar_acc = NULL; |
| 4528 | } |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 4529 | if (phba->idiag_pci_cfg) { |
| 4530 | /* iDiag pciCfg */ |
| 4531 | debugfs_remove(phba->idiag_pci_cfg); |
| 4532 | phba->idiag_pci_cfg = NULL; |
| 4533 | } |
| 4534 | |
| 4535 | /* Finally remove the iDiag debugfs root */ |
| 4536 | if (phba->idiag_root) { |
| 4537 | /* iDiag root */ |
| 4538 | debugfs_remove(phba->idiag_root); |
| 4539 | phba->idiag_root = NULL; |
| 4540 | } |
| 4541 | } |
| 4542 | |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 4543 | if (phba->hba_debugfs_root) { |
James Smart | 2a622bf | 2011-02-16 12:40:06 -0500 | [diff] [blame] | 4544 | debugfs_remove(phba->hba_debugfs_root); /* fnX */ |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 4545 | phba->hba_debugfs_root = NULL; |
| 4546 | atomic_dec(&lpfc_debugfs_hba_count); |
| 4547 | } |
| 4548 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4549 | if (atomic_read(&lpfc_debugfs_hba_count) == 0) { |
| 4550 | debugfs_remove(lpfc_debugfs_root); /* lpfc */ |
| 4551 | lpfc_debugfs_root = NULL; |
| 4552 | } |
| 4553 | } |
| 4554 | #endif |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 4555 | return; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4556 | } |
James Smart | 809c753 | 2012-05-09 21:19:25 -0400 | [diff] [blame] | 4557 | |
| 4558 | /* |
| 4559 | * Driver debug utility routines outside of debugfs. The debug utility |
| 4560 | * routines implemented here is intended to be used in the instrumented |
| 4561 | * debug driver for debugging host or port issues. |
| 4562 | */ |
| 4563 | |
| 4564 | /** |
| 4565 | * lpfc_debug_dump_all_queues - dump all the queues with a hba |
| 4566 | * @phba: Pointer to HBA context object. |
| 4567 | * |
| 4568 | * This function dumps entries of all the queues asociated with the @phba. |
| 4569 | **/ |
| 4570 | void |
| 4571 | lpfc_debug_dump_all_queues(struct lpfc_hba *phba) |
| 4572 | { |
| 4573 | int fcp_wqidx; |
| 4574 | |
| 4575 | /* |
| 4576 | * Dump Work Queues (WQs) |
| 4577 | */ |
| 4578 | lpfc_debug_dump_mbx_wq(phba); |
| 4579 | lpfc_debug_dump_els_wq(phba); |
| 4580 | |
James Smart | 67d1273 | 2012-08-03 12:36:13 -0400 | [diff] [blame] | 4581 | for (fcp_wqidx = 0; fcp_wqidx < phba->cfg_fcp_io_channel; fcp_wqidx++) |
James Smart | 809c753 | 2012-05-09 21:19:25 -0400 | [diff] [blame] | 4582 | lpfc_debug_dump_fcp_wq(phba, fcp_wqidx); |
| 4583 | |
| 4584 | lpfc_debug_dump_hdr_rq(phba); |
| 4585 | lpfc_debug_dump_dat_rq(phba); |
| 4586 | /* |
| 4587 | * Dump Complete Queues (CQs) |
| 4588 | */ |
| 4589 | lpfc_debug_dump_mbx_cq(phba); |
| 4590 | lpfc_debug_dump_els_cq(phba); |
| 4591 | |
James Smart | 67d1273 | 2012-08-03 12:36:13 -0400 | [diff] [blame] | 4592 | for (fcp_wqidx = 0; fcp_wqidx < phba->cfg_fcp_io_channel; fcp_wqidx++) |
James Smart | 809c753 | 2012-05-09 21:19:25 -0400 | [diff] [blame] | 4593 | lpfc_debug_dump_fcp_cq(phba, fcp_wqidx); |
| 4594 | |
| 4595 | /* |
| 4596 | * Dump Event Queues (EQs) |
| 4597 | */ |
James Smart | 67d1273 | 2012-08-03 12:36:13 -0400 | [diff] [blame] | 4598 | for (fcp_wqidx = 0; fcp_wqidx < phba->cfg_fcp_io_channel; fcp_wqidx++) |
| 4599 | lpfc_debug_dump_hba_eq(phba, fcp_wqidx); |
James Smart | 809c753 | 2012-05-09 21:19:25 -0400 | [diff] [blame] | 4600 | } |