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 | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4 | * Copyright (C) 2007-2008 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> |
| 23 | #include <linux/dma-mapping.h> |
| 24 | #include <linux/idr.h> |
| 25 | #include <linux/interrupt.h> |
| 26 | #include <linux/kthread.h> |
| 27 | #include <linux/pci.h> |
| 28 | #include <linux/spinlock.h> |
| 29 | #include <linux/ctype.h> |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 30 | |
| 31 | #include <scsi/scsi.h> |
| 32 | #include <scsi/scsi_device.h> |
| 33 | #include <scsi/scsi_host.h> |
| 34 | #include <scsi/scsi_transport_fc.h> |
| 35 | |
| 36 | #include "lpfc_hw.h" |
| 37 | #include "lpfc_sli.h" |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 38 | #include "lpfc_nl.h" |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 39 | #include "lpfc_disc.h" |
| 40 | #include "lpfc_scsi.h" |
| 41 | #include "lpfc.h" |
| 42 | #include "lpfc_logmsg.h" |
| 43 | #include "lpfc_crtn.h" |
| 44 | #include "lpfc_vport.h" |
| 45 | #include "lpfc_version.h" |
James Smart | c95d6c6 | 2008-01-11 01:53:23 -0500 | [diff] [blame] | 46 | #include "lpfc_compat.h" |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 47 | #include "lpfc_debugfs.h" |
| 48 | |
James Smart | 923e4b6 | 2008-12-04 22:40:07 -0500 | [diff] [blame] | 49 | #ifdef CONFIG_SCSI_LPFC_DEBUG_FS |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 50 | /* |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 51 | * debugfs interface |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 52 | * |
| 53 | * To access this interface the user should: |
| 54 | * # mkdir /debug |
| 55 | * # mount -t debugfs none /debug |
| 56 | * |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 57 | * The lpfc debugfs directory hierarchy is: |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 58 | * lpfc/lpfcX/vportY |
| 59 | * where X is the lpfc hba unique_id |
| 60 | * where Y is the vport VPI on that hba |
| 61 | * |
| 62 | * Debugging services available per vport: |
| 63 | * discovery_trace |
| 64 | * This is an ACSII readable file that contains a trace of the last |
| 65 | * lpfc_debugfs_max_disc_trc events that happened on a specific vport. |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 66 | * See lpfc_debugfs.h for different categories of discovery events. |
| 67 | * To enable the discovery trace, the following module parameters must be set: |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 68 | * lpfc_debugfs_enable=1 Turns on lpfc debugfs filesystem support |
| 69 | * lpfc_debugfs_max_disc_trc=X Where X is the event trace depth for |
| 70 | * EACH vport. X MUST also be a power of 2. |
| 71 | * lpfc_debugfs_mask_disc_trc=Y Where Y is an event mask as defined in |
| 72 | * lpfc_debugfs.h . |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 73 | * |
| 74 | * slow_ring_trace |
| 75 | * This is an ACSII readable file that contains a trace of the last |
| 76 | * lpfc_debugfs_max_slow_ring_trc events that happened on a specific HBA. |
| 77 | * To enable the slow ring trace, the following module parameters must be set: |
| 78 | * lpfc_debugfs_enable=1 Turns on lpfc debugfs filesystem support |
| 79 | * lpfc_debugfs_max_slow_ring_trc=X Where X is the event trace depth for |
| 80 | * the HBA. X MUST also be a power of 2. |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 81 | */ |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 82 | static int lpfc_debugfs_enable = 1; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 83 | module_param(lpfc_debugfs_enable, int, 0); |
| 84 | MODULE_PARM_DESC(lpfc_debugfs_enable, "Enable debugfs services"); |
| 85 | |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 86 | /* This MUST be a power of 2 */ |
James Smart | c95d6c6 | 2008-01-11 01:53:23 -0500 | [diff] [blame] | 87 | static int lpfc_debugfs_max_disc_trc; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 88 | module_param(lpfc_debugfs_max_disc_trc, int, 0); |
| 89 | MODULE_PARM_DESC(lpfc_debugfs_max_disc_trc, |
| 90 | "Set debugfs discovery trace depth"); |
| 91 | |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 92 | /* This MUST be a power of 2 */ |
James Smart | c95d6c6 | 2008-01-11 01:53:23 -0500 | [diff] [blame] | 93 | static int lpfc_debugfs_max_slow_ring_trc; |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 94 | module_param(lpfc_debugfs_max_slow_ring_trc, int, 0); |
| 95 | MODULE_PARM_DESC(lpfc_debugfs_max_slow_ring_trc, |
| 96 | "Set debugfs slow ring trace depth"); |
| 97 | |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 98 | static int lpfc_debugfs_mask_disc_trc; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 99 | module_param(lpfc_debugfs_mask_disc_trc, int, 0); |
| 100 | MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc, |
| 101 | "Set debugfs discovery trace mask"); |
| 102 | |
| 103 | #include <linux/debugfs.h> |
| 104 | |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 105 | /* size of output line, for discovery_trace and slow_ring_trace */ |
| 106 | #define LPFC_DEBUG_TRC_ENTRY_SIZE 100 |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 107 | |
| 108 | /* nodelist output buffer size */ |
| 109 | #define LPFC_NODELIST_SIZE 8192 |
| 110 | #define LPFC_NODELIST_ENTRY_SIZE 120 |
| 111 | |
James Smart | c95d6c6 | 2008-01-11 01:53:23 -0500 | [diff] [blame] | 112 | /* dumpHBASlim output buffer size */ |
| 113 | #define LPFC_DUMPHBASLIM_SIZE 4096 |
| 114 | |
| 115 | /* dumpHostSlim output buffer size */ |
| 116 | #define LPFC_DUMPHOSTSLIM_SIZE 4096 |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 117 | |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 118 | /* hbqinfo output buffer size */ |
| 119 | #define LPFC_HBQINFO_SIZE 8192 |
| 120 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 121 | struct lpfc_debug { |
| 122 | char *buffer; |
| 123 | int len; |
| 124 | }; |
| 125 | |
James Smart | 311464e | 2007-08-02 11:10:37 -0400 | [diff] [blame] | 126 | static atomic_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0); |
| 127 | static unsigned long lpfc_debugfs_start_time = 0L; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 128 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 129 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 130 | * lpfc_debugfs_disc_trc_data - Dump discovery logging to a buffer |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 131 | * @vport: The vport to gather the log info from. |
| 132 | * @buf: The buffer to dump log into. |
| 133 | * @size: The maximum amount of data to process. |
| 134 | * |
| 135 | * Description: |
| 136 | * This routine gathers the lpfc discovery debugfs data from the @vport and |
| 137 | * dumps it to @buf up to @size number of bytes. It will start at the next entry |
| 138 | * in the log and process the log until the end of the buffer. Then it will |
| 139 | * gather from the beginning of the log and process until the current entry. |
| 140 | * |
| 141 | * Notes: |
| 142 | * Discovery logging will be disabled while while this routine dumps the log. |
| 143 | * |
| 144 | * Return Value: |
| 145 | * This routine returns the amount of bytes that were dumped into @buf and will |
| 146 | * not exceed @size. |
| 147 | **/ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 148 | static int |
| 149 | lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size) |
| 150 | { |
| 151 | int i, index, len, enable; |
| 152 | uint32_t ms; |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 153 | struct lpfc_debugfs_trc *dtp; |
| 154 | char buffer[LPFC_DEBUG_TRC_ENTRY_SIZE]; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 155 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 156 | enable = lpfc_debugfs_enable; |
| 157 | lpfc_debugfs_enable = 0; |
| 158 | |
| 159 | len = 0; |
| 160 | index = (atomic_read(&vport->disc_trc_cnt) + 1) & |
| 161 | (lpfc_debugfs_max_disc_trc - 1); |
| 162 | for (i = index; i < lpfc_debugfs_max_disc_trc; i++) { |
| 163 | dtp = vport->disc_trc + i; |
| 164 | if (!dtp->fmt) |
| 165 | continue; |
| 166 | ms = jiffies_to_msecs(dtp->jif - lpfc_debugfs_start_time); |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 167 | snprintf(buffer, |
| 168 | LPFC_DEBUG_TRC_ENTRY_SIZE, "%010d:%010d ms:%s\n", |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 169 | dtp->seq_cnt, ms, dtp->fmt); |
| 170 | len += snprintf(buf+len, size-len, buffer, |
| 171 | dtp->data1, dtp->data2, dtp->data3); |
| 172 | } |
| 173 | for (i = 0; i < index; i++) { |
| 174 | dtp = vport->disc_trc + i; |
| 175 | if (!dtp->fmt) |
| 176 | continue; |
| 177 | ms = jiffies_to_msecs(dtp->jif - lpfc_debugfs_start_time); |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 178 | snprintf(buffer, |
| 179 | LPFC_DEBUG_TRC_ENTRY_SIZE, "%010d:%010d ms:%s\n", |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 180 | dtp->seq_cnt, ms, dtp->fmt); |
| 181 | len += snprintf(buf+len, size-len, buffer, |
| 182 | dtp->data1, dtp->data2, dtp->data3); |
| 183 | } |
| 184 | |
| 185 | lpfc_debugfs_enable = enable; |
| 186 | return len; |
| 187 | } |
| 188 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 189 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 190 | * 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] | 191 | * @phba: The HBA to gather the log info from. |
| 192 | * @buf: The buffer to dump log into. |
| 193 | * @size: The maximum amount of data to process. |
| 194 | * |
| 195 | * Description: |
| 196 | * This routine gathers the lpfc slow ring debugfs data from the @phba and |
| 197 | * dumps it to @buf up to @size number of bytes. It will start at the next entry |
| 198 | * in the log and process the log until the end of the buffer. Then it will |
| 199 | * gather from the beginning of the log and process until the current entry. |
| 200 | * |
| 201 | * Notes: |
| 202 | * Slow ring logging will be disabled while while this routine dumps the log. |
| 203 | * |
| 204 | * Return Value: |
| 205 | * This routine returns the amount of bytes that were dumped into @buf and will |
| 206 | * not exceed @size. |
| 207 | **/ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 208 | static int |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 209 | lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba *phba, char *buf, int size) |
| 210 | { |
| 211 | int i, index, len, enable; |
| 212 | uint32_t ms; |
| 213 | struct lpfc_debugfs_trc *dtp; |
| 214 | char buffer[LPFC_DEBUG_TRC_ENTRY_SIZE]; |
| 215 | |
| 216 | |
| 217 | enable = lpfc_debugfs_enable; |
| 218 | lpfc_debugfs_enable = 0; |
| 219 | |
| 220 | len = 0; |
| 221 | index = (atomic_read(&phba->slow_ring_trc_cnt) + 1) & |
| 222 | (lpfc_debugfs_max_slow_ring_trc - 1); |
| 223 | for (i = index; i < lpfc_debugfs_max_slow_ring_trc; i++) { |
| 224 | dtp = phba->slow_ring_trc + i; |
| 225 | if (!dtp->fmt) |
| 226 | continue; |
| 227 | ms = jiffies_to_msecs(dtp->jif - lpfc_debugfs_start_time); |
| 228 | snprintf(buffer, |
| 229 | LPFC_DEBUG_TRC_ENTRY_SIZE, "%010d:%010d ms:%s\n", |
| 230 | dtp->seq_cnt, ms, dtp->fmt); |
| 231 | len += snprintf(buf+len, size-len, buffer, |
| 232 | dtp->data1, dtp->data2, dtp->data3); |
| 233 | } |
| 234 | for (i = 0; i < index; i++) { |
| 235 | dtp = phba->slow_ring_trc + i; |
| 236 | if (!dtp->fmt) |
| 237 | continue; |
| 238 | ms = jiffies_to_msecs(dtp->jif - lpfc_debugfs_start_time); |
| 239 | snprintf(buffer, |
| 240 | LPFC_DEBUG_TRC_ENTRY_SIZE, "%010d:%010d ms:%s\n", |
| 241 | dtp->seq_cnt, ms, dtp->fmt); |
| 242 | len += snprintf(buf+len, size-len, buffer, |
| 243 | dtp->data1, dtp->data2, dtp->data3); |
| 244 | } |
| 245 | |
| 246 | lpfc_debugfs_enable = enable; |
| 247 | return len; |
| 248 | } |
| 249 | |
James Smart | 311464e | 2007-08-02 11:10:37 -0400 | [diff] [blame] | 250 | static int lpfc_debugfs_last_hbq = -1; |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 251 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 252 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 253 | * lpfc_debugfs_hbqinfo_data - Dump host buffer queue info to a buffer |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 254 | * @phba: The HBA to gather host buffer info from. |
| 255 | * @buf: The buffer to dump log into. |
| 256 | * @size: The maximum amount of data to process. |
| 257 | * |
| 258 | * Description: |
| 259 | * This routine dumps the host buffer queue info from the @phba to @buf up to |
| 260 | * @size number of bytes. A header that describes the current hbq state will be |
| 261 | * dumped to @buf first and then info on each hbq entry will be dumped to @buf |
| 262 | * until @size bytes have been dumped or all the hbq info has been dumped. |
| 263 | * |
| 264 | * Notes: |
| 265 | * This routine will rotate through each configured HBQ each time called. |
| 266 | * |
| 267 | * Return Value: |
| 268 | * This routine returns the amount of bytes that were dumped into @buf and will |
| 269 | * not exceed @size. |
| 270 | **/ |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 271 | static int |
| 272 | lpfc_debugfs_hbqinfo_data(struct lpfc_hba *phba, char *buf, int size) |
| 273 | { |
| 274 | int len = 0; |
| 275 | int cnt, i, j, found, posted, low; |
| 276 | uint32_t phys, raw_index, getidx; |
| 277 | struct lpfc_hbq_init *hip; |
| 278 | struct hbq_s *hbqs; |
| 279 | struct lpfc_hbq_entry *hbqe; |
| 280 | struct lpfc_dmabuf *d_buf; |
| 281 | struct hbq_dmabuf *hbq_buf; |
| 282 | |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame^] | 283 | if (phba->sli_rev != 3) |
| 284 | return 0; |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 285 | cnt = LPFC_HBQINFO_SIZE; |
| 286 | spin_lock_irq(&phba->hbalock); |
| 287 | |
| 288 | /* toggle between multiple hbqs, if any */ |
| 289 | i = lpfc_sli_hbq_count(); |
| 290 | if (i > 1) { |
| 291 | lpfc_debugfs_last_hbq++; |
| 292 | if (lpfc_debugfs_last_hbq >= i) |
| 293 | lpfc_debugfs_last_hbq = 0; |
| 294 | } |
| 295 | else |
| 296 | lpfc_debugfs_last_hbq = 0; |
| 297 | |
| 298 | i = lpfc_debugfs_last_hbq; |
| 299 | |
| 300 | len += snprintf(buf+len, size-len, "HBQ %d Info\n", i); |
| 301 | |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 302 | hbqs = &phba->hbqs[i]; |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 303 | posted = 0; |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 304 | list_for_each_entry(d_buf, &hbqs->hbq_buffer_list, list) |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 305 | posted++; |
| 306 | |
| 307 | hip = lpfc_hbq_defs[i]; |
| 308 | len += snprintf(buf+len, size-len, |
| 309 | "idx:%d prof:%d rn:%d bufcnt:%d icnt:%d acnt:%d posted %d\n", |
| 310 | hip->hbq_index, hip->profile, hip->rn, |
| 311 | hip->buffer_count, hip->init_count, hip->add_count, posted); |
| 312 | |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 313 | raw_index = phba->hbq_get[i]; |
| 314 | getidx = le32_to_cpu(raw_index); |
| 315 | len += snprintf(buf+len, size-len, |
James Smart | a8adb83 | 2007-10-27 13:37:53 -0400 | [diff] [blame] | 316 | "entrys:%d bufcnt:%d Put:%d nPut:%d localGet:%d hbaGet:%d\n", |
| 317 | hbqs->entry_count, hbqs->buffer_count, hbqs->hbqPutIdx, |
| 318 | hbqs->next_hbqPutIdx, hbqs->local_hbqGetIdx, getidx); |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 319 | |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 320 | hbqe = (struct lpfc_hbq_entry *) phba->hbqs[i].hbq_virt; |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 321 | for (j=0; j<hbqs->entry_count; j++) { |
| 322 | len += snprintf(buf+len, size-len, |
| 323 | "%03d: %08x %04x %05x ", j, |
James Smart | a8adb83 | 2007-10-27 13:37:53 -0400 | [diff] [blame] | 324 | le32_to_cpu(hbqe->bde.addrLow), |
| 325 | le32_to_cpu(hbqe->bde.tus.w), |
| 326 | le32_to_cpu(hbqe->buffer_tag)); |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 327 | i = 0; |
| 328 | found = 0; |
| 329 | |
| 330 | /* First calculate if slot has an associated posted buffer */ |
| 331 | low = hbqs->hbqPutIdx - posted; |
| 332 | if (low >= 0) { |
| 333 | if ((j >= hbqs->hbqPutIdx) || (j < low)) { |
| 334 | len += snprintf(buf+len, size-len, "Unused\n"); |
| 335 | goto skipit; |
| 336 | } |
| 337 | } |
| 338 | else { |
| 339 | if ((j >= hbqs->hbqPutIdx) && |
| 340 | (j < (hbqs->entry_count+low))) { |
| 341 | len += snprintf(buf+len, size-len, "Unused\n"); |
| 342 | goto skipit; |
| 343 | } |
| 344 | } |
| 345 | |
| 346 | /* Get the Buffer info for the posted buffer */ |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 347 | list_for_each_entry(d_buf, &hbqs->hbq_buffer_list, list) { |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 348 | hbq_buf = container_of(d_buf, struct hbq_dmabuf, dbuf); |
| 349 | phys = ((uint64_t)hbq_buf->dbuf.phys & 0xffffffff); |
James Smart | a8adb83 | 2007-10-27 13:37:53 -0400 | [diff] [blame] | 350 | if (phys == le32_to_cpu(hbqe->bde.addrLow)) { |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 351 | len += snprintf(buf+len, size-len, |
| 352 | "Buf%d: %p %06x\n", i, |
| 353 | hbq_buf->dbuf.virt, hbq_buf->tag); |
| 354 | found = 1; |
| 355 | break; |
| 356 | } |
| 357 | i++; |
| 358 | } |
| 359 | if (!found) { |
| 360 | len += snprintf(buf+len, size-len, "No DMAinfo?\n"); |
| 361 | } |
| 362 | skipit: |
| 363 | hbqe++; |
| 364 | if (len > LPFC_HBQINFO_SIZE - 54) |
| 365 | break; |
| 366 | } |
| 367 | spin_unlock_irq(&phba->hbalock); |
| 368 | return len; |
| 369 | } |
| 370 | |
James Smart | c95d6c6 | 2008-01-11 01:53:23 -0500 | [diff] [blame] | 371 | static int lpfc_debugfs_last_hba_slim_off; |
| 372 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 373 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 374 | * lpfc_debugfs_dumpHBASlim_data - Dump HBA SLIM info to a buffer |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 375 | * @phba: The HBA to gather SLIM info from. |
| 376 | * @buf: The buffer to dump log into. |
| 377 | * @size: The maximum amount of data to process. |
| 378 | * |
| 379 | * Description: |
| 380 | * This routine dumps the current contents of HBA SLIM for the HBA associated |
| 381 | * with @phba to @buf up to @size bytes of data. This is the raw HBA SLIM data. |
| 382 | * |
| 383 | * Notes: |
| 384 | * This routine will only dump up to 1024 bytes of data each time called and |
| 385 | * should be called multiple times to dump the entire HBA SLIM. |
| 386 | * |
| 387 | * Return Value: |
| 388 | * This routine returns the amount of bytes that were dumped into @buf and will |
| 389 | * not exceed @size. |
| 390 | **/ |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 391 | static int |
James Smart | c95d6c6 | 2008-01-11 01:53:23 -0500 | [diff] [blame] | 392 | lpfc_debugfs_dumpHBASlim_data(struct lpfc_hba *phba, char *buf, int size) |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 393 | { |
| 394 | int len = 0; |
James Smart | c95d6c6 | 2008-01-11 01:53:23 -0500 | [diff] [blame] | 395 | int i, off; |
| 396 | uint32_t *ptr; |
| 397 | char buffer[1024]; |
| 398 | |
| 399 | off = 0; |
| 400 | spin_lock_irq(&phba->hbalock); |
| 401 | |
| 402 | len += snprintf(buf+len, size-len, "HBA SLIM\n"); |
| 403 | lpfc_memcpy_from_slim(buffer, |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 404 | phba->MBslimaddr + lpfc_debugfs_last_hba_slim_off, 1024); |
James Smart | c95d6c6 | 2008-01-11 01:53:23 -0500 | [diff] [blame] | 405 | |
| 406 | ptr = (uint32_t *)&buffer[0]; |
| 407 | off = lpfc_debugfs_last_hba_slim_off; |
| 408 | |
| 409 | /* Set it up for the next time */ |
| 410 | lpfc_debugfs_last_hba_slim_off += 1024; |
| 411 | if (lpfc_debugfs_last_hba_slim_off >= 4096) |
| 412 | lpfc_debugfs_last_hba_slim_off = 0; |
| 413 | |
| 414 | i = 1024; |
| 415 | while (i > 0) { |
| 416 | len += snprintf(buf+len, size-len, |
| 417 | "%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n", |
| 418 | off, *ptr, *(ptr+1), *(ptr+2), *(ptr+3), *(ptr+4), |
| 419 | *(ptr+5), *(ptr+6), *(ptr+7)); |
| 420 | ptr += 8; |
| 421 | i -= (8 * sizeof(uint32_t)); |
| 422 | off += (8 * sizeof(uint32_t)); |
| 423 | } |
| 424 | |
| 425 | spin_unlock_irq(&phba->hbalock); |
| 426 | return len; |
| 427 | } |
| 428 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 429 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 430 | * lpfc_debugfs_dumpHostSlim_data - Dump host SLIM info to a buffer |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 431 | * @phba: The HBA to gather Host SLIM info from. |
| 432 | * @buf: The buffer to dump log into. |
| 433 | * @size: The maximum amount of data to process. |
| 434 | * |
| 435 | * Description: |
| 436 | * This routine dumps the current contents of host SLIM for the host associated |
| 437 | * with @phba to @buf up to @size bytes of data. The dump will contain the |
| 438 | * Mailbox, PCB, Rings, and Registers that are located in host memory. |
| 439 | * |
| 440 | * Return Value: |
| 441 | * This routine returns the amount of bytes that were dumped into @buf and will |
| 442 | * not exceed @size. |
| 443 | **/ |
James Smart | c95d6c6 | 2008-01-11 01:53:23 -0500 | [diff] [blame] | 444 | static int |
| 445 | lpfc_debugfs_dumpHostSlim_data(struct lpfc_hba *phba, char *buf, int size) |
| 446 | { |
| 447 | int len = 0; |
| 448 | int i, off; |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 449 | uint32_t word0, word1, word2, word3; |
| 450 | uint32_t *ptr; |
| 451 | struct lpfc_pgp *pgpp; |
| 452 | struct lpfc_sli *psli = &phba->sli; |
| 453 | struct lpfc_sli_ring *pring; |
| 454 | |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 455 | off = 0; |
| 456 | spin_lock_irq(&phba->hbalock); |
| 457 | |
| 458 | len += snprintf(buf+len, size-len, "SLIM Mailbox\n"); |
James Smart | 34b02dc | 2008-08-24 21:49:55 -0400 | [diff] [blame] | 459 | ptr = (uint32_t *)phba->slim2p.virt; |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 460 | i = sizeof(MAILBOX_t); |
| 461 | while (i > 0) { |
| 462 | len += snprintf(buf+len, size-len, |
| 463 | "%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n", |
| 464 | off, *ptr, *(ptr+1), *(ptr+2), *(ptr+3), *(ptr+4), |
| 465 | *(ptr+5), *(ptr+6), *(ptr+7)); |
| 466 | ptr += 8; |
| 467 | i -= (8 * sizeof(uint32_t)); |
| 468 | off += (8 * sizeof(uint32_t)); |
| 469 | } |
| 470 | |
| 471 | len += snprintf(buf+len, size-len, "SLIM PCB\n"); |
James Smart | 34b02dc | 2008-08-24 21:49:55 -0400 | [diff] [blame] | 472 | ptr = (uint32_t *)phba->pcb; |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 473 | i = sizeof(PCB_t); |
| 474 | while (i > 0) { |
| 475 | len += snprintf(buf+len, size-len, |
| 476 | "%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n", |
| 477 | off, *ptr, *(ptr+1), *(ptr+2), *(ptr+3), *(ptr+4), |
| 478 | *(ptr+5), *(ptr+6), *(ptr+7)); |
| 479 | ptr += 8; |
| 480 | i -= (8 * sizeof(uint32_t)); |
| 481 | off += (8 * sizeof(uint32_t)); |
| 482 | } |
| 483 | |
James Smart | 34b02dc | 2008-08-24 21:49:55 -0400 | [diff] [blame] | 484 | for (i = 0; i < 4; i++) { |
| 485 | pgpp = &phba->port_gp[i]; |
| 486 | pring = &psli->ring[i]; |
| 487 | len += snprintf(buf+len, size-len, |
| 488 | "Ring %d: CMD GetInx:%d (Max:%d Next:%d " |
| 489 | "Local:%d flg:x%x) RSP PutInx:%d Max:%d\n", |
| 490 | i, pgpp->cmdGetInx, pring->numCiocb, |
| 491 | pring->next_cmdidx, pring->local_getidx, |
| 492 | pring->flag, pgpp->rspPutInx, pring->numRiocb); |
| 493 | } |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame^] | 494 | |
| 495 | if (phba->sli_rev <= LPFC_SLI_REV3) { |
| 496 | word0 = readl(phba->HAregaddr); |
| 497 | word1 = readl(phba->CAregaddr); |
| 498 | word2 = readl(phba->HSregaddr); |
| 499 | word3 = readl(phba->HCregaddr); |
| 500 | len += snprintf(buf+len, size-len, "HA:%08x CA:%08x HS:%08x " |
| 501 | "HC:%08x\n", word0, word1, word2, word3); |
| 502 | } |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 503 | spin_unlock_irq(&phba->hbalock); |
| 504 | return len; |
| 505 | } |
| 506 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 507 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 508 | * lpfc_debugfs_nodelist_data - Dump target node list to a buffer |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 509 | * @vport: The vport to gather target node info from. |
| 510 | * @buf: The buffer to dump log into. |
| 511 | * @size: The maximum amount of data to process. |
| 512 | * |
| 513 | * Description: |
| 514 | * This routine dumps the current target node list associated with @vport to |
| 515 | * @buf up to @size bytes of data. Each node entry in the dump will contain a |
| 516 | * node state, DID, WWPN, WWNN, RPI, flags, type, and other useful fields. |
| 517 | * |
| 518 | * Return Value: |
| 519 | * This routine returns the amount of bytes that were dumped into @buf and will |
| 520 | * not exceed @size. |
| 521 | **/ |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 522 | static int |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 523 | lpfc_debugfs_nodelist_data(struct lpfc_vport *vport, char *buf, int size) |
| 524 | { |
| 525 | int len = 0; |
| 526 | int cnt; |
| 527 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 528 | struct lpfc_nodelist *ndlp; |
| 529 | unsigned char *statep, *name; |
| 530 | |
| 531 | cnt = (LPFC_NODELIST_SIZE / LPFC_NODELIST_ENTRY_SIZE); |
| 532 | |
| 533 | spin_lock_irq(shost->host_lock); |
| 534 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { |
| 535 | if (!cnt) { |
| 536 | len += snprintf(buf+len, size-len, |
| 537 | "Missing Nodelist Entries\n"); |
| 538 | break; |
| 539 | } |
| 540 | cnt--; |
| 541 | switch (ndlp->nlp_state) { |
| 542 | case NLP_STE_UNUSED_NODE: |
| 543 | statep = "UNUSED"; |
| 544 | break; |
| 545 | case NLP_STE_PLOGI_ISSUE: |
| 546 | statep = "PLOGI "; |
| 547 | break; |
| 548 | case NLP_STE_ADISC_ISSUE: |
| 549 | statep = "ADISC "; |
| 550 | break; |
| 551 | case NLP_STE_REG_LOGIN_ISSUE: |
| 552 | statep = "REGLOG"; |
| 553 | break; |
| 554 | case NLP_STE_PRLI_ISSUE: |
| 555 | statep = "PRLI "; |
| 556 | break; |
| 557 | case NLP_STE_UNMAPPED_NODE: |
| 558 | statep = "UNMAP "; |
| 559 | break; |
| 560 | case NLP_STE_MAPPED_NODE: |
| 561 | statep = "MAPPED"; |
| 562 | break; |
| 563 | case NLP_STE_NPR_NODE: |
| 564 | statep = "NPR "; |
| 565 | break; |
| 566 | default: |
| 567 | statep = "UNKNOWN"; |
| 568 | } |
| 569 | len += snprintf(buf+len, size-len, "%s DID:x%06x ", |
| 570 | statep, ndlp->nlp_DID); |
| 571 | name = (unsigned char *)&ndlp->nlp_portname; |
| 572 | len += snprintf(buf+len, size-len, |
| 573 | "WWPN %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x ", |
| 574 | *name, *(name+1), *(name+2), *(name+3), |
| 575 | *(name+4), *(name+5), *(name+6), *(name+7)); |
| 576 | name = (unsigned char *)&ndlp->nlp_nodename; |
| 577 | len += snprintf(buf+len, size-len, |
| 578 | "WWNN %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 | len += snprintf(buf+len, size-len, "RPI:%03d flag:x%08x ", |
| 582 | ndlp->nlp_rpi, ndlp->nlp_flag); |
| 583 | if (!ndlp->nlp_type) |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 584 | len += snprintf(buf+len, size-len, "UNKNOWN_TYPE "); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 585 | if (ndlp->nlp_type & NLP_FC_NODE) |
| 586 | len += snprintf(buf+len, size-len, "FC_NODE "); |
| 587 | if (ndlp->nlp_type & NLP_FABRIC) |
| 588 | len += snprintf(buf+len, size-len, "FABRIC "); |
| 589 | if (ndlp->nlp_type & NLP_FCP_TARGET) |
| 590 | len += snprintf(buf+len, size-len, "FCP_TGT sid:%d ", |
| 591 | ndlp->nlp_sid); |
| 592 | if (ndlp->nlp_type & NLP_FCP_INITIATOR) |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 593 | len += snprintf(buf+len, size-len, "FCP_INITIATOR "); |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 594 | len += snprintf(buf+len, size-len, "usgmap:%x ", |
| 595 | ndlp->nlp_usg_map); |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 596 | len += snprintf(buf+len, size-len, "refcnt:%x", |
| 597 | atomic_read(&ndlp->kref.refcount)); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 598 | len += snprintf(buf+len, size-len, "\n"); |
| 599 | } |
| 600 | spin_unlock_irq(shost->host_lock); |
| 601 | return len; |
| 602 | } |
| 603 | #endif |
| 604 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 605 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 606 | * lpfc_debugfs_disc_trc - Store discovery trace log |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 607 | * @vport: The vport to associate this trace string with for retrieval. |
| 608 | * @mask: Log entry classification. |
| 609 | * @fmt: Format string to be displayed when dumping the log. |
| 610 | * @data1: 1st data parameter to be applied to @fmt. |
| 611 | * @data2: 2nd data parameter to be applied to @fmt. |
| 612 | * @data3: 3rd data parameter to be applied to @fmt. |
| 613 | * |
| 614 | * Description: |
| 615 | * This routine is used by the driver code to add a debugfs log entry to the |
| 616 | * discovery trace buffer associated with @vport. Only entries with a @mask that |
| 617 | * match the current debugfs discovery mask will be saved. Entries that do not |
| 618 | * match will be thrown away. @fmt, @data1, @data2, and @data3 are used like |
| 619 | * printf when displaying the log. |
| 620 | **/ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 621 | inline void |
| 622 | lpfc_debugfs_disc_trc(struct lpfc_vport *vport, int mask, char *fmt, |
| 623 | uint32_t data1, uint32_t data2, uint32_t data3) |
| 624 | { |
James Smart | 923e4b6 | 2008-12-04 22:40:07 -0500 | [diff] [blame] | 625 | #ifdef CONFIG_SCSI_LPFC_DEBUG_FS |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 626 | struct lpfc_debugfs_trc *dtp; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 627 | int index; |
| 628 | |
| 629 | if (!(lpfc_debugfs_mask_disc_trc & mask)) |
| 630 | return; |
| 631 | |
| 632 | if (!lpfc_debugfs_enable || !lpfc_debugfs_max_disc_trc || |
| 633 | !vport || !vport->disc_trc) |
| 634 | return; |
| 635 | |
| 636 | index = atomic_inc_return(&vport->disc_trc_cnt) & |
| 637 | (lpfc_debugfs_max_disc_trc - 1); |
| 638 | dtp = vport->disc_trc + index; |
| 639 | dtp->fmt = fmt; |
| 640 | dtp->data1 = data1; |
| 641 | dtp->data2 = data2; |
| 642 | dtp->data3 = data3; |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 643 | dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt); |
| 644 | dtp->jif = jiffies; |
| 645 | #endif |
| 646 | return; |
| 647 | } |
| 648 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 649 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 650 | * lpfc_debugfs_slow_ring_trc - Store slow ring trace log |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 651 | * @phba: The phba to associate this trace string with for retrieval. |
| 652 | * @fmt: Format string to be displayed when dumping the log. |
| 653 | * @data1: 1st data parameter to be applied to @fmt. |
| 654 | * @data2: 2nd data parameter to be applied to @fmt. |
| 655 | * @data3: 3rd data parameter to be applied to @fmt. |
| 656 | * |
| 657 | * Description: |
| 658 | * This routine is used by the driver code to add a debugfs log entry to the |
| 659 | * discovery trace buffer associated with @vport. @fmt, @data1, @data2, and |
| 660 | * @data3 are used like printf when displaying the log. |
| 661 | **/ |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 662 | inline void |
| 663 | lpfc_debugfs_slow_ring_trc(struct lpfc_hba *phba, char *fmt, |
| 664 | uint32_t data1, uint32_t data2, uint32_t data3) |
| 665 | { |
James Smart | 923e4b6 | 2008-12-04 22:40:07 -0500 | [diff] [blame] | 666 | #ifdef CONFIG_SCSI_LPFC_DEBUG_FS |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 667 | struct lpfc_debugfs_trc *dtp; |
| 668 | int index; |
| 669 | |
| 670 | if (!lpfc_debugfs_enable || !lpfc_debugfs_max_slow_ring_trc || |
| 671 | !phba || !phba->slow_ring_trc) |
| 672 | return; |
| 673 | |
| 674 | index = atomic_inc_return(&phba->slow_ring_trc_cnt) & |
| 675 | (lpfc_debugfs_max_slow_ring_trc - 1); |
| 676 | dtp = phba->slow_ring_trc + index; |
| 677 | dtp->fmt = fmt; |
| 678 | dtp->data1 = data1; |
| 679 | dtp->data2 = data2; |
| 680 | dtp->data3 = data3; |
| 681 | dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 682 | dtp->jif = jiffies; |
| 683 | #endif |
| 684 | return; |
| 685 | } |
| 686 | |
James Smart | 923e4b6 | 2008-12-04 22:40:07 -0500 | [diff] [blame] | 687 | #ifdef CONFIG_SCSI_LPFC_DEBUG_FS |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 688 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 689 | * lpfc_debugfs_disc_trc_open - Open the discovery trace log |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 690 | * @inode: The inode pointer that contains a vport pointer. |
| 691 | * @file: The file pointer to attach the log output. |
| 692 | * |
| 693 | * Description: |
| 694 | * This routine is the entry point for the debugfs open file operation. It gets |
| 695 | * the vport from the i_private field in @inode, allocates the necessary buffer |
| 696 | * for the log, fills the buffer from the in-memory log for this vport, and then |
| 697 | * returns a pointer to that log in the private_data field in @file. |
| 698 | * |
| 699 | * Returns: |
| 700 | * This function returns zero if successful. On error it will return an negative |
| 701 | * error value. |
| 702 | **/ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 703 | static int |
| 704 | lpfc_debugfs_disc_trc_open(struct inode *inode, struct file *file) |
| 705 | { |
| 706 | struct lpfc_vport *vport = inode->i_private; |
| 707 | struct lpfc_debug *debug; |
| 708 | int size; |
| 709 | int rc = -ENOMEM; |
| 710 | |
| 711 | if (!lpfc_debugfs_max_disc_trc) { |
| 712 | rc = -ENOSPC; |
| 713 | goto out; |
| 714 | } |
| 715 | |
| 716 | debug = kmalloc(sizeof(*debug), GFP_KERNEL); |
| 717 | if (!debug) |
| 718 | goto out; |
| 719 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 720 | /* Round to page boundary */ |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 721 | size = (lpfc_debugfs_max_disc_trc * LPFC_DEBUG_TRC_ENTRY_SIZE); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 722 | size = PAGE_ALIGN(size); |
| 723 | |
| 724 | debug->buffer = kmalloc(size, GFP_KERNEL); |
| 725 | if (!debug->buffer) { |
| 726 | kfree(debug); |
| 727 | goto out; |
| 728 | } |
| 729 | |
| 730 | debug->len = lpfc_debugfs_disc_trc_data(vport, debug->buffer, size); |
| 731 | file->private_data = debug; |
| 732 | |
| 733 | rc = 0; |
| 734 | out: |
| 735 | return rc; |
| 736 | } |
| 737 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 738 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 739 | * lpfc_debugfs_slow_ring_trc_open - Open the Slow Ring trace log |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 740 | * @inode: The inode pointer that contains a vport pointer. |
| 741 | * @file: The file pointer to attach the log output. |
| 742 | * |
| 743 | * Description: |
| 744 | * This routine is the entry point for the debugfs open file operation. It gets |
| 745 | * the vport from the i_private field in @inode, allocates the necessary buffer |
| 746 | * for the log, fills the buffer from the in-memory log for this vport, and then |
| 747 | * returns a pointer to that log in the private_data field in @file. |
| 748 | * |
| 749 | * Returns: |
| 750 | * This function returns zero if successful. On error it will return an negative |
| 751 | * error value. |
| 752 | **/ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 753 | static int |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 754 | lpfc_debugfs_slow_ring_trc_open(struct inode *inode, struct file *file) |
| 755 | { |
| 756 | struct lpfc_hba *phba = inode->i_private; |
| 757 | struct lpfc_debug *debug; |
| 758 | int size; |
| 759 | int rc = -ENOMEM; |
| 760 | |
| 761 | if (!lpfc_debugfs_max_slow_ring_trc) { |
| 762 | rc = -ENOSPC; |
| 763 | goto out; |
| 764 | } |
| 765 | |
| 766 | debug = kmalloc(sizeof(*debug), GFP_KERNEL); |
| 767 | if (!debug) |
| 768 | goto out; |
| 769 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 770 | /* Round to page boundary */ |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 771 | size = (lpfc_debugfs_max_slow_ring_trc * LPFC_DEBUG_TRC_ENTRY_SIZE); |
| 772 | size = PAGE_ALIGN(size); |
| 773 | |
| 774 | debug->buffer = kmalloc(size, GFP_KERNEL); |
| 775 | if (!debug->buffer) { |
| 776 | kfree(debug); |
| 777 | goto out; |
| 778 | } |
| 779 | |
| 780 | debug->len = lpfc_debugfs_slow_ring_trc_data(phba, debug->buffer, size); |
| 781 | file->private_data = debug; |
| 782 | |
| 783 | rc = 0; |
| 784 | out: |
| 785 | return rc; |
| 786 | } |
| 787 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 788 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 789 | * lpfc_debugfs_hbqinfo_open - Open the hbqinfo debugfs buffer |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 790 | * @inode: The inode pointer that contains a vport pointer. |
| 791 | * @file: The file pointer to attach the log output. |
| 792 | * |
| 793 | * Description: |
| 794 | * This routine is the entry point for the debugfs open file operation. It gets |
| 795 | * the vport from the i_private field in @inode, allocates the necessary buffer |
| 796 | * for the log, fills the buffer from the in-memory log for this vport, and then |
| 797 | * returns a pointer to that log in the private_data field in @file. |
| 798 | * |
| 799 | * Returns: |
| 800 | * This function returns zero if successful. On error it will return an negative |
| 801 | * error value. |
| 802 | **/ |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 803 | static int |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 804 | lpfc_debugfs_hbqinfo_open(struct inode *inode, struct file *file) |
| 805 | { |
| 806 | struct lpfc_hba *phba = inode->i_private; |
| 807 | struct lpfc_debug *debug; |
| 808 | int rc = -ENOMEM; |
| 809 | |
| 810 | debug = kmalloc(sizeof(*debug), GFP_KERNEL); |
| 811 | if (!debug) |
| 812 | goto out; |
| 813 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 814 | /* Round to page boundary */ |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 815 | debug->buffer = kmalloc(LPFC_HBQINFO_SIZE, GFP_KERNEL); |
| 816 | if (!debug->buffer) { |
| 817 | kfree(debug); |
| 818 | goto out; |
| 819 | } |
| 820 | |
| 821 | debug->len = lpfc_debugfs_hbqinfo_data(phba, debug->buffer, |
| 822 | LPFC_HBQINFO_SIZE); |
| 823 | file->private_data = debug; |
| 824 | |
| 825 | rc = 0; |
| 826 | out: |
| 827 | return rc; |
| 828 | } |
| 829 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 830 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 831 | * lpfc_debugfs_dumpHBASlim_open - Open the Dump HBA SLIM debugfs buffer |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 832 | * @inode: The inode pointer that contains a vport pointer. |
| 833 | * @file: The file pointer to attach the log output. |
| 834 | * |
| 835 | * Description: |
| 836 | * This routine is the entry point for the debugfs open file operation. It gets |
| 837 | * the vport from the i_private field in @inode, allocates the necessary buffer |
| 838 | * for the log, fills the buffer from the in-memory log for this vport, and then |
| 839 | * returns a pointer to that log in the private_data field in @file. |
| 840 | * |
| 841 | * Returns: |
| 842 | * This function returns zero if successful. On error it will return an negative |
| 843 | * error value. |
| 844 | **/ |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 845 | static int |
James Smart | c95d6c6 | 2008-01-11 01:53:23 -0500 | [diff] [blame] | 846 | lpfc_debugfs_dumpHBASlim_open(struct inode *inode, struct file *file) |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 847 | { |
| 848 | struct lpfc_hba *phba = inode->i_private; |
| 849 | struct lpfc_debug *debug; |
| 850 | int rc = -ENOMEM; |
| 851 | |
| 852 | debug = kmalloc(sizeof(*debug), GFP_KERNEL); |
| 853 | if (!debug) |
| 854 | goto out; |
| 855 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 856 | /* Round to page boundary */ |
James Smart | c95d6c6 | 2008-01-11 01:53:23 -0500 | [diff] [blame] | 857 | debug->buffer = kmalloc(LPFC_DUMPHBASLIM_SIZE, GFP_KERNEL); |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 858 | if (!debug->buffer) { |
| 859 | kfree(debug); |
| 860 | goto out; |
| 861 | } |
| 862 | |
James Smart | c95d6c6 | 2008-01-11 01:53:23 -0500 | [diff] [blame] | 863 | debug->len = lpfc_debugfs_dumpHBASlim_data(phba, debug->buffer, |
| 864 | LPFC_DUMPHBASLIM_SIZE); |
| 865 | file->private_data = debug; |
| 866 | |
| 867 | rc = 0; |
| 868 | out: |
| 869 | return rc; |
| 870 | } |
| 871 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 872 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 873 | * lpfc_debugfs_dumpHostSlim_open - Open the Dump Host SLIM debugfs buffer |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 874 | * @inode: The inode pointer that contains a vport pointer. |
| 875 | * @file: The file pointer to attach the log output. |
| 876 | * |
| 877 | * Description: |
| 878 | * This routine is the entry point for the debugfs open file operation. It gets |
| 879 | * the vport from the i_private field in @inode, allocates the necessary buffer |
| 880 | * for the log, fills the buffer from the in-memory log for this vport, and then |
| 881 | * returns a pointer to that log in the private_data field in @file. |
| 882 | * |
| 883 | * Returns: |
| 884 | * This function returns zero if successful. On error it will return an negative |
| 885 | * error value. |
| 886 | **/ |
James Smart | c95d6c6 | 2008-01-11 01:53:23 -0500 | [diff] [blame] | 887 | static int |
| 888 | lpfc_debugfs_dumpHostSlim_open(struct inode *inode, struct file *file) |
| 889 | { |
| 890 | struct lpfc_hba *phba = inode->i_private; |
| 891 | struct lpfc_debug *debug; |
| 892 | int rc = -ENOMEM; |
| 893 | |
| 894 | debug = kmalloc(sizeof(*debug), GFP_KERNEL); |
| 895 | if (!debug) |
| 896 | goto out; |
| 897 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 898 | /* Round to page boundary */ |
James Smart | c95d6c6 | 2008-01-11 01:53:23 -0500 | [diff] [blame] | 899 | debug->buffer = kmalloc(LPFC_DUMPHOSTSLIM_SIZE, GFP_KERNEL); |
| 900 | if (!debug->buffer) { |
| 901 | kfree(debug); |
| 902 | goto out; |
| 903 | } |
| 904 | |
| 905 | debug->len = lpfc_debugfs_dumpHostSlim_data(phba, debug->buffer, |
| 906 | LPFC_DUMPHOSTSLIM_SIZE); |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 907 | file->private_data = debug; |
| 908 | |
| 909 | rc = 0; |
| 910 | out: |
| 911 | return rc; |
| 912 | } |
| 913 | |
James Smart | e2a0a9d | 2008-12-04 22:40:02 -0500 | [diff] [blame] | 914 | static int |
| 915 | lpfc_debugfs_dumpData_open(struct inode *inode, struct file *file) |
| 916 | { |
| 917 | struct lpfc_debug *debug; |
| 918 | int rc = -ENOMEM; |
| 919 | |
| 920 | if (!_dump_buf_data) |
| 921 | return -EBUSY; |
| 922 | |
| 923 | debug = kmalloc(sizeof(*debug), GFP_KERNEL); |
| 924 | if (!debug) |
| 925 | goto out; |
| 926 | |
| 927 | /* Round to page boundry */ |
| 928 | printk(KERN_ERR "BLKGRD %s: _dump_buf_data=0x%p\n", |
| 929 | __func__, _dump_buf_data); |
| 930 | debug->buffer = _dump_buf_data; |
| 931 | if (!debug->buffer) { |
| 932 | kfree(debug); |
| 933 | goto out; |
| 934 | } |
| 935 | |
| 936 | debug->len = (1 << _dump_buf_data_order) << PAGE_SHIFT; |
| 937 | file->private_data = debug; |
| 938 | |
| 939 | rc = 0; |
| 940 | out: |
| 941 | return rc; |
| 942 | } |
| 943 | |
| 944 | static int |
| 945 | lpfc_debugfs_dumpDif_open(struct inode *inode, struct file *file) |
| 946 | { |
| 947 | struct lpfc_debug *debug; |
| 948 | int rc = -ENOMEM; |
| 949 | |
| 950 | if (!_dump_buf_dif) |
| 951 | return -EBUSY; |
| 952 | |
| 953 | debug = kmalloc(sizeof(*debug), GFP_KERNEL); |
| 954 | if (!debug) |
| 955 | goto out; |
| 956 | |
| 957 | /* Round to page boundry */ |
| 958 | printk(KERN_ERR "BLKGRD %s: _dump_buf_dif=0x%p file=%s\n", __func__, |
| 959 | _dump_buf_dif, file->f_dentry->d_name.name); |
| 960 | debug->buffer = _dump_buf_dif; |
| 961 | if (!debug->buffer) { |
| 962 | kfree(debug); |
| 963 | goto out; |
| 964 | } |
| 965 | |
| 966 | debug->len = (1 << _dump_buf_dif_order) << PAGE_SHIFT; |
| 967 | file->private_data = debug; |
| 968 | |
| 969 | rc = 0; |
| 970 | out: |
| 971 | return rc; |
| 972 | } |
| 973 | |
| 974 | static ssize_t |
| 975 | lpfc_debugfs_dumpDataDif_write(struct file *file, const char __user *buf, |
| 976 | size_t nbytes, loff_t *ppos) |
| 977 | { |
| 978 | /* |
| 979 | * The Data/DIF buffers only save one failing IO |
| 980 | * The write op is used as a reset mechanism after an IO has |
| 981 | * already been saved to the next one can be saved |
| 982 | */ |
| 983 | spin_lock(&_dump_buf_lock); |
| 984 | |
| 985 | memset((void *)_dump_buf_data, 0, |
| 986 | ((1 << PAGE_SHIFT) << _dump_buf_data_order)); |
| 987 | memset((void *)_dump_buf_dif, 0, |
| 988 | ((1 << PAGE_SHIFT) << _dump_buf_dif_order)); |
| 989 | |
| 990 | _dump_buf_done = 0; |
| 991 | |
| 992 | spin_unlock(&_dump_buf_lock); |
| 993 | |
| 994 | return nbytes; |
| 995 | } |
| 996 | |
| 997 | |
| 998 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 999 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1000 | * lpfc_debugfs_nodelist_open - Open the nodelist debugfs file |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1001 | * @inode: The inode pointer that contains a vport pointer. |
| 1002 | * @file: The file pointer to attach the log output. |
| 1003 | * |
| 1004 | * Description: |
| 1005 | * This routine is the entry point for the debugfs open file operation. It gets |
| 1006 | * the vport from the i_private field in @inode, allocates the necessary buffer |
| 1007 | * for the log, fills the buffer from the in-memory log for this vport, and then |
| 1008 | * returns a pointer to that log in the private_data field in @file. |
| 1009 | * |
| 1010 | * Returns: |
| 1011 | * This function returns zero if successful. On error it will return an negative |
| 1012 | * error value. |
| 1013 | **/ |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 1014 | static int |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1015 | lpfc_debugfs_nodelist_open(struct inode *inode, struct file *file) |
| 1016 | { |
| 1017 | struct lpfc_vport *vport = inode->i_private; |
| 1018 | struct lpfc_debug *debug; |
| 1019 | int rc = -ENOMEM; |
| 1020 | |
| 1021 | debug = kmalloc(sizeof(*debug), GFP_KERNEL); |
| 1022 | if (!debug) |
| 1023 | goto out; |
| 1024 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1025 | /* Round to page boundary */ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1026 | debug->buffer = kmalloc(LPFC_NODELIST_SIZE, GFP_KERNEL); |
| 1027 | if (!debug->buffer) { |
| 1028 | kfree(debug); |
| 1029 | goto out; |
| 1030 | } |
| 1031 | |
| 1032 | debug->len = lpfc_debugfs_nodelist_data(vport, debug->buffer, |
| 1033 | LPFC_NODELIST_SIZE); |
| 1034 | file->private_data = debug; |
| 1035 | |
| 1036 | rc = 0; |
| 1037 | out: |
| 1038 | return rc; |
| 1039 | } |
| 1040 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1041 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1042 | * lpfc_debugfs_lseek - Seek through a debugfs file |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1043 | * @file: The file pointer to seek through. |
| 1044 | * @off: The offset to seek to or the amount to seek by. |
| 1045 | * @whence: Indicates how to seek. |
| 1046 | * |
| 1047 | * Description: |
| 1048 | * This routine is the entry point for the debugfs lseek file operation. The |
| 1049 | * @whence parameter indicates whether @off is the offset to directly seek to, |
| 1050 | * or if it is a value to seek forward or reverse by. This function figures out |
| 1051 | * what the new offset of the debugfs file will be and assigns that value to the |
| 1052 | * f_pos field of @file. |
| 1053 | * |
| 1054 | * Returns: |
| 1055 | * This function returns the new offset if successful and returns a negative |
| 1056 | * error if unable to process the seek. |
| 1057 | **/ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1058 | static loff_t |
| 1059 | lpfc_debugfs_lseek(struct file *file, loff_t off, int whence) |
| 1060 | { |
| 1061 | struct lpfc_debug *debug; |
| 1062 | loff_t pos = -1; |
| 1063 | |
| 1064 | debug = file->private_data; |
| 1065 | |
| 1066 | switch (whence) { |
| 1067 | case 0: |
| 1068 | pos = off; |
| 1069 | break; |
| 1070 | case 1: |
| 1071 | pos = file->f_pos + off; |
| 1072 | break; |
| 1073 | case 2: |
| 1074 | pos = debug->len - off; |
| 1075 | } |
| 1076 | return (pos < 0 || pos > debug->len) ? -EINVAL : (file->f_pos = pos); |
| 1077 | } |
| 1078 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1079 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1080 | * lpfc_debugfs_read - Read a debugfs file |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1081 | * @file: The file pointer to read from. |
| 1082 | * @buf: The buffer to copy the data to. |
| 1083 | * @nbytes: The number of bytes to read. |
| 1084 | * @ppos: The position in the file to start reading from. |
| 1085 | * |
| 1086 | * Description: |
| 1087 | * This routine reads data from from the buffer indicated in the private_data |
| 1088 | * field of @file. It will start reading at @ppos and copy up to @nbytes of |
| 1089 | * data to @buf. |
| 1090 | * |
| 1091 | * Returns: |
| 1092 | * This function returns the amount of data that was read (this could be less |
| 1093 | * than @nbytes if the end of the file was reached) or a negative error value. |
| 1094 | **/ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1095 | static ssize_t |
| 1096 | lpfc_debugfs_read(struct file *file, char __user *buf, |
| 1097 | size_t nbytes, loff_t *ppos) |
| 1098 | { |
| 1099 | struct lpfc_debug *debug = file->private_data; |
| 1100 | return simple_read_from_buffer(buf, nbytes, ppos, debug->buffer, |
| 1101 | debug->len); |
| 1102 | } |
| 1103 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1104 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1105 | * lpfc_debugfs_release - Release the buffer used to store debugfs file data |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1106 | * @inode: The inode pointer that contains a vport pointer. (unused) |
| 1107 | * @file: The file pointer that contains the buffer to release. |
| 1108 | * |
| 1109 | * Description: |
| 1110 | * This routine frees the buffer that was allocated when the debugfs file was |
| 1111 | * opened. |
| 1112 | * |
| 1113 | * Returns: |
| 1114 | * This function returns zero. |
| 1115 | **/ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1116 | static int |
| 1117 | lpfc_debugfs_release(struct inode *inode, struct file *file) |
| 1118 | { |
| 1119 | struct lpfc_debug *debug = file->private_data; |
| 1120 | |
| 1121 | kfree(debug->buffer); |
| 1122 | kfree(debug); |
| 1123 | |
| 1124 | return 0; |
| 1125 | } |
| 1126 | |
James Smart | e2a0a9d | 2008-12-04 22:40:02 -0500 | [diff] [blame] | 1127 | static int |
| 1128 | lpfc_debugfs_dumpDataDif_release(struct inode *inode, struct file *file) |
| 1129 | { |
| 1130 | struct lpfc_debug *debug = file->private_data; |
| 1131 | |
| 1132 | debug->buffer = NULL; |
| 1133 | kfree(debug); |
| 1134 | |
| 1135 | return 0; |
| 1136 | } |
| 1137 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1138 | #undef lpfc_debugfs_op_disc_trc |
Jan Engelhardt | 71fa742 | 2009-01-11 10:38:59 +0100 | [diff] [blame] | 1139 | static const struct file_operations lpfc_debugfs_op_disc_trc = { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1140 | .owner = THIS_MODULE, |
| 1141 | .open = lpfc_debugfs_disc_trc_open, |
| 1142 | .llseek = lpfc_debugfs_lseek, |
| 1143 | .read = lpfc_debugfs_read, |
| 1144 | .release = lpfc_debugfs_release, |
| 1145 | }; |
| 1146 | |
| 1147 | #undef lpfc_debugfs_op_nodelist |
Jan Engelhardt | 71fa742 | 2009-01-11 10:38:59 +0100 | [diff] [blame] | 1148 | static const struct file_operations lpfc_debugfs_op_nodelist = { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1149 | .owner = THIS_MODULE, |
| 1150 | .open = lpfc_debugfs_nodelist_open, |
| 1151 | .llseek = lpfc_debugfs_lseek, |
| 1152 | .read = lpfc_debugfs_read, |
| 1153 | .release = lpfc_debugfs_release, |
| 1154 | }; |
| 1155 | |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 1156 | #undef lpfc_debugfs_op_hbqinfo |
Jan Engelhardt | 71fa742 | 2009-01-11 10:38:59 +0100 | [diff] [blame] | 1157 | static const struct file_operations lpfc_debugfs_op_hbqinfo = { |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 1158 | .owner = THIS_MODULE, |
| 1159 | .open = lpfc_debugfs_hbqinfo_open, |
| 1160 | .llseek = lpfc_debugfs_lseek, |
| 1161 | .read = lpfc_debugfs_read, |
| 1162 | .release = lpfc_debugfs_release, |
| 1163 | }; |
| 1164 | |
James Smart | c95d6c6 | 2008-01-11 01:53:23 -0500 | [diff] [blame] | 1165 | #undef lpfc_debugfs_op_dumpHBASlim |
Jan Engelhardt | 71fa742 | 2009-01-11 10:38:59 +0100 | [diff] [blame] | 1166 | static const struct file_operations lpfc_debugfs_op_dumpHBASlim = { |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 1167 | .owner = THIS_MODULE, |
James Smart | c95d6c6 | 2008-01-11 01:53:23 -0500 | [diff] [blame] | 1168 | .open = lpfc_debugfs_dumpHBASlim_open, |
| 1169 | .llseek = lpfc_debugfs_lseek, |
| 1170 | .read = lpfc_debugfs_read, |
| 1171 | .release = lpfc_debugfs_release, |
| 1172 | }; |
| 1173 | |
| 1174 | #undef lpfc_debugfs_op_dumpHostSlim |
Jan Engelhardt | 71fa742 | 2009-01-11 10:38:59 +0100 | [diff] [blame] | 1175 | static const struct file_operations lpfc_debugfs_op_dumpHostSlim = { |
James Smart | c95d6c6 | 2008-01-11 01:53:23 -0500 | [diff] [blame] | 1176 | .owner = THIS_MODULE, |
| 1177 | .open = lpfc_debugfs_dumpHostSlim_open, |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 1178 | .llseek = lpfc_debugfs_lseek, |
| 1179 | .read = lpfc_debugfs_read, |
| 1180 | .release = lpfc_debugfs_release, |
| 1181 | }; |
| 1182 | |
James Smart | e2a0a9d | 2008-12-04 22:40:02 -0500 | [diff] [blame] | 1183 | #undef lpfc_debugfs_op_dumpData |
Jan Engelhardt | 71fa742 | 2009-01-11 10:38:59 +0100 | [diff] [blame] | 1184 | static const struct file_operations lpfc_debugfs_op_dumpData = { |
James Smart | e2a0a9d | 2008-12-04 22:40:02 -0500 | [diff] [blame] | 1185 | .owner = THIS_MODULE, |
| 1186 | .open = lpfc_debugfs_dumpData_open, |
| 1187 | .llseek = lpfc_debugfs_lseek, |
| 1188 | .read = lpfc_debugfs_read, |
| 1189 | .write = lpfc_debugfs_dumpDataDif_write, |
| 1190 | .release = lpfc_debugfs_dumpDataDif_release, |
| 1191 | }; |
| 1192 | |
| 1193 | #undef lpfc_debugfs_op_dumpDif |
Jan Engelhardt | 71fa742 | 2009-01-11 10:38:59 +0100 | [diff] [blame] | 1194 | static const struct file_operations lpfc_debugfs_op_dumpDif = { |
James Smart | e2a0a9d | 2008-12-04 22:40:02 -0500 | [diff] [blame] | 1195 | .owner = THIS_MODULE, |
| 1196 | .open = lpfc_debugfs_dumpDif_open, |
| 1197 | .llseek = lpfc_debugfs_lseek, |
| 1198 | .read = lpfc_debugfs_read, |
| 1199 | .write = lpfc_debugfs_dumpDataDif_write, |
| 1200 | .release = lpfc_debugfs_dumpDataDif_release, |
| 1201 | }; |
| 1202 | |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 1203 | #undef lpfc_debugfs_op_slow_ring_trc |
Jan Engelhardt | 71fa742 | 2009-01-11 10:38:59 +0100 | [diff] [blame] | 1204 | static const struct file_operations lpfc_debugfs_op_slow_ring_trc = { |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 1205 | .owner = THIS_MODULE, |
| 1206 | .open = lpfc_debugfs_slow_ring_trc_open, |
| 1207 | .llseek = lpfc_debugfs_lseek, |
| 1208 | .read = lpfc_debugfs_read, |
| 1209 | .release = lpfc_debugfs_release, |
| 1210 | }; |
| 1211 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1212 | static struct dentry *lpfc_debugfs_root = NULL; |
| 1213 | static atomic_t lpfc_debugfs_hba_count; |
| 1214 | #endif |
| 1215 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1216 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1217 | * lpfc_debugfs_initialize - Initialize debugfs for a vport |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1218 | * @vport: The vport pointer to initialize. |
| 1219 | * |
| 1220 | * Description: |
| 1221 | * When Debugfs is configured this routine sets up the lpfc debugfs file system. |
| 1222 | * If not already created, this routine will create the lpfc directory, and |
| 1223 | * lpfcX directory (for this HBA), and vportX directory for this vport. It will |
| 1224 | * also create each file used to access lpfc specific debugfs information. |
| 1225 | **/ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1226 | inline void |
| 1227 | lpfc_debugfs_initialize(struct lpfc_vport *vport) |
| 1228 | { |
James Smart | 923e4b6 | 2008-12-04 22:40:07 -0500 | [diff] [blame] | 1229 | #ifdef CONFIG_SCSI_LPFC_DEBUG_FS |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1230 | struct lpfc_hba *phba = vport->phba; |
| 1231 | char name[64]; |
| 1232 | uint32_t num, i; |
| 1233 | |
| 1234 | if (!lpfc_debugfs_enable) |
| 1235 | return; |
| 1236 | |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 1237 | /* Setup lpfc root directory */ |
| 1238 | if (!lpfc_debugfs_root) { |
| 1239 | lpfc_debugfs_root = debugfs_create_dir("lpfc", NULL); |
| 1240 | atomic_set(&lpfc_debugfs_hba_count, 0); |
| 1241 | if (!lpfc_debugfs_root) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1242 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 1243 | "0408 Cannot create debugfs root\n"); |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 1244 | goto debug_failed; |
| 1245 | } |
| 1246 | } |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 1247 | if (!lpfc_debugfs_start_time) |
| 1248 | lpfc_debugfs_start_time = jiffies; |
| 1249 | |
| 1250 | /* Setup lpfcX directory for specific HBA */ |
| 1251 | snprintf(name, sizeof(name), "lpfc%d", phba->brd_no); |
| 1252 | if (!phba->hba_debugfs_root) { |
| 1253 | phba->hba_debugfs_root = |
| 1254 | debugfs_create_dir(name, lpfc_debugfs_root); |
| 1255 | if (!phba->hba_debugfs_root) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1256 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 1257 | "0412 Cannot create debugfs hba\n"); |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 1258 | goto debug_failed; |
| 1259 | } |
| 1260 | atomic_inc(&lpfc_debugfs_hba_count); |
| 1261 | atomic_set(&phba->debugfs_vport_count, 0); |
| 1262 | |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 1263 | /* Setup hbqinfo */ |
| 1264 | snprintf(name, sizeof(name), "hbqinfo"); |
| 1265 | phba->debug_hbqinfo = |
| 1266 | debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR, |
| 1267 | phba->hba_debugfs_root, |
| 1268 | phba, &lpfc_debugfs_op_hbqinfo); |
| 1269 | if (!phba->debug_hbqinfo) { |
| 1270 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 1271 | "0411 Cannot create debugfs hbqinfo\n"); |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 1272 | goto debug_failed; |
| 1273 | } |
| 1274 | |
James Smart | c95d6c6 | 2008-01-11 01:53:23 -0500 | [diff] [blame] | 1275 | /* Setup dumpHBASlim */ |
| 1276 | snprintf(name, sizeof(name), "dumpHBASlim"); |
| 1277 | phba->debug_dumpHBASlim = |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 1278 | debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR, |
| 1279 | phba->hba_debugfs_root, |
James Smart | c95d6c6 | 2008-01-11 01:53:23 -0500 | [diff] [blame] | 1280 | phba, &lpfc_debugfs_op_dumpHBASlim); |
| 1281 | if (!phba->debug_dumpHBASlim) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1282 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 1283 | "0413 Cannot create debugfs dumpHBASlim\n"); |
James Smart | c95d6c6 | 2008-01-11 01:53:23 -0500 | [diff] [blame] | 1284 | goto debug_failed; |
| 1285 | } |
| 1286 | |
| 1287 | /* Setup dumpHostSlim */ |
| 1288 | snprintf(name, sizeof(name), "dumpHostSlim"); |
| 1289 | phba->debug_dumpHostSlim = |
| 1290 | debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR, |
| 1291 | phba->hba_debugfs_root, |
| 1292 | phba, &lpfc_debugfs_op_dumpHostSlim); |
| 1293 | if (!phba->debug_dumpHostSlim) { |
| 1294 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 1295 | "0414 Cannot create debugfs dumpHostSlim\n"); |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 1296 | goto debug_failed; |
| 1297 | } |
| 1298 | |
James Smart | e2a0a9d | 2008-12-04 22:40:02 -0500 | [diff] [blame] | 1299 | /* Setup dumpData */ |
| 1300 | snprintf(name, sizeof(name), "dumpData"); |
| 1301 | phba->debug_dumpData = |
| 1302 | debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR, |
| 1303 | phba->hba_debugfs_root, |
| 1304 | phba, &lpfc_debugfs_op_dumpData); |
| 1305 | if (!phba->debug_dumpData) { |
| 1306 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 1307 | "0800 Cannot create debugfs dumpData\n"); |
| 1308 | goto debug_failed; |
| 1309 | } |
| 1310 | |
| 1311 | /* Setup dumpDif */ |
| 1312 | snprintf(name, sizeof(name), "dumpDif"); |
| 1313 | phba->debug_dumpDif = |
| 1314 | debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR, |
| 1315 | phba->hba_debugfs_root, |
| 1316 | phba, &lpfc_debugfs_op_dumpDif); |
| 1317 | if (!phba->debug_dumpDif) { |
| 1318 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 1319 | "0801 Cannot create debugfs dumpDif\n"); |
| 1320 | goto debug_failed; |
| 1321 | } |
| 1322 | |
| 1323 | |
| 1324 | |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 1325 | /* Setup slow ring trace */ |
| 1326 | if (lpfc_debugfs_max_slow_ring_trc) { |
| 1327 | num = lpfc_debugfs_max_slow_ring_trc - 1; |
| 1328 | if (num & lpfc_debugfs_max_slow_ring_trc) { |
| 1329 | /* Change to be a power of 2 */ |
| 1330 | num = lpfc_debugfs_max_slow_ring_trc; |
| 1331 | i = 0; |
| 1332 | while (num > 1) { |
| 1333 | num = num >> 1; |
| 1334 | i++; |
| 1335 | } |
| 1336 | lpfc_debugfs_max_slow_ring_trc = (1 << i); |
| 1337 | printk(KERN_ERR |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1338 | "lpfc_debugfs_max_disc_trc changed to " |
| 1339 | "%d\n", lpfc_debugfs_max_disc_trc); |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 1340 | } |
| 1341 | } |
| 1342 | |
| 1343 | |
| 1344 | snprintf(name, sizeof(name), "slow_ring_trace"); |
| 1345 | phba->debug_slow_ring_trc = |
| 1346 | debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR, |
| 1347 | phba->hba_debugfs_root, |
| 1348 | phba, &lpfc_debugfs_op_slow_ring_trc); |
| 1349 | if (!phba->debug_slow_ring_trc) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1350 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 1351 | "0415 Cannot create debugfs " |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1352 | "slow_ring_trace\n"); |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 1353 | goto debug_failed; |
| 1354 | } |
| 1355 | if (!phba->slow_ring_trc) { |
| 1356 | phba->slow_ring_trc = kmalloc( |
| 1357 | (sizeof(struct lpfc_debugfs_trc) * |
| 1358 | lpfc_debugfs_max_slow_ring_trc), |
| 1359 | GFP_KERNEL); |
| 1360 | if (!phba->slow_ring_trc) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1361 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 1362 | "0416 Cannot create debugfs " |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1363 | "slow_ring buffer\n"); |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 1364 | goto debug_failed; |
| 1365 | } |
| 1366 | atomic_set(&phba->slow_ring_trc_cnt, 0); |
| 1367 | memset(phba->slow_ring_trc, 0, |
| 1368 | (sizeof(struct lpfc_debugfs_trc) * |
| 1369 | lpfc_debugfs_max_slow_ring_trc)); |
| 1370 | } |
| 1371 | } |
| 1372 | |
| 1373 | snprintf(name, sizeof(name), "vport%d", vport->vpi); |
| 1374 | if (!vport->vport_debugfs_root) { |
| 1375 | vport->vport_debugfs_root = |
| 1376 | debugfs_create_dir(name, phba->hba_debugfs_root); |
| 1377 | if (!vport->vport_debugfs_root) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1378 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 1379 | "0417 Cant create debugfs"); |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 1380 | goto debug_failed; |
| 1381 | } |
| 1382 | atomic_inc(&phba->debugfs_vport_count); |
| 1383 | } |
| 1384 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1385 | if (lpfc_debugfs_max_disc_trc) { |
| 1386 | num = lpfc_debugfs_max_disc_trc - 1; |
| 1387 | if (num & lpfc_debugfs_max_disc_trc) { |
| 1388 | /* Change to be a power of 2 */ |
| 1389 | num = lpfc_debugfs_max_disc_trc; |
| 1390 | i = 0; |
| 1391 | while (num > 1) { |
| 1392 | num = num >> 1; |
| 1393 | i++; |
| 1394 | } |
| 1395 | lpfc_debugfs_max_disc_trc = (1 << i); |
| 1396 | printk(KERN_ERR |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1397 | "lpfc_debugfs_max_disc_trc changed to %d\n", |
| 1398 | lpfc_debugfs_max_disc_trc); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1399 | } |
| 1400 | } |
| 1401 | |
Adrian Bunk | ff86ba5 | 2007-10-18 12:52:37 +0200 | [diff] [blame] | 1402 | vport->disc_trc = kzalloc( |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 1403 | (sizeof(struct lpfc_debugfs_trc) * lpfc_debugfs_max_disc_trc), |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1404 | GFP_KERNEL); |
| 1405 | |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 1406 | if (!vport->disc_trc) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1407 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 1408 | "0418 Cannot create debugfs disc trace " |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1409 | "buffer\n"); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1410 | goto debug_failed; |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 1411 | } |
| 1412 | atomic_set(&vport->disc_trc_cnt, 0); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1413 | |
| 1414 | snprintf(name, sizeof(name), "discovery_trace"); |
| 1415 | vport->debug_disc_trc = |
| 1416 | debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR, |
| 1417 | vport->vport_debugfs_root, |
| 1418 | vport, &lpfc_debugfs_op_disc_trc); |
| 1419 | if (!vport->debug_disc_trc) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1420 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 1421 | "0419 Cannot create debugfs " |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1422 | "discovery_trace\n"); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1423 | goto debug_failed; |
| 1424 | } |
| 1425 | snprintf(name, sizeof(name), "nodelist"); |
| 1426 | vport->debug_nodelist = |
| 1427 | debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR, |
| 1428 | vport->vport_debugfs_root, |
| 1429 | vport, &lpfc_debugfs_op_nodelist); |
| 1430 | if (!vport->debug_nodelist) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1431 | lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, |
| 1432 | "0409 Cant create debugfs nodelist"); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1433 | goto debug_failed; |
| 1434 | } |
| 1435 | debug_failed: |
| 1436 | return; |
| 1437 | #endif |
| 1438 | } |
| 1439 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1440 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1441 | * lpfc_debugfs_terminate - Tear down debugfs infrastructure for this vport |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1442 | * @vport: The vport pointer to remove from debugfs. |
| 1443 | * |
| 1444 | * Description: |
| 1445 | * When Debugfs is configured this routine removes debugfs file system elements |
| 1446 | * that are specific to this vport. It also checks to see if there are any |
| 1447 | * users left for the debugfs directories associated with the HBA and driver. If |
| 1448 | * this is the last user of the HBA directory or driver directory then it will |
| 1449 | * remove those from the debugfs infrastructure as well. |
| 1450 | **/ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1451 | inline void |
| 1452 | lpfc_debugfs_terminate(struct lpfc_vport *vport) |
| 1453 | { |
James Smart | 923e4b6 | 2008-12-04 22:40:07 -0500 | [diff] [blame] | 1454 | #ifdef CONFIG_SCSI_LPFC_DEBUG_FS |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1455 | struct lpfc_hba *phba = vport->phba; |
| 1456 | |
| 1457 | if (vport->disc_trc) { |
| 1458 | kfree(vport->disc_trc); |
| 1459 | vport->disc_trc = NULL; |
| 1460 | } |
| 1461 | if (vport->debug_disc_trc) { |
| 1462 | debugfs_remove(vport->debug_disc_trc); /* discovery_trace */ |
| 1463 | vport->debug_disc_trc = NULL; |
| 1464 | } |
| 1465 | if (vport->debug_nodelist) { |
| 1466 | debugfs_remove(vport->debug_nodelist); /* nodelist */ |
| 1467 | vport->debug_nodelist = NULL; |
| 1468 | } |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 1469 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1470 | if (vport->vport_debugfs_root) { |
| 1471 | debugfs_remove(vport->vport_debugfs_root); /* vportX */ |
| 1472 | vport->vport_debugfs_root = NULL; |
| 1473 | atomic_dec(&phba->debugfs_vport_count); |
| 1474 | } |
| 1475 | if (atomic_read(&phba->debugfs_vport_count) == 0) { |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 1476 | |
James Smart | 78b2d85 | 2007-08-02 11:10:21 -0400 | [diff] [blame] | 1477 | if (phba->debug_hbqinfo) { |
| 1478 | debugfs_remove(phba->debug_hbqinfo); /* hbqinfo */ |
| 1479 | phba->debug_hbqinfo = NULL; |
| 1480 | } |
James Smart | c95d6c6 | 2008-01-11 01:53:23 -0500 | [diff] [blame] | 1481 | if (phba->debug_dumpHBASlim) { |
| 1482 | debugfs_remove(phba->debug_dumpHBASlim); /* HBASlim */ |
| 1483 | phba->debug_dumpHBASlim = NULL; |
| 1484 | } |
| 1485 | if (phba->debug_dumpHostSlim) { |
| 1486 | debugfs_remove(phba->debug_dumpHostSlim); /* HostSlim */ |
| 1487 | phba->debug_dumpHostSlim = NULL; |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 1488 | } |
James Smart | e2a0a9d | 2008-12-04 22:40:02 -0500 | [diff] [blame] | 1489 | if (phba->debug_dumpData) { |
| 1490 | debugfs_remove(phba->debug_dumpData); /* dumpData */ |
| 1491 | phba->debug_dumpData = NULL; |
| 1492 | } |
| 1493 | |
| 1494 | if (phba->debug_dumpDif) { |
| 1495 | debugfs_remove(phba->debug_dumpDif); /* dumpDif */ |
| 1496 | phba->debug_dumpDif = NULL; |
| 1497 | } |
| 1498 | |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 1499 | if (phba->slow_ring_trc) { |
| 1500 | kfree(phba->slow_ring_trc); |
| 1501 | phba->slow_ring_trc = NULL; |
| 1502 | } |
| 1503 | if (phba->debug_slow_ring_trc) { |
| 1504 | /* slow_ring_trace */ |
| 1505 | debugfs_remove(phba->debug_slow_ring_trc); |
| 1506 | phba->debug_slow_ring_trc = NULL; |
| 1507 | } |
| 1508 | |
| 1509 | if (phba->hba_debugfs_root) { |
| 1510 | debugfs_remove(phba->hba_debugfs_root); /* lpfcX */ |
| 1511 | phba->hba_debugfs_root = NULL; |
| 1512 | atomic_dec(&lpfc_debugfs_hba_count); |
| 1513 | } |
| 1514 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1515 | if (atomic_read(&lpfc_debugfs_hba_count) == 0) { |
| 1516 | debugfs_remove(lpfc_debugfs_root); /* lpfc */ |
| 1517 | lpfc_debugfs_root = NULL; |
| 1518 | } |
| 1519 | } |
| 1520 | #endif |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 1521 | return; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1522 | } |