bfa_svc.h 26 KB

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