2 * Copyright (c) 2005-2009 Brocade Communications Systems, Inc.
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__
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]); \
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)
63 * Queue element to wait for room in request queue. FIFO order is
64 * maintained when fullfilling requests.
66 struct bfa_reqq_wait_s
{
68 void (*qresume
) (void *cbarg
);
73 * Circular queue usage assignments
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 */
90 bfa_reqq_winit(struct bfa_reqq_wait_s
*wqe
, void (*qresume
) (void *cbarg
),
93 wqe
->qresume
= qresume
;
97 #define bfa_reqq(__bfa, __reqq) &(__bfa)->reqq_waitq[__reqq]
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); \
113 #define bfa_reqq_wcancel(__wqe) list_del(&(__wqe)->qe)
115 #endif /* __BFA_INTR_PRIV_H__ */