2 * Copyright (c) 2005-2009 Brocade Communications Systems, Inc.
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.
19 * hal_sgpg.h BFA SG page module
22 #ifndef __BFA_SGPG_PRIV_H__
23 #define __BFA_SGPG_PRIV_H__
27 #define BFA_SGPG_MIN (16)
30 * Alignment macro for SG page allocation
32 #define BFA_SGPG_ROUNDUP(_l) (((_l) + (sizeof(struct bfi_sgpg_s) - 1)) \
33 & ~(sizeof(struct bfi_sgpg_s) - 1))
35 struct bfa_sgpg_wqe_s
{
36 struct list_head qe
; /* queue sg page element */
37 int nsgpg
; /* pages to be allocated */
38 int nsgpg_total
; /* total pages required */
39 void (*cbfn
) (void *cbarg
);
40 /* callback function */
41 void *cbarg
; /* callback arg */
42 struct list_head sgpg_q
; /* queue of alloced sgpgs */
46 struct list_head qe
; /* queue sg page element */
47 struct bfi_sgpg_s
*sgpg
; /* va of SG page */
48 union bfi_addr_u sgpg_pa
;/* pa of SG page */
52 * Given number of SG elements, BFA_SGPG_NPAGE() returns the number of
55 #define BFA_SGPG_NPAGE(_nsges) (((_nsges) / BFI_SGPG_DATA_SGES) + 1)
57 struct bfa_sgpg_mod_s
{
59 int num_sgpgs
; /* number of SG pages */
60 int free_sgpgs
; /* number of free SG pages */
61 struct bfa_sgpg_s
*hsgpg_arr
; /* BFA SG page array */
62 struct bfi_sgpg_s
*sgpg_arr
; /* actual SG page array */
63 u64 sgpg_arr_pa
; /* SG page array DMA addr */
64 struct list_head sgpg_q
; /* queue of free SG pages */
65 struct list_head sgpg_wait_q
; /* wait queue for SG pages */
67 #define BFA_SGPG_MOD(__bfa) (&(__bfa)->modules.sgpg_mod)
69 bfa_status_t
bfa_sgpg_malloc(struct bfa_s
*bfa
, struct list_head
*sgpg_q
,
71 void bfa_sgpg_mfree(struct bfa_s
*bfa
, struct list_head
*sgpg_q
,
73 void bfa_sgpg_winit(struct bfa_sgpg_wqe_s
*wqe
,
74 void (*cbfn
) (void *cbarg
), void *cbarg
);
75 void bfa_sgpg_wait(struct bfa_s
*bfa
, struct bfa_sgpg_wqe_s
*wqe
,
77 void bfa_sgpg_wcancel(struct bfa_s
*bfa
, struct bfa_sgpg_wqe_s
*wqe
);
79 #endif /* __BFA_SGPG_PRIV_H__ */