Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 1 | /* |
Andreas Herrmann | 4a9d2d8 | 2006-05-22 18:14:08 +0200 | [diff] [blame] | 2 | * This file is part of the zfcp device driver for |
| 3 | * FCP adapters for IBM System z9 and zSeries. |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 4 | * |
Andreas Herrmann | 4a9d2d8 | 2006-05-22 18:14:08 +0200 | [diff] [blame] | 5 | * (C) Copyright IBM Corp. 2002, 2006 |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 2, or (at your option) |
| 10 | * any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program; if not, write to the Free Software |
| 19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 20 | */ |
| 21 | |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 22 | #include <linux/ctype.h> |
Heiko Carstens | 364c855 | 2007-10-12 16:11:35 +0200 | [diff] [blame] | 23 | #include <asm/debug.h> |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 24 | #include "zfcp_ext.h" |
| 25 | |
| 26 | static u32 dbfsize = 4; |
| 27 | |
| 28 | module_param(dbfsize, uint, 0400); |
| 29 | MODULE_PARM_DESC(dbfsize, |
| 30 | "number of pages for each debug feature area (default 4)"); |
| 31 | |
| 32 | #define ZFCP_LOG_AREA ZFCP_LOG_AREA_OTHER |
| 33 | |
Martin Peschke | c15450e | 2008-03-27 14:21:55 +0100 | [diff] [blame] | 34 | static void zfcp_dbf_hexdump(debug_info_t *dbf, void *to, int to_len, |
| 35 | int level, char *from, int from_len) |
| 36 | { |
| 37 | int offset; |
| 38 | struct zfcp_dbf_dump *dump = to; |
| 39 | int room = to_len - sizeof(*dump); |
| 40 | |
| 41 | for (offset = 0; offset < from_len; offset += dump->size) { |
| 42 | memset(to, 0, to_len); |
| 43 | strncpy(dump->tag, "dump", ZFCP_DBF_TAG_SIZE); |
| 44 | dump->total_size = from_len; |
| 45 | dump->offset = offset; |
| 46 | dump->size = min(from_len - offset, room); |
| 47 | memcpy(dump->data, from + offset, dump->size); |
| 48 | debug_event(dbf, level, dump, dump->size); |
| 49 | } |
| 50 | } |
| 51 | |
Martin Peschke | 8fc5af1 | 2008-03-31 11:15:23 +0200 | [diff] [blame] | 52 | /* FIXME: this duplicate this code in s390 debug feature */ |
| 53 | static void zfcp_dbf_timestamp(unsigned long long stck, struct timespec *time) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 54 | { |
| 55 | unsigned long long sec; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 56 | |
| 57 | stck -= 0x8126d60e46000000LL - (0x3c26700LL * 1000000 * 4096); |
| 58 | sec = stck >> 12; |
| 59 | do_div(sec, 1000000); |
Martin Peschke | 8fc5af1 | 2008-03-31 11:15:23 +0200 | [diff] [blame] | 60 | time->tv_sec = sec; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 61 | stck -= (sec * 1000000) << 12; |
Martin Peschke | 8fc5af1 | 2008-03-31 11:15:23 +0200 | [diff] [blame] | 62 | time->tv_nsec = ((stck * 1000) >> 12); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 63 | } |
| 64 | |
Martin Peschke | a9c8577 | 2008-03-31 11:15:27 +0200 | [diff] [blame] | 65 | static void zfcp_dbf_tag(char **p, const char *label, const char *tag) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 66 | { |
Martin Peschke | a9c8577 | 2008-03-31 11:15:27 +0200 | [diff] [blame] | 67 | int i; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 68 | |
Martin Peschke | a9c8577 | 2008-03-31 11:15:27 +0200 | [diff] [blame] | 69 | *p += sprintf(*p, "%-24s", label); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 70 | for (i = 0; i < ZFCP_DBF_TAG_SIZE; i++) |
Martin Peschke | a9c8577 | 2008-03-31 11:15:27 +0200 | [diff] [blame] | 71 | *p += sprintf(*p, "%c", tag[i]); |
| 72 | *p += sprintf(*p, "\n"); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 73 | } |
| 74 | |
Martin Peschke | 10223c6 | 2008-03-27 14:21:59 +0100 | [diff] [blame] | 75 | static void zfcp_dbf_outs(char **buf, const char *s1, const char *s2) |
| 76 | { |
| 77 | *buf += sprintf(*buf, "%-24s%s\n", s1, s2); |
| 78 | } |
| 79 | |
| 80 | static void zfcp_dbf_out(char **buf, const char *s, const char *format, ...) |
| 81 | { |
| 82 | va_list arg; |
| 83 | |
| 84 | *buf += sprintf(*buf, "%-24s", s); |
| 85 | va_start(arg, format); |
| 86 | *buf += vsprintf(*buf, format, arg); |
| 87 | va_end(arg); |
| 88 | *buf += sprintf(*buf, "\n"); |
| 89 | } |
| 90 | |
Martin Peschke | df29f4a | 2008-03-31 11:15:26 +0200 | [diff] [blame] | 91 | static void zfcp_dbf_outd(char **p, const char *label, char *buffer, |
| 92 | int buflen, int offset, int total_size) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 93 | { |
Martin Peschke | df29f4a | 2008-03-31 11:15:26 +0200 | [diff] [blame] | 94 | if (!offset) |
| 95 | *p += sprintf(*p, "%-24s ", label); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 96 | while (buflen--) { |
| 97 | if (offset > 0) { |
| 98 | if ((offset % 32) == 0) |
Martin Peschke | df29f4a | 2008-03-31 11:15:26 +0200 | [diff] [blame] | 99 | *p += sprintf(*p, "\n%-24c ", ' '); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 100 | else if ((offset % 4) == 0) |
Martin Peschke | df29f4a | 2008-03-31 11:15:26 +0200 | [diff] [blame] | 101 | *p += sprintf(*p, " "); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 102 | } |
Martin Peschke | df29f4a | 2008-03-31 11:15:26 +0200 | [diff] [blame] | 103 | *p += sprintf(*p, "%02x", *buffer++); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 104 | if (++offset == total_size) { |
Martin Peschke | df29f4a | 2008-03-31 11:15:26 +0200 | [diff] [blame] | 105 | *p += sprintf(*p, "\n"); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 106 | break; |
| 107 | } |
| 108 | } |
Martin Peschke | df29f4a | 2008-03-31 11:15:26 +0200 | [diff] [blame] | 109 | if (!total_size) |
| 110 | *p += sprintf(*p, "\n"); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 111 | } |
| 112 | |
Martin Peschke | 92c7a83 | 2008-03-31 11:15:30 +0200 | [diff] [blame] | 113 | static int zfcp_dbf_view_header(debug_info_t *id, struct debug_view *view, |
| 114 | int area, debug_entry_t *entry, char *out_buf) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 115 | { |
| 116 | struct zfcp_dbf_dump *dump = (struct zfcp_dbf_dump *)DEBUG_DATA(entry); |
Martin Peschke | 8fc5af1 | 2008-03-31 11:15:23 +0200 | [diff] [blame] | 117 | struct timespec t; |
Martin Peschke | b634fff | 2008-03-31 11:15:24 +0200 | [diff] [blame] | 118 | char *p = out_buf; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 119 | |
| 120 | if (strncmp(dump->tag, "dump", ZFCP_DBF_TAG_SIZE) != 0) { |
Martin Peschke | 8fc5af1 | 2008-03-31 11:15:23 +0200 | [diff] [blame] | 121 | zfcp_dbf_timestamp(entry->id.stck, &t); |
Martin Peschke | b634fff | 2008-03-31 11:15:24 +0200 | [diff] [blame] | 122 | zfcp_dbf_out(&p, "timestamp", "%011lu:%06lu", |
| 123 | t.tv_sec, t.tv_nsec); |
| 124 | zfcp_dbf_out(&p, "cpu", "%02i", entry->id.fields.cpuid); |
| 125 | } else { |
Martin Peschke | df29f4a | 2008-03-31 11:15:26 +0200 | [diff] [blame] | 126 | zfcp_dbf_outd(&p, NULL, dump->data, dump->size, dump->offset, |
| 127 | dump->total_size); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 128 | if ((dump->offset + dump->size) == dump->total_size) |
Martin Peschke | b634fff | 2008-03-31 11:15:24 +0200 | [diff] [blame] | 129 | p += sprintf(p, "\n"); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 130 | } |
Martin Peschke | b634fff | 2008-03-31 11:15:24 +0200 | [diff] [blame] | 131 | return p - out_buf; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 132 | } |
| 133 | |
Martin Peschke | bfab163 | 2008-03-31 11:15:31 +0200 | [diff] [blame] | 134 | /** |
| 135 | * zfcp_hba_dbf_event_fsf_response - trace event for request completion |
| 136 | * @fsf_req: request that has been completed |
| 137 | */ |
Heiko Carstens | 4d284ca | 2007-02-05 21:18:53 +0100 | [diff] [blame] | 138 | void zfcp_hba_dbf_event_fsf_response(struct zfcp_fsf_req *fsf_req) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 139 | { |
| 140 | struct zfcp_adapter *adapter = fsf_req->adapter; |
| 141 | struct fsf_qtcb *qtcb = fsf_req->qtcb; |
| 142 | union fsf_prot_status_qual *prot_status_qual = |
Martin Peschke | 92c7a83 | 2008-03-31 11:15:30 +0200 | [diff] [blame] | 143 | &qtcb->prefix.prot_status_qual; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 144 | union fsf_status_qual *fsf_status_qual = &qtcb->header.fsf_status_qual; |
| 145 | struct scsi_cmnd *scsi_cmnd; |
| 146 | struct zfcp_port *port; |
| 147 | struct zfcp_unit *unit; |
| 148 | struct zfcp_send_els *send_els; |
| 149 | struct zfcp_hba_dbf_record *rec = &adapter->hba_dbf_buf; |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 150 | struct zfcp_hba_dbf_record_response *response = &rec->u.response; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 151 | int level; |
| 152 | unsigned long flags; |
| 153 | |
| 154 | spin_lock_irqsave(&adapter->hba_dbf_lock, flags); |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 155 | memset(rec, 0, sizeof(*rec)); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 156 | strncpy(rec->tag, "resp", ZFCP_DBF_TAG_SIZE); |
| 157 | |
| 158 | if ((qtcb->prefix.prot_status != FSF_PROT_GOOD) && |
| 159 | (qtcb->prefix.prot_status != FSF_PROT_FSF_STATUS_PRESENTED)) { |
| 160 | strncpy(rec->tag2, "perr", ZFCP_DBF_TAG_SIZE); |
| 161 | level = 1; |
| 162 | } else if (qtcb->header.fsf_status != FSF_GOOD) { |
| 163 | strncpy(rec->tag2, "ferr", ZFCP_DBF_TAG_SIZE); |
| 164 | level = 1; |
| 165 | } else if ((fsf_req->fsf_command == FSF_QTCB_OPEN_PORT_WITH_DID) || |
| 166 | (fsf_req->fsf_command == FSF_QTCB_OPEN_LUN)) { |
| 167 | strncpy(rec->tag2, "open", ZFCP_DBF_TAG_SIZE); |
| 168 | level = 4; |
Martin Peschke | b75db73 | 2008-03-27 14:21:58 +0100 | [diff] [blame] | 169 | } else if (qtcb->header.log_length) { |
| 170 | strncpy(rec->tag2, "qtcb", ZFCP_DBF_TAG_SIZE); |
| 171 | level = 5; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 172 | } else { |
| 173 | strncpy(rec->tag2, "norm", ZFCP_DBF_TAG_SIZE); |
| 174 | level = 6; |
| 175 | } |
| 176 | |
| 177 | response->fsf_command = fsf_req->fsf_command; |
| 178 | response->fsf_reqid = (unsigned long)fsf_req; |
| 179 | response->fsf_seqno = fsf_req->seq_no; |
| 180 | response->fsf_issued = fsf_req->issued; |
| 181 | response->fsf_prot_status = qtcb->prefix.prot_status; |
| 182 | response->fsf_status = qtcb->header.fsf_status; |
| 183 | memcpy(response->fsf_prot_status_qual, |
| 184 | prot_status_qual, FSF_PROT_STATUS_QUAL_SIZE); |
| 185 | memcpy(response->fsf_status_qual, |
| 186 | fsf_status_qual, FSF_STATUS_QUALIFIER_SIZE); |
| 187 | response->fsf_req_status = fsf_req->status; |
| 188 | response->sbal_first = fsf_req->sbal_first; |
| 189 | response->sbal_curr = fsf_req->sbal_curr; |
| 190 | response->sbal_last = fsf_req->sbal_last; |
| 191 | response->pool = fsf_req->pool != NULL; |
| 192 | response->erp_action = (unsigned long)fsf_req->erp_action; |
| 193 | |
| 194 | switch (fsf_req->fsf_command) { |
| 195 | case FSF_QTCB_FCP_CMND: |
| 196 | if (fsf_req->status & ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT) |
| 197 | break; |
| 198 | scsi_cmnd = (struct scsi_cmnd *)fsf_req->data; |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 199 | if (scsi_cmnd) { |
| 200 | response->u.fcp.cmnd = (unsigned long)scsi_cmnd; |
| 201 | response->u.fcp.serial = scsi_cmnd->serial_number; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 202 | } |
| 203 | break; |
| 204 | |
| 205 | case FSF_QTCB_OPEN_PORT_WITH_DID: |
| 206 | case FSF_QTCB_CLOSE_PORT: |
| 207 | case FSF_QTCB_CLOSE_PHYSICAL_PORT: |
| 208 | port = (struct zfcp_port *)fsf_req->data; |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 209 | response->u.port.wwpn = port->wwpn; |
| 210 | response->u.port.d_id = port->d_id; |
| 211 | response->u.port.port_handle = qtcb->header.port_handle; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 212 | break; |
| 213 | |
| 214 | case FSF_QTCB_OPEN_LUN: |
| 215 | case FSF_QTCB_CLOSE_LUN: |
| 216 | unit = (struct zfcp_unit *)fsf_req->data; |
| 217 | port = unit->port; |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 218 | response->u.unit.wwpn = port->wwpn; |
| 219 | response->u.unit.fcp_lun = unit->fcp_lun; |
| 220 | response->u.unit.port_handle = qtcb->header.port_handle; |
| 221 | response->u.unit.lun_handle = qtcb->header.lun_handle; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 222 | break; |
| 223 | |
| 224 | case FSF_QTCB_SEND_ELS: |
| 225 | send_els = (struct zfcp_send_els *)fsf_req->data; |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 226 | response->u.els.d_id = qtcb->bottom.support.d_id; |
| 227 | response->u.els.ls_code = send_els->ls_code >> 24; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 228 | break; |
| 229 | |
| 230 | case FSF_QTCB_ABORT_FCP_CMND: |
| 231 | case FSF_QTCB_SEND_GENERIC: |
| 232 | case FSF_QTCB_EXCHANGE_CONFIG_DATA: |
| 233 | case FSF_QTCB_EXCHANGE_PORT_DATA: |
| 234 | case FSF_QTCB_DOWNLOAD_CONTROL_FILE: |
| 235 | case FSF_QTCB_UPLOAD_CONTROL_FILE: |
| 236 | break; |
| 237 | } |
| 238 | |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 239 | debug_event(adapter->hba_dbf, level, rec, sizeof(*rec)); |
Martin Peschke | b75db73 | 2008-03-27 14:21:58 +0100 | [diff] [blame] | 240 | |
| 241 | /* have fcp channel microcode fixed to use as little as possible */ |
| 242 | if (fsf_req->fsf_command != FSF_QTCB_FCP_CMND) { |
| 243 | /* adjust length skipping trailing zeros */ |
| 244 | char *buf = (char *)qtcb + qtcb->header.log_start; |
| 245 | int len = qtcb->header.log_length; |
| 246 | for (; len && !buf[len - 1]; len--); |
| 247 | zfcp_dbf_hexdump(adapter->hba_dbf, rec, sizeof(*rec), level, |
| 248 | buf, len); |
| 249 | } |
| 250 | |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 251 | spin_unlock_irqrestore(&adapter->hba_dbf_lock, flags); |
| 252 | } |
| 253 | |
Martin Peschke | bfab163 | 2008-03-31 11:15:31 +0200 | [diff] [blame] | 254 | /** |
| 255 | * zfcp_hba_dbf_event_fsf_unsol - trace event for an unsolicited status buffer |
| 256 | * @tag: tag indicating which kind of unsolicited status has been received |
| 257 | * @adapter: adapter that has issued the unsolicited status buffer |
| 258 | * @status_buffer: buffer containing payload of unsolicited status |
| 259 | */ |
Martin Peschke | 92c7a83 | 2008-03-31 11:15:30 +0200 | [diff] [blame] | 260 | void zfcp_hba_dbf_event_fsf_unsol(const char *tag, struct zfcp_adapter *adapter, |
| 261 | struct fsf_status_read_buffer *status_buffer) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 262 | { |
| 263 | struct zfcp_hba_dbf_record *rec = &adapter->hba_dbf_buf; |
| 264 | unsigned long flags; |
| 265 | |
| 266 | spin_lock_irqsave(&adapter->hba_dbf_lock, flags); |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 267 | memset(rec, 0, sizeof(*rec)); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 268 | strncpy(rec->tag, "stat", ZFCP_DBF_TAG_SIZE); |
| 269 | strncpy(rec->tag2, tag, ZFCP_DBF_TAG_SIZE); |
| 270 | |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 271 | rec->u.status.failed = adapter->status_read_failed; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 272 | if (status_buffer != NULL) { |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 273 | rec->u.status.status_type = status_buffer->status_type; |
| 274 | rec->u.status.status_subtype = status_buffer->status_subtype; |
| 275 | memcpy(&rec->u.status.queue_designator, |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 276 | &status_buffer->queue_designator, |
| 277 | sizeof(struct fsf_queue_designator)); |
| 278 | |
| 279 | switch (status_buffer->status_type) { |
| 280 | case FSF_STATUS_READ_SENSE_DATA_AVAIL: |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 281 | rec->u.status.payload_size = |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 282 | ZFCP_DBF_UNSOL_PAYLOAD_SENSE_DATA_AVAIL; |
| 283 | break; |
| 284 | |
| 285 | case FSF_STATUS_READ_BIT_ERROR_THRESHOLD: |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 286 | rec->u.status.payload_size = |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 287 | ZFCP_DBF_UNSOL_PAYLOAD_BIT_ERROR_THRESHOLD; |
| 288 | break; |
| 289 | |
| 290 | case FSF_STATUS_READ_LINK_DOWN: |
Maxim Shchetynin | aef4a98 | 2005-09-13 21:51:16 +0200 | [diff] [blame] | 291 | switch (status_buffer->status_subtype) { |
| 292 | case FSF_STATUS_READ_SUB_NO_PHYSICAL_LINK: |
| 293 | case FSF_STATUS_READ_SUB_FDISC_FAILED: |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 294 | rec->u.status.payload_size = |
Maxim Shchetynin | aef4a98 | 2005-09-13 21:51:16 +0200 | [diff] [blame] | 295 | sizeof(struct fsf_link_down_info); |
| 296 | } |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 297 | break; |
| 298 | |
Maxim Shchetynin | aef4a98 | 2005-09-13 21:51:16 +0200 | [diff] [blame] | 299 | case FSF_STATUS_READ_FEATURE_UPDATE_ALERT: |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 300 | rec->u.status.payload_size = |
Maxim Shchetynin | aef4a98 | 2005-09-13 21:51:16 +0200 | [diff] [blame] | 301 | ZFCP_DBF_UNSOL_PAYLOAD_FEATURE_UPDATE_ALERT; |
| 302 | break; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 303 | } |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 304 | memcpy(&rec->u.status.payload, |
| 305 | &status_buffer->payload, rec->u.status.payload_size); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 306 | } |
| 307 | |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 308 | debug_event(adapter->hba_dbf, 2, rec, sizeof(*rec)); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 309 | spin_unlock_irqrestore(&adapter->hba_dbf_lock, flags); |
| 310 | } |
| 311 | |
Martin Peschke | bfab163 | 2008-03-31 11:15:31 +0200 | [diff] [blame] | 312 | /** |
| 313 | * zfcp_hba_dbf_event_qdio - trace event for QDIO related failure |
| 314 | * @adapter: adapter affected by this QDIO related event |
| 315 | * @status: as passed by qdio module |
| 316 | * @qdio_error: as passed by qdio module |
| 317 | * @siga_error: as passed by qdio module |
| 318 | * @sbal_index: first buffer with error condition, as passed by qdio module |
| 319 | * @sbal_count: number of buffers affected, as passed by qdio module |
| 320 | */ |
Martin Peschke | 92c7a83 | 2008-03-31 11:15:30 +0200 | [diff] [blame] | 321 | void zfcp_hba_dbf_event_qdio(struct zfcp_adapter *adapter, unsigned int status, |
| 322 | unsigned int qdio_error, unsigned int siga_error, |
| 323 | int sbal_index, int sbal_count) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 324 | { |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 325 | struct zfcp_hba_dbf_record *r = &adapter->hba_dbf_buf; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 326 | unsigned long flags; |
| 327 | |
| 328 | spin_lock_irqsave(&adapter->hba_dbf_lock, flags); |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 329 | memset(r, 0, sizeof(*r)); |
| 330 | strncpy(r->tag, "qdio", ZFCP_DBF_TAG_SIZE); |
| 331 | r->u.qdio.status = status; |
| 332 | r->u.qdio.qdio_error = qdio_error; |
| 333 | r->u.qdio.siga_error = siga_error; |
| 334 | r->u.qdio.sbal_index = sbal_index; |
| 335 | r->u.qdio.sbal_count = sbal_count; |
| 336 | debug_event(adapter->hba_dbf, 0, r, sizeof(*r)); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 337 | spin_unlock_irqrestore(&adapter->hba_dbf_lock, flags); |
| 338 | } |
| 339 | |
Martin Peschke | a9c8577 | 2008-03-31 11:15:27 +0200 | [diff] [blame] | 340 | static void zfcp_hba_dbf_view_response(char **p, |
| 341 | struct zfcp_hba_dbf_record_response *r) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 342 | { |
Martin Peschke | 8fc5af1 | 2008-03-31 11:15:23 +0200 | [diff] [blame] | 343 | struct timespec t; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 344 | |
Martin Peschke | a9c8577 | 2008-03-31 11:15:27 +0200 | [diff] [blame] | 345 | zfcp_dbf_out(p, "fsf_command", "0x%08x", r->fsf_command); |
| 346 | zfcp_dbf_out(p, "fsf_reqid", "0x%0Lx", r->fsf_reqid); |
| 347 | zfcp_dbf_out(p, "fsf_seqno", "0x%08x", r->fsf_seqno); |
Martin Peschke | b634fff | 2008-03-31 11:15:24 +0200 | [diff] [blame] | 348 | zfcp_dbf_timestamp(r->fsf_issued, &t); |
Martin Peschke | a9c8577 | 2008-03-31 11:15:27 +0200 | [diff] [blame] | 349 | zfcp_dbf_out(p, "fsf_issued", "%011lu:%06lu", t.tv_sec, t.tv_nsec); |
| 350 | zfcp_dbf_out(p, "fsf_prot_status", "0x%08x", r->fsf_prot_status); |
| 351 | zfcp_dbf_out(p, "fsf_status", "0x%08x", r->fsf_status); |
| 352 | zfcp_dbf_outd(p, "fsf_prot_status_qual", r->fsf_prot_status_qual, |
Martin Peschke | df29f4a | 2008-03-31 11:15:26 +0200 | [diff] [blame] | 353 | FSF_PROT_STATUS_QUAL_SIZE, 0, FSF_PROT_STATUS_QUAL_SIZE); |
Martin Peschke | a9c8577 | 2008-03-31 11:15:27 +0200 | [diff] [blame] | 354 | zfcp_dbf_outd(p, "fsf_status_qual", r->fsf_status_qual, |
Martin Peschke | df29f4a | 2008-03-31 11:15:26 +0200 | [diff] [blame] | 355 | FSF_STATUS_QUALIFIER_SIZE, 0, FSF_STATUS_QUALIFIER_SIZE); |
Martin Peschke | a9c8577 | 2008-03-31 11:15:27 +0200 | [diff] [blame] | 356 | zfcp_dbf_out(p, "fsf_req_status", "0x%08x", r->fsf_req_status); |
| 357 | zfcp_dbf_out(p, "sbal_first", "0x%02x", r->sbal_first); |
| 358 | zfcp_dbf_out(p, "sbal_curr", "0x%02x", r->sbal_curr); |
| 359 | zfcp_dbf_out(p, "sbal_last", "0x%02x", r->sbal_last); |
| 360 | zfcp_dbf_out(p, "pool", "0x%02x", r->pool); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 361 | |
Martin Peschke | b634fff | 2008-03-31 11:15:24 +0200 | [diff] [blame] | 362 | switch (r->fsf_command) { |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 363 | case FSF_QTCB_FCP_CMND: |
Martin Peschke | b634fff | 2008-03-31 11:15:24 +0200 | [diff] [blame] | 364 | if (r->fsf_req_status & ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 365 | break; |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 366 | zfcp_dbf_out(p, "scsi_cmnd", "0x%0Lx", r->u.fcp.cmnd); |
| 367 | zfcp_dbf_out(p, "scsi_serial", "0x%016Lx", r->u.fcp.serial); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 368 | break; |
| 369 | |
| 370 | case FSF_QTCB_OPEN_PORT_WITH_DID: |
| 371 | case FSF_QTCB_CLOSE_PORT: |
| 372 | case FSF_QTCB_CLOSE_PHYSICAL_PORT: |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 373 | zfcp_dbf_out(p, "wwpn", "0x%016Lx", r->u.port.wwpn); |
| 374 | zfcp_dbf_out(p, "d_id", "0x%06x", r->u.port.d_id); |
| 375 | zfcp_dbf_out(p, "port_handle", "0x%08x", r->u.port.port_handle); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 376 | break; |
| 377 | |
| 378 | case FSF_QTCB_OPEN_LUN: |
| 379 | case FSF_QTCB_CLOSE_LUN: |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 380 | zfcp_dbf_out(p, "wwpn", "0x%016Lx", r->u.unit.wwpn); |
| 381 | zfcp_dbf_out(p, "fcp_lun", "0x%016Lx", r->u.unit.fcp_lun); |
| 382 | zfcp_dbf_out(p, "port_handle", "0x%08x", r->u.unit.port_handle); |
| 383 | zfcp_dbf_out(p, "lun_handle", "0x%08x", r->u.unit.lun_handle); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 384 | break; |
| 385 | |
| 386 | case FSF_QTCB_SEND_ELS: |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 387 | zfcp_dbf_out(p, "d_id", "0x%06x", r->u.els.d_id); |
| 388 | zfcp_dbf_out(p, "ls_code", "0x%02x", r->u.els.ls_code); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 389 | break; |
| 390 | |
| 391 | case FSF_QTCB_ABORT_FCP_CMND: |
| 392 | case FSF_QTCB_SEND_GENERIC: |
| 393 | case FSF_QTCB_EXCHANGE_CONFIG_DATA: |
| 394 | case FSF_QTCB_EXCHANGE_PORT_DATA: |
| 395 | case FSF_QTCB_DOWNLOAD_CONTROL_FILE: |
| 396 | case FSF_QTCB_UPLOAD_CONTROL_FILE: |
| 397 | break; |
| 398 | } |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 399 | } |
| 400 | |
Martin Peschke | a9c8577 | 2008-03-31 11:15:27 +0200 | [diff] [blame] | 401 | static void zfcp_hba_dbf_view_status(char **p, |
| 402 | struct zfcp_hba_dbf_record_status *r) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 403 | { |
Martin Peschke | a9c8577 | 2008-03-31 11:15:27 +0200 | [diff] [blame] | 404 | zfcp_dbf_out(p, "failed", "0x%02x", r->failed); |
| 405 | zfcp_dbf_out(p, "status_type", "0x%08x", r->status_type); |
| 406 | zfcp_dbf_out(p, "status_subtype", "0x%08x", r->status_subtype); |
| 407 | zfcp_dbf_outd(p, "queue_designator", (char *)&r->queue_designator, |
Martin Peschke | df29f4a | 2008-03-31 11:15:26 +0200 | [diff] [blame] | 408 | sizeof(struct fsf_queue_designator), 0, |
| 409 | sizeof(struct fsf_queue_designator)); |
Martin Peschke | a9c8577 | 2008-03-31 11:15:27 +0200 | [diff] [blame] | 410 | zfcp_dbf_outd(p, "payload", (char *)&r->payload, r->payload_size, 0, |
Martin Peschke | df29f4a | 2008-03-31 11:15:26 +0200 | [diff] [blame] | 411 | r->payload_size); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 412 | } |
| 413 | |
Martin Peschke | a9c8577 | 2008-03-31 11:15:27 +0200 | [diff] [blame] | 414 | static void zfcp_hba_dbf_view_qdio(char **p, struct zfcp_hba_dbf_record_qdio *r) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 415 | { |
Martin Peschke | a9c8577 | 2008-03-31 11:15:27 +0200 | [diff] [blame] | 416 | zfcp_dbf_out(p, "status", "0x%08x", r->status); |
| 417 | zfcp_dbf_out(p, "qdio_error", "0x%08x", r->qdio_error); |
| 418 | zfcp_dbf_out(p, "siga_error", "0x%08x", r->siga_error); |
| 419 | zfcp_dbf_out(p, "sbal_index", "0x%02x", r->sbal_index); |
| 420 | zfcp_dbf_out(p, "sbal_count", "0x%02x", r->sbal_count); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 421 | } |
| 422 | |
Martin Peschke | a9c8577 | 2008-03-31 11:15:27 +0200 | [diff] [blame] | 423 | static int zfcp_hba_dbf_view_format(debug_info_t *id, struct debug_view *view, |
| 424 | char *out_buf, const char *in_buf) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 425 | { |
Martin Peschke | a9c8577 | 2008-03-31 11:15:27 +0200 | [diff] [blame] | 426 | struct zfcp_hba_dbf_record *r = (struct zfcp_hba_dbf_record *)in_buf; |
| 427 | char *p = out_buf; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 428 | |
Martin Peschke | a9c8577 | 2008-03-31 11:15:27 +0200 | [diff] [blame] | 429 | if (strncmp(r->tag, "dump", ZFCP_DBF_TAG_SIZE) == 0) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 430 | return 0; |
| 431 | |
Martin Peschke | a9c8577 | 2008-03-31 11:15:27 +0200 | [diff] [blame] | 432 | zfcp_dbf_tag(&p, "tag", r->tag); |
| 433 | if (isalpha(r->tag2[0])) |
| 434 | zfcp_dbf_tag(&p, "tag2", r->tag2); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 435 | |
Martin Peschke | a9c8577 | 2008-03-31 11:15:27 +0200 | [diff] [blame] | 436 | if (strncmp(r->tag, "resp", ZFCP_DBF_TAG_SIZE) == 0) |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 437 | zfcp_hba_dbf_view_response(&p, &r->u.response); |
Martin Peschke | a9c8577 | 2008-03-31 11:15:27 +0200 | [diff] [blame] | 438 | else if (strncmp(r->tag, "stat", ZFCP_DBF_TAG_SIZE) == 0) |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 439 | zfcp_hba_dbf_view_status(&p, &r->u.status); |
Martin Peschke | a9c8577 | 2008-03-31 11:15:27 +0200 | [diff] [blame] | 440 | else if (strncmp(r->tag, "qdio", ZFCP_DBF_TAG_SIZE) == 0) |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 441 | zfcp_hba_dbf_view_qdio(&p, &r->u.qdio); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 442 | |
Martin Peschke | a9c8577 | 2008-03-31 11:15:27 +0200 | [diff] [blame] | 443 | p += sprintf(p, "\n"); |
| 444 | return p - out_buf; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 445 | } |
| 446 | |
Heiko Carstens | 2b67fc4 | 2007-02-05 21:16:47 +0100 | [diff] [blame] | 447 | static struct debug_view zfcp_hba_dbf_view = { |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 448 | "structured", |
| 449 | NULL, |
| 450 | &zfcp_dbf_view_header, |
| 451 | &zfcp_hba_dbf_view_format, |
| 452 | NULL, |
| 453 | NULL |
| 454 | }; |
| 455 | |
Martin Peschke | d79a83d | 2008-03-27 14:22:00 +0100 | [diff] [blame] | 456 | static const char *zfcp_rec_dbf_tags[] = { |
Martin Peschke | 348447e | 2008-03-27 14:22:01 +0100 | [diff] [blame] | 457 | [ZFCP_REC_DBF_ID_THREAD] = "thread", |
Martin Peschke | 698ec016 | 2008-03-27 14:22:02 +0100 | [diff] [blame] | 458 | [ZFCP_REC_DBF_ID_TARGET] = "target", |
Martin Peschke | 9467a9b | 2008-03-27 14:22:03 +0100 | [diff] [blame] | 459 | [ZFCP_REC_DBF_ID_TRIGGER] = "trigger", |
Martin Peschke | 6f4f365 | 2008-03-27 14:22:04 +0100 | [diff] [blame] | 460 | [ZFCP_REC_DBF_ID_ACTION] = "action", |
Martin Peschke | d79a83d | 2008-03-27 14:22:00 +0100 | [diff] [blame] | 461 | }; |
| 462 | |
| 463 | static const char *zfcp_rec_dbf_ids[] = { |
Martin Peschke | 348447e | 2008-03-27 14:22:01 +0100 | [diff] [blame] | 464 | [1] = "new", |
| 465 | [2] = "ready", |
| 466 | [3] = "kill", |
| 467 | [4] = "down sleep", |
| 468 | [5] = "down wakeup", |
| 469 | [6] = "down sleep ecd", |
| 470 | [7] = "down wakeup ecd", |
| 471 | [8] = "down sleep epd", |
| 472 | [9] = "down wakeup epd", |
Martin Peschke | 698ec016 | 2008-03-27 14:22:02 +0100 | [diff] [blame] | 473 | [10] = "online", |
| 474 | [11] = "operational", |
| 475 | [12] = "scsi slave destroy", |
| 476 | [13] = "propagate failed adapter", |
| 477 | [14] = "propagate failed port", |
| 478 | [15] = "block adapter", |
| 479 | [16] = "unblock adapter", |
| 480 | [17] = "block port", |
| 481 | [18] = "unblock port", |
| 482 | [19] = "block unit", |
| 483 | [20] = "unblock unit", |
| 484 | [21] = "unit recovery failed", |
| 485 | [22] = "port recovery failed", |
| 486 | [23] = "adapter recovery failed", |
| 487 | [24] = "qdio queues down", |
| 488 | [25] = "p2p failed", |
| 489 | [26] = "nameserver lookup failed", |
| 490 | [27] = "nameserver port failed", |
| 491 | [28] = "link up", |
| 492 | [29] = "link down", |
| 493 | [30] = "link up status read", |
| 494 | [31] = "open port failed", |
| 495 | [32] = "open port failed", |
| 496 | [33] = "close port", |
| 497 | [34] = "open unit failed", |
| 498 | [35] = "exclusive open unit failed", |
| 499 | [36] = "shared open unit failed", |
| 500 | [37] = "link down", |
| 501 | [38] = "link down status read no link", |
| 502 | [39] = "link down status read fdisc login", |
| 503 | [40] = "link down status read firmware update", |
| 504 | [41] = "link down status read unknown reason", |
| 505 | [42] = "link down ecd incomplete", |
| 506 | [43] = "link down epd incomplete", |
| 507 | [44] = "sysfs adapter recovery", |
| 508 | [45] = "sysfs port recovery", |
| 509 | [46] = "sysfs unit recovery", |
| 510 | [47] = "port boxed abort", |
| 511 | [48] = "unit boxed abort", |
| 512 | [49] = "port boxed ct", |
| 513 | [50] = "port boxed close physical", |
| 514 | [51] = "port boxed open unit", |
| 515 | [52] = "port boxed close unit", |
| 516 | [53] = "port boxed fcp", |
| 517 | [54] = "unit boxed fcp", |
| 518 | [55] = "port access denied ct", |
| 519 | [56] = "port access denied els", |
| 520 | [57] = "port access denied open port", |
| 521 | [58] = "port access denied close physical", |
| 522 | [59] = "unit access denied open unit", |
| 523 | [60] = "shared unit access denied open unit", |
| 524 | [61] = "unit access denied fcp", |
Martin Peschke | 9467a9b | 2008-03-27 14:22:03 +0100 | [diff] [blame] | 525 | [62] = "request timeout", |
| 526 | [63] = "adisc link test reject or timeout", |
| 527 | [64] = "adisc link test d_id changed", |
| 528 | [65] = "adisc link test failed", |
| 529 | [66] = "recovery out of memory", |
| 530 | [67] = "adapter recovery repeated after state change", |
| 531 | [68] = "port recovery repeated after state change", |
| 532 | [69] = "unit recovery repeated after state change", |
| 533 | [70] = "port recovery follow-up after successful adapter recovery", |
| 534 | [71] = "adapter recovery escalation after failed adapter recovery", |
| 535 | [72] = "port recovery follow-up after successful physical port " |
| 536 | "recovery", |
| 537 | [73] = "adapter recovery escalation after failed physical port " |
| 538 | "recovery", |
| 539 | [74] = "unit recovery follow-up after successful port recovery", |
| 540 | [75] = "physical port recovery escalation after failed port " |
| 541 | "recovery", |
| 542 | [76] = "port recovery escalation after failed unit recovery", |
| 543 | [77] = "recovery opening nameserver port", |
| 544 | [78] = "duplicate request id", |
| 545 | [79] = "link down", |
| 546 | [80] = "exclusive read-only unit access unsupported", |
| 547 | [81] = "shared read-write unit access unsupported", |
| 548 | [82] = "incoming rscn", |
| 549 | [83] = "incoming plogi", |
| 550 | [84] = "incoming logo", |
| 551 | [85] = "online", |
| 552 | [86] = "offline", |
| 553 | [87] = "ccw device gone", |
| 554 | [88] = "ccw device no path", |
| 555 | [89] = "ccw device operational", |
| 556 | [90] = "ccw device shutdown", |
| 557 | [91] = "sysfs port addition", |
| 558 | [92] = "sysfs port removal", |
| 559 | [93] = "sysfs adapter recovery", |
| 560 | [94] = "sysfs unit addition", |
| 561 | [95] = "sysfs unit removal", |
| 562 | [96] = "sysfs port recovery", |
| 563 | [97] = "sysfs unit recovery", |
| 564 | [98] = "sequence number mismatch", |
| 565 | [99] = "link up", |
| 566 | [100] = "error state", |
| 567 | [101] = "status read physical port closed", |
| 568 | [102] = "link up status read", |
| 569 | [103] = "too many failed status read buffers", |
| 570 | [104] = "port handle not valid abort", |
| 571 | [105] = "lun handle not valid abort", |
| 572 | [106] = "port handle not valid ct", |
| 573 | [107] = "port handle not valid close port", |
| 574 | [108] = "port handle not valid close physical port", |
| 575 | [109] = "port handle not valid open unit", |
| 576 | [110] = "port handle not valid close unit", |
| 577 | [111] = "lun handle not valid close unit", |
| 578 | [112] = "port handle not valid fcp", |
| 579 | [113] = "lun handle not valid fcp", |
| 580 | [114] = "handle mismatch fcp", |
| 581 | [115] = "lun not valid fcp", |
| 582 | [116] = "qdio send failed", |
| 583 | [117] = "version mismatch", |
| 584 | [118] = "incompatible qtcb type", |
| 585 | [119] = "unknown protocol status", |
| 586 | [120] = "unknown fsf command", |
| 587 | [121] = "no recommendation for status qualifier", |
| 588 | [122] = "status read physical port closed in error", |
| 589 | [123] = "fc service class not supported ct", |
| 590 | [124] = "fc service class not supported els", |
| 591 | [125] = "need newer zfcp", |
| 592 | [126] = "need newer microcode", |
| 593 | [127] = "arbitrated loop not supported", |
| 594 | [128] = "unknown topology", |
| 595 | [129] = "qtcb size mismatch", |
| 596 | [130] = "unknown fsf status ecd", |
| 597 | [131] = "fcp request too big", |
| 598 | [132] = "fc service class not supported fcp", |
| 599 | [133] = "data direction not valid fcp", |
| 600 | [134] = "command length not valid fcp", |
| 601 | [135] = "status read act update", |
| 602 | [136] = "status read cfdc update", |
| 603 | [137] = "hbaapi port open", |
| 604 | [138] = "hbaapi unit open", |
| 605 | [139] = "hbaapi unit shutdown", |
| 606 | [140] = "qdio error", |
| 607 | [141] = "scsi host reset", |
Martin Peschke | 6f4f365 | 2008-03-27 14:22:04 +0100 | [diff] [blame] | 608 | [142] = "dismissing fsf request for recovery action", |
| 609 | [143] = "recovery action timed out", |
| 610 | [144] = "recovery action gone", |
| 611 | [145] = "recovery action being processed", |
| 612 | [146] = "recovery action ready for next step", |
Martin Peschke | d79a83d | 2008-03-27 14:22:00 +0100 | [diff] [blame] | 613 | }; |
| 614 | |
| 615 | static int zfcp_rec_dbf_view_format(debug_info_t *id, struct debug_view *view, |
| 616 | char *buf, const char *_rec) |
| 617 | { |
| 618 | struct zfcp_rec_dbf_record *r = (struct zfcp_rec_dbf_record *)_rec; |
| 619 | char *p = buf; |
| 620 | |
| 621 | zfcp_dbf_outs(&p, "tag", zfcp_rec_dbf_tags[r->id]); |
| 622 | zfcp_dbf_outs(&p, "hint", zfcp_rec_dbf_ids[r->id2]); |
| 623 | zfcp_dbf_out(&p, "id", "%d", r->id2); |
| 624 | switch (r->id) { |
Martin Peschke | 348447e | 2008-03-27 14:22:01 +0100 | [diff] [blame] | 625 | case ZFCP_REC_DBF_ID_THREAD: |
Martin Peschke | 348447e | 2008-03-27 14:22:01 +0100 | [diff] [blame] | 626 | zfcp_dbf_out(&p, "total", "%d", r->u.thread.total); |
| 627 | zfcp_dbf_out(&p, "ready", "%d", r->u.thread.ready); |
| 628 | zfcp_dbf_out(&p, "running", "%d", r->u.thread.running); |
| 629 | break; |
Martin Peschke | 698ec016 | 2008-03-27 14:22:02 +0100 | [diff] [blame] | 630 | case ZFCP_REC_DBF_ID_TARGET: |
| 631 | zfcp_dbf_out(&p, "reference", "0x%016Lx", r->u.target.ref); |
| 632 | zfcp_dbf_out(&p, "status", "0x%08x", r->u.target.status); |
| 633 | zfcp_dbf_out(&p, "erp_count", "%d", r->u.target.erp_count); |
| 634 | zfcp_dbf_out(&p, "d_id", "0x%06x", r->u.target.d_id); |
| 635 | zfcp_dbf_out(&p, "wwpn", "0x%016Lx", r->u.target.wwpn); |
| 636 | zfcp_dbf_out(&p, "fcp_lun", "0x%016Lx", r->u.target.fcp_lun); |
| 637 | break; |
Martin Peschke | 9467a9b | 2008-03-27 14:22:03 +0100 | [diff] [blame] | 638 | case ZFCP_REC_DBF_ID_TRIGGER: |
| 639 | zfcp_dbf_out(&p, "reference", "0x%016Lx", r->u.trigger.ref); |
| 640 | zfcp_dbf_out(&p, "erp_action", "0x%016Lx", r->u.trigger.action); |
| 641 | zfcp_dbf_out(&p, "requested", "%d", r->u.trigger.want); |
| 642 | zfcp_dbf_out(&p, "executed", "%d", r->u.trigger.need); |
| 643 | zfcp_dbf_out(&p, "wwpn", "0x%016Lx", r->u.trigger.wwpn); |
| 644 | zfcp_dbf_out(&p, "fcp_lun", "0x%016Lx", r->u.trigger.fcp_lun); |
| 645 | zfcp_dbf_out(&p, "adapter_status", "0x%08x", r->u.trigger.as); |
| 646 | zfcp_dbf_out(&p, "port_status", "0x%08x", r->u.trigger.ps); |
| 647 | zfcp_dbf_out(&p, "unit_status", "0x%08x", r->u.trigger.us); |
| 648 | break; |
Martin Peschke | 6f4f365 | 2008-03-27 14:22:04 +0100 | [diff] [blame] | 649 | case ZFCP_REC_DBF_ID_ACTION: |
| 650 | zfcp_dbf_out(&p, "erp_action", "0x%016Lx", r->u.action.action); |
| 651 | zfcp_dbf_out(&p, "fsf_req", "0x%016Lx", r->u.action.fsf_req); |
| 652 | zfcp_dbf_out(&p, "status", "0x%08Lx", r->u.action.status); |
| 653 | zfcp_dbf_out(&p, "step", "0x%08Lx", r->u.action.step); |
| 654 | break; |
Martin Peschke | d79a83d | 2008-03-27 14:22:00 +0100 | [diff] [blame] | 655 | } |
Martin Peschke | b634fff | 2008-03-31 11:15:24 +0200 | [diff] [blame] | 656 | p += sprintf(p, "\n"); |
| 657 | return p - buf; |
Martin Peschke | d79a83d | 2008-03-27 14:22:00 +0100 | [diff] [blame] | 658 | } |
| 659 | |
| 660 | static struct debug_view zfcp_rec_dbf_view = { |
| 661 | "structured", |
| 662 | NULL, |
| 663 | &zfcp_dbf_view_header, |
| 664 | &zfcp_rec_dbf_view_format, |
| 665 | NULL, |
| 666 | NULL |
| 667 | }; |
| 668 | |
Martin Peschke | 348447e | 2008-03-27 14:22:01 +0100 | [diff] [blame] | 669 | /** |
| 670 | * zfcp_rec_dbf_event_thread - trace event related to recovery thread operation |
| 671 | * @id2: identifier for event |
| 672 | * @adapter: adapter |
| 673 | * @lock: non-zero value indicates that erp_lock has not yet been acquired |
| 674 | */ |
| 675 | void zfcp_rec_dbf_event_thread(u8 id2, struct zfcp_adapter *adapter, int lock) |
| 676 | { |
| 677 | struct zfcp_rec_dbf_record *r = &adapter->rec_dbf_buf; |
| 678 | unsigned long flags = 0; |
| 679 | struct list_head *entry; |
| 680 | unsigned ready = 0, running = 0, total; |
| 681 | |
| 682 | if (lock) |
| 683 | read_lock_irqsave(&adapter->erp_lock, flags); |
| 684 | list_for_each(entry, &adapter->erp_ready_head) |
| 685 | ready++; |
| 686 | list_for_each(entry, &adapter->erp_running_head) |
| 687 | running++; |
| 688 | total = adapter->erp_total_count; |
| 689 | if (lock) |
| 690 | read_unlock_irqrestore(&adapter->erp_lock, flags); |
| 691 | |
| 692 | spin_lock_irqsave(&adapter->rec_dbf_lock, flags); |
| 693 | memset(r, 0, sizeof(*r)); |
| 694 | r->id = ZFCP_REC_DBF_ID_THREAD; |
| 695 | r->id2 = id2; |
Martin Peschke | 348447e | 2008-03-27 14:22:01 +0100 | [diff] [blame] | 696 | r->u.thread.total = total; |
| 697 | r->u.thread.ready = ready; |
| 698 | r->u.thread.running = running; |
| 699 | debug_event(adapter->rec_dbf, 5, r, sizeof(*r)); |
| 700 | spin_unlock_irqrestore(&adapter->rec_dbf_lock, flags); |
| 701 | } |
| 702 | |
Martin Peschke | 1f6f712 | 2008-04-18 12:51:55 +0200 | [diff] [blame] | 703 | static void zfcp_rec_dbf_event_target(u8 id2, void *ref, |
Martin Peschke | 698ec016 | 2008-03-27 14:22:02 +0100 | [diff] [blame] | 704 | struct zfcp_adapter *adapter, |
| 705 | atomic_t *status, atomic_t *erp_count, |
| 706 | u64 wwpn, u32 d_id, u64 fcp_lun) |
| 707 | { |
| 708 | struct zfcp_rec_dbf_record *r = &adapter->rec_dbf_buf; |
| 709 | unsigned long flags; |
| 710 | |
| 711 | spin_lock_irqsave(&adapter->rec_dbf_lock, flags); |
| 712 | memset(r, 0, sizeof(*r)); |
| 713 | r->id = ZFCP_REC_DBF_ID_TARGET; |
| 714 | r->id2 = id2; |
Martin Peschke | 1f6f712 | 2008-04-18 12:51:55 +0200 | [diff] [blame] | 715 | r->u.target.ref = (unsigned long)ref; |
Martin Peschke | 698ec016 | 2008-03-27 14:22:02 +0100 | [diff] [blame] | 716 | r->u.target.status = atomic_read(status); |
| 717 | r->u.target.wwpn = wwpn; |
| 718 | r->u.target.d_id = d_id; |
| 719 | r->u.target.fcp_lun = fcp_lun; |
| 720 | r->u.target.erp_count = atomic_read(erp_count); |
| 721 | debug_event(adapter->rec_dbf, 3, r, sizeof(*r)); |
| 722 | spin_unlock_irqrestore(&adapter->rec_dbf_lock, flags); |
| 723 | } |
| 724 | |
| 725 | /** |
| 726 | * zfcp_rec_dbf_event_adapter - trace event for adapter state change |
| 727 | * @id: identifier for trigger of state change |
| 728 | * @ref: additional reference (e.g. request) |
| 729 | * @adapter: adapter |
| 730 | */ |
Martin Peschke | 1f6f712 | 2008-04-18 12:51:55 +0200 | [diff] [blame] | 731 | void zfcp_rec_dbf_event_adapter(u8 id, void *ref, struct zfcp_adapter *adapter) |
Martin Peschke | 698ec016 | 2008-03-27 14:22:02 +0100 | [diff] [blame] | 732 | { |
| 733 | zfcp_rec_dbf_event_target(id, ref, adapter, &adapter->status, |
| 734 | &adapter->erp_counter, 0, 0, 0); |
| 735 | } |
| 736 | |
| 737 | /** |
| 738 | * zfcp_rec_dbf_event_port - trace event for port state change |
| 739 | * @id: identifier for trigger of state change |
| 740 | * @ref: additional reference (e.g. request) |
| 741 | * @port: port |
| 742 | */ |
Martin Peschke | 1f6f712 | 2008-04-18 12:51:55 +0200 | [diff] [blame] | 743 | void zfcp_rec_dbf_event_port(u8 id, void *ref, struct zfcp_port *port) |
Martin Peschke | 698ec016 | 2008-03-27 14:22:02 +0100 | [diff] [blame] | 744 | { |
| 745 | struct zfcp_adapter *adapter = port->adapter; |
| 746 | |
| 747 | zfcp_rec_dbf_event_target(id, ref, adapter, &port->status, |
| 748 | &port->erp_counter, port->wwpn, port->d_id, |
| 749 | 0); |
| 750 | } |
| 751 | |
| 752 | /** |
| 753 | * zfcp_rec_dbf_event_unit - trace event for unit state change |
| 754 | * @id: identifier for trigger of state change |
| 755 | * @ref: additional reference (e.g. request) |
| 756 | * @unit: unit |
| 757 | */ |
Martin Peschke | 1f6f712 | 2008-04-18 12:51:55 +0200 | [diff] [blame] | 758 | void zfcp_rec_dbf_event_unit(u8 id, void *ref, struct zfcp_unit *unit) |
Martin Peschke | 698ec016 | 2008-03-27 14:22:02 +0100 | [diff] [blame] | 759 | { |
| 760 | struct zfcp_port *port = unit->port; |
| 761 | struct zfcp_adapter *adapter = port->adapter; |
| 762 | |
| 763 | zfcp_rec_dbf_event_target(id, ref, adapter, &unit->status, |
| 764 | &unit->erp_counter, port->wwpn, port->d_id, |
| 765 | unit->fcp_lun); |
| 766 | } |
| 767 | |
Martin Peschke | 9467a9b | 2008-03-27 14:22:03 +0100 | [diff] [blame] | 768 | /** |
| 769 | * zfcp_rec_dbf_event_trigger - trace event for triggered error recovery |
| 770 | * @id2: identifier for error recovery trigger |
| 771 | * @ref: additional reference (e.g. request) |
| 772 | * @want: originally requested error recovery action |
| 773 | * @need: error recovery action actually initiated |
| 774 | * @action: address of error recovery action struct |
| 775 | * @adapter: adapter |
| 776 | * @port: port |
| 777 | * @unit: unit |
| 778 | */ |
Martin Peschke | 1f6f712 | 2008-04-18 12:51:55 +0200 | [diff] [blame] | 779 | void zfcp_rec_dbf_event_trigger(u8 id2, void *ref, u8 want, u8 need, |
| 780 | void *action, struct zfcp_adapter *adapter, |
Martin Peschke | 9467a9b | 2008-03-27 14:22:03 +0100 | [diff] [blame] | 781 | struct zfcp_port *port, struct zfcp_unit *unit) |
| 782 | { |
| 783 | struct zfcp_rec_dbf_record *r = &adapter->rec_dbf_buf; |
| 784 | unsigned long flags; |
| 785 | |
| 786 | spin_lock_irqsave(&adapter->rec_dbf_lock, flags); |
| 787 | memset(r, 0, sizeof(*r)); |
| 788 | r->id = ZFCP_REC_DBF_ID_TRIGGER; |
| 789 | r->id2 = id2; |
Martin Peschke | 1f6f712 | 2008-04-18 12:51:55 +0200 | [diff] [blame] | 790 | r->u.trigger.ref = (unsigned long)ref; |
Martin Peschke | 9467a9b | 2008-03-27 14:22:03 +0100 | [diff] [blame] | 791 | r->u.trigger.want = want; |
| 792 | r->u.trigger.need = need; |
Martin Peschke | 1f6f712 | 2008-04-18 12:51:55 +0200 | [diff] [blame] | 793 | r->u.trigger.action = (unsigned long)action; |
Martin Peschke | 9467a9b | 2008-03-27 14:22:03 +0100 | [diff] [blame] | 794 | r->u.trigger.as = atomic_read(&adapter->status); |
| 795 | if (port) { |
| 796 | r->u.trigger.ps = atomic_read(&port->status); |
| 797 | r->u.trigger.wwpn = port->wwpn; |
| 798 | } |
| 799 | if (unit) { |
| 800 | r->u.trigger.us = atomic_read(&unit->status); |
| 801 | r->u.trigger.fcp_lun = unit->fcp_lun; |
| 802 | } |
| 803 | debug_event(adapter->rec_dbf, action ? 1 : 4, r, sizeof(*r)); |
| 804 | spin_unlock_irqrestore(&adapter->rec_dbf_lock, flags); |
| 805 | } |
| 806 | |
Martin Peschke | 6f4f365 | 2008-03-27 14:22:04 +0100 | [diff] [blame] | 807 | /** |
| 808 | * zfcp_rec_dbf_event_action - trace event showing progress of recovery action |
| 809 | * @id2: identifier |
| 810 | * @erp_action: error recovery action struct pointer |
| 811 | */ |
| 812 | void zfcp_rec_dbf_event_action(u8 id2, struct zfcp_erp_action *erp_action) |
| 813 | { |
| 814 | struct zfcp_adapter *adapter = erp_action->adapter; |
| 815 | struct zfcp_rec_dbf_record *r = &adapter->rec_dbf_buf; |
| 816 | unsigned long flags; |
| 817 | |
| 818 | spin_lock_irqsave(&adapter->rec_dbf_lock, flags); |
| 819 | memset(r, 0, sizeof(*r)); |
| 820 | r->id = ZFCP_REC_DBF_ID_ACTION; |
| 821 | r->id2 = id2; |
Martin Peschke | 1f6f712 | 2008-04-18 12:51:55 +0200 | [diff] [blame] | 822 | r->u.action.action = (unsigned long)erp_action; |
Martin Peschke | 6f4f365 | 2008-03-27 14:22:04 +0100 | [diff] [blame] | 823 | r->u.action.status = erp_action->status; |
| 824 | r->u.action.step = erp_action->step; |
Martin Peschke | 1f6f712 | 2008-04-18 12:51:55 +0200 | [diff] [blame] | 825 | r->u.action.fsf_req = (unsigned long)erp_action->fsf_req; |
Martin Peschke | 6f4f365 | 2008-03-27 14:22:04 +0100 | [diff] [blame] | 826 | debug_event(adapter->rec_dbf, 4, r, sizeof(*r)); |
| 827 | spin_unlock_irqrestore(&adapter->rec_dbf_lock, flags); |
| 828 | } |
| 829 | |
Martin Peschke | bfab163 | 2008-03-31 11:15:31 +0200 | [diff] [blame] | 830 | /** |
| 831 | * zfcp_san_dbf_event_ct_request - trace event for issued CT request |
| 832 | * @fsf_req: request containing issued CT data |
| 833 | */ |
Heiko Carstens | 4d284ca | 2007-02-05 21:18:53 +0100 | [diff] [blame] | 834 | void zfcp_san_dbf_event_ct_request(struct zfcp_fsf_req *fsf_req) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 835 | { |
| 836 | struct zfcp_send_ct *ct = (struct zfcp_send_ct *)fsf_req->data; |
| 837 | struct zfcp_port *port = ct->port; |
| 838 | struct zfcp_adapter *adapter = port->adapter; |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 839 | struct ct_hdr *hdr = zfcp_sg_to_address(ct->req); |
| 840 | struct zfcp_san_dbf_record *r = &adapter->san_dbf_buf; |
| 841 | struct zfcp_san_dbf_record_ct_request *oct = &r->u.ct_req; |
| 842 | unsigned long flags; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 843 | |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 844 | spin_lock_irqsave(&adapter->san_dbf_lock, flags); |
| 845 | memset(r, 0, sizeof(*r)); |
| 846 | strncpy(r->tag, "octc", ZFCP_DBF_TAG_SIZE); |
| 847 | r->fsf_reqid = (unsigned long)fsf_req; |
| 848 | r->fsf_seqno = fsf_req->seq_no; |
| 849 | r->s_id = fc_host_port_id(adapter->scsi_host); |
| 850 | r->d_id = port->d_id; |
| 851 | oct->cmd_req_code = hdr->cmd_rsp_code; |
| 852 | oct->revision = hdr->revision; |
| 853 | oct->gs_type = hdr->gs_type; |
| 854 | oct->gs_subtype = hdr->gs_subtype; |
| 855 | oct->options = hdr->options; |
| 856 | oct->max_res_size = hdr->max_res_size; |
| 857 | oct->len = min((int)ct->req->length - (int)sizeof(struct ct_hdr), |
| 858 | ZFCP_DBF_CT_PAYLOAD); |
| 859 | memcpy(oct->payload, (void *)hdr + sizeof(struct ct_hdr), oct->len); |
| 860 | debug_event(adapter->san_dbf, 3, r, sizeof(*r)); |
| 861 | spin_unlock_irqrestore(&adapter->san_dbf_lock, flags); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 862 | } |
| 863 | |
Martin Peschke | bfab163 | 2008-03-31 11:15:31 +0200 | [diff] [blame] | 864 | /** |
| 865 | * zfcp_san_dbf_event_ct_response - trace event for completion of CT request |
| 866 | * @fsf_req: request containing CT response |
| 867 | */ |
Heiko Carstens | 4d284ca | 2007-02-05 21:18:53 +0100 | [diff] [blame] | 868 | void zfcp_san_dbf_event_ct_response(struct zfcp_fsf_req *fsf_req) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 869 | { |
| 870 | struct zfcp_send_ct *ct = (struct zfcp_send_ct *)fsf_req->data; |
| 871 | struct zfcp_port *port = ct->port; |
| 872 | struct zfcp_adapter *adapter = port->adapter; |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 873 | struct ct_hdr *hdr = zfcp_sg_to_address(ct->resp); |
| 874 | struct zfcp_san_dbf_record *r = &adapter->san_dbf_buf; |
| 875 | struct zfcp_san_dbf_record_ct_response *rct = &r->u.ct_resp; |
| 876 | unsigned long flags; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 877 | |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 878 | spin_lock_irqsave(&adapter->san_dbf_lock, flags); |
| 879 | memset(r, 0, sizeof(*r)); |
| 880 | strncpy(r->tag, "rctc", ZFCP_DBF_TAG_SIZE); |
| 881 | r->fsf_reqid = (unsigned long)fsf_req; |
| 882 | r->fsf_seqno = fsf_req->seq_no; |
| 883 | r->s_id = port->d_id; |
| 884 | r->d_id = fc_host_port_id(adapter->scsi_host); |
| 885 | rct->cmd_rsp_code = hdr->cmd_rsp_code; |
| 886 | rct->revision = hdr->revision; |
| 887 | rct->reason_code = hdr->reason_code; |
| 888 | rct->expl = hdr->reason_code_expl; |
| 889 | rct->vendor_unique = hdr->vendor_unique; |
| 890 | rct->len = min((int)ct->resp->length - (int)sizeof(struct ct_hdr), |
| 891 | ZFCP_DBF_CT_PAYLOAD); |
| 892 | memcpy(rct->payload, (void *)hdr + sizeof(struct ct_hdr), rct->len); |
| 893 | debug_event(adapter->san_dbf, 3, r, sizeof(*r)); |
| 894 | spin_unlock_irqrestore(&adapter->san_dbf_lock, flags); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 895 | } |
| 896 | |
Martin Peschke | 92c7a83 | 2008-03-31 11:15:30 +0200 | [diff] [blame] | 897 | static void zfcp_san_dbf_event_els(const char *tag, int level, |
| 898 | struct zfcp_fsf_req *fsf_req, u32 s_id, |
| 899 | u32 d_id, u8 ls_code, void *buffer, |
| 900 | int buflen) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 901 | { |
| 902 | struct zfcp_adapter *adapter = fsf_req->adapter; |
| 903 | struct zfcp_san_dbf_record *rec = &adapter->san_dbf_buf; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 904 | unsigned long flags; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 905 | |
| 906 | spin_lock_irqsave(&adapter->san_dbf_lock, flags); |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 907 | memset(rec, 0, sizeof(*rec)); |
Martin Peschke | 0f65e95 | 2008-03-27 14:21:56 +0100 | [diff] [blame] | 908 | strncpy(rec->tag, tag, ZFCP_DBF_TAG_SIZE); |
| 909 | rec->fsf_reqid = (unsigned long)fsf_req; |
| 910 | rec->fsf_seqno = fsf_req->seq_no; |
| 911 | rec->s_id = s_id; |
| 912 | rec->d_id = d_id; |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 913 | rec->u.els.ls_code = ls_code; |
Martin Peschke | 0f65e95 | 2008-03-27 14:21:56 +0100 | [diff] [blame] | 914 | debug_event(adapter->san_dbf, level, rec, sizeof(*rec)); |
| 915 | zfcp_dbf_hexdump(adapter->san_dbf, rec, sizeof(*rec), level, |
| 916 | buffer, min(buflen, ZFCP_DBF_ELS_MAX_PAYLOAD)); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 917 | spin_unlock_irqrestore(&adapter->san_dbf_lock, flags); |
| 918 | } |
| 919 | |
Martin Peschke | bfab163 | 2008-03-31 11:15:31 +0200 | [diff] [blame] | 920 | /** |
| 921 | * zfcp_san_dbf_event_els_request - trace event for issued ELS |
| 922 | * @fsf_req: request containing issued ELS |
| 923 | */ |
Heiko Carstens | 4d284ca | 2007-02-05 21:18:53 +0100 | [diff] [blame] | 924 | void zfcp_san_dbf_event_els_request(struct zfcp_fsf_req *fsf_req) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 925 | { |
| 926 | struct zfcp_send_els *els = (struct zfcp_send_els *)fsf_req->data; |
| 927 | |
Martin Peschke | 92c7a83 | 2008-03-31 11:15:30 +0200 | [diff] [blame] | 928 | zfcp_san_dbf_event_els("oels", 2, fsf_req, |
| 929 | fc_host_port_id(els->adapter->scsi_host), |
| 930 | els->d_id, *(u8 *) zfcp_sg_to_address(els->req), |
| 931 | zfcp_sg_to_address(els->req), els->req->length); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 932 | } |
| 933 | |
Martin Peschke | bfab163 | 2008-03-31 11:15:31 +0200 | [diff] [blame] | 934 | /** |
| 935 | * zfcp_san_dbf_event_els_response - trace event for completed ELS |
| 936 | * @fsf_req: request containing ELS response |
| 937 | */ |
Heiko Carstens | 4d284ca | 2007-02-05 21:18:53 +0100 | [diff] [blame] | 938 | void zfcp_san_dbf_event_els_response(struct zfcp_fsf_req *fsf_req) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 939 | { |
| 940 | struct zfcp_send_els *els = (struct zfcp_send_els *)fsf_req->data; |
| 941 | |
Martin Peschke | 92c7a83 | 2008-03-31 11:15:30 +0200 | [diff] [blame] | 942 | zfcp_san_dbf_event_els("rels", 2, fsf_req, els->d_id, |
| 943 | fc_host_port_id(els->adapter->scsi_host), |
| 944 | *(u8 *)zfcp_sg_to_address(els->req), |
| 945 | zfcp_sg_to_address(els->resp), |
| 946 | els->resp->length); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 947 | } |
| 948 | |
Martin Peschke | bfab163 | 2008-03-31 11:15:31 +0200 | [diff] [blame] | 949 | /** |
| 950 | * zfcp_san_dbf_event_incoming_els - trace event for incomig ELS |
| 951 | * @fsf_req: request containing unsolicited status buffer with incoming ELS |
| 952 | */ |
Heiko Carstens | 4d284ca | 2007-02-05 21:18:53 +0100 | [diff] [blame] | 953 | void zfcp_san_dbf_event_incoming_els(struct zfcp_fsf_req *fsf_req) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 954 | { |
| 955 | struct zfcp_adapter *adapter = fsf_req->adapter; |
Martin Peschke | 92c7a83 | 2008-03-31 11:15:30 +0200 | [diff] [blame] | 956 | struct fsf_status_read_buffer *buf = |
| 957 | (struct fsf_status_read_buffer *)fsf_req->data; |
| 958 | int length = (int)buf->length - |
| 959 | (int)((void *)&buf->payload - (void *)buf); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 960 | |
Martin Peschke | 92c7a83 | 2008-03-31 11:15:30 +0200 | [diff] [blame] | 961 | zfcp_san_dbf_event_els("iels", 1, fsf_req, buf->d_id, |
| 962 | fc_host_port_id(adapter->scsi_host), |
| 963 | *(u8 *)buf->payload, (void *)buf->payload, |
| 964 | length); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 965 | } |
| 966 | |
Martin Peschke | 92c7a83 | 2008-03-31 11:15:30 +0200 | [diff] [blame] | 967 | static int zfcp_san_dbf_view_format(debug_info_t *id, struct debug_view *view, |
| 968 | char *out_buf, const char *in_buf) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 969 | { |
Martin Peschke | b634fff | 2008-03-31 11:15:24 +0200 | [diff] [blame] | 970 | struct zfcp_san_dbf_record *r = (struct zfcp_san_dbf_record *)in_buf; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 971 | char *buffer = NULL; |
| 972 | int buflen = 0, total = 0; |
Martin Peschke | b634fff | 2008-03-31 11:15:24 +0200 | [diff] [blame] | 973 | char *p = out_buf; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 974 | |
Martin Peschke | b634fff | 2008-03-31 11:15:24 +0200 | [diff] [blame] | 975 | if (strncmp(r->tag, "dump", ZFCP_DBF_TAG_SIZE) == 0) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 976 | return 0; |
| 977 | |
Martin Peschke | a9c8577 | 2008-03-31 11:15:27 +0200 | [diff] [blame] | 978 | zfcp_dbf_tag(&p, "tag", r->tag); |
Martin Peschke | b634fff | 2008-03-31 11:15:24 +0200 | [diff] [blame] | 979 | zfcp_dbf_out(&p, "fsf_reqid", "0x%0Lx", r->fsf_reqid); |
| 980 | zfcp_dbf_out(&p, "fsf_seqno", "0x%08x", r->fsf_seqno); |
| 981 | zfcp_dbf_out(&p, "s_id", "0x%06x", r->s_id); |
| 982 | zfcp_dbf_out(&p, "d_id", "0x%06x", r->d_id); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 983 | |
Martin Peschke | b634fff | 2008-03-31 11:15:24 +0200 | [diff] [blame] | 984 | if (strncmp(r->tag, "octc", ZFCP_DBF_TAG_SIZE) == 0) { |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 985 | struct zfcp_san_dbf_record_ct_request *ct = &r->u.ct_req; |
| 986 | zfcp_dbf_out(&p, "cmd_req_code", "0x%04x", ct->cmd_req_code); |
| 987 | zfcp_dbf_out(&p, "revision", "0x%02x", ct->revision); |
| 988 | zfcp_dbf_out(&p, "gs_type", "0x%02x", ct->gs_type); |
| 989 | zfcp_dbf_out(&p, "gs_subtype", "0x%02x", ct->gs_subtype); |
| 990 | zfcp_dbf_out(&p, "options", "0x%02x", ct->options); |
| 991 | zfcp_dbf_out(&p, "max_res_size", "0x%04x", ct->max_res_size); |
| 992 | total = ct->len; |
| 993 | buffer = ct->payload; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 994 | buflen = min(total, ZFCP_DBF_CT_PAYLOAD); |
Martin Peschke | b634fff | 2008-03-31 11:15:24 +0200 | [diff] [blame] | 995 | } else if (strncmp(r->tag, "rctc", ZFCP_DBF_TAG_SIZE) == 0) { |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 996 | struct zfcp_san_dbf_record_ct_response *ct = &r->u.ct_resp; |
| 997 | zfcp_dbf_out(&p, "cmd_rsp_code", "0x%04x", ct->cmd_rsp_code); |
| 998 | zfcp_dbf_out(&p, "revision", "0x%02x", ct->revision); |
| 999 | zfcp_dbf_out(&p, "reason_code", "0x%02x", ct->reason_code); |
| 1000 | zfcp_dbf_out(&p, "reason_code_expl", "0x%02x", ct->expl); |
| 1001 | zfcp_dbf_out(&p, "vendor_unique", "0x%02x", ct->vendor_unique); |
| 1002 | total = ct->len; |
| 1003 | buffer = ct->payload; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 1004 | buflen = min(total, ZFCP_DBF_CT_PAYLOAD); |
Martin Peschke | b634fff | 2008-03-31 11:15:24 +0200 | [diff] [blame] | 1005 | } else if (strncmp(r->tag, "oels", ZFCP_DBF_TAG_SIZE) == 0 || |
| 1006 | strncmp(r->tag, "rels", ZFCP_DBF_TAG_SIZE) == 0 || |
| 1007 | strncmp(r->tag, "iels", ZFCP_DBF_TAG_SIZE) == 0) { |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 1008 | struct zfcp_san_dbf_record_els *els = &r->u.els; |
| 1009 | zfcp_dbf_out(&p, "ls_code", "0x%02x", els->ls_code); |
| 1010 | total = els->len; |
| 1011 | buffer = els->payload; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 1012 | buflen = min(total, ZFCP_DBF_ELS_PAYLOAD); |
| 1013 | } |
| 1014 | |
Martin Peschke | df29f4a | 2008-03-31 11:15:26 +0200 | [diff] [blame] | 1015 | zfcp_dbf_outd(&p, "payload", buffer, buflen, 0, total); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 1016 | if (buflen == total) |
Martin Peschke | b634fff | 2008-03-31 11:15:24 +0200 | [diff] [blame] | 1017 | p += sprintf(p, "\n"); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 1018 | |
Martin Peschke | b634fff | 2008-03-31 11:15:24 +0200 | [diff] [blame] | 1019 | return p - out_buf; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 1020 | } |
| 1021 | |
Heiko Carstens | 2b67fc4 | 2007-02-05 21:16:47 +0100 | [diff] [blame] | 1022 | static struct debug_view zfcp_san_dbf_view = { |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 1023 | "structured", |
| 1024 | NULL, |
| 1025 | &zfcp_dbf_view_header, |
| 1026 | &zfcp_san_dbf_view_format, |
| 1027 | NULL, |
| 1028 | NULL |
| 1029 | }; |
| 1030 | |
Martin Peschke | 92c7a83 | 2008-03-31 11:15:30 +0200 | [diff] [blame] | 1031 | static void zfcp_scsi_dbf_event(const char *tag, const char *tag2, int level, |
| 1032 | struct zfcp_adapter *adapter, |
| 1033 | struct scsi_cmnd *scsi_cmnd, |
| 1034 | struct zfcp_fsf_req *fsf_req, |
| 1035 | unsigned long old_req_id) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 1036 | { |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 1037 | struct zfcp_scsi_dbf_record *rec = &adapter->scsi_dbf_buf; |
| 1038 | struct zfcp_dbf_dump *dump = (struct zfcp_dbf_dump *)rec; |
| 1039 | unsigned long flags; |
| 1040 | struct fcp_rsp_iu *fcp_rsp; |
| 1041 | char *fcp_rsp_info = NULL, *fcp_sns_info = NULL; |
| 1042 | int offset = 0, buflen = 0; |
| 1043 | |
| 1044 | spin_lock_irqsave(&adapter->scsi_dbf_lock, flags); |
| 1045 | do { |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 1046 | memset(rec, 0, sizeof(*rec)); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 1047 | if (offset == 0) { |
| 1048 | strncpy(rec->tag, tag, ZFCP_DBF_TAG_SIZE); |
| 1049 | strncpy(rec->tag2, tag2, ZFCP_DBF_TAG_SIZE); |
Maxim Shchetynin | ed829ad | 2006-02-11 01:42:58 +0100 | [diff] [blame] | 1050 | if (scsi_cmnd != NULL) { |
| 1051 | if (scsi_cmnd->device) { |
| 1052 | rec->scsi_id = scsi_cmnd->device->id; |
| 1053 | rec->scsi_lun = scsi_cmnd->device->lun; |
| 1054 | } |
| 1055 | rec->scsi_result = scsi_cmnd->result; |
| 1056 | rec->scsi_cmnd = (unsigned long)scsi_cmnd; |
| 1057 | rec->scsi_serial = scsi_cmnd->serial_number; |
Boaz Harrosh | 64a87b2 | 2008-04-30 11:19:47 +0300 | [diff] [blame] | 1058 | memcpy(rec->scsi_opcode, scsi_cmnd->cmnd, |
Maxim Shchetynin | ed829ad | 2006-02-11 01:42:58 +0100 | [diff] [blame] | 1059 | min((int)scsi_cmnd->cmd_len, |
| 1060 | ZFCP_DBF_SCSI_OPCODE)); |
| 1061 | rec->scsi_retries = scsi_cmnd->retries; |
| 1062 | rec->scsi_allowed = scsi_cmnd->allowed; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 1063 | } |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 1064 | if (fsf_req != NULL) { |
| 1065 | fcp_rsp = (struct fcp_rsp_iu *) |
| 1066 | &(fsf_req->qtcb->bottom.io.fcp_rsp); |
| 1067 | fcp_rsp_info = |
| 1068 | zfcp_get_fcp_rsp_info_ptr(fcp_rsp); |
| 1069 | fcp_sns_info = |
| 1070 | zfcp_get_fcp_sns_info_ptr(fcp_rsp); |
| 1071 | |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 1072 | rec->rsp_validity = fcp_rsp->validity.value; |
| 1073 | rec->rsp_scsi_status = fcp_rsp->scsi_status; |
| 1074 | rec->rsp_resid = fcp_rsp->fcp_resid; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 1075 | if (fcp_rsp->validity.bits.fcp_rsp_len_valid) |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 1076 | rec->rsp_code = *(fcp_rsp_info + 3); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 1077 | if (fcp_rsp->validity.bits.fcp_sns_len_valid) { |
| 1078 | buflen = min((int)fcp_rsp->fcp_sns_len, |
| 1079 | ZFCP_DBF_SCSI_MAX_FCP_SNS_INFO); |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 1080 | rec->sns_info_len = buflen; |
| 1081 | memcpy(rec->sns_info, fcp_sns_info, |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 1082 | min(buflen, |
| 1083 | ZFCP_DBF_SCSI_FCP_SNS_INFO)); |
| 1084 | offset += min(buflen, |
| 1085 | ZFCP_DBF_SCSI_FCP_SNS_INFO); |
| 1086 | } |
| 1087 | |
| 1088 | rec->fsf_reqid = (unsigned long)fsf_req; |
| 1089 | rec->fsf_seqno = fsf_req->seq_no; |
| 1090 | rec->fsf_issued = fsf_req->issued; |
| 1091 | } |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 1092 | rec->old_fsf_reqid = old_req_id; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 1093 | } else { |
| 1094 | strncpy(dump->tag, "dump", ZFCP_DBF_TAG_SIZE); |
| 1095 | dump->total_size = buflen; |
| 1096 | dump->offset = offset; |
| 1097 | dump->size = min(buflen - offset, |
| 1098 | (int)sizeof(struct |
| 1099 | zfcp_scsi_dbf_record) - |
| 1100 | (int)sizeof(struct zfcp_dbf_dump)); |
| 1101 | memcpy(dump->data, fcp_sns_info + offset, dump->size); |
| 1102 | offset += dump->size; |
| 1103 | } |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 1104 | debug_event(adapter->scsi_dbf, level, rec, sizeof(*rec)); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 1105 | } while (offset < buflen); |
| 1106 | spin_unlock_irqrestore(&adapter->scsi_dbf_lock, flags); |
| 1107 | } |
| 1108 | |
Martin Peschke | bfab163 | 2008-03-31 11:15:31 +0200 | [diff] [blame] | 1109 | /** |
| 1110 | * zfcp_scsi_dbf_event_result - trace event for SCSI command completion |
| 1111 | * @tag: tag indicating success or failure of SCSI command |
| 1112 | * @level: trace level applicable for this event |
| 1113 | * @adapter: adapter that has been used to issue the SCSI command |
| 1114 | * @scsi_cmnd: SCSI command pointer |
| 1115 | * @fsf_req: request used to issue SCSI command (might be NULL) |
| 1116 | */ |
Martin Peschke | 92c7a83 | 2008-03-31 11:15:30 +0200 | [diff] [blame] | 1117 | void zfcp_scsi_dbf_event_result(const char *tag, int level, |
| 1118 | struct zfcp_adapter *adapter, |
| 1119 | struct scsi_cmnd *scsi_cmnd, |
| 1120 | struct zfcp_fsf_req *fsf_req) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 1121 | { |
Martin Peschke | 92c7a83 | 2008-03-31 11:15:30 +0200 | [diff] [blame] | 1122 | zfcp_scsi_dbf_event("rslt", tag, level, adapter, scsi_cmnd, fsf_req, 0); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 1123 | } |
| 1124 | |
Martin Peschke | bfab163 | 2008-03-31 11:15:31 +0200 | [diff] [blame] | 1125 | /** |
| 1126 | * zfcp_scsi_dbf_event_abort - trace event for SCSI command abort |
| 1127 | * @tag: tag indicating success or failure of abort operation |
| 1128 | * @adapter: adapter thas has been used to issue SCSI command to be aborted |
| 1129 | * @scsi_cmnd: SCSI command to be aborted |
| 1130 | * @new_fsf_req: request containing abort (might be NULL) |
| 1131 | * @old_req_id: identifier of request containg SCSI command to be aborted |
| 1132 | */ |
Martin Peschke | 92c7a83 | 2008-03-31 11:15:30 +0200 | [diff] [blame] | 1133 | void zfcp_scsi_dbf_event_abort(const char *tag, struct zfcp_adapter *adapter, |
| 1134 | struct scsi_cmnd *scsi_cmnd, |
| 1135 | struct zfcp_fsf_req *new_fsf_req, |
| 1136 | unsigned long old_req_id) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 1137 | { |
Martin Peschke | 92c7a83 | 2008-03-31 11:15:30 +0200 | [diff] [blame] | 1138 | zfcp_scsi_dbf_event("abrt", tag, 1, adapter, scsi_cmnd, new_fsf_req, |
| 1139 | old_req_id); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 1140 | } |
| 1141 | |
Martin Peschke | bfab163 | 2008-03-31 11:15:31 +0200 | [diff] [blame] | 1142 | /** |
| 1143 | * zfcp_scsi_dbf_event_devreset - trace event for Logical Unit or Target Reset |
| 1144 | * @tag: tag indicating success or failure of reset operation |
| 1145 | * @flag: indicates type of reset (Target Reset, Logical Unit Reset) |
| 1146 | * @unit: unit that needs reset |
| 1147 | * @scsi_cmnd: SCSI command which caused this error recovery |
| 1148 | */ |
Martin Peschke | 92c7a83 | 2008-03-31 11:15:30 +0200 | [diff] [blame] | 1149 | void zfcp_scsi_dbf_event_devreset(const char *tag, u8 flag, |
| 1150 | struct zfcp_unit *unit, |
| 1151 | struct scsi_cmnd *scsi_cmnd) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 1152 | { |
Martin Peschke | 92c7a83 | 2008-03-31 11:15:30 +0200 | [diff] [blame] | 1153 | zfcp_scsi_dbf_event(flag == FCP_TARGET_RESET ? "trst" : "lrst", tag, 1, |
| 1154 | unit->port->adapter, scsi_cmnd, NULL, 0); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 1155 | } |
| 1156 | |
Martin Peschke | 92c7a83 | 2008-03-31 11:15:30 +0200 | [diff] [blame] | 1157 | static int zfcp_scsi_dbf_view_format(debug_info_t *id, struct debug_view *view, |
| 1158 | char *out_buf, const char *in_buf) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 1159 | { |
Martin Peschke | b634fff | 2008-03-31 11:15:24 +0200 | [diff] [blame] | 1160 | struct zfcp_scsi_dbf_record *r = (struct zfcp_scsi_dbf_record *)in_buf; |
Martin Peschke | 8fc5af1 | 2008-03-31 11:15:23 +0200 | [diff] [blame] | 1161 | struct timespec t; |
Martin Peschke | b634fff | 2008-03-31 11:15:24 +0200 | [diff] [blame] | 1162 | char *p = out_buf; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 1163 | |
Martin Peschke | b634fff | 2008-03-31 11:15:24 +0200 | [diff] [blame] | 1164 | if (strncmp(r->tag, "dump", ZFCP_DBF_TAG_SIZE) == 0) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 1165 | return 0; |
| 1166 | |
Martin Peschke | a9c8577 | 2008-03-31 11:15:27 +0200 | [diff] [blame] | 1167 | zfcp_dbf_tag(&p, "tag", r->tag); |
| 1168 | zfcp_dbf_tag(&p, "tag2", r->tag2); |
Martin Peschke | b634fff | 2008-03-31 11:15:24 +0200 | [diff] [blame] | 1169 | zfcp_dbf_out(&p, "scsi_id", "0x%08x", r->scsi_id); |
| 1170 | zfcp_dbf_out(&p, "scsi_lun", "0x%08x", r->scsi_lun); |
| 1171 | zfcp_dbf_out(&p, "scsi_result", "0x%08x", r->scsi_result); |
| 1172 | zfcp_dbf_out(&p, "scsi_cmnd", "0x%0Lx", r->scsi_cmnd); |
| 1173 | zfcp_dbf_out(&p, "scsi_serial", "0x%016Lx", r->scsi_serial); |
Martin Peschke | df29f4a | 2008-03-31 11:15:26 +0200 | [diff] [blame] | 1174 | zfcp_dbf_outd(&p, "scsi_opcode", r->scsi_opcode, ZFCP_DBF_SCSI_OPCODE, |
| 1175 | 0, ZFCP_DBF_SCSI_OPCODE); |
Martin Peschke | b634fff | 2008-03-31 11:15:24 +0200 | [diff] [blame] | 1176 | zfcp_dbf_out(&p, "scsi_retries", "0x%02x", r->scsi_retries); |
| 1177 | zfcp_dbf_out(&p, "scsi_allowed", "0x%02x", r->scsi_allowed); |
| 1178 | if (strncmp(r->tag, "abrt", ZFCP_DBF_TAG_SIZE) == 0) |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 1179 | zfcp_dbf_out(&p, "old_fsf_reqid", "0x%0Lx", r->old_fsf_reqid); |
Martin Peschke | b634fff | 2008-03-31 11:15:24 +0200 | [diff] [blame] | 1180 | zfcp_dbf_out(&p, "fsf_reqid", "0x%0Lx", r->fsf_reqid); |
| 1181 | zfcp_dbf_out(&p, "fsf_seqno", "0x%08x", r->fsf_seqno); |
| 1182 | zfcp_dbf_timestamp(r->fsf_issued, &t); |
| 1183 | zfcp_dbf_out(&p, "fsf_issued", "%011lu:%06lu", t.tv_sec, t.tv_nsec); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 1184 | |
Martin Peschke | b634fff | 2008-03-31 11:15:24 +0200 | [diff] [blame] | 1185 | if (strncmp(r->tag, "rslt", ZFCP_DBF_TAG_SIZE) == 0) { |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 1186 | zfcp_dbf_out(&p, "fcp_rsp_validity", "0x%02x", r->rsp_validity); |
| 1187 | zfcp_dbf_out(&p, "fcp_rsp_scsi_status", "0x%02x", |
| 1188 | r->rsp_scsi_status); |
| 1189 | zfcp_dbf_out(&p, "fcp_rsp_resid", "0x%08x", r->rsp_resid); |
| 1190 | zfcp_dbf_out(&p, "fcp_rsp_code", "0x%08x", r->rsp_code); |
| 1191 | zfcp_dbf_out(&p, "fcp_sns_info_len", "0x%08x", r->sns_info_len); |
| 1192 | zfcp_dbf_outd(&p, "fcp_sns_info", r->sns_info, |
| 1193 | min((int)r->sns_info_len, |
Martin Peschke | df29f4a | 2008-03-31 11:15:26 +0200 | [diff] [blame] | 1194 | ZFCP_DBF_SCSI_FCP_SNS_INFO), 0, |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 1195 | r->sns_info_len); |
Martin Peschke | b634fff | 2008-03-31 11:15:24 +0200 | [diff] [blame] | 1196 | } |
| 1197 | p += sprintf(p, "\n"); |
| 1198 | return p - out_buf; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 1199 | } |
| 1200 | |
Heiko Carstens | 2b67fc4 | 2007-02-05 21:16:47 +0100 | [diff] [blame] | 1201 | static struct debug_view zfcp_scsi_dbf_view = { |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 1202 | "structured", |
| 1203 | NULL, |
| 1204 | &zfcp_dbf_view_header, |
| 1205 | &zfcp_scsi_dbf_view_format, |
| 1206 | NULL, |
| 1207 | NULL |
| 1208 | }; |
| 1209 | |
| 1210 | /** |
| 1211 | * zfcp_adapter_debug_register - registers debug feature for an adapter |
| 1212 | * @adapter: pointer to adapter for which debug features should be registered |
| 1213 | * return: -ENOMEM on error, 0 otherwise |
| 1214 | */ |
| 1215 | int zfcp_adapter_debug_register(struct zfcp_adapter *adapter) |
| 1216 | { |
| 1217 | char dbf_name[DEBUG_MAX_NAME_LEN]; |
| 1218 | |
| 1219 | /* debug feature area which records recovery activity */ |
Martin Peschke | d79a83d | 2008-03-27 14:22:00 +0100 | [diff] [blame] | 1220 | sprintf(dbf_name, "zfcp_%s_rec", zfcp_get_busid_by_adapter(adapter)); |
| 1221 | adapter->rec_dbf = debug_register(dbf_name, dbfsize, 1, |
| 1222 | sizeof(struct zfcp_rec_dbf_record)); |
| 1223 | if (!adapter->rec_dbf) |
| 1224 | goto failed; |
| 1225 | debug_register_view(adapter->rec_dbf, &debug_hex_ascii_view); |
| 1226 | debug_register_view(adapter->rec_dbf, &zfcp_rec_dbf_view); |
| 1227 | debug_set_level(adapter->rec_dbf, 3); |
| 1228 | |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 1229 | /* debug feature area which records HBA (FSF and QDIO) conditions */ |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 1230 | sprintf(dbf_name, "zfcp_%s_hba", zfcp_get_busid_by_adapter(adapter)); |
| 1231 | adapter->hba_dbf = debug_register(dbf_name, dbfsize, 1, |
| 1232 | sizeof(struct zfcp_hba_dbf_record)); |
| 1233 | if (!adapter->hba_dbf) |
| 1234 | goto failed; |
| 1235 | debug_register_view(adapter->hba_dbf, &debug_hex_ascii_view); |
| 1236 | debug_register_view(adapter->hba_dbf, &zfcp_hba_dbf_view); |
| 1237 | debug_set_level(adapter->hba_dbf, 3); |
| 1238 | |
| 1239 | /* debug feature area which records SAN command failures and recovery */ |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 1240 | sprintf(dbf_name, "zfcp_%s_san", zfcp_get_busid_by_adapter(adapter)); |
| 1241 | adapter->san_dbf = debug_register(dbf_name, dbfsize, 1, |
| 1242 | sizeof(struct zfcp_san_dbf_record)); |
| 1243 | if (!adapter->san_dbf) |
| 1244 | goto failed; |
| 1245 | debug_register_view(adapter->san_dbf, &debug_hex_ascii_view); |
| 1246 | debug_register_view(adapter->san_dbf, &zfcp_san_dbf_view); |
| 1247 | debug_set_level(adapter->san_dbf, 6); |
| 1248 | |
| 1249 | /* debug feature area which records SCSI command failures and recovery */ |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 1250 | sprintf(dbf_name, "zfcp_%s_scsi", zfcp_get_busid_by_adapter(adapter)); |
| 1251 | adapter->scsi_dbf = debug_register(dbf_name, dbfsize, 1, |
| 1252 | sizeof(struct zfcp_scsi_dbf_record)); |
| 1253 | if (!adapter->scsi_dbf) |
| 1254 | goto failed; |
| 1255 | debug_register_view(adapter->scsi_dbf, &debug_hex_ascii_view); |
| 1256 | debug_register_view(adapter->scsi_dbf, &zfcp_scsi_dbf_view); |
| 1257 | debug_set_level(adapter->scsi_dbf, 3); |
| 1258 | |
| 1259 | return 0; |
| 1260 | |
| 1261 | failed: |
| 1262 | zfcp_adapter_debug_unregister(adapter); |
| 1263 | |
| 1264 | return -ENOMEM; |
| 1265 | } |
| 1266 | |
| 1267 | /** |
| 1268 | * zfcp_adapter_debug_unregister - unregisters debug feature for an adapter |
| 1269 | * @adapter: pointer to adapter for which debug features should be unregistered |
| 1270 | */ |
| 1271 | void zfcp_adapter_debug_unregister(struct zfcp_adapter *adapter) |
| 1272 | { |
| 1273 | debug_unregister(adapter->scsi_dbf); |
| 1274 | debug_unregister(adapter->san_dbf); |
| 1275 | debug_unregister(adapter->hba_dbf); |
Martin Peschke | d79a83d | 2008-03-27 14:22:00 +0100 | [diff] [blame] | 1276 | debug_unregister(adapter->rec_dbf); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 1277 | adapter->scsi_dbf = NULL; |
| 1278 | adapter->san_dbf = NULL; |
| 1279 | adapter->hba_dbf = NULL; |
Martin Peschke | d79a83d | 2008-03-27 14:22:00 +0100 | [diff] [blame] | 1280 | adapter->rec_dbf = NULL; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 1281 | } |
| 1282 | |
| 1283 | #undef ZFCP_LOG_AREA |