blob: 4da2b58c8eb7b96accbad5ca1ef96a80979ed6f6 [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 */
Krishna Gudipatic3f1b122012-08-22 19:51:08 -0700100 struct list_head fcxp_req_free_q; /* free FCXPs used for sending req */
101 struct list_head fcxp_rsp_free_q; /* free FCXPs used for sending req */
102 struct list_head fcxp_active_q; /* active FCXPs */
103 struct list_head req_wait_q; /* wait queue for free req_fcxp */
104 struct list_head rsp_wait_q; /* wait queue for free rsp_fcxp */
105 struct list_head fcxp_req_unused_q; /* unused req_fcxps */
106 struct list_head fcxp_rsp_unused_q; /* unused rsp_fcxps */
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700107 u32 req_pld_sz;
108 u32 rsp_pld_sz;
Krishna Gudipati45070252011-06-24 20:24:29 -0700109 struct bfa_mem_dma_s dma_seg[BFA_FCXP_DMA_SEGS];
110 struct bfa_mem_kva_s kva_seg;
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700111};
112
113#define BFA_FCXP_MOD(__bfa) (&(__bfa)->modules.fcxp_mod)
114#define BFA_FCXP_FROM_TAG(__mod, __tag) (&(__mod)->fcxp_list[__tag])
Krishna Gudipati45070252011-06-24 20:24:29 -0700115#define BFA_MEM_FCXP_KVA(__bfa) (&(BFA_FCXP_MOD(__bfa)->kva_seg))
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700116
117typedef void (*fcxp_send_cb_t) (struct bfa_s *ioc, struct bfa_fcxp_s *fcxp,
118 void *cb_arg, bfa_status_t req_status,
119 u32 rsp_len, u32 resid_len,
120 struct fchs_s *rsp_fchs);
121
122typedef u64 (*bfa_fcxp_get_sgaddr_t) (void *bfad_fcxp, int sgeid);
123typedef u32 (*bfa_fcxp_get_sglen_t) (void *bfad_fcxp, int sgeid);
124typedef void (*bfa_cb_fcxp_send_t) (void *bfad_fcxp, struct bfa_fcxp_s *fcxp,
125 void *cbarg, enum bfa_status req_status,
126 u32 rsp_len, u32 resid_len,
127 struct fchs_s *rsp_fchs);
128typedef void (*bfa_fcxp_alloc_cbfn_t) (void *cbarg, struct bfa_fcxp_s *fcxp);
129
130
131
Jing Huangacdc79a2010-10-18 17:15:55 -0700132/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700133 * Information needed for a FCXP request
134 */
135struct bfa_fcxp_req_info_s {
136 struct bfa_rport_s *bfa_rport;
Jing Huangacdc79a2010-10-18 17:15:55 -0700137 /* Pointer to the bfa rport that was
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700138 * returned from bfa_rport_create().
139 * This could be left NULL for WKA or
140 * for FCXP interactions before the
141 * rport nexus is established
142 */
143 struct fchs_s fchs; /* request FC header structure */
Lucas De Marchi25985ed2011-03-30 22:57:33 -0300144 u8 cts; /* continuous sequence */
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700145 u8 class; /* FC class for the request/response */
146 u16 max_frmsz; /* max send frame size */
147 u16 vf_id; /* vsan tag if applicable */
148 u8 lp_tag; /* lport tag */
149 u32 req_tot_len; /* request payload total length */
150};
151
152struct bfa_fcxp_rsp_info_s {
153 struct fchs_s rsp_fchs;
Jing Huangacdc79a2010-10-18 17:15:55 -0700154 /* Response frame's FC header will
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700155 * be sent back in this field */
156 u8 rsp_timeout;
Jing Huangacdc79a2010-10-18 17:15:55 -0700157 /* timeout in seconds, 0-no response */
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700158 u8 rsvd2[3];
159 u32 rsp_maxlen; /* max response length expected */
160};
161
162struct bfa_fcxp_s {
163 struct list_head qe; /* fcxp queue element */
164 bfa_sm_t sm; /* state machine */
165 void *caller; /* driver or fcs */
166 struct bfa_fcxp_mod_s *fcxp_mod;
167 /* back pointer to fcxp mod */
168 u16 fcxp_tag; /* internal tag */
169 struct bfa_fcxp_req_info_s req_info;
170 /* request info */
171 struct bfa_fcxp_rsp_info_s rsp_info;
172 /* response info */
173 u8 use_ireqbuf; /* use internal req buf */
174 u8 use_irspbuf; /* use internal rsp buf */
175 u32 nreq_sgles; /* num request SGLEs */
176 u32 nrsp_sgles; /* num response SGLEs */
177 struct list_head req_sgpg_q; /* SG pages for request buf */
178 struct list_head req_sgpg_wqe; /* wait queue for req SG page */
179 struct list_head rsp_sgpg_q; /* SG pages for response buf */
180 struct list_head rsp_sgpg_wqe; /* wait queue for rsp SG page */
181
182 bfa_fcxp_get_sgaddr_t req_sga_cbfn;
183 /* SG elem addr user function */
184 bfa_fcxp_get_sglen_t req_sglen_cbfn;
185 /* SG elem len user function */
186 bfa_fcxp_get_sgaddr_t rsp_sga_cbfn;
187 /* SG elem addr user function */
188 bfa_fcxp_get_sglen_t rsp_sglen_cbfn;
189 /* SG elem len user function */
190 bfa_cb_fcxp_send_t send_cbfn; /* send completion callback */
191 void *send_cbarg; /* callback arg */
192 struct bfa_sge_s req_sge[BFA_FCXP_MAX_SGES];
193 /* req SG elems */
194 struct bfa_sge_s rsp_sge[BFA_FCXP_MAX_SGES];
195 /* rsp SG elems */
196 u8 rsp_status; /* comp: rsp status */
197 u32 rsp_len; /* comp: actual response len */
198 u32 residue_len; /* comp: residual rsp length */
199 struct fchs_s rsp_fchs; /* comp: response fchs */
200 struct bfa_cb_qe_s hcb_qe; /* comp: callback qelem */
201 struct bfa_reqq_wait_s reqq_wqe;
202 bfa_boolean_t reqq_waiting;
Krishna Gudipatic3f1b122012-08-22 19:51:08 -0700203 bfa_boolean_t req_rsp; /* Used to track req/rsp fcxp */
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700204};
205
206struct bfa_fcxp_wqe_s {
207 struct list_head qe;
208 bfa_fcxp_alloc_cbfn_t alloc_cbfn;
209 void *alloc_cbarg;
210 void *caller;
211 struct bfa_s *bfa;
212 int nreq_sgles;
213 int nrsp_sgles;
214 bfa_fcxp_get_sgaddr_t req_sga_cbfn;
215 bfa_fcxp_get_sglen_t req_sglen_cbfn;
216 bfa_fcxp_get_sgaddr_t rsp_sga_cbfn;
217 bfa_fcxp_get_sglen_t rsp_sglen_cbfn;
218};
219
220#define BFA_FCXP_REQ_PLD(_fcxp) (bfa_fcxp_get_reqbuf(_fcxp))
221#define BFA_FCXP_RSP_FCHS(_fcxp) (&((_fcxp)->rsp_info.fchs))
222#define BFA_FCXP_RSP_PLD(_fcxp) (bfa_fcxp_get_rspbuf(_fcxp))
223
Krishna Gudipati45070252011-06-24 20:24:29 -0700224#define BFA_FCXP_REQ_PLD_PA(_fcxp) \
225 bfa_mem_get_dmabuf_pa((_fcxp)->fcxp_mod, (_fcxp)->fcxp_tag, \
226 (_fcxp)->fcxp_mod->req_pld_sz + (_fcxp)->fcxp_mod->rsp_pld_sz)
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700227
Krishna Gudipati45070252011-06-24 20:24:29 -0700228/* fcxp_buf = req_buf + rsp_buf :- add req_buf_sz to get to rsp_buf */
229#define BFA_FCXP_RSP_PLD_PA(_fcxp) \
230 (bfa_mem_get_dmabuf_pa((_fcxp)->fcxp_mod, (_fcxp)->fcxp_tag, \
231 (_fcxp)->fcxp_mod->req_pld_sz + (_fcxp)->fcxp_mod->rsp_pld_sz) + \
232 (_fcxp)->fcxp_mod->req_pld_sz)
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700233
234void bfa_fcxp_isr(struct bfa_s *bfa, struct bfi_msg_s *msg);
235
236
Jing Huangacdc79a2010-10-18 17:15:55 -0700237/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700238 * RPORT related defines
239 */
Maggie Zhangf7f738122010-12-09 19:08:43 -0800240enum bfa_rport_event {
241 BFA_RPORT_SM_CREATE = 1, /* rport create event */
242 BFA_RPORT_SM_DELETE = 2, /* deleting an existing rport */
243 BFA_RPORT_SM_ONLINE = 3, /* rport is online */
244 BFA_RPORT_SM_OFFLINE = 4, /* rport is offline */
245 BFA_RPORT_SM_FWRSP = 5, /* firmware response */
246 BFA_RPORT_SM_HWFAIL = 6, /* IOC h/w failure */
247 BFA_RPORT_SM_QOS_SCN = 7, /* QoS SCN from firmware */
248 BFA_RPORT_SM_SET_SPEED = 8, /* Set Rport Speed */
249 BFA_RPORT_SM_QRESUME = 9, /* space in requeue queue */
250};
251
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700252#define BFA_RPORT_MIN 4
253
254struct bfa_rport_mod_s {
255 struct bfa_rport_s *rps_list; /* list of rports */
256 struct list_head rp_free_q; /* free bfa_rports */
257 struct list_head rp_active_q; /* free bfa_rports */
Krishna Gudipati3fd45982011-06-24 20:24:08 -0700258 struct list_head rp_unused_q; /* unused bfa rports */
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700259 u16 num_rports; /* number of rports */
Krishna Gudipati45070252011-06-24 20:24:29 -0700260 struct bfa_mem_kva_s kva_seg;
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700261};
262
263#define BFA_RPORT_MOD(__bfa) (&(__bfa)->modules.rport_mod)
Krishna Gudipati45070252011-06-24 20:24:29 -0700264#define BFA_MEM_RPORT_KVA(__bfa) (&(BFA_RPORT_MOD(__bfa)->kva_seg))
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700265
Jing Huangacdc79a2010-10-18 17:15:55 -0700266/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700267 * Convert rport tag to RPORT
268 */
269#define BFA_RPORT_FROM_TAG(__bfa, _tag) \
270 (BFA_RPORT_MOD(__bfa)->rps_list + \
271 ((_tag) & (BFA_RPORT_MOD(__bfa)->num_rports - 1)))
272
273/*
274 * protected functions
275 */
276void bfa_rport_isr(struct bfa_s *bfa, struct bfi_msg_s *msg);
Krishna Gudipati3fd45982011-06-24 20:24:08 -0700277void bfa_rport_res_recfg(struct bfa_s *bfa, u16 num_rport_fw);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700278
Jing Huangacdc79a2010-10-18 17:15:55 -0700279/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700280 * BFA rport information.
281 */
282struct bfa_rport_info_s {
283 u16 max_frmsz; /* max rcv pdu size */
284 u32 pid:24, /* remote port ID */
285 lp_tag:8; /* tag */
286 u32 local_pid:24, /* local port ID */
287 cisc:8; /* CIRO supported */
288 u8 fc_class; /* supported FC classes. enum fc_cos */
289 u8 vf_en; /* virtual fabric enable */
290 u16 vf_id; /* virtual fabric ID */
291 enum bfa_port_speed speed; /* Rport's current speed */
292};
293
Jing Huangacdc79a2010-10-18 17:15:55 -0700294/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700295 * BFA rport data structure
296 */
297struct bfa_rport_s {
298 struct list_head qe; /* queue element */
299 bfa_sm_t sm; /* state machine */
300 struct bfa_s *bfa; /* backpointer to BFA */
301 void *rport_drv; /* fcs/driver rport object */
302 u16 fw_handle; /* firmware rport handle */
303 u16 rport_tag; /* BFA rport tag */
Krishna Gudipati83763d52011-07-20 17:04:03 -0700304 u8 lun_mask; /* LUN mask flag */
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700305 struct bfa_rport_info_s rport_info; /* rport info from fcs/driver */
306 struct bfa_reqq_wait_s reqq_wait; /* to wait for room in reqq */
307 struct bfa_cb_qe_s hcb_qe; /* BFA callback qelem */
308 struct bfa_rport_hal_stats_s stats; /* BFA rport statistics */
309 struct bfa_rport_qos_attr_s qos_attr;
310 union a {
311 bfa_status_t status; /* f/w status */
312 void *fw_msg; /* QoS scn event */
313 } event_arg;
314};
315#define BFA_RPORT_FC_COS(_rport) ((_rport)->rport_info.fc_class)
316
317
Jing Huangacdc79a2010-10-18 17:15:55 -0700318/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700319 * UF - unsolicited receive related defines
320 */
321
322#define BFA_UF_MIN (4)
Krishna Gudipati45070252011-06-24 20:24:29 -0700323#define BFA_UF_MAX (256)
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700324
325struct bfa_uf_s {
326 struct list_head qe; /* queue element */
327 struct bfa_s *bfa; /* bfa instance */
328 u16 uf_tag; /* identifying tag fw msgs */
329 u16 vf_id;
330 u16 src_rport_handle;
331 u16 rsvd;
332 u8 *data_ptr;
333 u16 data_len; /* actual receive length */
334 u16 pb_len; /* posted buffer length */
335 void *buf_kva; /* buffer virtual address */
336 u64 buf_pa; /* buffer physical address */
337 struct bfa_cb_qe_s hcb_qe; /* comp: BFA comp qelem */
338 struct bfa_sge_s sges[BFI_SGE_INLINE_MAX];
339};
340
Jing Huangacdc79a2010-10-18 17:15:55 -0700341/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700342 * Callback prototype for unsolicited frame receive handler.
343 *
344 * @param[in] cbarg callback arg for receive handler
345 * @param[in] uf unsolicited frame descriptor
346 *
347 * @return None
348 */
349typedef void (*bfa_cb_uf_recv_t) (void *cbarg, struct bfa_uf_s *uf);
350
Krishna Gudipati45070252011-06-24 20:24:29 -0700351#define BFA_UF_BUFSZ (2 * 1024 + 256)
352
353struct bfa_uf_buf_s {
354 u8 d[BFA_UF_BUFSZ];
355};
356
357#define BFA_PER_UF_DMA_SZ \
358 (u32)BFA_ROUNDUP(sizeof(struct bfa_uf_buf_s), BFA_DMA_ALIGN_SZ)
359
360/* Max UF dma segs required */
361#define BFA_UF_DMA_SEGS BFI_MEM_DMA_NSEGS(BFA_UF_MAX, BFA_PER_UF_DMA_SZ)
362
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700363struct bfa_uf_mod_s {
364 struct bfa_s *bfa; /* back pointer to BFA */
365 struct bfa_uf_s *uf_list; /* array of UFs */
366 u16 num_ufs; /* num unsolicited rx frames */
367 struct list_head uf_free_q; /* free UFs */
368 struct list_head uf_posted_q; /* UFs posted to IOC */
Krishna Gudipati3fd45982011-06-24 20:24:08 -0700369 struct list_head uf_unused_q; /* unused UF's */
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700370 struct bfi_uf_buf_post_s *uf_buf_posts;
371 /* pre-built UF post msgs */
372 bfa_cb_uf_recv_t ufrecv; /* uf recv handler function */
373 void *cbarg; /* uf receive handler arg */
Krishna Gudipati45070252011-06-24 20:24:29 -0700374 struct bfa_mem_dma_s dma_seg[BFA_UF_DMA_SEGS];
375 struct bfa_mem_kva_s kva_seg;
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700376};
377
378#define BFA_UF_MOD(__bfa) (&(__bfa)->modules.uf_mod)
Krishna Gudipati45070252011-06-24 20:24:29 -0700379#define BFA_MEM_UF_KVA(__bfa) (&(BFA_UF_MOD(__bfa)->kva_seg))
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700380
381#define ufm_pbs_pa(_ufmod, _uftag) \
Krishna Gudipati45070252011-06-24 20:24:29 -0700382 bfa_mem_get_dmabuf_pa(_ufmod, _uftag, BFA_PER_UF_DMA_SZ)
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700383
384void bfa_uf_isr(struct bfa_s *bfa, struct bfi_msg_s *msg);
Krishna Gudipati3fd45982011-06-24 20:24:08 -0700385void bfa_uf_res_recfg(struct bfa_s *bfa, u16 num_uf_fw);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700386
Jing Huangacdc79a2010-10-18 17:15:55 -0700387/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700388 * LPS - bfa lport login/logout service interface
389 */
390struct bfa_lps_s {
391 struct list_head qe; /* queue element */
392 struct bfa_s *bfa; /* parent bfa instance */
393 bfa_sm_t sm; /* finite state machine */
Krishna Gudipati3fd45982011-06-24 20:24:08 -0700394 u8 bfa_tag; /* lport tag */
395 u8 fw_tag; /* lport fw tag */
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700396 u8 reqq; /* lport request queue */
397 u8 alpa; /* ALPA for loop topologies */
398 u32 lp_pid; /* lport port ID */
399 bfa_boolean_t fdisc; /* snd FDISC instead of FLOGI */
400 bfa_boolean_t auth_en; /* enable authentication */
401 bfa_boolean_t auth_req; /* authentication required */
402 bfa_boolean_t npiv_en; /* NPIV is allowed by peer */
403 bfa_boolean_t fport; /* attached peer is F_PORT */
404 bfa_boolean_t brcd_switch; /* attached peer is brcd sw */
405 bfa_status_t status; /* login status */
406 u16 pdusz; /* max receive PDU size */
407 u16 pr_bbcred; /* BB_CREDIT from peer */
Krishna Gudipatibe540a92011-06-13 15:53:04 -0700408 u8 pr_bbscn; /* BB_SCN from peer */
409 u8 bb_scn; /* local BB_SCN */
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700410 u8 lsrjt_rsn; /* LSRJT reason */
411 u8 lsrjt_expl; /* LSRJT explanation */
Krishna Gudipati83763d52011-07-20 17:04:03 -0700412 u8 lun_mask; /* LUN mask flag */
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700413 wwn_t pwwn; /* port wwn of lport */
414 wwn_t nwwn; /* node wwn of lport */
415 wwn_t pr_pwwn; /* port wwn of lport peer */
416 wwn_t pr_nwwn; /* node wwn of lport peer */
417 mac_t lp_mac; /* fpma/spma MAC for lport */
418 mac_t fcf_mac; /* FCF MAC of lport */
419 struct bfa_reqq_wait_s wqe; /* request wait queue element */
420 void *uarg; /* user callback arg */
421 struct bfa_cb_qe_s hcb_qe; /* comp: callback qelem */
422 struct bfi_lps_login_rsp_s *loginrsp;
423 bfa_eproto_status_t ext_status;
424};
425
426struct bfa_lps_mod_s {
427 struct list_head lps_free_q;
428 struct list_head lps_active_q;
Krishna Gudipati3fd45982011-06-24 20:24:08 -0700429 struct list_head lps_login_q;
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700430 struct bfa_lps_s *lps_arr;
431 int num_lps;
Krishna Gudipati45070252011-06-24 20:24:29 -0700432 struct bfa_mem_kva_s kva_seg;
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700433};
434
435#define BFA_LPS_MOD(__bfa) (&(__bfa)->modules.lps_mod)
436#define BFA_LPS_FROM_TAG(__mod, __tag) (&(__mod)->lps_arr[__tag])
Krishna Gudipati45070252011-06-24 20:24:29 -0700437#define BFA_MEM_LPS_KVA(__bfa) (&(BFA_LPS_MOD(__bfa)->kva_seg))
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700438
439/*
440 * external functions
441 */
442void bfa_lps_isr(struct bfa_s *bfa, struct bfi_msg_s *msg);
443
444
Jing Huangacdc79a2010-10-18 17:15:55 -0700445/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700446 * FCPORT related defines
447 */
448
449#define BFA_FCPORT(_bfa) (&((_bfa)->modules.port))
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700450
Jing Huangacdc79a2010-10-18 17:15:55 -0700451/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700452 * Link notification data structure
453 */
454struct bfa_fcport_ln_s {
455 struct bfa_fcport_s *fcport;
456 bfa_sm_t sm;
457 struct bfa_cb_qe_s ln_qe; /* BFA callback queue elem for ln */
458 enum bfa_port_linkstate ln_event; /* ln event for callback */
459};
460
461struct bfa_fcport_trunk_s {
462 struct bfa_trunk_attr_s attr;
463};
464
Jing Huangacdc79a2010-10-18 17:15:55 -0700465/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700466 * BFA FC port data structure
467 */
468struct bfa_fcport_s {
469 struct bfa_s *bfa; /* parent BFA instance */
470 bfa_sm_t sm; /* port state machine */
471 wwn_t nwwn; /* node wwn of physical port */
472 wwn_t pwwn; /* port wwn of physical oprt */
473 enum bfa_port_speed speed_sup;
474 /* supported speeds */
475 enum bfa_port_speed speed; /* current speed */
476 enum bfa_port_topology topology; /* current topology */
477 u8 myalpa; /* my ALPA in LOOP topology */
478 u8 rsvd[3];
479 struct bfa_port_cfg_s cfg; /* current port configuration */
Krishna Gudipatif3a060c2010-12-13 16:16:50 -0800480 bfa_boolean_t use_flash_cfg; /* get port cfg from flash */
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700481 struct bfa_qos_attr_s qos_attr; /* QoS Attributes */
482 struct bfa_qos_vc_attr_s qos_vc_attr; /* VC info from ELP */
483 struct bfa_reqq_wait_s reqq_wait;
484 /* to wait for room in reqq */
485 struct bfa_reqq_wait_s svcreq_wait;
486 /* to wait for room in reqq */
487 struct bfa_reqq_wait_s stats_reqq_wait;
488 /* to wait for room in reqq (stats) */
489 void *event_cbarg;
490 void (*event_cbfn) (void *cbarg,
491 enum bfa_port_linkstate event);
492 union {
493 union bfi_fcport_i2h_msg_u i2hmsg;
494 } event_arg;
495 void *bfad; /* BFA driver handle */
496 struct bfa_fcport_ln_s ln; /* Link Notification */
497 struct bfa_cb_qe_s hcb_qe; /* BFA callback queue elem */
498 struct bfa_timer_s timer; /* timer */
499 u32 msgtag; /* fimrware msg tag for reply */
500 u8 *stats_kva;
501 u64 stats_pa;
502 union bfa_fcport_stats_u *stats;
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700503 bfa_status_t stats_status; /* stats/statsclr status */
Krishna Gudipati37ea0552011-07-20 17:02:11 -0700504 struct list_head stats_pending_q;
505 struct list_head statsclr_pending_q;
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700506 bfa_boolean_t stats_qfull;
507 u32 stats_reset_time; /* stats reset time stamp */
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700508 bfa_boolean_t diag_busy; /* diag busy status */
509 bfa_boolean_t beacon; /* port beacon status */
510 bfa_boolean_t link_e2e_beacon; /* link beacon status */
Krishna Gudipatibe540a92011-06-13 15:53:04 -0700511 bfa_boolean_t bbsc_op_state; /* Cred recov Oper State */
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700512 struct bfa_fcport_trunk_s trunk;
513 u16 fcoe_vlan;
Krishna Gudipati45070252011-06-24 20:24:29 -0700514 struct bfa_mem_dma_s fcport_dma;
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700515};
516
517#define BFA_FCPORT_MOD(__bfa) (&(__bfa)->modules.fcport)
Krishna Gudipati45070252011-06-24 20:24:29 -0700518#define BFA_MEM_FCPORT_DMA(__bfa) (&(BFA_FCPORT_MOD(__bfa)->fcport_dma))
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700519
520/*
521 * protected functions
522 */
523void bfa_fcport_init(struct bfa_s *bfa);
524void bfa_fcport_isr(struct bfa_s *bfa, struct bfi_msg_s *msg);
525
526/*
527 * bfa fcport API functions
528 */
529bfa_status_t bfa_fcport_enable(struct bfa_s *bfa);
530bfa_status_t bfa_fcport_disable(struct bfa_s *bfa);
531bfa_status_t bfa_fcport_cfg_speed(struct bfa_s *bfa,
532 enum bfa_port_speed speed);
533enum bfa_port_speed bfa_fcport_get_speed(struct bfa_s *bfa);
534bfa_status_t bfa_fcport_cfg_topology(struct bfa_s *bfa,
535 enum bfa_port_topology topo);
536enum bfa_port_topology bfa_fcport_get_topology(struct bfa_s *bfa);
537bfa_status_t bfa_fcport_cfg_hardalpa(struct bfa_s *bfa, u8 alpa);
538bfa_boolean_t bfa_fcport_get_hardalpa(struct bfa_s *bfa, u8 *alpa);
539u8 bfa_fcport_get_myalpa(struct bfa_s *bfa);
540bfa_status_t bfa_fcport_clr_hardalpa(struct bfa_s *bfa);
541bfa_status_t bfa_fcport_cfg_maxfrsize(struct bfa_s *bfa, u16 maxsize);
542u16 bfa_fcport_get_maxfrsize(struct bfa_s *bfa);
543u8 bfa_fcport_get_rx_bbcredit(struct bfa_s *bfa);
544void bfa_fcport_get_attr(struct bfa_s *bfa, struct bfa_port_attr_s *attr);
545wwn_t bfa_fcport_get_wwn(struct bfa_s *bfa, bfa_boolean_t node);
546void bfa_fcport_event_register(struct bfa_s *bfa,
547 void (*event_cbfn) (void *cbarg,
548 enum bfa_port_linkstate event), void *event_cbarg);
549bfa_boolean_t bfa_fcport_is_disabled(struct bfa_s *bfa);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700550enum bfa_port_speed bfa_fcport_get_ratelim_speed(struct bfa_s *bfa);
551
Krishna Gudipatibe540a92011-06-13 15:53:04 -0700552void bfa_fcport_set_tx_bbcredit(struct bfa_s *bfa, u16 tx_bbcredit, u8 bb_scn);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700553bfa_boolean_t bfa_fcport_is_ratelim(struct bfa_s *bfa);
Krishna Gudipati3d7fc662011-06-24 20:28:17 -0700554void bfa_fcport_beacon(void *dev, bfa_boolean_t beacon,
555 bfa_boolean_t link_e2e_beacon);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700556bfa_boolean_t bfa_fcport_is_linkup(struct bfa_s *bfa);
557bfa_status_t bfa_fcport_get_stats(struct bfa_s *bfa,
Krishna Gudipati37ea0552011-07-20 17:02:11 -0700558 struct bfa_cb_pending_q_s *cb);
559bfa_status_t bfa_fcport_clear_stats(struct bfa_s *bfa,
560 struct bfa_cb_pending_q_s *cb);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700561bfa_boolean_t bfa_fcport_is_qos_enabled(struct bfa_s *bfa);
Krishna Gudipatibe540a92011-06-13 15:53:04 -0700562bfa_boolean_t bfa_fcport_is_trunk_enabled(struct bfa_s *bfa);
Krishna Gudipati43ffdf42011-06-13 15:46:21 -0700563bfa_status_t bfa_fcport_is_pbcdisabled(struct bfa_s *bfa);
Krishna Gudipatia7141342011-06-24 20:23:19 -0700564void bfa_fcport_cfg_faa(struct bfa_s *bfa, u8 state);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700565
566/*
567 * bfa rport API functions
568 */
569struct bfa_rport_s *bfa_rport_create(struct bfa_s *bfa, void *rport_drv);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700570void bfa_rport_online(struct bfa_rport_s *rport,
571 struct bfa_rport_info_s *rport_info);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700572void bfa_rport_speed(struct bfa_rport_s *rport, enum bfa_port_speed speed);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700573void bfa_cb_rport_online(void *rport);
574void bfa_cb_rport_offline(void *rport);
575void bfa_cb_rport_qos_scn_flowid(void *rport,
576 struct bfa_rport_qos_attr_s old_qos_attr,
577 struct bfa_rport_qos_attr_s new_qos_attr);
578void bfa_cb_rport_qos_scn_prio(void *rport,
579 struct bfa_rport_qos_attr_s old_qos_attr,
580 struct bfa_rport_qos_attr_s new_qos_attr);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700581
582/*
Krishna Gudipati83763d52011-07-20 17:04:03 -0700583 * Rport LUN masking related
584 */
585#define BFA_RPORT_TAG_INVALID 0xffff
586#define BFA_LP_TAG_INVALID 0xff
587void bfa_rport_set_lunmask(struct bfa_s *bfa, struct bfa_rport_s *rp);
588void bfa_rport_unset_lunmask(struct bfa_s *bfa, struct bfa_rport_s *rp);
Krishna Gudipati83763d52011-07-20 17:04:03 -0700589
590/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700591 * bfa fcxp API functions
592 */
Krishna Gudipatic3f1b122012-08-22 19:51:08 -0700593struct bfa_fcxp_s *bfa_fcxp_req_rsp_alloc(void *bfad_fcxp, struct bfa_s *bfa,
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700594 int nreq_sgles, int nrsp_sgles,
595 bfa_fcxp_get_sgaddr_t get_req_sga,
596 bfa_fcxp_get_sglen_t get_req_sglen,
597 bfa_fcxp_get_sgaddr_t get_rsp_sga,
Krishna Gudipatic3f1b122012-08-22 19:51:08 -0700598 bfa_fcxp_get_sglen_t get_rsp_sglen,
599 bfa_boolean_t req);
600void bfa_fcxp_req_rsp_alloc_wait(struct bfa_s *bfa, struct bfa_fcxp_wqe_s *wqe,
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700601 bfa_fcxp_alloc_cbfn_t alloc_cbfn,
602 void *cbarg, void *bfad_fcxp,
603 int nreq_sgles, int nrsp_sgles,
604 bfa_fcxp_get_sgaddr_t get_req_sga,
605 bfa_fcxp_get_sglen_t get_req_sglen,
606 bfa_fcxp_get_sgaddr_t get_rsp_sga,
Krishna Gudipatic3f1b122012-08-22 19:51:08 -0700607 bfa_fcxp_get_sglen_t get_rsp_sglen,
608 bfa_boolean_t req);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700609void bfa_fcxp_walloc_cancel(struct bfa_s *bfa,
610 struct bfa_fcxp_wqe_s *wqe);
611void bfa_fcxp_discard(struct bfa_fcxp_s *fcxp);
612
613void *bfa_fcxp_get_reqbuf(struct bfa_fcxp_s *fcxp);
614void *bfa_fcxp_get_rspbuf(struct bfa_fcxp_s *fcxp);
615
616void bfa_fcxp_free(struct bfa_fcxp_s *fcxp);
617
618void bfa_fcxp_send(struct bfa_fcxp_s *fcxp, struct bfa_rport_s *rport,
619 u16 vf_id, u8 lp_tag,
620 bfa_boolean_t cts, enum fc_cos cos,
621 u32 reqlen, struct fchs_s *fchs,
622 bfa_cb_fcxp_send_t cbfn,
623 void *cbarg,
624 u32 rsp_maxlen, u8 rsp_timeout);
625bfa_status_t bfa_fcxp_abort(struct bfa_fcxp_s *fcxp);
626u32 bfa_fcxp_get_reqbufsz(struct bfa_fcxp_s *fcxp);
627u32 bfa_fcxp_get_maxrsp(struct bfa_s *bfa);
Krishna Gudipati3fd45982011-06-24 20:24:08 -0700628void bfa_fcxp_res_recfg(struct bfa_s *bfa, u16 num_fcxp_fw);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700629
630static inline void *
631bfa_uf_get_frmbuf(struct bfa_uf_s *uf)
632{
633 return uf->data_ptr;
634}
635
636static inline u16
637bfa_uf_get_frmlen(struct bfa_uf_s *uf)
638{
639 return uf->data_len;
640}
641
642/*
643 * bfa uf API functions
644 */
645void bfa_uf_recv_register(struct bfa_s *bfa, bfa_cb_uf_recv_t ufrecv,
646 void *cbarg);
647void bfa_uf_free(struct bfa_uf_s *uf);
648
Jing Huangacdc79a2010-10-18 17:15:55 -0700649/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700650 * bfa lport service api
651 */
652
653u32 bfa_lps_get_max_vport(struct bfa_s *bfa);
654struct bfa_lps_s *bfa_lps_alloc(struct bfa_s *bfa);
655void bfa_lps_delete(struct bfa_lps_s *lps);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700656void bfa_lps_flogi(struct bfa_lps_s *lps, void *uarg, u8 alpa,
657 u16 pdusz, wwn_t pwwn, wwn_t nwwn,
Krishna Gudipatibe540a92011-06-13 15:53:04 -0700658 bfa_boolean_t auth_en, u8 bb_scn);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700659void bfa_lps_fdisc(struct bfa_lps_s *lps, void *uarg, u16 pdusz,
660 wwn_t pwwn, wwn_t nwwn);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700661void bfa_lps_fdisclogo(struct bfa_lps_s *lps);
Krishna Gudipatib7044952010-12-13 16:17:42 -0800662void bfa_lps_set_n2n_pid(struct bfa_lps_s *lps, u32 n2n_pid);
Krishna Gudipati3fd45982011-06-24 20:24:08 -0700663u8 bfa_lps_get_fwtag(struct bfa_s *bfa, u8 lp_tag);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700664u32 bfa_lps_get_base_pid(struct bfa_s *bfa);
665u8 bfa_lps_get_tag_from_pid(struct bfa_s *bfa, u32 pid);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700666void bfa_cb_lps_flogi_comp(void *bfad, void *uarg, bfa_status_t status);
667void bfa_cb_lps_fdisc_comp(void *bfad, void *uarg, bfa_status_t status);
668void bfa_cb_lps_fdisclogo_comp(void *bfad, void *uarg);
669void bfa_cb_lps_cvl_event(void *bfad, void *uarg);
670
Krishna Gudipatia7141342011-06-24 20:23:19 -0700671/* FAA specific APIs */
Krishna Gudipatia7141342011-06-24 20:23:19 -0700672bfa_status_t bfa_faa_query(struct bfa_s *bfa, struct bfa_faa_attr_s *attr,
673 bfa_cb_iocfc_t cbfn, void *cbarg);
674
Krishna Gudipati3d7fc662011-06-24 20:28:17 -0700675/*
676 * FC DIAG data structure
677 */
678struct bfa_fcdiag_qtest_s {
679 struct bfa_diag_qtest_result_s *result;
680 bfa_cb_diag_t cbfn;
681 void *cbarg;
682 struct bfa_timer_s timer;
683 u32 status;
684 u32 count;
685 u8 lock;
686 u8 queue;
687 u8 all;
688 u8 timer_active;
689};
690
691struct bfa_fcdiag_lb_s {
692 bfa_cb_diag_t cbfn;
693 void *cbarg;
694 void *result;
695 bfa_boolean_t lock;
696 u32 status;
697};
698
699struct bfa_fcdiag_s {
700 struct bfa_s *bfa; /* Back pointer to BFA */
701 struct bfa_trc_mod_s *trcmod;
702 struct bfa_fcdiag_lb_s lb;
703 struct bfa_fcdiag_qtest_s qtest;
704};
705
706#define BFA_FCDIAG_MOD(__bfa) (&(__bfa)->modules.fcdiag)
707
708void bfa_fcdiag_intr(struct bfa_s *bfa, struct bfi_msg_s *msg);
709
710bfa_status_t bfa_fcdiag_loopback(struct bfa_s *bfa,
711 enum bfa_port_opmode opmode,
712 enum bfa_port_speed speed, u32 lpcnt, u32 pat,
713 struct bfa_diag_loopback_result_s *result,
714 bfa_cb_diag_t cbfn, void *cbarg);
715bfa_status_t bfa_fcdiag_queuetest(struct bfa_s *bfa, u32 ignore,
716 u32 queue, struct bfa_diag_qtest_result_s *result,
717 bfa_cb_diag_t cbfn, void *cbarg);
718bfa_status_t bfa_fcdiag_lb_is_running(struct bfa_s *bfa);
719
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700720#endif /* __BFA_SVC_H__ */