blob: 6df1492089cf4ac7bde91a2f168c0c91742c4576 [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)
29
Jing Huangacdc79a2010-10-18 17:15:55 -070030/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -070031 * Alignment macro for SG page allocation
32 */
33#define BFA_SGPG_ROUNDUP(_l) (((_l) + (sizeof(struct bfi_sgpg_s) - 1)) \
34 & ~(sizeof(struct bfi_sgpg_s) - 1))
35
36struct bfa_sgpg_wqe_s {
37 struct list_head qe; /* queue sg page element */
38 int nsgpg; /* pages to be allocated */
39 int nsgpg_total; /* total pages required */
40 void (*cbfn) (void *cbarg); /* callback function */
41 void *cbarg; /* callback arg */
42 struct list_head sgpg_q; /* queue of alloced sgpgs */
43};
44
45struct bfa_sgpg_s {
46 struct list_head qe; /* queue sg page element */
47 struct bfi_sgpg_s *sgpg; /* va of SG page */
48 union bfi_addr_u sgpg_pa; /* pa of SG page */
49};
50
Jing Huangacdc79a2010-10-18 17:15:55 -070051/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -070052 * Given number of SG elements, BFA_SGPG_NPAGE() returns the number of
53 * SG pages required.
54 */
55#define BFA_SGPG_NPAGE(_nsges) (((_nsges) / BFI_SGPG_DATA_SGES) + 1)
56
57struct bfa_sgpg_mod_s {
58 struct bfa_s *bfa;
59 int num_sgpgs; /* number of SG pages */
60 int free_sgpgs; /* number of free SG pages */
61 struct bfa_sgpg_s *hsgpg_arr; /* BFA SG page array */
62 struct bfi_sgpg_s *sgpg_arr; /* actual SG page array */
63 u64 sgpg_arr_pa; /* SG page array DMA addr */
64 struct list_head sgpg_q; /* queue of free SG pages */
65 struct list_head sgpg_wait_q; /* wait queue for SG pages */
66};
67#define BFA_SGPG_MOD(__bfa) (&(__bfa)->modules.sgpg_mod)
68
69bfa_status_t bfa_sgpg_malloc(struct bfa_s *bfa, struct list_head *sgpg_q,
70 int nsgpgs);
71void bfa_sgpg_mfree(struct bfa_s *bfa, struct list_head *sgpg_q, int nsgpgs);
72void bfa_sgpg_winit(struct bfa_sgpg_wqe_s *wqe,
73 void (*cbfn) (void *cbarg), void *cbarg);
74void bfa_sgpg_wait(struct bfa_s *bfa, struct bfa_sgpg_wqe_s *wqe, int nsgpgs);
75void bfa_sgpg_wcancel(struct bfa_s *bfa, struct bfa_sgpg_wqe_s *wqe);
76
77
Jing Huangacdc79a2010-10-18 17:15:55 -070078/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -070079 * FCXP related defines
80 */
81#define BFA_FCXP_MIN (1)
82#define BFA_FCXP_MAX_IBUF_SZ (2 * 1024 + 256)
83#define BFA_FCXP_MAX_LBUF_SZ (4 * 1024 + 256)
84
85struct bfa_fcxp_mod_s {
86 struct bfa_s *bfa; /* backpointer to BFA */
87 struct bfa_fcxp_s *fcxp_list; /* array of FCXPs */
88 u16 num_fcxps; /* max num FCXP requests */
89 struct list_head fcxp_free_q; /* free FCXPs */
90 struct list_head fcxp_active_q; /* active FCXPs */
91 void *req_pld_list_kva; /* list of FCXP req pld */
92 u64 req_pld_list_pa; /* list of FCXP req pld */
93 void *rsp_pld_list_kva; /* list of FCXP resp pld */
94 u64 rsp_pld_list_pa; /* list of FCXP resp pld */
95 struct list_head wait_q; /* wait queue for free fcxp */
Krishna Gudipati3fd45982011-06-24 20:24:08 -070096 struct list_head fcxp_unused_q; /* unused fcxps */
Krishna Gudipatia36c61f2010-09-15 11:50:55 -070097 u32 req_pld_sz;
98 u32 rsp_pld_sz;
99};
100
101#define BFA_FCXP_MOD(__bfa) (&(__bfa)->modules.fcxp_mod)
102#define BFA_FCXP_FROM_TAG(__mod, __tag) (&(__mod)->fcxp_list[__tag])
103
104typedef void (*fcxp_send_cb_t) (struct bfa_s *ioc, struct bfa_fcxp_s *fcxp,
105 void *cb_arg, bfa_status_t req_status,
106 u32 rsp_len, u32 resid_len,
107 struct fchs_s *rsp_fchs);
108
109typedef u64 (*bfa_fcxp_get_sgaddr_t) (void *bfad_fcxp, int sgeid);
110typedef u32 (*bfa_fcxp_get_sglen_t) (void *bfad_fcxp, int sgeid);
111typedef void (*bfa_cb_fcxp_send_t) (void *bfad_fcxp, struct bfa_fcxp_s *fcxp,
112 void *cbarg, enum bfa_status req_status,
113 u32 rsp_len, u32 resid_len,
114 struct fchs_s *rsp_fchs);
115typedef void (*bfa_fcxp_alloc_cbfn_t) (void *cbarg, struct bfa_fcxp_s *fcxp);
116
117
118
Jing Huangacdc79a2010-10-18 17:15:55 -0700119/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700120 * Information needed for a FCXP request
121 */
122struct bfa_fcxp_req_info_s {
123 struct bfa_rport_s *bfa_rport;
Jing Huangacdc79a2010-10-18 17:15:55 -0700124 /* Pointer to the bfa rport that was
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700125 * returned from bfa_rport_create().
126 * This could be left NULL for WKA or
127 * for FCXP interactions before the
128 * rport nexus is established
129 */
130 struct fchs_s fchs; /* request FC header structure */
Lucas De Marchi25985ed2011-03-30 22:57:33 -0300131 u8 cts; /* continuous sequence */
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700132 u8 class; /* FC class for the request/response */
133 u16 max_frmsz; /* max send frame size */
134 u16 vf_id; /* vsan tag if applicable */
135 u8 lp_tag; /* lport tag */
136 u32 req_tot_len; /* request payload total length */
137};
138
139struct bfa_fcxp_rsp_info_s {
140 struct fchs_s rsp_fchs;
Jing Huangacdc79a2010-10-18 17:15:55 -0700141 /* Response frame's FC header will
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700142 * be sent back in this field */
143 u8 rsp_timeout;
Jing Huangacdc79a2010-10-18 17:15:55 -0700144 /* timeout in seconds, 0-no response */
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700145 u8 rsvd2[3];
146 u32 rsp_maxlen; /* max response length expected */
147};
148
149struct bfa_fcxp_s {
150 struct list_head qe; /* fcxp queue element */
151 bfa_sm_t sm; /* state machine */
152 void *caller; /* driver or fcs */
153 struct bfa_fcxp_mod_s *fcxp_mod;
154 /* back pointer to fcxp mod */
155 u16 fcxp_tag; /* internal tag */
156 struct bfa_fcxp_req_info_s req_info;
157 /* request info */
158 struct bfa_fcxp_rsp_info_s rsp_info;
159 /* response info */
160 u8 use_ireqbuf; /* use internal req buf */
161 u8 use_irspbuf; /* use internal rsp buf */
162 u32 nreq_sgles; /* num request SGLEs */
163 u32 nrsp_sgles; /* num response SGLEs */
164 struct list_head req_sgpg_q; /* SG pages for request buf */
165 struct list_head req_sgpg_wqe; /* wait queue for req SG page */
166 struct list_head rsp_sgpg_q; /* SG pages for response buf */
167 struct list_head rsp_sgpg_wqe; /* wait queue for rsp SG page */
168
169 bfa_fcxp_get_sgaddr_t req_sga_cbfn;
170 /* SG elem addr user function */
171 bfa_fcxp_get_sglen_t req_sglen_cbfn;
172 /* SG elem len user function */
173 bfa_fcxp_get_sgaddr_t rsp_sga_cbfn;
174 /* SG elem addr user function */
175 bfa_fcxp_get_sglen_t rsp_sglen_cbfn;
176 /* SG elem len user function */
177 bfa_cb_fcxp_send_t send_cbfn; /* send completion callback */
178 void *send_cbarg; /* callback arg */
179 struct bfa_sge_s req_sge[BFA_FCXP_MAX_SGES];
180 /* req SG elems */
181 struct bfa_sge_s rsp_sge[BFA_FCXP_MAX_SGES];
182 /* rsp SG elems */
183 u8 rsp_status; /* comp: rsp status */
184 u32 rsp_len; /* comp: actual response len */
185 u32 residue_len; /* comp: residual rsp length */
186 struct fchs_s rsp_fchs; /* comp: response fchs */
187 struct bfa_cb_qe_s hcb_qe; /* comp: callback qelem */
188 struct bfa_reqq_wait_s reqq_wqe;
189 bfa_boolean_t reqq_waiting;
190};
191
192struct bfa_fcxp_wqe_s {
193 struct list_head qe;
194 bfa_fcxp_alloc_cbfn_t alloc_cbfn;
195 void *alloc_cbarg;
196 void *caller;
197 struct bfa_s *bfa;
198 int nreq_sgles;
199 int nrsp_sgles;
200 bfa_fcxp_get_sgaddr_t req_sga_cbfn;
201 bfa_fcxp_get_sglen_t req_sglen_cbfn;
202 bfa_fcxp_get_sgaddr_t rsp_sga_cbfn;
203 bfa_fcxp_get_sglen_t rsp_sglen_cbfn;
204};
205
206#define BFA_FCXP_REQ_PLD(_fcxp) (bfa_fcxp_get_reqbuf(_fcxp))
207#define BFA_FCXP_RSP_FCHS(_fcxp) (&((_fcxp)->rsp_info.fchs))
208#define BFA_FCXP_RSP_PLD(_fcxp) (bfa_fcxp_get_rspbuf(_fcxp))
209
210#define BFA_FCXP_REQ_PLD_PA(_fcxp) \
211 ((_fcxp)->fcxp_mod->req_pld_list_pa + \
212 ((_fcxp)->fcxp_mod->req_pld_sz * (_fcxp)->fcxp_tag))
213
214#define BFA_FCXP_RSP_PLD_PA(_fcxp) \
215 ((_fcxp)->fcxp_mod->rsp_pld_list_pa + \
216 ((_fcxp)->fcxp_mod->rsp_pld_sz * (_fcxp)->fcxp_tag))
217
218void bfa_fcxp_isr(struct bfa_s *bfa, struct bfi_msg_s *msg);
219
220
Jing Huangacdc79a2010-10-18 17:15:55 -0700221/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700222 * RPORT related defines
223 */
Maggie Zhangf7f73812010-12-09 19:08:43 -0800224enum bfa_rport_event {
225 BFA_RPORT_SM_CREATE = 1, /* rport create event */
226 BFA_RPORT_SM_DELETE = 2, /* deleting an existing rport */
227 BFA_RPORT_SM_ONLINE = 3, /* rport is online */
228 BFA_RPORT_SM_OFFLINE = 4, /* rport is offline */
229 BFA_RPORT_SM_FWRSP = 5, /* firmware response */
230 BFA_RPORT_SM_HWFAIL = 6, /* IOC h/w failure */
231 BFA_RPORT_SM_QOS_SCN = 7, /* QoS SCN from firmware */
232 BFA_RPORT_SM_SET_SPEED = 8, /* Set Rport Speed */
233 BFA_RPORT_SM_QRESUME = 9, /* space in requeue queue */
234};
235
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700236#define BFA_RPORT_MIN 4
237
238struct bfa_rport_mod_s {
239 struct bfa_rport_s *rps_list; /* list of rports */
240 struct list_head rp_free_q; /* free bfa_rports */
241 struct list_head rp_active_q; /* free bfa_rports */
Krishna Gudipati3fd45982011-06-24 20:24:08 -0700242 struct list_head rp_unused_q; /* unused bfa rports */
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700243 u16 num_rports; /* number of rports */
244};
245
246#define BFA_RPORT_MOD(__bfa) (&(__bfa)->modules.rport_mod)
247
Jing Huangacdc79a2010-10-18 17:15:55 -0700248/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700249 * Convert rport tag to RPORT
250 */
251#define BFA_RPORT_FROM_TAG(__bfa, _tag) \
252 (BFA_RPORT_MOD(__bfa)->rps_list + \
253 ((_tag) & (BFA_RPORT_MOD(__bfa)->num_rports - 1)))
254
255/*
256 * protected functions
257 */
258void bfa_rport_isr(struct bfa_s *bfa, struct bfi_msg_s *msg);
Krishna Gudipati3fd45982011-06-24 20:24:08 -0700259void bfa_rport_res_recfg(struct bfa_s *bfa, u16 num_rport_fw);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700260
Jing Huangacdc79a2010-10-18 17:15:55 -0700261/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700262 * BFA rport information.
263 */
264struct bfa_rport_info_s {
265 u16 max_frmsz; /* max rcv pdu size */
266 u32 pid:24, /* remote port ID */
267 lp_tag:8; /* tag */
268 u32 local_pid:24, /* local port ID */
269 cisc:8; /* CIRO supported */
270 u8 fc_class; /* supported FC classes. enum fc_cos */
271 u8 vf_en; /* virtual fabric enable */
272 u16 vf_id; /* virtual fabric ID */
273 enum bfa_port_speed speed; /* Rport's current speed */
274};
275
Jing Huangacdc79a2010-10-18 17:15:55 -0700276/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700277 * BFA rport data structure
278 */
279struct bfa_rport_s {
280 struct list_head qe; /* queue element */
281 bfa_sm_t sm; /* state machine */
282 struct bfa_s *bfa; /* backpointer to BFA */
283 void *rport_drv; /* fcs/driver rport object */
284 u16 fw_handle; /* firmware rport handle */
285 u16 rport_tag; /* BFA rport tag */
286 struct bfa_rport_info_s rport_info; /* rport info from fcs/driver */
287 struct bfa_reqq_wait_s reqq_wait; /* to wait for room in reqq */
288 struct bfa_cb_qe_s hcb_qe; /* BFA callback qelem */
289 struct bfa_rport_hal_stats_s stats; /* BFA rport statistics */
290 struct bfa_rport_qos_attr_s qos_attr;
291 union a {
292 bfa_status_t status; /* f/w status */
293 void *fw_msg; /* QoS scn event */
294 } event_arg;
295};
296#define BFA_RPORT_FC_COS(_rport) ((_rport)->rport_info.fc_class)
297
298
Jing Huangacdc79a2010-10-18 17:15:55 -0700299/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700300 * UF - unsolicited receive related defines
301 */
302
303#define BFA_UF_MIN (4)
304
305
306struct bfa_uf_s {
307 struct list_head qe; /* queue element */
308 struct bfa_s *bfa; /* bfa instance */
309 u16 uf_tag; /* identifying tag fw msgs */
310 u16 vf_id;
311 u16 src_rport_handle;
312 u16 rsvd;
313 u8 *data_ptr;
314 u16 data_len; /* actual receive length */
315 u16 pb_len; /* posted buffer length */
316 void *buf_kva; /* buffer virtual address */
317 u64 buf_pa; /* buffer physical address */
318 struct bfa_cb_qe_s hcb_qe; /* comp: BFA comp qelem */
319 struct bfa_sge_s sges[BFI_SGE_INLINE_MAX];
320};
321
Jing Huangacdc79a2010-10-18 17:15:55 -0700322/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700323 * Callback prototype for unsolicited frame receive handler.
324 *
325 * @param[in] cbarg callback arg for receive handler
326 * @param[in] uf unsolicited frame descriptor
327 *
328 * @return None
329 */
330typedef void (*bfa_cb_uf_recv_t) (void *cbarg, struct bfa_uf_s *uf);
331
332struct bfa_uf_mod_s {
333 struct bfa_s *bfa; /* back pointer to BFA */
334 struct bfa_uf_s *uf_list; /* array of UFs */
335 u16 num_ufs; /* num unsolicited rx frames */
336 struct list_head uf_free_q; /* free UFs */
337 struct list_head uf_posted_q; /* UFs posted to IOC */
Krishna Gudipati3fd45982011-06-24 20:24:08 -0700338 struct list_head uf_unused_q; /* unused UF's */
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700339 struct bfa_uf_buf_s *uf_pbs_kva; /* list UF bufs request pld */
340 u64 uf_pbs_pa; /* phy addr for UF bufs */
341 struct bfi_uf_buf_post_s *uf_buf_posts;
342 /* pre-built UF post msgs */
343 bfa_cb_uf_recv_t ufrecv; /* uf recv handler function */
344 void *cbarg; /* uf receive handler arg */
345};
346
347#define BFA_UF_MOD(__bfa) (&(__bfa)->modules.uf_mod)
348
349#define ufm_pbs_pa(_ufmod, _uftag) \
350 ((_ufmod)->uf_pbs_pa + sizeof(struct bfa_uf_buf_s) * (_uftag))
351
352void bfa_uf_isr(struct bfa_s *bfa, struct bfi_msg_s *msg);
Krishna Gudipati3fd45982011-06-24 20:24:08 -0700353void bfa_uf_res_recfg(struct bfa_s *bfa, u16 num_uf_fw);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700354
355#define BFA_UF_BUFSZ (2 * 1024 + 256)
356
Jing Huangacdc79a2010-10-18 17:15:55 -0700357/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700358 * @todo private
359 */
360struct bfa_uf_buf_s {
361 u8 d[BFA_UF_BUFSZ];
362};
363
364
Jing Huangacdc79a2010-10-18 17:15:55 -0700365/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700366 * LPS - bfa lport login/logout service interface
367 */
368struct bfa_lps_s {
369 struct list_head qe; /* queue element */
370 struct bfa_s *bfa; /* parent bfa instance */
371 bfa_sm_t sm; /* finite state machine */
Krishna Gudipati3fd45982011-06-24 20:24:08 -0700372 u8 bfa_tag; /* lport tag */
373 u8 fw_tag; /* lport fw tag */
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700374 u8 reqq; /* lport request queue */
375 u8 alpa; /* ALPA for loop topologies */
376 u32 lp_pid; /* lport port ID */
377 bfa_boolean_t fdisc; /* snd FDISC instead of FLOGI */
378 bfa_boolean_t auth_en; /* enable authentication */
379 bfa_boolean_t auth_req; /* authentication required */
380 bfa_boolean_t npiv_en; /* NPIV is allowed by peer */
381 bfa_boolean_t fport; /* attached peer is F_PORT */
382 bfa_boolean_t brcd_switch; /* attached peer is brcd sw */
383 bfa_status_t status; /* login status */
384 u16 pdusz; /* max receive PDU size */
385 u16 pr_bbcred; /* BB_CREDIT from peer */
Krishna Gudipatibe540a92011-06-13 15:53:04 -0700386 u8 pr_bbscn; /* BB_SCN from peer */
387 u8 bb_scn; /* local BB_SCN */
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700388 u8 lsrjt_rsn; /* LSRJT reason */
389 u8 lsrjt_expl; /* LSRJT explanation */
390 wwn_t pwwn; /* port wwn of lport */
391 wwn_t nwwn; /* node wwn of lport */
392 wwn_t pr_pwwn; /* port wwn of lport peer */
393 wwn_t pr_nwwn; /* node wwn of lport peer */
394 mac_t lp_mac; /* fpma/spma MAC for lport */
395 mac_t fcf_mac; /* FCF MAC of lport */
396 struct bfa_reqq_wait_s wqe; /* request wait queue element */
397 void *uarg; /* user callback arg */
398 struct bfa_cb_qe_s hcb_qe; /* comp: callback qelem */
399 struct bfi_lps_login_rsp_s *loginrsp;
400 bfa_eproto_status_t ext_status;
401};
402
403struct bfa_lps_mod_s {
404 struct list_head lps_free_q;
405 struct list_head lps_active_q;
Krishna Gudipati3fd45982011-06-24 20:24:08 -0700406 struct list_head lps_login_q;
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700407 struct bfa_lps_s *lps_arr;
408 int num_lps;
409};
410
411#define BFA_LPS_MOD(__bfa) (&(__bfa)->modules.lps_mod)
412#define BFA_LPS_FROM_TAG(__mod, __tag) (&(__mod)->lps_arr[__tag])
413
414/*
415 * external functions
416 */
417void bfa_lps_isr(struct bfa_s *bfa, struct bfi_msg_s *msg);
418
419
Jing Huangacdc79a2010-10-18 17:15:55 -0700420/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700421 * FCPORT related defines
422 */
423
424#define BFA_FCPORT(_bfa) (&((_bfa)->modules.port))
425typedef void (*bfa_cb_port_t) (void *cbarg, enum bfa_status status);
426
Jing Huangacdc79a2010-10-18 17:15:55 -0700427/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700428 * Link notification data structure
429 */
430struct bfa_fcport_ln_s {
431 struct bfa_fcport_s *fcport;
432 bfa_sm_t sm;
433 struct bfa_cb_qe_s ln_qe; /* BFA callback queue elem for ln */
434 enum bfa_port_linkstate ln_event; /* ln event for callback */
435};
436
437struct bfa_fcport_trunk_s {
438 struct bfa_trunk_attr_s attr;
439};
440
Jing Huangacdc79a2010-10-18 17:15:55 -0700441/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700442 * BFA FC port data structure
443 */
444struct bfa_fcport_s {
445 struct bfa_s *bfa; /* parent BFA instance */
446 bfa_sm_t sm; /* port state machine */
447 wwn_t nwwn; /* node wwn of physical port */
448 wwn_t pwwn; /* port wwn of physical oprt */
449 enum bfa_port_speed speed_sup;
450 /* supported speeds */
451 enum bfa_port_speed speed; /* current speed */
452 enum bfa_port_topology topology; /* current topology */
453 u8 myalpa; /* my ALPA in LOOP topology */
454 u8 rsvd[3];
455 struct bfa_port_cfg_s cfg; /* current port configuration */
Krishna Gudipatif3a060c2010-12-13 16:16:50 -0800456 bfa_boolean_t use_flash_cfg; /* get port cfg from flash */
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700457 struct bfa_qos_attr_s qos_attr; /* QoS Attributes */
458 struct bfa_qos_vc_attr_s qos_vc_attr; /* VC info from ELP */
459 struct bfa_reqq_wait_s reqq_wait;
460 /* to wait for room in reqq */
461 struct bfa_reqq_wait_s svcreq_wait;
462 /* to wait for room in reqq */
463 struct bfa_reqq_wait_s stats_reqq_wait;
464 /* to wait for room in reqq (stats) */
465 void *event_cbarg;
466 void (*event_cbfn) (void *cbarg,
467 enum bfa_port_linkstate event);
468 union {
469 union bfi_fcport_i2h_msg_u i2hmsg;
470 } event_arg;
471 void *bfad; /* BFA driver handle */
472 struct bfa_fcport_ln_s ln; /* Link Notification */
473 struct bfa_cb_qe_s hcb_qe; /* BFA callback queue elem */
474 struct bfa_timer_s timer; /* timer */
475 u32 msgtag; /* fimrware msg tag for reply */
476 u8 *stats_kva;
477 u64 stats_pa;
478 union bfa_fcport_stats_u *stats;
479 union bfa_fcport_stats_u *stats_ret; /* driver stats location */
480 bfa_status_t stats_status; /* stats/statsclr status */
481 bfa_boolean_t stats_busy; /* outstanding stats/statsclr */
482 bfa_boolean_t stats_qfull;
483 u32 stats_reset_time; /* stats reset time stamp */
484 bfa_cb_port_t stats_cbfn; /* driver callback function */
485 void *stats_cbarg; /* *!< user callback arg */
486 bfa_boolean_t diag_busy; /* diag busy status */
487 bfa_boolean_t beacon; /* port beacon status */
488 bfa_boolean_t link_e2e_beacon; /* link beacon status */
Krishna Gudipatibe540a92011-06-13 15:53:04 -0700489 bfa_boolean_t bbsc_op_state; /* Cred recov Oper State */
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700490 struct bfa_fcport_trunk_s trunk;
491 u16 fcoe_vlan;
492};
493
494#define BFA_FCPORT_MOD(__bfa) (&(__bfa)->modules.fcport)
495
496/*
497 * protected functions
498 */
499void bfa_fcport_init(struct bfa_s *bfa);
500void bfa_fcport_isr(struct bfa_s *bfa, struct bfi_msg_s *msg);
501
502/*
503 * bfa fcport API functions
504 */
505bfa_status_t bfa_fcport_enable(struct bfa_s *bfa);
506bfa_status_t bfa_fcport_disable(struct bfa_s *bfa);
507bfa_status_t bfa_fcport_cfg_speed(struct bfa_s *bfa,
508 enum bfa_port_speed speed);
509enum bfa_port_speed bfa_fcport_get_speed(struct bfa_s *bfa);
510bfa_status_t bfa_fcport_cfg_topology(struct bfa_s *bfa,
511 enum bfa_port_topology topo);
512enum bfa_port_topology bfa_fcport_get_topology(struct bfa_s *bfa);
513bfa_status_t bfa_fcport_cfg_hardalpa(struct bfa_s *bfa, u8 alpa);
514bfa_boolean_t bfa_fcport_get_hardalpa(struct bfa_s *bfa, u8 *alpa);
515u8 bfa_fcport_get_myalpa(struct bfa_s *bfa);
516bfa_status_t bfa_fcport_clr_hardalpa(struct bfa_s *bfa);
517bfa_status_t bfa_fcport_cfg_maxfrsize(struct bfa_s *bfa, u16 maxsize);
518u16 bfa_fcport_get_maxfrsize(struct bfa_s *bfa);
519u8 bfa_fcport_get_rx_bbcredit(struct bfa_s *bfa);
520void bfa_fcport_get_attr(struct bfa_s *bfa, struct bfa_port_attr_s *attr);
521wwn_t bfa_fcport_get_wwn(struct bfa_s *bfa, bfa_boolean_t node);
522void bfa_fcport_event_register(struct bfa_s *bfa,
523 void (*event_cbfn) (void *cbarg,
524 enum bfa_port_linkstate event), void *event_cbarg);
525bfa_boolean_t bfa_fcport_is_disabled(struct bfa_s *bfa);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700526enum bfa_port_speed bfa_fcport_get_ratelim_speed(struct bfa_s *bfa);
527
Krishna Gudipatibe540a92011-06-13 15:53:04 -0700528void bfa_fcport_set_tx_bbcredit(struct bfa_s *bfa, u16 tx_bbcredit, u8 bb_scn);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700529bfa_boolean_t bfa_fcport_is_ratelim(struct bfa_s *bfa);
530bfa_boolean_t bfa_fcport_is_linkup(struct bfa_s *bfa);
531bfa_status_t bfa_fcport_get_stats(struct bfa_s *bfa,
532 union bfa_fcport_stats_u *stats,
533 bfa_cb_port_t cbfn, void *cbarg);
534bfa_status_t bfa_fcport_clear_stats(struct bfa_s *bfa, bfa_cb_port_t cbfn,
535 void *cbarg);
536bfa_boolean_t bfa_fcport_is_qos_enabled(struct bfa_s *bfa);
Krishna Gudipatibe540a92011-06-13 15:53:04 -0700537bfa_boolean_t bfa_fcport_is_trunk_enabled(struct bfa_s *bfa);
Krishna Gudipati43ffdf42011-06-13 15:46:21 -0700538bfa_status_t bfa_fcport_is_pbcdisabled(struct bfa_s *bfa);
Krishna Gudipatia7141342011-06-24 20:23:19 -0700539void bfa_fcport_cfg_faa(struct bfa_s *bfa, u8 state);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700540
541/*
542 * bfa rport API functions
543 */
544struct bfa_rport_s *bfa_rport_create(struct bfa_s *bfa, void *rport_drv);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700545void bfa_rport_online(struct bfa_rport_s *rport,
546 struct bfa_rport_info_s *rport_info);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700547void bfa_rport_speed(struct bfa_rport_s *rport, enum bfa_port_speed speed);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700548void bfa_cb_rport_online(void *rport);
549void bfa_cb_rport_offline(void *rport);
550void bfa_cb_rport_qos_scn_flowid(void *rport,
551 struct bfa_rport_qos_attr_s old_qos_attr,
552 struct bfa_rport_qos_attr_s new_qos_attr);
553void bfa_cb_rport_qos_scn_prio(void *rport,
554 struct bfa_rport_qos_attr_s old_qos_attr,
555 struct bfa_rport_qos_attr_s new_qos_attr);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700556
557/*
558 * bfa fcxp API functions
559 */
560struct bfa_fcxp_s *bfa_fcxp_alloc(void *bfad_fcxp, struct bfa_s *bfa,
561 int nreq_sgles, int nrsp_sgles,
562 bfa_fcxp_get_sgaddr_t get_req_sga,
563 bfa_fcxp_get_sglen_t get_req_sglen,
564 bfa_fcxp_get_sgaddr_t get_rsp_sga,
565 bfa_fcxp_get_sglen_t get_rsp_sglen);
566void bfa_fcxp_alloc_wait(struct bfa_s *bfa, struct bfa_fcxp_wqe_s *wqe,
567 bfa_fcxp_alloc_cbfn_t alloc_cbfn,
568 void *cbarg, void *bfad_fcxp,
569 int nreq_sgles, int nrsp_sgles,
570 bfa_fcxp_get_sgaddr_t get_req_sga,
571 bfa_fcxp_get_sglen_t get_req_sglen,
572 bfa_fcxp_get_sgaddr_t get_rsp_sga,
573 bfa_fcxp_get_sglen_t get_rsp_sglen);
574void bfa_fcxp_walloc_cancel(struct bfa_s *bfa,
575 struct bfa_fcxp_wqe_s *wqe);
576void bfa_fcxp_discard(struct bfa_fcxp_s *fcxp);
577
578void *bfa_fcxp_get_reqbuf(struct bfa_fcxp_s *fcxp);
579void *bfa_fcxp_get_rspbuf(struct bfa_fcxp_s *fcxp);
580
581void bfa_fcxp_free(struct bfa_fcxp_s *fcxp);
582
583void bfa_fcxp_send(struct bfa_fcxp_s *fcxp, struct bfa_rport_s *rport,
584 u16 vf_id, u8 lp_tag,
585 bfa_boolean_t cts, enum fc_cos cos,
586 u32 reqlen, struct fchs_s *fchs,
587 bfa_cb_fcxp_send_t cbfn,
588 void *cbarg,
589 u32 rsp_maxlen, u8 rsp_timeout);
590bfa_status_t bfa_fcxp_abort(struct bfa_fcxp_s *fcxp);
591u32 bfa_fcxp_get_reqbufsz(struct bfa_fcxp_s *fcxp);
592u32 bfa_fcxp_get_maxrsp(struct bfa_s *bfa);
Krishna Gudipati3fd45982011-06-24 20:24:08 -0700593void bfa_fcxp_res_recfg(struct bfa_s *bfa, u16 num_fcxp_fw);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700594
595static inline void *
596bfa_uf_get_frmbuf(struct bfa_uf_s *uf)
597{
598 return uf->data_ptr;
599}
600
601static inline u16
602bfa_uf_get_frmlen(struct bfa_uf_s *uf)
603{
604 return uf->data_len;
605}
606
607/*
608 * bfa uf API functions
609 */
610void bfa_uf_recv_register(struct bfa_s *bfa, bfa_cb_uf_recv_t ufrecv,
611 void *cbarg);
612void bfa_uf_free(struct bfa_uf_s *uf);
613
Jing Huangacdc79a2010-10-18 17:15:55 -0700614/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700615 * bfa lport service api
616 */
617
618u32 bfa_lps_get_max_vport(struct bfa_s *bfa);
619struct bfa_lps_s *bfa_lps_alloc(struct bfa_s *bfa);
620void bfa_lps_delete(struct bfa_lps_s *lps);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700621void bfa_lps_flogi(struct bfa_lps_s *lps, void *uarg, u8 alpa,
622 u16 pdusz, wwn_t pwwn, wwn_t nwwn,
Krishna Gudipatibe540a92011-06-13 15:53:04 -0700623 bfa_boolean_t auth_en, u8 bb_scn);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700624void bfa_lps_fdisc(struct bfa_lps_s *lps, void *uarg, u16 pdusz,
625 wwn_t pwwn, wwn_t nwwn);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700626void bfa_lps_fdisclogo(struct bfa_lps_s *lps);
Krishna Gudipatib7044952010-12-13 16:17:42 -0800627void bfa_lps_set_n2n_pid(struct bfa_lps_s *lps, u32 n2n_pid);
Krishna Gudipati3fd45982011-06-24 20:24:08 -0700628u8 bfa_lps_get_fwtag(struct bfa_s *bfa, u8 lp_tag);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700629u32 bfa_lps_get_base_pid(struct bfa_s *bfa);
630u8 bfa_lps_get_tag_from_pid(struct bfa_s *bfa, u32 pid);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700631void bfa_cb_lps_flogi_comp(void *bfad, void *uarg, bfa_status_t status);
632void bfa_cb_lps_fdisc_comp(void *bfad, void *uarg, bfa_status_t status);
633void bfa_cb_lps_fdisclogo_comp(void *bfad, void *uarg);
634void bfa_cb_lps_cvl_event(void *bfad, void *uarg);
635
Krishna Gudipatia7141342011-06-24 20:23:19 -0700636/* FAA specific APIs */
637bfa_status_t bfa_faa_enable(struct bfa_s *bfa,
638 bfa_cb_iocfc_t cbfn, void *cbarg);
639bfa_status_t bfa_faa_disable(struct bfa_s *bfa,
640 bfa_cb_iocfc_t cbfn, void *cbarg);
641bfa_status_t bfa_faa_query(struct bfa_s *bfa, struct bfa_faa_attr_s *attr,
642 bfa_cb_iocfc_t cbfn, void *cbarg);
643
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700644#endif /* __BFA_SVC_H__ */