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_out(char **buf, const char *s, const char *format, ...) |
| 54 | { |
| 55 | va_list arg; |
| 56 | |
| 57 | *buf += sprintf(*buf, "%-24s", s); |
| 58 | va_start(arg, format); |
| 59 | *buf += vsprintf(*buf, format, arg); |
| 60 | va_end(arg); |
| 61 | *buf += sprintf(*buf, "\n"); |
| 62 | } |
| 63 | |
Martin Peschke | df29f4a | 2008-03-31 11:15:26 +0200 | [diff] [blame] | 64 | static void zfcp_dbf_outd(char **p, const char *label, char *buffer, |
| 65 | int buflen, int offset, int total_size) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 66 | { |
Martin Peschke | df29f4a | 2008-03-31 11:15:26 +0200 | [diff] [blame] | 67 | if (!offset) |
| 68 | *p += sprintf(*p, "%-24s ", label); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 69 | while (buflen--) { |
| 70 | if (offset > 0) { |
| 71 | if ((offset % 32) == 0) |
Martin Peschke | df29f4a | 2008-03-31 11:15:26 +0200 | [diff] [blame] | 72 | *p += sprintf(*p, "\n%-24c ", ' '); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 73 | else if ((offset % 4) == 0) |
Martin Peschke | df29f4a | 2008-03-31 11:15:26 +0200 | [diff] [blame] | 74 | *p += sprintf(*p, " "); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 75 | } |
Martin Peschke | df29f4a | 2008-03-31 11:15:26 +0200 | [diff] [blame] | 76 | *p += sprintf(*p, "%02x", *buffer++); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 77 | if (++offset == total_size) { |
Martin Peschke | df29f4a | 2008-03-31 11:15:26 +0200 | [diff] [blame] | 78 | *p += sprintf(*p, "\n"); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 79 | break; |
| 80 | } |
| 81 | } |
Martin Peschke | df29f4a | 2008-03-31 11:15:26 +0200 | [diff] [blame] | 82 | if (!total_size) |
| 83 | *p += sprintf(*p, "\n"); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 84 | } |
| 85 | |
Martin Peschke | 92c7a83 | 2008-03-31 11:15:30 +0200 | [diff] [blame] | 86 | static int zfcp_dbf_view_header(debug_info_t *id, struct debug_view *view, |
| 87 | int area, debug_entry_t *entry, char *out_buf) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 88 | { |
| 89 | struct zfcp_dbf_dump *dump = (struct zfcp_dbf_dump *)DEBUG_DATA(entry); |
Martin Peschke | 8fc5af1 | 2008-03-31 11:15:23 +0200 | [diff] [blame] | 90 | struct timespec t; |
Martin Peschke | b634fff | 2008-03-31 11:15:24 +0200 | [diff] [blame] | 91 | char *p = out_buf; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 92 | |
| 93 | if (strncmp(dump->tag, "dump", ZFCP_DBF_TAG_SIZE) != 0) { |
Christof Schmitt | b592e89 | 2009-08-18 15:43:31 +0200 | [diff] [blame] | 94 | stck_to_timespec(entry->id.stck, &t); |
Martin Peschke | b634fff | 2008-03-31 11:15:24 +0200 | [diff] [blame] | 95 | zfcp_dbf_out(&p, "timestamp", "%011lu:%06lu", |
| 96 | t.tv_sec, t.tv_nsec); |
| 97 | zfcp_dbf_out(&p, "cpu", "%02i", entry->id.fields.cpuid); |
| 98 | } else { |
Christof Schmitt | d94ce6c | 2008-11-04 16:35:12 +0100 | [diff] [blame] | 99 | zfcp_dbf_outd(&p, "", dump->data, dump->size, dump->offset, |
Martin Peschke | df29f4a | 2008-03-31 11:15:26 +0200 | [diff] [blame] | 100 | dump->total_size); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 101 | if ((dump->offset + dump->size) == dump->total_size) |
Martin Peschke | b634fff | 2008-03-31 11:15:24 +0200 | [diff] [blame] | 102 | p += sprintf(p, "\n"); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 103 | } |
Martin Peschke | b634fff | 2008-03-31 11:15:24 +0200 | [diff] [blame] | 104 | return p - out_buf; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 105 | } |
| 106 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 107 | void _zfcp_dbf_hba_fsf_response(const char *tag2, int level, |
| 108 | struct zfcp_fsf_req *fsf_req, |
| 109 | struct zfcp_dbf *dbf) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 110 | { |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 111 | struct fsf_qtcb *qtcb = fsf_req->qtcb; |
| 112 | union fsf_prot_status_qual *prot_status_qual = |
Martin Peschke | 92c7a83 | 2008-03-31 11:15:30 +0200 | [diff] [blame] | 113 | &qtcb->prefix.prot_status_qual; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 114 | union fsf_status_qual *fsf_status_qual = &qtcb->header.fsf_status_qual; |
| 115 | struct scsi_cmnd *scsi_cmnd; |
| 116 | struct zfcp_port *port; |
| 117 | struct zfcp_unit *unit; |
| 118 | struct zfcp_send_els *send_els; |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 119 | struct zfcp_dbf_hba_record *rec = &dbf->hba_buf; |
| 120 | struct zfcp_dbf_hba_record_response *response = &rec->u.response; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 121 | unsigned long flags; |
| 122 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 123 | spin_lock_irqsave(&dbf->hba_lock, flags); |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 124 | memset(rec, 0, sizeof(*rec)); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 125 | strncpy(rec->tag, "resp", ZFCP_DBF_TAG_SIZE); |
Christof Schmitt | 2e261af | 2009-08-18 15:43:09 +0200 | [diff] [blame] | 126 | strncpy(rec->tag2, tag2, ZFCP_DBF_TAG_SIZE); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 127 | |
| 128 | response->fsf_command = fsf_req->fsf_command; |
Christof Schmitt | f0216ae | 2009-05-15 13:18:14 +0200 | [diff] [blame] | 129 | response->fsf_reqid = fsf_req->req_id; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 130 | response->fsf_seqno = fsf_req->seq_no; |
| 131 | response->fsf_issued = fsf_req->issued; |
| 132 | response->fsf_prot_status = qtcb->prefix.prot_status; |
| 133 | response->fsf_status = qtcb->header.fsf_status; |
| 134 | memcpy(response->fsf_prot_status_qual, |
| 135 | prot_status_qual, FSF_PROT_STATUS_QUAL_SIZE); |
| 136 | memcpy(response->fsf_status_qual, |
| 137 | fsf_status_qual, FSF_STATUS_QUALIFIER_SIZE); |
| 138 | response->fsf_req_status = fsf_req->status; |
Christof Schmitt | 34c2b71 | 2010-02-17 11:18:59 +0100 | [diff] [blame] | 139 | response->sbal_first = fsf_req->qdio_req.sbal_first; |
| 140 | response->sbal_last = fsf_req->qdio_req.sbal_last; |
| 141 | response->sbal_response = fsf_req->qdio_req.sbal_response; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 142 | response->pool = fsf_req->pool != NULL; |
| 143 | response->erp_action = (unsigned long)fsf_req->erp_action; |
| 144 | |
| 145 | switch (fsf_req->fsf_command) { |
| 146 | case FSF_QTCB_FCP_CMND: |
| 147 | if (fsf_req->status & ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT) |
| 148 | break; |
| 149 | scsi_cmnd = (struct scsi_cmnd *)fsf_req->data; |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 150 | if (scsi_cmnd) { |
| 151 | response->u.fcp.cmnd = (unsigned long)scsi_cmnd; |
Felix Beck | ef3eb71 | 2010-07-16 15:37:42 +0200 | [diff] [blame] | 152 | response->u.fcp.data_dir = |
| 153 | qtcb->bottom.io.data_direction; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 154 | } |
| 155 | break; |
| 156 | |
| 157 | case FSF_QTCB_OPEN_PORT_WITH_DID: |
| 158 | case FSF_QTCB_CLOSE_PORT: |
| 159 | case FSF_QTCB_CLOSE_PHYSICAL_PORT: |
| 160 | port = (struct zfcp_port *)fsf_req->data; |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 161 | response->u.port.wwpn = port->wwpn; |
| 162 | response->u.port.d_id = port->d_id; |
| 163 | response->u.port.port_handle = qtcb->header.port_handle; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 164 | break; |
| 165 | |
| 166 | case FSF_QTCB_OPEN_LUN: |
| 167 | case FSF_QTCB_CLOSE_LUN: |
| 168 | unit = (struct zfcp_unit *)fsf_req->data; |
| 169 | port = unit->port; |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 170 | response->u.unit.wwpn = port->wwpn; |
| 171 | response->u.unit.fcp_lun = unit->fcp_lun; |
| 172 | response->u.unit.port_handle = qtcb->header.port_handle; |
| 173 | response->u.unit.lun_handle = qtcb->header.lun_handle; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 174 | break; |
| 175 | |
| 176 | case FSF_QTCB_SEND_ELS: |
| 177 | send_els = (struct zfcp_send_els *)fsf_req->data; |
Christof Schmitt | 800c0ca | 2009-11-24 16:54:12 +0100 | [diff] [blame] | 178 | response->u.els.d_id = ntoh24(qtcb->bottom.support.d_id); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 179 | break; |
| 180 | |
| 181 | case FSF_QTCB_ABORT_FCP_CMND: |
| 182 | case FSF_QTCB_SEND_GENERIC: |
| 183 | case FSF_QTCB_EXCHANGE_CONFIG_DATA: |
| 184 | case FSF_QTCB_EXCHANGE_PORT_DATA: |
| 185 | case FSF_QTCB_DOWNLOAD_CONTROL_FILE: |
| 186 | case FSF_QTCB_UPLOAD_CONTROL_FILE: |
| 187 | break; |
| 188 | } |
| 189 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 190 | debug_event(dbf->hba, level, rec, sizeof(*rec)); |
Martin Peschke | b75db73 | 2008-03-27 14:21:58 +0100 | [diff] [blame] | 191 | |
| 192 | /* have fcp channel microcode fixed to use as little as possible */ |
| 193 | if (fsf_req->fsf_command != FSF_QTCB_FCP_CMND) { |
| 194 | /* adjust length skipping trailing zeros */ |
| 195 | char *buf = (char *)qtcb + qtcb->header.log_start; |
| 196 | int len = qtcb->header.log_length; |
| 197 | for (; len && !buf[len - 1]; len--); |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 198 | zfcp_dbf_hexdump(dbf->hba, rec, sizeof(*rec), level, buf, |
Christof Schmitt | d46f384 | 2009-08-18 15:43:07 +0200 | [diff] [blame] | 199 | len); |
Martin Peschke | b75db73 | 2008-03-27 14:21:58 +0100 | [diff] [blame] | 200 | } |
| 201 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 202 | spin_unlock_irqrestore(&dbf->hba_lock, flags); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 203 | } |
| 204 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 205 | void _zfcp_dbf_hba_fsf_unsol(const char *tag, int level, struct zfcp_dbf *dbf, |
| 206 | struct fsf_status_read_buffer *status_buffer) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 207 | { |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 208 | struct zfcp_dbf_hba_record *rec = &dbf->hba_buf; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 209 | unsigned long flags; |
| 210 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 211 | spin_lock_irqsave(&dbf->hba_lock, flags); |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 212 | memset(rec, 0, sizeof(*rec)); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 213 | strncpy(rec->tag, "stat", ZFCP_DBF_TAG_SIZE); |
| 214 | strncpy(rec->tag2, tag, ZFCP_DBF_TAG_SIZE); |
| 215 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 216 | rec->u.status.failed = atomic_read(&dbf->adapter->stat_miss); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 217 | if (status_buffer != NULL) { |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 218 | rec->u.status.status_type = status_buffer->status_type; |
| 219 | rec->u.status.status_subtype = status_buffer->status_subtype; |
| 220 | memcpy(&rec->u.status.queue_designator, |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 221 | &status_buffer->queue_designator, |
| 222 | sizeof(struct fsf_queue_designator)); |
| 223 | |
| 224 | switch (status_buffer->status_type) { |
| 225 | case FSF_STATUS_READ_SENSE_DATA_AVAIL: |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 226 | rec->u.status.payload_size = |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 227 | ZFCP_DBF_UNSOL_PAYLOAD_SENSE_DATA_AVAIL; |
| 228 | break; |
| 229 | |
| 230 | case FSF_STATUS_READ_BIT_ERROR_THRESHOLD: |
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_BIT_ERROR_THRESHOLD; |
| 233 | break; |
| 234 | |
| 235 | case FSF_STATUS_READ_LINK_DOWN: |
Maxim Shchetynin | aef4a98 | 2005-09-13 21:51:16 +0200 | [diff] [blame] | 236 | switch (status_buffer->status_subtype) { |
| 237 | case FSF_STATUS_READ_SUB_NO_PHYSICAL_LINK: |
| 238 | case FSF_STATUS_READ_SUB_FDISC_FAILED: |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 239 | rec->u.status.payload_size = |
Maxim Shchetynin | aef4a98 | 2005-09-13 21:51:16 +0200 | [diff] [blame] | 240 | sizeof(struct fsf_link_down_info); |
| 241 | } |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 242 | break; |
| 243 | |
Maxim Shchetynin | aef4a98 | 2005-09-13 21:51:16 +0200 | [diff] [blame] | 244 | case FSF_STATUS_READ_FEATURE_UPDATE_ALERT: |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 245 | rec->u.status.payload_size = |
Maxim Shchetynin | aef4a98 | 2005-09-13 21:51:16 +0200 | [diff] [blame] | 246 | ZFCP_DBF_UNSOL_PAYLOAD_FEATURE_UPDATE_ALERT; |
| 247 | break; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 248 | } |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 249 | memcpy(&rec->u.status.payload, |
| 250 | &status_buffer->payload, rec->u.status.payload_size); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 251 | } |
| 252 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 253 | debug_event(dbf->hba, level, rec, sizeof(*rec)); |
| 254 | spin_unlock_irqrestore(&dbf->hba_lock, flags); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 255 | } |
| 256 | |
Martin Peschke | bfab163 | 2008-03-31 11:15:31 +0200 | [diff] [blame] | 257 | /** |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 258 | * zfcp_dbf_hba_qdio - trace event for QDIO related failure |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 259 | * @qdio: qdio structure affected by this QDIO related event |
Martin Peschke | bfab163 | 2008-03-31 11:15:31 +0200 | [diff] [blame] | 260 | * @qdio_error: as passed by qdio module |
Martin Peschke | bfab163 | 2008-03-31 11:15:31 +0200 | [diff] [blame] | 261 | * @sbal_index: first buffer with error condition, as passed by qdio module |
| 262 | * @sbal_count: number of buffers affected, as passed by qdio module |
| 263 | */ |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 264 | void zfcp_dbf_hba_qdio(struct zfcp_dbf *dbf, unsigned int qdio_error, |
| 265 | int sbal_index, int sbal_count) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 266 | { |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 267 | struct zfcp_dbf_hba_record *r = &dbf->hba_buf; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 268 | unsigned long flags; |
| 269 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 270 | spin_lock_irqsave(&dbf->hba_lock, flags); |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 271 | memset(r, 0, sizeof(*r)); |
| 272 | strncpy(r->tag, "qdio", ZFCP_DBF_TAG_SIZE); |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 273 | r->u.qdio.qdio_error = qdio_error; |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 274 | r->u.qdio.sbal_index = sbal_index; |
| 275 | r->u.qdio.sbal_count = sbal_count; |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 276 | debug_event(dbf->hba, 0, r, sizeof(*r)); |
| 277 | spin_unlock_irqrestore(&dbf->hba_lock, flags); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 278 | } |
| 279 | |
Swen Schillig | 5706938 | 2008-10-01 12:42:21 +0200 | [diff] [blame] | 280 | /** |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 281 | * zfcp_dbf_hba_berr - trace event for bit error threshold |
| 282 | * @dbf: dbf structure affected by this QDIO related event |
Swen Schillig | 5706938 | 2008-10-01 12:42:21 +0200 | [diff] [blame] | 283 | * @req: fsf request |
| 284 | */ |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 285 | 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] | 286 | { |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 287 | struct zfcp_dbf_hba_record *r = &dbf->hba_buf; |
Swen Schillig | 5706938 | 2008-10-01 12:42:21 +0200 | [diff] [blame] | 288 | struct fsf_status_read_buffer *sr_buf = req->data; |
| 289 | struct fsf_bit_error_payload *err = &sr_buf->payload.bit_error; |
| 290 | unsigned long flags; |
| 291 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 292 | spin_lock_irqsave(&dbf->hba_lock, flags); |
Swen Schillig | 5706938 | 2008-10-01 12:42:21 +0200 | [diff] [blame] | 293 | memset(r, 0, sizeof(*r)); |
| 294 | strncpy(r->tag, "berr", ZFCP_DBF_TAG_SIZE); |
| 295 | memcpy(&r->u.berr, err, sizeof(struct fsf_bit_error_payload)); |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 296 | debug_event(dbf->hba, 0, r, sizeof(*r)); |
| 297 | spin_unlock_irqrestore(&dbf->hba_lock, flags); |
Swen Schillig | 5706938 | 2008-10-01 12:42:21 +0200 | [diff] [blame] | 298 | } |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 299 | static void zfcp_dbf_hba_view_response(char **p, |
| 300 | struct zfcp_dbf_hba_record_response *r) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 301 | { |
Martin Peschke | 8fc5af1 | 2008-03-31 11:15:23 +0200 | [diff] [blame] | 302 | struct timespec t; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 303 | |
Martin Peschke | a9c8577 | 2008-03-31 11:15:27 +0200 | [diff] [blame] | 304 | zfcp_dbf_out(p, "fsf_command", "0x%08x", r->fsf_command); |
| 305 | zfcp_dbf_out(p, "fsf_reqid", "0x%0Lx", r->fsf_reqid); |
| 306 | zfcp_dbf_out(p, "fsf_seqno", "0x%08x", r->fsf_seqno); |
Christof Schmitt | b592e89 | 2009-08-18 15:43:31 +0200 | [diff] [blame] | 307 | stck_to_timespec(r->fsf_issued, &t); |
Martin Peschke | a9c8577 | 2008-03-31 11:15:27 +0200 | [diff] [blame] | 308 | zfcp_dbf_out(p, "fsf_issued", "%011lu:%06lu", t.tv_sec, t.tv_nsec); |
| 309 | zfcp_dbf_out(p, "fsf_prot_status", "0x%08x", r->fsf_prot_status); |
| 310 | zfcp_dbf_out(p, "fsf_status", "0x%08x", r->fsf_status); |
| 311 | 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] | 312 | FSF_PROT_STATUS_QUAL_SIZE, 0, FSF_PROT_STATUS_QUAL_SIZE); |
Martin Peschke | a9c8577 | 2008-03-31 11:15:27 +0200 | [diff] [blame] | 313 | zfcp_dbf_outd(p, "fsf_status_qual", r->fsf_status_qual, |
Martin Peschke | df29f4a | 2008-03-31 11:15:26 +0200 | [diff] [blame] | 314 | FSF_STATUS_QUALIFIER_SIZE, 0, FSF_STATUS_QUALIFIER_SIZE); |
Martin Peschke | a9c8577 | 2008-03-31 11:15:27 +0200 | [diff] [blame] | 315 | zfcp_dbf_out(p, "fsf_req_status", "0x%08x", r->fsf_req_status); |
| 316 | zfcp_dbf_out(p, "sbal_first", "0x%02x", r->sbal_first); |
Martin Peschke | e891bff | 2008-05-19 12:17:43 +0200 | [diff] [blame] | 317 | zfcp_dbf_out(p, "sbal_last", "0x%02x", r->sbal_last); |
Martin Peschke | c3baa9a2 | 2008-05-19 12:17:44 +0200 | [diff] [blame] | 318 | zfcp_dbf_out(p, "sbal_response", "0x%02x", r->sbal_response); |
Martin Peschke | a9c8577 | 2008-03-31 11:15:27 +0200 | [diff] [blame] | 319 | zfcp_dbf_out(p, "pool", "0x%02x", r->pool); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 320 | |
Martin Peschke | b634fff | 2008-03-31 11:15:24 +0200 | [diff] [blame] | 321 | switch (r->fsf_command) { |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 322 | case FSF_QTCB_FCP_CMND: |
Martin Peschke | b634fff | 2008-03-31 11:15:24 +0200 | [diff] [blame] | 323 | if (r->fsf_req_status & ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 324 | break; |
Felix Beck | ef3eb71 | 2010-07-16 15:37:42 +0200 | [diff] [blame] | 325 | 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] | 326 | zfcp_dbf_out(p, "scsi_cmnd", "0x%0Lx", r->u.fcp.cmnd); |
Christof Schmitt | 5a3fb30 | 2010-01-13 17:52:37 +0100 | [diff] [blame] | 327 | *p += sprintf(*p, "\n"); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 328 | break; |
| 329 | |
| 330 | case FSF_QTCB_OPEN_PORT_WITH_DID: |
| 331 | case FSF_QTCB_CLOSE_PORT: |
| 332 | case FSF_QTCB_CLOSE_PHYSICAL_PORT: |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 333 | zfcp_dbf_out(p, "wwpn", "0x%016Lx", r->u.port.wwpn); |
| 334 | zfcp_dbf_out(p, "d_id", "0x%06x", r->u.port.d_id); |
| 335 | 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] | 336 | break; |
| 337 | |
| 338 | case FSF_QTCB_OPEN_LUN: |
| 339 | case FSF_QTCB_CLOSE_LUN: |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 340 | zfcp_dbf_out(p, "wwpn", "0x%016Lx", r->u.unit.wwpn); |
| 341 | zfcp_dbf_out(p, "fcp_lun", "0x%016Lx", r->u.unit.fcp_lun); |
| 342 | zfcp_dbf_out(p, "port_handle", "0x%08x", r->u.unit.port_handle); |
| 343 | 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] | 344 | break; |
| 345 | |
| 346 | case FSF_QTCB_SEND_ELS: |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 347 | 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] | 348 | break; |
| 349 | |
| 350 | case FSF_QTCB_ABORT_FCP_CMND: |
| 351 | case FSF_QTCB_SEND_GENERIC: |
| 352 | case FSF_QTCB_EXCHANGE_CONFIG_DATA: |
| 353 | case FSF_QTCB_EXCHANGE_PORT_DATA: |
| 354 | case FSF_QTCB_DOWNLOAD_CONTROL_FILE: |
| 355 | case FSF_QTCB_UPLOAD_CONTROL_FILE: |
| 356 | break; |
| 357 | } |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 358 | } |
| 359 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 360 | static void zfcp_dbf_hba_view_status(char **p, |
| 361 | struct zfcp_dbf_hba_record_status *r) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 362 | { |
Martin Peschke | a9c8577 | 2008-03-31 11:15:27 +0200 | [diff] [blame] | 363 | zfcp_dbf_out(p, "failed", "0x%02x", r->failed); |
| 364 | zfcp_dbf_out(p, "status_type", "0x%08x", r->status_type); |
| 365 | zfcp_dbf_out(p, "status_subtype", "0x%08x", r->status_subtype); |
| 366 | zfcp_dbf_outd(p, "queue_designator", (char *)&r->queue_designator, |
Martin Peschke | df29f4a | 2008-03-31 11:15:26 +0200 | [diff] [blame] | 367 | sizeof(struct fsf_queue_designator), 0, |
| 368 | sizeof(struct fsf_queue_designator)); |
Martin Peschke | a9c8577 | 2008-03-31 11:15:27 +0200 | [diff] [blame] | 369 | zfcp_dbf_outd(p, "payload", (char *)&r->payload, r->payload_size, 0, |
Martin Peschke | df29f4a | 2008-03-31 11:15:26 +0200 | [diff] [blame] | 370 | r->payload_size); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 371 | } |
| 372 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 373 | 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] | 374 | { |
Martin Peschke | a9c8577 | 2008-03-31 11:15:27 +0200 | [diff] [blame] | 375 | zfcp_dbf_out(p, "qdio_error", "0x%08x", r->qdio_error); |
Martin Peschke | a9c8577 | 2008-03-31 11:15:27 +0200 | [diff] [blame] | 376 | zfcp_dbf_out(p, "sbal_index", "0x%02x", r->sbal_index); |
| 377 | zfcp_dbf_out(p, "sbal_count", "0x%02x", r->sbal_count); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 378 | } |
| 379 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 380 | 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] | 381 | { |
| 382 | zfcp_dbf_out(p, "link_failures", "%d", r->link_failure_error_count); |
| 383 | zfcp_dbf_out(p, "loss_of_sync_err", "%d", r->loss_of_sync_error_count); |
| 384 | zfcp_dbf_out(p, "loss_of_sig_err", "%d", r->loss_of_signal_error_count); |
| 385 | zfcp_dbf_out(p, "prim_seq_err", "%d", |
| 386 | r->primitive_sequence_error_count); |
| 387 | zfcp_dbf_out(p, "inval_trans_word_err", "%d", |
| 388 | r->invalid_transmission_word_error_count); |
| 389 | zfcp_dbf_out(p, "CRC_errors", "%d", r->crc_error_count); |
| 390 | zfcp_dbf_out(p, "prim_seq_event_to", "%d", |
| 391 | r->primitive_sequence_event_timeout_count); |
| 392 | zfcp_dbf_out(p, "elast_buf_overrun_err", "%d", |
| 393 | r->elastic_buffer_overrun_error_count); |
| 394 | zfcp_dbf_out(p, "adv_rec_buf2buf_cred", "%d", |
| 395 | r->advertised_receive_b2b_credit); |
| 396 | zfcp_dbf_out(p, "curr_rec_buf2buf_cred", "%d", |
| 397 | r->current_receive_b2b_credit); |
| 398 | zfcp_dbf_out(p, "adv_trans_buf2buf_cred", "%d", |
| 399 | r->advertised_transmit_b2b_credit); |
| 400 | zfcp_dbf_out(p, "curr_trans_buf2buf_cred", "%d", |
| 401 | r->current_transmit_b2b_credit); |
| 402 | } |
| 403 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 404 | 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] | 405 | char *out_buf, const char *in_buf) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 406 | { |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 407 | 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] | 408 | char *p = out_buf; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 409 | |
Martin Peschke | a9c8577 | 2008-03-31 11:15:27 +0200 | [diff] [blame] | 410 | if (strncmp(r->tag, "dump", ZFCP_DBF_TAG_SIZE) == 0) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 411 | return 0; |
| 412 | |
Martin Peschke | a9c8577 | 2008-03-31 11:15:27 +0200 | [diff] [blame] | 413 | zfcp_dbf_tag(&p, "tag", r->tag); |
| 414 | if (isalpha(r->tag2[0])) |
| 415 | zfcp_dbf_tag(&p, "tag2", r->tag2); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 416 | |
Martin Peschke | a9c8577 | 2008-03-31 11:15:27 +0200 | [diff] [blame] | 417 | if (strncmp(r->tag, "resp", ZFCP_DBF_TAG_SIZE) == 0) |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 418 | zfcp_dbf_hba_view_response(&p, &r->u.response); |
Martin Peschke | a9c8577 | 2008-03-31 11:15:27 +0200 | [diff] [blame] | 419 | else if (strncmp(r->tag, "stat", ZFCP_DBF_TAG_SIZE) == 0) |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 420 | zfcp_dbf_hba_view_status(&p, &r->u.status); |
Martin Peschke | a9c8577 | 2008-03-31 11:15:27 +0200 | [diff] [blame] | 421 | else if (strncmp(r->tag, "qdio", ZFCP_DBF_TAG_SIZE) == 0) |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 422 | zfcp_dbf_hba_view_qdio(&p, &r->u.qdio); |
Swen Schillig | 5706938 | 2008-10-01 12:42:21 +0200 | [diff] [blame] | 423 | else if (strncmp(r->tag, "berr", ZFCP_DBF_TAG_SIZE) == 0) |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 424 | zfcp_dbf_hba_view_berr(&p, &r->u.berr); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 425 | |
Christof Schmitt | d94ce6c | 2008-11-04 16:35:12 +0100 | [diff] [blame] | 426 | if (strncmp(r->tag, "resp", ZFCP_DBF_TAG_SIZE) != 0) |
| 427 | p += sprintf(p, "\n"); |
Martin Peschke | a9c8577 | 2008-03-31 11:15:27 +0200 | [diff] [blame] | 428 | return p - out_buf; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 429 | } |
| 430 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 431 | static struct debug_view zfcp_dbf_hba_view = { |
| 432 | .name = "structured", |
| 433 | .header_proc = zfcp_dbf_view_header, |
| 434 | .format_proc = zfcp_dbf_hba_view_format, |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 435 | }; |
| 436 | |
Swen Schillig | ae0904f | 2010-12-02 15:16:12 +0100 | [diff] [blame] | 437 | static void zfcp_dbf_set_common(struct zfcp_dbf_rec *rec, |
| 438 | struct zfcp_adapter *adapter, |
| 439 | struct zfcp_port *port, |
| 440 | struct scsi_device *sdev) |
Martin Peschke | d79a83d | 2008-03-27 14:22:00 +0100 | [diff] [blame] | 441 | { |
Swen Schillig | ae0904f | 2010-12-02 15:16:12 +0100 | [diff] [blame] | 442 | rec->adapter_status = atomic_read(&adapter->status); |
| 443 | if (port) { |
| 444 | rec->port_status = atomic_read(&port->status); |
| 445 | rec->wwpn = port->wwpn; |
| 446 | rec->d_id = port->d_id; |
Martin Peschke | d79a83d | 2008-03-27 14:22:00 +0100 | [diff] [blame] | 447 | } |
Swen Schillig | ae0904f | 2010-12-02 15:16:12 +0100 | [diff] [blame] | 448 | if (sdev) { |
| 449 | rec->lun_status = atomic_read(&sdev_to_zfcp(sdev)->status); |
| 450 | rec->lun = zfcp_scsi_dev_lun(sdev); |
| 451 | } |
Martin Peschke | 348447e | 2008-03-27 14:22:01 +0100 | [diff] [blame] | 452 | } |
| 453 | |
Christof Schmitt | aa0fec6 | 2008-05-19 12:17:47 +0200 | [diff] [blame] | 454 | /** |
Swen Schillig | ae0904f | 2010-12-02 15:16:12 +0100 | [diff] [blame] | 455 | * zfcp_dbf_rec_trig - trace event related to triggered recovery |
| 456 | * @tag: identifier for event |
| 457 | * @adapter: adapter on which the erp_action should run |
| 458 | * @port: remote port involved in the erp_action |
| 459 | * @sdev: scsi device involved in the erp_action |
| 460 | * @want: wanted erp_action |
| 461 | * @need: required erp_action |
| 462 | * |
| 463 | * The adapter->erp_lock has to be held. |
Christof Schmitt | aa0fec6 | 2008-05-19 12:17:47 +0200 | [diff] [blame] | 464 | */ |
Swen Schillig | ae0904f | 2010-12-02 15:16:12 +0100 | [diff] [blame] | 465 | void zfcp_dbf_rec_trig(char *tag, struct zfcp_adapter *adapter, |
| 466 | struct zfcp_port *port, struct scsi_device *sdev, |
| 467 | u8 want, u8 need) |
Martin Peschke | 9467a9b | 2008-03-27 14:22:03 +0100 | [diff] [blame] | 468 | { |
Christof Schmitt | d46f384 | 2009-08-18 15:43:07 +0200 | [diff] [blame] | 469 | struct zfcp_dbf *dbf = adapter->dbf; |
Swen Schillig | ae0904f | 2010-12-02 15:16:12 +0100 | [diff] [blame] | 470 | struct zfcp_dbf_rec *rec = &dbf->rec_buf; |
| 471 | struct list_head *entry; |
Martin Peschke | 9467a9b | 2008-03-27 14:22:03 +0100 | [diff] [blame] | 472 | unsigned long flags; |
| 473 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 474 | spin_lock_irqsave(&dbf->rec_lock, flags); |
Swen Schillig | ae0904f | 2010-12-02 15:16:12 +0100 | [diff] [blame] | 475 | memset(rec, 0, sizeof(*rec)); |
| 476 | |
| 477 | rec->id = ZFCP_DBF_REC_TRIG; |
| 478 | memcpy(rec->tag, tag, ZFCP_DBF_TAG_LEN); |
| 479 | zfcp_dbf_set_common(rec, adapter, port, sdev); |
| 480 | |
| 481 | list_for_each(entry, &adapter->erp_ready_head) |
| 482 | rec->u.trig.ready++; |
| 483 | |
| 484 | list_for_each(entry, &adapter->erp_running_head) |
| 485 | rec->u.trig.running++; |
| 486 | |
| 487 | rec->u.trig.want = want; |
| 488 | rec->u.trig.need = need; |
| 489 | |
| 490 | debug_event(dbf->rec, 1, rec, sizeof(*rec)); |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 491 | spin_unlock_irqrestore(&dbf->rec_lock, flags); |
Martin Peschke | 9467a9b | 2008-03-27 14:22:03 +0100 | [diff] [blame] | 492 | } |
| 493 | |
Swen Schillig | ae0904f | 2010-12-02 15:16:12 +0100 | [diff] [blame] | 494 | |
Martin Peschke | 6f4f365 | 2008-03-27 14:22:04 +0100 | [diff] [blame] | 495 | /** |
Swen Schillig | ae0904f | 2010-12-02 15:16:12 +0100 | [diff] [blame] | 496 | * zfcp_dbf_rec_run - trace event related to running recovery |
| 497 | * @tag: identifier for event |
| 498 | * @erp: erp_action running |
Martin Peschke | 6f4f365 | 2008-03-27 14:22:04 +0100 | [diff] [blame] | 499 | */ |
Swen Schillig | ae0904f | 2010-12-02 15:16:12 +0100 | [diff] [blame] | 500 | void zfcp_dbf_rec_run(char *tag, struct zfcp_erp_action *erp) |
Martin Peschke | 6f4f365 | 2008-03-27 14:22:04 +0100 | [diff] [blame] | 501 | { |
Swen Schillig | ae0904f | 2010-12-02 15:16:12 +0100 | [diff] [blame] | 502 | struct zfcp_dbf *dbf = erp->adapter->dbf; |
| 503 | struct zfcp_dbf_rec *rec = &dbf->rec_buf; |
Martin Peschke | 6f4f365 | 2008-03-27 14:22:04 +0100 | [diff] [blame] | 504 | unsigned long flags; |
| 505 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 506 | spin_lock_irqsave(&dbf->rec_lock, flags); |
Swen Schillig | ae0904f | 2010-12-02 15:16:12 +0100 | [diff] [blame] | 507 | memset(rec, 0, sizeof(*rec)); |
| 508 | |
| 509 | rec->id = ZFCP_DBF_REC_RUN; |
| 510 | memcpy(rec->tag, tag, ZFCP_DBF_TAG_LEN); |
| 511 | zfcp_dbf_set_common(rec, erp->adapter, erp->port, erp->sdev); |
| 512 | |
| 513 | rec->u.run.fsf_req_id = erp->fsf_req_id; |
| 514 | rec->u.run.rec_status = erp->status; |
| 515 | rec->u.run.rec_step = erp->step; |
| 516 | rec->u.run.rec_action = erp->action; |
| 517 | |
| 518 | if (erp->sdev) |
| 519 | rec->u.run.rec_count = |
| 520 | atomic_read(&sdev_to_zfcp(erp->sdev)->erp_counter); |
| 521 | else if (erp->port) |
| 522 | rec->u.run.rec_count = atomic_read(&erp->port->erp_counter); |
| 523 | else |
| 524 | rec->u.run.rec_count = atomic_read(&erp->adapter->erp_counter); |
| 525 | |
| 526 | debug_event(dbf->rec, 1, rec, sizeof(*rec)); |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 527 | spin_unlock_irqrestore(&dbf->rec_lock, flags); |
Martin Peschke | 6f4f365 | 2008-03-27 14:22:04 +0100 | [diff] [blame] | 528 | } |
| 529 | |
Swen Schillig | 2c55b75 | 2010-12-02 15:16:13 +0100 | [diff] [blame^] | 530 | static inline |
| 531 | void zfcp_dbf_san(char *tag, struct zfcp_dbf *dbf, void *data, u8 id, u16 len, |
| 532 | u64 req_id, u32 d_id) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 533 | { |
Swen Schillig | 2c55b75 | 2010-12-02 15:16:13 +0100 | [diff] [blame^] | 534 | struct zfcp_dbf_san *rec = &dbf->san_buf; |
| 535 | u16 rec_len; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 536 | unsigned long flags; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 537 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 538 | spin_lock_irqsave(&dbf->san_lock, flags); |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 539 | memset(rec, 0, sizeof(*rec)); |
Swen Schillig | 2c55b75 | 2010-12-02 15:16:13 +0100 | [diff] [blame^] | 540 | |
| 541 | rec->id = id; |
| 542 | rec->fsf_req_id = req_id; |
| 543 | rec->d_id = d_id; |
| 544 | rec_len = min(len, (u16)ZFCP_DBF_SAN_MAX_PAYLOAD); |
| 545 | memcpy(rec->payload, data, rec_len); |
| 546 | memcpy(rec->tag, tag, ZFCP_DBF_TAG_LEN); |
| 547 | |
| 548 | debug_event(dbf->san, 1, rec, sizeof(*rec)); |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 549 | spin_unlock_irqrestore(&dbf->san_lock, flags); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 550 | } |
| 551 | |
Martin Peschke | bfab163 | 2008-03-31 11:15:31 +0200 | [diff] [blame] | 552 | /** |
Swen Schillig | 2c55b75 | 2010-12-02 15:16:13 +0100 | [diff] [blame^] | 553 | * zfcp_dbf_san_req - trace event for issued SAN request |
| 554 | * @tag: indentifier for event |
| 555 | * @fsf_req: request containing issued CT data |
| 556 | * d_id: destination ID |
Martin Peschke | bfab163 | 2008-03-31 11:15:31 +0200 | [diff] [blame] | 557 | */ |
Swen Schillig | 2c55b75 | 2010-12-02 15:16:13 +0100 | [diff] [blame^] | 558 | void zfcp_dbf_san_req(char *tag, struct zfcp_fsf_req *fsf, u32 d_id) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 559 | { |
Swen Schillig | 2c55b75 | 2010-12-02 15:16:13 +0100 | [diff] [blame^] | 560 | struct zfcp_dbf *dbf = fsf->adapter->dbf; |
| 561 | struct zfcp_fsf_ct_els *ct_els = fsf->data; |
| 562 | u16 length; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 563 | |
Swen Schillig | 2c55b75 | 2010-12-02 15:16:13 +0100 | [diff] [blame^] | 564 | length = (u16)(ct_els->req->length + FC_CT_HDR_LEN); |
| 565 | zfcp_dbf_san(tag, dbf, sg_virt(ct_els->req), ZFCP_DBF_SAN_REQ, length, |
| 566 | fsf->req_id, d_id); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 567 | } |
| 568 | |
Martin Peschke | bfab163 | 2008-03-31 11:15:31 +0200 | [diff] [blame] | 569 | /** |
Swen Schillig | 2c55b75 | 2010-12-02 15:16:13 +0100 | [diff] [blame^] | 570 | * zfcp_dbf_san_res - trace event for received SAN request |
| 571 | * @tag: indentifier for event |
| 572 | * @fsf_req: request containing issued CT data |
Martin Peschke | bfab163 | 2008-03-31 11:15:31 +0200 | [diff] [blame] | 573 | */ |
Swen Schillig | 2c55b75 | 2010-12-02 15:16:13 +0100 | [diff] [blame^] | 574 | void zfcp_dbf_san_res(char *tag, struct zfcp_fsf_req *fsf) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 575 | { |
Swen Schillig | 2c55b75 | 2010-12-02 15:16:13 +0100 | [diff] [blame^] | 576 | struct zfcp_dbf *dbf = fsf->adapter->dbf; |
| 577 | struct zfcp_fsf_ct_els *ct_els = fsf->data; |
| 578 | u16 length; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 579 | |
Swen Schillig | 2c55b75 | 2010-12-02 15:16:13 +0100 | [diff] [blame^] | 580 | length = (u16)(ct_els->resp->length + FC_CT_HDR_LEN); |
| 581 | zfcp_dbf_san(tag, dbf, sg_virt(ct_els->resp), ZFCP_DBF_SAN_RES, length, |
| 582 | fsf->req_id, 0); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 583 | } |
| 584 | |
Martin Peschke | bfab163 | 2008-03-31 11:15:31 +0200 | [diff] [blame] | 585 | /** |
Swen Schillig | 2c55b75 | 2010-12-02 15:16:13 +0100 | [diff] [blame^] | 586 | * zfcp_dbf_san_in_els - trace event for incoming ELS |
| 587 | * @tag: indentifier for event |
| 588 | * @fsf_req: request containing issued CT data |
Martin Peschke | bfab163 | 2008-03-31 11:15:31 +0200 | [diff] [blame] | 589 | */ |
Swen Schillig | 2c55b75 | 2010-12-02 15:16:13 +0100 | [diff] [blame^] | 590 | void zfcp_dbf_san_in_els(char *tag, struct zfcp_fsf_req *fsf) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 591 | { |
Swen Schillig | 2c55b75 | 2010-12-02 15:16:13 +0100 | [diff] [blame^] | 592 | struct zfcp_dbf *dbf = fsf->adapter->dbf; |
| 593 | struct fsf_status_read_buffer *srb = |
| 594 | (struct fsf_status_read_buffer *) fsf->data; |
| 595 | u16 length; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 596 | |
Swen Schillig | 2c55b75 | 2010-12-02 15:16:13 +0100 | [diff] [blame^] | 597 | length = (u16)(srb->length - |
| 598 | offsetof(struct fsf_status_read_buffer, payload)); |
| 599 | zfcp_dbf_san(tag, dbf, srb->payload.data, ZFCP_DBF_SAN_ELS, length, |
| 600 | fsf->req_id, ntoh24(srb->d_id)); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 601 | } |
| 602 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 603 | void _zfcp_dbf_scsi(const char *tag, const char *tag2, int level, |
| 604 | struct zfcp_dbf *dbf, struct scsi_cmnd *scsi_cmnd, |
| 605 | struct zfcp_fsf_req *fsf_req, unsigned long old_req_id) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 606 | { |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 607 | struct zfcp_dbf_scsi_record *rec = &dbf->scsi_buf; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 608 | struct zfcp_dbf_dump *dump = (struct zfcp_dbf_dump *)rec; |
| 609 | unsigned long flags; |
Christof Schmitt | 4318e08 | 2009-11-24 16:54:08 +0100 | [diff] [blame] | 610 | struct fcp_resp_with_ext *fcp_rsp; |
| 611 | struct fcp_resp_rsp_info *fcp_rsp_info = NULL; |
| 612 | char *fcp_sns_info = NULL; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 613 | int offset = 0, buflen = 0; |
| 614 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 615 | spin_lock_irqsave(&dbf->scsi_lock, flags); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 616 | do { |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 617 | memset(rec, 0, sizeof(*rec)); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 618 | if (offset == 0) { |
| 619 | strncpy(rec->tag, tag, ZFCP_DBF_TAG_SIZE); |
| 620 | strncpy(rec->tag2, tag2, ZFCP_DBF_TAG_SIZE); |
Maxim Shchetynin | ed829ad | 2006-02-11 01:42:58 +0100 | [diff] [blame] | 621 | if (scsi_cmnd != NULL) { |
| 622 | if (scsi_cmnd->device) { |
| 623 | rec->scsi_id = scsi_cmnd->device->id; |
| 624 | rec->scsi_lun = scsi_cmnd->device->lun; |
| 625 | } |
| 626 | rec->scsi_result = scsi_cmnd->result; |
| 627 | rec->scsi_cmnd = (unsigned long)scsi_cmnd; |
Boaz Harrosh | 64a87b2 | 2008-04-30 11:19:47 +0300 | [diff] [blame] | 628 | memcpy(rec->scsi_opcode, scsi_cmnd->cmnd, |
Maxim Shchetynin | ed829ad | 2006-02-11 01:42:58 +0100 | [diff] [blame] | 629 | min((int)scsi_cmnd->cmd_len, |
| 630 | ZFCP_DBF_SCSI_OPCODE)); |
| 631 | rec->scsi_retries = scsi_cmnd->retries; |
| 632 | rec->scsi_allowed = scsi_cmnd->allowed; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 633 | } |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 634 | if (fsf_req != NULL) { |
Christof Schmitt | 4318e08 | 2009-11-24 16:54:08 +0100 | [diff] [blame] | 635 | fcp_rsp = (struct fcp_resp_with_ext *) |
| 636 | &(fsf_req->qtcb->bottom.io.fcp_rsp); |
| 637 | fcp_rsp_info = (struct fcp_resp_rsp_info *) |
| 638 | &fcp_rsp[1]; |
| 639 | fcp_sns_info = (char *) &fcp_rsp[1]; |
| 640 | if (fcp_rsp->resp.fr_flags & FCP_RSP_LEN_VAL) |
| 641 | fcp_sns_info += fcp_rsp->ext.fr_sns_len; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 642 | |
Christof Schmitt | 4318e08 | 2009-11-24 16:54:08 +0100 | [diff] [blame] | 643 | rec->rsp_validity = fcp_rsp->resp.fr_flags; |
| 644 | rec->rsp_scsi_status = fcp_rsp->resp.fr_status; |
| 645 | rec->rsp_resid = fcp_rsp->ext.fr_resid; |
| 646 | if (fcp_rsp->resp.fr_flags & FCP_RSP_LEN_VAL) |
| 647 | rec->rsp_code = fcp_rsp_info->rsp_code; |
| 648 | if (fcp_rsp->resp.fr_flags & FCP_SNS_LEN_VAL) { |
| 649 | buflen = min(fcp_rsp->ext.fr_sns_len, |
| 650 | (u32)ZFCP_DBF_SCSI_MAX_FCP_SNS_INFO); |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 651 | rec->sns_info_len = buflen; |
| 652 | memcpy(rec->sns_info, fcp_sns_info, |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 653 | min(buflen, |
| 654 | ZFCP_DBF_SCSI_FCP_SNS_INFO)); |
| 655 | offset += min(buflen, |
| 656 | ZFCP_DBF_SCSI_FCP_SNS_INFO); |
| 657 | } |
| 658 | |
Christof Schmitt | f0216ae | 2009-05-15 13:18:14 +0200 | [diff] [blame] | 659 | rec->fsf_reqid = fsf_req->req_id; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 660 | rec->fsf_seqno = fsf_req->seq_no; |
| 661 | rec->fsf_issued = fsf_req->issued; |
| 662 | } |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 663 | rec->old_fsf_reqid = old_req_id; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 664 | } else { |
| 665 | strncpy(dump->tag, "dump", ZFCP_DBF_TAG_SIZE); |
| 666 | dump->total_size = buflen; |
| 667 | dump->offset = offset; |
| 668 | dump->size = min(buflen - offset, |
| 669 | (int)sizeof(struct |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 670 | zfcp_dbf_scsi_record) - |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 671 | (int)sizeof(struct zfcp_dbf_dump)); |
| 672 | memcpy(dump->data, fcp_sns_info + offset, dump->size); |
| 673 | offset += dump->size; |
| 674 | } |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 675 | debug_event(dbf->scsi, level, rec, sizeof(*rec)); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 676 | } while (offset < buflen); |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 677 | spin_unlock_irqrestore(&dbf->scsi_lock, flags); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 678 | } |
| 679 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 680 | 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] | 681 | char *out_buf, const char *in_buf) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 682 | { |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 683 | 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] | 684 | struct timespec t; |
Martin Peschke | b634fff | 2008-03-31 11:15:24 +0200 | [diff] [blame] | 685 | char *p = out_buf; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 686 | |
Martin Peschke | b634fff | 2008-03-31 11:15:24 +0200 | [diff] [blame] | 687 | if (strncmp(r->tag, "dump", ZFCP_DBF_TAG_SIZE) == 0) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 688 | return 0; |
| 689 | |
Martin Peschke | a9c8577 | 2008-03-31 11:15:27 +0200 | [diff] [blame] | 690 | zfcp_dbf_tag(&p, "tag", r->tag); |
| 691 | zfcp_dbf_tag(&p, "tag2", r->tag2); |
Martin Peschke | b634fff | 2008-03-31 11:15:24 +0200 | [diff] [blame] | 692 | zfcp_dbf_out(&p, "scsi_id", "0x%08x", r->scsi_id); |
| 693 | zfcp_dbf_out(&p, "scsi_lun", "0x%08x", r->scsi_lun); |
| 694 | zfcp_dbf_out(&p, "scsi_result", "0x%08x", r->scsi_result); |
| 695 | zfcp_dbf_out(&p, "scsi_cmnd", "0x%0Lx", r->scsi_cmnd); |
Martin Peschke | df29f4a | 2008-03-31 11:15:26 +0200 | [diff] [blame] | 696 | zfcp_dbf_outd(&p, "scsi_opcode", r->scsi_opcode, ZFCP_DBF_SCSI_OPCODE, |
| 697 | 0, ZFCP_DBF_SCSI_OPCODE); |
Martin Peschke | b634fff | 2008-03-31 11:15:24 +0200 | [diff] [blame] | 698 | zfcp_dbf_out(&p, "scsi_retries", "0x%02x", r->scsi_retries); |
| 699 | zfcp_dbf_out(&p, "scsi_allowed", "0x%02x", r->scsi_allowed); |
| 700 | if (strncmp(r->tag, "abrt", ZFCP_DBF_TAG_SIZE) == 0) |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 701 | 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] | 702 | zfcp_dbf_out(&p, "fsf_reqid", "0x%0Lx", r->fsf_reqid); |
| 703 | zfcp_dbf_out(&p, "fsf_seqno", "0x%08x", r->fsf_seqno); |
Christof Schmitt | b592e89 | 2009-08-18 15:43:31 +0200 | [diff] [blame] | 704 | stck_to_timespec(r->fsf_issued, &t); |
Martin Peschke | b634fff | 2008-03-31 11:15:24 +0200 | [diff] [blame] | 705 | 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] | 706 | |
Martin Peschke | b634fff | 2008-03-31 11:15:24 +0200 | [diff] [blame] | 707 | if (strncmp(r->tag, "rslt", ZFCP_DBF_TAG_SIZE) == 0) { |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 708 | zfcp_dbf_out(&p, "fcp_rsp_validity", "0x%02x", r->rsp_validity); |
| 709 | zfcp_dbf_out(&p, "fcp_rsp_scsi_status", "0x%02x", |
| 710 | r->rsp_scsi_status); |
| 711 | zfcp_dbf_out(&p, "fcp_rsp_resid", "0x%08x", r->rsp_resid); |
| 712 | zfcp_dbf_out(&p, "fcp_rsp_code", "0x%08x", r->rsp_code); |
| 713 | zfcp_dbf_out(&p, "fcp_sns_info_len", "0x%08x", r->sns_info_len); |
| 714 | zfcp_dbf_outd(&p, "fcp_sns_info", r->sns_info, |
| 715 | min((int)r->sns_info_len, |
Martin Peschke | df29f4a | 2008-03-31 11:15:26 +0200 | [diff] [blame] | 716 | ZFCP_DBF_SCSI_FCP_SNS_INFO), 0, |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 717 | r->sns_info_len); |
Martin Peschke | b634fff | 2008-03-31 11:15:24 +0200 | [diff] [blame] | 718 | } |
| 719 | p += sprintf(p, "\n"); |
| 720 | return p - out_buf; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 721 | } |
| 722 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 723 | static struct debug_view zfcp_dbf_scsi_view = { |
| 724 | .name = "structured", |
| 725 | .header_proc = zfcp_dbf_view_header, |
| 726 | .format_proc = zfcp_dbf_scsi_view_format, |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 727 | }; |
| 728 | |
Christof Schmitt | d46f384 | 2009-08-18 15:43:07 +0200 | [diff] [blame] | 729 | static debug_info_t *zfcp_dbf_reg(const char *name, int level, |
| 730 | struct debug_view *view, int size) |
| 731 | { |
| 732 | struct debug_info *d; |
| 733 | |
| 734 | d = debug_register(name, dbfsize, level, size); |
| 735 | if (!d) |
| 736 | return NULL; |
| 737 | |
| 738 | debug_register_view(d, &debug_hex_ascii_view); |
| 739 | debug_register_view(d, view); |
| 740 | debug_set_level(d, level); |
| 741 | |
| 742 | return d; |
| 743 | } |
| 744 | |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 745 | /** |
| 746 | * zfcp_adapter_debug_register - registers debug feature for an adapter |
| 747 | * @adapter: pointer to adapter for which debug features should be registered |
| 748 | * return: -ENOMEM on error, 0 otherwise |
| 749 | */ |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 750 | int zfcp_dbf_adapter_register(struct zfcp_adapter *adapter) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 751 | { |
| 752 | char dbf_name[DEBUG_MAX_NAME_LEN]; |
Christof Schmitt | d46f384 | 2009-08-18 15:43:07 +0200 | [diff] [blame] | 753 | struct zfcp_dbf *dbf; |
| 754 | |
Swen Schillig | d23948e | 2010-07-16 15:37:40 +0200 | [diff] [blame] | 755 | dbf = kzalloc(sizeof(struct zfcp_dbf), GFP_KERNEL); |
Christof Schmitt | d46f384 | 2009-08-18 15:43:07 +0200 | [diff] [blame] | 756 | if (!dbf) |
| 757 | return -ENOMEM; |
| 758 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 759 | dbf->adapter = adapter; |
| 760 | |
| 761 | spin_lock_init(&dbf->hba_lock); |
| 762 | spin_lock_init(&dbf->san_lock); |
| 763 | spin_lock_init(&dbf->scsi_lock); |
| 764 | spin_lock_init(&dbf->rec_lock); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 765 | |
| 766 | /* debug feature area which records recovery activity */ |
Christof Schmitt | b225cf9 | 2008-12-19 16:57:00 +0100 | [diff] [blame] | 767 | sprintf(dbf_name, "zfcp_%s_rec", dev_name(&adapter->ccw_device->dev)); |
Swen Schillig | ae0904f | 2010-12-02 15:16:12 +0100 | [diff] [blame] | 768 | dbf->rec = zfcp_dbf_reg(dbf_name, 3, NULL, sizeof(struct zfcp_dbf_rec)); |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 769 | if (!dbf->rec) |
| 770 | goto err_out; |
Martin Peschke | d79a83d | 2008-03-27 14:22:00 +0100 | [diff] [blame] | 771 | |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 772 | /* debug feature area which records HBA (FSF and QDIO) conditions */ |
Christof Schmitt | b225cf9 | 2008-12-19 16:57:00 +0100 | [diff] [blame] | 773 | sprintf(dbf_name, "zfcp_%s_hba", dev_name(&adapter->ccw_device->dev)); |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 774 | dbf->hba = zfcp_dbf_reg(dbf_name, 3, &zfcp_dbf_hba_view, |
| 775 | sizeof(struct zfcp_dbf_hba_record)); |
| 776 | if (!dbf->hba) |
| 777 | goto err_out; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 778 | |
| 779 | /* debug feature area which records SAN command failures and recovery */ |
Christof Schmitt | b225cf9 | 2008-12-19 16:57:00 +0100 | [diff] [blame] | 780 | sprintf(dbf_name, "zfcp_%s_san", dev_name(&adapter->ccw_device->dev)); |
Swen Schillig | 2c55b75 | 2010-12-02 15:16:13 +0100 | [diff] [blame^] | 781 | dbf->san = zfcp_dbf_reg(dbf_name, 3, NULL, sizeof(struct zfcp_dbf_san)); |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 782 | if (!dbf->san) |
| 783 | goto err_out; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 784 | |
| 785 | /* debug feature area which records SCSI command failures and recovery */ |
Christof Schmitt | b225cf9 | 2008-12-19 16:57:00 +0100 | [diff] [blame] | 786 | sprintf(dbf_name, "zfcp_%s_scsi", dev_name(&adapter->ccw_device->dev)); |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 787 | dbf->scsi = zfcp_dbf_reg(dbf_name, 3, &zfcp_dbf_scsi_view, |
| 788 | sizeof(struct zfcp_dbf_scsi_record)); |
| 789 | if (!dbf->scsi) |
| 790 | goto err_out; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 791 | |
Christof Schmitt | d46f384 | 2009-08-18 15:43:07 +0200 | [diff] [blame] | 792 | adapter->dbf = dbf; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 793 | return 0; |
| 794 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 795 | err_out: |
| 796 | zfcp_dbf_adapter_unregister(dbf); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 797 | return -ENOMEM; |
| 798 | } |
| 799 | |
| 800 | /** |
| 801 | * zfcp_adapter_debug_unregister - unregisters debug feature for an adapter |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 802 | * @dbf: pointer to dbf for which debug features should be unregistered |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 803 | */ |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 804 | void zfcp_dbf_adapter_unregister(struct zfcp_dbf *dbf) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 805 | { |
Swen Schillig | f3450c7 | 2009-11-24 16:53:59 +0100 | [diff] [blame] | 806 | if (!dbf) |
| 807 | return; |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 808 | debug_unregister(dbf->scsi); |
| 809 | debug_unregister(dbf->san); |
| 810 | debug_unregister(dbf->hba); |
| 811 | debug_unregister(dbf->rec); |
| 812 | dbf->adapter->dbf = NULL; |
| 813 | kfree(dbf); |
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 | |