3 * debug feature declarations
5 * Copyright IBM Corp. 2008, 2017
11 #include <scsi/fc/fc_fcp.h>
16 #define ZFCP_DBF_TAG_LEN 7
18 #define ZFCP_DBF_INVALID_LUN 0xFFFFFFFFFFFFFFFFull
20 enum zfcp_dbf_pseudo_erp_act_type {
21 ZFCP_PSEUDO_ERP_ACTION_RPORT_ADD = 0xff,
22 ZFCP_PSEUDO_ERP_ACTION_RPORT_DEL = 0xfe,
26 * struct zfcp_dbf_rec_trigger - trace record for triggered recovery action
27 * @ready: number of ready recovery actions
28 * @running: number of running recovery actions
29 * @want: wanted recovery action
30 * @need: needed recovery action
32 struct zfcp_dbf_rec_trigger {
40 * struct zfcp_dbf_rec_running - trace record for running recovery
41 * @fsf_req_id: request id for fsf requests
42 * @rec_status: status of the fsf request
43 * @rec_step: current step of the recovery action
44 * rec_count: recovery counter
46 struct zfcp_dbf_rec_running {
55 * enum zfcp_dbf_rec_id - recovery trace record id
56 * @ZFCP_DBF_REC_TRIG: triggered recovery identifier
57 * @ZFCP_DBF_REC_RUN: running recovery identifier
59 enum zfcp_dbf_rec_id {
60 ZFCP_DBF_REC_TRIG = 1,
65 * struct zfcp_dbf_rec - trace record for error recovery actions
66 * @id: unique number of recovery record type
67 * @tag: identifier string specifying the location of initiation
68 * @lun: logical unit number
69 * @wwpn: word wide port number
70 * @d_id: destination ID
71 * @adapter_status: current status of the adapter
72 * @port_status: current status of the port
73 * @lun_status: current status of the lun
74 * @u.trig: structure zfcp_dbf_rec_trigger
75 * @u.run: structure zfcp_dbf_rec_running
79 char tag[ZFCP_DBF_TAG_LEN];
87 struct zfcp_dbf_rec_trigger trig;
88 struct zfcp_dbf_rec_running run;
93 * enum zfcp_dbf_san_id - SAN trace record identifier
94 * @ZFCP_DBF_SAN_REQ: request trace record id
95 * @ZFCP_DBF_SAN_RES: response trace record id
96 * @ZFCP_DBF_SAN_ELS: extended link service record id
98 enum zfcp_dbf_san_id {
100 ZFCP_DBF_SAN_RES = 2,
101 ZFCP_DBF_SAN_ELS = 3,
104 /** struct zfcp_dbf_san - trace record for SAN requests and responses
105 * @id: unique number of recovery record type
106 * @tag: identifier string specifying the location of initiation
107 * @fsf_req_id: request id for fsf requests
108 * @payload: unformatted information related to request/response
109 * @d_id: destination id
111 struct zfcp_dbf_san {
113 char tag[ZFCP_DBF_TAG_LEN];
116 #define ZFCP_DBF_SAN_MAX_PAYLOAD (FC_CT_HDR_LEN + 32)
117 char payload[ZFCP_DBF_SAN_MAX_PAYLOAD];
122 * struct zfcp_dbf_hba_res - trace record for hba responses
123 * @req_issued: timestamp when request was issued
124 * @prot_status: protocol status
125 * @prot_status_qual: protocol status qualifier
126 * @fsf_status: fsf status
127 * @fsf_status_qual: fsf status qualifier
129 struct zfcp_dbf_hba_res {
132 u8 prot_status_qual[FSF_PROT_STATUS_QUAL_SIZE];
134 u8 fsf_status_qual[FSF_STATUS_QUALIFIER_SIZE];
140 * struct zfcp_dbf_hba_uss - trace record for unsolicited status
141 * @status_type: type of unsolicited status
142 * @status_subtype: subtype of unsolicited status
143 * @d_id: destination ID
144 * @lun: logical unit number
145 * @queue_designator: queue designator
147 struct zfcp_dbf_hba_uss {
152 u64 queue_designator;
156 * enum zfcp_dbf_hba_id - HBA trace record identifier
157 * @ZFCP_DBF_HBA_RES: response trace record
158 * @ZFCP_DBF_HBA_USS: unsolicited status trace record
159 * @ZFCP_DBF_HBA_BIT: bit error trace record
161 enum zfcp_dbf_hba_id {
162 ZFCP_DBF_HBA_RES = 1,
163 ZFCP_DBF_HBA_USS = 2,
164 ZFCP_DBF_HBA_BIT = 3,
165 ZFCP_DBF_HBA_BASIC = 4,
169 * struct zfcp_dbf_hba - common trace record for HBA records
170 * @id: unique number of recovery record type
171 * @tag: identifier string specifying the location of initiation
172 * @fsf_req_id: request id for fsf requests
173 * @fsf_req_status: status of fsf request
174 * @fsf_cmd: fsf command
175 * @fsf_seq_no: fsf sequence number
176 * @pl_len: length of payload stored as zfcp_dbf_pay
177 * @u: record type specific data
179 struct zfcp_dbf_hba {
181 char tag[ZFCP_DBF_TAG_LEN];
188 struct zfcp_dbf_hba_res res;
189 struct zfcp_dbf_hba_uss uss;
190 struct fsf_bit_error_payload be;
195 * enum zfcp_dbf_scsi_id - scsi trace record identifier
196 * @ZFCP_DBF_SCSI_CMND: scsi command trace record
198 enum zfcp_dbf_scsi_id {
199 ZFCP_DBF_SCSI_CMND = 1,
203 * struct zfcp_dbf_scsi - common trace record for SCSI records
204 * @id: unique number of recovery record type
205 * @tag: identifier string specifying the location of initiation
206 * @scsi_id: scsi device id
207 * @scsi_lun: scsi device logical unit number
208 * @scsi_result: scsi result
209 * @scsi_retries: current retry number of scsi request
210 * @scsi_allowed: allowed retries
211 * @fcp_rsp_info: FCP response info
212 * @scsi_opcode: scsi opcode
213 * @fsf_req_id: request id of fsf request
214 * @host_scribble: LLD specific data attached to SCSI request
215 * @pl_len: length of paload stored as zfcp_dbf_pay
216 * @fsf_rsp: response for fsf request
218 struct zfcp_dbf_scsi {
220 char tag[ZFCP_DBF_TAG_LEN];
227 #define ZFCP_DBF_SCSI_OPCODE 16
228 u8 scsi_opcode[ZFCP_DBF_SCSI_OPCODE];
232 struct fcp_resp_with_ext fcp_rsp;
236 * struct zfcp_dbf_pay - trace record for unformatted payload information
237 * @area: area this record is originated from
238 * @counter: ascending record number
239 * @fsf_req_id: request id of fsf request
240 * @data: unformatted data
242 struct zfcp_dbf_pay {
244 char area[ZFCP_DBF_TAG_LEN];
246 #define ZFCP_DBF_PAY_MAX_REC 0x100
247 char data[ZFCP_DBF_PAY_MAX_REC];
251 * struct zfcp_dbf - main dbf trace structure
252 * @pay: reference to payload trace area
253 * @rec: reference to recovery trace area
254 * @hba: reference to hba trace area
255 * @san: reference to san trace area
256 * @scsi: reference to scsi trace area
257 * @pay_lock: lock protecting payload trace buffer
258 * @rec_lock: lock protecting recovery trace buffer
259 * @hba_lock: lock protecting hba trace buffer
260 * @san_lock: lock protecting san trace buffer
261 * @scsi_lock: lock protecting scsi trace buffer
262 * @pay_buf: pre-allocated buffer for payload
263 * @rec_buf: pre-allocated buffer for recovery
264 * @hba_buf: pre-allocated buffer for hba
265 * @san_buf: pre-allocated buffer for san
266 * @scsi_buf: pre-allocated buffer for scsi
278 spinlock_t scsi_lock;
279 struct zfcp_dbf_pay pay_buf;
280 struct zfcp_dbf_rec rec_buf;
281 struct zfcp_dbf_hba hba_buf;
282 struct zfcp_dbf_san san_buf;
283 struct zfcp_dbf_scsi scsi_buf;
287 * zfcp_dbf_hba_fsf_resp_suppress - true if we should not trace by default
288 * @req: request that has been completed
290 * Returns true if FCP response with only benign residual under count.
293 bool zfcp_dbf_hba_fsf_resp_suppress(struct zfcp_fsf_req *req)
295 struct fsf_qtcb *qtcb = req->qtcb;
296 u32 fsf_stat = qtcb->header.fsf_status;
297 struct fcp_resp *fcp_rsp;
298 u8 rsp_flags, fr_status;
300 if (qtcb->prefix.qtcb_type != FSF_IO_COMMAND)
301 return false; /* not an FCP response */
302 fcp_rsp = (struct fcp_resp *)&qtcb->bottom.io.fcp_rsp;
303 rsp_flags = fcp_rsp->fr_flags;
304 fr_status = fcp_rsp->fr_status;
305 return (fsf_stat == FSF_FCP_RSP_AVAILABLE) &&
306 (rsp_flags == FCP_RESID_UNDER) &&
307 (fr_status == SAM_STAT_GOOD);
311 void zfcp_dbf_hba_fsf_resp(char *tag, int level, struct zfcp_fsf_req *req)
313 if (level <= req->adapter->dbf->hba->level)
314 zfcp_dbf_hba_fsf_res(tag, level, req);
318 * zfcp_dbf_hba_fsf_response - trace event for request completion
319 * @req: request that has been completed
322 void zfcp_dbf_hba_fsf_response(struct zfcp_fsf_req *req)
324 struct fsf_qtcb *qtcb = req->qtcb;
326 if (unlikely(req->status & (ZFCP_STATUS_FSFREQ_DISMISSED |
327 ZFCP_STATUS_FSFREQ_ERROR))) {
328 zfcp_dbf_hba_fsf_resp("fs_rerr", 3, req);
330 } else if ((qtcb->prefix.prot_status != FSF_PROT_GOOD) &&
331 (qtcb->prefix.prot_status != FSF_PROT_FSF_STATUS_PRESENTED)) {
332 zfcp_dbf_hba_fsf_resp("fs_perr", 1, req);
334 } else if (qtcb->header.fsf_status != FSF_GOOD) {
335 zfcp_dbf_hba_fsf_resp("fs_ferr",
336 zfcp_dbf_hba_fsf_resp_suppress(req)
339 } else if ((req->fsf_command == FSF_QTCB_OPEN_PORT_WITH_DID) ||
340 (req->fsf_command == FSF_QTCB_OPEN_LUN)) {
341 zfcp_dbf_hba_fsf_resp("fs_open", 4, req);
343 } else if (qtcb->header.log_length) {
344 zfcp_dbf_hba_fsf_resp("fs_qtcb", 5, req);
347 zfcp_dbf_hba_fsf_resp("fs_norm", 6, req);
352 void _zfcp_dbf_scsi(char *tag, int level, struct scsi_cmnd *scmd,
353 struct zfcp_fsf_req *req)
355 struct zfcp_adapter *adapter = (struct zfcp_adapter *)
356 scmd->device->host->hostdata[0];
358 if (level <= adapter->dbf->scsi->level)
359 zfcp_dbf_scsi(tag, level, scmd, req);
363 * zfcp_dbf_scsi_result - trace event for SCSI command completion
364 * @scmd: SCSI command pointer
365 * @req: FSF request used to issue SCSI command
368 void zfcp_dbf_scsi_result(struct scsi_cmnd *scmd, struct zfcp_fsf_req *req)
370 if (scmd->result != 0)
371 _zfcp_dbf_scsi("rsl_err", 3, scmd, req);
372 else if (scmd->retries > 0)
373 _zfcp_dbf_scsi("rsl_ret", 4, scmd, req);
375 _zfcp_dbf_scsi("rsl_nor", 6, scmd, req);
379 * zfcp_dbf_scsi_fail_send - trace event for failure to send SCSI command
380 * @scmd: SCSI command pointer
383 void zfcp_dbf_scsi_fail_send(struct scsi_cmnd *scmd)
385 _zfcp_dbf_scsi("rsl_fai", 4, scmd, NULL);
389 * zfcp_dbf_scsi_abort - trace event for SCSI command abort
390 * @tag: tag indicating success or failure of abort operation
391 * @scmd: SCSI command to be aborted
392 * @fsf_req: request containing abort (might be NULL)
395 void zfcp_dbf_scsi_abort(char *tag, struct scsi_cmnd *scmd,
396 struct zfcp_fsf_req *fsf_req)
398 _zfcp_dbf_scsi(tag, 1, scmd, fsf_req);
402 * zfcp_dbf_scsi_devreset - trace event for Logical Unit or Target Reset
403 * @tag: tag indicating success or failure of reset operation
404 * @scmnd: SCSI command which caused this error recovery
405 * @flag: indicates type of reset (Target Reset, Logical Unit Reset)
408 void zfcp_dbf_scsi_devreset(char *tag, struct scsi_cmnd *scmnd, u8 flag,
409 struct zfcp_fsf_req *fsf_req)
411 char tmp_tag[ZFCP_DBF_TAG_LEN];
413 if (flag == FCP_TMF_TGT_RESET)
414 memcpy(tmp_tag, "tr_", 3);
416 memcpy(tmp_tag, "lr_", 3);
418 memcpy(&tmp_tag[3], tag, 4);
419 _zfcp_dbf_scsi(tmp_tag, 1, scmnd, fsf_req);
423 * zfcp_dbf_scsi_nullcmnd() - trace NULLify of SCSI command in dev/tgt-reset.
424 * @scmnd: SCSI command that was NULLified.
425 * @fsf_req: request that owned @scmnd.
427 static inline void zfcp_dbf_scsi_nullcmnd(struct scsi_cmnd *scmnd,
428 struct zfcp_fsf_req *fsf_req)
430 _zfcp_dbf_scsi("scfc__1", 3, scmnd, fsf_req);
433 #endif /* ZFCP_DBF_H */