ath5k: fix values for bus error bits in ISR2
[linux-2.6/next.git] / drivers / s390 / scsi / zfcp_def.h
blob49d0532bca1cb1333fb6b104264bb638ec92d19c
1 /*
2 * zfcp device driver
4 * Global definitions for the zfcp device driver.
6 * Copyright IBM Corporation 2002, 2009
7 */
9 #ifndef ZFCP_DEF_H
10 #define ZFCP_DEF_H
12 /*************************** INCLUDES *****************************************/
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_dbf.h"
41 #include "zfcp_fsf.h"
44 /********************* GENERAL DEFINES *********************************/
46 #define REQUEST_LIST_SIZE 128
48 /********************* SCSI SPECIFIC DEFINES *********************************/
49 #define ZFCP_SCSI_ER_TIMEOUT (10*HZ)
51 /********************* CIO/QDIO SPECIFIC DEFINES *****************************/
53 /* DMQ bug workaround: don't use last SBALE */
54 #define ZFCP_MAX_SBALES_PER_SBAL (QDIO_MAX_ELEMENTS_PER_BUFFER - 1)
56 /* index of last SBALE (with respect to DMQ bug workaround) */
57 #define ZFCP_LAST_SBALE_PER_SBAL (ZFCP_MAX_SBALES_PER_SBAL - 1)
59 /* max. number of (data buffer) SBALEs in largest SBAL chain */
60 #define ZFCP_MAX_SBALES_PER_REQ \
61 (FSF_MAX_SBALS_PER_REQ * ZFCP_MAX_SBALES_PER_SBAL - 2)
62 /* request ID + QTCB in SBALE 0 + 1 of first SBAL in chain */
64 #define ZFCP_MAX_SECTORS (ZFCP_MAX_SBALES_PER_REQ * 8)
65 /* max. number of (data buffer) SBALEs in largest SBAL chain
66 multiplied with number of sectors per 4k block */
68 /********************* FSF SPECIFIC DEFINES *********************************/
70 /* ATTENTION: value must not be used by hardware */
71 #define FSF_QTCB_UNSOLICITED_STATUS 0x6305
73 /* timeout value for "default timer" for fsf requests */
74 #define ZFCP_FSF_REQUEST_TIMEOUT (60*HZ)
76 /*************** FIBRE CHANNEL PROTOCOL SPECIFIC DEFINES ********************/
78 /* timeout for name-server lookup (in seconds) */
79 #define ZFCP_NS_GID_PN_TIMEOUT 10
81 /* task attribute values in FCP-2 FCP_CMND IU */
82 #define SIMPLE_Q 0
83 #define HEAD_OF_Q 1
84 #define ORDERED_Q 2
85 #define ACA_Q 4
86 #define UNTAGGED 5
88 /* task management flags in FCP-2 FCP_CMND IU */
89 #define FCP_CLEAR_ACA 0x40
90 #define FCP_TARGET_RESET 0x20
91 #define FCP_LOGICAL_UNIT_RESET 0x10
92 #define FCP_CLEAR_TASK_SET 0x04
93 #define FCP_ABORT_TASK_SET 0x02
95 #define FCP_CDB_LENGTH 16
97 #define ZFCP_DID_MASK 0x00FFFFFF
99 /* FCP(-2) FCP_CMND IU */
100 struct fcp_cmnd_iu {
101 u64 fcp_lun; /* FCP logical unit number */
102 u8 crn; /* command reference number */
103 u8 reserved0:5; /* reserved */
104 u8 task_attribute:3; /* task attribute */
105 u8 task_management_flags; /* task management flags */
106 u8 add_fcp_cdb_length:6; /* additional FCP_CDB length */
107 u8 rddata:1; /* read data */
108 u8 wddata:1; /* write data */
109 u8 fcp_cdb[FCP_CDB_LENGTH];
110 } __attribute__((packed));
112 /* FCP(-2) FCP_RSP IU */
113 struct fcp_rsp_iu {
114 u8 reserved0[10];
115 union {
116 struct {
117 u8 reserved1:3;
118 u8 fcp_conf_req:1;
119 u8 fcp_resid_under:1;
120 u8 fcp_resid_over:1;
121 u8 fcp_sns_len_valid:1;
122 u8 fcp_rsp_len_valid:1;
123 } bits;
124 u8 value;
125 } validity;
126 u8 scsi_status;
127 u32 fcp_resid;
128 u32 fcp_sns_len;
129 u32 fcp_rsp_len;
130 } __attribute__((packed));
133 #define RSP_CODE_GOOD 0
134 #define RSP_CODE_LENGTH_MISMATCH 1
135 #define RSP_CODE_FIELD_INVALID 2
136 #define RSP_CODE_RO_MISMATCH 3
137 #define RSP_CODE_TASKMAN_UNSUPP 4
138 #define RSP_CODE_TASKMAN_FAILED 5
140 /* see fc-fs */
141 #define LS_RSCN 0x61
142 #define LS_LOGO 0x05
143 #define LS_PLOGI 0x03
145 struct fcp_rscn_head {
146 u8 command;
147 u8 page_length; /* always 0x04 */
148 u16 payload_len;
149 } __attribute__((packed));
151 struct fcp_rscn_element {
152 u8 reserved:2;
153 u8 event_qual:4;
154 u8 addr_format:2;
155 u32 nport_did:24;
156 } __attribute__((packed));
158 /* see fc-ph */
159 struct fcp_logo {
160 u32 command;
161 u32 nport_did;
162 u64 nport_wwpn;
163 } __attribute__((packed));
166 * FC-FS stuff
168 #define R_A_TOV 10 /* seconds */
170 #define ZFCP_LS_RLS 0x0f
171 #define ZFCP_LS_ADISC 0x52
172 #define ZFCP_LS_RPS 0x56
173 #define ZFCP_LS_RSCN 0x61
174 #define ZFCP_LS_RNID 0x78
176 struct zfcp_ls_adisc {
177 u8 code;
178 u8 field[3];
179 u32 hard_nport_id;
180 u64 wwpn;
181 u64 wwnn;
182 u32 nport_id;
183 } __attribute__ ((packed));
186 * FC-GS-2 stuff
188 #define ZFCP_CT_REVISION 0x01
189 #define ZFCP_CT_DIRECTORY_SERVICE 0xFC
190 #define ZFCP_CT_NAME_SERVER 0x02
191 #define ZFCP_CT_SYNCHRONOUS 0x00
192 #define ZFCP_CT_SCSI_FCP 0x08
193 #define ZFCP_CT_UNABLE_TO_PERFORM_CMD 0x09
194 #define ZFCP_CT_GID_PN 0x0121
195 #define ZFCP_CT_GPN_FT 0x0172
196 #define ZFCP_CT_ACCEPT 0x8002
197 #define ZFCP_CT_REJECT 0x8001
200 * FC-GS-4 stuff
202 #define ZFCP_CT_TIMEOUT (3 * R_A_TOV)
204 /*************** ADAPTER/PORT/UNIT AND FSF_REQ STATUS FLAGS ******************/
207 * Note, the leftmost status byte is common among adapter, port
208 * and unit
210 #define ZFCP_COMMON_FLAGS 0xfff00000
212 /* common status bits */
213 #define ZFCP_STATUS_COMMON_REMOVE 0x80000000
214 #define ZFCP_STATUS_COMMON_RUNNING 0x40000000
215 #define ZFCP_STATUS_COMMON_ERP_FAILED 0x20000000
216 #define ZFCP_STATUS_COMMON_UNBLOCKED 0x10000000
217 #define ZFCP_STATUS_COMMON_OPEN 0x04000000
218 #define ZFCP_STATUS_COMMON_ERP_INUSE 0x01000000
219 #define ZFCP_STATUS_COMMON_ACCESS_DENIED 0x00800000
220 #define ZFCP_STATUS_COMMON_ACCESS_BOXED 0x00400000
221 #define ZFCP_STATUS_COMMON_NOESC 0x00200000
223 /* adapter status */
224 #define ZFCP_STATUS_ADAPTER_QDIOUP 0x00000002
225 #define ZFCP_STATUS_ADAPTER_XCONFIG_OK 0x00000008
226 #define ZFCP_STATUS_ADAPTER_HOST_CON_INIT 0x00000010
227 #define ZFCP_STATUS_ADAPTER_ERP_THREAD_UP 0x00000020
228 #define ZFCP_STATUS_ADAPTER_ERP_THREAD_KILL 0x00000080
229 #define ZFCP_STATUS_ADAPTER_ERP_PENDING 0x00000100
230 #define ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED 0x00000200
232 /* FC-PH/FC-GS well-known address identifiers for generic services */
233 #define ZFCP_DID_WKA 0xFFFFF0
235 /* remote port status */
236 #define ZFCP_STATUS_PORT_PHYS_OPEN 0x00000001
238 /* well known address (WKA) port status*/
239 enum zfcp_wka_status {
240 ZFCP_WKA_PORT_OFFLINE,
241 ZFCP_WKA_PORT_CLOSING,
242 ZFCP_WKA_PORT_OPENING,
243 ZFCP_WKA_PORT_ONLINE,
246 /* logical unit status */
247 #define ZFCP_STATUS_UNIT_SHARED 0x00000004
248 #define ZFCP_STATUS_UNIT_READONLY 0x00000008
250 /* FSF request status (this does not have a common part) */
251 #define ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT 0x00000002
252 #define ZFCP_STATUS_FSFREQ_COMPLETED 0x00000004
253 #define ZFCP_STATUS_FSFREQ_ERROR 0x00000008
254 #define ZFCP_STATUS_FSFREQ_CLEANUP 0x00000010
255 #define ZFCP_STATUS_FSFREQ_ABORTSUCCEEDED 0x00000040
256 #define ZFCP_STATUS_FSFREQ_ABORTNOTNEEDED 0x00000080
257 #define ZFCP_STATUS_FSFREQ_ABORTED 0x00000100
258 #define ZFCP_STATUS_FSFREQ_TMFUNCFAILED 0x00000200
259 #define ZFCP_STATUS_FSFREQ_TMFUNCNOTSUPP 0x00000400
260 #define ZFCP_STATUS_FSFREQ_RETRY 0x00000800
261 #define ZFCP_STATUS_FSFREQ_DISMISSED 0x00001000
263 /************************* STRUCTURE DEFINITIONS *****************************/
265 struct zfcp_fsf_req;
267 /* holds various memory pools of an adapter */
268 struct zfcp_adapter_mempool {
269 mempool_t *fsf_req_erp;
270 mempool_t *fsf_req_scsi;
271 mempool_t *fsf_req_abort;
272 mempool_t *fsf_req_status_read;
273 mempool_t *data_status_read;
274 mempool_t *data_gid_pn;
278 * header for CT_IU
280 struct ct_hdr {
281 u8 revision; // 0x01
282 u8 in_id[3]; // 0x00
283 u8 gs_type; // 0xFC Directory Service
284 u8 gs_subtype; // 0x02 Name Server
285 u8 options; // 0x00 single bidirectional exchange
286 u8 reserved0;
287 u16 cmd_rsp_code; // 0x0121 GID_PN, or 0x0100 GA_NXT
288 u16 max_res_size; // <= (4096 - 16) / 4
289 u8 reserved1;
290 u8 reason_code;
291 u8 reason_code_expl;
292 u8 vendor_unique;
293 } __attribute__ ((packed));
295 /* nameserver request CT_IU -- for requests where
296 * a port name is required */
297 struct ct_iu_gid_pn_req {
298 struct ct_hdr header;
299 u64 wwpn;
300 } __attribute__ ((packed));
302 /* FS_ACC IU and data unit for GID_PN nameserver request */
303 struct ct_iu_gid_pn_resp {
304 struct ct_hdr header;
305 u32 d_id;
306 } __attribute__ ((packed));
309 * struct zfcp_send_ct - used to pass parameters to function zfcp_fsf_send_ct
310 * @wka_port: port where the request is sent to
311 * @req: scatter-gather list for request
312 * @resp: scatter-gather list for response
313 * @handler: handler function (called for response to the request)
314 * @handler_data: data passed to handler function
315 * @timeout: FSF timeout for this request
316 * @completion: completion for synchronization purposes
317 * @status: used to pass error status to calling function
319 struct zfcp_send_ct {
320 struct zfcp_wka_port *wka_port;
321 struct scatterlist *req;
322 struct scatterlist *resp;
323 void (*handler)(unsigned long);
324 unsigned long handler_data;
325 int timeout;
326 struct completion *completion;
327 int status;
330 /* used for name server requests in error recovery */
331 struct zfcp_gid_pn_data {
332 struct zfcp_send_ct ct;
333 struct scatterlist req;
334 struct scatterlist resp;
335 struct ct_iu_gid_pn_req ct_iu_req;
336 struct ct_iu_gid_pn_resp ct_iu_resp;
337 struct zfcp_port *port;
341 * struct zfcp_send_els - used to pass parameters to function zfcp_fsf_send_els
342 * @adapter: adapter where request is sent from
343 * @port: port where ELS is destinated (port reference count has to be increased)
344 * @d_id: destiniation id of port where request is sent to
345 * @req: scatter-gather list for request
346 * @resp: scatter-gather list for response
347 * @handler: handler function (called for response to the request)
348 * @handler_data: data passed to handler function
349 * @completion: completion for synchronization purposes
350 * @ls_code: hex code of ELS command
351 * @status: used to pass error status to calling function
353 struct zfcp_send_els {
354 struct zfcp_adapter *adapter;
355 struct zfcp_port *port;
356 u32 d_id;
357 struct scatterlist *req;
358 struct scatterlist *resp;
359 void (*handler)(unsigned long);
360 unsigned long handler_data;
361 struct completion *completion;
362 int ls_code;
363 int status;
366 struct zfcp_wka_port {
367 struct zfcp_adapter *adapter;
368 wait_queue_head_t completion_wq;
369 enum zfcp_wka_status status;
370 atomic_t refcount;
371 u32 d_id;
372 u32 handle;
373 struct mutex mutex;
374 struct delayed_work work;
377 struct zfcp_wka_ports {
378 struct zfcp_wka_port ms; /* management service */
379 struct zfcp_wka_port ts; /* time service */
380 struct zfcp_wka_port ds; /* directory service */
381 struct zfcp_wka_port as; /* alias service */
382 struct zfcp_wka_port ks; /* key distribution service */
385 struct zfcp_qdio_queue {
386 struct qdio_buffer *sbal[QDIO_MAX_BUFFERS_PER_Q];
387 u8 first; /* index of next free bfr in queue */
388 atomic_t count; /* number of free buffers in queue */
391 struct zfcp_erp_action {
392 struct list_head list;
393 int action; /* requested action code */
394 struct zfcp_adapter *adapter; /* device which should be recovered */
395 struct zfcp_port *port;
396 struct zfcp_unit *unit;
397 u32 status; /* recovery status */
398 u32 step; /* active step of this erp action */
399 struct zfcp_fsf_req *fsf_req; /* fsf request currently pending
400 for this action */
401 struct timer_list timer;
404 struct fsf_latency_record {
405 u32 min;
406 u32 max;
407 u64 sum;
410 struct latency_cont {
411 struct fsf_latency_record channel;
412 struct fsf_latency_record fabric;
413 u64 counter;
416 struct zfcp_latencies {
417 struct latency_cont read;
418 struct latency_cont write;
419 struct latency_cont cmd;
420 spinlock_t lock;
423 struct zfcp_adapter {
424 atomic_t refcount; /* reference count */
425 wait_queue_head_t remove_wq; /* can be used to wait for
426 refcount drop to zero */
427 u64 peer_wwnn; /* P2P peer WWNN */
428 u64 peer_wwpn; /* P2P peer WWPN */
429 u32 peer_d_id; /* P2P peer D_ID */
430 struct ccw_device *ccw_device; /* S/390 ccw device */
431 u32 hydra_version; /* Hydra version */
432 u32 fsf_lic_version;
433 u32 adapter_features; /* FCP channel features */
434 u32 connection_features; /* host connection features */
435 u32 hardware_version; /* of FCP channel */
436 u16 timer_ticks; /* time int for a tick */
437 struct Scsi_Host *scsi_host; /* Pointer to mid-layer */
438 struct list_head port_list_head; /* remote port list */
439 unsigned long req_no; /* unique FSF req number */
440 struct list_head *req_list; /* list of pending reqs */
441 spinlock_t req_list_lock; /* request list lock */
442 struct zfcp_qdio_queue req_q; /* request queue */
443 spinlock_t req_q_lock; /* for operations on queue */
444 ktime_t req_q_time; /* time of last fill level change */
445 u64 req_q_util; /* for accounting */
446 spinlock_t qdio_stat_lock;
447 u32 fsf_req_seq_no; /* FSF cmnd seq number */
448 wait_queue_head_t request_wq; /* can be used to wait for
449 more avaliable SBALs */
450 struct zfcp_qdio_queue resp_q; /* response queue */
451 rwlock_t abort_lock; /* Protects against SCSI
452 stack abort/command
453 completion races */
454 atomic_t stat_miss; /* # missing status reads*/
455 struct work_struct stat_work;
456 atomic_t status; /* status of this adapter */
457 struct list_head erp_ready_head; /* error recovery for this
458 adapter/devices */
459 struct list_head erp_running_head;
460 rwlock_t erp_lock;
461 struct semaphore erp_ready_sem;
462 wait_queue_head_t erp_thread_wqh;
463 wait_queue_head_t erp_done_wqh;
464 struct zfcp_erp_action erp_action; /* pending error recovery */
465 atomic_t erp_counter;
466 u32 erp_total_count; /* total nr of enqueued erp
467 actions */
468 u32 erp_low_mem_count; /* nr of erp actions waiting
469 for memory */
470 struct zfcp_wka_ports *gs; /* generic services */
471 debug_info_t *rec_dbf;
472 debug_info_t *hba_dbf;
473 debug_info_t *san_dbf; /* debug feature areas */
474 debug_info_t *scsi_dbf;
475 spinlock_t rec_dbf_lock;
476 spinlock_t hba_dbf_lock;
477 spinlock_t san_dbf_lock;
478 spinlock_t scsi_dbf_lock;
479 struct zfcp_rec_dbf_record rec_dbf_buf;
480 struct zfcp_hba_dbf_record hba_dbf_buf;
481 struct zfcp_san_dbf_record san_dbf_buf;
482 struct zfcp_scsi_dbf_record scsi_dbf_buf;
483 struct zfcp_adapter_mempool pool; /* Adapter memory pools */
484 struct qdio_initialize qdio_init_data; /* for qdio_establish */
485 struct fc_host_statistics *fc_stats;
486 struct fsf_qtcb_bottom_port *stats_reset_data;
487 unsigned long stats_reset;
488 struct work_struct scan_work;
489 struct service_level service_level;
490 atomic_t qdio_outb_full; /* queue full incidents */
493 struct zfcp_port {
494 struct device sysfs_device; /* sysfs device */
495 struct fc_rport *rport; /* rport of fc transport class */
496 struct list_head list; /* list of remote ports */
497 atomic_t refcount; /* reference count */
498 wait_queue_head_t remove_wq; /* can be used to wait for
499 refcount drop to zero */
500 struct zfcp_adapter *adapter; /* adapter used to access port */
501 struct list_head unit_list_head; /* head of logical unit list */
502 atomic_t status; /* status of this remote port */
503 u64 wwnn; /* WWNN if known */
504 u64 wwpn; /* WWPN */
505 u32 d_id; /* D_ID */
506 u32 handle; /* handle assigned by FSF */
507 struct zfcp_erp_action erp_action; /* pending error recovery */
508 atomic_t erp_counter;
509 u32 maxframe_size;
510 u32 supported_classes;
511 struct work_struct gid_pn_work;
512 struct work_struct test_link_work;
513 struct work_struct rport_work;
514 enum { RPORT_NONE, RPORT_ADD, RPORT_DEL } rport_task;
517 struct zfcp_unit {
518 struct device sysfs_device; /* sysfs device */
519 struct list_head list; /* list of logical units */
520 atomic_t refcount; /* reference count */
521 wait_queue_head_t remove_wq; /* can be used to wait for
522 refcount drop to zero */
523 struct zfcp_port *port; /* remote port of unit */
524 atomic_t status; /* status of this logical unit */
525 u64 fcp_lun; /* own FCP_LUN */
526 u32 handle; /* handle assigned by FSF */
527 struct scsi_device *device; /* scsi device struct pointer */
528 struct zfcp_erp_action erp_action; /* pending error recovery */
529 atomic_t erp_counter;
530 struct zfcp_latencies latencies;
531 struct work_struct scsi_work;
534 /* FSF request */
535 struct zfcp_fsf_req {
536 struct list_head list; /* list of FSF requests */
537 unsigned long req_id; /* unique request ID */
538 struct zfcp_adapter *adapter; /* adapter request belongs to */
539 u8 sbal_number; /* nr of SBALs free for use */
540 u8 sbal_first; /* first SBAL for this request */
541 u8 sbal_last; /* last SBAL for this request */
542 u8 sbal_limit; /* last possible SBAL for
543 this reuest */
544 u8 sbale_curr; /* current SBALE during creation
545 of request */
546 u8 sbal_response; /* SBAL used in interrupt */
547 wait_queue_head_t completion_wq; /* can be used by a routine
548 to wait for completion */
549 u32 status; /* status of this request */
550 u32 fsf_command; /* FSF Command copy */
551 struct fsf_qtcb *qtcb; /* address of associated QTCB */
552 u32 seq_no; /* Sequence number of request */
553 void *data; /* private data of request */
554 struct timer_list timer; /* used for erp or scsi er */
555 struct zfcp_erp_action *erp_action; /* used if this request is
556 issued on behalf of erp */
557 mempool_t *pool; /* used if request was alloacted
558 from emergency pool */
559 unsigned long long issued; /* request sent time (STCK) */
560 struct zfcp_unit *unit;
561 void (*handler)(struct zfcp_fsf_req *);
562 u16 qdio_outb_usage;/* usage of outbound queue */
563 u16 qdio_inb_usage; /* usage of inbound queue */
566 /* driver data */
567 struct zfcp_data {
568 struct scsi_host_template scsi_host_template;
569 struct scsi_transport_template *scsi_transport_template;
570 rwlock_t config_lock; /* serialises changes
571 to adapter/port/unit
572 lists */
573 struct semaphore config_sema; /* serialises configuration
574 changes */
575 struct kmem_cache *fsf_req_qtcb_cache;
576 struct kmem_cache *sr_buffer_cache;
577 struct kmem_cache *gid_pn_cache;
578 struct workqueue_struct *work_queue;
581 /* struct used by memory pools for fsf_requests */
582 struct zfcp_fsf_req_qtcb {
583 struct zfcp_fsf_req fsf_req;
584 struct fsf_qtcb qtcb;
587 /********************** ZFCP SPECIFIC DEFINES ********************************/
589 #define ZFCP_SET 0x00000100
590 #define ZFCP_CLEAR 0x00000200
593 * Helper functions for request ID management.
595 static inline int zfcp_reqlist_hash(unsigned long req_id)
597 return req_id % REQUEST_LIST_SIZE;
600 static inline void zfcp_reqlist_remove(struct zfcp_adapter *adapter,
601 struct zfcp_fsf_req *fsf_req)
603 list_del(&fsf_req->list);
606 static inline struct zfcp_fsf_req *
607 zfcp_reqlist_find(struct zfcp_adapter *adapter, unsigned long req_id)
609 struct zfcp_fsf_req *request;
610 unsigned int idx;
612 idx = zfcp_reqlist_hash(req_id);
613 list_for_each_entry(request, &adapter->req_list[idx], list)
614 if (request->req_id == req_id)
615 return request;
616 return NULL;
619 static inline struct zfcp_fsf_req *
620 zfcp_reqlist_find_safe(struct zfcp_adapter *adapter, struct zfcp_fsf_req *req)
622 struct zfcp_fsf_req *request;
623 unsigned int idx;
625 for (idx = 0; idx < REQUEST_LIST_SIZE; idx++) {
626 list_for_each_entry(request, &adapter->req_list[idx], list)
627 if (request == req)
628 return request;
630 return NULL;
634 * functions needed for reference/usage counting
637 static inline void
638 zfcp_unit_get(struct zfcp_unit *unit)
640 atomic_inc(&unit->refcount);
643 static inline void
644 zfcp_unit_put(struct zfcp_unit *unit)
646 if (atomic_dec_return(&unit->refcount) == 0)
647 wake_up(&unit->remove_wq);
650 static inline void
651 zfcp_port_get(struct zfcp_port *port)
653 atomic_inc(&port->refcount);
656 static inline void
657 zfcp_port_put(struct zfcp_port *port)
659 if (atomic_dec_return(&port->refcount) == 0)
660 wake_up(&port->remove_wq);
663 static inline void
664 zfcp_adapter_get(struct zfcp_adapter *adapter)
666 atomic_inc(&adapter->refcount);
669 static inline void
670 zfcp_adapter_put(struct zfcp_adapter *adapter)
672 if (atomic_dec_return(&adapter->refcount) == 0)
673 wake_up(&adapter->remove_wq);
676 #endif /* ZFCP_DEF_H */