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