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