bfa_svc.h 25 KB

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