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