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