3 * debug feature declarations
5 * Copyright IBM Corp. 2008, 2015
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 void zfcp_dbf_hba_fsf_resp(char *tag, int level, struct zfcp_fsf_req *req)
289 if (level <= req->adapter->dbf->hba->level)
290 zfcp_dbf_hba_fsf_res(tag, level, req);
294 * zfcp_dbf_hba_fsf_response - trace event for request completion
295 * @req: request that has been completed
298 void zfcp_dbf_hba_fsf_response(struct zfcp_fsf_req *req)
300 struct fsf_qtcb *qtcb = req->qtcb;
302 if ((qtcb->prefix.prot_status != FSF_PROT_GOOD) &&
303 (qtcb->prefix.prot_status != FSF_PROT_FSF_STATUS_PRESENTED)) {
304 zfcp_dbf_hba_fsf_resp("fs_perr", 1, req);
306 } else if (qtcb->header.fsf_status != FSF_GOOD) {
307 zfcp_dbf_hba_fsf_resp("fs_ferr", 1, req);
309 } else if ((req->fsf_command == FSF_QTCB_OPEN_PORT_WITH_DID) ||
310 (req->fsf_command == FSF_QTCB_OPEN_LUN)) {
311 zfcp_dbf_hba_fsf_resp("fs_open", 4, req);
313 } else if (qtcb->header.log_length) {
314 zfcp_dbf_hba_fsf_resp("fs_qtcb", 5, req);
317 zfcp_dbf_hba_fsf_resp("fs_norm", 6, req);
322 void _zfcp_dbf_scsi(char *tag, int level, struct scsi_cmnd *scmd,
323 struct zfcp_fsf_req *req)
325 struct zfcp_adapter *adapter = (struct zfcp_adapter *)
326 scmd->device->host->hostdata[0];
328 if (level <= adapter->dbf->scsi->level)
329 zfcp_dbf_scsi(tag, level, scmd, req);
333 * zfcp_dbf_scsi_result - trace event for SCSI command completion
334 * @scmd: SCSI command pointer
335 * @req: FSF request used to issue SCSI command
338 void zfcp_dbf_scsi_result(struct scsi_cmnd *scmd, struct zfcp_fsf_req *req)
340 if (scmd->result != 0)
341 _zfcp_dbf_scsi("rsl_err", 3, scmd, req);
342 else if (scmd->retries > 0)
343 _zfcp_dbf_scsi("rsl_ret", 4, scmd, req);
345 _zfcp_dbf_scsi("rsl_nor", 6, scmd, req);
349 * zfcp_dbf_scsi_fail_send - trace event for failure to send SCSI command
350 * @scmd: SCSI command pointer
353 void zfcp_dbf_scsi_fail_send(struct scsi_cmnd *scmd)
355 _zfcp_dbf_scsi("rsl_fai", 4, scmd, NULL);
359 * zfcp_dbf_scsi_abort - trace event for SCSI command abort
360 * @tag: tag indicating success or failure of abort operation
361 * @scmd: SCSI command to be aborted
362 * @fsf_req: request containing abort (might be NULL)
365 void zfcp_dbf_scsi_abort(char *tag, struct scsi_cmnd *scmd,
366 struct zfcp_fsf_req *fsf_req)
368 _zfcp_dbf_scsi(tag, 1, scmd, fsf_req);
372 * zfcp_dbf_scsi_devreset - trace event for Logical Unit or Target Reset
373 * @tag: tag indicating success or failure of reset operation
374 * @scmnd: SCSI command which caused this error recovery
375 * @flag: indicates type of reset (Target Reset, Logical Unit Reset)
378 void zfcp_dbf_scsi_devreset(char *tag, struct scsi_cmnd *scmnd, u8 flag)
380 char tmp_tag[ZFCP_DBF_TAG_LEN];
382 if (flag == FCP_TMF_TGT_RESET)
383 memcpy(tmp_tag, "tr_", 3);
385 memcpy(tmp_tag, "lr_", 3);
387 memcpy(&tmp_tag[3], tag, 4);
388 _zfcp_dbf_scsi(tmp_tag, 1, scmnd, NULL);
391 #endif /* ZFCP_DBF_H */