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