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 struct zfcp_dbf_dump {
34 u8 tag[ZFCP_DBF_TAG_SIZE];
35 u32 total_size; /* size of total dump data */
36 u32 offset; /* how much data has being already dumped */
37 u32 size; /* how much data comes with this record */
38 u8 data[]; /* dump data */
39 } __attribute__ ((packed));
41 struct zfcp_dbf_rec_record_thread {
47 struct zfcp_dbf_rec_record_target {
56 struct zfcp_dbf_rec_record_trigger {
68 struct zfcp_dbf_rec_record_action {
75 struct zfcp_dbf_rec_record {
79 struct zfcp_dbf_rec_record_action action;
80 struct zfcp_dbf_rec_record_thread thread;
81 struct zfcp_dbf_rec_record_target target;
82 struct zfcp_dbf_rec_record_trigger trigger;
87 ZFCP_REC_DBF_ID_ACTION,
88 ZFCP_REC_DBF_ID_THREAD,
89 ZFCP_REC_DBF_ID_TARGET,
90 ZFCP_REC_DBF_ID_TRIGGER,
93 struct zfcp_dbf_hba_record_response {
100 u8 fsf_prot_status_qual[FSF_PROT_STATUS_QUAL_SIZE];
101 u8 fsf_status_qual[FSF_STATUS_QUALIFIER_SIZE];
129 } __attribute__ ((packed));
131 struct zfcp_dbf_hba_record_status {
135 struct fsf_queue_designator
138 #define ZFCP_DBF_UNSOL_PAYLOAD 80
139 #define ZFCP_DBF_UNSOL_PAYLOAD_SENSE_DATA_AVAIL 32
140 #define ZFCP_DBF_UNSOL_PAYLOAD_BIT_ERROR_THRESHOLD 56
141 #define ZFCP_DBF_UNSOL_PAYLOAD_FEATURE_UPDATE_ALERT 2 * sizeof(u32)
142 u8 payload[ZFCP_DBF_UNSOL_PAYLOAD];
143 } __attribute__ ((packed));
145 struct zfcp_dbf_hba_record_qdio {
149 } __attribute__ ((packed));
151 struct zfcp_dbf_hba_record {
152 u8 tag[ZFCP_DBF_TAG_SIZE];
153 u8 tag2[ZFCP_DBF_TAG_SIZE];
155 struct zfcp_dbf_hba_record_response response;
156 struct zfcp_dbf_hba_record_status status;
157 struct zfcp_dbf_hba_record_qdio qdio;
158 struct fsf_bit_error_payload berr;
160 } __attribute__ ((packed));
162 struct zfcp_dbf_san_record_ct_request {
170 } __attribute__ ((packed));
172 struct zfcp_dbf_san_record_ct_response {
180 } __attribute__ ((packed));
182 struct zfcp_dbf_san_record_els {
185 } __attribute__ ((packed));
187 struct zfcp_dbf_san_record {
188 u8 tag[ZFCP_DBF_TAG_SIZE];
194 struct zfcp_dbf_san_record_ct_request ct_req;
195 struct zfcp_dbf_san_record_ct_response ct_resp;
196 struct zfcp_dbf_san_record_els els;
198 #define ZFCP_DBF_SAN_MAX_PAYLOAD 1024
200 } __attribute__ ((packed));
202 struct zfcp_dbf_scsi_record {
203 u8 tag[ZFCP_DBF_TAG_SIZE];
204 u8 tag2[ZFCP_DBF_TAG_SIZE];
210 #define ZFCP_DBF_SCSI_OPCODE 16
211 u8 scsi_opcode[ZFCP_DBF_SCSI_OPCODE];
222 #define ZFCP_DBF_SCSI_FCP_SNS_INFO 16
223 #define ZFCP_DBF_SCSI_MAX_FCP_SNS_INFO 256
225 u8 sns_info[ZFCP_DBF_SCSI_FCP_SNS_INFO];
226 } __attribute__ ((packed));
236 spinlock_t scsi_lock;
237 struct zfcp_dbf_rec_record rec_buf;
238 struct zfcp_dbf_hba_record hba_buf;
239 struct zfcp_dbf_san_record san_buf;
240 struct zfcp_dbf_scsi_record scsi_buf;
241 struct zfcp_adapter *adapter;
245 void zfcp_dbf_hba_fsf_resp(const char *tag2, int level,
246 struct zfcp_fsf_req *req, struct zfcp_dbf *dbf)
248 if (level <= dbf->hba->level)
249 _zfcp_dbf_hba_fsf_response(tag2, level, req, dbf);
253 * zfcp_dbf_hba_fsf_response - trace event for request completion
254 * @fsf_req: request that has been completed
256 static inline void zfcp_dbf_hba_fsf_response(struct zfcp_fsf_req *req)
258 struct zfcp_dbf *dbf = req->adapter->dbf;
259 struct fsf_qtcb *qtcb = req->qtcb;
261 if ((qtcb->prefix.prot_status != FSF_PROT_GOOD) &&
262 (qtcb->prefix.prot_status != FSF_PROT_FSF_STATUS_PRESENTED)) {
263 zfcp_dbf_hba_fsf_resp("perr", 1, req, dbf);
265 } else if (qtcb->header.fsf_status != FSF_GOOD) {
266 zfcp_dbf_hba_fsf_resp("ferr", 1, req, dbf);
268 } else if ((req->fsf_command == FSF_QTCB_OPEN_PORT_WITH_DID) ||
269 (req->fsf_command == FSF_QTCB_OPEN_LUN)) {
270 zfcp_dbf_hba_fsf_resp("open", 4, req, dbf);
272 } else if (qtcb->header.log_length) {
273 zfcp_dbf_hba_fsf_resp("qtcb", 5, req, dbf);
276 zfcp_dbf_hba_fsf_resp("norm", 6, req, dbf);
281 * zfcp_dbf_hba_fsf_unsol - trace event for an unsolicited status buffer
282 * @tag: tag indicating which kind of unsolicited status has been received
283 * @dbf: reference to dbf structure
284 * @status_buffer: buffer containing payload of unsolicited status
287 void zfcp_dbf_hba_fsf_unsol(const char *tag, struct zfcp_dbf *dbf,
288 struct fsf_status_read_buffer *buf)
292 if (level <= dbf->hba->level)
293 _zfcp_dbf_hba_fsf_unsol(tag, level, dbf, buf);
297 void zfcp_dbf_scsi(const char *tag, const char *tag2, int level,
298 struct zfcp_dbf *dbf, struct scsi_cmnd *scmd,
299 struct zfcp_fsf_req *req, unsigned long old_id)
301 if (level <= dbf->scsi->level)
302 _zfcp_dbf_scsi(tag, tag2, level, dbf, scmd, req, old_id);
306 * zfcp_dbf_scsi_result - trace event for SCSI command completion
307 * @tag: tag indicating success or failure of SCSI command
308 * @level: trace level applicable for this event
309 * @adapter: adapter that has been used to issue the SCSI command
310 * @scmd: SCSI command pointer
311 * @fsf_req: request used to issue SCSI command (might be NULL)
314 void zfcp_dbf_scsi_result(const char *tag, int level, struct zfcp_dbf *dbf,
315 struct scsi_cmnd *scmd, struct zfcp_fsf_req *fsf_req)
317 zfcp_dbf_scsi("rslt", tag, level, dbf, scmd, fsf_req, 0);
321 * zfcp_dbf_scsi_abort - trace event for SCSI command abort
322 * @tag: tag indicating success or failure of abort operation
323 * @adapter: adapter thas has been used to issue SCSI command to be aborted
324 * @scmd: SCSI command to be aborted
325 * @new_req: request containing abort (might be NULL)
326 * @old_id: identifier of request containg SCSI command to be aborted
329 void zfcp_dbf_scsi_abort(const char *tag, struct zfcp_dbf *dbf,
330 struct scsi_cmnd *scmd, struct zfcp_fsf_req *new_req,
331 unsigned long old_id)
333 zfcp_dbf_scsi("abrt", tag, 1, dbf, scmd, new_req, old_id);
337 * zfcp_dbf_scsi_devreset - trace event for Logical Unit or Target Reset
338 * @tag: tag indicating success or failure of reset operation
339 * @flag: indicates type of reset (Target Reset, Logical Unit Reset)
340 * @unit: unit that needs reset
341 * @scsi_cmnd: SCSI command which caused this error recovery
344 void zfcp_dbf_scsi_devreset(const char *tag, u8 flag, struct zfcp_unit *unit,
345 struct scsi_cmnd *scsi_cmnd)
347 zfcp_dbf_scsi(flag == FCP_TMF_TGT_RESET ? "trst" : "lrst", tag, 1,
348 unit->port->adapter->dbf, scsi_cmnd, NULL, 0);
351 #endif /* ZFCP_DBF_H */