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 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 18 | #include "bfa_modules.h" |
| 19 | #include "bfi_ctreg.h" |
| 20 | #include "bfad_drv.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 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 25 | * BFA IOC FC related definitions |
| 26 | */ |
| 27 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 28 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 29 | * IOC local definitions |
| 30 | */ |
| 31 | #define BFA_IOCFC_TOV 5000 /* msecs */ |
| 32 | |
| 33 | enum { |
| 34 | BFA_IOCFC_ACT_NONE = 0, |
| 35 | BFA_IOCFC_ACT_INIT = 1, |
| 36 | BFA_IOCFC_ACT_STOP = 2, |
| 37 | BFA_IOCFC_ACT_DISABLE = 3, |
| 38 | }; |
| 39 | |
| 40 | #define DEF_CFG_NUM_FABRICS 1 |
| 41 | #define DEF_CFG_NUM_LPORTS 256 |
| 42 | #define DEF_CFG_NUM_CQS 4 |
| 43 | #define DEF_CFG_NUM_IOIM_REQS (BFA_IOIM_MAX) |
| 44 | #define DEF_CFG_NUM_TSKIM_REQS 128 |
| 45 | #define DEF_CFG_NUM_FCXP_REQS 64 |
| 46 | #define DEF_CFG_NUM_UF_BUFS 64 |
| 47 | #define DEF_CFG_NUM_RPORTS 1024 |
| 48 | #define DEF_CFG_NUM_ITNIMS (DEF_CFG_NUM_RPORTS) |
| 49 | #define DEF_CFG_NUM_TINS 256 |
| 50 | |
| 51 | #define DEF_CFG_NUM_SGPGS 2048 |
| 52 | #define DEF_CFG_NUM_REQQ_ELEMS 256 |
| 53 | #define DEF_CFG_NUM_RSPQ_ELEMS 64 |
| 54 | #define DEF_CFG_NUM_SBOOT_TGTS 16 |
| 55 | #define DEF_CFG_NUM_SBOOT_LUNS 16 |
| 56 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 57 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 58 | * forward declaration for IOC FC functions |
| 59 | */ |
| 60 | static void bfa_iocfc_enable_cbfn(void *bfa_arg, enum bfa_status status); |
| 61 | static void bfa_iocfc_disable_cbfn(void *bfa_arg); |
| 62 | static void bfa_iocfc_hbfail_cbfn(void *bfa_arg); |
| 63 | static void bfa_iocfc_reset_cbfn(void *bfa_arg); |
| 64 | static struct bfa_ioc_cbfn_s bfa_iocfc_cbfn; |
| 65 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 66 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 67 | * BFA Interrupt handling functions |
| 68 | */ |
| 69 | static void |
| 70 | bfa_msix_errint(struct bfa_s *bfa, u32 intr) |
| 71 | { |
| 72 | bfa_ioc_error_isr(&bfa->ioc); |
| 73 | } |
| 74 | |
| 75 | static void |
| 76 | bfa_msix_lpu(struct bfa_s *bfa) |
| 77 | { |
| 78 | bfa_ioc_mbox_isr(&bfa->ioc); |
| 79 | } |
| 80 | |
| 81 | static void |
| 82 | bfa_reqq_resume(struct bfa_s *bfa, int qid) |
| 83 | { |
| 84 | struct list_head *waitq, *qe, *qen; |
| 85 | struct bfa_reqq_wait_s *wqe; |
| 86 | |
| 87 | waitq = bfa_reqq(bfa, qid); |
| 88 | list_for_each_safe(qe, qen, waitq) { |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 89 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 90 | * Callback only as long as there is room in request queue |
| 91 | */ |
| 92 | if (bfa_reqq_full(bfa, qid)) |
| 93 | break; |
| 94 | |
| 95 | list_del(qe); |
| 96 | wqe = (struct bfa_reqq_wait_s *) qe; |
| 97 | wqe->qresume(wqe->cbarg); |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | void |
| 102 | bfa_msix_all(struct bfa_s *bfa, int vec) |
| 103 | { |
| 104 | bfa_intx(bfa); |
| 105 | } |
| 106 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 107 | bfa_boolean_t |
| 108 | bfa_intx(struct bfa_s *bfa) |
| 109 | { |
| 110 | u32 intr, qintr; |
| 111 | int queue; |
| 112 | |
Jing Huang | 5344026 | 2010-10-18 17:12:29 -0700 | [diff] [blame] | 113 | intr = readl(bfa->iocfc.bfa_regs.intr_status); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 114 | if (!intr) |
| 115 | return BFA_FALSE; |
| 116 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 117 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 118 | * RME completion queue interrupt |
| 119 | */ |
| 120 | qintr = intr & __HFN_INT_RME_MASK; |
Jing Huang | 5344026 | 2010-10-18 17:12:29 -0700 | [diff] [blame] | 121 | writel(qintr, bfa->iocfc.bfa_regs.intr_status); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 122 | |
| 123 | for (queue = 0; queue < BFI_IOC_MAX_CQS_ASIC; queue++) { |
| 124 | if (intr & (__HFN_INT_RME_Q0 << queue)) |
| 125 | bfa_msix_rspq(bfa, queue & (BFI_IOC_MAX_CQS - 1)); |
| 126 | } |
| 127 | intr &= ~qintr; |
| 128 | if (!intr) |
| 129 | return BFA_TRUE; |
| 130 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 131 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 132 | * CPE completion queue interrupt |
| 133 | */ |
| 134 | qintr = intr & __HFN_INT_CPE_MASK; |
Jing Huang | 5344026 | 2010-10-18 17:12:29 -0700 | [diff] [blame] | 135 | writel(qintr, bfa->iocfc.bfa_regs.intr_status); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 136 | |
| 137 | for (queue = 0; queue < BFI_IOC_MAX_CQS_ASIC; queue++) { |
| 138 | if (intr & (__HFN_INT_CPE_Q0 << queue)) |
| 139 | bfa_msix_reqq(bfa, queue & (BFI_IOC_MAX_CQS - 1)); |
| 140 | } |
| 141 | intr &= ~qintr; |
| 142 | if (!intr) |
| 143 | return BFA_TRUE; |
| 144 | |
| 145 | bfa_msix_lpu_err(bfa, intr); |
| 146 | |
| 147 | return BFA_TRUE; |
| 148 | } |
| 149 | |
| 150 | void |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 151 | bfa_isr_enable(struct bfa_s *bfa) |
| 152 | { |
| 153 | u32 intr_unmask; |
| 154 | int pci_func = bfa_ioc_pcifn(&bfa->ioc); |
| 155 | |
| 156 | bfa_trc(bfa, pci_func); |
| 157 | |
| 158 | bfa_msix_install(bfa); |
| 159 | intr_unmask = (__HFN_INT_ERR_EMC | __HFN_INT_ERR_LPU0 | |
| 160 | __HFN_INT_ERR_LPU1 | __HFN_INT_ERR_PSS | |
| 161 | __HFN_INT_LL_HALT); |
| 162 | |
| 163 | if (pci_func == 0) |
| 164 | intr_unmask |= (__HFN_INT_CPE_Q0 | __HFN_INT_CPE_Q1 | |
| 165 | __HFN_INT_CPE_Q2 | __HFN_INT_CPE_Q3 | |
| 166 | __HFN_INT_RME_Q0 | __HFN_INT_RME_Q1 | |
| 167 | __HFN_INT_RME_Q2 | __HFN_INT_RME_Q3 | |
| 168 | __HFN_INT_MBOX_LPU0); |
| 169 | else |
| 170 | intr_unmask |= (__HFN_INT_CPE_Q4 | __HFN_INT_CPE_Q5 | |
| 171 | __HFN_INT_CPE_Q6 | __HFN_INT_CPE_Q7 | |
| 172 | __HFN_INT_RME_Q4 | __HFN_INT_RME_Q5 | |
| 173 | __HFN_INT_RME_Q6 | __HFN_INT_RME_Q7 | |
| 174 | __HFN_INT_MBOX_LPU1); |
| 175 | |
Jing Huang | 5344026 | 2010-10-18 17:12:29 -0700 | [diff] [blame] | 176 | writel(intr_unmask, bfa->iocfc.bfa_regs.intr_status); |
| 177 | writel(~intr_unmask, bfa->iocfc.bfa_regs.intr_mask); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 178 | bfa->iocfc.intr_mask = ~intr_unmask; |
| 179 | bfa_isr_mode_set(bfa, bfa->msix.nvecs != 0); |
| 180 | } |
| 181 | |
| 182 | void |
| 183 | bfa_isr_disable(struct bfa_s *bfa) |
| 184 | { |
| 185 | bfa_isr_mode_set(bfa, BFA_FALSE); |
Jing Huang | 5344026 | 2010-10-18 17:12:29 -0700 | [diff] [blame] | 186 | writel(-1L, bfa->iocfc.bfa_regs.intr_mask); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 187 | bfa_msix_uninstall(bfa); |
| 188 | } |
| 189 | |
| 190 | void |
| 191 | bfa_msix_reqq(struct bfa_s *bfa, int qid) |
| 192 | { |
| 193 | struct list_head *waitq; |
| 194 | |
| 195 | qid &= (BFI_IOC_MAX_CQS - 1); |
| 196 | |
| 197 | bfa->iocfc.hwif.hw_reqq_ack(bfa, qid); |
| 198 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 199 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 200 | * Resume any pending requests in the corresponding reqq. |
| 201 | */ |
| 202 | waitq = bfa_reqq(bfa, qid); |
| 203 | if (!list_empty(waitq)) |
| 204 | bfa_reqq_resume(bfa, qid); |
| 205 | } |
| 206 | |
| 207 | void |
| 208 | bfa_isr_unhandled(struct bfa_s *bfa, struct bfi_msg_s *m) |
| 209 | { |
| 210 | bfa_trc(bfa, m->mhdr.msg_class); |
| 211 | bfa_trc(bfa, m->mhdr.msg_id); |
| 212 | bfa_trc(bfa, m->mhdr.mtag.i2htok); |
| 213 | bfa_assert(0); |
| 214 | bfa_trc_stop(bfa->trcmod); |
| 215 | } |
| 216 | |
| 217 | void |
| 218 | bfa_msix_rspq(struct bfa_s *bfa, int qid) |
| 219 | { |
| 220 | struct bfi_msg_s *m; |
| 221 | u32 pi, ci; |
| 222 | struct list_head *waitq; |
| 223 | |
| 224 | bfa_trc_fp(bfa, qid); |
| 225 | |
| 226 | qid &= (BFI_IOC_MAX_CQS - 1); |
| 227 | |
| 228 | bfa->iocfc.hwif.hw_rspq_ack(bfa, qid); |
| 229 | |
| 230 | ci = bfa_rspq_ci(bfa, qid); |
| 231 | pi = bfa_rspq_pi(bfa, qid); |
| 232 | |
| 233 | bfa_trc_fp(bfa, ci); |
| 234 | bfa_trc_fp(bfa, pi); |
| 235 | |
| 236 | if (bfa->rme_process) { |
| 237 | while (ci != pi) { |
| 238 | m = bfa_rspq_elem(bfa, qid, ci); |
| 239 | bfa_assert_fp(m->mhdr.msg_class < BFI_MC_MAX); |
| 240 | |
| 241 | bfa_isrs[m->mhdr.msg_class] (bfa, m); |
| 242 | |
| 243 | CQ_INCR(ci, bfa->iocfc.cfg.drvcfg.num_rspq_elems); |
| 244 | } |
| 245 | } |
| 246 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 247 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 248 | * update CI |
| 249 | */ |
| 250 | bfa_rspq_ci(bfa, qid) = pi; |
Jing Huang | 5344026 | 2010-10-18 17:12:29 -0700 | [diff] [blame] | 251 | writel(pi, bfa->iocfc.bfa_regs.rme_q_ci[qid]); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 252 | mmiowb(); |
| 253 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 254 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 255 | * Resume any pending requests in the corresponding reqq. |
| 256 | */ |
| 257 | waitq = bfa_reqq(bfa, qid); |
| 258 | if (!list_empty(waitq)) |
| 259 | bfa_reqq_resume(bfa, qid); |
| 260 | } |
| 261 | |
| 262 | void |
| 263 | bfa_msix_lpu_err(struct bfa_s *bfa, int vec) |
| 264 | { |
| 265 | u32 intr, curr_value; |
| 266 | |
Jing Huang | 5344026 | 2010-10-18 17:12:29 -0700 | [diff] [blame] | 267 | intr = readl(bfa->iocfc.bfa_regs.intr_status); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 268 | |
| 269 | if (intr & (__HFN_INT_MBOX_LPU0 | __HFN_INT_MBOX_LPU1)) |
| 270 | bfa_msix_lpu(bfa); |
| 271 | |
| 272 | intr &= (__HFN_INT_ERR_EMC | __HFN_INT_ERR_LPU0 | |
| 273 | __HFN_INT_ERR_LPU1 | __HFN_INT_ERR_PSS | __HFN_INT_LL_HALT); |
| 274 | |
| 275 | if (intr) { |
| 276 | if (intr & __HFN_INT_LL_HALT) { |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 277 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 278 | * If LL_HALT bit is set then FW Init Halt LL Port |
| 279 | * Register needs to be cleared as well so Interrupt |
| 280 | * Status Register will be cleared. |
| 281 | */ |
Jing Huang | 5344026 | 2010-10-18 17:12:29 -0700 | [diff] [blame] | 282 | curr_value = readl(bfa->ioc.ioc_regs.ll_halt); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 283 | curr_value &= ~__FW_INIT_HALT_P; |
Jing Huang | 5344026 | 2010-10-18 17:12:29 -0700 | [diff] [blame] | 284 | writel(curr_value, bfa->ioc.ioc_regs.ll_halt); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 285 | } |
| 286 | |
| 287 | if (intr & __HFN_INT_ERR_PSS) { |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 288 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 289 | * ERR_PSS bit needs to be cleared as well in case |
| 290 | * interrups are shared so driver's interrupt handler is |
| 291 | * still called eventhough it is already masked out. |
| 292 | */ |
Jing Huang | 5344026 | 2010-10-18 17:12:29 -0700 | [diff] [blame] | 293 | curr_value = readl( |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 294 | bfa->ioc.ioc_regs.pss_err_status_reg); |
| 295 | curr_value &= __PSS_ERR_STATUS_SET; |
Jing Huang | 5344026 | 2010-10-18 17:12:29 -0700 | [diff] [blame] | 296 | writel(curr_value, |
| 297 | bfa->ioc.ioc_regs.pss_err_status_reg); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 298 | } |
| 299 | |
Jing Huang | 5344026 | 2010-10-18 17:12:29 -0700 | [diff] [blame] | 300 | writel(intr, bfa->iocfc.bfa_regs.intr_status); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 301 | bfa_msix_errint(bfa, intr); |
| 302 | } |
| 303 | } |
| 304 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 305 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 306 | * BFA IOC FC related functions |
| 307 | */ |
| 308 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 309 | /* |
Maggie Zhang | df0f193 | 2010-12-09 19:07:46 -0800 | [diff] [blame^] | 310 | * BFA IOC private functions |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 311 | */ |
| 312 | |
| 313 | static void |
| 314 | bfa_iocfc_cqs_sz(struct bfa_iocfc_cfg_s *cfg, u32 *dm_len) |
| 315 | { |
| 316 | int i, per_reqq_sz, per_rspq_sz; |
| 317 | |
| 318 | per_reqq_sz = BFA_ROUNDUP((cfg->drvcfg.num_reqq_elems * BFI_LMSG_SZ), |
| 319 | BFA_DMA_ALIGN_SZ); |
| 320 | per_rspq_sz = BFA_ROUNDUP((cfg->drvcfg.num_rspq_elems * BFI_LMSG_SZ), |
| 321 | BFA_DMA_ALIGN_SZ); |
| 322 | |
| 323 | /* |
| 324 | * Calculate CQ size |
| 325 | */ |
| 326 | for (i = 0; i < cfg->fwcfg.num_cqs; i++) { |
| 327 | *dm_len = *dm_len + per_reqq_sz; |
| 328 | *dm_len = *dm_len + per_rspq_sz; |
| 329 | } |
| 330 | |
| 331 | /* |
| 332 | * Calculate Shadow CI/PI size |
| 333 | */ |
| 334 | for (i = 0; i < cfg->fwcfg.num_cqs; i++) |
| 335 | *dm_len += (2 * BFA_CACHELINE_SZ); |
| 336 | } |
| 337 | |
| 338 | static void |
| 339 | bfa_iocfc_fw_cfg_sz(struct bfa_iocfc_cfg_s *cfg, u32 *dm_len) |
| 340 | { |
| 341 | *dm_len += |
| 342 | BFA_ROUNDUP(sizeof(struct bfi_iocfc_cfg_s), BFA_CACHELINE_SZ); |
| 343 | *dm_len += |
| 344 | BFA_ROUNDUP(sizeof(struct bfi_iocfc_cfgrsp_s), |
| 345 | BFA_CACHELINE_SZ); |
| 346 | } |
| 347 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 348 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 349 | * Use the Mailbox interface to send BFI_IOCFC_H2I_CFG_REQ |
| 350 | */ |
| 351 | static void |
| 352 | bfa_iocfc_send_cfg(void *bfa_arg) |
| 353 | { |
| 354 | struct bfa_s *bfa = bfa_arg; |
| 355 | struct bfa_iocfc_s *iocfc = &bfa->iocfc; |
| 356 | struct bfi_iocfc_cfg_req_s cfg_req; |
| 357 | struct bfi_iocfc_cfg_s *cfg_info = iocfc->cfginfo; |
| 358 | struct bfa_iocfc_cfg_s *cfg = &iocfc->cfg; |
| 359 | int i; |
| 360 | |
| 361 | bfa_assert(cfg->fwcfg.num_cqs <= BFI_IOC_MAX_CQS); |
| 362 | bfa_trc(bfa, cfg->fwcfg.num_cqs); |
| 363 | |
| 364 | bfa_iocfc_reset_queues(bfa); |
| 365 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 366 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 367 | * initialize IOC configuration info |
| 368 | */ |
| 369 | cfg_info->endian_sig = BFI_IOC_ENDIAN_SIG; |
| 370 | cfg_info->num_cqs = cfg->fwcfg.num_cqs; |
| 371 | |
| 372 | 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] | 373 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 374 | * dma map REQ and RSP circular queues and shadow pointers |
| 375 | */ |
| 376 | for (i = 0; i < cfg->fwcfg.num_cqs; i++) { |
| 377 | bfa_dma_be_addr_set(cfg_info->req_cq_ba[i], |
| 378 | iocfc->req_cq_ba[i].pa); |
| 379 | bfa_dma_be_addr_set(cfg_info->req_shadow_ci[i], |
| 380 | iocfc->req_cq_shadow_ci[i].pa); |
| 381 | cfg_info->req_cq_elems[i] = |
Jing Huang | ba816ea | 2010-10-18 17:10:50 -0700 | [diff] [blame] | 382 | cpu_to_be16(cfg->drvcfg.num_reqq_elems); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 383 | |
| 384 | bfa_dma_be_addr_set(cfg_info->rsp_cq_ba[i], |
| 385 | iocfc->rsp_cq_ba[i].pa); |
| 386 | bfa_dma_be_addr_set(cfg_info->rsp_shadow_pi[i], |
| 387 | iocfc->rsp_cq_shadow_pi[i].pa); |
| 388 | cfg_info->rsp_cq_elems[i] = |
Jing Huang | ba816ea | 2010-10-18 17:10:50 -0700 | [diff] [blame] | 389 | cpu_to_be16(cfg->drvcfg.num_rspq_elems); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 390 | } |
| 391 | |
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 | * Enable interrupt coalescing if it is driver init path |
| 394 | * and not ioc disable/enable path. |
| 395 | */ |
| 396 | if (!iocfc->cfgdone) |
| 397 | cfg_info->intr_attr.coalesce = BFA_TRUE; |
| 398 | |
| 399 | iocfc->cfgdone = BFA_FALSE; |
| 400 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 401 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 402 | * dma map IOC configuration itself |
| 403 | */ |
| 404 | bfi_h2i_set(cfg_req.mh, BFI_MC_IOCFC, BFI_IOCFC_H2I_CFG_REQ, |
| 405 | bfa_lpuid(bfa)); |
| 406 | bfa_dma_be_addr_set(cfg_req.ioc_cfg_dma_addr, iocfc->cfg_info.pa); |
| 407 | |
| 408 | bfa_ioc_mbox_send(&bfa->ioc, &cfg_req, |
| 409 | sizeof(struct bfi_iocfc_cfg_req_s)); |
| 410 | } |
| 411 | |
| 412 | static void |
| 413 | bfa_iocfc_init_mem(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg, |
| 414 | struct bfa_pcidev_s *pcidev) |
| 415 | { |
| 416 | struct bfa_iocfc_s *iocfc = &bfa->iocfc; |
| 417 | |
| 418 | bfa->bfad = bfad; |
| 419 | iocfc->bfa = bfa; |
| 420 | iocfc->action = BFA_IOCFC_ACT_NONE; |
| 421 | |
Jing Huang | 6a18b16 | 2010-10-18 17:08:54 -0700 | [diff] [blame] | 422 | iocfc->cfg = *cfg; |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 423 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 424 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 425 | * Initialize chip specific handlers. |
| 426 | */ |
| 427 | if (bfa_asic_id_ct(bfa_ioc_devid(&bfa->ioc))) { |
| 428 | iocfc->hwif.hw_reginit = bfa_hwct_reginit; |
| 429 | iocfc->hwif.hw_reqq_ack = bfa_hwct_reqq_ack; |
| 430 | iocfc->hwif.hw_rspq_ack = bfa_hwct_rspq_ack; |
| 431 | iocfc->hwif.hw_msix_init = bfa_hwct_msix_init; |
| 432 | iocfc->hwif.hw_msix_install = bfa_hwct_msix_install; |
| 433 | iocfc->hwif.hw_msix_uninstall = bfa_hwct_msix_uninstall; |
| 434 | iocfc->hwif.hw_isr_mode_set = bfa_hwct_isr_mode_set; |
| 435 | iocfc->hwif.hw_msix_getvecs = bfa_hwct_msix_getvecs; |
| 436 | iocfc->hwif.hw_msix_get_rme_range = bfa_hwct_msix_get_rme_range; |
| 437 | } else { |
| 438 | iocfc->hwif.hw_reginit = bfa_hwcb_reginit; |
| 439 | iocfc->hwif.hw_reqq_ack = bfa_hwcb_reqq_ack; |
| 440 | iocfc->hwif.hw_rspq_ack = bfa_hwcb_rspq_ack; |
| 441 | iocfc->hwif.hw_msix_init = bfa_hwcb_msix_init; |
| 442 | iocfc->hwif.hw_msix_install = bfa_hwcb_msix_install; |
| 443 | iocfc->hwif.hw_msix_uninstall = bfa_hwcb_msix_uninstall; |
| 444 | iocfc->hwif.hw_isr_mode_set = bfa_hwcb_isr_mode_set; |
| 445 | iocfc->hwif.hw_msix_getvecs = bfa_hwcb_msix_getvecs; |
| 446 | iocfc->hwif.hw_msix_get_rme_range = bfa_hwcb_msix_get_rme_range; |
| 447 | } |
| 448 | |
| 449 | iocfc->hwif.hw_reginit(bfa); |
| 450 | bfa->msix.nvecs = 0; |
| 451 | } |
| 452 | |
| 453 | static void |
| 454 | bfa_iocfc_mem_claim(struct bfa_s *bfa, struct bfa_iocfc_cfg_s *cfg, |
| 455 | struct bfa_meminfo_s *meminfo) |
| 456 | { |
| 457 | u8 *dm_kva; |
| 458 | u64 dm_pa; |
| 459 | int i, per_reqq_sz, per_rspq_sz; |
| 460 | struct bfa_iocfc_s *iocfc = &bfa->iocfc; |
| 461 | int dbgsz; |
| 462 | |
| 463 | dm_kva = bfa_meminfo_dma_virt(meminfo); |
| 464 | dm_pa = bfa_meminfo_dma_phys(meminfo); |
| 465 | |
| 466 | /* |
| 467 | * First allocate dma memory for IOC. |
| 468 | */ |
| 469 | bfa_ioc_mem_claim(&bfa->ioc, dm_kva, dm_pa); |
| 470 | dm_kva += bfa_ioc_meminfo(); |
| 471 | dm_pa += bfa_ioc_meminfo(); |
| 472 | |
| 473 | /* |
| 474 | * Claim DMA-able memory for the request/response queues and for shadow |
| 475 | * ci/pi registers |
| 476 | */ |
| 477 | per_reqq_sz = BFA_ROUNDUP((cfg->drvcfg.num_reqq_elems * BFI_LMSG_SZ), |
| 478 | BFA_DMA_ALIGN_SZ); |
| 479 | per_rspq_sz = BFA_ROUNDUP((cfg->drvcfg.num_rspq_elems * BFI_LMSG_SZ), |
| 480 | BFA_DMA_ALIGN_SZ); |
| 481 | |
| 482 | for (i = 0; i < cfg->fwcfg.num_cqs; i++) { |
| 483 | iocfc->req_cq_ba[i].kva = dm_kva; |
| 484 | iocfc->req_cq_ba[i].pa = dm_pa; |
Jing Huang | 6a18b16 | 2010-10-18 17:08:54 -0700 | [diff] [blame] | 485 | memset(dm_kva, 0, per_reqq_sz); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 486 | dm_kva += per_reqq_sz; |
| 487 | dm_pa += per_reqq_sz; |
| 488 | |
| 489 | iocfc->rsp_cq_ba[i].kva = dm_kva; |
| 490 | iocfc->rsp_cq_ba[i].pa = dm_pa; |
Jing Huang | 6a18b16 | 2010-10-18 17:08:54 -0700 | [diff] [blame] | 491 | memset(dm_kva, 0, per_rspq_sz); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 492 | dm_kva += per_rspq_sz; |
| 493 | dm_pa += per_rspq_sz; |
| 494 | } |
| 495 | |
| 496 | for (i = 0; i < cfg->fwcfg.num_cqs; i++) { |
| 497 | iocfc->req_cq_shadow_ci[i].kva = dm_kva; |
| 498 | iocfc->req_cq_shadow_ci[i].pa = dm_pa; |
| 499 | dm_kva += BFA_CACHELINE_SZ; |
| 500 | dm_pa += BFA_CACHELINE_SZ; |
| 501 | |
| 502 | iocfc->rsp_cq_shadow_pi[i].kva = dm_kva; |
| 503 | iocfc->rsp_cq_shadow_pi[i].pa = dm_pa; |
| 504 | dm_kva += BFA_CACHELINE_SZ; |
| 505 | dm_pa += BFA_CACHELINE_SZ; |
| 506 | } |
| 507 | |
| 508 | /* |
| 509 | * Claim DMA-able memory for the config info page |
| 510 | */ |
| 511 | bfa->iocfc.cfg_info.kva = dm_kva; |
| 512 | bfa->iocfc.cfg_info.pa = dm_pa; |
| 513 | bfa->iocfc.cfginfo = (struct bfi_iocfc_cfg_s *) dm_kva; |
| 514 | dm_kva += BFA_ROUNDUP(sizeof(struct bfi_iocfc_cfg_s), BFA_CACHELINE_SZ); |
| 515 | dm_pa += BFA_ROUNDUP(sizeof(struct bfi_iocfc_cfg_s), BFA_CACHELINE_SZ); |
| 516 | |
| 517 | /* |
| 518 | * Claim DMA-able memory for the config response |
| 519 | */ |
| 520 | bfa->iocfc.cfgrsp_dma.kva = dm_kva; |
| 521 | bfa->iocfc.cfgrsp_dma.pa = dm_pa; |
| 522 | bfa->iocfc.cfgrsp = (struct bfi_iocfc_cfgrsp_s *) dm_kva; |
| 523 | |
| 524 | dm_kva += |
| 525 | BFA_ROUNDUP(sizeof(struct bfi_iocfc_cfgrsp_s), |
| 526 | BFA_CACHELINE_SZ); |
| 527 | dm_pa += BFA_ROUNDUP(sizeof(struct bfi_iocfc_cfgrsp_s), |
| 528 | BFA_CACHELINE_SZ); |
| 529 | |
| 530 | |
| 531 | bfa_meminfo_dma_virt(meminfo) = dm_kva; |
| 532 | bfa_meminfo_dma_phys(meminfo) = dm_pa; |
| 533 | |
| 534 | dbgsz = bfa_ioc_debug_trcsz(bfa_auto_recover); |
| 535 | if (dbgsz > 0) { |
| 536 | bfa_ioc_debug_memclaim(&bfa->ioc, bfa_meminfo_kva(meminfo)); |
| 537 | bfa_meminfo_kva(meminfo) += dbgsz; |
| 538 | } |
| 539 | } |
| 540 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 541 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 542 | * Start BFA submodules. |
| 543 | */ |
| 544 | static void |
| 545 | bfa_iocfc_start_submod(struct bfa_s *bfa) |
| 546 | { |
| 547 | int i; |
| 548 | |
| 549 | bfa->rme_process = BFA_TRUE; |
| 550 | |
| 551 | for (i = 0; hal_mods[i]; i++) |
| 552 | hal_mods[i]->start(bfa); |
| 553 | } |
| 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 | * Disable BFA submodules. |
| 557 | */ |
| 558 | static void |
| 559 | bfa_iocfc_disable_submod(struct bfa_s *bfa) |
| 560 | { |
| 561 | int i; |
| 562 | |
| 563 | for (i = 0; hal_mods[i]; i++) |
| 564 | hal_mods[i]->iocdisable(bfa); |
| 565 | } |
| 566 | |
| 567 | static void |
| 568 | bfa_iocfc_init_cb(void *bfa_arg, bfa_boolean_t complete) |
| 569 | { |
| 570 | struct bfa_s *bfa = bfa_arg; |
| 571 | |
| 572 | if (complete) { |
| 573 | if (bfa->iocfc.cfgdone) |
| 574 | bfa_cb_init(bfa->bfad, BFA_STATUS_OK); |
| 575 | else |
| 576 | bfa_cb_init(bfa->bfad, BFA_STATUS_FAILED); |
| 577 | } else { |
| 578 | if (bfa->iocfc.cfgdone) |
| 579 | bfa->iocfc.action = BFA_IOCFC_ACT_NONE; |
| 580 | } |
| 581 | } |
| 582 | |
| 583 | static void |
| 584 | bfa_iocfc_stop_cb(void *bfa_arg, bfa_boolean_t compl) |
| 585 | { |
| 586 | struct bfa_s *bfa = bfa_arg; |
| 587 | struct bfad_s *bfad = bfa->bfad; |
| 588 | |
| 589 | if (compl) |
| 590 | complete(&bfad->comp); |
| 591 | else |
| 592 | bfa->iocfc.action = BFA_IOCFC_ACT_NONE; |
| 593 | } |
| 594 | |
| 595 | static void |
| 596 | bfa_iocfc_disable_cb(void *bfa_arg, bfa_boolean_t compl) |
| 597 | { |
| 598 | struct bfa_s *bfa = bfa_arg; |
| 599 | struct bfad_s *bfad = bfa->bfad; |
| 600 | |
| 601 | if (compl) |
| 602 | complete(&bfad->disable_comp); |
| 603 | } |
| 604 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 605 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 606 | * Update BFA configuration from firmware configuration. |
| 607 | */ |
| 608 | static void |
| 609 | bfa_iocfc_cfgrsp(struct bfa_s *bfa) |
| 610 | { |
| 611 | struct bfa_iocfc_s *iocfc = &bfa->iocfc; |
| 612 | struct bfi_iocfc_cfgrsp_s *cfgrsp = iocfc->cfgrsp; |
| 613 | struct bfa_iocfc_fwcfg_s *fwcfg = &cfgrsp->fwcfg; |
| 614 | |
| 615 | fwcfg->num_cqs = fwcfg->num_cqs; |
Jing Huang | ba816ea | 2010-10-18 17:10:50 -0700 | [diff] [blame] | 616 | fwcfg->num_ioim_reqs = be16_to_cpu(fwcfg->num_ioim_reqs); |
| 617 | fwcfg->num_tskim_reqs = be16_to_cpu(fwcfg->num_tskim_reqs); |
| 618 | fwcfg->num_fcxp_reqs = be16_to_cpu(fwcfg->num_fcxp_reqs); |
| 619 | fwcfg->num_uf_bufs = be16_to_cpu(fwcfg->num_uf_bufs); |
| 620 | fwcfg->num_rports = be16_to_cpu(fwcfg->num_rports); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 621 | |
| 622 | iocfc->cfgdone = BFA_TRUE; |
| 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 | * Configuration is complete - initialize/start submodules |
| 626 | */ |
| 627 | bfa_fcport_init(bfa); |
| 628 | |
| 629 | if (iocfc->action == BFA_IOCFC_ACT_INIT) |
| 630 | bfa_cb_queue(bfa, &iocfc->init_hcb_qe, bfa_iocfc_init_cb, bfa); |
| 631 | else |
| 632 | bfa_iocfc_start_submod(bfa); |
| 633 | } |
| 634 | void |
| 635 | bfa_iocfc_reset_queues(struct bfa_s *bfa) |
| 636 | { |
| 637 | int q; |
| 638 | |
| 639 | for (q = 0; q < BFI_IOC_MAX_CQS; q++) { |
| 640 | bfa_reqq_ci(bfa, q) = 0; |
| 641 | bfa_reqq_pi(bfa, q) = 0; |
| 642 | bfa_rspq_ci(bfa, q) = 0; |
| 643 | bfa_rspq_pi(bfa, q) = 0; |
| 644 | } |
| 645 | } |
| 646 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 647 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 648 | * IOC enable request is complete |
| 649 | */ |
| 650 | static void |
| 651 | bfa_iocfc_enable_cbfn(void *bfa_arg, enum bfa_status status) |
| 652 | { |
| 653 | struct bfa_s *bfa = bfa_arg; |
| 654 | |
| 655 | if (status != BFA_STATUS_OK) { |
| 656 | bfa_isr_disable(bfa); |
| 657 | if (bfa->iocfc.action == BFA_IOCFC_ACT_INIT) |
| 658 | bfa_cb_queue(bfa, &bfa->iocfc.init_hcb_qe, |
| 659 | bfa_iocfc_init_cb, bfa); |
| 660 | return; |
| 661 | } |
| 662 | |
| 663 | bfa_iocfc_send_cfg(bfa); |
| 664 | } |
| 665 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 666 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 667 | * IOC disable request is complete |
| 668 | */ |
| 669 | static void |
| 670 | bfa_iocfc_disable_cbfn(void *bfa_arg) |
| 671 | { |
| 672 | struct bfa_s *bfa = bfa_arg; |
| 673 | |
| 674 | bfa_isr_disable(bfa); |
| 675 | bfa_iocfc_disable_submod(bfa); |
| 676 | |
| 677 | if (bfa->iocfc.action == BFA_IOCFC_ACT_STOP) |
| 678 | bfa_cb_queue(bfa, &bfa->iocfc.stop_hcb_qe, bfa_iocfc_stop_cb, |
| 679 | bfa); |
| 680 | else { |
| 681 | bfa_assert(bfa->iocfc.action == BFA_IOCFC_ACT_DISABLE); |
| 682 | bfa_cb_queue(bfa, &bfa->iocfc.dis_hcb_qe, bfa_iocfc_disable_cb, |
| 683 | bfa); |
| 684 | } |
| 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 | * Notify sub-modules of hardware failure. |
| 689 | */ |
| 690 | static void |
| 691 | bfa_iocfc_hbfail_cbfn(void *bfa_arg) |
| 692 | { |
| 693 | struct bfa_s *bfa = bfa_arg; |
| 694 | |
| 695 | bfa->rme_process = BFA_FALSE; |
| 696 | |
| 697 | bfa_isr_disable(bfa); |
| 698 | bfa_iocfc_disable_submod(bfa); |
| 699 | |
| 700 | if (bfa->iocfc.action == BFA_IOCFC_ACT_INIT) |
| 701 | bfa_cb_queue(bfa, &bfa->iocfc.init_hcb_qe, bfa_iocfc_init_cb, |
| 702 | bfa); |
| 703 | } |
| 704 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 705 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 706 | * Actions on chip-reset completion. |
| 707 | */ |
| 708 | static void |
| 709 | bfa_iocfc_reset_cbfn(void *bfa_arg) |
| 710 | { |
| 711 | struct bfa_s *bfa = bfa_arg; |
| 712 | |
| 713 | bfa_iocfc_reset_queues(bfa); |
| 714 | bfa_isr_enable(bfa); |
| 715 | } |
| 716 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 717 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 718 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 719 | * Query IOC memory requirement information. |
| 720 | */ |
| 721 | void |
| 722 | bfa_iocfc_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *km_len, |
| 723 | u32 *dm_len) |
| 724 | { |
| 725 | /* dma memory for IOC */ |
| 726 | *dm_len += bfa_ioc_meminfo(); |
| 727 | |
| 728 | bfa_iocfc_fw_cfg_sz(cfg, dm_len); |
| 729 | bfa_iocfc_cqs_sz(cfg, dm_len); |
| 730 | *km_len += bfa_ioc_debug_trcsz(bfa_auto_recover); |
| 731 | } |
| 732 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 733 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 734 | * Query IOC memory requirement information. |
| 735 | */ |
| 736 | void |
| 737 | bfa_iocfc_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg, |
| 738 | struct bfa_meminfo_s *meminfo, struct bfa_pcidev_s *pcidev) |
| 739 | { |
| 740 | int i; |
| 741 | struct bfa_ioc_s *ioc = &bfa->ioc; |
| 742 | |
| 743 | bfa_iocfc_cbfn.enable_cbfn = bfa_iocfc_enable_cbfn; |
| 744 | bfa_iocfc_cbfn.disable_cbfn = bfa_iocfc_disable_cbfn; |
| 745 | bfa_iocfc_cbfn.hbfail_cbfn = bfa_iocfc_hbfail_cbfn; |
| 746 | bfa_iocfc_cbfn.reset_cbfn = bfa_iocfc_reset_cbfn; |
| 747 | |
| 748 | ioc->trcmod = bfa->trcmod; |
| 749 | bfa_ioc_attach(&bfa->ioc, bfa, &bfa_iocfc_cbfn, &bfa->timer_mod); |
| 750 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 751 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 752 | * Set FC mode for BFA_PCI_DEVICE_ID_CT_FC. |
| 753 | */ |
| 754 | if (pcidev->device_id == BFA_PCI_DEVICE_ID_CT_FC) |
| 755 | bfa_ioc_set_fcmode(&bfa->ioc); |
| 756 | |
| 757 | bfa_ioc_pci_init(&bfa->ioc, pcidev, BFI_MC_IOCFC); |
| 758 | bfa_ioc_mbox_register(&bfa->ioc, bfa_mbox_isrs); |
| 759 | |
| 760 | bfa_iocfc_init_mem(bfa, bfad, cfg, pcidev); |
| 761 | bfa_iocfc_mem_claim(bfa, cfg, meminfo); |
| 762 | bfa_timer_init(&bfa->timer_mod); |
| 763 | |
| 764 | INIT_LIST_HEAD(&bfa->comp_q); |
| 765 | for (i = 0; i < BFI_IOC_MAX_CQS; i++) |
| 766 | INIT_LIST_HEAD(&bfa->reqq_waitq[i]); |
| 767 | } |
| 768 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 769 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 770 | * Query IOC memory requirement information. |
| 771 | */ |
| 772 | void |
| 773 | bfa_iocfc_detach(struct bfa_s *bfa) |
| 774 | { |
| 775 | bfa_ioc_detach(&bfa->ioc); |
| 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 | * Query IOC memory requirement information. |
| 780 | */ |
| 781 | void |
| 782 | bfa_iocfc_init(struct bfa_s *bfa) |
| 783 | { |
| 784 | bfa->iocfc.action = BFA_IOCFC_ACT_INIT; |
| 785 | bfa_ioc_enable(&bfa->ioc); |
| 786 | } |
| 787 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 788 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 789 | * IOC start called from bfa_start(). Called to start IOC operations |
| 790 | * at driver instantiation for this instance. |
| 791 | */ |
| 792 | void |
| 793 | bfa_iocfc_start(struct bfa_s *bfa) |
| 794 | { |
| 795 | if (bfa->iocfc.cfgdone) |
| 796 | bfa_iocfc_start_submod(bfa); |
| 797 | } |
| 798 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 799 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 800 | * IOC stop called from bfa_stop(). Called only when driver is unloaded |
| 801 | * for this instance. |
| 802 | */ |
| 803 | void |
| 804 | bfa_iocfc_stop(struct bfa_s *bfa) |
| 805 | { |
| 806 | bfa->iocfc.action = BFA_IOCFC_ACT_STOP; |
| 807 | |
| 808 | bfa->rme_process = BFA_FALSE; |
| 809 | bfa_ioc_disable(&bfa->ioc); |
| 810 | } |
| 811 | |
| 812 | void |
| 813 | bfa_iocfc_isr(void *bfaarg, struct bfi_mbmsg_s *m) |
| 814 | { |
| 815 | struct bfa_s *bfa = bfaarg; |
| 816 | struct bfa_iocfc_s *iocfc = &bfa->iocfc; |
| 817 | union bfi_iocfc_i2h_msg_u *msg; |
| 818 | |
| 819 | msg = (union bfi_iocfc_i2h_msg_u *) m; |
| 820 | bfa_trc(bfa, msg->mh.msg_id); |
| 821 | |
| 822 | switch (msg->mh.msg_id) { |
| 823 | case BFI_IOCFC_I2H_CFG_REPLY: |
| 824 | iocfc->cfg_reply = &msg->cfg_reply; |
| 825 | bfa_iocfc_cfgrsp(bfa); |
| 826 | break; |
| 827 | case BFI_IOCFC_I2H_UPDATEQ_RSP: |
| 828 | iocfc->updateq_cbfn(iocfc->updateq_cbarg, BFA_STATUS_OK); |
| 829 | break; |
| 830 | default: |
| 831 | bfa_assert(0); |
| 832 | } |
| 833 | } |
| 834 | |
| 835 | void |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 836 | bfa_iocfc_get_attr(struct bfa_s *bfa, struct bfa_iocfc_attr_s *attr) |
| 837 | { |
| 838 | struct bfa_iocfc_s *iocfc = &bfa->iocfc; |
| 839 | |
| 840 | attr->intr_attr.coalesce = iocfc->cfginfo->intr_attr.coalesce; |
| 841 | |
| 842 | attr->intr_attr.delay = iocfc->cfginfo->intr_attr.delay ? |
Jing Huang | ba816ea | 2010-10-18 17:10:50 -0700 | [diff] [blame] | 843 | be16_to_cpu(iocfc->cfginfo->intr_attr.delay) : |
| 844 | be16_to_cpu(iocfc->cfgrsp->intr_attr.delay); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 845 | |
| 846 | attr->intr_attr.latency = iocfc->cfginfo->intr_attr.latency ? |
Jing Huang | ba816ea | 2010-10-18 17:10:50 -0700 | [diff] [blame] | 847 | be16_to_cpu(iocfc->cfginfo->intr_attr.latency) : |
| 848 | be16_to_cpu(iocfc->cfgrsp->intr_attr.latency); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 849 | |
| 850 | attr->config = iocfc->cfg; |
| 851 | } |
| 852 | |
| 853 | bfa_status_t |
| 854 | bfa_iocfc_israttr_set(struct bfa_s *bfa, struct bfa_iocfc_intr_attr_s *attr) |
| 855 | { |
| 856 | struct bfa_iocfc_s *iocfc = &bfa->iocfc; |
| 857 | struct bfi_iocfc_set_intr_req_s *m; |
| 858 | |
| 859 | iocfc->cfginfo->intr_attr.coalesce = attr->coalesce; |
Jing Huang | ba816ea | 2010-10-18 17:10:50 -0700 | [diff] [blame] | 860 | iocfc->cfginfo->intr_attr.delay = cpu_to_be16(attr->delay); |
| 861 | iocfc->cfginfo->intr_attr.latency = cpu_to_be16(attr->latency); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 862 | |
| 863 | if (!bfa_iocfc_is_operational(bfa)) |
| 864 | return BFA_STATUS_OK; |
| 865 | |
| 866 | m = bfa_reqq_next(bfa, BFA_REQQ_IOC); |
| 867 | if (!m) |
| 868 | return BFA_STATUS_DEVBUSY; |
| 869 | |
| 870 | bfi_h2i_set(m->mh, BFI_MC_IOCFC, BFI_IOCFC_H2I_SET_INTR_REQ, |
| 871 | bfa_lpuid(bfa)); |
| 872 | m->coalesce = iocfc->cfginfo->intr_attr.coalesce; |
| 873 | m->delay = iocfc->cfginfo->intr_attr.delay; |
| 874 | m->latency = iocfc->cfginfo->intr_attr.latency; |
| 875 | |
| 876 | bfa_trc(bfa, attr->delay); |
| 877 | bfa_trc(bfa, attr->latency); |
| 878 | |
| 879 | bfa_reqq_produce(bfa, BFA_REQQ_IOC); |
| 880 | return BFA_STATUS_OK; |
| 881 | } |
| 882 | |
| 883 | void |
| 884 | bfa_iocfc_set_snsbase(struct bfa_s *bfa, u64 snsbase_pa) |
| 885 | { |
| 886 | struct bfa_iocfc_s *iocfc = &bfa->iocfc; |
| 887 | |
| 888 | iocfc->cfginfo->sense_buf_len = (BFI_IOIM_SNSLEN - 1); |
| 889 | bfa_dma_be_addr_set(iocfc->cfginfo->ioim_snsbase, snsbase_pa); |
| 890 | } |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 891 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 892 | * Enable IOC after it is disabled. |
| 893 | */ |
| 894 | void |
| 895 | bfa_iocfc_enable(struct bfa_s *bfa) |
| 896 | { |
| 897 | bfa_plog_str(bfa->plog, BFA_PL_MID_HAL, BFA_PL_EID_MISC, 0, |
| 898 | "IOC Enable"); |
| 899 | bfa_ioc_enable(&bfa->ioc); |
| 900 | } |
| 901 | |
| 902 | void |
| 903 | bfa_iocfc_disable(struct bfa_s *bfa) |
| 904 | { |
| 905 | bfa_plog_str(bfa->plog, BFA_PL_MID_HAL, BFA_PL_EID_MISC, 0, |
| 906 | "IOC Disable"); |
| 907 | bfa->iocfc.action = BFA_IOCFC_ACT_DISABLE; |
| 908 | |
| 909 | bfa->rme_process = BFA_FALSE; |
| 910 | bfa_ioc_disable(&bfa->ioc); |
| 911 | } |
| 912 | |
| 913 | |
| 914 | bfa_boolean_t |
| 915 | bfa_iocfc_is_operational(struct bfa_s *bfa) |
| 916 | { |
| 917 | return bfa_ioc_is_operational(&bfa->ioc) && bfa->iocfc.cfgdone; |
| 918 | } |
| 919 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 920 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 921 | * Return boot target port wwns -- read from boot information in flash. |
| 922 | */ |
| 923 | void |
| 924 | bfa_iocfc_get_bootwwns(struct bfa_s *bfa, u8 *nwwns, wwn_t *wwns) |
| 925 | { |
| 926 | struct bfa_iocfc_s *iocfc = &bfa->iocfc; |
| 927 | struct bfi_iocfc_cfgrsp_s *cfgrsp = iocfc->cfgrsp; |
| 928 | int i; |
| 929 | |
| 930 | if (cfgrsp->pbc_cfg.boot_enabled && cfgrsp->pbc_cfg.nbluns) { |
| 931 | bfa_trc(bfa, cfgrsp->pbc_cfg.nbluns); |
| 932 | *nwwns = cfgrsp->pbc_cfg.nbluns; |
| 933 | for (i = 0; i < cfgrsp->pbc_cfg.nbluns; i++) |
| 934 | wwns[i] = cfgrsp->pbc_cfg.blun[i].tgt_pwwn; |
| 935 | |
| 936 | return; |
| 937 | } |
| 938 | |
| 939 | *nwwns = cfgrsp->bootwwns.nwwns; |
| 940 | memcpy(wwns, cfgrsp->bootwwns.wwn, sizeof(cfgrsp->bootwwns.wwn)); |
| 941 | } |
| 942 | |
| 943 | void |
| 944 | bfa_iocfc_get_pbc_boot_cfg(struct bfa_s *bfa, struct bfa_boot_pbc_s *pbcfg) |
| 945 | { |
| 946 | struct bfa_iocfc_s *iocfc = &bfa->iocfc; |
| 947 | struct bfi_iocfc_cfgrsp_s *cfgrsp = iocfc->cfgrsp; |
| 948 | |
| 949 | pbcfg->enable = cfgrsp->pbc_cfg.boot_enabled; |
| 950 | pbcfg->nbluns = cfgrsp->pbc_cfg.nbluns; |
| 951 | pbcfg->speed = cfgrsp->pbc_cfg.port_speed; |
| 952 | memcpy(pbcfg->pblun, cfgrsp->pbc_cfg.blun, sizeof(pbcfg->pblun)); |
| 953 | } |
| 954 | |
| 955 | int |
| 956 | bfa_iocfc_get_pbc_vports(struct bfa_s *bfa, struct bfi_pbc_vport_s *pbc_vport) |
| 957 | { |
| 958 | struct bfa_iocfc_s *iocfc = &bfa->iocfc; |
| 959 | struct bfi_iocfc_cfgrsp_s *cfgrsp = iocfc->cfgrsp; |
| 960 | |
| 961 | memcpy(pbc_vport, cfgrsp->pbc_cfg.vport, sizeof(cfgrsp->pbc_cfg.vport)); |
| 962 | return cfgrsp->pbc_cfg.nvports; |
| 963 | } |
| 964 | |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 965 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 966 | /* |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 967 | * Use this function query the memory requirement of the BFA library. |
| 968 | * This function needs to be called before bfa_attach() to get the |
| 969 | * memory required of the BFA layer for a given driver configuration. |
| 970 | * |
| 971 | * This call will fail, if the cap is out of range compared to pre-defined |
| 972 | * values within the BFA library |
| 973 | * |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 974 | * @param[in] cfg - pointer to bfa_ioc_cfg_t. Driver layer should indicate |
| 975 | * its configuration in this structure. |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 976 | * The default values for struct bfa_iocfc_cfg_s can be |
| 977 | * fetched using bfa_cfg_get_default() API. |
| 978 | * |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 979 | * If cap's boundary check fails, the library will use |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 980 | * the default bfa_cap_t values (and log a warning msg). |
| 981 | * |
| 982 | * @param[out] meminfo - pointer to bfa_meminfo_t. This content |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 983 | * indicates the memory type (see bfa_mem_type_t) and |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 984 | * amount of memory required. |
| 985 | * |
| 986 | * Driver should allocate the memory, populate the |
| 987 | * starting address for each block and provide the same |
| 988 | * structure as input parameter to bfa_attach() call. |
| 989 | * |
| 990 | * @return void |
| 991 | * |
| 992 | * Special Considerations: @note |
| 993 | */ |
| 994 | void |
| 995 | bfa_cfg_get_meminfo(struct bfa_iocfc_cfg_s *cfg, struct bfa_meminfo_s *meminfo) |
| 996 | { |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 997 | int i; |
| 998 | u32 km_len = 0, dm_len = 0; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 999 | |
| 1000 | bfa_assert((cfg != NULL) && (meminfo != NULL)); |
| 1001 | |
Jing Huang | 6a18b16 | 2010-10-18 17:08:54 -0700 | [diff] [blame] | 1002 | memset((void *)meminfo, 0, sizeof(struct bfa_meminfo_s)); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1003 | meminfo->meminfo[BFA_MEM_TYPE_KVA - 1].mem_type = |
| 1004 | BFA_MEM_TYPE_KVA; |
| 1005 | meminfo->meminfo[BFA_MEM_TYPE_DMA - 1].mem_type = |
| 1006 | BFA_MEM_TYPE_DMA; |
| 1007 | |
| 1008 | bfa_iocfc_meminfo(cfg, &km_len, &dm_len); |
| 1009 | |
| 1010 | for (i = 0; hal_mods[i]; i++) |
| 1011 | hal_mods[i]->meminfo(cfg, &km_len, &dm_len); |
| 1012 | |
Krishna Gudipati | 7873ca4 | 2010-05-21 14:39:45 -0700 | [diff] [blame] | 1013 | dm_len += bfa_port_meminfo(); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1014 | |
| 1015 | meminfo->meminfo[BFA_MEM_TYPE_KVA - 1].mem_len = km_len; |
| 1016 | meminfo->meminfo[BFA_MEM_TYPE_DMA - 1].mem_len = dm_len; |
| 1017 | } |
| 1018 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 1019 | /* |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1020 | * Use this function to do attach the driver instance with the BFA |
| 1021 | * library. This function will not trigger any HW initialization |
| 1022 | * process (which will be done in bfa_init() call) |
| 1023 | * |
| 1024 | * This call will fail, if the cap is out of range compared to |
| 1025 | * pre-defined values within the BFA library |
| 1026 | * |
| 1027 | * @param[out] bfa Pointer to bfa_t. |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1028 | * @param[in] bfad Opaque handle back to the driver's IOC structure |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1029 | * @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] | 1030 | * that was used in bfa_cfg_get_meminfo(). |
| 1031 | * @param[in] meminfo Pointer to bfa_meminfo_t. The driver should |
| 1032 | * use the bfa_cfg_get_meminfo() call to |
| 1033 | * find the memory blocks required, allocate the |
| 1034 | * required memory and provide the starting addresses. |
| 1035 | * @param[in] pcidev pointer to struct bfa_pcidev_s |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1036 | * |
| 1037 | * @return |
| 1038 | * void |
| 1039 | * |
| 1040 | * Special Considerations: |
| 1041 | * |
| 1042 | * @note |
| 1043 | * |
| 1044 | */ |
| 1045 | void |
| 1046 | bfa_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg, |
| 1047 | struct bfa_meminfo_s *meminfo, struct bfa_pcidev_s *pcidev) |
| 1048 | { |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1049 | int i; |
| 1050 | struct bfa_mem_elem_s *melem; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1051 | |
| 1052 | bfa->fcs = BFA_FALSE; |
| 1053 | |
| 1054 | bfa_assert((cfg != NULL) && (meminfo != NULL)); |
| 1055 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 1056 | /* |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1057 | * initialize all memory pointers for iterative allocation |
| 1058 | */ |
| 1059 | for (i = 0; i < BFA_MEM_TYPE_MAX; i++) { |
| 1060 | melem = meminfo->meminfo + i; |
| 1061 | melem->kva_curp = melem->kva; |
| 1062 | melem->dma_curp = melem->dma; |
| 1063 | } |
| 1064 | |
| 1065 | bfa_iocfc_attach(bfa, bfad, cfg, meminfo, pcidev); |
| 1066 | |
| 1067 | for (i = 0; hal_mods[i]; i++) |
| 1068 | hal_mods[i]->attach(bfa, bfad, cfg, meminfo, pcidev); |
| 1069 | |
Krishna Gudipati | 7873ca4 | 2010-05-21 14:39:45 -0700 | [diff] [blame] | 1070 | bfa_com_port_attach(bfa, meminfo); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1071 | } |
| 1072 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 1073 | /* |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1074 | * Use this function to delete a BFA IOC. IOC should be stopped (by |
| 1075 | * calling bfa_stop()) before this function call. |
| 1076 | * |
| 1077 | * @param[in] bfa - pointer to bfa_t. |
| 1078 | * |
| 1079 | * @return |
| 1080 | * void |
| 1081 | * |
| 1082 | * Special Considerations: |
| 1083 | * |
| 1084 | * @note |
| 1085 | */ |
| 1086 | void |
| 1087 | bfa_detach(struct bfa_s *bfa) |
| 1088 | { |
| 1089 | int i; |
| 1090 | |
| 1091 | for (i = 0; hal_mods[i]; i++) |
| 1092 | hal_mods[i]->detach(bfa); |
| 1093 | |
| 1094 | bfa_iocfc_detach(bfa); |
| 1095 | } |
| 1096 | |
| 1097 | |
| 1098 | void |
| 1099 | bfa_init_trc(struct bfa_s *bfa, struct bfa_trc_mod_s *trcmod) |
| 1100 | { |
| 1101 | bfa->trcmod = trcmod; |
| 1102 | } |
| 1103 | |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1104 | void |
| 1105 | bfa_init_plog(struct bfa_s *bfa, struct bfa_plog_s *plog) |
| 1106 | { |
| 1107 | bfa->plog = plog; |
| 1108 | } |
| 1109 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 1110 | /* |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1111 | * Initialize IOC. |
| 1112 | * |
| 1113 | * This function will return immediately, when the IOC initialization is |
| 1114 | * completed, the bfa_cb_init() will be called. |
| 1115 | * |
| 1116 | * @param[in] bfa instance |
| 1117 | * |
| 1118 | * @return void |
| 1119 | * |
| 1120 | * Special Considerations: |
| 1121 | * |
| 1122 | * @note |
| 1123 | * When this function returns, the driver should register the interrupt service |
| 1124 | * routine(s) and enable the device interrupts. If this is not done, |
| 1125 | * bfa_cb_init() will never get called |
| 1126 | */ |
| 1127 | void |
| 1128 | bfa_init(struct bfa_s *bfa) |
| 1129 | { |
| 1130 | bfa_iocfc_init(bfa); |
| 1131 | } |
| 1132 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 1133 | /* |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1134 | * Use this function initiate the IOC configuration setup. This function |
| 1135 | * will return immediately. |
| 1136 | * |
| 1137 | * @param[in] bfa instance |
| 1138 | * |
| 1139 | * @return None |
| 1140 | */ |
| 1141 | void |
| 1142 | bfa_start(struct bfa_s *bfa) |
| 1143 | { |
| 1144 | bfa_iocfc_start(bfa); |
| 1145 | } |
| 1146 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 1147 | /* |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1148 | * Use this function quiese the IOC. This function will return immediately, |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1149 | * when the IOC is actually stopped, the bfad->comp will be set. |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1150 | * |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1151 | * @param[in]bfa - pointer to bfa_t. |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1152 | * |
| 1153 | * @return None |
| 1154 | * |
| 1155 | * Special Considerations: |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1156 | * bfad->comp can be set before or after bfa_stop() returns. |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1157 | * |
| 1158 | * @note |
| 1159 | * In case of any failure, we could handle it automatically by doing a |
| 1160 | * reset and then succeed the bfa_stop() call. |
| 1161 | */ |
| 1162 | void |
| 1163 | bfa_stop(struct bfa_s *bfa) |
| 1164 | { |
| 1165 | bfa_iocfc_stop(bfa); |
| 1166 | } |
| 1167 | |
| 1168 | void |
| 1169 | bfa_comp_deq(struct bfa_s *bfa, struct list_head *comp_q) |
| 1170 | { |
| 1171 | INIT_LIST_HEAD(comp_q); |
| 1172 | list_splice_tail_init(&bfa->comp_q, comp_q); |
| 1173 | } |
| 1174 | |
| 1175 | void |
| 1176 | bfa_comp_process(struct bfa_s *bfa, struct list_head *comp_q) |
| 1177 | { |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1178 | struct list_head *qe; |
| 1179 | struct list_head *qen; |
| 1180 | struct bfa_cb_qe_s *hcb_qe; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1181 | |
| 1182 | list_for_each_safe(qe, qen, comp_q) { |
| 1183 | hcb_qe = (struct bfa_cb_qe_s *) qe; |
| 1184 | hcb_qe->cbfn(hcb_qe->cbarg, BFA_TRUE); |
| 1185 | } |
| 1186 | } |
| 1187 | |
| 1188 | void |
| 1189 | bfa_comp_free(struct bfa_s *bfa, struct list_head *comp_q) |
| 1190 | { |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1191 | struct list_head *qe; |
| 1192 | struct bfa_cb_qe_s *hcb_qe; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1193 | |
| 1194 | while (!list_empty(comp_q)) { |
| 1195 | bfa_q_deq(comp_q, &qe); |
| 1196 | hcb_qe = (struct bfa_cb_qe_s *) qe; |
| 1197 | hcb_qe->cbfn(hcb_qe->cbarg, BFA_FALSE); |
| 1198 | } |
| 1199 | } |
| 1200 | |
| 1201 | void |
| 1202 | bfa_attach_fcs(struct bfa_s *bfa) |
| 1203 | { |
| 1204 | bfa->fcs = BFA_TRUE; |
| 1205 | } |
| 1206 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 1207 | /* |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1208 | * Periodic timer heart beat from driver |
| 1209 | */ |
| 1210 | void |
| 1211 | bfa_timer_tick(struct bfa_s *bfa) |
| 1212 | { |
| 1213 | bfa_timer_beat(&bfa->timer_mod); |
| 1214 | } |
| 1215 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 1216 | /* |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1217 | * Return the list of PCI vendor/device id lists supported by this |
| 1218 | * BFA instance. |
| 1219 | */ |
| 1220 | void |
| 1221 | bfa_get_pciids(struct bfa_pciid_s **pciids, int *npciids) |
| 1222 | { |
| 1223 | static struct bfa_pciid_s __pciids[] = { |
| 1224 | {BFA_PCI_VENDOR_ID_BROCADE, BFA_PCI_DEVICE_ID_FC_8G2P}, |
| 1225 | {BFA_PCI_VENDOR_ID_BROCADE, BFA_PCI_DEVICE_ID_FC_8G1P}, |
| 1226 | {BFA_PCI_VENDOR_ID_BROCADE, BFA_PCI_DEVICE_ID_CT}, |
Jing Huang | 293f82d | 2010-07-08 19:45:20 -0700 | [diff] [blame] | 1227 | {BFA_PCI_VENDOR_ID_BROCADE, BFA_PCI_DEVICE_ID_CT_FC}, |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1228 | }; |
| 1229 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1230 | *npciids = sizeof(__pciids) / sizeof(__pciids[0]); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1231 | *pciids = __pciids; |
| 1232 | } |
| 1233 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 1234 | /* |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1235 | * Use this function query the default struct bfa_iocfc_cfg_s value (compiled |
| 1236 | * into BFA layer). The OS driver can then turn back and overwrite entries that |
| 1237 | * have been configured by the user. |
| 1238 | * |
| 1239 | * @param[in] cfg - pointer to bfa_ioc_cfg_t |
| 1240 | * |
| 1241 | * @return |
| 1242 | * void |
| 1243 | * |
| 1244 | * Special Considerations: |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1245 | * note |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1246 | */ |
| 1247 | void |
| 1248 | bfa_cfg_get_default(struct bfa_iocfc_cfg_s *cfg) |
| 1249 | { |
| 1250 | cfg->fwcfg.num_fabrics = DEF_CFG_NUM_FABRICS; |
| 1251 | cfg->fwcfg.num_lports = DEF_CFG_NUM_LPORTS; |
| 1252 | cfg->fwcfg.num_rports = DEF_CFG_NUM_RPORTS; |
| 1253 | cfg->fwcfg.num_ioim_reqs = DEF_CFG_NUM_IOIM_REQS; |
| 1254 | cfg->fwcfg.num_tskim_reqs = DEF_CFG_NUM_TSKIM_REQS; |
| 1255 | cfg->fwcfg.num_fcxp_reqs = DEF_CFG_NUM_FCXP_REQS; |
| 1256 | cfg->fwcfg.num_uf_bufs = DEF_CFG_NUM_UF_BUFS; |
| 1257 | cfg->fwcfg.num_cqs = DEF_CFG_NUM_CQS; |
| 1258 | |
| 1259 | cfg->drvcfg.num_reqq_elems = DEF_CFG_NUM_REQQ_ELEMS; |
| 1260 | cfg->drvcfg.num_rspq_elems = DEF_CFG_NUM_RSPQ_ELEMS; |
| 1261 | cfg->drvcfg.num_sgpgs = DEF_CFG_NUM_SGPGS; |
| 1262 | cfg->drvcfg.num_sboot_tgts = DEF_CFG_NUM_SBOOT_TGTS; |
| 1263 | cfg->drvcfg.num_sboot_luns = DEF_CFG_NUM_SBOOT_LUNS; |
| 1264 | cfg->drvcfg.path_tov = BFA_FCPIM_PATHTOV_DEF; |
| 1265 | cfg->drvcfg.ioc_recover = BFA_FALSE; |
| 1266 | cfg->drvcfg.delay_comp = BFA_FALSE; |
| 1267 | |
| 1268 | } |
| 1269 | |
| 1270 | void |
| 1271 | bfa_cfg_get_min(struct bfa_iocfc_cfg_s *cfg) |
| 1272 | { |
| 1273 | bfa_cfg_get_default(cfg); |
| 1274 | cfg->fwcfg.num_ioim_reqs = BFA_IOIM_MIN; |
| 1275 | cfg->fwcfg.num_tskim_reqs = BFA_TSKIM_MIN; |
| 1276 | cfg->fwcfg.num_fcxp_reqs = BFA_FCXP_MIN; |
| 1277 | cfg->fwcfg.num_uf_bufs = BFA_UF_MIN; |
| 1278 | cfg->fwcfg.num_rports = BFA_RPORT_MIN; |
| 1279 | |
| 1280 | cfg->drvcfg.num_sgpgs = BFA_SGPG_MIN; |
| 1281 | cfg->drvcfg.num_reqq_elems = BFA_REQQ_NELEMS_MIN; |
| 1282 | cfg->drvcfg.num_rspq_elems = BFA_RSPQ_NELEMS_MIN; |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1283 | cfg->drvcfg.min_cfg = BFA_TRUE; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1284 | } |
| 1285 | |
| 1286 | void |
| 1287 | bfa_get_attr(struct bfa_s *bfa, struct bfa_ioc_attr_s *ioc_attr) |
| 1288 | { |
| 1289 | bfa_ioc_get_attr(&bfa->ioc, ioc_attr); |
| 1290 | } |
| 1291 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 1292 | /* |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1293 | * Retrieve firmware trace information on IOC failure. |
| 1294 | */ |
| 1295 | bfa_status_t |
| 1296 | bfa_debug_fwsave(struct bfa_s *bfa, void *trcdata, int *trclen) |
| 1297 | { |
| 1298 | return bfa_ioc_debug_fwsave(&bfa->ioc, trcdata, trclen); |
| 1299 | } |
| 1300 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 1301 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1302 | * Fetch firmware trace data. |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1303 | * |
| 1304 | * @param[in] bfa BFA instance |
| 1305 | * @param[out] trcdata Firmware trace buffer |
| 1306 | * @param[in,out] trclen Firmware trace buffer len |
| 1307 | * |
| 1308 | * @retval BFA_STATUS_OK Firmware trace is fetched. |
| 1309 | * @retval BFA_STATUS_INPROGRESS Firmware trace fetch is in progress. |
| 1310 | */ |
| 1311 | bfa_status_t |
| 1312 | bfa_debug_fwtrc(struct bfa_s *bfa, void *trcdata, int *trclen) |
| 1313 | { |
| 1314 | return bfa_ioc_debug_fwtrc(&bfa->ioc, trcdata, trclen); |
| 1315 | } |
Krishna Gudipati | 0a20de4 | 2010-03-05 19:34:20 -0800 | [diff] [blame] | 1316 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 1317 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1318 | * Dump firmware memory. |
| 1319 | * |
| 1320 | * @param[in] bfa BFA instance |
| 1321 | * @param[out] buf buffer for dump |
| 1322 | * @param[in,out] offset smem offset to start read |
| 1323 | * @param[in,out] buflen length of buffer |
| 1324 | * |
| 1325 | * @retval BFA_STATUS_OK Firmware memory is dumped. |
| 1326 | * @retval BFA_STATUS_INPROGRESS Firmware memory dump is in progress. |
| 1327 | */ |
| 1328 | bfa_status_t |
| 1329 | bfa_debug_fwcore(struct bfa_s *bfa, void *buf, u32 *offset, int *buflen) |
| 1330 | { |
| 1331 | return bfa_ioc_debug_fwcore(&bfa->ioc, buf, offset, buflen); |
| 1332 | } |