Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
bfa_svc.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2005-2010 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 
18 #ifndef __BFA_SVC_H__
19 #define __BFA_SVC_H__
20 
21 #include "bfa_cs.h"
22 #include "bfi_ms.h"
23 
24 
25 /*
26  * Scatter-gather DMA related defines
27  */
28 #define BFA_SGPG_MIN (16)
29 #define BFA_SGPG_MAX (8192)
30 
31 /*
32  * Alignment macro for SG page allocation
33  */
34 #define BFA_SGPG_ROUNDUP(_l) (((_l) + (sizeof(struct bfi_sgpg_s) - 1)) \
35  & ~(sizeof(struct bfi_sgpg_s) - 1))
36 
38  struct list_head qe; /* queue sg page element */
39  int nsgpg; /* pages to be allocated */
40  int nsgpg_total; /* total pages required */
41  void (*cbfn) (void *cbarg); /* callback function */
42  void *cbarg; /* callback arg */
43  struct list_head sgpg_q; /* queue of alloced sgpgs */
44 };
45 
46 struct bfa_sgpg_s {
47  struct list_head qe; /* queue sg page element */
48  struct bfi_sgpg_s *sgpg; /* va of SG page */
49  union bfi_addr_u sgpg_pa; /* pa of SG page */
50 };
51 
52 /*
53  * Given number of SG elements, BFA_SGPG_NPAGE() returns the number of
54  * SG pages required.
55  */
56 #define BFA_SGPG_NPAGE(_nsges) (((_nsges) / BFI_SGPG_DATA_SGES) + 1)
57 
58 /* Max SGPG dma segs required */
59 #define BFA_SGPG_DMA_SEGS \
60  BFI_MEM_DMA_NSEGS(BFA_SGPG_MAX, (uint32_t)sizeof(struct bfi_sgpg_s))
61 
63  struct bfa_s *bfa;
64  int num_sgpgs; /* number of SG pages */
65  int free_sgpgs; /* number of free SG pages */
66  struct list_head sgpg_q; /* queue of free SG pages */
67  struct list_head sgpg_wait_q; /* wait queue for SG pages */
70 };
71 #define BFA_SGPG_MOD(__bfa) (&(__bfa)->modules.sgpg_mod)
72 #define BFA_MEM_SGPG_KVA(__bfa) (&(BFA_SGPG_MOD(__bfa)->kva_seg))
73 
74 bfa_status_t bfa_sgpg_malloc(struct bfa_s *bfa, struct list_head *sgpg_q,
75  int nsgpgs);
76 void bfa_sgpg_mfree(struct bfa_s *bfa, struct list_head *sgpg_q, int nsgpgs);
77 void bfa_sgpg_winit(struct bfa_sgpg_wqe_s *wqe,
78  void (*cbfn) (void *cbarg), void *cbarg);
79 void bfa_sgpg_wait(struct bfa_s *bfa, struct bfa_sgpg_wqe_s *wqe, int nsgpgs);
80 void bfa_sgpg_wcancel(struct bfa_s *bfa, struct bfa_sgpg_wqe_s *wqe);
81 
82 
83 /*
84  * FCXP related defines
85  */
86 #define BFA_FCXP_MIN (1)
87 #define BFA_FCXP_MAX (256)
88 #define BFA_FCXP_MAX_IBUF_SZ (2 * 1024 + 256)
89 #define BFA_FCXP_MAX_LBUF_SZ (4 * 1024 + 256)
90 
91 /* Max FCXP dma segs required */
92 #define BFA_FCXP_DMA_SEGS \
93  BFI_MEM_DMA_NSEGS(BFA_FCXP_MAX, \
94  (u32)BFA_FCXP_MAX_IBUF_SZ + BFA_FCXP_MAX_LBUF_SZ)
95 
97  struct bfa_s *bfa; /* backpointer to BFA */
98  struct bfa_fcxp_s *fcxp_list; /* array of FCXPs */
99  u16 num_fcxps; /* max num FCXP requests */
100  struct list_head fcxp_req_free_q; /* free FCXPs used for sending req */
101  struct list_head fcxp_rsp_free_q; /* free FCXPs used for sending req */
102  struct list_head fcxp_active_q; /* active FCXPs */
103  struct list_head req_wait_q; /* wait queue for free req_fcxp */
104  struct list_head rsp_wait_q; /* wait queue for free rsp_fcxp */
105  struct list_head fcxp_req_unused_q; /* unused req_fcxps */
106  struct list_head fcxp_rsp_unused_q; /* unused rsp_fcxps */
111 };
112 
113 #define BFA_FCXP_MOD(__bfa) (&(__bfa)->modules.fcxp_mod)
114 #define BFA_FCXP_FROM_TAG(__mod, __tag) (&(__mod)->fcxp_list[__tag])
115 #define BFA_MEM_FCXP_KVA(__bfa) (&(BFA_FCXP_MOD(__bfa)->kva_seg))
116 
117 typedef void (*fcxp_send_cb_t) (struct bfa_s *ioc, struct bfa_fcxp_s *fcxp,
118  void *cb_arg, bfa_status_t req_status,
119  u32 rsp_len, u32 resid_len,
120  struct fchs_s *rsp_fchs);
121 
122 typedef u64 (*bfa_fcxp_get_sgaddr_t) (void *bfad_fcxp, int sgeid);
123 typedef u32 (*bfa_fcxp_get_sglen_t) (void *bfad_fcxp, int sgeid);
124 typedef void (*bfa_cb_fcxp_send_t) (void *bfad_fcxp, struct bfa_fcxp_s *fcxp,
125  void *cbarg, enum bfa_status req_status,
126  u32 rsp_len, u32 resid_len,
127  struct fchs_s *rsp_fchs);
128 typedef void (*bfa_fcxp_alloc_cbfn_t) (void *cbarg, struct bfa_fcxp_s *fcxp);
129 
130 
131 
132 /*
133  * Information needed for a FCXP request
134  */
137  /* Pointer to the bfa rport that was
138  * returned from bfa_rport_create().
139  * This could be left NULL for WKA or
140  * for FCXP interactions before the
141  * rport nexus is established
142  */
143  struct fchs_s fchs; /* request FC header structure */
144  u8 cts; /* continuous sequence */
145  u8 class; /* FC class for the request/response */
146  u16 max_frmsz; /* max send frame size */
147  u16 vf_id; /* vsan tag if applicable */
148  u8 lp_tag; /* lport tag */
149  u32 req_tot_len; /* request payload total length */
150 };
151 
153  struct fchs_s rsp_fchs;
154  /* Response frame's FC header will
155  * be sent back in this field */
157  /* timeout in seconds, 0-no response */
158  u8 rsvd2[3];
159  u32 rsp_maxlen; /* max response length expected */
160 };
161 
162 struct bfa_fcxp_s {
163  struct list_head qe; /* fcxp queue element */
164  bfa_sm_t sm; /* state machine */
165  void *caller; /* driver or fcs */
167  /* back pointer to fcxp mod */
168  u16 fcxp_tag; /* internal tag */
170  /* request info */
172  /* response info */
173  u8 use_ireqbuf; /* use internal req buf */
174  u8 use_irspbuf; /* use internal rsp buf */
175  u32 nreq_sgles; /* num request SGLEs */
176  u32 nrsp_sgles; /* num response SGLEs */
177  struct list_head req_sgpg_q; /* SG pages for request buf */
178  struct list_head req_sgpg_wqe; /* wait queue for req SG page */
179  struct list_head rsp_sgpg_q; /* SG pages for response buf */
180  struct list_head rsp_sgpg_wqe; /* wait queue for rsp SG page */
181 
183  /* SG elem addr user function */
185  /* SG elem len user function */
187  /* SG elem addr user function */
189  /* SG elem len user function */
190  bfa_cb_fcxp_send_t send_cbfn; /* send completion callback */
191  void *send_cbarg; /* callback arg */
193  /* req SG elems */
195  /* rsp SG elems */
196  u8 rsp_status; /* comp: rsp status */
197  u32 rsp_len; /* comp: actual response len */
198  u32 residue_len; /* comp: residual rsp length */
199  struct fchs_s rsp_fchs; /* comp: response fchs */
200  struct bfa_cb_qe_s hcb_qe; /* comp: callback qelem */
203  bfa_boolean_t req_rsp; /* Used to track req/rsp fcxp */
204 };
205 
207  struct list_head qe;
209  void *alloc_cbarg;
210  void *caller;
211  struct bfa_s *bfa;
218 };
219 
220 #define BFA_FCXP_REQ_PLD(_fcxp) (bfa_fcxp_get_reqbuf(_fcxp))
221 #define BFA_FCXP_RSP_FCHS(_fcxp) (&((_fcxp)->rsp_info.fchs))
222 #define BFA_FCXP_RSP_PLD(_fcxp) (bfa_fcxp_get_rspbuf(_fcxp))
223 
224 #define BFA_FCXP_REQ_PLD_PA(_fcxp) \
225  bfa_mem_get_dmabuf_pa((_fcxp)->fcxp_mod, (_fcxp)->fcxp_tag, \
226  (_fcxp)->fcxp_mod->req_pld_sz + (_fcxp)->fcxp_mod->rsp_pld_sz)
227 
228 /* fcxp_buf = req_buf + rsp_buf :- add req_buf_sz to get to rsp_buf */
229 #define BFA_FCXP_RSP_PLD_PA(_fcxp) \
230  (bfa_mem_get_dmabuf_pa((_fcxp)->fcxp_mod, (_fcxp)->fcxp_tag, \
231  (_fcxp)->fcxp_mod->req_pld_sz + (_fcxp)->fcxp_mod->rsp_pld_sz) + \
232  (_fcxp)->fcxp_mod->req_pld_sz)
233 
234 void bfa_fcxp_isr(struct bfa_s *bfa, struct bfi_msg_s *msg);
235 
236 
237 /*
238  * RPORT related defines
239  */
241  BFA_RPORT_SM_CREATE = 1, /* rport create event */
242  BFA_RPORT_SM_DELETE = 2, /* deleting an existing rport */
243  BFA_RPORT_SM_ONLINE = 3, /* rport is online */
244  BFA_RPORT_SM_OFFLINE = 4, /* rport is offline */
245  BFA_RPORT_SM_FWRSP = 5, /* firmware response */
246  BFA_RPORT_SM_HWFAIL = 6, /* IOC h/w failure */
247  BFA_RPORT_SM_QOS_SCN = 7, /* QoS SCN from firmware */
248  BFA_RPORT_SM_SET_SPEED = 8, /* Set Rport Speed */
249  BFA_RPORT_SM_QRESUME = 9, /* space in requeue queue */
250 };
251 
252 #define BFA_RPORT_MIN 4
253 
255  struct bfa_rport_s *rps_list; /* list of rports */
256  struct list_head rp_free_q; /* free bfa_rports */
257  struct list_head rp_active_q; /* free bfa_rports */
258  struct list_head rp_unused_q; /* unused bfa rports */
259  u16 num_rports; /* number of rports */
261 };
262 
263 #define BFA_RPORT_MOD(__bfa) (&(__bfa)->modules.rport_mod)
264 #define BFA_MEM_RPORT_KVA(__bfa) (&(BFA_RPORT_MOD(__bfa)->kva_seg))
265 
266 /*
267  * Convert rport tag to RPORT
268  */
269 #define BFA_RPORT_FROM_TAG(__bfa, _tag) \
270  (BFA_RPORT_MOD(__bfa)->rps_list + \
271  ((_tag) & (BFA_RPORT_MOD(__bfa)->num_rports - 1)))
272 
273 /*
274  * protected functions
275  */
276 void bfa_rport_isr(struct bfa_s *bfa, struct bfi_msg_s *msg);
277 void bfa_rport_res_recfg(struct bfa_s *bfa, u16 num_rport_fw);
278 
279 /*
280  * BFA rport information.
281  */
283  u16 max_frmsz; /* max rcv pdu size */
284  u32 pid:24, /* remote port ID */
285  lp_tag:8; /* tag */
286  u32 local_pid:24, /* local port ID */
287  cisc:8; /* CIRO supported */
288  u8 fc_class; /* supported FC classes. enum fc_cos */
289  u8 vf_en; /* virtual fabric enable */
290  u16 vf_id; /* virtual fabric ID */
291  enum bfa_port_speed speed; /* Rport's current speed */
292 };
293 
294 /*
295  * BFA rport data structure
296  */
297 struct bfa_rport_s {
298  struct list_head qe; /* queue element */
299  bfa_sm_t sm; /* state machine */
300  struct bfa_s *bfa; /* backpointer to BFA */
301  void *rport_drv; /* fcs/driver rport object */
302  u16 fw_handle; /* firmware rport handle */
303  u16 rport_tag; /* BFA rport tag */
304  u8 lun_mask; /* LUN mask flag */
305  struct bfa_rport_info_s rport_info; /* rport info from fcs/driver */
306  struct bfa_reqq_wait_s reqq_wait; /* to wait for room in reqq */
307  struct bfa_cb_qe_s hcb_qe; /* BFA callback qelem */
308  struct bfa_rport_hal_stats_s stats; /* BFA rport statistics */
310  union a {
311  bfa_status_t status; /* f/w status */
312  void *fw_msg; /* QoS scn event */
313  } event_arg;
314 };
315 #define BFA_RPORT_FC_COS(_rport) ((_rport)->rport_info.fc_class)
316 
317 
318 /*
319  * UF - unsolicited receive related defines
320  */
321 
322 #define BFA_UF_MIN (4)
323 #define BFA_UF_MAX (256)
324 
325 struct bfa_uf_s {
326  struct list_head qe; /* queue element */
327  struct bfa_s *bfa; /* bfa instance */
328  u16 uf_tag; /* identifying tag fw msgs */
333  u16 data_len; /* actual receive length */
334  u16 pb_len; /* posted buffer length */
335  void *buf_kva; /* buffer virtual address */
336  u64 buf_pa; /* buffer physical address */
337  struct bfa_cb_qe_s hcb_qe; /* comp: BFA comp qelem */
339 };
340 
341 /*
342  * Callback prototype for unsolicited frame receive handler.
343  *
344  * @param[in] cbarg callback arg for receive handler
345  * @param[in] uf unsolicited frame descriptor
346  *
347  * @return None
348  */
349 typedef void (*bfa_cb_uf_recv_t) (void *cbarg, struct bfa_uf_s *uf);
350 
351 #define BFA_UF_BUFSZ (2 * 1024 + 256)
352 
353 struct bfa_uf_buf_s {
355 };
356 
357 #define BFA_PER_UF_DMA_SZ \
358  (u32)BFA_ROUNDUP(sizeof(struct bfa_uf_buf_s), BFA_DMA_ALIGN_SZ)
359 
360 /* Max UF dma segs required */
361 #define BFA_UF_DMA_SEGS BFI_MEM_DMA_NSEGS(BFA_UF_MAX, BFA_PER_UF_DMA_SZ)
362 
363 struct bfa_uf_mod_s {
364  struct bfa_s *bfa; /* back pointer to BFA */
365  struct bfa_uf_s *uf_list; /* array of UFs */
366  u16 num_ufs; /* num unsolicited rx frames */
367  struct list_head uf_free_q; /* free UFs */
368  struct list_head uf_posted_q; /* UFs posted to IOC */
369  struct list_head uf_unused_q; /* unused UF's */
371  /* pre-built UF post msgs */
372  bfa_cb_uf_recv_t ufrecv; /* uf recv handler function */
373  void *cbarg; /* uf receive handler arg */
376 };
377 
378 #define BFA_UF_MOD(__bfa) (&(__bfa)->modules.uf_mod)
379 #define BFA_MEM_UF_KVA(__bfa) (&(BFA_UF_MOD(__bfa)->kva_seg))
380 
381 #define ufm_pbs_pa(_ufmod, _uftag) \
382  bfa_mem_get_dmabuf_pa(_ufmod, _uftag, BFA_PER_UF_DMA_SZ)
383 
384 void bfa_uf_isr(struct bfa_s *bfa, struct bfi_msg_s *msg);
385 void bfa_uf_res_recfg(struct bfa_s *bfa, u16 num_uf_fw);
386 
387 /*
388  * LPS - bfa lport login/logout service interface
389  */
390 struct bfa_lps_s {
391  struct list_head qe; /* queue element */
392  struct bfa_s *bfa; /* parent bfa instance */
393  bfa_sm_t sm; /* finite state machine */
394  u8 bfa_tag; /* lport tag */
395  u8 fw_tag; /* lport fw tag */
396  u8 reqq; /* lport request queue */
397  u8 alpa; /* ALPA for loop topologies */
398  u32 lp_pid; /* lport port ID */
399  bfa_boolean_t fdisc; /* snd FDISC instead of FLOGI */
400  bfa_boolean_t auth_en; /* enable authentication */
401  bfa_boolean_t auth_req; /* authentication required */
402  bfa_boolean_t npiv_en; /* NPIV is allowed by peer */
403  bfa_boolean_t fport; /* attached peer is F_PORT */
404  bfa_boolean_t brcd_switch; /* attached peer is brcd sw */
405  bfa_status_t status; /* login status */
406  u16 pdusz; /* max receive PDU size */
407  u16 pr_bbcred; /* BB_CREDIT from peer */
408  u8 pr_bbscn; /* BB_SCN from peer */
409  u8 bb_scn; /* local BB_SCN */
410  u8 lsrjt_rsn; /* LSRJT reason */
411  u8 lsrjt_expl; /* LSRJT explanation */
412  u8 lun_mask; /* LUN mask flag */
413  wwn_t pwwn; /* port wwn of lport */
414  wwn_t nwwn; /* node wwn of lport */
415  wwn_t pr_pwwn; /* port wwn of lport peer */
416  wwn_t pr_nwwn; /* node wwn of lport peer */
417  mac_t lp_mac; /* fpma/spma MAC for lport */
418  mac_t fcf_mac; /* FCF MAC of lport */
419  struct bfa_reqq_wait_s wqe; /* request wait queue element */
420  void *uarg; /* user callback arg */
421  struct bfa_cb_qe_s hcb_qe; /* comp: callback qelem */
424 };
425 
431  int num_lps;
433 };
434 
435 #define BFA_LPS_MOD(__bfa) (&(__bfa)->modules.lps_mod)
436 #define BFA_LPS_FROM_TAG(__mod, __tag) (&(__mod)->lps_arr[__tag])
437 #define BFA_MEM_LPS_KVA(__bfa) (&(BFA_LPS_MOD(__bfa)->kva_seg))
438 
439 /*
440  * external functions
441  */
442 void bfa_lps_isr(struct bfa_s *bfa, struct bfi_msg_s *msg);
443 
444 
445 /*
446  * FCPORT related defines
447  */
448 
449 #define BFA_FCPORT(_bfa) (&((_bfa)->modules.port))
450 
451 /*
452  * Link notification data structure
453  */
457  struct bfa_cb_qe_s ln_qe; /* BFA callback queue elem for ln */
458  enum bfa_port_linkstate ln_event; /* ln event for callback */
459 };
460 
463 };
464 
465 /*
466  * BFA FC port data structure
467  */
468 struct bfa_fcport_s {
469  struct bfa_s *bfa; /* parent BFA instance */
470  bfa_sm_t sm; /* port state machine */
471  wwn_t nwwn; /* node wwn of physical port */
472  wwn_t pwwn; /* port wwn of physical oprt */
474  /* supported speeds */
475  enum bfa_port_speed speed; /* current speed */
476  enum bfa_port_topology topology; /* current topology */
477  u8 rsvd[3];
478  u8 myalpa; /* my ALPA in LOOP topology */
479  u8 alpabm_valid; /* alpa bitmap valid or not */
480  struct fc_alpabm_s alpabm; /* alpa bitmap */
481  struct bfa_port_cfg_s cfg; /* current port configuration */
482  bfa_boolean_t use_flash_cfg; /* get port cfg from flash */
483  struct bfa_qos_attr_s qos_attr; /* QoS Attributes */
484  struct bfa_qos_vc_attr_s qos_vc_attr; /* VC info from ELP */
486  /* to wait for room in reqq */
488  /* to wait for room in reqq */
490  /* to wait for room in reqq (stats) */
491  void *event_cbarg;
492  void (*event_cbfn) (void *cbarg,
494  union {
496  } event_arg;
497  void *bfad; /* BFA driver handle */
498  struct bfa_fcport_ln_s ln; /* Link Notification */
499  struct bfa_cb_qe_s hcb_qe; /* BFA callback queue elem */
500  struct bfa_timer_s timer; /* timer */
501  u32 msgtag; /* fimrware msg tag for reply */
505  bfa_status_t stats_status; /* stats/statsclr status */
509  u32 stats_reset_time; /* stats reset time stamp */
510  bfa_boolean_t diag_busy; /* diag busy status */
511  bfa_boolean_t beacon; /* port beacon status */
512  bfa_boolean_t link_e2e_beacon; /* link beacon status */
513  bfa_boolean_t bbsc_op_state; /* Cred recov Oper State */
518 };
519 
520 #define BFA_FCPORT_MOD(__bfa) (&(__bfa)->modules.fcport)
521 #define BFA_MEM_FCPORT_DMA(__bfa) (&(BFA_FCPORT_MOD(__bfa)->fcport_dma))
522 
523 /*
524  * protected functions
525  */
526 void bfa_fcport_init(struct bfa_s *bfa);
527 void bfa_fcport_isr(struct bfa_s *bfa, struct bfi_msg_s *msg);
528 
529 /*
530  * bfa fcport API functions
531  */
535  enum bfa_port_speed speed);
536 enum bfa_port_speed bfa_fcport_get_speed(struct bfa_s *bfa);
538  enum bfa_port_topology topo);
541 bfa_status_t bfa_fcport_cfg_hardalpa(struct bfa_s *bfa, u8 alpa);
542 bfa_boolean_t bfa_fcport_get_hardalpa(struct bfa_s *bfa, u8 *alpa);
543 u8 bfa_fcport_get_myalpa(struct bfa_s *bfa);
545 bfa_status_t bfa_fcport_cfg_maxfrsize(struct bfa_s *bfa, u16 maxsize);
546 u16 bfa_fcport_get_maxfrsize(struct bfa_s *bfa);
547 u8 bfa_fcport_get_rx_bbcredit(struct bfa_s *bfa);
548 void bfa_fcport_get_attr(struct bfa_s *bfa, struct bfa_port_attr_s *attr);
550 void bfa_fcport_event_register(struct bfa_s *bfa,
551  void (*event_cbfn) (void *cbarg,
552  enum bfa_port_linkstate event), void *event_cbarg);
556  struct bfa_qos_bw_s *qos_bw);
558 
559 void bfa_fcport_set_tx_bbcredit(struct bfa_s *bfa, u16 tx_bbcredit, u8 bb_scn);
562  bfa_boolean_t link_e2e_beacon);
565  struct bfa_cb_pending_q_s *cb);
567  struct bfa_cb_pending_q_s *cb);
570 void bfa_fcport_dportenable(struct bfa_s *bfa);
571 void bfa_fcport_dportdisable(struct bfa_s *bfa);
573 void bfa_fcport_cfg_faa(struct bfa_s *bfa, u8 state);
574 
575 /*
576  * bfa rport API functions
577  */
578 struct bfa_rport_s *bfa_rport_create(struct bfa_s *bfa, void *rport_drv);
579 void bfa_rport_online(struct bfa_rport_s *rport,
580  struct bfa_rport_info_s *rport_info);
581 void bfa_rport_speed(struct bfa_rport_s *rport, enum bfa_port_speed speed);
582 void bfa_cb_rport_online(void *rport);
583 void bfa_cb_rport_offline(void *rport);
585  struct bfa_rport_qos_attr_s old_qos_attr,
586  struct bfa_rport_qos_attr_s new_qos_attr);
587 void bfa_cb_rport_scn_online(struct bfa_s *bfa);
588 void bfa_cb_rport_scn_offline(struct bfa_s *bfa);
589 void bfa_cb_rport_scn_no_dev(void *rp);
591  struct bfa_rport_qos_attr_s old_qos_attr,
592  struct bfa_rport_qos_attr_s new_qos_attr);
593 
594 /*
595  * Rport LUN masking related
596  */
597 #define BFA_RPORT_TAG_INVALID 0xffff
598 #define BFA_LP_TAG_INVALID 0xff
599 void bfa_rport_set_lunmask(struct bfa_s *bfa, struct bfa_rport_s *rp);
600 void bfa_rport_unset_lunmask(struct bfa_s *bfa, struct bfa_rport_s *rp);
601 
602 /*
603  * bfa fcxp API functions
604  */
605 struct bfa_fcxp_s *bfa_fcxp_req_rsp_alloc(void *bfad_fcxp, struct bfa_s *bfa,
606  int nreq_sgles, int nrsp_sgles,
607  bfa_fcxp_get_sgaddr_t get_req_sga,
608  bfa_fcxp_get_sglen_t get_req_sglen,
609  bfa_fcxp_get_sgaddr_t get_rsp_sga,
610  bfa_fcxp_get_sglen_t get_rsp_sglen,
612 void bfa_fcxp_req_rsp_alloc_wait(struct bfa_s *bfa, struct bfa_fcxp_wqe_s *wqe,
613  bfa_fcxp_alloc_cbfn_t alloc_cbfn,
614  void *cbarg, void *bfad_fcxp,
615  int nreq_sgles, int nrsp_sgles,
616  bfa_fcxp_get_sgaddr_t get_req_sga,
617  bfa_fcxp_get_sglen_t get_req_sglen,
618  bfa_fcxp_get_sgaddr_t get_rsp_sga,
619  bfa_fcxp_get_sglen_t get_rsp_sglen,
621 void bfa_fcxp_walloc_cancel(struct bfa_s *bfa,
622  struct bfa_fcxp_wqe_s *wqe);
623 void bfa_fcxp_discard(struct bfa_fcxp_s *fcxp);
624 
625 void *bfa_fcxp_get_reqbuf(struct bfa_fcxp_s *fcxp);
626 void *bfa_fcxp_get_rspbuf(struct bfa_fcxp_s *fcxp);
627 
628 void bfa_fcxp_free(struct bfa_fcxp_s *fcxp);
629 
630 void bfa_fcxp_send(struct bfa_fcxp_s *fcxp, struct bfa_rport_s *rport,
631  u16 vf_id, u8 lp_tag,
632  bfa_boolean_t cts, enum fc_cos cos,
633  u32 reqlen, struct fchs_s *fchs,
634  bfa_cb_fcxp_send_t cbfn,
635  void *cbarg,
636  u32 rsp_maxlen, u8 rsp_timeout);
638 u32 bfa_fcxp_get_reqbufsz(struct bfa_fcxp_s *fcxp);
639 u32 bfa_fcxp_get_maxrsp(struct bfa_s *bfa);
640 void bfa_fcxp_res_recfg(struct bfa_s *bfa, u16 num_fcxp_fw);
641 
642 static inline void *
643 bfa_uf_get_frmbuf(struct bfa_uf_s *uf)
644 {
645  return uf->data_ptr;
646 }
647 
648 static inline u16
649 bfa_uf_get_frmlen(struct bfa_uf_s *uf)
650 {
651  return uf->data_len;
652 }
653 
654 /*
655  * bfa uf API functions
656  */
657 void bfa_uf_recv_register(struct bfa_s *bfa, bfa_cb_uf_recv_t ufrecv,
658  void *cbarg);
659 void bfa_uf_free(struct bfa_uf_s *uf);
660 
661 /*
662  * bfa lport service api
663  */
664 
665 u32 bfa_lps_get_max_vport(struct bfa_s *bfa);
666 struct bfa_lps_s *bfa_lps_alloc(struct bfa_s *bfa);
667 void bfa_lps_delete(struct bfa_lps_s *lps);
668 void bfa_lps_flogi(struct bfa_lps_s *lps, void *uarg, u8 alpa,
671 void bfa_lps_fdisc(struct bfa_lps_s *lps, void *uarg, u16 pdusz,
672  wwn_t pwwn, wwn_t nwwn);
673 void bfa_lps_fdisclogo(struct bfa_lps_s *lps);
674 void bfa_lps_set_n2n_pid(struct bfa_lps_s *lps, u32 n2n_pid);
675 u8 bfa_lps_get_fwtag(struct bfa_s *bfa, u8 lp_tag);
676 u32 bfa_lps_get_base_pid(struct bfa_s *bfa);
677 u8 bfa_lps_get_tag_from_pid(struct bfa_s *bfa, u32 pid);
678 void bfa_cb_lps_flogi_comp(void *bfad, void *uarg, bfa_status_t status);
679 void bfa_cb_lps_flogo_comp(void *bfad, void *uarg);
680 void bfa_cb_lps_fdisc_comp(void *bfad, void *uarg, bfa_status_t status);
681 void bfa_cb_lps_fdisclogo_comp(void *bfad, void *uarg);
682 void bfa_cb_lps_cvl_event(void *bfad, void *uarg);
683 
684 /* FAA specific APIs */
685 bfa_status_t bfa_faa_query(struct bfa_s *bfa, struct bfa_faa_attr_s *attr,
686  bfa_cb_iocfc_t cbfn, void *cbarg);
687 
688 /*
689  * FC DIAG data structure
690  */
694  void *cbarg;
702 };
703 
706  void *cbarg;
707  void *result;
710 };
711 
712 struct bfa_dport_s {
713  struct bfa_s *bfa; /* Back pointer to BFA */
714  bfa_sm_t sm; /* finite state machine */
715  u32 msgtag; /* firmware msg tag for reply */
718  void *cbarg;
719 };
720 
721 struct bfa_fcdiag_s {
722  struct bfa_s *bfa; /* Back pointer to BFA */
727 };
728 
729 #define BFA_FCDIAG_MOD(__bfa) (&(__bfa)->modules.fcdiag)
730 
731 void bfa_fcdiag_intr(struct bfa_s *bfa, struct bfi_msg_s *msg);
732 
734  enum bfa_port_opmode opmode,
735  enum bfa_port_speed speed, u32 lpcnt, u32 pat,
737  bfa_cb_diag_t cbfn, void *cbarg);
738 bfa_status_t bfa_fcdiag_queuetest(struct bfa_s *bfa, u32 ignore,
740  bfa_cb_diag_t cbfn, void *cbarg);
743  void *cbarg);
745  void *cbarg);
747  enum bfa_dport_state *state);
748 
749 #endif /* __BFA_SVC_H__ */