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