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 | |
Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame^] | 25 | static inline unsigned int zfcp_dbf_plen(unsigned int offset) |
Martin Peschke | c15450e | 2008-03-27 14:21:55 +0100 | [diff] [blame] | 26 | { |
Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame^] | 27 | return sizeof(struct zfcp_dbf_pay) + offset - ZFCP_DBF_PAY_MAX_REC; |
| 28 | } |
Martin Peschke | c15450e | 2008-03-27 14:21:55 +0100 | [diff] [blame] | 29 | |
Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame^] | 30 | static inline |
| 31 | void zfcp_dbf_pl_write(struct zfcp_dbf *dbf, void *data, u16 length, char *area, |
| 32 | u64 req_id) |
| 33 | { |
| 34 | struct zfcp_dbf_pay *pl = &dbf->pay_buf; |
| 35 | u16 offset = 0, rec_length; |
| 36 | |
| 37 | spin_lock(&dbf->pay_lock); |
| 38 | memset(pl, 0, sizeof(*pl)); |
| 39 | pl->fsf_req_id = req_id; |
| 40 | memcpy(pl->area, area, ZFCP_DBF_TAG_LEN); |
| 41 | |
| 42 | while (offset < length) { |
| 43 | rec_length = min((u16) ZFCP_DBF_PAY_MAX_REC, |
| 44 | (u16) (length - offset)); |
| 45 | memcpy(pl->data, data + offset, rec_length); |
| 46 | debug_event(dbf->pay, 1, pl, zfcp_dbf_plen(rec_length)); |
| 47 | |
| 48 | offset += rec_length; |
| 49 | pl->counter++; |
Martin Peschke | c15450e | 2008-03-27 14:21:55 +0100 | [diff] [blame] | 50 | } |
Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame^] | 51 | |
| 52 | spin_unlock(&dbf->pay_lock); |
Martin Peschke | c15450e | 2008-03-27 14:21:55 +0100 | [diff] [blame] | 53 | } |
| 54 | |
Martin Peschke | a9c8577 | 2008-03-31 11:15:27 +0200 | [diff] [blame] | 55 | 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] | 56 | { |
Martin Peschke | a9c8577 | 2008-03-31 11:15:27 +0200 | [diff] [blame] | 57 | int i; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 58 | |
Martin Peschke | a9c8577 | 2008-03-31 11:15:27 +0200 | [diff] [blame] | 59 | *p += sprintf(*p, "%-24s", label); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 60 | for (i = 0; i < ZFCP_DBF_TAG_SIZE; i++) |
Martin Peschke | a9c8577 | 2008-03-31 11:15:27 +0200 | [diff] [blame] | 61 | *p += sprintf(*p, "%c", tag[i]); |
| 62 | *p += sprintf(*p, "\n"); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 63 | } |
| 64 | |
Martin Peschke | 10223c6 | 2008-03-27 14:21:59 +0100 | [diff] [blame] | 65 | static void zfcp_dbf_out(char **buf, const char *s, const char *format, ...) |
| 66 | { |
| 67 | va_list arg; |
| 68 | |
| 69 | *buf += sprintf(*buf, "%-24s", s); |
| 70 | va_start(arg, format); |
| 71 | *buf += vsprintf(*buf, format, arg); |
| 72 | va_end(arg); |
| 73 | *buf += sprintf(*buf, "\n"); |
| 74 | } |
| 75 | |
Martin Peschke | df29f4a | 2008-03-31 11:15:26 +0200 | [diff] [blame] | 76 | static void zfcp_dbf_outd(char **p, const char *label, char *buffer, |
| 77 | int buflen, int offset, int total_size) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 78 | { |
Martin Peschke | df29f4a | 2008-03-31 11:15:26 +0200 | [diff] [blame] | 79 | if (!offset) |
| 80 | *p += sprintf(*p, "%-24s ", label); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 81 | while (buflen--) { |
| 82 | if (offset > 0) { |
| 83 | if ((offset % 32) == 0) |
Martin Peschke | df29f4a | 2008-03-31 11:15:26 +0200 | [diff] [blame] | 84 | *p += sprintf(*p, "\n%-24c ", ' '); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 85 | else if ((offset % 4) == 0) |
Martin Peschke | df29f4a | 2008-03-31 11:15:26 +0200 | [diff] [blame] | 86 | *p += sprintf(*p, " "); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 87 | } |
Martin Peschke | df29f4a | 2008-03-31 11:15:26 +0200 | [diff] [blame] | 88 | *p += sprintf(*p, "%02x", *buffer++); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 89 | if (++offset == total_size) { |
Martin Peschke | df29f4a | 2008-03-31 11:15:26 +0200 | [diff] [blame] | 90 | *p += sprintf(*p, "\n"); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 91 | break; |
| 92 | } |
| 93 | } |
Martin Peschke | df29f4a | 2008-03-31 11:15:26 +0200 | [diff] [blame] | 94 | if (!total_size) |
| 95 | *p += sprintf(*p, "\n"); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 96 | } |
| 97 | |
Martin Peschke | 92c7a83 | 2008-03-31 11:15:30 +0200 | [diff] [blame] | 98 | static int zfcp_dbf_view_header(debug_info_t *id, struct debug_view *view, |
| 99 | int area, debug_entry_t *entry, char *out_buf) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 100 | { |
| 101 | struct zfcp_dbf_dump *dump = (struct zfcp_dbf_dump *)DEBUG_DATA(entry); |
Martin Peschke | 8fc5af1 | 2008-03-31 11:15:23 +0200 | [diff] [blame] | 102 | struct timespec t; |
Martin Peschke | b634fff | 2008-03-31 11:15:24 +0200 | [diff] [blame] | 103 | char *p = out_buf; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 104 | |
| 105 | if (strncmp(dump->tag, "dump", ZFCP_DBF_TAG_SIZE) != 0) { |
Christof Schmitt | b592e89 | 2009-08-18 15:43:31 +0200 | [diff] [blame] | 106 | stck_to_timespec(entry->id.stck, &t); |
Martin Peschke | b634fff | 2008-03-31 11:15:24 +0200 | [diff] [blame] | 107 | zfcp_dbf_out(&p, "timestamp", "%011lu:%06lu", |
| 108 | t.tv_sec, t.tv_nsec); |
| 109 | zfcp_dbf_out(&p, "cpu", "%02i", entry->id.fields.cpuid); |
| 110 | } else { |
Christof Schmitt | d94ce6c | 2008-11-04 16:35:12 +0100 | [diff] [blame] | 111 | zfcp_dbf_outd(&p, "", dump->data, dump->size, dump->offset, |
Martin Peschke | df29f4a | 2008-03-31 11:15:26 +0200 | [diff] [blame] | 112 | dump->total_size); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 113 | if ((dump->offset + dump->size) == dump->total_size) |
Martin Peschke | b634fff | 2008-03-31 11:15:24 +0200 | [diff] [blame] | 114 | p += sprintf(p, "\n"); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 115 | } |
Martin Peschke | b634fff | 2008-03-31 11:15:24 +0200 | [diff] [blame] | 116 | return p - out_buf; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 117 | } |
| 118 | |
Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame^] | 119 | /** |
| 120 | * zfcp_dbf_hba_fsf_res - trace event for fsf responses |
| 121 | * @tag: tag indicating which kind of unsolicited status has been received |
| 122 | * @req: request for which a response was received |
| 123 | */ |
| 124 | void zfcp_dbf_hba_fsf_res(char *tag, struct zfcp_fsf_req *req) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 125 | { |
Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame^] | 126 | struct zfcp_dbf *dbf = req->adapter->dbf; |
| 127 | struct fsf_qtcb_prefix *q_pref = &req->qtcb->prefix; |
| 128 | struct fsf_qtcb_header *q_head = &req->qtcb->header; |
| 129 | struct zfcp_dbf_hba *rec = &dbf->hba_buf; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 130 | unsigned long flags; |
| 131 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 132 | spin_lock_irqsave(&dbf->hba_lock, flags); |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 133 | memset(rec, 0, sizeof(*rec)); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 134 | |
Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame^] | 135 | memcpy(rec->tag, tag, ZFCP_DBF_TAG_LEN); |
| 136 | rec->id = ZFCP_DBF_HBA_RES; |
| 137 | rec->fsf_req_id = req->req_id; |
| 138 | rec->fsf_req_status = req->status; |
| 139 | rec->fsf_cmd = req->fsf_command; |
| 140 | rec->fsf_seq_no = req->seq_no; |
| 141 | rec->u.res.req_issued = req->issued; |
| 142 | rec->u.res.prot_status = q_pref->prot_status; |
| 143 | rec->u.res.fsf_status = q_head->fsf_status; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 144 | |
Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame^] | 145 | memcpy(rec->u.res.prot_status_qual, &q_pref->prot_status_qual, |
| 146 | FSF_PROT_STATUS_QUAL_SIZE); |
| 147 | memcpy(rec->u.res.fsf_status_qual, &q_head->fsf_status_qual, |
| 148 | FSF_STATUS_QUALIFIER_SIZE); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 149 | |
Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame^] | 150 | if (req->fsf_command != FSF_QTCB_FCP_CMND) { |
| 151 | rec->pl_len = q_head->log_length; |
| 152 | zfcp_dbf_pl_write(dbf, (char *)q_pref + q_head->log_start, |
| 153 | rec->pl_len, "fsf_res", req->req_id); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 154 | } |
| 155 | |
Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame^] | 156 | debug_event(dbf->hba, 1, rec, sizeof(*rec)); |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 157 | spin_unlock_irqrestore(&dbf->hba_lock, flags); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 158 | } |
| 159 | |
Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame^] | 160 | /** |
| 161 | * zfcp_dbf_hba_fsf_uss - trace event for an unsolicited status buffer |
| 162 | * @tag: tag indicating which kind of unsolicited status has been received |
| 163 | * @req: request providing the unsolicited status |
| 164 | */ |
| 165 | void zfcp_dbf_hba_fsf_uss(char *tag, struct zfcp_fsf_req *req) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 166 | { |
Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame^] | 167 | struct zfcp_dbf *dbf = req->adapter->dbf; |
| 168 | struct fsf_status_read_buffer *srb = req->data; |
| 169 | struct zfcp_dbf_hba *rec = &dbf->hba_buf; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 170 | unsigned long flags; |
| 171 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 172 | spin_lock_irqsave(&dbf->hba_lock, flags); |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 173 | memset(rec, 0, sizeof(*rec)); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 174 | |
Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame^] | 175 | memcpy(rec->tag, tag, ZFCP_DBF_TAG_LEN); |
| 176 | rec->id = ZFCP_DBF_HBA_USS; |
| 177 | rec->fsf_req_id = req->req_id; |
| 178 | rec->fsf_req_status = req->status; |
| 179 | rec->fsf_cmd = req->fsf_command; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 180 | |
Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame^] | 181 | if (!srb) |
| 182 | goto log; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 183 | |
Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame^] | 184 | rec->u.uss.status_type = srb->status_type; |
| 185 | rec->u.uss.status_subtype = srb->status_subtype; |
| 186 | rec->u.uss.d_id = ntoh24(srb->d_id); |
| 187 | rec->u.uss.lun = srb->fcp_lun; |
| 188 | memcpy(&rec->u.uss.queue_designator, &srb->queue_designator, |
| 189 | sizeof(rec->u.uss.queue_designator)); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 190 | |
Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame^] | 191 | /* status read buffer payload length */ |
| 192 | rec->pl_len = (!srb->length) ? 0 : srb->length - |
| 193 | offsetof(struct fsf_status_read_buffer, payload); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 194 | |
Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame^] | 195 | if (rec->pl_len) |
| 196 | zfcp_dbf_pl_write(dbf, srb->payload.data, rec->pl_len, |
| 197 | "fsf_uss", req->req_id); |
| 198 | log: |
| 199 | debug_event(dbf->hba, 2, rec, sizeof(*rec)); |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 200 | spin_unlock_irqrestore(&dbf->hba_lock, flags); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 201 | } |
| 202 | |
Martin Peschke | bfab163 | 2008-03-31 11:15:31 +0200 | [diff] [blame] | 203 | /** |
Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame^] | 204 | * zfcp_dbf_hba_bit_err - trace event for bit error conditions |
| 205 | * @tag: tag indicating which kind of unsolicited status has been received |
| 206 | * @req: request which caused the bit_error condition |
Martin Peschke | bfab163 | 2008-03-31 11:15:31 +0200 | [diff] [blame] | 207 | */ |
Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame^] | 208 | void zfcp_dbf_hba_bit_err(char *tag, struct zfcp_fsf_req *req) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 209 | { |
Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame^] | 210 | struct zfcp_dbf *dbf = req->adapter->dbf; |
| 211 | struct zfcp_dbf_hba *rec = &dbf->hba_buf; |
Swen Schillig | 5706938 | 2008-10-01 12:42:21 +0200 | [diff] [blame] | 212 | struct fsf_status_read_buffer *sr_buf = req->data; |
Swen Schillig | 5706938 | 2008-10-01 12:42:21 +0200 | [diff] [blame] | 213 | unsigned long flags; |
| 214 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 215 | spin_lock_irqsave(&dbf->hba_lock, flags); |
Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame^] | 216 | memset(rec, 0, sizeof(*rec)); |
| 217 | |
| 218 | memcpy(rec->tag, tag, ZFCP_DBF_TAG_LEN); |
| 219 | rec->id = ZFCP_DBF_HBA_BIT; |
| 220 | rec->fsf_req_id = req->req_id; |
| 221 | rec->fsf_req_status = req->status; |
| 222 | rec->fsf_cmd = req->fsf_command; |
| 223 | memcpy(&rec->u.be, &sr_buf->payload.bit_error, |
| 224 | sizeof(struct fsf_bit_error_payload)); |
| 225 | |
| 226 | debug_event(dbf->hba, 1, rec, sizeof(*rec)); |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 227 | spin_unlock_irqrestore(&dbf->hba_lock, flags); |
Swen Schillig | 5706938 | 2008-10-01 12:42:21 +0200 | [diff] [blame] | 228 | } |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 229 | |
Swen Schillig | ae0904f | 2010-12-02 15:16:12 +0100 | [diff] [blame] | 230 | static void zfcp_dbf_set_common(struct zfcp_dbf_rec *rec, |
| 231 | struct zfcp_adapter *adapter, |
| 232 | struct zfcp_port *port, |
| 233 | struct scsi_device *sdev) |
Martin Peschke | d79a83d | 2008-03-27 14:22:00 +0100 | [diff] [blame] | 234 | { |
Swen Schillig | ae0904f | 2010-12-02 15:16:12 +0100 | [diff] [blame] | 235 | rec->adapter_status = atomic_read(&adapter->status); |
| 236 | if (port) { |
| 237 | rec->port_status = atomic_read(&port->status); |
| 238 | rec->wwpn = port->wwpn; |
| 239 | rec->d_id = port->d_id; |
Martin Peschke | d79a83d | 2008-03-27 14:22:00 +0100 | [diff] [blame] | 240 | } |
Swen Schillig | ae0904f | 2010-12-02 15:16:12 +0100 | [diff] [blame] | 241 | if (sdev) { |
| 242 | rec->lun_status = atomic_read(&sdev_to_zfcp(sdev)->status); |
| 243 | rec->lun = zfcp_scsi_dev_lun(sdev); |
| 244 | } |
Martin Peschke | 348447e | 2008-03-27 14:22:01 +0100 | [diff] [blame] | 245 | } |
| 246 | |
Christof Schmitt | aa0fec6 | 2008-05-19 12:17:47 +0200 | [diff] [blame] | 247 | /** |
Swen Schillig | ae0904f | 2010-12-02 15:16:12 +0100 | [diff] [blame] | 248 | * zfcp_dbf_rec_trig - trace event related to triggered recovery |
| 249 | * @tag: identifier for event |
| 250 | * @adapter: adapter on which the erp_action should run |
| 251 | * @port: remote port involved in the erp_action |
| 252 | * @sdev: scsi device involved in the erp_action |
| 253 | * @want: wanted erp_action |
| 254 | * @need: required erp_action |
| 255 | * |
| 256 | * The adapter->erp_lock has to be held. |
Christof Schmitt | aa0fec6 | 2008-05-19 12:17:47 +0200 | [diff] [blame] | 257 | */ |
Swen Schillig | ae0904f | 2010-12-02 15:16:12 +0100 | [diff] [blame] | 258 | void zfcp_dbf_rec_trig(char *tag, struct zfcp_adapter *adapter, |
| 259 | struct zfcp_port *port, struct scsi_device *sdev, |
| 260 | u8 want, u8 need) |
Martin Peschke | 9467a9b | 2008-03-27 14:22:03 +0100 | [diff] [blame] | 261 | { |
Christof Schmitt | d46f384 | 2009-08-18 15:43:07 +0200 | [diff] [blame] | 262 | struct zfcp_dbf *dbf = adapter->dbf; |
Swen Schillig | ae0904f | 2010-12-02 15:16:12 +0100 | [diff] [blame] | 263 | struct zfcp_dbf_rec *rec = &dbf->rec_buf; |
| 264 | struct list_head *entry; |
Martin Peschke | 9467a9b | 2008-03-27 14:22:03 +0100 | [diff] [blame] | 265 | unsigned long flags; |
| 266 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 267 | spin_lock_irqsave(&dbf->rec_lock, flags); |
Swen Schillig | ae0904f | 2010-12-02 15:16:12 +0100 | [diff] [blame] | 268 | memset(rec, 0, sizeof(*rec)); |
| 269 | |
| 270 | rec->id = ZFCP_DBF_REC_TRIG; |
| 271 | memcpy(rec->tag, tag, ZFCP_DBF_TAG_LEN); |
| 272 | zfcp_dbf_set_common(rec, adapter, port, sdev); |
| 273 | |
| 274 | list_for_each(entry, &adapter->erp_ready_head) |
| 275 | rec->u.trig.ready++; |
| 276 | |
| 277 | list_for_each(entry, &adapter->erp_running_head) |
| 278 | rec->u.trig.running++; |
| 279 | |
| 280 | rec->u.trig.want = want; |
| 281 | rec->u.trig.need = need; |
| 282 | |
| 283 | debug_event(dbf->rec, 1, rec, sizeof(*rec)); |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 284 | spin_unlock_irqrestore(&dbf->rec_lock, flags); |
Martin Peschke | 9467a9b | 2008-03-27 14:22:03 +0100 | [diff] [blame] | 285 | } |
| 286 | |
Swen Schillig | ae0904f | 2010-12-02 15:16:12 +0100 | [diff] [blame] | 287 | |
Martin Peschke | 6f4f365 | 2008-03-27 14:22:04 +0100 | [diff] [blame] | 288 | /** |
Swen Schillig | ae0904f | 2010-12-02 15:16:12 +0100 | [diff] [blame] | 289 | * zfcp_dbf_rec_run - trace event related to running recovery |
| 290 | * @tag: identifier for event |
| 291 | * @erp: erp_action running |
Martin Peschke | 6f4f365 | 2008-03-27 14:22:04 +0100 | [diff] [blame] | 292 | */ |
Swen Schillig | ae0904f | 2010-12-02 15:16:12 +0100 | [diff] [blame] | 293 | void zfcp_dbf_rec_run(char *tag, struct zfcp_erp_action *erp) |
Martin Peschke | 6f4f365 | 2008-03-27 14:22:04 +0100 | [diff] [blame] | 294 | { |
Swen Schillig | ae0904f | 2010-12-02 15:16:12 +0100 | [diff] [blame] | 295 | struct zfcp_dbf *dbf = erp->adapter->dbf; |
| 296 | struct zfcp_dbf_rec *rec = &dbf->rec_buf; |
Martin Peschke | 6f4f365 | 2008-03-27 14:22:04 +0100 | [diff] [blame] | 297 | unsigned long flags; |
| 298 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 299 | spin_lock_irqsave(&dbf->rec_lock, flags); |
Swen Schillig | ae0904f | 2010-12-02 15:16:12 +0100 | [diff] [blame] | 300 | memset(rec, 0, sizeof(*rec)); |
| 301 | |
| 302 | rec->id = ZFCP_DBF_REC_RUN; |
| 303 | memcpy(rec->tag, tag, ZFCP_DBF_TAG_LEN); |
| 304 | zfcp_dbf_set_common(rec, erp->adapter, erp->port, erp->sdev); |
| 305 | |
| 306 | rec->u.run.fsf_req_id = erp->fsf_req_id; |
| 307 | rec->u.run.rec_status = erp->status; |
| 308 | rec->u.run.rec_step = erp->step; |
| 309 | rec->u.run.rec_action = erp->action; |
| 310 | |
| 311 | if (erp->sdev) |
| 312 | rec->u.run.rec_count = |
| 313 | atomic_read(&sdev_to_zfcp(erp->sdev)->erp_counter); |
| 314 | else if (erp->port) |
| 315 | rec->u.run.rec_count = atomic_read(&erp->port->erp_counter); |
| 316 | else |
| 317 | rec->u.run.rec_count = atomic_read(&erp->adapter->erp_counter); |
| 318 | |
| 319 | debug_event(dbf->rec, 1, rec, sizeof(*rec)); |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 320 | spin_unlock_irqrestore(&dbf->rec_lock, flags); |
Martin Peschke | 6f4f365 | 2008-03-27 14:22:04 +0100 | [diff] [blame] | 321 | } |
| 322 | |
Swen Schillig | 2c55b75 | 2010-12-02 15:16:13 +0100 | [diff] [blame] | 323 | static inline |
| 324 | void zfcp_dbf_san(char *tag, struct zfcp_dbf *dbf, void *data, u8 id, u16 len, |
| 325 | u64 req_id, u32 d_id) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 326 | { |
Swen Schillig | 2c55b75 | 2010-12-02 15:16:13 +0100 | [diff] [blame] | 327 | struct zfcp_dbf_san *rec = &dbf->san_buf; |
| 328 | u16 rec_len; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 329 | unsigned long flags; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 330 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 331 | spin_lock_irqsave(&dbf->san_lock, flags); |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 332 | memset(rec, 0, sizeof(*rec)); |
Swen Schillig | 2c55b75 | 2010-12-02 15:16:13 +0100 | [diff] [blame] | 333 | |
| 334 | rec->id = id; |
| 335 | rec->fsf_req_id = req_id; |
| 336 | rec->d_id = d_id; |
| 337 | rec_len = min(len, (u16)ZFCP_DBF_SAN_MAX_PAYLOAD); |
| 338 | memcpy(rec->payload, data, rec_len); |
| 339 | memcpy(rec->tag, tag, ZFCP_DBF_TAG_LEN); |
| 340 | |
| 341 | debug_event(dbf->san, 1, rec, sizeof(*rec)); |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 342 | spin_unlock_irqrestore(&dbf->san_lock, flags); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 343 | } |
| 344 | |
Martin Peschke | bfab163 | 2008-03-31 11:15:31 +0200 | [diff] [blame] | 345 | /** |
Swen Schillig | 2c55b75 | 2010-12-02 15:16:13 +0100 | [diff] [blame] | 346 | * zfcp_dbf_san_req - trace event for issued SAN request |
| 347 | * @tag: indentifier for event |
| 348 | * @fsf_req: request containing issued CT data |
| 349 | * d_id: destination ID |
Martin Peschke | bfab163 | 2008-03-31 11:15:31 +0200 | [diff] [blame] | 350 | */ |
Swen Schillig | 2c55b75 | 2010-12-02 15:16:13 +0100 | [diff] [blame] | 351 | 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] | 352 | { |
Swen Schillig | 2c55b75 | 2010-12-02 15:16:13 +0100 | [diff] [blame] | 353 | struct zfcp_dbf *dbf = fsf->adapter->dbf; |
| 354 | struct zfcp_fsf_ct_els *ct_els = fsf->data; |
| 355 | u16 length; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 356 | |
Swen Schillig | 2c55b75 | 2010-12-02 15:16:13 +0100 | [diff] [blame] | 357 | length = (u16)(ct_els->req->length + FC_CT_HDR_LEN); |
| 358 | zfcp_dbf_san(tag, dbf, sg_virt(ct_els->req), ZFCP_DBF_SAN_REQ, length, |
| 359 | fsf->req_id, d_id); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 360 | } |
| 361 | |
Martin Peschke | bfab163 | 2008-03-31 11:15:31 +0200 | [diff] [blame] | 362 | /** |
Swen Schillig | 2c55b75 | 2010-12-02 15:16:13 +0100 | [diff] [blame] | 363 | * zfcp_dbf_san_res - trace event for received SAN request |
| 364 | * @tag: indentifier for event |
| 365 | * @fsf_req: request containing issued CT data |
Martin Peschke | bfab163 | 2008-03-31 11:15:31 +0200 | [diff] [blame] | 366 | */ |
Swen Schillig | 2c55b75 | 2010-12-02 15:16:13 +0100 | [diff] [blame] | 367 | void zfcp_dbf_san_res(char *tag, struct zfcp_fsf_req *fsf) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 368 | { |
Swen Schillig | 2c55b75 | 2010-12-02 15:16:13 +0100 | [diff] [blame] | 369 | struct zfcp_dbf *dbf = fsf->adapter->dbf; |
| 370 | struct zfcp_fsf_ct_els *ct_els = fsf->data; |
| 371 | u16 length; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 372 | |
Swen Schillig | 2c55b75 | 2010-12-02 15:16:13 +0100 | [diff] [blame] | 373 | length = (u16)(ct_els->resp->length + FC_CT_HDR_LEN); |
| 374 | zfcp_dbf_san(tag, dbf, sg_virt(ct_els->resp), ZFCP_DBF_SAN_RES, length, |
| 375 | fsf->req_id, 0); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 376 | } |
| 377 | |
Martin Peschke | bfab163 | 2008-03-31 11:15:31 +0200 | [diff] [blame] | 378 | /** |
Swen Schillig | 2c55b75 | 2010-12-02 15:16:13 +0100 | [diff] [blame] | 379 | * zfcp_dbf_san_in_els - trace event for incoming ELS |
| 380 | * @tag: indentifier for event |
| 381 | * @fsf_req: request containing issued CT data |
Martin Peschke | bfab163 | 2008-03-31 11:15:31 +0200 | [diff] [blame] | 382 | */ |
Swen Schillig | 2c55b75 | 2010-12-02 15:16:13 +0100 | [diff] [blame] | 383 | 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] | 384 | { |
Swen Schillig | 2c55b75 | 2010-12-02 15:16:13 +0100 | [diff] [blame] | 385 | struct zfcp_dbf *dbf = fsf->adapter->dbf; |
| 386 | struct fsf_status_read_buffer *srb = |
| 387 | (struct fsf_status_read_buffer *) fsf->data; |
| 388 | u16 length; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 389 | |
Swen Schillig | 2c55b75 | 2010-12-02 15:16:13 +0100 | [diff] [blame] | 390 | length = (u16)(srb->length - |
| 391 | offsetof(struct fsf_status_read_buffer, payload)); |
| 392 | zfcp_dbf_san(tag, dbf, srb->payload.data, ZFCP_DBF_SAN_ELS, length, |
| 393 | fsf->req_id, ntoh24(srb->d_id)); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 394 | } |
| 395 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 396 | void _zfcp_dbf_scsi(const char *tag, const char *tag2, int level, |
| 397 | struct zfcp_dbf *dbf, struct scsi_cmnd *scsi_cmnd, |
| 398 | struct zfcp_fsf_req *fsf_req, unsigned long old_req_id) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 399 | { |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 400 | struct zfcp_dbf_scsi_record *rec = &dbf->scsi_buf; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 401 | struct zfcp_dbf_dump *dump = (struct zfcp_dbf_dump *)rec; |
| 402 | unsigned long flags; |
Christof Schmitt | 4318e08 | 2009-11-24 16:54:08 +0100 | [diff] [blame] | 403 | struct fcp_resp_with_ext *fcp_rsp; |
| 404 | struct fcp_resp_rsp_info *fcp_rsp_info = NULL; |
| 405 | char *fcp_sns_info = NULL; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 406 | int offset = 0, buflen = 0; |
| 407 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 408 | spin_lock_irqsave(&dbf->scsi_lock, flags); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 409 | do { |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 410 | memset(rec, 0, sizeof(*rec)); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 411 | if (offset == 0) { |
| 412 | strncpy(rec->tag, tag, ZFCP_DBF_TAG_SIZE); |
| 413 | strncpy(rec->tag2, tag2, ZFCP_DBF_TAG_SIZE); |
Maxim Shchetynin | ed829ad | 2006-02-11 01:42:58 +0100 | [diff] [blame] | 414 | if (scsi_cmnd != NULL) { |
| 415 | if (scsi_cmnd->device) { |
| 416 | rec->scsi_id = scsi_cmnd->device->id; |
| 417 | rec->scsi_lun = scsi_cmnd->device->lun; |
| 418 | } |
| 419 | rec->scsi_result = scsi_cmnd->result; |
| 420 | rec->scsi_cmnd = (unsigned long)scsi_cmnd; |
Boaz Harrosh | 64a87b2 | 2008-04-30 11:19:47 +0300 | [diff] [blame] | 421 | memcpy(rec->scsi_opcode, scsi_cmnd->cmnd, |
Maxim Shchetynin | ed829ad | 2006-02-11 01:42:58 +0100 | [diff] [blame] | 422 | min((int)scsi_cmnd->cmd_len, |
| 423 | ZFCP_DBF_SCSI_OPCODE)); |
| 424 | rec->scsi_retries = scsi_cmnd->retries; |
| 425 | rec->scsi_allowed = scsi_cmnd->allowed; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 426 | } |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 427 | if (fsf_req != NULL) { |
Christof Schmitt | 4318e08 | 2009-11-24 16:54:08 +0100 | [diff] [blame] | 428 | fcp_rsp = (struct fcp_resp_with_ext *) |
| 429 | &(fsf_req->qtcb->bottom.io.fcp_rsp); |
| 430 | fcp_rsp_info = (struct fcp_resp_rsp_info *) |
| 431 | &fcp_rsp[1]; |
| 432 | fcp_sns_info = (char *) &fcp_rsp[1]; |
| 433 | if (fcp_rsp->resp.fr_flags & FCP_RSP_LEN_VAL) |
| 434 | fcp_sns_info += fcp_rsp->ext.fr_sns_len; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 435 | |
Christof Schmitt | 4318e08 | 2009-11-24 16:54:08 +0100 | [diff] [blame] | 436 | rec->rsp_validity = fcp_rsp->resp.fr_flags; |
| 437 | rec->rsp_scsi_status = fcp_rsp->resp.fr_status; |
| 438 | rec->rsp_resid = fcp_rsp->ext.fr_resid; |
| 439 | if (fcp_rsp->resp.fr_flags & FCP_RSP_LEN_VAL) |
| 440 | rec->rsp_code = fcp_rsp_info->rsp_code; |
| 441 | if (fcp_rsp->resp.fr_flags & FCP_SNS_LEN_VAL) { |
| 442 | buflen = min(fcp_rsp->ext.fr_sns_len, |
| 443 | (u32)ZFCP_DBF_SCSI_MAX_FCP_SNS_INFO); |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 444 | rec->sns_info_len = buflen; |
| 445 | memcpy(rec->sns_info, fcp_sns_info, |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 446 | min(buflen, |
| 447 | ZFCP_DBF_SCSI_FCP_SNS_INFO)); |
| 448 | offset += min(buflen, |
| 449 | ZFCP_DBF_SCSI_FCP_SNS_INFO); |
| 450 | } |
| 451 | |
Christof Schmitt | f0216ae | 2009-05-15 13:18:14 +0200 | [diff] [blame] | 452 | rec->fsf_reqid = fsf_req->req_id; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 453 | rec->fsf_seqno = fsf_req->seq_no; |
| 454 | rec->fsf_issued = fsf_req->issued; |
| 455 | } |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 456 | rec->old_fsf_reqid = old_req_id; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 457 | } else { |
| 458 | strncpy(dump->tag, "dump", ZFCP_DBF_TAG_SIZE); |
| 459 | dump->total_size = buflen; |
| 460 | dump->offset = offset; |
| 461 | dump->size = min(buflen - offset, |
| 462 | (int)sizeof(struct |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 463 | zfcp_dbf_scsi_record) - |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 464 | (int)sizeof(struct zfcp_dbf_dump)); |
| 465 | memcpy(dump->data, fcp_sns_info + offset, dump->size); |
| 466 | offset += dump->size; |
| 467 | } |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 468 | debug_event(dbf->scsi, level, rec, sizeof(*rec)); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 469 | } while (offset < buflen); |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 470 | spin_unlock_irqrestore(&dbf->scsi_lock, flags); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 471 | } |
| 472 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 473 | 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] | 474 | char *out_buf, const char *in_buf) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 475 | { |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 476 | 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] | 477 | struct timespec t; |
Martin Peschke | b634fff | 2008-03-31 11:15:24 +0200 | [diff] [blame] | 478 | char *p = out_buf; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 479 | |
Martin Peschke | b634fff | 2008-03-31 11:15:24 +0200 | [diff] [blame] | 480 | if (strncmp(r->tag, "dump", ZFCP_DBF_TAG_SIZE) == 0) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 481 | return 0; |
| 482 | |
Martin Peschke | a9c8577 | 2008-03-31 11:15:27 +0200 | [diff] [blame] | 483 | zfcp_dbf_tag(&p, "tag", r->tag); |
| 484 | zfcp_dbf_tag(&p, "tag2", r->tag2); |
Martin Peschke | b634fff | 2008-03-31 11:15:24 +0200 | [diff] [blame] | 485 | zfcp_dbf_out(&p, "scsi_id", "0x%08x", r->scsi_id); |
| 486 | zfcp_dbf_out(&p, "scsi_lun", "0x%08x", r->scsi_lun); |
| 487 | zfcp_dbf_out(&p, "scsi_result", "0x%08x", r->scsi_result); |
| 488 | zfcp_dbf_out(&p, "scsi_cmnd", "0x%0Lx", r->scsi_cmnd); |
Martin Peschke | df29f4a | 2008-03-31 11:15:26 +0200 | [diff] [blame] | 489 | zfcp_dbf_outd(&p, "scsi_opcode", r->scsi_opcode, ZFCP_DBF_SCSI_OPCODE, |
| 490 | 0, ZFCP_DBF_SCSI_OPCODE); |
Martin Peschke | b634fff | 2008-03-31 11:15:24 +0200 | [diff] [blame] | 491 | zfcp_dbf_out(&p, "scsi_retries", "0x%02x", r->scsi_retries); |
| 492 | zfcp_dbf_out(&p, "scsi_allowed", "0x%02x", r->scsi_allowed); |
| 493 | if (strncmp(r->tag, "abrt", ZFCP_DBF_TAG_SIZE) == 0) |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 494 | 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] | 495 | zfcp_dbf_out(&p, "fsf_reqid", "0x%0Lx", r->fsf_reqid); |
| 496 | zfcp_dbf_out(&p, "fsf_seqno", "0x%08x", r->fsf_seqno); |
Christof Schmitt | b592e89 | 2009-08-18 15:43:31 +0200 | [diff] [blame] | 497 | stck_to_timespec(r->fsf_issued, &t); |
Martin Peschke | b634fff | 2008-03-31 11:15:24 +0200 | [diff] [blame] | 498 | 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] | 499 | |
Martin Peschke | b634fff | 2008-03-31 11:15:24 +0200 | [diff] [blame] | 500 | if (strncmp(r->tag, "rslt", ZFCP_DBF_TAG_SIZE) == 0) { |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 501 | zfcp_dbf_out(&p, "fcp_rsp_validity", "0x%02x", r->rsp_validity); |
| 502 | zfcp_dbf_out(&p, "fcp_rsp_scsi_status", "0x%02x", |
| 503 | r->rsp_scsi_status); |
| 504 | zfcp_dbf_out(&p, "fcp_rsp_resid", "0x%08x", r->rsp_resid); |
| 505 | zfcp_dbf_out(&p, "fcp_rsp_code", "0x%08x", r->rsp_code); |
| 506 | zfcp_dbf_out(&p, "fcp_sns_info_len", "0x%08x", r->sns_info_len); |
| 507 | zfcp_dbf_outd(&p, "fcp_sns_info", r->sns_info, |
| 508 | min((int)r->sns_info_len, |
Martin Peschke | df29f4a | 2008-03-31 11:15:26 +0200 | [diff] [blame] | 509 | ZFCP_DBF_SCSI_FCP_SNS_INFO), 0, |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 510 | r->sns_info_len); |
Martin Peschke | b634fff | 2008-03-31 11:15:24 +0200 | [diff] [blame] | 511 | } |
| 512 | p += sprintf(p, "\n"); |
| 513 | return p - out_buf; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 514 | } |
| 515 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 516 | static struct debug_view zfcp_dbf_scsi_view = { |
| 517 | .name = "structured", |
| 518 | .header_proc = zfcp_dbf_view_header, |
| 519 | .format_proc = zfcp_dbf_scsi_view_format, |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 520 | }; |
| 521 | |
Christof Schmitt | d46f384 | 2009-08-18 15:43:07 +0200 | [diff] [blame] | 522 | static debug_info_t *zfcp_dbf_reg(const char *name, int level, |
| 523 | struct debug_view *view, int size) |
| 524 | { |
| 525 | struct debug_info *d; |
| 526 | |
| 527 | d = debug_register(name, dbfsize, level, size); |
| 528 | if (!d) |
| 529 | return NULL; |
| 530 | |
| 531 | debug_register_view(d, &debug_hex_ascii_view); |
| 532 | debug_register_view(d, view); |
| 533 | debug_set_level(d, level); |
| 534 | |
| 535 | return d; |
| 536 | } |
| 537 | |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 538 | /** |
| 539 | * zfcp_adapter_debug_register - registers debug feature for an adapter |
| 540 | * @adapter: pointer to adapter for which debug features should be registered |
| 541 | * return: -ENOMEM on error, 0 otherwise |
| 542 | */ |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 543 | int zfcp_dbf_adapter_register(struct zfcp_adapter *adapter) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 544 | { |
| 545 | char dbf_name[DEBUG_MAX_NAME_LEN]; |
Christof Schmitt | d46f384 | 2009-08-18 15:43:07 +0200 | [diff] [blame] | 546 | struct zfcp_dbf *dbf; |
| 547 | |
Swen Schillig | d23948e | 2010-07-16 15:37:40 +0200 | [diff] [blame] | 548 | dbf = kzalloc(sizeof(struct zfcp_dbf), GFP_KERNEL); |
Christof Schmitt | d46f384 | 2009-08-18 15:43:07 +0200 | [diff] [blame] | 549 | if (!dbf) |
| 550 | return -ENOMEM; |
| 551 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 552 | dbf->adapter = adapter; |
| 553 | |
Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame^] | 554 | spin_lock_init(&dbf->pay_lock); |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 555 | spin_lock_init(&dbf->hba_lock); |
| 556 | spin_lock_init(&dbf->san_lock); |
| 557 | spin_lock_init(&dbf->scsi_lock); |
| 558 | spin_lock_init(&dbf->rec_lock); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 559 | |
| 560 | /* debug feature area which records recovery activity */ |
Christof Schmitt | b225cf9 | 2008-12-19 16:57:00 +0100 | [diff] [blame] | 561 | sprintf(dbf_name, "zfcp_%s_rec", dev_name(&adapter->ccw_device->dev)); |
Swen Schillig | ae0904f | 2010-12-02 15:16:12 +0100 | [diff] [blame] | 562 | 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] | 563 | if (!dbf->rec) |
| 564 | goto err_out; |
Martin Peschke | d79a83d | 2008-03-27 14:22:00 +0100 | [diff] [blame] | 565 | |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 566 | /* debug feature area which records HBA (FSF and QDIO) conditions */ |
Christof Schmitt | b225cf9 | 2008-12-19 16:57:00 +0100 | [diff] [blame] | 567 | sprintf(dbf_name, "zfcp_%s_hba", dev_name(&adapter->ccw_device->dev)); |
Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame^] | 568 | dbf->hba = zfcp_dbf_reg(dbf_name, 3, NULL, sizeof(struct zfcp_dbf_hba)); |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 569 | if (!dbf->hba) |
| 570 | goto err_out; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 571 | |
Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame^] | 572 | /* debug feature area which records payload info */ |
| 573 | sprintf(dbf_name, "zfcp_%s_pay", dev_name(&adapter->ccw_device->dev)); |
| 574 | dbf->pay = zfcp_dbf_reg(dbf_name, 3, NULL, |
| 575 | sizeof(struct zfcp_dbf_pay)); |
| 576 | if (!dbf->pay) |
| 577 | goto err_out; |
| 578 | |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 579 | /* debug feature area which records SAN command failures and recovery */ |
Christof Schmitt | b225cf9 | 2008-12-19 16:57:00 +0100 | [diff] [blame] | 580 | sprintf(dbf_name, "zfcp_%s_san", dev_name(&adapter->ccw_device->dev)); |
Swen Schillig | 2c55b75 | 2010-12-02 15:16:13 +0100 | [diff] [blame] | 581 | 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] | 582 | if (!dbf->san) |
| 583 | goto err_out; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 584 | |
| 585 | /* debug feature area which records SCSI command failures and recovery */ |
Christof Schmitt | b225cf9 | 2008-12-19 16:57:00 +0100 | [diff] [blame] | 586 | sprintf(dbf_name, "zfcp_%s_scsi", dev_name(&adapter->ccw_device->dev)); |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 587 | dbf->scsi = zfcp_dbf_reg(dbf_name, 3, &zfcp_dbf_scsi_view, |
| 588 | sizeof(struct zfcp_dbf_scsi_record)); |
| 589 | if (!dbf->scsi) |
| 590 | goto err_out; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 591 | |
Christof Schmitt | d46f384 | 2009-08-18 15:43:07 +0200 | [diff] [blame] | 592 | adapter->dbf = dbf; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 593 | return 0; |
| 594 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 595 | err_out: |
| 596 | zfcp_dbf_adapter_unregister(dbf); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 597 | return -ENOMEM; |
| 598 | } |
| 599 | |
| 600 | /** |
| 601 | * zfcp_adapter_debug_unregister - unregisters debug feature for an adapter |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 602 | * @dbf: pointer to dbf for which debug features should be unregistered |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 603 | */ |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 604 | void zfcp_dbf_adapter_unregister(struct zfcp_dbf *dbf) |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 605 | { |
Swen Schillig | f3450c7 | 2009-11-24 16:53:59 +0100 | [diff] [blame] | 606 | if (!dbf) |
| 607 | return; |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 608 | debug_unregister(dbf->scsi); |
| 609 | debug_unregister(dbf->san); |
| 610 | debug_unregister(dbf->hba); |
Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame^] | 611 | debug_unregister(dbf->pay); |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 612 | debug_unregister(dbf->rec); |
| 613 | dbf->adapter->dbf = NULL; |
| 614 | kfree(dbf); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 615 | } |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 616 | |