xref: /linux/drivers/scsi/bfa/bfa_svc.h (revision 79790b6818e96c58fe2bffee1b418c16e64e7b80)
152fa7bf9SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
2a36c61f9SKrishna Gudipati /*
3889d0d42SAnil Gurumurthy  * Copyright (c) 2005-2014 Brocade Communications Systems, Inc.
4889d0d42SAnil Gurumurthy  * Copyright (c) 2014- QLogic Corporation.
5a36c61f9SKrishna Gudipati  * All rights reserved
6889d0d42SAnil Gurumurthy  * www.qlogic.com
7a36c61f9SKrishna Gudipati  *
831e1d569SAnil Gurumurthy  * Linux driver for QLogic BR-series Fibre Channel Host Bus Adapter.
9a36c61f9SKrishna Gudipati  */
10a36c61f9SKrishna Gudipati 
11a36c61f9SKrishna Gudipati #ifndef __BFA_SVC_H__
12a36c61f9SKrishna Gudipati #define __BFA_SVC_H__
13a36c61f9SKrishna Gudipati 
14a36c61f9SKrishna Gudipati #include "bfa_cs.h"
15a36c61f9SKrishna Gudipati #include "bfi_ms.h"
16a36c61f9SKrishna Gudipati 
17a36c61f9SKrishna Gudipati 
18acdc79a6SJing Huang /*
19a36c61f9SKrishna Gudipati  * Scatter-gather DMA related defines
20a36c61f9SKrishna Gudipati  */
21a36c61f9SKrishna Gudipati #define BFA_SGPG_MIN	(16)
224507025dSKrishna Gudipati #define BFA_SGPG_MAX	(8192)
23a36c61f9SKrishna Gudipati 
24acdc79a6SJing Huang /*
25a36c61f9SKrishna Gudipati  * Alignment macro for SG page allocation
26a36c61f9SKrishna Gudipati  */
27a36c61f9SKrishna Gudipati #define BFA_SGPG_ROUNDUP(_l) (((_l) + (sizeof(struct bfi_sgpg_s) - 1))	\
28a36c61f9SKrishna Gudipati 			      & ~(sizeof(struct bfi_sgpg_s) - 1))
29a36c61f9SKrishna Gudipati 
30a36c61f9SKrishna Gudipati struct bfa_sgpg_wqe_s {
31a36c61f9SKrishna Gudipati 	struct list_head qe;	/*  queue sg page element	*/
32a36c61f9SKrishna Gudipati 	int	nsgpg;		/*  pages to be allocated	*/
33a36c61f9SKrishna Gudipati 	int	nsgpg_total;	/*  total pages required	*/
34a36c61f9SKrishna Gudipati 	void	(*cbfn) (void *cbarg);	/*  callback function	*/
35a36c61f9SKrishna Gudipati 	void	*cbarg;		/*  callback arg		*/
36a36c61f9SKrishna Gudipati 	struct list_head sgpg_q;	/*  queue of alloced sgpgs	*/
37a36c61f9SKrishna Gudipati };
38a36c61f9SKrishna Gudipati 
39a36c61f9SKrishna Gudipati struct bfa_sgpg_s {
40a36c61f9SKrishna Gudipati 	struct list_head  qe;	/*  queue sg page element	*/
41a36c61f9SKrishna Gudipati 	struct bfi_sgpg_s *sgpg;	/*  va of SG page		*/
42a36c61f9SKrishna Gudipati 	union bfi_addr_u sgpg_pa;	/*  pa of SG page		*/
43a36c61f9SKrishna Gudipati };
44a36c61f9SKrishna Gudipati 
45acdc79a6SJing Huang /*
46a36c61f9SKrishna Gudipati  * Given number of SG elements, BFA_SGPG_NPAGE() returns the number of
47a36c61f9SKrishna Gudipati  * SG pages required.
48a36c61f9SKrishna Gudipati  */
49a36c61f9SKrishna Gudipati #define BFA_SGPG_NPAGE(_nsges)  (((_nsges) / BFI_SGPG_DATA_SGES) + 1)
50a36c61f9SKrishna Gudipati 
514507025dSKrishna Gudipati /* Max SGPG dma segs required */
524507025dSKrishna Gudipati #define BFA_SGPG_DMA_SEGS	\
534507025dSKrishna Gudipati 	BFI_MEM_DMA_NSEGS(BFA_SGPG_MAX, (uint32_t)sizeof(struct bfi_sgpg_s))
544507025dSKrishna Gudipati 
55a36c61f9SKrishna Gudipati struct bfa_sgpg_mod_s {
56a36c61f9SKrishna Gudipati 	struct bfa_s *bfa;
57a36c61f9SKrishna Gudipati 	int		num_sgpgs;	/*  number of SG pages		*/
58a36c61f9SKrishna Gudipati 	int		free_sgpgs;	/*  number of free SG pages	*/
59a36c61f9SKrishna Gudipati 	struct list_head	sgpg_q;		/*  queue of free SG pages */
60a36c61f9SKrishna Gudipati 	struct list_head	sgpg_wait_q;	/*  wait queue for SG pages */
614507025dSKrishna Gudipati 	struct bfa_mem_dma_s	dma_seg[BFA_SGPG_DMA_SEGS];
624507025dSKrishna Gudipati 	struct bfa_mem_kva_s	kva_seg;
63a36c61f9SKrishna Gudipati };
64a36c61f9SKrishna Gudipati #define BFA_SGPG_MOD(__bfa)	(&(__bfa)->modules.sgpg_mod)
654507025dSKrishna Gudipati #define BFA_MEM_SGPG_KVA(__bfa) (&(BFA_SGPG_MOD(__bfa)->kva_seg))
66a36c61f9SKrishna Gudipati 
67a36c61f9SKrishna Gudipati bfa_status_t bfa_sgpg_malloc(struct bfa_s *bfa, struct list_head *sgpg_q,
68a36c61f9SKrishna Gudipati 			     int nsgpgs);
69a36c61f9SKrishna Gudipati void bfa_sgpg_mfree(struct bfa_s *bfa, struct list_head *sgpg_q, int nsgpgs);
70a36c61f9SKrishna Gudipati void bfa_sgpg_winit(struct bfa_sgpg_wqe_s *wqe,
71a36c61f9SKrishna Gudipati 		    void (*cbfn) (void *cbarg), void *cbarg);
72a36c61f9SKrishna Gudipati void bfa_sgpg_wait(struct bfa_s *bfa, struct bfa_sgpg_wqe_s *wqe, int nsgpgs);
73a36c61f9SKrishna Gudipati void bfa_sgpg_wcancel(struct bfa_s *bfa, struct bfa_sgpg_wqe_s *wqe);
74a36c61f9SKrishna Gudipati 
75a36c61f9SKrishna Gudipati 
76acdc79a6SJing Huang /*
77a36c61f9SKrishna Gudipati  * FCXP related defines
78a36c61f9SKrishna Gudipati  */
79a36c61f9SKrishna Gudipati #define BFA_FCXP_MIN		(1)
804507025dSKrishna Gudipati #define BFA_FCXP_MAX		(256)
81a36c61f9SKrishna Gudipati #define BFA_FCXP_MAX_IBUF_SZ	(2 * 1024 + 256)
82a36c61f9SKrishna Gudipati #define BFA_FCXP_MAX_LBUF_SZ	(4 * 1024 + 256)
83a36c61f9SKrishna Gudipati 
844507025dSKrishna Gudipati /* Max FCXP dma segs required */
854507025dSKrishna Gudipati #define BFA_FCXP_DMA_SEGS						\
864507025dSKrishna Gudipati 	BFI_MEM_DMA_NSEGS(BFA_FCXP_MAX,					\
874507025dSKrishna Gudipati 		(u32)BFA_FCXP_MAX_IBUF_SZ + BFA_FCXP_MAX_LBUF_SZ)
884507025dSKrishna Gudipati 
89a36c61f9SKrishna Gudipati struct bfa_fcxp_mod_s {
90a36c61f9SKrishna Gudipati 	struct bfa_s      *bfa;		/* backpointer to BFA */
91a36c61f9SKrishna Gudipati 	struct bfa_fcxp_s *fcxp_list;	/* array of FCXPs */
92a36c61f9SKrishna Gudipati 	u16	num_fcxps;	/* max num FCXP requests */
93c3f1b123SKrishna Gudipati 	struct list_head fcxp_req_free_q; /* free FCXPs used for sending req */
94c3f1b123SKrishna Gudipati 	struct list_head fcxp_rsp_free_q; /* free FCXPs used for sending req */
95a36c61f9SKrishna Gudipati 	struct list_head fcxp_active_q;	/* active FCXPs */
96c3f1b123SKrishna Gudipati 	struct list_head req_wait_q;	/* wait queue for free req_fcxp */
97c3f1b123SKrishna Gudipati 	struct list_head rsp_wait_q;	/* wait queue for free rsp_fcxp */
98c3f1b123SKrishna Gudipati 	struct list_head fcxp_req_unused_q;	/* unused req_fcxps */
99c3f1b123SKrishna Gudipati 	struct list_head fcxp_rsp_unused_q;	/* unused rsp_fcxps */
100a36c61f9SKrishna Gudipati 	u32	req_pld_sz;
101a36c61f9SKrishna Gudipati 	u32	rsp_pld_sz;
1024507025dSKrishna Gudipati 	struct bfa_mem_dma_s dma_seg[BFA_FCXP_DMA_SEGS];
1034507025dSKrishna Gudipati 	struct bfa_mem_kva_s kva_seg;
104a36c61f9SKrishna Gudipati };
105a36c61f9SKrishna Gudipati 
106a36c61f9SKrishna Gudipati #define BFA_FCXP_MOD(__bfa)		(&(__bfa)->modules.fcxp_mod)
107a36c61f9SKrishna Gudipati #define BFA_FCXP_FROM_TAG(__mod, __tag)	(&(__mod)->fcxp_list[__tag])
1084507025dSKrishna Gudipati #define BFA_MEM_FCXP_KVA(__bfa) (&(BFA_FCXP_MOD(__bfa)->kva_seg))
109a36c61f9SKrishna Gudipati 
110a36c61f9SKrishna Gudipati typedef void    (*fcxp_send_cb_t) (struct bfa_s *ioc, struct bfa_fcxp_s *fcxp,
111a36c61f9SKrishna Gudipati 				   void *cb_arg, bfa_status_t req_status,
112a36c61f9SKrishna Gudipati 				   u32 rsp_len, u32 resid_len,
113a36c61f9SKrishna Gudipati 				   struct fchs_s *rsp_fchs);
114a36c61f9SKrishna Gudipati 
115a36c61f9SKrishna Gudipati typedef u64 (*bfa_fcxp_get_sgaddr_t) (void *bfad_fcxp, int sgeid);
116a36c61f9SKrishna Gudipati typedef u32 (*bfa_fcxp_get_sglen_t) (void *bfad_fcxp, int sgeid);
117a36c61f9SKrishna Gudipati typedef void (*bfa_cb_fcxp_send_t) (void *bfad_fcxp, struct bfa_fcxp_s *fcxp,
118a36c61f9SKrishna Gudipati 				    void *cbarg, enum bfa_status req_status,
119a36c61f9SKrishna Gudipati 				    u32 rsp_len, u32 resid_len,
120a36c61f9SKrishna Gudipati 				    struct fchs_s *rsp_fchs);
121a36c61f9SKrishna Gudipati typedef void (*bfa_fcxp_alloc_cbfn_t) (void *cbarg, struct bfa_fcxp_s *fcxp);
122a36c61f9SKrishna Gudipati 
123a36c61f9SKrishna Gudipati 
124a36c61f9SKrishna Gudipati 
125acdc79a6SJing Huang /*
126a36c61f9SKrishna Gudipati  * Information needed for a FCXP request
127a36c61f9SKrishna Gudipati  */
128a36c61f9SKrishna Gudipati struct bfa_fcxp_req_info_s {
129a36c61f9SKrishna Gudipati 	struct bfa_rport_s *bfa_rport;
130acdc79a6SJing Huang 					/* Pointer to the bfa rport that was
131a36c61f9SKrishna Gudipati 					 * returned from bfa_rport_create().
132a36c61f9SKrishna Gudipati 					 * This could be left NULL for WKA or
133a36c61f9SKrishna Gudipati 					 * for FCXP interactions before the
134a36c61f9SKrishna Gudipati 					 * rport nexus is established
135a36c61f9SKrishna Gudipati 					 */
136a36c61f9SKrishna Gudipati 	struct fchs_s	fchs;	/*  request FC header structure */
13725985edcSLucas De Marchi 	u8		cts;	/*  continuous sequence */
138a36c61f9SKrishna Gudipati 	u8		class;	/*  FC class for the request/response */
139a36c61f9SKrishna Gudipati 	u16	max_frmsz;	/*  max send frame size */
140a36c61f9SKrishna Gudipati 	u16	vf_id;	/*  vsan tag if applicable */
141a36c61f9SKrishna Gudipati 	u8		lp_tag;	/*  lport tag */
142a36c61f9SKrishna Gudipati 	u32	req_tot_len;	/*  request payload total length */
143a36c61f9SKrishna Gudipati };
144a36c61f9SKrishna Gudipati 
145a36c61f9SKrishna Gudipati struct bfa_fcxp_rsp_info_s {
146a36c61f9SKrishna Gudipati 	struct fchs_s	rsp_fchs;
147acdc79a6SJing Huang 				/* Response frame's FC header will
148a36c61f9SKrishna Gudipati 				 * be sent back in this field */
149a36c61f9SKrishna Gudipati 	u8		rsp_timeout;
150acdc79a6SJing Huang 				/* timeout in seconds, 0-no response */
151a36c61f9SKrishna Gudipati 	u8		rsvd2[3];
152a36c61f9SKrishna Gudipati 	u32	rsp_maxlen;	/*  max response length expected */
153a36c61f9SKrishna Gudipati };
154a36c61f9SKrishna Gudipati 
155a36c61f9SKrishna Gudipati struct bfa_fcxp_s {
156a36c61f9SKrishna Gudipati 	struct list_head	qe;		/*  fcxp queue element */
157a36c61f9SKrishna Gudipati 	bfa_sm_t	sm;		/*  state machine */
158a36c61f9SKrishna Gudipati 	void		*caller;	/*  driver or fcs */
159a36c61f9SKrishna Gudipati 	struct bfa_fcxp_mod_s *fcxp_mod;
160a36c61f9SKrishna Gudipati 	/*  back pointer to fcxp mod */
161a36c61f9SKrishna Gudipati 	u16	fcxp_tag;	/*  internal tag */
162a36c61f9SKrishna Gudipati 	struct bfa_fcxp_req_info_s req_info;
163a36c61f9SKrishna Gudipati 	/*  request info */
164a36c61f9SKrishna Gudipati 	struct bfa_fcxp_rsp_info_s rsp_info;
165a36c61f9SKrishna Gudipati 	/*  response info */
166a36c61f9SKrishna Gudipati 	u8	use_ireqbuf;	/*  use internal req buf */
167a36c61f9SKrishna Gudipati 	u8		use_irspbuf;	/*  use internal rsp buf */
168a36c61f9SKrishna Gudipati 	u32	nreq_sgles;	/*  num request SGLEs */
169a36c61f9SKrishna Gudipati 	u32	nrsp_sgles;	/*  num response SGLEs */
170a36c61f9SKrishna Gudipati 	struct list_head req_sgpg_q;	/*  SG pages for request buf */
171a36c61f9SKrishna Gudipati 	struct list_head req_sgpg_wqe;	/*  wait queue for req SG page */
172a36c61f9SKrishna Gudipati 	struct list_head rsp_sgpg_q;	/*  SG pages for response buf */
173a36c61f9SKrishna Gudipati 	struct list_head rsp_sgpg_wqe;	/*  wait queue for rsp SG page */
174a36c61f9SKrishna Gudipati 
175a36c61f9SKrishna Gudipati 	bfa_fcxp_get_sgaddr_t req_sga_cbfn;
176a36c61f9SKrishna Gudipati 	/*  SG elem addr user function */
177a36c61f9SKrishna Gudipati 	bfa_fcxp_get_sglen_t req_sglen_cbfn;
178a36c61f9SKrishna Gudipati 	/*  SG elem len user function */
179a36c61f9SKrishna Gudipati 	bfa_fcxp_get_sgaddr_t rsp_sga_cbfn;
180a36c61f9SKrishna Gudipati 	/*  SG elem addr user function */
181a36c61f9SKrishna Gudipati 	bfa_fcxp_get_sglen_t rsp_sglen_cbfn;
182a36c61f9SKrishna Gudipati 	/*  SG elem len user function */
183a36c61f9SKrishna Gudipati 	bfa_cb_fcxp_send_t send_cbfn;   /*  send completion callback */
184a36c61f9SKrishna Gudipati 	void		*send_cbarg;	/*  callback arg */
185a36c61f9SKrishna Gudipati 	struct bfa_sge_s   req_sge[BFA_FCXP_MAX_SGES];
186a36c61f9SKrishna Gudipati 	/*  req SG elems */
187a36c61f9SKrishna Gudipati 	struct bfa_sge_s   rsp_sge[BFA_FCXP_MAX_SGES];
188a36c61f9SKrishna Gudipati 	/*  rsp SG elems */
189a36c61f9SKrishna Gudipati 	u8		rsp_status;	/*  comp: rsp status */
190a36c61f9SKrishna Gudipati 	u32	rsp_len;	/*  comp: actual response len */
191a36c61f9SKrishna Gudipati 	u32	residue_len;	/*  comp: residual rsp length */
192a36c61f9SKrishna Gudipati 	struct fchs_s	rsp_fchs;	/*  comp: response fchs */
193a36c61f9SKrishna Gudipati 	struct bfa_cb_qe_s    hcb_qe;	/*  comp: callback qelem */
194a36c61f9SKrishna Gudipati 	struct bfa_reqq_wait_s	reqq_wqe;
195a36c61f9SKrishna Gudipati 	bfa_boolean_t	reqq_waiting;
196c3f1b123SKrishna Gudipati 	bfa_boolean_t	req_rsp;	/* Used to track req/rsp fcxp */
197a36c61f9SKrishna Gudipati };
198a36c61f9SKrishna Gudipati 
199a36c61f9SKrishna Gudipati struct bfa_fcxp_wqe_s {
200a36c61f9SKrishna Gudipati 	struct list_head		qe;
201a36c61f9SKrishna Gudipati 	bfa_fcxp_alloc_cbfn_t	alloc_cbfn;
202a36c61f9SKrishna Gudipati 	void		*alloc_cbarg;
203a36c61f9SKrishna Gudipati 	void		*caller;
204a36c61f9SKrishna Gudipati 	struct bfa_s	*bfa;
205a36c61f9SKrishna Gudipati 	int		nreq_sgles;
206a36c61f9SKrishna Gudipati 	int		nrsp_sgles;
207a36c61f9SKrishna Gudipati 	bfa_fcxp_get_sgaddr_t	req_sga_cbfn;
208a36c61f9SKrishna Gudipati 	bfa_fcxp_get_sglen_t	req_sglen_cbfn;
209a36c61f9SKrishna Gudipati 	bfa_fcxp_get_sgaddr_t	rsp_sga_cbfn;
210a36c61f9SKrishna Gudipati 	bfa_fcxp_get_sglen_t	rsp_sglen_cbfn;
211a36c61f9SKrishna Gudipati };
212a36c61f9SKrishna Gudipati 
213a36c61f9SKrishna Gudipati #define BFA_FCXP_REQ_PLD(_fcxp)		(bfa_fcxp_get_reqbuf(_fcxp))
214a36c61f9SKrishna Gudipati #define BFA_FCXP_RSP_FCHS(_fcxp)	(&((_fcxp)->rsp_info.fchs))
215a36c61f9SKrishna Gudipati #define BFA_FCXP_RSP_PLD(_fcxp)		(bfa_fcxp_get_rspbuf(_fcxp))
216a36c61f9SKrishna Gudipati 
217a36c61f9SKrishna Gudipati #define BFA_FCXP_REQ_PLD_PA(_fcxp)					      \
2184507025dSKrishna Gudipati 	bfa_mem_get_dmabuf_pa((_fcxp)->fcxp_mod, (_fcxp)->fcxp_tag,	      \
2194507025dSKrishna Gudipati 		(_fcxp)->fcxp_mod->req_pld_sz + (_fcxp)->fcxp_mod->rsp_pld_sz)
220a36c61f9SKrishna Gudipati 
2214507025dSKrishna Gudipati /* fcxp_buf = req_buf + rsp_buf :- add req_buf_sz to get to rsp_buf */
222a36c61f9SKrishna Gudipati #define BFA_FCXP_RSP_PLD_PA(_fcxp)					       \
2234507025dSKrishna Gudipati 	(bfa_mem_get_dmabuf_pa((_fcxp)->fcxp_mod, (_fcxp)->fcxp_tag,	       \
2244507025dSKrishna Gudipati 	      (_fcxp)->fcxp_mod->req_pld_sz + (_fcxp)->fcxp_mod->rsp_pld_sz) + \
2254507025dSKrishna Gudipati 	      (_fcxp)->fcxp_mod->req_pld_sz)
226a36c61f9SKrishna Gudipati 
227a36c61f9SKrishna Gudipati void	bfa_fcxp_isr(struct bfa_s *bfa, struct bfi_msg_s *msg);
228a36c61f9SKrishna Gudipati 
229a36c61f9SKrishna Gudipati #define BFA_RPORT_MIN	4
230a36c61f9SKrishna Gudipati 
231a36c61f9SKrishna Gudipati struct bfa_rport_mod_s {
232a36c61f9SKrishna Gudipati 	struct bfa_rport_s *rps_list;	/*  list of rports	*/
233a36c61f9SKrishna Gudipati 	struct list_head	rp_free_q;	/*  free bfa_rports	*/
234a36c61f9SKrishna Gudipati 	struct list_head	rp_active_q;	/*  free bfa_rports	*/
2353fd45980SKrishna Gudipati 	struct list_head	rp_unused_q;	/*  unused bfa rports  */
236a36c61f9SKrishna Gudipati 	u16	num_rports;	/*  number of rports	*/
2374507025dSKrishna Gudipati 	struct bfa_mem_kva_s	kva_seg;
238a36c61f9SKrishna Gudipati };
239a36c61f9SKrishna Gudipati 
240a36c61f9SKrishna Gudipati #define BFA_RPORT_MOD(__bfa)	(&(__bfa)->modules.rport_mod)
2414507025dSKrishna Gudipati #define BFA_MEM_RPORT_KVA(__bfa) (&(BFA_RPORT_MOD(__bfa)->kva_seg))
242a36c61f9SKrishna Gudipati 
243acdc79a6SJing Huang /*
244a36c61f9SKrishna Gudipati  * Convert rport tag to RPORT
245a36c61f9SKrishna Gudipati  */
246a36c61f9SKrishna Gudipati #define BFA_RPORT_FROM_TAG(__bfa, _tag)				\
247a36c61f9SKrishna Gudipati 	(BFA_RPORT_MOD(__bfa)->rps_list +			\
248a36c61f9SKrishna Gudipati 	 ((_tag) & (BFA_RPORT_MOD(__bfa)->num_rports - 1)))
249a36c61f9SKrishna Gudipati 
250a36c61f9SKrishna Gudipati /*
251a36c61f9SKrishna Gudipati  * protected functions
252a36c61f9SKrishna Gudipati  */
253a36c61f9SKrishna Gudipati void	bfa_rport_isr(struct bfa_s *bfa, struct bfi_msg_s *msg);
2543fd45980SKrishna Gudipati void	bfa_rport_res_recfg(struct bfa_s *bfa, u16 num_rport_fw);
255a36c61f9SKrishna Gudipati 
256acdc79a6SJing Huang /*
257a36c61f9SKrishna Gudipati  *	BFA rport information.
258a36c61f9SKrishna Gudipati  */
259a36c61f9SKrishna Gudipati struct bfa_rport_info_s {
260a36c61f9SKrishna Gudipati 	u16	max_frmsz;	/*  max rcv pdu size		    */
261a36c61f9SKrishna Gudipati 	u32	pid:24,	/*  remote port ID		    */
262a36c61f9SKrishna Gudipati 		lp_tag:8;	/*  tag			    */
263a36c61f9SKrishna Gudipati 	u32	local_pid:24,	/*  local port ID		    */
264a36c61f9SKrishna Gudipati 		cisc:8;	/*  CIRO supported		    */
265a36c61f9SKrishna Gudipati 	u8	fc_class;	/*  supported FC classes. enum fc_cos */
266a36c61f9SKrishna Gudipati 	u8	vf_en;		/*  virtual fabric enable	    */
267a36c61f9SKrishna Gudipati 	u16	vf_id;		/*  virtual fabric ID		    */
268a36c61f9SKrishna Gudipati 	enum bfa_port_speed speed;	/*  Rport's current speed	    */
269a36c61f9SKrishna Gudipati };
270a36c61f9SKrishna Gudipati 
271acdc79a6SJing Huang /*
272*37126399SArnd Bergmann  * RPORT related defines
273*37126399SArnd Bergmann  */
274*37126399SArnd Bergmann enum bfa_rport_event {
275*37126399SArnd Bergmann 	BFA_RPORT_SM_CREATE	= 1,	/*  rport create event          */
276*37126399SArnd Bergmann 	BFA_RPORT_SM_DELETE	= 2,	/*  deleting an existing rport  */
277*37126399SArnd Bergmann 	BFA_RPORT_SM_ONLINE	= 3,	/*  rport is online             */
278*37126399SArnd Bergmann 	BFA_RPORT_SM_OFFLINE	= 4,	/*  rport is offline            */
279*37126399SArnd Bergmann 	BFA_RPORT_SM_FWRSP	= 5,	/*  firmware response           */
280*37126399SArnd Bergmann 	BFA_RPORT_SM_HWFAIL	= 6,	/*  IOC h/w failure             */
281*37126399SArnd Bergmann 	BFA_RPORT_SM_QOS_SCN	= 7,	/*  QoS SCN from firmware       */
282*37126399SArnd Bergmann 	BFA_RPORT_SM_SET_SPEED	= 8,	/*  Set Rport Speed             */
283*37126399SArnd Bergmann 	BFA_RPORT_SM_QRESUME	= 9,	/*  space in requeue queue      */
284*37126399SArnd Bergmann };
285*37126399SArnd Bergmann 
286*37126399SArnd Bergmann struct bfa_rport_s;
287*37126399SArnd Bergmann typedef void (*bfa_rport_sm_t)(struct bfa_rport_s *, enum bfa_rport_event);
288*37126399SArnd Bergmann 
289*37126399SArnd Bergmann /*
290a36c61f9SKrishna Gudipati  * BFA rport data structure
291a36c61f9SKrishna Gudipati  */
292a36c61f9SKrishna Gudipati struct bfa_rport_s {
293a36c61f9SKrishna Gudipati 	struct list_head	qe;	/*  queue element		    */
294*37126399SArnd Bergmann 	bfa_rport_sm_t	sm;		/*  state machine		    */
295a36c61f9SKrishna Gudipati 	struct bfa_s	*bfa;		/*  backpointer to BFA		    */
296a36c61f9SKrishna Gudipati 	void		*rport_drv;	/*  fcs/driver rport object	    */
297a36c61f9SKrishna Gudipati 	u16	fw_handle;	/*  firmware rport handle	    */
298a36c61f9SKrishna Gudipati 	u16	rport_tag;	/*  BFA rport tag		    */
29983763d59SKrishna Gudipati 	u8	lun_mask;	/*  LUN mask flag		    */
300a36c61f9SKrishna Gudipati 	struct bfa_rport_info_s rport_info; /*  rport info from fcs/driver */
301a36c61f9SKrishna Gudipati 	struct bfa_reqq_wait_s reqq_wait; /*  to wait for room in reqq     */
302a36c61f9SKrishna Gudipati 	struct bfa_cb_qe_s hcb_qe;	/*  BFA callback qelem		    */
303a36c61f9SKrishna Gudipati 	struct bfa_rport_hal_stats_s stats; /*  BFA rport statistics	    */
304a36c61f9SKrishna Gudipati 	struct bfa_rport_qos_attr_s qos_attr;
305a36c61f9SKrishna Gudipati 	union a {
306a36c61f9SKrishna Gudipati 		bfa_status_t	status;	/*  f/w status */
307a36c61f9SKrishna Gudipati 		void		*fw_msg; /*  QoS scn event		    */
308a36c61f9SKrishna Gudipati 	} event_arg;
309a36c61f9SKrishna Gudipati };
310a36c61f9SKrishna Gudipati #define BFA_RPORT_FC_COS(_rport)	((_rport)->rport_info.fc_class)
311a36c61f9SKrishna Gudipati 
312a36c61f9SKrishna Gudipati 
313acdc79a6SJing Huang /*
314a36c61f9SKrishna Gudipati  * UF - unsolicited receive related defines
315a36c61f9SKrishna Gudipati  */
316a36c61f9SKrishna Gudipati 
317a36c61f9SKrishna Gudipati #define BFA_UF_MIN	(4)
3184507025dSKrishna Gudipati #define BFA_UF_MAX	(256)
319a36c61f9SKrishna Gudipati 
320a36c61f9SKrishna Gudipati struct bfa_uf_s {
321a36c61f9SKrishna Gudipati 	struct list_head	qe;	/*  queue element		*/
322a36c61f9SKrishna Gudipati 	struct bfa_s		*bfa;	/*  bfa instance		*/
323a36c61f9SKrishna Gudipati 	u16	uf_tag;		/*  identifying tag fw msgs	*/
324a36c61f9SKrishna Gudipati 	u16	vf_id;
325a36c61f9SKrishna Gudipati 	u16	src_rport_handle;
326a36c61f9SKrishna Gudipati 	u16	rsvd;
327a36c61f9SKrishna Gudipati 	u8		*data_ptr;
328a36c61f9SKrishna Gudipati 	u16	data_len;	/*  actual receive length	*/
329a36c61f9SKrishna Gudipati 	u16	pb_len;		/*  posted buffer length	*/
330a36c61f9SKrishna Gudipati 	void		*buf_kva;	/*  buffer virtual address	*/
331a36c61f9SKrishna Gudipati 	u64	buf_pa;		/*  buffer physical address	*/
332a36c61f9SKrishna Gudipati 	struct bfa_cb_qe_s hcb_qe;	/*  comp: BFA comp qelem	*/
333a36c61f9SKrishna Gudipati 	struct bfa_sge_s sges[BFI_SGE_INLINE_MAX];
334a36c61f9SKrishna Gudipati };
335a36c61f9SKrishna Gudipati 
336acdc79a6SJing Huang /*
337a36c61f9SKrishna Gudipati  *      Callback prototype for unsolicited frame receive handler.
338a36c61f9SKrishna Gudipati  *
339a36c61f9SKrishna Gudipati  * @param[in]           cbarg           callback arg for receive handler
340a36c61f9SKrishna Gudipati  * @param[in]           uf              unsolicited frame descriptor
341a36c61f9SKrishna Gudipati  *
342a36c61f9SKrishna Gudipati  * @return None
343a36c61f9SKrishna Gudipati  */
344a36c61f9SKrishna Gudipati typedef void (*bfa_cb_uf_recv_t) (void *cbarg, struct bfa_uf_s *uf);
345a36c61f9SKrishna Gudipati 
3464507025dSKrishna Gudipati #define BFA_UF_BUFSZ	(2 * 1024 + 256)
3474507025dSKrishna Gudipati 
3484507025dSKrishna Gudipati struct bfa_uf_buf_s {
3494507025dSKrishna Gudipati 	u8	d[BFA_UF_BUFSZ];
3504507025dSKrishna Gudipati };
3514507025dSKrishna Gudipati 
3524507025dSKrishna Gudipati #define BFA_PER_UF_DMA_SZ	\
3534507025dSKrishna Gudipati 	(u32)BFA_ROUNDUP(sizeof(struct bfa_uf_buf_s), BFA_DMA_ALIGN_SZ)
3544507025dSKrishna Gudipati 
3554507025dSKrishna Gudipati /* Max UF dma segs required */
3564507025dSKrishna Gudipati #define BFA_UF_DMA_SEGS BFI_MEM_DMA_NSEGS(BFA_UF_MAX, BFA_PER_UF_DMA_SZ)
3574507025dSKrishna Gudipati 
358a36c61f9SKrishna Gudipati struct bfa_uf_mod_s {
359a36c61f9SKrishna Gudipati 	struct bfa_s *bfa;		/*  back pointer to BFA */
360a36c61f9SKrishna Gudipati 	struct bfa_uf_s *uf_list;	/*  array of UFs */
361a36c61f9SKrishna Gudipati 	u16	num_ufs;	/*  num unsolicited rx frames */
362a36c61f9SKrishna Gudipati 	struct list_head	uf_free_q;	/*  free UFs */
363a36c61f9SKrishna Gudipati 	struct list_head	uf_posted_q;	/*  UFs posted to IOC */
3643fd45980SKrishna Gudipati 	struct list_head	uf_unused_q;	/*  unused UF's */
365a36c61f9SKrishna Gudipati 	struct bfi_uf_buf_post_s *uf_buf_posts;
366a36c61f9SKrishna Gudipati 	/*  pre-built UF post msgs */
367a36c61f9SKrishna Gudipati 	bfa_cb_uf_recv_t ufrecv;	/*  uf recv handler function */
368a36c61f9SKrishna Gudipati 	void		*cbarg;		/*  uf receive handler arg */
3694507025dSKrishna Gudipati 	struct bfa_mem_dma_s	dma_seg[BFA_UF_DMA_SEGS];
3704507025dSKrishna Gudipati 	struct bfa_mem_kva_s	kva_seg;
371a36c61f9SKrishna Gudipati };
372a36c61f9SKrishna Gudipati 
373a36c61f9SKrishna Gudipati #define BFA_UF_MOD(__bfa)	(&(__bfa)->modules.uf_mod)
3744507025dSKrishna Gudipati #define BFA_MEM_UF_KVA(__bfa)	(&(BFA_UF_MOD(__bfa)->kva_seg))
375a36c61f9SKrishna Gudipati 
376a36c61f9SKrishna Gudipati #define ufm_pbs_pa(_ufmod, _uftag)					\
3774507025dSKrishna Gudipati 	bfa_mem_get_dmabuf_pa(_ufmod, _uftag, BFA_PER_UF_DMA_SZ)
378a36c61f9SKrishna Gudipati 
379a36c61f9SKrishna Gudipati void	bfa_uf_isr(struct bfa_s *bfa, struct bfi_msg_s *msg);
3803fd45980SKrishna Gudipati void	bfa_uf_res_recfg(struct bfa_s *bfa, u16 num_uf_fw);
381a36c61f9SKrishna Gudipati 
382acdc79a6SJing Huang /*
383*37126399SArnd Bergmann  *  lps_pvt BFA LPS private functions
384*37126399SArnd Bergmann  */
385*37126399SArnd Bergmann 
386*37126399SArnd Bergmann enum bfa_lps_event {
387*37126399SArnd Bergmann 	BFA_LPS_SM_LOGIN	= 1,	/* login request from user      */
388*37126399SArnd Bergmann 	BFA_LPS_SM_LOGOUT	= 2,	/* logout request from user     */
389*37126399SArnd Bergmann 	BFA_LPS_SM_FWRSP	= 3,	/* f/w response to login/logout */
390*37126399SArnd Bergmann 	BFA_LPS_SM_RESUME	= 4,	/* space present in reqq queue  */
391*37126399SArnd Bergmann 	BFA_LPS_SM_DELETE	= 5,	/* lps delete from user         */
392*37126399SArnd Bergmann 	BFA_LPS_SM_OFFLINE	= 6,	/* Link is offline              */
393*37126399SArnd Bergmann 	BFA_LPS_SM_RX_CVL	= 7,	/* Rx clear virtual link        */
394*37126399SArnd Bergmann 	BFA_LPS_SM_SET_N2N_PID  = 8,	/* Set assigned PID for n2n */
395*37126399SArnd Bergmann };
396*37126399SArnd Bergmann 
397*37126399SArnd Bergmann struct bfa_lps_s;
398*37126399SArnd Bergmann typedef void (*bfa_lps_sm_t)(struct bfa_lps_s *, enum bfa_lps_event);
399*37126399SArnd Bergmann 
400*37126399SArnd Bergmann /*
401a36c61f9SKrishna Gudipati  * LPS - bfa lport login/logout service interface
402a36c61f9SKrishna Gudipati  */
403a36c61f9SKrishna Gudipati struct bfa_lps_s {
404a36c61f9SKrishna Gudipati 	struct list_head	qe;	/*  queue element		*/
405a36c61f9SKrishna Gudipati 	struct bfa_s	*bfa;		/*  parent bfa instance	*/
406*37126399SArnd Bergmann 	bfa_lps_sm_t	sm;		/*  finite state machine	*/
4073fd45980SKrishna Gudipati 	u8		bfa_tag;	/*  lport tag		*/
4083fd45980SKrishna Gudipati 	u8		fw_tag;		/*  lport fw tag                */
409a36c61f9SKrishna Gudipati 	u8		reqq;		/*  lport request queue	*/
410a36c61f9SKrishna Gudipati 	u8		alpa;		/*  ALPA for loop topologies	*/
411a36c61f9SKrishna Gudipati 	u32	lp_pid;		/*  lport port ID		*/
412a36c61f9SKrishna Gudipati 	bfa_boolean_t	fdisc;		/*  snd FDISC instead of FLOGI	*/
413a36c61f9SKrishna Gudipati 	bfa_boolean_t	auth_en;	/*  enable authentication	*/
414a36c61f9SKrishna Gudipati 	bfa_boolean_t	auth_req;	/*  authentication required	*/
415a36c61f9SKrishna Gudipati 	bfa_boolean_t	npiv_en;	/*  NPIV is allowed by peer	*/
416a36c61f9SKrishna Gudipati 	bfa_boolean_t	fport;		/*  attached peer is F_PORT	*/
417a36c61f9SKrishna Gudipati 	bfa_boolean_t	brcd_switch;	/*  attached peer is brcd sw	*/
418a36c61f9SKrishna Gudipati 	bfa_status_t	status;		/*  login status		*/
419a36c61f9SKrishna Gudipati 	u16		pdusz;		/*  max receive PDU size	*/
420a36c61f9SKrishna Gudipati 	u16		pr_bbcred;	/*  BB_CREDIT from peer		*/
421a36c61f9SKrishna Gudipati 	u8		lsrjt_rsn;	/*  LSRJT reason		*/
422a36c61f9SKrishna Gudipati 	u8		lsrjt_expl;	/*  LSRJT explanation		*/
42383763d59SKrishna Gudipati 	u8		lun_mask;	/*  LUN mask flag		*/
424a36c61f9SKrishna Gudipati 	wwn_t		pwwn;		/*  port wwn of lport		*/
425a36c61f9SKrishna Gudipati 	wwn_t		nwwn;		/*  node wwn of lport		*/
426a36c61f9SKrishna Gudipati 	wwn_t		pr_pwwn;	/*  port wwn of lport peer	*/
427a36c61f9SKrishna Gudipati 	wwn_t		pr_nwwn;	/*  node wwn of lport peer	*/
428a36c61f9SKrishna Gudipati 	mac_t		lp_mac;		/*  fpma/spma MAC for lport	*/
429a36c61f9SKrishna Gudipati 	mac_t		fcf_mac;	/*  FCF MAC of lport		*/
430a36c61f9SKrishna Gudipati 	struct bfa_reqq_wait_s	wqe;	/*  request wait queue element	*/
431a36c61f9SKrishna Gudipati 	void		*uarg;		/*  user callback arg		*/
432a36c61f9SKrishna Gudipati 	struct bfa_cb_qe_s hcb_qe;	/*  comp: callback qelem	*/
433a36c61f9SKrishna Gudipati 	struct bfi_lps_login_rsp_s *loginrsp;
434a36c61f9SKrishna Gudipati 	bfa_eproto_status_t ext_status;
435a36c61f9SKrishna Gudipati };
436a36c61f9SKrishna Gudipati 
437a36c61f9SKrishna Gudipati struct bfa_lps_mod_s {
438a36c61f9SKrishna Gudipati 	struct list_head		lps_free_q;
439a36c61f9SKrishna Gudipati 	struct list_head		lps_active_q;
4403fd45980SKrishna Gudipati 	struct list_head		lps_login_q;
441a36c61f9SKrishna Gudipati 	struct bfa_lps_s	*lps_arr;
442a36c61f9SKrishna Gudipati 	int			num_lps;
4434507025dSKrishna Gudipati 	struct bfa_mem_kva_s	kva_seg;
444a36c61f9SKrishna Gudipati };
445a36c61f9SKrishna Gudipati 
446a36c61f9SKrishna Gudipati #define BFA_LPS_MOD(__bfa)		(&(__bfa)->modules.lps_mod)
447a36c61f9SKrishna Gudipati #define BFA_LPS_FROM_TAG(__mod, __tag)	(&(__mod)->lps_arr[__tag])
4484507025dSKrishna Gudipati #define BFA_MEM_LPS_KVA(__bfa)	(&(BFA_LPS_MOD(__bfa)->kva_seg))
449a36c61f9SKrishna Gudipati 
450a36c61f9SKrishna Gudipati /*
451a36c61f9SKrishna Gudipati  * external functions
452a36c61f9SKrishna Gudipati  */
453a36c61f9SKrishna Gudipati void	bfa_lps_isr(struct bfa_s *bfa, struct bfi_msg_s *msg);
454a36c61f9SKrishna Gudipati 
455a36c61f9SKrishna Gudipati 
456acdc79a6SJing Huang /*
457a36c61f9SKrishna Gudipati  * FCPORT related defines
458a36c61f9SKrishna Gudipati  */
459a36c61f9SKrishna Gudipati 
460a36c61f9SKrishna Gudipati #define BFA_FCPORT(_bfa)	(&((_bfa)->modules.port))
461a36c61f9SKrishna Gudipati 
462acdc79a6SJing Huang /*
463*37126399SArnd Bergmann  * BFA port link notification state machine events
464*37126399SArnd Bergmann  */
465*37126399SArnd Bergmann 
466*37126399SArnd Bergmann enum bfa_fcport_ln_sm_event {
467*37126399SArnd Bergmann 	BFA_FCPORT_LN_SM_LINKUP		= 1,	/*  linkup event	*/
468*37126399SArnd Bergmann 	BFA_FCPORT_LN_SM_LINKDOWN	= 2,	/*  linkdown event	*/
469*37126399SArnd Bergmann 	BFA_FCPORT_LN_SM_NOTIFICATION	= 3	/*  done notification	*/
470*37126399SArnd Bergmann };
471*37126399SArnd Bergmann 
472*37126399SArnd Bergmann struct bfa_fcport_ln_s;
473*37126399SArnd Bergmann typedef void (*bfa_fcport_ln_sm_t)(struct bfa_fcport_ln_s *, enum bfa_fcport_ln_sm_event);
474*37126399SArnd Bergmann 
475*37126399SArnd Bergmann /*
476a36c61f9SKrishna Gudipati  * Link notification data structure
477a36c61f9SKrishna Gudipati  */
478a36c61f9SKrishna Gudipati struct bfa_fcport_ln_s {
479a36c61f9SKrishna Gudipati 	struct bfa_fcport_s	*fcport;
480*37126399SArnd Bergmann 	bfa_fcport_ln_sm_t	sm;
481a36c61f9SKrishna Gudipati 	struct bfa_cb_qe_s	ln_qe;	/*  BFA callback queue elem for ln */
482a36c61f9SKrishna Gudipati 	enum bfa_port_linkstate ln_event; /*  ln event for callback */
483a36c61f9SKrishna Gudipati };
484a36c61f9SKrishna Gudipati 
485a36c61f9SKrishna Gudipati struct bfa_fcport_trunk_s {
486a36c61f9SKrishna Gudipati 	struct bfa_trunk_attr_s	attr;
487a36c61f9SKrishna Gudipati };
488a36c61f9SKrishna Gudipati 
489acdc79a6SJing Huang /*
490*37126399SArnd Bergmann  * BFA port state machine events
491*37126399SArnd Bergmann  */
492*37126399SArnd Bergmann enum bfa_fcport_sm_event {
493*37126399SArnd Bergmann 	BFA_FCPORT_SM_START	= 1,	/*  start port state machine	*/
494*37126399SArnd Bergmann 	BFA_FCPORT_SM_STOP	= 2,	/*  stop port state machine	*/
495*37126399SArnd Bergmann 	BFA_FCPORT_SM_ENABLE	= 3,	/*  enable port		*/
496*37126399SArnd Bergmann 	BFA_FCPORT_SM_DISABLE	= 4,	/*  disable port state machine */
497*37126399SArnd Bergmann 	BFA_FCPORT_SM_FWRSP	= 5,	/*  firmware enable/disable rsp */
498*37126399SArnd Bergmann 	BFA_FCPORT_SM_LINKUP	= 6,	/*  firmware linkup event	*/
499*37126399SArnd Bergmann 	BFA_FCPORT_SM_LINKDOWN	= 7,	/*  firmware linkup down	*/
500*37126399SArnd Bergmann 	BFA_FCPORT_SM_QRESUME	= 8,	/*  CQ space available	*/
501*37126399SArnd Bergmann 	BFA_FCPORT_SM_HWFAIL	= 9,	/*  IOC h/w failure		*/
502*37126399SArnd Bergmann 	BFA_FCPORT_SM_DPORTENABLE = 10, /*  enable dport      */
503*37126399SArnd Bergmann 	BFA_FCPORT_SM_DPORTDISABLE = 11,/*  disable dport     */
504*37126399SArnd Bergmann 	BFA_FCPORT_SM_FAA_MISCONFIG = 12,	/* FAA misconfiguratin */
505*37126399SArnd Bergmann 	BFA_FCPORT_SM_DDPORTENABLE  = 13,	/* enable ddport	*/
506*37126399SArnd Bergmann 	BFA_FCPORT_SM_DDPORTDISABLE = 14,	/* disable ddport	*/
507*37126399SArnd Bergmann };
508*37126399SArnd Bergmann 
509*37126399SArnd Bergmann struct bfa_fcport_s;
510*37126399SArnd Bergmann typedef void (*bfa_fcport_sm_t)(struct bfa_fcport_s *, enum bfa_fcport_sm_event);
511*37126399SArnd Bergmann 
512*37126399SArnd Bergmann /*
513a36c61f9SKrishna Gudipati  * BFA FC port data structure
514a36c61f9SKrishna Gudipati  */
515a36c61f9SKrishna Gudipati struct bfa_fcport_s {
516a36c61f9SKrishna Gudipati 	struct bfa_s		*bfa;	/*  parent BFA instance */
517*37126399SArnd Bergmann 	bfa_fcport_sm_t		sm;	/*  port state machine */
518a36c61f9SKrishna Gudipati 	wwn_t			nwwn;	/*  node wwn of physical port */
519a36c61f9SKrishna Gudipati 	wwn_t			pwwn;	/*  port wwn of physical oprt */
520a36c61f9SKrishna Gudipati 	enum bfa_port_speed speed_sup;
521a36c61f9SKrishna Gudipati 	/*  supported speeds */
522a36c61f9SKrishna Gudipati 	enum bfa_port_speed speed;	/*  current speed */
523a36c61f9SKrishna Gudipati 	enum bfa_port_topology topology;	/*  current topology */
524a36c61f9SKrishna Gudipati 	u8			rsvd[3];
525bc0e2c2aSKrishna Gudipati 	u8			myalpa;	/*  my ALPA in LOOP topology */
526bc0e2c2aSKrishna Gudipati 	u8			alpabm_valid; /* alpa bitmap valid or not */
527bc0e2c2aSKrishna Gudipati 	struct fc_alpabm_s	alpabm;	/* alpa bitmap */
528a36c61f9SKrishna Gudipati 	struct bfa_port_cfg_s	cfg;	/*  current port configuration */
529f3a060caSKrishna Gudipati 	bfa_boolean_t		use_flash_cfg; /* get port cfg from flash */
530a36c61f9SKrishna Gudipati 	struct bfa_qos_attr_s  qos_attr;   /* QoS Attributes */
531a36c61f9SKrishna Gudipati 	struct bfa_qos_vc_attr_s qos_vc_attr;  /*  VC info from ELP */
532a36c61f9SKrishna Gudipati 	struct bfa_reqq_wait_s	reqq_wait;
533a36c61f9SKrishna Gudipati 	/*  to wait for room in reqq */
534a36c61f9SKrishna Gudipati 	struct bfa_reqq_wait_s	svcreq_wait;
535a36c61f9SKrishna Gudipati 	/*  to wait for room in reqq */
536a36c61f9SKrishna Gudipati 	struct bfa_reqq_wait_s	stats_reqq_wait;
537a36c61f9SKrishna Gudipati 	/*  to wait for room in reqq (stats) */
538a36c61f9SKrishna Gudipati 	void			*event_cbarg;
539a36c61f9SKrishna Gudipati 	void			(*event_cbfn) (void *cbarg,
540a36c61f9SKrishna Gudipati 					       enum bfa_port_linkstate event);
541a36c61f9SKrishna Gudipati 	union {
542a36c61f9SKrishna Gudipati 		union bfi_fcport_i2h_msg_u i2hmsg;
543a36c61f9SKrishna Gudipati 	} event_arg;
544a36c61f9SKrishna Gudipati 	void			*bfad;	/*  BFA driver handle */
545a36c61f9SKrishna Gudipati 	struct bfa_fcport_ln_s	ln; /*  Link Notification */
546a36c61f9SKrishna Gudipati 	struct bfa_cb_qe_s	hcb_qe;	/*  BFA callback queue elem */
547a36c61f9SKrishna Gudipati 	struct bfa_timer_s	timer;	/*  timer */
548a36c61f9SKrishna Gudipati 	u32		msgtag;	/*  fimrware msg tag for reply */
549a36c61f9SKrishna Gudipati 	u8			*stats_kva;
550a36c61f9SKrishna Gudipati 	u64		stats_pa;
551a36c61f9SKrishna Gudipati 	union bfa_fcport_stats_u *stats;
552a36c61f9SKrishna Gudipati 	bfa_status_t		stats_status; /*  stats/statsclr status */
55337ea0558SKrishna Gudipati 	struct list_head	stats_pending_q;
55437ea0558SKrishna Gudipati 	struct list_head	statsclr_pending_q;
555a36c61f9SKrishna Gudipati 	bfa_boolean_t		stats_qfull;
5568f604a03SArnd Bergmann 	time64_t		stats_reset_time; /*  stats reset time stamp */
557a36c61f9SKrishna Gudipati 	bfa_boolean_t		diag_busy; /*  diag busy status */
558a36c61f9SKrishna Gudipati 	bfa_boolean_t		beacon; /*  port beacon status */
559a36c61f9SKrishna Gudipati 	bfa_boolean_t		link_e2e_beacon; /*  link beacon status */
560a36c61f9SKrishna Gudipati 	struct bfa_fcport_trunk_s trunk;
561a36c61f9SKrishna Gudipati 	u16		fcoe_vlan;
5624507025dSKrishna Gudipati 	struct bfa_mem_dma_s	fcport_dma;
5636894f013SKrishna Gudipati 	bfa_boolean_t		stats_dma_ready;
564bbe37a67SVijaya Mohan Guvva 	struct bfa_bbcr_attr_s	bbcr_attr;
5654e1e0d8dSVijaya Mohan Guvva 	enum bfa_fec_state_s	fec_state;
566a36c61f9SKrishna Gudipati };
567a36c61f9SKrishna Gudipati 
568a36c61f9SKrishna Gudipati #define BFA_FCPORT_MOD(__bfa)	(&(__bfa)->modules.fcport)
5694507025dSKrishna Gudipati #define BFA_MEM_FCPORT_DMA(__bfa) (&(BFA_FCPORT_MOD(__bfa)->fcport_dma))
570a36c61f9SKrishna Gudipati 
571a36c61f9SKrishna Gudipati /*
572a36c61f9SKrishna Gudipati  * protected functions
573a36c61f9SKrishna Gudipati  */
574a36c61f9SKrishna Gudipati void bfa_fcport_init(struct bfa_s *bfa);
575a36c61f9SKrishna Gudipati void bfa_fcport_isr(struct bfa_s *bfa, struct bfi_msg_s *msg);
576a36c61f9SKrishna Gudipati 
577a36c61f9SKrishna Gudipati /*
578a36c61f9SKrishna Gudipati  * bfa fcport API functions
579a36c61f9SKrishna Gudipati  */
580a36c61f9SKrishna Gudipati bfa_status_t bfa_fcport_enable(struct bfa_s *bfa);
581a36c61f9SKrishna Gudipati bfa_status_t bfa_fcport_disable(struct bfa_s *bfa);
582a36c61f9SKrishna Gudipati bfa_status_t bfa_fcport_cfg_speed(struct bfa_s *bfa,
583a36c61f9SKrishna Gudipati 				  enum bfa_port_speed speed);
584a36c61f9SKrishna Gudipati enum bfa_port_speed bfa_fcport_get_speed(struct bfa_s *bfa);
585a36c61f9SKrishna Gudipati bfa_status_t bfa_fcport_cfg_topology(struct bfa_s *bfa,
586a36c61f9SKrishna Gudipati 				     enum bfa_port_topology topo);
587a36c61f9SKrishna Gudipati enum bfa_port_topology bfa_fcport_get_topology(struct bfa_s *bfa);
588bc0e2c2aSKrishna Gudipati enum bfa_port_topology bfa_fcport_get_cfg_topology(struct bfa_s *bfa);
589a36c61f9SKrishna Gudipati bfa_status_t bfa_fcport_cfg_hardalpa(struct bfa_s *bfa, u8 alpa);
590a36c61f9SKrishna Gudipati bfa_boolean_t bfa_fcport_get_hardalpa(struct bfa_s *bfa, u8 *alpa);
591a36c61f9SKrishna Gudipati u8 bfa_fcport_get_myalpa(struct bfa_s *bfa);
592a36c61f9SKrishna Gudipati bfa_status_t bfa_fcport_clr_hardalpa(struct bfa_s *bfa);
593a36c61f9SKrishna Gudipati bfa_status_t bfa_fcport_cfg_maxfrsize(struct bfa_s *bfa, u16 maxsize);
594a36c61f9SKrishna Gudipati u16 bfa_fcport_get_maxfrsize(struct bfa_s *bfa);
595a36c61f9SKrishna Gudipati u8 bfa_fcport_get_rx_bbcredit(struct bfa_s *bfa);
596a36c61f9SKrishna Gudipati void bfa_fcport_get_attr(struct bfa_s *bfa, struct bfa_port_attr_s *attr);
597a36c61f9SKrishna Gudipati wwn_t bfa_fcport_get_wwn(struct bfa_s *bfa, bfa_boolean_t node);
598a36c61f9SKrishna Gudipati void bfa_fcport_event_register(struct bfa_s *bfa,
599a36c61f9SKrishna Gudipati 			void (*event_cbfn) (void *cbarg,
600a36c61f9SKrishna Gudipati 			enum bfa_port_linkstate event), void *event_cbarg);
601a36c61f9SKrishna Gudipati bfa_boolean_t bfa_fcport_is_disabled(struct bfa_s *bfa);
602e353546eSKrishna Gudipati bfa_boolean_t bfa_fcport_is_dport(struct bfa_s *bfa);
6031a898a79SVijaya Mohan Guvva bfa_boolean_t bfa_fcport_is_ddport(struct bfa_s *bfa);
6046894f013SKrishna Gudipati bfa_status_t bfa_fcport_set_qos_bw(struct bfa_s *bfa,
6056894f013SKrishna Gudipati 				   struct bfa_qos_bw_s *qos_bw);
606a36c61f9SKrishna Gudipati enum bfa_port_speed bfa_fcport_get_ratelim_speed(struct bfa_s *bfa);
607a36c61f9SKrishna Gudipati 
608bbe37a67SVijaya Mohan Guvva void bfa_fcport_set_tx_bbcredit(struct bfa_s *bfa, u16 tx_bbcredit);
609a36c61f9SKrishna Gudipati bfa_boolean_t     bfa_fcport_is_ratelim(struct bfa_s *bfa);
6103d7fc66dSKrishna Gudipati void bfa_fcport_beacon(void *dev, bfa_boolean_t beacon,
6113d7fc66dSKrishna Gudipati 			bfa_boolean_t link_e2e_beacon);
612a36c61f9SKrishna Gudipati bfa_boolean_t	bfa_fcport_is_linkup(struct bfa_s *bfa);
613a36c61f9SKrishna Gudipati bfa_status_t bfa_fcport_get_stats(struct bfa_s *bfa,
61437ea0558SKrishna Gudipati 			struct bfa_cb_pending_q_s *cb);
61537ea0558SKrishna Gudipati bfa_status_t bfa_fcport_clear_stats(struct bfa_s *bfa,
61637ea0558SKrishna Gudipati 			struct bfa_cb_pending_q_s *cb);
617a36c61f9SKrishna Gudipati bfa_boolean_t bfa_fcport_is_qos_enabled(struct bfa_s *bfa);
618be540a99SKrishna Gudipati bfa_boolean_t bfa_fcport_is_trunk_enabled(struct bfa_s *bfa);
619e353546eSKrishna Gudipati void bfa_fcport_dportenable(struct bfa_s *bfa);
620e353546eSKrishna Gudipati void bfa_fcport_dportdisable(struct bfa_s *bfa);
62143ffdf4dSKrishna Gudipati bfa_status_t bfa_fcport_is_pbcdisabled(struct bfa_s *bfa);
622a714134aSKrishna Gudipati void bfa_fcport_cfg_faa(struct bfa_s *bfa, u8 state);
623bbe37a67SVijaya Mohan Guvva bfa_status_t bfa_fcport_cfg_bbcr(struct bfa_s *bfa,
624bbe37a67SVijaya Mohan Guvva 			bfa_boolean_t on_off, u8 bb_scn);
625bbe37a67SVijaya Mohan Guvva bfa_status_t bfa_fcport_get_bbcr_attr(struct bfa_s *bfa,
626bbe37a67SVijaya Mohan Guvva 			struct bfa_bbcr_attr_s *bbcr_attr);
627a36c61f9SKrishna Gudipati 
628a36c61f9SKrishna Gudipati /*
629a36c61f9SKrishna Gudipati  * bfa rport API functions
630a36c61f9SKrishna Gudipati  */
631a36c61f9SKrishna Gudipati struct bfa_rport_s *bfa_rport_create(struct bfa_s *bfa, void *rport_drv);
632a36c61f9SKrishna Gudipati void bfa_rport_online(struct bfa_rport_s *rport,
633a36c61f9SKrishna Gudipati 		      struct bfa_rport_info_s *rport_info);
634a36c61f9SKrishna Gudipati void bfa_rport_speed(struct bfa_rport_s *rport, enum bfa_port_speed speed);
635a36c61f9SKrishna Gudipati void bfa_cb_rport_online(void *rport);
636a36c61f9SKrishna Gudipati void bfa_cb_rport_offline(void *rport);
637a36c61f9SKrishna Gudipati void bfa_cb_rport_qos_scn_flowid(void *rport,
638a36c61f9SKrishna Gudipati 				 struct bfa_rport_qos_attr_s old_qos_attr,
639a36c61f9SKrishna Gudipati 				 struct bfa_rport_qos_attr_s new_qos_attr);
640bc0e2c2aSKrishna Gudipati void bfa_cb_rport_scn_online(struct bfa_s *bfa);
641bc0e2c2aSKrishna Gudipati void bfa_cb_rport_scn_offline(struct bfa_s *bfa);
642bc0e2c2aSKrishna Gudipati void bfa_cb_rport_scn_no_dev(void *rp);
643a36c61f9SKrishna Gudipati void bfa_cb_rport_qos_scn_prio(void *rport,
644a36c61f9SKrishna Gudipati 			       struct bfa_rport_qos_attr_s old_qos_attr,
645a36c61f9SKrishna Gudipati 			       struct bfa_rport_qos_attr_s new_qos_attr);
646a36c61f9SKrishna Gudipati 
647a36c61f9SKrishna Gudipati /*
64883763d59SKrishna Gudipati  *	Rport LUN masking related
64983763d59SKrishna Gudipati  */
65083763d59SKrishna Gudipati #define BFA_RPORT_TAG_INVALID	0xffff
65183763d59SKrishna Gudipati #define BFA_LP_TAG_INVALID	0xff
65283763d59SKrishna Gudipati void	bfa_rport_set_lunmask(struct bfa_s *bfa, struct bfa_rport_s *rp);
65383763d59SKrishna Gudipati void	bfa_rport_unset_lunmask(struct bfa_s *bfa, struct bfa_rport_s *rp);
65483763d59SKrishna Gudipati 
65583763d59SKrishna Gudipati /*
656a36c61f9SKrishna Gudipati  * bfa fcxp API functions
657a36c61f9SKrishna Gudipati  */
658c3f1b123SKrishna Gudipati struct bfa_fcxp_s *bfa_fcxp_req_rsp_alloc(void *bfad_fcxp, struct bfa_s *bfa,
659a36c61f9SKrishna Gudipati 				  int nreq_sgles, int nrsp_sgles,
660a36c61f9SKrishna Gudipati 				  bfa_fcxp_get_sgaddr_t get_req_sga,
661a36c61f9SKrishna Gudipati 				  bfa_fcxp_get_sglen_t get_req_sglen,
662a36c61f9SKrishna Gudipati 				  bfa_fcxp_get_sgaddr_t get_rsp_sga,
663c3f1b123SKrishna Gudipati 				  bfa_fcxp_get_sglen_t get_rsp_sglen,
664c3f1b123SKrishna Gudipati 				  bfa_boolean_t req);
665c3f1b123SKrishna Gudipati void bfa_fcxp_req_rsp_alloc_wait(struct bfa_s *bfa, struct bfa_fcxp_wqe_s *wqe,
666a36c61f9SKrishna Gudipati 				bfa_fcxp_alloc_cbfn_t alloc_cbfn,
667a36c61f9SKrishna Gudipati 				void *cbarg, void *bfad_fcxp,
668a36c61f9SKrishna Gudipati 				int nreq_sgles, int nrsp_sgles,
669a36c61f9SKrishna Gudipati 				bfa_fcxp_get_sgaddr_t get_req_sga,
670a36c61f9SKrishna Gudipati 				bfa_fcxp_get_sglen_t get_req_sglen,
671a36c61f9SKrishna Gudipati 				bfa_fcxp_get_sgaddr_t get_rsp_sga,
672c3f1b123SKrishna Gudipati 				bfa_fcxp_get_sglen_t get_rsp_sglen,
673c3f1b123SKrishna Gudipati 				bfa_boolean_t req);
674a36c61f9SKrishna Gudipati void bfa_fcxp_walloc_cancel(struct bfa_s *bfa,
675a36c61f9SKrishna Gudipati 			    struct bfa_fcxp_wqe_s *wqe);
676a36c61f9SKrishna Gudipati void bfa_fcxp_discard(struct bfa_fcxp_s *fcxp);
677a36c61f9SKrishna Gudipati 
678a36c61f9SKrishna Gudipati void *bfa_fcxp_get_reqbuf(struct bfa_fcxp_s *fcxp);
679a36c61f9SKrishna Gudipati void *bfa_fcxp_get_rspbuf(struct bfa_fcxp_s *fcxp);
680a36c61f9SKrishna Gudipati 
681a36c61f9SKrishna Gudipati void bfa_fcxp_free(struct bfa_fcxp_s *fcxp);
682a36c61f9SKrishna Gudipati 
683a36c61f9SKrishna Gudipati void bfa_fcxp_send(struct bfa_fcxp_s *fcxp, struct bfa_rport_s *rport,
684a36c61f9SKrishna Gudipati 		   u16 vf_id, u8 lp_tag,
685a36c61f9SKrishna Gudipati 		   bfa_boolean_t cts, enum fc_cos cos,
686a36c61f9SKrishna Gudipati 		   u32 reqlen, struct fchs_s *fchs,
687a36c61f9SKrishna Gudipati 		   bfa_cb_fcxp_send_t cbfn,
688a36c61f9SKrishna Gudipati 		   void *cbarg,
689a36c61f9SKrishna Gudipati 		   u32 rsp_maxlen, u8 rsp_timeout);
690a36c61f9SKrishna Gudipati bfa_status_t bfa_fcxp_abort(struct bfa_fcxp_s *fcxp);
691a36c61f9SKrishna Gudipati u32 bfa_fcxp_get_reqbufsz(struct bfa_fcxp_s *fcxp);
692a36c61f9SKrishna Gudipati u32 bfa_fcxp_get_maxrsp(struct bfa_s *bfa);
6933fd45980SKrishna Gudipati void bfa_fcxp_res_recfg(struct bfa_s *bfa, u16 num_fcxp_fw);
694a36c61f9SKrishna Gudipati 
695a36c61f9SKrishna Gudipati static inline void *
bfa_uf_get_frmbuf(struct bfa_uf_s * uf)696a36c61f9SKrishna Gudipati bfa_uf_get_frmbuf(struct bfa_uf_s *uf)
697a36c61f9SKrishna Gudipati {
698a36c61f9SKrishna Gudipati 	return uf->data_ptr;
699a36c61f9SKrishna Gudipati }
700a36c61f9SKrishna Gudipati 
701a36c61f9SKrishna Gudipati static inline   u16
bfa_uf_get_frmlen(struct bfa_uf_s * uf)702a36c61f9SKrishna Gudipati bfa_uf_get_frmlen(struct bfa_uf_s *uf)
703a36c61f9SKrishna Gudipati {
704a36c61f9SKrishna Gudipati 	return uf->data_len;
705a36c61f9SKrishna Gudipati }
706a36c61f9SKrishna Gudipati 
707a36c61f9SKrishna Gudipati /*
708a36c61f9SKrishna Gudipati  * bfa uf API functions
709a36c61f9SKrishna Gudipati  */
710a36c61f9SKrishna Gudipati void bfa_uf_recv_register(struct bfa_s *bfa, bfa_cb_uf_recv_t ufrecv,
711a36c61f9SKrishna Gudipati 			  void *cbarg);
712a36c61f9SKrishna Gudipati void bfa_uf_free(struct bfa_uf_s *uf);
713a36c61f9SKrishna Gudipati 
714acdc79a6SJing Huang /*
715a36c61f9SKrishna Gudipati  * bfa lport service api
716a36c61f9SKrishna Gudipati  */
717a36c61f9SKrishna Gudipati 
718a36c61f9SKrishna Gudipati u32 bfa_lps_get_max_vport(struct bfa_s *bfa);
719a36c61f9SKrishna Gudipati struct bfa_lps_s *bfa_lps_alloc(struct bfa_s *bfa);
720a36c61f9SKrishna Gudipati void bfa_lps_delete(struct bfa_lps_s *lps);
721a36c61f9SKrishna Gudipati void bfa_lps_flogi(struct bfa_lps_s *lps, void *uarg, u8 alpa,
722a36c61f9SKrishna Gudipati 		   u16 pdusz, wwn_t pwwn, wwn_t nwwn,
723bbe37a67SVijaya Mohan Guvva 		   bfa_boolean_t auth_en);
724a36c61f9SKrishna Gudipati void bfa_lps_fdisc(struct bfa_lps_s *lps, void *uarg, u16 pdusz,
725a36c61f9SKrishna Gudipati 		   wwn_t pwwn, wwn_t nwwn);
726a36c61f9SKrishna Gudipati void bfa_lps_fdisclogo(struct bfa_lps_s *lps);
727b704495cSKrishna Gudipati void bfa_lps_set_n2n_pid(struct bfa_lps_s *lps, u32 n2n_pid);
7283fd45980SKrishna Gudipati u8 bfa_lps_get_fwtag(struct bfa_s *bfa, u8 lp_tag);
729a36c61f9SKrishna Gudipati u32 bfa_lps_get_base_pid(struct bfa_s *bfa);
730a36c61f9SKrishna Gudipati u8 bfa_lps_get_tag_from_pid(struct bfa_s *bfa, u32 pid);
731a36c61f9SKrishna Gudipati void bfa_cb_lps_flogi_comp(void *bfad, void *uarg, bfa_status_t status);
732881c1b3cSKrishna Gudipati void bfa_cb_lps_flogo_comp(void *bfad, void *uarg);
733a36c61f9SKrishna Gudipati void bfa_cb_lps_fdisc_comp(void *bfad, void *uarg, bfa_status_t status);
734a36c61f9SKrishna Gudipati void bfa_cb_lps_fdisclogo_comp(void *bfad, void *uarg);
735a36c61f9SKrishna Gudipati void bfa_cb_lps_cvl_event(void *bfad, void *uarg);
736a36c61f9SKrishna Gudipati 
737a714134aSKrishna Gudipati /* FAA specific APIs */
738a714134aSKrishna Gudipati bfa_status_t bfa_faa_query(struct bfa_s *bfa, struct bfa_faa_attr_s *attr,
739a714134aSKrishna Gudipati 			bfa_cb_iocfc_t cbfn, void *cbarg);
740a714134aSKrishna Gudipati 
7413d7fc66dSKrishna Gudipati /*
7423d7fc66dSKrishna Gudipati  *	FC DIAG data structure
7433d7fc66dSKrishna Gudipati  */
7443d7fc66dSKrishna Gudipati struct bfa_fcdiag_qtest_s {
7453d7fc66dSKrishna Gudipati 	struct bfa_diag_qtest_result_s *result;
7463d7fc66dSKrishna Gudipati 	bfa_cb_diag_t	cbfn;
7473d7fc66dSKrishna Gudipati 	void		*cbarg;
7483d7fc66dSKrishna Gudipati 	struct bfa_timer_s	timer;
7493d7fc66dSKrishna Gudipati 	u32	status;
7503d7fc66dSKrishna Gudipati 	u32	count;
7513d7fc66dSKrishna Gudipati 	u8	lock;
7523d7fc66dSKrishna Gudipati 	u8	queue;
7533d7fc66dSKrishna Gudipati 	u8	all;
7543d7fc66dSKrishna Gudipati 	u8	timer_active;
7553d7fc66dSKrishna Gudipati };
7563d7fc66dSKrishna Gudipati 
7573d7fc66dSKrishna Gudipati struct bfa_fcdiag_lb_s {
7583d7fc66dSKrishna Gudipati 	bfa_cb_diag_t   cbfn;
7593d7fc66dSKrishna Gudipati 	void            *cbarg;
7603d7fc66dSKrishna Gudipati 	void            *result;
7613d7fc66dSKrishna Gudipati 	bfa_boolean_t   lock;
7623d7fc66dSKrishna Gudipati 	u32        status;
7633d7fc66dSKrishna Gudipati };
7643d7fc66dSKrishna Gudipati 
765*37126399SArnd Bergmann /*
766*37126399SArnd Bergmann  * BFA DPORT state machine events
767*37126399SArnd Bergmann  */
768*37126399SArnd Bergmann enum bfa_dport_sm_event {
769*37126399SArnd Bergmann 	BFA_DPORT_SM_ENABLE	= 1,	/* dport enable event         */
770*37126399SArnd Bergmann 	BFA_DPORT_SM_DISABLE    = 2,    /* dport disable event        */
771*37126399SArnd Bergmann 	BFA_DPORT_SM_FWRSP      = 3,    /* fw enable/disable rsp      */
772*37126399SArnd Bergmann 	BFA_DPORT_SM_QRESUME    = 4,    /* CQ space available         */
773*37126399SArnd Bergmann 	BFA_DPORT_SM_HWFAIL     = 5,    /* IOC h/w failure            */
774*37126399SArnd Bergmann 	BFA_DPORT_SM_START	= 6,	/* re-start dport test        */
775*37126399SArnd Bergmann 	BFA_DPORT_SM_REQFAIL	= 7,	/* request failure            */
776*37126399SArnd Bergmann 	BFA_DPORT_SM_SCN	= 8,	/* state change notify frm fw */
777*37126399SArnd Bergmann };
778*37126399SArnd Bergmann 
779*37126399SArnd Bergmann struct bfa_dport_s;
780*37126399SArnd Bergmann typedef void (*bfa_dport_sm_t)(struct bfa_dport_s *, enum bfa_dport_sm_event);
781*37126399SArnd Bergmann 
782e353546eSKrishna Gudipati struct bfa_dport_s {
783e353546eSKrishna Gudipati 	struct bfa_s	*bfa;		/* Back pointer to BFA	*/
784*37126399SArnd Bergmann 	bfa_dport_sm_t	sm;		/* finite state machine */
785e353546eSKrishna Gudipati 	struct bfa_reqq_wait_s reqq_wait;
786e353546eSKrishna Gudipati 	bfa_cb_diag_t	cbfn;
787e353546eSKrishna Gudipati 	void		*cbarg;
7881a898a79SVijaya Mohan Guvva 	union bfi_diag_dport_msg_u i2hmsg;
7891a898a79SVijaya Mohan Guvva 	u8		test_state;	/* enum dport_test_state  */
7901a898a79SVijaya Mohan Guvva 	u8		dynamic;	/* boolean_t  */
7911a898a79SVijaya Mohan Guvva 	u8		rsvd[2];
7921a898a79SVijaya Mohan Guvva 	u32		lpcnt;
7931a898a79SVijaya Mohan Guvva 	u32		payload;	/* user defined payload pattern */
7941a898a79SVijaya Mohan Guvva 	wwn_t		rp_pwwn;
7951a898a79SVijaya Mohan Guvva 	wwn_t		rp_nwwn;
7961a898a79SVijaya Mohan Guvva 	struct bfa_diag_dport_result_s result;
797e353546eSKrishna Gudipati };
798e353546eSKrishna Gudipati 
7993d7fc66dSKrishna Gudipati struct bfa_fcdiag_s {
8003d7fc66dSKrishna Gudipati 	struct bfa_s    *bfa;           /* Back pointer to BFA */
8013d7fc66dSKrishna Gudipati 	struct bfa_trc_mod_s   *trcmod;
8023d7fc66dSKrishna Gudipati 	struct bfa_fcdiag_lb_s lb;
8033d7fc66dSKrishna Gudipati 	struct bfa_fcdiag_qtest_s qtest;
804e353546eSKrishna Gudipati 	struct bfa_dport_s	dport;
8053d7fc66dSKrishna Gudipati };
8063d7fc66dSKrishna Gudipati 
8073d7fc66dSKrishna Gudipati #define BFA_FCDIAG_MOD(__bfa)	(&(__bfa)->modules.fcdiag)
8083d7fc66dSKrishna Gudipati 
8093d7fc66dSKrishna Gudipati void	bfa_fcdiag_intr(struct bfa_s *bfa, struct bfi_msg_s *msg);
8103d7fc66dSKrishna Gudipati 
8113d7fc66dSKrishna Gudipati bfa_status_t	bfa_fcdiag_loopback(struct bfa_s *bfa,
8123d7fc66dSKrishna Gudipati 				enum bfa_port_opmode opmode,
8133d7fc66dSKrishna Gudipati 				enum bfa_port_speed speed, u32 lpcnt, u32 pat,
8143d7fc66dSKrishna Gudipati 				struct bfa_diag_loopback_result_s *result,
8153d7fc66dSKrishna Gudipati 				bfa_cb_diag_t cbfn, void *cbarg);
8163d7fc66dSKrishna Gudipati bfa_status_t	bfa_fcdiag_queuetest(struct bfa_s *bfa, u32 ignore,
8173d7fc66dSKrishna Gudipati 			u32 queue, struct bfa_diag_qtest_result_s *result,
8183d7fc66dSKrishna Gudipati 			bfa_cb_diag_t cbfn, void *cbarg);
8193d7fc66dSKrishna Gudipati bfa_status_t	bfa_fcdiag_lb_is_running(struct bfa_s *bfa);
8201a898a79SVijaya Mohan Guvva bfa_status_t	bfa_dport_enable(struct bfa_s *bfa, u32 lpcnt, u32 pat,
8211a898a79SVijaya Mohan Guvva 					bfa_cb_diag_t cbfn, void *cbarg);
822e353546eSKrishna Gudipati bfa_status_t	bfa_dport_disable(struct bfa_s *bfa, bfa_cb_diag_t cbfn,
823e353546eSKrishna Gudipati 				  void *cbarg);
8241a898a79SVijaya Mohan Guvva bfa_status_t	bfa_dport_start(struct bfa_s *bfa, u32 lpcnt, u32 pat,
8251a898a79SVijaya Mohan Guvva 				bfa_cb_diag_t cbfn, void *cbarg);
8261a898a79SVijaya Mohan Guvva bfa_status_t	bfa_dport_show(struct bfa_s *bfa,
8271a898a79SVijaya Mohan Guvva 				struct bfa_diag_dport_result_s *result);
8283d7fc66dSKrishna Gudipati 
829a36c61f9SKrishna Gudipati #endif /* __BFA_SVC_H__ */
830