- patches.suse/slab-handle-memoryless-nodes-v2a.patch: Refresh.
[linux-flexiantxendom0-3.2.10.git] / drivers / scsi / bfa / include / bfa_svc.h
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>
29 #include <cs/bfa_sm.h>
30 #include <bfa.h>
31
32 /**
33  *              BFA rport information.
34  */
35 struct bfa_rport_info_s {
36         u16        max_frmsz;   /*  max rcv pdu size               */
37         u32        pid:24,              /*  remote port ID                 */
38                         lp_tag:8;
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           */
45 };
46
47 /**
48  * BFA rport data structure
49  */
50 struct bfa_rport_s {
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;
62         union a {
63                 bfa_status_t    status;  /*  f/w status */
64                 void            *fw_msg; /*  QoS scn event */
65         } event_arg;
66 };
67 #define BFA_RPORT_FC_COS(_rport)        ((_rport)->rport_info.fc_class)
68
69 /**
70  * Send completion callback.
71  */
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);
76
77 /**
78  * BFA fcxp allocation (asynchronous)
79  */
80 typedef void (*bfa_fcxp_alloc_cbfn_t) (void *cbarg, struct bfa_fcxp_s *fcxp);
81
82 struct bfa_fcxp_wqe_s {
83         struct list_head         qe;
84         bfa_fcxp_alloc_cbfn_t  alloc_cbfn;
85         void           *alloc_cbarg;
86 };
87
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);
90
91 #define BFA_UF_BUFSZ    (2 * 1024 + 256)
92
93 /**
94  * @todo private
95  */
96 struct bfa_uf_buf_s {
97         u8         d[BFA_UF_BUFSZ];
98 };
99
100
101 struct bfa_uf_s {
102         struct list_head        qe;             /*  queue element         */
103         struct bfa_s    *bfa;           /*  bfa instance          */
104         u16        uf_tag;              /*  identifying tag f/w messages */
105         u16        vf_id;
106         u16        src_rport_handle;
107         u16        rsvd;
108         u8              *data_ptr;
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];
115 };
116
117 typedef void (*bfa_cb_pport_t) (void *cbarg, enum bfa_status status);
118
119 /**
120  * bfa lport login/logout service interface
121  */
122 struct bfa_lps_s {
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;
152 };
153
154 /*
155  * bfa pport API functions
156  */
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,
182                         void *cbarg);
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);
192
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,
205                         void *cbarg);
206 bfa_boolean_t     bfa_pport_is_ratelim(struct bfa_s *bfa);
207 bfa_boolean_t   bfa_pport_is_linkup(struct bfa_s *bfa);
208
209 /*
210  * bfa rport API functions
211  */
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);
231
232 /*
233  * bfa fcxp API functions
234  */
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);
246
247 void *bfa_fcxp_get_reqbuf(struct bfa_fcxp_s *fcxp);
248 void *bfa_fcxp_get_rspbuf(struct bfa_fcxp_s *fcxp);
249
250 void bfa_fcxp_free(struct bfa_fcxp_s *fcxp);
251
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,
257                         void *cbarg,
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);
262
263 static inline void *
264 bfa_uf_get_frmbuf(struct bfa_uf_s *uf)
265 {
266         return uf->data_ptr;
267 }
268
269 static inline   u16
270 bfa_uf_get_frmlen(struct bfa_uf_s *uf)
271 {
272         return uf->data_len;
273 }
274
275 /**
276  *      Callback prototype for unsolicited frame receive handler.
277  *
278  * @param[in]           cbarg           callback arg for receive handler
279  * @param[in]           uf              unsolicited frame descriptor
280  *
281  * @return None
282  */
283 typedef void (*bfa_cb_uf_recv_t) (void *cbarg, struct bfa_uf_s *uf);
284
285 /*
286  * bfa uf API functions
287  */
288 void bfa_uf_recv_register(struct bfa_s *bfa, bfa_cb_uf_recv_t ufrecv,
289                         void *cbarg);
290 void bfa_uf_free(struct bfa_uf_s *uf);
291
292 /**
293  * bfa lport service api
294  */
295
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,
302                    wwn_t nwwn);
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);
322
323 #endif /* __BFA_SVC_H__ */
324