2 * This file is part of the zfcp device driver for
3 * FCP adapters for IBM System z9 and zSeries.
5 * Copyright IBM Corp. 2008, 2009
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 #include <scsi/fc/fc_fcp.h>
30 #define ZFCP_DBF_TAG_LEN 7
31 #define ZFCP_DBF_TAG_SIZE 4
32 #define ZFCP_DBF_ID_SIZE 7
34 #define ZFCP_DBF_INVALID_LUN 0xFFFFFFFFFFFFFFFFull
36 struct zfcp_dbf_dump {
37 u8 tag[ZFCP_DBF_TAG_SIZE];
38 u32 total_size; /* size of total dump data */
39 u32 offset; /* how much data has being already dumped */
40 u32 size; /* how much data comes with this record */
41 u8 data[]; /* dump data */
42 } __attribute__ ((packed));
45 * struct zfcp_dbf_rec_trigger - trace record for triggered recovery action
46 * @ready: number of ready recovery actions
47 * @running: number of running recovery actions
48 * @want: wanted recovery action
49 * @need: needed recovery action
51 struct zfcp_dbf_rec_trigger {
59 * struct zfcp_dbf_rec_running - trace record for running recovery
60 * @fsf_req_id: request id for fsf requests
61 * @rec_status: status of the fsf request
62 * @rec_step: current step of the recovery action
63 * rec_count: recovery counter
65 struct zfcp_dbf_rec_running {
74 * enum zfcp_dbf_rec_id - recovery trace record id
75 * @ZFCP_DBF_REC_TRIG: triggered recovery identifier
76 * @ZFCP_DBF_REC_RUN: running recovery identifier
78 enum zfcp_dbf_rec_id {
79 ZFCP_DBF_REC_TRIG = 1,
84 * struct zfcp_dbf_rec - trace record for error recovery actions
85 * @id: unique number of recovery record type
86 * @tag: identifier string specifying the location of initiation
87 * @lun: logical unit number
88 * @wwpn: word wide port number
89 * @d_id: destination ID
90 * @adapter_status: current status of the adapter
91 * @port_status: current status of the port
92 * @lun_status: current status of the lun
93 * @u.trig: structure zfcp_dbf_rec_trigger
94 * @u.run: structure zfcp_dbf_rec_running
98 char tag[ZFCP_DBF_TAG_LEN];
106 struct zfcp_dbf_rec_trigger trig;
107 struct zfcp_dbf_rec_running run;
111 struct zfcp_dbf_hba_record_response {
118 u8 fsf_prot_status_qual[FSF_PROT_STATUS_QUAL_SIZE];
119 u8 fsf_status_qual[FSF_STATUS_QUALIFIER_SIZE];
146 } __attribute__ ((packed));
148 struct zfcp_dbf_hba_record_status {
152 struct fsf_queue_designator
155 #define ZFCP_DBF_UNSOL_PAYLOAD 80
156 #define ZFCP_DBF_UNSOL_PAYLOAD_SENSE_DATA_AVAIL 32
157 #define ZFCP_DBF_UNSOL_PAYLOAD_BIT_ERROR_THRESHOLD 56
158 #define ZFCP_DBF_UNSOL_PAYLOAD_FEATURE_UPDATE_ALERT 2 * sizeof(u32)
159 u8 payload[ZFCP_DBF_UNSOL_PAYLOAD];
160 } __attribute__ ((packed));
162 struct zfcp_dbf_hba_record_qdio {
166 } __attribute__ ((packed));
168 struct zfcp_dbf_hba_record {
169 u8 tag[ZFCP_DBF_TAG_SIZE];
170 u8 tag2[ZFCP_DBF_TAG_SIZE];
172 struct zfcp_dbf_hba_record_response response;
173 struct zfcp_dbf_hba_record_status status;
174 struct zfcp_dbf_hba_record_qdio qdio;
175 struct fsf_bit_error_payload berr;
177 } __attribute__ ((packed));
179 struct zfcp_dbf_san_record_ct_request {
188 } __attribute__ ((packed));
190 struct zfcp_dbf_san_record_ct_response {
198 } __attribute__ ((packed));
200 struct zfcp_dbf_san_record_els {
202 } __attribute__ ((packed));
204 struct zfcp_dbf_san_record {
205 u8 tag[ZFCP_DBF_TAG_SIZE];
209 struct zfcp_dbf_san_record_ct_request ct_req;
210 struct zfcp_dbf_san_record_ct_response ct_resp;
211 struct zfcp_dbf_san_record_els els;
213 } __attribute__ ((packed));
215 #define ZFCP_DBF_SAN_MAX_PAYLOAD 1024
217 struct zfcp_dbf_scsi_record {
218 u8 tag[ZFCP_DBF_TAG_SIZE];
219 u8 tag2[ZFCP_DBF_TAG_SIZE];
224 #define ZFCP_DBF_SCSI_OPCODE 16
225 u8 scsi_opcode[ZFCP_DBF_SCSI_OPCODE];
236 #define ZFCP_DBF_SCSI_FCP_SNS_INFO 16
237 #define ZFCP_DBF_SCSI_MAX_FCP_SNS_INFO 256
239 u8 sns_info[ZFCP_DBF_SCSI_FCP_SNS_INFO];
240 } __attribute__ ((packed));
250 spinlock_t scsi_lock;
251 struct zfcp_dbf_rec rec_buf;
252 struct zfcp_dbf_hba_record hba_buf;
253 struct zfcp_dbf_san_record san_buf;
254 struct zfcp_dbf_scsi_record scsi_buf;
255 struct zfcp_adapter *adapter;
259 void zfcp_dbf_hba_fsf_resp(const char *tag2, int level,
260 struct zfcp_fsf_req *req, struct zfcp_dbf *dbf)
262 if (level <= dbf->hba->level)
263 _zfcp_dbf_hba_fsf_response(tag2, level, req, dbf);
267 * zfcp_dbf_hba_fsf_response - trace event for request completion
268 * @fsf_req: request that has been completed
270 static inline void zfcp_dbf_hba_fsf_response(struct zfcp_fsf_req *req)
272 struct zfcp_dbf *dbf = req->adapter->dbf;
273 struct fsf_qtcb *qtcb = req->qtcb;
275 if ((qtcb->prefix.prot_status != FSF_PROT_GOOD) &&
276 (qtcb->prefix.prot_status != FSF_PROT_FSF_STATUS_PRESENTED)) {
277 zfcp_dbf_hba_fsf_resp("perr", 1, req, dbf);
279 } else if (qtcb->header.fsf_status != FSF_GOOD) {
280 zfcp_dbf_hba_fsf_resp("ferr", 1, req, dbf);
282 } else if ((req->fsf_command == FSF_QTCB_OPEN_PORT_WITH_DID) ||
283 (req->fsf_command == FSF_QTCB_OPEN_LUN)) {
284 zfcp_dbf_hba_fsf_resp("open", 4, req, dbf);
286 } else if (qtcb->header.log_length) {
287 zfcp_dbf_hba_fsf_resp("qtcb", 5, req, dbf);
290 zfcp_dbf_hba_fsf_resp("norm", 6, req, dbf);
295 * zfcp_dbf_hba_fsf_unsol - trace event for an unsolicited status buffer
296 * @tag: tag indicating which kind of unsolicited status has been received
297 * @dbf: reference to dbf structure
298 * @status_buffer: buffer containing payload of unsolicited status
301 void zfcp_dbf_hba_fsf_unsol(const char *tag, struct zfcp_dbf *dbf,
302 struct fsf_status_read_buffer *buf)
306 if (level <= dbf->hba->level)
307 _zfcp_dbf_hba_fsf_unsol(tag, level, dbf, buf);
311 void zfcp_dbf_scsi(const char *tag, const char *tag2, int level,
312 struct zfcp_dbf *dbf, struct scsi_cmnd *scmd,
313 struct zfcp_fsf_req *req, unsigned long old_id)
315 if (level <= dbf->scsi->level)
316 _zfcp_dbf_scsi(tag, tag2, level, dbf, scmd, req, old_id);
320 * zfcp_dbf_scsi_result - trace event for SCSI command completion
321 * @dbf: adapter dbf trace
322 * @scmd: SCSI command pointer
323 * @req: FSF request used to issue SCSI command
326 void zfcp_dbf_scsi_result(struct zfcp_dbf *dbf, struct scsi_cmnd *scmd,
327 struct zfcp_fsf_req *req)
329 if (scmd->result != 0)
330 zfcp_dbf_scsi("rslt", "erro", 3, dbf, scmd, req, 0);
331 else if (scmd->retries > 0)
332 zfcp_dbf_scsi("rslt", "retr", 4, dbf, scmd, req, 0);
334 zfcp_dbf_scsi("rslt", "norm", 6, dbf, scmd, req, 0);
338 * zfcp_dbf_scsi_fail_send - trace event for failure to send SCSI command
339 * @dbf: adapter dbf trace
340 * @scmd: SCSI command pointer
343 void zfcp_dbf_scsi_fail_send(struct zfcp_dbf *dbf, struct scsi_cmnd *scmd)
345 zfcp_dbf_scsi("rslt", "fail", 4, dbf, scmd, NULL, 0);
349 * zfcp_dbf_scsi_abort - trace event for SCSI command abort
350 * @tag: tag indicating success or failure of abort operation
351 * @adapter: adapter thas has been used to issue SCSI command to be aborted
352 * @scmd: SCSI command to be aborted
353 * @new_req: request containing abort (might be NULL)
354 * @old_id: identifier of request containg SCSI command to be aborted
357 void zfcp_dbf_scsi_abort(const char *tag, struct zfcp_dbf *dbf,
358 struct scsi_cmnd *scmd, struct zfcp_fsf_req *new_req,
359 unsigned long old_id)
361 zfcp_dbf_scsi("abrt", tag, 1, dbf, scmd, new_req, old_id);
365 * zfcp_dbf_scsi_devreset - trace event for Logical Unit or Target Reset
366 * @tag: tag indicating success or failure of reset operation
367 * @scmnd: SCSI command which caused this error recovery
368 * @flag: indicates type of reset (Target Reset, Logical Unit Reset)
371 void zfcp_dbf_scsi_devreset(const char *tag, struct scsi_cmnd *scmnd, u8 flag)
373 struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(scmnd->device);
375 zfcp_dbf_scsi(flag == FCP_TMF_TGT_RESET ? "trst" : "lrst", tag, 1,
376 zfcp_sdev->port->adapter->dbf, scmnd, NULL, 0);
379 #endif /* ZFCP_DBF_H */