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