[SCSI] zfcp: Update FSF error reporting
[deliverable/linux.git] / drivers / s390 / scsi / zfcp_def.h
CommitLineData
41fa2ada 1/*
553448f6 2 * zfcp device driver
1da177e4 3 *
553448f6 4 * Global definitions for the zfcp device driver.
41fa2ada 5 *
a2fa0aed 6 * Copyright IBM Corporation 2002, 2009
41fa2ada 7 */
1da177e4 8
1da177e4
LT
9#ifndef ZFCP_DEF_H
10#define ZFCP_DEF_H
11
1da177e4
LT
12/*************************** INCLUDES *****************************************/
13
14#include <linux/init.h>
15#include <linux/moduleparam.h>
1da177e4
LT
16#include <linux/major.h>
17#include <linux/blkdev.h>
18#include <linux/delay.h>
19#include <linux/timer.h>
dd52e0ea
HC
20#include <linux/slab.h>
21#include <linux/mempool.h>
22#include <linux/syscalls.h>
f1346372 23#include <linux/scatterlist.h>
dd52e0ea 24#include <linux/ioctl.h>
9d544f2b
SS
25#include <scsi/fc/fc_fs.h>
26#include <scsi/fc/fc_gs.h>
1da177e4
LT
27#include <scsi/scsi.h>
28#include <scsi/scsi_tcq.h>
29#include <scsi/scsi_cmnd.h>
30#include <scsi/scsi_device.h>
31#include <scsi/scsi_host.h>
32#include <scsi/scsi_transport.h>
33#include <scsi/scsi_transport_fc.h>
9d544f2b 34#include <scsi/scsi_bsg_fc.h>
1da177e4
LT
35#include <asm/ccwdev.h>
36#include <asm/qdio.h>
37#include <asm/debug.h>
38#include <asm/ebcdic.h>
bd43a42b 39#include <asm/sysinfo.h>
dd52e0ea 40#include "zfcp_fsf.h"
1da177e4 41
1da177e4
LT
42/********************* GENERAL DEFINES *********************************/
43
06506d00 44#define REQUEST_LIST_SIZE 128
1da177e4 45
06506d00 46/********************* SCSI SPECIFIC DEFINES *********************************/
f6c0e7a7 47#define ZFCP_SCSI_ER_TIMEOUT (10*HZ)
1da177e4
LT
48
49/********************* CIO/QDIO SPECIFIC DEFINES *****************************/
50
1da177e4
LT
51/* DMQ bug workaround: don't use last SBALE */
52#define ZFCP_MAX_SBALES_PER_SBAL (QDIO_MAX_ELEMENTS_PER_BUFFER - 1)
53
54/* index of last SBALE (with respect to DMQ bug workaround) */
55#define ZFCP_LAST_SBALE_PER_SBAL (ZFCP_MAX_SBALES_PER_SBAL - 1)
56
57/* max. number of (data buffer) SBALEs in largest SBAL chain */
58#define ZFCP_MAX_SBALES_PER_REQ \
c41f8cbd 59 (FSF_MAX_SBALS_PER_REQ * ZFCP_MAX_SBALES_PER_SBAL - 2)
1da177e4
LT
60 /* request ID + QTCB in SBALE 0 + 1 of first SBAL in chain */
61
8d1a0060
SS
62#define ZFCP_MAX_SECTORS (ZFCP_MAX_SBALES_PER_REQ * 8)
63 /* max. number of (data buffer) SBALEs in largest SBAL chain
64 multiplied with number of sectors per 4k block */
65
1da177e4
LT
66/********************* FSF SPECIFIC DEFINES *********************************/
67
1da177e4
LT
68/* ATTENTION: value must not be used by hardware */
69#define FSF_QTCB_UNSOLICITED_STATUS 0x6305
22753fa5 70
1da177e4 71/* timeout value for "default timer" for fsf requests */
2abbe866 72#define ZFCP_FSF_REQUEST_TIMEOUT (60*HZ)
1da177e4 73
1da177e4
LT
74/*************** ADAPTER/PORT/UNIT AND FSF_REQ STATUS FLAGS ******************/
75
41fa2ada
SS
76/*
77 * Note, the leftmost status byte is common among adapter, port
1da177e4
LT
78 * and unit
79 */
80#define ZFCP_COMMON_FLAGS 0xfff00000
1da177e4
LT
81
82/* common status bits */
1da177e4
LT
83#define ZFCP_STATUS_COMMON_RUNNING 0x40000000
84#define ZFCP_STATUS_COMMON_ERP_FAILED 0x20000000
85#define ZFCP_STATUS_COMMON_UNBLOCKED 0x10000000
1da177e4 86#define ZFCP_STATUS_COMMON_OPEN 0x04000000
1da177e4
LT
87#define ZFCP_STATUS_COMMON_ERP_INUSE 0x01000000
88#define ZFCP_STATUS_COMMON_ACCESS_DENIED 0x00800000
d736a27b 89#define ZFCP_STATUS_COMMON_ACCESS_BOXED 0x00400000
cc8c2829 90#define ZFCP_STATUS_COMMON_NOESC 0x00200000
1da177e4
LT
91
92/* adapter status */
93#define ZFCP_STATUS_ADAPTER_QDIOUP 0x00000002
1da177e4
LT
94#define ZFCP_STATUS_ADAPTER_XCONFIG_OK 0x00000008
95#define ZFCP_STATUS_ADAPTER_HOST_CON_INIT 0x00000010
1da177e4
LT
96#define ZFCP_STATUS_ADAPTER_ERP_PENDING 0x00000100
97#define ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED 0x00000200
98
1da177e4
LT
99/* remote port status */
100#define ZFCP_STATUS_PORT_PHYS_OPEN 0x00000001
14e242ea 101#define ZFCP_STATUS_PORT_LINK_TEST 0x00000002
1da177e4 102
1da177e4 103/* logical unit status */
1da177e4
LT
104#define ZFCP_STATUS_UNIT_SHARED 0x00000004
105#define ZFCP_STATUS_UNIT_READONLY 0x00000008
106
107/* FSF request status (this does not have a common part) */
1da177e4 108#define ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT 0x00000002
1da177e4
LT
109#define ZFCP_STATUS_FSFREQ_ERROR 0x00000008
110#define ZFCP_STATUS_FSFREQ_CLEANUP 0x00000010
1da177e4
LT
111#define ZFCP_STATUS_FSFREQ_ABORTSUCCEEDED 0x00000040
112#define ZFCP_STATUS_FSFREQ_ABORTNOTNEEDED 0x00000080
1da177e4
LT
113#define ZFCP_STATUS_FSFREQ_TMFUNCFAILED 0x00000200
114#define ZFCP_STATUS_FSFREQ_TMFUNCNOTSUPP 0x00000400
1da177e4
LT
115#define ZFCP_STATUS_FSFREQ_DISMISSED 0x00001000
116
1da177e4
LT
117/************************* STRUCTURE DEFINITIONS *****************************/
118
119struct zfcp_fsf_req;
120
121/* holds various memory pools of an adapter */
122struct zfcp_adapter_mempool {
a4623c46 123 mempool_t *erp_req;
799b76d0 124 mempool_t *gid_pn_req;
a4623c46
SS
125 mempool_t *scsi_req;
126 mempool_t *scsi_abort;
127 mempool_t *status_read_req;
128 mempool_t *status_read_data;
dbf5dfe9 129 mempool_t *gid_pn;
a4623c46 130 mempool_t *qtcb_pool;
1da177e4
LT
131};
132
1da177e4 133struct zfcp_qdio_queue {
0406289e
CS
134 struct qdio_buffer *sbal[QDIO_MAX_BUFFERS_PER_Q];
135 u8 first; /* index of next free bfr in queue */
136 atomic_t count; /* number of free buffers in queue */
1da177e4
LT
137};
138
139struct zfcp_erp_action {
140 struct list_head list;
141 int action; /* requested action code */
142 struct zfcp_adapter *adapter; /* device which should be recovered */
143 struct zfcp_port *port;
144 struct zfcp_unit *unit;
44cc76f2 145 u32 status; /* recovery status */
1da177e4
LT
146 u32 step; /* active step of this erp action */
147 struct zfcp_fsf_req *fsf_req; /* fsf request currently pending
148 for this action */
149 struct timer_list timer;
150};
151
c9615858
CS
152struct fsf_latency_record {
153 u32 min;
154 u32 max;
155 u64 sum;
156};
157
158struct latency_cont {
159 struct fsf_latency_record channel;
160 struct fsf_latency_record fabric;
161 u64 counter;
162};
163
164struct zfcp_latencies {
165 struct latency_cont read;
166 struct latency_cont write;
167 struct latency_cont cmd;
168 spinlock_t lock;
169};
1da177e4 170
564e1c86
SS
171/** struct zfcp_qdio - basic QDIO data structure
172 * @resp_q: response queue
173 * @req_q: request queue
174 * @stat_lock: lock to protect req_q_util and req_q_time
175 * @req_q_lock; lock to serialize access to request queue
176 * @req_q_time: time of last fill level change
177 * @req_q_util: used for accounting
178 * @req_q_full: queue full incidents
179 * @req_q_wq: used to wait for SBAL availability
180 * @adapter: adapter used in conjunction with this QDIO structure
181 */
182struct zfcp_qdio {
183 struct zfcp_qdio_queue resp_q;
184 struct zfcp_qdio_queue req_q;
185 spinlock_t stat_lock;
186 spinlock_t req_q_lock;
41e05a12 187 unsigned long long req_q_time;
564e1c86
SS
188 u64 req_q_util;
189 atomic_t req_q_full;
190 wait_queue_head_t req_q_wq;
191 struct zfcp_adapter *adapter;
192};
193
1da177e4 194struct zfcp_adapter {
f3450c7b 195 struct kref ref;
7ba58c9c
SS
196 u64 peer_wwnn; /* P2P peer WWNN */
197 u64 peer_wwpn; /* P2P peer WWPN */
13e1e1f0 198 u32 peer_d_id; /* P2P peer D_ID */
1da177e4 199 struct ccw_device *ccw_device; /* S/390 ccw device */
564e1c86 200 struct zfcp_qdio *qdio;
1da177e4
LT
201 u32 hydra_version; /* Hydra version */
202 u32 fsf_lic_version;
aef4a983
MS
203 u32 adapter_features; /* FCP channel features */
204 u32 connection_features; /* host connection features */
1da177e4 205 u32 hardware_version; /* of FCP channel */
c9615858 206 u16 timer_ticks; /* time int for a tick */
1da177e4 207 struct Scsi_Host *scsi_host; /* Pointer to mid-layer */
ecf0c772
SS
208 struct list_head port_list; /* remote port list */
209 rwlock_t port_list_lock; /* port list lock */
fea9d6c7
VS
210 unsigned long req_no; /* unique FSF req number */
211 struct list_head *req_list; /* list of pending reqs */
212 spinlock_t req_list_lock; /* request list lock */
1da177e4 213 u32 fsf_req_seq_no; /* FSF cmnd seq number */
1da177e4
LT
214 rwlock_t abort_lock; /* Protects against SCSI
215 stack abort/command
216 completion races */
d26ab06e
SS
217 atomic_t stat_miss; /* # missing status reads*/
218 struct work_struct stat_work;
1da177e4
LT
219 atomic_t status; /* status of this adapter */
220 struct list_head erp_ready_head; /* error recovery for this
221 adapter/devices */
347c6a96 222 wait_queue_head_t erp_ready_wq;
1da177e4
LT
223 struct list_head erp_running_head;
224 rwlock_t erp_lock;
1da177e4
LT
225 wait_queue_head_t erp_done_wqh;
226 struct zfcp_erp_action erp_action; /* pending error recovery */
227 atomic_t erp_counter;
228 u32 erp_total_count; /* total nr of enqueued erp
229 actions */
230 u32 erp_low_mem_count; /* nr of erp actions waiting
231 for memory */
347c6a96 232 struct task_struct *erp_thread;
bd0072ec 233 struct zfcp_fc_wka_ports *gs; /* generic services */
d46f384a 234 struct zfcp_dbf *dbf; /* debug traces */
1da177e4 235 struct zfcp_adapter_mempool pool; /* Adapter memory pools */
f6cd94b1
AH
236 struct fc_host_statistics *fc_stats;
237 struct fsf_qtcb_bottom_port *stats_reset_data;
238 unsigned long stats_reset;
cc8c2829 239 struct work_struct scan_work;
bd43a42b 240 struct service_level service_level;
4544683a 241 struct workqueue_struct *work_queue;
1da177e4
LT
242};
243
1da177e4
LT
244struct zfcp_port {
245 struct device sysfs_device; /* sysfs device */
3859f6a2 246 struct fc_rport *rport; /* rport of fc transport class */
1da177e4 247 struct list_head list; /* list of remote ports */
1da177e4 248 struct zfcp_adapter *adapter; /* adapter used to access port */
ecf0c772
SS
249 struct list_head unit_list; /* head of logical unit list */
250 rwlock_t unit_list_lock; /* unit list lock */
1da177e4 251 atomic_t status; /* status of this remote port */
7ba58c9c
SS
252 u64 wwnn; /* WWNN if known */
253 u64 wwpn; /* WWPN */
13e1e1f0 254 u32 d_id; /* D_ID */
1da177e4
LT
255 u32 handle; /* handle assigned by FSF */
256 struct zfcp_erp_action erp_action; /* pending error recovery */
257 atomic_t erp_counter;
75bfc283
RW
258 u32 maxframe_size;
259 u32 supported_classes;
5ab944f9 260 struct work_struct gid_pn_work;
8fdf30d5 261 struct work_struct test_link_work;
a2fa0aed
CS
262 struct work_struct rport_work;
263 enum { RPORT_NONE, RPORT_ADD, RPORT_DEL } rport_task;
1da177e4
LT
264};
265
1da177e4
LT
266struct zfcp_unit {
267 struct device sysfs_device; /* sysfs device */
268 struct list_head list; /* list of logical units */
1da177e4
LT
269 struct zfcp_port *port; /* remote port of unit */
270 atomic_t status; /* status of this logical unit */
7ba58c9c 271 u64 fcp_lun; /* own FCP_LUN */
1da177e4
LT
272 u32 handle; /* handle assigned by FSF */
273 struct scsi_device *device; /* scsi device struct pointer */
274 struct zfcp_erp_action erp_action; /* pending error recovery */
275 atomic_t erp_counter;
c9615858 276 struct zfcp_latencies latencies;
92d5193b 277 struct work_struct scsi_work;
1da177e4
LT
278};
279
42428f74
SS
280/**
281 * struct zfcp_queue_req - queue related values for a request
282 * @sbal_number: number of free SBALs
283 * @sbal_first: first SBAL for this request
284 * @sbal_last: last SBAL for this request
285 * @sbal_limit: last possible SBAL for this request
286 * @sbale_curr: current SBALE at creation of this request
287 * @sbal_response: SBAL used in interrupt
288 * @qdio_outb_usage: usage of outbound queue
289 * @qdio_inb_usage: usage of inbound queue
290 */
291struct zfcp_queue_req {
292 u8 sbal_number;
293 u8 sbal_first;
294 u8 sbal_last;
295 u8 sbal_limit;
296 u8 sbale_curr;
297 u8 sbal_response;
298 u16 qdio_outb_usage;
299 u16 qdio_inb_usage;
300};
301
302/**
303 * struct zfcp_fsf_req - basic FSF request structure
304 * @list: list of FSF requests
305 * @req_id: unique request ID
306 * @adapter: adapter this request belongs to
307 * @queue_req: queue related values
308 * @completion: used to signal the completion of the request
309 * @status: status of the request
310 * @fsf_command: FSF command issued
311 * @qtcb: associated QTCB
312 * @seq_no: sequence number of this request
313 * @data: private data
314 * @timer: timer data of this request
315 * @erp_action: reference to erp action if request issued on behalf of ERP
316 * @pool: reference to memory pool if used for this request
317 * @issued: time when request was send (STCK)
318 * @unit: reference to unit if this request is a SCSI request
319 * @handler: handler which should be called to process response
320 */
1da177e4 321struct zfcp_fsf_req {
42428f74
SS
322 struct list_head list;
323 unsigned long req_id;
324 struct zfcp_adapter *adapter;
325 struct zfcp_queue_req queue_req;
326 struct completion completion;
327 u32 status;
328 u32 fsf_command;
329 struct fsf_qtcb *qtcb;
330 u32 seq_no;
331 void *data;
332 struct timer_list timer;
333 struct zfcp_erp_action *erp_action;
334 mempool_t *pool;
335 unsigned long long issued;
336 struct zfcp_unit *unit;
c41f8cbd 337 void (*handler)(struct zfcp_fsf_req *);
1da177e4
LT
338};
339
1da177e4
LT
340/* driver data */
341struct zfcp_data {
342 struct scsi_host_template scsi_host_template;
dd52e0ea 343 struct scsi_transport_template *scsi_transport_template;
a4623c46
SS
344 struct kmem_cache *gpn_ft_cache;
345 struct kmem_cache *qtcb_cache;
7ba58c9c
SS
346 struct kmem_cache *sr_buffer_cache;
347 struct kmem_cache *gid_pn_cache;
ee744622 348 struct kmem_cache *adisc_cache;
1da177e4
LT
349};
350
1da177e4
LT
351/********************** ZFCP SPECIFIC DEFINES ********************************/
352
1da177e4
LT
353#define ZFCP_SET 0x00000100
354#define ZFCP_CLEAR 0x00000200
355
ca2d02c2
HC
356/*
357 * Helper functions for request ID management.
358 */
359static inline int zfcp_reqlist_hash(unsigned long req_id)
360{
361 return req_id % REQUEST_LIST_SIZE;
362}
363
ca2d02c2
HC
364static inline void zfcp_reqlist_remove(struct zfcp_adapter *adapter,
365 struct zfcp_fsf_req *fsf_req)
366{
367 list_del(&fsf_req->list);
368}
369
370static inline struct zfcp_fsf_req *
371zfcp_reqlist_find(struct zfcp_adapter *adapter, unsigned long req_id)
372{
373 struct zfcp_fsf_req *request;
374 unsigned int idx;
375
376 idx = zfcp_reqlist_hash(req_id);
377 list_for_each_entry(request, &adapter->req_list[idx], list)
378 if (request->req_id == req_id)
379 return request;
380 return NULL;
381}
382
d1ad09db
HC
383static inline struct zfcp_fsf_req *
384zfcp_reqlist_find_safe(struct zfcp_adapter *adapter, struct zfcp_fsf_req *req)
385{
386 struct zfcp_fsf_req *request;
387 unsigned int idx;
388
389 for (idx = 0; idx < REQUEST_LIST_SIZE; idx++) {
390 list_for_each_entry(request, &adapter->req_list[idx], list)
391 if (request == req)
392 return request;
393 }
394 return NULL;
395}
396
1da177e4 397#endif /* ZFCP_DEF_H */
This page took 0.514475 seconds and 5 git commands to generate.