3 * debug feature declarations
5 * Copyright IBM Corp. 2008, 2010
11 #include <scsi/fc/fc_fcp.h>
16 #define ZFCP_DBF_TAG_LEN 7
17 #define ZFCP_DBF_TAG_SIZE 4
18 #define ZFCP_DBF_ID_SIZE 7
20 #define ZFCP_DBF_INVALID_LUN 0xFFFFFFFFFFFFFFFFull
22 struct zfcp_dbf_dump {
23 u8 tag[ZFCP_DBF_TAG_SIZE];
24 u32 total_size; /* size of total dump data */
25 u32 offset; /* how much data has being already dumped */
26 u32 size; /* how much data comes with this record */
27 u8 data[]; /* dump data */
28 } __attribute__ ((packed));
31 * struct zfcp_dbf_rec_trigger - trace record for triggered recovery action
32 * @ready: number of ready recovery actions
33 * @running: number of running recovery actions
34 * @want: wanted recovery action
35 * @need: needed recovery action
37 struct zfcp_dbf_rec_trigger {
45 * struct zfcp_dbf_rec_running - trace record for running recovery
46 * @fsf_req_id: request id for fsf requests
47 * @rec_status: status of the fsf request
48 * @rec_step: current step of the recovery action
49 * rec_count: recovery counter
51 struct zfcp_dbf_rec_running {
60 * enum zfcp_dbf_rec_id - recovery trace record id
61 * @ZFCP_DBF_REC_TRIG: triggered recovery identifier
62 * @ZFCP_DBF_REC_RUN: running recovery identifier
64 enum zfcp_dbf_rec_id {
65 ZFCP_DBF_REC_TRIG = 1,
70 * struct zfcp_dbf_rec - trace record for error recovery actions
71 * @id: unique number of recovery record type
72 * @tag: identifier string specifying the location of initiation
73 * @lun: logical unit number
74 * @wwpn: word wide port number
75 * @d_id: destination ID
76 * @adapter_status: current status of the adapter
77 * @port_status: current status of the port
78 * @lun_status: current status of the lun
79 * @u.trig: structure zfcp_dbf_rec_trigger
80 * @u.run: structure zfcp_dbf_rec_running
84 char tag[ZFCP_DBF_TAG_LEN];
92 struct zfcp_dbf_rec_trigger trig;
93 struct zfcp_dbf_rec_running run;
98 * enum zfcp_dbf_san_id - SAN trace record identifier
99 * @ZFCP_DBF_SAN_REQ: request trace record id
100 * @ZFCP_DBF_SAN_RES: response trace record id
101 * @ZFCP_DBF_SAN_ELS: extended link service record id
103 enum zfcp_dbf_san_id {
104 ZFCP_DBF_SAN_REQ = 1,
105 ZFCP_DBF_SAN_RES = 2,
106 ZFCP_DBF_SAN_ELS = 3,
109 /** struct zfcp_dbf_san - trace record for SAN requests and responses
110 * @id: unique number of recovery record type
111 * @tag: identifier string specifying the location of initiation
112 * @fsf_req_id: request id for fsf requests
113 * @payload: unformatted information related to request/response
114 * @d_id: destination id
116 struct zfcp_dbf_san {
118 char tag[ZFCP_DBF_TAG_LEN];
121 #define ZFCP_DBF_SAN_MAX_PAYLOAD (FC_CT_HDR_LEN + 32)
122 char payload[ZFCP_DBF_SAN_MAX_PAYLOAD];
126 * struct zfcp_dbf_hba_res - trace record for hba responses
127 * @req_issued: timestamp when request was issued
128 * @prot_status: protocol status
129 * @prot_status_qual: protocol status qualifier
130 * @fsf_status: fsf status
131 * @fsf_status_qual: fsf status qualifier
133 struct zfcp_dbf_hba_res {
136 u8 prot_status_qual[FSF_PROT_STATUS_QUAL_SIZE];
138 u8 fsf_status_qual[FSF_STATUS_QUALIFIER_SIZE];
142 * struct zfcp_dbf_hba_uss - trace record for unsolicited status
143 * @status_type: type of unsolicited status
144 * @status_subtype: subtype of unsolicited status
145 * @d_id: destination ID
146 * @lun: logical unit number
147 * @queue_designator: queue designator
149 struct zfcp_dbf_hba_uss {
154 u64 queue_designator;
158 * enum zfcp_dbf_hba_id - HBA trace record identifier
159 * @ZFCP_DBF_HBA_RES: response trace record
160 * @ZFCP_DBF_HBA_USS: unsolicited status trace record
161 * @ZFCP_DBF_HBA_BIT: bit error trace record
163 enum zfcp_dbf_hba_id {
164 ZFCP_DBF_HBA_RES = 1,
165 ZFCP_DBF_HBA_USS = 2,
166 ZFCP_DBF_HBA_BIT = 3,
170 * struct zfcp_dbf_hba - common trace record for HBA records
171 * @id: unique number of recovery record type
172 * @tag: identifier string specifying the location of initiation
173 * @fsf_req_id: request id for fsf requests
174 * @fsf_req_status: status of fsf request
175 * @fsf_cmd: fsf command
176 * @fsf_seq_no: fsf sequence number
177 * @pl_len: length of payload stored as zfcp_dbf_pay
178 * @u: record type specific data
180 struct zfcp_dbf_hba {
182 char tag[ZFCP_DBF_TAG_LEN];
189 struct zfcp_dbf_hba_res res;
190 struct zfcp_dbf_hba_uss uss;
191 struct fsf_bit_error_payload be;
196 * struct zfcp_dbf_pay - trace record for unformatted payload information
197 * @area: area this record is originated from
198 * @counter: ascending record number
199 * @fsf_req_id: request id of fsf request
200 * @data: unformatted data
202 struct zfcp_dbf_pay {
203 char area[ZFCP_DBF_TAG_LEN];
206 #define ZFCP_DBF_PAY_MAX_REC 0x100
207 char data[ZFCP_DBF_PAY_MAX_REC];
210 struct zfcp_dbf_scsi_record {
211 u8 tag[ZFCP_DBF_TAG_SIZE];
212 u8 tag2[ZFCP_DBF_TAG_SIZE];
217 #define ZFCP_DBF_SCSI_OPCODE 16
218 u8 scsi_opcode[ZFCP_DBF_SCSI_OPCODE];
229 #define ZFCP_DBF_SCSI_FCP_SNS_INFO 16
230 #define ZFCP_DBF_SCSI_MAX_FCP_SNS_INFO 256
232 u8 sns_info[ZFCP_DBF_SCSI_FCP_SNS_INFO];
233 } __attribute__ ((packed));
245 spinlock_t scsi_lock;
246 struct zfcp_dbf_rec rec_buf;
247 struct zfcp_dbf_hba hba_buf;
248 struct zfcp_dbf_san san_buf;
249 struct zfcp_dbf_scsi_record scsi_buf;
250 struct zfcp_dbf_pay pay_buf;
251 struct zfcp_adapter *adapter;
255 void zfcp_dbf_hba_fsf_resp(char *tag, int level, struct zfcp_fsf_req *req)
257 if (level <= req->adapter->dbf->hba->level)
258 zfcp_dbf_hba_fsf_res(tag, req);
262 * zfcp_dbf_hba_fsf_response - trace event for request completion
263 * @fsf_req: request that has been completed
266 void zfcp_dbf_hba_fsf_response(struct zfcp_fsf_req *req)
268 struct fsf_qtcb *qtcb = req->qtcb;
270 if ((qtcb->prefix.prot_status != FSF_PROT_GOOD) &&
271 (qtcb->prefix.prot_status != FSF_PROT_FSF_STATUS_PRESENTED)) {
272 zfcp_dbf_hba_fsf_resp("fs_perr", 1, req);
274 } else if (qtcb->header.fsf_status != FSF_GOOD) {
275 zfcp_dbf_hba_fsf_resp("fs_ferr", 1, req);
277 } else if ((req->fsf_command == FSF_QTCB_OPEN_PORT_WITH_DID) ||
278 (req->fsf_command == FSF_QTCB_OPEN_LUN)) {
279 zfcp_dbf_hba_fsf_resp("fs_open", 4, req);
281 } else if (qtcb->header.log_length) {
282 zfcp_dbf_hba_fsf_resp("fs_qtcb", 5, req);
285 zfcp_dbf_hba_fsf_resp("fs_norm", 6, req);
290 void zfcp_dbf_scsi(const char *tag, const char *tag2, int level,
291 struct zfcp_dbf *dbf, struct scsi_cmnd *scmd,
292 struct zfcp_fsf_req *req, unsigned long old_id)
294 if (level <= dbf->scsi->level)
295 _zfcp_dbf_scsi(tag, tag2, level, dbf, scmd, req, old_id);
299 * zfcp_dbf_scsi_result - trace event for SCSI command completion
300 * @dbf: adapter dbf trace
301 * @scmd: SCSI command pointer
302 * @req: FSF request used to issue SCSI command
305 void zfcp_dbf_scsi_result(struct zfcp_dbf *dbf, struct scsi_cmnd *scmd,
306 struct zfcp_fsf_req *req)
308 if (scmd->result != 0)
309 zfcp_dbf_scsi("rslt", "erro", 3, dbf, scmd, req, 0);
310 else if (scmd->retries > 0)
311 zfcp_dbf_scsi("rslt", "retr", 4, dbf, scmd, req, 0);
313 zfcp_dbf_scsi("rslt", "norm", 6, dbf, scmd, req, 0);
317 * zfcp_dbf_scsi_fail_send - trace event for failure to send SCSI command
318 * @dbf: adapter dbf trace
319 * @scmd: SCSI command pointer
322 void zfcp_dbf_scsi_fail_send(struct zfcp_dbf *dbf, struct scsi_cmnd *scmd)
324 zfcp_dbf_scsi("rslt", "fail", 4, dbf, scmd, NULL, 0);
328 * zfcp_dbf_scsi_abort - trace event for SCSI command abort
329 * @tag: tag indicating success or failure of abort operation
330 * @adapter: adapter thas has been used to issue SCSI command to be aborted
331 * @scmd: SCSI command to be aborted
332 * @new_req: request containing abort (might be NULL)
333 * @old_id: identifier of request containg SCSI command to be aborted
336 void zfcp_dbf_scsi_abort(const char *tag, struct zfcp_dbf *dbf,
337 struct scsi_cmnd *scmd, struct zfcp_fsf_req *new_req,
338 unsigned long old_id)
340 zfcp_dbf_scsi("abrt", tag, 1, dbf, scmd, new_req, old_id);
344 * zfcp_dbf_scsi_devreset - trace event for Logical Unit or Target Reset
345 * @tag: tag indicating success or failure of reset operation
346 * @scmnd: SCSI command which caused this error recovery
347 * @flag: indicates type of reset (Target Reset, Logical Unit Reset)
350 void zfcp_dbf_scsi_devreset(const char *tag, struct scsi_cmnd *scmnd, u8 flag)
352 struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(scmnd->device);
354 zfcp_dbf_scsi(flag == FCP_TMF_TGT_RESET ? "trst" : "lrst", tag, 1,
355 zfcp_sdev->port->adapter->dbf, scmnd, NULL, 0);
358 #endif /* ZFCP_DBF_H */