2 * Copyright (c) 2005-2009 Brocade Communications Systems, Inc.
6 * Linux driver for Brocade Fibre Channel Host Bus Adapter.
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
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.
21 * forward declarations
25 #include <defs/bfa_defs_status.h>
26 #include <defs/bfa_defs_pport.h>
27 #include <defs/bfa_defs_rport.h>
28 #include <defs/bfa_defs_qos.h>
29 #include <cs/bfa_sm.h>
33 * BFA rport information.
35 struct bfa_rport_info_s
{
36 u16 max_frmsz
; /* max rcv pdu size */
37 u32 pid
: 24, /* remote port ID */
39 u32 local_pid
: 24, /* local port ID */
40 cisc
: 8; /* CIRO supported */
41 u8 fc_class
; /* supported FC classes. enum fc_cos */
42 u8 vf_en
; /* virtual fabric enable */
43 u16 vf_id
; /* virtual fabric ID */
44 enum bfa_pport_speed speed
; /* Rport's current speed */
48 * BFA rport data structure
51 struct list_head qe
; /* queue element */
52 bfa_sm_t sm
; /* state machine */
53 struct bfa_s
*bfa
; /* backpointer to BFA */
54 void *rport_drv
; /* fcs/driver rport object */
55 u16 fw_handle
; /* firmware rport handle */
56 u16 rport_tag
; /* BFA rport tag */
57 struct bfa_rport_info_s rport_info
; /* rport info from *fcs/driver */
58 struct bfa_reqq_wait_s reqq_wait
; /* to wait for room in reqq */
59 struct bfa_cb_qe_s hcb_qe
; /* BFA callback qelem */
60 struct bfa_rport_hal_stats_s stats
; /* BFA rport statistics */
61 struct bfa_rport_qos_attr_s qos_attr
;
63 bfa_status_t status
; /* f/w status */
64 void *fw_msg
; /* QoS scn event */
67 #define BFA_RPORT_FC_COS(_rport) ((_rport)->rport_info.fc_class)
70 * Send completion callback.
72 typedef void (*bfa_cb_fcxp_send_t
) (void *bfad_fcxp
, struct bfa_fcxp_s
*fcxp
,
73 void *cbarg
, enum bfa_status req_status
,
74 u32 rsp_len
, u32 resid_len
,
75 struct fchs_s
*rsp_fchs
);
78 * BFA fcxp allocation (asynchronous)
80 typedef void (*bfa_fcxp_alloc_cbfn_t
) (void *cbarg
, struct bfa_fcxp_s
*fcxp
);
82 struct bfa_fcxp_wqe_s
{
84 bfa_fcxp_alloc_cbfn_t alloc_cbfn
;
88 typedef u64 (*bfa_fcxp_get_sgaddr_t
) (void *bfad_fcxp
, int sgeid
);
89 typedef u32 (*bfa_fcxp_get_sglen_t
) (void *bfad_fcxp
, int sgeid
);
91 #define BFA_UF_BUFSZ (2 * 1024 + 256)
102 struct list_head qe
; /* queue element */
103 struct bfa_s
*bfa
; /* bfa instance */
104 u16 uf_tag
; /* identifying tag f/w messages */
106 u16 src_rport_handle
;
109 u16 data_len
; /* actual receive length */
110 u16 pb_len
; /* posted buffer length */
111 void *buf_kva
; /* buffer virtual address */
112 u64 buf_pa
; /* buffer physical address */
113 struct bfa_cb_qe_s hcb_qe
; /* comp: BFA comp qelem */
114 struct bfa_sge_s sges
[BFI_SGE_INLINE_MAX
];
117 typedef void (*bfa_cb_pport_t
) (void *cbarg
, enum bfa_status status
);
120 * bfa lport login/logout service interface
123 struct list_head qe
; /* queue element */
124 struct bfa_s
*bfa
; /* parent bfa instance */
125 bfa_sm_t sm
; /* finite state machine */
126 u8 lp_tag
; /* lport tag */
127 u8 reqq
; /* lport request queue */
128 u8 alpa
; /* ALPA for loop topologies */
129 u32 lp_pid
; /* lport port ID */
130 bfa_boolean_t fdisc
; /* send FDISC instead of FLOGI*/
131 bfa_boolean_t auth_en
; /* enable authentication */
132 bfa_boolean_t auth_req
; /* authentication required */
133 bfa_boolean_t npiv_en
; /* NPIV is allowed by peer */
134 bfa_boolean_t fport
; /* attached peer is F_PORT */
135 bfa_boolean_t brcd_switch
;/* attached peer is brcd switch */
136 bfa_status_t status
; /* login status */
137 u16 pdusz
; /* max receive PDU size */
138 u16 pr_bbcred
; /* BB_CREDIT from peer */
139 u8 lsrjt_rsn
; /* LSRJT reason */
140 u8 lsrjt_expl
; /* LSRJT explanation */
141 wwn_t pwwn
; /* port wwn of lport */
142 wwn_t nwwn
; /* node wwn of lport */
143 wwn_t pr_pwwn
; /* port wwn of lport peer */
144 wwn_t pr_nwwn
; /* node wwn of lport peer */
145 mac_t lp_mac
; /* fpma/spma MAC for lport */
146 mac_t fcf_mac
; /* FCF MAC of lport */
147 struct bfa_reqq_wait_s wqe
; /* request wait queue element */
148 void *uarg
; /* user callback arg */
149 struct bfa_cb_qe_s hcb_qe
; /* comp: callback qelem */
150 struct bfi_lps_login_rsp_s
*loginrsp
;
151 bfa_eproto_status_t ext_status
;
155 * bfa pport API functions
157 bfa_status_t
bfa_pport_enable(struct bfa_s
*bfa
);
158 bfa_status_t
bfa_pport_disable(struct bfa_s
*bfa
);
159 bfa_status_t
bfa_pport_cfg_speed(struct bfa_s
*bfa
,
160 enum bfa_pport_speed speed
);
161 enum bfa_pport_speed
bfa_pport_get_speed(struct bfa_s
*bfa
);
162 bfa_status_t
bfa_pport_cfg_topology(struct bfa_s
*bfa
,
163 enum bfa_pport_topology topo
);
164 enum bfa_pport_topology
bfa_pport_get_topology(struct bfa_s
*bfa
);
165 bfa_status_t
bfa_pport_cfg_hardalpa(struct bfa_s
*bfa
, u8 alpa
);
166 bfa_boolean_t
bfa_pport_get_hardalpa(struct bfa_s
*bfa
, u8
*alpa
);
167 u8
bfa_pport_get_myalpa(struct bfa_s
*bfa
);
168 bfa_status_t
bfa_pport_clr_hardalpa(struct bfa_s
*bfa
);
169 bfa_status_t
bfa_pport_cfg_maxfrsize(struct bfa_s
*bfa
, u16 maxsize
);
170 u16
bfa_pport_get_maxfrsize(struct bfa_s
*bfa
);
171 u32
bfa_pport_mypid(struct bfa_s
*bfa
);
172 u8
bfa_pport_get_rx_bbcredit(struct bfa_s
*bfa
);
173 bfa_status_t
bfa_pport_trunk_enable(struct bfa_s
*bfa
, u8 bitmap
);
174 bfa_status_t
bfa_pport_trunk_disable(struct bfa_s
*bfa
);
175 bfa_boolean_t
bfa_pport_trunk_query(struct bfa_s
*bfa
, u32
*bitmap
);
176 void bfa_pport_get_attr(struct bfa_s
*bfa
, struct bfa_pport_attr_s
*attr
);
177 wwn_t
bfa_pport_get_wwn(struct bfa_s
*bfa
, bfa_boolean_t node
);
178 bfa_status_t
bfa_pport_get_stats(struct bfa_s
*bfa
,
179 union bfa_pport_stats_u
*stats
,
180 bfa_cb_pport_t cbfn
, void *cbarg
);
181 bfa_status_t
bfa_pport_clear_stats(struct bfa_s
*bfa
, bfa_cb_pport_t cbfn
,
183 void bfa_pport_event_register(struct bfa_s
*bfa
,
184 void (*event_cbfn
) (void *cbarg
,
185 bfa_pport_event_t event
), void *event_cbarg
);
186 bfa_boolean_t
bfa_pport_is_disabled(struct bfa_s
*bfa
);
187 void bfa_pport_cfg_qos(struct bfa_s
*bfa
, bfa_boolean_t on_off
);
188 void bfa_pport_cfg_ratelim(struct bfa_s
*bfa
, bfa_boolean_t on_off
);
189 bfa_status_t
bfa_pport_cfg_ratelim_speed(struct bfa_s
*bfa
,
190 enum bfa_pport_speed speed
);
191 enum bfa_pport_speed
bfa_pport_get_ratelim_speed(struct bfa_s
*bfa
);
193 void bfa_pport_set_tx_bbcredit(struct bfa_s
*bfa
, u16 tx_bbcredit
);
194 void bfa_pport_busy(struct bfa_s
*bfa
, bfa_boolean_t status
);
195 void bfa_pport_beacon(struct bfa_s
*bfa
, bfa_boolean_t beacon
,
196 bfa_boolean_t link_e2e_beacon
);
197 void bfa_cb_pport_event(void *cbarg
, bfa_pport_event_t event
);
198 void bfa_pport_qos_get_attr(struct bfa_s
*bfa
, struct bfa_qos_attr_s
*qos_attr
);
199 void bfa_pport_qos_get_vc_attr(struct bfa_s
*bfa
,
200 struct bfa_qos_vc_attr_s
*qos_vc_attr
);
201 bfa_status_t
bfa_pport_get_qos_stats(struct bfa_s
*bfa
,
202 union bfa_pport_stats_u
*stats
,
203 bfa_cb_pport_t cbfn
, void *cbarg
);
204 bfa_status_t
bfa_pport_clear_qos_stats(struct bfa_s
*bfa
, bfa_cb_pport_t cbfn
,
206 bfa_boolean_t
bfa_pport_is_ratelim(struct bfa_s
*bfa
);
207 bfa_boolean_t
bfa_pport_is_linkup(struct bfa_s
*bfa
);
210 * bfa rport API functions
212 struct bfa_rport_s
*bfa_rport_create(struct bfa_s
*bfa
, void *rport_drv
);
213 void bfa_rport_delete(struct bfa_rport_s
*rport
);
214 void bfa_rport_online(struct bfa_rport_s
*rport
,
215 struct bfa_rport_info_s
*rport_info
);
216 void bfa_rport_offline(struct bfa_rport_s
*rport
);
217 void bfa_rport_speed(struct bfa_rport_s
*rport
, enum bfa_pport_speed speed
);
218 void bfa_rport_get_stats(struct bfa_rport_s
*rport
,
219 struct bfa_rport_hal_stats_s
*stats
);
220 void bfa_rport_clear_stats(struct bfa_rport_s
*rport
);
221 void bfa_cb_rport_online(void *rport
);
222 void bfa_cb_rport_offline(void *rport
);
223 void bfa_cb_rport_qos_scn_flowid(void *rport
,
224 struct bfa_rport_qos_attr_s old_qos_attr
,
225 struct bfa_rport_qos_attr_s new_qos_attr
);
226 void bfa_cb_rport_qos_scn_prio(void *rport
,
227 struct bfa_rport_qos_attr_s old_qos_attr
,
228 struct bfa_rport_qos_attr_s new_qos_attr
);
229 void bfa_rport_get_qos_attr(struct bfa_rport_s
*rport
,
230 struct bfa_rport_qos_attr_s
*qos_attr
);
233 * bfa fcxp API functions
235 struct bfa_fcxp_s
*bfa_fcxp_alloc(void *bfad_fcxp
, struct bfa_s
*bfa
,
236 int nreq_sgles
, int nrsp_sgles
,
237 bfa_fcxp_get_sgaddr_t get_req_sga
,
238 bfa_fcxp_get_sglen_t get_req_sglen
,
239 bfa_fcxp_get_sgaddr_t get_rsp_sga
,
240 bfa_fcxp_get_sglen_t get_rsp_sglen
);
241 void bfa_fcxp_alloc_wait(struct bfa_s
*bfa
, struct bfa_fcxp_wqe_s
*wqe
,
242 bfa_fcxp_alloc_cbfn_t alloc_cbfn
, void *cbarg
);
243 void bfa_fcxp_walloc_cancel(struct bfa_s
*bfa
,
244 struct bfa_fcxp_wqe_s
*wqe
);
245 void bfa_fcxp_discard(struct bfa_fcxp_s
*fcxp
);
247 void *bfa_fcxp_get_reqbuf(struct bfa_fcxp_s
*fcxp
);
248 void *bfa_fcxp_get_rspbuf(struct bfa_fcxp_s
*fcxp
);
250 void bfa_fcxp_free(struct bfa_fcxp_s
*fcxp
);
252 void bfa_fcxp_send(struct bfa_fcxp_s
*fcxp
,
253 struct bfa_rport_s
*rport
, u16 vf_id
, u8 lp_tag
,
254 bfa_boolean_t cts
, enum fc_cos cos
,
255 u32 reqlen
, struct fchs_s
*fchs
,
256 bfa_cb_fcxp_send_t cbfn
,
258 u32 rsp_maxlen
, u8 rsp_timeout
);
259 bfa_status_t
bfa_fcxp_abort(struct bfa_fcxp_s
*fcxp
);
260 u32
bfa_fcxp_get_reqbufsz(struct bfa_fcxp_s
*fcxp
);
261 u32
bfa_fcxp_get_maxrsp(struct bfa_s
*bfa
);
264 bfa_uf_get_frmbuf(struct bfa_uf_s
*uf
)
270 bfa_uf_get_frmlen(struct bfa_uf_s
*uf
)
276 * Callback prototype for unsolicited frame receive handler.
278 * @param[in] cbarg callback arg for receive handler
279 * @param[in] uf unsolicited frame descriptor
283 typedef void (*bfa_cb_uf_recv_t
) (void *cbarg
, struct bfa_uf_s
*uf
);
286 * bfa uf API functions
288 void bfa_uf_recv_register(struct bfa_s
*bfa
, bfa_cb_uf_recv_t ufrecv
,
290 void bfa_uf_free(struct bfa_uf_s
*uf
);
293 * bfa lport service api
296 struct bfa_lps_s
*bfa_lps_alloc(struct bfa_s
*bfa
);
297 void bfa_lps_delete(struct bfa_lps_s
*lps
);
298 void bfa_lps_discard(struct bfa_lps_s
*lps
);
299 void bfa_lps_flogi(struct bfa_lps_s
*lps
, void *uarg
, u8 alpa
, u16 pdusz
,
300 wwn_t pwwn
, wwn_t nwwn
, bfa_boolean_t auth_en
);
301 void bfa_lps_fdisc(struct bfa_lps_s
*lps
, void *uarg
, u16 pdusz
, wwn_t pwwn
,
303 void bfa_lps_flogo(struct bfa_lps_s
*lps
);
304 void bfa_lps_fdisclogo(struct bfa_lps_s
*lps
);
305 u8
bfa_lps_get_tag(struct bfa_lps_s
*lps
);
306 bfa_boolean_t
bfa_lps_is_npiv_en(struct bfa_lps_s
*lps
);
307 bfa_boolean_t
bfa_lps_is_fport(struct bfa_lps_s
*lps
);
308 bfa_boolean_t
bfa_lps_is_brcd_fabric(struct bfa_lps_s
*lps
);
309 bfa_boolean_t
bfa_lps_is_authreq(struct bfa_lps_s
*lps
);
310 bfa_eproto_status_t
bfa_lps_get_extstatus(struct bfa_lps_s
*lps
);
311 u32
bfa_lps_get_pid(struct bfa_lps_s
*lps
);
312 u8
bfa_lps_get_tag_from_pid(struct bfa_s
*bfa
, u32 pid
);
313 u16
bfa_lps_get_peer_bbcredit(struct bfa_lps_s
*lps
);
314 wwn_t
bfa_lps_get_peer_pwwn(struct bfa_lps_s
*lps
);
315 wwn_t
bfa_lps_get_peer_nwwn(struct bfa_lps_s
*lps
);
316 u8
bfa_lps_get_lsrjt_rsn(struct bfa_lps_s
*lps
);
317 u8
bfa_lps_get_lsrjt_expl(struct bfa_lps_s
*lps
);
318 void bfa_cb_lps_flogi_comp(void *bfad
, void *uarg
, bfa_status_t status
);
319 void bfa_cb_lps_flogo_comp(void *bfad
, void *uarg
);
320 void bfa_cb_lps_fdisc_comp(void *bfad
, void *uarg
, bfa_status_t status
);
321 void bfa_cb_lps_fdisclogo_comp(void *bfad
, void *uarg
);
323 #endif /* __BFA_SVC_H__ */