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