i2c-s3c2410: Remove unconditional 1ms delay on each transfer
[safe/jmp/linux-2.6] / drivers / scsi / bfa / bfa_intr_priv.h
1 /*
2  * Copyright (c) 2005-2009 Brocade Communications Systems, Inc.
3  * All rights reserved
4  * www.brocade.com
5  *
6  * Linux driver for Brocade Fibre Channel Host Bus Adapter.
7  *
8  * This program is free software; you can redistribute it and/or modify it
9  * under the terms of the GNU General Public License (GPL) Version 2 as
10  * published by the Free Software Foundation
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * General Public License for more details.
16  */
17
18 #ifndef __BFA_INTR_PRIV_H__
19 #define __BFA_INTR_PRIV_H__
20
21 /**
22  * Message handler
23  */
24 typedef void (*bfa_isr_func_t) (struct bfa_s *bfa, struct bfi_msg_s *m);
25 void bfa_isr_unhandled(struct bfa_s *bfa, struct bfi_msg_s *m);
26 void bfa_isr_bind(enum bfi_mclass mc, bfa_isr_func_t isr_func);
27
28
29 #define bfa_reqq_pi(__bfa, __reqq)      ((__bfa)->iocfc.req_cq_pi[__reqq])
30 #define bfa_reqq_ci(__bfa, __reqq)                                      \
31         (*(u32 *)((__bfa)->iocfc.req_cq_shadow_ci[__reqq].kva))
32
33 #define bfa_reqq_full(__bfa, __reqq)                            \
34         (((bfa_reqq_pi(__bfa, __reqq) + 1) &                    \
35           ((__bfa)->iocfc.cfg.drvcfg.num_reqq_elems - 1)) ==    \
36          bfa_reqq_ci(__bfa, __reqq))
37
38 #define bfa_reqq_next(__bfa, __reqq)                            \
39         (bfa_reqq_full(__bfa, __reqq) ? NULL :                  \
40          ((void *)((struct bfi_msg_s *)((__bfa)->iocfc.req_cq_ba[__reqq].kva) \
41                           + bfa_reqq_pi((__bfa), (__reqq)))))
42
43 #define bfa_reqq_produce(__bfa, __reqq) do {                            \
44         (__bfa)->iocfc.req_cq_pi[__reqq]++;                             \
45         (__bfa)->iocfc.req_cq_pi[__reqq] &=                             \
46                 ((__bfa)->iocfc.cfg.drvcfg.num_reqq_elems - 1);      \
47         bfa_reg_write((__bfa)->iocfc.bfa_regs.cpe_q_pi[__reqq],         \
48                                 (__bfa)->iocfc.req_cq_pi[__reqq]);      \
49         bfa_os_mmiowb();      \
50 } while (0)
51
52 #define bfa_rspq_pi(__bfa, __rspq)                                      \
53         (*(u32 *)((__bfa)->iocfc.rsp_cq_shadow_pi[__rspq].kva))
54
55 #define bfa_rspq_ci(__bfa, __rspq)      ((__bfa)->iocfc.rsp_cq_ci[__rspq])
56 #define bfa_rspq_elem(__bfa, __rspq, __ci)                              \
57         (&((struct bfi_msg_s *)((__bfa)->iocfc.rsp_cq_ba[__rspq].kva))[__ci])
58
59 #define CQ_INCR(__index, __size) do {                                   \
60                         (__index)++;                                    \
61                         (__index) &= ((__size) - 1);      \
62 } while (0)
63
64 /**
65  * Queue element to wait for room in request queue. FIFO order is
66  * maintained when fullfilling requests.
67  */
68 struct bfa_reqq_wait_s {
69         struct list_head        qe;
70         void            (*qresume) (void *cbarg);
71         void            *cbarg;
72 };
73
74 /**
75  * Circular queue usage assignments
76  */
77 enum {
78         BFA_REQQ_IOC    = 0,    /*  all low-priority IOC msgs   */
79         BFA_REQQ_FCXP   = 0,    /*  all FCXP messages           */
80         BFA_REQQ_LPS    = 0,    /*  all lport service msgs      */
81         BFA_REQQ_PORT   = 0,    /*  all port messages           */
82         BFA_REQQ_FLASH  = 0,    /*  for flash module            */
83         BFA_REQQ_DIAG   = 0,    /*  for diag module             */
84         BFA_REQQ_RPORT  = 0,    /*  all port messages           */
85         BFA_REQQ_SBOOT  = 0,    /*  all san boot messages       */
86         BFA_REQQ_QOS_LO = 1,    /*  all low priority IO */
87         BFA_REQQ_QOS_MD = 2,    /*  all medium priority IO      */
88         BFA_REQQ_QOS_HI = 3,    /*  all high priority IO        */
89 };
90
91 static inline void
92 bfa_reqq_winit(struct bfa_reqq_wait_s *wqe, void (*qresume) (void *cbarg),
93                         void *cbarg)
94 {
95         wqe->qresume = qresume;
96         wqe->cbarg = cbarg;
97 }
98
99 #define bfa_reqq(__bfa, __reqq) (&(__bfa)->reqq_waitq[__reqq])
100
101 /**
102  * static inline void
103  * bfa_reqq_wait(struct bfa_s *bfa, int reqq, struct bfa_reqq_wait_s *wqe)
104  */
105 #define bfa_reqq_wait(__bfa, __reqq, __wqe) do {                        \
106                                                                         \
107                 struct list_head *waitq = bfa_reqq(__bfa, __reqq);      \
108                                                                         \
109                 bfa_assert(((__reqq) < BFI_IOC_MAX_CQS));      \
110                 bfa_assert((__wqe)->qresume && (__wqe)->cbarg);      \
111                                                                         \
112                 list_add_tail(&(__wqe)->qe, waitq);      \
113 } while (0)
114
115 #define bfa_reqq_wcancel(__wqe) list_del(&(__wqe)->qe)
116
117 #endif /* __BFA_INTR_PRIV_H__ */