bfa_fcs.h 26 KB

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