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
23 * struct zfcp_dbf_rec_trigger - trace record for triggered recovery action
24 * @ready: number of ready recovery actions
25 * @running: number of running recovery actions
26 * @want: wanted recovery action
27 * @need: needed recovery action
29 struct zfcp_dbf_rec_trigger {
37 * struct zfcp_dbf_rec_running - trace record for running recovery
38 * @fsf_req_id: request id for fsf requests
39 * @rec_status: status of the fsf request
40 * @rec_step: current step of the recovery action
41 * rec_count: recovery counter
43 struct zfcp_dbf_rec_running {
52 * enum zfcp_dbf_rec_id - recovery trace record id
53 * @ZFCP_DBF_REC_TRIG: triggered recovery identifier
54 * @ZFCP_DBF_REC_RUN: running recovery identifier
56 enum zfcp_dbf_rec_id {
57 ZFCP_DBF_REC_TRIG = 1,
62 * struct zfcp_dbf_rec - trace record for error recovery actions
63 * @id: unique number of recovery record type
64 * @tag: identifier string specifying the location of initiation
65 * @lun: logical unit number
66 * @wwpn: word wide port number
67 * @d_id: destination ID
68 * @adapter_status: current status of the adapter
69 * @port_status: current status of the port
70 * @lun_status: current status of the lun
71 * @u.trig: structure zfcp_dbf_rec_trigger
72 * @u.run: structure zfcp_dbf_rec_running
76 char tag[ZFCP_DBF_TAG_LEN];
84 struct zfcp_dbf_rec_trigger trig;
85 struct zfcp_dbf_rec_running run;
90 * enum zfcp_dbf_san_id - SAN trace record identifier
91 * @ZFCP_DBF_SAN_REQ: request trace record id
92 * @ZFCP_DBF_SAN_RES: response trace record id
93 * @ZFCP_DBF_SAN_ELS: extended link service record id
95 enum zfcp_dbf_san_id {
101 /** struct zfcp_dbf_san - trace record for SAN requests and responses
102 * @id: unique number of recovery record type
103 * @tag: identifier string specifying the location of initiation
104 * @fsf_req_id: request id for fsf requests
105 * @payload: unformatted information related to request/response
106 * @d_id: destination id
108 struct zfcp_dbf_san {
110 char tag[ZFCP_DBF_TAG_LEN];
113 #define ZFCP_DBF_SAN_MAX_PAYLOAD (FC_CT_HDR_LEN + 32)
114 char payload[ZFCP_DBF_SAN_MAX_PAYLOAD];
118 * struct zfcp_dbf_hba_res - trace record for hba responses
119 * @req_issued: timestamp when request was issued
120 * @prot_status: protocol status
121 * @prot_status_qual: protocol status qualifier
122 * @fsf_status: fsf status
123 * @fsf_status_qual: fsf status qualifier
125 struct zfcp_dbf_hba_res {
128 u8 prot_status_qual[FSF_PROT_STATUS_QUAL_SIZE];
130 u8 fsf_status_qual[FSF_STATUS_QUALIFIER_SIZE];
134 * struct zfcp_dbf_hba_uss - trace record for unsolicited status
135 * @status_type: type of unsolicited status
136 * @status_subtype: subtype of unsolicited status
137 * @d_id: destination ID
138 * @lun: logical unit number
139 * @queue_designator: queue designator
141 struct zfcp_dbf_hba_uss {
146 u64 queue_designator;
150 * enum zfcp_dbf_hba_id - HBA trace record identifier
151 * @ZFCP_DBF_HBA_RES: response trace record
152 * @ZFCP_DBF_HBA_USS: unsolicited status trace record
153 * @ZFCP_DBF_HBA_BIT: bit error trace record
155 enum zfcp_dbf_hba_id {
156 ZFCP_DBF_HBA_RES = 1,
157 ZFCP_DBF_HBA_USS = 2,
158 ZFCP_DBF_HBA_BIT = 3,
162 * struct zfcp_dbf_hba - common trace record for HBA records
163 * @id: unique number of recovery record type
164 * @tag: identifier string specifying the location of initiation
165 * @fsf_req_id: request id for fsf requests
166 * @fsf_req_status: status of fsf request
167 * @fsf_cmd: fsf command
168 * @fsf_seq_no: fsf sequence number
169 * @pl_len: length of payload stored as zfcp_dbf_pay
170 * @u: record type specific data
172 struct zfcp_dbf_hba {
174 char tag[ZFCP_DBF_TAG_LEN];
181 struct zfcp_dbf_hba_res res;
182 struct zfcp_dbf_hba_uss uss;
183 struct fsf_bit_error_payload be;
188 * enum zfcp_dbf_scsi_id - scsi trace record identifier
189 * @ZFCP_DBF_SCSI_CMND: scsi command trace record
191 enum zfcp_dbf_scsi_id {
192 ZFCP_DBF_SCSI_CMND = 1,
196 * struct zfcp_dbf_scsi - common trace record for SCSI records
197 * @id: unique number of recovery record type
198 * @tag: identifier string specifying the location of initiation
199 * @scsi_id: scsi device id
200 * @scsi_lun: scsi device logical unit number
201 * @scsi_result: scsi result
202 * @scsi_retries: current retry number of scsi request
203 * @scsi_allowed: allowed retries
204 * @fcp_rsp_info: FCP response info
205 * @scsi_opcode: scsi opcode
206 * @fsf_req_id: request id of fsf request
207 * @host_scribble: LLD specific data attached to SCSI request
208 * @pl_len: length of paload stored as zfcp_dbf_pay
209 * @fsf_rsp: response for fsf request
211 struct zfcp_dbf_scsi {
213 char tag[ZFCP_DBF_TAG_LEN];
220 #define ZFCP_DBF_SCSI_OPCODE 16
221 u8 scsi_opcode[ZFCP_DBF_SCSI_OPCODE];
225 struct fcp_resp_with_ext fcp_rsp;
229 * struct zfcp_dbf_pay - trace record for unformatted payload information
230 * @area: area this record is originated from
231 * @counter: ascending record number
232 * @fsf_req_id: request id of fsf request
233 * @data: unformatted data
235 struct zfcp_dbf_pay {
236 char area[ZFCP_DBF_TAG_LEN];
239 #define ZFCP_DBF_PAY_MAX_REC 0x100
240 char data[ZFCP_DBF_PAY_MAX_REC];
253 spinlock_t scsi_lock;
254 struct zfcp_dbf_rec rec_buf;
255 struct zfcp_dbf_hba hba_buf;
256 struct zfcp_dbf_san san_buf;
257 struct zfcp_dbf_scsi scsi_buf;
258 struct zfcp_dbf_pay pay_buf;
259 struct zfcp_adapter *adapter;
263 void zfcp_dbf_hba_fsf_resp(char *tag, int level, struct zfcp_fsf_req *req)
265 if (level <= req->adapter->dbf->hba->level)
266 zfcp_dbf_hba_fsf_res(tag, req);
270 * zfcp_dbf_hba_fsf_response - trace event for request completion
271 * @req: request that has been completed
274 void zfcp_dbf_hba_fsf_response(struct zfcp_fsf_req *req)
276 struct fsf_qtcb *qtcb = req->qtcb;
278 if ((qtcb->prefix.prot_status != FSF_PROT_GOOD) &&
279 (qtcb->prefix.prot_status != FSF_PROT_FSF_STATUS_PRESENTED)) {
280 zfcp_dbf_hba_fsf_resp("fs_perr", 1, req);
282 } else if (qtcb->header.fsf_status != FSF_GOOD) {
283 zfcp_dbf_hba_fsf_resp("fs_ferr", 1, req);
285 } else if ((req->fsf_command == FSF_QTCB_OPEN_PORT_WITH_DID) ||
286 (req->fsf_command == FSF_QTCB_OPEN_LUN)) {
287 zfcp_dbf_hba_fsf_resp("fs_open", 4, req);
289 } else if (qtcb->header.log_length) {
290 zfcp_dbf_hba_fsf_resp("fs_qtcb", 5, req);
293 zfcp_dbf_hba_fsf_resp("fs_norm", 6, req);
298 void _zfcp_dbf_scsi(char *tag, int level, struct scsi_cmnd *scmd,
299 struct zfcp_fsf_req *req)
301 struct zfcp_adapter *adapter = (struct zfcp_adapter *)
302 scmd->device->host->hostdata[0];
304 if (level <= adapter->dbf->scsi->level)
305 zfcp_dbf_scsi(tag, scmd, req);
309 * zfcp_dbf_scsi_result - trace event for SCSI command completion
310 * @scmd: SCSI command pointer
311 * @req: FSF request used to issue SCSI command
314 void zfcp_dbf_scsi_result(struct scsi_cmnd *scmd, struct zfcp_fsf_req *req)
316 if (scmd->result != 0)
317 _zfcp_dbf_scsi("rsl_err", 3, scmd, req);
318 else if (scmd->retries > 0)
319 _zfcp_dbf_scsi("rsl_ret", 4, scmd, req);
321 _zfcp_dbf_scsi("rsl_nor", 6, scmd, req);
325 * zfcp_dbf_scsi_fail_send - trace event for failure to send SCSI command
326 * @scmd: SCSI command pointer
329 void zfcp_dbf_scsi_fail_send(struct scsi_cmnd *scmd)
331 _zfcp_dbf_scsi("rsl_fai", 4, scmd, NULL);
335 * zfcp_dbf_scsi_abort - trace event for SCSI command abort
336 * @tag: tag indicating success or failure of abort operation
337 * @scmd: SCSI command to be aborted
338 * @fsf_req: request containing abort (might be NULL)
341 void zfcp_dbf_scsi_abort(char *tag, struct scsi_cmnd *scmd,
342 struct zfcp_fsf_req *fsf_req)
344 _zfcp_dbf_scsi(tag, 1, scmd, fsf_req);
348 * zfcp_dbf_scsi_devreset - trace event for Logical Unit or Target Reset
349 * @tag: tag indicating success or failure of reset operation
350 * @scmnd: SCSI command which caused this error recovery
351 * @flag: indicates type of reset (Target Reset, Logical Unit Reset)
354 void zfcp_dbf_scsi_devreset(char *tag, struct scsi_cmnd *scmnd, u8 flag)
356 char tmp_tag[ZFCP_DBF_TAG_LEN];
358 if (flag == FCP_TMF_TGT_RESET)
359 memcpy(tmp_tag, "tr_", 3);
361 memcpy(tmp_tag, "lr_", 3);
363 memcpy(&tmp_tag[3], tag, 4);
364 _zfcp_dbf_scsi(tmp_tag, 1, scmnd, NULL);
367 #endif /* ZFCP_DBF_H */