3 * debug feature declarations
5 * Copyright IBM Corp. 2008, 2010
11 #include <scsi/fc/fc_fcp.h>
16 #define ZFCP_DBF_TAG_LEN 7
18 #define ZFCP_DBF_INVALID_LUN 0xFFFFFFFFFFFFFFFFull
21 * struct zfcp_dbf_rec_trigger - trace record for triggered recovery action
22 * @ready: number of ready recovery actions
23 * @running: number of running recovery actions
24 * @want: wanted recovery action
25 * @need: needed recovery action
27 struct zfcp_dbf_rec_trigger
{
35 * struct zfcp_dbf_rec_running - trace record for running recovery
36 * @fsf_req_id: request id for fsf requests
37 * @rec_status: status of the fsf request
38 * @rec_step: current step of the recovery action
39 * rec_count: recovery counter
41 struct zfcp_dbf_rec_running
{
50 * enum zfcp_dbf_rec_id - recovery trace record id
51 * @ZFCP_DBF_REC_TRIG: triggered recovery identifier
52 * @ZFCP_DBF_REC_RUN: running recovery identifier
54 enum zfcp_dbf_rec_id
{
55 ZFCP_DBF_REC_TRIG
= 1,
60 * struct zfcp_dbf_rec - trace record for error recovery actions
61 * @id: unique number of recovery record type
62 * @tag: identifier string specifying the location of initiation
63 * @lun: logical unit number
64 * @wwpn: word wide port number
65 * @d_id: destination ID
66 * @adapter_status: current status of the adapter
67 * @port_status: current status of the port
68 * @lun_status: current status of the lun
69 * @u.trig: structure zfcp_dbf_rec_trigger
70 * @u.run: structure zfcp_dbf_rec_running
74 char tag
[ZFCP_DBF_TAG_LEN
];
82 struct zfcp_dbf_rec_trigger trig
;
83 struct zfcp_dbf_rec_running run
;
88 * enum zfcp_dbf_san_id - SAN trace record identifier
89 * @ZFCP_DBF_SAN_REQ: request trace record id
90 * @ZFCP_DBF_SAN_RES: response trace record id
91 * @ZFCP_DBF_SAN_ELS: extended link service record id
93 enum zfcp_dbf_san_id
{
99 /** struct zfcp_dbf_san - trace record for SAN requests and responses
100 * @id: unique number of recovery record type
101 * @tag: identifier string specifying the location of initiation
102 * @fsf_req_id: request id for fsf requests
103 * @payload: unformatted information related to request/response
104 * @d_id: destination id
106 struct zfcp_dbf_san
{
108 char tag
[ZFCP_DBF_TAG_LEN
];
111 #define ZFCP_DBF_SAN_MAX_PAYLOAD (FC_CT_HDR_LEN + 32)
112 char payload
[ZFCP_DBF_SAN_MAX_PAYLOAD
];
116 * struct zfcp_dbf_hba_res - trace record for hba responses
117 * @req_issued: timestamp when request was issued
118 * @prot_status: protocol status
119 * @prot_status_qual: protocol status qualifier
120 * @fsf_status: fsf status
121 * @fsf_status_qual: fsf status qualifier
123 struct zfcp_dbf_hba_res
{
126 u8 prot_status_qual
[FSF_PROT_STATUS_QUAL_SIZE
];
128 u8 fsf_status_qual
[FSF_STATUS_QUALIFIER_SIZE
];
132 * struct zfcp_dbf_hba_uss - trace record for unsolicited status
133 * @status_type: type of unsolicited status
134 * @status_subtype: subtype of unsolicited status
135 * @d_id: destination ID
136 * @lun: logical unit number
137 * @queue_designator: queue designator
139 struct zfcp_dbf_hba_uss
{
144 u64 queue_designator
;
148 * enum zfcp_dbf_hba_id - HBA trace record identifier
149 * @ZFCP_DBF_HBA_RES: response trace record
150 * @ZFCP_DBF_HBA_USS: unsolicited status trace record
151 * @ZFCP_DBF_HBA_BIT: bit error trace record
153 enum zfcp_dbf_hba_id
{
154 ZFCP_DBF_HBA_RES
= 1,
155 ZFCP_DBF_HBA_USS
= 2,
156 ZFCP_DBF_HBA_BIT
= 3,
157 ZFCP_DBF_HBA_BASIC
= 4,
161 * struct zfcp_dbf_hba - common trace record for HBA records
162 * @id: unique number of recovery record type
163 * @tag: identifier string specifying the location of initiation
164 * @fsf_req_id: request id for fsf requests
165 * @fsf_req_status: status of fsf request
166 * @fsf_cmd: fsf command
167 * @fsf_seq_no: fsf sequence number
168 * @pl_len: length of payload stored as zfcp_dbf_pay
169 * @u: record type specific data
171 struct zfcp_dbf_hba
{
173 char tag
[ZFCP_DBF_TAG_LEN
];
180 struct zfcp_dbf_hba_res res
;
181 struct zfcp_dbf_hba_uss uss
;
182 struct fsf_bit_error_payload be
;
187 * enum zfcp_dbf_scsi_id - scsi trace record identifier
188 * @ZFCP_DBF_SCSI_CMND: scsi command trace record
190 enum zfcp_dbf_scsi_id
{
191 ZFCP_DBF_SCSI_CMND
= 1,
195 * struct zfcp_dbf_scsi - common trace record for SCSI records
196 * @id: unique number of recovery record type
197 * @tag: identifier string specifying the location of initiation
198 * @scsi_id: scsi device id
199 * @scsi_lun: scsi device logical unit number
200 * @scsi_result: scsi result
201 * @scsi_retries: current retry number of scsi request
202 * @scsi_allowed: allowed retries
203 * @fcp_rsp_info: FCP response info
204 * @scsi_opcode: scsi opcode
205 * @fsf_req_id: request id of fsf request
206 * @host_scribble: LLD specific data attached to SCSI request
207 * @pl_len: length of paload stored as zfcp_dbf_pay
208 * @fsf_rsp: response for fsf request
210 struct zfcp_dbf_scsi
{
212 char tag
[ZFCP_DBF_TAG_LEN
];
219 #define ZFCP_DBF_SCSI_OPCODE 16
220 u8 scsi_opcode
[ZFCP_DBF_SCSI_OPCODE
];
224 struct fcp_resp_with_ext fcp_rsp
;
228 * struct zfcp_dbf_pay - trace record for unformatted payload information
229 * @area: area this record is originated from
230 * @counter: ascending record number
231 * @fsf_req_id: request id of fsf request
232 * @data: unformatted data
234 struct zfcp_dbf_pay
{
236 char area
[ZFCP_DBF_TAG_LEN
];
238 #define ZFCP_DBF_PAY_MAX_REC 0x100
239 char data
[ZFCP_DBF_PAY_MAX_REC
];
243 * struct zfcp_dbf - main dbf trace structure
244 * @pay: reference to payload trace area
245 * @rec: reference to recovery trace area
246 * @hba: reference to hba trace area
247 * @san: reference to san trace area
248 * @scsi: reference to scsi trace area
249 * @pay_lock: lock protecting payload trace buffer
250 * @rec_lock: lock protecting recovery trace buffer
251 * @hba_lock: lock protecting hba trace buffer
252 * @san_lock: lock protecting san trace buffer
253 * @scsi_lock: lock protecting scsi trace buffer
254 * @pay_buf: pre-allocated buffer for payload
255 * @rec_buf: pre-allocated buffer for recovery
256 * @hba_buf: pre-allocated buffer for hba
257 * @san_buf: pre-allocated buffer for san
258 * @scsi_buf: pre-allocated buffer for scsi
270 spinlock_t scsi_lock
;
271 struct zfcp_dbf_pay pay_buf
;
272 struct zfcp_dbf_rec rec_buf
;
273 struct zfcp_dbf_hba hba_buf
;
274 struct zfcp_dbf_san san_buf
;
275 struct zfcp_dbf_scsi scsi_buf
;
279 void zfcp_dbf_hba_fsf_resp(char *tag
, int level
, struct zfcp_fsf_req
*req
)
281 if (debug_level_enabled(req
->adapter
->dbf
->hba
, level
))
282 zfcp_dbf_hba_fsf_res(tag
, req
);
286 * zfcp_dbf_hba_fsf_response - trace event for request completion
287 * @req: request that has been completed
290 void zfcp_dbf_hba_fsf_response(struct zfcp_fsf_req
*req
)
292 struct fsf_qtcb
*qtcb
= req
->qtcb
;
294 if ((qtcb
->prefix
.prot_status
!= FSF_PROT_GOOD
) &&
295 (qtcb
->prefix
.prot_status
!= FSF_PROT_FSF_STATUS_PRESENTED
)) {
296 zfcp_dbf_hba_fsf_resp("fs_perr", 1, req
);
298 } else if (qtcb
->header
.fsf_status
!= FSF_GOOD
) {
299 zfcp_dbf_hba_fsf_resp("fs_ferr", 1, req
);
301 } else if ((req
->fsf_command
== FSF_QTCB_OPEN_PORT_WITH_DID
) ||
302 (req
->fsf_command
== FSF_QTCB_OPEN_LUN
)) {
303 zfcp_dbf_hba_fsf_resp("fs_open", 4, req
);
305 } else if (qtcb
->header
.log_length
) {
306 zfcp_dbf_hba_fsf_resp("fs_qtcb", 5, req
);
309 zfcp_dbf_hba_fsf_resp("fs_norm", 6, req
);
314 void _zfcp_dbf_scsi(char *tag
, int level
, struct scsi_cmnd
*scmd
,
315 struct zfcp_fsf_req
*req
)
317 struct zfcp_adapter
*adapter
= (struct zfcp_adapter
*)
318 scmd
->device
->host
->hostdata
[0];
320 if (debug_level_enabled(adapter
->dbf
->scsi
, level
))
321 zfcp_dbf_scsi(tag
, scmd
, req
);
325 * zfcp_dbf_scsi_result - trace event for SCSI command completion
326 * @scmd: SCSI command pointer
327 * @req: FSF request used to issue SCSI command
330 void zfcp_dbf_scsi_result(struct scsi_cmnd
*scmd
, struct zfcp_fsf_req
*req
)
332 if (scmd
->result
!= 0)
333 _zfcp_dbf_scsi("rsl_err", 3, scmd
, req
);
334 else if (scmd
->retries
> 0)
335 _zfcp_dbf_scsi("rsl_ret", 4, scmd
, req
);
337 _zfcp_dbf_scsi("rsl_nor", 6, scmd
, req
);
341 * zfcp_dbf_scsi_fail_send - trace event for failure to send SCSI command
342 * @scmd: SCSI command pointer
345 void zfcp_dbf_scsi_fail_send(struct scsi_cmnd
*scmd
)
347 _zfcp_dbf_scsi("rsl_fai", 4, scmd
, NULL
);
351 * zfcp_dbf_scsi_abort - trace event for SCSI command abort
352 * @tag: tag indicating success or failure of abort operation
353 * @scmd: SCSI command to be aborted
354 * @fsf_req: request containing abort (might be NULL)
357 void zfcp_dbf_scsi_abort(char *tag
, struct scsi_cmnd
*scmd
,
358 struct zfcp_fsf_req
*fsf_req
)
360 _zfcp_dbf_scsi(tag
, 1, scmd
, fsf_req
);
364 * zfcp_dbf_scsi_devreset - trace event for Logical Unit or Target Reset
365 * @tag: tag indicating success or failure of reset operation
366 * @scmnd: SCSI command which caused this error recovery
367 * @flag: indicates type of reset (Target Reset, Logical Unit Reset)
370 void zfcp_dbf_scsi_devreset(char *tag
, struct scsi_cmnd
*scmnd
, u8 flag
)
372 char tmp_tag
[ZFCP_DBF_TAG_LEN
];
374 if (flag
== FCP_TMF_TGT_RESET
)
375 memcpy(tmp_tag
, "tr_", 3);
377 memcpy(tmp_tag
, "lr_", 3);
379 memcpy(&tmp_tag
[3], tag
, 4);
380 _zfcp_dbf_scsi(tmp_tag
, 1, scmnd
, NULL
);
383 #endif /* ZFCP_DBF_H */