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