1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22#ifndef ZFCP_DBF_H
23#define ZFCP_DBF_H
24
25#include "zfcp_ext.h"
26#include "zfcp_fsf.h"
27#include "zfcp_def.h"
28
29#define ZFCP_DBF_TAG_SIZE 4
30#define ZFCP_DBF_ID_SIZE 7
31
32struct zfcp_dbf_dump {
33 u8 tag[ZFCP_DBF_TAG_SIZE];
34 u32 total_size;
35 u32 offset;
36 u32 size;
37 u8 data[];
38} __attribute__ ((packed));
39
40struct zfcp_dbf_rec_record_thread {
41 u32 total;
42 u32 ready;
43 u32 running;
44};
45
46struct zfcp_dbf_rec_record_target {
47 u64 ref;
48 u32 status;
49 u32 d_id;
50 u64 wwpn;
51 u64 fcp_lun;
52 u32 erp_count;
53};
54
55struct zfcp_dbf_rec_record_trigger {
56 u8 want;
57 u8 need;
58 u32 as;
59 u32 ps;
60 u32 us;
61 u64 ref;
62 u64 action;
63 u64 wwpn;
64 u64 fcp_lun;
65};
66
67struct zfcp_dbf_rec_record_action {
68 u32 status;
69 u32 step;
70 u64 action;
71 u64 fsf_req;
72};
73
74struct zfcp_dbf_rec_record {
75 u8 id;
76 char id2[7];
77 union {
78 struct zfcp_dbf_rec_record_action action;
79 struct zfcp_dbf_rec_record_thread thread;
80 struct zfcp_dbf_rec_record_target target;
81 struct zfcp_dbf_rec_record_trigger trigger;
82 } u;
83};
84
85enum {
86 ZFCP_REC_DBF_ID_ACTION,
87 ZFCP_REC_DBF_ID_THREAD,
88 ZFCP_REC_DBF_ID_TARGET,
89 ZFCP_REC_DBF_ID_TRIGGER,
90};
91
92struct zfcp_dbf_hba_record_response {
93 u32 fsf_command;
94 u64 fsf_reqid;
95 u32 fsf_seqno;
96 u64 fsf_issued;
97 u32 fsf_prot_status;
98 u32 fsf_status;
99 u8 fsf_prot_status_qual[FSF_PROT_STATUS_QUAL_SIZE];
100 u8 fsf_status_qual[FSF_STATUS_QUALIFIER_SIZE];
101 u32 fsf_req_status;
102 u8 sbal_first;
103 u8 sbal_last;
104 u8 sbal_response;
105 u8 pool;
106 u64 erp_action;
107 union {
108 struct {
109 u64 cmnd;
110 u64 serial;
111 } fcp;
112 struct {
113 u64 wwpn;
114 u32 d_id;
115 u32 port_handle;
116 } port;
117 struct {
118 u64 wwpn;
119 u64 fcp_lun;
120 u32 port_handle;
121 u32 lun_handle;
122 } unit;
123 struct {
124 u32 d_id;
125 u8 ls_code;
126 } els;
127 } u;
128} __attribute__ ((packed));
129
130struct zfcp_dbf_hba_record_status {
131 u8 failed;
132 u32 status_type;
133 u32 status_subtype;
134 struct fsf_queue_designator
135 queue_designator;
136 u32 payload_size;
137#define ZFCP_DBF_UNSOL_PAYLOAD 80
138#define ZFCP_DBF_UNSOL_PAYLOAD_SENSE_DATA_AVAIL 32
139#define ZFCP_DBF_UNSOL_PAYLOAD_BIT_ERROR_THRESHOLD 56
140#define ZFCP_DBF_UNSOL_PAYLOAD_FEATURE_UPDATE_ALERT 2 * sizeof(u32)
141 u8 payload[ZFCP_DBF_UNSOL_PAYLOAD];
142} __attribute__ ((packed));
143
144struct zfcp_dbf_hba_record_qdio {
145 u32 qdio_error;
146 u8 sbal_index;
147 u8 sbal_count;
148} __attribute__ ((packed));
149
150struct zfcp_dbf_hba_record {
151 u8 tag[ZFCP_DBF_TAG_SIZE];
152 u8 tag2[ZFCP_DBF_TAG_SIZE];
153 union {
154 struct zfcp_dbf_hba_record_response response;
155 struct zfcp_dbf_hba_record_status status;
156 struct zfcp_dbf_hba_record_qdio qdio;
157 struct fsf_bit_error_payload berr;
158 } u;
159} __attribute__ ((packed));
160
161struct zfcp_dbf_san_record_ct_request {
162 u16 cmd_req_code;
163 u8 revision;
164 u8 gs_type;
165 u8 gs_subtype;
166 u8 options;
167 u16 max_res_size;
168 u32 len;
169} __attribute__ ((packed));
170
171struct zfcp_dbf_san_record_ct_response {
172 u16 cmd_rsp_code;
173 u8 revision;
174 u8 reason_code;
175 u8 expl;
176 u8 vendor_unique;
177 u16 max_res_size;
178 u32 len;
179} __attribute__ ((packed));
180
181struct zfcp_dbf_san_record_els {
182 u8 ls_code;
183 u32 len;
184} __attribute__ ((packed));
185
186struct zfcp_dbf_san_record {
187 u8 tag[ZFCP_DBF_TAG_SIZE];
188 u64 fsf_reqid;
189 u32 fsf_seqno;
190 u32 s_id;
191 u32 d_id;
192 union {
193 struct zfcp_dbf_san_record_ct_request ct_req;
194 struct zfcp_dbf_san_record_ct_response ct_resp;
195 struct zfcp_dbf_san_record_els els;
196 } u;
197#define ZFCP_DBF_SAN_MAX_PAYLOAD 1024
198 u8 payload[32];
199} __attribute__ ((packed));
200
201struct zfcp_dbf_scsi_record {
202 u8 tag[ZFCP_DBF_TAG_SIZE];
203 u8 tag2[ZFCP_DBF_TAG_SIZE];
204 u32 scsi_id;
205 u32 scsi_lun;
206 u32 scsi_result;
207 u64 scsi_cmnd;
208 u64 scsi_serial;
209#define ZFCP_DBF_SCSI_OPCODE 16
210 u8 scsi_opcode[ZFCP_DBF_SCSI_OPCODE];
211 u8 scsi_retries;
212 u8 scsi_allowed;
213 u64 fsf_reqid;
214 u32 fsf_seqno;
215 u64 fsf_issued;
216 u64 old_fsf_reqid;
217 u8 rsp_validity;
218 u8 rsp_scsi_status;
219 u32 rsp_resid;
220 u8 rsp_code;
221#define ZFCP_DBF_SCSI_FCP_SNS_INFO 16
222#define ZFCP_DBF_SCSI_MAX_FCP_SNS_INFO 256
223 u32 sns_info_len;
224 u8 sns_info[ZFCP_DBF_SCSI_FCP_SNS_INFO];
225} __attribute__ ((packed));
226
227struct zfcp_dbf {
228 debug_info_t *rec;
229 debug_info_t *hba;
230 debug_info_t *san;
231 debug_info_t *scsi;
232 spinlock_t rec_lock;
233 spinlock_t hba_lock;
234 spinlock_t san_lock;
235 spinlock_t scsi_lock;
236 struct zfcp_dbf_rec_record rec_buf;
237 struct zfcp_dbf_hba_record hba_buf;
238 struct zfcp_dbf_san_record san_buf;
239 struct zfcp_dbf_scsi_record scsi_buf;
240 struct zfcp_adapter *adapter;
241};
242
243static inline
244void zfcp_dbf_hba_fsf_resp(const char *tag2, int level,
245 struct zfcp_fsf_req *req, struct zfcp_dbf *dbf)
246{
247 if (level <= dbf->hba->level)
248 _zfcp_dbf_hba_fsf_response(tag2, level, req, dbf);
249}
250
251
252
253
254
255static inline void zfcp_dbf_hba_fsf_response(struct zfcp_fsf_req *req)
256{
257 struct zfcp_dbf *dbf = req->adapter->dbf;
258 struct fsf_qtcb *qtcb = req->qtcb;
259
260 if ((qtcb->prefix.prot_status != FSF_PROT_GOOD) &&
261 (qtcb->prefix.prot_status != FSF_PROT_FSF_STATUS_PRESENTED)) {
262 zfcp_dbf_hba_fsf_resp("perr", 1, req, dbf);
263
264 } else if (qtcb->header.fsf_status != FSF_GOOD) {
265 zfcp_dbf_hba_fsf_resp("ferr", 1, req, dbf);
266
267 } else if ((req->fsf_command == FSF_QTCB_OPEN_PORT_WITH_DID) ||
268 (req->fsf_command == FSF_QTCB_OPEN_LUN)) {
269 zfcp_dbf_hba_fsf_resp("open", 4, req, dbf);
270
271 } else if (qtcb->header.log_length) {
272 zfcp_dbf_hba_fsf_resp("qtcb", 5, req, dbf);
273
274 } else {
275 zfcp_dbf_hba_fsf_resp("norm", 6, req, dbf);
276 }
277 }
278
279
280
281
282
283
284
285static inline
286void zfcp_dbf_hba_fsf_unsol(const char *tag, struct zfcp_dbf *dbf,
287 struct fsf_status_read_buffer *buf)
288{
289 int level = 2;
290
291 if (level <= dbf->hba->level)
292 _zfcp_dbf_hba_fsf_unsol(tag, level, dbf, buf);
293}
294
295static inline
296void zfcp_dbf_scsi(const char *tag, const char *tag2, int level,
297 struct zfcp_dbf *dbf, struct scsi_cmnd *scmd,
298 struct zfcp_fsf_req *req, unsigned long old_id)
299{
300 if (level <= dbf->scsi->level)
301 _zfcp_dbf_scsi(tag, tag2, level, dbf, scmd, req, old_id);
302}
303
304
305
306
307
308
309
310
311
312static inline
313void zfcp_dbf_scsi_result(const char *tag, int level, struct zfcp_dbf *dbf,
314 struct scsi_cmnd *scmd, struct zfcp_fsf_req *fsf_req)
315{
316 zfcp_dbf_scsi("rslt", tag, level, dbf, scmd, fsf_req, 0);
317}
318
319
320
321
322
323
324
325
326
327static inline
328void zfcp_dbf_scsi_abort(const char *tag, struct zfcp_dbf *dbf,
329 struct scsi_cmnd *scmd, struct zfcp_fsf_req *new_req,
330 unsigned long old_id)
331{
332 zfcp_dbf_scsi("abrt", tag, 1, dbf, scmd, new_req, old_id);
333}
334
335
336
337
338
339
340
341
342static inline
343void zfcp_dbf_scsi_devreset(const char *tag, u8 flag, struct zfcp_unit *unit,
344 struct scsi_cmnd *scsi_cmnd)
345{
346 zfcp_dbf_scsi(flag == FCP_TARGET_RESET ? "trst" : "lrst", tag, 1,
347 unit->port->adapter->dbf, scsi_cmnd, NULL, 0);
348}
349
350#endif
351