bfa_fcs.h 28 KB

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