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