Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2005-2009 Brocade Communications Systems, Inc. |
| 3 | * All rights reserved |
| 4 | * www.brocade.com |
| 5 | * |
| 6 | * Linux driver for Brocade Fibre Channel Host Bus Adapter. |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify it |
| 9 | * under the terms of the GNU General Public License (GPL) Version 2 as |
| 10 | * published by the Free Software Foundation |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, but |
| 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | * General Public License for more details. |
| 16 | */ |
| 17 | |
| 18 | #include <bfa.h> |
| 19 | #include <bfa_svc.h> |
| 20 | #include <bfi/bfi_pport.h> |
Jing Huang | 3e98cc0 | 2010-07-08 19:52:46 -0700 | [diff] [blame] | 21 | #include <bfi/bfi_pbc.h> |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 22 | #include <cs/bfa_debug.h> |
| 23 | #include <aen/bfa_aen.h> |
| 24 | #include <cs/bfa_plog.h> |
| 25 | #include <aen/bfa_aen_port.h> |
| 26 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 27 | BFA_TRC_FILE(HAL, FCPORT); |
| 28 | BFA_MODULE(fcport); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 29 | |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 30 | /* |
| 31 | * The port is considered disabled if corresponding physical port or IOC are |
| 32 | * disabled explicitly |
| 33 | */ |
| 34 | #define BFA_PORT_IS_DISABLED(bfa) \ |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 35 | ((bfa_fcport_is_disabled(bfa) == BFA_TRUE) || \ |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 36 | (bfa_ioc_is_disabled(&bfa->ioc) == BFA_TRUE)) |
| 37 | |
| 38 | /* |
| 39 | * forward declarations |
| 40 | */ |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 41 | static bfa_boolean_t bfa_fcport_send_enable(struct bfa_fcport_s *fcport); |
| 42 | static bfa_boolean_t bfa_fcport_send_disable(struct bfa_fcport_s *fcport); |
| 43 | static void bfa_fcport_update_linkinfo(struct bfa_fcport_s *fcport); |
| 44 | static void bfa_fcport_reset_linkinfo(struct bfa_fcport_s *fcport); |
| 45 | static void bfa_fcport_set_wwns(struct bfa_fcport_s *fcport); |
| 46 | static void __bfa_cb_fcport_event(void *cbarg, bfa_boolean_t complete); |
| 47 | static void bfa_fcport_callback(struct bfa_fcport_s *fcport, |
| 48 | enum bfa_pport_linkstate event); |
| 49 | static void bfa_fcport_queue_cb(struct bfa_fcport_ln_s *ln, |
| 50 | enum bfa_pport_linkstate event); |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 51 | static void __bfa_cb_fcport_stats_clr(void *cbarg, bfa_boolean_t complete); |
Krishna Gudipati | ca8b432 | 2010-03-05 19:38:07 -0800 | [diff] [blame] | 52 | static void bfa_fcport_stats_get_timeout(void *cbarg); |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 53 | static void bfa_fcport_stats_clr_timeout(void *cbarg); |
| 54 | |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 55 | /** |
| 56 | * bfa_pport_private |
| 57 | */ |
| 58 | |
| 59 | /** |
| 60 | * BFA port state machine events |
| 61 | */ |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 62 | enum bfa_fcport_sm_event { |
| 63 | BFA_FCPORT_SM_START = 1, /* start port state machine */ |
| 64 | BFA_FCPORT_SM_STOP = 2, /* stop port state machine */ |
| 65 | BFA_FCPORT_SM_ENABLE = 3, /* enable port */ |
| 66 | BFA_FCPORT_SM_DISABLE = 4, /* disable port state machine */ |
| 67 | BFA_FCPORT_SM_FWRSP = 5, /* firmware enable/disable rsp */ |
| 68 | BFA_FCPORT_SM_LINKUP = 6, /* firmware linkup event */ |
| 69 | BFA_FCPORT_SM_LINKDOWN = 7, /* firmware linkup down */ |
| 70 | BFA_FCPORT_SM_QRESUME = 8, /* CQ space available */ |
| 71 | BFA_FCPORT_SM_HWFAIL = 9, /* IOC h/w failure */ |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 72 | }; |
| 73 | |
Krishna Gudipati | 9693e7d | 2010-03-05 19:36:30 -0800 | [diff] [blame] | 74 | /** |
| 75 | * BFA port link notification state machine events |
| 76 | */ |
| 77 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 78 | enum bfa_fcport_ln_sm_event { |
| 79 | BFA_FCPORT_LN_SM_LINKUP = 1, /* linkup event */ |
| 80 | BFA_FCPORT_LN_SM_LINKDOWN = 2, /* linkdown event */ |
| 81 | BFA_FCPORT_LN_SM_NOTIFICATION = 3 /* done notification */ |
Krishna Gudipati | 9693e7d | 2010-03-05 19:36:30 -0800 | [diff] [blame] | 82 | }; |
| 83 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 84 | static void bfa_fcport_sm_uninit(struct bfa_fcport_s *fcport, |
| 85 | enum bfa_fcport_sm_event event); |
| 86 | static void bfa_fcport_sm_enabling_qwait(struct bfa_fcport_s *fcport, |
| 87 | enum bfa_fcport_sm_event event); |
| 88 | static void bfa_fcport_sm_enabling(struct bfa_fcport_s *fcport, |
| 89 | enum bfa_fcport_sm_event event); |
| 90 | static void bfa_fcport_sm_linkdown(struct bfa_fcport_s *fcport, |
| 91 | enum bfa_fcport_sm_event event); |
| 92 | static void bfa_fcport_sm_linkup(struct bfa_fcport_s *fcport, |
| 93 | enum bfa_fcport_sm_event event); |
| 94 | static void bfa_fcport_sm_disabling(struct bfa_fcport_s *fcport, |
| 95 | enum bfa_fcport_sm_event event); |
| 96 | static void bfa_fcport_sm_disabling_qwait(struct bfa_fcport_s *fcport, |
| 97 | enum bfa_fcport_sm_event event); |
| 98 | static void bfa_fcport_sm_disabled(struct bfa_fcport_s *fcport, |
| 99 | enum bfa_fcport_sm_event event); |
| 100 | static void bfa_fcport_sm_stopped(struct bfa_fcport_s *fcport, |
| 101 | enum bfa_fcport_sm_event event); |
| 102 | static void bfa_fcport_sm_iocdown(struct bfa_fcport_s *fcport, |
| 103 | enum bfa_fcport_sm_event event); |
| 104 | static void bfa_fcport_sm_iocfail(struct bfa_fcport_s *fcport, |
| 105 | enum bfa_fcport_sm_event event); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 106 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 107 | static void bfa_fcport_ln_sm_dn(struct bfa_fcport_ln_s *ln, |
| 108 | enum bfa_fcport_ln_sm_event event); |
| 109 | static void bfa_fcport_ln_sm_dn_nf(struct bfa_fcport_ln_s *ln, |
| 110 | enum bfa_fcport_ln_sm_event event); |
| 111 | static void bfa_fcport_ln_sm_dn_up_nf(struct bfa_fcport_ln_s *ln, |
| 112 | enum bfa_fcport_ln_sm_event event); |
| 113 | static void bfa_fcport_ln_sm_up(struct bfa_fcport_ln_s *ln, |
| 114 | enum bfa_fcport_ln_sm_event event); |
| 115 | static void bfa_fcport_ln_sm_up_nf(struct bfa_fcport_ln_s *ln, |
| 116 | enum bfa_fcport_ln_sm_event event); |
| 117 | static void bfa_fcport_ln_sm_up_dn_nf(struct bfa_fcport_ln_s *ln, |
| 118 | enum bfa_fcport_ln_sm_event event); |
| 119 | static void bfa_fcport_ln_sm_up_dn_up_nf(struct bfa_fcport_ln_s *ln, |
| 120 | enum bfa_fcport_ln_sm_event event); |
Krishna Gudipati | 9693e7d | 2010-03-05 19:36:30 -0800 | [diff] [blame] | 121 | |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 122 | static struct bfa_sm_table_s hal_pport_sm_table[] = { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 123 | {BFA_SM(bfa_fcport_sm_uninit), BFA_PPORT_ST_UNINIT}, |
| 124 | {BFA_SM(bfa_fcport_sm_enabling_qwait), BFA_PPORT_ST_ENABLING_QWAIT}, |
| 125 | {BFA_SM(bfa_fcport_sm_enabling), BFA_PPORT_ST_ENABLING}, |
| 126 | {BFA_SM(bfa_fcport_sm_linkdown), BFA_PPORT_ST_LINKDOWN}, |
| 127 | {BFA_SM(bfa_fcport_sm_linkup), BFA_PPORT_ST_LINKUP}, |
| 128 | {BFA_SM(bfa_fcport_sm_disabling_qwait), BFA_PPORT_ST_DISABLING_QWAIT}, |
| 129 | {BFA_SM(bfa_fcport_sm_disabling), BFA_PPORT_ST_DISABLING}, |
| 130 | {BFA_SM(bfa_fcport_sm_disabled), BFA_PPORT_ST_DISABLED}, |
| 131 | {BFA_SM(bfa_fcport_sm_stopped), BFA_PPORT_ST_STOPPED}, |
| 132 | {BFA_SM(bfa_fcport_sm_iocdown), BFA_PPORT_ST_IOCDOWN}, |
| 133 | {BFA_SM(bfa_fcport_sm_iocfail), BFA_PPORT_ST_IOCDOWN}, |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 134 | }; |
| 135 | |
| 136 | static void |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 137 | bfa_fcport_aen_post(struct bfa_fcport_s *fcport, enum bfa_port_aen_event event) |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 138 | { |
| 139 | union bfa_aen_data_u aen_data; |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 140 | struct bfa_log_mod_s *logmod = fcport->bfa->logm; |
| 141 | wwn_t pwwn = fcport->pwwn; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 142 | char pwwn_ptr[BFA_STRING_32]; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 143 | |
Krishna Gudipati | 2993cc7 | 2010-03-05 19:36:47 -0800 | [diff] [blame] | 144 | memset(&aen_data, 0, sizeof(aen_data)); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 145 | wwn2str(pwwn_ptr, pwwn); |
Krishna Gudipati | 0a4b1fc | 2010-03-05 19:37:57 -0800 | [diff] [blame] | 146 | bfa_log(logmod, BFA_LOG_CREATE_ID(BFA_AEN_CAT_PORT, event), pwwn_ptr); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 147 | |
Krishna Gudipati | 0a4b1fc | 2010-03-05 19:37:57 -0800 | [diff] [blame] | 148 | aen_data.port.ioc_type = bfa_get_type(fcport->bfa); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 149 | aen_data.port.pwwn = pwwn; |
| 150 | } |
| 151 | |
| 152 | static void |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 153 | bfa_fcport_sm_uninit(struct bfa_fcport_s *fcport, |
| 154 | enum bfa_fcport_sm_event event) |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 155 | { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 156 | bfa_trc(fcport->bfa, event); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 157 | |
| 158 | switch (event) { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 159 | case BFA_FCPORT_SM_START: |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 160 | /** |
| 161 | * Start event after IOC is configured and BFA is started. |
| 162 | */ |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 163 | if (bfa_fcport_send_enable(fcport)) |
| 164 | bfa_sm_set_state(fcport, bfa_fcport_sm_enabling); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 165 | else |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 166 | bfa_sm_set_state(fcport, bfa_fcport_sm_enabling_qwait); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 167 | break; |
| 168 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 169 | case BFA_FCPORT_SM_ENABLE: |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 170 | /** |
| 171 | * Port is persistently configured to be in enabled state. Do |
| 172 | * not change state. Port enabling is done when START event is |
| 173 | * received. |
| 174 | */ |
| 175 | break; |
| 176 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 177 | case BFA_FCPORT_SM_DISABLE: |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 178 | /** |
| 179 | * If a port is persistently configured to be disabled, the |
| 180 | * first event will a port disable request. |
| 181 | */ |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 182 | bfa_sm_set_state(fcport, bfa_fcport_sm_disabled); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 183 | break; |
| 184 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 185 | case BFA_FCPORT_SM_HWFAIL: |
| 186 | bfa_sm_set_state(fcport, bfa_fcport_sm_iocdown); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 187 | break; |
| 188 | |
| 189 | default: |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 190 | bfa_sm_fault(fcport->bfa, event); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 191 | } |
| 192 | } |
| 193 | |
| 194 | static void |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 195 | bfa_fcport_sm_enabling_qwait(struct bfa_fcport_s *fcport, |
| 196 | enum bfa_fcport_sm_event event) |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 197 | { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 198 | bfa_trc(fcport->bfa, event); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 199 | |
| 200 | switch (event) { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 201 | case BFA_FCPORT_SM_QRESUME: |
| 202 | bfa_sm_set_state(fcport, bfa_fcport_sm_enabling); |
| 203 | bfa_fcport_send_enable(fcport); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 204 | break; |
| 205 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 206 | case BFA_FCPORT_SM_STOP: |
| 207 | bfa_reqq_wcancel(&fcport->reqq_wait); |
| 208 | bfa_sm_set_state(fcport, bfa_fcport_sm_stopped); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 209 | break; |
| 210 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 211 | case BFA_FCPORT_SM_ENABLE: |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 212 | /** |
| 213 | * Already enable is in progress. |
| 214 | */ |
| 215 | break; |
| 216 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 217 | case BFA_FCPORT_SM_DISABLE: |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 218 | /** |
| 219 | * Just send disable request to firmware when room becomes |
| 220 | * available in request queue. |
| 221 | */ |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 222 | bfa_sm_set_state(fcport, bfa_fcport_sm_disabled); |
| 223 | bfa_reqq_wcancel(&fcport->reqq_wait); |
| 224 | bfa_plog_str(fcport->bfa->plog, BFA_PL_MID_HAL, |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 225 | BFA_PL_EID_PORT_DISABLE, 0, "Port Disable"); |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 226 | bfa_fcport_aen_post(fcport, BFA_PORT_AEN_DISABLE); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 227 | break; |
| 228 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 229 | case BFA_FCPORT_SM_LINKUP: |
| 230 | case BFA_FCPORT_SM_LINKDOWN: |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 231 | /** |
| 232 | * Possible to get link events when doing back-to-back |
| 233 | * enable/disables. |
| 234 | */ |
| 235 | break; |
| 236 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 237 | case BFA_FCPORT_SM_HWFAIL: |
| 238 | bfa_reqq_wcancel(&fcport->reqq_wait); |
| 239 | bfa_sm_set_state(fcport, bfa_fcport_sm_iocdown); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 240 | break; |
| 241 | |
| 242 | default: |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 243 | bfa_sm_fault(fcport->bfa, event); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 244 | } |
| 245 | } |
| 246 | |
| 247 | static void |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 248 | bfa_fcport_sm_enabling(struct bfa_fcport_s *fcport, |
| 249 | enum bfa_fcport_sm_event event) |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 250 | { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 251 | bfa_trc(fcport->bfa, event); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 252 | |
| 253 | switch (event) { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 254 | case BFA_FCPORT_SM_FWRSP: |
| 255 | case BFA_FCPORT_SM_LINKDOWN: |
| 256 | bfa_sm_set_state(fcport, bfa_fcport_sm_linkdown); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 257 | break; |
| 258 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 259 | case BFA_FCPORT_SM_LINKUP: |
| 260 | bfa_fcport_update_linkinfo(fcport); |
| 261 | bfa_sm_set_state(fcport, bfa_fcport_sm_linkup); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 262 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 263 | bfa_assert(fcport->event_cbfn); |
| 264 | bfa_fcport_callback(fcport, BFA_PPORT_LINKUP); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 265 | break; |
| 266 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 267 | case BFA_FCPORT_SM_ENABLE: |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 268 | /** |
| 269 | * Already being enabled. |
| 270 | */ |
| 271 | break; |
| 272 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 273 | case BFA_FCPORT_SM_DISABLE: |
| 274 | if (bfa_fcport_send_disable(fcport)) |
| 275 | bfa_sm_set_state(fcport, bfa_fcport_sm_disabling); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 276 | else |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 277 | bfa_sm_set_state(fcport, bfa_fcport_sm_disabling_qwait); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 278 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 279 | bfa_plog_str(fcport->bfa->plog, BFA_PL_MID_HAL, |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 280 | BFA_PL_EID_PORT_DISABLE, 0, "Port Disable"); |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 281 | bfa_fcport_aen_post(fcport, BFA_PORT_AEN_DISABLE); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 282 | break; |
| 283 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 284 | case BFA_FCPORT_SM_STOP: |
| 285 | bfa_sm_set_state(fcport, bfa_fcport_sm_stopped); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 286 | break; |
| 287 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 288 | case BFA_FCPORT_SM_HWFAIL: |
| 289 | bfa_sm_set_state(fcport, bfa_fcport_sm_iocdown); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 290 | break; |
| 291 | |
| 292 | default: |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 293 | bfa_sm_fault(fcport->bfa, event); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 294 | } |
| 295 | } |
| 296 | |
| 297 | static void |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 298 | bfa_fcport_sm_linkdown(struct bfa_fcport_s *fcport, |
| 299 | enum bfa_fcport_sm_event event) |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 300 | { |
Krishna Gudipati | ca8b432 | 2010-03-05 19:38:07 -0800 | [diff] [blame] | 301 | struct bfi_fcport_event_s *pevent = fcport->event_arg.i2hmsg.event; |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 302 | bfa_trc(fcport->bfa, event); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 303 | |
| 304 | switch (event) { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 305 | case BFA_FCPORT_SM_LINKUP: |
| 306 | bfa_fcport_update_linkinfo(fcport); |
| 307 | bfa_sm_set_state(fcport, bfa_fcport_sm_linkup); |
| 308 | bfa_assert(fcport->event_cbfn); |
| 309 | bfa_plog_str(fcport->bfa->plog, BFA_PL_MID_HAL, |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 310 | BFA_PL_EID_PORT_ST_CHANGE, 0, "Port Linkup"); |
Krishna Gudipati | f58e9eb | 2010-03-05 19:37:45 -0800 | [diff] [blame] | 311 | |
| 312 | if (!bfa_ioc_get_fcmode(&fcport->bfa->ioc)) { |
| 313 | |
Jing Huang | db954c0 | 2010-07-08 19:58:01 -0700 | [diff] [blame] | 314 | bfa_trc(fcport->bfa, |
| 315 | pevent->link_state.vc_fcf.fcf.fipenabled); |
| 316 | bfa_trc(fcport->bfa, |
| 317 | pevent->link_state.vc_fcf.fcf.fipfailed); |
Krishna Gudipati | f58e9eb | 2010-03-05 19:37:45 -0800 | [diff] [blame] | 318 | |
Jing Huang | db954c0 | 2010-07-08 19:58:01 -0700 | [diff] [blame] | 319 | if (pevent->link_state.vc_fcf.fcf.fipfailed) |
Krishna Gudipati | f58e9eb | 2010-03-05 19:37:45 -0800 | [diff] [blame] | 320 | bfa_plog_str(fcport->bfa->plog, BFA_PL_MID_HAL, |
| 321 | BFA_PL_EID_FIP_FCF_DISC, 0, |
| 322 | "FIP FCF Discovery Failed"); |
| 323 | else |
| 324 | bfa_plog_str(fcport->bfa->plog, BFA_PL_MID_HAL, |
| 325 | BFA_PL_EID_FIP_FCF_DISC, 0, |
| 326 | "FIP FCF Discovered"); |
| 327 | } |
| 328 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 329 | bfa_fcport_callback(fcport, BFA_PPORT_LINKUP); |
| 330 | bfa_fcport_aen_post(fcport, BFA_PORT_AEN_ONLINE); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 331 | /** |
| 332 | * If QoS is enabled and it is not online, |
| 333 | * Send a separate event. |
| 334 | */ |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 335 | if ((fcport->cfg.qos_enabled) |
| 336 | && (bfa_os_ntohl(fcport->qos_attr.state) != BFA_QOS_ONLINE)) |
| 337 | bfa_fcport_aen_post(fcport, BFA_PORT_AEN_QOS_NEG); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 338 | |
| 339 | break; |
| 340 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 341 | case BFA_FCPORT_SM_LINKDOWN: |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 342 | /** |
| 343 | * Possible to get link down event. |
| 344 | */ |
| 345 | break; |
| 346 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 347 | case BFA_FCPORT_SM_ENABLE: |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 348 | /** |
| 349 | * Already enabled. |
| 350 | */ |
| 351 | break; |
| 352 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 353 | case BFA_FCPORT_SM_DISABLE: |
| 354 | if (bfa_fcport_send_disable(fcport)) |
| 355 | bfa_sm_set_state(fcport, bfa_fcport_sm_disabling); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 356 | else |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 357 | bfa_sm_set_state(fcport, bfa_fcport_sm_disabling_qwait); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 358 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 359 | bfa_plog_str(fcport->bfa->plog, BFA_PL_MID_HAL, |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 360 | BFA_PL_EID_PORT_DISABLE, 0, "Port Disable"); |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 361 | bfa_fcport_aen_post(fcport, BFA_PORT_AEN_DISABLE); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 362 | break; |
| 363 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 364 | case BFA_FCPORT_SM_STOP: |
| 365 | bfa_sm_set_state(fcport, bfa_fcport_sm_stopped); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 366 | break; |
| 367 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 368 | case BFA_FCPORT_SM_HWFAIL: |
| 369 | bfa_sm_set_state(fcport, bfa_fcport_sm_iocdown); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 370 | break; |
| 371 | |
| 372 | default: |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 373 | bfa_sm_fault(fcport->bfa, event); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 374 | } |
| 375 | } |
| 376 | |
| 377 | static void |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 378 | bfa_fcport_sm_linkup(struct bfa_fcport_s *fcport, |
| 379 | enum bfa_fcport_sm_event event) |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 380 | { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 381 | bfa_trc(fcport->bfa, event); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 382 | |
| 383 | switch (event) { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 384 | case BFA_FCPORT_SM_ENABLE: |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 385 | /** |
| 386 | * Already enabled. |
| 387 | */ |
| 388 | break; |
| 389 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 390 | case BFA_FCPORT_SM_DISABLE: |
| 391 | if (bfa_fcport_send_disable(fcport)) |
| 392 | bfa_sm_set_state(fcport, bfa_fcport_sm_disabling); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 393 | else |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 394 | bfa_sm_set_state(fcport, bfa_fcport_sm_disabling_qwait); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 395 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 396 | bfa_fcport_reset_linkinfo(fcport); |
| 397 | bfa_fcport_callback(fcport, BFA_PPORT_LINKDOWN); |
| 398 | bfa_plog_str(fcport->bfa->plog, BFA_PL_MID_HAL, |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 399 | BFA_PL_EID_PORT_DISABLE, 0, "Port Disable"); |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 400 | bfa_fcport_aen_post(fcport, BFA_PORT_AEN_OFFLINE); |
| 401 | bfa_fcport_aen_post(fcport, BFA_PORT_AEN_DISABLE); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 402 | break; |
| 403 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 404 | case BFA_FCPORT_SM_LINKDOWN: |
| 405 | bfa_sm_set_state(fcport, bfa_fcport_sm_linkdown); |
| 406 | bfa_fcport_reset_linkinfo(fcport); |
| 407 | bfa_fcport_callback(fcport, BFA_PPORT_LINKDOWN); |
| 408 | bfa_plog_str(fcport->bfa->plog, BFA_PL_MID_HAL, |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 409 | BFA_PL_EID_PORT_ST_CHANGE, 0, "Port Linkdown"); |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 410 | if (BFA_PORT_IS_DISABLED(fcport->bfa)) |
| 411 | bfa_fcport_aen_post(fcport, BFA_PORT_AEN_OFFLINE); |
Jing Huang | f8ceafd | 2009-09-25 12:29:54 -0700 | [diff] [blame] | 412 | else |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 413 | bfa_fcport_aen_post(fcport, BFA_PORT_AEN_DISCONNECT); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 414 | break; |
| 415 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 416 | case BFA_FCPORT_SM_STOP: |
| 417 | bfa_sm_set_state(fcport, bfa_fcport_sm_stopped); |
| 418 | bfa_fcport_reset_linkinfo(fcport); |
| 419 | if (BFA_PORT_IS_DISABLED(fcport->bfa)) |
| 420 | bfa_fcport_aen_post(fcport, BFA_PORT_AEN_OFFLINE); |
Jing Huang | f8ceafd | 2009-09-25 12:29:54 -0700 | [diff] [blame] | 421 | else |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 422 | bfa_fcport_aen_post(fcport, BFA_PORT_AEN_DISCONNECT); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 423 | break; |
| 424 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 425 | case BFA_FCPORT_SM_HWFAIL: |
| 426 | bfa_sm_set_state(fcport, bfa_fcport_sm_iocdown); |
| 427 | bfa_fcport_reset_linkinfo(fcport); |
| 428 | bfa_fcport_callback(fcport, BFA_PPORT_LINKDOWN); |
| 429 | if (BFA_PORT_IS_DISABLED(fcport->bfa)) |
| 430 | bfa_fcport_aen_post(fcport, BFA_PORT_AEN_OFFLINE); |
Jing Huang | f8ceafd | 2009-09-25 12:29:54 -0700 | [diff] [blame] | 431 | else |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 432 | bfa_fcport_aen_post(fcport, BFA_PORT_AEN_DISCONNECT); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 433 | break; |
| 434 | |
| 435 | default: |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 436 | bfa_sm_fault(fcport->bfa, event); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 437 | } |
| 438 | } |
| 439 | |
| 440 | static void |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 441 | bfa_fcport_sm_disabling_qwait(struct bfa_fcport_s *fcport, |
| 442 | enum bfa_fcport_sm_event event) |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 443 | { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 444 | bfa_trc(fcport->bfa, event); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 445 | |
| 446 | switch (event) { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 447 | case BFA_FCPORT_SM_QRESUME: |
| 448 | bfa_sm_set_state(fcport, bfa_fcport_sm_disabling); |
| 449 | bfa_fcport_send_disable(fcport); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 450 | break; |
| 451 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 452 | case BFA_FCPORT_SM_STOP: |
| 453 | bfa_sm_set_state(fcport, bfa_fcport_sm_stopped); |
| 454 | bfa_reqq_wcancel(&fcport->reqq_wait); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 455 | break; |
| 456 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 457 | case BFA_FCPORT_SM_DISABLE: |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 458 | /** |
| 459 | * Already being disabled. |
| 460 | */ |
| 461 | break; |
| 462 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 463 | case BFA_FCPORT_SM_LINKUP: |
| 464 | case BFA_FCPORT_SM_LINKDOWN: |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 465 | /** |
| 466 | * Possible to get link events when doing back-to-back |
| 467 | * enable/disables. |
| 468 | */ |
| 469 | break; |
| 470 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 471 | case BFA_FCPORT_SM_HWFAIL: |
| 472 | bfa_sm_set_state(fcport, bfa_fcport_sm_iocfail); |
| 473 | bfa_reqq_wcancel(&fcport->reqq_wait); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 474 | break; |
| 475 | |
| 476 | default: |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 477 | bfa_sm_fault(fcport->bfa, event); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 478 | } |
| 479 | } |
| 480 | |
| 481 | static void |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 482 | bfa_fcport_sm_disabling(struct bfa_fcport_s *fcport, |
| 483 | enum bfa_fcport_sm_event event) |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 484 | { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 485 | bfa_trc(fcport->bfa, event); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 486 | |
| 487 | switch (event) { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 488 | case BFA_FCPORT_SM_FWRSP: |
| 489 | bfa_sm_set_state(fcport, bfa_fcport_sm_disabled); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 490 | break; |
| 491 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 492 | case BFA_FCPORT_SM_DISABLE: |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 493 | /** |
| 494 | * Already being disabled. |
| 495 | */ |
| 496 | break; |
| 497 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 498 | case BFA_FCPORT_SM_ENABLE: |
| 499 | if (bfa_fcport_send_enable(fcport)) |
| 500 | bfa_sm_set_state(fcport, bfa_fcport_sm_enabling); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 501 | else |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 502 | bfa_sm_set_state(fcport, bfa_fcport_sm_enabling_qwait); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 503 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 504 | bfa_plog_str(fcport->bfa->plog, BFA_PL_MID_HAL, |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 505 | BFA_PL_EID_PORT_ENABLE, 0, "Port Enable"); |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 506 | bfa_fcport_aen_post(fcport, BFA_PORT_AEN_ENABLE); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 507 | break; |
| 508 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 509 | case BFA_FCPORT_SM_STOP: |
| 510 | bfa_sm_set_state(fcport, bfa_fcport_sm_stopped); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 511 | break; |
| 512 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 513 | case BFA_FCPORT_SM_LINKUP: |
| 514 | case BFA_FCPORT_SM_LINKDOWN: |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 515 | /** |
| 516 | * Possible to get link events when doing back-to-back |
| 517 | * enable/disables. |
| 518 | */ |
| 519 | break; |
| 520 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 521 | case BFA_FCPORT_SM_HWFAIL: |
| 522 | bfa_sm_set_state(fcport, bfa_fcport_sm_iocfail); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 523 | break; |
| 524 | |
| 525 | default: |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 526 | bfa_sm_fault(fcport->bfa, event); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 527 | } |
| 528 | } |
| 529 | |
| 530 | static void |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 531 | bfa_fcport_sm_disabled(struct bfa_fcport_s *fcport, |
| 532 | enum bfa_fcport_sm_event event) |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 533 | { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 534 | bfa_trc(fcport->bfa, event); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 535 | |
| 536 | switch (event) { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 537 | case BFA_FCPORT_SM_START: |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 538 | /** |
| 539 | * Ignore start event for a port that is disabled. |
| 540 | */ |
| 541 | break; |
| 542 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 543 | case BFA_FCPORT_SM_STOP: |
| 544 | bfa_sm_set_state(fcport, bfa_fcport_sm_stopped); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 545 | break; |
| 546 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 547 | case BFA_FCPORT_SM_ENABLE: |
| 548 | if (bfa_fcport_send_enable(fcport)) |
| 549 | bfa_sm_set_state(fcport, bfa_fcport_sm_enabling); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 550 | else |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 551 | bfa_sm_set_state(fcport, bfa_fcport_sm_enabling_qwait); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 552 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 553 | bfa_plog_str(fcport->bfa->plog, BFA_PL_MID_HAL, |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 554 | BFA_PL_EID_PORT_ENABLE, 0, "Port Enable"); |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 555 | bfa_fcport_aen_post(fcport, BFA_PORT_AEN_ENABLE); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 556 | break; |
| 557 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 558 | case BFA_FCPORT_SM_DISABLE: |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 559 | /** |
| 560 | * Already disabled. |
| 561 | */ |
| 562 | break; |
| 563 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 564 | case BFA_FCPORT_SM_HWFAIL: |
| 565 | bfa_sm_set_state(fcport, bfa_fcport_sm_iocfail); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 566 | break; |
| 567 | |
| 568 | default: |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 569 | bfa_sm_fault(fcport->bfa, event); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 570 | } |
| 571 | } |
| 572 | |
| 573 | static void |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 574 | bfa_fcport_sm_stopped(struct bfa_fcport_s *fcport, |
| 575 | enum bfa_fcport_sm_event event) |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 576 | { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 577 | bfa_trc(fcport->bfa, event); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 578 | |
| 579 | switch (event) { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 580 | case BFA_FCPORT_SM_START: |
| 581 | if (bfa_fcport_send_enable(fcport)) |
| 582 | bfa_sm_set_state(fcport, bfa_fcport_sm_enabling); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 583 | else |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 584 | bfa_sm_set_state(fcport, bfa_fcport_sm_enabling_qwait); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 585 | break; |
| 586 | |
| 587 | default: |
| 588 | /** |
| 589 | * Ignore all other events. |
| 590 | */ |
| 591 | ; |
| 592 | } |
| 593 | } |
| 594 | |
| 595 | /** |
| 596 | * Port is enabled. IOC is down/failed. |
| 597 | */ |
| 598 | static void |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 599 | bfa_fcport_sm_iocdown(struct bfa_fcport_s *fcport, |
| 600 | enum bfa_fcport_sm_event event) |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 601 | { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 602 | bfa_trc(fcport->bfa, event); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 603 | |
| 604 | switch (event) { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 605 | case BFA_FCPORT_SM_START: |
| 606 | if (bfa_fcport_send_enable(fcport)) |
| 607 | bfa_sm_set_state(fcport, bfa_fcport_sm_enabling); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 608 | else |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 609 | bfa_sm_set_state(fcport, bfa_fcport_sm_enabling_qwait); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 610 | break; |
| 611 | |
| 612 | default: |
| 613 | /** |
| 614 | * Ignore all events. |
| 615 | */ |
| 616 | ; |
| 617 | } |
| 618 | } |
| 619 | |
| 620 | /** |
| 621 | * Port is disabled. IOC is down/failed. |
| 622 | */ |
| 623 | static void |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 624 | bfa_fcport_sm_iocfail(struct bfa_fcport_s *fcport, |
| 625 | enum bfa_fcport_sm_event event) |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 626 | { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 627 | bfa_trc(fcport->bfa, event); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 628 | |
| 629 | switch (event) { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 630 | case BFA_FCPORT_SM_START: |
| 631 | bfa_sm_set_state(fcport, bfa_fcport_sm_disabled); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 632 | break; |
| 633 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 634 | case BFA_FCPORT_SM_ENABLE: |
| 635 | bfa_sm_set_state(fcport, bfa_fcport_sm_iocdown); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 636 | break; |
| 637 | |
| 638 | default: |
| 639 | /** |
| 640 | * Ignore all events. |
| 641 | */ |
| 642 | ; |
| 643 | } |
| 644 | } |
| 645 | |
Krishna Gudipati | 9693e7d | 2010-03-05 19:36:30 -0800 | [diff] [blame] | 646 | /** |
| 647 | * Link state is down |
| 648 | */ |
| 649 | static void |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 650 | bfa_fcport_ln_sm_dn(struct bfa_fcport_ln_s *ln, |
| 651 | enum bfa_fcport_ln_sm_event event) |
Krishna Gudipati | 9693e7d | 2010-03-05 19:36:30 -0800 | [diff] [blame] | 652 | { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 653 | bfa_trc(ln->fcport->bfa, event); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 654 | |
Krishna Gudipati | 9693e7d | 2010-03-05 19:36:30 -0800 | [diff] [blame] | 655 | switch (event) { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 656 | case BFA_FCPORT_LN_SM_LINKUP: |
| 657 | bfa_sm_set_state(ln, bfa_fcport_ln_sm_up_nf); |
| 658 | bfa_fcport_queue_cb(ln, BFA_PPORT_LINKUP); |
Krishna Gudipati | 9693e7d | 2010-03-05 19:36:30 -0800 | [diff] [blame] | 659 | break; |
| 660 | |
| 661 | default: |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 662 | bfa_sm_fault(ln->fcport->bfa, event); |
Krishna Gudipati | 9693e7d | 2010-03-05 19:36:30 -0800 | [diff] [blame] | 663 | } |
| 664 | } |
| 665 | |
| 666 | /** |
| 667 | * Link state is waiting for down notification |
| 668 | */ |
| 669 | static void |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 670 | bfa_fcport_ln_sm_dn_nf(struct bfa_fcport_ln_s *ln, |
| 671 | enum bfa_fcport_ln_sm_event event) |
Krishna Gudipati | 9693e7d | 2010-03-05 19:36:30 -0800 | [diff] [blame] | 672 | { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 673 | bfa_trc(ln->fcport->bfa, event); |
Krishna Gudipati | 9693e7d | 2010-03-05 19:36:30 -0800 | [diff] [blame] | 674 | |
| 675 | switch (event) { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 676 | case BFA_FCPORT_LN_SM_LINKUP: |
| 677 | bfa_sm_set_state(ln, bfa_fcport_ln_sm_dn_up_nf); |
Krishna Gudipati | 9693e7d | 2010-03-05 19:36:30 -0800 | [diff] [blame] | 678 | break; |
| 679 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 680 | case BFA_FCPORT_LN_SM_NOTIFICATION: |
| 681 | bfa_sm_set_state(ln, bfa_fcport_ln_sm_dn); |
Krishna Gudipati | 9693e7d | 2010-03-05 19:36:30 -0800 | [diff] [blame] | 682 | break; |
| 683 | |
| 684 | default: |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 685 | bfa_sm_fault(ln->fcport->bfa, event); |
Krishna Gudipati | 9693e7d | 2010-03-05 19:36:30 -0800 | [diff] [blame] | 686 | } |
| 687 | } |
| 688 | |
| 689 | /** |
| 690 | * Link state is waiting for down notification and there is a pending up |
| 691 | */ |
| 692 | static void |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 693 | bfa_fcport_ln_sm_dn_up_nf(struct bfa_fcport_ln_s *ln, |
| 694 | enum bfa_fcport_ln_sm_event event) |
Krishna Gudipati | 9693e7d | 2010-03-05 19:36:30 -0800 | [diff] [blame] | 695 | { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 696 | bfa_trc(ln->fcport->bfa, event); |
Krishna Gudipati | 9693e7d | 2010-03-05 19:36:30 -0800 | [diff] [blame] | 697 | |
| 698 | switch (event) { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 699 | case BFA_FCPORT_LN_SM_LINKDOWN: |
| 700 | bfa_sm_set_state(ln, bfa_fcport_ln_sm_dn_nf); |
Krishna Gudipati | 9693e7d | 2010-03-05 19:36:30 -0800 | [diff] [blame] | 701 | break; |
| 702 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 703 | case BFA_FCPORT_LN_SM_NOTIFICATION: |
| 704 | bfa_sm_set_state(ln, bfa_fcport_ln_sm_up_nf); |
| 705 | bfa_fcport_queue_cb(ln, BFA_PPORT_LINKUP); |
Krishna Gudipati | 9693e7d | 2010-03-05 19:36:30 -0800 | [diff] [blame] | 706 | break; |
| 707 | |
| 708 | default: |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 709 | bfa_sm_fault(ln->fcport->bfa, event); |
Krishna Gudipati | 9693e7d | 2010-03-05 19:36:30 -0800 | [diff] [blame] | 710 | } |
| 711 | } |
| 712 | |
| 713 | /** |
| 714 | * Link state is up |
| 715 | */ |
| 716 | static void |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 717 | bfa_fcport_ln_sm_up(struct bfa_fcport_ln_s *ln, |
| 718 | enum bfa_fcport_ln_sm_event event) |
Krishna Gudipati | 9693e7d | 2010-03-05 19:36:30 -0800 | [diff] [blame] | 719 | { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 720 | bfa_trc(ln->fcport->bfa, event); |
Krishna Gudipati | 9693e7d | 2010-03-05 19:36:30 -0800 | [diff] [blame] | 721 | |
| 722 | switch (event) { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 723 | case BFA_FCPORT_LN_SM_LINKDOWN: |
| 724 | bfa_sm_set_state(ln, bfa_fcport_ln_sm_dn_nf); |
| 725 | bfa_fcport_queue_cb(ln, BFA_PPORT_LINKDOWN); |
Krishna Gudipati | 9693e7d | 2010-03-05 19:36:30 -0800 | [diff] [blame] | 726 | break; |
| 727 | |
| 728 | default: |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 729 | bfa_sm_fault(ln->fcport->bfa, event); |
Krishna Gudipati | 9693e7d | 2010-03-05 19:36:30 -0800 | [diff] [blame] | 730 | } |
| 731 | } |
| 732 | |
| 733 | /** |
| 734 | * Link state is waiting for up notification |
| 735 | */ |
| 736 | static void |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 737 | bfa_fcport_ln_sm_up_nf(struct bfa_fcport_ln_s *ln, |
| 738 | enum bfa_fcport_ln_sm_event event) |
Krishna Gudipati | 9693e7d | 2010-03-05 19:36:30 -0800 | [diff] [blame] | 739 | { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 740 | bfa_trc(ln->fcport->bfa, event); |
Krishna Gudipati | 9693e7d | 2010-03-05 19:36:30 -0800 | [diff] [blame] | 741 | |
| 742 | switch (event) { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 743 | case BFA_FCPORT_LN_SM_LINKDOWN: |
| 744 | bfa_sm_set_state(ln, bfa_fcport_ln_sm_up_dn_nf); |
Krishna Gudipati | 9693e7d | 2010-03-05 19:36:30 -0800 | [diff] [blame] | 745 | break; |
| 746 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 747 | case BFA_FCPORT_LN_SM_NOTIFICATION: |
| 748 | bfa_sm_set_state(ln, bfa_fcport_ln_sm_up); |
Krishna Gudipati | 9693e7d | 2010-03-05 19:36:30 -0800 | [diff] [blame] | 749 | break; |
| 750 | |
| 751 | default: |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 752 | bfa_sm_fault(ln->fcport->bfa, event); |
Krishna Gudipati | 9693e7d | 2010-03-05 19:36:30 -0800 | [diff] [blame] | 753 | } |
| 754 | } |
| 755 | |
| 756 | /** |
| 757 | * Link state is waiting for up notification and there is a pending down |
| 758 | */ |
| 759 | static void |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 760 | bfa_fcport_ln_sm_up_dn_nf(struct bfa_fcport_ln_s *ln, |
| 761 | enum bfa_fcport_ln_sm_event event) |
Krishna Gudipati | 9693e7d | 2010-03-05 19:36:30 -0800 | [diff] [blame] | 762 | { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 763 | bfa_trc(ln->fcport->bfa, event); |
Krishna Gudipati | 9693e7d | 2010-03-05 19:36:30 -0800 | [diff] [blame] | 764 | |
| 765 | switch (event) { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 766 | case BFA_FCPORT_LN_SM_LINKUP: |
| 767 | bfa_sm_set_state(ln, bfa_fcport_ln_sm_up_dn_up_nf); |
Krishna Gudipati | 9693e7d | 2010-03-05 19:36:30 -0800 | [diff] [blame] | 768 | break; |
| 769 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 770 | case BFA_FCPORT_LN_SM_NOTIFICATION: |
| 771 | bfa_sm_set_state(ln, bfa_fcport_ln_sm_dn_nf); |
| 772 | bfa_fcport_queue_cb(ln, BFA_PPORT_LINKDOWN); |
Krishna Gudipati | 9693e7d | 2010-03-05 19:36:30 -0800 | [diff] [blame] | 773 | break; |
| 774 | |
| 775 | default: |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 776 | bfa_sm_fault(ln->fcport->bfa, event); |
Krishna Gudipati | 9693e7d | 2010-03-05 19:36:30 -0800 | [diff] [blame] | 777 | } |
| 778 | } |
| 779 | |
| 780 | /** |
| 781 | * Link state is waiting for up notification and there are pending down and up |
| 782 | */ |
| 783 | static void |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 784 | bfa_fcport_ln_sm_up_dn_up_nf(struct bfa_fcport_ln_s *ln, |
| 785 | enum bfa_fcport_ln_sm_event event) |
Krishna Gudipati | 9693e7d | 2010-03-05 19:36:30 -0800 | [diff] [blame] | 786 | { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 787 | bfa_trc(ln->fcport->bfa, event); |
Krishna Gudipati | 9693e7d | 2010-03-05 19:36:30 -0800 | [diff] [blame] | 788 | |
| 789 | switch (event) { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 790 | case BFA_FCPORT_LN_SM_LINKDOWN: |
| 791 | bfa_sm_set_state(ln, bfa_fcport_ln_sm_up_dn_nf); |
Krishna Gudipati | 9693e7d | 2010-03-05 19:36:30 -0800 | [diff] [blame] | 792 | break; |
| 793 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 794 | case BFA_FCPORT_LN_SM_NOTIFICATION: |
| 795 | bfa_sm_set_state(ln, bfa_fcport_ln_sm_dn_up_nf); |
| 796 | bfa_fcport_queue_cb(ln, BFA_PPORT_LINKDOWN); |
Krishna Gudipati | 9693e7d | 2010-03-05 19:36:30 -0800 | [diff] [blame] | 797 | break; |
| 798 | |
| 799 | default: |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 800 | bfa_sm_fault(ln->fcport->bfa, event); |
Krishna Gudipati | 9693e7d | 2010-03-05 19:36:30 -0800 | [diff] [blame] | 801 | } |
| 802 | } |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 803 | |
| 804 | /** |
| 805 | * bfa_pport_private |
| 806 | */ |
| 807 | |
| 808 | static void |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 809 | __bfa_cb_fcport_event(void *cbarg, bfa_boolean_t complete) |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 810 | { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 811 | struct bfa_fcport_ln_s *ln = cbarg; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 812 | |
| 813 | if (complete) |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 814 | ln->fcport->event_cbfn(ln->fcport->event_cbarg, ln->ln_event); |
Krishna Gudipati | 9693e7d | 2010-03-05 19:36:30 -0800 | [diff] [blame] | 815 | else |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 816 | bfa_sm_send_event(ln, BFA_FCPORT_LN_SM_NOTIFICATION); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 817 | } |
| 818 | |
Krishna Gudipati | ca8b432 | 2010-03-05 19:38:07 -0800 | [diff] [blame] | 819 | static void |
| 820 | bfa_fcport_callback(struct bfa_fcport_s *fcport, enum bfa_pport_linkstate event) |
| 821 | { |
| 822 | if (fcport->bfa->fcs) { |
| 823 | fcport->event_cbfn(fcport->event_cbarg, event); |
| 824 | return; |
| 825 | } |
| 826 | |
| 827 | switch (event) { |
| 828 | case BFA_PPORT_LINKUP: |
| 829 | bfa_sm_send_event(&fcport->ln, BFA_FCPORT_LN_SM_LINKUP); |
| 830 | break; |
| 831 | case BFA_PPORT_LINKDOWN: |
| 832 | bfa_sm_send_event(&fcport->ln, BFA_FCPORT_LN_SM_LINKDOWN); |
| 833 | break; |
| 834 | default: |
| 835 | bfa_assert(0); |
| 836 | } |
| 837 | } |
| 838 | |
| 839 | static void |
| 840 | bfa_fcport_queue_cb(struct bfa_fcport_ln_s *ln, enum bfa_pport_linkstate event) |
| 841 | { |
| 842 | ln->ln_event = event; |
| 843 | bfa_cb_queue(ln->fcport->bfa, &ln->ln_qe, __bfa_cb_fcport_event, ln); |
| 844 | } |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 845 | |
| 846 | #define FCPORT_STATS_DMA_SZ (BFA_ROUNDUP(sizeof(union bfa_fcport_stats_u), \ |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 847 | BFA_CACHELINE_SZ)) |
| 848 | |
| 849 | static void |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 850 | bfa_fcport_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *ndm_len, |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 851 | u32 *dm_len) |
| 852 | { |
Krishna Gudipati | ca8b432 | 2010-03-05 19:38:07 -0800 | [diff] [blame] | 853 | *dm_len += FCPORT_STATS_DMA_SZ; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 854 | } |
| 855 | |
| 856 | static void |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 857 | bfa_fcport_qresume(void *cbarg) |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 858 | { |
Krishna Gudipati | d1c61f8 | 2010-03-05 19:38:44 -0800 | [diff] [blame] | 859 | struct bfa_fcport_s *fcport = cbarg; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 860 | |
Krishna Gudipati | d1c61f8 | 2010-03-05 19:38:44 -0800 | [diff] [blame] | 861 | bfa_sm_send_event(fcport, BFA_FCPORT_SM_QRESUME); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 862 | } |
| 863 | |
| 864 | static void |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 865 | bfa_fcport_mem_claim(struct bfa_fcport_s *fcport, struct bfa_meminfo_s *meminfo) |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 866 | { |
| 867 | u8 *dm_kva; |
| 868 | u64 dm_pa; |
| 869 | |
| 870 | dm_kva = bfa_meminfo_dma_virt(meminfo); |
| 871 | dm_pa = bfa_meminfo_dma_phys(meminfo); |
| 872 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 873 | fcport->stats_kva = dm_kva; |
| 874 | fcport->stats_pa = dm_pa; |
Krishna Gudipati | ca8b432 | 2010-03-05 19:38:07 -0800 | [diff] [blame] | 875 | fcport->stats = (union bfa_fcport_stats_u *)dm_kva; |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 876 | |
| 877 | dm_kva += FCPORT_STATS_DMA_SZ; |
| 878 | dm_pa += FCPORT_STATS_DMA_SZ; |
| 879 | |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 880 | bfa_meminfo_dma_virt(meminfo) = dm_kva; |
| 881 | bfa_meminfo_dma_phys(meminfo) = dm_pa; |
| 882 | } |
| 883 | |
| 884 | /** |
| 885 | * Memory initialization. |
| 886 | */ |
| 887 | static void |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 888 | bfa_fcport_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg, |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 889 | struct bfa_meminfo_s *meminfo, struct bfa_pcidev_s *pcidev) |
| 890 | { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 891 | struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); |
| 892 | struct bfa_pport_cfg_s *port_cfg = &fcport->cfg; |
| 893 | struct bfa_fcport_ln_s *ln = &fcport->ln; |
Jing Huang | b85d045 | 2010-07-08 19:48:49 -0700 | [diff] [blame] | 894 | struct bfa_timeval_s tv; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 895 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 896 | bfa_os_memset(fcport, 0, sizeof(struct bfa_fcport_s)); |
| 897 | fcport->bfa = bfa; |
| 898 | ln->fcport = fcport; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 899 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 900 | bfa_fcport_mem_claim(fcport, meminfo); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 901 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 902 | bfa_sm_set_state(fcport, bfa_fcport_sm_uninit); |
| 903 | bfa_sm_set_state(ln, bfa_fcport_ln_sm_dn); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 904 | |
| 905 | /** |
Jing Huang | b85d045 | 2010-07-08 19:48:49 -0700 | [diff] [blame] | 906 | * initialize time stamp for stats reset |
| 907 | */ |
| 908 | bfa_os_gettimeofday(&tv); |
| 909 | fcport->stats_reset_time = tv.tv_sec; |
| 910 | |
| 911 | /** |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 912 | * initialize and set default configuration |
| 913 | */ |
| 914 | port_cfg->topology = BFA_PPORT_TOPOLOGY_P2P; |
| 915 | port_cfg->speed = BFA_PPORT_SPEED_AUTO; |
| 916 | port_cfg->trunked = BFA_FALSE; |
| 917 | port_cfg->maxfrsize = 0; |
| 918 | |
| 919 | port_cfg->trl_def_speed = BFA_PPORT_SPEED_1GBPS; |
| 920 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 921 | bfa_reqq_winit(&fcport->reqq_wait, bfa_fcport_qresume, fcport); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 922 | } |
| 923 | |
| 924 | static void |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 925 | bfa_fcport_detach(struct bfa_s *bfa) |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 926 | { |
| 927 | } |
| 928 | |
| 929 | /** |
| 930 | * Called when IOC is ready. |
| 931 | */ |
| 932 | static void |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 933 | bfa_fcport_start(struct bfa_s *bfa) |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 934 | { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 935 | bfa_sm_send_event(BFA_FCPORT_MOD(bfa), BFA_FCPORT_SM_START); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 936 | } |
| 937 | |
| 938 | /** |
| 939 | * Called before IOC is stopped. |
| 940 | */ |
| 941 | static void |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 942 | bfa_fcport_stop(struct bfa_s *bfa) |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 943 | { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 944 | bfa_sm_send_event(BFA_FCPORT_MOD(bfa), BFA_FCPORT_SM_STOP); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 945 | } |
| 946 | |
| 947 | /** |
| 948 | * Called when IOC failure is detected. |
| 949 | */ |
| 950 | static void |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 951 | bfa_fcport_iocdisable(struct bfa_s *bfa) |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 952 | { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 953 | bfa_sm_send_event(BFA_FCPORT_MOD(bfa), BFA_FCPORT_SM_HWFAIL); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 954 | } |
| 955 | |
| 956 | static void |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 957 | bfa_fcport_update_linkinfo(struct bfa_fcport_s *fcport) |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 958 | { |
Krishna Gudipati | ca8b432 | 2010-03-05 19:38:07 -0800 | [diff] [blame] | 959 | struct bfi_fcport_event_s *pevent = fcport->event_arg.i2hmsg.event; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 960 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 961 | fcport->speed = pevent->link_state.speed; |
| 962 | fcport->topology = pevent->link_state.topology; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 963 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 964 | if (fcport->topology == BFA_PPORT_TOPOLOGY_LOOP) |
Jing Huang | db954c0 | 2010-07-08 19:58:01 -0700 | [diff] [blame] | 965 | fcport->myalpa = 0; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 966 | |
| 967 | /* |
| 968 | * QoS Details |
| 969 | */ |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 970 | bfa_os_assign(fcport->qos_attr, pevent->link_state.qos_attr); |
Jing Huang | db954c0 | 2010-07-08 19:58:01 -0700 | [diff] [blame] | 971 | bfa_os_assign(fcport->qos_vc_attr, |
| 972 | pevent->link_state.vc_fcf.qos_vc_attr); |
| 973 | |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 974 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 975 | bfa_trc(fcport->bfa, fcport->speed); |
| 976 | bfa_trc(fcport->bfa, fcport->topology); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 977 | } |
| 978 | |
| 979 | static void |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 980 | bfa_fcport_reset_linkinfo(struct bfa_fcport_s *fcport) |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 981 | { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 982 | fcport->speed = BFA_PPORT_SPEED_UNKNOWN; |
| 983 | fcport->topology = BFA_PPORT_TOPOLOGY_NONE; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 984 | } |
| 985 | |
| 986 | /** |
| 987 | * Send port enable message to firmware. |
| 988 | */ |
| 989 | static bfa_boolean_t |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 990 | bfa_fcport_send_enable(struct bfa_fcport_s *fcport) |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 991 | { |
Krishna Gudipati | ca8b432 | 2010-03-05 19:38:07 -0800 | [diff] [blame] | 992 | struct bfi_fcport_enable_req_s *m; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 993 | |
| 994 | /** |
| 995 | * Increment message tag before queue check, so that responses to old |
| 996 | * requests are discarded. |
| 997 | */ |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 998 | fcport->msgtag++; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 999 | |
| 1000 | /** |
| 1001 | * check for room in queue to send request now |
| 1002 | */ |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1003 | m = bfa_reqq_next(fcport->bfa, BFA_REQQ_PORT); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1004 | if (!m) { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1005 | bfa_reqq_wait(fcport->bfa, BFA_REQQ_PORT, |
| 1006 | &fcport->reqq_wait); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1007 | return BFA_FALSE; |
| 1008 | } |
| 1009 | |
Krishna Gudipati | ca8b432 | 2010-03-05 19:38:07 -0800 | [diff] [blame] | 1010 | bfi_h2i_set(m->mh, BFI_MC_FCPORT, BFI_FCPORT_H2I_ENABLE_REQ, |
| 1011 | bfa_lpuid(fcport->bfa)); |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1012 | m->nwwn = fcport->nwwn; |
| 1013 | m->pwwn = fcport->pwwn; |
| 1014 | m->port_cfg = fcport->cfg; |
| 1015 | m->msgtag = fcport->msgtag; |
| 1016 | m->port_cfg.maxfrsize = bfa_os_htons(fcport->cfg.maxfrsize); |
| 1017 | bfa_dma_be_addr_set(m->stats_dma_addr, fcport->stats_pa); |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1018 | bfa_trc(fcport->bfa, m->stats_dma_addr.a32.addr_lo); |
| 1019 | bfa_trc(fcport->bfa, m->stats_dma_addr.a32.addr_hi); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1020 | |
| 1021 | /** |
| 1022 | * queue I/O message to firmware |
| 1023 | */ |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1024 | bfa_reqq_produce(fcport->bfa, BFA_REQQ_PORT); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1025 | return BFA_TRUE; |
| 1026 | } |
| 1027 | |
| 1028 | /** |
| 1029 | * Send port disable message to firmware. |
| 1030 | */ |
| 1031 | static bfa_boolean_t |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1032 | bfa_fcport_send_disable(struct bfa_fcport_s *fcport) |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1033 | { |
Krishna Gudipati | ca8b432 | 2010-03-05 19:38:07 -0800 | [diff] [blame] | 1034 | struct bfi_fcport_req_s *m; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1035 | |
| 1036 | /** |
| 1037 | * Increment message tag before queue check, so that responses to old |
| 1038 | * requests are discarded. |
| 1039 | */ |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1040 | fcport->msgtag++; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1041 | |
| 1042 | /** |
| 1043 | * check for room in queue to send request now |
| 1044 | */ |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1045 | m = bfa_reqq_next(fcport->bfa, BFA_REQQ_PORT); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1046 | if (!m) { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1047 | bfa_reqq_wait(fcport->bfa, BFA_REQQ_PORT, |
| 1048 | &fcport->reqq_wait); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1049 | return BFA_FALSE; |
| 1050 | } |
| 1051 | |
Krishna Gudipati | ca8b432 | 2010-03-05 19:38:07 -0800 | [diff] [blame] | 1052 | bfi_h2i_set(m->mh, BFI_MC_FCPORT, BFI_FCPORT_H2I_DISABLE_REQ, |
| 1053 | bfa_lpuid(fcport->bfa)); |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1054 | m->msgtag = fcport->msgtag; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1055 | |
| 1056 | /** |
| 1057 | * queue I/O message to firmware |
| 1058 | */ |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1059 | bfa_reqq_produce(fcport->bfa, BFA_REQQ_PORT); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1060 | |
| 1061 | return BFA_TRUE; |
| 1062 | } |
| 1063 | |
| 1064 | static void |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1065 | bfa_fcport_set_wwns(struct bfa_fcport_s *fcport) |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1066 | { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1067 | fcport->pwwn = bfa_ioc_get_pwwn(&fcport->bfa->ioc); |
| 1068 | fcport->nwwn = bfa_ioc_get_nwwn(&fcport->bfa->ioc); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1069 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1070 | bfa_trc(fcport->bfa, fcport->pwwn); |
| 1071 | bfa_trc(fcport->bfa, fcport->nwwn); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1072 | } |
| 1073 | |
| 1074 | static void |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1075 | bfa_fcport_send_txcredit(void *port_cbarg) |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1076 | { |
| 1077 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1078 | struct bfa_fcport_s *fcport = port_cbarg; |
Krishna Gudipati | ca8b432 | 2010-03-05 19:38:07 -0800 | [diff] [blame] | 1079 | struct bfi_fcport_set_svc_params_req_s *m; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1080 | |
| 1081 | /** |
| 1082 | * check for room in queue to send request now |
| 1083 | */ |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1084 | m = bfa_reqq_next(fcport->bfa, BFA_REQQ_PORT); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1085 | if (!m) { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1086 | bfa_trc(fcport->bfa, fcport->cfg.tx_bbcredit); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1087 | return; |
| 1088 | } |
| 1089 | |
Krishna Gudipati | ca8b432 | 2010-03-05 19:38:07 -0800 | [diff] [blame] | 1090 | bfi_h2i_set(m->mh, BFI_MC_FCPORT, BFI_FCPORT_H2I_SET_SVC_PARAMS_REQ, |
| 1091 | bfa_lpuid(fcport->bfa)); |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1092 | m->tx_bbcredit = bfa_os_htons((u16) fcport->cfg.tx_bbcredit); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1093 | |
| 1094 | /** |
| 1095 | * queue I/O message to firmware |
| 1096 | */ |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1097 | bfa_reqq_produce(fcport->bfa, BFA_REQQ_PORT); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1098 | } |
| 1099 | |
Krishna Gudipati | ca8b432 | 2010-03-05 19:38:07 -0800 | [diff] [blame] | 1100 | static void |
| 1101 | bfa_fcport_qos_stats_swap(struct bfa_qos_stats_s *d, |
| 1102 | struct bfa_qos_stats_s *s) |
| 1103 | { |
| 1104 | u32 *dip = (u32 *) d; |
| 1105 | u32 *sip = (u32 *) s; |
| 1106 | int i; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1107 | |
Krishna Gudipati | ca8b432 | 2010-03-05 19:38:07 -0800 | [diff] [blame] | 1108 | /* Now swap the 32 bit fields */ |
| 1109 | for (i = 0; i < (sizeof(struct bfa_qos_stats_s)/sizeof(u32)); ++i) |
| 1110 | dip[i] = bfa_os_ntohl(sip[i]); |
| 1111 | } |
| 1112 | |
| 1113 | static void |
| 1114 | bfa_fcport_fcoe_stats_swap(struct bfa_fcoe_stats_s *d, |
| 1115 | struct bfa_fcoe_stats_s *s) |
| 1116 | { |
| 1117 | u32 *dip = (u32 *) d; |
| 1118 | u32 *sip = (u32 *) s; |
| 1119 | int i; |
| 1120 | |
| 1121 | for (i = 0; i < ((sizeof(struct bfa_fcoe_stats_s))/sizeof(u32)); |
| 1122 | i = i + 2) { |
| 1123 | #ifdef __BIGENDIAN |
| 1124 | dip[i] = bfa_os_ntohl(sip[i]); |
| 1125 | dip[i + 1] = bfa_os_ntohl(sip[i + 1]); |
| 1126 | #else |
| 1127 | dip[i] = bfa_os_ntohl(sip[i + 1]); |
| 1128 | dip[i + 1] = bfa_os_ntohl(sip[i]); |
| 1129 | #endif |
| 1130 | } |
| 1131 | } |
| 1132 | |
| 1133 | static void |
| 1134 | __bfa_cb_fcport_stats_get(void *cbarg, bfa_boolean_t complete) |
| 1135 | { |
| 1136 | struct bfa_fcport_s *fcport = cbarg; |
| 1137 | |
| 1138 | if (complete) { |
| 1139 | if (fcport->stats_status == BFA_STATUS_OK) { |
Jing Huang | b85d045 | 2010-07-08 19:48:49 -0700 | [diff] [blame] | 1140 | struct bfa_timeval_s tv; |
Krishna Gudipati | ca8b432 | 2010-03-05 19:38:07 -0800 | [diff] [blame] | 1141 | |
| 1142 | /* Swap FC QoS or FCoE stats */ |
Jing Huang | b85d045 | 2010-07-08 19:48:49 -0700 | [diff] [blame] | 1143 | if (bfa_ioc_get_fcmode(&fcport->bfa->ioc)) { |
Krishna Gudipati | ca8b432 | 2010-03-05 19:38:07 -0800 | [diff] [blame] | 1144 | bfa_fcport_qos_stats_swap( |
| 1145 | &fcport->stats_ret->fcqos, |
| 1146 | &fcport->stats->fcqos); |
Jing Huang | b85d045 | 2010-07-08 19:48:49 -0700 | [diff] [blame] | 1147 | } else { |
Krishna Gudipati | ca8b432 | 2010-03-05 19:38:07 -0800 | [diff] [blame] | 1148 | bfa_fcport_fcoe_stats_swap( |
| 1149 | &fcport->stats_ret->fcoe, |
| 1150 | &fcport->stats->fcoe); |
Jing Huang | b85d045 | 2010-07-08 19:48:49 -0700 | [diff] [blame] | 1151 | |
| 1152 | bfa_os_gettimeofday(&tv); |
| 1153 | fcport->stats_ret->fcoe.secs_reset = |
| 1154 | tv.tv_sec - fcport->stats_reset_time; |
| 1155 | } |
Krishna Gudipati | ca8b432 | 2010-03-05 19:38:07 -0800 | [diff] [blame] | 1156 | } |
| 1157 | fcport->stats_cbfn(fcport->stats_cbarg, fcport->stats_status); |
| 1158 | } else { |
| 1159 | fcport->stats_busy = BFA_FALSE; |
| 1160 | fcport->stats_status = BFA_STATUS_OK; |
| 1161 | } |
| 1162 | } |
| 1163 | |
| 1164 | static void |
| 1165 | bfa_fcport_stats_get_timeout(void *cbarg) |
| 1166 | { |
| 1167 | struct bfa_fcport_s *fcport = (struct bfa_fcport_s *) cbarg; |
| 1168 | |
| 1169 | bfa_trc(fcport->bfa, fcport->stats_qfull); |
| 1170 | |
| 1171 | if (fcport->stats_qfull) { |
| 1172 | bfa_reqq_wcancel(&fcport->stats_reqq_wait); |
| 1173 | fcport->stats_qfull = BFA_FALSE; |
| 1174 | } |
| 1175 | |
| 1176 | fcport->stats_status = BFA_STATUS_ETIMER; |
| 1177 | bfa_cb_queue(fcport->bfa, &fcport->hcb_qe, __bfa_cb_fcport_stats_get, |
| 1178 | fcport); |
| 1179 | } |
| 1180 | |
| 1181 | static void |
| 1182 | bfa_fcport_send_stats_get(void *cbarg) |
| 1183 | { |
| 1184 | struct bfa_fcport_s *fcport = (struct bfa_fcport_s *) cbarg; |
| 1185 | struct bfi_fcport_req_s *msg; |
| 1186 | |
| 1187 | msg = bfa_reqq_next(fcport->bfa, BFA_REQQ_PORT); |
| 1188 | |
| 1189 | if (!msg) { |
| 1190 | fcport->stats_qfull = BFA_TRUE; |
| 1191 | bfa_reqq_winit(&fcport->stats_reqq_wait, |
| 1192 | bfa_fcport_send_stats_get, fcport); |
| 1193 | bfa_reqq_wait(fcport->bfa, BFA_REQQ_PORT, |
| 1194 | &fcport->stats_reqq_wait); |
| 1195 | return; |
| 1196 | } |
| 1197 | fcport->stats_qfull = BFA_FALSE; |
| 1198 | |
| 1199 | bfa_os_memset(msg, 0, sizeof(struct bfi_fcport_req_s)); |
| 1200 | bfi_h2i_set(msg->mh, BFI_MC_FCPORT, BFI_FCPORT_H2I_STATS_GET_REQ, |
| 1201 | bfa_lpuid(fcport->bfa)); |
| 1202 | bfa_reqq_produce(fcport->bfa, BFA_REQQ_PORT); |
| 1203 | } |
| 1204 | |
| 1205 | static void |
| 1206 | __bfa_cb_fcport_stats_clr(void *cbarg, bfa_boolean_t complete) |
| 1207 | { |
| 1208 | struct bfa_fcport_s *fcport = cbarg; |
| 1209 | |
| 1210 | if (complete) { |
Jing Huang | b85d045 | 2010-07-08 19:48:49 -0700 | [diff] [blame] | 1211 | struct bfa_timeval_s tv; |
| 1212 | |
| 1213 | /** |
| 1214 | * re-initialize time stamp for stats reset |
| 1215 | */ |
| 1216 | bfa_os_gettimeofday(&tv); |
| 1217 | fcport->stats_reset_time = tv.tv_sec; |
| 1218 | |
Krishna Gudipati | ca8b432 | 2010-03-05 19:38:07 -0800 | [diff] [blame] | 1219 | fcport->stats_cbfn(fcport->stats_cbarg, fcport->stats_status); |
| 1220 | } else { |
| 1221 | fcport->stats_busy = BFA_FALSE; |
| 1222 | fcport->stats_status = BFA_STATUS_OK; |
| 1223 | } |
| 1224 | } |
| 1225 | |
| 1226 | static void |
| 1227 | bfa_fcport_stats_clr_timeout(void *cbarg) |
| 1228 | { |
| 1229 | struct bfa_fcport_s *fcport = (struct bfa_fcport_s *) cbarg; |
| 1230 | |
| 1231 | bfa_trc(fcport->bfa, fcport->stats_qfull); |
| 1232 | |
| 1233 | if (fcport->stats_qfull) { |
| 1234 | bfa_reqq_wcancel(&fcport->stats_reqq_wait); |
| 1235 | fcport->stats_qfull = BFA_FALSE; |
| 1236 | } |
| 1237 | |
| 1238 | fcport->stats_status = BFA_STATUS_ETIMER; |
| 1239 | bfa_cb_queue(fcport->bfa, &fcport->hcb_qe, |
| 1240 | __bfa_cb_fcport_stats_clr, fcport); |
| 1241 | } |
| 1242 | |
| 1243 | static void |
| 1244 | bfa_fcport_send_stats_clear(void *cbarg) |
| 1245 | { |
| 1246 | struct bfa_fcport_s *fcport = (struct bfa_fcport_s *) cbarg; |
| 1247 | struct bfi_fcport_req_s *msg; |
| 1248 | |
| 1249 | msg = bfa_reqq_next(fcport->bfa, BFA_REQQ_PORT); |
| 1250 | |
| 1251 | if (!msg) { |
| 1252 | fcport->stats_qfull = BFA_TRUE; |
| 1253 | bfa_reqq_winit(&fcport->stats_reqq_wait, |
| 1254 | bfa_fcport_send_stats_clear, fcport); |
| 1255 | bfa_reqq_wait(fcport->bfa, BFA_REQQ_PORT, |
| 1256 | &fcport->stats_reqq_wait); |
| 1257 | return; |
| 1258 | } |
| 1259 | fcport->stats_qfull = BFA_FALSE; |
| 1260 | |
| 1261 | bfa_os_memset(msg, 0, sizeof(struct bfi_fcport_req_s)); |
| 1262 | bfi_h2i_set(msg->mh, BFI_MC_FCPORT, BFI_FCPORT_H2I_STATS_CLEAR_REQ, |
| 1263 | bfa_lpuid(fcport->bfa)); |
| 1264 | bfa_reqq_produce(fcport->bfa, BFA_REQQ_PORT); |
| 1265 | } |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1266 | |
| 1267 | /** |
| 1268 | * bfa_pport_public |
| 1269 | */ |
| 1270 | |
| 1271 | /** |
Jing Huang | ed96932 | 2010-07-08 19:45:56 -0700 | [diff] [blame] | 1272 | * Called to initialize port attributes |
| 1273 | */ |
| 1274 | void |
| 1275 | bfa_fcport_init(struct bfa_s *bfa) |
| 1276 | { |
| 1277 | struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); |
| 1278 | |
| 1279 | /** |
| 1280 | * Initialize port attributes from IOC hardware data. |
| 1281 | */ |
| 1282 | bfa_fcport_set_wwns(fcport); |
| 1283 | if (fcport->cfg.maxfrsize == 0) |
| 1284 | fcport->cfg.maxfrsize = bfa_ioc_maxfrsize(&bfa->ioc); |
| 1285 | fcport->cfg.rx_bbcredit = bfa_ioc_rx_bbcredit(&bfa->ioc); |
| 1286 | fcport->speed_sup = bfa_ioc_speed_sup(&bfa->ioc); |
| 1287 | |
| 1288 | bfa_assert(fcport->cfg.maxfrsize); |
| 1289 | bfa_assert(fcport->cfg.rx_bbcredit); |
| 1290 | bfa_assert(fcport->speed_sup); |
| 1291 | } |
| 1292 | |
| 1293 | |
| 1294 | /** |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1295 | * Firmware message handler. |
| 1296 | */ |
| 1297 | void |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1298 | bfa_fcport_isr(struct bfa_s *bfa, struct bfi_msg_s *msg) |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1299 | { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1300 | struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); |
Krishna Gudipati | ca8b432 | 2010-03-05 19:38:07 -0800 | [diff] [blame] | 1301 | union bfi_fcport_i2h_msg_u i2hmsg; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1302 | |
| 1303 | i2hmsg.msg = msg; |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1304 | fcport->event_arg.i2hmsg = i2hmsg; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1305 | |
| 1306 | switch (msg->mhdr.msg_id) { |
Krishna Gudipati | ca8b432 | 2010-03-05 19:38:07 -0800 | [diff] [blame] | 1307 | case BFI_FCPORT_I2H_ENABLE_RSP: |
| 1308 | if (fcport->msgtag == i2hmsg.penable_rsp->msgtag) |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1309 | bfa_sm_send_event(fcport, BFA_FCPORT_SM_FWRSP); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1310 | break; |
| 1311 | |
Krishna Gudipati | ca8b432 | 2010-03-05 19:38:07 -0800 | [diff] [blame] | 1312 | case BFI_FCPORT_I2H_DISABLE_RSP: |
Roel Kluin | 6de61f9 | 2010-08-10 18:01:23 -0700 | [diff] [blame] | 1313 | if (fcport->msgtag == i2hmsg.pdisable_rsp->msgtag) |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1314 | bfa_sm_send_event(fcport, BFA_FCPORT_SM_FWRSP); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1315 | break; |
| 1316 | |
Krishna Gudipati | ca8b432 | 2010-03-05 19:38:07 -0800 | [diff] [blame] | 1317 | case BFI_FCPORT_I2H_EVENT: |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1318 | switch (i2hmsg.event->link_state.linkstate) { |
| 1319 | case BFA_PPORT_LINKUP: |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1320 | bfa_sm_send_event(fcport, BFA_FCPORT_SM_LINKUP); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1321 | break; |
| 1322 | case BFA_PPORT_LINKDOWN: |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1323 | bfa_sm_send_event(fcport, BFA_FCPORT_SM_LINKDOWN); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1324 | break; |
| 1325 | case BFA_PPORT_TRUNK_LINKDOWN: |
| 1326 | /** todo: event notification */ |
| 1327 | break; |
| 1328 | } |
| 1329 | break; |
| 1330 | |
Krishna Gudipati | ca8b432 | 2010-03-05 19:38:07 -0800 | [diff] [blame] | 1331 | case BFI_FCPORT_I2H_STATS_GET_RSP: |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1332 | /* |
| 1333 | * check for timer pop before processing the rsp |
| 1334 | */ |
| 1335 | if (fcport->stats_busy == BFA_FALSE || |
Krishna Gudipati | ca8b432 | 2010-03-05 19:38:07 -0800 | [diff] [blame] | 1336 | fcport->stats_status == BFA_STATUS_ETIMER) |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1337 | break; |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1338 | |
| 1339 | bfa_timer_stop(&fcport->timer); |
Krishna Gudipati | ca8b432 | 2010-03-05 19:38:07 -0800 | [diff] [blame] | 1340 | fcport->stats_status = i2hmsg.pstatsget_rsp->status; |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1341 | bfa_cb_queue(fcport->bfa, &fcport->hcb_qe, |
Krishna Gudipati | ca8b432 | 2010-03-05 19:38:07 -0800 | [diff] [blame] | 1342 | __bfa_cb_fcport_stats_get, fcport); |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1343 | break; |
| 1344 | |
Krishna Gudipati | ca8b432 | 2010-03-05 19:38:07 -0800 | [diff] [blame] | 1345 | case BFI_FCPORT_I2H_STATS_CLEAR_RSP: |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1346 | /* |
| 1347 | * check for timer pop before processing the rsp |
| 1348 | */ |
| 1349 | if (fcport->stats_busy == BFA_FALSE || |
Krishna Gudipati | ca8b432 | 2010-03-05 19:38:07 -0800 | [diff] [blame] | 1350 | fcport->stats_status == BFA_STATUS_ETIMER) |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1351 | break; |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1352 | |
| 1353 | bfa_timer_stop(&fcport->timer); |
| 1354 | fcport->stats_status = BFA_STATUS_OK; |
| 1355 | bfa_cb_queue(fcport->bfa, &fcport->hcb_qe, |
| 1356 | __bfa_cb_fcport_stats_clr, fcport); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1357 | break; |
| 1358 | |
| 1359 | default: |
| 1360 | bfa_assert(0); |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1361 | break; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1362 | } |
| 1363 | } |
| 1364 | |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1365 | /** |
| 1366 | * bfa_pport_api |
| 1367 | */ |
| 1368 | |
| 1369 | /** |
| 1370 | * Registered callback for port events. |
| 1371 | */ |
| 1372 | void |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1373 | bfa_fcport_event_register(struct bfa_s *bfa, |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1374 | void (*cbfn) (void *cbarg, bfa_pport_event_t event), |
| 1375 | void *cbarg) |
| 1376 | { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1377 | struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1378 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1379 | fcport->event_cbfn = cbfn; |
| 1380 | fcport->event_cbarg = cbarg; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1381 | } |
| 1382 | |
| 1383 | bfa_status_t |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1384 | bfa_fcport_enable(struct bfa_s *bfa) |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1385 | { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1386 | struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); |
Jing Huang | 3e98cc0 | 2010-07-08 19:52:46 -0700 | [diff] [blame] | 1387 | struct bfa_iocfc_s *iocfc = &bfa->iocfc; |
| 1388 | struct bfi_iocfc_cfgrsp_s *cfgrsp = iocfc->cfgrsp; |
| 1389 | |
| 1390 | /* if port is PBC disabled, return error */ |
| 1391 | if (cfgrsp->pbc_cfg.port_enabled == BFI_PBC_PORT_DISABLED) { |
| 1392 | bfa_trc(bfa, fcport->pwwn); |
| 1393 | return BFA_STATUS_PBC; |
| 1394 | } |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1395 | |
Jing Huang | ba83458 | 2010-07-08 20:00:24 -0700 | [diff] [blame] | 1396 | if (bfa_ioc_is_disabled(&bfa->ioc)) |
| 1397 | return BFA_STATUS_IOC_DISABLED; |
| 1398 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1399 | if (fcport->diag_busy) |
Jing Huang | f8ceafd | 2009-09-25 12:29:54 -0700 | [diff] [blame] | 1400 | return BFA_STATUS_DIAG_BUSY; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1401 | else if (bfa_sm_cmp_state |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1402 | (BFA_FCPORT_MOD(bfa), bfa_fcport_sm_disabling_qwait)) |
Jing Huang | f8ceafd | 2009-09-25 12:29:54 -0700 | [diff] [blame] | 1403 | return BFA_STATUS_DEVBUSY; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1404 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1405 | bfa_sm_send_event(BFA_FCPORT_MOD(bfa), BFA_FCPORT_SM_ENABLE); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1406 | return BFA_STATUS_OK; |
| 1407 | } |
| 1408 | |
| 1409 | bfa_status_t |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1410 | bfa_fcport_disable(struct bfa_s *bfa) |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1411 | { |
Jing Huang | 3e98cc0 | 2010-07-08 19:52:46 -0700 | [diff] [blame] | 1412 | struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); |
| 1413 | struct bfa_iocfc_s *iocfc = &bfa->iocfc; |
| 1414 | struct bfi_iocfc_cfgrsp_s *cfgrsp = iocfc->cfgrsp; |
| 1415 | |
| 1416 | /* if port is PBC disabled, return error */ |
| 1417 | if (cfgrsp->pbc_cfg.port_enabled == BFI_PBC_PORT_DISABLED) { |
| 1418 | bfa_trc(bfa, fcport->pwwn); |
| 1419 | return BFA_STATUS_PBC; |
| 1420 | } |
| 1421 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1422 | bfa_sm_send_event(BFA_FCPORT_MOD(bfa), BFA_FCPORT_SM_DISABLE); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1423 | return BFA_STATUS_OK; |
| 1424 | } |
| 1425 | |
| 1426 | /** |
| 1427 | * Configure port speed. |
| 1428 | */ |
| 1429 | bfa_status_t |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1430 | bfa_fcport_cfg_speed(struct bfa_s *bfa, enum bfa_pport_speed speed) |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1431 | { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1432 | struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1433 | |
| 1434 | bfa_trc(bfa, speed); |
| 1435 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1436 | if ((speed != BFA_PPORT_SPEED_AUTO) && (speed > fcport->speed_sup)) { |
| 1437 | bfa_trc(bfa, fcport->speed_sup); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1438 | return BFA_STATUS_UNSUPP_SPEED; |
| 1439 | } |
| 1440 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1441 | fcport->cfg.speed = speed; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1442 | |
Jing Huang | f8ceafd | 2009-09-25 12:29:54 -0700 | [diff] [blame] | 1443 | return BFA_STATUS_OK; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1444 | } |
| 1445 | |
| 1446 | /** |
| 1447 | * Get current speed. |
| 1448 | */ |
| 1449 | enum bfa_pport_speed |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1450 | bfa_fcport_get_speed(struct bfa_s *bfa) |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1451 | { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1452 | struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1453 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1454 | return fcport->speed; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1455 | } |
| 1456 | |
| 1457 | /** |
| 1458 | * Configure port topology. |
| 1459 | */ |
| 1460 | bfa_status_t |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1461 | bfa_fcport_cfg_topology(struct bfa_s *bfa, enum bfa_pport_topology topology) |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1462 | { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1463 | struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1464 | |
| 1465 | bfa_trc(bfa, topology); |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1466 | bfa_trc(bfa, fcport->cfg.topology); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1467 | |
| 1468 | switch (topology) { |
| 1469 | case BFA_PPORT_TOPOLOGY_P2P: |
| 1470 | case BFA_PPORT_TOPOLOGY_LOOP: |
| 1471 | case BFA_PPORT_TOPOLOGY_AUTO: |
| 1472 | break; |
| 1473 | |
| 1474 | default: |
| 1475 | return BFA_STATUS_EINVAL; |
| 1476 | } |
| 1477 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1478 | fcport->cfg.topology = topology; |
Jing Huang | f8ceafd | 2009-09-25 12:29:54 -0700 | [diff] [blame] | 1479 | return BFA_STATUS_OK; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1480 | } |
| 1481 | |
| 1482 | /** |
| 1483 | * Get current topology. |
| 1484 | */ |
| 1485 | enum bfa_pport_topology |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1486 | bfa_fcport_get_topology(struct bfa_s *bfa) |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1487 | { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1488 | struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1489 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1490 | return fcport->topology; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1491 | } |
| 1492 | |
| 1493 | bfa_status_t |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1494 | bfa_fcport_cfg_hardalpa(struct bfa_s *bfa, u8 alpa) |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1495 | { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1496 | struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1497 | |
| 1498 | bfa_trc(bfa, alpa); |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1499 | bfa_trc(bfa, fcport->cfg.cfg_hardalpa); |
| 1500 | bfa_trc(bfa, fcport->cfg.hardalpa); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1501 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1502 | fcport->cfg.cfg_hardalpa = BFA_TRUE; |
| 1503 | fcport->cfg.hardalpa = alpa; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1504 | |
Jing Huang | f8ceafd | 2009-09-25 12:29:54 -0700 | [diff] [blame] | 1505 | return BFA_STATUS_OK; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1506 | } |
| 1507 | |
| 1508 | bfa_status_t |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1509 | bfa_fcport_clr_hardalpa(struct bfa_s *bfa) |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1510 | { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1511 | struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1512 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1513 | bfa_trc(bfa, fcport->cfg.cfg_hardalpa); |
| 1514 | bfa_trc(bfa, fcport->cfg.hardalpa); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1515 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1516 | fcport->cfg.cfg_hardalpa = BFA_FALSE; |
Jing Huang | f8ceafd | 2009-09-25 12:29:54 -0700 | [diff] [blame] | 1517 | return BFA_STATUS_OK; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1518 | } |
| 1519 | |
| 1520 | bfa_boolean_t |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1521 | bfa_fcport_get_hardalpa(struct bfa_s *bfa, u8 *alpa) |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1522 | { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1523 | struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1524 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1525 | *alpa = fcport->cfg.hardalpa; |
| 1526 | return fcport->cfg.cfg_hardalpa; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1527 | } |
| 1528 | |
| 1529 | u8 |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1530 | bfa_fcport_get_myalpa(struct bfa_s *bfa) |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1531 | { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1532 | struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1533 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1534 | return fcport->myalpa; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1535 | } |
| 1536 | |
| 1537 | bfa_status_t |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1538 | bfa_fcport_cfg_maxfrsize(struct bfa_s *bfa, u16 maxfrsize) |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1539 | { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1540 | struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1541 | |
| 1542 | bfa_trc(bfa, maxfrsize); |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1543 | bfa_trc(bfa, fcport->cfg.maxfrsize); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1544 | |
| 1545 | /* |
| 1546 | * with in range |
| 1547 | */ |
| 1548 | if ((maxfrsize > FC_MAX_PDUSZ) || (maxfrsize < FC_MIN_PDUSZ)) |
Jing Huang | f8ceafd | 2009-09-25 12:29:54 -0700 | [diff] [blame] | 1549 | return BFA_STATUS_INVLD_DFSZ; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1550 | |
| 1551 | /* |
| 1552 | * power of 2, if not the max frame size of 2112 |
| 1553 | */ |
| 1554 | if ((maxfrsize != FC_MAX_PDUSZ) && (maxfrsize & (maxfrsize - 1))) |
Jing Huang | f8ceafd | 2009-09-25 12:29:54 -0700 | [diff] [blame] | 1555 | return BFA_STATUS_INVLD_DFSZ; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1556 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1557 | fcport->cfg.maxfrsize = maxfrsize; |
Jing Huang | f8ceafd | 2009-09-25 12:29:54 -0700 | [diff] [blame] | 1558 | return BFA_STATUS_OK; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1559 | } |
| 1560 | |
| 1561 | u16 |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1562 | bfa_fcport_get_maxfrsize(struct bfa_s *bfa) |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1563 | { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1564 | struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1565 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1566 | return fcport->cfg.maxfrsize; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1567 | } |
| 1568 | |
| 1569 | u32 |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1570 | bfa_fcport_mypid(struct bfa_s *bfa) |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1571 | { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1572 | struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1573 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1574 | return fcport->mypid; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1575 | } |
| 1576 | |
| 1577 | u8 |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1578 | bfa_fcport_get_rx_bbcredit(struct bfa_s *bfa) |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1579 | { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1580 | struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1581 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1582 | return fcport->cfg.rx_bbcredit; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1583 | } |
| 1584 | |
| 1585 | void |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1586 | bfa_fcport_set_tx_bbcredit(struct bfa_s *bfa, u16 tx_bbcredit) |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1587 | { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1588 | struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1589 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1590 | fcport->cfg.tx_bbcredit = (u8) tx_bbcredit; |
| 1591 | bfa_fcport_send_txcredit(fcport); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1592 | } |
| 1593 | |
| 1594 | /** |
| 1595 | * Get port attributes. |
| 1596 | */ |
| 1597 | |
| 1598 | wwn_t |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1599 | bfa_fcport_get_wwn(struct bfa_s *bfa, bfa_boolean_t node) |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1600 | { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1601 | struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1602 | if (node) |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1603 | return fcport->nwwn; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1604 | else |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1605 | return fcport->pwwn; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1606 | } |
| 1607 | |
| 1608 | void |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1609 | bfa_fcport_get_attr(struct bfa_s *bfa, struct bfa_pport_attr_s *attr) |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1610 | { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1611 | struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); |
Jing Huang | 3e98cc0 | 2010-07-08 19:52:46 -0700 | [diff] [blame] | 1612 | struct bfa_iocfc_s *iocfc = &bfa->iocfc; |
| 1613 | struct bfi_iocfc_cfgrsp_s *cfgrsp = iocfc->cfgrsp; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1614 | |
| 1615 | bfa_os_memset(attr, 0, sizeof(struct bfa_pport_attr_s)); |
| 1616 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1617 | attr->nwwn = fcport->nwwn; |
| 1618 | attr->pwwn = fcport->pwwn; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1619 | |
Jing Huang | 15b64a8 | 2010-07-08 19:48:12 -0700 | [diff] [blame] | 1620 | attr->factorypwwn = bfa_ioc_get_mfg_pwwn(&bfa->ioc); |
| 1621 | attr->factorynwwn = bfa_ioc_get_mfg_nwwn(&bfa->ioc); |
| 1622 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1623 | bfa_os_memcpy(&attr->pport_cfg, &fcport->cfg, |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1624 | sizeof(struct bfa_pport_cfg_s)); |
| 1625 | /* |
| 1626 | * speed attributes |
| 1627 | */ |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1628 | attr->pport_cfg.speed = fcport->cfg.speed; |
| 1629 | attr->speed_supported = fcport->speed_sup; |
| 1630 | attr->speed = fcport->speed; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1631 | attr->cos_supported = FC_CLASS_3; |
| 1632 | |
| 1633 | /* |
| 1634 | * topology attributes |
| 1635 | */ |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1636 | attr->pport_cfg.topology = fcport->cfg.topology; |
| 1637 | attr->topology = fcport->topology; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1638 | |
| 1639 | /* |
| 1640 | * beacon attributes |
| 1641 | */ |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1642 | attr->beacon = fcport->beacon; |
| 1643 | attr->link_e2e_beacon = fcport->link_e2e_beacon; |
| 1644 | attr->plog_enabled = bfa_plog_get_setting(fcport->bfa->plog); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1645 | |
| 1646 | attr->pport_cfg.path_tov = bfa_fcpim_path_tov_get(bfa); |
| 1647 | attr->pport_cfg.q_depth = bfa_fcpim_qdepth_get(bfa); |
Jing Huang | 3e98cc0 | 2010-07-08 19:52:46 -0700 | [diff] [blame] | 1648 | |
| 1649 | /* PBC Disabled State */ |
| 1650 | if (cfgrsp->pbc_cfg.port_enabled == BFI_PBC_PORT_DISABLED) |
| 1651 | attr->port_state = BFA_PPORT_ST_PREBOOT_DISABLED; |
| 1652 | else { |
| 1653 | attr->port_state = bfa_sm_to_state( |
| 1654 | hal_pport_sm_table, fcport->sm); |
| 1655 | if (bfa_ioc_is_disabled(&fcport->bfa->ioc)) |
| 1656 | attr->port_state = BFA_PPORT_ST_IOCDIS; |
| 1657 | else if (bfa_ioc_fw_mismatch(&fcport->bfa->ioc)) |
| 1658 | attr->port_state = BFA_PPORT_ST_FWMISMATCH; |
| 1659 | } |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1660 | } |
| 1661 | |
Krishna Gudipati | ca8b432 | 2010-03-05 19:38:07 -0800 | [diff] [blame] | 1662 | #define BFA_FCPORT_STATS_TOV 1000 |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1663 | |
| 1664 | /** |
Krishna Gudipati | ca8b432 | 2010-03-05 19:38:07 -0800 | [diff] [blame] | 1665 | * Fetch port attributes (FCQoS or FCoE). |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1666 | */ |
| 1667 | bfa_status_t |
Krishna Gudipati | ca8b432 | 2010-03-05 19:38:07 -0800 | [diff] [blame] | 1668 | bfa_fcport_get_stats(struct bfa_s *bfa, union bfa_fcport_stats_u *stats, |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1669 | bfa_cb_pport_t cbfn, void *cbarg) |
| 1670 | { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1671 | struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1672 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1673 | if (fcport->stats_busy) { |
| 1674 | bfa_trc(bfa, fcport->stats_busy); |
Jing Huang | f8ceafd | 2009-09-25 12:29:54 -0700 | [diff] [blame] | 1675 | return BFA_STATUS_DEVBUSY; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1676 | } |
| 1677 | |
Krishna Gudipati | ca8b432 | 2010-03-05 19:38:07 -0800 | [diff] [blame] | 1678 | fcport->stats_busy = BFA_TRUE; |
| 1679 | fcport->stats_ret = stats; |
| 1680 | fcport->stats_cbfn = cbfn; |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1681 | fcport->stats_cbarg = cbarg; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1682 | |
Krishna Gudipati | ca8b432 | 2010-03-05 19:38:07 -0800 | [diff] [blame] | 1683 | bfa_fcport_send_stats_get(fcport); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1684 | |
Krishna Gudipati | ca8b432 | 2010-03-05 19:38:07 -0800 | [diff] [blame] | 1685 | bfa_timer_start(bfa, &fcport->timer, bfa_fcport_stats_get_timeout, |
| 1686 | fcport, BFA_FCPORT_STATS_TOV); |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1687 | return BFA_STATUS_OK; |
| 1688 | } |
| 1689 | |
| 1690 | /** |
Krishna Gudipati | ca8b432 | 2010-03-05 19:38:07 -0800 | [diff] [blame] | 1691 | * Reset port statistics (FCQoS or FCoE). |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1692 | */ |
| 1693 | bfa_status_t |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1694 | bfa_fcport_clear_stats(struct bfa_s *bfa, bfa_cb_pport_t cbfn, void *cbarg) |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1695 | { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1696 | struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); |
| 1697 | |
| 1698 | if (fcport->stats_busy) { |
| 1699 | bfa_trc(bfa, fcport->stats_busy); |
| 1700 | return BFA_STATUS_DEVBUSY; |
| 1701 | } |
| 1702 | |
| 1703 | fcport->stats_busy = BFA_TRUE; |
| 1704 | fcport->stats_cbfn = cbfn; |
| 1705 | fcport->stats_cbarg = cbarg; |
| 1706 | |
Krishna Gudipati | ca8b432 | 2010-03-05 19:38:07 -0800 | [diff] [blame] | 1707 | bfa_fcport_send_stats_clear(fcport); |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1708 | |
| 1709 | bfa_timer_start(bfa, &fcport->timer, bfa_fcport_stats_clr_timeout, |
Krishna Gudipati | ca8b432 | 2010-03-05 19:38:07 -0800 | [diff] [blame] | 1710 | fcport, BFA_FCPORT_STATS_TOV); |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1711 | return BFA_STATUS_OK; |
| 1712 | } |
| 1713 | |
Krishna Gudipati | ca8b432 | 2010-03-05 19:38:07 -0800 | [diff] [blame] | 1714 | /** |
| 1715 | * Fetch FCQoS port statistics |
| 1716 | */ |
| 1717 | bfa_status_t |
| 1718 | bfa_fcport_get_qos_stats(struct bfa_s *bfa, union bfa_fcport_stats_u *stats, |
| 1719 | bfa_cb_pport_t cbfn, void *cbarg) |
| 1720 | { |
| 1721 | /* Meaningful only for FC mode */ |
| 1722 | bfa_assert(bfa_ioc_get_fcmode(&bfa->ioc)); |
| 1723 | |
| 1724 | return bfa_fcport_get_stats(bfa, stats, cbfn, cbarg); |
| 1725 | } |
| 1726 | |
| 1727 | /** |
| 1728 | * Reset FCoE port statistics |
| 1729 | */ |
| 1730 | bfa_status_t |
| 1731 | bfa_fcport_clear_qos_stats(struct bfa_s *bfa, bfa_cb_pport_t cbfn, void *cbarg) |
| 1732 | { |
| 1733 | /* Meaningful only for FC mode */ |
| 1734 | bfa_assert(bfa_ioc_get_fcmode(&bfa->ioc)); |
| 1735 | |
| 1736 | return bfa_fcport_clear_stats(bfa, cbfn, cbarg); |
| 1737 | } |
| 1738 | |
| 1739 | /** |
| 1740 | * Fetch FCQoS port statistics |
| 1741 | */ |
| 1742 | bfa_status_t |
| 1743 | bfa_fcport_get_fcoe_stats(struct bfa_s *bfa, union bfa_fcport_stats_u *stats, |
| 1744 | bfa_cb_pport_t cbfn, void *cbarg) |
| 1745 | { |
| 1746 | /* Meaningful only for FCoE mode */ |
| 1747 | bfa_assert(!bfa_ioc_get_fcmode(&bfa->ioc)); |
| 1748 | |
| 1749 | return bfa_fcport_get_stats(bfa, stats, cbfn, cbarg); |
| 1750 | } |
| 1751 | |
| 1752 | /** |
| 1753 | * Reset FCoE port statistics |
| 1754 | */ |
| 1755 | bfa_status_t |
| 1756 | bfa_fcport_clear_fcoe_stats(struct bfa_s *bfa, bfa_cb_pport_t cbfn, void *cbarg) |
| 1757 | { |
| 1758 | /* Meaningful only for FCoE mode */ |
| 1759 | bfa_assert(!bfa_ioc_get_fcmode(&bfa->ioc)); |
| 1760 | |
| 1761 | return bfa_fcport_clear_stats(bfa, cbfn, cbarg); |
| 1762 | } |
| 1763 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1764 | bfa_status_t |
| 1765 | bfa_fcport_trunk_enable(struct bfa_s *bfa, u8 bitmap) |
| 1766 | { |
| 1767 | struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1768 | |
| 1769 | bfa_trc(bfa, bitmap); |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1770 | bfa_trc(bfa, fcport->cfg.trunked); |
| 1771 | bfa_trc(bfa, fcport->cfg.trunk_ports); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1772 | |
| 1773 | if (!bitmap || (bitmap & (bitmap - 1))) |
| 1774 | return BFA_STATUS_EINVAL; |
| 1775 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1776 | fcport->cfg.trunked = BFA_TRUE; |
| 1777 | fcport->cfg.trunk_ports = bitmap; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1778 | |
| 1779 | return BFA_STATUS_OK; |
| 1780 | } |
| 1781 | |
| 1782 | void |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1783 | bfa_fcport_qos_get_attr(struct bfa_s *bfa, struct bfa_qos_attr_s *qos_attr) |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1784 | { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1785 | struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1786 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1787 | qos_attr->state = bfa_os_ntohl(fcport->qos_attr.state); |
| 1788 | qos_attr->total_bb_cr = bfa_os_ntohl(fcport->qos_attr.total_bb_cr); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1789 | } |
| 1790 | |
| 1791 | void |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1792 | bfa_fcport_qos_get_vc_attr(struct bfa_s *bfa, |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1793 | struct bfa_qos_vc_attr_s *qos_vc_attr) |
| 1794 | { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1795 | struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); |
| 1796 | struct bfa_qos_vc_attr_s *bfa_vc_attr = &fcport->qos_vc_attr; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1797 | u32 i = 0; |
| 1798 | |
| 1799 | qos_vc_attr->total_vc_count = bfa_os_ntohs(bfa_vc_attr->total_vc_count); |
| 1800 | qos_vc_attr->shared_credit = bfa_os_ntohs(bfa_vc_attr->shared_credit); |
| 1801 | qos_vc_attr->elp_opmode_flags = |
| 1802 | bfa_os_ntohl(bfa_vc_attr->elp_opmode_flags); |
| 1803 | |
| 1804 | /* |
| 1805 | * Individual VC info |
| 1806 | */ |
| 1807 | while (i < qos_vc_attr->total_vc_count) { |
| 1808 | qos_vc_attr->vc_info[i].vc_credit = |
| 1809 | bfa_vc_attr->vc_info[i].vc_credit; |
| 1810 | qos_vc_attr->vc_info[i].borrow_credit = |
| 1811 | bfa_vc_attr->vc_info[i].borrow_credit; |
| 1812 | qos_vc_attr->vc_info[i].priority = |
| 1813 | bfa_vc_attr->vc_info[i].priority; |
| 1814 | ++i; |
| 1815 | } |
| 1816 | } |
| 1817 | |
| 1818 | /** |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1819 | * Fetch port attributes. |
| 1820 | */ |
| 1821 | bfa_status_t |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1822 | bfa_fcport_trunk_disable(struct bfa_s *bfa) |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1823 | { |
Jing Huang | f8ceafd | 2009-09-25 12:29:54 -0700 | [diff] [blame] | 1824 | return BFA_STATUS_OK; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1825 | } |
| 1826 | |
| 1827 | bfa_boolean_t |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1828 | bfa_fcport_trunk_query(struct bfa_s *bfa, u32 *bitmap) |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1829 | { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1830 | struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1831 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1832 | *bitmap = fcport->cfg.trunk_ports; |
| 1833 | return fcport->cfg.trunked; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1834 | } |
| 1835 | |
| 1836 | bfa_boolean_t |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1837 | bfa_fcport_is_disabled(struct bfa_s *bfa) |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1838 | { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1839 | struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1840 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1841 | return bfa_sm_to_state(hal_pport_sm_table, fcport->sm) == |
Jing Huang | f8ceafd | 2009-09-25 12:29:54 -0700 | [diff] [blame] | 1842 | BFA_PPORT_ST_DISABLED; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1843 | |
| 1844 | } |
| 1845 | |
| 1846 | bfa_boolean_t |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1847 | bfa_fcport_is_ratelim(struct bfa_s *bfa) |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1848 | { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1849 | struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1850 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1851 | return fcport->cfg.ratelimit ? BFA_TRUE : BFA_FALSE; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1852 | |
| 1853 | } |
| 1854 | |
| 1855 | void |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1856 | bfa_fcport_cfg_qos(struct bfa_s *bfa, bfa_boolean_t on_off) |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1857 | { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1858 | struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); |
Krishna Gudipati | 0a4b1fc | 2010-03-05 19:37:57 -0800 | [diff] [blame] | 1859 | enum bfa_ioc_type_e ioc_type = bfa_get_type(bfa); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1860 | |
| 1861 | bfa_trc(bfa, on_off); |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1862 | bfa_trc(bfa, fcport->cfg.qos_enabled); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1863 | |
Krishna Gudipati | 0a4b1fc | 2010-03-05 19:37:57 -0800 | [diff] [blame] | 1864 | bfa_trc(bfa, ioc_type); |
| 1865 | |
Jing Huang | 36d345a | 2010-07-08 19:57:33 -0700 | [diff] [blame] | 1866 | if (ioc_type == BFA_IOC_TYPE_FC) { |
Krishna Gudipati | 0a4b1fc | 2010-03-05 19:37:57 -0800 | [diff] [blame] | 1867 | fcport->cfg.qos_enabled = on_off; |
Jing Huang | 36d345a | 2010-07-08 19:57:33 -0700 | [diff] [blame] | 1868 | /** |
| 1869 | * Notify fcpim of the change in QoS state |
| 1870 | */ |
| 1871 | bfa_fcpim_update_ioredirect(bfa); |
| 1872 | } |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1873 | } |
| 1874 | |
| 1875 | void |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1876 | bfa_fcport_cfg_ratelim(struct bfa_s *bfa, bfa_boolean_t on_off) |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1877 | { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1878 | struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1879 | |
| 1880 | bfa_trc(bfa, on_off); |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1881 | bfa_trc(bfa, fcport->cfg.ratelimit); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1882 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1883 | fcport->cfg.ratelimit = on_off; |
| 1884 | if (fcport->cfg.trl_def_speed == BFA_PPORT_SPEED_UNKNOWN) |
| 1885 | fcport->cfg.trl_def_speed = BFA_PPORT_SPEED_1GBPS; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1886 | } |
| 1887 | |
| 1888 | /** |
| 1889 | * Configure default minimum ratelim speed |
| 1890 | */ |
| 1891 | bfa_status_t |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1892 | bfa_fcport_cfg_ratelim_speed(struct bfa_s *bfa, enum bfa_pport_speed speed) |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1893 | { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1894 | struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1895 | |
| 1896 | bfa_trc(bfa, speed); |
| 1897 | |
| 1898 | /* |
| 1899 | * Auto and speeds greater than the supported speed, are invalid |
| 1900 | */ |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1901 | if ((speed == BFA_PPORT_SPEED_AUTO) || (speed > fcport->speed_sup)) { |
| 1902 | bfa_trc(bfa, fcport->speed_sup); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1903 | return BFA_STATUS_UNSUPP_SPEED; |
| 1904 | } |
| 1905 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1906 | fcport->cfg.trl_def_speed = speed; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1907 | |
Jing Huang | f8ceafd | 2009-09-25 12:29:54 -0700 | [diff] [blame] | 1908 | return BFA_STATUS_OK; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1909 | } |
| 1910 | |
| 1911 | /** |
| 1912 | * Get default minimum ratelim speed |
| 1913 | */ |
| 1914 | enum bfa_pport_speed |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1915 | bfa_fcport_get_ratelim_speed(struct bfa_s *bfa) |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1916 | { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1917 | struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1918 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1919 | bfa_trc(bfa, fcport->cfg.trl_def_speed); |
| 1920 | return fcport->cfg.trl_def_speed; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1921 | |
| 1922 | } |
| 1923 | |
| 1924 | void |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1925 | bfa_fcport_busy(struct bfa_s *bfa, bfa_boolean_t status) |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1926 | { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1927 | struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1928 | |
| 1929 | bfa_trc(bfa, status); |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1930 | bfa_trc(bfa, fcport->diag_busy); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1931 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1932 | fcport->diag_busy = status; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1933 | } |
| 1934 | |
| 1935 | void |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1936 | bfa_fcport_beacon(struct bfa_s *bfa, bfa_boolean_t beacon, |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1937 | bfa_boolean_t link_e2e_beacon) |
| 1938 | { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1939 | struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1940 | |
| 1941 | bfa_trc(bfa, beacon); |
| 1942 | bfa_trc(bfa, link_e2e_beacon); |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1943 | bfa_trc(bfa, fcport->beacon); |
| 1944 | bfa_trc(bfa, fcport->link_e2e_beacon); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1945 | |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1946 | fcport->beacon = beacon; |
| 1947 | fcport->link_e2e_beacon = link_e2e_beacon; |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1948 | } |
| 1949 | |
| 1950 | bfa_boolean_t |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1951 | bfa_fcport_is_linkup(struct bfa_s *bfa) |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1952 | { |
Krishna Gudipati | 1c8a4c3 | 2010-03-05 19:37:37 -0800 | [diff] [blame] | 1953 | return bfa_sm_cmp_state(BFA_FCPORT_MOD(bfa), bfa_fcport_sm_linkup); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1954 | } |
| 1955 | |
Jing Huang | 36d345a | 2010-07-08 19:57:33 -0700 | [diff] [blame] | 1956 | bfa_boolean_t |
| 1957 | bfa_fcport_is_qos_enabled(struct bfa_s *bfa) |
| 1958 | { |
| 1959 | struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); |
Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1960 | |
Jing Huang | 36d345a | 2010-07-08 19:57:33 -0700 | [diff] [blame] | 1961 | return fcport->cfg.qos_enabled; |
| 1962 | } |