Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2005-2010 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 | #ifndef __BFA_FCS_H__ |
| 19 | #define __BFA_FCS_H__ |
| 20 | |
| 21 | #include "bfa_cs.h" |
| 22 | #include "bfa_defs.h" |
| 23 | #include "bfa_defs_fcs.h" |
| 24 | #include "bfa_modules.h" |
| 25 | #include "bfa_fc.h" |
| 26 | |
| 27 | #define BFA_FCS_OS_STR_LEN 64 |
| 28 | |
| 29 | /* |
Maggie Zhang | f7f73812 | 2010-12-09 19:08:43 -0800 | [diff] [blame] | 30 | * lps_pvt BFA LPS private functions |
| 31 | */ |
| 32 | |
| 33 | enum bfa_lps_event { |
| 34 | BFA_LPS_SM_LOGIN = 1, /* login request from user */ |
| 35 | BFA_LPS_SM_LOGOUT = 2, /* logout request from user */ |
| 36 | BFA_LPS_SM_FWRSP = 3, /* f/w response to login/logout */ |
| 37 | BFA_LPS_SM_RESUME = 4, /* space present in reqq queue */ |
| 38 | BFA_LPS_SM_DELETE = 5, /* lps delete from user */ |
| 39 | BFA_LPS_SM_OFFLINE = 6, /* Link is offline */ |
| 40 | BFA_LPS_SM_RX_CVL = 7, /* Rx clear virtual link */ |
Krishna Gudipati | b704495 | 2010-12-13 16:17:42 -0800 | [diff] [blame] | 41 | BFA_LPS_SM_SET_N2N_PID = 8, /* Set assigned PID for n2n */ |
Maggie Zhang | f7f73812 | 2010-12-09 19:08:43 -0800 | [diff] [blame] | 42 | }; |
| 43 | |
| 44 | |
| 45 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 46 | * !!! Only append to the enums defined here to avoid any versioning |
| 47 | * !!! needed between trace utility and driver version |
| 48 | */ |
| 49 | enum { |
| 50 | BFA_TRC_FCS_FCS = 1, |
| 51 | BFA_TRC_FCS_PORT = 2, |
| 52 | BFA_TRC_FCS_RPORT = 3, |
| 53 | BFA_TRC_FCS_FCPIM = 4, |
| 54 | }; |
| 55 | |
| 56 | |
| 57 | struct bfa_fcs_s; |
| 58 | |
| 59 | #define __fcs_min_cfg(__fcs) ((__fcs)->min_cfg) |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 60 | |
| 61 | #define BFA_FCS_BRCD_SWITCH_OUI 0x051e |
| 62 | #define N2N_LOCAL_PID 0x010000 |
| 63 | #define N2N_REMOTE_PID 0x020000 |
| 64 | #define BFA_FCS_RETRY_TIMEOUT 2000 |
Krishna Gudipati | ce7242b | 2012-08-22 19:52:43 -0700 | [diff] [blame] | 65 | #define BFA_FCS_MAX_NS_RETRIES 5 |
Maggie Zhang | f16a175 | 2010-12-09 19:12:32 -0800 | [diff] [blame] | 66 | #define BFA_FCS_PID_IS_WKA(pid) ((bfa_ntoh3b(pid) > 0xFFF000) ? 1 : 0) |
Krishna Gudipati | 61ba439 | 2012-08-22 19:52:58 -0700 | [diff] [blame] | 67 | #define BFA_FCS_MAX_RPORT_LOGINS 1024 |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 68 | |
| 69 | struct bfa_fcs_lport_ns_s { |
| 70 | bfa_sm_t sm; /* state machine */ |
| 71 | struct bfa_timer_s timer; |
| 72 | struct bfa_fcs_lport_s *port; /* parent port */ |
| 73 | struct bfa_fcxp_s *fcxp; |
| 74 | struct bfa_fcxp_wqe_s fcxp_wqe; |
Krishna Gudipati | ce7242b | 2012-08-22 19:52:43 -0700 | [diff] [blame] | 75 | u8 num_rnnid_retries; |
| 76 | u8 num_rsnn_nn_retries; |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 77 | }; |
| 78 | |
| 79 | |
| 80 | struct bfa_fcs_lport_scn_s { |
| 81 | bfa_sm_t sm; /* state machine */ |
| 82 | struct bfa_timer_s timer; |
| 83 | struct bfa_fcs_lport_s *port; /* parent port */ |
| 84 | struct bfa_fcxp_s *fcxp; |
| 85 | struct bfa_fcxp_wqe_s fcxp_wqe; |
| 86 | }; |
| 87 | |
| 88 | |
| 89 | struct bfa_fcs_lport_fdmi_s { |
| 90 | bfa_sm_t sm; /* state machine */ |
| 91 | struct bfa_timer_s timer; |
| 92 | struct bfa_fcs_lport_ms_s *ms; /* parent ms */ |
| 93 | struct bfa_fcxp_s *fcxp; |
| 94 | struct bfa_fcxp_wqe_s fcxp_wqe; |
| 95 | u8 retry_cnt; /* retry count */ |
| 96 | u8 rsvd[3]; |
| 97 | }; |
| 98 | |
| 99 | |
| 100 | struct bfa_fcs_lport_ms_s { |
| 101 | bfa_sm_t sm; /* state machine */ |
| 102 | struct bfa_timer_s timer; |
| 103 | struct bfa_fcs_lport_s *port; /* parent port */ |
| 104 | struct bfa_fcxp_s *fcxp; |
| 105 | struct bfa_fcxp_wqe_s fcxp_wqe; |
| 106 | struct bfa_fcs_lport_fdmi_s fdmi; /* FDMI component of MS */ |
| 107 | u8 retry_cnt; /* retry count */ |
| 108 | u8 rsvd[3]; |
| 109 | }; |
| 110 | |
| 111 | |
| 112 | struct bfa_fcs_lport_fab_s { |
| 113 | struct bfa_fcs_lport_ns_s ns; /* NS component of port */ |
| 114 | struct bfa_fcs_lport_scn_s scn; /* scn component of port */ |
| 115 | struct bfa_fcs_lport_ms_s ms; /* MS component of port */ |
| 116 | }; |
| 117 | |
| 118 | #define MAX_ALPA_COUNT 127 |
| 119 | |
| 120 | struct bfa_fcs_lport_loop_s { |
Krishna Gudipati | bc0e2c2 | 2012-09-21 17:23:59 -0700 | [diff] [blame] | 121 | u8 num_alpa; /* Num of ALPA entries in the map */ |
| 122 | u8 alpabm_valid; /* alpa bitmap valid or not (1 or 0) */ |
| 123 | u8 alpa_pos_map[MAX_ALPA_COUNT]; /* ALPA Positional Map */ |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 124 | struct bfa_fcs_lport_s *port; /* parent port */ |
| 125 | }; |
| 126 | |
| 127 | struct bfa_fcs_lport_n2n_s { |
| 128 | u32 rsvd; |
Maggie | 50444a3 | 2010-11-29 18:26:32 -0800 | [diff] [blame] | 129 | __be16 reply_oxid; /* ox_id from the req flogi to be |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 130 | *used in flogi acc */ |
| 131 | wwn_t rem_port_wwn; /* Attached port's wwn */ |
| 132 | }; |
| 133 | |
| 134 | |
| 135 | union bfa_fcs_lport_topo_u { |
| 136 | struct bfa_fcs_lport_fab_s pfab; |
| 137 | struct bfa_fcs_lport_loop_s ploop; |
| 138 | struct bfa_fcs_lport_n2n_s pn2n; |
| 139 | }; |
| 140 | |
| 141 | |
| 142 | struct bfa_fcs_lport_s { |
| 143 | struct list_head qe; /* used by port/vport */ |
| 144 | bfa_sm_t sm; /* state machine */ |
| 145 | struct bfa_fcs_fabric_s *fabric; /* parent fabric */ |
| 146 | struct bfa_lport_cfg_s port_cfg; /* port configuration */ |
| 147 | struct bfa_timer_s link_timer; /* timer for link offline */ |
| 148 | u32 pid:24; /* FC address */ |
| 149 | u8 lp_tag; /* lport tag */ |
| 150 | u16 num_rports; /* Num of r-ports */ |
| 151 | struct list_head rport_q; /* queue of discovered r-ports */ |
| 152 | struct bfa_fcs_s *fcs; /* FCS instance */ |
| 153 | union bfa_fcs_lport_topo_u port_topo; /* fabric/loop/n2n details */ |
| 154 | struct bfad_port_s *bfad_port; /* driver peer instance */ |
| 155 | struct bfa_fcs_vport_s *vport; /* NULL for base ports */ |
| 156 | struct bfa_fcxp_s *fcxp; |
| 157 | struct bfa_fcxp_wqe_s fcxp_wqe; |
| 158 | struct bfa_lport_stats_s stats; |
| 159 | struct bfa_wc_s wc; /* waiting counter for events */ |
| 160 | }; |
| 161 | #define BFA_FCS_GET_HAL_FROM_PORT(port) (port->fcs->bfa) |
| 162 | #define BFA_FCS_GET_NS_FROM_PORT(port) (&port->port_topo.pfab.ns) |
| 163 | #define BFA_FCS_GET_SCN_FROM_PORT(port) (&port->port_topo.pfab.scn) |
| 164 | #define BFA_FCS_GET_MS_FROM_PORT(port) (&port->port_topo.pfab.ms) |
| 165 | #define BFA_FCS_GET_FDMI_FROM_PORT(port) (&port->port_topo.pfab.ms.fdmi) |
| 166 | #define BFA_FCS_VPORT_IS_INITIATOR_MODE(port) \ |
| 167 | (port->port_cfg.roles & BFA_LPORT_ROLE_FCP_IM) |
| 168 | |
| 169 | /* |
| 170 | * forward declaration |
| 171 | */ |
| 172 | struct bfad_vf_s; |
| 173 | |
| 174 | enum bfa_fcs_fabric_type { |
| 175 | BFA_FCS_FABRIC_UNKNOWN = 0, |
| 176 | BFA_FCS_FABRIC_SWITCHED = 1, |
| 177 | BFA_FCS_FABRIC_N2N = 2, |
Krishna Gudipati | bc0e2c2 | 2012-09-21 17:23:59 -0700 | [diff] [blame] | 178 | BFA_FCS_FABRIC_LOOP = 3, |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 179 | }; |
| 180 | |
| 181 | |
| 182 | struct bfa_fcs_fabric_s { |
| 183 | struct list_head qe; /* queue element */ |
| 184 | bfa_sm_t sm; /* state machine */ |
| 185 | struct bfa_fcs_s *fcs; /* FCS instance */ |
| 186 | struct bfa_fcs_lport_s bport; /* base logical port */ |
| 187 | enum bfa_fcs_fabric_type fab_type; /* fabric type */ |
| 188 | enum bfa_port_type oper_type; /* current link topology */ |
| 189 | u8 is_vf; /* is virtual fabric? */ |
| 190 | u8 is_npiv; /* is NPIV supported ? */ |
| 191 | u8 is_auth; /* is Security/Auth supported ? */ |
| 192 | u16 bb_credit; /* BB credit from fabric */ |
| 193 | u16 vf_id; /* virtual fabric ID */ |
| 194 | u16 num_vports; /* num vports */ |
| 195 | u16 rsvd; |
| 196 | struct list_head vport_q; /* queue of virtual ports */ |
| 197 | struct list_head vf_q; /* queue of virtual fabrics */ |
| 198 | struct bfad_vf_s *vf_drv; /* driver vf structure */ |
| 199 | struct bfa_timer_s link_timer; /* Link Failure timer. Vport */ |
| 200 | wwn_t fabric_name; /* attached fabric name */ |
| 201 | bfa_boolean_t auth_reqd; /* authentication required */ |
| 202 | struct bfa_timer_s delay_timer; /* delay timer */ |
| 203 | union { |
| 204 | u16 swp_vfid;/* switch port VF id */ |
| 205 | } event_arg; |
| 206 | struct bfa_wc_s wc; /* wait counter for delete */ |
| 207 | struct bfa_vf_stats_s stats; /* fabric/vf stats */ |
| 208 | struct bfa_lps_s *lps; /* lport login services */ |
| 209 | u8 fabric_ip_addr[BFA_FCS_FABRIC_IPADDR_SZ]; |
| 210 | /* attached fabric's ip addr */ |
Krishna Gudipati | 881c1b3 | 2012-08-22 19:52:02 -0700 | [diff] [blame] | 211 | struct bfa_wc_s stop_wc; /* wait counter for stop */ |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 212 | }; |
| 213 | |
| 214 | #define bfa_fcs_fabric_npiv_capable(__f) ((__f)->is_npiv) |
| 215 | #define bfa_fcs_fabric_is_switched(__f) \ |
| 216 | ((__f)->fab_type == BFA_FCS_FABRIC_SWITCHED) |
| 217 | |
Jing Huang | acdc79a | 2010-10-18 17:15:55 -0700 | [diff] [blame] | 218 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 219 | * The design calls for a single implementation of base fabric and vf. |
| 220 | */ |
| 221 | #define bfa_fcs_vf_t struct bfa_fcs_fabric_s |
| 222 | |
| 223 | struct bfa_vf_event_s { |
| 224 | u32 undefined; |
| 225 | }; |
| 226 | |
| 227 | struct bfa_fcs_s; |
| 228 | struct bfa_fcs_fabric_s; |
| 229 | |
| 230 | /* |
| 231 | * @todo : need to move to a global config file. |
| 232 | * Maximum Rports supported per port (physical/logical). |
| 233 | */ |
| 234 | #define BFA_FCS_MAX_RPORTS_SUPP 256 /* @todo : tentative value */ |
| 235 | |
| 236 | #define bfa_fcs_lport_t struct bfa_fcs_lport_s |
| 237 | |
Jing Huang | acdc79a | 2010-10-18 17:15:55 -0700 | [diff] [blame] | 238 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 239 | * Symbolic Name related defines |
| 240 | * Total bytes 255. |
| 241 | * Physical Port's symbolic name 128 bytes. |
| 242 | * For Vports, Vport's symbolic name is appended to the Physical port's |
| 243 | * Symbolic Name. |
| 244 | * |
| 245 | * Physical Port's symbolic name Format : (Total 128 bytes) |
| 246 | * Adapter Model number/name : 12 bytes |
| 247 | * Driver Version : 10 bytes |
| 248 | * Host Machine Name : 30 bytes |
| 249 | * Host OS Info : 48 bytes |
| 250 | * Host OS PATCH Info : 16 bytes |
| 251 | * ( remaining 12 bytes reserved to be used for separator) |
| 252 | */ |
| 253 | #define BFA_FCS_PORT_SYMBNAME_SEPARATOR " | " |
| 254 | |
| 255 | #define BFA_FCS_PORT_SYMBNAME_MODEL_SZ 12 |
| 256 | #define BFA_FCS_PORT_SYMBNAME_VERSION_SZ 10 |
| 257 | #define BFA_FCS_PORT_SYMBNAME_MACHINENAME_SZ 30 |
| 258 | #define BFA_FCS_PORT_SYMBNAME_OSINFO_SZ 48 |
| 259 | #define BFA_FCS_PORT_SYMBNAME_OSPATCH_SZ 16 |
| 260 | |
Krishna Gudipati | be540a9 | 2011-06-13 15:53:04 -0700 | [diff] [blame] | 261 | /* bb_scn value in 2^bb_scn */ |
| 262 | #define BFA_FCS_PORT_DEF_BB_SCN 3 |
| 263 | |
Jing Huang | acdc79a | 2010-10-18 17:15:55 -0700 | [diff] [blame] | 264 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 265 | * Get FC port ID for a logical port. |
| 266 | */ |
| 267 | #define bfa_fcs_lport_get_fcid(_lport) ((_lport)->pid) |
| 268 | #define bfa_fcs_lport_get_pwwn(_lport) ((_lport)->port_cfg.pwwn) |
| 269 | #define bfa_fcs_lport_get_nwwn(_lport) ((_lport)->port_cfg.nwwn) |
| 270 | #define bfa_fcs_lport_get_psym_name(_lport) ((_lport)->port_cfg.sym_name) |
Krishna Gudipati | ce7242b | 2012-08-22 19:52:43 -0700 | [diff] [blame] | 271 | #define bfa_fcs_lport_get_nsym_name(_lport) ((_lport)->port_cfg.node_sym_name) |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 272 | #define bfa_fcs_lport_is_initiator(_lport) \ |
| 273 | ((_lport)->port_cfg.roles & BFA_LPORT_ROLE_FCP_IM) |
| 274 | #define bfa_fcs_lport_get_nrports(_lport) \ |
| 275 | ((_lport) ? (_lport)->num_rports : 0) |
| 276 | |
| 277 | static inline struct bfad_port_s * |
| 278 | bfa_fcs_lport_get_drvport(struct bfa_fcs_lport_s *port) |
| 279 | { |
| 280 | return port->bfad_port; |
| 281 | } |
| 282 | |
| 283 | #define bfa_fcs_lport_get_opertype(_lport) ((_lport)->fabric->oper_type) |
| 284 | #define bfa_fcs_lport_get_fabric_name(_lport) ((_lport)->fabric->fabric_name) |
| 285 | #define bfa_fcs_lport_get_fabric_ipaddr(_lport) \ |
| 286 | ((_lport)->fabric->fabric_ip_addr) |
| 287 | |
Jing Huang | acdc79a | 2010-10-18 17:15:55 -0700 | [diff] [blame] | 288 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 289 | * bfa fcs port public functions |
| 290 | */ |
| 291 | |
| 292 | bfa_boolean_t bfa_fcs_lport_is_online(struct bfa_fcs_lport_s *port); |
| 293 | struct bfa_fcs_lport_s *bfa_fcs_get_base_port(struct bfa_fcs_s *fcs); |
Krishna Gudipati | ee1a4a4 | 2012-08-22 19:50:43 -0700 | [diff] [blame] | 294 | void bfa_fcs_lport_get_rport_quals(struct bfa_fcs_lport_s *port, |
| 295 | struct bfa_rport_qualifier_s rport[], int *nrports); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 296 | wwn_t bfa_fcs_lport_get_rport(struct bfa_fcs_lport_s *port, wwn_t wwn, |
| 297 | int index, int nrports, bfa_boolean_t bwwn); |
| 298 | |
| 299 | struct bfa_fcs_lport_s *bfa_fcs_lookup_port(struct bfa_fcs_s *fcs, |
| 300 | u16 vf_id, wwn_t lpwwn); |
| 301 | |
| 302 | void bfa_fcs_lport_get_info(struct bfa_fcs_lport_s *port, |
| 303 | struct bfa_lport_info_s *port_info); |
| 304 | void bfa_fcs_lport_get_attr(struct bfa_fcs_lport_s *port, |
| 305 | struct bfa_lport_attr_s *port_attr); |
| 306 | void bfa_fcs_lport_get_stats(struct bfa_fcs_lport_s *fcs_port, |
| 307 | struct bfa_lport_stats_s *port_stats); |
| 308 | void bfa_fcs_lport_clear_stats(struct bfa_fcs_lport_s *fcs_port); |
| 309 | enum bfa_port_speed bfa_fcs_lport_get_rport_max_speed( |
| 310 | struct bfa_fcs_lport_s *port); |
| 311 | |
| 312 | /* MS FCS routines */ |
| 313 | void bfa_fcs_lport_ms_init(struct bfa_fcs_lport_s *port); |
| 314 | void bfa_fcs_lport_ms_offline(struct bfa_fcs_lport_s *port); |
| 315 | void bfa_fcs_lport_ms_online(struct bfa_fcs_lport_s *port); |
| 316 | void bfa_fcs_lport_ms_fabric_rscn(struct bfa_fcs_lport_s *port); |
| 317 | |
| 318 | /* FDMI FCS routines */ |
| 319 | void bfa_fcs_lport_fdmi_init(struct bfa_fcs_lport_ms_s *ms); |
| 320 | void bfa_fcs_lport_fdmi_offline(struct bfa_fcs_lport_ms_s *ms); |
| 321 | void bfa_fcs_lport_fdmi_online(struct bfa_fcs_lport_ms_s *ms); |
| 322 | void bfa_fcs_lport_uf_recv(struct bfa_fcs_lport_s *lport, struct fchs_s *fchs, |
| 323 | u16 len); |
| 324 | void bfa_fcs_lport_attach(struct bfa_fcs_lport_s *lport, struct bfa_fcs_s *fcs, |
| 325 | u16 vf_id, struct bfa_fcs_vport_s *vport); |
| 326 | void bfa_fcs_lport_init(struct bfa_fcs_lport_s *lport, |
| 327 | struct bfa_lport_cfg_s *port_cfg); |
| 328 | void bfa_fcs_lport_online(struct bfa_fcs_lport_s *port); |
| 329 | void bfa_fcs_lport_offline(struct bfa_fcs_lport_s *port); |
| 330 | void bfa_fcs_lport_delete(struct bfa_fcs_lport_s *port); |
Krishna Gudipati | 881c1b3 | 2012-08-22 19:52:02 -0700 | [diff] [blame] | 331 | void bfa_fcs_lport_stop(struct bfa_fcs_lport_s *port); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 332 | struct bfa_fcs_rport_s *bfa_fcs_lport_get_rport_by_pid( |
| 333 | struct bfa_fcs_lport_s *port, u32 pid); |
Krishna Gudipati | ee1a4a4 | 2012-08-22 19:50:43 -0700 | [diff] [blame] | 334 | struct bfa_fcs_rport_s *bfa_fcs_lport_get_rport_by_old_pid( |
| 335 | struct bfa_fcs_lport_s *port, u32 pid); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 336 | struct bfa_fcs_rport_s *bfa_fcs_lport_get_rport_by_pwwn( |
| 337 | struct bfa_fcs_lport_s *port, wwn_t pwwn); |
| 338 | struct bfa_fcs_rport_s *bfa_fcs_lport_get_rport_by_nwwn( |
| 339 | struct bfa_fcs_lport_s *port, wwn_t nwwn); |
Krishna Gudipati | ee1a4a4 | 2012-08-22 19:50:43 -0700 | [diff] [blame] | 340 | struct bfa_fcs_rport_s *bfa_fcs_lport_get_rport_by_qualifier( |
| 341 | struct bfa_fcs_lport_s *port, wwn_t pwwn, u32 pid); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 342 | void bfa_fcs_lport_add_rport(struct bfa_fcs_lport_s *port, |
| 343 | struct bfa_fcs_rport_s *rport); |
| 344 | void bfa_fcs_lport_del_rport(struct bfa_fcs_lport_s *port, |
| 345 | struct bfa_fcs_rport_s *rport); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 346 | void bfa_fcs_lport_ns_init(struct bfa_fcs_lport_s *vport); |
| 347 | void bfa_fcs_lport_ns_offline(struct bfa_fcs_lport_s *vport); |
| 348 | void bfa_fcs_lport_ns_online(struct bfa_fcs_lport_s *vport); |
| 349 | void bfa_fcs_lport_ns_query(struct bfa_fcs_lport_s *port); |
Krishna Gudipati | ebfe839 | 2012-08-22 19:50:20 -0700 | [diff] [blame] | 350 | void bfa_fcs_lport_ns_util_send_rspn_id(void *cbarg, |
| 351 | struct bfa_fcxp_s *fcxp_alloced); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 352 | void bfa_fcs_lport_scn_init(struct bfa_fcs_lport_s *vport); |
| 353 | void bfa_fcs_lport_scn_offline(struct bfa_fcs_lport_s *vport); |
Krishna Gudipati | bc0e2c2 | 2012-09-21 17:23:59 -0700 | [diff] [blame] | 354 | void bfa_fcs_lport_fab_scn_online(struct bfa_fcs_lport_s *vport); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 355 | void bfa_fcs_lport_scn_process_rscn(struct bfa_fcs_lport_s *port, |
| 356 | struct fchs_s *rx_frame, u32 len); |
Krishna Gudipati | bc0e2c2 | 2012-09-21 17:23:59 -0700 | [diff] [blame] | 357 | void bfa_fcs_lport_lip_scn_online(bfa_fcs_lport_t *port); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 358 | |
| 359 | struct bfa_fcs_vport_s { |
| 360 | struct list_head qe; /* queue elem */ |
| 361 | bfa_sm_t sm; /* state machine */ |
| 362 | bfa_fcs_lport_t lport; /* logical port */ |
| 363 | struct bfa_timer_s timer; |
| 364 | struct bfad_vport_s *vport_drv; /* Driver private */ |
| 365 | struct bfa_vport_stats_s vport_stats; /* vport statistics */ |
| 366 | struct bfa_lps_s *lps; /* Lport login service*/ |
| 367 | int fdisc_retries; |
| 368 | }; |
| 369 | |
| 370 | #define bfa_fcs_vport_get_port(vport) \ |
| 371 | ((struct bfa_fcs_lport_s *)(&vport->port)) |
| 372 | |
Jing Huang | acdc79a | 2010-10-18 17:15:55 -0700 | [diff] [blame] | 373 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 374 | * bfa fcs vport public functions |
| 375 | */ |
| 376 | bfa_status_t bfa_fcs_vport_create(struct bfa_fcs_vport_s *vport, |
| 377 | struct bfa_fcs_s *fcs, u16 vf_id, |
| 378 | struct bfa_lport_cfg_s *port_cfg, |
| 379 | struct bfad_vport_s *vport_drv); |
| 380 | bfa_status_t bfa_fcs_pbc_vport_create(struct bfa_fcs_vport_s *vport, |
| 381 | struct bfa_fcs_s *fcs, u16 vf_id, |
| 382 | struct bfa_lport_cfg_s *port_cfg, |
| 383 | struct bfad_vport_s *vport_drv); |
| 384 | bfa_boolean_t bfa_fcs_is_pbc_vport(struct bfa_fcs_vport_s *vport); |
| 385 | bfa_status_t bfa_fcs_vport_delete(struct bfa_fcs_vport_s *vport); |
| 386 | bfa_status_t bfa_fcs_vport_start(struct bfa_fcs_vport_s *vport); |
| 387 | bfa_status_t bfa_fcs_vport_stop(struct bfa_fcs_vport_s *vport); |
| 388 | void bfa_fcs_vport_get_attr(struct bfa_fcs_vport_s *vport, |
| 389 | struct bfa_vport_attr_s *vport_attr); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 390 | struct bfa_fcs_vport_s *bfa_fcs_vport_lookup(struct bfa_fcs_s *fcs, |
| 391 | u16 vf_id, wwn_t vpwwn); |
| 392 | void bfa_fcs_vport_cleanup(struct bfa_fcs_vport_s *vport); |
| 393 | void bfa_fcs_vport_online(struct bfa_fcs_vport_s *vport); |
| 394 | void bfa_fcs_vport_offline(struct bfa_fcs_vport_s *vport); |
| 395 | void bfa_fcs_vport_delete_comp(struct bfa_fcs_vport_s *vport); |
| 396 | void bfa_fcs_vport_fcs_delete(struct bfa_fcs_vport_s *vport); |
Krishna Gudipati | 881c1b3 | 2012-08-22 19:52:02 -0700 | [diff] [blame] | 397 | void bfa_fcs_vport_fcs_stop(struct bfa_fcs_vport_s *vport); |
Krishna Gudipati | dd5aaf4 | 2011-06-13 15:51:24 -0700 | [diff] [blame] | 398 | void bfa_fcs_vport_stop_comp(struct bfa_fcs_vport_s *vport); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 399 | |
| 400 | #define BFA_FCS_RPORT_DEF_DEL_TIMEOUT 90 /* in secs */ |
| 401 | #define BFA_FCS_RPORT_MAX_RETRIES (5) |
| 402 | |
| 403 | /* |
| 404 | * forward declarations |
| 405 | */ |
| 406 | struct bfad_rport_s; |
| 407 | |
| 408 | struct bfa_fcs_itnim_s; |
| 409 | struct bfa_fcs_tin_s; |
| 410 | struct bfa_fcs_iprp_s; |
| 411 | |
| 412 | /* Rport Features (RPF) */ |
| 413 | struct bfa_fcs_rpf_s { |
| 414 | bfa_sm_t sm; /* state machine */ |
| 415 | struct bfa_fcs_rport_s *rport; /* parent rport */ |
| 416 | struct bfa_timer_s timer; /* general purpose timer */ |
| 417 | struct bfa_fcxp_s *fcxp; /* FCXP needed for discarding */ |
| 418 | struct bfa_fcxp_wqe_s fcxp_wqe; /* fcxp wait queue element */ |
| 419 | int rpsc_retries; /* max RPSC retry attempts */ |
| 420 | enum bfa_port_speed rpsc_speed; |
| 421 | /* Current Speed from RPSC. O if RPSC fails */ |
| 422 | enum bfa_port_speed assigned_speed; |
Jing Huang | acdc79a | 2010-10-18 17:15:55 -0700 | [diff] [blame] | 423 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 424 | * Speed assigned by the user. will be used if RPSC is |
| 425 | * not supported by the rport. |
| 426 | */ |
| 427 | }; |
| 428 | |
| 429 | struct bfa_fcs_rport_s { |
| 430 | struct list_head qe; /* used by port/vport */ |
| 431 | struct bfa_fcs_lport_s *port; /* parent FCS port */ |
| 432 | struct bfa_fcs_s *fcs; /* fcs instance */ |
| 433 | struct bfad_rport_s *rp_drv; /* driver peer instance */ |
| 434 | u32 pid; /* port ID of rport */ |
Krishna Gudipati | ee1a4a4 | 2012-08-22 19:50:43 -0700 | [diff] [blame] | 435 | u32 old_pid; /* PID before rport goes offline */ |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 436 | u16 maxfrsize; /* maximum frame size */ |
Maggie | 50444a3 | 2010-11-29 18:26:32 -0800 | [diff] [blame] | 437 | __be16 reply_oxid; /* OX_ID of inbound requests */ |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 438 | enum fc_cos fc_cos; /* FC classes of service supp */ |
| 439 | bfa_boolean_t cisc; /* CISC capable device */ |
| 440 | bfa_boolean_t prlo; /* processing prlo or LOGO */ |
Krishna Gudipati | d7be54c | 2011-06-24 20:24:52 -0700 | [diff] [blame] | 441 | bfa_boolean_t plogi_pending; /* Rx Plogi Pending */ |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 442 | wwn_t pwwn; /* port wwn of rport */ |
| 443 | wwn_t nwwn; /* node wwn of rport */ |
| 444 | struct bfa_rport_symname_s psym_name; /* port symbolic name */ |
| 445 | bfa_sm_t sm; /* state machine */ |
| 446 | struct bfa_timer_s timer; /* general purpose timer */ |
| 447 | struct bfa_fcs_itnim_s *itnim; /* ITN initiator mode role */ |
| 448 | struct bfa_fcs_tin_s *tin; /* ITN initiator mode role */ |
| 449 | struct bfa_fcs_iprp_s *iprp; /* IP/FC role */ |
| 450 | struct bfa_rport_s *bfa_rport; /* BFA Rport */ |
| 451 | struct bfa_fcxp_s *fcxp; /* FCXP needed for discarding */ |
| 452 | int plogi_retries; /* max plogi retry attempts */ |
| 453 | int ns_retries; /* max NS query retry attempts */ |
| 454 | struct bfa_fcxp_wqe_s fcxp_wqe; /* fcxp wait queue element */ |
| 455 | struct bfa_rport_stats_s stats; /* rport stats */ |
| 456 | enum bfa_rport_function scsi_function; /* Initiator/Target */ |
| 457 | struct bfa_fcs_rpf_s rpf; /* Rport features module */ |
Krishna Gudipati | bc0e2c2 | 2012-09-21 17:23:59 -0700 | [diff] [blame] | 458 | bfa_boolean_t scn_online; /* SCN online flag */ |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 459 | }; |
| 460 | |
| 461 | static inline struct bfa_rport_s * |
| 462 | bfa_fcs_rport_get_halrport(struct bfa_fcs_rport_s *rport) |
| 463 | { |
| 464 | return rport->bfa_rport; |
| 465 | } |
| 466 | |
Jing Huang | acdc79a | 2010-10-18 17:15:55 -0700 | [diff] [blame] | 467 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 468 | * bfa fcs rport API functions |
| 469 | */ |
Krishna Gudipati | 6013806 | 2011-06-24 20:25:15 -0700 | [diff] [blame] | 470 | void bfa_fcs_rport_get_attr(struct bfa_fcs_rport_s *rport, |
| 471 | struct bfa_rport_attr_s *attr); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 472 | struct bfa_fcs_rport_s *bfa_fcs_rport_lookup(struct bfa_fcs_lport_s *port, |
| 473 | wwn_t rpwwn); |
| 474 | struct bfa_fcs_rport_s *bfa_fcs_rport_lookup_by_nwwn( |
| 475 | struct bfa_fcs_lport_s *port, wwn_t rnwwn); |
| 476 | void bfa_fcs_rport_set_del_timeout(u8 rport_tmo); |
Krishna Gudipati | 61ba439 | 2012-08-22 19:52:58 -0700 | [diff] [blame] | 477 | void bfa_fcs_rport_set_max_logins(u32 max_logins); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 478 | void bfa_fcs_rport_uf_recv(struct bfa_fcs_rport_s *rport, |
| 479 | struct fchs_s *fchs, u16 len); |
| 480 | void bfa_fcs_rport_scn(struct bfa_fcs_rport_s *rport); |
| 481 | |
| 482 | struct bfa_fcs_rport_s *bfa_fcs_rport_create(struct bfa_fcs_lport_s *port, |
| 483 | u32 pid); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 484 | void bfa_fcs_rport_start(struct bfa_fcs_lport_s *port, struct fchs_s *rx_fchs, |
| 485 | struct fc_logi_s *plogi_rsp); |
| 486 | void bfa_fcs_rport_plogi_create(struct bfa_fcs_lport_s *port, |
| 487 | struct fchs_s *rx_fchs, |
| 488 | struct fc_logi_s *plogi); |
| 489 | void bfa_fcs_rport_plogi(struct bfa_fcs_rport_s *rport, struct fchs_s *fchs, |
| 490 | struct fc_logi_s *plogi); |
Maggie | 50444a3 | 2010-11-29 18:26:32 -0800 | [diff] [blame] | 491 | void bfa_fcs_rport_prlo(struct bfa_fcs_rport_s *rport, __be16 ox_id); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 492 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 493 | void bfa_fcs_rport_itntm_ack(struct bfa_fcs_rport_s *rport); |
| 494 | void bfa_fcs_rport_fcptm_offline_done(struct bfa_fcs_rport_s *rport); |
| 495 | int bfa_fcs_rport_get_state(struct bfa_fcs_rport_s *rport); |
| 496 | struct bfa_fcs_rport_s *bfa_fcs_rport_create_by_wwn( |
| 497 | struct bfa_fcs_lport_s *port, wwn_t wwn); |
| 498 | void bfa_fcs_rpf_init(struct bfa_fcs_rport_s *rport); |
| 499 | void bfa_fcs_rpf_rport_online(struct bfa_fcs_rport_s *rport); |
| 500 | void bfa_fcs_rpf_rport_offline(struct bfa_fcs_rport_s *rport); |
| 501 | |
| 502 | /* |
| 503 | * forward declarations |
| 504 | */ |
| 505 | struct bfad_itnim_s; |
| 506 | |
| 507 | struct bfa_fcs_itnim_s { |
| 508 | bfa_sm_t sm; /* state machine */ |
| 509 | struct bfa_fcs_rport_s *rport; /* parent remote rport */ |
| 510 | struct bfad_itnim_s *itnim_drv; /* driver peer instance */ |
| 511 | struct bfa_fcs_s *fcs; /* fcs instance */ |
| 512 | struct bfa_timer_s timer; /* timer functions */ |
| 513 | struct bfa_itnim_s *bfa_itnim; /* BFA itnim struct */ |
| 514 | u32 prli_retries; /* max prli retry attempts */ |
| 515 | bfa_boolean_t seq_rec; /* seq recovery support */ |
| 516 | bfa_boolean_t rec_support; /* REC supported */ |
| 517 | bfa_boolean_t conf_comp; /* FCP_CONF support */ |
| 518 | bfa_boolean_t task_retry_id; /* task retry id supp */ |
| 519 | struct bfa_fcxp_wqe_s fcxp_wqe; /* wait qelem for fcxp */ |
| 520 | struct bfa_fcxp_s *fcxp; /* FCXP in use */ |
| 521 | struct bfa_itnim_stats_s stats; /* itn statistics */ |
| 522 | }; |
Krishna Gudipati | c3f1b12 | 2012-08-22 19:51:08 -0700 | [diff] [blame] | 523 | #define bfa_fcs_fcxp_alloc(__fcs, __req) \ |
| 524 | bfa_fcxp_req_rsp_alloc(NULL, (__fcs)->bfa, 0, 0, \ |
| 525 | NULL, NULL, NULL, NULL, __req) |
| 526 | #define bfa_fcs_fcxp_alloc_wait(__bfa, __wqe, __alloc_cbfn, \ |
| 527 | __alloc_cbarg, __req) \ |
| 528 | bfa_fcxp_req_rsp_alloc_wait(__bfa, __wqe, __alloc_cbfn, \ |
| 529 | __alloc_cbarg, NULL, 0, 0, NULL, NULL, NULL, NULL, __req) |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 530 | |
| 531 | static inline struct bfad_port_s * |
| 532 | bfa_fcs_itnim_get_drvport(struct bfa_fcs_itnim_s *itnim) |
| 533 | { |
| 534 | return itnim->rport->port->bfad_port; |
| 535 | } |
| 536 | |
| 537 | |
| 538 | static inline struct bfa_fcs_lport_s * |
| 539 | bfa_fcs_itnim_get_port(struct bfa_fcs_itnim_s *itnim) |
| 540 | { |
| 541 | return itnim->rport->port; |
| 542 | } |
| 543 | |
| 544 | |
| 545 | static inline wwn_t |
| 546 | bfa_fcs_itnim_get_nwwn(struct bfa_fcs_itnim_s *itnim) |
| 547 | { |
| 548 | return itnim->rport->nwwn; |
| 549 | } |
| 550 | |
| 551 | |
| 552 | static inline wwn_t |
| 553 | bfa_fcs_itnim_get_pwwn(struct bfa_fcs_itnim_s *itnim) |
| 554 | { |
| 555 | return itnim->rport->pwwn; |
| 556 | } |
| 557 | |
| 558 | |
| 559 | static inline u32 |
| 560 | bfa_fcs_itnim_get_fcid(struct bfa_fcs_itnim_s *itnim) |
| 561 | { |
| 562 | return itnim->rport->pid; |
| 563 | } |
| 564 | |
| 565 | |
| 566 | static inline u32 |
| 567 | bfa_fcs_itnim_get_maxfrsize(struct bfa_fcs_itnim_s *itnim) |
| 568 | { |
| 569 | return itnim->rport->maxfrsize; |
| 570 | } |
| 571 | |
| 572 | |
| 573 | static inline enum fc_cos |
| 574 | bfa_fcs_itnim_get_cos(struct bfa_fcs_itnim_s *itnim) |
| 575 | { |
| 576 | return itnim->rport->fc_cos; |
| 577 | } |
| 578 | |
| 579 | |
| 580 | static inline struct bfad_itnim_s * |
| 581 | bfa_fcs_itnim_get_drvitn(struct bfa_fcs_itnim_s *itnim) |
| 582 | { |
| 583 | return itnim->itnim_drv; |
| 584 | } |
| 585 | |
| 586 | |
| 587 | static inline struct bfa_itnim_s * |
| 588 | bfa_fcs_itnim_get_halitn(struct bfa_fcs_itnim_s *itnim) |
| 589 | { |
| 590 | return itnim->bfa_itnim; |
| 591 | } |
| 592 | |
Jing Huang | acdc79a | 2010-10-18 17:15:55 -0700 | [diff] [blame] | 593 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 594 | * bfa fcs FCP Initiator mode API functions |
| 595 | */ |
| 596 | void bfa_fcs_itnim_get_attr(struct bfa_fcs_itnim_s *itnim, |
| 597 | struct bfa_itnim_attr_s *attr); |
| 598 | void bfa_fcs_itnim_get_stats(struct bfa_fcs_itnim_s *itnim, |
| 599 | struct bfa_itnim_stats_s *stats); |
| 600 | struct bfa_fcs_itnim_s *bfa_fcs_itnim_lookup(struct bfa_fcs_lport_s *port, |
| 601 | wwn_t rpwwn); |
| 602 | bfa_status_t bfa_fcs_itnim_attr_get(struct bfa_fcs_lport_s *port, wwn_t rpwwn, |
| 603 | struct bfa_itnim_attr_s *attr); |
| 604 | bfa_status_t bfa_fcs_itnim_stats_get(struct bfa_fcs_lport_s *port, wwn_t rpwwn, |
| 605 | struct bfa_itnim_stats_s *stats); |
| 606 | bfa_status_t bfa_fcs_itnim_stats_clear(struct bfa_fcs_lport_s *port, |
| 607 | wwn_t rpwwn); |
| 608 | struct bfa_fcs_itnim_s *bfa_fcs_itnim_create(struct bfa_fcs_rport_s *rport); |
| 609 | void bfa_fcs_itnim_delete(struct bfa_fcs_itnim_s *itnim); |
| 610 | void bfa_fcs_itnim_rport_offline(struct bfa_fcs_itnim_s *itnim); |
Krishna Gudipati | 61ba439 | 2012-08-22 19:52:58 -0700 | [diff] [blame] | 611 | void bfa_fcs_itnim_brp_online(struct bfa_fcs_itnim_s *itnim); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 612 | bfa_status_t bfa_fcs_itnim_get_online_state(struct bfa_fcs_itnim_s *itnim); |
| 613 | void bfa_fcs_itnim_is_initiator(struct bfa_fcs_itnim_s *itnim); |
| 614 | void bfa_fcs_fcpim_uf_recv(struct bfa_fcs_itnim_s *itnim, |
| 615 | struct fchs_s *fchs, u16 len); |
| 616 | |
Krishna Gudipati | d7be54c | 2011-06-24 20:24:52 -0700 | [diff] [blame] | 617 | #define BFA_FCS_FDMI_SUPP_SPEEDS_4G (FDMI_TRANS_SPEED_1G | \ |
| 618 | FDMI_TRANS_SPEED_2G | \ |
| 619 | FDMI_TRANS_SPEED_4G) |
| 620 | |
| 621 | #define BFA_FCS_FDMI_SUPP_SPEEDS_8G (FDMI_TRANS_SPEED_1G | \ |
| 622 | FDMI_TRANS_SPEED_2G | \ |
| 623 | FDMI_TRANS_SPEED_4G | \ |
| 624 | FDMI_TRANS_SPEED_8G) |
| 625 | |
| 626 | #define BFA_FCS_FDMI_SUPP_SPEEDS_16G (FDMI_TRANS_SPEED_2G | \ |
| 627 | FDMI_TRANS_SPEED_4G | \ |
| 628 | FDMI_TRANS_SPEED_8G | \ |
| 629 | FDMI_TRANS_SPEED_16G) |
| 630 | |
| 631 | #define BFA_FCS_FDMI_SUPP_SPEEDS_10G FDMI_TRANS_SPEED_10G |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 632 | |
| 633 | /* |
| 634 | * HBA Attribute Block : BFA internal representation. Note : Some variable |
| 635 | * sizes have been trimmed to suit BFA For Ex : Model will be "Brocade". Based |
| 636 | * on this the size has been reduced to 16 bytes from the standard's 64 bytes. |
| 637 | */ |
| 638 | struct bfa_fcs_fdmi_hba_attr_s { |
| 639 | wwn_t node_name; |
| 640 | u8 manufacturer[64]; |
| 641 | u8 serial_num[64]; |
| 642 | u8 model[16]; |
| 643 | u8 model_desc[256]; |
| 644 | u8 hw_version[8]; |
Krishna Gudipati | b480a32 | 2012-09-21 17:25:20 -0700 | [diff] [blame^] | 645 | u8 driver_version[BFA_VERSION_LEN]; |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 646 | u8 option_rom_ver[BFA_VERSION_LEN]; |
Krishna Gudipati | b480a32 | 2012-09-21 17:25:20 -0700 | [diff] [blame^] | 647 | u8 fw_version[BFA_VERSION_LEN]; |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 648 | u8 os_name[256]; |
Maggie | 50444a3 | 2010-11-29 18:26:32 -0800 | [diff] [blame] | 649 | __be32 max_ct_pyld; |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 650 | }; |
| 651 | |
| 652 | /* |
| 653 | * Port Attribute Block |
| 654 | */ |
| 655 | struct bfa_fcs_fdmi_port_attr_s { |
| 656 | u8 supp_fc4_types[32]; /* supported FC4 types */ |
Maggie | 50444a3 | 2010-11-29 18:26:32 -0800 | [diff] [blame] | 657 | __be32 supp_speed; /* supported speed */ |
| 658 | __be32 curr_speed; /* current Speed */ |
| 659 | __be32 max_frm_size; /* max frame size */ |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 660 | u8 os_device_name[256]; /* OS device Name */ |
| 661 | u8 host_name[256]; /* host name */ |
| 662 | }; |
| 663 | |
| 664 | struct bfa_fcs_stats_s { |
| 665 | struct { |
| 666 | u32 untagged; /* untagged receive frames */ |
| 667 | u32 tagged; /* tagged receive frames */ |
| 668 | u32 vfid_unknown; /* VF id is unknown */ |
| 669 | } uf; |
| 670 | }; |
| 671 | |
| 672 | struct bfa_fcs_driver_info_s { |
| 673 | u8 version[BFA_VERSION_LEN]; /* Driver Version */ |
| 674 | u8 host_machine_name[BFA_FCS_OS_STR_LEN]; |
| 675 | u8 host_os_name[BFA_FCS_OS_STR_LEN]; /* OS name and version */ |
| 676 | u8 host_os_patch[BFA_FCS_OS_STR_LEN]; /* patch or service pack */ |
| 677 | u8 os_device_name[BFA_FCS_OS_STR_LEN]; /* Driver Device Name */ |
| 678 | }; |
| 679 | |
| 680 | struct bfa_fcs_s { |
| 681 | struct bfa_s *bfa; /* corresponding BFA bfa instance */ |
| 682 | struct bfad_s *bfad; /* corresponding BDA driver instance */ |
| 683 | struct bfa_trc_mod_s *trcmod; /* tracing module */ |
| 684 | bfa_boolean_t vf_enabled; /* VF mode is enabled */ |
| 685 | bfa_boolean_t fdmi_enabled; /* FDMI is enabled */ |
Krishna Gudipati | be540a9 | 2011-06-13 15:53:04 -0700 | [diff] [blame] | 686 | bfa_boolean_t bbscn_enabled; /* Driver Config Parameter */ |
| 687 | bfa_boolean_t bbscn_flogi_rjt;/* FLOGI reject due to BB_SCN */ |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 688 | bfa_boolean_t min_cfg; /* min cfg enabled/disabled */ |
| 689 | u16 port_vfid; /* port default VF ID */ |
| 690 | struct bfa_fcs_driver_info_s driver_info; |
| 691 | struct bfa_fcs_fabric_s fabric; /* base fabric state machine */ |
| 692 | struct bfa_fcs_stats_s stats; /* FCS statistics */ |
| 693 | struct bfa_wc_s wc; /* waiting counter */ |
Krishna Gudipati | 7826f30 | 2011-07-20 16:59:13 -0700 | [diff] [blame] | 694 | int fcs_aen_seq; |
Krishna Gudipati | 61ba439 | 2012-08-22 19:52:58 -0700 | [diff] [blame] | 695 | u32 num_rport_logins; |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 696 | }; |
| 697 | |
| 698 | /* |
Maggie Zhang | f7f73812 | 2010-12-09 19:08:43 -0800 | [diff] [blame] | 699 | * fcs_fabric_sm fabric state machine functions |
| 700 | */ |
| 701 | |
| 702 | /* |
| 703 | * Fabric state machine events |
| 704 | */ |
| 705 | enum bfa_fcs_fabric_event { |
| 706 | BFA_FCS_FABRIC_SM_CREATE = 1, /* create from driver */ |
| 707 | BFA_FCS_FABRIC_SM_DELETE = 2, /* delete from driver */ |
| 708 | BFA_FCS_FABRIC_SM_LINK_DOWN = 3, /* link down from port */ |
| 709 | BFA_FCS_FABRIC_SM_LINK_UP = 4, /* link up from port */ |
| 710 | BFA_FCS_FABRIC_SM_CONT_OP = 5, /* flogi/auth continue op */ |
| 711 | BFA_FCS_FABRIC_SM_RETRY_OP = 6, /* flogi/auth retry op */ |
| 712 | BFA_FCS_FABRIC_SM_NO_FABRIC = 7, /* from flogi/auth */ |
| 713 | BFA_FCS_FABRIC_SM_PERF_EVFP = 8, /* from flogi/auth */ |
| 714 | BFA_FCS_FABRIC_SM_ISOLATE = 9, /* from EVFP processing */ |
| 715 | BFA_FCS_FABRIC_SM_NO_TAGGING = 10, /* no VFT tagging from EVFP */ |
| 716 | BFA_FCS_FABRIC_SM_DELAYED = 11, /* timeout delay event */ |
| 717 | BFA_FCS_FABRIC_SM_AUTH_FAILED = 12, /* auth failed */ |
| 718 | BFA_FCS_FABRIC_SM_AUTH_SUCCESS = 13, /* auth successful */ |
| 719 | BFA_FCS_FABRIC_SM_DELCOMP = 14, /* all vports deleted event */ |
| 720 | BFA_FCS_FABRIC_SM_LOOPBACK = 15, /* Received our own FLOGI */ |
| 721 | BFA_FCS_FABRIC_SM_START = 16, /* from driver */ |
Krishna Gudipati | 881c1b3 | 2012-08-22 19:52:02 -0700 | [diff] [blame] | 722 | BFA_FCS_FABRIC_SM_STOP = 17, /* Stop from driver */ |
| 723 | BFA_FCS_FABRIC_SM_STOPCOMP = 18, /* Stop completion */ |
| 724 | BFA_FCS_FABRIC_SM_LOGOCOMP = 19, /* FLOGO completion */ |
Maggie Zhang | f7f73812 | 2010-12-09 19:08:43 -0800 | [diff] [blame] | 725 | }; |
| 726 | |
| 727 | /* |
| 728 | * fcs_rport_sm FCS rport state machine events |
| 729 | */ |
| 730 | |
| 731 | enum rport_event { |
| 732 | RPSM_EVENT_PLOGI_SEND = 1, /* new rport; start with PLOGI */ |
| 733 | RPSM_EVENT_PLOGI_RCVD = 2, /* Inbound PLOGI from remote port */ |
| 734 | RPSM_EVENT_PLOGI_COMP = 3, /* PLOGI completed to rport */ |
| 735 | RPSM_EVENT_LOGO_RCVD = 4, /* LOGO from remote device */ |
| 736 | RPSM_EVENT_LOGO_IMP = 5, /* implicit logo for SLER */ |
| 737 | RPSM_EVENT_FCXP_SENT = 6, /* Frame from has been sent */ |
| 738 | RPSM_EVENT_DELETE = 7, /* RPORT delete request */ |
Krishna Gudipati | bc0e2c2 | 2012-09-21 17:23:59 -0700 | [diff] [blame] | 739 | RPSM_EVENT_FAB_SCN = 8, /* state change notification */ |
Maggie Zhang | f7f73812 | 2010-12-09 19:08:43 -0800 | [diff] [blame] | 740 | RPSM_EVENT_ACCEPTED = 9, /* Good response from remote device */ |
| 741 | RPSM_EVENT_FAILED = 10, /* Request to rport failed. */ |
| 742 | RPSM_EVENT_TIMEOUT = 11, /* Rport SM timeout event */ |
| 743 | RPSM_EVENT_HCB_ONLINE = 12, /* BFA rport online callback */ |
| 744 | RPSM_EVENT_HCB_OFFLINE = 13, /* BFA rport offline callback */ |
| 745 | RPSM_EVENT_FC4_OFFLINE = 14, /* FC-4 offline complete */ |
| 746 | RPSM_EVENT_ADDRESS_CHANGE = 15, /* Rport's PID has changed */ |
| 747 | RPSM_EVENT_ADDRESS_DISC = 16, /* Need to Discover rport's PID */ |
| 748 | RPSM_EVENT_PRLO_RCVD = 17, /* PRLO from remote device */ |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 749 | RPSM_EVENT_PLOGI_RETRY = 18, /* Retry PLOGI continuously */ |
Krishna Gudipati | bc0e2c2 | 2012-09-21 17:23:59 -0700 | [diff] [blame] | 750 | RPSM_EVENT_SCN_OFFLINE = 19, /* loop scn offline */ |
| 751 | RPSM_EVENT_SCN_ONLINE = 20, /* loop scn online */ |
| 752 | RPSM_EVENT_FC4_FCS_ONLINE = 21, /* FC-4 FCS online complete */ |
Krishna Gudipati | 61ba439 | 2012-08-22 19:52:58 -0700 | [diff] [blame] | 753 | }; |
| 754 | |
| 755 | /* |
| 756 | * fcs_itnim_sm FCS itnim state machine events |
| 757 | */ |
| 758 | enum bfa_fcs_itnim_event { |
| 759 | BFA_FCS_ITNIM_SM_FCS_ONLINE = 1, /* rport online event */ |
| 760 | BFA_FCS_ITNIM_SM_OFFLINE = 2, /* rport offline */ |
| 761 | BFA_FCS_ITNIM_SM_FRMSENT = 3, /* prli frame is sent */ |
| 762 | BFA_FCS_ITNIM_SM_RSP_OK = 4, /* good response */ |
| 763 | BFA_FCS_ITNIM_SM_RSP_ERROR = 5, /* error response */ |
| 764 | BFA_FCS_ITNIM_SM_TIMEOUT = 6, /* delay timeout */ |
| 765 | BFA_FCS_ITNIM_SM_HCB_OFFLINE = 7, /* BFA online callback */ |
| 766 | BFA_FCS_ITNIM_SM_HCB_ONLINE = 8, /* BFA offline callback */ |
| 767 | BFA_FCS_ITNIM_SM_INITIATOR = 9, /* rport is initiator */ |
| 768 | BFA_FCS_ITNIM_SM_DELETE = 10, /* delete event from rport */ |
| 769 | BFA_FCS_ITNIM_SM_PRLO = 11, /* delete event from rport */ |
| 770 | BFA_FCS_ITNIM_SM_RSP_NOT_SUPP = 12, /* cmd not supported rsp */ |
Krishna Gudipati | bc0e2c2 | 2012-09-21 17:23:59 -0700 | [diff] [blame] | 771 | BFA_FCS_ITNIM_SM_HAL_ONLINE = 13, /* bfa rport online event */ |
Maggie Zhang | f7f73812 | 2010-12-09 19:08:43 -0800 | [diff] [blame] | 772 | }; |
| 773 | |
| 774 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 775 | * bfa fcs API functions |
| 776 | */ |
| 777 | void bfa_fcs_attach(struct bfa_fcs_s *fcs, struct bfa_s *bfa, |
| 778 | struct bfad_s *bfad, |
| 779 | bfa_boolean_t min_cfg); |
| 780 | void bfa_fcs_init(struct bfa_fcs_s *fcs); |
Krishna Gudipati | 75332a7 | 2011-06-13 15:54:31 -0700 | [diff] [blame] | 781 | void bfa_fcs_pbc_vport_init(struct bfa_fcs_s *fcs); |
| 782 | void bfa_fcs_update_cfg(struct bfa_fcs_s *fcs); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 783 | void bfa_fcs_driver_info_init(struct bfa_fcs_s *fcs, |
| 784 | struct bfa_fcs_driver_info_s *driver_info); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 785 | void bfa_fcs_exit(struct bfa_fcs_s *fcs); |
Krishna Gudipati | 881c1b3 | 2012-08-22 19:52:02 -0700 | [diff] [blame] | 786 | void bfa_fcs_stop(struct bfa_fcs_s *fcs); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 787 | |
Jing Huang | acdc79a | 2010-10-18 17:15:55 -0700 | [diff] [blame] | 788 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 789 | * bfa fcs vf public functions |
| 790 | */ |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 791 | bfa_fcs_vf_t *bfa_fcs_vf_lookup(struct bfa_fcs_s *fcs, u16 vf_id); |
Krishna Gudipati | b85daaf | 2011-06-13 15:55:11 -0700 | [diff] [blame] | 792 | void bfa_fcs_vf_get_ports(bfa_fcs_vf_t *vf, wwn_t vpwwn[], int *nports); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 793 | |
| 794 | /* |
| 795 | * fabric protected interface functions |
| 796 | */ |
| 797 | void bfa_fcs_fabric_attach(struct bfa_fcs_s *fcs); |
| 798 | void bfa_fcs_fabric_modinit(struct bfa_fcs_s *fcs); |
| 799 | void bfa_fcs_fabric_modexit(struct bfa_fcs_s *fcs); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 800 | void bfa_fcs_fabric_link_up(struct bfa_fcs_fabric_s *fabric); |
| 801 | void bfa_fcs_fabric_link_down(struct bfa_fcs_fabric_s *fabric); |
| 802 | void bfa_fcs_fabric_addvport(struct bfa_fcs_fabric_s *fabric, |
| 803 | struct bfa_fcs_vport_s *vport); |
| 804 | void bfa_fcs_fabric_delvport(struct bfa_fcs_fabric_s *fabric, |
| 805 | struct bfa_fcs_vport_s *vport); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 806 | struct bfa_fcs_vport_s *bfa_fcs_fabric_vport_lookup( |
| 807 | struct bfa_fcs_fabric_s *fabric, wwn_t pwwn); |
| 808 | void bfa_fcs_fabric_modstart(struct bfa_fcs_s *fcs); |
| 809 | void bfa_fcs_fabric_uf_recv(struct bfa_fcs_fabric_s *fabric, |
| 810 | struct fchs_s *fchs, u16 len); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 811 | void bfa_fcs_fabric_psymb_init(struct bfa_fcs_fabric_s *fabric); |
Krishna Gudipati | ce7242b | 2012-08-22 19:52:43 -0700 | [diff] [blame] | 812 | void bfa_fcs_fabric_nsymb_init(struct bfa_fcs_fabric_s *fabric); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 813 | void bfa_fcs_fabric_set_fabric_name(struct bfa_fcs_fabric_s *fabric, |
| 814 | wwn_t fabric_name); |
| 815 | u16 bfa_fcs_fabric_get_switch_oui(struct bfa_fcs_fabric_s *fabric); |
| 816 | void bfa_fcs_uf_attach(struct bfa_fcs_s *fcs); |
| 817 | void bfa_fcs_port_attach(struct bfa_fcs_s *fcs); |
Krishna Gudipati | 881c1b3 | 2012-08-22 19:52:02 -0700 | [diff] [blame] | 818 | void bfa_fcs_fabric_modstop(struct bfa_fcs_s *fcs); |
Maggie Zhang | f7f73812 | 2010-12-09 19:08:43 -0800 | [diff] [blame] | 819 | void bfa_fcs_fabric_sm_online(struct bfa_fcs_fabric_s *fabric, |
| 820 | enum bfa_fcs_fabric_event event); |
| 821 | void bfa_fcs_fabric_sm_loopback(struct bfa_fcs_fabric_s *fabric, |
| 822 | enum bfa_fcs_fabric_event event); |
| 823 | void bfa_fcs_fabric_sm_auth_failed(struct bfa_fcs_fabric_s *fabric, |
| 824 | enum bfa_fcs_fabric_event event); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 825 | |
Jing Huang | acdc79a | 2010-10-18 17:15:55 -0700 | [diff] [blame] | 826 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 827 | * BFA FCS callback interfaces |
| 828 | */ |
| 829 | |
Jing Huang | acdc79a | 2010-10-18 17:15:55 -0700 | [diff] [blame] | 830 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 831 | * fcb Main fcs callbacks |
| 832 | */ |
| 833 | |
| 834 | struct bfad_port_s; |
| 835 | struct bfad_vf_s; |
| 836 | struct bfad_vport_s; |
| 837 | struct bfad_rport_s; |
| 838 | |
Jing Huang | acdc79a | 2010-10-18 17:15:55 -0700 | [diff] [blame] | 839 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 840 | * lport callbacks |
| 841 | */ |
| 842 | struct bfad_port_s *bfa_fcb_lport_new(struct bfad_s *bfad, |
| 843 | struct bfa_fcs_lport_s *port, |
| 844 | enum bfa_lport_role roles, |
| 845 | struct bfad_vf_s *vf_drv, |
| 846 | struct bfad_vport_s *vp_drv); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 847 | |
Jing Huang | acdc79a | 2010-10-18 17:15:55 -0700 | [diff] [blame] | 848 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 849 | * vport callbacks |
| 850 | */ |
| 851 | void bfa_fcb_pbc_vport_create(struct bfad_s *bfad, struct bfi_pbc_vport_s); |
| 852 | |
Jing Huang | acdc79a | 2010-10-18 17:15:55 -0700 | [diff] [blame] | 853 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 854 | * rport callbacks |
| 855 | */ |
| 856 | bfa_status_t bfa_fcb_rport_alloc(struct bfad_s *bfad, |
| 857 | struct bfa_fcs_rport_s **rport, |
| 858 | struct bfad_rport_s **rport_drv); |
| 859 | |
Jing Huang | acdc79a | 2010-10-18 17:15:55 -0700 | [diff] [blame] | 860 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 861 | * itnim callbacks |
| 862 | */ |
| 863 | void bfa_fcb_itnim_alloc(struct bfad_s *bfad, struct bfa_fcs_itnim_s **itnim, |
| 864 | struct bfad_itnim_s **itnim_drv); |
| 865 | void bfa_fcb_itnim_free(struct bfad_s *bfad, |
| 866 | struct bfad_itnim_s *itnim_drv); |
| 867 | void bfa_fcb_itnim_online(struct bfad_itnim_s *itnim_drv); |
| 868 | void bfa_fcb_itnim_offline(struct bfad_itnim_s *itnim_drv); |
| 869 | |
| 870 | #endif /* __BFA_FCS_H__ */ |