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 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 18 | /* |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 19 | * bfa_fcs.c BFA FCS main |
| 20 | */ |
| 21 | |
Maggie Zhang | f16a175 | 2010-12-09 19:12:32 -0800 | [diff] [blame] | 22 | #include "bfad_drv.h" |
Krishna Gudipati | 7826f30 | 2011-07-20 16:59:13 -0700 | [diff] [blame] | 23 | #include "bfad_im.h" |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 24 | #include "bfa_fcs.h" |
| 25 | #include "bfa_fcbuild.h" |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 26 | |
| 27 | BFA_TRC_FILE(FCS, FCS); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 28 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 29 | /* |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 30 | * FCS sub-modules |
| 31 | */ |
| 32 | struct bfa_fcs_mod_s { |
Krishna Gudipati | 82794a2 | 2010-03-03 17:43:30 -0800 | [diff] [blame] | 33 | void (*attach) (struct bfa_fcs_s *fcs); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 34 | void (*modinit) (struct bfa_fcs_s *fcs); |
| 35 | void (*modexit) (struct bfa_fcs_s *fcs); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 36 | }; |
| 37 | |
| 38 | #define BFA_FCS_MODULE(_mod) { _mod ## _modinit, _mod ## _modexit } |
| 39 | |
| 40 | static struct bfa_fcs_mod_s fcs_modules[] = { |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 41 | { bfa_fcs_port_attach, NULL, NULL }, |
Krishna Gudipati | 82794a2 | 2010-03-03 17:43:30 -0800 | [diff] [blame] | 42 | { bfa_fcs_uf_attach, NULL, NULL }, |
| 43 | { bfa_fcs_fabric_attach, bfa_fcs_fabric_modinit, |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 44 | bfa_fcs_fabric_modexit }, |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 45 | }; |
| 46 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 47 | /* |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 48 | * fcs_api BFA FCS API |
| 49 | */ |
| 50 | |
| 51 | static void |
| 52 | bfa_fcs_exit_comp(void *fcs_cbarg) |
| 53 | { |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 54 | struct bfa_fcs_s *fcs = fcs_cbarg; |
| 55 | struct bfad_s *bfad = fcs->bfad; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 56 | |
| 57 | complete(&bfad->comp); |
| 58 | } |
| 59 | |
| 60 | |
| 61 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 62 | /* |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 63 | * fcs_api BFA FCS API |
| 64 | */ |
| 65 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 66 | /* |
Krishna Gudipati | 82794a2 | 2010-03-03 17:43:30 -0800 | [diff] [blame] | 67 | * fcs attach -- called once to initialize data structures at driver attach time |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 68 | */ |
| 69 | void |
Krishna Gudipati | 82794a2 | 2010-03-03 17:43:30 -0800 | [diff] [blame] | 70 | bfa_fcs_attach(struct bfa_fcs_s *fcs, struct bfa_s *bfa, struct bfad_s *bfad, |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 71 | bfa_boolean_t min_cfg) |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 72 | { |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 73 | int i; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 74 | struct bfa_fcs_mod_s *mod; |
| 75 | |
| 76 | fcs->bfa = bfa; |
| 77 | fcs->bfad = bfad; |
| 78 | fcs->min_cfg = min_cfg; |
Krishna Gudipati | 61ba439 | 2012-08-22 19:52:58 -0700 | [diff] [blame] | 79 | fcs->num_rport_logins = 0; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 80 | |
Maggie Zhang | f7f73812 | 2010-12-09 19:08:43 -0800 | [diff] [blame] | 81 | bfa->fcs = BFA_TRUE; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 82 | fcbuild_init(); |
| 83 | |
Fabian Frederick | 44416c4 | 2014-06-30 19:42:42 +0200 | [diff] [blame] | 84 | for (i = 0; i < ARRAY_SIZE(fcs_modules); i++) { |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 85 | mod = &fcs_modules[i]; |
Krishna Gudipati | 82794a2 | 2010-03-03 17:43:30 -0800 | [diff] [blame] | 86 | if (mod->attach) |
| 87 | mod->attach(fcs); |
| 88 | } |
| 89 | } |
| 90 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 91 | /* |
Krishna Gudipati | 82794a2 | 2010-03-03 17:43:30 -0800 | [diff] [blame] | 92 | * fcs initialization, called once after bfa initialization is complete |
| 93 | */ |
| 94 | void |
| 95 | bfa_fcs_init(struct bfa_fcs_s *fcs) |
| 96 | { |
Krishna Gudipati | 75332a7 | 2011-06-13 15:54:31 -0700 | [diff] [blame] | 97 | int i; |
Krishna Gudipati | 82794a2 | 2010-03-03 17:43:30 -0800 | [diff] [blame] | 98 | struct bfa_fcs_mod_s *mod; |
| 99 | |
Fabian Frederick | 44416c4 | 2014-06-30 19:42:42 +0200 | [diff] [blame] | 100 | for (i = 0; i < ARRAY_SIZE(fcs_modules); i++) { |
Krishna Gudipati | 82794a2 | 2010-03-03 17:43:30 -0800 | [diff] [blame] | 101 | mod = &fcs_modules[i]; |
| 102 | if (mod->modinit) |
| 103 | mod->modinit(fcs); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 104 | } |
Krishna Gudipati | 75332a7 | 2011-06-13 15:54:31 -0700 | [diff] [blame] | 105 | } |
| 106 | |
| 107 | /* |
| 108 | * FCS update cfg - reset the pwwn/nwwn of fabric base logical port |
| 109 | * with values learned during bfa_init firmware GETATTR REQ. |
| 110 | */ |
| 111 | void |
| 112 | bfa_fcs_update_cfg(struct bfa_fcs_s *fcs) |
| 113 | { |
| 114 | struct bfa_fcs_fabric_s *fabric = &fcs->fabric; |
| 115 | struct bfa_lport_cfg_s *port_cfg = &fabric->bport.port_cfg; |
| 116 | struct bfa_ioc_s *ioc = &fabric->fcs->bfa->ioc; |
| 117 | |
| 118 | port_cfg->nwwn = ioc->attr->nwwn; |
| 119 | port_cfg->pwwn = ioc->attr->pwwn; |
| 120 | } |
| 121 | |
| 122 | /* |
Krishna Gudipati | 881c1b3 | 2012-08-22 19:52:02 -0700 | [diff] [blame] | 123 | * Stop FCS operations. |
| 124 | */ |
| 125 | void |
| 126 | bfa_fcs_stop(struct bfa_fcs_s *fcs) |
| 127 | { |
| 128 | bfa_wc_init(&fcs->wc, bfa_fcs_exit_comp, fcs); |
| 129 | bfa_wc_up(&fcs->wc); |
| 130 | bfa_fcs_fabric_modstop(fcs); |
| 131 | bfa_wc_wait(&fcs->wc); |
| 132 | } |
| 133 | |
| 134 | /* |
Krishna Gudipati | 75332a7 | 2011-06-13 15:54:31 -0700 | [diff] [blame] | 135 | * fcs pbc vport initialization |
| 136 | */ |
| 137 | void |
| 138 | bfa_fcs_pbc_vport_init(struct bfa_fcs_s *fcs) |
| 139 | { |
| 140 | int i, npbc_vports; |
| 141 | struct bfi_pbc_vport_s pbc_vports[BFI_PBC_MAX_VPORTS]; |
| 142 | |
Jing Huang | d988354 | 2010-07-08 19:46:26 -0700 | [diff] [blame] | 143 | /* Initialize pbc vports */ |
| 144 | if (!fcs->min_cfg) { |
| 145 | npbc_vports = |
Krishna Gudipati | 75332a7 | 2011-06-13 15:54:31 -0700 | [diff] [blame] | 146 | bfa_iocfc_get_pbc_vports(fcs->bfa, pbc_vports); |
Jing Huang | d988354 | 2010-07-08 19:46:26 -0700 | [diff] [blame] | 147 | for (i = 0; i < npbc_vports; i++) |
| 148 | bfa_fcb_pbc_vport_create(fcs->bfa->bfad, pbc_vports[i]); |
| 149 | } |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 150 | } |
| 151 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 152 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 153 | * brief |
| 154 | * FCS driver details initialization. |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 155 | * |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 156 | * param[in] fcs FCS instance |
| 157 | * param[in] driver_info Driver Details |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 158 | * |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 159 | * return None |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 160 | */ |
| 161 | void |
| 162 | bfa_fcs_driver_info_init(struct bfa_fcs_s *fcs, |
| 163 | struct bfa_fcs_driver_info_s *driver_info) |
| 164 | { |
| 165 | |
| 166 | fcs->driver_info = *driver_info; |
| 167 | |
| 168 | bfa_fcs_fabric_psymb_init(&fcs->fabric); |
Krishna Gudipati | ce7242b | 2012-08-22 19:52:43 -0700 | [diff] [blame] | 169 | bfa_fcs_fabric_nsymb_init(&fcs->fabric); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 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 | * brief |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 174 | * FCS instance cleanup and exit. |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 175 | * |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 176 | * param[in] fcs FCS instance |
| 177 | * return None |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 178 | */ |
| 179 | void |
| 180 | bfa_fcs_exit(struct bfa_fcs_s *fcs) |
| 181 | { |
| 182 | struct bfa_fcs_mod_s *mod; |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 183 | int nmods, i; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 184 | |
| 185 | bfa_wc_init(&fcs->wc, bfa_fcs_exit_comp, fcs); |
| 186 | |
Fabian Frederick | 44416c4 | 2014-06-30 19:42:42 +0200 | [diff] [blame] | 187 | nmods = ARRAY_SIZE(fcs_modules); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 188 | |
| 189 | for (i = 0; i < nmods; i++) { |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 190 | |
| 191 | mod = &fcs_modules[i]; |
Krishna Gudipati | 82794a2 | 2010-03-03 17:43:30 -0800 | [diff] [blame] | 192 | if (mod->modexit) { |
| 193 | bfa_wc_up(&fcs->wc); |
| 194 | mod->modexit(fcs); |
| 195 | } |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 196 | } |
| 197 | |
| 198 | bfa_wc_wait(&fcs->wc); |
| 199 | } |
| 200 | |
| 201 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 202 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 203 | * Fabric module implementation. |
| 204 | */ |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 205 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 206 | #define BFA_FCS_FABRIC_RETRY_DELAY (2000) /* Milliseconds */ |
| 207 | #define BFA_FCS_FABRIC_CLEANUP_DELAY (10000) /* Milliseconds */ |
| 208 | |
| 209 | #define bfa_fcs_fabric_set_opertype(__fabric) do { \ |
Krishna Gudipati | d7be54c | 2011-06-24 20:24:52 -0700 | [diff] [blame] | 210 | if (bfa_fcport_get_topology((__fabric)->fcs->bfa) \ |
| 211 | == BFA_PORT_TOPOLOGY_P2P) { \ |
| 212 | if (fabric->fab_type == BFA_FCS_FABRIC_SWITCHED) \ |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 213 | (__fabric)->oper_type = BFA_PORT_TYPE_NPORT; \ |
| 214 | else \ |
Krishna Gudipati | d7be54c | 2011-06-24 20:24:52 -0700 | [diff] [blame] | 215 | (__fabric)->oper_type = BFA_PORT_TYPE_P2P; \ |
| 216 | } else \ |
| 217 | (__fabric)->oper_type = BFA_PORT_TYPE_NLPORT; \ |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 218 | } while (0) |
| 219 | |
| 220 | /* |
| 221 | * forward declarations |
| 222 | */ |
| 223 | static void bfa_fcs_fabric_init(struct bfa_fcs_fabric_s *fabric); |
| 224 | static void bfa_fcs_fabric_login(struct bfa_fcs_fabric_s *fabric); |
| 225 | static void bfa_fcs_fabric_notify_online(struct bfa_fcs_fabric_s *fabric); |
| 226 | static void bfa_fcs_fabric_notify_offline(struct bfa_fcs_fabric_s *fabric); |
| 227 | static void bfa_fcs_fabric_delay(void *cbarg); |
| 228 | static void bfa_fcs_fabric_delete(struct bfa_fcs_fabric_s *fabric); |
| 229 | static void bfa_fcs_fabric_delete_comp(void *cbarg); |
Krishna Gudipati | 881c1b3 | 2012-08-22 19:52:02 -0700 | [diff] [blame] | 230 | static void bfa_fcs_fabric_stop(struct bfa_fcs_fabric_s *fabric); |
| 231 | static void bfa_fcs_fabric_stop_comp(void *cbarg); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 232 | static void bfa_fcs_fabric_process_uf(struct bfa_fcs_fabric_s *fabric, |
| 233 | struct fchs_s *fchs, u16 len); |
| 234 | static void bfa_fcs_fabric_process_flogi(struct bfa_fcs_fabric_s *fabric, |
| 235 | struct fchs_s *fchs, u16 len); |
| 236 | static void bfa_fcs_fabric_send_flogi_acc(struct bfa_fcs_fabric_s *fabric); |
| 237 | static void bfa_fcs_fabric_flogiacc_comp(void *fcsarg, |
| 238 | struct bfa_fcxp_s *fcxp, void *cbarg, |
| 239 | bfa_status_t status, |
| 240 | u32 rsp_len, |
| 241 | u32 resid_len, |
| 242 | struct fchs_s *rspfchs); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 243 | |
| 244 | static void bfa_fcs_fabric_sm_uninit(struct bfa_fcs_fabric_s *fabric, |
| 245 | enum bfa_fcs_fabric_event event); |
| 246 | static void bfa_fcs_fabric_sm_created(struct bfa_fcs_fabric_s *fabric, |
| 247 | enum bfa_fcs_fabric_event event); |
| 248 | static void bfa_fcs_fabric_sm_linkdown(struct bfa_fcs_fabric_s *fabric, |
| 249 | enum bfa_fcs_fabric_event event); |
| 250 | static void bfa_fcs_fabric_sm_flogi(struct bfa_fcs_fabric_s *fabric, |
| 251 | enum bfa_fcs_fabric_event event); |
| 252 | static void bfa_fcs_fabric_sm_flogi_retry(struct bfa_fcs_fabric_s *fabric, |
| 253 | enum bfa_fcs_fabric_event event); |
| 254 | static void bfa_fcs_fabric_sm_auth(struct bfa_fcs_fabric_s *fabric, |
| 255 | enum bfa_fcs_fabric_event event); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 256 | static void bfa_fcs_fabric_sm_nofabric(struct bfa_fcs_fabric_s *fabric, |
| 257 | enum bfa_fcs_fabric_event event); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 258 | static void bfa_fcs_fabric_sm_evfp(struct bfa_fcs_fabric_s *fabric, |
| 259 | enum bfa_fcs_fabric_event event); |
| 260 | static void bfa_fcs_fabric_sm_evfp_done(struct bfa_fcs_fabric_s *fabric, |
| 261 | enum bfa_fcs_fabric_event event); |
| 262 | static void bfa_fcs_fabric_sm_isolated(struct bfa_fcs_fabric_s *fabric, |
| 263 | enum bfa_fcs_fabric_event event); |
| 264 | static void bfa_fcs_fabric_sm_deleting(struct bfa_fcs_fabric_s *fabric, |
| 265 | enum bfa_fcs_fabric_event event); |
Krishna Gudipati | 881c1b3 | 2012-08-22 19:52:02 -0700 | [diff] [blame] | 266 | static void bfa_fcs_fabric_sm_stopping(struct bfa_fcs_fabric_s *fabric, |
| 267 | enum bfa_fcs_fabric_event event); |
| 268 | static void bfa_fcs_fabric_sm_cleanup(struct bfa_fcs_fabric_s *fabric, |
| 269 | enum bfa_fcs_fabric_event event); |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 270 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 271 | * Beginning state before fabric creation. |
| 272 | */ |
| 273 | static void |
| 274 | bfa_fcs_fabric_sm_uninit(struct bfa_fcs_fabric_s *fabric, |
| 275 | enum bfa_fcs_fabric_event event) |
| 276 | { |
| 277 | bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn); |
| 278 | bfa_trc(fabric->fcs, event); |
| 279 | |
| 280 | switch (event) { |
| 281 | case BFA_FCS_FABRIC_SM_CREATE: |
| 282 | bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_created); |
| 283 | bfa_fcs_fabric_init(fabric); |
| 284 | bfa_fcs_lport_init(&fabric->bport, &fabric->bport.port_cfg); |
| 285 | break; |
| 286 | |
| 287 | case BFA_FCS_FABRIC_SM_LINK_UP: |
| 288 | case BFA_FCS_FABRIC_SM_LINK_DOWN: |
| 289 | break; |
| 290 | |
| 291 | default: |
| 292 | bfa_sm_fault(fabric->fcs, event); |
| 293 | } |
| 294 | } |
| 295 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 296 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 297 | * Beginning state before fabric creation. |
| 298 | */ |
| 299 | static void |
| 300 | bfa_fcs_fabric_sm_created(struct bfa_fcs_fabric_s *fabric, |
| 301 | enum bfa_fcs_fabric_event event) |
| 302 | { |
Krishna Gudipati | bc0e2c2 | 2012-09-21 17:23:59 -0700 | [diff] [blame] | 303 | struct bfa_s *bfa = fabric->fcs->bfa; |
| 304 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 305 | bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn); |
| 306 | bfa_trc(fabric->fcs, event); |
| 307 | |
| 308 | switch (event) { |
| 309 | case BFA_FCS_FABRIC_SM_START: |
Krishna Gudipati | bc0e2c2 | 2012-09-21 17:23:59 -0700 | [diff] [blame] | 310 | if (!bfa_fcport_is_linkup(fabric->fcs->bfa)) { |
| 311 | bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_linkdown); |
| 312 | break; |
| 313 | } |
| 314 | if (bfa_fcport_get_topology(bfa) == |
| 315 | BFA_PORT_TOPOLOGY_LOOP) { |
| 316 | fabric->fab_type = BFA_FCS_FABRIC_LOOP; |
| 317 | fabric->bport.pid = bfa_fcport_get_myalpa(bfa); |
| 318 | fabric->bport.pid = bfa_hton3b(fabric->bport.pid); |
| 319 | bfa_sm_set_state(fabric, |
| 320 | bfa_fcs_fabric_sm_online); |
| 321 | bfa_fcs_fabric_set_opertype(fabric); |
| 322 | bfa_fcs_lport_online(&fabric->bport); |
| 323 | } else { |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 324 | bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_flogi); |
| 325 | bfa_fcs_fabric_login(fabric); |
Krishna Gudipati | bc0e2c2 | 2012-09-21 17:23:59 -0700 | [diff] [blame] | 326 | } |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 327 | break; |
| 328 | |
| 329 | case BFA_FCS_FABRIC_SM_LINK_UP: |
| 330 | case BFA_FCS_FABRIC_SM_LINK_DOWN: |
| 331 | break; |
| 332 | |
| 333 | case BFA_FCS_FABRIC_SM_DELETE: |
Krishna Gudipati | dd5aaf4 | 2011-06-13 15:51:24 -0700 | [diff] [blame] | 334 | bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_deleting); |
| 335 | bfa_fcs_fabric_delete(fabric); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 336 | break; |
| 337 | |
| 338 | default: |
| 339 | bfa_sm_fault(fabric->fcs, event); |
| 340 | } |
| 341 | } |
| 342 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 343 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 344 | * Link is down, awaiting LINK UP event from port. This is also the |
| 345 | * first state at fabric creation. |
| 346 | */ |
| 347 | static void |
| 348 | bfa_fcs_fabric_sm_linkdown(struct bfa_fcs_fabric_s *fabric, |
| 349 | enum bfa_fcs_fabric_event event) |
| 350 | { |
Krishna Gudipati | bc0e2c2 | 2012-09-21 17:23:59 -0700 | [diff] [blame] | 351 | struct bfa_s *bfa = fabric->fcs->bfa; |
| 352 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 353 | bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn); |
| 354 | bfa_trc(fabric->fcs, event); |
| 355 | |
| 356 | switch (event) { |
| 357 | case BFA_FCS_FABRIC_SM_LINK_UP: |
Krishna Gudipati | bc0e2c2 | 2012-09-21 17:23:59 -0700 | [diff] [blame] | 358 | if (bfa_fcport_get_topology(bfa) != BFA_PORT_TOPOLOGY_LOOP) { |
| 359 | bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_flogi); |
| 360 | bfa_fcs_fabric_login(fabric); |
| 361 | break; |
| 362 | } |
| 363 | fabric->fab_type = BFA_FCS_FABRIC_LOOP; |
| 364 | fabric->bport.pid = bfa_fcport_get_myalpa(bfa); |
| 365 | fabric->bport.pid = bfa_hton3b(fabric->bport.pid); |
| 366 | bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_online); |
| 367 | bfa_fcs_fabric_set_opertype(fabric); |
| 368 | bfa_fcs_lport_online(&fabric->bport); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 369 | break; |
| 370 | |
| 371 | case BFA_FCS_FABRIC_SM_RETRY_OP: |
Krishna Gudipati | bc0e2c2 | 2012-09-21 17:23:59 -0700 | [diff] [blame] | 372 | case BFA_FCS_FABRIC_SM_LOOPBACK: |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 373 | break; |
| 374 | |
| 375 | case BFA_FCS_FABRIC_SM_DELETE: |
| 376 | bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_deleting); |
| 377 | bfa_fcs_fabric_delete(fabric); |
| 378 | break; |
| 379 | |
Krishna Gudipati | 881c1b3 | 2012-08-22 19:52:02 -0700 | [diff] [blame] | 380 | case BFA_FCS_FABRIC_SM_STOP: |
| 381 | bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_cleanup); |
| 382 | bfa_fcs_fabric_stop(fabric); |
| 383 | break; |
| 384 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 385 | default: |
| 386 | bfa_sm_fault(fabric->fcs, event); |
| 387 | } |
| 388 | } |
| 389 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 390 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 391 | * FLOGI is in progress, awaiting FLOGI reply. |
| 392 | */ |
| 393 | static void |
| 394 | bfa_fcs_fabric_sm_flogi(struct bfa_fcs_fabric_s *fabric, |
| 395 | enum bfa_fcs_fabric_event event) |
| 396 | { |
| 397 | bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn); |
| 398 | bfa_trc(fabric->fcs, event); |
| 399 | |
| 400 | switch (event) { |
| 401 | case BFA_FCS_FABRIC_SM_CONT_OP: |
| 402 | |
| 403 | bfa_fcport_set_tx_bbcredit(fabric->fcs->bfa, |
Vijaya Mohan Guvva | bbe37a6 | 2013-05-13 02:33:19 -0700 | [diff] [blame] | 404 | fabric->bb_credit); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 405 | fabric->fab_type = BFA_FCS_FABRIC_SWITCHED; |
| 406 | |
| 407 | if (fabric->auth_reqd && fabric->is_auth) { |
| 408 | bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_auth); |
| 409 | bfa_trc(fabric->fcs, event); |
| 410 | } else { |
| 411 | bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_online); |
| 412 | bfa_fcs_fabric_notify_online(fabric); |
| 413 | } |
| 414 | break; |
| 415 | |
| 416 | case BFA_FCS_FABRIC_SM_RETRY_OP: |
| 417 | bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_flogi_retry); |
| 418 | bfa_timer_start(fabric->fcs->bfa, &fabric->delay_timer, |
| 419 | bfa_fcs_fabric_delay, fabric, |
| 420 | BFA_FCS_FABRIC_RETRY_DELAY); |
| 421 | break; |
| 422 | |
| 423 | case BFA_FCS_FABRIC_SM_LOOPBACK: |
| 424 | bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_loopback); |
Maggie Zhang | f7f73812 | 2010-12-09 19:08:43 -0800 | [diff] [blame] | 425 | bfa_sm_send_event(fabric->lps, BFA_LPS_SM_OFFLINE); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 426 | bfa_fcs_fabric_set_opertype(fabric); |
| 427 | break; |
| 428 | |
| 429 | case BFA_FCS_FABRIC_SM_NO_FABRIC: |
| 430 | fabric->fab_type = BFA_FCS_FABRIC_N2N; |
| 431 | bfa_fcport_set_tx_bbcredit(fabric->fcs->bfa, |
Vijaya Mohan Guvva | bbe37a6 | 2013-05-13 02:33:19 -0700 | [diff] [blame] | 432 | fabric->bb_credit); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 433 | bfa_fcs_fabric_notify_online(fabric); |
| 434 | bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_nofabric); |
| 435 | break; |
| 436 | |
| 437 | case BFA_FCS_FABRIC_SM_LINK_DOWN: |
| 438 | bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_linkdown); |
Maggie Zhang | f7f73812 | 2010-12-09 19:08:43 -0800 | [diff] [blame] | 439 | bfa_sm_send_event(fabric->lps, BFA_LPS_SM_OFFLINE); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 440 | break; |
| 441 | |
| 442 | case BFA_FCS_FABRIC_SM_DELETE: |
| 443 | bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_deleting); |
Maggie Zhang | f7f73812 | 2010-12-09 19:08:43 -0800 | [diff] [blame] | 444 | bfa_sm_send_event(fabric->lps, BFA_LPS_SM_OFFLINE); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 445 | bfa_fcs_fabric_delete(fabric); |
| 446 | break; |
| 447 | |
| 448 | default: |
| 449 | bfa_sm_fault(fabric->fcs, event); |
| 450 | } |
| 451 | } |
| 452 | |
| 453 | |
| 454 | static void |
| 455 | bfa_fcs_fabric_sm_flogi_retry(struct bfa_fcs_fabric_s *fabric, |
| 456 | enum bfa_fcs_fabric_event event) |
| 457 | { |
| 458 | bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn); |
| 459 | bfa_trc(fabric->fcs, event); |
| 460 | |
| 461 | switch (event) { |
| 462 | case BFA_FCS_FABRIC_SM_DELAYED: |
| 463 | bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_flogi); |
| 464 | bfa_fcs_fabric_login(fabric); |
| 465 | break; |
| 466 | |
| 467 | case BFA_FCS_FABRIC_SM_LINK_DOWN: |
| 468 | bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_linkdown); |
| 469 | bfa_timer_stop(&fabric->delay_timer); |
| 470 | break; |
| 471 | |
| 472 | case BFA_FCS_FABRIC_SM_DELETE: |
| 473 | bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_deleting); |
| 474 | bfa_timer_stop(&fabric->delay_timer); |
| 475 | bfa_fcs_fabric_delete(fabric); |
| 476 | break; |
| 477 | |
| 478 | default: |
| 479 | bfa_sm_fault(fabric->fcs, event); |
| 480 | } |
| 481 | } |
| 482 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 483 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 484 | * Authentication is in progress, awaiting authentication results. |
| 485 | */ |
| 486 | static void |
| 487 | bfa_fcs_fabric_sm_auth(struct bfa_fcs_fabric_s *fabric, |
| 488 | enum bfa_fcs_fabric_event event) |
| 489 | { |
| 490 | bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn); |
| 491 | bfa_trc(fabric->fcs, event); |
| 492 | |
| 493 | switch (event) { |
| 494 | case BFA_FCS_FABRIC_SM_AUTH_FAILED: |
| 495 | bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_auth_failed); |
Maggie Zhang | f7f73812 | 2010-12-09 19:08:43 -0800 | [diff] [blame] | 496 | bfa_sm_send_event(fabric->lps, BFA_LPS_SM_OFFLINE); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 497 | break; |
| 498 | |
| 499 | case BFA_FCS_FABRIC_SM_AUTH_SUCCESS: |
| 500 | bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_online); |
| 501 | bfa_fcs_fabric_notify_online(fabric); |
| 502 | break; |
| 503 | |
| 504 | case BFA_FCS_FABRIC_SM_PERF_EVFP: |
| 505 | bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_evfp); |
| 506 | break; |
| 507 | |
| 508 | case BFA_FCS_FABRIC_SM_LINK_DOWN: |
| 509 | bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_linkdown); |
Maggie Zhang | f7f73812 | 2010-12-09 19:08:43 -0800 | [diff] [blame] | 510 | bfa_sm_send_event(fabric->lps, BFA_LPS_SM_OFFLINE); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 511 | break; |
| 512 | |
| 513 | case BFA_FCS_FABRIC_SM_DELETE: |
| 514 | bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_deleting); |
| 515 | bfa_fcs_fabric_delete(fabric); |
| 516 | break; |
| 517 | |
| 518 | default: |
| 519 | bfa_sm_fault(fabric->fcs, event); |
| 520 | } |
| 521 | } |
| 522 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 523 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 524 | * Authentication failed |
| 525 | */ |
Maggie Zhang | f7f73812 | 2010-12-09 19:08:43 -0800 | [diff] [blame] | 526 | void |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 527 | bfa_fcs_fabric_sm_auth_failed(struct bfa_fcs_fabric_s *fabric, |
| 528 | enum bfa_fcs_fabric_event event) |
| 529 | { |
| 530 | bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn); |
| 531 | bfa_trc(fabric->fcs, event); |
| 532 | |
| 533 | switch (event) { |
| 534 | case BFA_FCS_FABRIC_SM_LINK_DOWN: |
| 535 | bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_linkdown); |
| 536 | bfa_fcs_fabric_notify_offline(fabric); |
| 537 | break; |
| 538 | |
| 539 | case BFA_FCS_FABRIC_SM_DELETE: |
| 540 | bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_deleting); |
| 541 | bfa_fcs_fabric_delete(fabric); |
| 542 | break; |
| 543 | |
| 544 | default: |
| 545 | bfa_sm_fault(fabric->fcs, event); |
| 546 | } |
| 547 | } |
| 548 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 549 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 550 | * Port is in loopback mode. |
| 551 | */ |
Maggie Zhang | f7f73812 | 2010-12-09 19:08:43 -0800 | [diff] [blame] | 552 | void |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 553 | bfa_fcs_fabric_sm_loopback(struct bfa_fcs_fabric_s *fabric, |
| 554 | enum bfa_fcs_fabric_event event) |
| 555 | { |
| 556 | bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn); |
| 557 | bfa_trc(fabric->fcs, event); |
| 558 | |
| 559 | switch (event) { |
| 560 | case BFA_FCS_FABRIC_SM_LINK_DOWN: |
| 561 | bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_linkdown); |
| 562 | bfa_fcs_fabric_notify_offline(fabric); |
| 563 | break; |
| 564 | |
| 565 | case BFA_FCS_FABRIC_SM_DELETE: |
| 566 | bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_deleting); |
| 567 | bfa_fcs_fabric_delete(fabric); |
| 568 | break; |
| 569 | |
| 570 | default: |
| 571 | bfa_sm_fault(fabric->fcs, event); |
| 572 | } |
| 573 | } |
| 574 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 575 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 576 | * There is no attached fabric - private loop or NPort-to-NPort topology. |
| 577 | */ |
| 578 | static void |
| 579 | bfa_fcs_fabric_sm_nofabric(struct bfa_fcs_fabric_s *fabric, |
| 580 | enum bfa_fcs_fabric_event event) |
| 581 | { |
| 582 | bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn); |
| 583 | bfa_trc(fabric->fcs, event); |
| 584 | |
| 585 | switch (event) { |
| 586 | case BFA_FCS_FABRIC_SM_LINK_DOWN: |
| 587 | bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_linkdown); |
Maggie Zhang | f7f73812 | 2010-12-09 19:08:43 -0800 | [diff] [blame] | 588 | bfa_sm_send_event(fabric->lps, BFA_LPS_SM_OFFLINE); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 589 | bfa_fcs_fabric_notify_offline(fabric); |
| 590 | break; |
| 591 | |
| 592 | case BFA_FCS_FABRIC_SM_DELETE: |
| 593 | bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_deleting); |
| 594 | bfa_fcs_fabric_delete(fabric); |
| 595 | break; |
| 596 | |
| 597 | case BFA_FCS_FABRIC_SM_NO_FABRIC: |
| 598 | bfa_trc(fabric->fcs, fabric->bb_credit); |
| 599 | bfa_fcport_set_tx_bbcredit(fabric->fcs->bfa, |
Vijaya Mohan Guvva | bbe37a6 | 2013-05-13 02:33:19 -0700 | [diff] [blame] | 600 | fabric->bb_credit); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 601 | break; |
| 602 | |
Krishna Gudipati | d7be54c | 2011-06-24 20:24:52 -0700 | [diff] [blame] | 603 | case BFA_FCS_FABRIC_SM_RETRY_OP: |
| 604 | break; |
| 605 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 606 | default: |
| 607 | bfa_sm_fault(fabric->fcs, event); |
| 608 | } |
| 609 | } |
| 610 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 611 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 612 | * Fabric is online - normal operating state. |
| 613 | */ |
Maggie Zhang | f7f73812 | 2010-12-09 19:08:43 -0800 | [diff] [blame] | 614 | void |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 615 | bfa_fcs_fabric_sm_online(struct bfa_fcs_fabric_s *fabric, |
| 616 | enum bfa_fcs_fabric_event event) |
| 617 | { |
Krishna Gudipati | bc0e2c2 | 2012-09-21 17:23:59 -0700 | [diff] [blame] | 618 | struct bfa_s *bfa = fabric->fcs->bfa; |
| 619 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 620 | bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn); |
| 621 | bfa_trc(fabric->fcs, event); |
| 622 | |
| 623 | switch (event) { |
| 624 | case BFA_FCS_FABRIC_SM_LINK_DOWN: |
| 625 | bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_linkdown); |
Krishna Gudipati | bc0e2c2 | 2012-09-21 17:23:59 -0700 | [diff] [blame] | 626 | if (bfa_fcport_get_topology(bfa) == BFA_PORT_TOPOLOGY_LOOP) { |
| 627 | bfa_fcs_lport_offline(&fabric->bport); |
| 628 | } else { |
| 629 | bfa_sm_send_event(fabric->lps, BFA_LPS_SM_OFFLINE); |
| 630 | bfa_fcs_fabric_notify_offline(fabric); |
| 631 | } |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 632 | break; |
| 633 | |
| 634 | case BFA_FCS_FABRIC_SM_DELETE: |
| 635 | bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_deleting); |
| 636 | bfa_fcs_fabric_delete(fabric); |
| 637 | break; |
| 638 | |
Krishna Gudipati | 881c1b3 | 2012-08-22 19:52:02 -0700 | [diff] [blame] | 639 | case BFA_FCS_FABRIC_SM_STOP: |
| 640 | bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_stopping); |
| 641 | bfa_fcs_fabric_stop(fabric); |
| 642 | break; |
| 643 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 644 | case BFA_FCS_FABRIC_SM_AUTH_FAILED: |
| 645 | bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_auth_failed); |
Maggie Zhang | f7f73812 | 2010-12-09 19:08:43 -0800 | [diff] [blame] | 646 | bfa_sm_send_event(fabric->lps, BFA_LPS_SM_OFFLINE); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 647 | break; |
| 648 | |
| 649 | case BFA_FCS_FABRIC_SM_AUTH_SUCCESS: |
| 650 | break; |
| 651 | |
| 652 | default: |
| 653 | bfa_sm_fault(fabric->fcs, event); |
| 654 | } |
| 655 | } |
| 656 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 657 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 658 | * Exchanging virtual fabric parameters. |
| 659 | */ |
| 660 | static void |
| 661 | bfa_fcs_fabric_sm_evfp(struct bfa_fcs_fabric_s *fabric, |
| 662 | enum bfa_fcs_fabric_event event) |
| 663 | { |
| 664 | bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn); |
| 665 | bfa_trc(fabric->fcs, event); |
| 666 | |
| 667 | switch (event) { |
| 668 | case BFA_FCS_FABRIC_SM_CONT_OP: |
| 669 | bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_evfp_done); |
| 670 | break; |
| 671 | |
| 672 | case BFA_FCS_FABRIC_SM_ISOLATE: |
| 673 | bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_isolated); |
| 674 | break; |
| 675 | |
| 676 | default: |
| 677 | bfa_sm_fault(fabric->fcs, event); |
| 678 | } |
| 679 | } |
| 680 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 681 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 682 | * EVFP exchange complete and VFT tagging is enabled. |
| 683 | */ |
| 684 | static void |
| 685 | bfa_fcs_fabric_sm_evfp_done(struct bfa_fcs_fabric_s *fabric, |
| 686 | enum bfa_fcs_fabric_event event) |
| 687 | { |
| 688 | bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn); |
| 689 | bfa_trc(fabric->fcs, event); |
| 690 | } |
| 691 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 692 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 693 | * Port is isolated after EVFP exchange due to VF_ID mismatch (N and F). |
| 694 | */ |
| 695 | static void |
| 696 | bfa_fcs_fabric_sm_isolated(struct bfa_fcs_fabric_s *fabric, |
| 697 | enum bfa_fcs_fabric_event event) |
| 698 | { |
| 699 | struct bfad_s *bfad = (struct bfad_s *)fabric->fcs->bfad; |
| 700 | char pwwn_ptr[BFA_STRING_32]; |
| 701 | |
| 702 | bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn); |
| 703 | bfa_trc(fabric->fcs, event); |
| 704 | wwn2str(pwwn_ptr, fabric->bport.port_cfg.pwwn); |
| 705 | |
Jing Huang | 8816624 | 2010-12-09 17:11:53 -0800 | [diff] [blame] | 706 | BFA_LOG(KERN_INFO, bfad, bfa_log_level, |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 707 | "Port is isolated due to VF_ID mismatch. " |
| 708 | "PWWN: %s Port VF_ID: %04x switch port VF_ID: %04x.", |
| 709 | pwwn_ptr, fabric->fcs->port_vfid, |
| 710 | fabric->event_arg.swp_vfid); |
| 711 | } |
| 712 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 713 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 714 | * Fabric is being deleted, awaiting vport delete completions. |
| 715 | */ |
| 716 | static void |
| 717 | bfa_fcs_fabric_sm_deleting(struct bfa_fcs_fabric_s *fabric, |
| 718 | enum bfa_fcs_fabric_event event) |
| 719 | { |
| 720 | bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn); |
| 721 | bfa_trc(fabric->fcs, event); |
| 722 | |
| 723 | switch (event) { |
| 724 | case BFA_FCS_FABRIC_SM_DELCOMP: |
| 725 | bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_uninit); |
Maggie Zhang | f7f73812 | 2010-12-09 19:08:43 -0800 | [diff] [blame] | 726 | bfa_wc_down(&fabric->fcs->wc); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 727 | break; |
| 728 | |
| 729 | case BFA_FCS_FABRIC_SM_LINK_UP: |
| 730 | break; |
| 731 | |
| 732 | case BFA_FCS_FABRIC_SM_LINK_DOWN: |
| 733 | bfa_fcs_fabric_notify_offline(fabric); |
| 734 | break; |
| 735 | |
| 736 | default: |
| 737 | bfa_sm_fault(fabric->fcs, event); |
| 738 | } |
| 739 | } |
| 740 | |
Krishna Gudipati | 881c1b3 | 2012-08-22 19:52:02 -0700 | [diff] [blame] | 741 | /* |
| 742 | * Fabric is being stopped, awaiting vport stop completions. |
| 743 | */ |
| 744 | static void |
| 745 | bfa_fcs_fabric_sm_stopping(struct bfa_fcs_fabric_s *fabric, |
| 746 | enum bfa_fcs_fabric_event event) |
| 747 | { |
Krishna Gudipati | bc0e2c2 | 2012-09-21 17:23:59 -0700 | [diff] [blame] | 748 | struct bfa_s *bfa = fabric->fcs->bfa; |
| 749 | |
Krishna Gudipati | 881c1b3 | 2012-08-22 19:52:02 -0700 | [diff] [blame] | 750 | bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn); |
| 751 | bfa_trc(fabric->fcs, event); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 752 | |
Krishna Gudipati | 881c1b3 | 2012-08-22 19:52:02 -0700 | [diff] [blame] | 753 | switch (event) { |
| 754 | case BFA_FCS_FABRIC_SM_STOPCOMP: |
Krishna Gudipati | bc0e2c2 | 2012-09-21 17:23:59 -0700 | [diff] [blame] | 755 | if (bfa_fcport_get_topology(bfa) == BFA_PORT_TOPOLOGY_LOOP) { |
| 756 | bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_created); |
| 757 | } else { |
| 758 | bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_cleanup); |
| 759 | bfa_sm_send_event(fabric->lps, BFA_LPS_SM_LOGOUT); |
| 760 | } |
Krishna Gudipati | 881c1b3 | 2012-08-22 19:52:02 -0700 | [diff] [blame] | 761 | break; |
| 762 | |
| 763 | case BFA_FCS_FABRIC_SM_LINK_UP: |
| 764 | break; |
| 765 | |
| 766 | case BFA_FCS_FABRIC_SM_LINK_DOWN: |
Krishna Gudipati | bc0e2c2 | 2012-09-21 17:23:59 -0700 | [diff] [blame] | 767 | if (bfa_fcport_get_topology(bfa) == BFA_PORT_TOPOLOGY_LOOP) |
| 768 | bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_created); |
| 769 | else |
| 770 | bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_cleanup); |
Krishna Gudipati | 881c1b3 | 2012-08-22 19:52:02 -0700 | [diff] [blame] | 771 | break; |
| 772 | |
| 773 | default: |
| 774 | bfa_sm_fault(fabric->fcs, event); |
| 775 | } |
| 776 | } |
| 777 | |
| 778 | /* |
| 779 | * Fabric is being stopped, cleanup without FLOGO |
| 780 | */ |
| 781 | static void |
| 782 | bfa_fcs_fabric_sm_cleanup(struct bfa_fcs_fabric_s *fabric, |
| 783 | enum bfa_fcs_fabric_event event) |
| 784 | { |
| 785 | bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn); |
| 786 | bfa_trc(fabric->fcs, event); |
| 787 | |
| 788 | switch (event) { |
| 789 | case BFA_FCS_FABRIC_SM_STOPCOMP: |
| 790 | case BFA_FCS_FABRIC_SM_LOGOCOMP: |
| 791 | bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_created); |
| 792 | bfa_wc_down(&(fabric->fcs)->wc); |
| 793 | break; |
| 794 | |
| 795 | case BFA_FCS_FABRIC_SM_LINK_DOWN: |
| 796 | /* |
| 797 | * Ignore - can get this event if we get notified about IOC down |
| 798 | * before the fabric completion callbk is done. |
| 799 | */ |
| 800 | break; |
| 801 | |
| 802 | default: |
| 803 | bfa_sm_fault(fabric->fcs, event); |
| 804 | } |
| 805 | } |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 806 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 807 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 808 | * fcs_fabric_private fabric private functions |
| 809 | */ |
| 810 | |
| 811 | static void |
| 812 | bfa_fcs_fabric_init(struct bfa_fcs_fabric_s *fabric) |
| 813 | { |
| 814 | struct bfa_lport_cfg_s *port_cfg = &fabric->bport.port_cfg; |
| 815 | |
| 816 | port_cfg->roles = BFA_LPORT_ROLE_FCP_IM; |
Maggie Zhang | f7f73812 | 2010-12-09 19:08:43 -0800 | [diff] [blame] | 817 | port_cfg->nwwn = fabric->fcs->bfa->ioc.attr->nwwn; |
| 818 | port_cfg->pwwn = fabric->fcs->bfa->ioc.attr->pwwn; |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 819 | } |
| 820 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 821 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 822 | * Port Symbolic Name Creation for base port. |
| 823 | */ |
| 824 | void |
| 825 | bfa_fcs_fabric_psymb_init(struct bfa_fcs_fabric_s *fabric) |
| 826 | { |
| 827 | struct bfa_lport_cfg_s *port_cfg = &fabric->bport.port_cfg; |
| 828 | char model[BFA_ADAPTER_MODEL_NAME_LEN] = {0}; |
| 829 | struct bfa_fcs_driver_info_s *driver_info = &fabric->fcs->driver_info; |
| 830 | |
| 831 | bfa_ioc_get_adapter_model(&fabric->fcs->bfa->ioc, model); |
| 832 | |
| 833 | /* Model name/number */ |
| 834 | strncpy((char *)&port_cfg->sym_name, model, |
| 835 | BFA_FCS_PORT_SYMBNAME_MODEL_SZ); |
| 836 | strncat((char *)&port_cfg->sym_name, BFA_FCS_PORT_SYMBNAME_SEPARATOR, |
| 837 | sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR)); |
| 838 | |
| 839 | /* Driver Version */ |
| 840 | strncat((char *)&port_cfg->sym_name, (char *)driver_info->version, |
| 841 | BFA_FCS_PORT_SYMBNAME_VERSION_SZ); |
| 842 | strncat((char *)&port_cfg->sym_name, BFA_FCS_PORT_SYMBNAME_SEPARATOR, |
| 843 | sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR)); |
| 844 | |
| 845 | /* Host machine name */ |
| 846 | strncat((char *)&port_cfg->sym_name, |
| 847 | (char *)driver_info->host_machine_name, |
| 848 | BFA_FCS_PORT_SYMBNAME_MACHINENAME_SZ); |
| 849 | strncat((char *)&port_cfg->sym_name, BFA_FCS_PORT_SYMBNAME_SEPARATOR, |
| 850 | sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR)); |
| 851 | |
| 852 | /* |
| 853 | * Host OS Info : |
| 854 | * If OS Patch Info is not there, do not truncate any bytes from the |
| 855 | * OS name string and instead copy the entire OS info string (64 bytes). |
| 856 | */ |
| 857 | if (driver_info->host_os_patch[0] == '\0') { |
| 858 | strncat((char *)&port_cfg->sym_name, |
| 859 | (char *)driver_info->host_os_name, |
| 860 | BFA_FCS_OS_STR_LEN); |
| 861 | strncat((char *)&port_cfg->sym_name, |
| 862 | BFA_FCS_PORT_SYMBNAME_SEPARATOR, |
| 863 | sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR)); |
| 864 | } else { |
| 865 | strncat((char *)&port_cfg->sym_name, |
| 866 | (char *)driver_info->host_os_name, |
| 867 | BFA_FCS_PORT_SYMBNAME_OSINFO_SZ); |
| 868 | strncat((char *)&port_cfg->sym_name, |
| 869 | BFA_FCS_PORT_SYMBNAME_SEPARATOR, |
| 870 | sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR)); |
| 871 | |
| 872 | /* Append host OS Patch Info */ |
| 873 | strncat((char *)&port_cfg->sym_name, |
| 874 | (char *)driver_info->host_os_patch, |
| 875 | BFA_FCS_PORT_SYMBNAME_OSPATCH_SZ); |
| 876 | } |
| 877 | |
| 878 | /* null terminate */ |
| 879 | port_cfg->sym_name.symname[BFA_SYMNAME_MAXLEN - 1] = 0; |
| 880 | } |
| 881 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 882 | /* |
Krishna Gudipati | ce7242b | 2012-08-22 19:52:43 -0700 | [diff] [blame] | 883 | * Node Symbolic Name Creation for base port and all vports |
| 884 | */ |
| 885 | void |
| 886 | bfa_fcs_fabric_nsymb_init(struct bfa_fcs_fabric_s *fabric) |
| 887 | { |
| 888 | struct bfa_lport_cfg_s *port_cfg = &fabric->bport.port_cfg; |
| 889 | char model[BFA_ADAPTER_MODEL_NAME_LEN] = {0}; |
| 890 | struct bfa_fcs_driver_info_s *driver_info = &fabric->fcs->driver_info; |
| 891 | |
| 892 | bfa_ioc_get_adapter_model(&fabric->fcs->bfa->ioc, model); |
| 893 | |
| 894 | /* Model name/number */ |
| 895 | strncpy((char *)&port_cfg->node_sym_name, model, |
| 896 | BFA_FCS_PORT_SYMBNAME_MODEL_SZ); |
| 897 | strncat((char *)&port_cfg->node_sym_name, |
| 898 | BFA_FCS_PORT_SYMBNAME_SEPARATOR, |
| 899 | sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR)); |
| 900 | |
| 901 | /* Driver Version */ |
| 902 | strncat((char *)&port_cfg->node_sym_name, (char *)driver_info->version, |
| 903 | BFA_FCS_PORT_SYMBNAME_VERSION_SZ); |
| 904 | strncat((char *)&port_cfg->node_sym_name, |
| 905 | BFA_FCS_PORT_SYMBNAME_SEPARATOR, |
| 906 | sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR)); |
| 907 | |
| 908 | /* Host machine name */ |
| 909 | strncat((char *)&port_cfg->node_sym_name, |
| 910 | (char *)driver_info->host_machine_name, |
| 911 | BFA_FCS_PORT_SYMBNAME_MACHINENAME_SZ); |
| 912 | strncat((char *)&port_cfg->node_sym_name, |
| 913 | BFA_FCS_PORT_SYMBNAME_SEPARATOR, |
| 914 | sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR)); |
| 915 | |
| 916 | /* null terminate */ |
| 917 | port_cfg->node_sym_name.symname[BFA_SYMNAME_MAXLEN - 1] = 0; |
| 918 | } |
| 919 | |
| 920 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 921 | * bfa lps login completion callback |
| 922 | */ |
| 923 | void |
| 924 | bfa_cb_lps_flogi_comp(void *bfad, void *uarg, bfa_status_t status) |
| 925 | { |
| 926 | struct bfa_fcs_fabric_s *fabric = uarg; |
| 927 | |
| 928 | bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn); |
| 929 | bfa_trc(fabric->fcs, status); |
| 930 | |
| 931 | switch (status) { |
| 932 | case BFA_STATUS_OK: |
| 933 | fabric->stats.flogi_accepts++; |
| 934 | break; |
| 935 | |
| 936 | case BFA_STATUS_INVALID_MAC: |
| 937 | /* Only for CNA */ |
| 938 | fabric->stats.flogi_acc_err++; |
| 939 | bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_RETRY_OP); |
| 940 | |
| 941 | return; |
| 942 | |
| 943 | case BFA_STATUS_EPROTOCOL: |
Maggie Zhang | f7f73812 | 2010-12-09 19:08:43 -0800 | [diff] [blame] | 944 | switch (fabric->lps->ext_status) { |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 945 | case BFA_EPROTO_BAD_ACCEPT: |
| 946 | fabric->stats.flogi_acc_err++; |
| 947 | break; |
| 948 | |
| 949 | case BFA_EPROTO_UNKNOWN_RSP: |
| 950 | fabric->stats.flogi_unknown_rsp++; |
| 951 | break; |
| 952 | |
| 953 | default: |
| 954 | break; |
| 955 | } |
| 956 | bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_RETRY_OP); |
| 957 | |
| 958 | return; |
| 959 | |
| 960 | case BFA_STATUS_FABRIC_RJT: |
| 961 | fabric->stats.flogi_rejects++; |
| 962 | bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_RETRY_OP); |
| 963 | return; |
| 964 | |
| 965 | default: |
| 966 | fabric->stats.flogi_rsp_err++; |
| 967 | bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_RETRY_OP); |
| 968 | return; |
| 969 | } |
| 970 | |
Maggie Zhang | f7f73812 | 2010-12-09 19:08:43 -0800 | [diff] [blame] | 971 | fabric->bb_credit = fabric->lps->pr_bbcred; |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 972 | bfa_trc(fabric->fcs, fabric->bb_credit); |
| 973 | |
Maggie Zhang | f7f73812 | 2010-12-09 19:08:43 -0800 | [diff] [blame] | 974 | if (!(fabric->lps->brcd_switch)) |
| 975 | fabric->fabric_name = fabric->lps->pr_nwwn; |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 976 | |
| 977 | /* |
| 978 | * Check port type. It should be 1 = F-port. |
| 979 | */ |
Maggie Zhang | f7f73812 | 2010-12-09 19:08:43 -0800 | [diff] [blame] | 980 | if (fabric->lps->fport) { |
| 981 | fabric->bport.pid = fabric->lps->lp_pid; |
| 982 | fabric->is_npiv = fabric->lps->npiv_en; |
| 983 | fabric->is_auth = fabric->lps->auth_req; |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 984 | bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_CONT_OP); |
| 985 | } else { |
| 986 | /* |
| 987 | * Nport-2-Nport direct attached |
| 988 | */ |
| 989 | fabric->bport.port_topo.pn2n.rem_port_wwn = |
Maggie Zhang | f7f73812 | 2010-12-09 19:08:43 -0800 | [diff] [blame] | 990 | fabric->lps->pr_pwwn; |
Krishna Gudipati | d7be54c | 2011-06-24 20:24:52 -0700 | [diff] [blame] | 991 | fabric->fab_type = BFA_FCS_FABRIC_N2N; |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 992 | bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_NO_FABRIC); |
| 993 | } |
| 994 | |
| 995 | bfa_trc(fabric->fcs, fabric->bport.pid); |
| 996 | bfa_trc(fabric->fcs, fabric->is_npiv); |
| 997 | bfa_trc(fabric->fcs, fabric->is_auth); |
| 998 | } |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 999 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1000 | * Allocate and send FLOGI. |
| 1001 | */ |
| 1002 | static void |
| 1003 | bfa_fcs_fabric_login(struct bfa_fcs_fabric_s *fabric) |
| 1004 | { |
| 1005 | struct bfa_s *bfa = fabric->fcs->bfa; |
| 1006 | struct bfa_lport_cfg_s *pcfg = &fabric->bport.port_cfg; |
Vijaya Mohan Guvva | bbe37a6 | 2013-05-13 02:33:19 -0700 | [diff] [blame] | 1007 | u8 alpa = 0; |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1008 | |
Krishna Gudipati | be540a9 | 2011-06-13 15:53:04 -0700 | [diff] [blame] | 1009 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1010 | bfa_lps_flogi(fabric->lps, fabric, alpa, bfa_fcport_get_maxfrsize(bfa), |
Vijaya Mohan Guvva | bbe37a6 | 2013-05-13 02:33:19 -0700 | [diff] [blame] | 1011 | pcfg->pwwn, pcfg->nwwn, fabric->auth_reqd); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1012 | |
| 1013 | fabric->stats.flogi_sent++; |
| 1014 | } |
| 1015 | |
| 1016 | static void |
| 1017 | bfa_fcs_fabric_notify_online(struct bfa_fcs_fabric_s *fabric) |
| 1018 | { |
| 1019 | struct bfa_fcs_vport_s *vport; |
| 1020 | struct list_head *qe, *qen; |
| 1021 | |
| 1022 | bfa_trc(fabric->fcs, fabric->fabric_name); |
| 1023 | |
| 1024 | bfa_fcs_fabric_set_opertype(fabric); |
| 1025 | fabric->stats.fabric_onlines++; |
| 1026 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 1027 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1028 | * notify online event to base and then virtual ports |
| 1029 | */ |
| 1030 | bfa_fcs_lport_online(&fabric->bport); |
| 1031 | |
| 1032 | list_for_each_safe(qe, qen, &fabric->vport_q) { |
| 1033 | vport = (struct bfa_fcs_vport_s *) qe; |
| 1034 | bfa_fcs_vport_online(vport); |
| 1035 | } |
| 1036 | } |
| 1037 | |
| 1038 | static void |
| 1039 | bfa_fcs_fabric_notify_offline(struct bfa_fcs_fabric_s *fabric) |
| 1040 | { |
| 1041 | struct bfa_fcs_vport_s *vport; |
| 1042 | struct list_head *qe, *qen; |
| 1043 | |
| 1044 | bfa_trc(fabric->fcs, fabric->fabric_name); |
| 1045 | fabric->stats.fabric_offlines++; |
| 1046 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 1047 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1048 | * notify offline event first to vports and then base port. |
| 1049 | */ |
| 1050 | list_for_each_safe(qe, qen, &fabric->vport_q) { |
| 1051 | vport = (struct bfa_fcs_vport_s *) qe; |
| 1052 | bfa_fcs_vport_offline(vport); |
| 1053 | } |
| 1054 | |
| 1055 | bfa_fcs_lport_offline(&fabric->bport); |
| 1056 | |
| 1057 | fabric->fabric_name = 0; |
| 1058 | fabric->fabric_ip_addr[0] = 0; |
| 1059 | } |
| 1060 | |
| 1061 | static void |
| 1062 | bfa_fcs_fabric_delay(void *cbarg) |
| 1063 | { |
| 1064 | struct bfa_fcs_fabric_s *fabric = cbarg; |
| 1065 | |
| 1066 | bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_DELAYED); |
| 1067 | } |
| 1068 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 1069 | /* |
Krishna Gudipati | 881c1b3 | 2012-08-22 19:52:02 -0700 | [diff] [blame] | 1070 | * Stop all vports and wait for vport stop completions. |
| 1071 | */ |
| 1072 | static void |
| 1073 | bfa_fcs_fabric_stop(struct bfa_fcs_fabric_s *fabric) |
| 1074 | { |
| 1075 | struct bfa_fcs_vport_s *vport; |
| 1076 | struct list_head *qe, *qen; |
| 1077 | |
| 1078 | bfa_wc_init(&fabric->stop_wc, bfa_fcs_fabric_stop_comp, fabric); |
| 1079 | |
| 1080 | list_for_each_safe(qe, qen, &fabric->vport_q) { |
| 1081 | vport = (struct bfa_fcs_vport_s *) qe; |
| 1082 | bfa_wc_up(&fabric->stop_wc); |
| 1083 | bfa_fcs_vport_fcs_stop(vport); |
| 1084 | } |
| 1085 | |
| 1086 | bfa_wc_up(&fabric->stop_wc); |
| 1087 | bfa_fcs_lport_stop(&fabric->bport); |
| 1088 | bfa_wc_wait(&fabric->stop_wc); |
| 1089 | } |
| 1090 | |
| 1091 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1092 | * Delete all vports and wait for vport delete completions. |
| 1093 | */ |
| 1094 | static void |
| 1095 | bfa_fcs_fabric_delete(struct bfa_fcs_fabric_s *fabric) |
| 1096 | { |
| 1097 | struct bfa_fcs_vport_s *vport; |
| 1098 | struct list_head *qe, *qen; |
| 1099 | |
| 1100 | list_for_each_safe(qe, qen, &fabric->vport_q) { |
| 1101 | vport = (struct bfa_fcs_vport_s *) qe; |
| 1102 | bfa_fcs_vport_fcs_delete(vport); |
| 1103 | } |
| 1104 | |
| 1105 | bfa_fcs_lport_delete(&fabric->bport); |
| 1106 | bfa_wc_wait(&fabric->wc); |
| 1107 | } |
| 1108 | |
| 1109 | static void |
| 1110 | bfa_fcs_fabric_delete_comp(void *cbarg) |
| 1111 | { |
| 1112 | struct bfa_fcs_fabric_s *fabric = cbarg; |
| 1113 | |
| 1114 | bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_DELCOMP); |
| 1115 | } |
| 1116 | |
Krishna Gudipati | 881c1b3 | 2012-08-22 19:52:02 -0700 | [diff] [blame] | 1117 | static void |
| 1118 | bfa_fcs_fabric_stop_comp(void *cbarg) |
| 1119 | { |
| 1120 | struct bfa_fcs_fabric_s *fabric = cbarg; |
| 1121 | |
| 1122 | bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_STOPCOMP); |
| 1123 | } |
| 1124 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 1125 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1126 | * fcs_fabric_public fabric public functions |
| 1127 | */ |
| 1128 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 1129 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1130 | * Attach time initialization. |
| 1131 | */ |
| 1132 | void |
| 1133 | bfa_fcs_fabric_attach(struct bfa_fcs_s *fcs) |
| 1134 | { |
| 1135 | struct bfa_fcs_fabric_s *fabric; |
| 1136 | |
| 1137 | fabric = &fcs->fabric; |
Jing Huang | 6a18b16 | 2010-10-18 17:08:54 -0700 | [diff] [blame] | 1138 | memset(fabric, 0, sizeof(struct bfa_fcs_fabric_s)); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1139 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 1140 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1141 | * Initialize base fabric. |
| 1142 | */ |
| 1143 | fabric->fcs = fcs; |
| 1144 | INIT_LIST_HEAD(&fabric->vport_q); |
| 1145 | INIT_LIST_HEAD(&fabric->vf_q); |
| 1146 | fabric->lps = bfa_lps_alloc(fcs->bfa); |
Jing Huang | d4b671c | 2010-12-26 21:46:35 -0800 | [diff] [blame] | 1147 | WARN_ON(!fabric->lps); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1148 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 1149 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1150 | * Initialize fabric delete completion handler. Fabric deletion is |
| 1151 | * complete when the last vport delete is complete. |
| 1152 | */ |
| 1153 | bfa_wc_init(&fabric->wc, bfa_fcs_fabric_delete_comp, fabric); |
| 1154 | bfa_wc_up(&fabric->wc); /* For the base port */ |
| 1155 | |
| 1156 | bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_uninit); |
| 1157 | bfa_fcs_lport_attach(&fabric->bport, fabric->fcs, FC_VF_ID_NULL, NULL); |
| 1158 | } |
| 1159 | |
| 1160 | void |
| 1161 | bfa_fcs_fabric_modinit(struct bfa_fcs_s *fcs) |
| 1162 | { |
| 1163 | bfa_sm_send_event(&fcs->fabric, BFA_FCS_FABRIC_SM_CREATE); |
| 1164 | bfa_trc(fcs, 0); |
| 1165 | } |
| 1166 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 1167 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1168 | * Module cleanup |
| 1169 | */ |
| 1170 | void |
| 1171 | bfa_fcs_fabric_modexit(struct bfa_fcs_s *fcs) |
| 1172 | { |
| 1173 | struct bfa_fcs_fabric_s *fabric; |
| 1174 | |
| 1175 | bfa_trc(fcs, 0); |
| 1176 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 1177 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1178 | * Cleanup base fabric. |
| 1179 | */ |
| 1180 | fabric = &fcs->fabric; |
| 1181 | bfa_lps_delete(fabric->lps); |
| 1182 | bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_DELETE); |
| 1183 | } |
| 1184 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 1185 | /* |
Krishna Gudipati | 881c1b3 | 2012-08-22 19:52:02 -0700 | [diff] [blame] | 1186 | * Fabric module stop -- stop FCS actions |
| 1187 | */ |
| 1188 | void |
| 1189 | bfa_fcs_fabric_modstop(struct bfa_fcs_s *fcs) |
| 1190 | { |
| 1191 | struct bfa_fcs_fabric_s *fabric; |
| 1192 | |
| 1193 | bfa_trc(fcs, 0); |
| 1194 | fabric = &fcs->fabric; |
| 1195 | bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_STOP); |
| 1196 | } |
| 1197 | |
| 1198 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1199 | * Fabric module start -- kick starts FCS actions |
| 1200 | */ |
| 1201 | void |
| 1202 | bfa_fcs_fabric_modstart(struct bfa_fcs_s *fcs) |
| 1203 | { |
| 1204 | struct bfa_fcs_fabric_s *fabric; |
| 1205 | |
| 1206 | bfa_trc(fcs, 0); |
| 1207 | fabric = &fcs->fabric; |
| 1208 | bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_START); |
| 1209 | } |
| 1210 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1211 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 1212 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1213 | * Link up notification from BFA physical port module. |
| 1214 | */ |
| 1215 | void |
| 1216 | bfa_fcs_fabric_link_up(struct bfa_fcs_fabric_s *fabric) |
| 1217 | { |
| 1218 | bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn); |
| 1219 | bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_LINK_UP); |
| 1220 | } |
| 1221 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 1222 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1223 | * Link down notification from BFA physical port module. |
| 1224 | */ |
| 1225 | void |
| 1226 | bfa_fcs_fabric_link_down(struct bfa_fcs_fabric_s *fabric) |
| 1227 | { |
| 1228 | bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn); |
| 1229 | bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_LINK_DOWN); |
| 1230 | } |
| 1231 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 1232 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1233 | * A child vport is being created in the fabric. |
| 1234 | * |
| 1235 | * Call from vport module at vport creation. A list of base port and vports |
| 1236 | * belonging to a fabric is maintained to propagate link events. |
| 1237 | * |
| 1238 | * param[in] fabric - Fabric instance. This can be a base fabric or vf. |
| 1239 | * param[in] vport - Vport being created. |
| 1240 | * |
| 1241 | * @return None (always succeeds) |
| 1242 | */ |
| 1243 | void |
| 1244 | bfa_fcs_fabric_addvport(struct bfa_fcs_fabric_s *fabric, |
| 1245 | struct bfa_fcs_vport_s *vport) |
| 1246 | { |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 1247 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1248 | * - add vport to fabric's vport_q |
| 1249 | */ |
| 1250 | bfa_trc(fabric->fcs, fabric->vf_id); |
| 1251 | |
| 1252 | list_add_tail(&vport->qe, &fabric->vport_q); |
| 1253 | fabric->num_vports++; |
| 1254 | bfa_wc_up(&fabric->wc); |
| 1255 | } |
| 1256 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 1257 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1258 | * A child vport is being deleted from fabric. |
| 1259 | * |
| 1260 | * Vport is being deleted. |
| 1261 | */ |
| 1262 | void |
| 1263 | bfa_fcs_fabric_delvport(struct bfa_fcs_fabric_s *fabric, |
| 1264 | struct bfa_fcs_vport_s *vport) |
| 1265 | { |
| 1266 | list_del(&vport->qe); |
| 1267 | fabric->num_vports--; |
| 1268 | bfa_wc_down(&fabric->wc); |
| 1269 | } |
| 1270 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1271 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 1272 | /* |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 1273 | * Lookup for a vport within a fabric given its pwwn |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1274 | */ |
| 1275 | struct bfa_fcs_vport_s * |
| 1276 | bfa_fcs_fabric_vport_lookup(struct bfa_fcs_fabric_s *fabric, wwn_t pwwn) |
| 1277 | { |
| 1278 | struct bfa_fcs_vport_s *vport; |
| 1279 | struct list_head *qe; |
| 1280 | |
| 1281 | list_for_each(qe, &fabric->vport_q) { |
| 1282 | vport = (struct bfa_fcs_vport_s *) qe; |
| 1283 | if (bfa_fcs_lport_get_pwwn(&vport->lport) == pwwn) |
| 1284 | return vport; |
| 1285 | } |
| 1286 | |
| 1287 | return NULL; |
| 1288 | } |
| 1289 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1290 | |
| 1291 | /* |
| 1292 | * Get OUI of the attached switch. |
| 1293 | * |
| 1294 | * Note : Use of this function should be avoided as much as possible. |
| 1295 | * This function should be used only if there is any requirement |
| 1296 | * to check for FOS version below 6.3. |
| 1297 | * To check if the attached fabric is a brocade fabric, use |
| 1298 | * bfa_lps_is_brcd_fabric() which works for FOS versions 6.3 |
| 1299 | * or above only. |
| 1300 | */ |
| 1301 | |
| 1302 | u16 |
| 1303 | bfa_fcs_fabric_get_switch_oui(struct bfa_fcs_fabric_s *fabric) |
| 1304 | { |
| 1305 | wwn_t fab_nwwn; |
| 1306 | u8 *tmp; |
| 1307 | u16 oui; |
| 1308 | |
Maggie Zhang | f7f73812 | 2010-12-09 19:08:43 -0800 | [diff] [blame] | 1309 | fab_nwwn = fabric->lps->pr_nwwn; |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1310 | |
| 1311 | tmp = (u8 *)&fab_nwwn; |
| 1312 | oui = (tmp[3] << 8) | tmp[4]; |
| 1313 | |
| 1314 | return oui; |
| 1315 | } |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 1316 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1317 | * Unsolicited frame receive handling. |
| 1318 | */ |
| 1319 | void |
| 1320 | bfa_fcs_fabric_uf_recv(struct bfa_fcs_fabric_s *fabric, struct fchs_s *fchs, |
| 1321 | u16 len) |
| 1322 | { |
| 1323 | u32 pid = fchs->d_id; |
| 1324 | struct bfa_fcs_vport_s *vport; |
| 1325 | struct list_head *qe; |
| 1326 | struct fc_els_cmd_s *els_cmd = (struct fc_els_cmd_s *) (fchs + 1); |
| 1327 | struct fc_logi_s *flogi = (struct fc_logi_s *) els_cmd; |
| 1328 | |
| 1329 | bfa_trc(fabric->fcs, len); |
| 1330 | bfa_trc(fabric->fcs, pid); |
| 1331 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 1332 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1333 | * Look for our own FLOGI frames being looped back. This means an |
| 1334 | * external loopback cable is in place. Our own FLOGI frames are |
| 1335 | * sometimes looped back when switch port gets temporarily bypassed. |
| 1336 | */ |
Maggie Zhang | f16a175 | 2010-12-09 19:12:32 -0800 | [diff] [blame] | 1337 | if ((pid == bfa_ntoh3b(FC_FABRIC_PORT)) && |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1338 | (els_cmd->els_code == FC_ELS_FLOGI) && |
| 1339 | (flogi->port_name == bfa_fcs_lport_get_pwwn(&fabric->bport))) { |
| 1340 | bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_LOOPBACK); |
| 1341 | return; |
| 1342 | } |
| 1343 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 1344 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1345 | * FLOGI/EVFP exchanges should be consumed by base fabric. |
| 1346 | */ |
Maggie Zhang | f16a175 | 2010-12-09 19:12:32 -0800 | [diff] [blame] | 1347 | if (fchs->d_id == bfa_hton3b(FC_FABRIC_PORT)) { |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1348 | bfa_trc(fabric->fcs, pid); |
| 1349 | bfa_fcs_fabric_process_uf(fabric, fchs, len); |
| 1350 | return; |
| 1351 | } |
| 1352 | |
| 1353 | if (fabric->bport.pid == pid) { |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 1354 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1355 | * All authentication frames should be routed to auth |
| 1356 | */ |
| 1357 | bfa_trc(fabric->fcs, els_cmd->els_code); |
| 1358 | if (els_cmd->els_code == FC_ELS_AUTH) { |
| 1359 | bfa_trc(fabric->fcs, els_cmd->els_code); |
| 1360 | return; |
| 1361 | } |
| 1362 | |
| 1363 | bfa_trc(fabric->fcs, *(u8 *) ((u8 *) fchs)); |
| 1364 | bfa_fcs_lport_uf_recv(&fabric->bport, fchs, len); |
| 1365 | return; |
| 1366 | } |
| 1367 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 1368 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1369 | * look for a matching local port ID |
| 1370 | */ |
| 1371 | list_for_each(qe, &fabric->vport_q) { |
| 1372 | vport = (struct bfa_fcs_vport_s *) qe; |
| 1373 | if (vport->lport.pid == pid) { |
| 1374 | bfa_fcs_lport_uf_recv(&vport->lport, fchs, len); |
| 1375 | return; |
| 1376 | } |
| 1377 | } |
Krishna Gudipati | 61ba439 | 2012-08-22 19:52:58 -0700 | [diff] [blame] | 1378 | |
| 1379 | if (!bfa_fcs_fabric_is_switched(fabric)) |
| 1380 | bfa_fcs_lport_uf_recv(&fabric->bport, fchs, len); |
| 1381 | |
| 1382 | bfa_trc(fabric->fcs, fchs->type); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1383 | } |
| 1384 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 1385 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1386 | * Unsolicited frames to be processed by fabric. |
| 1387 | */ |
| 1388 | static void |
| 1389 | bfa_fcs_fabric_process_uf(struct bfa_fcs_fabric_s *fabric, struct fchs_s *fchs, |
| 1390 | u16 len) |
| 1391 | { |
| 1392 | struct fc_els_cmd_s *els_cmd = (struct fc_els_cmd_s *) (fchs + 1); |
| 1393 | |
| 1394 | bfa_trc(fabric->fcs, els_cmd->els_code); |
| 1395 | |
| 1396 | switch (els_cmd->els_code) { |
| 1397 | case FC_ELS_FLOGI: |
| 1398 | bfa_fcs_fabric_process_flogi(fabric, fchs, len); |
| 1399 | break; |
| 1400 | |
| 1401 | default: |
| 1402 | /* |
| 1403 | * need to generate a LS_RJT |
| 1404 | */ |
| 1405 | break; |
| 1406 | } |
| 1407 | } |
| 1408 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 1409 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1410 | * Process incoming FLOGI |
| 1411 | */ |
| 1412 | static void |
| 1413 | bfa_fcs_fabric_process_flogi(struct bfa_fcs_fabric_s *fabric, |
| 1414 | struct fchs_s *fchs, u16 len) |
| 1415 | { |
| 1416 | struct fc_logi_s *flogi = (struct fc_logi_s *) (fchs + 1); |
| 1417 | struct bfa_fcs_lport_s *bport = &fabric->bport; |
| 1418 | |
| 1419 | bfa_trc(fabric->fcs, fchs->s_id); |
| 1420 | |
| 1421 | fabric->stats.flogi_rcvd++; |
| 1422 | /* |
| 1423 | * Check port type. It should be 0 = n-port. |
| 1424 | */ |
| 1425 | if (flogi->csp.port_type) { |
| 1426 | /* |
| 1427 | * @todo: may need to send a LS_RJT |
| 1428 | */ |
| 1429 | bfa_trc(fabric->fcs, flogi->port_name); |
| 1430 | fabric->stats.flogi_rejected++; |
| 1431 | return; |
| 1432 | } |
| 1433 | |
Jing Huang | ba816ea | 2010-10-18 17:10:50 -0700 | [diff] [blame] | 1434 | fabric->bb_credit = be16_to_cpu(flogi->csp.bbcred); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1435 | bport->port_topo.pn2n.rem_port_wwn = flogi->port_name; |
| 1436 | bport->port_topo.pn2n.reply_oxid = fchs->ox_id; |
| 1437 | |
| 1438 | /* |
| 1439 | * Send a Flogi Acc |
| 1440 | */ |
| 1441 | bfa_fcs_fabric_send_flogi_acc(fabric); |
| 1442 | bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_NO_FABRIC); |
| 1443 | } |
| 1444 | |
| 1445 | static void |
| 1446 | bfa_fcs_fabric_send_flogi_acc(struct bfa_fcs_fabric_s *fabric) |
| 1447 | { |
| 1448 | struct bfa_lport_cfg_s *pcfg = &fabric->bport.port_cfg; |
| 1449 | struct bfa_fcs_lport_n2n_s *n2n_port = &fabric->bport.port_topo.pn2n; |
| 1450 | struct bfa_s *bfa = fabric->fcs->bfa; |
| 1451 | struct bfa_fcxp_s *fcxp; |
| 1452 | u16 reqlen; |
| 1453 | struct fchs_s fchs; |
| 1454 | |
Krishna Gudipati | c3f1b12 | 2012-08-22 19:51:08 -0700 | [diff] [blame] | 1455 | fcxp = bfa_fcs_fcxp_alloc(fabric->fcs, BFA_FALSE); |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 1456 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1457 | * Do not expect this failure -- expect remote node to retry |
| 1458 | */ |
| 1459 | if (!fcxp) |
| 1460 | return; |
| 1461 | |
| 1462 | reqlen = fc_flogi_acc_build(&fchs, bfa_fcxp_get_reqbuf(fcxp), |
Maggie Zhang | f16a175 | 2010-12-09 19:12:32 -0800 | [diff] [blame] | 1463 | bfa_hton3b(FC_FABRIC_PORT), |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1464 | n2n_port->reply_oxid, pcfg->pwwn, |
| 1465 | pcfg->nwwn, |
| 1466 | bfa_fcport_get_maxfrsize(bfa), |
Vijaya Mohan Guvva | bbe37a6 | 2013-05-13 02:33:19 -0700 | [diff] [blame] | 1467 | bfa_fcport_get_rx_bbcredit(bfa), 0); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1468 | |
Krishna Gudipati | 3fd4598 | 2011-06-24 20:24:08 -0700 | [diff] [blame] | 1469 | bfa_fcxp_send(fcxp, NULL, fabric->vf_id, fabric->lps->bfa_tag, |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1470 | BFA_FALSE, FC_CLASS_3, |
| 1471 | reqlen, &fchs, bfa_fcs_fabric_flogiacc_comp, fabric, |
| 1472 | FC_MAX_PDUSZ, 0); |
| 1473 | } |
| 1474 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 1475 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1476 | * Flogi Acc completion callback. |
| 1477 | */ |
| 1478 | static void |
| 1479 | bfa_fcs_fabric_flogiacc_comp(void *fcsarg, struct bfa_fcxp_s *fcxp, void *cbarg, |
| 1480 | bfa_status_t status, u32 rsp_len, |
| 1481 | u32 resid_len, struct fchs_s *rspfchs) |
| 1482 | { |
| 1483 | struct bfa_fcs_fabric_s *fabric = cbarg; |
| 1484 | |
| 1485 | bfa_trc(fabric->fcs, status); |
| 1486 | } |
| 1487 | |
Krishna Gudipati | 7826f30 | 2011-07-20 16:59:13 -0700 | [diff] [blame] | 1488 | |
| 1489 | /* |
| 1490 | * Send AEN notification |
| 1491 | */ |
| 1492 | static void |
| 1493 | bfa_fcs_fabric_aen_post(struct bfa_fcs_lport_s *port, |
| 1494 | enum bfa_port_aen_event event) |
| 1495 | { |
| 1496 | struct bfad_s *bfad = (struct bfad_s *)port->fabric->fcs->bfad; |
| 1497 | struct bfa_aen_entry_s *aen_entry; |
| 1498 | |
| 1499 | bfad_get_aen_entry(bfad, aen_entry); |
| 1500 | if (!aen_entry) |
| 1501 | return; |
| 1502 | |
| 1503 | aen_entry->aen_data.port.pwwn = bfa_fcs_lport_get_pwwn(port); |
| 1504 | aen_entry->aen_data.port.fwwn = bfa_fcs_lport_get_fabric_name(port); |
| 1505 | |
| 1506 | /* Send the AEN notification */ |
| 1507 | bfad_im_post_vendor_event(aen_entry, bfad, ++port->fcs->fcs_aen_seq, |
| 1508 | BFA_AEN_CAT_PORT, event); |
| 1509 | } |
| 1510 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1511 | /* |
| 1512 | * |
| 1513 | * @param[in] fabric - fabric |
| 1514 | * @param[in] wwn_t - new fabric name |
| 1515 | * |
| 1516 | * @return - none |
| 1517 | */ |
| 1518 | void |
| 1519 | bfa_fcs_fabric_set_fabric_name(struct bfa_fcs_fabric_s *fabric, |
| 1520 | wwn_t fabric_name) |
| 1521 | { |
| 1522 | struct bfad_s *bfad = (struct bfad_s *)fabric->fcs->bfad; |
| 1523 | char pwwn_ptr[BFA_STRING_32]; |
| 1524 | char fwwn_ptr[BFA_STRING_32]; |
| 1525 | |
| 1526 | bfa_trc(fabric->fcs, fabric_name); |
| 1527 | |
| 1528 | if (fabric->fabric_name == 0) { |
| 1529 | /* |
| 1530 | * With BRCD switches, we don't get Fabric Name in FLOGI. |
| 1531 | * Don't generate a fabric name change event in this case. |
| 1532 | */ |
| 1533 | fabric->fabric_name = fabric_name; |
| 1534 | } else { |
| 1535 | fabric->fabric_name = fabric_name; |
| 1536 | wwn2str(pwwn_ptr, bfa_fcs_lport_get_pwwn(&fabric->bport)); |
| 1537 | wwn2str(fwwn_ptr, |
| 1538 | bfa_fcs_lport_get_fabric_name(&fabric->bport)); |
Jing Huang | 8816624 | 2010-12-09 17:11:53 -0800 | [diff] [blame] | 1539 | BFA_LOG(KERN_WARNING, bfad, bfa_log_level, |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1540 | "Base port WWN = %s Fabric WWN = %s\n", |
| 1541 | pwwn_ptr, fwwn_ptr); |
Krishna Gudipati | 7826f30 | 2011-07-20 16:59:13 -0700 | [diff] [blame] | 1542 | bfa_fcs_fabric_aen_post(&fabric->bport, |
| 1543 | BFA_PORT_AEN_FABRIC_NAME_CHANGE); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1544 | } |
| 1545 | } |
| 1546 | |
Krishna Gudipati | 881c1b3 | 2012-08-22 19:52:02 -0700 | [diff] [blame] | 1547 | void |
| 1548 | bfa_cb_lps_flogo_comp(void *bfad, void *uarg) |
| 1549 | { |
| 1550 | struct bfa_fcs_fabric_s *fabric = uarg; |
| 1551 | bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_LOGOCOMP); |
| 1552 | } |
| 1553 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 1554 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1555 | * Returns FCS vf structure for a given vf_id. |
| 1556 | * |
| 1557 | * param[in] vf_id - VF_ID |
| 1558 | * |
| 1559 | * return |
| 1560 | * If lookup succeeds, retuns fcs vf object, otherwise returns NULL |
| 1561 | */ |
| 1562 | bfa_fcs_vf_t * |
| 1563 | bfa_fcs_vf_lookup(struct bfa_fcs_s *fcs, u16 vf_id) |
| 1564 | { |
| 1565 | bfa_trc(fcs, vf_id); |
| 1566 | if (vf_id == FC_VF_ID_NULL) |
| 1567 | return &fcs->fabric; |
| 1568 | |
| 1569 | return NULL; |
| 1570 | } |
| 1571 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 1572 | /* |
Krishna Gudipati | b85daaf | 2011-06-13 15:55:11 -0700 | [diff] [blame] | 1573 | * Return the list of local logical ports present in the given VF. |
| 1574 | * |
| 1575 | * @param[in] vf vf for which logical ports are returned |
| 1576 | * @param[out] lpwwn returned logical port wwn list |
| 1577 | * @param[in,out] nlports in:size of lpwwn list; |
| 1578 | * out:total elements present, |
| 1579 | * actual elements returned is limited by the size |
| 1580 | */ |
| 1581 | void |
| 1582 | bfa_fcs_vf_get_ports(bfa_fcs_vf_t *vf, wwn_t lpwwn[], int *nlports) |
| 1583 | { |
| 1584 | struct list_head *qe; |
| 1585 | struct bfa_fcs_vport_s *vport; |
| 1586 | int i = 0; |
| 1587 | struct bfa_fcs_s *fcs; |
| 1588 | |
| 1589 | if (vf == NULL || lpwwn == NULL || *nlports == 0) |
| 1590 | return; |
| 1591 | |
| 1592 | fcs = vf->fcs; |
| 1593 | |
| 1594 | bfa_trc(fcs, vf->vf_id); |
| 1595 | bfa_trc(fcs, (uint32_t) *nlports); |
| 1596 | |
| 1597 | lpwwn[i++] = vf->bport.port_cfg.pwwn; |
| 1598 | |
| 1599 | list_for_each(qe, &vf->vport_q) { |
| 1600 | if (i >= *nlports) |
| 1601 | break; |
| 1602 | |
| 1603 | vport = (struct bfa_fcs_vport_s *) qe; |
| 1604 | lpwwn[i++] = vport->lport.port_cfg.pwwn; |
| 1605 | } |
| 1606 | |
| 1607 | bfa_trc(fcs, i); |
| 1608 | *nlports = i; |
| 1609 | } |
| 1610 | |
| 1611 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1612 | * BFA FCS PPORT ( physical port) |
| 1613 | */ |
| 1614 | static void |
| 1615 | bfa_fcs_port_event_handler(void *cbarg, enum bfa_port_linkstate event) |
| 1616 | { |
| 1617 | struct bfa_fcs_s *fcs = cbarg; |
| 1618 | |
| 1619 | bfa_trc(fcs, event); |
| 1620 | |
| 1621 | switch (event) { |
| 1622 | case BFA_PORT_LINKUP: |
| 1623 | bfa_fcs_fabric_link_up(&fcs->fabric); |
| 1624 | break; |
| 1625 | |
| 1626 | case BFA_PORT_LINKDOWN: |
| 1627 | bfa_fcs_fabric_link_down(&fcs->fabric); |
| 1628 | break; |
| 1629 | |
| 1630 | default: |
Jing Huang | d4b671c | 2010-12-26 21:46:35 -0800 | [diff] [blame] | 1631 | WARN_ON(1); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1632 | } |
| 1633 | } |
| 1634 | |
| 1635 | void |
| 1636 | bfa_fcs_port_attach(struct bfa_fcs_s *fcs) |
| 1637 | { |
| 1638 | bfa_fcport_event_register(fcs->bfa, bfa_fcs_port_event_handler, fcs); |
| 1639 | } |
| 1640 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 1641 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1642 | * BFA FCS UF ( Unsolicited Frames) |
| 1643 | */ |
| 1644 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 1645 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1646 | * BFA callback for unsolicited frame receive handler. |
| 1647 | * |
| 1648 | * @param[in] cbarg callback arg for receive handler |
| 1649 | * @param[in] uf unsolicited frame descriptor |
| 1650 | * |
| 1651 | * @return None |
| 1652 | */ |
| 1653 | static void |
| 1654 | bfa_fcs_uf_recv(void *cbarg, struct bfa_uf_s *uf) |
| 1655 | { |
| 1656 | struct bfa_fcs_s *fcs = (struct bfa_fcs_s *) cbarg; |
| 1657 | struct fchs_s *fchs = bfa_uf_get_frmbuf(uf); |
| 1658 | u16 len = bfa_uf_get_frmlen(uf); |
| 1659 | struct fc_vft_s *vft; |
| 1660 | struct bfa_fcs_fabric_s *fabric; |
| 1661 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 1662 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1663 | * check for VFT header |
| 1664 | */ |
| 1665 | if (fchs->routing == FC_RTG_EXT_HDR && |
| 1666 | fchs->cat_info == FC_CAT_VFT_HDR) { |
| 1667 | bfa_stats(fcs, uf.tagged); |
| 1668 | vft = bfa_uf_get_frmbuf(uf); |
| 1669 | if (fcs->port_vfid == vft->vf_id) |
| 1670 | fabric = &fcs->fabric; |
| 1671 | else |
| 1672 | fabric = bfa_fcs_vf_lookup(fcs, (u16) vft->vf_id); |
| 1673 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 1674 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1675 | * drop frame if vfid is unknown |
| 1676 | */ |
| 1677 | if (!fabric) { |
Jing Huang | d4b671c | 2010-12-26 21:46:35 -0800 | [diff] [blame] | 1678 | WARN_ON(1); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1679 | bfa_stats(fcs, uf.vfid_unknown); |
| 1680 | bfa_uf_free(uf); |
| 1681 | return; |
| 1682 | } |
| 1683 | |
Jing Huang | 5fbe25c | 2010-10-18 17:17:23 -0700 | [diff] [blame] | 1684 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1685 | * skip vft header |
| 1686 | */ |
| 1687 | fchs = (struct fchs_s *) (vft + 1); |
| 1688 | len -= sizeof(struct fc_vft_s); |
| 1689 | |
| 1690 | bfa_trc(fcs, vft->vf_id); |
| 1691 | } else { |
| 1692 | bfa_stats(fcs, uf.untagged); |
| 1693 | fabric = &fcs->fabric; |
| 1694 | } |
| 1695 | |
| 1696 | bfa_trc(fcs, ((u32 *) fchs)[0]); |
| 1697 | bfa_trc(fcs, ((u32 *) fchs)[1]); |
| 1698 | bfa_trc(fcs, ((u32 *) fchs)[2]); |
| 1699 | bfa_trc(fcs, ((u32 *) fchs)[3]); |
| 1700 | bfa_trc(fcs, ((u32 *) fchs)[4]); |
| 1701 | bfa_trc(fcs, ((u32 *) fchs)[5]); |
| 1702 | bfa_trc(fcs, len); |
| 1703 | |
| 1704 | bfa_fcs_fabric_uf_recv(fabric, fchs, len); |
| 1705 | bfa_uf_free(uf); |
| 1706 | } |
| 1707 | |
| 1708 | void |
| 1709 | bfa_fcs_uf_attach(struct bfa_fcs_s *fcs) |
| 1710 | { |
| 1711 | bfa_uf_recv_register(fcs->bfa, bfa_fcs_uf_recv, fcs); |
| 1712 | } |