blob: 4c0ac3e1a137e767a10c86ed4d2ce6ad520e12c2 [file] [log] [blame]
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001/*
2 * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
3 * All rights reserved
4 * www.brocade.com
5 *
6 * Linux driver for Brocade Fibre Channel Host Bus Adapter.
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License (GPL) Version 2 as
10 * published by the Free Software Foundation
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 */
17
18#ifndef __BFA_SVC_H__
19#define __BFA_SVC_H__
20
21#include "bfa_cs.h"
22#include "bfi_ms.h"
23
24
Jing Huangacdc79a2010-10-18 17:15:55 -070025/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -070026 * Scatter-gather DMA related defines
27 */
28#define BFA_SGPG_MIN (16)
Krishna Gudipati45070252011-06-24 20:24:29 -070029#define BFA_SGPG_MAX (8192)
Krishna Gudipatia36c61f2010-09-15 11:50:55 -070030
Jing Huangacdc79a2010-10-18 17:15:55 -070031/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -070032 * Alignment macro for SG page allocation
33 */
34#define BFA_SGPG_ROUNDUP(_l) (((_l) + (sizeof(struct bfi_sgpg_s) - 1)) \
35 & ~(sizeof(struct bfi_sgpg_s) - 1))
36
37struct bfa_sgpg_wqe_s {
38 struct list_head qe; /* queue sg page element */
39 int nsgpg; /* pages to be allocated */
40 int nsgpg_total; /* total pages required */
41 void (*cbfn) (void *cbarg); /* callback function */
42 void *cbarg; /* callback arg */
43 struct list_head sgpg_q; /* queue of alloced sgpgs */
44};
45
46struct bfa_sgpg_s {
47 struct list_head qe; /* queue sg page element */
48 struct bfi_sgpg_s *sgpg; /* va of SG page */
49 union bfi_addr_u sgpg_pa; /* pa of SG page */
50};
51
Jing Huangacdc79a2010-10-18 17:15:55 -070052/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -070053 * Given number of SG elements, BFA_SGPG_NPAGE() returns the number of
54 * SG pages required.
55 */
56#define BFA_SGPG_NPAGE(_nsges) (((_nsges) / BFI_SGPG_DATA_SGES) + 1)
57
Krishna Gudipati45070252011-06-24 20:24:29 -070058/* Max SGPG dma segs required */
59#define BFA_SGPG_DMA_SEGS \
60 BFI_MEM_DMA_NSEGS(BFA_SGPG_MAX, (uint32_t)sizeof(struct bfi_sgpg_s))
61
Krishna Gudipatia36c61f2010-09-15 11:50:55 -070062struct bfa_sgpg_mod_s {
63 struct bfa_s *bfa;
64 int num_sgpgs; /* number of SG pages */
65 int free_sgpgs; /* number of free SG pages */
Krishna Gudipatia36c61f2010-09-15 11:50:55 -070066 struct list_head sgpg_q; /* queue of free SG pages */
67 struct list_head sgpg_wait_q; /* wait queue for SG pages */
Krishna Gudipati45070252011-06-24 20:24:29 -070068 struct bfa_mem_dma_s dma_seg[BFA_SGPG_DMA_SEGS];
69 struct bfa_mem_kva_s kva_seg;
Krishna Gudipatia36c61f2010-09-15 11:50:55 -070070};
71#define BFA_SGPG_MOD(__bfa) (&(__bfa)->modules.sgpg_mod)
Krishna Gudipati45070252011-06-24 20:24:29 -070072#define BFA_MEM_SGPG_KVA(__bfa) (&(BFA_SGPG_MOD(__bfa)->kva_seg))
Krishna Gudipatia36c61f2010-09-15 11:50:55 -070073
74bfa_status_t bfa_sgpg_malloc(struct bfa_s *bfa, struct list_head *sgpg_q,
75 int nsgpgs);
76void bfa_sgpg_mfree(struct bfa_s *bfa, struct list_head *sgpg_q, int nsgpgs);
77void bfa_sgpg_winit(struct bfa_sgpg_wqe_s *wqe,
78 void (*cbfn) (void *cbarg), void *cbarg);
79void bfa_sgpg_wait(struct bfa_s *bfa, struct bfa_sgpg_wqe_s *wqe, int nsgpgs);
80void bfa_sgpg_wcancel(struct bfa_s *bfa, struct bfa_sgpg_wqe_s *wqe);
81
82
Jing Huangacdc79a2010-10-18 17:15:55 -070083/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -070084 * FCXP related defines
85 */
86#define BFA_FCXP_MIN (1)
Krishna Gudipati45070252011-06-24 20:24:29 -070087#define BFA_FCXP_MAX (256)
Krishna Gudipatia36c61f2010-09-15 11:50:55 -070088#define BFA_FCXP_MAX_IBUF_SZ (2 * 1024 + 256)
89#define BFA_FCXP_MAX_LBUF_SZ (4 * 1024 + 256)
90
Krishna Gudipati45070252011-06-24 20:24:29 -070091/* Max FCXP dma segs required */
92#define BFA_FCXP_DMA_SEGS \
93 BFI_MEM_DMA_NSEGS(BFA_FCXP_MAX, \
94 (u32)BFA_FCXP_MAX_IBUF_SZ + BFA_FCXP_MAX_LBUF_SZ)
95
Krishna Gudipatia36c61f2010-09-15 11:50:55 -070096struct bfa_fcxp_mod_s {
97 struct bfa_s *bfa; /* backpointer to BFA */
98 struct bfa_fcxp_s *fcxp_list; /* array of FCXPs */
99 u16 num_fcxps; /* max num FCXP requests */
100 struct list_head fcxp_free_q; /* free FCXPs */
101 struct list_head fcxp_active_q; /* active FCXPs */
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700102 struct list_head wait_q; /* wait queue for free fcxp */
Krishna Gudipati3fd45982011-06-24 20:24:08 -0700103 struct list_head fcxp_unused_q; /* unused fcxps */
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700104 u32 req_pld_sz;
105 u32 rsp_pld_sz;
Krishna Gudipati45070252011-06-24 20:24:29 -0700106 struct bfa_mem_dma_s dma_seg[BFA_FCXP_DMA_SEGS];
107 struct bfa_mem_kva_s kva_seg;
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700108};
109
110#define BFA_FCXP_MOD(__bfa) (&(__bfa)->modules.fcxp_mod)
111#define BFA_FCXP_FROM_TAG(__mod, __tag) (&(__mod)->fcxp_list[__tag])
Krishna Gudipati45070252011-06-24 20:24:29 -0700112#define BFA_MEM_FCXP_KVA(__bfa) (&(BFA_FCXP_MOD(__bfa)->kva_seg))
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700113
114typedef void (*fcxp_send_cb_t) (struct bfa_s *ioc, struct bfa_fcxp_s *fcxp,
115 void *cb_arg, bfa_status_t req_status,
116 u32 rsp_len, u32 resid_len,
117 struct fchs_s *rsp_fchs);
118
119typedef u64 (*bfa_fcxp_get_sgaddr_t) (void *bfad_fcxp, int sgeid);
120typedef u32 (*bfa_fcxp_get_sglen_t) (void *bfad_fcxp, int sgeid);
121typedef void (*bfa_cb_fcxp_send_t) (void *bfad_fcxp, struct bfa_fcxp_s *fcxp,
122 void *cbarg, enum bfa_status req_status,
123 u32 rsp_len, u32 resid_len,
124 struct fchs_s *rsp_fchs);
125typedef void (*bfa_fcxp_alloc_cbfn_t) (void *cbarg, struct bfa_fcxp_s *fcxp);
126
127
128
Jing Huangacdc79a2010-10-18 17:15:55 -0700129/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700130 * Information needed for a FCXP request
131 */
132struct bfa_fcxp_req_info_s {
133 struct bfa_rport_s *bfa_rport;
Jing Huangacdc79a2010-10-18 17:15:55 -0700134 /* Pointer to the bfa rport that was
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700135 * returned from bfa_rport_create().
136 * This could be left NULL for WKA or
137 * for FCXP interactions before the
138 * rport nexus is established
139 */
140 struct fchs_s fchs; /* request FC header structure */
Lucas De Marchi25985ed2011-03-30 22:57:33 -0300141 u8 cts; /* continuous sequence */
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700142 u8 class; /* FC class for the request/response */
143 u16 max_frmsz; /* max send frame size */
144 u16 vf_id; /* vsan tag if applicable */
145 u8 lp_tag; /* lport tag */
146 u32 req_tot_len; /* request payload total length */
147};
148
149struct bfa_fcxp_rsp_info_s {
150 struct fchs_s rsp_fchs;
Jing Huangacdc79a2010-10-18 17:15:55 -0700151 /* Response frame's FC header will
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700152 * be sent back in this field */
153 u8 rsp_timeout;
Jing Huangacdc79a2010-10-18 17:15:55 -0700154 /* timeout in seconds, 0-no response */
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700155 u8 rsvd2[3];
156 u32 rsp_maxlen; /* max response length expected */
157};
158
159struct bfa_fcxp_s {
160 struct list_head qe; /* fcxp queue element */
161 bfa_sm_t sm; /* state machine */
162 void *caller; /* driver or fcs */
163 struct bfa_fcxp_mod_s *fcxp_mod;
164 /* back pointer to fcxp mod */
165 u16 fcxp_tag; /* internal tag */
166 struct bfa_fcxp_req_info_s req_info;
167 /* request info */
168 struct bfa_fcxp_rsp_info_s rsp_info;
169 /* response info */
170 u8 use_ireqbuf; /* use internal req buf */
171 u8 use_irspbuf; /* use internal rsp buf */
172 u32 nreq_sgles; /* num request SGLEs */
173 u32 nrsp_sgles; /* num response SGLEs */
174 struct list_head req_sgpg_q; /* SG pages for request buf */
175 struct list_head req_sgpg_wqe; /* wait queue for req SG page */
176 struct list_head rsp_sgpg_q; /* SG pages for response buf */
177 struct list_head rsp_sgpg_wqe; /* wait queue for rsp SG page */
178
179 bfa_fcxp_get_sgaddr_t req_sga_cbfn;
180 /* SG elem addr user function */
181 bfa_fcxp_get_sglen_t req_sglen_cbfn;
182 /* SG elem len user function */
183 bfa_fcxp_get_sgaddr_t rsp_sga_cbfn;
184 /* SG elem addr user function */
185 bfa_fcxp_get_sglen_t rsp_sglen_cbfn;
186 /* SG elem len user function */
187 bfa_cb_fcxp_send_t send_cbfn; /* send completion callback */
188 void *send_cbarg; /* callback arg */
189 struct bfa_sge_s req_sge[BFA_FCXP_MAX_SGES];
190 /* req SG elems */
191 struct bfa_sge_s rsp_sge[BFA_FCXP_MAX_SGES];
192 /* rsp SG elems */
193 u8 rsp_status; /* comp: rsp status */
194 u32 rsp_len; /* comp: actual response len */
195 u32 residue_len; /* comp: residual rsp length */
196 struct fchs_s rsp_fchs; /* comp: response fchs */
197 struct bfa_cb_qe_s hcb_qe; /* comp: callback qelem */
198 struct bfa_reqq_wait_s reqq_wqe;
199 bfa_boolean_t reqq_waiting;
200};
201
202struct bfa_fcxp_wqe_s {
203 struct list_head qe;
204 bfa_fcxp_alloc_cbfn_t alloc_cbfn;
205 void *alloc_cbarg;
206 void *caller;
207 struct bfa_s *bfa;
208 int nreq_sgles;
209 int nrsp_sgles;
210 bfa_fcxp_get_sgaddr_t req_sga_cbfn;
211 bfa_fcxp_get_sglen_t req_sglen_cbfn;
212 bfa_fcxp_get_sgaddr_t rsp_sga_cbfn;
213 bfa_fcxp_get_sglen_t rsp_sglen_cbfn;
214};
215
216#define BFA_FCXP_REQ_PLD(_fcxp) (bfa_fcxp_get_reqbuf(_fcxp))
217#define BFA_FCXP_RSP_FCHS(_fcxp) (&((_fcxp)->rsp_info.fchs))
218#define BFA_FCXP_RSP_PLD(_fcxp) (bfa_fcxp_get_rspbuf(_fcxp))
219
Krishna Gudipati45070252011-06-24 20:24:29 -0700220#define BFA_FCXP_REQ_PLD_PA(_fcxp) \
221 bfa_mem_get_dmabuf_pa((_fcxp)->fcxp_mod, (_fcxp)->fcxp_tag, \
222 (_fcxp)->fcxp_mod->req_pld_sz + (_fcxp)->fcxp_mod->rsp_pld_sz)
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700223
Krishna Gudipati45070252011-06-24 20:24:29 -0700224/* fcxp_buf = req_buf + rsp_buf :- add req_buf_sz to get to rsp_buf */
225#define BFA_FCXP_RSP_PLD_PA(_fcxp) \
226 (bfa_mem_get_dmabuf_pa((_fcxp)->fcxp_mod, (_fcxp)->fcxp_tag, \
227 (_fcxp)->fcxp_mod->req_pld_sz + (_fcxp)->fcxp_mod->rsp_pld_sz) + \
228 (_fcxp)->fcxp_mod->req_pld_sz)
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700229
230void bfa_fcxp_isr(struct bfa_s *bfa, struct bfi_msg_s *msg);
231
232
Jing Huangacdc79a2010-10-18 17:15:55 -0700233/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700234 * RPORT related defines
235 */
Maggie Zhangf7f738122010-12-09 19:08:43 -0800236enum bfa_rport_event {
237 BFA_RPORT_SM_CREATE = 1, /* rport create event */
238 BFA_RPORT_SM_DELETE = 2, /* deleting an existing rport */
239 BFA_RPORT_SM_ONLINE = 3, /* rport is online */
240 BFA_RPORT_SM_OFFLINE = 4, /* rport is offline */
241 BFA_RPORT_SM_FWRSP = 5, /* firmware response */
242 BFA_RPORT_SM_HWFAIL = 6, /* IOC h/w failure */
243 BFA_RPORT_SM_QOS_SCN = 7, /* QoS SCN from firmware */
244 BFA_RPORT_SM_SET_SPEED = 8, /* Set Rport Speed */
245 BFA_RPORT_SM_QRESUME = 9, /* space in requeue queue */
246};
247
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700248#define BFA_RPORT_MIN 4
249
250struct bfa_rport_mod_s {
251 struct bfa_rport_s *rps_list; /* list of rports */
252 struct list_head rp_free_q; /* free bfa_rports */
253 struct list_head rp_active_q; /* free bfa_rports */
Krishna Gudipati3fd45982011-06-24 20:24:08 -0700254 struct list_head rp_unused_q; /* unused bfa rports */
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700255 u16 num_rports; /* number of rports */
Krishna Gudipati45070252011-06-24 20:24:29 -0700256 struct bfa_mem_kva_s kva_seg;
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700257};
258
259#define BFA_RPORT_MOD(__bfa) (&(__bfa)->modules.rport_mod)
Krishna Gudipati45070252011-06-24 20:24:29 -0700260#define BFA_MEM_RPORT_KVA(__bfa) (&(BFA_RPORT_MOD(__bfa)->kva_seg))
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700261
Jing Huangacdc79a2010-10-18 17:15:55 -0700262/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700263 * Convert rport tag to RPORT
264 */
265#define BFA_RPORT_FROM_TAG(__bfa, _tag) \
266 (BFA_RPORT_MOD(__bfa)->rps_list + \
267 ((_tag) & (BFA_RPORT_MOD(__bfa)->num_rports - 1)))
268
269/*
270 * protected functions
271 */
272void bfa_rport_isr(struct bfa_s *bfa, struct bfi_msg_s *msg);
Krishna Gudipati3fd45982011-06-24 20:24:08 -0700273void bfa_rport_res_recfg(struct bfa_s *bfa, u16 num_rport_fw);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700274
Jing Huangacdc79a2010-10-18 17:15:55 -0700275/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700276 * BFA rport information.
277 */
278struct bfa_rport_info_s {
279 u16 max_frmsz; /* max rcv pdu size */
280 u32 pid:24, /* remote port ID */
281 lp_tag:8; /* tag */
282 u32 local_pid:24, /* local port ID */
283 cisc:8; /* CIRO supported */
284 u8 fc_class; /* supported FC classes. enum fc_cos */
285 u8 vf_en; /* virtual fabric enable */
286 u16 vf_id; /* virtual fabric ID */
287 enum bfa_port_speed speed; /* Rport's current speed */
288};
289
Jing Huangacdc79a2010-10-18 17:15:55 -0700290/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700291 * BFA rport data structure
292 */
293struct bfa_rport_s {
294 struct list_head qe; /* queue element */
295 bfa_sm_t sm; /* state machine */
296 struct bfa_s *bfa; /* backpointer to BFA */
297 void *rport_drv; /* fcs/driver rport object */
298 u16 fw_handle; /* firmware rport handle */
299 u16 rport_tag; /* BFA rport tag */
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
Jing Huangacdc79a2010-10-18 17:15:55 -0700313/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700314 * UF - unsolicited receive related defines
315 */
316
317#define BFA_UF_MIN (4)
Krishna Gudipati45070252011-06-24 20:24:29 -0700318#define BFA_UF_MAX (256)
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700319
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
Jing Huangacdc79a2010-10-18 17:15:55 -0700336/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700337 * 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
Krishna Gudipati45070252011-06-24 20:24:29 -0700346#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
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700358struct 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 */
Krishna Gudipati3fd45982011-06-24 20:24:08 -0700364 struct list_head uf_unused_q; /* unused UF's */
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700365 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 */
Krishna Gudipati45070252011-06-24 20:24:29 -0700369 struct bfa_mem_dma_s dma_seg[BFA_UF_DMA_SEGS];
370 struct bfa_mem_kva_s kva_seg;
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700371};
372
373#define BFA_UF_MOD(__bfa) (&(__bfa)->modules.uf_mod)
Krishna Gudipati45070252011-06-24 20:24:29 -0700374#define BFA_MEM_UF_KVA(__bfa) (&(BFA_UF_MOD(__bfa)->kva_seg))
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700375
376#define ufm_pbs_pa(_ufmod, _uftag) \
Krishna Gudipati45070252011-06-24 20:24:29 -0700377 bfa_mem_get_dmabuf_pa(_ufmod, _uftag, BFA_PER_UF_DMA_SZ)
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700378
379void bfa_uf_isr(struct bfa_s *bfa, struct bfi_msg_s *msg);
Krishna Gudipati3fd45982011-06-24 20:24:08 -0700380void bfa_uf_res_recfg(struct bfa_s *bfa, u16 num_uf_fw);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700381
Jing Huangacdc79a2010-10-18 17:15:55 -0700382/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700383 * LPS - bfa lport login/logout service interface
384 */
385struct bfa_lps_s {
386 struct list_head qe; /* queue element */
387 struct bfa_s *bfa; /* parent bfa instance */
388 bfa_sm_t sm; /* finite state machine */
Krishna Gudipati3fd45982011-06-24 20:24:08 -0700389 u8 bfa_tag; /* lport tag */
390 u8 fw_tag; /* lport fw tag */
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700391 u8 reqq; /* lport request queue */
392 u8 alpa; /* ALPA for loop topologies */
393 u32 lp_pid; /* lport port ID */
394 bfa_boolean_t fdisc; /* snd FDISC instead of FLOGI */
395 bfa_boolean_t auth_en; /* enable authentication */
396 bfa_boolean_t auth_req; /* authentication required */
397 bfa_boolean_t npiv_en; /* NPIV is allowed by peer */
398 bfa_boolean_t fport; /* attached peer is F_PORT */
399 bfa_boolean_t brcd_switch; /* attached peer is brcd sw */
400 bfa_status_t status; /* login status */
401 u16 pdusz; /* max receive PDU size */
402 u16 pr_bbcred; /* BB_CREDIT from peer */
Krishna Gudipatibe540a92011-06-13 15:53:04 -0700403 u8 pr_bbscn; /* BB_SCN from peer */
404 u8 bb_scn; /* local BB_SCN */
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700405 u8 lsrjt_rsn; /* LSRJT reason */
406 u8 lsrjt_expl; /* LSRJT explanation */
407 wwn_t pwwn; /* port wwn of lport */
408 wwn_t nwwn; /* node wwn of lport */
409 wwn_t pr_pwwn; /* port wwn of lport peer */
410 wwn_t pr_nwwn; /* node wwn of lport peer */
411 mac_t lp_mac; /* fpma/spma MAC for lport */
412 mac_t fcf_mac; /* FCF MAC of lport */
413 struct bfa_reqq_wait_s wqe; /* request wait queue element */
414 void *uarg; /* user callback arg */
415 struct bfa_cb_qe_s hcb_qe; /* comp: callback qelem */
416 struct bfi_lps_login_rsp_s *loginrsp;
417 bfa_eproto_status_t ext_status;
418};
419
420struct bfa_lps_mod_s {
421 struct list_head lps_free_q;
422 struct list_head lps_active_q;
Krishna Gudipati3fd45982011-06-24 20:24:08 -0700423 struct list_head lps_login_q;
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700424 struct bfa_lps_s *lps_arr;
425 int num_lps;
Krishna Gudipati45070252011-06-24 20:24:29 -0700426 struct bfa_mem_kva_s kva_seg;
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700427};
428
429#define BFA_LPS_MOD(__bfa) (&(__bfa)->modules.lps_mod)
430#define BFA_LPS_FROM_TAG(__mod, __tag) (&(__mod)->lps_arr[__tag])
Krishna Gudipati45070252011-06-24 20:24:29 -0700431#define BFA_MEM_LPS_KVA(__bfa) (&(BFA_LPS_MOD(__bfa)->kva_seg))
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700432
433/*
434 * external functions
435 */
436void bfa_lps_isr(struct bfa_s *bfa, struct bfi_msg_s *msg);
437
438
Jing Huangacdc79a2010-10-18 17:15:55 -0700439/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700440 * FCPORT related defines
441 */
442
443#define BFA_FCPORT(_bfa) (&((_bfa)->modules.port))
444typedef void (*bfa_cb_port_t) (void *cbarg, enum bfa_status status);
445
Jing Huangacdc79a2010-10-18 17:15:55 -0700446/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700447 * Link notification data structure
448 */
449struct bfa_fcport_ln_s {
450 struct bfa_fcport_s *fcport;
451 bfa_sm_t sm;
452 struct bfa_cb_qe_s ln_qe; /* BFA callback queue elem for ln */
453 enum bfa_port_linkstate ln_event; /* ln event for callback */
454};
455
456struct bfa_fcport_trunk_s {
457 struct bfa_trunk_attr_s attr;
458};
459
Jing Huangacdc79a2010-10-18 17:15:55 -0700460/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700461 * BFA FC port data structure
462 */
463struct bfa_fcport_s {
464 struct bfa_s *bfa; /* parent BFA instance */
465 bfa_sm_t sm; /* port state machine */
466 wwn_t nwwn; /* node wwn of physical port */
467 wwn_t pwwn; /* port wwn of physical oprt */
468 enum bfa_port_speed speed_sup;
469 /* supported speeds */
470 enum bfa_port_speed speed; /* current speed */
471 enum bfa_port_topology topology; /* current topology */
472 u8 myalpa; /* my ALPA in LOOP topology */
473 u8 rsvd[3];
474 struct bfa_port_cfg_s cfg; /* current port configuration */
Krishna Gudipatif3a060c2010-12-13 16:16:50 -0800475 bfa_boolean_t use_flash_cfg; /* get port cfg from flash */
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700476 struct bfa_qos_attr_s qos_attr; /* QoS Attributes */
477 struct bfa_qos_vc_attr_s qos_vc_attr; /* VC info from ELP */
478 struct bfa_reqq_wait_s reqq_wait;
479 /* to wait for room in reqq */
480 struct bfa_reqq_wait_s svcreq_wait;
481 /* to wait for room in reqq */
482 struct bfa_reqq_wait_s stats_reqq_wait;
483 /* to wait for room in reqq (stats) */
484 void *event_cbarg;
485 void (*event_cbfn) (void *cbarg,
486 enum bfa_port_linkstate event);
487 union {
488 union bfi_fcport_i2h_msg_u i2hmsg;
489 } event_arg;
490 void *bfad; /* BFA driver handle */
491 struct bfa_fcport_ln_s ln; /* Link Notification */
492 struct bfa_cb_qe_s hcb_qe; /* BFA callback queue elem */
493 struct bfa_timer_s timer; /* timer */
494 u32 msgtag; /* fimrware msg tag for reply */
495 u8 *stats_kva;
496 u64 stats_pa;
497 union bfa_fcport_stats_u *stats;
498 union bfa_fcport_stats_u *stats_ret; /* driver stats location */
499 bfa_status_t stats_status; /* stats/statsclr status */
500 bfa_boolean_t stats_busy; /* outstanding stats/statsclr */
501 bfa_boolean_t stats_qfull;
502 u32 stats_reset_time; /* stats reset time stamp */
503 bfa_cb_port_t stats_cbfn; /* driver callback function */
504 void *stats_cbarg; /* *!< user callback arg */
505 bfa_boolean_t diag_busy; /* diag busy status */
506 bfa_boolean_t beacon; /* port beacon status */
507 bfa_boolean_t link_e2e_beacon; /* link beacon status */
Krishna Gudipatibe540a92011-06-13 15:53:04 -0700508 bfa_boolean_t bbsc_op_state; /* Cred recov Oper State */
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700509 struct bfa_fcport_trunk_s trunk;
510 u16 fcoe_vlan;
Krishna Gudipati45070252011-06-24 20:24:29 -0700511 struct bfa_mem_dma_s fcport_dma;
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700512};
513
514#define BFA_FCPORT_MOD(__bfa) (&(__bfa)->modules.fcport)
Krishna Gudipati45070252011-06-24 20:24:29 -0700515#define BFA_MEM_FCPORT_DMA(__bfa) (&(BFA_FCPORT_MOD(__bfa)->fcport_dma))
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700516
517/*
518 * protected functions
519 */
520void bfa_fcport_init(struct bfa_s *bfa);
521void bfa_fcport_isr(struct bfa_s *bfa, struct bfi_msg_s *msg);
522
523/*
524 * bfa fcport API functions
525 */
526bfa_status_t bfa_fcport_enable(struct bfa_s *bfa);
527bfa_status_t bfa_fcport_disable(struct bfa_s *bfa);
528bfa_status_t bfa_fcport_cfg_speed(struct bfa_s *bfa,
529 enum bfa_port_speed speed);
530enum bfa_port_speed bfa_fcport_get_speed(struct bfa_s *bfa);
531bfa_status_t bfa_fcport_cfg_topology(struct bfa_s *bfa,
532 enum bfa_port_topology topo);
533enum bfa_port_topology bfa_fcport_get_topology(struct bfa_s *bfa);
534bfa_status_t bfa_fcport_cfg_hardalpa(struct bfa_s *bfa, u8 alpa);
535bfa_boolean_t bfa_fcport_get_hardalpa(struct bfa_s *bfa, u8 *alpa);
536u8 bfa_fcport_get_myalpa(struct bfa_s *bfa);
537bfa_status_t bfa_fcport_clr_hardalpa(struct bfa_s *bfa);
538bfa_status_t bfa_fcport_cfg_maxfrsize(struct bfa_s *bfa, u16 maxsize);
539u16 bfa_fcport_get_maxfrsize(struct bfa_s *bfa);
540u8 bfa_fcport_get_rx_bbcredit(struct bfa_s *bfa);
541void bfa_fcport_get_attr(struct bfa_s *bfa, struct bfa_port_attr_s *attr);
542wwn_t bfa_fcport_get_wwn(struct bfa_s *bfa, bfa_boolean_t node);
543void bfa_fcport_event_register(struct bfa_s *bfa,
544 void (*event_cbfn) (void *cbarg,
545 enum bfa_port_linkstate event), void *event_cbarg);
546bfa_boolean_t bfa_fcport_is_disabled(struct bfa_s *bfa);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700547enum bfa_port_speed bfa_fcport_get_ratelim_speed(struct bfa_s *bfa);
548
Krishna Gudipatibe540a92011-06-13 15:53:04 -0700549void bfa_fcport_set_tx_bbcredit(struct bfa_s *bfa, u16 tx_bbcredit, u8 bb_scn);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700550bfa_boolean_t bfa_fcport_is_ratelim(struct bfa_s *bfa);
551bfa_boolean_t bfa_fcport_is_linkup(struct bfa_s *bfa);
552bfa_status_t bfa_fcport_get_stats(struct bfa_s *bfa,
553 union bfa_fcport_stats_u *stats,
554 bfa_cb_port_t cbfn, void *cbarg);
555bfa_status_t bfa_fcport_clear_stats(struct bfa_s *bfa, bfa_cb_port_t cbfn,
556 void *cbarg);
557bfa_boolean_t bfa_fcport_is_qos_enabled(struct bfa_s *bfa);
Krishna Gudipatibe540a92011-06-13 15:53:04 -0700558bfa_boolean_t bfa_fcport_is_trunk_enabled(struct bfa_s *bfa);
Krishna Gudipati43ffdf42011-06-13 15:46:21 -0700559bfa_status_t bfa_fcport_is_pbcdisabled(struct bfa_s *bfa);
Krishna Gudipatia7141342011-06-24 20:23:19 -0700560void bfa_fcport_cfg_faa(struct bfa_s *bfa, u8 state);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700561
562/*
563 * bfa rport API functions
564 */
565struct bfa_rport_s *bfa_rport_create(struct bfa_s *bfa, void *rport_drv);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700566void bfa_rport_online(struct bfa_rport_s *rport,
567 struct bfa_rport_info_s *rport_info);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700568void bfa_rport_speed(struct bfa_rport_s *rport, enum bfa_port_speed speed);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700569void bfa_cb_rport_online(void *rport);
570void bfa_cb_rport_offline(void *rport);
571void bfa_cb_rport_qos_scn_flowid(void *rport,
572 struct bfa_rport_qos_attr_s old_qos_attr,
573 struct bfa_rport_qos_attr_s new_qos_attr);
574void bfa_cb_rport_qos_scn_prio(void *rport,
575 struct bfa_rport_qos_attr_s old_qos_attr,
576 struct bfa_rport_qos_attr_s new_qos_attr);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700577
578/*
579 * bfa fcxp API functions
580 */
581struct bfa_fcxp_s *bfa_fcxp_alloc(void *bfad_fcxp, struct bfa_s *bfa,
582 int nreq_sgles, int nrsp_sgles,
583 bfa_fcxp_get_sgaddr_t get_req_sga,
584 bfa_fcxp_get_sglen_t get_req_sglen,
585 bfa_fcxp_get_sgaddr_t get_rsp_sga,
586 bfa_fcxp_get_sglen_t get_rsp_sglen);
587void bfa_fcxp_alloc_wait(struct bfa_s *bfa, struct bfa_fcxp_wqe_s *wqe,
588 bfa_fcxp_alloc_cbfn_t alloc_cbfn,
589 void *cbarg, void *bfad_fcxp,
590 int nreq_sgles, int nrsp_sgles,
591 bfa_fcxp_get_sgaddr_t get_req_sga,
592 bfa_fcxp_get_sglen_t get_req_sglen,
593 bfa_fcxp_get_sgaddr_t get_rsp_sga,
594 bfa_fcxp_get_sglen_t get_rsp_sglen);
595void bfa_fcxp_walloc_cancel(struct bfa_s *bfa,
596 struct bfa_fcxp_wqe_s *wqe);
597void bfa_fcxp_discard(struct bfa_fcxp_s *fcxp);
598
599void *bfa_fcxp_get_reqbuf(struct bfa_fcxp_s *fcxp);
600void *bfa_fcxp_get_rspbuf(struct bfa_fcxp_s *fcxp);
601
602void bfa_fcxp_free(struct bfa_fcxp_s *fcxp);
603
604void bfa_fcxp_send(struct bfa_fcxp_s *fcxp, struct bfa_rport_s *rport,
605 u16 vf_id, u8 lp_tag,
606 bfa_boolean_t cts, enum fc_cos cos,
607 u32 reqlen, struct fchs_s *fchs,
608 bfa_cb_fcxp_send_t cbfn,
609 void *cbarg,
610 u32 rsp_maxlen, u8 rsp_timeout);
611bfa_status_t bfa_fcxp_abort(struct bfa_fcxp_s *fcxp);
612u32 bfa_fcxp_get_reqbufsz(struct bfa_fcxp_s *fcxp);
613u32 bfa_fcxp_get_maxrsp(struct bfa_s *bfa);
Krishna Gudipati3fd45982011-06-24 20:24:08 -0700614void bfa_fcxp_res_recfg(struct bfa_s *bfa, u16 num_fcxp_fw);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700615
616static inline void *
617bfa_uf_get_frmbuf(struct bfa_uf_s *uf)
618{
619 return uf->data_ptr;
620}
621
622static inline u16
623bfa_uf_get_frmlen(struct bfa_uf_s *uf)
624{
625 return uf->data_len;
626}
627
628/*
629 * bfa uf API functions
630 */
631void bfa_uf_recv_register(struct bfa_s *bfa, bfa_cb_uf_recv_t ufrecv,
632 void *cbarg);
633void bfa_uf_free(struct bfa_uf_s *uf);
634
Jing Huangacdc79a2010-10-18 17:15:55 -0700635/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700636 * bfa lport service api
637 */
638
639u32 bfa_lps_get_max_vport(struct bfa_s *bfa);
640struct bfa_lps_s *bfa_lps_alloc(struct bfa_s *bfa);
641void bfa_lps_delete(struct bfa_lps_s *lps);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700642void bfa_lps_flogi(struct bfa_lps_s *lps, void *uarg, u8 alpa,
643 u16 pdusz, wwn_t pwwn, wwn_t nwwn,
Krishna Gudipatibe540a92011-06-13 15:53:04 -0700644 bfa_boolean_t auth_en, u8 bb_scn);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700645void bfa_lps_fdisc(struct bfa_lps_s *lps, void *uarg, u16 pdusz,
646 wwn_t pwwn, wwn_t nwwn);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700647void bfa_lps_fdisclogo(struct bfa_lps_s *lps);
Krishna Gudipatib7044952010-12-13 16:17:42 -0800648void bfa_lps_set_n2n_pid(struct bfa_lps_s *lps, u32 n2n_pid);
Krishna Gudipati3fd45982011-06-24 20:24:08 -0700649u8 bfa_lps_get_fwtag(struct bfa_s *bfa, u8 lp_tag);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700650u32 bfa_lps_get_base_pid(struct bfa_s *bfa);
651u8 bfa_lps_get_tag_from_pid(struct bfa_s *bfa, u32 pid);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700652void bfa_cb_lps_flogi_comp(void *bfad, void *uarg, bfa_status_t status);
653void bfa_cb_lps_fdisc_comp(void *bfad, void *uarg, bfa_status_t status);
654void bfa_cb_lps_fdisclogo_comp(void *bfad, void *uarg);
655void bfa_cb_lps_cvl_event(void *bfad, void *uarg);
656
Krishna Gudipatia7141342011-06-24 20:23:19 -0700657/* FAA specific APIs */
658bfa_status_t bfa_faa_enable(struct bfa_s *bfa,
659 bfa_cb_iocfc_t cbfn, void *cbarg);
660bfa_status_t bfa_faa_disable(struct bfa_s *bfa,
661 bfa_cb_iocfc_t cbfn, void *cbarg);
662bfa_status_t bfa_faa_query(struct bfa_s *bfa, struct bfa_faa_attr_s *attr,
663 bfa_cb_iocfc_t cbfn, void *cbarg);
664
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700665#endif /* __BFA_SVC_H__ */