2 * Copyright(c) 2002-2011 Exar Corp.
5 * Redistribution and use in source and binary forms, with or without
6 * modification are permitted provided the following conditions are met:
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the Exar Corporation nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
33 #ifndef VXGE_HAL_BLOCKPOOL_H
34 #define VXGE_HAL_BLOCKPOOL_H
39 * struct __hal_blockpool_entry_t - Block private data structure
40 * @item: List header used to link.
41 * @length: Length of the block
42 * @memblock: Virtual address block
43 * @dma_addr: DMA Address of the block.
44 * @dma_handle: DMA handle of the block.
45 * @acc_handle: DMA acc handle
47 * Block is allocated with a header to put the blocks into list.
50 typedef struct __hal_blockpool_entry_t {
56 pci_dma_acc_h acc_handle;
57 } __hal_blockpool_entry_t;
60 * struct __hal_blockpool_t - Block Pool
62 * @block_size: size of each block.
63 * @Pool_size: Number of blocks in the pool
64 * @pool_incr: Number of blocks to be requested/freed at a time from OS
65 * @pool_min: Minimum number of block below which to request additional blocks
66 * @pool_max: Maximum number of blocks above which to free additional blocks
67 * @req_out: Number of block requests with OS out standing
68 * @dma_flags: DMA flags
69 * @free_block_list: List of free blocks
70 * @pool_lock: Spin lock for the pool
72 * Block pool contains the DMA blocks preallocated.
75 typedef struct __hal_blockpool_t {
76 vxge_hal_device_h hldev;
84 vxge_list_t free_block_list;
85 vxge_list_t free_entry_list;
87 #if defined(VXGE_HAL_BP_POST) || defined(VXGE_HAL_BP_POST_IRQ)
94 __hal_blockpool_create(vxge_hal_device_h hldev,
95 __hal_blockpool_t *blockpool,
102 __hal_blockpool_destroy(__hal_blockpool_t *blockpool);
104 __hal_blockpool_entry_t *
105 __hal_blockpool_block_allocate(vxge_hal_device_h hldev,
109 __hal_blockpool_block_free(vxge_hal_device_h hldev,
110 __hal_blockpool_entry_t *entry);
113 __hal_blockpool_malloc(vxge_hal_device_h hldev,
115 dma_addr_t *dma_addr,
116 pci_dma_h *dma_handle,
117 pci_dma_acc_h *acc_handle);
120 __hal_blockpool_free(vxge_hal_device_h hldev,
123 dma_addr_t *dma_addr,
124 pci_dma_h *dma_handle,
125 pci_dma_acc_h *acc_handle);
128 __hal_blockpool_list_allocate(vxge_hal_device_h hldev,
129 vxge_list_t *blocklist, u32 count);
132 __hal_blockpool_list_free(vxge_hal_device_h hldev,
133 vxge_list_t *blocklist);
137 #endif /* VXGE_HAL_BLOCKPOOL_H */