bfa_svc.h 26 KB

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