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