[SCSI] zfcp: Send ELS ADISC from workqueue
[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 *
553448f6 6 * Copyright IBM Corporation 2002, 2008
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>
1da177e4
LT
25#include <scsi/scsi.h>
26#include <scsi/scsi_tcq.h>
27#include <scsi/scsi_cmnd.h>
28#include <scsi/scsi_device.h>
29#include <scsi/scsi_host.h>
30#include <scsi/scsi_transport.h>
31#include <scsi/scsi_transport_fc.h>
1da177e4
LT
32#include <asm/ccwdev.h>
33#include <asm/qdio.h>
34#include <asm/debug.h>
35#include <asm/ebcdic.h>
bd43a42b 36#include <asm/sysinfo.h>
2b604c9b 37#include "zfcp_dbf.h"
dd52e0ea 38#include "zfcp_fsf.h"
1da177e4 39
1da177e4
LT
40
41/********************* GENERAL DEFINES *********************************/
42
06506d00 43#define REQUEST_LIST_SIZE 128
1da177e4 44
06506d00 45/********************* SCSI SPECIFIC DEFINES *********************************/
f6c0e7a7 46#define ZFCP_SCSI_ER_TIMEOUT (10*HZ)
1da177e4
LT
47
48/********************* CIO/QDIO SPECIFIC DEFINES *****************************/
49
50/* Adapter Identification Parameters */
51#define ZFCP_CONTROL_UNIT_TYPE 0x1731
52#define ZFCP_CONTROL_UNIT_MODEL 0x03
53#define ZFCP_DEVICE_TYPE 0x1732
54#define ZFCP_DEVICE_MODEL 0x03
55#define ZFCP_DEVICE_MODEL_PRIV 0x04
41fa2ada 56
1da177e4
LT
57/* DMQ bug workaround: don't use last SBALE */
58#define ZFCP_MAX_SBALES_PER_SBAL (QDIO_MAX_ELEMENTS_PER_BUFFER - 1)
59
60/* index of last SBALE (with respect to DMQ bug workaround) */
61#define ZFCP_LAST_SBALE_PER_SBAL (ZFCP_MAX_SBALES_PER_SBAL - 1)
62
63/* max. number of (data buffer) SBALEs in largest SBAL chain */
64#define ZFCP_MAX_SBALES_PER_REQ \
c41f8cbd 65 (FSF_MAX_SBALS_PER_REQ * ZFCP_MAX_SBALES_PER_SBAL - 2)
1da177e4
LT
66 /* request ID + QTCB in SBALE 0 + 1 of first SBAL in chain */
67
8d1a0060
SS
68#define ZFCP_MAX_SECTORS (ZFCP_MAX_SBALES_PER_REQ * 8)
69 /* max. number of (data buffer) SBALEs in largest SBAL chain
70 multiplied with number of sectors per 4k block */
71
1da177e4
LT
72/********************* FSF SPECIFIC DEFINES *********************************/
73
1da177e4
LT
74/* ATTENTION: value must not be used by hardware */
75#define FSF_QTCB_UNSOLICITED_STATUS 0x6305
22753fa5 76
1da177e4 77/* timeout value for "default timer" for fsf requests */
2abbe866 78#define ZFCP_FSF_REQUEST_TIMEOUT (60*HZ)
1da177e4
LT
79
80/*************** FIBRE CHANNEL PROTOCOL SPECIFIC DEFINES ********************/
81
1da177e4
LT
82/* timeout for name-server lookup (in seconds) */
83#define ZFCP_NS_GID_PN_TIMEOUT 10
84
1da177e4
LT
85/* task attribute values in FCP-2 FCP_CMND IU */
86#define SIMPLE_Q 0
87#define HEAD_OF_Q 1
88#define ORDERED_Q 2
89#define ACA_Q 4
90#define UNTAGGED 5
91
92/* task management flags in FCP-2 FCP_CMND IU */
93#define FCP_CLEAR_ACA 0x40
94#define FCP_TARGET_RESET 0x20
95#define FCP_LOGICAL_UNIT_RESET 0x10
96#define FCP_CLEAR_TASK_SET 0x04
97#define FCP_ABORT_TASK_SET 0x02
98
99#define FCP_CDB_LENGTH 16
100
101#define ZFCP_DID_MASK 0x00FFFFFF
102
103/* FCP(-2) FCP_CMND IU */
104struct fcp_cmnd_iu {
7ba58c9c 105 u64 fcp_lun; /* FCP logical unit number */
1da177e4
LT
106 u8 crn; /* command reference number */
107 u8 reserved0:5; /* reserved */
108 u8 task_attribute:3; /* task attribute */
109 u8 task_management_flags; /* task management flags */
110 u8 add_fcp_cdb_length:6; /* additional FCP_CDB length */
111 u8 rddata:1; /* read data */
112 u8 wddata:1; /* write data */
113 u8 fcp_cdb[FCP_CDB_LENGTH];
114} __attribute__((packed));
115
116/* FCP(-2) FCP_RSP IU */
117struct fcp_rsp_iu {
118 u8 reserved0[10];
119 union {
120 struct {
121 u8 reserved1:3;
122 u8 fcp_conf_req:1;
123 u8 fcp_resid_under:1;
124 u8 fcp_resid_over:1;
125 u8 fcp_sns_len_valid:1;
126 u8 fcp_rsp_len_valid:1;
127 } bits;
128 u8 value;
129 } validity;
130 u8 scsi_status;
131 u32 fcp_resid;
132 u32 fcp_sns_len;
133 u32 fcp_rsp_len;
134} __attribute__((packed));
135
136
137#define RSP_CODE_GOOD 0
138#define RSP_CODE_LENGTH_MISMATCH 1
139#define RSP_CODE_FIELD_INVALID 2
140#define RSP_CODE_RO_MISMATCH 3
141#define RSP_CODE_TASKMAN_UNSUPP 4
142#define RSP_CODE_TASKMAN_FAILED 5
143
144/* see fc-fs */
24073b47
CS
145#define LS_RSCN 0x61
146#define LS_LOGO 0x05
147#define LS_PLOGI 0x03
1da177e4
LT
148
149struct fcp_rscn_head {
150 u8 command;
151 u8 page_length; /* always 0x04 */
152 u16 payload_len;
153} __attribute__((packed));
154
155struct fcp_rscn_element {
156 u8 reserved:2;
157 u8 event_qual:4;
158 u8 addr_format:2;
159 u32 nport_did:24;
160} __attribute__((packed));
161
1da177e4
LT
162/* see fc-ph */
163struct fcp_logo {
164 u32 command;
165 u32 nport_did;
7ba58c9c 166 u64 nport_wwpn;
1da177e4
LT
167} __attribute__((packed));
168
169/*
170 * FC-FS stuff
171 */
172#define R_A_TOV 10 /* seconds */
1da177e4
LT
173
174#define ZFCP_LS_RLS 0x0f
175#define ZFCP_LS_ADISC 0x52
176#define ZFCP_LS_RPS 0x56
177#define ZFCP_LS_RSCN 0x61
178#define ZFCP_LS_RNID 0x78
179
1da177e4
LT
180struct zfcp_ls_adisc {
181 u8 code;
182 u8 field[3];
183 u32 hard_nport_id;
184 u64 wwpn;
185 u64 wwnn;
186 u32 nport_id;
187} __attribute__ ((packed));
188
1da177e4
LT
189/*
190 * FC-GS-2 stuff
191 */
192#define ZFCP_CT_REVISION 0x01
193#define ZFCP_CT_DIRECTORY_SERVICE 0xFC
194#define ZFCP_CT_NAME_SERVER 0x02
195#define ZFCP_CT_SYNCHRONOUS 0x00
cc8c2829
SS
196#define ZFCP_CT_SCSI_FCP 0x08
197#define ZFCP_CT_UNABLE_TO_PERFORM_CMD 0x09
1da177e4 198#define ZFCP_CT_GID_PN 0x0121
cc8c2829 199#define ZFCP_CT_GPN_FT 0x0172
1da177e4
LT
200#define ZFCP_CT_ACCEPT 0x8002
201#define ZFCP_CT_REJECT 0x8001
202
203/*
204 * FC-GS-4 stuff
205 */
206#define ZFCP_CT_TIMEOUT (3 * R_A_TOV)
207
1da177e4
LT
208/*************** ADAPTER/PORT/UNIT AND FSF_REQ STATUS FLAGS ******************/
209
41fa2ada
SS
210/*
211 * Note, the leftmost status byte is common among adapter, port
1da177e4
LT
212 * and unit
213 */
214#define ZFCP_COMMON_FLAGS 0xfff00000
1da177e4
LT
215
216/* common status bits */
217#define ZFCP_STATUS_COMMON_REMOVE 0x80000000
218#define ZFCP_STATUS_COMMON_RUNNING 0x40000000
219#define ZFCP_STATUS_COMMON_ERP_FAILED 0x20000000
220#define ZFCP_STATUS_COMMON_UNBLOCKED 0x10000000
1da177e4 221#define ZFCP_STATUS_COMMON_OPEN 0x04000000
1da177e4
LT
222#define ZFCP_STATUS_COMMON_ERP_INUSE 0x01000000
223#define ZFCP_STATUS_COMMON_ACCESS_DENIED 0x00800000
d736a27b 224#define ZFCP_STATUS_COMMON_ACCESS_BOXED 0x00400000
cc8c2829 225#define ZFCP_STATUS_COMMON_NOESC 0x00200000
1da177e4
LT
226
227/* adapter status */
228#define ZFCP_STATUS_ADAPTER_QDIOUP 0x00000002
1da177e4
LT
229#define ZFCP_STATUS_ADAPTER_XCONFIG_OK 0x00000008
230#define ZFCP_STATUS_ADAPTER_HOST_CON_INIT 0x00000010
231#define ZFCP_STATUS_ADAPTER_ERP_THREAD_UP 0x00000020
232#define ZFCP_STATUS_ADAPTER_ERP_THREAD_KILL 0x00000080
233#define ZFCP_STATUS_ADAPTER_ERP_PENDING 0x00000100
234#define ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED 0x00000200
235
1da177e4 236/* FC-PH/FC-GS well-known address identifiers for generic services */
5ab944f9 237#define ZFCP_DID_WKA 0xFFFFF0
1da177e4
LT
238#define ZFCP_DID_MANAGEMENT_SERVICE 0xFFFFFA
239#define ZFCP_DID_TIME_SERVICE 0xFFFFFB
240#define ZFCP_DID_DIRECTORY_SERVICE 0xFFFFFC
241#define ZFCP_DID_ALIAS_SERVICE 0xFFFFF8
242#define ZFCP_DID_KEY_DISTRIBUTION_SERVICE 0xFFFFF7
243
244/* remote port status */
245#define ZFCP_STATUS_PORT_PHYS_OPEN 0x00000001
1da177e4 246
5ab944f9
SS
247/* well known address (WKA) port status*/
248enum zfcp_wka_status {
249 ZFCP_WKA_PORT_OFFLINE,
250 ZFCP_WKA_PORT_CLOSING,
251 ZFCP_WKA_PORT_OPENING,
252 ZFCP_WKA_PORT_ONLINE,
253};
1da177e4
LT
254
255/* logical unit status */
1da177e4
LT
256#define ZFCP_STATUS_UNIT_SHARED 0x00000004
257#define ZFCP_STATUS_UNIT_READONLY 0x00000008
5f852be9 258#define ZFCP_STATUS_UNIT_SCSI_WORK_PENDING 0x00000020
1da177e4
LT
259
260/* FSF request status (this does not have a common part) */
1da177e4
LT
261#define ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT 0x00000002
262#define ZFCP_STATUS_FSFREQ_COMPLETED 0x00000004
263#define ZFCP_STATUS_FSFREQ_ERROR 0x00000008
264#define ZFCP_STATUS_FSFREQ_CLEANUP 0x00000010
1da177e4
LT
265#define ZFCP_STATUS_FSFREQ_ABORTSUCCEEDED 0x00000040
266#define ZFCP_STATUS_FSFREQ_ABORTNOTNEEDED 0x00000080
267#define ZFCP_STATUS_FSFREQ_ABORTED 0x00000100
268#define ZFCP_STATUS_FSFREQ_TMFUNCFAILED 0x00000200
269#define ZFCP_STATUS_FSFREQ_TMFUNCNOTSUPP 0x00000400
270#define ZFCP_STATUS_FSFREQ_RETRY 0x00000800
271#define ZFCP_STATUS_FSFREQ_DISMISSED 0x00001000
272
1da177e4
LT
273/************************* STRUCTURE DEFINITIONS *****************************/
274
275struct zfcp_fsf_req;
276
277/* holds various memory pools of an adapter */
278struct zfcp_adapter_mempool {
279 mempool_t *fsf_req_erp;
280 mempool_t *fsf_req_scsi;
281 mempool_t *fsf_req_abort;
282 mempool_t *fsf_req_status_read;
283 mempool_t *data_status_read;
284 mempool_t *data_gid_pn;
285};
286
1da177e4
LT
287/*
288 * header for CT_IU
289 */
290struct ct_hdr {
291 u8 revision; // 0x01
292 u8 in_id[3]; // 0x00
293 u8 gs_type; // 0xFC Directory Service
294 u8 gs_subtype; // 0x02 Name Server
295 u8 options; // 0x00 single bidirectional exchange
296 u8 reserved0;
297 u16 cmd_rsp_code; // 0x0121 GID_PN, or 0x0100 GA_NXT
298 u16 max_res_size; // <= (4096 - 16) / 4
299 u8 reserved1;
300 u8 reason_code;
301 u8 reason_code_expl;
302 u8 vendor_unique;
303} __attribute__ ((packed));
304
305/* nameserver request CT_IU -- for requests where
306 * a port name is required */
307struct ct_iu_gid_pn_req {
308 struct ct_hdr header;
7ba58c9c 309 u64 wwpn;
1da177e4
LT
310} __attribute__ ((packed));
311
312/* FS_ACC IU and data unit for GID_PN nameserver request */
313struct ct_iu_gid_pn_resp {
314 struct ct_hdr header;
13e1e1f0 315 u32 d_id;
1da177e4
LT
316} __attribute__ ((packed));
317
1da177e4
LT
318/**
319 * struct zfcp_send_ct - used to pass parameters to function zfcp_fsf_send_ct
5ab944f9 320 * @wka_port: port where the request is sent to
1da177e4
LT
321 * @req: scatter-gather list for request
322 * @resp: scatter-gather list for response
1da177e4
LT
323 * @handler: handler function (called for response to the request)
324 * @handler_data: data passed to handler function
1da177e4 325 * @timeout: FSF timeout for this request
1da177e4
LT
326 * @completion: completion for synchronization purposes
327 * @status: used to pass error status to calling function
328 */
329struct zfcp_send_ct {
5ab944f9 330 struct zfcp_wka_port *wka_port;
1da177e4
LT
331 struct scatterlist *req;
332 struct scatterlist *resp;
7ba58c9c 333 void (*handler)(unsigned long);
1da177e4 334 unsigned long handler_data;
1da177e4 335 int timeout;
1da177e4
LT
336 struct completion *completion;
337 int status;
338};
339
340/* used for name server requests in error recovery */
341struct zfcp_gid_pn_data {
342 struct zfcp_send_ct ct;
343 struct scatterlist req;
344 struct scatterlist resp;
345 struct ct_iu_gid_pn_req ct_iu_req;
346 struct ct_iu_gid_pn_resp ct_iu_resp;
347 struct zfcp_port *port;
348};
349
1da177e4
LT
350/**
351 * struct zfcp_send_els - used to pass parameters to function zfcp_fsf_send_els
352 * @adapter: adapter where request is sent from
64b29a13 353 * @port: port where ELS is destinated (port reference count has to be increased)
1da177e4
LT
354 * @d_id: destiniation id of port where request is sent to
355 * @req: scatter-gather list for request
356 * @resp: scatter-gather list for response
1da177e4
LT
357 * @handler: handler function (called for response to the request)
358 * @handler_data: data passed to handler function
1da177e4
LT
359 * @completion: completion for synchronization purposes
360 * @ls_code: hex code of ELS command
361 * @status: used to pass error status to calling function
362 */
363struct zfcp_send_els {
364 struct zfcp_adapter *adapter;
64b29a13 365 struct zfcp_port *port;
13e1e1f0 366 u32 d_id;
1da177e4
LT
367 struct scatterlist *req;
368 struct scatterlist *resp;
7ba58c9c 369 void (*handler)(unsigned long);
1da177e4 370 unsigned long handler_data;
1da177e4
LT
371 struct completion *completion;
372 int ls_code;
373 int status;
374};
375
5ab944f9
SS
376struct zfcp_wka_port {
377 struct zfcp_adapter *adapter;
378 wait_queue_head_t completion_wq;
379 enum zfcp_wka_status status;
380 atomic_t refcount;
381 u32 d_id;
382 u32 handle;
383 struct mutex mutex;
384 struct delayed_work work;
385};
386
1da177e4 387struct zfcp_qdio_queue {
0406289e
CS
388 struct qdio_buffer *sbal[QDIO_MAX_BUFFERS_PER_Q];
389 u8 first; /* index of next free bfr in queue */
390 atomic_t count; /* number of free buffers in queue */
1da177e4
LT
391};
392
393struct zfcp_erp_action {
394 struct list_head list;
395 int action; /* requested action code */
396 struct zfcp_adapter *adapter; /* device which should be recovered */
397 struct zfcp_port *port;
398 struct zfcp_unit *unit;
44cc76f2 399 u32 status; /* recovery status */
1da177e4
LT
400 u32 step; /* active step of this erp action */
401 struct zfcp_fsf_req *fsf_req; /* fsf request currently pending
402 for this action */
403 struct timer_list timer;
404};
405
c9615858
CS
406struct fsf_latency_record {
407 u32 min;
408 u32 max;
409 u64 sum;
410};
411
412struct latency_cont {
413 struct fsf_latency_record channel;
414 struct fsf_latency_record fabric;
415 u64 counter;
416};
417
418struct zfcp_latencies {
419 struct latency_cont read;
420 struct latency_cont write;
421 struct latency_cont cmd;
422 spinlock_t lock;
423};
1da177e4
LT
424
425struct zfcp_adapter {
1da177e4
LT
426 atomic_t refcount; /* reference count */
427 wait_queue_head_t remove_wq; /* can be used to wait for
428 refcount drop to zero */
7ba58c9c
SS
429 u64 peer_wwnn; /* P2P peer WWNN */
430 u64 peer_wwpn; /* P2P peer WWPN */
13e1e1f0 431 u32 peer_d_id; /* P2P peer D_ID */
1da177e4 432 struct ccw_device *ccw_device; /* S/390 ccw device */
1da177e4
LT
433 u32 hydra_version; /* Hydra version */
434 u32 fsf_lic_version;
aef4a983
MS
435 u32 adapter_features; /* FCP channel features */
436 u32 connection_features; /* host connection features */
1da177e4 437 u32 hardware_version; /* of FCP channel */
c9615858 438 u16 timer_ticks; /* time int for a tick */
1da177e4 439 struct Scsi_Host *scsi_host; /* Pointer to mid-layer */
1da177e4 440 struct list_head port_list_head; /* remote port list */
fea9d6c7
VS
441 unsigned long req_no; /* unique FSF req number */
442 struct list_head *req_list; /* list of pending reqs */
443 spinlock_t req_list_lock; /* request list lock */
00bab910 444 struct zfcp_qdio_queue req_q; /* request queue */
0406289e
CS
445 spinlock_t req_q_lock; /* for operations on queue */
446 int req_q_pci_batch; /* SBALs since PCI indication
447 was last set */
94506fd1
MP
448 ktime_t req_q_time; /* time of last fill level change */
449 u64 req_q_util; /* for accounting */
450 spinlock_t qdio_stat_lock;
1da177e4
LT
451 u32 fsf_req_seq_no; /* FSF cmnd seq number */
452 wait_queue_head_t request_wq; /* can be used to wait for
453 more avaliable SBALs */
00bab910 454 struct zfcp_qdio_queue resp_q; /* response queue */
1da177e4
LT
455 rwlock_t abort_lock; /* Protects against SCSI
456 stack abort/command
457 completion races */
d26ab06e
SS
458 atomic_t stat_miss; /* # missing status reads*/
459 struct work_struct stat_work;
1da177e4
LT
460 atomic_t status; /* status of this adapter */
461 struct list_head erp_ready_head; /* error recovery for this
462 adapter/devices */
463 struct list_head erp_running_head;
464 rwlock_t erp_lock;
465 struct semaphore erp_ready_sem;
466 wait_queue_head_t erp_thread_wqh;
467 wait_queue_head_t erp_done_wqh;
468 struct zfcp_erp_action erp_action; /* pending error recovery */
469 atomic_t erp_counter;
470 u32 erp_total_count; /* total nr of enqueued erp
471 actions */
472 u32 erp_low_mem_count; /* nr of erp actions waiting
473 for memory */
5ab944f9 474 struct zfcp_wka_port nsp; /* adapter's nameserver */
d79a83db 475 debug_info_t *rec_dbf;
8a36e453
MS
476 debug_info_t *hba_dbf;
477 debug_info_t *san_dbf; /* debug feature areas */
478 debug_info_t *scsi_dbf;
d79a83db 479 spinlock_t rec_dbf_lock;
8a36e453
MS
480 spinlock_t hba_dbf_lock;
481 spinlock_t san_dbf_lock;
482 spinlock_t scsi_dbf_lock;
d79a83db 483 struct zfcp_rec_dbf_record rec_dbf_buf;
8a36e453
MS
484 struct zfcp_hba_dbf_record hba_dbf_buf;
485 struct zfcp_san_dbf_record san_dbf_buf;
486 struct zfcp_scsi_dbf_record scsi_dbf_buf;
1da177e4
LT
487 struct zfcp_adapter_mempool pool; /* Adapter memory pools */
488 struct qdio_initialize qdio_init_data; /* for qdio_establish */
f6cd94b1
AH
489 struct fc_host_statistics *fc_stats;
490 struct fsf_qtcb_bottom_port *stats_reset_data;
491 unsigned long stats_reset;
cc8c2829 492 struct work_struct scan_work;
bd43a42b 493 struct service_level service_level;
2450d3e7 494 atomic_t qdio_outb_full; /* queue full incidents */
1da177e4
LT
495};
496
1da177e4
LT
497struct zfcp_port {
498 struct device sysfs_device; /* sysfs device */
3859f6a2 499 struct fc_rport *rport; /* rport of fc transport class */
1da177e4
LT
500 struct list_head list; /* list of remote ports */
501 atomic_t refcount; /* reference count */
502 wait_queue_head_t remove_wq; /* can be used to wait for
503 refcount drop to zero */
504 struct zfcp_adapter *adapter; /* adapter used to access port */
505 struct list_head unit_list_head; /* head of logical unit list */
1da177e4 506 atomic_t status; /* status of this remote port */
7ba58c9c
SS
507 u64 wwnn; /* WWNN if known */
508 u64 wwpn; /* WWPN */
13e1e1f0 509 u32 d_id; /* D_ID */
1da177e4
LT
510 u32 handle; /* handle assigned by FSF */
511 struct zfcp_erp_action erp_action; /* pending error recovery */
512 atomic_t erp_counter;
75bfc283
RW
513 u32 maxframe_size;
514 u32 supported_classes;
5ab944f9 515 struct work_struct gid_pn_work;
8fdf30d5 516 struct work_struct test_link_work;
1da177e4
LT
517};
518
1da177e4
LT
519struct zfcp_unit {
520 struct device sysfs_device; /* sysfs device */
521 struct list_head list; /* list of logical units */
522 atomic_t refcount; /* reference count */
523 wait_queue_head_t remove_wq; /* can be used to wait for
524 refcount drop to zero */
525 struct zfcp_port *port; /* remote port of unit */
526 atomic_t status; /* status of this logical unit */
7ba58c9c 527 u64 fcp_lun; /* own FCP_LUN */
1da177e4
LT
528 u32 handle; /* handle assigned by FSF */
529 struct scsi_device *device; /* scsi device struct pointer */
530 struct zfcp_erp_action erp_action; /* pending error recovery */
531 atomic_t erp_counter;
c9615858 532 struct zfcp_latencies latencies;
1da177e4
LT
533};
534
535/* FSF request */
536struct zfcp_fsf_req {
537 struct list_head list; /* list of FSF requests */
fea9d6c7 538 unsigned long req_id; /* unique request ID */
1da177e4
LT
539 struct zfcp_adapter *adapter; /* adapter request belongs to */
540 u8 sbal_number; /* nr of SBALs free for use */
541 u8 sbal_first; /* first SBAL for this request */
e891bffe 542 u8 sbal_last; /* last SBAL for this request */
d01d51be 543 u8 sbal_limit; /* last possible SBAL for
1da177e4 544 this reuest */
1da177e4
LT
545 u8 sbale_curr; /* current SBALE during creation
546 of request */
c3baa9a2 547 u8 sbal_response; /* SBAL used in interrupt */
1da177e4
LT
548 wait_queue_head_t completion_wq; /* can be used by a routine
549 to wait for completion */
44cc76f2 550 u32 status; /* status of this request */
1da177e4
LT
551 u32 fsf_command; /* FSF Command copy */
552 struct fsf_qtcb *qtcb; /* address of associated QTCB */
553 u32 seq_no; /* Sequence number of request */
c41f8cbd 554 void *data; /* private data of request */
41fa2ada 555 struct timer_list timer; /* used for erp or scsi er */
1da177e4
LT
556 struct zfcp_erp_action *erp_action; /* used if this request is
557 issued on behalf of erp */
558 mempool_t *pool; /* used if request was alloacted
559 from emergency pool */
8a36e453 560 unsigned long long issued; /* request sent time (STCK) */
059c97d0 561 struct zfcp_unit *unit;
c41f8cbd 562 void (*handler)(struct zfcp_fsf_req *);
0997f1c5
SR
563 u16 qdio_outb_usage;/* usage of outbound queue */
564 u16 qdio_inb_usage; /* usage of inbound queue */
1da177e4
LT
565};
566
1da177e4
LT
567/* driver data */
568struct zfcp_data {
569 struct scsi_host_template scsi_host_template;
dd52e0ea 570 struct scsi_transport_template *scsi_transport_template;
1da177e4
LT
571 rwlock_t config_lock; /* serialises changes
572 to adapter/port/unit
573 lists */
574 struct semaphore config_sema; /* serialises configuration
575 changes */
7ba58c9c
SS
576 struct kmem_cache *fsf_req_qtcb_cache;
577 struct kmem_cache *sr_buffer_cache;
578 struct kmem_cache *gid_pn_cache;
b7f15f3c 579 struct workqueue_struct *work_queue;
1da177e4
LT
580};
581
1da177e4 582/* struct used by memory pools for fsf_requests */
dd52e0ea 583struct zfcp_fsf_req_qtcb {
1da177e4
LT
584 struct zfcp_fsf_req fsf_req;
585 struct fsf_qtcb qtcb;
586};
587
588/********************** ZFCP SPECIFIC DEFINES ********************************/
589
1da177e4
LT
590#define ZFCP_SET 0x00000100
591#define ZFCP_CLEAR 0x00000200
592
ca2d02c2
HC
593/*
594 * Helper functions for request ID management.
595 */
596static inline int zfcp_reqlist_hash(unsigned long req_id)
597{
598 return req_id % REQUEST_LIST_SIZE;
599}
600
ca2d02c2
HC
601static inline void zfcp_reqlist_remove(struct zfcp_adapter *adapter,
602 struct zfcp_fsf_req *fsf_req)
603{
604 list_del(&fsf_req->list);
605}
606
607static inline struct zfcp_fsf_req *
608zfcp_reqlist_find(struct zfcp_adapter *adapter, unsigned long req_id)
609{
610 struct zfcp_fsf_req *request;
611 unsigned int idx;
612
613 idx = zfcp_reqlist_hash(req_id);
614 list_for_each_entry(request, &adapter->req_list[idx], list)
615 if (request->req_id == req_id)
616 return request;
617 return NULL;
618}
619
d1ad09db
HC
620static inline struct zfcp_fsf_req *
621zfcp_reqlist_find_safe(struct zfcp_adapter *adapter, struct zfcp_fsf_req *req)
622{
623 struct zfcp_fsf_req *request;
624 unsigned int idx;
625
626 for (idx = 0; idx < REQUEST_LIST_SIZE; idx++) {
627 list_for_each_entry(request, &adapter->req_list[idx], list)
628 if (request == req)
629 return request;
630 }
631 return NULL;
632}
633
1da177e4
LT
634/*
635 * functions needed for reference/usage counting
636 */
637
638static inline void
639zfcp_unit_get(struct zfcp_unit *unit)
640{
641 atomic_inc(&unit->refcount);
642}
643
644static inline void
645zfcp_unit_put(struct zfcp_unit *unit)
646{
647 if (atomic_dec_return(&unit->refcount) == 0)
648 wake_up(&unit->remove_wq);
649}
650
1da177e4
LT
651static inline void
652zfcp_port_get(struct zfcp_port *port)
653{
654 atomic_inc(&port->refcount);
655}
656
657static inline void
658zfcp_port_put(struct zfcp_port *port)
659{
660 if (atomic_dec_return(&port->refcount) == 0)
661 wake_up(&port->remove_wq);
662}
663
1da177e4
LT
664static inline void
665zfcp_adapter_get(struct zfcp_adapter *adapter)
666{
667 atomic_inc(&adapter->refcount);
668}
669
670static inline void
671zfcp_adapter_put(struct zfcp_adapter *adapter)
672{
673 if (atomic_dec_return(&adapter->refcount) == 0)
674 wake_up(&adapter->remove_wq);
675}
676
1da177e4 677#endif /* ZFCP_DEF_H */
This page took 0.442676 seconds and 5 git commands to generate.