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