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_SIZE 4
31 #define ZFCP_DBF_ID_SIZE 7
33 #define ZFCP_DBF_INVALID_LUN 0xFFFFFFFFFFFFFFFFull
35 struct zfcp_dbf_dump {
36 u8 tag[ZFCP_DBF_TAG_SIZE];
37 u32 total_size; /* size of total dump data */
38 u32 offset; /* how much data has being already dumped */
39 u32 size; /* how much data comes with this record */
40 u8 data[]; /* dump data */
41 } __attribute__ ((packed));
43 struct zfcp_dbf_rec_record_thread {
49 struct zfcp_dbf_rec_record_target {
58 struct zfcp_dbf_rec_record_trigger {
70 struct zfcp_dbf_rec_record_action {
77 struct zfcp_dbf_rec_record {
81 struct zfcp_dbf_rec_record_action action;
82 struct zfcp_dbf_rec_record_thread thread;
83 struct zfcp_dbf_rec_record_target target;
84 struct zfcp_dbf_rec_record_trigger trigger;
89 ZFCP_REC_DBF_ID_ACTION,
90 ZFCP_REC_DBF_ID_THREAD,
91 ZFCP_REC_DBF_ID_TARGET,
92 ZFCP_REC_DBF_ID_TRIGGER,
95 struct zfcp_dbf_hba_record_response {
102 u8 fsf_prot_status_qual[FSF_PROT_STATUS_QUAL_SIZE];
103 u8 fsf_status_qual[FSF_STATUS_QUALIFIER_SIZE];
130 } __attribute__ ((packed));
132 struct zfcp_dbf_hba_record_status {
136 struct fsf_queue_designator
139 #define ZFCP_DBF_UNSOL_PAYLOAD 80
140 #define ZFCP_DBF_UNSOL_PAYLOAD_SENSE_DATA_AVAIL 32
141 #define ZFCP_DBF_UNSOL_PAYLOAD_BIT_ERROR_THRESHOLD 56
142 #define ZFCP_DBF_UNSOL_PAYLOAD_FEATURE_UPDATE_ALERT 2 * sizeof(u32)
143 u8 payload[ZFCP_DBF_UNSOL_PAYLOAD];
144 } __attribute__ ((packed));
146 struct zfcp_dbf_hba_record_qdio {
150 } __attribute__ ((packed));
152 struct zfcp_dbf_hba_record {
153 u8 tag[ZFCP_DBF_TAG_SIZE];
154 u8 tag2[ZFCP_DBF_TAG_SIZE];
156 struct zfcp_dbf_hba_record_response response;
157 struct zfcp_dbf_hba_record_status status;
158 struct zfcp_dbf_hba_record_qdio qdio;
159 struct fsf_bit_error_payload berr;
161 } __attribute__ ((packed));
163 struct zfcp_dbf_san_record_ct_request {
172 } __attribute__ ((packed));
174 struct zfcp_dbf_san_record_ct_response {
182 } __attribute__ ((packed));
184 struct zfcp_dbf_san_record_els {
186 } __attribute__ ((packed));
188 struct zfcp_dbf_san_record {
189 u8 tag[ZFCP_DBF_TAG_SIZE];
193 struct zfcp_dbf_san_record_ct_request ct_req;
194 struct zfcp_dbf_san_record_ct_response ct_resp;
195 struct zfcp_dbf_san_record_els els;
197 } __attribute__ ((packed));
199 #define ZFCP_DBF_SAN_MAX_PAYLOAD 1024
201 struct zfcp_dbf_scsi_record {
202 u8 tag[ZFCP_DBF_TAG_SIZE];
203 u8 tag2[ZFCP_DBF_TAG_SIZE];
208 #define ZFCP_DBF_SCSI_OPCODE 16
209 u8 scsi_opcode[ZFCP_DBF_SCSI_OPCODE];
220 #define ZFCP_DBF_SCSI_FCP_SNS_INFO 16
221 #define ZFCP_DBF_SCSI_MAX_FCP_SNS_INFO 256
223 u8 sns_info[ZFCP_DBF_SCSI_FCP_SNS_INFO];
224 } __attribute__ ((packed));
234 spinlock_t scsi_lock;
235 struct zfcp_dbf_rec_record rec_buf;
236 struct zfcp_dbf_hba_record hba_buf;
237 struct zfcp_dbf_san_record san_buf;
238 struct zfcp_dbf_scsi_record scsi_buf;
239 struct zfcp_adapter *adapter;
243 void zfcp_dbf_hba_fsf_resp(const char *tag2, int level,
244 struct zfcp_fsf_req *req, struct zfcp_dbf *dbf)
246 if (level <= dbf->hba->level)
247 _zfcp_dbf_hba_fsf_response(tag2, level, req, dbf);
251 * zfcp_dbf_hba_fsf_response - trace event for request completion
252 * @fsf_req: request that has been completed
254 static inline void zfcp_dbf_hba_fsf_response(struct zfcp_fsf_req *req)
256 struct zfcp_dbf *dbf = req->adapter->dbf;
257 struct fsf_qtcb *qtcb = req->qtcb;
259 if ((qtcb->prefix.prot_status != FSF_PROT_GOOD) &&
260 (qtcb->prefix.prot_status != FSF_PROT_FSF_STATUS_PRESENTED)) {
261 zfcp_dbf_hba_fsf_resp("perr", 1, req, dbf);
263 } else if (qtcb->header.fsf_status != FSF_GOOD) {
264 zfcp_dbf_hba_fsf_resp("ferr", 1, req, dbf);
266 } else if ((req->fsf_command == FSF_QTCB_OPEN_PORT_WITH_DID) ||
267 (req->fsf_command == FSF_QTCB_OPEN_LUN)) {
268 zfcp_dbf_hba_fsf_resp("open", 4, req, dbf);
270 } else if (qtcb->header.log_length) {
271 zfcp_dbf_hba_fsf_resp("qtcb", 5, req, dbf);
274 zfcp_dbf_hba_fsf_resp("norm", 6, req, dbf);
279 * zfcp_dbf_hba_fsf_unsol - trace event for an unsolicited status buffer
280 * @tag: tag indicating which kind of unsolicited status has been received
281 * @dbf: reference to dbf structure
282 * @status_buffer: buffer containing payload of unsolicited status
285 void zfcp_dbf_hba_fsf_unsol(const char *tag, struct zfcp_dbf *dbf,
286 struct fsf_status_read_buffer *buf)
290 if (level <= dbf->hba->level)
291 _zfcp_dbf_hba_fsf_unsol(tag, level, dbf, buf);
295 void zfcp_dbf_scsi(const char *tag, const char *tag2, int level,
296 struct zfcp_dbf *dbf, struct scsi_cmnd *scmd,
297 struct zfcp_fsf_req *req, unsigned long old_id)
299 if (level <= dbf->scsi->level)
300 _zfcp_dbf_scsi(tag, tag2, level, dbf, scmd, req, old_id);
304 * zfcp_dbf_scsi_result - trace event for SCSI command completion
305 * @dbf: adapter dbf trace
306 * @scmd: SCSI command pointer
307 * @req: FSF request used to issue SCSI command
310 void zfcp_dbf_scsi_result(struct zfcp_dbf *dbf, struct scsi_cmnd *scmd,
311 struct zfcp_fsf_req *req)
313 if (scmd->result != 0)
314 zfcp_dbf_scsi("rslt", "erro", 3, dbf, scmd, req, 0);
315 else if (scmd->retries > 0)
316 zfcp_dbf_scsi("rslt", "retr", 4, dbf, scmd, req, 0);
318 zfcp_dbf_scsi("rslt", "norm", 6, dbf, scmd, req, 0);
322 * zfcp_dbf_scsi_fail_send - trace event for failure to send SCSI command
323 * @dbf: adapter dbf trace
324 * @scmd: SCSI command pointer
327 void zfcp_dbf_scsi_fail_send(struct zfcp_dbf *dbf, struct scsi_cmnd *scmd)
329 zfcp_dbf_scsi("rslt", "fail", 4, dbf, scmd, NULL, 0);
333 * zfcp_dbf_scsi_abort - trace event for SCSI command abort
334 * @tag: tag indicating success or failure of abort operation
335 * @adapter: adapter thas has been used to issue SCSI command to be aborted
336 * @scmd: SCSI command to be aborted
337 * @new_req: request containing abort (might be NULL)
338 * @old_id: identifier of request containg SCSI command to be aborted
341 void zfcp_dbf_scsi_abort(const char *tag, struct zfcp_dbf *dbf,
342 struct scsi_cmnd *scmd, struct zfcp_fsf_req *new_req,
343 unsigned long old_id)
345 zfcp_dbf_scsi("abrt", tag, 1, dbf, scmd, new_req, old_id);
349 * zfcp_dbf_scsi_devreset - trace event for Logical Unit or Target Reset
350 * @tag: tag indicating success or failure of reset operation
351 * @scmnd: SCSI command which caused this error recovery
352 * @flag: indicates type of reset (Target Reset, Logical Unit Reset)
355 void zfcp_dbf_scsi_devreset(const char *tag, struct scsi_cmnd *scmnd, u8 flag)
357 struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(scmnd->device);
359 zfcp_dbf_scsi(flag == FCP_TMF_TGT_RESET ? "trst" : "lrst", tag, 1,
360 zfcp_sdev->port->adapter->dbf, scmnd, NULL, 0);
363 #endif /* ZFCP_DBF_H */