This source file includes following definitions.
- zfcp_dbf_hba_fsf_resp_suppress
- zfcp_dbf_hba_fsf_resp
- zfcp_dbf_hba_fsf_response
- _zfcp_dbf_scsi
- zfcp_dbf_scsi_result
- zfcp_dbf_scsi_fail_send
- zfcp_dbf_scsi_abort
- zfcp_dbf_scsi_devreset
- zfcp_dbf_scsi_nullcmnd
1
2
3
4
5
6
7
8
9 #ifndef ZFCP_DBF_H
10 #define ZFCP_DBF_H
11
12 #include <scsi/fc/fc_fcp.h>
13 #include "zfcp_ext.h"
14 #include "zfcp_fsf.h"
15 #include "zfcp_def.h"
16
17 #define ZFCP_DBF_TAG_LEN 7
18
19 #define ZFCP_DBF_INVALID_LUN 0xFFFFFFFFFFFFFFFFull
20
21 enum zfcp_dbf_pseudo_erp_act_type {
22 ZFCP_PSEUDO_ERP_ACTION_RPORT_ADD = 0xff,
23 ZFCP_PSEUDO_ERP_ACTION_RPORT_DEL = 0xfe,
24 };
25
26
27
28
29
30
31
32
33 struct zfcp_dbf_rec_trigger {
34 u32 ready;
35 u32 running;
36 u8 want;
37 u8 need;
38 } __packed;
39
40
41
42
43
44
45
46
47
48 struct zfcp_dbf_rec_running {
49 u64 fsf_req_id;
50 u32 rec_status;
51 u16 rec_step;
52 u8 rec_action;
53 u8 rec_count;
54 } __packed;
55
56
57
58
59
60
61 enum zfcp_dbf_rec_id {
62 ZFCP_DBF_REC_TRIG = 1,
63 ZFCP_DBF_REC_RUN = 2,
64 };
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80 struct zfcp_dbf_rec {
81 u8 id;
82 char tag[ZFCP_DBF_TAG_LEN];
83 u64 lun;
84 u64 wwpn;
85 u32 d_id;
86 u32 adapter_status;
87 u32 port_status;
88 u32 lun_status;
89 union {
90 struct zfcp_dbf_rec_trigger trig;
91 struct zfcp_dbf_rec_running run;
92 } u;
93 } __packed;
94
95
96
97
98
99
100
101 enum zfcp_dbf_san_id {
102 ZFCP_DBF_SAN_REQ = 1,
103 ZFCP_DBF_SAN_RES = 2,
104 ZFCP_DBF_SAN_ELS = 3,
105 };
106
107
108
109
110
111
112
113
114 struct zfcp_dbf_san {
115 u8 id;
116 char tag[ZFCP_DBF_TAG_LEN];
117 u64 fsf_req_id;
118 u32 d_id;
119 #define ZFCP_DBF_SAN_MAX_PAYLOAD (FC_CT_HDR_LEN + 32)
120 char payload[ZFCP_DBF_SAN_MAX_PAYLOAD];
121 u16 pl_len;
122 } __packed;
123
124
125
126
127
128
129
130
131
132
133
134 struct zfcp_dbf_hba_res {
135 u64 req_issued;
136 u32 prot_status;
137 u8 prot_status_qual[FSF_PROT_STATUS_QUAL_SIZE];
138 u32 fsf_status;
139 u8 fsf_status_qual[FSF_STATUS_QUALIFIER_SIZE];
140 u32 port_handle;
141 u32 lun_handle;
142 } __packed;
143
144
145
146
147
148
149
150
151
152 struct zfcp_dbf_hba_uss {
153 u32 status_type;
154 u32 status_subtype;
155 u32 d_id;
156 u64 lun;
157 u64 queue_designator;
158 } __packed;
159
160
161
162
163
164
165
166
167 enum zfcp_dbf_hba_id {
168 ZFCP_DBF_HBA_RES = 1,
169 ZFCP_DBF_HBA_USS = 2,
170 ZFCP_DBF_HBA_BIT = 3,
171 ZFCP_DBF_HBA_BASIC = 4,
172 };
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188 struct zfcp_dbf_hba {
189 u8 id;
190 char tag[ZFCP_DBF_TAG_LEN];
191 u64 fsf_req_id;
192 u32 fsf_req_status;
193 u32 fsf_cmd;
194 u32 fsf_seq_no;
195 u16 pl_len;
196 union {
197 struct zfcp_dbf_hba_res res;
198 struct zfcp_dbf_hba_uss uss;
199 struct fsf_bit_error_payload be;
200 } u;
201 } __packed;
202
203
204
205
206
207 enum zfcp_dbf_scsi_id {
208 ZFCP_DBF_SCSI_CMND = 1,
209 };
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228 struct zfcp_dbf_scsi {
229 u8 id;
230 char tag[ZFCP_DBF_TAG_LEN];
231 u32 scsi_id;
232 u32 scsi_lun;
233 u32 scsi_result;
234 u8 scsi_retries;
235 u8 scsi_allowed;
236 u8 fcp_rsp_info;
237 #define ZFCP_DBF_SCSI_OPCODE 16
238 u8 scsi_opcode[ZFCP_DBF_SCSI_OPCODE];
239 u64 fsf_req_id;
240 u64 host_scribble;
241 u16 pl_len;
242 struct fcp_resp_with_ext fcp_rsp;
243 u32 scsi_lun_64_hi;
244 } __packed;
245
246
247
248
249
250
251
252
253 struct zfcp_dbf_pay {
254 u8 counter;
255 char area[ZFCP_DBF_TAG_LEN];
256 u64 fsf_req_id;
257 #define ZFCP_DBF_PAY_MAX_REC 0x100
258 char data[ZFCP_DBF_PAY_MAX_REC];
259 } __packed;
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279 struct zfcp_dbf {
280 debug_info_t *pay;
281 debug_info_t *rec;
282 debug_info_t *hba;
283 debug_info_t *san;
284 debug_info_t *scsi;
285 spinlock_t pay_lock;
286 spinlock_t rec_lock;
287 spinlock_t hba_lock;
288 spinlock_t san_lock;
289 spinlock_t scsi_lock;
290 struct zfcp_dbf_pay pay_buf;
291 struct zfcp_dbf_rec rec_buf;
292 struct zfcp_dbf_hba hba_buf;
293 struct zfcp_dbf_san san_buf;
294 struct zfcp_dbf_scsi scsi_buf;
295 };
296
297
298
299
300
301
302
303 static inline
304 bool zfcp_dbf_hba_fsf_resp_suppress(struct zfcp_fsf_req *req)
305 {
306 struct fsf_qtcb *qtcb = req->qtcb;
307 u32 fsf_stat = qtcb->header.fsf_status;
308 struct fcp_resp *fcp_rsp;
309 u8 rsp_flags, fr_status;
310
311 if (qtcb->prefix.qtcb_type != FSF_IO_COMMAND)
312 return false;
313 fcp_rsp = &qtcb->bottom.io.fcp_rsp.iu.resp;
314 rsp_flags = fcp_rsp->fr_flags;
315 fr_status = fcp_rsp->fr_status;
316 return (fsf_stat == FSF_FCP_RSP_AVAILABLE) &&
317 (rsp_flags == FCP_RESID_UNDER) &&
318 (fr_status == SAM_STAT_GOOD);
319 }
320
321 static inline
322 void zfcp_dbf_hba_fsf_resp(char *tag, int level, struct zfcp_fsf_req *req)
323 {
324 if (debug_level_enabled(req->adapter->dbf->hba, level))
325 zfcp_dbf_hba_fsf_res(tag, level, req);
326 }
327
328
329
330
331
332 static inline
333 void zfcp_dbf_hba_fsf_response(struct zfcp_fsf_req *req)
334 {
335 struct fsf_qtcb *qtcb = req->qtcb;
336
337 if (unlikely(req->status & (ZFCP_STATUS_FSFREQ_DISMISSED |
338 ZFCP_STATUS_FSFREQ_ERROR))) {
339 zfcp_dbf_hba_fsf_resp("fs_rerr", 3, req);
340
341 } else if ((qtcb->prefix.prot_status != FSF_PROT_GOOD) &&
342 (qtcb->prefix.prot_status != FSF_PROT_FSF_STATUS_PRESENTED)) {
343 zfcp_dbf_hba_fsf_resp("fs_perr", 1, req);
344
345 } else if (qtcb->header.fsf_status != FSF_GOOD) {
346 zfcp_dbf_hba_fsf_resp("fs_ferr",
347 zfcp_dbf_hba_fsf_resp_suppress(req)
348 ? 5 : 1, req);
349
350 } else if ((qtcb->header.fsf_command == FSF_QTCB_OPEN_PORT_WITH_DID) ||
351 (qtcb->header.fsf_command == FSF_QTCB_OPEN_LUN)) {
352 zfcp_dbf_hba_fsf_resp("fs_open", 4, req);
353
354 } else if (qtcb->header.log_length) {
355 zfcp_dbf_hba_fsf_resp("fs_qtcb", 5, req);
356
357 } else {
358 zfcp_dbf_hba_fsf_resp("fs_norm", 6, req);
359 }
360 }
361
362 static inline
363 void _zfcp_dbf_scsi(char *tag, int level, struct scsi_cmnd *scmd,
364 struct zfcp_fsf_req *req)
365 {
366 struct zfcp_adapter *adapter = (struct zfcp_adapter *)
367 scmd->device->host->hostdata[0];
368
369 if (debug_level_enabled(adapter->dbf->scsi, level))
370 zfcp_dbf_scsi_common(tag, level, scmd->device, scmd, req);
371 }
372
373
374
375
376
377
378 static inline
379 void zfcp_dbf_scsi_result(struct scsi_cmnd *scmd, struct zfcp_fsf_req *req)
380 {
381 if (scmd->result != 0)
382 _zfcp_dbf_scsi("rsl_err", 3, scmd, req);
383 else if (scmd->retries > 0)
384 _zfcp_dbf_scsi("rsl_ret", 4, scmd, req);
385 else
386 _zfcp_dbf_scsi("rsl_nor", 6, scmd, req);
387 }
388
389
390
391
392
393 static inline
394 void zfcp_dbf_scsi_fail_send(struct scsi_cmnd *scmd)
395 {
396 _zfcp_dbf_scsi("rsl_fai", 4, scmd, NULL);
397 }
398
399
400
401
402
403
404
405 static inline
406 void zfcp_dbf_scsi_abort(char *tag, struct scsi_cmnd *scmd,
407 struct zfcp_fsf_req *fsf_req)
408 {
409 _zfcp_dbf_scsi(tag, 1, scmd, fsf_req);
410 }
411
412
413
414
415
416
417
418
419 static inline
420 void zfcp_dbf_scsi_devreset(char *tag, struct scsi_device *sdev, u8 flag,
421 struct zfcp_fsf_req *fsf_req)
422 {
423 struct zfcp_adapter *adapter = (struct zfcp_adapter *)
424 sdev->host->hostdata[0];
425 char tmp_tag[ZFCP_DBF_TAG_LEN];
426 static int const level = 1;
427
428 if (unlikely(!debug_level_enabled(adapter->dbf->scsi, level)))
429 return;
430
431 if (flag == FCP_TMF_TGT_RESET)
432 memcpy(tmp_tag, "tr_", 3);
433 else
434 memcpy(tmp_tag, "lr_", 3);
435
436 memcpy(&tmp_tag[3], tag, 4);
437 zfcp_dbf_scsi_common(tmp_tag, level, sdev, NULL, fsf_req);
438 }
439
440
441
442
443
444
445 static inline void zfcp_dbf_scsi_nullcmnd(struct scsi_cmnd *scmnd,
446 struct zfcp_fsf_req *fsf_req)
447 {
448 _zfcp_dbf_scsi("scfc__1", 3, scmnd, fsf_req);
449 }
450
451 #endif