[SCSI] zfcp: Rename sysfs_device attribute to dev in zfcp_unit and zfcp_port
[linux-2.6-block.git] / drivers / s390 / scsi / zfcp_dbf.h
CommitLineData
2b604c9b
CS
1/*
2 * This file is part of the zfcp device driver for
3 * FCP adapters for IBM System z9 and zSeries.
4 *
d46f384a 5 * Copyright IBM Corp. 2008, 2009
2b604c9b
CS
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
4318e08c 25#include <scsi/fc/fc_fcp.h>
dcd20e23 26#include "zfcp_ext.h"
2b604c9b 27#include "zfcp_fsf.h"
dcd20e23 28#include "zfcp_def.h"
2b604c9b
CS
29
30#define ZFCP_DBF_TAG_SIZE 4
5ffd51a5 31#define ZFCP_DBF_ID_SIZE 7
2b604c9b 32
d21e9daa
CS
33#define ZFCP_DBF_INVALID_LUN 0xFFFFFFFFFFFFFFFFull
34
2b604c9b
CS
35struct zfcp_dbf_dump {
36 u8 tag[ZFCP_DBF_TAG_SIZE];
37 u32 total_size; /* size of total dump data */
38 u32 offset; /* how much data has being already dumped */
39 u32 size; /* how much data comes with this record */
40 u8 data[]; /* dump data */
41} __attribute__ ((packed));
42
5771710b 43struct zfcp_dbf_rec_record_thread {
2b604c9b
CS
44 u32 total;
45 u32 ready;
46 u32 running;
7337891f 47};
2b604c9b 48
5771710b 49struct zfcp_dbf_rec_record_target {
2b604c9b
CS
50 u64 ref;
51 u32 status;
52 u32 d_id;
53 u64 wwpn;
54 u64 fcp_lun;
55 u32 erp_count;
7337891f 56};
2b604c9b 57
5771710b 58struct zfcp_dbf_rec_record_trigger {
2b604c9b
CS
59 u8 want;
60 u8 need;
61 u32 as;
62 u32 ps;
63 u32 us;
64 u64 ref;
65 u64 action;
66 u64 wwpn;
67 u64 fcp_lun;
7337891f 68};
2b604c9b 69
5771710b 70struct zfcp_dbf_rec_record_action {
2b604c9b
CS
71 u32 status;
72 u32 step;
73 u64 action;
74 u64 fsf_req;
7337891f 75};
2b604c9b 76
5771710b 77struct zfcp_dbf_rec_record {
2b604c9b 78 u8 id;
5ffd51a5 79 char id2[7];
2b604c9b 80 union {
5771710b
SS
81 struct zfcp_dbf_rec_record_action action;
82 struct zfcp_dbf_rec_record_thread thread;
83 struct zfcp_dbf_rec_record_target target;
84 struct zfcp_dbf_rec_record_trigger trigger;
2b604c9b 85 } u;
7337891f 86};
2b604c9b
CS
87
88enum {
89 ZFCP_REC_DBF_ID_ACTION,
90 ZFCP_REC_DBF_ID_THREAD,
91 ZFCP_REC_DBF_ID_TARGET,
92 ZFCP_REC_DBF_ID_TRIGGER,
93};
94
5771710b 95struct zfcp_dbf_hba_record_response {
2b604c9b
CS
96 u32 fsf_command;
97 u64 fsf_reqid;
98 u32 fsf_seqno;
99 u64 fsf_issued;
100 u32 fsf_prot_status;
101 u32 fsf_status;
102 u8 fsf_prot_status_qual[FSF_PROT_STATUS_QUAL_SIZE];
103 u8 fsf_status_qual[FSF_STATUS_QUALIFIER_SIZE];
104 u32 fsf_req_status;
105 u8 sbal_first;
e891bffe 106 u8 sbal_last;
c3baa9a2 107 u8 sbal_response;
2b604c9b
CS
108 u8 pool;
109 u64 erp_action;
110 union {
111 struct {
6bc473dd
MP
112 u64 cmnd;
113 u64 serial;
114 } fcp;
2b604c9b
CS
115 struct {
116 u64 wwpn;
117 u32 d_id;
118 u32 port_handle;
119 } port;
120 struct {
121 u64 wwpn;
122 u64 fcp_lun;
123 u32 port_handle;
124 u32 lun_handle;
125 } unit;
126 struct {
127 u32 d_id;
6bc473dd
MP
128 } els;
129 } u;
2b604c9b
CS
130} __attribute__ ((packed));
131
5771710b 132struct zfcp_dbf_hba_record_status {
2b604c9b
CS
133 u8 failed;
134 u32 status_type;
135 u32 status_subtype;
136 struct fsf_queue_designator
137 queue_designator;
138 u32 payload_size;
139#define ZFCP_DBF_UNSOL_PAYLOAD 80
140#define ZFCP_DBF_UNSOL_PAYLOAD_SENSE_DATA_AVAIL 32
141#define ZFCP_DBF_UNSOL_PAYLOAD_BIT_ERROR_THRESHOLD 56
142#define ZFCP_DBF_UNSOL_PAYLOAD_FEATURE_UPDATE_ALERT 2 * sizeof(u32)
143 u8 payload[ZFCP_DBF_UNSOL_PAYLOAD];
144} __attribute__ ((packed));
145
5771710b 146struct zfcp_dbf_hba_record_qdio {
2b604c9b 147 u32 qdio_error;
2b604c9b
CS
148 u8 sbal_index;
149 u8 sbal_count;
150} __attribute__ ((packed));
151
5771710b 152struct zfcp_dbf_hba_record {
2b604c9b
CS
153 u8 tag[ZFCP_DBF_TAG_SIZE];
154 u8 tag2[ZFCP_DBF_TAG_SIZE];
155 union {
5771710b
SS
156 struct zfcp_dbf_hba_record_response response;
157 struct zfcp_dbf_hba_record_status status;
158 struct zfcp_dbf_hba_record_qdio qdio;
57069386 159 struct fsf_bit_error_payload berr;
6bc473dd 160 } u;
2b604c9b
CS
161} __attribute__ ((packed));
162
5771710b 163struct zfcp_dbf_san_record_ct_request {
6bc473dd
MP
164 u16 cmd_req_code;
165 u8 revision;
166 u8 gs_type;
167 u8 gs_subtype;
168 u8 options;
169 u16 max_res_size;
170 u32 len;
7c7dc196 171 u32 d_id;
2b604c9b
CS
172} __attribute__ ((packed));
173
5771710b 174struct zfcp_dbf_san_record_ct_response {
6bc473dd
MP
175 u16 cmd_rsp_code;
176 u8 revision;
177 u8 reason_code;
178 u8 expl;
179 u8 vendor_unique;
39eb7e9a 180 u16 max_res_size;
6bc473dd 181 u32 len;
6bc473dd
MP
182} __attribute__ ((packed));
183
5771710b 184struct zfcp_dbf_san_record_els {
7c7dc196 185 u32 d_id;
2b604c9b
CS
186} __attribute__ ((packed));
187
5771710b 188struct zfcp_dbf_san_record {
2b604c9b
CS
189 u8 tag[ZFCP_DBF_TAG_SIZE];
190 u64 fsf_reqid;
191 u32 fsf_seqno;
2b604c9b 192 union {
5771710b
SS
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;
6bc473dd 196 } u;
2b604c9b
CS
197} __attribute__ ((packed));
198
67feeeba
CS
199#define ZFCP_DBF_SAN_MAX_PAYLOAD 1024
200
5771710b 201struct zfcp_dbf_scsi_record {
2b604c9b
CS
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;
6bc473dd
MP
216 u64 old_fsf_reqid;
217 u8 rsp_validity;
218 u8 rsp_scsi_status;
219 u32 rsp_resid;
220 u8 rsp_code;
2b604c9b
CS
221#define ZFCP_DBF_SCSI_FCP_SNS_INFO 16
222#define ZFCP_DBF_SCSI_MAX_FCP_SNS_INFO 256
6bc473dd
MP
223 u32 sns_info_len;
224 u8 sns_info[ZFCP_DBF_SCSI_FCP_SNS_INFO];
2b604c9b
CS
225} __attribute__ ((packed));
226
d46f384a 227struct zfcp_dbf {
5771710b
SS
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;
d46f384a
CS
241};
242
2e261af8 243static inline
5771710b
SS
244void zfcp_dbf_hba_fsf_resp(const char *tag2, int level,
245 struct zfcp_fsf_req *req, struct zfcp_dbf *dbf)
2e261af8 246{
5771710b
SS
247 if (level <= dbf->hba->level)
248 _zfcp_dbf_hba_fsf_response(tag2, level, req, dbf);
2e261af8
CS
249}
250
251/**
5771710b 252 * zfcp_dbf_hba_fsf_response - trace event for request completion
2e261af8
CS
253 * @fsf_req: request that has been completed
254 */
5771710b 255static inline void zfcp_dbf_hba_fsf_response(struct zfcp_fsf_req *req)
2e261af8
CS
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)) {
5771710b 262 zfcp_dbf_hba_fsf_resp("perr", 1, req, dbf);
2e261af8
CS
263
264 } else if (qtcb->header.fsf_status != FSF_GOOD) {
5771710b 265 zfcp_dbf_hba_fsf_resp("ferr", 1, req, dbf);
2e261af8
CS
266
267 } else if ((req->fsf_command == FSF_QTCB_OPEN_PORT_WITH_DID) ||
268 (req->fsf_command == FSF_QTCB_OPEN_LUN)) {
5771710b 269 zfcp_dbf_hba_fsf_resp("open", 4, req, dbf);
2e261af8
CS
270
271 } else if (qtcb->header.log_length) {
5771710b 272 zfcp_dbf_hba_fsf_resp("qtcb", 5, req, dbf);
2e261af8
CS
273
274 } else {
5771710b 275 zfcp_dbf_hba_fsf_resp("norm", 6, req, dbf);
2e261af8
CS
276 }
277 }
278
279/**
5771710b 280 * zfcp_dbf_hba_fsf_unsol - trace event for an unsolicited status buffer
2e261af8 281 * @tag: tag indicating which kind of unsolicited status has been received
5771710b 282 * @dbf: reference to dbf structure
2e261af8
CS
283 * @status_buffer: buffer containing payload of unsolicited status
284 */
285static inline
5771710b
SS
286void zfcp_dbf_hba_fsf_unsol(const char *tag, struct zfcp_dbf *dbf,
287 struct fsf_status_read_buffer *buf)
2e261af8 288{
2e261af8
CS
289 int level = 2;
290
5771710b
SS
291 if (level <= dbf->hba->level)
292 _zfcp_dbf_hba_fsf_unsol(tag, level, dbf, buf);
2e261af8
CS
293}
294
dcd20e23 295static inline
5771710b
SS
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)
dcd20e23 299{
5771710b
SS
300 if (level <= dbf->scsi->level)
301 _zfcp_dbf_scsi(tag, tag2, level, dbf, scmd, req, old_id);
dcd20e23
CS
302}
303
304/**
5771710b 305 * zfcp_dbf_scsi_result - trace event for SCSI command completion
dcd20e23
CS
306 * @tag: tag indicating success or failure of SCSI command
307 * @level: trace level applicable for this event
308 * @adapter: adapter that has been used to issue the SCSI command
309 * @scmd: SCSI command pointer
310 * @fsf_req: request used to issue SCSI command (might be NULL)
311 */
312static inline
5771710b
SS
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)
dcd20e23 315{
5771710b 316 zfcp_dbf_scsi("rslt", tag, level, dbf, scmd, fsf_req, 0);
dcd20e23
CS
317}
318
319/**
5771710b 320 * zfcp_dbf_scsi_abort - trace event for SCSI command abort
dcd20e23
CS
321 * @tag: tag indicating success or failure of abort operation
322 * @adapter: adapter thas has been used to issue SCSI command to be aborted
323 * @scmd: SCSI command to be aborted
324 * @new_req: request containing abort (might be NULL)
325 * @old_id: identifier of request containg SCSI command to be aborted
326 */
327static inline
5771710b
SS
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)
dcd20e23 331{
5771710b 332 zfcp_dbf_scsi("abrt", tag, 1, dbf, scmd, new_req, old_id);
dcd20e23
CS
333}
334
335/**
5771710b 336 * zfcp_dbf_scsi_devreset - trace event for Logical Unit or Target Reset
dcd20e23
CS
337 * @tag: tag indicating success or failure of reset operation
338 * @flag: indicates type of reset (Target Reset, Logical Unit Reset)
339 * @unit: unit that needs reset
340 * @scsi_cmnd: SCSI command which caused this error recovery
341 */
342static inline
5771710b
SS
343void zfcp_dbf_scsi_devreset(const char *tag, u8 flag, struct zfcp_unit *unit,
344 struct scsi_cmnd *scsi_cmnd)
dcd20e23 345{
4318e08c 346 zfcp_dbf_scsi(flag == FCP_TMF_TGT_RESET ? "trst" : "lrst", tag, 1,
5771710b 347 unit->port->adapter->dbf, scsi_cmnd, NULL, 0);
dcd20e23
CS
348}
349
2b604c9b 350#endif /* ZFCP_DBF_H */