bfa_fcs.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746
  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. __be16 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_ns_init(struct bfa_fcs_lport_s *vport);
  272. void bfa_fcs_lport_ns_offline(struct bfa_fcs_lport_s *vport);
  273. void bfa_fcs_lport_ns_online(struct bfa_fcs_lport_s *vport);
  274. void bfa_fcs_lport_ns_query(struct bfa_fcs_lport_s *port);
  275. void bfa_fcs_lport_scn_init(struct bfa_fcs_lport_s *vport);
  276. void bfa_fcs_lport_scn_offline(struct bfa_fcs_lport_s *vport);
  277. void bfa_fcs_lport_scn_online(struct bfa_fcs_lport_s *vport);
  278. void bfa_fcs_lport_scn_process_rscn(struct bfa_fcs_lport_s *port,
  279. struct fchs_s *rx_frame, u32 len);
  280. struct bfa_fcs_vport_s {
  281. struct list_head qe; /* queue elem */
  282. bfa_sm_t sm; /* state machine */
  283. bfa_fcs_lport_t lport; /* logical port */
  284. struct bfa_timer_s timer;
  285. struct bfad_vport_s *vport_drv; /* Driver private */
  286. struct bfa_vport_stats_s vport_stats; /* vport statistics */
  287. struct bfa_lps_s *lps; /* Lport login service*/
  288. int fdisc_retries;
  289. };
  290. #define bfa_fcs_vport_get_port(vport) \
  291. ((struct bfa_fcs_lport_s *)(&vport->port))
  292. /*
  293. * bfa fcs vport public functions
  294. */
  295. bfa_status_t bfa_fcs_vport_create(struct bfa_fcs_vport_s *vport,
  296. struct bfa_fcs_s *fcs, u16 vf_id,
  297. struct bfa_lport_cfg_s *port_cfg,
  298. struct bfad_vport_s *vport_drv);
  299. bfa_status_t bfa_fcs_pbc_vport_create(struct bfa_fcs_vport_s *vport,
  300. struct bfa_fcs_s *fcs, u16 vf_id,
  301. struct bfa_lport_cfg_s *port_cfg,
  302. struct bfad_vport_s *vport_drv);
  303. bfa_boolean_t bfa_fcs_is_pbc_vport(struct bfa_fcs_vport_s *vport);
  304. bfa_status_t bfa_fcs_vport_delete(struct bfa_fcs_vport_s *vport);
  305. bfa_status_t bfa_fcs_vport_start(struct bfa_fcs_vport_s *vport);
  306. bfa_status_t bfa_fcs_vport_stop(struct bfa_fcs_vport_s *vport);
  307. void bfa_fcs_vport_get_attr(struct bfa_fcs_vport_s *vport,
  308. struct bfa_vport_attr_s *vport_attr);
  309. struct bfa_fcs_vport_s *bfa_fcs_vport_lookup(struct bfa_fcs_s *fcs,
  310. u16 vf_id, wwn_t vpwwn);
  311. void bfa_fcs_vport_cleanup(struct bfa_fcs_vport_s *vport);
  312. void bfa_fcs_vport_online(struct bfa_fcs_vport_s *vport);
  313. void bfa_fcs_vport_offline(struct bfa_fcs_vport_s *vport);
  314. void bfa_fcs_vport_delete_comp(struct bfa_fcs_vport_s *vport);
  315. void bfa_fcs_vport_fcs_delete(struct bfa_fcs_vport_s *vport);
  316. #define BFA_FCS_RPORT_DEF_DEL_TIMEOUT 90 /* in secs */
  317. #define BFA_FCS_RPORT_MAX_RETRIES (5)
  318. /*
  319. * forward declarations
  320. */
  321. struct bfad_rport_s;
  322. struct bfa_fcs_itnim_s;
  323. struct bfa_fcs_tin_s;
  324. struct bfa_fcs_iprp_s;
  325. /* Rport Features (RPF) */
  326. struct bfa_fcs_rpf_s {
  327. bfa_sm_t sm; /* state machine */
  328. struct bfa_fcs_rport_s *rport; /* parent rport */
  329. struct bfa_timer_s timer; /* general purpose timer */
  330. struct bfa_fcxp_s *fcxp; /* FCXP needed for discarding */
  331. struct bfa_fcxp_wqe_s fcxp_wqe; /* fcxp wait queue element */
  332. int rpsc_retries; /* max RPSC retry attempts */
  333. enum bfa_port_speed rpsc_speed;
  334. /* Current Speed from RPSC. O if RPSC fails */
  335. enum bfa_port_speed assigned_speed;
  336. /*
  337. * Speed assigned by the user. will be used if RPSC is
  338. * not supported by the rport.
  339. */
  340. };
  341. struct bfa_fcs_rport_s {
  342. struct list_head qe; /* used by port/vport */
  343. struct bfa_fcs_lport_s *port; /* parent FCS port */
  344. struct bfa_fcs_s *fcs; /* fcs instance */
  345. struct bfad_rport_s *rp_drv; /* driver peer instance */
  346. u32 pid; /* port ID of rport */
  347. u16 maxfrsize; /* maximum frame size */
  348. __be16 reply_oxid; /* OX_ID of inbound requests */
  349. enum fc_cos fc_cos; /* FC classes of service supp */
  350. bfa_boolean_t cisc; /* CISC capable device */
  351. bfa_boolean_t prlo; /* processing prlo or LOGO */
  352. wwn_t pwwn; /* port wwn of rport */
  353. wwn_t nwwn; /* node wwn of rport */
  354. struct bfa_rport_symname_s psym_name; /* port symbolic name */
  355. bfa_sm_t sm; /* state machine */
  356. struct bfa_timer_s timer; /* general purpose timer */
  357. struct bfa_fcs_itnim_s *itnim; /* ITN initiator mode role */
  358. struct bfa_fcs_tin_s *tin; /* ITN initiator mode role */
  359. struct bfa_fcs_iprp_s *iprp; /* IP/FC role */
  360. struct bfa_rport_s *bfa_rport; /* BFA Rport */
  361. struct bfa_fcxp_s *fcxp; /* FCXP needed for discarding */
  362. int plogi_retries; /* max plogi retry attempts */
  363. int ns_retries; /* max NS query retry attempts */
  364. struct bfa_fcxp_wqe_s fcxp_wqe; /* fcxp wait queue element */
  365. struct bfa_rport_stats_s stats; /* rport stats */
  366. enum bfa_rport_function scsi_function; /* Initiator/Target */
  367. struct bfa_fcs_rpf_s rpf; /* Rport features module */
  368. };
  369. static inline struct bfa_rport_s *
  370. bfa_fcs_rport_get_halrport(struct bfa_fcs_rport_s *rport)
  371. {
  372. return rport->bfa_rport;
  373. }
  374. /*
  375. * bfa fcs rport API functions
  376. */
  377. struct bfa_fcs_rport_s *bfa_fcs_rport_lookup(struct bfa_fcs_lport_s *port,
  378. wwn_t rpwwn);
  379. struct bfa_fcs_rport_s *bfa_fcs_rport_lookup_by_nwwn(
  380. struct bfa_fcs_lport_s *port, wwn_t rnwwn);
  381. void bfa_fcs_rport_set_del_timeout(u8 rport_tmo);
  382. void bfa_fcs_rport_uf_recv(struct bfa_fcs_rport_s *rport,
  383. struct fchs_s *fchs, u16 len);
  384. void bfa_fcs_rport_scn(struct bfa_fcs_rport_s *rport);
  385. struct bfa_fcs_rport_s *bfa_fcs_rport_create(struct bfa_fcs_lport_s *port,
  386. u32 pid);
  387. void bfa_fcs_rport_delete(struct bfa_fcs_rport_s *rport);
  388. void bfa_fcs_rport_online(struct bfa_fcs_rport_s *rport);
  389. void bfa_fcs_rport_offline(struct bfa_fcs_rport_s *rport);
  390. void bfa_fcs_rport_start(struct bfa_fcs_lport_s *port, struct fchs_s *rx_fchs,
  391. struct fc_logi_s *plogi_rsp);
  392. void bfa_fcs_rport_plogi_create(struct bfa_fcs_lport_s *port,
  393. struct fchs_s *rx_fchs,
  394. struct fc_logi_s *plogi);
  395. void bfa_fcs_rport_plogi(struct bfa_fcs_rport_s *rport, struct fchs_s *fchs,
  396. struct fc_logi_s *plogi);
  397. void bfa_fcs_rport_logo_imp(struct bfa_fcs_rport_s *rport);
  398. void bfa_fcs_rport_prlo(struct bfa_fcs_rport_s *rport, __be16 ox_id);
  399. void bfa_fcs_rport_itnim_ack(struct bfa_fcs_rport_s *rport);
  400. void bfa_fcs_rport_itntm_ack(struct bfa_fcs_rport_s *rport);
  401. void bfa_fcs_rport_fcptm_offline_done(struct bfa_fcs_rport_s *rport);
  402. int bfa_fcs_rport_get_state(struct bfa_fcs_rport_s *rport);
  403. struct bfa_fcs_rport_s *bfa_fcs_rport_create_by_wwn(
  404. struct bfa_fcs_lport_s *port, wwn_t wwn);
  405. void bfa_fcs_rpf_init(struct bfa_fcs_rport_s *rport);
  406. void bfa_fcs_rpf_rport_online(struct bfa_fcs_rport_s *rport);
  407. void bfa_fcs_rpf_rport_offline(struct bfa_fcs_rport_s *rport);
  408. /*
  409. * forward declarations
  410. */
  411. struct bfad_itnim_s;
  412. struct bfa_fcs_itnim_s {
  413. bfa_sm_t sm; /* state machine */
  414. struct bfa_fcs_rport_s *rport; /* parent remote rport */
  415. struct bfad_itnim_s *itnim_drv; /* driver peer instance */
  416. struct bfa_fcs_s *fcs; /* fcs instance */
  417. struct bfa_timer_s timer; /* timer functions */
  418. struct bfa_itnim_s *bfa_itnim; /* BFA itnim struct */
  419. u32 prli_retries; /* max prli retry attempts */
  420. bfa_boolean_t seq_rec; /* seq recovery support */
  421. bfa_boolean_t rec_support; /* REC supported */
  422. bfa_boolean_t conf_comp; /* FCP_CONF support */
  423. bfa_boolean_t task_retry_id; /* task retry id supp */
  424. struct bfa_fcxp_wqe_s fcxp_wqe; /* wait qelem for fcxp */
  425. struct bfa_fcxp_s *fcxp; /* FCXP in use */
  426. struct bfa_itnim_stats_s stats; /* itn statistics */
  427. };
  428. #define bfa_fcs_fcxp_alloc(__fcs) \
  429. bfa_fcxp_alloc(NULL, (__fcs)->bfa, 0, 0, NULL, NULL, NULL, NULL)
  430. #define bfa_fcs_fcxp_alloc_wait(__bfa, __wqe, __alloc_cbfn, __alloc_cbarg) \
  431. bfa_fcxp_alloc_wait(__bfa, __wqe, __alloc_cbfn, __alloc_cbarg, \
  432. NULL, 0, 0, NULL, NULL, NULL, NULL)
  433. static inline struct bfad_port_s *
  434. bfa_fcs_itnim_get_drvport(struct bfa_fcs_itnim_s *itnim)
  435. {
  436. return itnim->rport->port->bfad_port;
  437. }
  438. static inline struct bfa_fcs_lport_s *
  439. bfa_fcs_itnim_get_port(struct bfa_fcs_itnim_s *itnim)
  440. {
  441. return itnim->rport->port;
  442. }
  443. static inline wwn_t
  444. bfa_fcs_itnim_get_nwwn(struct bfa_fcs_itnim_s *itnim)
  445. {
  446. return itnim->rport->nwwn;
  447. }
  448. static inline wwn_t
  449. bfa_fcs_itnim_get_pwwn(struct bfa_fcs_itnim_s *itnim)
  450. {
  451. return itnim->rport->pwwn;
  452. }
  453. static inline u32
  454. bfa_fcs_itnim_get_fcid(struct bfa_fcs_itnim_s *itnim)
  455. {
  456. return itnim->rport->pid;
  457. }
  458. static inline u32
  459. bfa_fcs_itnim_get_maxfrsize(struct bfa_fcs_itnim_s *itnim)
  460. {
  461. return itnim->rport->maxfrsize;
  462. }
  463. static inline enum fc_cos
  464. bfa_fcs_itnim_get_cos(struct bfa_fcs_itnim_s *itnim)
  465. {
  466. return itnim->rport->fc_cos;
  467. }
  468. static inline struct bfad_itnim_s *
  469. bfa_fcs_itnim_get_drvitn(struct bfa_fcs_itnim_s *itnim)
  470. {
  471. return itnim->itnim_drv;
  472. }
  473. static inline struct bfa_itnim_s *
  474. bfa_fcs_itnim_get_halitn(struct bfa_fcs_itnim_s *itnim)
  475. {
  476. return itnim->bfa_itnim;
  477. }
  478. /*
  479. * bfa fcs FCP Initiator mode API functions
  480. */
  481. void bfa_fcs_itnim_get_attr(struct bfa_fcs_itnim_s *itnim,
  482. struct bfa_itnim_attr_s *attr);
  483. void bfa_fcs_itnim_get_stats(struct bfa_fcs_itnim_s *itnim,
  484. struct bfa_itnim_stats_s *stats);
  485. struct bfa_fcs_itnim_s *bfa_fcs_itnim_lookup(struct bfa_fcs_lport_s *port,
  486. wwn_t rpwwn);
  487. bfa_status_t bfa_fcs_itnim_attr_get(struct bfa_fcs_lport_s *port, wwn_t rpwwn,
  488. struct bfa_itnim_attr_s *attr);
  489. bfa_status_t bfa_fcs_itnim_stats_get(struct bfa_fcs_lport_s *port, wwn_t rpwwn,
  490. struct bfa_itnim_stats_s *stats);
  491. bfa_status_t bfa_fcs_itnim_stats_clear(struct bfa_fcs_lport_s *port,
  492. wwn_t rpwwn);
  493. struct bfa_fcs_itnim_s *bfa_fcs_itnim_create(struct bfa_fcs_rport_s *rport);
  494. void bfa_fcs_itnim_delete(struct bfa_fcs_itnim_s *itnim);
  495. void bfa_fcs_itnim_rport_offline(struct bfa_fcs_itnim_s *itnim);
  496. void bfa_fcs_itnim_rport_online(struct bfa_fcs_itnim_s *itnim);
  497. bfa_status_t bfa_fcs_itnim_get_online_state(struct bfa_fcs_itnim_s *itnim);
  498. void bfa_fcs_itnim_is_initiator(struct bfa_fcs_itnim_s *itnim);
  499. void bfa_fcs_fcpim_uf_recv(struct bfa_fcs_itnim_s *itnim,
  500. struct fchs_s *fchs, u16 len);
  501. #define BFA_FCS_FDMI_SUPORTED_SPEEDS (FDMI_TRANS_SPEED_1G | \
  502. FDMI_TRANS_SPEED_2G | \
  503. FDMI_TRANS_SPEED_4G | \
  504. FDMI_TRANS_SPEED_8G)
  505. /*
  506. * HBA Attribute Block : BFA internal representation. Note : Some variable
  507. * sizes have been trimmed to suit BFA For Ex : Model will be "Brocade". Based
  508. * on this the size has been reduced to 16 bytes from the standard's 64 bytes.
  509. */
  510. struct bfa_fcs_fdmi_hba_attr_s {
  511. wwn_t node_name;
  512. u8 manufacturer[64];
  513. u8 serial_num[64];
  514. u8 model[16];
  515. u8 model_desc[256];
  516. u8 hw_version[8];
  517. u8 driver_version[8];
  518. u8 option_rom_ver[BFA_VERSION_LEN];
  519. u8 fw_version[8];
  520. u8 os_name[256];
  521. __be32 max_ct_pyld;
  522. };
  523. /*
  524. * Port Attribute Block
  525. */
  526. struct bfa_fcs_fdmi_port_attr_s {
  527. u8 supp_fc4_types[32]; /* supported FC4 types */
  528. __be32 supp_speed; /* supported speed */
  529. __be32 curr_speed; /* current Speed */
  530. __be32 max_frm_size; /* max frame size */
  531. u8 os_device_name[256]; /* OS device Name */
  532. u8 host_name[256]; /* host name */
  533. };
  534. struct bfa_fcs_stats_s {
  535. struct {
  536. u32 untagged; /* untagged receive frames */
  537. u32 tagged; /* tagged receive frames */
  538. u32 vfid_unknown; /* VF id is unknown */
  539. } uf;
  540. };
  541. struct bfa_fcs_driver_info_s {
  542. u8 version[BFA_VERSION_LEN]; /* Driver Version */
  543. u8 host_machine_name[BFA_FCS_OS_STR_LEN];
  544. u8 host_os_name[BFA_FCS_OS_STR_LEN]; /* OS name and version */
  545. u8 host_os_patch[BFA_FCS_OS_STR_LEN]; /* patch or service pack */
  546. u8 os_device_name[BFA_FCS_OS_STR_LEN]; /* Driver Device Name */
  547. };
  548. struct bfa_fcs_s {
  549. struct bfa_s *bfa; /* corresponding BFA bfa instance */
  550. struct bfad_s *bfad; /* corresponding BDA driver instance */
  551. struct bfa_trc_mod_s *trcmod; /* tracing module */
  552. bfa_boolean_t vf_enabled; /* VF mode is enabled */
  553. bfa_boolean_t fdmi_enabled; /* FDMI is enabled */
  554. bfa_boolean_t min_cfg; /* min cfg enabled/disabled */
  555. u16 port_vfid; /* port default VF ID */
  556. struct bfa_fcs_driver_info_s driver_info;
  557. struct bfa_fcs_fabric_s fabric; /* base fabric state machine */
  558. struct bfa_fcs_stats_s stats; /* FCS statistics */
  559. struct bfa_wc_s wc; /* waiting counter */
  560. };
  561. /*
  562. * bfa fcs API functions
  563. */
  564. void bfa_fcs_attach(struct bfa_fcs_s *fcs, struct bfa_s *bfa,
  565. struct bfad_s *bfad,
  566. bfa_boolean_t min_cfg);
  567. void bfa_fcs_init(struct bfa_fcs_s *fcs);
  568. void bfa_fcs_driver_info_init(struct bfa_fcs_s *fcs,
  569. struct bfa_fcs_driver_info_s *driver_info);
  570. void bfa_fcs_set_fdmi_param(struct bfa_fcs_s *fcs, bfa_boolean_t fdmi_enable);
  571. void bfa_fcs_exit(struct bfa_fcs_s *fcs);
  572. void bfa_fcs_trc_init(struct bfa_fcs_s *fcs, struct bfa_trc_mod_s *trcmod);
  573. void bfa_fcs_start(struct bfa_fcs_s *fcs);
  574. /*
  575. * bfa fcs vf public functions
  576. */
  577. bfa_fcs_vf_t *bfa_fcs_vf_lookup(struct bfa_fcs_s *fcs, u16 vf_id);
  578. u16 bfa_fcs_fabric_vport_count(struct bfa_fcs_fabric_s *fabric);
  579. /*
  580. * fabric protected interface functions
  581. */
  582. void bfa_fcs_fabric_attach(struct bfa_fcs_s *fcs);
  583. void bfa_fcs_fabric_modinit(struct bfa_fcs_s *fcs);
  584. void bfa_fcs_fabric_modexit(struct bfa_fcs_s *fcs);
  585. void bfa_fcs_fabric_link_up(struct bfa_fcs_fabric_s *fabric);
  586. void bfa_fcs_fabric_link_down(struct bfa_fcs_fabric_s *fabric);
  587. void bfa_fcs_fabric_addvport(struct bfa_fcs_fabric_s *fabric,
  588. struct bfa_fcs_vport_s *vport);
  589. void bfa_fcs_fabric_delvport(struct bfa_fcs_fabric_s *fabric,
  590. struct bfa_fcs_vport_s *vport);
  591. int bfa_fcs_fabric_is_online(struct bfa_fcs_fabric_s *fabric);
  592. struct bfa_fcs_vport_s *bfa_fcs_fabric_vport_lookup(
  593. struct bfa_fcs_fabric_s *fabric, wwn_t pwwn);
  594. void bfa_fcs_fabric_modstart(struct bfa_fcs_s *fcs);
  595. void bfa_fcs_fabric_uf_recv(struct bfa_fcs_fabric_s *fabric,
  596. struct fchs_s *fchs, u16 len);
  597. bfa_boolean_t bfa_fcs_fabric_is_loopback(struct bfa_fcs_fabric_s *fabric);
  598. bfa_boolean_t bfa_fcs_fabric_is_auth_failed(struct bfa_fcs_fabric_s *fabric);
  599. enum bfa_port_type bfa_fcs_fabric_port_type(struct bfa_fcs_fabric_s *fabric);
  600. void bfa_fcs_fabric_psymb_init(struct bfa_fcs_fabric_s *fabric);
  601. void bfa_fcs_fabric_port_delete_comp(struct bfa_fcs_fabric_s *fabric);
  602. void bfa_fcs_fabric_set_fabric_name(struct bfa_fcs_fabric_s *fabric,
  603. wwn_t fabric_name);
  604. u16 bfa_fcs_fabric_get_switch_oui(struct bfa_fcs_fabric_s *fabric);
  605. void bfa_fcs_uf_attach(struct bfa_fcs_s *fcs);
  606. void bfa_fcs_port_attach(struct bfa_fcs_s *fcs);
  607. /*
  608. * BFA FCS callback interfaces
  609. */
  610. /*
  611. * fcb Main fcs callbacks
  612. */
  613. struct bfad_port_s;
  614. struct bfad_vf_s;
  615. struct bfad_vport_s;
  616. struct bfad_rport_s;
  617. /*
  618. * lport callbacks
  619. */
  620. struct bfad_port_s *bfa_fcb_lport_new(struct bfad_s *bfad,
  621. struct bfa_fcs_lport_s *port,
  622. enum bfa_lport_role roles,
  623. struct bfad_vf_s *vf_drv,
  624. struct bfad_vport_s *vp_drv);
  625. void bfa_fcb_lport_delete(struct bfad_s *bfad, enum bfa_lport_role roles,
  626. struct bfad_vf_s *vf_drv,
  627. struct bfad_vport_s *vp_drv);
  628. /*
  629. * vport callbacks
  630. */
  631. void bfa_fcb_pbc_vport_create(struct bfad_s *bfad, struct bfi_pbc_vport_s);
  632. /*
  633. * rport callbacks
  634. */
  635. bfa_status_t bfa_fcb_rport_alloc(struct bfad_s *bfad,
  636. struct bfa_fcs_rport_s **rport,
  637. struct bfad_rport_s **rport_drv);
  638. /*
  639. * itnim callbacks
  640. */
  641. void bfa_fcb_itnim_alloc(struct bfad_s *bfad, struct bfa_fcs_itnim_s **itnim,
  642. struct bfad_itnim_s **itnim_drv);
  643. void bfa_fcb_itnim_free(struct bfad_s *bfad,
  644. struct bfad_itnim_s *itnim_drv);
  645. void bfa_fcb_itnim_online(struct bfad_itnim_s *itnim_drv);
  646. void bfa_fcb_itnim_offline(struct bfad_itnim_s *itnim_drv);
  647. #endif /* __BFA_FCS_H__ */