601f5a575defa37d3f467f60f2b6ee8b32e506cc
[deliverable/linux.git] / drivers / s390 / scsi / zfcp_def.h
1 /*
2 * zfcp device driver
3 *
4 * Global definitions for the zfcp device driver.
5 *
6 * Copyright IBM Corporation 2002, 2009
7 */
8
9 #ifndef ZFCP_DEF_H
10 #define ZFCP_DEF_H
11
12 /*************************** INCLUDES *****************************************/
13
14 #include <linux/init.h>
15 #include <linux/moduleparam.h>
16 #include <linux/major.h>
17 #include <linux/blkdev.h>
18 #include <linux/delay.h>
19 #include <linux/timer.h>
20 #include <linux/slab.h>
21 #include <linux/mempool.h>
22 #include <linux/syscalls.h>
23 #include <linux/scatterlist.h>
24 #include <linux/ioctl.h>
25 #include <scsi/fc/fc_fs.h>
26 #include <scsi/fc/fc_gs.h>
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>
34 #include <scsi/scsi_bsg_fc.h>
35 #include <asm/ccwdev.h>
36 #include <asm/qdio.h>
37 #include <asm/debug.h>
38 #include <asm/ebcdic.h>
39 #include <asm/sysinfo.h>
40 #include "zfcp_fsf.h"
41
42 /********************* GENERAL DEFINES *********************************/
43
44 #define REQUEST_LIST_SIZE 128
45
46 /********************* SCSI SPECIFIC DEFINES *********************************/
47 #define ZFCP_SCSI_ER_TIMEOUT (10*HZ)
48
49 /********************* CIO/QDIO SPECIFIC DEFINES *****************************/
50
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 \
59 (FSF_MAX_SBALS_PER_REQ * ZFCP_MAX_SBALES_PER_SBAL - 2)
60 /* request ID + QTCB in SBALE 0 + 1 of first SBAL in chain */
61
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
66 /********************* FSF SPECIFIC DEFINES *********************************/
67
68 /* ATTENTION: value must not be used by hardware */
69 #define FSF_QTCB_UNSOLICITED_STATUS 0x6305
70
71 /* timeout value for "default timer" for fsf requests */
72 #define ZFCP_FSF_REQUEST_TIMEOUT (60*HZ)
73
74 /*************** FIBRE CHANNEL PROTOCOL SPECIFIC DEFINES ********************/
75
76 /* timeout for name-server lookup (in seconds) */
77 #define ZFCP_NS_GID_PN_TIMEOUT 10
78
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 {
99 u64 fcp_lun; /* FCP logical unit number */
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 */
139 #define LS_RSCN 0x61
140 #define LS_LOGO 0x05
141 #define LS_PLOGI 0x03
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
156 /* see fc-ph */
157 struct fcp_logo {
158 u32 command;
159 u32 nport_did;
160 u64 nport_wwpn;
161 } __attribute__((packed));
162
163 /*
164 * FC-FS stuff
165 */
166 #define R_A_TOV 10 /* seconds */
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
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
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
190 #define ZFCP_CT_SCSI_FCP 0x08
191 #define ZFCP_CT_UNABLE_TO_PERFORM_CMD 0x09
192 #define ZFCP_CT_GID_PN 0x0121
193 #define ZFCP_CT_GPN_FT 0x0172
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
202 /*************** ADAPTER/PORT/UNIT AND FSF_REQ STATUS FLAGS ******************/
203
204 /*
205 * Note, the leftmost status byte is common among adapter, port
206 * and unit
207 */
208 #define ZFCP_COMMON_FLAGS 0xfff00000
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
215 #define ZFCP_STATUS_COMMON_OPEN 0x04000000
216 #define ZFCP_STATUS_COMMON_ERP_INUSE 0x01000000
217 #define ZFCP_STATUS_COMMON_ACCESS_DENIED 0x00800000
218 #define ZFCP_STATUS_COMMON_ACCESS_BOXED 0x00400000
219 #define ZFCP_STATUS_COMMON_NOESC 0x00200000
220
221 /* adapter status */
222 #define ZFCP_STATUS_ADAPTER_QDIOUP 0x00000002
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
230 /* FC-PH/FC-GS well-known address identifiers for generic services */
231 #define ZFCP_DID_WKA 0xFFFFF0
232
233 /* remote port status */
234 #define ZFCP_STATUS_PORT_PHYS_OPEN 0x00000001
235
236 /* well known address (WKA) port status*/
237 enum zfcp_wka_status {
238 ZFCP_WKA_PORT_OFFLINE,
239 ZFCP_WKA_PORT_CLOSING,
240 ZFCP_WKA_PORT_OPENING,
241 ZFCP_WKA_PORT_ONLINE,
242 };
243
244 /* logical unit status */
245 #define ZFCP_STATUS_UNIT_SHARED 0x00000004
246 #define ZFCP_STATUS_UNIT_READONLY 0x00000008
247
248 /* FSF request status (this does not have a common part) */
249 #define ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT 0x00000002
250 #define ZFCP_STATUS_FSFREQ_COMPLETED 0x00000004
251 #define ZFCP_STATUS_FSFREQ_ERROR 0x00000008
252 #define ZFCP_STATUS_FSFREQ_CLEANUP 0x00000010
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
261 /************************* STRUCTURE DEFINITIONS *****************************/
262
263 struct zfcp_fsf_req;
264
265 /* holds various memory pools of an adapter */
266 struct zfcp_adapter_mempool {
267 mempool_t *fsf_req_erp;
268 mempool_t *fsf_req_scsi;
269 mempool_t *fsf_req_abort;
270 mempool_t *fsf_req_status_read;
271 mempool_t *data_status_read;
272 mempool_t *data_gid_pn;
273 };
274
275 /*
276 * header for CT_IU
277 */
278 struct ct_hdr {
279 u8 revision; // 0x01
280 u8 in_id[3]; // 0x00
281 u8 gs_type; // 0xFC Directory Service
282 u8 gs_subtype; // 0x02 Name Server
283 u8 options; // 0x00 single bidirectional exchange
284 u8 reserved0;
285 u16 cmd_rsp_code; // 0x0121 GID_PN, or 0x0100 GA_NXT
286 u16 max_res_size; // <= (4096 - 16) / 4
287 u8 reserved1;
288 u8 reason_code;
289 u8 reason_code_expl;
290 u8 vendor_unique;
291 } __attribute__ ((packed));
292
293 /* nameserver request CT_IU -- for requests where
294 * a port name is required */
295 struct ct_iu_gid_pn_req {
296 struct ct_hdr header;
297 u64 wwpn;
298 } __attribute__ ((packed));
299
300 /* FS_ACC IU and data unit for GID_PN nameserver request */
301 struct ct_iu_gid_pn_resp {
302 struct ct_hdr header;
303 u32 d_id;
304 } __attribute__ ((packed));
305
306 /**
307 * struct zfcp_send_ct - used to pass parameters to function zfcp_fsf_send_ct
308 * @wka_port: port where the request is sent to
309 * @req: scatter-gather list for request
310 * @resp: scatter-gather list for response
311 * @handler: handler function (called for response to the request)
312 * @handler_data: data passed to handler function
313 * @timeout: FSF timeout for this request
314 * @completion: completion for synchronization purposes
315 * @status: used to pass error status to calling function
316 */
317 struct zfcp_send_ct {
318 struct zfcp_wka_port *wka_port;
319 struct scatterlist *req;
320 struct scatterlist *resp;
321 void (*handler)(unsigned long);
322 unsigned long handler_data;
323 int timeout;
324 struct completion *completion;
325 int status;
326 };
327
328 /* used for name server requests in error recovery */
329 struct zfcp_gid_pn_data {
330 struct zfcp_send_ct ct;
331 struct scatterlist req;
332 struct scatterlist resp;
333 struct ct_iu_gid_pn_req ct_iu_req;
334 struct ct_iu_gid_pn_resp ct_iu_resp;
335 struct zfcp_port *port;
336 };
337
338 /**
339 * struct zfcp_send_els - used to pass parameters to function zfcp_fsf_send_els
340 * @adapter: adapter where request is sent from
341 * @port: port where ELS is destinated (port reference count has to be increased)
342 * @d_id: destiniation id of port where request is sent to
343 * @req: scatter-gather list for request
344 * @resp: scatter-gather list for response
345 * @handler: handler function (called for response to the request)
346 * @handler_data: data passed to handler function
347 * @completion: completion for synchronization purposes
348 * @ls_code: hex code of ELS command
349 * @status: used to pass error status to calling function
350 */
351 struct zfcp_send_els {
352 struct zfcp_adapter *adapter;
353 struct zfcp_port *port;
354 u32 d_id;
355 struct scatterlist *req;
356 struct scatterlist *resp;
357 void (*handler)(unsigned long);
358 unsigned long handler_data;
359 struct completion *completion;
360 int ls_code;
361 int status;
362 };
363
364 struct zfcp_wka_port {
365 struct zfcp_adapter *adapter;
366 wait_queue_head_t completion_wq;
367 enum zfcp_wka_status status;
368 atomic_t refcount;
369 u32 d_id;
370 u32 handle;
371 struct mutex mutex;
372 struct delayed_work work;
373 };
374
375 struct zfcp_wka_ports {
376 struct zfcp_wka_port ms; /* management service */
377 struct zfcp_wka_port ts; /* time service */
378 struct zfcp_wka_port ds; /* directory service */
379 struct zfcp_wka_port as; /* alias service */
380 struct zfcp_wka_port ks; /* key distribution service */
381 };
382
383 struct zfcp_qdio_queue {
384 struct qdio_buffer *sbal[QDIO_MAX_BUFFERS_PER_Q];
385 u8 first; /* index of next free bfr in queue */
386 atomic_t count; /* number of free buffers in queue */
387 };
388
389 struct zfcp_erp_action {
390 struct list_head list;
391 int action; /* requested action code */
392 struct zfcp_adapter *adapter; /* device which should be recovered */
393 struct zfcp_port *port;
394 struct zfcp_unit *unit;
395 u32 status; /* recovery status */
396 u32 step; /* active step of this erp action */
397 struct zfcp_fsf_req *fsf_req; /* fsf request currently pending
398 for this action */
399 struct timer_list timer;
400 };
401
402 struct fsf_latency_record {
403 u32 min;
404 u32 max;
405 u64 sum;
406 };
407
408 struct latency_cont {
409 struct fsf_latency_record channel;
410 struct fsf_latency_record fabric;
411 u64 counter;
412 };
413
414 struct zfcp_latencies {
415 struct latency_cont read;
416 struct latency_cont write;
417 struct latency_cont cmd;
418 spinlock_t lock;
419 };
420
421 struct zfcp_adapter {
422 atomic_t refcount; /* reference count */
423 wait_queue_head_t remove_wq; /* can be used to wait for
424 refcount drop to zero */
425 u64 peer_wwnn; /* P2P peer WWNN */
426 u64 peer_wwpn; /* P2P peer WWPN */
427 u32 peer_d_id; /* P2P peer D_ID */
428 struct ccw_device *ccw_device; /* S/390 ccw device */
429 u32 hydra_version; /* Hydra version */
430 u32 fsf_lic_version;
431 u32 adapter_features; /* FCP channel features */
432 u32 connection_features; /* host connection features */
433 u32 hardware_version; /* of FCP channel */
434 u16 timer_ticks; /* time int for a tick */
435 struct Scsi_Host *scsi_host; /* Pointer to mid-layer */
436 struct list_head port_list_head; /* remote port list */
437 unsigned long req_no; /* unique FSF req number */
438 struct list_head *req_list; /* list of pending reqs */
439 spinlock_t req_list_lock; /* request list lock */
440 struct zfcp_qdio_queue req_q; /* request queue */
441 spinlock_t req_q_lock; /* for operations on queue */
442 ktime_t req_q_time; /* time of last fill level change */
443 u64 req_q_util; /* for accounting */
444 spinlock_t qdio_stat_lock;
445 u32 fsf_req_seq_no; /* FSF cmnd seq number */
446 wait_queue_head_t request_wq; /* can be used to wait for
447 more avaliable SBALs */
448 struct zfcp_qdio_queue resp_q; /* response queue */
449 rwlock_t abort_lock; /* Protects against SCSI
450 stack abort/command
451 completion races */
452 atomic_t stat_miss; /* # missing status reads*/
453 struct work_struct stat_work;
454 atomic_t status; /* status of this adapter */
455 struct list_head erp_ready_head; /* error recovery for this
456 adapter/devices */
457 struct list_head erp_running_head;
458 rwlock_t erp_lock;
459 struct semaphore erp_ready_sem;
460 wait_queue_head_t erp_thread_wqh;
461 wait_queue_head_t erp_done_wqh;
462 struct zfcp_erp_action erp_action; /* pending error recovery */
463 atomic_t erp_counter;
464 u32 erp_total_count; /* total nr of enqueued erp
465 actions */
466 u32 erp_low_mem_count; /* nr of erp actions waiting
467 for memory */
468 struct zfcp_wka_ports *gs; /* generic services */
469 struct zfcp_dbf *dbf; /* debug traces */
470 struct zfcp_adapter_mempool pool; /* Adapter memory pools */
471 struct qdio_initialize qdio_init_data; /* for qdio_establish */
472 struct fc_host_statistics *fc_stats;
473 struct fsf_qtcb_bottom_port *stats_reset_data;
474 unsigned long stats_reset;
475 struct work_struct scan_work;
476 struct service_level service_level;
477 atomic_t qdio_outb_full; /* queue full incidents */
478 };
479
480 struct zfcp_port {
481 struct device sysfs_device; /* sysfs device */
482 struct fc_rport *rport; /* rport of fc transport class */
483 struct list_head list; /* list of remote ports */
484 atomic_t refcount; /* reference count */
485 wait_queue_head_t remove_wq; /* can be used to wait for
486 refcount drop to zero */
487 struct zfcp_adapter *adapter; /* adapter used to access port */
488 struct list_head unit_list_head; /* head of logical unit list */
489 atomic_t status; /* status of this remote port */
490 u64 wwnn; /* WWNN if known */
491 u64 wwpn; /* WWPN */
492 u32 d_id; /* D_ID */
493 u32 handle; /* handle assigned by FSF */
494 struct zfcp_erp_action erp_action; /* pending error recovery */
495 atomic_t erp_counter;
496 u32 maxframe_size;
497 u32 supported_classes;
498 struct work_struct gid_pn_work;
499 struct work_struct test_link_work;
500 struct work_struct rport_work;
501 enum { RPORT_NONE, RPORT_ADD, RPORT_DEL } rport_task;
502 };
503
504 struct zfcp_unit {
505 struct device sysfs_device; /* sysfs device */
506 struct list_head list; /* list of logical units */
507 atomic_t refcount; /* reference count */
508 wait_queue_head_t remove_wq; /* can be used to wait for
509 refcount drop to zero */
510 struct zfcp_port *port; /* remote port of unit */
511 atomic_t status; /* status of this logical unit */
512 u64 fcp_lun; /* own FCP_LUN */
513 u32 handle; /* handle assigned by FSF */
514 struct scsi_device *device; /* scsi device struct pointer */
515 struct zfcp_erp_action erp_action; /* pending error recovery */
516 atomic_t erp_counter;
517 struct zfcp_latencies latencies;
518 struct work_struct scsi_work;
519 };
520
521 /* FSF request */
522 struct zfcp_fsf_req {
523 struct list_head list; /* list of FSF requests */
524 unsigned long req_id; /* unique request ID */
525 struct zfcp_adapter *adapter; /* adapter request belongs to */
526 u8 sbal_number; /* nr of SBALs free for use */
527 u8 sbal_first; /* first SBAL for this request */
528 u8 sbal_last; /* last SBAL for this request */
529 u8 sbal_limit; /* last possible SBAL for
530 this reuest */
531 u8 sbale_curr; /* current SBALE during creation
532 of request */
533 u8 sbal_response; /* SBAL used in interrupt */
534 wait_queue_head_t completion_wq; /* can be used by a routine
535 to wait for completion */
536 u32 status; /* status of this request */
537 u32 fsf_command; /* FSF Command copy */
538 struct fsf_qtcb *qtcb; /* address of associated QTCB */
539 u32 seq_no; /* Sequence number of request */
540 void *data; /* private data of request */
541 struct timer_list timer; /* used for erp or scsi er */
542 struct zfcp_erp_action *erp_action; /* used if this request is
543 issued on behalf of erp */
544 mempool_t *pool; /* used if request was alloacted
545 from emergency pool */
546 unsigned long long issued; /* request sent time (STCK) */
547 struct zfcp_unit *unit;
548 void (*handler)(struct zfcp_fsf_req *);
549 u16 qdio_outb_usage;/* usage of outbound queue */
550 u16 qdio_inb_usage; /* usage of inbound queue */
551 };
552
553 /* driver data */
554 struct zfcp_data {
555 struct scsi_host_template scsi_host_template;
556 struct scsi_transport_template *scsi_transport_template;
557 rwlock_t config_lock; /* serialises changes
558 to adapter/port/unit
559 lists */
560 struct semaphore config_sema; /* serialises configuration
561 changes */
562 struct kmem_cache *fsf_req_qtcb_cache;
563 struct kmem_cache *sr_buffer_cache;
564 struct kmem_cache *gid_pn_cache;
565 struct workqueue_struct *work_queue;
566 };
567
568 /* struct used by memory pools for fsf_requests */
569 struct zfcp_fsf_req_qtcb {
570 struct zfcp_fsf_req fsf_req;
571 struct fsf_qtcb qtcb;
572 };
573
574 /********************** ZFCP SPECIFIC DEFINES ********************************/
575
576 #define ZFCP_SET 0x00000100
577 #define ZFCP_CLEAR 0x00000200
578
579 /*
580 * Helper functions for request ID management.
581 */
582 static inline int zfcp_reqlist_hash(unsigned long req_id)
583 {
584 return req_id % REQUEST_LIST_SIZE;
585 }
586
587 static inline void zfcp_reqlist_remove(struct zfcp_adapter *adapter,
588 struct zfcp_fsf_req *fsf_req)
589 {
590 list_del(&fsf_req->list);
591 }
592
593 static inline struct zfcp_fsf_req *
594 zfcp_reqlist_find(struct zfcp_adapter *adapter, unsigned long req_id)
595 {
596 struct zfcp_fsf_req *request;
597 unsigned int idx;
598
599 idx = zfcp_reqlist_hash(req_id);
600 list_for_each_entry(request, &adapter->req_list[idx], list)
601 if (request->req_id == req_id)
602 return request;
603 return NULL;
604 }
605
606 static inline struct zfcp_fsf_req *
607 zfcp_reqlist_find_safe(struct zfcp_adapter *adapter, struct zfcp_fsf_req *req)
608 {
609 struct zfcp_fsf_req *request;
610 unsigned int idx;
611
612 for (idx = 0; idx < REQUEST_LIST_SIZE; idx++) {
613 list_for_each_entry(request, &adapter->req_list[idx], list)
614 if (request == req)
615 return request;
616 }
617 return NULL;
618 }
619
620 /*
621 * functions needed for reference/usage counting
622 */
623
624 static inline void
625 zfcp_unit_get(struct zfcp_unit *unit)
626 {
627 atomic_inc(&unit->refcount);
628 }
629
630 static inline void
631 zfcp_unit_put(struct zfcp_unit *unit)
632 {
633 if (atomic_dec_return(&unit->refcount) == 0)
634 wake_up(&unit->remove_wq);
635 }
636
637 static inline void
638 zfcp_port_get(struct zfcp_port *port)
639 {
640 atomic_inc(&port->refcount);
641 }
642
643 static inline void
644 zfcp_port_put(struct zfcp_port *port)
645 {
646 if (atomic_dec_return(&port->refcount) == 0)
647 wake_up(&port->remove_wq);
648 }
649
650 static inline void
651 zfcp_adapter_get(struct zfcp_adapter *adapter)
652 {
653 atomic_inc(&adapter->refcount);
654 }
655
656 static inline void
657 zfcp_adapter_put(struct zfcp_adapter *adapter)
658 {
659 if (atomic_dec_return(&adapter->refcount) == 0)
660 wake_up(&adapter->remove_wq);
661 }
662
663 #endif /* ZFCP_DEF_H */
This page took 0.044532 seconds and 4 git commands to generate.