bfa_fcs.h 29 KB

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