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