bfa_svc.h 24 KB

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