Commit | Line | Data |
---|---|---|
7725ccfd JH |
1 | /* |
2 | * Copyright (c) 2005-2009 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 | #ifndef __BFA_SVC_H__ | |
18 | #define __BFA_SVC_H__ | |
19 | ||
20 | /* | |
21 | * forward declarations | |
22 | */ | |
23 | struct bfa_fcxp_s; | |
24 | ||
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> | |
1c8a4c37 | 29 | #include <defs/bfa_defs_fcport.h> |
7725ccfd JH |
30 | #include <cs/bfa_sm.h> |
31 | #include <bfa.h> | |
32 | ||
33 | /** | |
34 | * BFA rport information. | |
35 | */ | |
36 | struct bfa_rport_info_s { | |
37 | u16 max_frmsz; /* max rcv pdu size */ | |
f8ceafde | 38 | u32 pid:24, /* remote port ID */ |
ca8b4327 | 39 | lp_tag:8; /* tag */ |
f8ceafde JH |
40 | u32 local_pid:24, /* local port ID */ |
41 | cisc:8; /* CIRO supported */ | |
7725ccfd JH |
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 */ | |
46 | }; | |
47 | ||
48 | /** | |
49 | * BFA rport data structure | |
50 | */ | |
51 | struct bfa_rport_s { | |
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 */ | |
ca8b4327 | 58 | struct bfa_rport_info_s rport_info; /* rport info from fcs/driver */ |
7725ccfd JH |
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; | |
63 | union a { | |
64 | bfa_status_t status; /* f/w status */ | |
65 | void *fw_msg; /* QoS scn event */ | |
66 | } event_arg; | |
67 | }; | |
68 | #define BFA_RPORT_FC_COS(_rport) ((_rport)->rport_info.fc_class) | |
69 | ||
70 | /** | |
71 | * Send completion callback. | |
72 | */ | |
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); | |
77 | ||
78 | /** | |
79 | * BFA fcxp allocation (asynchronous) | |
80 | */ | |
81 | typedef void (*bfa_fcxp_alloc_cbfn_t) (void *cbarg, struct bfa_fcxp_s *fcxp); | |
82 | ||
83 | struct bfa_fcxp_wqe_s { | |
84 | struct list_head qe; | |
85 | bfa_fcxp_alloc_cbfn_t alloc_cbfn; | |
86 | void *alloc_cbarg; | |
87 | }; | |
88 | ||
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); | |
91 | ||
92 | #define BFA_UF_BUFSZ (2 * 1024 + 256) | |
93 | ||
94 | /** | |
95 | * @todo private | |
96 | */ | |
97 | struct bfa_uf_buf_s { | |
98 | u8 d[BFA_UF_BUFSZ]; | |
99 | }; | |
100 | ||
101 | ||
102 | struct bfa_uf_s { | |
103 | struct list_head qe; /* queue element */ | |
104 | struct bfa_s *bfa; /* bfa instance */ | |
ca8b4327 | 105 | u16 uf_tag; /* identifying tag fw msgs */ |
7725ccfd JH |
106 | u16 vf_id; |
107 | u16 src_rport_handle; | |
108 | u16 rsvd; | |
109 | u8 *data_ptr; | |
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]; | |
116 | }; | |
117 | ||
118 | typedef void (*bfa_cb_pport_t) (void *cbarg, enum bfa_status status); | |
119 | ||
120 | /** | |
121 | * bfa lport login/logout service interface | |
122 | */ | |
123 | struct bfa_lps_s { | |
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 */ | |
ca8b4327 | 131 | bfa_boolean_t fdisc; /* send FDISC instead of FLOGI */ |
7725ccfd JH |
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; | |
153 | }; | |
154 | ||
1c8a4c37 KG |
155 | #define BFA_FCPORT(_bfa) (&((_bfa)->modules.port)) |
156 | ||
7725ccfd JH |
157 | /* |
158 | * bfa pport API functions | |
159 | */ | |
1c8a4c37 KG |
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, | |
7725ccfd | 163 | enum bfa_pport_speed speed); |
1c8a4c37 KG |
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, | |
7725ccfd | 166 | enum bfa_pport_topology topo); |
1c8a4c37 KG |
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); | |
1c8a4c37 | 181 | void bfa_fcport_event_register(struct bfa_s *bfa, |
7725ccfd JH |
182 | void (*event_cbfn) (void *cbarg, |
183 | bfa_pport_event_t event), void *event_cbarg); | |
1c8a4c37 KG |
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, | |
7725ccfd | 188 | enum bfa_pport_speed speed); |
1c8a4c37 | 189 | enum bfa_pport_speed bfa_fcport_get_ratelim_speed(struct bfa_s *bfa); |
7725ccfd | 190 | |
1c8a4c37 KG |
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, | |
7725ccfd JH |
194 | bfa_boolean_t link_e2e_beacon); |
195 | void bfa_cb_pport_event(void *cbarg, bfa_pport_event_t event); | |
ca8b4327 KG |
196 | void bfa_fcport_qos_get_attr(struct bfa_s *bfa, |
197 | struct bfa_qos_attr_s *qos_attr); | |
1c8a4c37 | 198 | void bfa_fcport_qos_get_vc_attr(struct bfa_s *bfa, |
7725ccfd | 199 | struct bfa_qos_vc_attr_s *qos_vc_attr); |
1c8a4c37 | 200 | bfa_status_t bfa_fcport_get_qos_stats(struct bfa_s *bfa, |
ca8b4327 | 201 | union bfa_fcport_stats_u *stats, |
7725ccfd | 202 | bfa_cb_pport_t cbfn, void *cbarg); |
1c8a4c37 | 203 | bfa_status_t bfa_fcport_clear_qos_stats(struct bfa_s *bfa, bfa_cb_pport_t cbfn, |
7725ccfd | 204 | void *cbarg); |
ca8b4327 KG |
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, | |
209 | void *cbarg); | |
210 | ||
1c8a4c37 KG |
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, | |
217 | void *cbarg); | |
36d345a7 | 218 | bfa_boolean_t bfa_fcport_is_qos_enabled(struct bfa_s *bfa); |
7725ccfd JH |
219 | |
220 | /* | |
221 | * bfa rport API functions | |
222 | */ | |
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); | |
242 | ||
243 | /* | |
244 | * bfa fcxp API functions | |
245 | */ | |
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); | |
257 | ||
258 | void *bfa_fcxp_get_reqbuf(struct bfa_fcxp_s *fcxp); | |
259 | void *bfa_fcxp_get_rspbuf(struct bfa_fcxp_s *fcxp); | |
260 | ||
261 | void bfa_fcxp_free(struct bfa_fcxp_s *fcxp); | |
262 | ||
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, | |
268 | void *cbarg, | |
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); | |
273 | ||
274 | static inline void * | |
275 | bfa_uf_get_frmbuf(struct bfa_uf_s *uf) | |
276 | { | |
277 | return uf->data_ptr; | |
278 | } | |
279 | ||
280 | static inline u16 | |
281 | bfa_uf_get_frmlen(struct bfa_uf_s *uf) | |
282 | { | |
283 | return uf->data_len; | |
284 | } | |
285 | ||
286 | /** | |
287 | * Callback prototype for unsolicited frame receive handler. | |
288 | * | |
289 | * @param[in] cbarg callback arg for receive handler | |
290 | * @param[in] uf unsolicited frame descriptor | |
291 | * | |
292 | * @return None | |
293 | */ | |
294 | typedef void (*bfa_cb_uf_recv_t) (void *cbarg, struct bfa_uf_s *uf); | |
295 | ||
296 | /* | |
297 | * bfa uf API functions | |
298 | */ | |
299 | void bfa_uf_recv_register(struct bfa_s *bfa, bfa_cb_uf_recv_t ufrecv, | |
300 | void *cbarg); | |
301 | void bfa_uf_free(struct bfa_uf_s *uf); | |
302 | ||
303 | /** | |
304 | * bfa lport service api | |
305 | */ | |
306 | ||
a046bf05 | 307 | u32 bfa_lps_get_max_vport(struct bfa_s *bfa); |
7725ccfd JH |
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, | |
314 | wwn_t nwwn); | |
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); | |
86e32dab | 330 | mac_t bfa_lps_get_lp_mac(struct bfa_lps_s *lps); |
7725ccfd JH |
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); | |
5c1fb1d5 | 335 | void bfa_cb_lps_cvl_event(void *bfad, void *uarg); |
7725ccfd JH |
336 | |
337 | #endif /* __BFA_SVC_H__ */ | |
338 |