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 <defs/bfa_defs_fcport.h>
30 #include <cs/bfa_sm.h>
34 * BFA rport information.
36 struct bfa_rport_info_s {
37 u16 max_frmsz; /* max rcv pdu size */
38 u32 pid:24, /* remote port ID */
40 u32 local_pid:24, /* local port ID */
41 cisc:8; /* CIRO supported */
42 u8 fc_class; /* supported FC classes. enum fc_cos */
43 u8 vf_en; /* virtual fabric enable */
44 u16 vf_id; /* virtual fabric ID */
45 enum bfa_pport_speed speed; /* Rport's current speed */
49 * BFA rport data structure
52 struct list_head qe; /* queue element */
53 bfa_sm_t sm; /* state machine */
54 struct bfa_s *bfa; /* backpointer to BFA */
55 void *rport_drv; /* fcs/driver rport object */
56 u16 fw_handle; /* firmware rport handle */
57 u16 rport_tag; /* BFA rport tag */
58 struct bfa_rport_info_s rport_info; /* rport info from fcs/driver */
59 struct bfa_reqq_wait_s reqq_wait; /* to wait for room in reqq */
60 struct bfa_cb_qe_s hcb_qe; /* BFA callback qelem */
61 struct bfa_rport_hal_stats_s stats; /* BFA rport statistics */
62 struct bfa_rport_qos_attr_s qos_attr;
64 bfa_status_t status; /* f/w status */
65 void *fw_msg; /* QoS scn event */
68 #define BFA_RPORT_FC_COS(_rport) ((_rport)->rport_info.fc_class)
71 * Send completion callback.
73 typedef void (*bfa_cb_fcxp_send_t) (void *bfad_fcxp, struct bfa_fcxp_s *fcxp,
74 void *cbarg, enum bfa_status req_status,
75 u32 rsp_len, u32 resid_len,
76 struct fchs_s *rsp_fchs);
79 * BFA fcxp allocation (asynchronous)
81 typedef void (*bfa_fcxp_alloc_cbfn_t) (void *cbarg, struct bfa_fcxp_s *fcxp);
83 struct bfa_fcxp_wqe_s {
85 bfa_fcxp_alloc_cbfn_t alloc_cbfn;
89 typedef u64 (*bfa_fcxp_get_sgaddr_t) (void *bfad_fcxp, int sgeid);
90 typedef u32 (*bfa_fcxp_get_sglen_t) (void *bfad_fcxp, int sgeid);
92 #define BFA_UF_BUFSZ (2 * 1024 + 256)
103 struct list_head qe; /* queue element */
104 struct bfa_s *bfa; /* bfa instance */
105 u16 uf_tag; /* identifying tag fw msgs */
107 u16 src_rport_handle;
110 u16 data_len; /* actual receive length */
111 u16 pb_len; /* posted buffer length */
112 void *buf_kva; /* buffer virtual address */
113 u64 buf_pa; /* buffer physical address */
114 struct bfa_cb_qe_s hcb_qe; /* comp: BFA comp qelem */
115 struct bfa_sge_s sges[BFI_SGE_INLINE_MAX];
118 typedef void (*bfa_cb_pport_t) (void *cbarg, enum bfa_status status);
121 * bfa lport login/logout service interface
124 struct list_head qe; /* queue element */
125 struct bfa_s *bfa; /* parent bfa instance */
126 bfa_sm_t sm; /* finite state machine */
127 u8 lp_tag; /* lport tag */
128 u8 reqq; /* lport request queue */
129 u8 alpa; /* ALPA for loop topologies */
130 u32 lp_pid; /* lport port ID */
131 bfa_boolean_t fdisc; /* send FDISC instead of FLOGI */
132 bfa_boolean_t auth_en; /* enable authentication */
133 bfa_boolean_t auth_req; /* authentication required */
134 bfa_boolean_t npiv_en; /* NPIV is allowed by peer */
135 bfa_boolean_t fport; /* attached peer is F_PORT */
136 bfa_boolean_t brcd_switch;/* attached peer is brcd switch */
137 bfa_status_t status; /* login status */
138 u16 pdusz; /* max receive PDU size */
139 u16 pr_bbcred; /* BB_CREDIT from peer */
140 u8 lsrjt_rsn; /* LSRJT reason */
141 u8 lsrjt_expl; /* LSRJT explanation */
142 wwn_t pwwn; /* port wwn of lport */
143 wwn_t nwwn; /* node wwn of lport */
144 wwn_t pr_pwwn; /* port wwn of lport peer */
145 wwn_t pr_nwwn; /* node wwn of lport peer */
146 mac_t lp_mac; /* fpma/spma MAC for lport */
147 mac_t fcf_mac; /* FCF MAC of lport */
148 struct bfa_reqq_wait_s wqe; /* request wait queue element */
149 void *uarg; /* user callback arg */
150 struct bfa_cb_qe_s hcb_qe; /* comp: callback qelem */
151 struct bfi_lps_login_rsp_s *loginrsp;
152 bfa_eproto_status_t ext_status;
155 #define BFA_FCPORT(_bfa) (&((_bfa)->modules.port))
158 * bfa pport API functions
160 bfa_status_t bfa_fcport_enable(struct bfa_s *bfa);
161 bfa_status_t bfa_fcport_disable(struct bfa_s *bfa);
162 bfa_status_t bfa_fcport_cfg_speed(struct bfa_s *bfa,
163 enum bfa_pport_speed speed);
164 enum bfa_pport_speed bfa_fcport_get_speed(struct bfa_s *bfa);
165 bfa_status_t bfa_fcport_cfg_topology(struct bfa_s *bfa,
166 enum bfa_pport_topology topo);
167 enum bfa_pport_topology bfa_fcport_get_topology(struct bfa_s *bfa);
168 bfa_status_t bfa_fcport_cfg_hardalpa(struct bfa_s *bfa, u8 alpa);
169 bfa_boolean_t bfa_fcport_get_hardalpa(struct bfa_s *bfa, u8 *alpa);
170 u8 bfa_fcport_get_myalpa(struct bfa_s *bfa);
171 bfa_status_t bfa_fcport_clr_hardalpa(struct bfa_s *bfa);
172 bfa_status_t bfa_fcport_cfg_maxfrsize(struct bfa_s *bfa, u16 maxsize);
173 u16 bfa_fcport_get_maxfrsize(struct bfa_s *bfa);
174 u32 bfa_fcport_mypid(struct bfa_s *bfa);
175 u8 bfa_fcport_get_rx_bbcredit(struct bfa_s *bfa);
176 bfa_status_t bfa_fcport_trunk_enable(struct bfa_s *bfa, u8 bitmap);
177 bfa_status_t bfa_fcport_trunk_disable(struct bfa_s *bfa);
178 bfa_boolean_t bfa_fcport_trunk_query(struct bfa_s *bfa, u32 *bitmap);
179 void bfa_fcport_get_attr(struct bfa_s *bfa, struct bfa_pport_attr_s *attr);
180 wwn_t bfa_fcport_get_wwn(struct bfa_s *bfa, bfa_boolean_t node);
181 void bfa_fcport_event_register(struct bfa_s *bfa,
182 void (*event_cbfn) (void *cbarg,
183 bfa_pport_event_t event), void *event_cbarg);
184 bfa_boolean_t bfa_fcport_is_disabled(struct bfa_s *bfa);
185 void bfa_fcport_cfg_qos(struct bfa_s *bfa, bfa_boolean_t on_off);
186 void bfa_fcport_cfg_ratelim(struct bfa_s *bfa, bfa_boolean_t on_off);
187 bfa_status_t bfa_fcport_cfg_ratelim_speed(struct bfa_s *bfa,
188 enum bfa_pport_speed speed);
189 enum bfa_pport_speed bfa_fcport_get_ratelim_speed(struct bfa_s *bfa);
191 void bfa_fcport_set_tx_bbcredit(struct bfa_s *bfa, u16 tx_bbcredit);
192 void bfa_fcport_busy(struct bfa_s *bfa, bfa_boolean_t status);
193 void bfa_fcport_beacon(struct bfa_s *bfa, bfa_boolean_t beacon,
194 bfa_boolean_t link_e2e_beacon);
195 void bfa_cb_pport_event(void *cbarg, bfa_pport_event_t event);
196 void bfa_fcport_qos_get_attr(struct bfa_s *bfa,
197 struct bfa_qos_attr_s *qos_attr);
198 void bfa_fcport_qos_get_vc_attr(struct bfa_s *bfa,
199 struct bfa_qos_vc_attr_s *qos_vc_attr);
200 bfa_status_t bfa_fcport_get_qos_stats(struct bfa_s *bfa,
201 union bfa_fcport_stats_u *stats,
202 bfa_cb_pport_t cbfn, void *cbarg);
203 bfa_status_t bfa_fcport_clear_qos_stats(struct bfa_s *bfa, bfa_cb_pport_t cbfn,
205 bfa_status_t bfa_fcport_get_fcoe_stats(struct bfa_s *bfa,
206 union bfa_fcport_stats_u *stats,
207 bfa_cb_pport_t cbfn, void *cbarg);
208 bfa_status_t bfa_fcport_clear_fcoe_stats(struct bfa_s *bfa, bfa_cb_pport_t cbfn,
211 bfa_boolean_t bfa_fcport_is_ratelim(struct bfa_s *bfa);
212 bfa_boolean_t bfa_fcport_is_linkup(struct bfa_s *bfa);
213 bfa_status_t bfa_fcport_get_stats(struct bfa_s *bfa,
214 union bfa_fcport_stats_u *stats,
215 bfa_cb_pport_t cbfn, void *cbarg);
216 bfa_status_t bfa_fcport_clear_stats(struct bfa_s *bfa, bfa_cb_pport_t cbfn,
218 bfa_boolean_t bfa_fcport_is_qos_enabled(struct bfa_s *bfa);
221 * bfa rport API functions
223 struct bfa_rport_s *bfa_rport_create(struct bfa_s *bfa, void *rport_drv);
224 void bfa_rport_delete(struct bfa_rport_s *rport);
225 void bfa_rport_online(struct bfa_rport_s *rport,
226 struct bfa_rport_info_s *rport_info);
227 void bfa_rport_offline(struct bfa_rport_s *rport);
228 void bfa_rport_speed(struct bfa_rport_s *rport, enum bfa_pport_speed speed);
229 void bfa_rport_get_stats(struct bfa_rport_s *rport,
230 struct bfa_rport_hal_stats_s *stats);
231 void bfa_rport_clear_stats(struct bfa_rport_s *rport);
232 void bfa_cb_rport_online(void *rport);
233 void bfa_cb_rport_offline(void *rport);
234 void bfa_cb_rport_qos_scn_flowid(void *rport,
235 struct bfa_rport_qos_attr_s old_qos_attr,
236 struct bfa_rport_qos_attr_s new_qos_attr);
237 void bfa_cb_rport_qos_scn_prio(void *rport,
238 struct bfa_rport_qos_attr_s old_qos_attr,
239 struct bfa_rport_qos_attr_s new_qos_attr);
240 void bfa_rport_get_qos_attr(struct bfa_rport_s *rport,
241 struct bfa_rport_qos_attr_s *qos_attr);
244 * bfa fcxp API functions
246 struct bfa_fcxp_s *bfa_fcxp_alloc(void *bfad_fcxp, struct bfa_s *bfa,
247 int nreq_sgles, int nrsp_sgles,
248 bfa_fcxp_get_sgaddr_t get_req_sga,
249 bfa_fcxp_get_sglen_t get_req_sglen,
250 bfa_fcxp_get_sgaddr_t get_rsp_sga,
251 bfa_fcxp_get_sglen_t get_rsp_sglen);
252 void bfa_fcxp_alloc_wait(struct bfa_s *bfa, struct bfa_fcxp_wqe_s *wqe,
253 bfa_fcxp_alloc_cbfn_t alloc_cbfn, void *cbarg);
254 void bfa_fcxp_walloc_cancel(struct bfa_s *bfa,
255 struct bfa_fcxp_wqe_s *wqe);
256 void bfa_fcxp_discard(struct bfa_fcxp_s *fcxp);
258 void *bfa_fcxp_get_reqbuf(struct bfa_fcxp_s *fcxp);
259 void *bfa_fcxp_get_rspbuf(struct bfa_fcxp_s *fcxp);
261 void bfa_fcxp_free(struct bfa_fcxp_s *fcxp);
263 void bfa_fcxp_send(struct bfa_fcxp_s *fcxp,
264 struct bfa_rport_s *rport, u16 vf_id, u8 lp_tag,
265 bfa_boolean_t cts, enum fc_cos cos,
266 u32 reqlen, struct fchs_s *fchs,
267 bfa_cb_fcxp_send_t cbfn,
269 u32 rsp_maxlen, u8 rsp_timeout);
270 bfa_status_t bfa_fcxp_abort(struct bfa_fcxp_s *fcxp);
271 u32 bfa_fcxp_get_reqbufsz(struct bfa_fcxp_s *fcxp);
272 u32 bfa_fcxp_get_maxrsp(struct bfa_s *bfa);
275 bfa_uf_get_frmbuf(struct bfa_uf_s *uf)
281 bfa_uf_get_frmlen(struct bfa_uf_s *uf)
287 * Callback prototype for unsolicited frame receive handler.
289 * @param[in] cbarg callback arg for receive handler
290 * @param[in] uf unsolicited frame descriptor
294 typedef void (*bfa_cb_uf_recv_t) (void *cbarg, struct bfa_uf_s *uf);
297 * bfa uf API functions
299 void bfa_uf_recv_register(struct bfa_s *bfa, bfa_cb_uf_recv_t ufrecv,
301 void bfa_uf_free(struct bfa_uf_s *uf);
304 * bfa lport service api
307 u32 bfa_lps_get_max_vport(struct bfa_s *bfa);
308 struct bfa_lps_s *bfa_lps_alloc(struct bfa_s *bfa);
309 void bfa_lps_delete(struct bfa_lps_s *lps);
310 void bfa_lps_discard(struct bfa_lps_s *lps);
311 void bfa_lps_flogi(struct bfa_lps_s *lps, void *uarg, u8 alpa, u16 pdusz,
312 wwn_t pwwn, wwn_t nwwn, bfa_boolean_t auth_en);
313 void bfa_lps_fdisc(struct bfa_lps_s *lps, void *uarg, u16 pdusz, wwn_t pwwn,
315 void bfa_lps_flogo(struct bfa_lps_s *lps);
316 void bfa_lps_fdisclogo(struct bfa_lps_s *lps);
317 u8 bfa_lps_get_tag(struct bfa_lps_s *lps);
318 bfa_boolean_t bfa_lps_is_npiv_en(struct bfa_lps_s *lps);
319 bfa_boolean_t bfa_lps_is_fport(struct bfa_lps_s *lps);
320 bfa_boolean_t bfa_lps_is_brcd_fabric(struct bfa_lps_s *lps);
321 bfa_boolean_t bfa_lps_is_authreq(struct bfa_lps_s *lps);
322 bfa_eproto_status_t bfa_lps_get_extstatus(struct bfa_lps_s *lps);
323 u32 bfa_lps_get_pid(struct bfa_lps_s *lps);
324 u8 bfa_lps_get_tag_from_pid(struct bfa_s *bfa, u32 pid);
325 u16 bfa_lps_get_peer_bbcredit(struct bfa_lps_s *lps);
326 wwn_t bfa_lps_get_peer_pwwn(struct bfa_lps_s *lps);
327 wwn_t bfa_lps_get_peer_nwwn(struct bfa_lps_s *lps);
328 u8 bfa_lps_get_lsrjt_rsn(struct bfa_lps_s *lps);
329 u8 bfa_lps_get_lsrjt_expl(struct bfa_lps_s *lps);
330 mac_t bfa_lps_get_lp_mac(struct bfa_lps_s *lps);
331 void bfa_cb_lps_flogi_comp(void *bfad, void *uarg, bfa_status_t status);
332 void bfa_cb_lps_flogo_comp(void *bfad, void *uarg);
333 void bfa_cb_lps_fdisc_comp(void *bfad, void *uarg, bfa_status_t status);
334 void bfa_cb_lps_fdisclogo_comp(void *bfad, void *uarg);
335 void bfa_cb_lps_cvl_event(void *bfad, void *uarg);
337 #endif /* __BFA_SVC_H__ */