smsc911x: Add spinlocks around registers access
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / scsi / bfa / bfa_intr_priv.h
blob5fc301cf4d1b50f08770f659b4247bd9ccfcd63f
1 /*
2 * Copyright (c) 2005-2009 Brocade Communications Systems, Inc.
3 * All rights reserved
4 * www.brocade.com
6 * Linux driver for Brocade Fibre Channel Host Bus Adapter.
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
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.
18 #ifndef __BFA_INTR_PRIV_H__
19 #define __BFA_INTR_PRIV_H__
21 /**
22 * Message handler
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);
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))
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))
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)))))
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)
52 #define bfa_rspq_pi(__bfa, __rspq) \
53 (*(u32 *)((__bfa)->iocfc.rsp_cq_shadow_pi[__rspq].kva))
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])
59 #define CQ_INCR(__index, __size) do { \
60 (__index)++; \
61 (__index) &= ((__size) - 1); \
62 } while (0)
64 /**
65 * Queue element to wait for room in request queue. FIFO order is
66 * maintained when fullfilling requests.
68 struct bfa_reqq_wait_s {
69 struct list_head qe;
70 void (*qresume) (void *cbarg);
71 void *cbarg;
74 /**
75 * Circular queue usage assignments
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 */
91 static inline void
92 bfa_reqq_winit(struct bfa_reqq_wait_s *wqe, void (*qresume) (void *cbarg),
93 void *cbarg)
95 wqe->qresume = qresume;
96 wqe->cbarg = cbarg;
99 #define bfa_reqq(__bfa, __reqq) (&(__bfa)->reqq_waitq[__reqq])
102 * static inline void
103 * bfa_reqq_wait(struct bfa_s *bfa, int reqq, struct bfa_reqq_wait_s *wqe)
105 #define bfa_reqq_wait(__bfa, __reqq, __wqe) do { \
107 struct list_head *waitq = bfa_reqq(__bfa, __reqq); \
109 bfa_assert(((__reqq) < BFI_IOC_MAX_CQS)); \
110 bfa_assert((__wqe)->qresume && (__wqe)->cbarg); \
112 list_add_tail(&(__wqe)->qe, waitq); \
113 } while (0)
115 #define bfa_reqq_wcancel(__wqe) list_del(&(__wqe)->qe)
117 #endif /* __BFA_INTR_PRIV_H__ */