cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

bfa_svc.h (25863B)


      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__ */