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 | d46f384 | 2009-08-18 15:43:07 +0200 | [diff] [blame] | 6 | * Copyright IBM Corporation 2002, 2009 |
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> |
Christof Schmitt | d46f384 | 2009-08-18 15:43:07 +0200 | [diff] [blame] | 14 | #include "zfcp_dbf.h" |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 15 | #include "zfcp_ext.h" |
Christof Schmitt | bd0072e | 2009-11-24 16:54:11 +0100 | [diff] [blame] | 16 | #include "zfcp_fc.h" |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 17 | |
| 18 | static u32 dbfsize = 4; |
| 19 | |
| 20 | module_param(dbfsize, uint, 0400); |
| 21 | MODULE_PARM_DESC(dbfsize, |
| 22 | "number of pages for each debug feature area (default 4)"); |
| 23 | |
Martin Peschke | c15450e | 2008-03-27 14:21:55 +0100 | [diff] [blame] | 24 | static void zfcp_dbf_hexdump(debug_info_t *dbf, void *to, int to_len, |
| 25 | int level, char *from, int from_len) |
| 26 | { |
| 27 | int offset; |
| 28 | struct zfcp_dbf_dump *dump = to; |
| 29 | int room = to_len - sizeof(*dump); |
| 30 | |
| 31 | for (offset = 0; offset < from_len; offset += dump->size) { |
| 32 | memset(to, 0, to_len); |
| 33 | strncpy(dump->tag, "dump", ZFCP_DBF_TAG_SIZE); |
| 34 | dump->total_size = from_len; |
| 35 | dump->offset = offset; |
| 36 | dump->size = min(from_len - offset, room); |
| 37 | memcpy(dump->data, from + offset, dump->size); |
Christof Schmitt | d94ce6c | 2008-11-04 16:35:12 +0100 | [diff] [blame] | 38 | debug_event(dbf, level, dump, dump->size + sizeof(*dump)); |
Martin Peschke | c15450e | 2008-03-27 14:21:55 +0100 | [diff] [blame] | 39 | } |
| 40 | } |
| 41 | |
Martin Peschke | a9c8577 | 2008-03-31 11:15:27 +0200 | [diff] [blame] | 42 | 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] | 43 | { |
Martin Peschke | a9c8577 | 2008-03-31 11:15:27 +0200 | [diff] [blame] | 44 | int i; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 45 | |
Martin Peschke | a9c8577 | 2008-03-31 11:15:27 +0200 | [diff] [blame] | 46 | *p += sprintf(*p, "%-24s", label); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 47 | for (i = 0; i < ZFCP_DBF_TAG_SIZE; i++) |
Martin Peschke | a9c8577 | 2008-03-31 11:15:27 +0200 | [diff] [blame] | 48 | *p += sprintf(*p, "%c", tag[i]); |
| 49 | *p += sprintf(*p, "\n"); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 50 | } |
| 51 | |
Martin Peschke | 10223c6 | 2008-03-27 14:21:59 +0100 | [diff] [blame] | 52 | static void zfcp_dbf_outs(char **buf, const char *s1, const char *s2) |
| 53 | { |
| 54 | *buf += sprintf(*buf, "%-24s%s\n", s1, s2); |
| 55 | } |
| 56 | |
| 57 | static void zfcp_dbf_out(char **buf, const char *s, const char *format, ...) |
| 58 | { |
| 59 | va_list arg; |
| 60 | |
| 61 | *buf += sprintf(*buf, "%-24s", s); |
| 62 | va_start(arg, format); |
| 63 | *buf += vsprintf(*buf, format, arg); |
| 64 | va_end(arg); |
| 65 | *buf += sprintf(*buf, "\n"); |
| 66 | } |
| 67 | |
Martin Peschke | df29f4a | 2008-03-31 11:15:26 +0200 | [diff] [blame] | 68 | static void zfcp_dbf_outd(char **p, const char *label, char *buffer, |
| 69 | int buflen, int offset, int total_size) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 70 | { |
Martin Peschke | df29f4a | 2008-03-31 11:15:26 +0200 | [diff] [blame] | 71 | if (!offset) |
| 72 | *p += sprintf(*p, "%-24s ", label); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 73 | while (buflen--) { |
| 74 | if (offset > 0) { |
| 75 | if ((offset % 32) == 0) |
Martin Peschke | df29f4a | 2008-03-31 11:15:26 +0200 | [diff] [blame] | 76 | *p += sprintf(*p, "\n%-24c ", ' '); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 77 | else if ((offset % 4) == 0) |
Martin Peschke | df29f4a | 2008-03-31 11:15:26 +0200 | [diff] [blame] | 78 | *p += sprintf(*p, " "); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 79 | } |
Martin Peschke | df29f4a | 2008-03-31 11:15:26 +0200 | [diff] [blame] | 80 | *p += sprintf(*p, "%02x", *buffer++); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 81 | if (++offset == total_size) { |
Martin Peschke | df29f4a | 2008-03-31 11:15:26 +0200 | [diff] [blame] | 82 | *p += sprintf(*p, "\n"); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 83 | break; |
| 84 | } |
| 85 | } |
Martin Peschke | df29f4a | 2008-03-31 11:15:26 +0200 | [diff] [blame] | 86 | if (!total_size) |
| 87 | *p += sprintf(*p, "\n"); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 88 | } |
| 89 | |
Martin Peschke | 92c7a83 | 2008-03-31 11:15:30 +0200 | [diff] [blame] | 90 | static int zfcp_dbf_view_header(debug_info_t *id, struct debug_view *view, |
| 91 | int area, debug_entry_t *entry, char *out_buf) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 92 | { |
| 93 | struct zfcp_dbf_dump *dump = (struct zfcp_dbf_dump *)DEBUG_DATA(entry); |
Martin Peschke | 8fc5af1 | 2008-03-31 11:15:23 +0200 | [diff] [blame] | 94 | struct timespec t; |
Martin Peschke | b634fff | 2008-03-31 11:15:24 +0200 | [diff] [blame] | 95 | char *p = out_buf; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 96 | |
| 97 | if (strncmp(dump->tag, "dump", ZFCP_DBF_TAG_SIZE) != 0) { |
Christof Schmitt | b592e89 | 2009-08-18 15:43:31 +0200 | [diff] [blame] | 98 | stck_to_timespec(entry->id.stck, &t); |
Martin Peschke | b634fff | 2008-03-31 11:15:24 +0200 | [diff] [blame] | 99 | zfcp_dbf_out(&p, "timestamp", "%011lu:%06lu", |
| 100 | t.tv_sec, t.tv_nsec); |
| 101 | zfcp_dbf_out(&p, "cpu", "%02i", entry->id.fields.cpuid); |
| 102 | } else { |
Christof Schmitt | d94ce6c | 2008-11-04 16:35:12 +0100 | [diff] [blame] | 103 | zfcp_dbf_outd(&p, "", dump->data, dump->size, dump->offset, |
Martin Peschke | df29f4a | 2008-03-31 11:15:26 +0200 | [diff] [blame] | 104 | dump->total_size); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 105 | if ((dump->offset + dump->size) == dump->total_size) |
Martin Peschke | b634fff | 2008-03-31 11:15:24 +0200 | [diff] [blame] | 106 | p += sprintf(p, "\n"); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 107 | } |
Martin Peschke | b634fff | 2008-03-31 11:15:24 +0200 | [diff] [blame] | 108 | return p - out_buf; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 109 | } |
| 110 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 111 | void _zfcp_dbf_hba_fsf_response(const char *tag2, int level, |
| 112 | struct zfcp_fsf_req *fsf_req, |
| 113 | struct zfcp_dbf *dbf) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 114 | { |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 115 | struct fsf_qtcb *qtcb = fsf_req->qtcb; |
| 116 | union fsf_prot_status_qual *prot_status_qual = |
Martin Peschke | 92c7a83 | 2008-03-31 11:15:30 +0200 | [diff] [blame] | 117 | &qtcb->prefix.prot_status_qual; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 118 | union fsf_status_qual *fsf_status_qual = &qtcb->header.fsf_status_qual; |
| 119 | struct scsi_cmnd *scsi_cmnd; |
| 120 | struct zfcp_port *port; |
| 121 | struct zfcp_unit *unit; |
| 122 | struct zfcp_send_els *send_els; |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 123 | struct zfcp_dbf_hba_record *rec = &dbf->hba_buf; |
| 124 | struct zfcp_dbf_hba_record_response *response = &rec->u.response; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 125 | unsigned long flags; |
| 126 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 127 | spin_lock_irqsave(&dbf->hba_lock, flags); |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 128 | memset(rec, 0, sizeof(*rec)); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 129 | strncpy(rec->tag, "resp", ZFCP_DBF_TAG_SIZE); |
Christof Schmitt | 2e261af | 2009-08-18 15:43:09 +0200 | [diff] [blame] | 130 | strncpy(rec->tag2, tag2, ZFCP_DBF_TAG_SIZE); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 131 | |
| 132 | response->fsf_command = fsf_req->fsf_command; |
Christof Schmitt | f0216ae | 2009-05-15 13:18:14 +0200 | [diff] [blame] | 133 | response->fsf_reqid = fsf_req->req_id; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 134 | response->fsf_seqno = fsf_req->seq_no; |
| 135 | response->fsf_issued = fsf_req->issued; |
| 136 | response->fsf_prot_status = qtcb->prefix.prot_status; |
| 137 | response->fsf_status = qtcb->header.fsf_status; |
| 138 | memcpy(response->fsf_prot_status_qual, |
| 139 | prot_status_qual, FSF_PROT_STATUS_QUAL_SIZE); |
| 140 | memcpy(response->fsf_status_qual, |
| 141 | fsf_status_qual, FSF_STATUS_QUALIFIER_SIZE); |
| 142 | response->fsf_req_status = fsf_req->status; |
Swen Schillig | 42428f7 | 2009-08-18 15:43:18 +0200 | [diff] [blame] | 143 | response->sbal_first = fsf_req->queue_req.sbal_first; |
| 144 | response->sbal_last = fsf_req->queue_req.sbal_last; |
| 145 | response->sbal_response = fsf_req->queue_req.sbal_response; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 146 | response->pool = fsf_req->pool != NULL; |
| 147 | response->erp_action = (unsigned long)fsf_req->erp_action; |
| 148 | |
| 149 | switch (fsf_req->fsf_command) { |
| 150 | case FSF_QTCB_FCP_CMND: |
| 151 | if (fsf_req->status & ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT) |
| 152 | break; |
| 153 | scsi_cmnd = (struct scsi_cmnd *)fsf_req->data; |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 154 | if (scsi_cmnd) { |
| 155 | response->u.fcp.cmnd = (unsigned long)scsi_cmnd; |
| 156 | response->u.fcp.serial = scsi_cmnd->serial_number; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 157 | } |
| 158 | break; |
| 159 | |
| 160 | case FSF_QTCB_OPEN_PORT_WITH_DID: |
| 161 | case FSF_QTCB_CLOSE_PORT: |
| 162 | case FSF_QTCB_CLOSE_PHYSICAL_PORT: |
| 163 | port = (struct zfcp_port *)fsf_req->data; |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 164 | response->u.port.wwpn = port->wwpn; |
| 165 | response->u.port.d_id = port->d_id; |
| 166 | response->u.port.port_handle = qtcb->header.port_handle; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 167 | break; |
| 168 | |
| 169 | case FSF_QTCB_OPEN_LUN: |
| 170 | case FSF_QTCB_CLOSE_LUN: |
| 171 | unit = (struct zfcp_unit *)fsf_req->data; |
| 172 | port = unit->port; |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 173 | response->u.unit.wwpn = port->wwpn; |
| 174 | response->u.unit.fcp_lun = unit->fcp_lun; |
| 175 | response->u.unit.port_handle = qtcb->header.port_handle; |
| 176 | response->u.unit.lun_handle = qtcb->header.lun_handle; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 177 | break; |
| 178 | |
| 179 | case FSF_QTCB_SEND_ELS: |
| 180 | send_els = (struct zfcp_send_els *)fsf_req->data; |
Christof Schmitt | 800c0ca | 2009-11-24 16:54:12 +0100 | [diff] [blame] | 181 | response->u.els.d_id = ntoh24(qtcb->bottom.support.d_id); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 182 | break; |
| 183 | |
| 184 | case FSF_QTCB_ABORT_FCP_CMND: |
| 185 | case FSF_QTCB_SEND_GENERIC: |
| 186 | case FSF_QTCB_EXCHANGE_CONFIG_DATA: |
| 187 | case FSF_QTCB_EXCHANGE_PORT_DATA: |
| 188 | case FSF_QTCB_DOWNLOAD_CONTROL_FILE: |
| 189 | case FSF_QTCB_UPLOAD_CONTROL_FILE: |
| 190 | break; |
| 191 | } |
| 192 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 193 | debug_event(dbf->hba, level, rec, sizeof(*rec)); |
Martin Peschke | b75db73 | 2008-03-27 14:21:58 +0100 | [diff] [blame] | 194 | |
| 195 | /* have fcp channel microcode fixed to use as little as possible */ |
| 196 | if (fsf_req->fsf_command != FSF_QTCB_FCP_CMND) { |
| 197 | /* adjust length skipping trailing zeros */ |
| 198 | char *buf = (char *)qtcb + qtcb->header.log_start; |
| 199 | int len = qtcb->header.log_length; |
| 200 | for (; len && !buf[len - 1]; len--); |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 201 | zfcp_dbf_hexdump(dbf->hba, rec, sizeof(*rec), level, buf, |
Christof Schmitt | d46f384 | 2009-08-18 15:43:07 +0200 | [diff] [blame] | 202 | len); |
Martin Peschke | b75db73 | 2008-03-27 14:21:58 +0100 | [diff] [blame] | 203 | } |
| 204 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 205 | spin_unlock_irqrestore(&dbf->hba_lock, flags); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 206 | } |
| 207 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 208 | void _zfcp_dbf_hba_fsf_unsol(const char *tag, int level, struct zfcp_dbf *dbf, |
| 209 | struct fsf_status_read_buffer *status_buffer) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 210 | { |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 211 | struct zfcp_dbf_hba_record *rec = &dbf->hba_buf; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 212 | unsigned long flags; |
| 213 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 214 | spin_lock_irqsave(&dbf->hba_lock, flags); |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 215 | memset(rec, 0, sizeof(*rec)); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 216 | strncpy(rec->tag, "stat", ZFCP_DBF_TAG_SIZE); |
| 217 | strncpy(rec->tag2, tag, ZFCP_DBF_TAG_SIZE); |
| 218 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 219 | rec->u.status.failed = atomic_read(&dbf->adapter->stat_miss); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 220 | if (status_buffer != NULL) { |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 221 | rec->u.status.status_type = status_buffer->status_type; |
| 222 | rec->u.status.status_subtype = status_buffer->status_subtype; |
| 223 | memcpy(&rec->u.status.queue_designator, |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 224 | &status_buffer->queue_designator, |
| 225 | sizeof(struct fsf_queue_designator)); |
| 226 | |
| 227 | switch (status_buffer->status_type) { |
| 228 | case FSF_STATUS_READ_SENSE_DATA_AVAIL: |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 229 | rec->u.status.payload_size = |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 230 | ZFCP_DBF_UNSOL_PAYLOAD_SENSE_DATA_AVAIL; |
| 231 | break; |
| 232 | |
| 233 | case FSF_STATUS_READ_BIT_ERROR_THRESHOLD: |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 234 | rec->u.status.payload_size = |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 235 | ZFCP_DBF_UNSOL_PAYLOAD_BIT_ERROR_THRESHOLD; |
| 236 | break; |
| 237 | |
| 238 | case FSF_STATUS_READ_LINK_DOWN: |
Maxim Shchetynin | aef4a98 | 2005-09-13 21:51:16 +0200 | [diff] [blame] | 239 | switch (status_buffer->status_subtype) { |
| 240 | case FSF_STATUS_READ_SUB_NO_PHYSICAL_LINK: |
| 241 | case FSF_STATUS_READ_SUB_FDISC_FAILED: |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 242 | rec->u.status.payload_size = |
Maxim Shchetynin | aef4a98 | 2005-09-13 21:51:16 +0200 | [diff] [blame] | 243 | sizeof(struct fsf_link_down_info); |
| 244 | } |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 245 | break; |
| 246 | |
Maxim Shchetynin | aef4a98 | 2005-09-13 21:51:16 +0200 | [diff] [blame] | 247 | case FSF_STATUS_READ_FEATURE_UPDATE_ALERT: |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 248 | rec->u.status.payload_size = |
Maxim Shchetynin | aef4a98 | 2005-09-13 21:51:16 +0200 | [diff] [blame] | 249 | ZFCP_DBF_UNSOL_PAYLOAD_FEATURE_UPDATE_ALERT; |
| 250 | break; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 251 | } |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 252 | memcpy(&rec->u.status.payload, |
| 253 | &status_buffer->payload, rec->u.status.payload_size); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 254 | } |
| 255 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 256 | debug_event(dbf->hba, level, rec, sizeof(*rec)); |
| 257 | spin_unlock_irqrestore(&dbf->hba_lock, flags); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 258 | } |
| 259 | |
Martin Peschke | bfab163 | 2008-03-31 11:15:31 +0200 | [diff] [blame] | 260 | /** |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 261 | * zfcp_dbf_hba_qdio - trace event for QDIO related failure |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 262 | * @qdio: qdio structure affected by this QDIO related event |
Martin Peschke | bfab163 | 2008-03-31 11:15:31 +0200 | [diff] [blame] | 263 | * @qdio_error: as passed by qdio module |
Martin Peschke | bfab163 | 2008-03-31 11:15:31 +0200 | [diff] [blame] | 264 | * @sbal_index: first buffer with error condition, as passed by qdio module |
| 265 | * @sbal_count: number of buffers affected, as passed by qdio module |
| 266 | */ |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 267 | void zfcp_dbf_hba_qdio(struct zfcp_dbf *dbf, unsigned int qdio_error, |
| 268 | int sbal_index, int sbal_count) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 269 | { |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 270 | struct zfcp_dbf_hba_record *r = &dbf->hba_buf; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 271 | unsigned long flags; |
| 272 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 273 | spin_lock_irqsave(&dbf->hba_lock, flags); |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 274 | memset(r, 0, sizeof(*r)); |
| 275 | strncpy(r->tag, "qdio", ZFCP_DBF_TAG_SIZE); |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 276 | r->u.qdio.qdio_error = qdio_error; |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 277 | r->u.qdio.sbal_index = sbal_index; |
| 278 | r->u.qdio.sbal_count = sbal_count; |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 279 | debug_event(dbf->hba, 0, r, sizeof(*r)); |
| 280 | spin_unlock_irqrestore(&dbf->hba_lock, flags); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 281 | } |
| 282 | |
Swen Schillig | 5706938 | 2008-10-01 12:42:21 +0200 | [diff] [blame] | 283 | /** |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 284 | * zfcp_dbf_hba_berr - trace event for bit error threshold |
| 285 | * @dbf: dbf structure affected by this QDIO related event |
Swen Schillig | 5706938 | 2008-10-01 12:42:21 +0200 | [diff] [blame] | 286 | * @req: fsf request |
| 287 | */ |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 288 | void zfcp_dbf_hba_berr(struct zfcp_dbf *dbf, struct zfcp_fsf_req *req) |
Swen Schillig | 5706938 | 2008-10-01 12:42:21 +0200 | [diff] [blame] | 289 | { |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 290 | struct zfcp_dbf_hba_record *r = &dbf->hba_buf; |
Swen Schillig | 5706938 | 2008-10-01 12:42:21 +0200 | [diff] [blame] | 291 | struct fsf_status_read_buffer *sr_buf = req->data; |
| 292 | struct fsf_bit_error_payload *err = &sr_buf->payload.bit_error; |
| 293 | unsigned long flags; |
| 294 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 295 | spin_lock_irqsave(&dbf->hba_lock, flags); |
Swen Schillig | 5706938 | 2008-10-01 12:42:21 +0200 | [diff] [blame] | 296 | memset(r, 0, sizeof(*r)); |
| 297 | strncpy(r->tag, "berr", ZFCP_DBF_TAG_SIZE); |
| 298 | memcpy(&r->u.berr, err, sizeof(struct fsf_bit_error_payload)); |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 299 | debug_event(dbf->hba, 0, r, sizeof(*r)); |
| 300 | spin_unlock_irqrestore(&dbf->hba_lock, flags); |
Swen Schillig | 5706938 | 2008-10-01 12:42:21 +0200 | [diff] [blame] | 301 | } |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 302 | static void zfcp_dbf_hba_view_response(char **p, |
| 303 | struct zfcp_dbf_hba_record_response *r) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 304 | { |
Martin Peschke | 8fc5af1 | 2008-03-31 11:15:23 +0200 | [diff] [blame] | 305 | struct timespec t; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 306 | |
Martin Peschke | a9c8577 | 2008-03-31 11:15:27 +0200 | [diff] [blame] | 307 | zfcp_dbf_out(p, "fsf_command", "0x%08x", r->fsf_command); |
| 308 | zfcp_dbf_out(p, "fsf_reqid", "0x%0Lx", r->fsf_reqid); |
| 309 | zfcp_dbf_out(p, "fsf_seqno", "0x%08x", r->fsf_seqno); |
Christof Schmitt | b592e89 | 2009-08-18 15:43:31 +0200 | [diff] [blame] | 310 | stck_to_timespec(r->fsf_issued, &t); |
Martin Peschke | a9c8577 | 2008-03-31 11:15:27 +0200 | [diff] [blame] | 311 | zfcp_dbf_out(p, "fsf_issued", "%011lu:%06lu", t.tv_sec, t.tv_nsec); |
| 312 | zfcp_dbf_out(p, "fsf_prot_status", "0x%08x", r->fsf_prot_status); |
| 313 | zfcp_dbf_out(p, "fsf_status", "0x%08x", r->fsf_status); |
| 314 | 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] | 315 | FSF_PROT_STATUS_QUAL_SIZE, 0, FSF_PROT_STATUS_QUAL_SIZE); |
Martin Peschke | a9c8577 | 2008-03-31 11:15:27 +0200 | [diff] [blame] | 316 | zfcp_dbf_outd(p, "fsf_status_qual", r->fsf_status_qual, |
Martin Peschke | df29f4a | 2008-03-31 11:15:26 +0200 | [diff] [blame] | 317 | FSF_STATUS_QUALIFIER_SIZE, 0, FSF_STATUS_QUALIFIER_SIZE); |
Martin Peschke | a9c8577 | 2008-03-31 11:15:27 +0200 | [diff] [blame] | 318 | zfcp_dbf_out(p, "fsf_req_status", "0x%08x", r->fsf_req_status); |
| 319 | zfcp_dbf_out(p, "sbal_first", "0x%02x", r->sbal_first); |
Martin Peschke | e891bff | 2008-05-19 12:17:43 +0200 | [diff] [blame] | 320 | zfcp_dbf_out(p, "sbal_last", "0x%02x", r->sbal_last); |
Martin Peschke | c3baa9a2 | 2008-05-19 12:17:44 +0200 | [diff] [blame] | 321 | zfcp_dbf_out(p, "sbal_response", "0x%02x", r->sbal_response); |
Martin Peschke | a9c8577 | 2008-03-31 11:15:27 +0200 | [diff] [blame] | 322 | zfcp_dbf_out(p, "pool", "0x%02x", r->pool); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 323 | |
Martin Peschke | b634fff | 2008-03-31 11:15:24 +0200 | [diff] [blame] | 324 | switch (r->fsf_command) { |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 325 | case FSF_QTCB_FCP_CMND: |
Martin Peschke | b634fff | 2008-03-31 11:15:24 +0200 | [diff] [blame] | 326 | if (r->fsf_req_status & ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 327 | break; |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 328 | zfcp_dbf_out(p, "scsi_cmnd", "0x%0Lx", r->u.fcp.cmnd); |
| 329 | zfcp_dbf_out(p, "scsi_serial", "0x%016Lx", r->u.fcp.serial); |
Christof Schmitt | d94ce6c | 2008-11-04 16:35:12 +0100 | [diff] [blame] | 330 | p += sprintf(*p, "\n"); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 331 | break; |
| 332 | |
| 333 | case FSF_QTCB_OPEN_PORT_WITH_DID: |
| 334 | case FSF_QTCB_CLOSE_PORT: |
| 335 | case FSF_QTCB_CLOSE_PHYSICAL_PORT: |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 336 | zfcp_dbf_out(p, "wwpn", "0x%016Lx", r->u.port.wwpn); |
| 337 | zfcp_dbf_out(p, "d_id", "0x%06x", r->u.port.d_id); |
| 338 | 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] | 339 | break; |
| 340 | |
| 341 | case FSF_QTCB_OPEN_LUN: |
| 342 | case FSF_QTCB_CLOSE_LUN: |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 343 | zfcp_dbf_out(p, "wwpn", "0x%016Lx", r->u.unit.wwpn); |
| 344 | zfcp_dbf_out(p, "fcp_lun", "0x%016Lx", r->u.unit.fcp_lun); |
| 345 | zfcp_dbf_out(p, "port_handle", "0x%08x", r->u.unit.port_handle); |
| 346 | 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] | 347 | break; |
| 348 | |
| 349 | case FSF_QTCB_SEND_ELS: |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 350 | zfcp_dbf_out(p, "d_id", "0x%06x", r->u.els.d_id); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 351 | break; |
| 352 | |
| 353 | case FSF_QTCB_ABORT_FCP_CMND: |
| 354 | case FSF_QTCB_SEND_GENERIC: |
| 355 | case FSF_QTCB_EXCHANGE_CONFIG_DATA: |
| 356 | case FSF_QTCB_EXCHANGE_PORT_DATA: |
| 357 | case FSF_QTCB_DOWNLOAD_CONTROL_FILE: |
| 358 | case FSF_QTCB_UPLOAD_CONTROL_FILE: |
| 359 | break; |
| 360 | } |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 361 | } |
| 362 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 363 | static void zfcp_dbf_hba_view_status(char **p, |
| 364 | struct zfcp_dbf_hba_record_status *r) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 365 | { |
Martin Peschke | a9c8577 | 2008-03-31 11:15:27 +0200 | [diff] [blame] | 366 | zfcp_dbf_out(p, "failed", "0x%02x", r->failed); |
| 367 | zfcp_dbf_out(p, "status_type", "0x%08x", r->status_type); |
| 368 | zfcp_dbf_out(p, "status_subtype", "0x%08x", r->status_subtype); |
| 369 | zfcp_dbf_outd(p, "queue_designator", (char *)&r->queue_designator, |
Martin Peschke | df29f4a | 2008-03-31 11:15:26 +0200 | [diff] [blame] | 370 | sizeof(struct fsf_queue_designator), 0, |
| 371 | sizeof(struct fsf_queue_designator)); |
Martin Peschke | a9c8577 | 2008-03-31 11:15:27 +0200 | [diff] [blame] | 372 | zfcp_dbf_outd(p, "payload", (char *)&r->payload, r->payload_size, 0, |
Martin Peschke | df29f4a | 2008-03-31 11:15:26 +0200 | [diff] [blame] | 373 | r->payload_size); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 374 | } |
| 375 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 376 | static void zfcp_dbf_hba_view_qdio(char **p, struct zfcp_dbf_hba_record_qdio *r) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 377 | { |
Martin Peschke | a9c8577 | 2008-03-31 11:15:27 +0200 | [diff] [blame] | 378 | zfcp_dbf_out(p, "qdio_error", "0x%08x", r->qdio_error); |
Martin Peschke | a9c8577 | 2008-03-31 11:15:27 +0200 | [diff] [blame] | 379 | zfcp_dbf_out(p, "sbal_index", "0x%02x", r->sbal_index); |
| 380 | zfcp_dbf_out(p, "sbal_count", "0x%02x", r->sbal_count); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 381 | } |
| 382 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 383 | static void zfcp_dbf_hba_view_berr(char **p, struct fsf_bit_error_payload *r) |
Swen Schillig | 5706938 | 2008-10-01 12:42:21 +0200 | [diff] [blame] | 384 | { |
| 385 | zfcp_dbf_out(p, "link_failures", "%d", r->link_failure_error_count); |
| 386 | zfcp_dbf_out(p, "loss_of_sync_err", "%d", r->loss_of_sync_error_count); |
| 387 | zfcp_dbf_out(p, "loss_of_sig_err", "%d", r->loss_of_signal_error_count); |
| 388 | zfcp_dbf_out(p, "prim_seq_err", "%d", |
| 389 | r->primitive_sequence_error_count); |
| 390 | zfcp_dbf_out(p, "inval_trans_word_err", "%d", |
| 391 | r->invalid_transmission_word_error_count); |
| 392 | zfcp_dbf_out(p, "CRC_errors", "%d", r->crc_error_count); |
| 393 | zfcp_dbf_out(p, "prim_seq_event_to", "%d", |
| 394 | r->primitive_sequence_event_timeout_count); |
| 395 | zfcp_dbf_out(p, "elast_buf_overrun_err", "%d", |
| 396 | r->elastic_buffer_overrun_error_count); |
| 397 | zfcp_dbf_out(p, "adv_rec_buf2buf_cred", "%d", |
| 398 | r->advertised_receive_b2b_credit); |
| 399 | zfcp_dbf_out(p, "curr_rec_buf2buf_cred", "%d", |
| 400 | r->current_receive_b2b_credit); |
| 401 | zfcp_dbf_out(p, "adv_trans_buf2buf_cred", "%d", |
| 402 | r->advertised_transmit_b2b_credit); |
| 403 | zfcp_dbf_out(p, "curr_trans_buf2buf_cred", "%d", |
| 404 | r->current_transmit_b2b_credit); |
| 405 | } |
| 406 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 407 | static int zfcp_dbf_hba_view_format(debug_info_t *id, struct debug_view *view, |
Martin Peschke | a9c8577 | 2008-03-31 11:15:27 +0200 | [diff] [blame] | 408 | char *out_buf, const char *in_buf) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 409 | { |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 410 | struct zfcp_dbf_hba_record *r = (struct zfcp_dbf_hba_record *)in_buf; |
Martin Peschke | a9c8577 | 2008-03-31 11:15:27 +0200 | [diff] [blame] | 411 | char *p = out_buf; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 412 | |
Martin Peschke | a9c8577 | 2008-03-31 11:15:27 +0200 | [diff] [blame] | 413 | if (strncmp(r->tag, "dump", ZFCP_DBF_TAG_SIZE) == 0) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 414 | return 0; |
| 415 | |
Martin Peschke | a9c8577 | 2008-03-31 11:15:27 +0200 | [diff] [blame] | 416 | zfcp_dbf_tag(&p, "tag", r->tag); |
| 417 | if (isalpha(r->tag2[0])) |
| 418 | zfcp_dbf_tag(&p, "tag2", r->tag2); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 419 | |
Martin Peschke | a9c8577 | 2008-03-31 11:15:27 +0200 | [diff] [blame] | 420 | if (strncmp(r->tag, "resp", ZFCP_DBF_TAG_SIZE) == 0) |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 421 | zfcp_dbf_hba_view_response(&p, &r->u.response); |
Martin Peschke | a9c8577 | 2008-03-31 11:15:27 +0200 | [diff] [blame] | 422 | else if (strncmp(r->tag, "stat", ZFCP_DBF_TAG_SIZE) == 0) |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 423 | zfcp_dbf_hba_view_status(&p, &r->u.status); |
Martin Peschke | a9c8577 | 2008-03-31 11:15:27 +0200 | [diff] [blame] | 424 | else if (strncmp(r->tag, "qdio", ZFCP_DBF_TAG_SIZE) == 0) |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 425 | zfcp_dbf_hba_view_qdio(&p, &r->u.qdio); |
Swen Schillig | 5706938 | 2008-10-01 12:42:21 +0200 | [diff] [blame] | 426 | else if (strncmp(r->tag, "berr", ZFCP_DBF_TAG_SIZE) == 0) |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 427 | zfcp_dbf_hba_view_berr(&p, &r->u.berr); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 428 | |
Christof Schmitt | d94ce6c | 2008-11-04 16:35:12 +0100 | [diff] [blame] | 429 | if (strncmp(r->tag, "resp", ZFCP_DBF_TAG_SIZE) != 0) |
| 430 | p += sprintf(p, "\n"); |
Martin Peschke | a9c8577 | 2008-03-31 11:15:27 +0200 | [diff] [blame] | 431 | return p - out_buf; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 432 | } |
| 433 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 434 | static struct debug_view zfcp_dbf_hba_view = { |
| 435 | .name = "structured", |
| 436 | .header_proc = zfcp_dbf_view_header, |
| 437 | .format_proc = zfcp_dbf_hba_view_format, |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 438 | }; |
| 439 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 440 | static const char *zfcp_dbf_rec_tags[] = { |
Martin Peschke | 348447e | 2008-03-27 14:22:01 +0100 | [diff] [blame] | 441 | [ZFCP_REC_DBF_ID_THREAD] = "thread", |
Martin Peschke | 698ec016 | 2008-03-27 14:22:02 +0100 | [diff] [blame] | 442 | [ZFCP_REC_DBF_ID_TARGET] = "target", |
Martin Peschke | 9467a9b | 2008-03-27 14:22:03 +0100 | [diff] [blame] | 443 | [ZFCP_REC_DBF_ID_TRIGGER] = "trigger", |
Martin Peschke | 6f4f365 | 2008-03-27 14:22:04 +0100 | [diff] [blame] | 444 | [ZFCP_REC_DBF_ID_ACTION] = "action", |
Martin Peschke | d79a83d | 2008-03-27 14:22:00 +0100 | [diff] [blame] | 445 | }; |
| 446 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 447 | static int zfcp_dbf_rec_view_format(debug_info_t *id, struct debug_view *view, |
Martin Peschke | d79a83d | 2008-03-27 14:22:00 +0100 | [diff] [blame] | 448 | char *buf, const char *_rec) |
| 449 | { |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 450 | struct zfcp_dbf_rec_record *r = (struct zfcp_dbf_rec_record *)_rec; |
Martin Peschke | d79a83d | 2008-03-27 14:22:00 +0100 | [diff] [blame] | 451 | char *p = buf; |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 452 | char hint[ZFCP_DBF_ID_SIZE + 1]; |
Martin Peschke | d79a83d | 2008-03-27 14:22:00 +0100 | [diff] [blame] | 453 | |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 454 | memcpy(hint, r->id2, ZFCP_DBF_ID_SIZE); |
| 455 | hint[ZFCP_DBF_ID_SIZE] = 0; |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 456 | zfcp_dbf_outs(&p, "tag", zfcp_dbf_rec_tags[r->id]); |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 457 | zfcp_dbf_outs(&p, "hint", hint); |
Martin Peschke | d79a83d | 2008-03-27 14:22:00 +0100 | [diff] [blame] | 458 | switch (r->id) { |
Martin Peschke | 348447e | 2008-03-27 14:22:01 +0100 | [diff] [blame] | 459 | case ZFCP_REC_DBF_ID_THREAD: |
Martin Peschke | 348447e | 2008-03-27 14:22:01 +0100 | [diff] [blame] | 460 | zfcp_dbf_out(&p, "total", "%d", r->u.thread.total); |
| 461 | zfcp_dbf_out(&p, "ready", "%d", r->u.thread.ready); |
| 462 | zfcp_dbf_out(&p, "running", "%d", r->u.thread.running); |
| 463 | break; |
Martin Peschke | 698ec016 | 2008-03-27 14:22:02 +0100 | [diff] [blame] | 464 | case ZFCP_REC_DBF_ID_TARGET: |
| 465 | zfcp_dbf_out(&p, "reference", "0x%016Lx", r->u.target.ref); |
| 466 | zfcp_dbf_out(&p, "status", "0x%08x", r->u.target.status); |
| 467 | zfcp_dbf_out(&p, "erp_count", "%d", r->u.target.erp_count); |
| 468 | zfcp_dbf_out(&p, "d_id", "0x%06x", r->u.target.d_id); |
| 469 | zfcp_dbf_out(&p, "wwpn", "0x%016Lx", r->u.target.wwpn); |
| 470 | zfcp_dbf_out(&p, "fcp_lun", "0x%016Lx", r->u.target.fcp_lun); |
| 471 | break; |
Martin Peschke | 9467a9b | 2008-03-27 14:22:03 +0100 | [diff] [blame] | 472 | case ZFCP_REC_DBF_ID_TRIGGER: |
| 473 | zfcp_dbf_out(&p, "reference", "0x%016Lx", r->u.trigger.ref); |
| 474 | zfcp_dbf_out(&p, "erp_action", "0x%016Lx", r->u.trigger.action); |
| 475 | zfcp_dbf_out(&p, "requested", "%d", r->u.trigger.want); |
| 476 | zfcp_dbf_out(&p, "executed", "%d", r->u.trigger.need); |
| 477 | zfcp_dbf_out(&p, "wwpn", "0x%016Lx", r->u.trigger.wwpn); |
| 478 | zfcp_dbf_out(&p, "fcp_lun", "0x%016Lx", r->u.trigger.fcp_lun); |
| 479 | zfcp_dbf_out(&p, "adapter_status", "0x%08x", r->u.trigger.as); |
| 480 | zfcp_dbf_out(&p, "port_status", "0x%08x", r->u.trigger.ps); |
| 481 | zfcp_dbf_out(&p, "unit_status", "0x%08x", r->u.trigger.us); |
| 482 | break; |
Martin Peschke | 6f4f365 | 2008-03-27 14:22:04 +0100 | [diff] [blame] | 483 | case ZFCP_REC_DBF_ID_ACTION: |
| 484 | zfcp_dbf_out(&p, "erp_action", "0x%016Lx", r->u.action.action); |
| 485 | zfcp_dbf_out(&p, "fsf_req", "0x%016Lx", r->u.action.fsf_req); |
| 486 | zfcp_dbf_out(&p, "status", "0x%08Lx", r->u.action.status); |
| 487 | zfcp_dbf_out(&p, "step", "0x%08Lx", r->u.action.step); |
| 488 | break; |
Martin Peschke | d79a83d | 2008-03-27 14:22:00 +0100 | [diff] [blame] | 489 | } |
Martin Peschke | b634fff | 2008-03-31 11:15:24 +0200 | [diff] [blame] | 490 | p += sprintf(p, "\n"); |
| 491 | return p - buf; |
Martin Peschke | d79a83d | 2008-03-27 14:22:00 +0100 | [diff] [blame] | 492 | } |
| 493 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 494 | static struct debug_view zfcp_dbf_rec_view = { |
| 495 | .name = "structured", |
| 496 | .header_proc = zfcp_dbf_view_header, |
| 497 | .format_proc = zfcp_dbf_rec_view_format, |
Martin Peschke | d79a83d | 2008-03-27 14:22:00 +0100 | [diff] [blame] | 498 | }; |
| 499 | |
Martin Peschke | 348447e | 2008-03-27 14:22:01 +0100 | [diff] [blame] | 500 | /** |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 501 | * zfcp_dbf_rec_thread - trace event related to recovery thread operation |
Martin Peschke | 348447e | 2008-03-27 14:22:01 +0100 | [diff] [blame] | 502 | * @id2: identifier for event |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 503 | * @dbf: reference to dbf structure |
Christof Schmitt | aa0fec6 | 2008-05-19 12:17:47 +0200 | [diff] [blame] | 504 | * This function assumes that the caller is holding erp_lock. |
Martin Peschke | 348447e | 2008-03-27 14:22:01 +0100 | [diff] [blame] | 505 | */ |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 506 | void zfcp_dbf_rec_thread(char *id2, struct zfcp_dbf *dbf) |
Martin Peschke | 348447e | 2008-03-27 14:22:01 +0100 | [diff] [blame] | 507 | { |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 508 | struct zfcp_adapter *adapter = dbf->adapter; |
| 509 | struct zfcp_dbf_rec_record *r = &dbf->rec_buf; |
Martin Peschke | 348447e | 2008-03-27 14:22:01 +0100 | [diff] [blame] | 510 | unsigned long flags = 0; |
| 511 | struct list_head *entry; |
| 512 | unsigned ready = 0, running = 0, total; |
| 513 | |
Martin Peschke | 348447e | 2008-03-27 14:22:01 +0100 | [diff] [blame] | 514 | list_for_each(entry, &adapter->erp_ready_head) |
| 515 | ready++; |
| 516 | list_for_each(entry, &adapter->erp_running_head) |
| 517 | running++; |
| 518 | total = adapter->erp_total_count; |
Martin Peschke | 348447e | 2008-03-27 14:22:01 +0100 | [diff] [blame] | 519 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 520 | spin_lock_irqsave(&dbf->rec_lock, flags); |
Martin Peschke | 348447e | 2008-03-27 14:22:01 +0100 | [diff] [blame] | 521 | memset(r, 0, sizeof(*r)); |
| 522 | r->id = ZFCP_REC_DBF_ID_THREAD; |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 523 | memcpy(r->id2, id2, ZFCP_DBF_ID_SIZE); |
Martin Peschke | 348447e | 2008-03-27 14:22:01 +0100 | [diff] [blame] | 524 | r->u.thread.total = total; |
| 525 | r->u.thread.ready = ready; |
| 526 | r->u.thread.running = running; |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 527 | debug_event(dbf->rec, 6, r, sizeof(*r)); |
| 528 | spin_unlock_irqrestore(&dbf->rec_lock, flags); |
Martin Peschke | 348447e | 2008-03-27 14:22:01 +0100 | [diff] [blame] | 529 | } |
| 530 | |
Christof Schmitt | aa0fec6 | 2008-05-19 12:17:47 +0200 | [diff] [blame] | 531 | /** |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 532 | * zfcp_dbf_rec_thread - trace event related to recovery thread operation |
Christof Schmitt | aa0fec6 | 2008-05-19 12:17:47 +0200 | [diff] [blame] | 533 | * @id2: identifier for event |
| 534 | * @adapter: adapter |
| 535 | * This function assumes that the caller does not hold erp_lock. |
| 536 | */ |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 537 | void zfcp_dbf_rec_thread_lock(char *id2, struct zfcp_dbf *dbf) |
Christof Schmitt | aa0fec6 | 2008-05-19 12:17:47 +0200 | [diff] [blame] | 538 | { |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 539 | struct zfcp_adapter *adapter = dbf->adapter; |
Christof Schmitt | aa0fec6 | 2008-05-19 12:17:47 +0200 | [diff] [blame] | 540 | unsigned long flags; |
| 541 | |
| 542 | read_lock_irqsave(&adapter->erp_lock, flags); |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 543 | zfcp_dbf_rec_thread(id2, dbf); |
Christof Schmitt | aa0fec6 | 2008-05-19 12:17:47 +0200 | [diff] [blame] | 544 | read_unlock_irqrestore(&adapter->erp_lock, flags); |
| 545 | } |
| 546 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 547 | static void zfcp_dbf_rec_target(char *id2, void *ref, struct zfcp_dbf *dbf, |
| 548 | atomic_t *status, atomic_t *erp_count, u64 wwpn, |
| 549 | u32 d_id, u64 fcp_lun) |
Martin Peschke | 698ec016 | 2008-03-27 14:22:02 +0100 | [diff] [blame] | 550 | { |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 551 | struct zfcp_dbf_rec_record *r = &dbf->rec_buf; |
Martin Peschke | 698ec016 | 2008-03-27 14:22:02 +0100 | [diff] [blame] | 552 | unsigned long flags; |
| 553 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 554 | spin_lock_irqsave(&dbf->rec_lock, flags); |
Martin Peschke | 698ec016 | 2008-03-27 14:22:02 +0100 | [diff] [blame] | 555 | memset(r, 0, sizeof(*r)); |
| 556 | r->id = ZFCP_REC_DBF_ID_TARGET; |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 557 | memcpy(r->id2, id2, ZFCP_DBF_ID_SIZE); |
Martin Peschke | 1f6f712 | 2008-04-18 12:51:55 +0200 | [diff] [blame] | 558 | r->u.target.ref = (unsigned long)ref; |
Martin Peschke | 698ec016 | 2008-03-27 14:22:02 +0100 | [diff] [blame] | 559 | r->u.target.status = atomic_read(status); |
| 560 | r->u.target.wwpn = wwpn; |
| 561 | r->u.target.d_id = d_id; |
| 562 | r->u.target.fcp_lun = fcp_lun; |
| 563 | r->u.target.erp_count = atomic_read(erp_count); |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 564 | debug_event(dbf->rec, 3, r, sizeof(*r)); |
| 565 | spin_unlock_irqrestore(&dbf->rec_lock, flags); |
Martin Peschke | 698ec016 | 2008-03-27 14:22:02 +0100 | [diff] [blame] | 566 | } |
| 567 | |
| 568 | /** |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 569 | * zfcp_dbf_rec_adapter - trace event for adapter state change |
Martin Peschke | 698ec016 | 2008-03-27 14:22:02 +0100 | [diff] [blame] | 570 | * @id: identifier for trigger of state change |
| 571 | * @ref: additional reference (e.g. request) |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 572 | * @dbf: reference to dbf structure |
Martin Peschke | 698ec016 | 2008-03-27 14:22:02 +0100 | [diff] [blame] | 573 | */ |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 574 | void zfcp_dbf_rec_adapter(char *id, void *ref, struct zfcp_dbf *dbf) |
Martin Peschke | 698ec016 | 2008-03-27 14:22:02 +0100 | [diff] [blame] | 575 | { |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 576 | struct zfcp_adapter *adapter = dbf->adapter; |
| 577 | |
| 578 | zfcp_dbf_rec_target(id, ref, dbf, &adapter->status, |
Martin Peschke | 698ec016 | 2008-03-27 14:22:02 +0100 | [diff] [blame] | 579 | &adapter->erp_counter, 0, 0, 0); |
| 580 | } |
| 581 | |
| 582 | /** |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 583 | * zfcp_dbf_rec_port - trace event for port state change |
Martin Peschke | 698ec016 | 2008-03-27 14:22:02 +0100 | [diff] [blame] | 584 | * @id: identifier for trigger of state change |
| 585 | * @ref: additional reference (e.g. request) |
| 586 | * @port: port |
| 587 | */ |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 588 | void zfcp_dbf_rec_port(char *id, void *ref, struct zfcp_port *port) |
Martin Peschke | 698ec016 | 2008-03-27 14:22:02 +0100 | [diff] [blame] | 589 | { |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 590 | struct zfcp_dbf *dbf = port->adapter->dbf; |
Martin Peschke | 698ec016 | 2008-03-27 14:22:02 +0100 | [diff] [blame] | 591 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 592 | zfcp_dbf_rec_target(id, ref, dbf, &port->status, |
Martin Peschke | 698ec016 | 2008-03-27 14:22:02 +0100 | [diff] [blame] | 593 | &port->erp_counter, port->wwpn, port->d_id, |
| 594 | 0); |
| 595 | } |
| 596 | |
| 597 | /** |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 598 | * zfcp_dbf_rec_unit - trace event for unit state change |
Martin Peschke | 698ec016 | 2008-03-27 14:22:02 +0100 | [diff] [blame] | 599 | * @id: identifier for trigger of state change |
| 600 | * @ref: additional reference (e.g. request) |
| 601 | * @unit: unit |
| 602 | */ |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 603 | void zfcp_dbf_rec_unit(char *id, void *ref, struct zfcp_unit *unit) |
Martin Peschke | 698ec016 | 2008-03-27 14:22:02 +0100 | [diff] [blame] | 604 | { |
| 605 | struct zfcp_port *port = unit->port; |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 606 | struct zfcp_dbf *dbf = port->adapter->dbf; |
Martin Peschke | 698ec016 | 2008-03-27 14:22:02 +0100 | [diff] [blame] | 607 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 608 | zfcp_dbf_rec_target(id, ref, dbf, &unit->status, |
Martin Peschke | 698ec016 | 2008-03-27 14:22:02 +0100 | [diff] [blame] | 609 | &unit->erp_counter, port->wwpn, port->d_id, |
| 610 | unit->fcp_lun); |
| 611 | } |
| 612 | |
Martin Peschke | 9467a9b | 2008-03-27 14:22:03 +0100 | [diff] [blame] | 613 | /** |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 614 | * zfcp_dbf_rec_trigger - trace event for triggered error recovery |
Martin Peschke | 9467a9b | 2008-03-27 14:22:03 +0100 | [diff] [blame] | 615 | * @id2: identifier for error recovery trigger |
| 616 | * @ref: additional reference (e.g. request) |
| 617 | * @want: originally requested error recovery action |
| 618 | * @need: error recovery action actually initiated |
| 619 | * @action: address of error recovery action struct |
| 620 | * @adapter: adapter |
| 621 | * @port: port |
| 622 | * @unit: unit |
| 623 | */ |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 624 | void zfcp_dbf_rec_trigger(char *id2, void *ref, u8 want, u8 need, void *action, |
| 625 | struct zfcp_adapter *adapter, struct zfcp_port *port, |
| 626 | struct zfcp_unit *unit) |
Martin Peschke | 9467a9b | 2008-03-27 14:22:03 +0100 | [diff] [blame] | 627 | { |
Christof Schmitt | d46f384 | 2009-08-18 15:43:07 +0200 | [diff] [blame] | 628 | struct zfcp_dbf *dbf = adapter->dbf; |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 629 | struct zfcp_dbf_rec_record *r = &dbf->rec_buf; |
Martin Peschke | 9467a9b | 2008-03-27 14:22:03 +0100 | [diff] [blame] | 630 | unsigned long flags; |
| 631 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 632 | spin_lock_irqsave(&dbf->rec_lock, flags); |
Martin Peschke | 9467a9b | 2008-03-27 14:22:03 +0100 | [diff] [blame] | 633 | memset(r, 0, sizeof(*r)); |
| 634 | r->id = ZFCP_REC_DBF_ID_TRIGGER; |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 635 | memcpy(r->id2, id2, ZFCP_DBF_ID_SIZE); |
Martin Peschke | 1f6f712 | 2008-04-18 12:51:55 +0200 | [diff] [blame] | 636 | r->u.trigger.ref = (unsigned long)ref; |
Martin Peschke | 9467a9b | 2008-03-27 14:22:03 +0100 | [diff] [blame] | 637 | r->u.trigger.want = want; |
| 638 | r->u.trigger.need = need; |
Martin Peschke | 1f6f712 | 2008-04-18 12:51:55 +0200 | [diff] [blame] | 639 | r->u.trigger.action = (unsigned long)action; |
Martin Peschke | 9467a9b | 2008-03-27 14:22:03 +0100 | [diff] [blame] | 640 | r->u.trigger.as = atomic_read(&adapter->status); |
| 641 | if (port) { |
| 642 | r->u.trigger.ps = atomic_read(&port->status); |
| 643 | r->u.trigger.wwpn = port->wwpn; |
| 644 | } |
| 645 | if (unit) { |
| 646 | r->u.trigger.us = atomic_read(&unit->status); |
| 647 | r->u.trigger.fcp_lun = unit->fcp_lun; |
| 648 | } |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 649 | debug_event(dbf->rec, action ? 1 : 4, r, sizeof(*r)); |
| 650 | spin_unlock_irqrestore(&dbf->rec_lock, flags); |
Martin Peschke | 9467a9b | 2008-03-27 14:22:03 +0100 | [diff] [blame] | 651 | } |
| 652 | |
Martin Peschke | 6f4f365 | 2008-03-27 14:22:04 +0100 | [diff] [blame] | 653 | /** |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 654 | * zfcp_dbf_rec_action - trace event showing progress of recovery action |
Martin Peschke | 6f4f365 | 2008-03-27 14:22:04 +0100 | [diff] [blame] | 655 | * @id2: identifier |
| 656 | * @erp_action: error recovery action struct pointer |
| 657 | */ |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 658 | void zfcp_dbf_rec_action(char *id2, struct zfcp_erp_action *erp_action) |
Martin Peschke | 6f4f365 | 2008-03-27 14:22:04 +0100 | [diff] [blame] | 659 | { |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 660 | struct zfcp_dbf *dbf = erp_action->adapter->dbf; |
| 661 | struct zfcp_dbf_rec_record *r = &dbf->rec_buf; |
Martin Peschke | 6f4f365 | 2008-03-27 14:22:04 +0100 | [diff] [blame] | 662 | unsigned long flags; |
| 663 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 664 | spin_lock_irqsave(&dbf->rec_lock, flags); |
Martin Peschke | 6f4f365 | 2008-03-27 14:22:04 +0100 | [diff] [blame] | 665 | memset(r, 0, sizeof(*r)); |
| 666 | r->id = ZFCP_REC_DBF_ID_ACTION; |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 667 | memcpy(r->id2, id2, ZFCP_DBF_ID_SIZE); |
Martin Peschke | 1f6f712 | 2008-04-18 12:51:55 +0200 | [diff] [blame] | 668 | r->u.action.action = (unsigned long)erp_action; |
Martin Peschke | 6f4f365 | 2008-03-27 14:22:04 +0100 | [diff] [blame] | 669 | r->u.action.status = erp_action->status; |
| 670 | r->u.action.step = erp_action->step; |
Martin Peschke | 1f6f712 | 2008-04-18 12:51:55 +0200 | [diff] [blame] | 671 | r->u.action.fsf_req = (unsigned long)erp_action->fsf_req; |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 672 | debug_event(dbf->rec, 5, r, sizeof(*r)); |
| 673 | spin_unlock_irqrestore(&dbf->rec_lock, flags); |
Martin Peschke | 6f4f365 | 2008-03-27 14:22:04 +0100 | [diff] [blame] | 674 | } |
| 675 | |
Martin Peschke | bfab163 | 2008-03-31 11:15:31 +0200 | [diff] [blame] | 676 | /** |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 677 | * zfcp_dbf_san_ct_request - trace event for issued CT request |
Martin Peschke | bfab163 | 2008-03-31 11:15:31 +0200 | [diff] [blame] | 678 | * @fsf_req: request containing issued CT data |
Christof Schmitt | 7c7dc19 | 2009-11-24 16:54:13 +0100 | [diff] [blame] | 679 | * @d_id: destination id where ct request is sent to |
Martin Peschke | bfab163 | 2008-03-31 11:15:31 +0200 | [diff] [blame] | 680 | */ |
Christof Schmitt | 7c7dc19 | 2009-11-24 16:54:13 +0100 | [diff] [blame] | 681 | void zfcp_dbf_san_ct_request(struct zfcp_fsf_req *fsf_req, u32 d_id) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 682 | { |
Christof Schmitt | 7c7dc19 | 2009-11-24 16:54:13 +0100 | [diff] [blame] | 683 | struct zfcp_fsf_ct_els *ct = (struct zfcp_fsf_ct_els *)fsf_req->data; |
| 684 | struct zfcp_adapter *adapter = fsf_req->adapter; |
Christof Schmitt | d46f384 | 2009-08-18 15:43:07 +0200 | [diff] [blame] | 685 | struct zfcp_dbf *dbf = adapter->dbf; |
Christof Schmitt | dbf5dfe | 2009-11-24 16:54:10 +0100 | [diff] [blame] | 686 | struct fc_ct_hdr *hdr = sg_virt(ct->req); |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 687 | struct zfcp_dbf_san_record *r = &dbf->san_buf; |
| 688 | struct zfcp_dbf_san_record_ct_request *oct = &r->u.ct_req; |
Christof Schmitt | d94ce6c | 2008-11-04 16:35:12 +0100 | [diff] [blame] | 689 | int level = 3; |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 690 | unsigned long flags; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 691 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 692 | spin_lock_irqsave(&dbf->san_lock, flags); |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 693 | memset(r, 0, sizeof(*r)); |
| 694 | strncpy(r->tag, "octc", ZFCP_DBF_TAG_SIZE); |
Christof Schmitt | f0216ae | 2009-05-15 13:18:14 +0200 | [diff] [blame] | 695 | r->fsf_reqid = fsf_req->req_id; |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 696 | r->fsf_seqno = fsf_req->seq_no; |
Christof Schmitt | 7c7dc19 | 2009-11-24 16:54:13 +0100 | [diff] [blame] | 697 | oct->d_id = d_id; |
Christof Schmitt | dbf5dfe | 2009-11-24 16:54:10 +0100 | [diff] [blame] | 698 | oct->cmd_req_code = hdr->ct_cmd; |
| 699 | oct->revision = hdr->ct_rev; |
| 700 | oct->gs_type = hdr->ct_fs_type; |
| 701 | oct->gs_subtype = hdr->ct_fs_subtype; |
| 702 | oct->options = hdr->ct_options; |
| 703 | oct->max_res_size = hdr->ct_mr_size; |
| 704 | oct->len = min((int)ct->req->length - (int)sizeof(struct fc_ct_hdr), |
Christof Schmitt | d94ce6c | 2008-11-04 16:35:12 +0100 | [diff] [blame] | 705 | ZFCP_DBF_SAN_MAX_PAYLOAD); |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 706 | debug_event(dbf->san, level, r, sizeof(*r)); |
| 707 | zfcp_dbf_hexdump(dbf->san, r, sizeof(*r), level, |
Christof Schmitt | dbf5dfe | 2009-11-24 16:54:10 +0100 | [diff] [blame] | 708 | (void *)hdr + sizeof(struct fc_ct_hdr), oct->len); |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 709 | spin_unlock_irqrestore(&dbf->san_lock, flags); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 710 | } |
| 711 | |
Martin Peschke | bfab163 | 2008-03-31 11:15:31 +0200 | [diff] [blame] | 712 | /** |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 713 | * zfcp_dbf_san_ct_response - trace event for completion of CT request |
Martin Peschke | bfab163 | 2008-03-31 11:15:31 +0200 | [diff] [blame] | 714 | * @fsf_req: request containing CT response |
| 715 | */ |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 716 | void zfcp_dbf_san_ct_response(struct zfcp_fsf_req *fsf_req) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 717 | { |
Christof Schmitt | 7c7dc19 | 2009-11-24 16:54:13 +0100 | [diff] [blame] | 718 | struct zfcp_fsf_ct_els *ct = (struct zfcp_fsf_ct_els *)fsf_req->data; |
| 719 | struct zfcp_adapter *adapter = fsf_req->adapter; |
Christof Schmitt | dbf5dfe | 2009-11-24 16:54:10 +0100 | [diff] [blame] | 720 | struct fc_ct_hdr *hdr = sg_virt(ct->resp); |
Christof Schmitt | d46f384 | 2009-08-18 15:43:07 +0200 | [diff] [blame] | 721 | struct zfcp_dbf *dbf = adapter->dbf; |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 722 | struct zfcp_dbf_san_record *r = &dbf->san_buf; |
| 723 | struct zfcp_dbf_san_record_ct_response *rct = &r->u.ct_resp; |
Christof Schmitt | d94ce6c | 2008-11-04 16:35:12 +0100 | [diff] [blame] | 724 | int level = 3; |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 725 | unsigned long flags; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 726 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 727 | spin_lock_irqsave(&dbf->san_lock, flags); |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 728 | memset(r, 0, sizeof(*r)); |
| 729 | strncpy(r->tag, "rctc", ZFCP_DBF_TAG_SIZE); |
Christof Schmitt | f0216ae | 2009-05-15 13:18:14 +0200 | [diff] [blame] | 730 | r->fsf_reqid = fsf_req->req_id; |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 731 | r->fsf_seqno = fsf_req->seq_no; |
Christof Schmitt | dbf5dfe | 2009-11-24 16:54:10 +0100 | [diff] [blame] | 732 | rct->cmd_rsp_code = hdr->ct_cmd; |
| 733 | rct->revision = hdr->ct_rev; |
| 734 | rct->reason_code = hdr->ct_reason; |
| 735 | rct->expl = hdr->ct_explan; |
| 736 | rct->vendor_unique = hdr->ct_vendor; |
| 737 | rct->max_res_size = hdr->ct_mr_size; |
| 738 | rct->len = min((int)ct->resp->length - (int)sizeof(struct fc_ct_hdr), |
Christof Schmitt | d94ce6c | 2008-11-04 16:35:12 +0100 | [diff] [blame] | 739 | ZFCP_DBF_SAN_MAX_PAYLOAD); |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 740 | debug_event(dbf->san, level, r, sizeof(*r)); |
| 741 | zfcp_dbf_hexdump(dbf->san, r, sizeof(*r), level, |
Christof Schmitt | dbf5dfe | 2009-11-24 16:54:10 +0100 | [diff] [blame] | 742 | (void *)hdr + sizeof(struct fc_ct_hdr), rct->len); |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 743 | spin_unlock_irqrestore(&dbf->san_lock, flags); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 744 | } |
| 745 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 746 | static void zfcp_dbf_san_els(const char *tag, int level, |
Christof Schmitt | 7c7dc19 | 2009-11-24 16:54:13 +0100 | [diff] [blame] | 747 | struct zfcp_fsf_req *fsf_req, u32 d_id, |
| 748 | void *buffer, int buflen) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 749 | { |
| 750 | struct zfcp_adapter *adapter = fsf_req->adapter; |
Christof Schmitt | d46f384 | 2009-08-18 15:43:07 +0200 | [diff] [blame] | 751 | struct zfcp_dbf *dbf = adapter->dbf; |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 752 | struct zfcp_dbf_san_record *rec = &dbf->san_buf; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 753 | unsigned long flags; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 754 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 755 | spin_lock_irqsave(&dbf->san_lock, flags); |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 756 | memset(rec, 0, sizeof(*rec)); |
Martin Peschke | 0f65e95 | 2008-03-27 14:21:56 +0100 | [diff] [blame] | 757 | strncpy(rec->tag, tag, ZFCP_DBF_TAG_SIZE); |
Christof Schmitt | f0216ae | 2009-05-15 13:18:14 +0200 | [diff] [blame] | 758 | rec->fsf_reqid = fsf_req->req_id; |
Martin Peschke | 0f65e95 | 2008-03-27 14:21:56 +0100 | [diff] [blame] | 759 | rec->fsf_seqno = fsf_req->seq_no; |
Christof Schmitt | 7c7dc19 | 2009-11-24 16:54:13 +0100 | [diff] [blame] | 760 | rec->u.els.d_id = d_id; |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 761 | debug_event(dbf->san, level, rec, sizeof(*rec)); |
| 762 | zfcp_dbf_hexdump(dbf->san, rec, sizeof(*rec), level, |
Christof Schmitt | d94ce6c | 2008-11-04 16:35:12 +0100 | [diff] [blame] | 763 | buffer, min(buflen, ZFCP_DBF_SAN_MAX_PAYLOAD)); |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 764 | spin_unlock_irqrestore(&dbf->san_lock, flags); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 765 | } |
| 766 | |
Martin Peschke | bfab163 | 2008-03-31 11:15:31 +0200 | [diff] [blame] | 767 | /** |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 768 | * zfcp_dbf_san_els_request - trace event for issued ELS |
Martin Peschke | bfab163 | 2008-03-31 11:15:31 +0200 | [diff] [blame] | 769 | * @fsf_req: request containing issued ELS |
| 770 | */ |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 771 | void zfcp_dbf_san_els_request(struct zfcp_fsf_req *fsf_req) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 772 | { |
Christof Schmitt | 7c7dc19 | 2009-11-24 16:54:13 +0100 | [diff] [blame] | 773 | struct zfcp_fsf_ct_els *els = (struct zfcp_fsf_ct_els *)fsf_req->data; |
| 774 | u32 d_id = ntoh24(fsf_req->qtcb->bottom.support.d_id); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 775 | |
Christof Schmitt | 7c7dc19 | 2009-11-24 16:54:13 +0100 | [diff] [blame] | 776 | zfcp_dbf_san_els("oels", 2, fsf_req, d_id, |
| 777 | sg_virt(els->req), els->req->length); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 778 | } |
| 779 | |
Martin Peschke | bfab163 | 2008-03-31 11:15:31 +0200 | [diff] [blame] | 780 | /** |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 781 | * zfcp_dbf_san_els_response - trace event for completed ELS |
Martin Peschke | bfab163 | 2008-03-31 11:15:31 +0200 | [diff] [blame] | 782 | * @fsf_req: request containing ELS response |
| 783 | */ |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 784 | void zfcp_dbf_san_els_response(struct zfcp_fsf_req *fsf_req) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 785 | { |
Christof Schmitt | 7c7dc19 | 2009-11-24 16:54:13 +0100 | [diff] [blame] | 786 | struct zfcp_fsf_ct_els *els = (struct zfcp_fsf_ct_els *)fsf_req->data; |
| 787 | u32 d_id = ntoh24(fsf_req->qtcb->bottom.support.d_id); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 788 | |
Christof Schmitt | 7c7dc19 | 2009-11-24 16:54:13 +0100 | [diff] [blame] | 789 | zfcp_dbf_san_els("rels", 2, fsf_req, d_id, |
| 790 | sg_virt(els->resp), els->resp->length); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 791 | } |
| 792 | |
Martin Peschke | bfab163 | 2008-03-31 11:15:31 +0200 | [diff] [blame] | 793 | /** |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 794 | * zfcp_dbf_san_incoming_els - trace event for incomig ELS |
Martin Peschke | bfab163 | 2008-03-31 11:15:31 +0200 | [diff] [blame] | 795 | * @fsf_req: request containing unsolicited status buffer with incoming ELS |
| 796 | */ |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 797 | void zfcp_dbf_san_incoming_els(struct zfcp_fsf_req *fsf_req) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 798 | { |
Martin Peschke | 92c7a83 | 2008-03-31 11:15:30 +0200 | [diff] [blame] | 799 | struct fsf_status_read_buffer *buf = |
| 800 | (struct fsf_status_read_buffer *)fsf_req->data; |
| 801 | int length = (int)buf->length - |
| 802 | (int)((void *)&buf->payload - (void *)buf); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 803 | |
Christof Schmitt | 800c0ca | 2009-11-24 16:54:12 +0100 | [diff] [blame] | 804 | zfcp_dbf_san_els("iels", 1, fsf_req, ntoh24(buf->d_id), |
Christof Schmitt | 7c7dc19 | 2009-11-24 16:54:13 +0100 | [diff] [blame] | 805 | (void *)buf->payload.data, length); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 806 | } |
| 807 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 808 | static int zfcp_dbf_san_view_format(debug_info_t *id, struct debug_view *view, |
Martin Peschke | 92c7a83 | 2008-03-31 11:15:30 +0200 | [diff] [blame] | 809 | char *out_buf, const char *in_buf) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 810 | { |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 811 | struct zfcp_dbf_san_record *r = (struct zfcp_dbf_san_record *)in_buf; |
Martin Peschke | b634fff | 2008-03-31 11:15:24 +0200 | [diff] [blame] | 812 | char *p = out_buf; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 813 | |
Martin Peschke | b634fff | 2008-03-31 11:15:24 +0200 | [diff] [blame] | 814 | if (strncmp(r->tag, "dump", ZFCP_DBF_TAG_SIZE) == 0) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 815 | return 0; |
| 816 | |
Martin Peschke | a9c8577 | 2008-03-31 11:15:27 +0200 | [diff] [blame] | 817 | zfcp_dbf_tag(&p, "tag", r->tag); |
Martin Peschke | b634fff | 2008-03-31 11:15:24 +0200 | [diff] [blame] | 818 | zfcp_dbf_out(&p, "fsf_reqid", "0x%0Lx", r->fsf_reqid); |
| 819 | zfcp_dbf_out(&p, "fsf_seqno", "0x%08x", r->fsf_seqno); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 820 | |
Martin Peschke | b634fff | 2008-03-31 11:15:24 +0200 | [diff] [blame] | 821 | if (strncmp(r->tag, "octc", ZFCP_DBF_TAG_SIZE) == 0) { |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 822 | struct zfcp_dbf_san_record_ct_request *ct = &r->u.ct_req; |
Christof Schmitt | 7c7dc19 | 2009-11-24 16:54:13 +0100 | [diff] [blame] | 823 | zfcp_dbf_out(&p, "d_id", "0x%06x", ct->d_id); |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 824 | zfcp_dbf_out(&p, "cmd_req_code", "0x%04x", ct->cmd_req_code); |
| 825 | zfcp_dbf_out(&p, "revision", "0x%02x", ct->revision); |
| 826 | zfcp_dbf_out(&p, "gs_type", "0x%02x", ct->gs_type); |
| 827 | zfcp_dbf_out(&p, "gs_subtype", "0x%02x", ct->gs_subtype); |
| 828 | zfcp_dbf_out(&p, "options", "0x%02x", ct->options); |
| 829 | 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] | 830 | } else if (strncmp(r->tag, "rctc", ZFCP_DBF_TAG_SIZE) == 0) { |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 831 | struct zfcp_dbf_san_record_ct_response *ct = &r->u.ct_resp; |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 832 | zfcp_dbf_out(&p, "cmd_rsp_code", "0x%04x", ct->cmd_rsp_code); |
| 833 | zfcp_dbf_out(&p, "revision", "0x%02x", ct->revision); |
| 834 | zfcp_dbf_out(&p, "reason_code", "0x%02x", ct->reason_code); |
| 835 | zfcp_dbf_out(&p, "reason_code_expl", "0x%02x", ct->expl); |
| 836 | zfcp_dbf_out(&p, "vendor_unique", "0x%02x", ct->vendor_unique); |
Christof Schmitt | 39eb7e9a | 2008-12-19 16:57:01 +0100 | [diff] [blame] | 837 | 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] | 838 | } else if (strncmp(r->tag, "oels", ZFCP_DBF_TAG_SIZE) == 0 || |
| 839 | strncmp(r->tag, "rels", ZFCP_DBF_TAG_SIZE) == 0 || |
| 840 | strncmp(r->tag, "iels", ZFCP_DBF_TAG_SIZE) == 0) { |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 841 | struct zfcp_dbf_san_record_els *els = &r->u.els; |
Christof Schmitt | 7c7dc19 | 2009-11-24 16:54:13 +0100 | [diff] [blame] | 842 | zfcp_dbf_out(&p, "d_id", "0x%06x", els->d_id); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 843 | } |
Martin Peschke | b634fff | 2008-03-31 11:15:24 +0200 | [diff] [blame] | 844 | return p - out_buf; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 845 | } |
| 846 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 847 | static struct debug_view zfcp_dbf_san_view = { |
| 848 | .name = "structured", |
| 849 | .header_proc = zfcp_dbf_view_header, |
| 850 | .format_proc = zfcp_dbf_san_view_format, |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 851 | }; |
| 852 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 853 | void _zfcp_dbf_scsi(const char *tag, const char *tag2, int level, |
| 854 | struct zfcp_dbf *dbf, struct scsi_cmnd *scsi_cmnd, |
| 855 | struct zfcp_fsf_req *fsf_req, unsigned long old_req_id) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 856 | { |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 857 | struct zfcp_dbf_scsi_record *rec = &dbf->scsi_buf; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 858 | struct zfcp_dbf_dump *dump = (struct zfcp_dbf_dump *)rec; |
| 859 | unsigned long flags; |
Christof Schmitt | 4318e08 | 2009-11-24 16:54:08 +0100 | [diff] [blame] | 860 | struct fcp_resp_with_ext *fcp_rsp; |
| 861 | struct fcp_resp_rsp_info *fcp_rsp_info = NULL; |
| 862 | char *fcp_sns_info = NULL; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 863 | int offset = 0, buflen = 0; |
| 864 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 865 | spin_lock_irqsave(&dbf->scsi_lock, flags); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 866 | do { |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 867 | memset(rec, 0, sizeof(*rec)); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 868 | if (offset == 0) { |
| 869 | strncpy(rec->tag, tag, ZFCP_DBF_TAG_SIZE); |
| 870 | strncpy(rec->tag2, tag2, ZFCP_DBF_TAG_SIZE); |
Maxim Shchetynin | ed829ad | 2006-02-11 01:42:58 +0100 | [diff] [blame] | 871 | if (scsi_cmnd != NULL) { |
| 872 | if (scsi_cmnd->device) { |
| 873 | rec->scsi_id = scsi_cmnd->device->id; |
| 874 | rec->scsi_lun = scsi_cmnd->device->lun; |
| 875 | } |
| 876 | rec->scsi_result = scsi_cmnd->result; |
| 877 | rec->scsi_cmnd = (unsigned long)scsi_cmnd; |
| 878 | rec->scsi_serial = scsi_cmnd->serial_number; |
Boaz Harrosh | 64a87b2 | 2008-04-30 11:19:47 +0300 | [diff] [blame] | 879 | memcpy(rec->scsi_opcode, scsi_cmnd->cmnd, |
Maxim Shchetynin | ed829ad | 2006-02-11 01:42:58 +0100 | [diff] [blame] | 880 | min((int)scsi_cmnd->cmd_len, |
| 881 | ZFCP_DBF_SCSI_OPCODE)); |
| 882 | rec->scsi_retries = scsi_cmnd->retries; |
| 883 | rec->scsi_allowed = scsi_cmnd->allowed; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 884 | } |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 885 | if (fsf_req != NULL) { |
Christof Schmitt | 4318e08 | 2009-11-24 16:54:08 +0100 | [diff] [blame] | 886 | fcp_rsp = (struct fcp_resp_with_ext *) |
| 887 | &(fsf_req->qtcb->bottom.io.fcp_rsp); |
| 888 | fcp_rsp_info = (struct fcp_resp_rsp_info *) |
| 889 | &fcp_rsp[1]; |
| 890 | fcp_sns_info = (char *) &fcp_rsp[1]; |
| 891 | if (fcp_rsp->resp.fr_flags & FCP_RSP_LEN_VAL) |
| 892 | fcp_sns_info += fcp_rsp->ext.fr_sns_len; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 893 | |
Christof Schmitt | 4318e08 | 2009-11-24 16:54:08 +0100 | [diff] [blame] | 894 | rec->rsp_validity = fcp_rsp->resp.fr_flags; |
| 895 | rec->rsp_scsi_status = fcp_rsp->resp.fr_status; |
| 896 | rec->rsp_resid = fcp_rsp->ext.fr_resid; |
| 897 | if (fcp_rsp->resp.fr_flags & FCP_RSP_LEN_VAL) |
| 898 | rec->rsp_code = fcp_rsp_info->rsp_code; |
| 899 | if (fcp_rsp->resp.fr_flags & FCP_SNS_LEN_VAL) { |
| 900 | buflen = min(fcp_rsp->ext.fr_sns_len, |
| 901 | (u32)ZFCP_DBF_SCSI_MAX_FCP_SNS_INFO); |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 902 | rec->sns_info_len = buflen; |
| 903 | memcpy(rec->sns_info, fcp_sns_info, |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 904 | min(buflen, |
| 905 | ZFCP_DBF_SCSI_FCP_SNS_INFO)); |
| 906 | offset += min(buflen, |
| 907 | ZFCP_DBF_SCSI_FCP_SNS_INFO); |
| 908 | } |
| 909 | |
Christof Schmitt | f0216ae | 2009-05-15 13:18:14 +0200 | [diff] [blame] | 910 | rec->fsf_reqid = fsf_req->req_id; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 911 | rec->fsf_seqno = fsf_req->seq_no; |
| 912 | rec->fsf_issued = fsf_req->issued; |
| 913 | } |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 914 | rec->old_fsf_reqid = old_req_id; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 915 | } else { |
| 916 | strncpy(dump->tag, "dump", ZFCP_DBF_TAG_SIZE); |
| 917 | dump->total_size = buflen; |
| 918 | dump->offset = offset; |
| 919 | dump->size = min(buflen - offset, |
| 920 | (int)sizeof(struct |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 921 | zfcp_dbf_scsi_record) - |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 922 | (int)sizeof(struct zfcp_dbf_dump)); |
| 923 | memcpy(dump->data, fcp_sns_info + offset, dump->size); |
| 924 | offset += dump->size; |
| 925 | } |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 926 | debug_event(dbf->scsi, level, rec, sizeof(*rec)); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 927 | } while (offset < buflen); |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 928 | spin_unlock_irqrestore(&dbf->scsi_lock, flags); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 929 | } |
| 930 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 931 | static int zfcp_dbf_scsi_view_format(debug_info_t *id, struct debug_view *view, |
Martin Peschke | 92c7a83 | 2008-03-31 11:15:30 +0200 | [diff] [blame] | 932 | char *out_buf, const char *in_buf) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 933 | { |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 934 | struct zfcp_dbf_scsi_record *r = (struct zfcp_dbf_scsi_record *)in_buf; |
Martin Peschke | 8fc5af1 | 2008-03-31 11:15:23 +0200 | [diff] [blame] | 935 | struct timespec t; |
Martin Peschke | b634fff | 2008-03-31 11:15:24 +0200 | [diff] [blame] | 936 | char *p = out_buf; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 937 | |
Martin Peschke | b634fff | 2008-03-31 11:15:24 +0200 | [diff] [blame] | 938 | if (strncmp(r->tag, "dump", ZFCP_DBF_TAG_SIZE) == 0) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 939 | return 0; |
| 940 | |
Martin Peschke | a9c8577 | 2008-03-31 11:15:27 +0200 | [diff] [blame] | 941 | zfcp_dbf_tag(&p, "tag", r->tag); |
| 942 | zfcp_dbf_tag(&p, "tag2", r->tag2); |
Martin Peschke | b634fff | 2008-03-31 11:15:24 +0200 | [diff] [blame] | 943 | zfcp_dbf_out(&p, "scsi_id", "0x%08x", r->scsi_id); |
| 944 | zfcp_dbf_out(&p, "scsi_lun", "0x%08x", r->scsi_lun); |
| 945 | zfcp_dbf_out(&p, "scsi_result", "0x%08x", r->scsi_result); |
| 946 | zfcp_dbf_out(&p, "scsi_cmnd", "0x%0Lx", r->scsi_cmnd); |
| 947 | zfcp_dbf_out(&p, "scsi_serial", "0x%016Lx", r->scsi_serial); |
Martin Peschke | df29f4a | 2008-03-31 11:15:26 +0200 | [diff] [blame] | 948 | zfcp_dbf_outd(&p, "scsi_opcode", r->scsi_opcode, ZFCP_DBF_SCSI_OPCODE, |
| 949 | 0, ZFCP_DBF_SCSI_OPCODE); |
Martin Peschke | b634fff | 2008-03-31 11:15:24 +0200 | [diff] [blame] | 950 | zfcp_dbf_out(&p, "scsi_retries", "0x%02x", r->scsi_retries); |
| 951 | zfcp_dbf_out(&p, "scsi_allowed", "0x%02x", r->scsi_allowed); |
| 952 | if (strncmp(r->tag, "abrt", ZFCP_DBF_TAG_SIZE) == 0) |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 953 | 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] | 954 | zfcp_dbf_out(&p, "fsf_reqid", "0x%0Lx", r->fsf_reqid); |
| 955 | zfcp_dbf_out(&p, "fsf_seqno", "0x%08x", r->fsf_seqno); |
Christof Schmitt | b592e89 | 2009-08-18 15:43:31 +0200 | [diff] [blame] | 956 | stck_to_timespec(r->fsf_issued, &t); |
Martin Peschke | b634fff | 2008-03-31 11:15:24 +0200 | [diff] [blame] | 957 | 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] | 958 | |
Martin Peschke | b634fff | 2008-03-31 11:15:24 +0200 | [diff] [blame] | 959 | if (strncmp(r->tag, "rslt", ZFCP_DBF_TAG_SIZE) == 0) { |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 960 | zfcp_dbf_out(&p, "fcp_rsp_validity", "0x%02x", r->rsp_validity); |
| 961 | zfcp_dbf_out(&p, "fcp_rsp_scsi_status", "0x%02x", |
| 962 | r->rsp_scsi_status); |
| 963 | zfcp_dbf_out(&p, "fcp_rsp_resid", "0x%08x", r->rsp_resid); |
| 964 | zfcp_dbf_out(&p, "fcp_rsp_code", "0x%08x", r->rsp_code); |
| 965 | zfcp_dbf_out(&p, "fcp_sns_info_len", "0x%08x", r->sns_info_len); |
| 966 | zfcp_dbf_outd(&p, "fcp_sns_info", r->sns_info, |
| 967 | min((int)r->sns_info_len, |
Martin Peschke | df29f4a | 2008-03-31 11:15:26 +0200 | [diff] [blame] | 968 | ZFCP_DBF_SCSI_FCP_SNS_INFO), 0, |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 969 | r->sns_info_len); |
Martin Peschke | b634fff | 2008-03-31 11:15:24 +0200 | [diff] [blame] | 970 | } |
| 971 | p += sprintf(p, "\n"); |
| 972 | return p - out_buf; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 973 | } |
| 974 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 975 | static struct debug_view zfcp_dbf_scsi_view = { |
| 976 | .name = "structured", |
| 977 | .header_proc = zfcp_dbf_view_header, |
| 978 | .format_proc = zfcp_dbf_scsi_view_format, |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 979 | }; |
| 980 | |
Christof Schmitt | d46f384 | 2009-08-18 15:43:07 +0200 | [diff] [blame] | 981 | static debug_info_t *zfcp_dbf_reg(const char *name, int level, |
| 982 | struct debug_view *view, int size) |
| 983 | { |
| 984 | struct debug_info *d; |
| 985 | |
| 986 | d = debug_register(name, dbfsize, level, size); |
| 987 | if (!d) |
| 988 | return NULL; |
| 989 | |
| 990 | debug_register_view(d, &debug_hex_ascii_view); |
| 991 | debug_register_view(d, view); |
| 992 | debug_set_level(d, level); |
| 993 | |
| 994 | return d; |
| 995 | } |
| 996 | |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 997 | /** |
| 998 | * zfcp_adapter_debug_register - registers debug feature for an adapter |
| 999 | * @adapter: pointer to adapter for which debug features should be registered |
| 1000 | * return: -ENOMEM on error, 0 otherwise |
| 1001 | */ |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 1002 | int zfcp_dbf_adapter_register(struct zfcp_adapter *adapter) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 1003 | { |
| 1004 | char dbf_name[DEBUG_MAX_NAME_LEN]; |
Christof Schmitt | d46f384 | 2009-08-18 15:43:07 +0200 | [diff] [blame] | 1005 | struct zfcp_dbf *dbf; |
| 1006 | |
| 1007 | dbf = kmalloc(sizeof(struct zfcp_dbf), GFP_KERNEL); |
| 1008 | if (!dbf) |
| 1009 | return -ENOMEM; |
| 1010 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 1011 | dbf->adapter = adapter; |
| 1012 | |
| 1013 | spin_lock_init(&dbf->hba_lock); |
| 1014 | spin_lock_init(&dbf->san_lock); |
| 1015 | spin_lock_init(&dbf->scsi_lock); |
| 1016 | spin_lock_init(&dbf->rec_lock); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 1017 | |
| 1018 | /* debug feature area which records recovery activity */ |
Christof Schmitt | b225cf9 | 2008-12-19 16:57:00 +0100 | [diff] [blame] | 1019 | sprintf(dbf_name, "zfcp_%s_rec", dev_name(&adapter->ccw_device->dev)); |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 1020 | dbf->rec = zfcp_dbf_reg(dbf_name, 3, &zfcp_dbf_rec_view, |
| 1021 | sizeof(struct zfcp_dbf_rec_record)); |
| 1022 | if (!dbf->rec) |
| 1023 | goto err_out; |
Martin Peschke | d79a83d | 2008-03-27 14:22:00 +0100 | [diff] [blame] | 1024 | |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 1025 | /* debug feature area which records HBA (FSF and QDIO) conditions */ |
Christof Schmitt | b225cf9 | 2008-12-19 16:57:00 +0100 | [diff] [blame] | 1026 | sprintf(dbf_name, "zfcp_%s_hba", dev_name(&adapter->ccw_device->dev)); |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 1027 | dbf->hba = zfcp_dbf_reg(dbf_name, 3, &zfcp_dbf_hba_view, |
| 1028 | sizeof(struct zfcp_dbf_hba_record)); |
| 1029 | if (!dbf->hba) |
| 1030 | goto err_out; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 1031 | |
| 1032 | /* debug feature area which records SAN command failures and recovery */ |
Christof Schmitt | b225cf9 | 2008-12-19 16:57:00 +0100 | [diff] [blame] | 1033 | sprintf(dbf_name, "zfcp_%s_san", dev_name(&adapter->ccw_device->dev)); |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 1034 | dbf->san = zfcp_dbf_reg(dbf_name, 6, &zfcp_dbf_san_view, |
| 1035 | sizeof(struct zfcp_dbf_san_record)); |
| 1036 | if (!dbf->san) |
| 1037 | goto err_out; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 1038 | |
| 1039 | /* debug feature area which records SCSI command failures and recovery */ |
Christof Schmitt | b225cf9 | 2008-12-19 16:57:00 +0100 | [diff] [blame] | 1040 | sprintf(dbf_name, "zfcp_%s_scsi", dev_name(&adapter->ccw_device->dev)); |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 1041 | dbf->scsi = zfcp_dbf_reg(dbf_name, 3, &zfcp_dbf_scsi_view, |
| 1042 | sizeof(struct zfcp_dbf_scsi_record)); |
| 1043 | if (!dbf->scsi) |
| 1044 | goto err_out; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 1045 | |
Christof Schmitt | d46f384 | 2009-08-18 15:43:07 +0200 | [diff] [blame] | 1046 | adapter->dbf = dbf; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 1047 | return 0; |
| 1048 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 1049 | err_out: |
| 1050 | zfcp_dbf_adapter_unregister(dbf); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 1051 | return -ENOMEM; |
| 1052 | } |
| 1053 | |
| 1054 | /** |
| 1055 | * zfcp_adapter_debug_unregister - unregisters debug feature for an adapter |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 1056 | * @dbf: pointer to dbf for which debug features should be unregistered |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 1057 | */ |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 1058 | void zfcp_dbf_adapter_unregister(struct zfcp_dbf *dbf) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 1059 | { |
Swen Schillig | f3450c7 | 2009-11-24 16:53:59 +0100 | [diff] [blame] | 1060 | if (!dbf) |
| 1061 | return; |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 1062 | debug_unregister(dbf->scsi); |
| 1063 | debug_unregister(dbf->san); |
| 1064 | debug_unregister(dbf->hba); |
| 1065 | debug_unregister(dbf->rec); |
| 1066 | dbf->adapter->dbf = NULL; |
| 1067 | kfree(dbf); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 1068 | } |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 1069 | |