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