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 #include <bfi/bfi_cbreg.h>
19 #include <bfa_port_priv.h>
20 #include <bfa_intr_priv.h>
21 #include <cs/bfa_debug.h>
23 BFA_TRC_FILE(HAL
, INTR
);
26 bfa_msix_errint(struct bfa_s
*bfa
, u32 intr
)
28 bfa_ioc_error_isr(&bfa
->ioc
);
32 bfa_msix_lpu(struct bfa_s
*bfa
)
34 bfa_ioc_mbox_isr(&bfa
->ioc
);
38 bfa_msix_all(struct bfa_s
*bfa
, int vec
)
47 bfa_intx(struct bfa_s
*bfa
)
52 intr
= bfa_reg_read(bfa
->iocfc
.bfa_regs
.intr_status
);
57 * RME completion queue interrupt
59 qintr
= intr
& __HFN_INT_RME_MASK
;
60 bfa_reg_write(bfa
->iocfc
.bfa_regs
.intr_status
, qintr
);
62 for (queue
= 0; queue
< BFI_IOC_MAX_CQS_ASIC
; queue
++) {
63 if (intr
& (__HFN_INT_RME_Q0
<< queue
))
64 bfa_msix_rspq(bfa
, queue
& (BFI_IOC_MAX_CQS
- 1));
71 * CPE completion queue interrupt
73 qintr
= intr
& __HFN_INT_CPE_MASK
;
74 bfa_reg_write(bfa
->iocfc
.bfa_regs
.intr_status
, qintr
);
76 for (queue
= 0; queue
< BFI_IOC_MAX_CQS_ASIC
; queue
++) {
77 if (intr
& (__HFN_INT_CPE_Q0
<< queue
))
78 bfa_msix_reqq(bfa
, queue
& (BFI_IOC_MAX_CQS
- 1));
84 bfa_msix_lpu_err(bfa
, intr
);
90 bfa_isr_enable(struct bfa_s
*bfa
)
93 int pci_func
= bfa_ioc_pcifn(&bfa
->ioc
);
95 bfa_trc(bfa
, pci_func
);
97 bfa_msix_install(bfa
);
98 intr_unmask
= (__HFN_INT_ERR_EMC
| __HFN_INT_ERR_LPU0
|
99 __HFN_INT_ERR_LPU1
| __HFN_INT_ERR_PSS
);
102 intr_unmask
|= (__HFN_INT_CPE_Q0
| __HFN_INT_CPE_Q1
|
103 __HFN_INT_CPE_Q2
| __HFN_INT_CPE_Q3
|
104 __HFN_INT_RME_Q0
| __HFN_INT_RME_Q1
|
105 __HFN_INT_RME_Q2
| __HFN_INT_RME_Q3
|
106 __HFN_INT_MBOX_LPU0
);
108 intr_unmask
|= (__HFN_INT_CPE_Q4
| __HFN_INT_CPE_Q5
|
109 __HFN_INT_CPE_Q6
| __HFN_INT_CPE_Q7
|
110 __HFN_INT_RME_Q4
| __HFN_INT_RME_Q5
|
111 __HFN_INT_RME_Q6
| __HFN_INT_RME_Q7
|
112 __HFN_INT_MBOX_LPU1
);
114 bfa_reg_write(bfa
->iocfc
.bfa_regs
.intr_status
, intr_unmask
);
115 bfa_reg_write(bfa
->iocfc
.bfa_regs
.intr_mask
, ~intr_unmask
);
116 bfa_isr_mode_set(bfa
, bfa
->msix
.nvecs
!= 0);
120 bfa_isr_disable(struct bfa_s
*bfa
)
122 bfa_isr_mode_set(bfa
, BFA_FALSE
);
123 bfa_reg_write(bfa
->iocfc
.bfa_regs
.intr_mask
, -1L);
124 bfa_msix_uninstall(bfa
);
128 bfa_msix_reqq(struct bfa_s
*bfa
, int qid
)
130 struct list_head
*waitq
, *qe
, *qen
;
131 struct bfa_reqq_wait_s
*wqe
;
133 qid
&= (BFI_IOC_MAX_CQS
- 1);
135 waitq
= bfa_reqq(bfa
, qid
);
136 list_for_each_safe(qe
, qen
, waitq
) {
138 * Callback only as long as there is room in request queue
140 if (bfa_reqq_full(bfa
, qid
))
144 wqe
= (struct bfa_reqq_wait_s
*) qe
;
145 wqe
->qresume(wqe
->cbarg
);
150 bfa_isr_unhandled(struct bfa_s
*bfa
, struct bfi_msg_s
*m
)
152 bfa_trc(bfa
, m
->mhdr
.msg_class
);
153 bfa_trc(bfa
, m
->mhdr
.msg_id
);
154 bfa_trc(bfa
, m
->mhdr
.mtag
.i2htok
);
156 bfa_trc_stop(bfa
->trcmod
);
160 bfa_msix_rspq(struct bfa_s
*bfa
, int rsp_qid
)
165 bfa_trc_fp(bfa
, rsp_qid
);
167 rsp_qid
&= (BFI_IOC_MAX_CQS
- 1);
169 bfa
->iocfc
.hwif
.hw_rspq_ack(bfa
, rsp_qid
);
171 ci
= bfa_rspq_ci(bfa
, rsp_qid
);
172 pi
= bfa_rspq_pi(bfa
, rsp_qid
);
177 if (bfa
->rme_process
) {
179 m
= bfa_rspq_elem(bfa
, rsp_qid
, ci
);
180 bfa_assert_fp(m
->mhdr
.msg_class
< BFI_MC_MAX
);
182 bfa_isrs
[m
->mhdr
.msg_class
] (bfa
, m
);
184 CQ_INCR(ci
, bfa
->iocfc
.cfg
.drvcfg
.num_rspq_elems
);
191 bfa_rspq_ci(bfa
, rsp_qid
) = pi
;
192 bfa_reg_write(bfa
->iocfc
.bfa_regs
.rme_q_ci
[rsp_qid
], pi
);
197 bfa_msix_lpu_err(struct bfa_s
*bfa
, int vec
)
201 intr
= bfa_reg_read(bfa
->iocfc
.bfa_regs
.intr_status
);
203 if (intr
& (__HFN_INT_MBOX_LPU0
| __HFN_INT_MBOX_LPU1
))
206 if (intr
& (__HFN_INT_ERR_EMC
|
207 __HFN_INT_ERR_LPU0
| __HFN_INT_ERR_LPU1
|
209 bfa_msix_errint(bfa
, intr
);
213 bfa_isr_bind(enum bfi_mclass mc
, bfa_isr_func_t isr_func
)
215 bfa_isrs
[mc
] = isr_func
;