Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 2 | * Copyright (c) 2005-2010 Brocade Communications Systems, Inc. |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 3 | * 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 Zhang | f16a175 | 2010-12-09 19:12:32 -0800 | [diff] [blame] | 18 | #include "bfad_drv.h" |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 19 | #include "bfa_modules.h" |
Krishna Gudipati | 1118920 | 2011-06-13 15:50:35 -0700 | [diff] [blame] | 20 | #include "bfi_reg.h" |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 21 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 22 | BFA_TRC_FILE(HAL, CORE); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 23 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 24 | /* |
Maggie Zhang | b77ee1f | 2010-12-09 19:09:26 -0800 | [diff] [blame] | 25 | * BFA module list terminated by NULL |
| 26 | */ |
| 27 | static struct bfa_module_s *hal_mods[] = { |
| 28 | &hal_mod_sgpg, |
| 29 | &hal_mod_fcport, |
| 30 | &hal_mod_fcxp, |
| 31 | &hal_mod_lps, |
| 32 | &hal_mod_uf, |
| 33 | &hal_mod_rport, |
Krishna Gudipati | e2187d7 | 2011-06-13 15:53:58 -0700 | [diff] [blame] | 34 | &hal_mod_fcp, |
Maggie Zhang | b77ee1f | 2010-12-09 19:09:26 -0800 | [diff] [blame] | 35 | NULL |
| 36 | }; |
| 37 | |
| 38 | /* |
| 39 | * Message handlers for various modules. |
| 40 | */ |
| 41 | static bfa_isr_func_t bfa_isrs[BFI_MC_MAX] = { |
| 42 | bfa_isr_unhandled, /* NONE */ |
| 43 | bfa_isr_unhandled, /* BFI_MC_IOC */ |
| 44 | bfa_isr_unhandled, /* BFI_MC_DIAG */ |
| 45 | bfa_isr_unhandled, /* BFI_MC_FLASH */ |
| 46 | bfa_isr_unhandled, /* BFI_MC_CEE */ |
| 47 | bfa_fcport_isr, /* BFI_MC_FCPORT */ |
| 48 | bfa_isr_unhandled, /* BFI_MC_IOCFC */ |
| 49 | bfa_isr_unhandled, /* BFI_MC_LL */ |
| 50 | bfa_uf_isr, /* BFI_MC_UF */ |
| 51 | bfa_fcxp_isr, /* BFI_MC_FCXP */ |
| 52 | bfa_lps_isr, /* BFI_MC_LPS */ |
| 53 | bfa_rport_isr, /* BFI_MC_RPORT */ |
Krishna Gudipati | e2187d7 | 2011-06-13 15:53:58 -0700 | [diff] [blame] | 54 | bfa_itn_isr, /* BFI_MC_ITN */ |
Maggie Zhang | b77ee1f | 2010-12-09 19:09:26 -0800 | [diff] [blame] | 55 | bfa_isr_unhandled, /* BFI_MC_IOIM_READ */ |
| 56 | bfa_isr_unhandled, /* BFI_MC_IOIM_WRITE */ |
| 57 | bfa_isr_unhandled, /* BFI_MC_IOIM_IO */ |
| 58 | bfa_ioim_isr, /* BFI_MC_IOIM */ |
| 59 | bfa_ioim_good_comp_isr, /* BFI_MC_IOIM_IOCOM */ |
| 60 | bfa_tskim_isr, /* BFI_MC_TSKIM */ |
| 61 | bfa_isr_unhandled, /* BFI_MC_SBOOT */ |
| 62 | bfa_isr_unhandled, /* BFI_MC_IPFC */ |
| 63 | bfa_isr_unhandled, /* BFI_MC_PORT */ |
| 64 | bfa_isr_unhandled, /* --------- */ |
| 65 | bfa_isr_unhandled, /* --------- */ |
| 66 | bfa_isr_unhandled, /* --------- */ |
| 67 | bfa_isr_unhandled, /* --------- */ |
| 68 | bfa_isr_unhandled, /* --------- */ |
| 69 | bfa_isr_unhandled, /* --------- */ |
| 70 | bfa_isr_unhandled, /* --------- */ |
| 71 | bfa_isr_unhandled, /* --------- */ |
| 72 | bfa_isr_unhandled, /* --------- */ |
| 73 | bfa_isr_unhandled, /* --------- */ |
| 74 | }; |
| 75 | /* |
| 76 | * Message handlers for mailbox command classes |
| 77 | */ |
| 78 | static bfa_ioc_mbox_mcfunc_t bfa_mbox_isrs[BFI_MC_MAX] = { |
| 79 | NULL, |
| 80 | NULL, /* BFI_MC_IOC */ |
| 81 | NULL, /* BFI_MC_DIAG */ |
| 82 | NULL, /* BFI_MC_FLASH */ |
| 83 | NULL, /* BFI_MC_CEE */ |
| 84 | NULL, /* BFI_MC_PORT */ |
| 85 | bfa_iocfc_isr, /* BFI_MC_IOCFC */ |
| 86 | NULL, |
| 87 | }; |
| 88 | |
| 89 | |
| 90 | |
| 91 | static void |
Krishna Gudipati | 4507025 | 2011-06-24 20:24:29 -0700 | [diff] [blame^] | 92 | bfa_com_port_attach(struct bfa_s *bfa) |
Maggie Zhang | b77ee1f | 2010-12-09 19:09:26 -0800 | [diff] [blame] | 93 | { |
| 94 | struct bfa_port_s *port = &bfa->modules.port; |
Krishna Gudipati | 4507025 | 2011-06-24 20:24:29 -0700 | [diff] [blame^] | 95 | struct bfa_mem_dma_s *port_dma = BFA_MEM_PORT_DMA(bfa); |
Maggie Zhang | b77ee1f | 2010-12-09 19:09:26 -0800 | [diff] [blame] | 96 | |
Maggie Zhang | b77ee1f | 2010-12-09 19:09:26 -0800 | [diff] [blame] | 97 | bfa_port_attach(port, &bfa->ioc, bfa, bfa->trcmod); |
Krishna Gudipati | 4507025 | 2011-06-24 20:24:29 -0700 | [diff] [blame^] | 98 | bfa_port_mem_claim(port, port_dma->kva_curp, port_dma->dma_curp); |
Maggie Zhang | b77ee1f | 2010-12-09 19:09:26 -0800 | [diff] [blame] | 99 | } |
| 100 | |
| 101 | /* |
Krishna Gudipati | 1a4d8e1 | 2011-06-24 20:22:28 -0700 | [diff] [blame] | 102 | * ablk module attach |
| 103 | */ |
| 104 | static void |
Krishna Gudipati | 4507025 | 2011-06-24 20:24:29 -0700 | [diff] [blame^] | 105 | bfa_com_ablk_attach(struct bfa_s *bfa) |
Krishna Gudipati | 1a4d8e1 | 2011-06-24 20:22:28 -0700 | [diff] [blame] | 106 | { |
| 107 | struct bfa_ablk_s *ablk = &bfa->modules.ablk; |
Krishna Gudipati | 4507025 | 2011-06-24 20:24:29 -0700 | [diff] [blame^] | 108 | struct bfa_mem_dma_s *ablk_dma = BFA_MEM_ABLK_DMA(bfa); |
Krishna Gudipati | 1a4d8e1 | 2011-06-24 20:22:28 -0700 | [diff] [blame] | 109 | |
Krishna Gudipati | 1a4d8e1 | 2011-06-24 20:22:28 -0700 | [diff] [blame] | 110 | bfa_ablk_attach(ablk, &bfa->ioc); |
Krishna Gudipati | 4507025 | 2011-06-24 20:24:29 -0700 | [diff] [blame^] | 111 | bfa_ablk_memclaim(ablk, ablk_dma->kva_curp, ablk_dma->dma_curp); |
Krishna Gudipati | 1a4d8e1 | 2011-06-24 20:22:28 -0700 | [diff] [blame] | 112 | } |
| 113 | |
| 114 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 115 | * BFA IOC FC related definitions |
| 116 | */ |
| 117 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 118 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 119 | * IOC local definitions |
| 120 | */ |
| 121 | #define BFA_IOCFC_TOV 5000 /* msecs */ |
| 122 | |
| 123 | enum { |
| 124 | BFA_IOCFC_ACT_NONE = 0, |
| 125 | BFA_IOCFC_ACT_INIT = 1, |
| 126 | BFA_IOCFC_ACT_STOP = 2, |
| 127 | BFA_IOCFC_ACT_DISABLE = 3, |
| 128 | }; |
| 129 | |
| 130 | #define DEF_CFG_NUM_FABRICS 1 |
| 131 | #define DEF_CFG_NUM_LPORTS 256 |
| 132 | #define DEF_CFG_NUM_CQS 4 |
| 133 | #define DEF_CFG_NUM_IOIM_REQS (BFA_IOIM_MAX) |
| 134 | #define DEF_CFG_NUM_TSKIM_REQS 128 |
| 135 | #define DEF_CFG_NUM_FCXP_REQS 64 |
| 136 | #define DEF_CFG_NUM_UF_BUFS 64 |
| 137 | #define DEF_CFG_NUM_RPORTS 1024 |
| 138 | #define DEF_CFG_NUM_ITNIMS (DEF_CFG_NUM_RPORTS) |
| 139 | #define DEF_CFG_NUM_TINS 256 |
| 140 | |
| 141 | #define DEF_CFG_NUM_SGPGS 2048 |
| 142 | #define DEF_CFG_NUM_REQQ_ELEMS 256 |
| 143 | #define DEF_CFG_NUM_RSPQ_ELEMS 64 |
| 144 | #define DEF_CFG_NUM_SBOOT_TGTS 16 |
| 145 | #define DEF_CFG_NUM_SBOOT_LUNS 16 |
| 146 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 147 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 148 | * forward declaration for IOC FC functions |
| 149 | */ |
| 150 | static void bfa_iocfc_enable_cbfn(void *bfa_arg, enum bfa_status status); |
| 151 | static void bfa_iocfc_disable_cbfn(void *bfa_arg); |
| 152 | static void bfa_iocfc_hbfail_cbfn(void *bfa_arg); |
| 153 | static void bfa_iocfc_reset_cbfn(void *bfa_arg); |
| 154 | static struct bfa_ioc_cbfn_s bfa_iocfc_cbfn; |
| 155 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 156 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 157 | * BFA Interrupt handling functions |
| 158 | */ |
| 159 | static void |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 160 | bfa_reqq_resume(struct bfa_s *bfa, int qid) |
| 161 | { |
| 162 | struct list_head *waitq, *qe, *qen; |
| 163 | struct bfa_reqq_wait_s *wqe; |
| 164 | |
| 165 | waitq = bfa_reqq(bfa, qid); |
| 166 | list_for_each_safe(qe, qen, waitq) { |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 167 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 168 | * Callback only as long as there is room in request queue |
| 169 | */ |
| 170 | if (bfa_reqq_full(bfa, qid)) |
| 171 | break; |
| 172 | |
| 173 | list_del(qe); |
| 174 | wqe = (struct bfa_reqq_wait_s *) qe; |
| 175 | wqe->qresume(wqe->cbarg); |
| 176 | } |
| 177 | } |
| 178 | |
Krishna Gudipati | 1118920 | 2011-06-13 15:50:35 -0700 | [diff] [blame] | 179 | static inline void |
| 180 | bfa_isr_rspq(struct bfa_s *bfa, int qid) |
| 181 | { |
| 182 | struct bfi_msg_s *m; |
| 183 | u32 pi, ci; |
| 184 | struct list_head *waitq; |
| 185 | |
Krishna Gudipati | 3fd4598 | 2011-06-24 20:24:08 -0700 | [diff] [blame] | 186 | bfa_isr_rspq_ack(bfa, qid); |
Krishna Gudipati | 1118920 | 2011-06-13 15:50:35 -0700 | [diff] [blame] | 187 | |
| 188 | ci = bfa_rspq_ci(bfa, qid); |
| 189 | pi = bfa_rspq_pi(bfa, qid); |
| 190 | |
| 191 | while (ci != pi) { |
| 192 | m = bfa_rspq_elem(bfa, qid, ci); |
| 193 | WARN_ON(m->mhdr.msg_class >= BFI_MC_MAX); |
| 194 | |
| 195 | bfa_isrs[m->mhdr.msg_class] (bfa, m); |
| 196 | CQ_INCR(ci, bfa->iocfc.cfg.drvcfg.num_rspq_elems); |
| 197 | } |
| 198 | |
| 199 | /* |
| 200 | * update CI |
| 201 | */ |
| 202 | bfa_rspq_ci(bfa, qid) = pi; |
| 203 | writel(pi, bfa->iocfc.bfa_regs.rme_q_ci[qid]); |
| 204 | mmiowb(); |
| 205 | |
| 206 | /* |
| 207 | * Resume any pending requests in the corresponding reqq. |
| 208 | */ |
| 209 | waitq = bfa_reqq(bfa, qid); |
| 210 | if (!list_empty(waitq)) |
| 211 | bfa_reqq_resume(bfa, qid); |
| 212 | } |
| 213 | |
| 214 | static inline void |
| 215 | bfa_isr_reqq(struct bfa_s *bfa, int qid) |
| 216 | { |
| 217 | struct list_head *waitq; |
| 218 | |
Krishna Gudipati | 3fd4598 | 2011-06-24 20:24:08 -0700 | [diff] [blame] | 219 | bfa_isr_reqq_ack(bfa, qid); |
Krishna Gudipati | 1118920 | 2011-06-13 15:50:35 -0700 | [diff] [blame] | 220 | |
| 221 | /* |
| 222 | * Resume any pending requests in the corresponding reqq. |
| 223 | */ |
| 224 | waitq = bfa_reqq(bfa, qid); |
| 225 | if (!list_empty(waitq)) |
| 226 | bfa_reqq_resume(bfa, qid); |
| 227 | } |
| 228 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 229 | void |
| 230 | bfa_msix_all(struct bfa_s *bfa, int vec) |
| 231 | { |
Krishna Gudipati | 10a0737 | 2011-06-24 20:23:38 -0700 | [diff] [blame] | 232 | u32 intr, qintr; |
| 233 | int queue; |
| 234 | |
| 235 | intr = readl(bfa->iocfc.bfa_regs.intr_status); |
| 236 | if (!intr) |
| 237 | return; |
| 238 | |
| 239 | /* |
| 240 | * RME completion queue interrupt |
| 241 | */ |
| 242 | qintr = intr & __HFN_INT_RME_MASK; |
| 243 | if (qintr && bfa->queue_process) { |
| 244 | for (queue = 0; queue < BFI_IOC_MAX_CQS; queue++) |
| 245 | bfa_isr_rspq(bfa, queue); |
| 246 | } |
| 247 | |
| 248 | intr &= ~qintr; |
| 249 | if (!intr) |
| 250 | return; |
| 251 | |
| 252 | /* |
| 253 | * CPE completion queue interrupt |
| 254 | */ |
| 255 | qintr = intr & __HFN_INT_CPE_MASK; |
| 256 | if (qintr && bfa->queue_process) { |
| 257 | for (queue = 0; queue < BFI_IOC_MAX_CQS; queue++) |
| 258 | bfa_isr_reqq(bfa, queue); |
| 259 | } |
| 260 | intr &= ~qintr; |
| 261 | if (!intr) |
| 262 | return; |
| 263 | |
| 264 | bfa_msix_lpu_err(bfa, intr); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 265 | } |
| 266 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 267 | bfa_boolean_t |
| 268 | bfa_intx(struct bfa_s *bfa) |
| 269 | { |
| 270 | u32 intr, qintr; |
| 271 | int queue; |
| 272 | |
Jing Huang | 5344026 | 2010-10-18 17:12:29 -0700 | [diff] [blame] | 273 | intr = readl(bfa->iocfc.bfa_regs.intr_status); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 274 | if (!intr) |
| 275 | return BFA_FALSE; |
| 276 | |
Krishna Gudipati | 3fd4598 | 2011-06-24 20:24:08 -0700 | [diff] [blame] | 277 | qintr = intr & (__HFN_INT_RME_MASK | __HFN_INT_CPE_MASK); |
| 278 | if (qintr) |
| 279 | writel(qintr, bfa->iocfc.bfa_regs.intr_status); |
| 280 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 281 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 282 | * RME completion queue interrupt |
| 283 | */ |
| 284 | qintr = intr & __HFN_INT_RME_MASK; |
Krishna Gudipati | 3fd4598 | 2011-06-24 20:24:08 -0700 | [diff] [blame] | 285 | if (qintr && bfa->queue_process) { |
| 286 | for (queue = 0; queue < BFI_IOC_MAX_CQS; queue++) |
| 287 | bfa_isr_rspq(bfa, queue); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 288 | } |
Krishna Gudipati | 3fd4598 | 2011-06-24 20:24:08 -0700 | [diff] [blame] | 289 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 290 | intr &= ~qintr; |
| 291 | if (!intr) |
| 292 | return BFA_TRUE; |
| 293 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 294 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 295 | * CPE completion queue interrupt |
| 296 | */ |
| 297 | qintr = intr & __HFN_INT_CPE_MASK; |
Krishna Gudipati | 3fd4598 | 2011-06-24 20:24:08 -0700 | [diff] [blame] | 298 | if (qintr && bfa->queue_process) { |
| 299 | for (queue = 0; queue < BFI_IOC_MAX_CQS; queue++) |
| 300 | bfa_isr_reqq(bfa, queue); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 301 | } |
| 302 | intr &= ~qintr; |
| 303 | if (!intr) |
| 304 | return BFA_TRUE; |
| 305 | |
| 306 | bfa_msix_lpu_err(bfa, intr); |
| 307 | |
| 308 | return BFA_TRUE; |
| 309 | } |
| 310 | |
| 311 | void |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 312 | bfa_isr_enable(struct bfa_s *bfa) |
| 313 | { |
Krishna Gudipati | 1118920 | 2011-06-13 15:50:35 -0700 | [diff] [blame] | 314 | u32 umsk; |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 315 | int pci_func = bfa_ioc_pcifn(&bfa->ioc); |
| 316 | |
| 317 | bfa_trc(bfa, pci_func); |
| 318 | |
Krishna Gudipati | 775c774 | 2011-06-13 15:52:12 -0700 | [diff] [blame] | 319 | bfa_msix_ctrl_install(bfa); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 320 | |
Krishna Gudipati | 1118920 | 2011-06-13 15:50:35 -0700 | [diff] [blame] | 321 | if (bfa_asic_id_ct2(bfa->ioc.pcidev.device_id)) { |
| 322 | umsk = __HFN_INT_ERR_MASK_CT2; |
| 323 | umsk |= pci_func == 0 ? |
| 324 | __HFN_INT_FN0_MASK_CT2 : __HFN_INT_FN1_MASK_CT2; |
| 325 | } else { |
| 326 | umsk = __HFN_INT_ERR_MASK; |
| 327 | umsk |= pci_func == 0 ? __HFN_INT_FN0_MASK : __HFN_INT_FN1_MASK; |
| 328 | } |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 329 | |
Krishna Gudipati | 1118920 | 2011-06-13 15:50:35 -0700 | [diff] [blame] | 330 | writel(umsk, bfa->iocfc.bfa_regs.intr_status); |
| 331 | writel(~umsk, bfa->iocfc.bfa_regs.intr_mask); |
| 332 | bfa->iocfc.intr_mask = ~umsk; |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 333 | bfa_isr_mode_set(bfa, bfa->msix.nvecs != 0); |
| 334 | } |
| 335 | |
| 336 | void |
| 337 | bfa_isr_disable(struct bfa_s *bfa) |
| 338 | { |
| 339 | bfa_isr_mode_set(bfa, BFA_FALSE); |
Jing Huang | 5344026 | 2010-10-18 17:12:29 -0700 | [diff] [blame] | 340 | writel(-1L, bfa->iocfc.bfa_regs.intr_mask); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 341 | bfa_msix_uninstall(bfa); |
| 342 | } |
| 343 | |
| 344 | void |
Krishna Gudipati | 1118920 | 2011-06-13 15:50:35 -0700 | [diff] [blame] | 345 | bfa_msix_reqq(struct bfa_s *bfa, int vec) |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 346 | { |
Krishna Gudipati | 1118920 | 2011-06-13 15:50:35 -0700 | [diff] [blame] | 347 | bfa_isr_reqq(bfa, vec - bfa->iocfc.hwif.cpe_vec_q0); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 348 | } |
| 349 | |
| 350 | void |
| 351 | bfa_isr_unhandled(struct bfa_s *bfa, struct bfi_msg_s *m) |
| 352 | { |
| 353 | bfa_trc(bfa, m->mhdr.msg_class); |
| 354 | bfa_trc(bfa, m->mhdr.msg_id); |
| 355 | bfa_trc(bfa, m->mhdr.mtag.i2htok); |
Jing Huang | d4b671c | 2010-12-26 21:46:35 -0800 | [diff] [blame] | 356 | WARN_ON(1); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 357 | bfa_trc_stop(bfa->trcmod); |
| 358 | } |
| 359 | |
| 360 | void |
Krishna Gudipati | 1118920 | 2011-06-13 15:50:35 -0700 | [diff] [blame] | 361 | bfa_msix_rspq(struct bfa_s *bfa, int vec) |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 362 | { |
Krishna Gudipati | 1118920 | 2011-06-13 15:50:35 -0700 | [diff] [blame] | 363 | bfa_isr_rspq(bfa, vec - bfa->iocfc.hwif.rme_vec_q0); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 364 | } |
| 365 | |
| 366 | void |
| 367 | bfa_msix_lpu_err(struct bfa_s *bfa, int vec) |
| 368 | { |
| 369 | u32 intr, curr_value; |
Krishna Gudipati | 1118920 | 2011-06-13 15:50:35 -0700 | [diff] [blame] | 370 | bfa_boolean_t lpu_isr, halt_isr, pss_isr; |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 371 | |
Jing Huang | 5344026 | 2010-10-18 17:12:29 -0700 | [diff] [blame] | 372 | intr = readl(bfa->iocfc.bfa_regs.intr_status); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 373 | |
Krishna Gudipati | 1118920 | 2011-06-13 15:50:35 -0700 | [diff] [blame] | 374 | if (bfa_asic_id_ct2(bfa->ioc.pcidev.device_id)) { |
| 375 | halt_isr = intr & __HFN_INT_CPQ_HALT_CT2; |
| 376 | pss_isr = intr & __HFN_INT_ERR_PSS_CT2; |
| 377 | lpu_isr = intr & (__HFN_INT_MBOX_LPU0_CT2 | |
| 378 | __HFN_INT_MBOX_LPU1_CT2); |
| 379 | intr &= __HFN_INT_ERR_MASK_CT2; |
| 380 | } else { |
| 381 | halt_isr = intr & __HFN_INT_LL_HALT; |
| 382 | pss_isr = intr & __HFN_INT_ERR_PSS; |
| 383 | lpu_isr = intr & (__HFN_INT_MBOX_LPU0 | __HFN_INT_MBOX_LPU1); |
| 384 | intr &= __HFN_INT_ERR_MASK; |
| 385 | } |
| 386 | |
| 387 | if (lpu_isr) |
Maggie Zhang | da99dcc | 2010-12-09 19:13:20 -0800 | [diff] [blame] | 388 | bfa_ioc_mbox_isr(&bfa->ioc); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 389 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 390 | if (intr) { |
Krishna Gudipati | 1118920 | 2011-06-13 15:50:35 -0700 | [diff] [blame] | 391 | if (halt_isr) { |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 392 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 393 | * If LL_HALT bit is set then FW Init Halt LL Port |
| 394 | * Register needs to be cleared as well so Interrupt |
| 395 | * Status Register will be cleared. |
| 396 | */ |
Jing Huang | 5344026 | 2010-10-18 17:12:29 -0700 | [diff] [blame] | 397 | curr_value = readl(bfa->ioc.ioc_regs.ll_halt); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 398 | curr_value &= ~__FW_INIT_HALT_P; |
Jing Huang | 5344026 | 2010-10-18 17:12:29 -0700 | [diff] [blame] | 399 | writel(curr_value, bfa->ioc.ioc_regs.ll_halt); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 400 | } |
| 401 | |
Krishna Gudipati | 1118920 | 2011-06-13 15:50:35 -0700 | [diff] [blame] | 402 | if (pss_isr) { |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 403 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 404 | * ERR_PSS bit needs to be cleared as well in case |
| 405 | * interrups are shared so driver's interrupt handler is |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 406 | * still called even though it is already masked out. |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 407 | */ |
Jing Huang | 5344026 | 2010-10-18 17:12:29 -0700 | [diff] [blame] | 408 | curr_value = readl( |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 409 | bfa->ioc.ioc_regs.pss_err_status_reg); |
Jing Huang | 5344026 | 2010-10-18 17:12:29 -0700 | [diff] [blame] | 410 | writel(curr_value, |
| 411 | bfa->ioc.ioc_regs.pss_err_status_reg); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 412 | } |
| 413 | |
Jing Huang | 5344026 | 2010-10-18 17:12:29 -0700 | [diff] [blame] | 414 | writel(intr, bfa->iocfc.bfa_regs.intr_status); |
Maggie Zhang | f7f73812 | 2010-12-09 19:08:43 -0800 | [diff] [blame] | 415 | bfa_ioc_error_isr(&bfa->ioc); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 416 | } |
| 417 | } |
| 418 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 419 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 420 | * BFA IOC FC related functions |
| 421 | */ |
| 422 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 423 | /* |
Maggie Zhang | df0f193 | 2010-12-09 19:07:46 -0800 | [diff] [blame] | 424 | * BFA IOC private functions |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 425 | */ |
| 426 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 427 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 428 | * Use the Mailbox interface to send BFI_IOCFC_H2I_CFG_REQ |
| 429 | */ |
| 430 | static void |
| 431 | bfa_iocfc_send_cfg(void *bfa_arg) |
| 432 | { |
| 433 | struct bfa_s *bfa = bfa_arg; |
| 434 | struct bfa_iocfc_s *iocfc = &bfa->iocfc; |
| 435 | struct bfi_iocfc_cfg_req_s cfg_req; |
| 436 | struct bfi_iocfc_cfg_s *cfg_info = iocfc->cfginfo; |
| 437 | struct bfa_iocfc_cfg_s *cfg = &iocfc->cfg; |
| 438 | int i; |
| 439 | |
Jing Huang | d4b671c | 2010-12-26 21:46:35 -0800 | [diff] [blame] | 440 | WARN_ON(cfg->fwcfg.num_cqs > BFI_IOC_MAX_CQS); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 441 | bfa_trc(bfa, cfg->fwcfg.num_cqs); |
| 442 | |
| 443 | bfa_iocfc_reset_queues(bfa); |
| 444 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 445 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 446 | * initialize IOC configuration info |
| 447 | */ |
Krishna Gudipati | 10a0737 | 2011-06-24 20:23:38 -0700 | [diff] [blame] | 448 | cfg_info->single_msix_vec = 0; |
| 449 | if (bfa->msix.nvecs == 1) |
| 450 | cfg_info->single_msix_vec = 1; |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 451 | cfg_info->endian_sig = BFI_IOC_ENDIAN_SIG; |
| 452 | cfg_info->num_cqs = cfg->fwcfg.num_cqs; |
Krishna Gudipati | e2187d7 | 2011-06-13 15:53:58 -0700 | [diff] [blame] | 453 | cfg_info->num_ioim_reqs = cpu_to_be16(cfg->fwcfg.num_ioim_reqs); |
| 454 | cfg_info->num_fwtio_reqs = cpu_to_be16(cfg->fwcfg.num_fwtio_reqs); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 455 | |
| 456 | bfa_dma_be_addr_set(cfg_info->cfgrsp_addr, iocfc->cfgrsp_dma.pa); |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 457 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 458 | * dma map REQ and RSP circular queues and shadow pointers |
| 459 | */ |
| 460 | for (i = 0; i < cfg->fwcfg.num_cqs; i++) { |
| 461 | bfa_dma_be_addr_set(cfg_info->req_cq_ba[i], |
| 462 | iocfc->req_cq_ba[i].pa); |
| 463 | bfa_dma_be_addr_set(cfg_info->req_shadow_ci[i], |
| 464 | iocfc->req_cq_shadow_ci[i].pa); |
| 465 | cfg_info->req_cq_elems[i] = |
Jing Huang | ba816ea | 2010-10-18 17:10:50 -0700 | [diff] [blame] | 466 | cpu_to_be16(cfg->drvcfg.num_reqq_elems); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 467 | |
| 468 | bfa_dma_be_addr_set(cfg_info->rsp_cq_ba[i], |
| 469 | iocfc->rsp_cq_ba[i].pa); |
| 470 | bfa_dma_be_addr_set(cfg_info->rsp_shadow_pi[i], |
| 471 | iocfc->rsp_cq_shadow_pi[i].pa); |
| 472 | cfg_info->rsp_cq_elems[i] = |
Jing Huang | ba816ea | 2010-10-18 17:10:50 -0700 | [diff] [blame] | 473 | cpu_to_be16(cfg->drvcfg.num_rspq_elems); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 474 | } |
| 475 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 476 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 477 | * Enable interrupt coalescing if it is driver init path |
| 478 | * and not ioc disable/enable path. |
| 479 | */ |
| 480 | if (!iocfc->cfgdone) |
| 481 | cfg_info->intr_attr.coalesce = BFA_TRUE; |
| 482 | |
| 483 | iocfc->cfgdone = BFA_FALSE; |
| 484 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 485 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 486 | * dma map IOC configuration itself |
| 487 | */ |
| 488 | bfi_h2i_set(cfg_req.mh, BFI_MC_IOCFC, BFI_IOCFC_H2I_CFG_REQ, |
Krishna Gudipati | 3fd4598 | 2011-06-24 20:24:08 -0700 | [diff] [blame] | 489 | bfa_fn_lpu(bfa)); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 490 | bfa_dma_be_addr_set(cfg_req.ioc_cfg_dma_addr, iocfc->cfg_info.pa); |
| 491 | |
| 492 | bfa_ioc_mbox_send(&bfa->ioc, &cfg_req, |
| 493 | sizeof(struct bfi_iocfc_cfg_req_s)); |
| 494 | } |
| 495 | |
| 496 | static void |
| 497 | bfa_iocfc_init_mem(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg, |
| 498 | struct bfa_pcidev_s *pcidev) |
| 499 | { |
| 500 | struct bfa_iocfc_s *iocfc = &bfa->iocfc; |
| 501 | |
| 502 | bfa->bfad = bfad; |
| 503 | iocfc->bfa = bfa; |
| 504 | iocfc->action = BFA_IOCFC_ACT_NONE; |
| 505 | |
Jing Huang | 6a18b16 | 2010-10-18 17:08:54 -0700 | [diff] [blame] | 506 | iocfc->cfg = *cfg; |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 507 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 508 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 509 | * Initialize chip specific handlers. |
| 510 | */ |
Krishna Gudipati | 1118920 | 2011-06-13 15:50:35 -0700 | [diff] [blame] | 511 | if (bfa_asic_id_ctc(bfa_ioc_devid(&bfa->ioc))) { |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 512 | iocfc->hwif.hw_reginit = bfa_hwct_reginit; |
| 513 | iocfc->hwif.hw_reqq_ack = bfa_hwct_reqq_ack; |
| 514 | iocfc->hwif.hw_rspq_ack = bfa_hwct_rspq_ack; |
| 515 | iocfc->hwif.hw_msix_init = bfa_hwct_msix_init; |
Krishna Gudipati | 775c774 | 2011-06-13 15:52:12 -0700 | [diff] [blame] | 516 | iocfc->hwif.hw_msix_ctrl_install = bfa_hwct_msix_ctrl_install; |
| 517 | iocfc->hwif.hw_msix_queue_install = bfa_hwct_msix_queue_install; |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 518 | iocfc->hwif.hw_msix_uninstall = bfa_hwct_msix_uninstall; |
| 519 | iocfc->hwif.hw_isr_mode_set = bfa_hwct_isr_mode_set; |
| 520 | iocfc->hwif.hw_msix_getvecs = bfa_hwct_msix_getvecs; |
| 521 | iocfc->hwif.hw_msix_get_rme_range = bfa_hwct_msix_get_rme_range; |
Krishna Gudipati | 1118920 | 2011-06-13 15:50:35 -0700 | [diff] [blame] | 522 | iocfc->hwif.rme_vec_q0 = BFI_MSIX_RME_QMIN_CT; |
| 523 | iocfc->hwif.cpe_vec_q0 = BFI_MSIX_CPE_QMIN_CT; |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 524 | } else { |
| 525 | iocfc->hwif.hw_reginit = bfa_hwcb_reginit; |
Krishna Gudipati | 3fd4598 | 2011-06-24 20:24:08 -0700 | [diff] [blame] | 526 | iocfc->hwif.hw_reqq_ack = NULL; |
| 527 | iocfc->hwif.hw_rspq_ack = NULL; |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 528 | iocfc->hwif.hw_msix_init = bfa_hwcb_msix_init; |
Krishna Gudipati | 775c774 | 2011-06-13 15:52:12 -0700 | [diff] [blame] | 529 | iocfc->hwif.hw_msix_ctrl_install = bfa_hwcb_msix_ctrl_install; |
| 530 | iocfc->hwif.hw_msix_queue_install = bfa_hwcb_msix_queue_install; |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 531 | iocfc->hwif.hw_msix_uninstall = bfa_hwcb_msix_uninstall; |
| 532 | iocfc->hwif.hw_isr_mode_set = bfa_hwcb_isr_mode_set; |
| 533 | iocfc->hwif.hw_msix_getvecs = bfa_hwcb_msix_getvecs; |
| 534 | iocfc->hwif.hw_msix_get_rme_range = bfa_hwcb_msix_get_rme_range; |
Krishna Gudipati | 1118920 | 2011-06-13 15:50:35 -0700 | [diff] [blame] | 535 | iocfc->hwif.rme_vec_q0 = BFI_MSIX_RME_QMIN_CB + |
| 536 | bfa_ioc_pcifn(&bfa->ioc) * BFI_IOC_MAX_CQS; |
| 537 | iocfc->hwif.cpe_vec_q0 = BFI_MSIX_CPE_QMIN_CB + |
| 538 | bfa_ioc_pcifn(&bfa->ioc) * BFI_IOC_MAX_CQS; |
| 539 | } |
| 540 | |
| 541 | if (bfa_asic_id_ct2(bfa_ioc_devid(&bfa->ioc))) { |
| 542 | iocfc->hwif.hw_reginit = bfa_hwct2_reginit; |
| 543 | iocfc->hwif.hw_isr_mode_set = NULL; |
Krishna Gudipati | 3fd4598 | 2011-06-24 20:24:08 -0700 | [diff] [blame] | 544 | iocfc->hwif.hw_rspq_ack = NULL; |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 545 | } |
| 546 | |
| 547 | iocfc->hwif.hw_reginit(bfa); |
| 548 | bfa->msix.nvecs = 0; |
| 549 | } |
| 550 | |
| 551 | static void |
Krishna Gudipati | 4507025 | 2011-06-24 20:24:29 -0700 | [diff] [blame^] | 552 | bfa_iocfc_mem_claim(struct bfa_s *bfa, struct bfa_iocfc_cfg_s *cfg) |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 553 | { |
Krishna Gudipati | 4507025 | 2011-06-24 20:24:29 -0700 | [diff] [blame^] | 554 | u8 *dm_kva = NULL; |
| 555 | u64 dm_pa = 0; |
| 556 | int i, per_reqq_sz, per_rspq_sz, dbgsz; |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 557 | struct bfa_iocfc_s *iocfc = &bfa->iocfc; |
Krishna Gudipati | 4507025 | 2011-06-24 20:24:29 -0700 | [diff] [blame^] | 558 | struct bfa_mem_dma_s *ioc_dma = BFA_MEM_IOC_DMA(bfa); |
| 559 | struct bfa_mem_dma_s *iocfc_dma = BFA_MEM_IOCFC_DMA(bfa); |
| 560 | struct bfa_mem_dma_s *reqq_dma, *rspq_dma; |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 561 | |
Krishna Gudipati | 4507025 | 2011-06-24 20:24:29 -0700 | [diff] [blame^] | 562 | /* First allocate dma memory for IOC */ |
| 563 | bfa_ioc_mem_claim(&bfa->ioc, bfa_mem_dma_virt(ioc_dma), |
| 564 | bfa_mem_dma_phys(ioc_dma)); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 565 | |
Krishna Gudipati | 4507025 | 2011-06-24 20:24:29 -0700 | [diff] [blame^] | 566 | /* Claim DMA-able memory for the request/response queues */ |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 567 | per_reqq_sz = BFA_ROUNDUP((cfg->drvcfg.num_reqq_elems * BFI_LMSG_SZ), |
Krishna Gudipati | 4507025 | 2011-06-24 20:24:29 -0700 | [diff] [blame^] | 568 | BFA_DMA_ALIGN_SZ); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 569 | per_rspq_sz = BFA_ROUNDUP((cfg->drvcfg.num_rspq_elems * BFI_LMSG_SZ), |
Krishna Gudipati | 4507025 | 2011-06-24 20:24:29 -0700 | [diff] [blame^] | 570 | BFA_DMA_ALIGN_SZ); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 571 | |
| 572 | for (i = 0; i < cfg->fwcfg.num_cqs; i++) { |
Krishna Gudipati | 4507025 | 2011-06-24 20:24:29 -0700 | [diff] [blame^] | 573 | reqq_dma = BFA_MEM_REQQ_DMA(bfa, i); |
| 574 | iocfc->req_cq_ba[i].kva = bfa_mem_dma_virt(reqq_dma); |
| 575 | iocfc->req_cq_ba[i].pa = bfa_mem_dma_phys(reqq_dma); |
| 576 | memset(iocfc->req_cq_ba[i].kva, 0, per_reqq_sz); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 577 | |
Krishna Gudipati | 4507025 | 2011-06-24 20:24:29 -0700 | [diff] [blame^] | 578 | rspq_dma = BFA_MEM_RSPQ_DMA(bfa, i); |
| 579 | iocfc->rsp_cq_ba[i].kva = bfa_mem_dma_virt(rspq_dma); |
| 580 | iocfc->rsp_cq_ba[i].pa = bfa_mem_dma_phys(rspq_dma); |
| 581 | memset(iocfc->rsp_cq_ba[i].kva, 0, per_rspq_sz); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 582 | } |
| 583 | |
Krishna Gudipati | 4507025 | 2011-06-24 20:24:29 -0700 | [diff] [blame^] | 584 | /* Claim IOCFC dma memory - for shadow CI/PI */ |
| 585 | dm_kva = bfa_mem_dma_virt(iocfc_dma); |
| 586 | dm_pa = bfa_mem_dma_phys(iocfc_dma); |
| 587 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 588 | for (i = 0; i < cfg->fwcfg.num_cqs; i++) { |
| 589 | iocfc->req_cq_shadow_ci[i].kva = dm_kva; |
| 590 | iocfc->req_cq_shadow_ci[i].pa = dm_pa; |
| 591 | dm_kva += BFA_CACHELINE_SZ; |
| 592 | dm_pa += BFA_CACHELINE_SZ; |
| 593 | |
| 594 | iocfc->rsp_cq_shadow_pi[i].kva = dm_kva; |
| 595 | iocfc->rsp_cq_shadow_pi[i].pa = dm_pa; |
| 596 | dm_kva += BFA_CACHELINE_SZ; |
| 597 | dm_pa += BFA_CACHELINE_SZ; |
| 598 | } |
| 599 | |
Krishna Gudipati | 4507025 | 2011-06-24 20:24:29 -0700 | [diff] [blame^] | 600 | /* Claim IOCFC dma memory - for the config info page */ |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 601 | bfa->iocfc.cfg_info.kva = dm_kva; |
| 602 | bfa->iocfc.cfg_info.pa = dm_pa; |
| 603 | bfa->iocfc.cfginfo = (struct bfi_iocfc_cfg_s *) dm_kva; |
| 604 | dm_kva += BFA_ROUNDUP(sizeof(struct bfi_iocfc_cfg_s), BFA_CACHELINE_SZ); |
| 605 | dm_pa += BFA_ROUNDUP(sizeof(struct bfi_iocfc_cfg_s), BFA_CACHELINE_SZ); |
| 606 | |
Krishna Gudipati | 4507025 | 2011-06-24 20:24:29 -0700 | [diff] [blame^] | 607 | /* Claim IOCFC dma memory - for the config response */ |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 608 | bfa->iocfc.cfgrsp_dma.kva = dm_kva; |
| 609 | bfa->iocfc.cfgrsp_dma.pa = dm_pa; |
| 610 | bfa->iocfc.cfgrsp = (struct bfi_iocfc_cfgrsp_s *) dm_kva; |
Krishna Gudipati | 4507025 | 2011-06-24 20:24:29 -0700 | [diff] [blame^] | 611 | dm_kva += BFA_ROUNDUP(sizeof(struct bfi_iocfc_cfgrsp_s), |
| 612 | BFA_CACHELINE_SZ); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 613 | dm_pa += BFA_ROUNDUP(sizeof(struct bfi_iocfc_cfgrsp_s), |
Krishna Gudipati | 4507025 | 2011-06-24 20:24:29 -0700 | [diff] [blame^] | 614 | BFA_CACHELINE_SZ); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 615 | |
Krishna Gudipati | 4507025 | 2011-06-24 20:24:29 -0700 | [diff] [blame^] | 616 | /* Claim IOCFC kva memory */ |
Maggie Zhang | f7f73812 | 2010-12-09 19:08:43 -0800 | [diff] [blame] | 617 | dbgsz = (bfa_auto_recover) ? BFA_DBG_FWTRC_LEN : 0; |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 618 | if (dbgsz > 0) { |
Krishna Gudipati | 4507025 | 2011-06-24 20:24:29 -0700 | [diff] [blame^] | 619 | bfa_ioc_debug_memclaim(&bfa->ioc, bfa_mem_kva_curp(iocfc)); |
| 620 | bfa_mem_kva_curp(iocfc) += dbgsz; |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 621 | } |
| 622 | } |
| 623 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 624 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 625 | * Start BFA submodules. |
| 626 | */ |
| 627 | static void |
| 628 | bfa_iocfc_start_submod(struct bfa_s *bfa) |
| 629 | { |
| 630 | int i; |
| 631 | |
Krishna Gudipati | 775c774 | 2011-06-13 15:52:12 -0700 | [diff] [blame] | 632 | bfa->queue_process = BFA_TRUE; |
Krishna Gudipati | 1118920 | 2011-06-13 15:50:35 -0700 | [diff] [blame] | 633 | for (i = 0; i < BFI_IOC_MAX_CQS; i++) |
Krishna Gudipati | 3fd4598 | 2011-06-24 20:24:08 -0700 | [diff] [blame] | 634 | bfa_isr_rspq_ack(bfa, i); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 635 | |
| 636 | for (i = 0; hal_mods[i]; i++) |
| 637 | hal_mods[i]->start(bfa); |
| 638 | } |
| 639 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 640 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 641 | * Disable BFA submodules. |
| 642 | */ |
| 643 | static void |
| 644 | bfa_iocfc_disable_submod(struct bfa_s *bfa) |
| 645 | { |
| 646 | int i; |
| 647 | |
| 648 | for (i = 0; hal_mods[i]; i++) |
| 649 | hal_mods[i]->iocdisable(bfa); |
| 650 | } |
| 651 | |
| 652 | static void |
| 653 | bfa_iocfc_init_cb(void *bfa_arg, bfa_boolean_t complete) |
| 654 | { |
| 655 | struct bfa_s *bfa = bfa_arg; |
| 656 | |
| 657 | if (complete) { |
| 658 | if (bfa->iocfc.cfgdone) |
| 659 | bfa_cb_init(bfa->bfad, BFA_STATUS_OK); |
| 660 | else |
| 661 | bfa_cb_init(bfa->bfad, BFA_STATUS_FAILED); |
| 662 | } else { |
| 663 | if (bfa->iocfc.cfgdone) |
| 664 | bfa->iocfc.action = BFA_IOCFC_ACT_NONE; |
| 665 | } |
| 666 | } |
| 667 | |
| 668 | static void |
| 669 | bfa_iocfc_stop_cb(void *bfa_arg, bfa_boolean_t compl) |
| 670 | { |
| 671 | struct bfa_s *bfa = bfa_arg; |
| 672 | struct bfad_s *bfad = bfa->bfad; |
| 673 | |
| 674 | if (compl) |
| 675 | complete(&bfad->comp); |
| 676 | else |
| 677 | bfa->iocfc.action = BFA_IOCFC_ACT_NONE; |
| 678 | } |
| 679 | |
| 680 | static void |
| 681 | bfa_iocfc_disable_cb(void *bfa_arg, bfa_boolean_t compl) |
| 682 | { |
| 683 | struct bfa_s *bfa = bfa_arg; |
| 684 | struct bfad_s *bfad = bfa->bfad; |
| 685 | |
| 686 | if (compl) |
| 687 | complete(&bfad->disable_comp); |
| 688 | } |
| 689 | |
Krishna Gudipati | 1118920 | 2011-06-13 15:50:35 -0700 | [diff] [blame] | 690 | /** |
| 691 | * configure queue registers from firmware response |
| 692 | */ |
| 693 | static void |
| 694 | bfa_iocfc_qreg(struct bfa_s *bfa, struct bfi_iocfc_qreg_s *qreg) |
| 695 | { |
| 696 | int i; |
| 697 | struct bfa_iocfc_regs_s *r = &bfa->iocfc.bfa_regs; |
| 698 | void __iomem *kva = bfa_ioc_bar0(&bfa->ioc); |
| 699 | |
| 700 | for (i = 0; i < BFI_IOC_MAX_CQS; i++) { |
Krishna Gudipati | 3fd4598 | 2011-06-24 20:24:08 -0700 | [diff] [blame] | 701 | bfa->iocfc.hw_qid[i] = qreg->hw_qid[i]; |
Krishna Gudipati | 1118920 | 2011-06-13 15:50:35 -0700 | [diff] [blame] | 702 | r->cpe_q_ci[i] = kva + be32_to_cpu(qreg->cpe_q_ci_off[i]); |
| 703 | r->cpe_q_pi[i] = kva + be32_to_cpu(qreg->cpe_q_pi_off[i]); |
| 704 | r->cpe_q_ctrl[i] = kva + be32_to_cpu(qreg->cpe_qctl_off[i]); |
| 705 | r->rme_q_ci[i] = kva + be32_to_cpu(qreg->rme_q_ci_off[i]); |
| 706 | r->rme_q_pi[i] = kva + be32_to_cpu(qreg->rme_q_pi_off[i]); |
| 707 | r->rme_q_ctrl[i] = kva + be32_to_cpu(qreg->rme_qctl_off[i]); |
| 708 | } |
| 709 | } |
| 710 | |
Krishna Gudipati | 3fd4598 | 2011-06-24 20:24:08 -0700 | [diff] [blame] | 711 | static void |
| 712 | bfa_iocfc_res_recfg(struct bfa_s *bfa, struct bfa_iocfc_fwcfg_s *fwcfg) |
| 713 | { |
| 714 | bfa_fcxp_res_recfg(bfa, fwcfg->num_fcxp_reqs); |
| 715 | bfa_uf_res_recfg(bfa, fwcfg->num_uf_bufs); |
| 716 | bfa_rport_res_recfg(bfa, fwcfg->num_rports); |
| 717 | bfa_fcp_res_recfg(bfa, fwcfg->num_ioim_reqs); |
| 718 | bfa_tskim_res_recfg(bfa, fwcfg->num_tskim_reqs); |
| 719 | } |
| 720 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 721 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 722 | * Update BFA configuration from firmware configuration. |
| 723 | */ |
| 724 | static void |
| 725 | bfa_iocfc_cfgrsp(struct bfa_s *bfa) |
| 726 | { |
| 727 | struct bfa_iocfc_s *iocfc = &bfa->iocfc; |
| 728 | struct bfi_iocfc_cfgrsp_s *cfgrsp = iocfc->cfgrsp; |
| 729 | struct bfa_iocfc_fwcfg_s *fwcfg = &cfgrsp->fwcfg; |
| 730 | |
| 731 | fwcfg->num_cqs = fwcfg->num_cqs; |
Jing Huang | ba816ea | 2010-10-18 17:10:50 -0700 | [diff] [blame] | 732 | fwcfg->num_ioim_reqs = be16_to_cpu(fwcfg->num_ioim_reqs); |
Krishna Gudipati | e2187d7 | 2011-06-13 15:53:58 -0700 | [diff] [blame] | 733 | fwcfg->num_fwtio_reqs = be16_to_cpu(fwcfg->num_fwtio_reqs); |
Jing Huang | ba816ea | 2010-10-18 17:10:50 -0700 | [diff] [blame] | 734 | fwcfg->num_tskim_reqs = be16_to_cpu(fwcfg->num_tskim_reqs); |
| 735 | fwcfg->num_fcxp_reqs = be16_to_cpu(fwcfg->num_fcxp_reqs); |
| 736 | fwcfg->num_uf_bufs = be16_to_cpu(fwcfg->num_uf_bufs); |
| 737 | fwcfg->num_rports = be16_to_cpu(fwcfg->num_rports); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 738 | |
| 739 | iocfc->cfgdone = BFA_TRUE; |
| 740 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 741 | /* |
Krishna Gudipati | 1118920 | 2011-06-13 15:50:35 -0700 | [diff] [blame] | 742 | * configure queue register offsets as learnt from firmware |
| 743 | */ |
| 744 | bfa_iocfc_qreg(bfa, &cfgrsp->qreg); |
| 745 | |
| 746 | /* |
Krishna Gudipati | 3fd4598 | 2011-06-24 20:24:08 -0700 | [diff] [blame] | 747 | * Re-configure resources as learnt from Firmware |
| 748 | */ |
| 749 | bfa_iocfc_res_recfg(bfa, fwcfg); |
| 750 | |
| 751 | /* |
Krishna Gudipati | 775c774 | 2011-06-13 15:52:12 -0700 | [diff] [blame] | 752 | * Install MSIX queue handlers |
| 753 | */ |
| 754 | bfa_msix_queue_install(bfa); |
| 755 | |
| 756 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 757 | * Configuration is complete - initialize/start submodules |
| 758 | */ |
| 759 | bfa_fcport_init(bfa); |
| 760 | |
| 761 | if (iocfc->action == BFA_IOCFC_ACT_INIT) |
| 762 | bfa_cb_queue(bfa, &iocfc->init_hcb_qe, bfa_iocfc_init_cb, bfa); |
| 763 | else |
| 764 | bfa_iocfc_start_submod(bfa); |
| 765 | } |
| 766 | void |
| 767 | bfa_iocfc_reset_queues(struct bfa_s *bfa) |
| 768 | { |
| 769 | int q; |
| 770 | |
| 771 | for (q = 0; q < BFI_IOC_MAX_CQS; q++) { |
| 772 | bfa_reqq_ci(bfa, q) = 0; |
| 773 | bfa_reqq_pi(bfa, q) = 0; |
| 774 | bfa_rspq_ci(bfa, q) = 0; |
| 775 | bfa_rspq_pi(bfa, q) = 0; |
| 776 | } |
| 777 | } |
| 778 | |
Krishna Gudipati | a714134 | 2011-06-24 20:23:19 -0700 | [diff] [blame] | 779 | /* Fabric Assigned Address specific functions */ |
| 780 | |
| 781 | /* |
| 782 | * Check whether IOC is ready before sending command down |
| 783 | */ |
| 784 | static bfa_status_t |
| 785 | bfa_faa_validate_request(struct bfa_s *bfa) |
| 786 | { |
| 787 | enum bfa_ioc_type_e ioc_type = bfa_get_type(bfa); |
| 788 | u32 card_type = bfa->ioc.attr->card_type; |
| 789 | |
| 790 | if (bfa_ioc_is_operational(&bfa->ioc)) { |
| 791 | if ((ioc_type != BFA_IOC_TYPE_FC) || bfa_mfg_is_mezz(card_type)) |
| 792 | return BFA_STATUS_FEATURE_NOT_SUPPORTED; |
| 793 | } else { |
| 794 | if (!bfa_ioc_is_acq_addr(&bfa->ioc)) |
| 795 | return BFA_STATUS_IOC_NON_OP; |
| 796 | } |
| 797 | |
| 798 | return BFA_STATUS_OK; |
| 799 | } |
| 800 | |
| 801 | bfa_status_t |
| 802 | bfa_faa_enable(struct bfa_s *bfa, bfa_cb_iocfc_t cbfn, void *cbarg) |
| 803 | { |
| 804 | struct bfi_faa_en_dis_s faa_enable_req; |
| 805 | struct bfa_iocfc_s *iocfc = &bfa->iocfc; |
| 806 | bfa_status_t status; |
| 807 | |
| 808 | iocfc->faa_args.faa_cb.faa_cbfn = cbfn; |
| 809 | iocfc->faa_args.faa_cb.faa_cbarg = cbarg; |
| 810 | |
| 811 | status = bfa_faa_validate_request(bfa); |
| 812 | if (status != BFA_STATUS_OK) |
| 813 | return status; |
| 814 | |
| 815 | if (iocfc->faa_args.busy == BFA_TRUE) |
| 816 | return BFA_STATUS_DEVBUSY; |
| 817 | |
| 818 | if (iocfc->faa_args.faa_state == BFA_FAA_ENABLED) |
| 819 | return BFA_STATUS_FAA_ENABLED; |
| 820 | |
| 821 | if (bfa_fcport_is_trunk_enabled(bfa)) |
| 822 | return BFA_STATUS_ERROR_TRUNK_ENABLED; |
| 823 | |
| 824 | bfa_fcport_cfg_faa(bfa, BFA_FAA_ENABLED); |
| 825 | iocfc->faa_args.busy = BFA_TRUE; |
| 826 | |
| 827 | memset(&faa_enable_req, 0, sizeof(struct bfi_faa_en_dis_s)); |
| 828 | bfi_h2i_set(faa_enable_req.mh, BFI_MC_IOCFC, |
Krishna Gudipati | 3fd4598 | 2011-06-24 20:24:08 -0700 | [diff] [blame] | 829 | BFI_IOCFC_H2I_FAA_ENABLE_REQ, bfa_fn_lpu(bfa)); |
Krishna Gudipati | a714134 | 2011-06-24 20:23:19 -0700 | [diff] [blame] | 830 | |
| 831 | bfa_ioc_mbox_send(&bfa->ioc, &faa_enable_req, |
| 832 | sizeof(struct bfi_faa_en_dis_s)); |
| 833 | |
| 834 | return BFA_STATUS_OK; |
| 835 | } |
| 836 | |
| 837 | bfa_status_t |
| 838 | bfa_faa_disable(struct bfa_s *bfa, bfa_cb_iocfc_t cbfn, |
| 839 | void *cbarg) |
| 840 | { |
| 841 | struct bfi_faa_en_dis_s faa_disable_req; |
| 842 | struct bfa_iocfc_s *iocfc = &bfa->iocfc; |
| 843 | bfa_status_t status; |
| 844 | |
| 845 | iocfc->faa_args.faa_cb.faa_cbfn = cbfn; |
| 846 | iocfc->faa_args.faa_cb.faa_cbarg = cbarg; |
| 847 | |
| 848 | status = bfa_faa_validate_request(bfa); |
| 849 | if (status != BFA_STATUS_OK) |
| 850 | return status; |
| 851 | |
| 852 | if (iocfc->faa_args.busy == BFA_TRUE) |
| 853 | return BFA_STATUS_DEVBUSY; |
| 854 | |
| 855 | if (iocfc->faa_args.faa_state == BFA_FAA_DISABLED) |
| 856 | return BFA_STATUS_FAA_DISABLED; |
| 857 | |
| 858 | bfa_fcport_cfg_faa(bfa, BFA_FAA_DISABLED); |
| 859 | iocfc->faa_args.busy = BFA_TRUE; |
| 860 | |
| 861 | memset(&faa_disable_req, 0, sizeof(struct bfi_faa_en_dis_s)); |
| 862 | bfi_h2i_set(faa_disable_req.mh, BFI_MC_IOCFC, |
Krishna Gudipati | 3fd4598 | 2011-06-24 20:24:08 -0700 | [diff] [blame] | 863 | BFI_IOCFC_H2I_FAA_DISABLE_REQ, bfa_fn_lpu(bfa)); |
Krishna Gudipati | a714134 | 2011-06-24 20:23:19 -0700 | [diff] [blame] | 864 | |
| 865 | bfa_ioc_mbox_send(&bfa->ioc, &faa_disable_req, |
| 866 | sizeof(struct bfi_faa_en_dis_s)); |
| 867 | |
| 868 | return BFA_STATUS_OK; |
| 869 | } |
| 870 | |
| 871 | bfa_status_t |
| 872 | bfa_faa_query(struct bfa_s *bfa, struct bfa_faa_attr_s *attr, |
| 873 | bfa_cb_iocfc_t cbfn, void *cbarg) |
| 874 | { |
| 875 | struct bfi_faa_query_s faa_attr_req; |
| 876 | struct bfa_iocfc_s *iocfc = &bfa->iocfc; |
| 877 | bfa_status_t status; |
| 878 | |
| 879 | iocfc->faa_args.faa_attr = attr; |
| 880 | iocfc->faa_args.faa_cb.faa_cbfn = cbfn; |
| 881 | iocfc->faa_args.faa_cb.faa_cbarg = cbarg; |
| 882 | |
| 883 | status = bfa_faa_validate_request(bfa); |
| 884 | if (status != BFA_STATUS_OK) |
| 885 | return status; |
| 886 | |
| 887 | if (iocfc->faa_args.busy == BFA_TRUE) |
| 888 | return BFA_STATUS_DEVBUSY; |
| 889 | |
| 890 | iocfc->faa_args.busy = BFA_TRUE; |
| 891 | memset(&faa_attr_req, 0, sizeof(struct bfi_faa_query_s)); |
| 892 | bfi_h2i_set(faa_attr_req.mh, BFI_MC_IOCFC, |
Krishna Gudipati | 3fd4598 | 2011-06-24 20:24:08 -0700 | [diff] [blame] | 893 | BFI_IOCFC_H2I_FAA_QUERY_REQ, bfa_fn_lpu(bfa)); |
Krishna Gudipati | a714134 | 2011-06-24 20:23:19 -0700 | [diff] [blame] | 894 | |
| 895 | bfa_ioc_mbox_send(&bfa->ioc, &faa_attr_req, |
| 896 | sizeof(struct bfi_faa_query_s)); |
| 897 | |
| 898 | return BFA_STATUS_OK; |
| 899 | } |
| 900 | |
| 901 | /* |
| 902 | * FAA enable response |
| 903 | */ |
| 904 | static void |
| 905 | bfa_faa_enable_reply(struct bfa_iocfc_s *iocfc, |
| 906 | struct bfi_faa_en_dis_rsp_s *rsp) |
| 907 | { |
| 908 | void *cbarg = iocfc->faa_args.faa_cb.faa_cbarg; |
| 909 | bfa_status_t status = rsp->status; |
| 910 | |
| 911 | WARN_ON(!iocfc->faa_args.faa_cb.faa_cbfn); |
| 912 | |
| 913 | iocfc->faa_args.faa_cb.faa_cbfn(cbarg, status); |
| 914 | iocfc->faa_args.busy = BFA_FALSE; |
| 915 | } |
| 916 | |
| 917 | /* |
| 918 | * FAA disable response |
| 919 | */ |
| 920 | static void |
| 921 | bfa_faa_disable_reply(struct bfa_iocfc_s *iocfc, |
| 922 | struct bfi_faa_en_dis_rsp_s *rsp) |
| 923 | { |
| 924 | void *cbarg = iocfc->faa_args.faa_cb.faa_cbarg; |
| 925 | bfa_status_t status = rsp->status; |
| 926 | |
| 927 | WARN_ON(!iocfc->faa_args.faa_cb.faa_cbfn); |
| 928 | |
| 929 | iocfc->faa_args.faa_cb.faa_cbfn(cbarg, status); |
| 930 | iocfc->faa_args.busy = BFA_FALSE; |
| 931 | } |
| 932 | |
| 933 | /* |
| 934 | * FAA query response |
| 935 | */ |
| 936 | static void |
| 937 | bfa_faa_query_reply(struct bfa_iocfc_s *iocfc, |
| 938 | bfi_faa_query_rsp_t *rsp) |
| 939 | { |
| 940 | void *cbarg = iocfc->faa_args.faa_cb.faa_cbarg; |
| 941 | |
| 942 | if (iocfc->faa_args.faa_attr) { |
| 943 | iocfc->faa_args.faa_attr->faa = rsp->faa; |
| 944 | iocfc->faa_args.faa_attr->faa_state = rsp->faa_status; |
| 945 | iocfc->faa_args.faa_attr->pwwn_source = rsp->addr_source; |
| 946 | } |
| 947 | |
| 948 | WARN_ON(!iocfc->faa_args.faa_cb.faa_cbfn); |
| 949 | |
| 950 | iocfc->faa_args.faa_cb.faa_cbfn(cbarg, BFA_STATUS_OK); |
| 951 | iocfc->faa_args.busy = BFA_FALSE; |
| 952 | } |
| 953 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 954 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 955 | * IOC enable request is complete |
| 956 | */ |
| 957 | static void |
| 958 | bfa_iocfc_enable_cbfn(void *bfa_arg, enum bfa_status status) |
| 959 | { |
| 960 | struct bfa_s *bfa = bfa_arg; |
| 961 | |
Krishna Gudipati | a714134 | 2011-06-24 20:23:19 -0700 | [diff] [blame] | 962 | if (status == BFA_STATUS_FAA_ACQ_ADDR) { |
| 963 | bfa_cb_queue(bfa, &bfa->iocfc.init_hcb_qe, |
| 964 | bfa_iocfc_init_cb, bfa); |
| 965 | return; |
| 966 | } |
| 967 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 968 | if (status != BFA_STATUS_OK) { |
| 969 | bfa_isr_disable(bfa); |
| 970 | if (bfa->iocfc.action == BFA_IOCFC_ACT_INIT) |
| 971 | bfa_cb_queue(bfa, &bfa->iocfc.init_hcb_qe, |
| 972 | bfa_iocfc_init_cb, bfa); |
| 973 | return; |
| 974 | } |
| 975 | |
| 976 | bfa_iocfc_send_cfg(bfa); |
| 977 | } |
| 978 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 979 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 980 | * IOC disable request is complete |
| 981 | */ |
| 982 | static void |
| 983 | bfa_iocfc_disable_cbfn(void *bfa_arg) |
| 984 | { |
| 985 | struct bfa_s *bfa = bfa_arg; |
| 986 | |
| 987 | bfa_isr_disable(bfa); |
| 988 | bfa_iocfc_disable_submod(bfa); |
| 989 | |
| 990 | if (bfa->iocfc.action == BFA_IOCFC_ACT_STOP) |
| 991 | bfa_cb_queue(bfa, &bfa->iocfc.stop_hcb_qe, bfa_iocfc_stop_cb, |
| 992 | bfa); |
| 993 | else { |
Jing Huang | d4b671c | 2010-12-26 21:46:35 -0800 | [diff] [blame] | 994 | WARN_ON(bfa->iocfc.action != BFA_IOCFC_ACT_DISABLE); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 995 | bfa_cb_queue(bfa, &bfa->iocfc.dis_hcb_qe, bfa_iocfc_disable_cb, |
| 996 | bfa); |
| 997 | } |
| 998 | } |
| 999 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 1000 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1001 | * Notify sub-modules of hardware failure. |
| 1002 | */ |
| 1003 | static void |
| 1004 | bfa_iocfc_hbfail_cbfn(void *bfa_arg) |
| 1005 | { |
| 1006 | struct bfa_s *bfa = bfa_arg; |
| 1007 | |
Krishna Gudipati | 775c774 | 2011-06-13 15:52:12 -0700 | [diff] [blame] | 1008 | bfa->queue_process = BFA_FALSE; |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1009 | |
| 1010 | bfa_isr_disable(bfa); |
| 1011 | bfa_iocfc_disable_submod(bfa); |
| 1012 | |
| 1013 | if (bfa->iocfc.action == BFA_IOCFC_ACT_INIT) |
| 1014 | bfa_cb_queue(bfa, &bfa->iocfc.init_hcb_qe, bfa_iocfc_init_cb, |
| 1015 | bfa); |
| 1016 | } |
| 1017 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 1018 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1019 | * Actions on chip-reset completion. |
| 1020 | */ |
| 1021 | static void |
| 1022 | bfa_iocfc_reset_cbfn(void *bfa_arg) |
| 1023 | { |
| 1024 | struct bfa_s *bfa = bfa_arg; |
| 1025 | |
| 1026 | bfa_iocfc_reset_queues(bfa); |
| 1027 | bfa_isr_enable(bfa); |
| 1028 | } |
| 1029 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1030 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 1031 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1032 | * Query IOC memory requirement information. |
| 1033 | */ |
| 1034 | void |
Krishna Gudipati | 4507025 | 2011-06-24 20:24:29 -0700 | [diff] [blame^] | 1035 | bfa_iocfc_meminfo(struct bfa_iocfc_cfg_s *cfg, struct bfa_meminfo_s *meminfo, |
| 1036 | struct bfa_s *bfa) |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1037 | { |
Krishna Gudipati | 4507025 | 2011-06-24 20:24:29 -0700 | [diff] [blame^] | 1038 | int q, per_reqq_sz, per_rspq_sz; |
| 1039 | struct bfa_mem_dma_s *ioc_dma = BFA_MEM_IOC_DMA(bfa); |
| 1040 | struct bfa_mem_dma_s *iocfc_dma = BFA_MEM_IOCFC_DMA(bfa); |
| 1041 | struct bfa_mem_kva_s *iocfc_kva = BFA_MEM_IOCFC_KVA(bfa); |
| 1042 | u32 dm_len = 0; |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1043 | |
Krishna Gudipati | 4507025 | 2011-06-24 20:24:29 -0700 | [diff] [blame^] | 1044 | /* dma memory setup for IOC */ |
| 1045 | bfa_mem_dma_setup(meminfo, ioc_dma, |
| 1046 | BFA_ROUNDUP(sizeof(struct bfi_ioc_attr_s), BFA_DMA_ALIGN_SZ)); |
| 1047 | |
| 1048 | /* dma memory setup for REQ/RSP queues */ |
| 1049 | per_reqq_sz = BFA_ROUNDUP((cfg->drvcfg.num_reqq_elems * BFI_LMSG_SZ), |
| 1050 | BFA_DMA_ALIGN_SZ); |
| 1051 | per_rspq_sz = BFA_ROUNDUP((cfg->drvcfg.num_rspq_elems * BFI_LMSG_SZ), |
| 1052 | BFA_DMA_ALIGN_SZ); |
| 1053 | |
| 1054 | for (q = 0; q < cfg->fwcfg.num_cqs; q++) { |
| 1055 | bfa_mem_dma_setup(meminfo, BFA_MEM_REQQ_DMA(bfa, q), |
| 1056 | per_reqq_sz); |
| 1057 | bfa_mem_dma_setup(meminfo, BFA_MEM_RSPQ_DMA(bfa, q), |
| 1058 | per_rspq_sz); |
| 1059 | } |
| 1060 | |
| 1061 | /* IOCFC dma memory - calculate Shadow CI/PI size */ |
| 1062 | for (q = 0; q < cfg->fwcfg.num_cqs; q++) |
| 1063 | dm_len += (2 * BFA_CACHELINE_SZ); |
| 1064 | |
| 1065 | /* IOCFC dma memory - calculate config info / rsp size */ |
| 1066 | dm_len += BFA_ROUNDUP(sizeof(struct bfi_iocfc_cfg_s), BFA_CACHELINE_SZ); |
| 1067 | dm_len += BFA_ROUNDUP(sizeof(struct bfi_iocfc_cfgrsp_s), |
| 1068 | BFA_CACHELINE_SZ); |
| 1069 | |
| 1070 | /* dma memory setup for IOCFC */ |
| 1071 | bfa_mem_dma_setup(meminfo, iocfc_dma, dm_len); |
| 1072 | |
| 1073 | /* kva memory setup for IOCFC */ |
| 1074 | bfa_mem_kva_setup(meminfo, iocfc_kva, |
| 1075 | ((bfa_auto_recover) ? BFA_DBG_FWTRC_LEN : 0)); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1076 | } |
| 1077 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 1078 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1079 | * Query IOC memory requirement information. |
| 1080 | */ |
| 1081 | void |
| 1082 | bfa_iocfc_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg, |
Krishna Gudipati | 4507025 | 2011-06-24 20:24:29 -0700 | [diff] [blame^] | 1083 | struct bfa_pcidev_s *pcidev) |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1084 | { |
| 1085 | int i; |
| 1086 | struct bfa_ioc_s *ioc = &bfa->ioc; |
| 1087 | |
| 1088 | bfa_iocfc_cbfn.enable_cbfn = bfa_iocfc_enable_cbfn; |
| 1089 | bfa_iocfc_cbfn.disable_cbfn = bfa_iocfc_disable_cbfn; |
| 1090 | bfa_iocfc_cbfn.hbfail_cbfn = bfa_iocfc_hbfail_cbfn; |
| 1091 | bfa_iocfc_cbfn.reset_cbfn = bfa_iocfc_reset_cbfn; |
| 1092 | |
| 1093 | ioc->trcmod = bfa->trcmod; |
| 1094 | bfa_ioc_attach(&bfa->ioc, bfa, &bfa_iocfc_cbfn, &bfa->timer_mod); |
| 1095 | |
Krishna Gudipati | d37779f | 2011-06-13 15:42:10 -0700 | [diff] [blame] | 1096 | bfa_ioc_pci_init(&bfa->ioc, pcidev, BFI_PCIFN_CLASS_FC); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1097 | bfa_ioc_mbox_register(&bfa->ioc, bfa_mbox_isrs); |
| 1098 | |
| 1099 | bfa_iocfc_init_mem(bfa, bfad, cfg, pcidev); |
Krishna Gudipati | 4507025 | 2011-06-24 20:24:29 -0700 | [diff] [blame^] | 1100 | bfa_iocfc_mem_claim(bfa, cfg); |
Maggie Zhang | f7f73812 | 2010-12-09 19:08:43 -0800 | [diff] [blame] | 1101 | INIT_LIST_HEAD(&bfa->timer_mod.timer_q); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1102 | |
| 1103 | INIT_LIST_HEAD(&bfa->comp_q); |
| 1104 | for (i = 0; i < BFI_IOC_MAX_CQS; i++) |
| 1105 | INIT_LIST_HEAD(&bfa->reqq_waitq[i]); |
| 1106 | } |
| 1107 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 1108 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1109 | * Query IOC memory requirement information. |
| 1110 | */ |
| 1111 | void |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1112 | bfa_iocfc_init(struct bfa_s *bfa) |
| 1113 | { |
| 1114 | bfa->iocfc.action = BFA_IOCFC_ACT_INIT; |
| 1115 | bfa_ioc_enable(&bfa->ioc); |
| 1116 | } |
| 1117 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 1118 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1119 | * IOC start called from bfa_start(). Called to start IOC operations |
| 1120 | * at driver instantiation for this instance. |
| 1121 | */ |
| 1122 | void |
| 1123 | bfa_iocfc_start(struct bfa_s *bfa) |
| 1124 | { |
| 1125 | if (bfa->iocfc.cfgdone) |
| 1126 | bfa_iocfc_start_submod(bfa); |
| 1127 | } |
| 1128 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 1129 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1130 | * IOC stop called from bfa_stop(). Called only when driver is unloaded |
| 1131 | * for this instance. |
| 1132 | */ |
| 1133 | void |
| 1134 | bfa_iocfc_stop(struct bfa_s *bfa) |
| 1135 | { |
| 1136 | bfa->iocfc.action = BFA_IOCFC_ACT_STOP; |
| 1137 | |
Krishna Gudipati | 775c774 | 2011-06-13 15:52:12 -0700 | [diff] [blame] | 1138 | bfa->queue_process = BFA_FALSE; |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1139 | bfa_ioc_disable(&bfa->ioc); |
| 1140 | } |
| 1141 | |
| 1142 | void |
| 1143 | bfa_iocfc_isr(void *bfaarg, struct bfi_mbmsg_s *m) |
| 1144 | { |
| 1145 | struct bfa_s *bfa = bfaarg; |
| 1146 | struct bfa_iocfc_s *iocfc = &bfa->iocfc; |
| 1147 | union bfi_iocfc_i2h_msg_u *msg; |
| 1148 | |
| 1149 | msg = (union bfi_iocfc_i2h_msg_u *) m; |
| 1150 | bfa_trc(bfa, msg->mh.msg_id); |
| 1151 | |
| 1152 | switch (msg->mh.msg_id) { |
| 1153 | case BFI_IOCFC_I2H_CFG_REPLY: |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1154 | bfa_iocfc_cfgrsp(bfa); |
| 1155 | break; |
| 1156 | case BFI_IOCFC_I2H_UPDATEQ_RSP: |
| 1157 | iocfc->updateq_cbfn(iocfc->updateq_cbarg, BFA_STATUS_OK); |
| 1158 | break; |
Krishna Gudipati | a714134 | 2011-06-24 20:23:19 -0700 | [diff] [blame] | 1159 | case BFI_IOCFC_I2H_FAA_ENABLE_RSP: |
| 1160 | bfa_faa_enable_reply(iocfc, |
| 1161 | (struct bfi_faa_en_dis_rsp_s *)msg); |
| 1162 | break; |
| 1163 | case BFI_IOCFC_I2H_FAA_DISABLE_RSP: |
| 1164 | bfa_faa_disable_reply(iocfc, |
| 1165 | (struct bfi_faa_en_dis_rsp_s *)msg); |
| 1166 | break; |
| 1167 | case BFI_IOCFC_I2H_FAA_QUERY_RSP: |
| 1168 | bfa_faa_query_reply(iocfc, (bfi_faa_query_rsp_t *)msg); |
| 1169 | break; |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1170 | default: |
Jing Huang | d4b671c | 2010-12-26 21:46:35 -0800 | [diff] [blame] | 1171 | WARN_ON(1); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1172 | } |
| 1173 | } |
| 1174 | |
| 1175 | void |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1176 | bfa_iocfc_get_attr(struct bfa_s *bfa, struct bfa_iocfc_attr_s *attr) |
| 1177 | { |
| 1178 | struct bfa_iocfc_s *iocfc = &bfa->iocfc; |
| 1179 | |
| 1180 | attr->intr_attr.coalesce = iocfc->cfginfo->intr_attr.coalesce; |
| 1181 | |
| 1182 | attr->intr_attr.delay = iocfc->cfginfo->intr_attr.delay ? |
Jing Huang | ba816ea | 2010-10-18 17:10:50 -0700 | [diff] [blame] | 1183 | be16_to_cpu(iocfc->cfginfo->intr_attr.delay) : |
| 1184 | be16_to_cpu(iocfc->cfgrsp->intr_attr.delay); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1185 | |
| 1186 | attr->intr_attr.latency = iocfc->cfginfo->intr_attr.latency ? |
Jing Huang | ba816ea | 2010-10-18 17:10:50 -0700 | [diff] [blame] | 1187 | be16_to_cpu(iocfc->cfginfo->intr_attr.latency) : |
| 1188 | be16_to_cpu(iocfc->cfgrsp->intr_attr.latency); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1189 | |
| 1190 | attr->config = iocfc->cfg; |
| 1191 | } |
| 1192 | |
| 1193 | bfa_status_t |
| 1194 | bfa_iocfc_israttr_set(struct bfa_s *bfa, struct bfa_iocfc_intr_attr_s *attr) |
| 1195 | { |
| 1196 | struct bfa_iocfc_s *iocfc = &bfa->iocfc; |
| 1197 | struct bfi_iocfc_set_intr_req_s *m; |
| 1198 | |
| 1199 | iocfc->cfginfo->intr_attr.coalesce = attr->coalesce; |
Jing Huang | ba816ea | 2010-10-18 17:10:50 -0700 | [diff] [blame] | 1200 | iocfc->cfginfo->intr_attr.delay = cpu_to_be16(attr->delay); |
| 1201 | iocfc->cfginfo->intr_attr.latency = cpu_to_be16(attr->latency); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1202 | |
| 1203 | if (!bfa_iocfc_is_operational(bfa)) |
| 1204 | return BFA_STATUS_OK; |
| 1205 | |
| 1206 | m = bfa_reqq_next(bfa, BFA_REQQ_IOC); |
| 1207 | if (!m) |
| 1208 | return BFA_STATUS_DEVBUSY; |
| 1209 | |
| 1210 | bfi_h2i_set(m->mh, BFI_MC_IOCFC, BFI_IOCFC_H2I_SET_INTR_REQ, |
Krishna Gudipati | 3fd4598 | 2011-06-24 20:24:08 -0700 | [diff] [blame] | 1211 | bfa_fn_lpu(bfa)); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1212 | m->coalesce = iocfc->cfginfo->intr_attr.coalesce; |
| 1213 | m->delay = iocfc->cfginfo->intr_attr.delay; |
| 1214 | m->latency = iocfc->cfginfo->intr_attr.latency; |
| 1215 | |
| 1216 | bfa_trc(bfa, attr->delay); |
| 1217 | bfa_trc(bfa, attr->latency); |
| 1218 | |
Krishna Gudipati | 3fd4598 | 2011-06-24 20:24:08 -0700 | [diff] [blame] | 1219 | bfa_reqq_produce(bfa, BFA_REQQ_IOC, m->mh); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1220 | return BFA_STATUS_OK; |
| 1221 | } |
| 1222 | |
| 1223 | void |
Krishna Gudipati | 4507025 | 2011-06-24 20:24:29 -0700 | [diff] [blame^] | 1224 | bfa_iocfc_set_snsbase(struct bfa_s *bfa, int seg_no, u64 snsbase_pa) |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1225 | { |
| 1226 | struct bfa_iocfc_s *iocfc = &bfa->iocfc; |
| 1227 | |
| 1228 | iocfc->cfginfo->sense_buf_len = (BFI_IOIM_SNSLEN - 1); |
Krishna Gudipati | 4507025 | 2011-06-24 20:24:29 -0700 | [diff] [blame^] | 1229 | bfa_dma_be_addr_set(iocfc->cfginfo->ioim_snsbase[seg_no], snsbase_pa); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1230 | } |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 1231 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1232 | * Enable IOC after it is disabled. |
| 1233 | */ |
| 1234 | void |
| 1235 | bfa_iocfc_enable(struct bfa_s *bfa) |
| 1236 | { |
| 1237 | bfa_plog_str(bfa->plog, BFA_PL_MID_HAL, BFA_PL_EID_MISC, 0, |
| 1238 | "IOC Enable"); |
| 1239 | bfa_ioc_enable(&bfa->ioc); |
| 1240 | } |
| 1241 | |
| 1242 | void |
| 1243 | bfa_iocfc_disable(struct bfa_s *bfa) |
| 1244 | { |
| 1245 | bfa_plog_str(bfa->plog, BFA_PL_MID_HAL, BFA_PL_EID_MISC, 0, |
| 1246 | "IOC Disable"); |
| 1247 | bfa->iocfc.action = BFA_IOCFC_ACT_DISABLE; |
| 1248 | |
Krishna Gudipati | 775c774 | 2011-06-13 15:52:12 -0700 | [diff] [blame] | 1249 | bfa->queue_process = BFA_FALSE; |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1250 | bfa_ioc_disable(&bfa->ioc); |
| 1251 | } |
| 1252 | |
| 1253 | |
| 1254 | bfa_boolean_t |
| 1255 | bfa_iocfc_is_operational(struct bfa_s *bfa) |
| 1256 | { |
| 1257 | return bfa_ioc_is_operational(&bfa->ioc) && bfa->iocfc.cfgdone; |
| 1258 | } |
| 1259 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 1260 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1261 | * Return boot target port wwns -- read from boot information in flash. |
| 1262 | */ |
| 1263 | void |
| 1264 | bfa_iocfc_get_bootwwns(struct bfa_s *bfa, u8 *nwwns, wwn_t *wwns) |
| 1265 | { |
| 1266 | struct bfa_iocfc_s *iocfc = &bfa->iocfc; |
| 1267 | struct bfi_iocfc_cfgrsp_s *cfgrsp = iocfc->cfgrsp; |
| 1268 | int i; |
| 1269 | |
| 1270 | if (cfgrsp->pbc_cfg.boot_enabled && cfgrsp->pbc_cfg.nbluns) { |
| 1271 | bfa_trc(bfa, cfgrsp->pbc_cfg.nbluns); |
| 1272 | *nwwns = cfgrsp->pbc_cfg.nbluns; |
| 1273 | for (i = 0; i < cfgrsp->pbc_cfg.nbluns; i++) |
| 1274 | wwns[i] = cfgrsp->pbc_cfg.blun[i].tgt_pwwn; |
| 1275 | |
| 1276 | return; |
| 1277 | } |
| 1278 | |
| 1279 | *nwwns = cfgrsp->bootwwns.nwwns; |
| 1280 | memcpy(wwns, cfgrsp->bootwwns.wwn, sizeof(cfgrsp->bootwwns.wwn)); |
| 1281 | } |
| 1282 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1283 | int |
| 1284 | bfa_iocfc_get_pbc_vports(struct bfa_s *bfa, struct bfi_pbc_vport_s *pbc_vport) |
| 1285 | { |
| 1286 | struct bfa_iocfc_s *iocfc = &bfa->iocfc; |
| 1287 | struct bfi_iocfc_cfgrsp_s *cfgrsp = iocfc->cfgrsp; |
| 1288 | |
| 1289 | memcpy(pbc_vport, cfgrsp->pbc_cfg.vport, sizeof(cfgrsp->pbc_cfg.vport)); |
| 1290 | return cfgrsp->pbc_cfg.nvports; |
| 1291 | } |
| 1292 | |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1293 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 1294 | /* |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1295 | * Use this function query the memory requirement of the BFA library. |
| 1296 | * This function needs to be called before bfa_attach() to get the |
| 1297 | * memory required of the BFA layer for a given driver configuration. |
| 1298 | * |
| 1299 | * This call will fail, if the cap is out of range compared to pre-defined |
| 1300 | * values within the BFA library |
| 1301 | * |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1302 | * @param[in] cfg - pointer to bfa_ioc_cfg_t. Driver layer should indicate |
| 1303 | * its configuration in this structure. |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1304 | * The default values for struct bfa_iocfc_cfg_s can be |
| 1305 | * fetched using bfa_cfg_get_default() API. |
| 1306 | * |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1307 | * If cap's boundary check fails, the library will use |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1308 | * the default bfa_cap_t values (and log a warning msg). |
| 1309 | * |
| 1310 | * @param[out] meminfo - pointer to bfa_meminfo_t. This content |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1311 | * indicates the memory type (see bfa_mem_type_t) and |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1312 | * amount of memory required. |
| 1313 | * |
| 1314 | * Driver should allocate the memory, populate the |
| 1315 | * starting address for each block and provide the same |
| 1316 | * structure as input parameter to bfa_attach() call. |
| 1317 | * |
Krishna Gudipati | 4507025 | 2011-06-24 20:24:29 -0700 | [diff] [blame^] | 1318 | * @param[in] bfa - pointer to the bfa structure, used while fetching the |
| 1319 | * dma, kva memory information of the bfa sub-modules. |
| 1320 | * |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1321 | * @return void |
| 1322 | * |
| 1323 | * Special Considerations: @note |
| 1324 | */ |
| 1325 | void |
Krishna Gudipati | 4507025 | 2011-06-24 20:24:29 -0700 | [diff] [blame^] | 1326 | bfa_cfg_get_meminfo(struct bfa_iocfc_cfg_s *cfg, struct bfa_meminfo_s *meminfo, |
| 1327 | struct bfa_s *bfa) |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1328 | { |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1329 | int i; |
Krishna Gudipati | 4507025 | 2011-06-24 20:24:29 -0700 | [diff] [blame^] | 1330 | struct bfa_mem_dma_s *port_dma = BFA_MEM_PORT_DMA(bfa); |
| 1331 | struct bfa_mem_dma_s *ablk_dma = BFA_MEM_ABLK_DMA(bfa); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1332 | |
Jing Huang | d4b671c | 2010-12-26 21:46:35 -0800 | [diff] [blame] | 1333 | WARN_ON((cfg == NULL) || (meminfo == NULL)); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1334 | |
Jing Huang | 6a18b16 | 2010-10-18 17:08:54 -0700 | [diff] [blame] | 1335 | memset((void *)meminfo, 0, sizeof(struct bfa_meminfo_s)); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1336 | |
Krishna Gudipati | 4507025 | 2011-06-24 20:24:29 -0700 | [diff] [blame^] | 1337 | /* Initialize the DMA & KVA meminfo queues */ |
| 1338 | INIT_LIST_HEAD(&meminfo->dma_info.qe); |
| 1339 | INIT_LIST_HEAD(&meminfo->kva_info.qe); |
| 1340 | |
| 1341 | bfa_iocfc_meminfo(cfg, meminfo, bfa); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1342 | |
| 1343 | for (i = 0; hal_mods[i]; i++) |
Krishna Gudipati | 4507025 | 2011-06-24 20:24:29 -0700 | [diff] [blame^] | 1344 | hal_mods[i]->meminfo(cfg, meminfo, bfa); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1345 | |
Krishna Gudipati | 4507025 | 2011-06-24 20:24:29 -0700 | [diff] [blame^] | 1346 | /* dma info setup */ |
| 1347 | bfa_mem_dma_setup(meminfo, port_dma, bfa_port_meminfo()); |
| 1348 | bfa_mem_dma_setup(meminfo, ablk_dma, bfa_ablk_meminfo()); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1349 | } |
| 1350 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 1351 | /* |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1352 | * Use this function to do attach the driver instance with the BFA |
| 1353 | * library. This function will not trigger any HW initialization |
| 1354 | * process (which will be done in bfa_init() call) |
| 1355 | * |
| 1356 | * This call will fail, if the cap is out of range compared to |
| 1357 | * pre-defined values within the BFA library |
| 1358 | * |
| 1359 | * @param[out] bfa Pointer to bfa_t. |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1360 | * @param[in] bfad Opaque handle back to the driver's IOC structure |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1361 | * @param[in] cfg Pointer to bfa_ioc_cfg_t. Should be same structure |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1362 | * that was used in bfa_cfg_get_meminfo(). |
| 1363 | * @param[in] meminfo Pointer to bfa_meminfo_t. The driver should |
| 1364 | * use the bfa_cfg_get_meminfo() call to |
| 1365 | * find the memory blocks required, allocate the |
| 1366 | * required memory and provide the starting addresses. |
| 1367 | * @param[in] pcidev pointer to struct bfa_pcidev_s |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1368 | * |
| 1369 | * @return |
| 1370 | * void |
| 1371 | * |
| 1372 | * Special Considerations: |
| 1373 | * |
| 1374 | * @note |
| 1375 | * |
| 1376 | */ |
| 1377 | void |
| 1378 | bfa_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg, |
| 1379 | struct bfa_meminfo_s *meminfo, struct bfa_pcidev_s *pcidev) |
| 1380 | { |
Krishna Gudipati | 4507025 | 2011-06-24 20:24:29 -0700 | [diff] [blame^] | 1381 | int i; |
| 1382 | struct bfa_mem_dma_s *dma_info, *dma_elem; |
| 1383 | struct bfa_mem_kva_s *kva_info, *kva_elem; |
| 1384 | struct list_head *dm_qe, *km_qe; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1385 | |
| 1386 | bfa->fcs = BFA_FALSE; |
| 1387 | |
Jing Huang | d4b671c | 2010-12-26 21:46:35 -0800 | [diff] [blame] | 1388 | WARN_ON((cfg == NULL) || (meminfo == NULL)); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1389 | |
Krishna Gudipati | 4507025 | 2011-06-24 20:24:29 -0700 | [diff] [blame^] | 1390 | /* Initialize memory pointers for iterative allocation */ |
| 1391 | dma_info = &meminfo->dma_info; |
| 1392 | dma_info->kva_curp = dma_info->kva; |
| 1393 | dma_info->dma_curp = dma_info->dma; |
| 1394 | |
| 1395 | kva_info = &meminfo->kva_info; |
| 1396 | kva_info->kva_curp = kva_info->kva; |
| 1397 | |
| 1398 | list_for_each(dm_qe, &dma_info->qe) { |
| 1399 | dma_elem = (struct bfa_mem_dma_s *) dm_qe; |
| 1400 | dma_elem->kva_curp = dma_elem->kva; |
| 1401 | dma_elem->dma_curp = dma_elem->dma; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1402 | } |
| 1403 | |
Krishna Gudipati | 4507025 | 2011-06-24 20:24:29 -0700 | [diff] [blame^] | 1404 | list_for_each(km_qe, &kva_info->qe) { |
| 1405 | kva_elem = (struct bfa_mem_kva_s *) km_qe; |
| 1406 | kva_elem->kva_curp = kva_elem->kva; |
| 1407 | } |
| 1408 | |
| 1409 | bfa_iocfc_attach(bfa, bfad, cfg, pcidev); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1410 | |
| 1411 | for (i = 0; hal_mods[i]; i++) |
Krishna Gudipati | 4507025 | 2011-06-24 20:24:29 -0700 | [diff] [blame^] | 1412 | hal_mods[i]->attach(bfa, bfad, cfg, pcidev); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1413 | |
Krishna Gudipati | 4507025 | 2011-06-24 20:24:29 -0700 | [diff] [blame^] | 1414 | bfa_com_port_attach(bfa); |
| 1415 | bfa_com_ablk_attach(bfa); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1416 | } |
| 1417 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 1418 | /* |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1419 | * Use this function to delete a BFA IOC. IOC should be stopped (by |
| 1420 | * calling bfa_stop()) before this function call. |
| 1421 | * |
| 1422 | * @param[in] bfa - pointer to bfa_t. |
| 1423 | * |
| 1424 | * @return |
| 1425 | * void |
| 1426 | * |
| 1427 | * Special Considerations: |
| 1428 | * |
| 1429 | * @note |
| 1430 | */ |
| 1431 | void |
| 1432 | bfa_detach(struct bfa_s *bfa) |
| 1433 | { |
| 1434 | int i; |
| 1435 | |
| 1436 | for (i = 0; hal_mods[i]; i++) |
| 1437 | hal_mods[i]->detach(bfa); |
Maggie Zhang | f7f73812 | 2010-12-09 19:08:43 -0800 | [diff] [blame] | 1438 | bfa_ioc_detach(&bfa->ioc); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1439 | } |
| 1440 | |
| 1441 | void |
| 1442 | bfa_comp_deq(struct bfa_s *bfa, struct list_head *comp_q) |
| 1443 | { |
| 1444 | INIT_LIST_HEAD(comp_q); |
| 1445 | list_splice_tail_init(&bfa->comp_q, comp_q); |
| 1446 | } |
| 1447 | |
| 1448 | void |
| 1449 | bfa_comp_process(struct bfa_s *bfa, struct list_head *comp_q) |
| 1450 | { |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1451 | struct list_head *qe; |
| 1452 | struct list_head *qen; |
| 1453 | struct bfa_cb_qe_s *hcb_qe; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1454 | |
| 1455 | list_for_each_safe(qe, qen, comp_q) { |
| 1456 | hcb_qe = (struct bfa_cb_qe_s *) qe; |
| 1457 | hcb_qe->cbfn(hcb_qe->cbarg, BFA_TRUE); |
| 1458 | } |
| 1459 | } |
| 1460 | |
| 1461 | void |
| 1462 | bfa_comp_free(struct bfa_s *bfa, struct list_head *comp_q) |
| 1463 | { |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1464 | struct list_head *qe; |
| 1465 | struct bfa_cb_qe_s *hcb_qe; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1466 | |
| 1467 | while (!list_empty(comp_q)) { |
| 1468 | bfa_q_deq(comp_q, &qe); |
| 1469 | hcb_qe = (struct bfa_cb_qe_s *) qe; |
| 1470 | hcb_qe->cbfn(hcb_qe->cbarg, BFA_FALSE); |
| 1471 | } |
| 1472 | } |
| 1473 | |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1474 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 1475 | /* |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1476 | * Return the list of PCI vendor/device id lists supported by this |
| 1477 | * BFA instance. |
| 1478 | */ |
| 1479 | void |
| 1480 | bfa_get_pciids(struct bfa_pciid_s **pciids, int *npciids) |
| 1481 | { |
| 1482 | static struct bfa_pciid_s __pciids[] = { |
| 1483 | {BFA_PCI_VENDOR_ID_BROCADE, BFA_PCI_DEVICE_ID_FC_8G2P}, |
| 1484 | {BFA_PCI_VENDOR_ID_BROCADE, BFA_PCI_DEVICE_ID_FC_8G1P}, |
| 1485 | {BFA_PCI_VENDOR_ID_BROCADE, BFA_PCI_DEVICE_ID_CT}, |
Jing Huang | 293f82d | 2010-07-08 19:45:20 -0700 | [diff] [blame] | 1486 | {BFA_PCI_VENDOR_ID_BROCADE, BFA_PCI_DEVICE_ID_CT_FC}, |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1487 | }; |
| 1488 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1489 | *npciids = sizeof(__pciids) / sizeof(__pciids[0]); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1490 | *pciids = __pciids; |
| 1491 | } |
| 1492 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 1493 | /* |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1494 | * Use this function query the default struct bfa_iocfc_cfg_s value (compiled |
| 1495 | * into BFA layer). The OS driver can then turn back and overwrite entries that |
| 1496 | * have been configured by the user. |
| 1497 | * |
| 1498 | * @param[in] cfg - pointer to bfa_ioc_cfg_t |
| 1499 | * |
| 1500 | * @return |
| 1501 | * void |
| 1502 | * |
| 1503 | * Special Considerations: |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1504 | * note |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1505 | */ |
| 1506 | void |
| 1507 | bfa_cfg_get_default(struct bfa_iocfc_cfg_s *cfg) |
| 1508 | { |
| 1509 | cfg->fwcfg.num_fabrics = DEF_CFG_NUM_FABRICS; |
| 1510 | cfg->fwcfg.num_lports = DEF_CFG_NUM_LPORTS; |
| 1511 | cfg->fwcfg.num_rports = DEF_CFG_NUM_RPORTS; |
| 1512 | cfg->fwcfg.num_ioim_reqs = DEF_CFG_NUM_IOIM_REQS; |
| 1513 | cfg->fwcfg.num_tskim_reqs = DEF_CFG_NUM_TSKIM_REQS; |
| 1514 | cfg->fwcfg.num_fcxp_reqs = DEF_CFG_NUM_FCXP_REQS; |
| 1515 | cfg->fwcfg.num_uf_bufs = DEF_CFG_NUM_UF_BUFS; |
| 1516 | cfg->fwcfg.num_cqs = DEF_CFG_NUM_CQS; |
Krishna Gudipati | e2187d7 | 2011-06-13 15:53:58 -0700 | [diff] [blame] | 1517 | cfg->fwcfg.num_fwtio_reqs = 0; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1518 | |
| 1519 | cfg->drvcfg.num_reqq_elems = DEF_CFG_NUM_REQQ_ELEMS; |
| 1520 | cfg->drvcfg.num_rspq_elems = DEF_CFG_NUM_RSPQ_ELEMS; |
| 1521 | cfg->drvcfg.num_sgpgs = DEF_CFG_NUM_SGPGS; |
| 1522 | cfg->drvcfg.num_sboot_tgts = DEF_CFG_NUM_SBOOT_TGTS; |
| 1523 | cfg->drvcfg.num_sboot_luns = DEF_CFG_NUM_SBOOT_LUNS; |
| 1524 | cfg->drvcfg.path_tov = BFA_FCPIM_PATHTOV_DEF; |
| 1525 | cfg->drvcfg.ioc_recover = BFA_FALSE; |
| 1526 | cfg->drvcfg.delay_comp = BFA_FALSE; |
| 1527 | |
| 1528 | } |
| 1529 | |
| 1530 | void |
| 1531 | bfa_cfg_get_min(struct bfa_iocfc_cfg_s *cfg) |
| 1532 | { |
| 1533 | bfa_cfg_get_default(cfg); |
| 1534 | cfg->fwcfg.num_ioim_reqs = BFA_IOIM_MIN; |
| 1535 | cfg->fwcfg.num_tskim_reqs = BFA_TSKIM_MIN; |
| 1536 | cfg->fwcfg.num_fcxp_reqs = BFA_FCXP_MIN; |
| 1537 | cfg->fwcfg.num_uf_bufs = BFA_UF_MIN; |
| 1538 | cfg->fwcfg.num_rports = BFA_RPORT_MIN; |
Krishna Gudipati | e2187d7 | 2011-06-13 15:53:58 -0700 | [diff] [blame] | 1539 | cfg->fwcfg.num_fwtio_reqs = 0; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1540 | |
| 1541 | cfg->drvcfg.num_sgpgs = BFA_SGPG_MIN; |
| 1542 | cfg->drvcfg.num_reqq_elems = BFA_REQQ_NELEMS_MIN; |
| 1543 | cfg->drvcfg.num_rspq_elems = BFA_RSPQ_NELEMS_MIN; |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1544 | cfg->drvcfg.min_cfg = BFA_TRUE; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1545 | } |