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