blob: 4ef3cf2e7d985f3c6ee3c255fdffc26ab52e81da [file] [log] [blame]
Jing Huang7725ccf2009-09-23 17:46:15 -07001/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07002 * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
Jing Huang7725ccf2009-09-23 17:46:15 -07003 * 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
Maggie Zhangf16a1752010-12-09 19:12:32 -080018#include "bfad_drv.h"
Krishna Gudipatia36c61f2010-09-15 11:50:55 -070019#include "bfa_modules.h"
Krishna Gudipati11189202011-06-13 15:50:35 -070020#include "bfi_reg.h"
Jing Huang7725ccf2009-09-23 17:46:15 -070021
22void
23bfa_hwcb_reginit(struct bfa_s *bfa)
24{
25 struct bfa_iocfc_regs_s *bfa_regs = &bfa->iocfc.bfa_regs;
Jing Huang53440262010-10-18 17:12:29 -070026 void __iomem *kva = bfa_ioc_bar0(&bfa->ioc);
Krishna Gudipati11189202011-06-13 15:50:35 -070027 int fn = bfa_ioc_pcifn(&bfa->ioc);
Jing Huang7725ccf2009-09-23 17:46:15 -070028
29 if (fn == 0) {
30 bfa_regs->intr_status = (kva + HOSTFN0_INT_STATUS);
31 bfa_regs->intr_mask = (kva + HOSTFN0_INT_MSK);
32 } else {
33 bfa_regs->intr_status = (kva + HOSTFN1_INT_STATUS);
34 bfa_regs->intr_mask = (kva + HOSTFN1_INT_MSK);
35 }
Jing Huang7725ccf2009-09-23 17:46:15 -070036}
37
38void
Krishna Gudipatif5713c52010-03-05 19:37:09 -080039bfa_hwcb_reqq_ack(struct bfa_s *bfa, int reqq)
40{
41}
42
43static void
44bfa_hwcb_reqq_ack_msix(struct bfa_s *bfa, int reqq)
45{
Jing Huang53440262010-10-18 17:12:29 -070046 writel(__HFN_INT_CPE_Q0 << CPE_Q_NUM(bfa_ioc_pcifn(&bfa->ioc), reqq),
47 bfa->iocfc.bfa_regs.intr_status);
Krishna Gudipatif5713c52010-03-05 19:37:09 -080048}
49
50void
Jing Huang7725ccf2009-09-23 17:46:15 -070051bfa_hwcb_rspq_ack(struct bfa_s *bfa, int rspq)
52{
53}
54
55static void
56bfa_hwcb_rspq_ack_msix(struct bfa_s *bfa, int rspq)
57{
Jing Huang53440262010-10-18 17:12:29 -070058 writel(__HFN_INT_RME_Q0 << RME_Q_NUM(bfa_ioc_pcifn(&bfa->ioc), rspq),
59 bfa->iocfc.bfa_regs.intr_status);
Jing Huang7725ccf2009-09-23 17:46:15 -070060}
61
62void
63bfa_hwcb_msix_getvecs(struct bfa_s *bfa, u32 *msix_vecs_bmap,
64 u32 *num_vecs, u32 *max_vec_bit)
65{
66#define __HFN_NUMINTS 13
67 if (bfa_ioc_pcifn(&bfa->ioc) == 0) {
68 *msix_vecs_bmap = (__HFN_INT_CPE_Q0 | __HFN_INT_CPE_Q1 |
69 __HFN_INT_CPE_Q2 | __HFN_INT_CPE_Q3 |
70 __HFN_INT_RME_Q0 | __HFN_INT_RME_Q1 |
71 __HFN_INT_RME_Q2 | __HFN_INT_RME_Q3 |
72 __HFN_INT_MBOX_LPU0);
73 *max_vec_bit = __HFN_INT_MBOX_LPU0;
74 } else {
75 *msix_vecs_bmap = (__HFN_INT_CPE_Q4 | __HFN_INT_CPE_Q5 |
76 __HFN_INT_CPE_Q6 | __HFN_INT_CPE_Q7 |
77 __HFN_INT_RME_Q4 | __HFN_INT_RME_Q5 |
78 __HFN_INT_RME_Q6 | __HFN_INT_RME_Q7 |
79 __HFN_INT_MBOX_LPU1);
80 *max_vec_bit = __HFN_INT_MBOX_LPU1;
81 }
82
83 *msix_vecs_bmap |= (__HFN_INT_ERR_EMC | __HFN_INT_ERR_LPU0 |
84 __HFN_INT_ERR_LPU1 | __HFN_INT_ERR_PSS);
85 *num_vecs = __HFN_NUMINTS;
86}
87
Jing Huang5fbe25c2010-10-18 17:17:23 -070088/*
Jing Huang7725ccf2009-09-23 17:46:15 -070089 * No special setup required for crossbow -- vector assignments are implicit.
90 */
91void
92bfa_hwcb_msix_init(struct bfa_s *bfa, int nvecs)
93{
94 int i;
95
Jing Huangd4b671c2010-12-26 21:46:35 -080096 WARN_ON((nvecs != 1) && (nvecs != __HFN_NUMINTS));
Jing Huang7725ccf2009-09-23 17:46:15 -070097
98 bfa->msix.nvecs = nvecs;
99 if (nvecs == 1) {
Krishna Gudipati11189202011-06-13 15:50:35 -0700100 for (i = 0; i < BFI_MSIX_CB_MAX; i++)
Jing Huang7725ccf2009-09-23 17:46:15 -0700101 bfa->msix.handler[i] = bfa_msix_all;
102 return;
103 }
104
Krishna Gudipati11189202011-06-13 15:50:35 -0700105 for (i = BFI_MSIX_CPE_QMIN_CB; i <= BFI_MSIX_CPE_QMAX_CB; i++)
Jing Huang7725ccf2009-09-23 17:46:15 -0700106 bfa->msix.handler[i] = bfa_msix_reqq;
107
Krishna Gudipati11189202011-06-13 15:50:35 -0700108 for (i = BFI_MSIX_RME_QMIN_CB; i <= BFI_MSIX_RME_QMAX_CB; i++)
Jing Huang7725ccf2009-09-23 17:46:15 -0700109 bfa->msix.handler[i] = bfa_msix_rspq;
110
Krishna Gudipati11189202011-06-13 15:50:35 -0700111 for (; i < BFI_MSIX_CB_MAX; i++)
Jing Huang7725ccf2009-09-23 17:46:15 -0700112 bfa->msix.handler[i] = bfa_msix_lpu_err;
113}
114
Jing Huang5fbe25c2010-10-18 17:17:23 -0700115/*
Jing Huang7725ccf2009-09-23 17:46:15 -0700116 * Crossbow -- dummy, interrupts are masked
117 */
118void
119bfa_hwcb_msix_install(struct bfa_s *bfa)
120{
121}
122
123void
124bfa_hwcb_msix_uninstall(struct bfa_s *bfa)
125{
126}
127
Jing Huang5fbe25c2010-10-18 17:17:23 -0700128/*
Jing Huang7725ccf2009-09-23 17:46:15 -0700129 * No special enable/disable -- vector assignments are implicit.
130 */
131void
132bfa_hwcb_isr_mode_set(struct bfa_s *bfa, bfa_boolean_t msix)
133{
Krishna Gudipatif5713c52010-03-05 19:37:09 -0800134 bfa->iocfc.hwif.hw_reqq_ack = bfa_hwcb_reqq_ack_msix;
Jing Huang7725ccf2009-09-23 17:46:15 -0700135 bfa->iocfc.hwif.hw_rspq_ack = bfa_hwcb_rspq_ack_msix;
136}
137
Jing Huang36d345a2010-07-08 19:57:33 -0700138void
139bfa_hwcb_msix_get_rme_range(struct bfa_s *bfa, u32 *start, u32 *end)
140{
Krishna Gudipati11189202011-06-13 15:50:35 -0700141 *start = BFI_MSIX_RME_QMIN_CB;
142 *end = BFI_MSIX_RME_QMAX_CB;
Jing Huang36d345a2010-07-08 19:57:33 -0700143}