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