bfa_svc.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644
  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_SVC_H__
  18. #define __BFA_SVC_H__
  19. #include "bfa_cs.h"
  20. #include "bfi_ms.h"
  21. /*
  22. * Scatter-gather DMA related defines
  23. */
  24. #define BFA_SGPG_MIN (16)
  25. /*
  26. * Alignment macro for SG page allocation
  27. */
  28. #define BFA_SGPG_ROUNDUP(_l) (((_l) + (sizeof(struct bfi_sgpg_s) - 1)) \
  29. & ~(sizeof(struct bfi_sgpg_s) - 1))
  30. struct bfa_sgpg_wqe_s {
  31. struct list_head qe; /* queue sg page element */
  32. int nsgpg; /* pages to be allocated */
  33. int nsgpg_total; /* total pages required */
  34. void (*cbfn) (void *cbarg); /* callback function */
  35. void *cbarg; /* callback arg */
  36. struct list_head sgpg_q; /* queue of alloced sgpgs */
  37. };
  38. struct bfa_sgpg_s {
  39. struct list_head qe; /* queue sg page element */
  40. struct bfi_sgpg_s *sgpg; /* va of SG page */
  41. union bfi_addr_u sgpg_pa; /* pa of SG page */
  42. };
  43. /*
  44. * Given number of SG elements, BFA_SGPG_NPAGE() returns the number of
  45. * SG pages required.
  46. */
  47. #define BFA_SGPG_NPAGE(_nsges) (((_nsges) / BFI_SGPG_DATA_SGES) + 1)
  48. struct bfa_sgpg_mod_s {
  49. struct bfa_s *bfa;
  50. int num_sgpgs; /* number of SG pages */
  51. int free_sgpgs; /* number of free SG pages */
  52. struct bfa_sgpg_s *hsgpg_arr; /* BFA SG page array */
  53. struct bfi_sgpg_s *sgpg_arr; /* actual SG page array */
  54. u64 sgpg_arr_pa; /* SG page array DMA addr */
  55. struct list_head sgpg_q; /* queue of free SG pages */
  56. struct list_head sgpg_wait_q; /* wait queue for SG pages */
  57. };
  58. #define BFA_SGPG_MOD(__bfa) (&(__bfa)->modules.sgpg_mod)
  59. bfa_status_t bfa_sgpg_malloc(struct bfa_s *bfa, struct list_head *sgpg_q,
  60. int nsgpgs);
  61. void bfa_sgpg_mfree(struct bfa_s *bfa, struct list_head *sgpg_q, int nsgpgs);
  62. void bfa_sgpg_winit(struct bfa_sgpg_wqe_s *wqe,
  63. void (*cbfn) (void *cbarg), void *cbarg);
  64. void bfa_sgpg_wait(struct bfa_s *bfa, struct bfa_sgpg_wqe_s *wqe, int nsgpgs);
  65. void bfa_sgpg_wcancel(struct bfa_s *bfa, struct bfa_sgpg_wqe_s *wqe);
  66. /*
  67. * FCXP related defines
  68. */
  69. #define BFA_FCXP_MIN (1)
  70. #define BFA_FCXP_MAX_IBUF_SZ (2 * 1024 + 256)
  71. #define BFA_FCXP_MAX_LBUF_SZ (4 * 1024 + 256)
  72. struct bfa_fcxp_mod_s {
  73. struct bfa_s *bfa; /* backpointer to BFA */
  74. struct bfa_fcxp_s *fcxp_list; /* array of FCXPs */
  75. u16 num_fcxps; /* max num FCXP requests */
  76. struct list_head fcxp_free_q; /* free FCXPs */
  77. struct list_head fcxp_active_q; /* active FCXPs */
  78. void *req_pld_list_kva; /* list of FCXP req pld */
  79. u64 req_pld_list_pa; /* list of FCXP req pld */
  80. void *rsp_pld_list_kva; /* list of FCXP resp pld */
  81. u64 rsp_pld_list_pa; /* list of FCXP resp pld */
  82. struct list_head wait_q; /* wait queue for free fcxp */
  83. struct list_head fcxp_unused_q; /* unused fcxps */
  84. u32 req_pld_sz;
  85. u32 rsp_pld_sz;
  86. };
  87. #define BFA_FCXP_MOD(__bfa) (&(__bfa)->modules.fcxp_mod)
  88. #define BFA_FCXP_FROM_TAG(__mod, __tag) (&(__mod)->fcxp_list[__tag])
  89. typedef void (*fcxp_send_cb_t) (struct bfa_s *ioc, struct bfa_fcxp_s *fcxp,
  90. void *cb_arg, bfa_status_t req_status,
  91. u32 rsp_len, u32 resid_len,
  92. struct fchs_s *rsp_fchs);
  93. typedef u64 (*bfa_fcxp_get_sgaddr_t) (void *bfad_fcxp, int sgeid);
  94. typedef u32 (*bfa_fcxp_get_sglen_t) (void *bfad_fcxp, int sgeid);
  95. typedef void (*bfa_cb_fcxp_send_t) (void *bfad_fcxp, struct bfa_fcxp_s *fcxp,
  96. void *cbarg, enum bfa_status req_status,
  97. u32 rsp_len, u32 resid_len,
  98. struct fchs_s *rsp_fchs);
  99. typedef void (*bfa_fcxp_alloc_cbfn_t) (void *cbarg, struct bfa_fcxp_s *fcxp);
  100. /*
  101. * Information needed for a FCXP request
  102. */
  103. struct bfa_fcxp_req_info_s {
  104. struct bfa_rport_s *bfa_rport;
  105. /* Pointer to the bfa rport that was
  106. * returned from bfa_rport_create().
  107. * This could be left NULL for WKA or
  108. * for FCXP interactions before the
  109. * rport nexus is established
  110. */
  111. struct fchs_s fchs; /* request FC header structure */
  112. u8 cts; /* continuous sequence */
  113. u8 class; /* FC class for the request/response */
  114. u16 max_frmsz; /* max send frame size */
  115. u16 vf_id; /* vsan tag if applicable */
  116. u8 lp_tag; /* lport tag */
  117. u32 req_tot_len; /* request payload total length */
  118. };
  119. struct bfa_fcxp_rsp_info_s {
  120. struct fchs_s rsp_fchs;
  121. /* Response frame's FC header will
  122. * be sent back in this field */
  123. u8 rsp_timeout;
  124. /* timeout in seconds, 0-no response */
  125. u8 rsvd2[3];
  126. u32 rsp_maxlen; /* max response length expected */
  127. };
  128. struct bfa_fcxp_s {
  129. struct list_head qe; /* fcxp queue element */
  130. bfa_sm_t sm; /* state machine */
  131. void *caller; /* driver or fcs */
  132. struct bfa_fcxp_mod_s *fcxp_mod;
  133. /* back pointer to fcxp mod */
  134. u16 fcxp_tag; /* internal tag */
  135. struct bfa_fcxp_req_info_s req_info;
  136. /* request info */
  137. struct bfa_fcxp_rsp_info_s rsp_info;
  138. /* response info */
  139. u8 use_ireqbuf; /* use internal req buf */
  140. u8 use_irspbuf; /* use internal rsp buf */
  141. u32 nreq_sgles; /* num request SGLEs */
  142. u32 nrsp_sgles; /* num response SGLEs */
  143. struct list_head req_sgpg_q; /* SG pages for request buf */
  144. struct list_head req_sgpg_wqe; /* wait queue for req SG page */
  145. struct list_head rsp_sgpg_q; /* SG pages for response buf */
  146. struct list_head rsp_sgpg_wqe; /* wait queue for rsp SG page */
  147. bfa_fcxp_get_sgaddr_t req_sga_cbfn;
  148. /* SG elem addr user function */
  149. bfa_fcxp_get_sglen_t req_sglen_cbfn;
  150. /* SG elem len user function */
  151. bfa_fcxp_get_sgaddr_t rsp_sga_cbfn;
  152. /* SG elem addr user function */
  153. bfa_fcxp_get_sglen_t rsp_sglen_cbfn;
  154. /* SG elem len user function */
  155. bfa_cb_fcxp_send_t send_cbfn; /* send completion callback */
  156. void *send_cbarg; /* callback arg */
  157. struct bfa_sge_s req_sge[BFA_FCXP_MAX_SGES];
  158. /* req SG elems */
  159. struct bfa_sge_s rsp_sge[BFA_FCXP_MAX_SGES];
  160. /* rsp SG elems */
  161. u8 rsp_status; /* comp: rsp status */
  162. u32 rsp_len; /* comp: actual response len */
  163. u32 residue_len; /* comp: residual rsp length */
  164. struct fchs_s rsp_fchs; /* comp: response fchs */
  165. struct bfa_cb_qe_s hcb_qe; /* comp: callback qelem */
  166. struct bfa_reqq_wait_s reqq_wqe;
  167. bfa_boolean_t reqq_waiting;
  168. };
  169. struct bfa_fcxp_wqe_s {
  170. struct list_head qe;
  171. bfa_fcxp_alloc_cbfn_t alloc_cbfn;
  172. void *alloc_cbarg;
  173. void *caller;
  174. struct bfa_s *bfa;
  175. int nreq_sgles;
  176. int nrsp_sgles;
  177. bfa_fcxp_get_sgaddr_t req_sga_cbfn;
  178. bfa_fcxp_get_sglen_t req_sglen_cbfn;
  179. bfa_fcxp_get_sgaddr_t rsp_sga_cbfn;
  180. bfa_fcxp_get_sglen_t rsp_sglen_cbfn;
  181. };
  182. #define BFA_FCXP_REQ_PLD(_fcxp) (bfa_fcxp_get_reqbuf(_fcxp))
  183. #define BFA_FCXP_RSP_FCHS(_fcxp) (&((_fcxp)->rsp_info.fchs))
  184. #define BFA_FCXP_RSP_PLD(_fcxp) (bfa_fcxp_get_rspbuf(_fcxp))
  185. #define BFA_FCXP_REQ_PLD_PA(_fcxp) \
  186. ((_fcxp)->fcxp_mod->req_pld_list_pa + \
  187. ((_fcxp)->fcxp_mod->req_pld_sz * (_fcxp)->fcxp_tag))
  188. #define BFA_FCXP_RSP_PLD_PA(_fcxp) \
  189. ((_fcxp)->fcxp_mod->rsp_pld_list_pa + \
  190. ((_fcxp)->fcxp_mod->rsp_pld_sz * (_fcxp)->fcxp_tag))
  191. void bfa_fcxp_isr(struct bfa_s *bfa, struct bfi_msg_s *msg);
  192. /*
  193. * RPORT related defines
  194. */
  195. enum bfa_rport_event {
  196. BFA_RPORT_SM_CREATE = 1, /* rport create event */
  197. BFA_RPORT_SM_DELETE = 2, /* deleting an existing rport */
  198. BFA_RPORT_SM_ONLINE = 3, /* rport is online */
  199. BFA_RPORT_SM_OFFLINE = 4, /* rport is offline */
  200. BFA_RPORT_SM_FWRSP = 5, /* firmware response */
  201. BFA_RPORT_SM_HWFAIL = 6, /* IOC h/w failure */
  202. BFA_RPORT_SM_QOS_SCN = 7, /* QoS SCN from firmware */
  203. BFA_RPORT_SM_SET_SPEED = 8, /* Set Rport Speed */
  204. BFA_RPORT_SM_QRESUME = 9, /* space in requeue queue */
  205. };
  206. #define BFA_RPORT_MIN 4
  207. struct bfa_rport_mod_s {
  208. struct bfa_rport_s *rps_list; /* list of rports */
  209. struct list_head rp_free_q; /* free bfa_rports */
  210. struct list_head rp_active_q; /* free bfa_rports */
  211. struct list_head rp_unused_q; /* unused bfa rports */
  212. u16 num_rports; /* number of rports */
  213. };
  214. #define BFA_RPORT_MOD(__bfa) (&(__bfa)->modules.rport_mod)
  215. /*
  216. * Convert rport tag to RPORT
  217. */
  218. #define BFA_RPORT_FROM_TAG(__bfa, _tag) \
  219. (BFA_RPORT_MOD(__bfa)->rps_list + \
  220. ((_tag) & (BFA_RPORT_MOD(__bfa)->num_rports - 1)))
  221. /*
  222. * protected functions
  223. */
  224. void bfa_rport_isr(struct bfa_s *bfa, struct bfi_msg_s *msg);
  225. void bfa_rport_res_recfg(struct bfa_s *bfa, u16 num_rport_fw);
  226. /*
  227. * BFA rport information.
  228. */
  229. struct bfa_rport_info_s {
  230. u16 max_frmsz; /* max rcv pdu size */
  231. u32 pid:24, /* remote port ID */
  232. lp_tag:8; /* tag */
  233. u32 local_pid:24, /* local port ID */
  234. cisc:8; /* CIRO supported */
  235. u8 fc_class; /* supported FC classes. enum fc_cos */
  236. u8 vf_en; /* virtual fabric enable */
  237. u16 vf_id; /* virtual fabric ID */
  238. enum bfa_port_speed speed; /* Rport's current speed */
  239. };
  240. /*
  241. * BFA rport data structure
  242. */
  243. struct bfa_rport_s {
  244. struct list_head qe; /* queue element */
  245. bfa_sm_t sm; /* state machine */
  246. struct bfa_s *bfa; /* backpointer to BFA */
  247. void *rport_drv; /* fcs/driver rport object */
  248. u16 fw_handle; /* firmware rport handle */
  249. u16 rport_tag; /* BFA rport tag */
  250. struct bfa_rport_info_s rport_info; /* rport info from fcs/driver */
  251. struct bfa_reqq_wait_s reqq_wait; /* to wait for room in reqq */
  252. struct bfa_cb_qe_s hcb_qe; /* BFA callback qelem */
  253. struct bfa_rport_hal_stats_s stats; /* BFA rport statistics */
  254. struct bfa_rport_qos_attr_s qos_attr;
  255. union a {
  256. bfa_status_t status; /* f/w status */
  257. void *fw_msg; /* QoS scn event */
  258. } event_arg;
  259. };
  260. #define BFA_RPORT_FC_COS(_rport) ((_rport)->rport_info.fc_class)
  261. /*
  262. * UF - unsolicited receive related defines
  263. */
  264. #define BFA_UF_MIN (4)
  265. struct bfa_uf_s {
  266. struct list_head qe; /* queue element */
  267. struct bfa_s *bfa; /* bfa instance */
  268. u16 uf_tag; /* identifying tag fw msgs */
  269. u16 vf_id;
  270. u16 src_rport_handle;
  271. u16 rsvd;
  272. u8 *data_ptr;
  273. u16 data_len; /* actual receive length */
  274. u16 pb_len; /* posted buffer length */
  275. void *buf_kva; /* buffer virtual address */
  276. u64 buf_pa; /* buffer physical address */
  277. struct bfa_cb_qe_s hcb_qe; /* comp: BFA comp qelem */
  278. struct bfa_sge_s sges[BFI_SGE_INLINE_MAX];
  279. };
  280. /*
  281. * Callback prototype for unsolicited frame receive handler.
  282. *
  283. * @param[in] cbarg callback arg for receive handler
  284. * @param[in] uf unsolicited frame descriptor
  285. *
  286. * @return None
  287. */
  288. typedef void (*bfa_cb_uf_recv_t) (void *cbarg, struct bfa_uf_s *uf);
  289. struct bfa_uf_mod_s {
  290. struct bfa_s *bfa; /* back pointer to BFA */
  291. struct bfa_uf_s *uf_list; /* array of UFs */
  292. u16 num_ufs; /* num unsolicited rx frames */
  293. struct list_head uf_free_q; /* free UFs */
  294. struct list_head uf_posted_q; /* UFs posted to IOC */
  295. struct list_head uf_unused_q; /* unused UF's */
  296. struct bfa_uf_buf_s *uf_pbs_kva; /* list UF bufs request pld */
  297. u64 uf_pbs_pa; /* phy addr for UF bufs */
  298. struct bfi_uf_buf_post_s *uf_buf_posts;
  299. /* pre-built UF post msgs */
  300. bfa_cb_uf_recv_t ufrecv; /* uf recv handler function */
  301. void *cbarg; /* uf receive handler arg */
  302. };
  303. #define BFA_UF_MOD(__bfa) (&(__bfa)->modules.uf_mod)
  304. #define ufm_pbs_pa(_ufmod, _uftag) \
  305. ((_ufmod)->uf_pbs_pa + sizeof(struct bfa_uf_buf_s) * (_uftag))
  306. void bfa_uf_isr(struct bfa_s *bfa, struct bfi_msg_s *msg);
  307. void bfa_uf_res_recfg(struct bfa_s *bfa, u16 num_uf_fw);
  308. #define BFA_UF_BUFSZ (2 * 1024 + 256)
  309. /*
  310. * @todo private
  311. */
  312. struct bfa_uf_buf_s {
  313. u8 d[BFA_UF_BUFSZ];
  314. };
  315. /*
  316. * LPS - bfa lport login/logout service interface
  317. */
  318. struct bfa_lps_s {
  319. struct list_head qe; /* queue element */
  320. struct bfa_s *bfa; /* parent bfa instance */
  321. bfa_sm_t sm; /* finite state machine */
  322. u8 bfa_tag; /* lport tag */
  323. u8 fw_tag; /* lport fw tag */
  324. u8 reqq; /* lport request queue */
  325. u8 alpa; /* ALPA for loop topologies */
  326. u32 lp_pid; /* lport port ID */
  327. bfa_boolean_t fdisc; /* snd FDISC instead of FLOGI */
  328. bfa_boolean_t auth_en; /* enable authentication */
  329. bfa_boolean_t auth_req; /* authentication required */
  330. bfa_boolean_t npiv_en; /* NPIV is allowed by peer */
  331. bfa_boolean_t fport; /* attached peer is F_PORT */
  332. bfa_boolean_t brcd_switch; /* attached peer is brcd sw */
  333. bfa_status_t status; /* login status */
  334. u16 pdusz; /* max receive PDU size */
  335. u16 pr_bbcred; /* BB_CREDIT from peer */
  336. u8 pr_bbscn; /* BB_SCN from peer */
  337. u8 bb_scn; /* local BB_SCN */
  338. u8 lsrjt_rsn; /* LSRJT reason */
  339. u8 lsrjt_expl; /* LSRJT explanation */
  340. wwn_t pwwn; /* port wwn of lport */
  341. wwn_t nwwn; /* node wwn of lport */
  342. wwn_t pr_pwwn; /* port wwn of lport peer */
  343. wwn_t pr_nwwn; /* node wwn of lport peer */
  344. mac_t lp_mac; /* fpma/spma MAC for lport */
  345. mac_t fcf_mac; /* FCF MAC of lport */
  346. struct bfa_reqq_wait_s wqe; /* request wait queue element */
  347. void *uarg; /* user callback arg */
  348. struct bfa_cb_qe_s hcb_qe; /* comp: callback qelem */
  349. struct bfi_lps_login_rsp_s *loginrsp;
  350. bfa_eproto_status_t ext_status;
  351. };
  352. struct bfa_lps_mod_s {
  353. struct list_head lps_free_q;
  354. struct list_head lps_active_q;
  355. struct list_head lps_login_q;
  356. struct bfa_lps_s *lps_arr;
  357. int num_lps;
  358. };
  359. #define BFA_LPS_MOD(__bfa) (&(__bfa)->modules.lps_mod)
  360. #define BFA_LPS_FROM_TAG(__mod, __tag) (&(__mod)->lps_arr[__tag])
  361. /*
  362. * external functions
  363. */
  364. void bfa_lps_isr(struct bfa_s *bfa, struct bfi_msg_s *msg);
  365. /*
  366. * FCPORT related defines
  367. */
  368. #define BFA_FCPORT(_bfa) (&((_bfa)->modules.port))
  369. typedef void (*bfa_cb_port_t) (void *cbarg, enum bfa_status status);
  370. /*
  371. * Link notification data structure
  372. */
  373. struct bfa_fcport_ln_s {
  374. struct bfa_fcport_s *fcport;
  375. bfa_sm_t sm;
  376. struct bfa_cb_qe_s ln_qe; /* BFA callback queue elem for ln */
  377. enum bfa_port_linkstate ln_event; /* ln event for callback */
  378. };
  379. struct bfa_fcport_trunk_s {
  380. struct bfa_trunk_attr_s attr;
  381. };
  382. /*
  383. * BFA FC port data structure
  384. */
  385. struct bfa_fcport_s {
  386. struct bfa_s *bfa; /* parent BFA instance */
  387. bfa_sm_t sm; /* port state machine */
  388. wwn_t nwwn; /* node wwn of physical port */
  389. wwn_t pwwn; /* port wwn of physical oprt */
  390. enum bfa_port_speed speed_sup;
  391. /* supported speeds */
  392. enum bfa_port_speed speed; /* current speed */
  393. enum bfa_port_topology topology; /* current topology */
  394. u8 myalpa; /* my ALPA in LOOP topology */
  395. u8 rsvd[3];
  396. struct bfa_port_cfg_s cfg; /* current port configuration */
  397. bfa_boolean_t use_flash_cfg; /* get port cfg from flash */
  398. struct bfa_qos_attr_s qos_attr; /* QoS Attributes */
  399. struct bfa_qos_vc_attr_s qos_vc_attr; /* VC info from ELP */
  400. struct bfa_reqq_wait_s reqq_wait;
  401. /* to wait for room in reqq */
  402. struct bfa_reqq_wait_s svcreq_wait;
  403. /* to wait for room in reqq */
  404. struct bfa_reqq_wait_s stats_reqq_wait;
  405. /* to wait for room in reqq (stats) */
  406. void *event_cbarg;
  407. void (*event_cbfn) (void *cbarg,
  408. enum bfa_port_linkstate event);
  409. union {
  410. union bfi_fcport_i2h_msg_u i2hmsg;
  411. } event_arg;
  412. void *bfad; /* BFA driver handle */
  413. struct bfa_fcport_ln_s ln; /* Link Notification */
  414. struct bfa_cb_qe_s hcb_qe; /* BFA callback queue elem */
  415. struct bfa_timer_s timer; /* timer */
  416. u32 msgtag; /* fimrware msg tag for reply */
  417. u8 *stats_kva;
  418. u64 stats_pa;
  419. union bfa_fcport_stats_u *stats;
  420. union bfa_fcport_stats_u *stats_ret; /* driver stats location */
  421. bfa_status_t stats_status; /* stats/statsclr status */
  422. bfa_boolean_t stats_busy; /* outstanding stats/statsclr */
  423. bfa_boolean_t stats_qfull;
  424. u32 stats_reset_time; /* stats reset time stamp */
  425. bfa_cb_port_t stats_cbfn; /* driver callback function */
  426. void *stats_cbarg; /* *!< user callback arg */
  427. bfa_boolean_t diag_busy; /* diag busy status */
  428. bfa_boolean_t beacon; /* port beacon status */
  429. bfa_boolean_t link_e2e_beacon; /* link beacon status */
  430. bfa_boolean_t bbsc_op_state; /* Cred recov Oper State */
  431. struct bfa_fcport_trunk_s trunk;
  432. u16 fcoe_vlan;
  433. };
  434. #define BFA_FCPORT_MOD(__bfa) (&(__bfa)->modules.fcport)
  435. /*
  436. * protected functions
  437. */
  438. void bfa_fcport_init(struct bfa_s *bfa);
  439. void bfa_fcport_isr(struct bfa_s *bfa, struct bfi_msg_s *msg);
  440. /*
  441. * bfa fcport API functions
  442. */
  443. bfa_status_t bfa_fcport_enable(struct bfa_s *bfa);
  444. bfa_status_t bfa_fcport_disable(struct bfa_s *bfa);
  445. bfa_status_t bfa_fcport_cfg_speed(struct bfa_s *bfa,
  446. enum bfa_port_speed speed);
  447. enum bfa_port_speed bfa_fcport_get_speed(struct bfa_s *bfa);
  448. bfa_status_t bfa_fcport_cfg_topology(struct bfa_s *bfa,
  449. enum bfa_port_topology topo);
  450. enum bfa_port_topology bfa_fcport_get_topology(struct bfa_s *bfa);
  451. bfa_status_t bfa_fcport_cfg_hardalpa(struct bfa_s *bfa, u8 alpa);
  452. bfa_boolean_t bfa_fcport_get_hardalpa(struct bfa_s *bfa, u8 *alpa);
  453. u8 bfa_fcport_get_myalpa(struct bfa_s *bfa);
  454. bfa_status_t bfa_fcport_clr_hardalpa(struct bfa_s *bfa);
  455. bfa_status_t bfa_fcport_cfg_maxfrsize(struct bfa_s *bfa, u16 maxsize);
  456. u16 bfa_fcport_get_maxfrsize(struct bfa_s *bfa);
  457. u8 bfa_fcport_get_rx_bbcredit(struct bfa_s *bfa);
  458. void bfa_fcport_get_attr(struct bfa_s *bfa, struct bfa_port_attr_s *attr);
  459. wwn_t bfa_fcport_get_wwn(struct bfa_s *bfa, bfa_boolean_t node);
  460. void bfa_fcport_event_register(struct bfa_s *bfa,
  461. void (*event_cbfn) (void *cbarg,
  462. enum bfa_port_linkstate event), void *event_cbarg);
  463. bfa_boolean_t bfa_fcport_is_disabled(struct bfa_s *bfa);
  464. enum bfa_port_speed bfa_fcport_get_ratelim_speed(struct bfa_s *bfa);
  465. void bfa_fcport_set_tx_bbcredit(struct bfa_s *bfa, u16 tx_bbcredit, u8 bb_scn);
  466. bfa_boolean_t bfa_fcport_is_ratelim(struct bfa_s *bfa);
  467. bfa_boolean_t bfa_fcport_is_linkup(struct bfa_s *bfa);
  468. bfa_status_t bfa_fcport_get_stats(struct bfa_s *bfa,
  469. union bfa_fcport_stats_u *stats,
  470. bfa_cb_port_t cbfn, void *cbarg);
  471. bfa_status_t bfa_fcport_clear_stats(struct bfa_s *bfa, bfa_cb_port_t cbfn,
  472. void *cbarg);
  473. bfa_boolean_t bfa_fcport_is_qos_enabled(struct bfa_s *bfa);
  474. bfa_boolean_t bfa_fcport_is_trunk_enabled(struct bfa_s *bfa);
  475. bfa_status_t bfa_fcport_is_pbcdisabled(struct bfa_s *bfa);
  476. void bfa_fcport_cfg_faa(struct bfa_s *bfa, u8 state);
  477. /*
  478. * bfa rport API functions
  479. */
  480. struct bfa_rport_s *bfa_rport_create(struct bfa_s *bfa, void *rport_drv);
  481. void bfa_rport_online(struct bfa_rport_s *rport,
  482. struct bfa_rport_info_s *rport_info);
  483. void bfa_rport_speed(struct bfa_rport_s *rport, enum bfa_port_speed speed);
  484. void bfa_cb_rport_online(void *rport);
  485. void bfa_cb_rport_offline(void *rport);
  486. void bfa_cb_rport_qos_scn_flowid(void *rport,
  487. struct bfa_rport_qos_attr_s old_qos_attr,
  488. struct bfa_rport_qos_attr_s new_qos_attr);
  489. void bfa_cb_rport_qos_scn_prio(void *rport,
  490. struct bfa_rport_qos_attr_s old_qos_attr,
  491. struct bfa_rport_qos_attr_s new_qos_attr);
  492. /*
  493. * bfa fcxp API functions
  494. */
  495. struct bfa_fcxp_s *bfa_fcxp_alloc(void *bfad_fcxp, struct bfa_s *bfa,
  496. int nreq_sgles, int nrsp_sgles,
  497. bfa_fcxp_get_sgaddr_t get_req_sga,
  498. bfa_fcxp_get_sglen_t get_req_sglen,
  499. bfa_fcxp_get_sgaddr_t get_rsp_sga,
  500. bfa_fcxp_get_sglen_t get_rsp_sglen);
  501. void bfa_fcxp_alloc_wait(struct bfa_s *bfa, struct bfa_fcxp_wqe_s *wqe,
  502. bfa_fcxp_alloc_cbfn_t alloc_cbfn,
  503. void *cbarg, void *bfad_fcxp,
  504. int nreq_sgles, int nrsp_sgles,
  505. bfa_fcxp_get_sgaddr_t get_req_sga,
  506. bfa_fcxp_get_sglen_t get_req_sglen,
  507. bfa_fcxp_get_sgaddr_t get_rsp_sga,
  508. bfa_fcxp_get_sglen_t get_rsp_sglen);
  509. void bfa_fcxp_walloc_cancel(struct bfa_s *bfa,
  510. struct bfa_fcxp_wqe_s *wqe);
  511. void bfa_fcxp_discard(struct bfa_fcxp_s *fcxp);
  512. void *bfa_fcxp_get_reqbuf(struct bfa_fcxp_s *fcxp);
  513. void *bfa_fcxp_get_rspbuf(struct bfa_fcxp_s *fcxp);
  514. void bfa_fcxp_free(struct bfa_fcxp_s *fcxp);
  515. void bfa_fcxp_send(struct bfa_fcxp_s *fcxp, struct bfa_rport_s *rport,
  516. u16 vf_id, u8 lp_tag,
  517. bfa_boolean_t cts, enum fc_cos cos,
  518. u32 reqlen, struct fchs_s *fchs,
  519. bfa_cb_fcxp_send_t cbfn,
  520. void *cbarg,
  521. u32 rsp_maxlen, u8 rsp_timeout);
  522. bfa_status_t bfa_fcxp_abort(struct bfa_fcxp_s *fcxp);
  523. u32 bfa_fcxp_get_reqbufsz(struct bfa_fcxp_s *fcxp);
  524. u32 bfa_fcxp_get_maxrsp(struct bfa_s *bfa);
  525. void bfa_fcxp_res_recfg(struct bfa_s *bfa, u16 num_fcxp_fw);
  526. static inline void *
  527. bfa_uf_get_frmbuf(struct bfa_uf_s *uf)
  528. {
  529. return uf->data_ptr;
  530. }
  531. static inline u16
  532. bfa_uf_get_frmlen(struct bfa_uf_s *uf)
  533. {
  534. return uf->data_len;
  535. }
  536. /*
  537. * bfa uf API functions
  538. */
  539. void bfa_uf_recv_register(struct bfa_s *bfa, bfa_cb_uf_recv_t ufrecv,
  540. void *cbarg);
  541. void bfa_uf_free(struct bfa_uf_s *uf);
  542. /*
  543. * bfa lport service api
  544. */
  545. u32 bfa_lps_get_max_vport(struct bfa_s *bfa);
  546. struct bfa_lps_s *bfa_lps_alloc(struct bfa_s *bfa);
  547. void bfa_lps_delete(struct bfa_lps_s *lps);
  548. void bfa_lps_flogi(struct bfa_lps_s *lps, void *uarg, u8 alpa,
  549. u16 pdusz, wwn_t pwwn, wwn_t nwwn,
  550. bfa_boolean_t auth_en, u8 bb_scn);
  551. void bfa_lps_fdisc(struct bfa_lps_s *lps, void *uarg, u16 pdusz,
  552. wwn_t pwwn, wwn_t nwwn);
  553. void bfa_lps_fdisclogo(struct bfa_lps_s *lps);
  554. void bfa_lps_set_n2n_pid(struct bfa_lps_s *lps, u32 n2n_pid);
  555. u8 bfa_lps_get_fwtag(struct bfa_s *bfa, u8 lp_tag);
  556. u32 bfa_lps_get_base_pid(struct bfa_s *bfa);
  557. u8 bfa_lps_get_tag_from_pid(struct bfa_s *bfa, u32 pid);
  558. void bfa_cb_lps_flogi_comp(void *bfad, void *uarg, bfa_status_t status);
  559. void bfa_cb_lps_fdisc_comp(void *bfad, void *uarg, bfa_status_t status);
  560. void bfa_cb_lps_fdisclogo_comp(void *bfad, void *uarg);
  561. void bfa_cb_lps_cvl_event(void *bfad, void *uarg);
  562. /* FAA specific APIs */
  563. bfa_status_t bfa_faa_enable(struct bfa_s *bfa,
  564. bfa_cb_iocfc_t cbfn, void *cbarg);
  565. bfa_status_t bfa_faa_disable(struct bfa_s *bfa,
  566. bfa_cb_iocfc_t cbfn, void *cbarg);
  567. bfa_status_t bfa_faa_query(struct bfa_s *bfa, struct bfa_faa_attr_s *attr,
  568. bfa_cb_iocfc_t cbfn, void *cbarg);
  569. #endif /* __BFA_SVC_H__ */