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