• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/linux/linux-2.6.36/drivers/scsi/bfa/include/
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 */
23struct 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 <defs/bfa_defs_fcport.h>
30#include <cs/bfa_sm.h>
31#include <bfa.h>
32
33/**
34 * 		BFA rport information.
35 */
36struct 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	    */
46};
47
48/**
49 * BFA rport data structure
50 */
51struct 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;
67};
68#define BFA_RPORT_FC_COS(_rport)	((_rport)->rport_info.fc_class)
69
70/**
71 * Send completion callback.
72 */
73typedef 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 */
81typedef void (*bfa_fcxp_alloc_cbfn_t) (void *cbarg, struct bfa_fcxp_s *fcxp);
82
83struct bfa_fcxp_wqe_s {
84	struct list_head         qe;
85	bfa_fcxp_alloc_cbfn_t  alloc_cbfn;
86	void           *alloc_cbarg;
87};
88
89typedef u64 (*bfa_fcxp_get_sgaddr_t) (void *bfad_fcxp, int sgeid);
90typedef 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 */
97struct bfa_uf_buf_s {
98	u8         d[BFA_UF_BUFSZ];
99};
100
101
102struct 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];
116};
117
118typedef void (*bfa_cb_pport_t) (void *cbarg, enum bfa_status status);
119
120/**
121 * bfa lport login/logout service interface
122 */
123struct 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;
153};
154
155#define BFA_FCPORT(_bfa)        (&((_bfa)->modules.port))
156
157/*
158 * bfa pport API functions
159 */
160bfa_status_t bfa_fcport_enable(struct bfa_s *bfa);
161bfa_status_t bfa_fcport_disable(struct bfa_s *bfa);
162bfa_status_t bfa_fcport_cfg_speed(struct bfa_s *bfa,
163			enum bfa_pport_speed speed);
164enum bfa_pport_speed bfa_fcport_get_speed(struct bfa_s *bfa);
165bfa_status_t bfa_fcport_cfg_topology(struct bfa_s *bfa,
166			enum bfa_pport_topology topo);
167enum bfa_pport_topology bfa_fcport_get_topology(struct bfa_s *bfa);
168bfa_status_t bfa_fcport_cfg_hardalpa(struct bfa_s *bfa, u8 alpa);
169bfa_boolean_t bfa_fcport_get_hardalpa(struct bfa_s *bfa, u8 *alpa);
170u8 bfa_fcport_get_myalpa(struct bfa_s *bfa);
171bfa_status_t bfa_fcport_clr_hardalpa(struct bfa_s *bfa);
172bfa_status_t bfa_fcport_cfg_maxfrsize(struct bfa_s *bfa, u16 maxsize);
173u16 bfa_fcport_get_maxfrsize(struct bfa_s *bfa);
174u32 bfa_fcport_mypid(struct bfa_s *bfa);
175u8 bfa_fcport_get_rx_bbcredit(struct bfa_s *bfa);
176bfa_status_t bfa_fcport_trunk_enable(struct bfa_s *bfa, u8 bitmap);
177bfa_status_t bfa_fcport_trunk_disable(struct bfa_s *bfa);
178bfa_boolean_t bfa_fcport_trunk_query(struct bfa_s *bfa, u32 *bitmap);
179void bfa_fcport_get_attr(struct bfa_s *bfa, struct bfa_pport_attr_s *attr);
180wwn_t bfa_fcport_get_wwn(struct bfa_s *bfa, bfa_boolean_t node);
181void bfa_fcport_event_register(struct bfa_s *bfa,
182			void (*event_cbfn) (void *cbarg,
183			bfa_pport_event_t event), void *event_cbarg);
184bfa_boolean_t bfa_fcport_is_disabled(struct bfa_s *bfa);
185void bfa_fcport_cfg_qos(struct bfa_s *bfa, bfa_boolean_t on_off);
186void bfa_fcport_cfg_ratelim(struct bfa_s *bfa, bfa_boolean_t on_off);
187bfa_status_t bfa_fcport_cfg_ratelim_speed(struct bfa_s *bfa,
188			enum bfa_pport_speed speed);
189enum bfa_pport_speed bfa_fcport_get_ratelim_speed(struct bfa_s *bfa);
190
191void bfa_fcport_set_tx_bbcredit(struct bfa_s *bfa, u16 tx_bbcredit);
192void bfa_fcport_busy(struct bfa_s *bfa, bfa_boolean_t status);
193void bfa_fcport_beacon(struct bfa_s *bfa, bfa_boolean_t beacon,
194			bfa_boolean_t link_e2e_beacon);
195void bfa_cb_pport_event(void *cbarg, bfa_pport_event_t event);
196void bfa_fcport_qos_get_attr(struct bfa_s *bfa,
197			struct bfa_qos_attr_s *qos_attr);
198void bfa_fcport_qos_get_vc_attr(struct bfa_s *bfa,
199			struct bfa_qos_vc_attr_s *qos_vc_attr);
200bfa_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);
203bfa_status_t bfa_fcport_clear_qos_stats(struct bfa_s *bfa, bfa_cb_pport_t cbfn,
204			void *cbarg);
205bfa_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);
208bfa_status_t bfa_fcport_clear_fcoe_stats(struct bfa_s *bfa, bfa_cb_pport_t cbfn,
209			void *cbarg);
210
211bfa_boolean_t     bfa_fcport_is_ratelim(struct bfa_s *bfa);
212bfa_boolean_t	bfa_fcport_is_linkup(struct bfa_s *bfa);
213bfa_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);
216bfa_status_t bfa_fcport_clear_stats(struct bfa_s *bfa, bfa_cb_pport_t cbfn,
217		void *cbarg);
218bfa_boolean_t bfa_fcport_is_qos_enabled(struct bfa_s *bfa);
219
220/*
221 * bfa rport API functions
222 */
223struct bfa_rport_s *bfa_rport_create(struct bfa_s *bfa, void *rport_drv);
224void bfa_rport_delete(struct bfa_rport_s *rport);
225void bfa_rport_online(struct bfa_rport_s *rport,
226			struct bfa_rport_info_s *rport_info);
227void bfa_rport_offline(struct bfa_rport_s *rport);
228void bfa_rport_speed(struct bfa_rport_s *rport, enum bfa_pport_speed speed);
229void bfa_rport_get_stats(struct bfa_rport_s *rport,
230			struct bfa_rport_hal_stats_s *stats);
231void bfa_rport_clear_stats(struct bfa_rport_s *rport);
232void bfa_cb_rport_online(void *rport);
233void bfa_cb_rport_offline(void *rport);
234void 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);
237void 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);
240void 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 */
246struct 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);
252void bfa_fcxp_alloc_wait(struct bfa_s *bfa, struct bfa_fcxp_wqe_s *wqe,
253			bfa_fcxp_alloc_cbfn_t alloc_cbfn, void *cbarg);
254void bfa_fcxp_walloc_cancel(struct bfa_s *bfa,
255			struct bfa_fcxp_wqe_s *wqe);
256void bfa_fcxp_discard(struct bfa_fcxp_s *fcxp);
257
258void *bfa_fcxp_get_reqbuf(struct bfa_fcxp_s *fcxp);
259void *bfa_fcxp_get_rspbuf(struct bfa_fcxp_s *fcxp);
260
261void bfa_fcxp_free(struct bfa_fcxp_s *fcxp);
262
263void 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);
270bfa_status_t bfa_fcxp_abort(struct bfa_fcxp_s *fcxp);
271u32        bfa_fcxp_get_reqbufsz(struct bfa_fcxp_s *fcxp);
272u32	bfa_fcxp_get_maxrsp(struct bfa_s *bfa);
273
274static inline void *
275bfa_uf_get_frmbuf(struct bfa_uf_s *uf)
276{
277	return uf->data_ptr;
278}
279
280static inline   u16
281bfa_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 */
294typedef void (*bfa_cb_uf_recv_t) (void *cbarg, struct bfa_uf_s *uf);
295
296/*
297 * bfa uf API functions
298 */
299void bfa_uf_recv_register(struct bfa_s *bfa, bfa_cb_uf_recv_t ufrecv,
300			void *cbarg);
301void bfa_uf_free(struct bfa_uf_s *uf);
302
303/**
304 * bfa lport service api
305 */
306
307u32	bfa_lps_get_max_vport(struct bfa_s *bfa);
308struct bfa_lps_s *bfa_lps_alloc(struct bfa_s *bfa);
309void bfa_lps_delete(struct bfa_lps_s *lps);
310void bfa_lps_discard(struct bfa_lps_s *lps);
311void 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);
313void bfa_lps_fdisc(struct bfa_lps_s *lps, void *uarg, u16 pdusz, wwn_t pwwn,
314		   wwn_t nwwn);
315void bfa_lps_flogo(struct bfa_lps_s *lps);
316void bfa_lps_fdisclogo(struct bfa_lps_s *lps);
317u8 bfa_lps_get_tag(struct bfa_lps_s *lps);
318bfa_boolean_t bfa_lps_is_npiv_en(struct bfa_lps_s *lps);
319bfa_boolean_t bfa_lps_is_fport(struct bfa_lps_s *lps);
320bfa_boolean_t bfa_lps_is_brcd_fabric(struct bfa_lps_s *lps);
321bfa_boolean_t bfa_lps_is_authreq(struct bfa_lps_s *lps);
322bfa_eproto_status_t bfa_lps_get_extstatus(struct bfa_lps_s *lps);
323u32 bfa_lps_get_pid(struct bfa_lps_s *lps);
324u8 bfa_lps_get_tag_from_pid(struct bfa_s *bfa, u32 pid);
325u16 bfa_lps_get_peer_bbcredit(struct bfa_lps_s *lps);
326wwn_t bfa_lps_get_peer_pwwn(struct bfa_lps_s *lps);
327wwn_t bfa_lps_get_peer_nwwn(struct bfa_lps_s *lps);
328u8 bfa_lps_get_lsrjt_rsn(struct bfa_lps_s *lps);
329u8 bfa_lps_get_lsrjt_expl(struct bfa_lps_s *lps);
330mac_t bfa_lps_get_lp_mac(struct bfa_lps_s *lps);
331void bfa_cb_lps_flogi_comp(void *bfad, void *uarg, bfa_status_t status);
332void bfa_cb_lps_flogo_comp(void *bfad, void *uarg);
333void bfa_cb_lps_fdisc_comp(void *bfad, void *uarg, bfa_status_t status);
334void bfa_cb_lps_fdisclogo_comp(void *bfad, void *uarg);
335void bfa_cb_lps_cvl_event(void *bfad, void *uarg);
336
337#endif /* __BFA_SVC_H__ */
338