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