]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - drivers/s390/scsi/zfcp_def.h
[SCSI] imm: no need for unchecked_isa_dma
[mirror_ubuntu-bionic-kernel.git] / drivers / s390 / scsi / zfcp_def.h
CommitLineData
1da177e4
LT
1/*
2 *
3 * linux/drivers/s390/scsi/zfcp_def.h
4 *
5 * FCP adapter driver for IBM eServer zSeries
6 *
7 * (C) Copyright IBM Corp. 2002, 2004
8 *
9 * Author(s): Martin Peschke <mpeschke@de.ibm.com>
10 * Raimund Schroeder <raimund.schroeder@de.ibm.com>
11 * Aron Zeh
12 * Wolfgang Taphorn
13 * Stefan Bader <stefan.bader@de.ibm.com>
14 * Heiko Carstens <heiko.carstens@de.ibm.com>
15 * Andreas Herrmann <aherrman@de.ibm.com>
16 * Volker Sameske <sameske@de.ibm.com>
17 *
18 * This program is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published by
20 * the Free Software Foundation; either version 2, or (at your option)
21 * any later version.
22 *
23 * This program is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
27 *
28 * You should have received a copy of the GNU General Public License
29 * along with this program; if not, write to the Free Software
30 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
31 */
32
33
34#ifndef ZFCP_DEF_H
35#define ZFCP_DEF_H
36
1da177e4
LT
37/*************************** INCLUDES *****************************************/
38
39#include <linux/init.h>
40#include <linux/moduleparam.h>
41#include <linux/miscdevice.h>
42#include <linux/major.h>
43#include <linux/blkdev.h>
44#include <linux/delay.h>
45#include <linux/timer.h>
46#include <scsi/scsi.h>
47#include <scsi/scsi_tcq.h>
48#include <scsi/scsi_cmnd.h>
49#include <scsi/scsi_device.h>
50#include <scsi/scsi_host.h>
51#include <scsi/scsi_transport.h>
52#include <scsi/scsi_transport_fc.h>
53#include "../../fc4/fc.h"
54#include "zfcp_fsf.h"
55#include <asm/ccwdev.h>
56#include <asm/qdio.h>
57#include <asm/debug.h>
58#include <asm/ebcdic.h>
59#include <linux/mempool.h>
60#include <linux/syscalls.h>
61#include <linux/ioctl.h>
1da177e4 62
1da177e4
LT
63
64/********************* GENERAL DEFINES *********************************/
65
66/* zfcp version number, it consists of major, minor, and patch-level number */
aef4a983 67#define ZFCP_VERSION "4.5.0"
1da177e4
LT
68
69/**
70 * zfcp_sg_to_address - determine kernel address from struct scatterlist
71 * @list: struct scatterlist
72 * Return: kernel address
73 */
74static inline void *
75zfcp_sg_to_address(struct scatterlist *list)
76{
77 return (void *) (page_address(list->page) + list->offset);
78}
79
80/**
81 * zfcp_address_to_sg - set up struct scatterlist from kernel address
82 * @address: kernel address
83 * @list: struct scatterlist
84 */
85static inline void
86zfcp_address_to_sg(void *address, struct scatterlist *list)
87{
88 list->page = virt_to_page(address);
89 list->offset = ((unsigned long) address) & (PAGE_SIZE - 1);
90}
91
92/********************* SCSI SPECIFIC DEFINES *********************************/
93
94/* 32 bit for SCSI ID and LUN as long as the SCSI stack uses this type */
95typedef u32 scsi_id_t;
96typedef u32 scsi_lun_t;
97
98#define ZFCP_ERP_SCSI_LOW_MEM_TIMEOUT (100*HZ)
99#define ZFCP_SCSI_ER_TIMEOUT (100*HZ)
100
101/********************* CIO/QDIO SPECIFIC DEFINES *****************************/
102
103/* Adapter Identification Parameters */
104#define ZFCP_CONTROL_UNIT_TYPE 0x1731
105#define ZFCP_CONTROL_UNIT_MODEL 0x03
106#define ZFCP_DEVICE_TYPE 0x1732
107#define ZFCP_DEVICE_MODEL 0x03
108#define ZFCP_DEVICE_MODEL_PRIV 0x04
109
110/* allow as many chained SBALs as are supported by hardware */
111#define ZFCP_MAX_SBALS_PER_REQ FSF_MAX_SBALS_PER_REQ
112#define ZFCP_MAX_SBALS_PER_CT_REQ FSF_MAX_SBALS_PER_REQ
113#define ZFCP_MAX_SBALS_PER_ELS_REQ FSF_MAX_SBALS_PER_ELS_REQ
114
115/* DMQ bug workaround: don't use last SBALE */
116#define ZFCP_MAX_SBALES_PER_SBAL (QDIO_MAX_ELEMENTS_PER_BUFFER - 1)
117
118/* index of last SBALE (with respect to DMQ bug workaround) */
119#define ZFCP_LAST_SBALE_PER_SBAL (ZFCP_MAX_SBALES_PER_SBAL - 1)
120
121/* max. number of (data buffer) SBALEs in largest SBAL chain */
122#define ZFCP_MAX_SBALES_PER_REQ \
123 (ZFCP_MAX_SBALS_PER_REQ * ZFCP_MAX_SBALES_PER_SBAL - 2)
124 /* request ID + QTCB in SBALE 0 + 1 of first SBAL in chain */
125
126/* FIXME(tune): free space should be one max. SBAL chain plus what? */
127#define ZFCP_QDIO_PCI_INTERVAL (QDIO_MAX_BUFFERS_PER_Q \
128 - (ZFCP_MAX_SBALS_PER_REQ + 4))
129
130#define ZFCP_SBAL_TIMEOUT (5*HZ)
131
132#define ZFCP_TYPE2_RECOVERY_TIME (8*HZ)
133
134/* queue polling (values in microseconds) */
135#define ZFCP_MAX_INPUT_THRESHOLD 5000 /* FIXME: tune */
136#define ZFCP_MAX_OUTPUT_THRESHOLD 1000 /* FIXME: tune */
137#define ZFCP_MIN_INPUT_THRESHOLD 1 /* ignored by QDIO layer */
138#define ZFCP_MIN_OUTPUT_THRESHOLD 1 /* ignored by QDIO layer */
139
140#define QDIO_SCSI_QFMT 1 /* 1 for FSF */
141
142/********************* FSF SPECIFIC DEFINES *********************************/
143
144#define ZFCP_ULP_INFO_VERSION 26
145#define ZFCP_QTCB_VERSION FSF_QTCB_CURRENT_VERSION
146/* ATTENTION: value must not be used by hardware */
147#define FSF_QTCB_UNSOLICITED_STATUS 0x6305
148#define ZFCP_STATUS_READ_FAILED_THRESHOLD 3
149#define ZFCP_STATUS_READS_RECOM FSF_STATUS_READS_RECOM
22753fa5
AH
150
151/* Do 1st retry in 1 second, then double the timeout for each following retry */
152#define ZFCP_EXCHANGE_CONFIG_DATA_FIRST_SLEEP 100
153#define ZFCP_EXCHANGE_CONFIG_DATA_RETRIES 7
1da177e4
LT
154
155/* timeout value for "default timer" for fsf requests */
156#define ZFCP_FSF_REQUEST_TIMEOUT (60*HZ);
157
158/*************** FIBRE CHANNEL PROTOCOL SPECIFIC DEFINES ********************/
159
160typedef unsigned long long wwn_t;
1da177e4
LT
161typedef unsigned long long fcp_lun_t;
162/* data length field may be at variable position in FCP-2 FCP_CMND IU */
163typedef unsigned int fcp_dl_t;
164
165#define ZFCP_FC_SERVICE_CLASS_DEFAULT FSF_CLASS_3
166
167/* timeout for name-server lookup (in seconds) */
168#define ZFCP_NS_GID_PN_TIMEOUT 10
169
170/* largest SCSI command we can process */
171/* FCP-2 (FCP_CMND IU) allows up to (255-3+16) */
172#define ZFCP_MAX_SCSI_CMND_LENGTH 255
173/* maximum number of commands in LUN queue (tagged queueing) */
174#define ZFCP_CMND_PER_LUN 32
175
176/* task attribute values in FCP-2 FCP_CMND IU */
177#define SIMPLE_Q 0
178#define HEAD_OF_Q 1
179#define ORDERED_Q 2
180#define ACA_Q 4
181#define UNTAGGED 5
182
183/* task management flags in FCP-2 FCP_CMND IU */
184#define FCP_CLEAR_ACA 0x40
185#define FCP_TARGET_RESET 0x20
186#define FCP_LOGICAL_UNIT_RESET 0x10
187#define FCP_CLEAR_TASK_SET 0x04
188#define FCP_ABORT_TASK_SET 0x02
189
190#define FCP_CDB_LENGTH 16
191
192#define ZFCP_DID_MASK 0x00FFFFFF
193
194/* FCP(-2) FCP_CMND IU */
195struct fcp_cmnd_iu {
196 fcp_lun_t fcp_lun; /* FCP logical unit number */
197 u8 crn; /* command reference number */
198 u8 reserved0:5; /* reserved */
199 u8 task_attribute:3; /* task attribute */
200 u8 task_management_flags; /* task management flags */
201 u8 add_fcp_cdb_length:6; /* additional FCP_CDB length */
202 u8 rddata:1; /* read data */
203 u8 wddata:1; /* write data */
204 u8 fcp_cdb[FCP_CDB_LENGTH];
205} __attribute__((packed));
206
207/* FCP(-2) FCP_RSP IU */
208struct fcp_rsp_iu {
209 u8 reserved0[10];
210 union {
211 struct {
212 u8 reserved1:3;
213 u8 fcp_conf_req:1;
214 u8 fcp_resid_under:1;
215 u8 fcp_resid_over:1;
216 u8 fcp_sns_len_valid:1;
217 u8 fcp_rsp_len_valid:1;
218 } bits;
219 u8 value;
220 } validity;
221 u8 scsi_status;
222 u32 fcp_resid;
223 u32 fcp_sns_len;
224 u32 fcp_rsp_len;
225} __attribute__((packed));
226
227
228#define RSP_CODE_GOOD 0
229#define RSP_CODE_LENGTH_MISMATCH 1
230#define RSP_CODE_FIELD_INVALID 2
231#define RSP_CODE_RO_MISMATCH 3
232#define RSP_CODE_TASKMAN_UNSUPP 4
233#define RSP_CODE_TASKMAN_FAILED 5
234
235/* see fc-fs */
236#define LS_FAN 0x60000000
237#define LS_RSCN 0x61040000
238
239struct fcp_rscn_head {
240 u8 command;
241 u8 page_length; /* always 0x04 */
242 u16 payload_len;
243} __attribute__((packed));
244
245struct fcp_rscn_element {
246 u8 reserved:2;
247 u8 event_qual:4;
248 u8 addr_format:2;
249 u32 nport_did:24;
250} __attribute__((packed));
251
252#define ZFCP_PORT_ADDRESS 0x0
253#define ZFCP_AREA_ADDRESS 0x1
254#define ZFCP_DOMAIN_ADDRESS 0x2
255#define ZFCP_FABRIC_ADDRESS 0x3
256
257#define ZFCP_PORTS_RANGE_PORT 0xFFFFFF
258#define ZFCP_PORTS_RANGE_AREA 0xFFFF00
259#define ZFCP_PORTS_RANGE_DOMAIN 0xFF0000
260#define ZFCP_PORTS_RANGE_FABRIC 0x000000
261
262#define ZFCP_NO_PORTS_PER_AREA 0x100
263#define ZFCP_NO_PORTS_PER_DOMAIN 0x10000
264#define ZFCP_NO_PORTS_PER_FABRIC 0x1000000
265
266struct fcp_fan {
267 u32 command;
268 u32 fport_did;
269 wwn_t fport_wwpn;
270 wwn_t fport_wwname;
271} __attribute__((packed));
272
273/* see fc-ph */
274struct fcp_logo {
275 u32 command;
276 u32 nport_did;
277 wwn_t nport_wwpn;
278} __attribute__((packed));
279
8a36e453
MS
280/*
281 * DBF stuff
282 */
283#define ZFCP_DBF_TAG_SIZE 4
284
285struct zfcp_dbf_dump {
286 u8 tag[ZFCP_DBF_TAG_SIZE];
287 u32 total_size; /* size of total dump data */
288 u32 offset; /* how much data has being already dumped */
289 u32 size; /* how much data comes with this record */
290 u8 data[]; /* dump data */
291} __attribute__ ((packed));
292
293/* FIXME: to be inflated when reworking the erp dbf */
294struct zfcp_erp_dbf_record {
295 u8 dummy[16];
296} __attribute__ ((packed));
297
298struct zfcp_hba_dbf_record_response {
299 u32 fsf_command;
300 u64 fsf_reqid;
301 u32 fsf_seqno;
302 u64 fsf_issued;
303 u32 fsf_prot_status;
304 u32 fsf_status;
305 u8 fsf_prot_status_qual[FSF_PROT_STATUS_QUAL_SIZE];
306 u8 fsf_status_qual[FSF_STATUS_QUALIFIER_SIZE];
307 u32 fsf_req_status;
308 u8 sbal_first;
309 u8 sbal_curr;
310 u8 sbal_last;
311 u8 pool;
312 u64 erp_action;
313 union {
314 struct {
315 u64 scsi_cmnd;
316 u64 scsi_serial;
317 } send_fcp;
318 struct {
319 u64 wwpn;
320 u32 d_id;
321 u32 port_handle;
322 } port;
323 struct {
324 u64 wwpn;
325 u64 fcp_lun;
326 u32 port_handle;
327 u32 lun_handle;
328 } unit;
329 struct {
330 u32 d_id;
331 u8 ls_code;
332 } send_els;
333 } data;
334} __attribute__ ((packed));
335
336struct zfcp_hba_dbf_record_status {
337 u8 failed;
338 u32 status_type;
339 u32 status_subtype;
340 struct fsf_queue_designator
341 queue_designator;
342 u32 payload_size;
343#define ZFCP_DBF_UNSOL_PAYLOAD 80
344#define ZFCP_DBF_UNSOL_PAYLOAD_SENSE_DATA_AVAIL 32
345#define ZFCP_DBF_UNSOL_PAYLOAD_BIT_ERROR_THRESHOLD 56
346#define ZFCP_DBF_UNSOL_PAYLOAD_FEATURE_UPDATE_ALERT 2 * sizeof(u32)
347 u8 payload[ZFCP_DBF_UNSOL_PAYLOAD];
348} __attribute__ ((packed));
349
350struct zfcp_hba_dbf_record_qdio {
351 u32 status;
352 u32 qdio_error;
353 u32 siga_error;
354 u8 sbal_index;
355 u8 sbal_count;
356} __attribute__ ((packed));
357
358struct zfcp_hba_dbf_record {
359 u8 tag[ZFCP_DBF_TAG_SIZE];
360 u8 tag2[ZFCP_DBF_TAG_SIZE];
361 union {
362 struct zfcp_hba_dbf_record_response response;
363 struct zfcp_hba_dbf_record_status status;
364 struct zfcp_hba_dbf_record_qdio qdio;
365 } type;
366} __attribute__ ((packed));
367
368struct zfcp_san_dbf_record_ct {
369 union {
370 struct {
371 u16 cmd_req_code;
372 u8 revision;
373 u8 gs_type;
374 u8 gs_subtype;
375 u8 options;
376 u16 max_res_size;
377 } request;
378 struct {
379 u16 cmd_rsp_code;
380 u8 revision;
381 u8 reason_code;
382 u8 reason_code_expl;
383 u8 vendor_unique;
384 } response;
385 } type;
386 u32 payload_size;
387#define ZFCP_DBF_CT_PAYLOAD 24
388 u8 payload[ZFCP_DBF_CT_PAYLOAD];
389} __attribute__ ((packed));
390
391struct zfcp_san_dbf_record_els {
392 u8 ls_code;
393 u32 payload_size;
394#define ZFCP_DBF_ELS_PAYLOAD 32
395#define ZFCP_DBF_ELS_MAX_PAYLOAD 1024
396 u8 payload[ZFCP_DBF_ELS_PAYLOAD];
397} __attribute__ ((packed));
398
399struct zfcp_san_dbf_record {
400 u8 tag[ZFCP_DBF_TAG_SIZE];
401 u64 fsf_reqid;
402 u32 fsf_seqno;
403 u32 s_id;
404 u32 d_id;
405 union {
406 struct zfcp_san_dbf_record_ct ct;
407 struct zfcp_san_dbf_record_els els;
408 } type;
409} __attribute__ ((packed));
410
411struct zfcp_scsi_dbf_record {
412 u8 tag[ZFCP_DBF_TAG_SIZE];
413 u8 tag2[ZFCP_DBF_TAG_SIZE];
414 u32 scsi_id;
415 u32 scsi_lun;
416 u32 scsi_result;
417 u64 scsi_cmnd;
418 u64 scsi_serial;
419#define ZFCP_DBF_SCSI_OPCODE 16
420 u8 scsi_opcode[ZFCP_DBF_SCSI_OPCODE];
421 u8 scsi_retries;
422 u8 scsi_allowed;
423 u64 fsf_reqid;
424 u32 fsf_seqno;
425 u64 fsf_issued;
426 union {
ed829ad6 427 u64 old_fsf_reqid;
8a36e453
MS
428 struct {
429 u8 rsp_validity;
430 u8 rsp_scsi_status;
431 u32 rsp_resid;
432 u8 rsp_code;
433#define ZFCP_DBF_SCSI_FCP_SNS_INFO 16
434#define ZFCP_DBF_SCSI_MAX_FCP_SNS_INFO 256
435 u32 sns_info_len;
436 u8 sns_info[ZFCP_DBF_SCSI_FCP_SNS_INFO];
437 } fcp;
438 } type;
439} __attribute__ ((packed));
440
1da177e4
LT
441/*
442 * FC-FS stuff
443 */
444#define R_A_TOV 10 /* seconds */
445#define ZFCP_ELS_TIMEOUT (2 * R_A_TOV)
446
447#define ZFCP_LS_RLS 0x0f
448#define ZFCP_LS_ADISC 0x52
449#define ZFCP_LS_RPS 0x56
450#define ZFCP_LS_RSCN 0x61
451#define ZFCP_LS_RNID 0x78
452
453struct zfcp_ls_rjt_par {
454 u8 action;
455 u8 reason_code;
456 u8 reason_expl;
457 u8 vendor_unique;
458} __attribute__ ((packed));
459
460struct zfcp_ls_adisc {
461 u8 code;
462 u8 field[3];
463 u32 hard_nport_id;
464 u64 wwpn;
465 u64 wwnn;
466 u32 nport_id;
467} __attribute__ ((packed));
468
469struct zfcp_ls_adisc_acc {
470 u8 code;
471 u8 field[3];
472 u32 hard_nport_id;
473 u64 wwpn;
474 u64 wwnn;
475 u32 nport_id;
476} __attribute__ ((packed));
477
478struct zfcp_rc_entry {
479 u8 code;
480 const char *description;
481};
482
483/*
484 * FC-GS-2 stuff
485 */
486#define ZFCP_CT_REVISION 0x01
487#define ZFCP_CT_DIRECTORY_SERVICE 0xFC
488#define ZFCP_CT_NAME_SERVER 0x02
489#define ZFCP_CT_SYNCHRONOUS 0x00
490#define ZFCP_CT_GID_PN 0x0121
491#define ZFCP_CT_MAX_SIZE 0x1020
492#define ZFCP_CT_ACCEPT 0x8002
493#define ZFCP_CT_REJECT 0x8001
494
495/*
496 * FC-GS-4 stuff
497 */
498#define ZFCP_CT_TIMEOUT (3 * R_A_TOV)
499
1da177e4
LT
500/******************** LOGGING MACROS AND DEFINES *****************************/
501
502/*
503 * Logging may be applied on certain kinds of driver operations
504 * independently. Additionally, different log-levels are supported for
505 * each of these areas.
506 */
507
508#define ZFCP_NAME "zfcp"
509
510/* read-only LUN sharing switch initial value */
511#define ZFCP_RO_LUN_SHARING_DEFAULTS 0
512
513/* independent log areas */
514#define ZFCP_LOG_AREA_OTHER 0
515#define ZFCP_LOG_AREA_SCSI 1
516#define ZFCP_LOG_AREA_FSF 2
517#define ZFCP_LOG_AREA_CONFIG 3
518#define ZFCP_LOG_AREA_CIO 4
519#define ZFCP_LOG_AREA_QDIO 5
520#define ZFCP_LOG_AREA_ERP 6
521#define ZFCP_LOG_AREA_FC 7
522
523/* log level values*/
524#define ZFCP_LOG_LEVEL_NORMAL 0
525#define ZFCP_LOG_LEVEL_INFO 1
526#define ZFCP_LOG_LEVEL_DEBUG 2
527#define ZFCP_LOG_LEVEL_TRACE 3
528
529/*
530 * this allows removal of logging code by the preprocessor
531 * (the most detailed log level still to be compiled in is specified,
532 * higher log levels are removed)
533 */
534#define ZFCP_LOG_LEVEL_LIMIT ZFCP_LOG_LEVEL_TRACE
535
536/* get "loglevel" nibble assignment */
537#define ZFCP_GET_LOG_VALUE(zfcp_lognibble) \
538 ((atomic_read(&zfcp_data.loglevel) >> (zfcp_lognibble<<2)) & 0xF)
539
540/* set "loglevel" nibble */
541#define ZFCP_SET_LOG_NIBBLE(value, zfcp_lognibble) \
542 (value << (zfcp_lognibble << 2))
543
544/* all log-level defaults are combined to generate initial log-level */
545#define ZFCP_LOG_LEVEL_DEFAULTS \
546 (ZFCP_SET_LOG_NIBBLE(ZFCP_LOG_LEVEL_NORMAL, ZFCP_LOG_AREA_OTHER) | \
547 ZFCP_SET_LOG_NIBBLE(ZFCP_LOG_LEVEL_NORMAL, ZFCP_LOG_AREA_SCSI) | \
548 ZFCP_SET_LOG_NIBBLE(ZFCP_LOG_LEVEL_NORMAL, ZFCP_LOG_AREA_FSF) | \
549 ZFCP_SET_LOG_NIBBLE(ZFCP_LOG_LEVEL_NORMAL, ZFCP_LOG_AREA_CONFIG) | \
550 ZFCP_SET_LOG_NIBBLE(ZFCP_LOG_LEVEL_NORMAL, ZFCP_LOG_AREA_CIO) | \
551 ZFCP_SET_LOG_NIBBLE(ZFCP_LOG_LEVEL_NORMAL, ZFCP_LOG_AREA_QDIO) | \
552 ZFCP_SET_LOG_NIBBLE(ZFCP_LOG_LEVEL_NORMAL, ZFCP_LOG_AREA_ERP) | \
553 ZFCP_SET_LOG_NIBBLE(ZFCP_LOG_LEVEL_NORMAL, ZFCP_LOG_AREA_FC))
554
555/* check whether we have the right level for logging */
556#define ZFCP_LOG_CHECK(level) \
557 ((ZFCP_GET_LOG_VALUE(ZFCP_LOG_AREA)) >= level)
558
559/* logging routine for zfcp */
560#define _ZFCP_LOG(fmt, args...) \
561 printk(KERN_ERR ZFCP_NAME": %s(%d): " fmt, __FUNCTION__, \
562 __LINE__ , ##args)
563
564#define ZFCP_LOG(level, fmt, args...) \
565do { \
566 if (ZFCP_LOG_CHECK(level)) \
567 _ZFCP_LOG(fmt, ##args); \
568} while (0)
569
570#if ZFCP_LOG_LEVEL_LIMIT < ZFCP_LOG_LEVEL_NORMAL
571# define ZFCP_LOG_NORMAL(fmt, args...)
572#else
573# define ZFCP_LOG_NORMAL(fmt, args...) \
574do { \
575 if (ZFCP_LOG_CHECK(ZFCP_LOG_LEVEL_NORMAL)) \
576 printk(KERN_ERR ZFCP_NAME": " fmt, ##args); \
577} while (0)
578#endif
579
580#if ZFCP_LOG_LEVEL_LIMIT < ZFCP_LOG_LEVEL_INFO
581# define ZFCP_LOG_INFO(fmt, args...)
582#else
583# define ZFCP_LOG_INFO(fmt, args...) \
584do { \
585 if (ZFCP_LOG_CHECK(ZFCP_LOG_LEVEL_INFO)) \
586 printk(KERN_ERR ZFCP_NAME": " fmt, ##args); \
587} while (0)
588#endif
589
590#if ZFCP_LOG_LEVEL_LIMIT < ZFCP_LOG_LEVEL_DEBUG
591# define ZFCP_LOG_DEBUG(fmt, args...)
592#else
593# define ZFCP_LOG_DEBUG(fmt, args...) \
594 ZFCP_LOG(ZFCP_LOG_LEVEL_DEBUG, fmt , ##args)
595#endif
596
597#if ZFCP_LOG_LEVEL_LIMIT < ZFCP_LOG_LEVEL_TRACE
598# define ZFCP_LOG_TRACE(fmt, args...)
599#else
600# define ZFCP_LOG_TRACE(fmt, args...) \
601 ZFCP_LOG(ZFCP_LOG_LEVEL_TRACE, fmt , ##args)
602#endif
603
1da177e4
LT
604/*************** ADAPTER/PORT/UNIT AND FSF_REQ STATUS FLAGS ******************/
605
606/*
607 * Note, the leftmost status byte is common among adapter, port
608 * and unit
609 */
610#define ZFCP_COMMON_FLAGS 0xfff00000
611#define ZFCP_SPECIFIC_FLAGS 0x000fffff
612
613/* common status bits */
614#define ZFCP_STATUS_COMMON_REMOVE 0x80000000
615#define ZFCP_STATUS_COMMON_RUNNING 0x40000000
616#define ZFCP_STATUS_COMMON_ERP_FAILED 0x20000000
617#define ZFCP_STATUS_COMMON_UNBLOCKED 0x10000000
618#define ZFCP_STATUS_COMMON_OPENING 0x08000000
619#define ZFCP_STATUS_COMMON_OPEN 0x04000000
620#define ZFCP_STATUS_COMMON_CLOSING 0x02000000
621#define ZFCP_STATUS_COMMON_ERP_INUSE 0x01000000
622#define ZFCP_STATUS_COMMON_ACCESS_DENIED 0x00800000
d736a27b 623#define ZFCP_STATUS_COMMON_ACCESS_BOXED 0x00400000
1da177e4
LT
624
625/* adapter status */
626#define ZFCP_STATUS_ADAPTER_QDIOUP 0x00000002
627#define ZFCP_STATUS_ADAPTER_REGISTERED 0x00000004
628#define ZFCP_STATUS_ADAPTER_XCONFIG_OK 0x00000008
629#define ZFCP_STATUS_ADAPTER_HOST_CON_INIT 0x00000010
630#define ZFCP_STATUS_ADAPTER_ERP_THREAD_UP 0x00000020
631#define ZFCP_STATUS_ADAPTER_ERP_THREAD_KILL 0x00000080
632#define ZFCP_STATUS_ADAPTER_ERP_PENDING 0x00000100
633#define ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED 0x00000200
aef4a983 634#define ZFCP_STATUS_ADAPTER_XPORT_OK 0x00000800
1da177e4
LT
635
636#define ZFCP_STATUS_ADAPTER_SCSI_UP \
637 (ZFCP_STATUS_COMMON_UNBLOCKED | \
638 ZFCP_STATUS_ADAPTER_REGISTERED)
639
640
641/* FC-PH/FC-GS well-known address identifiers for generic services */
642#define ZFCP_DID_MANAGEMENT_SERVICE 0xFFFFFA
643#define ZFCP_DID_TIME_SERVICE 0xFFFFFB
644#define ZFCP_DID_DIRECTORY_SERVICE 0xFFFFFC
645#define ZFCP_DID_ALIAS_SERVICE 0xFFFFF8
646#define ZFCP_DID_KEY_DISTRIBUTION_SERVICE 0xFFFFF7
647
648/* remote port status */
649#define ZFCP_STATUS_PORT_PHYS_OPEN 0x00000001
650#define ZFCP_STATUS_PORT_DID_DID 0x00000002
651#define ZFCP_STATUS_PORT_PHYS_CLOSING 0x00000004
652#define ZFCP_STATUS_PORT_NO_WWPN 0x00000008
653#define ZFCP_STATUS_PORT_NO_SCSI_ID 0x00000010
654#define ZFCP_STATUS_PORT_INVALID_WWPN 0x00000020
655#define ZFCP_STATUS_PORT_ACCESS_DENIED 0x00000040
656
657/* for ports with well known addresses */
658#define ZFCP_STATUS_PORT_WKA \
659 (ZFCP_STATUS_PORT_NO_WWPN | \
660 ZFCP_STATUS_PORT_NO_SCSI_ID)
661
662/* logical unit status */
663#define ZFCP_STATUS_UNIT_NOTSUPPUNITRESET 0x00000001
664#define ZFCP_STATUS_UNIT_TEMPORARY 0x00000002
665#define ZFCP_STATUS_UNIT_SHARED 0x00000004
666#define ZFCP_STATUS_UNIT_READONLY 0x00000008
ad58f7db 667#define ZFCP_STATUS_UNIT_REGISTERED 0x00000010
1da177e4
LT
668
669/* FSF request status (this does not have a common part) */
670#define ZFCP_STATUS_FSFREQ_NOT_INIT 0x00000000
671#define ZFCP_STATUS_FSFREQ_POOL 0x00000001
672#define ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT 0x00000002
673#define ZFCP_STATUS_FSFREQ_COMPLETED 0x00000004
674#define ZFCP_STATUS_FSFREQ_ERROR 0x00000008
675#define ZFCP_STATUS_FSFREQ_CLEANUP 0x00000010
676#define ZFCP_STATUS_FSFREQ_ABORTING 0x00000020
677#define ZFCP_STATUS_FSFREQ_ABORTSUCCEEDED 0x00000040
678#define ZFCP_STATUS_FSFREQ_ABORTNOTNEEDED 0x00000080
679#define ZFCP_STATUS_FSFREQ_ABORTED 0x00000100
680#define ZFCP_STATUS_FSFREQ_TMFUNCFAILED 0x00000200
681#define ZFCP_STATUS_FSFREQ_TMFUNCNOTSUPP 0x00000400
682#define ZFCP_STATUS_FSFREQ_RETRY 0x00000800
683#define ZFCP_STATUS_FSFREQ_DISMISSED 0x00001000
684
685/*********************** ERROR RECOVERY PROCEDURE DEFINES ********************/
686
687#define ZFCP_MAX_ERPS 3
688
689#define ZFCP_ERP_FSFREQ_TIMEOUT (30 * HZ)
690#define ZFCP_ERP_MEMWAIT_TIMEOUT HZ
691
692#define ZFCP_STATUS_ERP_TIMEDOUT 0x10000000
693#define ZFCP_STATUS_ERP_CLOSE_ONLY 0x01000000
694#define ZFCP_STATUS_ERP_DISMISSING 0x00100000
695#define ZFCP_STATUS_ERP_DISMISSED 0x00200000
696#define ZFCP_STATUS_ERP_LOWMEM 0x00400000
697
698#define ZFCP_ERP_STEP_UNINITIALIZED 0x00000000
699#define ZFCP_ERP_STEP_FSF_XCONFIG 0x00000001
700#define ZFCP_ERP_STEP_PHYS_PORT_CLOSING 0x00000010
701#define ZFCP_ERP_STEP_PORT_CLOSING 0x00000100
702#define ZFCP_ERP_STEP_NAMESERVER_OPEN 0x00000200
703#define ZFCP_ERP_STEP_NAMESERVER_LOOKUP 0x00000400
704#define ZFCP_ERP_STEP_PORT_OPENING 0x00000800
705#define ZFCP_ERP_STEP_UNIT_CLOSING 0x00001000
706#define ZFCP_ERP_STEP_UNIT_OPENING 0x00002000
707
708/* Ordered by escalation level (necessary for proper erp-code operation) */
709#define ZFCP_ERP_ACTION_REOPEN_ADAPTER 0x4
710#define ZFCP_ERP_ACTION_REOPEN_PORT_FORCED 0x3
711#define ZFCP_ERP_ACTION_REOPEN_PORT 0x2
712#define ZFCP_ERP_ACTION_REOPEN_UNIT 0x1
713
714#define ZFCP_ERP_ACTION_RUNNING 0x1
715#define ZFCP_ERP_ACTION_READY 0x2
716
717#define ZFCP_ERP_SUCCEEDED 0x0
718#define ZFCP_ERP_FAILED 0x1
719#define ZFCP_ERP_CONTINUES 0x2
720#define ZFCP_ERP_EXIT 0x3
721#define ZFCP_ERP_DISMISSED 0x4
722#define ZFCP_ERP_NOMEM 0x5
723
724
725/******************** CFDC SPECIFIC STUFF *****************************/
726
727/* Firewall data channel sense data record */
728struct zfcp_cfdc_sense_data {
729 u32 signature; /* Request signature */
730 u32 devno; /* FCP adapter device number */
731 u32 command; /* Command code */
732 u32 fsf_status; /* FSF request status and status qualifier */
733 u8 fsf_status_qual[FSF_STATUS_QUALIFIER_SIZE];
734 u8 payloads[256]; /* Access conflicts list */
735 u8 control_file[0]; /* Access control table */
736};
737
738#define ZFCP_CFDC_SIGNATURE 0xCFDCACDF
739
740#define ZFCP_CFDC_CMND_DOWNLOAD_NORMAL 0x00010001
741#define ZFCP_CFDC_CMND_DOWNLOAD_FORCE 0x00010101
742#define ZFCP_CFDC_CMND_FULL_ACCESS 0x00000201
743#define ZFCP_CFDC_CMND_RESTRICTED_ACCESS 0x00000401
744#define ZFCP_CFDC_CMND_UPLOAD 0x00010002
745
746#define ZFCP_CFDC_DOWNLOAD 0x00000001
747#define ZFCP_CFDC_UPLOAD 0x00000002
748#define ZFCP_CFDC_WITH_CONTROL_FILE 0x00010000
749
750#define ZFCP_CFDC_DEV_NAME "zfcp_cfdc"
751#define ZFCP_CFDC_DEV_MAJOR MISC_MAJOR
752#define ZFCP_CFDC_DEV_MINOR MISC_DYNAMIC_MINOR
753
754#define ZFCP_CFDC_MAX_CONTROL_FILE_SIZE 127 * 1024
755
756/************************* STRUCTURE DEFINITIONS *****************************/
757
758struct zfcp_fsf_req;
759
760/* holds various memory pools of an adapter */
761struct zfcp_adapter_mempool {
762 mempool_t *fsf_req_erp;
763 mempool_t *fsf_req_scsi;
764 mempool_t *fsf_req_abort;
765 mempool_t *fsf_req_status_read;
766 mempool_t *data_status_read;
767 mempool_t *data_gid_pn;
768};
769
1da177e4
LT
770/*
771 * header for CT_IU
772 */
773struct ct_hdr {
774 u8 revision; // 0x01
775 u8 in_id[3]; // 0x00
776 u8 gs_type; // 0xFC Directory Service
777 u8 gs_subtype; // 0x02 Name Server
778 u8 options; // 0x00 single bidirectional exchange
779 u8 reserved0;
780 u16 cmd_rsp_code; // 0x0121 GID_PN, or 0x0100 GA_NXT
781 u16 max_res_size; // <= (4096 - 16) / 4
782 u8 reserved1;
783 u8 reason_code;
784 u8 reason_code_expl;
785 u8 vendor_unique;
786} __attribute__ ((packed));
787
788/* nameserver request CT_IU -- for requests where
789 * a port name is required */
790struct ct_iu_gid_pn_req {
791 struct ct_hdr header;
792 wwn_t wwpn;
793} __attribute__ ((packed));
794
795/* FS_ACC IU and data unit for GID_PN nameserver request */
796struct ct_iu_gid_pn_resp {
797 struct ct_hdr header;
13e1e1f0 798 u32 d_id;
1da177e4
LT
799} __attribute__ ((packed));
800
801typedef void (*zfcp_send_ct_handler_t)(unsigned long);
802
803/**
804 * struct zfcp_send_ct - used to pass parameters to function zfcp_fsf_send_ct
805 * @port: port where the request is sent to
806 * @req: scatter-gather list for request
807 * @resp: scatter-gather list for response
808 * @req_count: number of elements in request scatter-gather list
809 * @resp_count: number of elements in response scatter-gather list
810 * @handler: handler function (called for response to the request)
811 * @handler_data: data passed to handler function
812 * @pool: pointer to memory pool for ct request structure
813 * @timeout: FSF timeout for this request
814 * @timer: timer (e.g. for request initiated by erp)
815 * @completion: completion for synchronization purposes
816 * @status: used to pass error status to calling function
817 */
818struct zfcp_send_ct {
819 struct zfcp_port *port;
820 struct scatterlist *req;
821 struct scatterlist *resp;
822 unsigned int req_count;
823 unsigned int resp_count;
824 zfcp_send_ct_handler_t handler;
825 unsigned long handler_data;
826 mempool_t *pool;
827 int timeout;
828 struct timer_list *timer;
829 struct completion *completion;
830 int status;
831};
832
833/* used for name server requests in error recovery */
834struct zfcp_gid_pn_data {
835 struct zfcp_send_ct ct;
836 struct scatterlist req;
837 struct scatterlist resp;
838 struct ct_iu_gid_pn_req ct_iu_req;
839 struct ct_iu_gid_pn_resp ct_iu_resp;
840 struct zfcp_port *port;
841};
842
843typedef void (*zfcp_send_els_handler_t)(unsigned long);
844
845/**
846 * struct zfcp_send_els - used to pass parameters to function zfcp_fsf_send_els
847 * @adapter: adapter where request is sent from
64b29a13 848 * @port: port where ELS is destinated (port reference count has to be increased)
1da177e4
LT
849 * @d_id: destiniation id of port where request is sent to
850 * @req: scatter-gather list for request
851 * @resp: scatter-gather list for response
852 * @req_count: number of elements in request scatter-gather list
853 * @resp_count: number of elements in response scatter-gather list
854 * @handler: handler function (called for response to the request)
855 * @handler_data: data passed to handler function
856 * @timer: timer (e.g. for request initiated by erp)
857 * @completion: completion for synchronization purposes
858 * @ls_code: hex code of ELS command
859 * @status: used to pass error status to calling function
860 */
861struct zfcp_send_els {
862 struct zfcp_adapter *adapter;
64b29a13 863 struct zfcp_port *port;
13e1e1f0 864 u32 d_id;
1da177e4
LT
865 struct scatterlist *req;
866 struct scatterlist *resp;
867 unsigned int req_count;
868 unsigned int resp_count;
869 zfcp_send_els_handler_t handler;
870 unsigned long handler_data;
871 struct timer_list *timer;
872 struct completion *completion;
873 int ls_code;
874 int status;
875};
876
1da177e4
LT
877struct zfcp_qdio_queue {
878 struct qdio_buffer *buffer[QDIO_MAX_BUFFERS_PER_Q]; /* SBALs */
879 u8 free_index; /* index of next free bfr
880 in queue (free_count>0) */
881 atomic_t free_count; /* number of free buffers
882 in queue */
883 rwlock_t queue_lock; /* lock for operations on queue */
884 int distance_from_int; /* SBALs used since PCI indication
885 was last set */
886};
887
888struct zfcp_erp_action {
889 struct list_head list;
890 int action; /* requested action code */
891 struct zfcp_adapter *adapter; /* device which should be recovered */
892 struct zfcp_port *port;
893 struct zfcp_unit *unit;
894 volatile u32 status; /* recovery status */
895 u32 step; /* active step of this erp action */
896 struct zfcp_fsf_req *fsf_req; /* fsf request currently pending
897 for this action */
898 struct timer_list timer;
899};
900
901
902struct zfcp_adapter {
903 struct list_head list; /* list of adapters */
904 atomic_t refcount; /* reference count */
905 wait_queue_head_t remove_wq; /* can be used to wait for
906 refcount drop to zero */
6f71d9bc
JB
907 wwn_t peer_wwnn; /* P2P peer WWNN */
908 wwn_t peer_wwpn; /* P2P peer WWPN */
13e1e1f0 909 u32 peer_d_id; /* P2P peer D_ID */
1da177e4
LT
910 struct ccw_device *ccw_device; /* S/390 ccw device */
911 u8 fc_service_class;
1da177e4
LT
912 u32 hydra_version; /* Hydra version */
913 u32 fsf_lic_version;
aef4a983
MS
914 u32 adapter_features; /* FCP channel features */
915 u32 connection_features; /* host connection features */
1da177e4 916 u32 hardware_version; /* of FCP channel */
1da177e4
LT
917 struct Scsi_Host *scsi_host; /* Pointer to mid-layer */
918 unsigned short scsi_host_no; /* Assigned host number */
919 unsigned char name[9];
920 struct list_head port_list_head; /* remote port list */
921 struct list_head port_remove_lh; /* head of ports to be
922 removed */
923 u32 ports; /* number of remote ports */
924 struct timer_list scsi_er_timer; /* SCSI err recovery watch */
925 struct list_head fsf_req_list_head; /* head of FSF req list */
1db2c9c0 926 spinlock_t fsf_req_list_lock; /* lock for ops on list of
1da177e4
LT
927 FSF requests */
928 atomic_t fsf_reqs_active; /* # active FSF reqs */
929 struct zfcp_qdio_queue request_queue; /* request queue */
930 u32 fsf_req_seq_no; /* FSF cmnd seq number */
931 wait_queue_head_t request_wq; /* can be used to wait for
932 more avaliable SBALs */
933 struct zfcp_qdio_queue response_queue; /* response queue */
934 rwlock_t abort_lock; /* Protects against SCSI
935 stack abort/command
936 completion races */
937 u16 status_read_failed; /* # failed status reads */
938 atomic_t status; /* status of this adapter */
939 struct list_head erp_ready_head; /* error recovery for this
940 adapter/devices */
941 struct list_head erp_running_head;
942 rwlock_t erp_lock;
943 struct semaphore erp_ready_sem;
944 wait_queue_head_t erp_thread_wqh;
945 wait_queue_head_t erp_done_wqh;
946 struct zfcp_erp_action erp_action; /* pending error recovery */
947 atomic_t erp_counter;
948 u32 erp_total_count; /* total nr of enqueued erp
949 actions */
950 u32 erp_low_mem_count; /* nr of erp actions waiting
951 for memory */
952 struct zfcp_port *nameserver_port; /* adapter's nameserver */
8a36e453
MS
953 debug_info_t *erp_dbf;
954 debug_info_t *hba_dbf;
955 debug_info_t *san_dbf; /* debug feature areas */
956 debug_info_t *scsi_dbf;
957 spinlock_t erp_dbf_lock;
958 spinlock_t hba_dbf_lock;
959 spinlock_t san_dbf_lock;
960 spinlock_t scsi_dbf_lock;
961 struct zfcp_erp_dbf_record erp_dbf_buf;
962 struct zfcp_hba_dbf_record hba_dbf_buf;
963 struct zfcp_san_dbf_record san_dbf_buf;
964 struct zfcp_scsi_dbf_record scsi_dbf_buf;
1da177e4
LT
965 struct zfcp_adapter_mempool pool; /* Adapter memory pools */
966 struct qdio_initialize qdio_init_data; /* for qdio_establish */
967 struct device generic_services; /* directory for WKA ports */
f6cd94b1
AH
968 struct fc_host_statistics *fc_stats;
969 struct fsf_qtcb_bottom_port *stats_reset_data;
970 unsigned long stats_reset;
1da177e4
LT
971};
972
973/*
974 * the struct device sysfs_device must be at the beginning of this structure.
975 * pointer to struct device is used to free port structure in release function
976 * of the device. don't change!
977 */
978struct zfcp_port {
979 struct device sysfs_device; /* sysfs device */
3859f6a2 980 struct fc_rport *rport; /* rport of fc transport class */
1da177e4
LT
981 struct list_head list; /* list of remote ports */
982 atomic_t refcount; /* reference count */
983 wait_queue_head_t remove_wq; /* can be used to wait for
984 refcount drop to zero */
985 struct zfcp_adapter *adapter; /* adapter used to access port */
986 struct list_head unit_list_head; /* head of logical unit list */
987 struct list_head unit_remove_lh; /* head of luns to be removed
988 list */
989 u32 units; /* # of logical units in list */
990 atomic_t status; /* status of this remote port */
1da177e4
LT
991 wwn_t wwnn; /* WWNN if known */
992 wwn_t wwpn; /* WWPN */
13e1e1f0 993 u32 d_id; /* D_ID */
1da177e4
LT
994 u32 handle; /* handle assigned by FSF */
995 struct zfcp_erp_action erp_action; /* pending error recovery */
996 atomic_t erp_counter;
997};
998
999/* the struct device sysfs_device must be at the beginning of this structure.
1000 * pointer to struct device is used to free unit structure in release function
1001 * of the device. don't change!
1002 */
1003struct zfcp_unit {
1004 struct device sysfs_device; /* sysfs device */
1005 struct list_head list; /* list of logical units */
1006 atomic_t refcount; /* reference count */
1007 wait_queue_head_t remove_wq; /* can be used to wait for
1008 refcount drop to zero */
1009 struct zfcp_port *port; /* remote port of unit */
1010 atomic_t status; /* status of this logical unit */
1011 scsi_lun_t scsi_lun; /* own SCSI LUN */
1012 fcp_lun_t fcp_lun; /* own FCP_LUN */
1013 u32 handle; /* handle assigned by FSF */
1014 struct scsi_device *device; /* scsi device struct pointer */
1015 struct zfcp_erp_action erp_action; /* pending error recovery */
1016 atomic_t erp_counter;
1017};
1018
1019/* FSF request */
1020struct zfcp_fsf_req {
1021 struct list_head list; /* list of FSF requests */
1022 struct zfcp_adapter *adapter; /* adapter request belongs to */
1023 u8 sbal_number; /* nr of SBALs free for use */
1024 u8 sbal_first; /* first SBAL for this request */
1025 u8 sbal_last; /* last possible SBAL for
1026 this reuest */
1027 u8 sbal_curr; /* current SBAL during creation
1028 of request */
1029 u8 sbale_curr; /* current SBALE during creation
1030 of request */
1031 wait_queue_head_t completion_wq; /* can be used by a routine
1032 to wait for completion */
1033 volatile u32 status; /* status of this request */
1034 u32 fsf_command; /* FSF Command copy */
1035 struct fsf_qtcb *qtcb; /* address of associated QTCB */
1036 u32 seq_no; /* Sequence number of request */
059c97d0 1037 unsigned long data; /* private data of request */
1da177e4
LT
1038 struct zfcp_erp_action *erp_action; /* used if this request is
1039 issued on behalf of erp */
1040 mempool_t *pool; /* used if request was alloacted
1041 from emergency pool */
8a36e453 1042 unsigned long long issued; /* request sent time (STCK) */
059c97d0 1043 struct zfcp_unit *unit;
1da177e4
LT
1044};
1045
1046typedef void zfcp_fsf_req_handler_t(struct zfcp_fsf_req*);
1047
1048/* driver data */
1049struct zfcp_data {
1050 struct scsi_host_template scsi_host_template;
1051 atomic_t status; /* Module status flags */
1052 struct list_head adapter_list_head; /* head of adapter list */
1053 struct list_head adapter_remove_lh; /* head of adapters to be
1054 removed */
1055 rwlock_t status_read_lock; /* for status read thread */
1056 struct list_head status_read_receive_head;
1057 struct list_head status_read_send_head;
1058 struct semaphore status_read_sema;
1059 wait_queue_head_t status_read_thread_wqh;
1060 u32 adapters; /* # of adapters in list */
1061 rwlock_t config_lock; /* serialises changes
1062 to adapter/port/unit
1063 lists */
1064 struct semaphore config_sema; /* serialises configuration
1065 changes */
1066 atomic_t loglevel; /* current loglevel */
1067 char init_busid[BUS_ID_SIZE];
1068 wwn_t init_wwpn;
1069 fcp_lun_t init_fcp_lun;
1070 char *driver_version;
1071};
1072
1073/**
1074 * struct zfcp_sg_list - struct describing a scatter-gather list
1075 * @sg: pointer to array of (struct scatterlist)
1076 * @count: number of elements in scatter-gather list
1077 */
1078struct zfcp_sg_list {
1079 struct scatterlist *sg;
1080 unsigned int count;
1081};
1082
1083/* number of elements for various memory pools */
1084#define ZFCP_POOL_FSF_REQ_ERP_NR 1
1085#define ZFCP_POOL_FSF_REQ_SCSI_NR 1
1086#define ZFCP_POOL_FSF_REQ_ABORT_NR 1
1087#define ZFCP_POOL_STATUS_READ_NR ZFCP_STATUS_READS_RECOM
1088#define ZFCP_POOL_DATA_GID_PN_NR 1
1089
1090/* struct used by memory pools for fsf_requests */
1091struct zfcp_fsf_req_pool_element {
1092 struct zfcp_fsf_req fsf_req;
1093 struct fsf_qtcb qtcb;
1094};
1095
1096/********************** ZFCP SPECIFIC DEFINES ********************************/
1097
1098#define ZFCP_FSFREQ_CLEANUP_TIMEOUT HZ/10
1099
1100#define ZFCP_KNOWN 0x00000001
1101#define ZFCP_REQ_AUTO_CLEANUP 0x00000002
1102#define ZFCP_WAIT_FOR_SBAL 0x00000004
1103#define ZFCP_REQ_NO_QTCB 0x00000008
1104
1105#define ZFCP_SET 0x00000100
1106#define ZFCP_CLEAR 0x00000200
1107
1108#define ZFCP_INTERRUPTIBLE 1
1109#define ZFCP_UNINTERRUPTIBLE 0
1110
1111#ifndef atomic_test_mask
1112#define atomic_test_mask(mask, target) \
1113 ((atomic_read(target) & mask) == mask)
1114#endif
1115
1116extern void _zfcp_hex_dump(char *, int);
1117#define ZFCP_HEX_DUMP(level, addr, count) \
1118 if (ZFCP_LOG_CHECK(level)) { \
1119 _zfcp_hex_dump(addr, count); \
1120 }
1121
1122#define zfcp_get_busid_by_adapter(adapter) (adapter->ccw_device->dev.bus_id)
1123#define zfcp_get_busid_by_port(port) (zfcp_get_busid_by_adapter(port->adapter))
1124#define zfcp_get_busid_by_unit(unit) (zfcp_get_busid_by_port(unit->port))
1125
1126/*
1127 * functions needed for reference/usage counting
1128 */
1129
1130static inline void
1131zfcp_unit_get(struct zfcp_unit *unit)
1132{
1133 atomic_inc(&unit->refcount);
1134}
1135
1136static inline void
1137zfcp_unit_put(struct zfcp_unit *unit)
1138{
1139 if (atomic_dec_return(&unit->refcount) == 0)
1140 wake_up(&unit->remove_wq);
1141}
1142
1143static inline void
1144zfcp_unit_wait(struct zfcp_unit *unit)
1145{
1146 wait_event(unit->remove_wq, atomic_read(&unit->refcount) == 0);
1147}
1148
1149static inline void
1150zfcp_port_get(struct zfcp_port *port)
1151{
1152 atomic_inc(&port->refcount);
1153}
1154
1155static inline void
1156zfcp_port_put(struct zfcp_port *port)
1157{
1158 if (atomic_dec_return(&port->refcount) == 0)
1159 wake_up(&port->remove_wq);
1160}
1161
1162static inline void
1163zfcp_port_wait(struct zfcp_port *port)
1164{
1165 wait_event(port->remove_wq, atomic_read(&port->refcount) == 0);
1166}
1167
1168static inline void
1169zfcp_adapter_get(struct zfcp_adapter *adapter)
1170{
1171 atomic_inc(&adapter->refcount);
1172}
1173
1174static inline void
1175zfcp_adapter_put(struct zfcp_adapter *adapter)
1176{
1177 if (atomic_dec_return(&adapter->refcount) == 0)
1178 wake_up(&adapter->remove_wq);
1179}
1180
1181static inline void
1182zfcp_adapter_wait(struct zfcp_adapter *adapter)
1183{
1184 wait_event(adapter->remove_wq, atomic_read(&adapter->refcount) == 0);
1185}
1186
1187#endif /* ZFCP_DEF_H */