bfa_svc.h 20 KB

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