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