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