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