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