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