Commit | Line | Data |
---|---|---|
41fa2ada | 1 | /* |
553448f6 | 2 | * zfcp device driver |
1da177e4 | 3 | * |
553448f6 | 4 | * Global definitions for the zfcp device driver. |
41fa2ada | 5 | * |
a2fa0aed | 6 | * Copyright IBM Corporation 2002, 2009 |
41fa2ada | 7 | */ |
1da177e4 | 8 | |
1da177e4 LT |
9 | #ifndef ZFCP_DEF_H |
10 | #define ZFCP_DEF_H | |
11 | ||
1da177e4 LT |
12 | /*************************** INCLUDES *****************************************/ |
13 | ||
14 | #include <linux/init.h> | |
15 | #include <linux/moduleparam.h> | |
1da177e4 LT |
16 | #include <linux/major.h> |
17 | #include <linux/blkdev.h> | |
18 | #include <linux/delay.h> | |
19 | #include <linux/timer.h> | |
dd52e0ea HC |
20 | #include <linux/slab.h> |
21 | #include <linux/mempool.h> | |
22 | #include <linux/syscalls.h> | |
f1346372 | 23 | #include <linux/scatterlist.h> |
dd52e0ea | 24 | #include <linux/ioctl.h> |
9d544f2b SS |
25 | #include <scsi/fc/fc_fs.h> |
26 | #include <scsi/fc/fc_gs.h> | |
1da177e4 LT |
27 | #include <scsi/scsi.h> |
28 | #include <scsi/scsi_tcq.h> | |
29 | #include <scsi/scsi_cmnd.h> | |
30 | #include <scsi/scsi_device.h> | |
31 | #include <scsi/scsi_host.h> | |
32 | #include <scsi/scsi_transport.h> | |
33 | #include <scsi/scsi_transport_fc.h> | |
9d544f2b | 34 | #include <scsi/scsi_bsg_fc.h> |
1da177e4 LT |
35 | #include <asm/ccwdev.h> |
36 | #include <asm/qdio.h> | |
37 | #include <asm/debug.h> | |
38 | #include <asm/ebcdic.h> | |
bd43a42b | 39 | #include <asm/sysinfo.h> |
dd52e0ea | 40 | #include "zfcp_fsf.h" |
1da177e4 | 41 | |
1da177e4 LT |
42 | /********************* GENERAL DEFINES *********************************/ |
43 | ||
06506d00 | 44 | #define REQUEST_LIST_SIZE 128 |
1da177e4 | 45 | |
06506d00 | 46 | /********************* SCSI SPECIFIC DEFINES *********************************/ |
f6c0e7a7 | 47 | #define ZFCP_SCSI_ER_TIMEOUT (10*HZ) |
1da177e4 LT |
48 | |
49 | /********************* CIO/QDIO SPECIFIC DEFINES *****************************/ | |
50 | ||
1da177e4 LT |
51 | /* DMQ bug workaround: don't use last SBALE */ |
52 | #define ZFCP_MAX_SBALES_PER_SBAL (QDIO_MAX_ELEMENTS_PER_BUFFER - 1) | |
53 | ||
54 | /* index of last SBALE (with respect to DMQ bug workaround) */ | |
55 | #define ZFCP_LAST_SBALE_PER_SBAL (ZFCP_MAX_SBALES_PER_SBAL - 1) | |
56 | ||
57 | /* max. number of (data buffer) SBALEs in largest SBAL chain */ | |
58 | #define ZFCP_MAX_SBALES_PER_REQ \ | |
c41f8cbd | 59 | (FSF_MAX_SBALS_PER_REQ * ZFCP_MAX_SBALES_PER_SBAL - 2) |
1da177e4 LT |
60 | /* request ID + QTCB in SBALE 0 + 1 of first SBAL in chain */ |
61 | ||
8d1a0060 SS |
62 | #define ZFCP_MAX_SECTORS (ZFCP_MAX_SBALES_PER_REQ * 8) |
63 | /* max. number of (data buffer) SBALEs in largest SBAL chain | |
64 | multiplied with number of sectors per 4k block */ | |
65 | ||
1da177e4 LT |
66 | /********************* FSF SPECIFIC DEFINES *********************************/ |
67 | ||
1da177e4 LT |
68 | /* ATTENTION: value must not be used by hardware */ |
69 | #define FSF_QTCB_UNSOLICITED_STATUS 0x6305 | |
22753fa5 | 70 | |
1da177e4 | 71 | /* timeout value for "default timer" for fsf requests */ |
2abbe866 | 72 | #define ZFCP_FSF_REQUEST_TIMEOUT (60*HZ) |
1da177e4 LT |
73 | |
74 | /*************** FIBRE CHANNEL PROTOCOL SPECIFIC DEFINES ********************/ | |
75 | ||
1da177e4 LT |
76 | /* timeout for name-server lookup (in seconds) */ |
77 | #define ZFCP_NS_GID_PN_TIMEOUT 10 | |
78 | ||
1da177e4 LT |
79 | /* task attribute values in FCP-2 FCP_CMND IU */ |
80 | #define SIMPLE_Q 0 | |
81 | #define HEAD_OF_Q 1 | |
82 | #define ORDERED_Q 2 | |
83 | #define ACA_Q 4 | |
84 | #define UNTAGGED 5 | |
85 | ||
86 | /* task management flags in FCP-2 FCP_CMND IU */ | |
87 | #define FCP_CLEAR_ACA 0x40 | |
88 | #define FCP_TARGET_RESET 0x20 | |
89 | #define FCP_LOGICAL_UNIT_RESET 0x10 | |
90 | #define FCP_CLEAR_TASK_SET 0x04 | |
91 | #define FCP_ABORT_TASK_SET 0x02 | |
92 | ||
93 | #define FCP_CDB_LENGTH 16 | |
94 | ||
95 | #define ZFCP_DID_MASK 0x00FFFFFF | |
96 | ||
97 | /* FCP(-2) FCP_CMND IU */ | |
98 | struct fcp_cmnd_iu { | |
7ba58c9c | 99 | u64 fcp_lun; /* FCP logical unit number */ |
1da177e4 LT |
100 | u8 crn; /* command reference number */ |
101 | u8 reserved0:5; /* reserved */ | |
102 | u8 task_attribute:3; /* task attribute */ | |
103 | u8 task_management_flags; /* task management flags */ | |
104 | u8 add_fcp_cdb_length:6; /* additional FCP_CDB length */ | |
105 | u8 rddata:1; /* read data */ | |
106 | u8 wddata:1; /* write data */ | |
107 | u8 fcp_cdb[FCP_CDB_LENGTH]; | |
108 | } __attribute__((packed)); | |
109 | ||
110 | /* FCP(-2) FCP_RSP IU */ | |
111 | struct fcp_rsp_iu { | |
112 | u8 reserved0[10]; | |
113 | union { | |
114 | struct { | |
115 | u8 reserved1:3; | |
116 | u8 fcp_conf_req:1; | |
117 | u8 fcp_resid_under:1; | |
118 | u8 fcp_resid_over:1; | |
119 | u8 fcp_sns_len_valid:1; | |
120 | u8 fcp_rsp_len_valid:1; | |
121 | } bits; | |
122 | u8 value; | |
123 | } validity; | |
124 | u8 scsi_status; | |
125 | u32 fcp_resid; | |
126 | u32 fcp_sns_len; | |
127 | u32 fcp_rsp_len; | |
128 | } __attribute__((packed)); | |
129 | ||
130 | ||
131 | #define RSP_CODE_GOOD 0 | |
132 | #define RSP_CODE_LENGTH_MISMATCH 1 | |
133 | #define RSP_CODE_FIELD_INVALID 2 | |
134 | #define RSP_CODE_RO_MISMATCH 3 | |
135 | #define RSP_CODE_TASKMAN_UNSUPP 4 | |
136 | #define RSP_CODE_TASKMAN_FAILED 5 | |
137 | ||
138 | /* see fc-fs */ | |
24073b47 CS |
139 | #define LS_RSCN 0x61 |
140 | #define LS_LOGO 0x05 | |
141 | #define LS_PLOGI 0x03 | |
1da177e4 LT |
142 | |
143 | struct fcp_rscn_head { | |
144 | u8 command; | |
145 | u8 page_length; /* always 0x04 */ | |
146 | u16 payload_len; | |
147 | } __attribute__((packed)); | |
148 | ||
149 | struct fcp_rscn_element { | |
150 | u8 reserved:2; | |
151 | u8 event_qual:4; | |
152 | u8 addr_format:2; | |
153 | u32 nport_did:24; | |
154 | } __attribute__((packed)); | |
155 | ||
1da177e4 LT |
156 | /* see fc-ph */ |
157 | struct fcp_logo { | |
158 | u32 command; | |
159 | u32 nport_did; | |
7ba58c9c | 160 | u64 nport_wwpn; |
1da177e4 LT |
161 | } __attribute__((packed)); |
162 | ||
163 | /* | |
164 | * FC-FS stuff | |
165 | */ | |
166 | #define R_A_TOV 10 /* seconds */ | |
1da177e4 LT |
167 | |
168 | #define ZFCP_LS_RLS 0x0f | |
169 | #define ZFCP_LS_ADISC 0x52 | |
170 | #define ZFCP_LS_RPS 0x56 | |
171 | #define ZFCP_LS_RSCN 0x61 | |
172 | #define ZFCP_LS_RNID 0x78 | |
173 | ||
1da177e4 LT |
174 | struct zfcp_ls_adisc { |
175 | u8 code; | |
176 | u8 field[3]; | |
177 | u32 hard_nport_id; | |
178 | u64 wwpn; | |
179 | u64 wwnn; | |
180 | u32 nport_id; | |
181 | } __attribute__ ((packed)); | |
182 | ||
1da177e4 LT |
183 | /* |
184 | * FC-GS-2 stuff | |
185 | */ | |
186 | #define ZFCP_CT_REVISION 0x01 | |
187 | #define ZFCP_CT_DIRECTORY_SERVICE 0xFC | |
188 | #define ZFCP_CT_NAME_SERVER 0x02 | |
189 | #define ZFCP_CT_SYNCHRONOUS 0x00 | |
cc8c2829 SS |
190 | #define ZFCP_CT_SCSI_FCP 0x08 |
191 | #define ZFCP_CT_UNABLE_TO_PERFORM_CMD 0x09 | |
1da177e4 | 192 | #define ZFCP_CT_GID_PN 0x0121 |
cc8c2829 | 193 | #define ZFCP_CT_GPN_FT 0x0172 |
1da177e4 LT |
194 | #define ZFCP_CT_ACCEPT 0x8002 |
195 | #define ZFCP_CT_REJECT 0x8001 | |
196 | ||
197 | /* | |
198 | * FC-GS-4 stuff | |
199 | */ | |
200 | #define ZFCP_CT_TIMEOUT (3 * R_A_TOV) | |
201 | ||
1da177e4 LT |
202 | /*************** ADAPTER/PORT/UNIT AND FSF_REQ STATUS FLAGS ******************/ |
203 | ||
41fa2ada SS |
204 | /* |
205 | * Note, the leftmost status byte is common among adapter, port | |
1da177e4 LT |
206 | * and unit |
207 | */ | |
208 | #define ZFCP_COMMON_FLAGS 0xfff00000 | |
1da177e4 LT |
209 | |
210 | /* common status bits */ | |
211 | #define ZFCP_STATUS_COMMON_REMOVE 0x80000000 | |
212 | #define ZFCP_STATUS_COMMON_RUNNING 0x40000000 | |
213 | #define ZFCP_STATUS_COMMON_ERP_FAILED 0x20000000 | |
214 | #define ZFCP_STATUS_COMMON_UNBLOCKED 0x10000000 | |
1da177e4 | 215 | #define ZFCP_STATUS_COMMON_OPEN 0x04000000 |
1da177e4 LT |
216 | #define ZFCP_STATUS_COMMON_ERP_INUSE 0x01000000 |
217 | #define ZFCP_STATUS_COMMON_ACCESS_DENIED 0x00800000 | |
d736a27b | 218 | #define ZFCP_STATUS_COMMON_ACCESS_BOXED 0x00400000 |
cc8c2829 | 219 | #define ZFCP_STATUS_COMMON_NOESC 0x00200000 |
1da177e4 LT |
220 | |
221 | /* adapter status */ | |
222 | #define ZFCP_STATUS_ADAPTER_QDIOUP 0x00000002 | |
1da177e4 LT |
223 | #define ZFCP_STATUS_ADAPTER_XCONFIG_OK 0x00000008 |
224 | #define ZFCP_STATUS_ADAPTER_HOST_CON_INIT 0x00000010 | |
225 | #define ZFCP_STATUS_ADAPTER_ERP_THREAD_UP 0x00000020 | |
226 | #define ZFCP_STATUS_ADAPTER_ERP_THREAD_KILL 0x00000080 | |
227 | #define ZFCP_STATUS_ADAPTER_ERP_PENDING 0x00000100 | |
228 | #define ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED 0x00000200 | |
229 | ||
1da177e4 | 230 | /* FC-PH/FC-GS well-known address identifiers for generic services */ |
5ab944f9 | 231 | #define ZFCP_DID_WKA 0xFFFFF0 |
1da177e4 LT |
232 | |
233 | /* remote port status */ | |
234 | #define ZFCP_STATUS_PORT_PHYS_OPEN 0x00000001 | |
14e242ea | 235 | #define ZFCP_STATUS_PORT_LINK_TEST 0x00000002 |
1da177e4 | 236 | |
5ab944f9 SS |
237 | /* well known address (WKA) port status*/ |
238 | enum zfcp_wka_status { | |
239 | ZFCP_WKA_PORT_OFFLINE, | |
240 | ZFCP_WKA_PORT_CLOSING, | |
241 | ZFCP_WKA_PORT_OPENING, | |
242 | ZFCP_WKA_PORT_ONLINE, | |
243 | }; | |
1da177e4 LT |
244 | |
245 | /* logical unit status */ | |
1da177e4 LT |
246 | #define ZFCP_STATUS_UNIT_SHARED 0x00000004 |
247 | #define ZFCP_STATUS_UNIT_READONLY 0x00000008 | |
248 | ||
249 | /* FSF request status (this does not have a common part) */ | |
1da177e4 | 250 | #define ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT 0x00000002 |
1da177e4 LT |
251 | #define ZFCP_STATUS_FSFREQ_ERROR 0x00000008 |
252 | #define ZFCP_STATUS_FSFREQ_CLEANUP 0x00000010 | |
1da177e4 LT |
253 | #define ZFCP_STATUS_FSFREQ_ABORTSUCCEEDED 0x00000040 |
254 | #define ZFCP_STATUS_FSFREQ_ABORTNOTNEEDED 0x00000080 | |
255 | #define ZFCP_STATUS_FSFREQ_ABORTED 0x00000100 | |
256 | #define ZFCP_STATUS_FSFREQ_TMFUNCFAILED 0x00000200 | |
257 | #define ZFCP_STATUS_FSFREQ_TMFUNCNOTSUPP 0x00000400 | |
258 | #define ZFCP_STATUS_FSFREQ_RETRY 0x00000800 | |
259 | #define ZFCP_STATUS_FSFREQ_DISMISSED 0x00001000 | |
260 | ||
1da177e4 LT |
261 | /************************* STRUCTURE DEFINITIONS *****************************/ |
262 | ||
263 | struct zfcp_fsf_req; | |
264 | ||
265 | /* holds various memory pools of an adapter */ | |
266 | struct zfcp_adapter_mempool { | |
a4623c46 SS |
267 | mempool_t *erp_req; |
268 | mempool_t *scsi_req; | |
269 | mempool_t *scsi_abort; | |
270 | mempool_t *status_read_req; | |
271 | mempool_t *status_read_data; | |
272 | mempool_t *gid_pn_data; | |
273 | mempool_t *qtcb_pool; | |
1da177e4 LT |
274 | }; |
275 | ||
1da177e4 LT |
276 | /* |
277 | * header for CT_IU | |
278 | */ | |
279 | struct ct_hdr { | |
280 | u8 revision; // 0x01 | |
281 | u8 in_id[3]; // 0x00 | |
282 | u8 gs_type; // 0xFC Directory Service | |
283 | u8 gs_subtype; // 0x02 Name Server | |
284 | u8 options; // 0x00 single bidirectional exchange | |
285 | u8 reserved0; | |
286 | u16 cmd_rsp_code; // 0x0121 GID_PN, or 0x0100 GA_NXT | |
287 | u16 max_res_size; // <= (4096 - 16) / 4 | |
288 | u8 reserved1; | |
289 | u8 reason_code; | |
290 | u8 reason_code_expl; | |
291 | u8 vendor_unique; | |
292 | } __attribute__ ((packed)); | |
293 | ||
294 | /* nameserver request CT_IU -- for requests where | |
295 | * a port name is required */ | |
296 | struct ct_iu_gid_pn_req { | |
297 | struct ct_hdr header; | |
7ba58c9c | 298 | u64 wwpn; |
1da177e4 LT |
299 | } __attribute__ ((packed)); |
300 | ||
301 | /* FS_ACC IU and data unit for GID_PN nameserver request */ | |
302 | struct ct_iu_gid_pn_resp { | |
303 | struct ct_hdr header; | |
13e1e1f0 | 304 | u32 d_id; |
1da177e4 LT |
305 | } __attribute__ ((packed)); |
306 | ||
a4623c46 SS |
307 | struct ct_iu_gpn_ft_req { |
308 | struct ct_hdr header; | |
309 | u8 flags; | |
310 | u8 domain_id_scope; | |
311 | u8 area_id_scope; | |
312 | u8 fc4_type; | |
313 | } __attribute__ ((packed)); | |
314 | ||
315 | ||
1da177e4 LT |
316 | /** |
317 | * struct zfcp_send_ct - used to pass parameters to function zfcp_fsf_send_ct | |
5ab944f9 | 318 | * @wka_port: port where the request is sent to |
1da177e4 LT |
319 | * @req: scatter-gather list for request |
320 | * @resp: scatter-gather list for response | |
1da177e4 LT |
321 | * @handler: handler function (called for response to the request) |
322 | * @handler_data: data passed to handler function | |
1da177e4 | 323 | * @timeout: FSF timeout for this request |
1da177e4 LT |
324 | * @completion: completion for synchronization purposes |
325 | * @status: used to pass error status to calling function | |
326 | */ | |
327 | struct zfcp_send_ct { | |
5ab944f9 | 328 | struct zfcp_wka_port *wka_port; |
1da177e4 LT |
329 | struct scatterlist *req; |
330 | struct scatterlist *resp; | |
7ba58c9c | 331 | void (*handler)(unsigned long); |
1da177e4 | 332 | unsigned long handler_data; |
1da177e4 | 333 | int timeout; |
1da177e4 LT |
334 | struct completion *completion; |
335 | int status; | |
336 | }; | |
337 | ||
338 | /* used for name server requests in error recovery */ | |
339 | struct zfcp_gid_pn_data { | |
340 | struct zfcp_send_ct ct; | |
341 | struct scatterlist req; | |
342 | struct scatterlist resp; | |
343 | struct ct_iu_gid_pn_req ct_iu_req; | |
344 | struct ct_iu_gid_pn_resp ct_iu_resp; | |
345 | struct zfcp_port *port; | |
346 | }; | |
347 | ||
1da177e4 LT |
348 | /** |
349 | * struct zfcp_send_els - used to pass parameters to function zfcp_fsf_send_els | |
350 | * @adapter: adapter where request is sent from | |
64b29a13 | 351 | * @port: port where ELS is destinated (port reference count has to be increased) |
1da177e4 LT |
352 | * @d_id: destiniation id of port where request is sent to |
353 | * @req: scatter-gather list for request | |
354 | * @resp: scatter-gather list for response | |
1da177e4 LT |
355 | * @handler: handler function (called for response to the request) |
356 | * @handler_data: data passed to handler function | |
1da177e4 LT |
357 | * @completion: completion for synchronization purposes |
358 | * @ls_code: hex code of ELS command | |
359 | * @status: used to pass error status to calling function | |
360 | */ | |
361 | struct zfcp_send_els { | |
362 | struct zfcp_adapter *adapter; | |
64b29a13 | 363 | struct zfcp_port *port; |
13e1e1f0 | 364 | u32 d_id; |
1da177e4 LT |
365 | struct scatterlist *req; |
366 | struct scatterlist *resp; | |
7ba58c9c | 367 | void (*handler)(unsigned long); |
1da177e4 | 368 | unsigned long handler_data; |
1da177e4 LT |
369 | struct completion *completion; |
370 | int ls_code; | |
371 | int status; | |
372 | }; | |
373 | ||
5ab944f9 SS |
374 | struct zfcp_wka_port { |
375 | struct zfcp_adapter *adapter; | |
376 | wait_queue_head_t completion_wq; | |
377 | enum zfcp_wka_status status; | |
378 | atomic_t refcount; | |
379 | u32 d_id; | |
380 | u32 handle; | |
381 | struct mutex mutex; | |
382 | struct delayed_work work; | |
383 | }; | |
384 | ||
9d544f2b SS |
385 | struct zfcp_wka_ports { |
386 | struct zfcp_wka_port ms; /* management service */ | |
387 | struct zfcp_wka_port ts; /* time service */ | |
388 | struct zfcp_wka_port ds; /* directory service */ | |
389 | struct zfcp_wka_port as; /* alias service */ | |
390 | struct zfcp_wka_port ks; /* key distribution service */ | |
391 | }; | |
392 | ||
1da177e4 | 393 | struct zfcp_qdio_queue { |
0406289e CS |
394 | struct qdio_buffer *sbal[QDIO_MAX_BUFFERS_PER_Q]; |
395 | u8 first; /* index of next free bfr in queue */ | |
396 | atomic_t count; /* number of free buffers in queue */ | |
1da177e4 LT |
397 | }; |
398 | ||
399 | struct zfcp_erp_action { | |
400 | struct list_head list; | |
401 | int action; /* requested action code */ | |
402 | struct zfcp_adapter *adapter; /* device which should be recovered */ | |
403 | struct zfcp_port *port; | |
404 | struct zfcp_unit *unit; | |
44cc76f2 | 405 | u32 status; /* recovery status */ |
1da177e4 LT |
406 | u32 step; /* active step of this erp action */ |
407 | struct zfcp_fsf_req *fsf_req; /* fsf request currently pending | |
408 | for this action */ | |
409 | struct timer_list timer; | |
410 | }; | |
411 | ||
c9615858 CS |
412 | struct fsf_latency_record { |
413 | u32 min; | |
414 | u32 max; | |
415 | u64 sum; | |
416 | }; | |
417 | ||
418 | struct latency_cont { | |
419 | struct fsf_latency_record channel; | |
420 | struct fsf_latency_record fabric; | |
421 | u64 counter; | |
422 | }; | |
423 | ||
424 | struct zfcp_latencies { | |
425 | struct latency_cont read; | |
426 | struct latency_cont write; | |
427 | struct latency_cont cmd; | |
428 | spinlock_t lock; | |
429 | }; | |
1da177e4 LT |
430 | |
431 | struct zfcp_adapter { | |
1da177e4 LT |
432 | atomic_t refcount; /* reference count */ |
433 | wait_queue_head_t remove_wq; /* can be used to wait for | |
434 | refcount drop to zero */ | |
7ba58c9c SS |
435 | u64 peer_wwnn; /* P2P peer WWNN */ |
436 | u64 peer_wwpn; /* P2P peer WWPN */ | |
13e1e1f0 | 437 | u32 peer_d_id; /* P2P peer D_ID */ |
1da177e4 | 438 | struct ccw_device *ccw_device; /* S/390 ccw device */ |
1da177e4 LT |
439 | u32 hydra_version; /* Hydra version */ |
440 | u32 fsf_lic_version; | |
aef4a983 MS |
441 | u32 adapter_features; /* FCP channel features */ |
442 | u32 connection_features; /* host connection features */ | |
1da177e4 | 443 | u32 hardware_version; /* of FCP channel */ |
c9615858 | 444 | u16 timer_ticks; /* time int for a tick */ |
1da177e4 | 445 | struct Scsi_Host *scsi_host; /* Pointer to mid-layer */ |
1da177e4 | 446 | struct list_head port_list_head; /* remote port list */ |
fea9d6c7 VS |
447 | unsigned long req_no; /* unique FSF req number */ |
448 | struct list_head *req_list; /* list of pending reqs */ | |
449 | spinlock_t req_list_lock; /* request list lock */ | |
00bab910 | 450 | struct zfcp_qdio_queue req_q; /* request queue */ |
0406289e | 451 | spinlock_t req_q_lock; /* for operations on queue */ |
94506fd1 MP |
452 | ktime_t req_q_time; /* time of last fill level change */ |
453 | u64 req_q_util; /* for accounting */ | |
454 | spinlock_t qdio_stat_lock; | |
1da177e4 LT |
455 | u32 fsf_req_seq_no; /* FSF cmnd seq number */ |
456 | wait_queue_head_t request_wq; /* can be used to wait for | |
457 | more avaliable SBALs */ | |
00bab910 | 458 | struct zfcp_qdio_queue resp_q; /* response queue */ |
1da177e4 LT |
459 | rwlock_t abort_lock; /* Protects against SCSI |
460 | stack abort/command | |
461 | completion races */ | |
d26ab06e SS |
462 | atomic_t stat_miss; /* # missing status reads*/ |
463 | struct work_struct stat_work; | |
1da177e4 LT |
464 | atomic_t status; /* status of this adapter */ |
465 | struct list_head erp_ready_head; /* error recovery for this | |
466 | adapter/devices */ | |
467 | struct list_head erp_running_head; | |
468 | rwlock_t erp_lock; | |
469 | struct semaphore erp_ready_sem; | |
470 | wait_queue_head_t erp_thread_wqh; | |
471 | wait_queue_head_t erp_done_wqh; | |
472 | struct zfcp_erp_action erp_action; /* pending error recovery */ | |
473 | atomic_t erp_counter; | |
474 | u32 erp_total_count; /* total nr of enqueued erp | |
475 | actions */ | |
476 | u32 erp_low_mem_count; /* nr of erp actions waiting | |
477 | for memory */ | |
9d544f2b | 478 | struct zfcp_wka_ports *gs; /* generic services */ |
d46f384a | 479 | struct zfcp_dbf *dbf; /* debug traces */ |
1da177e4 LT |
480 | struct zfcp_adapter_mempool pool; /* Adapter memory pools */ |
481 | struct qdio_initialize qdio_init_data; /* for qdio_establish */ | |
f6cd94b1 AH |
482 | struct fc_host_statistics *fc_stats; |
483 | struct fsf_qtcb_bottom_port *stats_reset_data; | |
484 | unsigned long stats_reset; | |
cc8c2829 | 485 | struct work_struct scan_work; |
bd43a42b | 486 | struct service_level service_level; |
2450d3e7 | 487 | atomic_t qdio_outb_full; /* queue full incidents */ |
1da177e4 LT |
488 | }; |
489 | ||
1da177e4 LT |
490 | struct zfcp_port { |
491 | struct device sysfs_device; /* sysfs device */ | |
3859f6a2 | 492 | struct fc_rport *rport; /* rport of fc transport class */ |
1da177e4 LT |
493 | struct list_head list; /* list of remote ports */ |
494 | atomic_t refcount; /* reference count */ | |
495 | wait_queue_head_t remove_wq; /* can be used to wait for | |
496 | refcount drop to zero */ | |
497 | struct zfcp_adapter *adapter; /* adapter used to access port */ | |
498 | struct list_head unit_list_head; /* head of logical unit list */ | |
1da177e4 | 499 | atomic_t status; /* status of this remote port */ |
7ba58c9c SS |
500 | u64 wwnn; /* WWNN if known */ |
501 | u64 wwpn; /* WWPN */ | |
13e1e1f0 | 502 | u32 d_id; /* D_ID */ |
1da177e4 LT |
503 | u32 handle; /* handle assigned by FSF */ |
504 | struct zfcp_erp_action erp_action; /* pending error recovery */ | |
505 | atomic_t erp_counter; | |
75bfc283 RW |
506 | u32 maxframe_size; |
507 | u32 supported_classes; | |
5ab944f9 | 508 | struct work_struct gid_pn_work; |
8fdf30d5 | 509 | struct work_struct test_link_work; |
a2fa0aed CS |
510 | struct work_struct rport_work; |
511 | enum { RPORT_NONE, RPORT_ADD, RPORT_DEL } rport_task; | |
1da177e4 LT |
512 | }; |
513 | ||
1da177e4 LT |
514 | struct zfcp_unit { |
515 | struct device sysfs_device; /* sysfs device */ | |
516 | struct list_head list; /* list of logical units */ | |
517 | atomic_t refcount; /* reference count */ | |
518 | wait_queue_head_t remove_wq; /* can be used to wait for | |
519 | refcount drop to zero */ | |
520 | struct zfcp_port *port; /* remote port of unit */ | |
521 | atomic_t status; /* status of this logical unit */ | |
7ba58c9c | 522 | u64 fcp_lun; /* own FCP_LUN */ |
1da177e4 LT |
523 | u32 handle; /* handle assigned by FSF */ |
524 | struct scsi_device *device; /* scsi device struct pointer */ | |
525 | struct zfcp_erp_action erp_action; /* pending error recovery */ | |
526 | atomic_t erp_counter; | |
c9615858 | 527 | struct zfcp_latencies latencies; |
92d5193b | 528 | struct work_struct scsi_work; |
1da177e4 LT |
529 | }; |
530 | ||
531 | /* FSF request */ | |
532 | struct zfcp_fsf_req { | |
533 | struct list_head list; /* list of FSF requests */ | |
fea9d6c7 | 534 | unsigned long req_id; /* unique request ID */ |
1da177e4 LT |
535 | struct zfcp_adapter *adapter; /* adapter request belongs to */ |
536 | u8 sbal_number; /* nr of SBALs free for use */ | |
537 | u8 sbal_first; /* first SBAL for this request */ | |
e891bffe | 538 | u8 sbal_last; /* last SBAL for this request */ |
d01d51be | 539 | u8 sbal_limit; /* last possible SBAL for |
1da177e4 | 540 | this reuest */ |
1da177e4 LT |
541 | u8 sbale_curr; /* current SBALE during creation |
542 | of request */ | |
c3baa9a2 | 543 | u8 sbal_response; /* SBAL used in interrupt */ |
058b8647 | 544 | struct completion completion; /* can be used by a routine |
1da177e4 | 545 | to wait for completion */ |
44cc76f2 | 546 | u32 status; /* status of this request */ |
1da177e4 LT |
547 | u32 fsf_command; /* FSF Command copy */ |
548 | struct fsf_qtcb *qtcb; /* address of associated QTCB */ | |
549 | u32 seq_no; /* Sequence number of request */ | |
c41f8cbd | 550 | void *data; /* private data of request */ |
41fa2ada | 551 | struct timer_list timer; /* used for erp or scsi er */ |
1da177e4 LT |
552 | struct zfcp_erp_action *erp_action; /* used if this request is |
553 | issued on behalf of erp */ | |
554 | mempool_t *pool; /* used if request was alloacted | |
555 | from emergency pool */ | |
8a36e453 | 556 | unsigned long long issued; /* request sent time (STCK) */ |
059c97d0 | 557 | struct zfcp_unit *unit; |
c41f8cbd | 558 | void (*handler)(struct zfcp_fsf_req *); |
0997f1c5 SR |
559 | u16 qdio_outb_usage;/* usage of outbound queue */ |
560 | u16 qdio_inb_usage; /* usage of inbound queue */ | |
1da177e4 LT |
561 | }; |
562 | ||
1da177e4 LT |
563 | /* driver data */ |
564 | struct zfcp_data { | |
565 | struct scsi_host_template scsi_host_template; | |
dd52e0ea | 566 | struct scsi_transport_template *scsi_transport_template; |
1da177e4 LT |
567 | rwlock_t config_lock; /* serialises changes |
568 | to adapter/port/unit | |
569 | lists */ | |
570 | struct semaphore config_sema; /* serialises configuration | |
571 | changes */ | |
a4623c46 SS |
572 | struct kmem_cache *gpn_ft_cache; |
573 | struct kmem_cache *qtcb_cache; | |
7ba58c9c SS |
574 | struct kmem_cache *sr_buffer_cache; |
575 | struct kmem_cache *gid_pn_cache; | |
b7f15f3c | 576 | struct workqueue_struct *work_queue; |
1da177e4 LT |
577 | }; |
578 | ||
1da177e4 LT |
579 | /********************** ZFCP SPECIFIC DEFINES ********************************/ |
580 | ||
1da177e4 LT |
581 | #define ZFCP_SET 0x00000100 |
582 | #define ZFCP_CLEAR 0x00000200 | |
583 | ||
ca2d02c2 HC |
584 | /* |
585 | * Helper functions for request ID management. | |
586 | */ | |
587 | static inline int zfcp_reqlist_hash(unsigned long req_id) | |
588 | { | |
589 | return req_id % REQUEST_LIST_SIZE; | |
590 | } | |
591 | ||
ca2d02c2 HC |
592 | static inline void zfcp_reqlist_remove(struct zfcp_adapter *adapter, |
593 | struct zfcp_fsf_req *fsf_req) | |
594 | { | |
595 | list_del(&fsf_req->list); | |
596 | } | |
597 | ||
598 | static inline struct zfcp_fsf_req * | |
599 | zfcp_reqlist_find(struct zfcp_adapter *adapter, unsigned long req_id) | |
600 | { | |
601 | struct zfcp_fsf_req *request; | |
602 | unsigned int idx; | |
603 | ||
604 | idx = zfcp_reqlist_hash(req_id); | |
605 | list_for_each_entry(request, &adapter->req_list[idx], list) | |
606 | if (request->req_id == req_id) | |
607 | return request; | |
608 | return NULL; | |
609 | } | |
610 | ||
d1ad09db HC |
611 | static inline struct zfcp_fsf_req * |
612 | zfcp_reqlist_find_safe(struct zfcp_adapter *adapter, struct zfcp_fsf_req *req) | |
613 | { | |
614 | struct zfcp_fsf_req *request; | |
615 | unsigned int idx; | |
616 | ||
617 | for (idx = 0; idx < REQUEST_LIST_SIZE; idx++) { | |
618 | list_for_each_entry(request, &adapter->req_list[idx], list) | |
619 | if (request == req) | |
620 | return request; | |
621 | } | |
622 | return NULL; | |
623 | } | |
624 | ||
1da177e4 LT |
625 | /* |
626 | * functions needed for reference/usage counting | |
627 | */ | |
628 | ||
629 | static inline void | |
630 | zfcp_unit_get(struct zfcp_unit *unit) | |
631 | { | |
632 | atomic_inc(&unit->refcount); | |
633 | } | |
634 | ||
635 | static inline void | |
636 | zfcp_unit_put(struct zfcp_unit *unit) | |
637 | { | |
638 | if (atomic_dec_return(&unit->refcount) == 0) | |
639 | wake_up(&unit->remove_wq); | |
640 | } | |
641 | ||
1da177e4 LT |
642 | static inline void |
643 | zfcp_port_get(struct zfcp_port *port) | |
644 | { | |
645 | atomic_inc(&port->refcount); | |
646 | } | |
647 | ||
648 | static inline void | |
649 | zfcp_port_put(struct zfcp_port *port) | |
650 | { | |
651 | if (atomic_dec_return(&port->refcount) == 0) | |
652 | wake_up(&port->remove_wq); | |
653 | } | |
654 | ||
1da177e4 LT |
655 | static inline void |
656 | zfcp_adapter_get(struct zfcp_adapter *adapter) | |
657 | { | |
658 | atomic_inc(&adapter->refcount); | |
659 | } | |
660 | ||
661 | static inline void | |
662 | zfcp_adapter_put(struct zfcp_adapter *adapter) | |
663 | { | |
664 | if (atomic_dec_return(&adapter->refcount) == 0) | |
665 | wake_up(&adapter->remove_wq); | |
666 | } | |
667 | ||
1da177e4 | 668 | #endif /* ZFCP_DEF_H */ |