Linux Audio

Check our new training course

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