[SCSI] zfcp: zfcp_fsf cleanup.
[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>
2b604c9b 36#include "zfcp_dbf.h"
dd52e0ea 37#include "zfcp_fsf.h"
1da177e4 38
1da177e4
LT
39
40/********************* GENERAL DEFINES *********************************/
41
1da177e4
LT
42/**
43 * zfcp_sg_to_address - determine kernel address from struct scatterlist
44 * @list: struct scatterlist
45 * Return: kernel address
46 */
47static inline void *
48zfcp_sg_to_address(struct scatterlist *list)
49{
73fc4f0d 50 return sg_virt(list);
1da177e4
LT
51}
52
53/**
54 * zfcp_address_to_sg - set up struct scatterlist from kernel address
55 * @address: kernel address
56 * @list: struct scatterlist
93354329 57 * @size: buffer size
1da177e4
LT
58 */
59static inline void
93354329 60zfcp_address_to_sg(void *address, struct scatterlist *list, unsigned int size)
1da177e4 61{
93354329 62 sg_set_buf(list, address, size);
1da177e4
LT
63}
64
06506d00 65#define REQUEST_LIST_SIZE 128
1da177e4 66
06506d00 67/********************* SCSI SPECIFIC DEFINES *********************************/
f6c0e7a7 68#define ZFCP_SCSI_ER_TIMEOUT (10*HZ)
1da177e4
LT
69
70/********************* CIO/QDIO SPECIFIC DEFINES *****************************/
71
72/* Adapter Identification Parameters */
73#define ZFCP_CONTROL_UNIT_TYPE 0x1731
74#define ZFCP_CONTROL_UNIT_MODEL 0x03
75#define ZFCP_DEVICE_TYPE 0x1732
76#define ZFCP_DEVICE_MODEL 0x03
77#define ZFCP_DEVICE_MODEL_PRIV 0x04
41fa2ada 78
1da177e4
LT
79/* DMQ bug workaround: don't use last SBALE */
80#define ZFCP_MAX_SBALES_PER_SBAL (QDIO_MAX_ELEMENTS_PER_BUFFER - 1)
81
82/* index of last SBALE (with respect to DMQ bug workaround) */
83#define ZFCP_LAST_SBALE_PER_SBAL (ZFCP_MAX_SBALES_PER_SBAL - 1)
84
85/* max. number of (data buffer) SBALEs in largest SBAL chain */
86#define ZFCP_MAX_SBALES_PER_REQ \
c41f8cbd 87 (FSF_MAX_SBALS_PER_REQ * ZFCP_MAX_SBALES_PER_SBAL - 2)
1da177e4
LT
88 /* request ID + QTCB in SBALE 0 + 1 of first SBAL in chain */
89
8d1a0060
SS
90#define ZFCP_MAX_SECTORS (ZFCP_MAX_SBALES_PER_REQ * 8)
91 /* max. number of (data buffer) SBALEs in largest SBAL chain
92 multiplied with number of sectors per 4k block */
93
18edcdbd 94#define ZFCP_TYPE2_RECOVERY_TIME 8 /* seconds */
1da177e4 95
1da177e4
LT
96/********************* FSF SPECIFIC DEFINES *********************************/
97
1da177e4
LT
98/* ATTENTION: value must not be used by hardware */
99#define FSF_QTCB_UNSOLICITED_STATUS 0x6305
22753fa5
AH
100
101/* Do 1st retry in 1 second, then double the timeout for each following retry */
18edcdbd 102#define ZFCP_EXCHANGE_CONFIG_DATA_FIRST_SLEEP 1
22753fa5 103#define ZFCP_EXCHANGE_CONFIG_DATA_RETRIES 7
1da177e4
LT
104
105/* timeout value for "default timer" for fsf requests */
2abbe866 106#define ZFCP_FSF_REQUEST_TIMEOUT (60*HZ)
1da177e4
LT
107
108/*************** FIBRE CHANNEL PROTOCOL SPECIFIC DEFINES ********************/
109
110typedef unsigned long long wwn_t;
1da177e4
LT
111typedef unsigned long long fcp_lun_t;
112/* data length field may be at variable position in FCP-2 FCP_CMND IU */
113typedef unsigned int fcp_dl_t;
114
1da177e4
LT
115/* timeout for name-server lookup (in seconds) */
116#define ZFCP_NS_GID_PN_TIMEOUT 10
117
1da177e4
LT
118/* task attribute values in FCP-2 FCP_CMND IU */
119#define SIMPLE_Q 0
120#define HEAD_OF_Q 1
121#define ORDERED_Q 2
122#define ACA_Q 4
123#define UNTAGGED 5
124
125/* task management flags in FCP-2 FCP_CMND IU */
126#define FCP_CLEAR_ACA 0x40
127#define FCP_TARGET_RESET 0x20
128#define FCP_LOGICAL_UNIT_RESET 0x10
129#define FCP_CLEAR_TASK_SET 0x04
130#define FCP_ABORT_TASK_SET 0x02
131
132#define FCP_CDB_LENGTH 16
133
134#define ZFCP_DID_MASK 0x00FFFFFF
135
136/* FCP(-2) FCP_CMND IU */
137struct fcp_cmnd_iu {
138 fcp_lun_t fcp_lun; /* FCP logical unit number */
139 u8 crn; /* command reference number */
140 u8 reserved0:5; /* reserved */
141 u8 task_attribute:3; /* task attribute */
142 u8 task_management_flags; /* task management flags */
143 u8 add_fcp_cdb_length:6; /* additional FCP_CDB length */
144 u8 rddata:1; /* read data */
145 u8 wddata:1; /* write data */
146 u8 fcp_cdb[FCP_CDB_LENGTH];
147} __attribute__((packed));
148
149/* FCP(-2) FCP_RSP IU */
150struct fcp_rsp_iu {
151 u8 reserved0[10];
152 union {
153 struct {
154 u8 reserved1:3;
155 u8 fcp_conf_req:1;
156 u8 fcp_resid_under:1;
157 u8 fcp_resid_over:1;
158 u8 fcp_sns_len_valid:1;
159 u8 fcp_rsp_len_valid:1;
160 } bits;
161 u8 value;
162 } validity;
163 u8 scsi_status;
164 u32 fcp_resid;
165 u32 fcp_sns_len;
166 u32 fcp_rsp_len;
167} __attribute__((packed));
168
169
170#define RSP_CODE_GOOD 0
171#define RSP_CODE_LENGTH_MISMATCH 1
172#define RSP_CODE_FIELD_INVALID 2
173#define RSP_CODE_RO_MISMATCH 3
174#define RSP_CODE_TASKMAN_UNSUPP 4
175#define RSP_CODE_TASKMAN_FAILED 5
176
177/* see fc-fs */
24073b47
CS
178#define LS_RSCN 0x61
179#define LS_LOGO 0x05
180#define LS_PLOGI 0x03
1da177e4
LT
181
182struct fcp_rscn_head {
183 u8 command;
184 u8 page_length; /* always 0x04 */
185 u16 payload_len;
186} __attribute__((packed));
187
188struct fcp_rscn_element {
189 u8 reserved:2;
190 u8 event_qual:4;
191 u8 addr_format:2;
192 u32 nport_did:24;
193} __attribute__((packed));
194
195#define ZFCP_PORT_ADDRESS 0x0
196#define ZFCP_AREA_ADDRESS 0x1
197#define ZFCP_DOMAIN_ADDRESS 0x2
198#define ZFCP_FABRIC_ADDRESS 0x3
199
200#define ZFCP_PORTS_RANGE_PORT 0xFFFFFF
201#define ZFCP_PORTS_RANGE_AREA 0xFFFF00
202#define ZFCP_PORTS_RANGE_DOMAIN 0xFF0000
203#define ZFCP_PORTS_RANGE_FABRIC 0x000000
204
205#define ZFCP_NO_PORTS_PER_AREA 0x100
206#define ZFCP_NO_PORTS_PER_DOMAIN 0x10000
207#define ZFCP_NO_PORTS_PER_FABRIC 0x1000000
208
1da177e4
LT
209/* see fc-ph */
210struct fcp_logo {
211 u32 command;
212 u32 nport_did;
213 wwn_t nport_wwpn;
214} __attribute__((packed));
215
216/*
217 * FC-FS stuff
218 */
219#define R_A_TOV 10 /* seconds */
1da177e4
LT
220
221#define ZFCP_LS_RLS 0x0f
222#define ZFCP_LS_ADISC 0x52
223#define ZFCP_LS_RPS 0x56
224#define ZFCP_LS_RSCN 0x61
225#define ZFCP_LS_RNID 0x78
226
227struct zfcp_ls_rjt_par {
228 u8 action;
229 u8 reason_code;
230 u8 reason_expl;
231 u8 vendor_unique;
232} __attribute__ ((packed));
233
234struct zfcp_ls_adisc {
235 u8 code;
236 u8 field[3];
237 u32 hard_nport_id;
238 u64 wwpn;
239 u64 wwnn;
240 u32 nport_id;
241} __attribute__ ((packed));
242
243struct zfcp_ls_adisc_acc {
244 u8 code;
245 u8 field[3];
246 u32 hard_nport_id;
247 u64 wwpn;
248 u64 wwnn;
249 u32 nport_id;
250} __attribute__ ((packed));
251
252struct zfcp_rc_entry {
253 u8 code;
254 const char *description;
255};
256
257/*
258 * FC-GS-2 stuff
259 */
260#define ZFCP_CT_REVISION 0x01
261#define ZFCP_CT_DIRECTORY_SERVICE 0xFC
262#define ZFCP_CT_NAME_SERVER 0x02
263#define ZFCP_CT_SYNCHRONOUS 0x00
cc8c2829
SS
264#define ZFCP_CT_SCSI_FCP 0x08
265#define ZFCP_CT_UNABLE_TO_PERFORM_CMD 0x09
1da177e4 266#define ZFCP_CT_GID_PN 0x0121
cc8c2829 267#define ZFCP_CT_GPN_FT 0x0172
1da177e4
LT
268#define ZFCP_CT_MAX_SIZE 0x1020
269#define ZFCP_CT_ACCEPT 0x8002
270#define ZFCP_CT_REJECT 0x8001
271
272/*
273 * FC-GS-4 stuff
274 */
275#define ZFCP_CT_TIMEOUT (3 * R_A_TOV)
276
1da177e4
LT
277/*************** ADAPTER/PORT/UNIT AND FSF_REQ STATUS FLAGS ******************/
278
41fa2ada
SS
279/*
280 * Note, the leftmost status byte is common among adapter, port
1da177e4
LT
281 * and unit
282 */
283#define ZFCP_COMMON_FLAGS 0xfff00000
1da177e4
LT
284
285/* common status bits */
286#define ZFCP_STATUS_COMMON_REMOVE 0x80000000
287#define ZFCP_STATUS_COMMON_RUNNING 0x40000000
288#define ZFCP_STATUS_COMMON_ERP_FAILED 0x20000000
289#define ZFCP_STATUS_COMMON_UNBLOCKED 0x10000000
290#define ZFCP_STATUS_COMMON_OPENING 0x08000000
291#define ZFCP_STATUS_COMMON_OPEN 0x04000000
292#define ZFCP_STATUS_COMMON_CLOSING 0x02000000
293#define ZFCP_STATUS_COMMON_ERP_INUSE 0x01000000
294#define ZFCP_STATUS_COMMON_ACCESS_DENIED 0x00800000
d736a27b 295#define ZFCP_STATUS_COMMON_ACCESS_BOXED 0x00400000
cc8c2829 296#define ZFCP_STATUS_COMMON_NOESC 0x00200000
1da177e4
LT
297
298/* adapter status */
299#define ZFCP_STATUS_ADAPTER_QDIOUP 0x00000002
300#define ZFCP_STATUS_ADAPTER_REGISTERED 0x00000004
301#define ZFCP_STATUS_ADAPTER_XCONFIG_OK 0x00000008
302#define ZFCP_STATUS_ADAPTER_HOST_CON_INIT 0x00000010
303#define ZFCP_STATUS_ADAPTER_ERP_THREAD_UP 0x00000020
304#define ZFCP_STATUS_ADAPTER_ERP_THREAD_KILL 0x00000080
305#define ZFCP_STATUS_ADAPTER_ERP_PENDING 0x00000100
306#define ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED 0x00000200
aef4a983 307#define ZFCP_STATUS_ADAPTER_XPORT_OK 0x00000800
1da177e4 308
1da177e4
LT
309/* FC-PH/FC-GS well-known address identifiers for generic services */
310#define ZFCP_DID_MANAGEMENT_SERVICE 0xFFFFFA
311#define ZFCP_DID_TIME_SERVICE 0xFFFFFB
312#define ZFCP_DID_DIRECTORY_SERVICE 0xFFFFFC
313#define ZFCP_DID_ALIAS_SERVICE 0xFFFFF8
314#define ZFCP_DID_KEY_DISTRIBUTION_SERVICE 0xFFFFF7
315
316/* remote port status */
317#define ZFCP_STATUS_PORT_PHYS_OPEN 0x00000001
318#define ZFCP_STATUS_PORT_DID_DID 0x00000002
319#define ZFCP_STATUS_PORT_PHYS_CLOSING 0x00000004
320#define ZFCP_STATUS_PORT_NO_WWPN 0x00000008
321#define ZFCP_STATUS_PORT_NO_SCSI_ID 0x00000010
322#define ZFCP_STATUS_PORT_INVALID_WWPN 0x00000020
1da177e4
LT
323
324/* for ports with well known addresses */
325#define ZFCP_STATUS_PORT_WKA \
326 (ZFCP_STATUS_PORT_NO_WWPN | \
327 ZFCP_STATUS_PORT_NO_SCSI_ID)
328
329/* logical unit status */
1da177e4
LT
330#define ZFCP_STATUS_UNIT_TEMPORARY 0x00000002
331#define ZFCP_STATUS_UNIT_SHARED 0x00000004
332#define ZFCP_STATUS_UNIT_READONLY 0x00000008
ad58f7db 333#define ZFCP_STATUS_UNIT_REGISTERED 0x00000010
5f852be9 334#define ZFCP_STATUS_UNIT_SCSI_WORK_PENDING 0x00000020
1da177e4
LT
335
336/* FSF request status (this does not have a common part) */
337#define ZFCP_STATUS_FSFREQ_NOT_INIT 0x00000000
338#define ZFCP_STATUS_FSFREQ_POOL 0x00000001
339#define ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT 0x00000002
340#define ZFCP_STATUS_FSFREQ_COMPLETED 0x00000004
341#define ZFCP_STATUS_FSFREQ_ERROR 0x00000008
342#define ZFCP_STATUS_FSFREQ_CLEANUP 0x00000010
343#define ZFCP_STATUS_FSFREQ_ABORTING 0x00000020
344#define ZFCP_STATUS_FSFREQ_ABORTSUCCEEDED 0x00000040
345#define ZFCP_STATUS_FSFREQ_ABORTNOTNEEDED 0x00000080
346#define ZFCP_STATUS_FSFREQ_ABORTED 0x00000100
347#define ZFCP_STATUS_FSFREQ_TMFUNCFAILED 0x00000200
348#define ZFCP_STATUS_FSFREQ_TMFUNCNOTSUPP 0x00000400
349#define ZFCP_STATUS_FSFREQ_RETRY 0x00000800
350#define ZFCP_STATUS_FSFREQ_DISMISSED 0x00001000
351
352/*********************** ERROR RECOVERY PROCEDURE DEFINES ********************/
353
354#define ZFCP_MAX_ERPS 3
355
356#define ZFCP_ERP_FSFREQ_TIMEOUT (30 * HZ)
357#define ZFCP_ERP_MEMWAIT_TIMEOUT HZ
358
359#define ZFCP_STATUS_ERP_TIMEDOUT 0x10000000
360#define ZFCP_STATUS_ERP_CLOSE_ONLY 0x01000000
361#define ZFCP_STATUS_ERP_DISMISSING 0x00100000
362#define ZFCP_STATUS_ERP_DISMISSED 0x00200000
363#define ZFCP_STATUS_ERP_LOWMEM 0x00400000
364
365#define ZFCP_ERP_STEP_UNINITIALIZED 0x00000000
366#define ZFCP_ERP_STEP_FSF_XCONFIG 0x00000001
367#define ZFCP_ERP_STEP_PHYS_PORT_CLOSING 0x00000010
368#define ZFCP_ERP_STEP_PORT_CLOSING 0x00000100
369#define ZFCP_ERP_STEP_NAMESERVER_OPEN 0x00000200
370#define ZFCP_ERP_STEP_NAMESERVER_LOOKUP 0x00000400
371#define ZFCP_ERP_STEP_PORT_OPENING 0x00000800
372#define ZFCP_ERP_STEP_UNIT_CLOSING 0x00001000
373#define ZFCP_ERP_STEP_UNIT_OPENING 0x00002000
374
375/* Ordered by escalation level (necessary for proper erp-code operation) */
376#define ZFCP_ERP_ACTION_REOPEN_ADAPTER 0x4
377#define ZFCP_ERP_ACTION_REOPEN_PORT_FORCED 0x3
378#define ZFCP_ERP_ACTION_REOPEN_PORT 0x2
379#define ZFCP_ERP_ACTION_REOPEN_UNIT 0x1
380
381#define ZFCP_ERP_ACTION_RUNNING 0x1
382#define ZFCP_ERP_ACTION_READY 0x2
383
384#define ZFCP_ERP_SUCCEEDED 0x0
385#define ZFCP_ERP_FAILED 0x1
386#define ZFCP_ERP_CONTINUES 0x2
387#define ZFCP_ERP_EXIT 0x3
388#define ZFCP_ERP_DISMISSED 0x4
389#define ZFCP_ERP_NOMEM 0x5
390
1da177e4
LT
391/************************* STRUCTURE DEFINITIONS *****************************/
392
393struct zfcp_fsf_req;
394
395/* holds various memory pools of an adapter */
396struct zfcp_adapter_mempool {
397 mempool_t *fsf_req_erp;
398 mempool_t *fsf_req_scsi;
399 mempool_t *fsf_req_abort;
400 mempool_t *fsf_req_status_read;
401 mempool_t *data_status_read;
402 mempool_t *data_gid_pn;
403};
404
1da177e4
LT
405/*
406 * header for CT_IU
407 */
408struct ct_hdr {
409 u8 revision; // 0x01
410 u8 in_id[3]; // 0x00
411 u8 gs_type; // 0xFC Directory Service
412 u8 gs_subtype; // 0x02 Name Server
413 u8 options; // 0x00 single bidirectional exchange
414 u8 reserved0;
415 u16 cmd_rsp_code; // 0x0121 GID_PN, or 0x0100 GA_NXT
416 u16 max_res_size; // <= (4096 - 16) / 4
417 u8 reserved1;
418 u8 reason_code;
419 u8 reason_code_expl;
420 u8 vendor_unique;
421} __attribute__ ((packed));
422
423/* nameserver request CT_IU -- for requests where
424 * a port name is required */
425struct ct_iu_gid_pn_req {
426 struct ct_hdr header;
427 wwn_t wwpn;
428} __attribute__ ((packed));
429
430/* FS_ACC IU and data unit for GID_PN nameserver request */
431struct ct_iu_gid_pn_resp {
432 struct ct_hdr header;
13e1e1f0 433 u32 d_id;
1da177e4
LT
434} __attribute__ ((packed));
435
436typedef void (*zfcp_send_ct_handler_t)(unsigned long);
437
438/**
439 * struct zfcp_send_ct - used to pass parameters to function zfcp_fsf_send_ct
440 * @port: port where the request is sent to
441 * @req: scatter-gather list for request
442 * @resp: scatter-gather list for response
443 * @req_count: number of elements in request scatter-gather list
444 * @resp_count: number of elements in response scatter-gather list
445 * @handler: handler function (called for response to the request)
446 * @handler_data: data passed to handler function
1da177e4 447 * @timeout: FSF timeout for this request
1da177e4
LT
448 * @completion: completion for synchronization purposes
449 * @status: used to pass error status to calling function
450 */
451struct zfcp_send_ct {
452 struct zfcp_port *port;
453 struct scatterlist *req;
454 struct scatterlist *resp;
455 unsigned int req_count;
456 unsigned int resp_count;
457 zfcp_send_ct_handler_t handler;
458 unsigned long handler_data;
1da177e4 459 int timeout;
1da177e4
LT
460 struct completion *completion;
461 int status;
462};
463
464/* used for name server requests in error recovery */
465struct zfcp_gid_pn_data {
466 struct zfcp_send_ct ct;
467 struct scatterlist req;
468 struct scatterlist resp;
469 struct ct_iu_gid_pn_req ct_iu_req;
470 struct ct_iu_gid_pn_resp ct_iu_resp;
471 struct zfcp_port *port;
472};
473
474typedef void (*zfcp_send_els_handler_t)(unsigned long);
475
476/**
477 * struct zfcp_send_els - used to pass parameters to function zfcp_fsf_send_els
478 * @adapter: adapter where request is sent from
64b29a13 479 * @port: port where ELS is destinated (port reference count has to be increased)
1da177e4
LT
480 * @d_id: destiniation id of port where request is sent to
481 * @req: scatter-gather list for request
482 * @resp: scatter-gather list for response
483 * @req_count: number of elements in request scatter-gather list
484 * @resp_count: number of elements in response scatter-gather list
485 * @handler: handler function (called for response to the request)
486 * @handler_data: data passed to handler function
1da177e4
LT
487 * @completion: completion for synchronization purposes
488 * @ls_code: hex code of ELS command
489 * @status: used to pass error status to calling function
490 */
491struct zfcp_send_els {
492 struct zfcp_adapter *adapter;
64b29a13 493 struct zfcp_port *port;
13e1e1f0 494 u32 d_id;
1da177e4
LT
495 struct scatterlist *req;
496 struct scatterlist *resp;
497 unsigned int req_count;
498 unsigned int resp_count;
499 zfcp_send_els_handler_t handler;
500 unsigned long handler_data;
1da177e4
LT
501 struct completion *completion;
502 int ls_code;
503 int status;
504};
505
1da177e4 506struct zfcp_qdio_queue {
00bab910
SS
507 struct qdio_buffer *sbal[QDIO_MAX_BUFFERS_PER_Q]; /* SBALs */
508 u8 first; /* index of next free bfr
1da177e4 509 in queue (free_count>0) */
00bab910 510 atomic_t count; /* number of free buffers
1da177e4 511 in queue */
c41f8cbd 512 spinlock_t lock; /* lock for operations on queue */
00bab910 513 int pci_batch; /* SBALs since PCI indication
1da177e4
LT
514 was last set */
515};
516
517struct zfcp_erp_action {
518 struct list_head list;
519 int action; /* requested action code */
520 struct zfcp_adapter *adapter; /* device which should be recovered */
521 struct zfcp_port *port;
522 struct zfcp_unit *unit;
523 volatile u32 status; /* recovery status */
524 u32 step; /* active step of this erp action */
525 struct zfcp_fsf_req *fsf_req; /* fsf request currently pending
526 for this action */
527 struct timer_list timer;
528};
529
c9615858
CS
530struct fsf_latency_record {
531 u32 min;
532 u32 max;
533 u64 sum;
534};
535
536struct latency_cont {
537 struct fsf_latency_record channel;
538 struct fsf_latency_record fabric;
539 u64 counter;
540};
541
542struct zfcp_latencies {
543 struct latency_cont read;
544 struct latency_cont write;
545 struct latency_cont cmd;
546 spinlock_t lock;
547};
1da177e4
LT
548
549struct zfcp_adapter {
550 struct list_head list; /* list of adapters */
551 atomic_t refcount; /* reference count */
552 wait_queue_head_t remove_wq; /* can be used to wait for
553 refcount drop to zero */
6f71d9bc 554 wwn_t peer_wwnn; /* P2P peer WWNN */
555 wwn_t peer_wwpn; /* P2P peer WWPN */
13e1e1f0 556 u32 peer_d_id; /* P2P peer D_ID */
1da177e4 557 struct ccw_device *ccw_device; /* S/390 ccw device */
1da177e4
LT
558 u32 hydra_version; /* Hydra version */
559 u32 fsf_lic_version;
aef4a983
MS
560 u32 adapter_features; /* FCP channel features */
561 u32 connection_features; /* host connection features */
1da177e4 562 u32 hardware_version; /* of FCP channel */
c9615858 563 u16 timer_ticks; /* time int for a tick */
1da177e4 564 struct Scsi_Host *scsi_host; /* Pointer to mid-layer */
1da177e4
LT
565 struct list_head port_list_head; /* remote port list */
566 struct list_head port_remove_lh; /* head of ports to be
567 removed */
568 u32 ports; /* number of remote ports */
fea9d6c7
VS
569 unsigned long req_no; /* unique FSF req number */
570 struct list_head *req_list; /* list of pending reqs */
571 spinlock_t req_list_lock; /* request list lock */
00bab910 572 struct zfcp_qdio_queue req_q; /* request queue */
1da177e4
LT
573 u32 fsf_req_seq_no; /* FSF cmnd seq number */
574 wait_queue_head_t request_wq; /* can be used to wait for
575 more avaliable SBALs */
00bab910 576 struct zfcp_qdio_queue resp_q; /* response queue */
1da177e4
LT
577 rwlock_t abort_lock; /* Protects against SCSI
578 stack abort/command
579 completion races */
d26ab06e
SS
580 atomic_t stat_miss; /* # missing status reads*/
581 struct work_struct stat_work;
1da177e4
LT
582 atomic_t status; /* status of this adapter */
583 struct list_head erp_ready_head; /* error recovery for this
584 adapter/devices */
585 struct list_head erp_running_head;
586 rwlock_t erp_lock;
587 struct semaphore erp_ready_sem;
588 wait_queue_head_t erp_thread_wqh;
589 wait_queue_head_t erp_done_wqh;
590 struct zfcp_erp_action erp_action; /* pending error recovery */
591 atomic_t erp_counter;
592 u32 erp_total_count; /* total nr of enqueued erp
593 actions */
594 u32 erp_low_mem_count; /* nr of erp actions waiting
595 for memory */
596 struct zfcp_port *nameserver_port; /* adapter's nameserver */
d79a83db 597 debug_info_t *rec_dbf;
8a36e453
MS
598 debug_info_t *hba_dbf;
599 debug_info_t *san_dbf; /* debug feature areas */
600 debug_info_t *scsi_dbf;
d79a83db 601 spinlock_t rec_dbf_lock;
8a36e453
MS
602 spinlock_t hba_dbf_lock;
603 spinlock_t san_dbf_lock;
604 spinlock_t scsi_dbf_lock;
d79a83db 605 struct zfcp_rec_dbf_record rec_dbf_buf;
8a36e453
MS
606 struct zfcp_hba_dbf_record hba_dbf_buf;
607 struct zfcp_san_dbf_record san_dbf_buf;
608 struct zfcp_scsi_dbf_record scsi_dbf_buf;
1da177e4
LT
609 struct zfcp_adapter_mempool pool; /* Adapter memory pools */
610 struct qdio_initialize qdio_init_data; /* for qdio_establish */
611 struct device generic_services; /* directory for WKA ports */
f6cd94b1
AH
612 struct fc_host_statistics *fc_stats;
613 struct fsf_qtcb_bottom_port *stats_reset_data;
614 unsigned long stats_reset;
cc8c2829 615 struct work_struct scan_work;
1da177e4
LT
616};
617
1da177e4
LT
618struct zfcp_port {
619 struct device sysfs_device; /* sysfs device */
3859f6a2 620 struct fc_rport *rport; /* rport of fc transport class */
1da177e4
LT
621 struct list_head list; /* list of remote ports */
622 atomic_t refcount; /* reference count */
623 wait_queue_head_t remove_wq; /* can be used to wait for
624 refcount drop to zero */
625 struct zfcp_adapter *adapter; /* adapter used to access port */
626 struct list_head unit_list_head; /* head of logical unit list */
627 struct list_head unit_remove_lh; /* head of luns to be removed
628 list */
629 u32 units; /* # of logical units in list */
630 atomic_t status; /* status of this remote port */
1da177e4
LT
631 wwn_t wwnn; /* WWNN if known */
632 wwn_t wwpn; /* WWPN */
13e1e1f0 633 u32 d_id; /* D_ID */
1da177e4
LT
634 u32 handle; /* handle assigned by FSF */
635 struct zfcp_erp_action erp_action; /* pending error recovery */
636 atomic_t erp_counter;
75bfc283
RW
637 u32 maxframe_size;
638 u32 supported_classes;
1da177e4
LT
639};
640
1da177e4
LT
641struct zfcp_unit {
642 struct device sysfs_device; /* sysfs device */
643 struct list_head list; /* list of logical units */
644 atomic_t refcount; /* reference count */
645 wait_queue_head_t remove_wq; /* can be used to wait for
646 refcount drop to zero */
647 struct zfcp_port *port; /* remote port of unit */
648 atomic_t status; /* status of this logical unit */
06506d00 649 unsigned int scsi_lun; /* own SCSI LUN */
1da177e4
LT
650 fcp_lun_t fcp_lun; /* own FCP_LUN */
651 u32 handle; /* handle assigned by FSF */
652 struct scsi_device *device; /* scsi device struct pointer */
653 struct zfcp_erp_action erp_action; /* pending error recovery */
654 atomic_t erp_counter;
c9615858 655 struct zfcp_latencies latencies;
1da177e4
LT
656};
657
658/* FSF request */
659struct zfcp_fsf_req {
660 struct list_head list; /* list of FSF requests */
fea9d6c7 661 unsigned long req_id; /* unique request ID */
1da177e4
LT
662 struct zfcp_adapter *adapter; /* adapter request belongs to */
663 u8 sbal_number; /* nr of SBALs free for use */
664 u8 sbal_first; /* first SBAL for this request */
e891bffe 665 u8 sbal_last; /* last SBAL for this request */
d01d51be 666 u8 sbal_limit; /* last possible SBAL for
1da177e4 667 this reuest */
1da177e4
LT
668 u8 sbale_curr; /* current SBALE during creation
669 of request */
c3baa9a2 670 u8 sbal_response; /* SBAL used in interrupt */
1da177e4
LT
671 wait_queue_head_t completion_wq; /* can be used by a routine
672 to wait for completion */
673 volatile u32 status; /* status of this request */
674 u32 fsf_command; /* FSF Command copy */
675 struct fsf_qtcb *qtcb; /* address of associated QTCB */
676 u32 seq_no; /* Sequence number of request */
c41f8cbd 677 void *data; /* private data of request */
41fa2ada 678 struct timer_list timer; /* used for erp or scsi er */
1da177e4
LT
679 struct zfcp_erp_action *erp_action; /* used if this request is
680 issued on behalf of erp */
681 mempool_t *pool; /* used if request was alloacted
682 from emergency pool */
8a36e453 683 unsigned long long issued; /* request sent time (STCK) */
059c97d0 684 struct zfcp_unit *unit;
c41f8cbd 685 void (*handler)(struct zfcp_fsf_req *);
1da177e4
LT
686};
687
1da177e4
LT
688/* driver data */
689struct zfcp_data {
690 struct scsi_host_template scsi_host_template;
dd52e0ea 691 struct scsi_transport_template *scsi_transport_template;
1da177e4
LT
692 atomic_t status; /* Module status flags */
693 struct list_head adapter_list_head; /* head of adapter list */
694 struct list_head adapter_remove_lh; /* head of adapters to be
695 removed */
1da177e4
LT
696 u32 adapters; /* # of adapters in list */
697 rwlock_t config_lock; /* serialises changes
698 to adapter/port/unit
699 lists */
700 struct semaphore config_sema; /* serialises configuration
701 changes */
702 atomic_t loglevel; /* current loglevel */
703 char init_busid[BUS_ID_SIZE];
704 wwn_t init_wwpn;
705 fcp_lun_t init_fcp_lun;
e18b890b
CL
706 struct kmem_cache *fsf_req_qtcb_cache;
707 struct kmem_cache *sr_buffer_cache;
708 struct kmem_cache *gid_pn_cache;
1da177e4
LT
709};
710
1da177e4 711/* struct used by memory pools for fsf_requests */
dd52e0ea 712struct zfcp_fsf_req_qtcb {
1da177e4
LT
713 struct zfcp_fsf_req fsf_req;
714 struct fsf_qtcb qtcb;
715};
716
717/********************** ZFCP SPECIFIC DEFINES ********************************/
718
1da177e4 719#define ZFCP_REQ_AUTO_CLEANUP 0x00000002
1da177e4
LT
720#define ZFCP_REQ_NO_QTCB 0x00000008
721
722#define ZFCP_SET 0x00000100
723#define ZFCP_CLEAR 0x00000200
724
1da177e4
LT
725#ifndef atomic_test_mask
726#define atomic_test_mask(mask, target) \
727 ((atomic_read(target) & mask) == mask)
728#endif
729
1da177e4
LT
730#define zfcp_get_busid_by_adapter(adapter) (adapter->ccw_device->dev.bus_id)
731#define zfcp_get_busid_by_port(port) (zfcp_get_busid_by_adapter(port->adapter))
732#define zfcp_get_busid_by_unit(unit) (zfcp_get_busid_by_port(unit->port))
733
ca2d02c2
HC
734/*
735 * Helper functions for request ID management.
736 */
737static inline int zfcp_reqlist_hash(unsigned long req_id)
738{
739 return req_id % REQUEST_LIST_SIZE;
740}
741
ca2d02c2
HC
742static inline void zfcp_reqlist_remove(struct zfcp_adapter *adapter,
743 struct zfcp_fsf_req *fsf_req)
744{
745 list_del(&fsf_req->list);
746}
747
748static inline struct zfcp_fsf_req *
749zfcp_reqlist_find(struct zfcp_adapter *adapter, unsigned long req_id)
750{
751 struct zfcp_fsf_req *request;
752 unsigned int idx;
753
754 idx = zfcp_reqlist_hash(req_id);
755 list_for_each_entry(request, &adapter->req_list[idx], list)
756 if (request->req_id == req_id)
757 return request;
758 return NULL;
759}
760
d1ad09db
HC
761static inline struct zfcp_fsf_req *
762zfcp_reqlist_find_safe(struct zfcp_adapter *adapter, struct zfcp_fsf_req *req)
763{
764 struct zfcp_fsf_req *request;
765 unsigned int idx;
766
767 for (idx = 0; idx < REQUEST_LIST_SIZE; idx++) {
768 list_for_each_entry(request, &adapter->req_list[idx], list)
769 if (request == req)
770 return request;
771 }
772 return NULL;
773}
774
1da177e4
LT
775/*
776 * functions needed for reference/usage counting
777 */
778
779static inline void
780zfcp_unit_get(struct zfcp_unit *unit)
781{
782 atomic_inc(&unit->refcount);
783}
784
785static inline void
786zfcp_unit_put(struct zfcp_unit *unit)
787{
788 if (atomic_dec_return(&unit->refcount) == 0)
789 wake_up(&unit->remove_wq);
790}
791
792static inline void
793zfcp_unit_wait(struct zfcp_unit *unit)
794{
795 wait_event(unit->remove_wq, atomic_read(&unit->refcount) == 0);
796}
797
798static inline void
799zfcp_port_get(struct zfcp_port *port)
800{
801 atomic_inc(&port->refcount);
802}
803
804static inline void
805zfcp_port_put(struct zfcp_port *port)
806{
807 if (atomic_dec_return(&port->refcount) == 0)
808 wake_up(&port->remove_wq);
809}
810
811static inline void
812zfcp_port_wait(struct zfcp_port *port)
813{
814 wait_event(port->remove_wq, atomic_read(&port->refcount) == 0);
815}
816
817static inline void
818zfcp_adapter_get(struct zfcp_adapter *adapter)
819{
820 atomic_inc(&adapter->refcount);
821}
822
823static inline void
824zfcp_adapter_put(struct zfcp_adapter *adapter)
825{
826 if (atomic_dec_return(&adapter->refcount) == 0)
827 wake_up(&adapter->remove_wq);
828}
829
830static inline void
831zfcp_adapter_wait(struct zfcp_adapter *adapter)
832{
833 wait_event(adapter->remove_wq, atomic_read(&adapter->refcount) == 0);
834}
835
836#endif /* ZFCP_DEF_H */
This page took 0.393317 seconds and 5 git commands to generate.