Merge master.kernel.org:/home/rmk/linux-2.6-arm
[deliverable/linux.git] / drivers / s390 / scsi / zfcp_dbf.h
1 /*
2 * This file is part of the zfcp device driver for
3 * FCP adapters for IBM System z9 and zSeries.
4 *
5 * Copyright IBM Corp. 2008, 2009
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
10 * any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22 #ifndef ZFCP_DBF_H
23 #define ZFCP_DBF_H
24
25 #include <scsi/fc/fc_fcp.h>
26 #include "zfcp_ext.h"
27 #include "zfcp_fsf.h"
28 #include "zfcp_def.h"
29
30 #define ZFCP_DBF_TAG_SIZE 4
31 #define ZFCP_DBF_ID_SIZE 7
32
33 struct zfcp_dbf_dump {
34 u8 tag[ZFCP_DBF_TAG_SIZE];
35 u32 total_size; /* size of total dump data */
36 u32 offset; /* how much data has being already dumped */
37 u32 size; /* how much data comes with this record */
38 u8 data[]; /* dump data */
39 } __attribute__ ((packed));
40
41 struct zfcp_dbf_rec_record_thread {
42 u32 total;
43 u32 ready;
44 u32 running;
45 };
46
47 struct zfcp_dbf_rec_record_target {
48 u64 ref;
49 u32 status;
50 u32 d_id;
51 u64 wwpn;
52 u64 fcp_lun;
53 u32 erp_count;
54 };
55
56 struct zfcp_dbf_rec_record_trigger {
57 u8 want;
58 u8 need;
59 u32 as;
60 u32 ps;
61 u32 us;
62 u64 ref;
63 u64 action;
64 u64 wwpn;
65 u64 fcp_lun;
66 };
67
68 struct zfcp_dbf_rec_record_action {
69 u32 status;
70 u32 step;
71 u64 action;
72 u64 fsf_req;
73 };
74
75 struct zfcp_dbf_rec_record {
76 u8 id;
77 char id2[7];
78 union {
79 struct zfcp_dbf_rec_record_action action;
80 struct zfcp_dbf_rec_record_thread thread;
81 struct zfcp_dbf_rec_record_target target;
82 struct zfcp_dbf_rec_record_trigger trigger;
83 } u;
84 };
85
86 enum {
87 ZFCP_REC_DBF_ID_ACTION,
88 ZFCP_REC_DBF_ID_THREAD,
89 ZFCP_REC_DBF_ID_TARGET,
90 ZFCP_REC_DBF_ID_TRIGGER,
91 };
92
93 struct zfcp_dbf_hba_record_response {
94 u32 fsf_command;
95 u64 fsf_reqid;
96 u32 fsf_seqno;
97 u64 fsf_issued;
98 u32 fsf_prot_status;
99 u32 fsf_status;
100 u8 fsf_prot_status_qual[FSF_PROT_STATUS_QUAL_SIZE];
101 u8 fsf_status_qual[FSF_STATUS_QUALIFIER_SIZE];
102 u32 fsf_req_status;
103 u8 sbal_first;
104 u8 sbal_last;
105 u8 sbal_response;
106 u8 pool;
107 u64 erp_action;
108 union {
109 struct {
110 u64 cmnd;
111 u64 serial;
112 } fcp;
113 struct {
114 u64 wwpn;
115 u32 d_id;
116 u32 port_handle;
117 } port;
118 struct {
119 u64 wwpn;
120 u64 fcp_lun;
121 u32 port_handle;
122 u32 lun_handle;
123 } unit;
124 struct {
125 u32 d_id;
126 } els;
127 } u;
128 } __attribute__ ((packed));
129
130 struct 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
144 struct zfcp_dbf_hba_record_qdio {
145 u32 qdio_error;
146 u8 sbal_index;
147 u8 sbal_count;
148 } __attribute__ ((packed));
149
150 struct 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
161 struct 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 u32 d_id;
170 } __attribute__ ((packed));
171
172 struct zfcp_dbf_san_record_ct_response {
173 u16 cmd_rsp_code;
174 u8 revision;
175 u8 reason_code;
176 u8 expl;
177 u8 vendor_unique;
178 u16 max_res_size;
179 u32 len;
180 } __attribute__ ((packed));
181
182 struct zfcp_dbf_san_record_els {
183 u32 d_id;
184 } __attribute__ ((packed));
185
186 struct zfcp_dbf_san_record {
187 u8 tag[ZFCP_DBF_TAG_SIZE];
188 u64 fsf_reqid;
189 u32 fsf_seqno;
190 union {
191 struct zfcp_dbf_san_record_ct_request ct_req;
192 struct zfcp_dbf_san_record_ct_response ct_resp;
193 struct zfcp_dbf_san_record_els els;
194 } u;
195 #define ZFCP_DBF_SAN_MAX_PAYLOAD 1024
196 u8 payload[32];
197 } __attribute__ ((packed));
198
199 struct zfcp_dbf_scsi_record {
200 u8 tag[ZFCP_DBF_TAG_SIZE];
201 u8 tag2[ZFCP_DBF_TAG_SIZE];
202 u32 scsi_id;
203 u32 scsi_lun;
204 u32 scsi_result;
205 u64 scsi_cmnd;
206 u64 scsi_serial;
207 #define ZFCP_DBF_SCSI_OPCODE 16
208 u8 scsi_opcode[ZFCP_DBF_SCSI_OPCODE];
209 u8 scsi_retries;
210 u8 scsi_allowed;
211 u64 fsf_reqid;
212 u32 fsf_seqno;
213 u64 fsf_issued;
214 u64 old_fsf_reqid;
215 u8 rsp_validity;
216 u8 rsp_scsi_status;
217 u32 rsp_resid;
218 u8 rsp_code;
219 #define ZFCP_DBF_SCSI_FCP_SNS_INFO 16
220 #define ZFCP_DBF_SCSI_MAX_FCP_SNS_INFO 256
221 u32 sns_info_len;
222 u8 sns_info[ZFCP_DBF_SCSI_FCP_SNS_INFO];
223 } __attribute__ ((packed));
224
225 struct zfcp_dbf {
226 debug_info_t *rec;
227 debug_info_t *hba;
228 debug_info_t *san;
229 debug_info_t *scsi;
230 spinlock_t rec_lock;
231 spinlock_t hba_lock;
232 spinlock_t san_lock;
233 spinlock_t scsi_lock;
234 struct zfcp_dbf_rec_record rec_buf;
235 struct zfcp_dbf_hba_record hba_buf;
236 struct zfcp_dbf_san_record san_buf;
237 struct zfcp_dbf_scsi_record scsi_buf;
238 struct zfcp_adapter *adapter;
239 };
240
241 static inline
242 void zfcp_dbf_hba_fsf_resp(const char *tag2, int level,
243 struct zfcp_fsf_req *req, struct zfcp_dbf *dbf)
244 {
245 if (level <= dbf->hba->level)
246 _zfcp_dbf_hba_fsf_response(tag2, level, req, dbf);
247 }
248
249 /**
250 * zfcp_dbf_hba_fsf_response - trace event for request completion
251 * @fsf_req: request that has been completed
252 */
253 static inline void zfcp_dbf_hba_fsf_response(struct zfcp_fsf_req *req)
254 {
255 struct zfcp_dbf *dbf = req->adapter->dbf;
256 struct fsf_qtcb *qtcb = req->qtcb;
257
258 if ((qtcb->prefix.prot_status != FSF_PROT_GOOD) &&
259 (qtcb->prefix.prot_status != FSF_PROT_FSF_STATUS_PRESENTED)) {
260 zfcp_dbf_hba_fsf_resp("perr", 1, req, dbf);
261
262 } else if (qtcb->header.fsf_status != FSF_GOOD) {
263 zfcp_dbf_hba_fsf_resp("ferr", 1, req, dbf);
264
265 } else if ((req->fsf_command == FSF_QTCB_OPEN_PORT_WITH_DID) ||
266 (req->fsf_command == FSF_QTCB_OPEN_LUN)) {
267 zfcp_dbf_hba_fsf_resp("open", 4, req, dbf);
268
269 } else if (qtcb->header.log_length) {
270 zfcp_dbf_hba_fsf_resp("qtcb", 5, req, dbf);
271
272 } else {
273 zfcp_dbf_hba_fsf_resp("norm", 6, req, dbf);
274 }
275 }
276
277 /**
278 * zfcp_dbf_hba_fsf_unsol - trace event for an unsolicited status buffer
279 * @tag: tag indicating which kind of unsolicited status has been received
280 * @dbf: reference to dbf structure
281 * @status_buffer: buffer containing payload of unsolicited status
282 */
283 static inline
284 void zfcp_dbf_hba_fsf_unsol(const char *tag, struct zfcp_dbf *dbf,
285 struct fsf_status_read_buffer *buf)
286 {
287 int level = 2;
288
289 if (level <= dbf->hba->level)
290 _zfcp_dbf_hba_fsf_unsol(tag, level, dbf, buf);
291 }
292
293 static inline
294 void zfcp_dbf_scsi(const char *tag, const char *tag2, int level,
295 struct zfcp_dbf *dbf, struct scsi_cmnd *scmd,
296 struct zfcp_fsf_req *req, unsigned long old_id)
297 {
298 if (level <= dbf->scsi->level)
299 _zfcp_dbf_scsi(tag, tag2, level, dbf, scmd, req, old_id);
300 }
301
302 /**
303 * zfcp_dbf_scsi_result - trace event for SCSI command completion
304 * @tag: tag indicating success or failure of SCSI command
305 * @level: trace level applicable for this event
306 * @adapter: adapter that has been used to issue the SCSI command
307 * @scmd: SCSI command pointer
308 * @fsf_req: request used to issue SCSI command (might be NULL)
309 */
310 static inline
311 void zfcp_dbf_scsi_result(const char *tag, int level, struct zfcp_dbf *dbf,
312 struct scsi_cmnd *scmd, struct zfcp_fsf_req *fsf_req)
313 {
314 zfcp_dbf_scsi("rslt", tag, level, dbf, scmd, fsf_req, 0);
315 }
316
317 /**
318 * zfcp_dbf_scsi_abort - trace event for SCSI command abort
319 * @tag: tag indicating success or failure of abort operation
320 * @adapter: adapter thas has been used to issue SCSI command to be aborted
321 * @scmd: SCSI command to be aborted
322 * @new_req: request containing abort (might be NULL)
323 * @old_id: identifier of request containg SCSI command to be aborted
324 */
325 static inline
326 void zfcp_dbf_scsi_abort(const char *tag, struct zfcp_dbf *dbf,
327 struct scsi_cmnd *scmd, struct zfcp_fsf_req *new_req,
328 unsigned long old_id)
329 {
330 zfcp_dbf_scsi("abrt", tag, 1, dbf, scmd, new_req, old_id);
331 }
332
333 /**
334 * zfcp_dbf_scsi_devreset - trace event for Logical Unit or Target Reset
335 * @tag: tag indicating success or failure of reset operation
336 * @flag: indicates type of reset (Target Reset, Logical Unit Reset)
337 * @unit: unit that needs reset
338 * @scsi_cmnd: SCSI command which caused this error recovery
339 */
340 static inline
341 void zfcp_dbf_scsi_devreset(const char *tag, u8 flag, struct zfcp_unit *unit,
342 struct scsi_cmnd *scsi_cmnd)
343 {
344 zfcp_dbf_scsi(flag == FCP_TMF_TGT_RESET ? "trst" : "lrst", tag, 1,
345 unit->port->adapter->dbf, scsi_cmnd, NULL, 0);
346 }
347
348 #endif /* ZFCP_DBF_H */
This page took 0.046073 seconds and 5 git commands to generate.