1 /* 2 * Copyright (c) 2005-2009 Brocade Communications Systems, Inc. 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 18 /** 19 * bfa_fcs.c BFA FCS main 20 */ 21 22 #include <fcs/bfa_fcs.h> 23 #include "fcs_port.h" 24 #include "fcs_uf.h" 25 #include "fcs_vport.h" 26 #include "fcs_rport.h" 27 #include "fcs_fabric.h" 28 #include "fcs_fcpim.h" 29 #include "fcs_fcptm.h" 30 #include "fcbuild.h" 31 #include "fcs.h" 32 #include "bfad_drv.h" 33 #include <fcb/bfa_fcb.h> 34 35 /** 36 * FCS sub-modules 37 */ 38 struct bfa_fcs_mod_s { 39 void (*modinit) (struct bfa_fcs_s *fcs); 40 void (*modexit) (struct bfa_fcs_s *fcs); 41 }; 42 43 #define BFA_FCS_MODULE(_mod) { _mod ## _modinit, _mod ## _modexit } 44 45 static struct bfa_fcs_mod_s fcs_modules[] = { 46 BFA_FCS_MODULE(bfa_fcs_pport), 47 BFA_FCS_MODULE(bfa_fcs_uf), 48 BFA_FCS_MODULE(bfa_fcs_fabric), 49 BFA_FCS_MODULE(bfa_fcs_vport), 50 BFA_FCS_MODULE(bfa_fcs_rport), 51 BFA_FCS_MODULE(bfa_fcs_fcpim), 52 }; 53 54 /** 55 * fcs_api BFA FCS API 56 */ 57 58 static void 59 bfa_fcs_exit_comp(void *fcs_cbarg) 60 { 61 struct bfa_fcs_s *fcs = fcs_cbarg; 62 struct bfad_s *bfad = fcs->bfad; 63 64 complete(&bfad->comp); 65 } 66 67 68 69 /** 70 * fcs_api BFA FCS API 71 */ 72 73 /** 74 * FCS instance initialization. 75 * 76 * param[in] fcs FCS instance 77 * param[in] bfa BFA instance 78 * param[in] bfad BFA driver instance 79 * 80 * return None 81 */ 82 void 83 bfa_fcs_init(struct bfa_fcs_s *fcs, struct bfa_s *bfa, struct bfad_s *bfad, 84 bfa_boolean_t min_cfg) 85 { 86 int i; 87 struct bfa_fcs_mod_s *mod; 88 89 fcs->bfa = bfa; 90 fcs->bfad = bfad; 91 fcs->min_cfg = min_cfg; 92 93 bfa_attach_fcs(bfa); 94 fcbuild_init(); 95 96 for (i = 0; i < sizeof(fcs_modules) / sizeof(fcs_modules[0]); i++) { 97 mod = &fcs_modules[i]; 98 mod->modinit(fcs); 99 } 100 } 101 102 /** 103 * Start FCS operations. 104 */ 105 void 106 bfa_fcs_start(struct bfa_fcs_s *fcs) 107 { 108 bfa_fcs_fabric_modstart(fcs); 109 } 110 111 /** 112 * FCS driver details initialization. 113 * 114 * param[in] fcs FCS instance 115 * param[in] driver_info Driver Details 116 * 117 * return None 118 */ 119 void 120 bfa_fcs_driver_info_init(struct bfa_fcs_s *fcs, 121 struct bfa_fcs_driver_info_s *driver_info) 122 { 123 124 fcs->driver_info = *driver_info; 125 126 bfa_fcs_fabric_psymb_init(&fcs->fabric); 127 } 128 129 /** 130 * @brief 131 * FCS FDMI Driver Parameter Initialization 132 * 133 * @param[in] fcs FCS instance 134 * @param[in] fdmi_enable TRUE/FALSE 135 * 136 * @return None 137 */ 138 void 139 bfa_fcs_set_fdmi_param(struct bfa_fcs_s *fcs, bfa_boolean_t fdmi_enable) 140 { 141 142 fcs->fdmi_enabled = fdmi_enable; 143 144 } 145 146 /** 147 * FCS instance cleanup and exit. 148 * 149 * param[in] fcs FCS instance 150 * return None 151 */ 152 void 153 bfa_fcs_exit(struct bfa_fcs_s *fcs) 154 { 155 struct bfa_fcs_mod_s *mod; 156 int nmods, i; 157 158 bfa_wc_init(&fcs->wc, bfa_fcs_exit_comp, fcs); 159 160 nmods = sizeof(fcs_modules) / sizeof(fcs_modules[0]); 161 162 for (i = 0; i < nmods; i++) { 163 bfa_wc_up(&fcs->wc); 164 165 mod = &fcs_modules[i]; 166 mod->modexit(fcs); 167 } 168 169 bfa_wc_wait(&fcs->wc); 170 } 171 172 173 void 174 bfa_fcs_trc_init(struct bfa_fcs_s *fcs, struct bfa_trc_mod_s *trcmod) 175 { 176 fcs->trcmod = trcmod; 177 } 178 179 180 void 181 bfa_fcs_log_init(struct bfa_fcs_s *fcs, struct bfa_log_mod_s *logmod) 182 { 183 fcs->logm = logmod; 184 } 185 186 187 void 188 bfa_fcs_aen_init(struct bfa_fcs_s *fcs, struct bfa_aen_s *aen) 189 { 190 fcs->aen = aen; 191 } 192 193 void 194 bfa_fcs_modexit_comp(struct bfa_fcs_s *fcs) 195 { 196 bfa_wc_down(&fcs->wc); 197 } 198 199 200