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