ath9k: remove unneeded calculation of minimal calibration power
[linux-2.6/next.git] / drivers / scsi / bfa / include / bfa_svc.h
blob1349b99a3c6dff233e3f602e0254b5542f74e5e7
1 /*
2 * Copyright (c) 2005-2009 Brocade Communications Systems, Inc.
3 * All rights reserved
4 * www.brocade.com
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.
17 #ifndef __BFA_SVC_H__
18 #define __BFA_SVC_H__
21 * forward declarations
23 struct bfa_fcxp_s;
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>
31 #include <bfa.h>
33 /**
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 */
39 lp_tag:8; /* tag */
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 */
48 /**
49 * BFA rport data structure
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 */
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;
63 union a {
64 bfa_status_t status; /* f/w status */
65 void *fw_msg; /* QoS scn event */
66 } event_arg;
68 #define BFA_RPORT_FC_COS(_rport) ((_rport)->rport_info.fc_class)
70 /**
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);
78 /**
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 {
84 struct list_head qe;
85 bfa_fcxp_alloc_cbfn_t alloc_cbfn;
86 void *alloc_cbarg;
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)
94 /**
95 * @todo private
97 struct bfa_uf_buf_s {
98 u8 d[BFA_UF_BUFSZ];
102 struct bfa_uf_s {
103 struct list_head qe; /* queue element */
104 struct bfa_s *bfa; /* bfa instance */
105 u16 uf_tag; /* identifying tag fw msgs */
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];
118 typedef void (*bfa_cb_pport_t) (void *cbarg, enum bfa_status status);
121 * bfa lport login/logout service interface
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 */
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,
204 void *cbarg);
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);
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);
220 * bfa rport API functions
222 struct bfa_rport_s *bfa_rport_create(struct bfa_s *bfa, void *rport_drv);
223 void bfa_rport_delete(struct bfa_rport_s *rport);
224 void bfa_rport_online(struct bfa_rport_s *rport,
225 struct bfa_rport_info_s *rport_info);
226 void bfa_rport_offline(struct bfa_rport_s *rport);
227 void bfa_rport_speed(struct bfa_rport_s *rport, enum bfa_pport_speed speed);
228 void bfa_rport_get_stats(struct bfa_rport_s *rport,
229 struct bfa_rport_hal_stats_s *stats);
230 void bfa_rport_clear_stats(struct bfa_rport_s *rport);
231 void bfa_cb_rport_online(void *rport);
232 void bfa_cb_rport_offline(void *rport);
233 void bfa_cb_rport_qos_scn_flowid(void *rport,
234 struct bfa_rport_qos_attr_s old_qos_attr,
235 struct bfa_rport_qos_attr_s new_qos_attr);
236 void bfa_cb_rport_qos_scn_prio(void *rport,
237 struct bfa_rport_qos_attr_s old_qos_attr,
238 struct bfa_rport_qos_attr_s new_qos_attr);
239 void bfa_rport_get_qos_attr(struct bfa_rport_s *rport,
240 struct bfa_rport_qos_attr_s *qos_attr);
243 * bfa fcxp API functions
245 struct bfa_fcxp_s *bfa_fcxp_alloc(void *bfad_fcxp, struct bfa_s *bfa,
246 int nreq_sgles, int nrsp_sgles,
247 bfa_fcxp_get_sgaddr_t get_req_sga,
248 bfa_fcxp_get_sglen_t get_req_sglen,
249 bfa_fcxp_get_sgaddr_t get_rsp_sga,
250 bfa_fcxp_get_sglen_t get_rsp_sglen);
251 void bfa_fcxp_alloc_wait(struct bfa_s *bfa, struct bfa_fcxp_wqe_s *wqe,
252 bfa_fcxp_alloc_cbfn_t alloc_cbfn, void *cbarg);
253 void bfa_fcxp_walloc_cancel(struct bfa_s *bfa,
254 struct bfa_fcxp_wqe_s *wqe);
255 void bfa_fcxp_discard(struct bfa_fcxp_s *fcxp);
257 void *bfa_fcxp_get_reqbuf(struct bfa_fcxp_s *fcxp);
258 void *bfa_fcxp_get_rspbuf(struct bfa_fcxp_s *fcxp);
260 void bfa_fcxp_free(struct bfa_fcxp_s *fcxp);
262 void bfa_fcxp_send(struct bfa_fcxp_s *fcxp,
263 struct bfa_rport_s *rport, u16 vf_id, u8 lp_tag,
264 bfa_boolean_t cts, enum fc_cos cos,
265 u32 reqlen, struct fchs_s *fchs,
266 bfa_cb_fcxp_send_t cbfn,
267 void *cbarg,
268 u32 rsp_maxlen, u8 rsp_timeout);
269 bfa_status_t bfa_fcxp_abort(struct bfa_fcxp_s *fcxp);
270 u32 bfa_fcxp_get_reqbufsz(struct bfa_fcxp_s *fcxp);
271 u32 bfa_fcxp_get_maxrsp(struct bfa_s *bfa);
273 static inline void *
274 bfa_uf_get_frmbuf(struct bfa_uf_s *uf)
276 return uf->data_ptr;
279 static inline u16
280 bfa_uf_get_frmlen(struct bfa_uf_s *uf)
282 return uf->data_len;
286 * Callback prototype for unsolicited frame receive handler.
288 * @param[in] cbarg callback arg for receive handler
289 * @param[in] uf unsolicited frame descriptor
291 * @return None
293 typedef void (*bfa_cb_uf_recv_t) (void *cbarg, struct bfa_uf_s *uf);
296 * bfa uf API functions
298 void bfa_uf_recv_register(struct bfa_s *bfa, bfa_cb_uf_recv_t ufrecv,
299 void *cbarg);
300 void bfa_uf_free(struct bfa_uf_s *uf);
303 * bfa lport service api
306 u32 bfa_lps_get_max_vport(struct bfa_s *bfa);
307 struct bfa_lps_s *bfa_lps_alloc(struct bfa_s *bfa);
308 void bfa_lps_delete(struct bfa_lps_s *lps);
309 void bfa_lps_discard(struct bfa_lps_s *lps);
310 void bfa_lps_flogi(struct bfa_lps_s *lps, void *uarg, u8 alpa, u16 pdusz,
311 wwn_t pwwn, wwn_t nwwn, bfa_boolean_t auth_en);
312 void bfa_lps_fdisc(struct bfa_lps_s *lps, void *uarg, u16 pdusz, wwn_t pwwn,
313 wwn_t nwwn);
314 void bfa_lps_flogo(struct bfa_lps_s *lps);
315 void bfa_lps_fdisclogo(struct bfa_lps_s *lps);
316 u8 bfa_lps_get_tag(struct bfa_lps_s *lps);
317 bfa_boolean_t bfa_lps_is_npiv_en(struct bfa_lps_s *lps);
318 bfa_boolean_t bfa_lps_is_fport(struct bfa_lps_s *lps);
319 bfa_boolean_t bfa_lps_is_brcd_fabric(struct bfa_lps_s *lps);
320 bfa_boolean_t bfa_lps_is_authreq(struct bfa_lps_s *lps);
321 bfa_eproto_status_t bfa_lps_get_extstatus(struct bfa_lps_s *lps);
322 u32 bfa_lps_get_pid(struct bfa_lps_s *lps);
323 u8 bfa_lps_get_tag_from_pid(struct bfa_s *bfa, u32 pid);
324 u16 bfa_lps_get_peer_bbcredit(struct bfa_lps_s *lps);
325 wwn_t bfa_lps_get_peer_pwwn(struct bfa_lps_s *lps);
326 wwn_t bfa_lps_get_peer_nwwn(struct bfa_lps_s *lps);
327 u8 bfa_lps_get_lsrjt_rsn(struct bfa_lps_s *lps);
328 u8 bfa_lps_get_lsrjt_expl(struct bfa_lps_s *lps);
329 mac_t bfa_lps_get_lp_mac(struct bfa_lps_s *lps);
330 void bfa_cb_lps_flogi_comp(void *bfad, void *uarg, bfa_status_t status);
331 void bfa_cb_lps_flogo_comp(void *bfad, void *uarg);
332 void bfa_cb_lps_fdisc_comp(void *bfad, void *uarg, bfa_status_t status);
333 void bfa_cb_lps_fdisclogo_comp(void *bfad, void *uarg);
334 void bfa_cb_lps_cvl_event(void *bfad, void *uarg);
336 #endif /* __BFA_SVC_H__ */