mac80211: fix reorder buffer release
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / scsi / bfa / bfa_intr_priv.h
blob8ce6e6b105c8e726db0e1278b2d2e40630852753
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) \
60 (__index)++; (__index) &= ((__size) - 1)
62 /**
63 * Queue element to wait for room in request queue. FIFO order is
64 * maintained when fullfilling requests.
66 struct bfa_reqq_wait_s {
67 struct list_head qe;
68 void (*qresume) (void *cbarg);
69 void *cbarg;
72 /**
73 * Circular queue usage assignments
75 enum {
76 BFA_REQQ_IOC = 0, /* all low-priority IOC msgs */
77 BFA_REQQ_FCXP = 0, /* all FCXP messages */
78 BFA_REQQ_LPS = 0, /* all lport service msgs */
79 BFA_REQQ_PORT = 0, /* all port messages */
80 BFA_REQQ_FLASH = 0, /* for flash module */
81 BFA_REQQ_DIAG = 0, /* for diag module */
82 BFA_REQQ_RPORT = 0, /* all port messages */
83 BFA_REQQ_SBOOT = 0, /* all san boot messages */
84 BFA_REQQ_QOS_LO = 1, /* all low priority IO */
85 BFA_REQQ_QOS_MD = 2, /* all medium priority IO */
86 BFA_REQQ_QOS_HI = 3, /* all high priority IO */
89 static inline void
90 bfa_reqq_winit(struct bfa_reqq_wait_s *wqe, void (*qresume) (void *cbarg),
91 void *cbarg)
93 wqe->qresume = qresume;
94 wqe->cbarg = cbarg;
97 #define bfa_reqq(__bfa, __reqq) &(__bfa)->reqq_waitq[__reqq]
99 /**
100 * static inline void
101 * bfa_reqq_wait(struct bfa_s *bfa, int reqq, struct bfa_reqq_wait_s *wqe)
103 #define bfa_reqq_wait(__bfa, __reqq, __wqe) do { \
105 struct list_head *waitq = bfa_reqq(__bfa, __reqq); \
107 bfa_assert(((__reqq) < BFI_IOC_MAX_CQS)); \
108 bfa_assert((__wqe)->qresume && (__wqe)->cbarg); \
110 list_add_tail(&(__wqe)->qe, waitq); \
111 } while (0)
113 #define bfa_reqq_wcancel(__wqe) list_del(&(__wqe)->qe)
115 #endif /* __BFA_INTR_PRIV_H__ */