~ubuntu-branches/ubuntu/vivid/bcmwl/vivid-proposed

« back to all changes in this revision

Viewing changes to src/src/shared/bcm_mpool_pri.h

  • Committer: Package Import Robot
  • Author(s): Alberto Milone
  • Date: 2012-12-11 17:06:22 UTC
  • mfrom: (2.1.6)
  • Revision ID: package-import@ubuntu.com-20121211170622-7bd9yp2wm1plhhu1
Tags: 6.20.155.1+bdcom-0ubuntu1
* New upstream release (LP: #923809):
  - Added 43142 support.
  - Added 4331 support.
* debian/control:
  - depend on the different flavours of the linux-headers.
* Refresh 0002-Makefile.patch and 0001-MODULE_LICENSE.patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *
 
3
 * Memory pool type definitions
 
4
 *
 
5
 * Prealloc memory pools:
 
6
 *    These memory pools are memory allocators based on subdividing a single
 
7
 *    block of memory into homogenous objects. It's suitable for data structures
 
8
 *    with a statically configured maximum # of objects, such as using tunable
 
9
 *    parameters. It's not suitable for heterogenous data structures nor for
 
10
 *    data structures where the maximum count is unbounded.
 
11
 *
 
12
 *    Since the memory for all the objects is preallocated during initialization,
 
13
 *    that memory is unavailable to the rest of the system. This is appropriate both for
 
14
 *    small data structures, and for medium/large data structures where the peak and average
 
15
 *    utilization are similar. For data structures where average utilization is low but peak
 
16
 *    is very high, it's better to use the real heap so the memory gets freed when it's
 
17
 *    not in use.
 
18
 *
 
19
 *    Each individual memory pool can obtain it's memory from the user/client
 
20
 *    code or from the heap, as desired.
 
21
 *
 
22
 *
 
23
 * Heap memory pools:
 
24
 *    The memory pool allocator uses the heap (malloc/free) for memory.
 
25
 *    In this case, the pool allocator is just providing statistics and instrumentation
 
26
 *    on top of the heap, without modifying the heap allocation implementation.
 
27
 *
 
28
 * The memory pool component consists of two major abstractions:
 
29
 *     Manager: the factory for memory pools
 
30
 *     Pool: an individual pool that can allocate objects
 
31
 *
 
32
 * The memory pool manager maintains an array of individual pools so that instrumentation
 
33
 * can examine and manage all of them globally.
 
34
 *
 
35
 * Copyright (C) 2011, Broadcom Corporation. All Rights Reserved.
 
36
 * 
 
37
 * Permission to use, copy, modify, and/or distribute this software for any
 
38
 * purpose with or without fee is hereby granted, provided that the above
 
39
 * copyright notice and this permission notice appear in all copies.
 
40
 * 
 
41
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 
42
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 
43
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
 
44
 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 
45
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
 
46
 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
 
47
 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
48
 *
 
49
 * $Id$
 
50
 */
 
51
 
 
52
#ifndef _BCM_MPOOL_PRI_H
 
53
#define _BCM_MPOOL_PRI_H 1
 
54
 
 
55
#include "osl.h"
 
56
#include "typedefs.h"
 
57
#include "bcm_mpool_pub.h"
 
58
 
 
59
typedef struct bcm_mp_free_list {
 
60
        struct bcm_mp_free_list *next;  
 
61
} bcm_mp_free_list_t;
 
62
 
 
63
typedef struct bcm_mp_prealloc_pool {
 
64
 
 
65
        uint16             nobj;             
 
66
        unsigned int       padded_objsz;     
 
67
        void               *malloc_memstart; 
 
68
        bcm_mp_free_list_t *free_objp;       
 
69
} bcm_mp_prealloc_pool_t;
 
70
 
 
71
typedef struct bcm_mp_heap_pool {
 
72
 
 
73
        osl_t *osh;   
 
74
} bcm_mp_heap_pool_t;
 
75
 
 
76
typedef struct bcm_mp_pool {
 
77
 
 
78
        char   name[BCM_MP_NAMELEN];      
 
79
        unsigned int objsz;               
 
80
        uint16 num_alloc;                 
 
81
        uint16 high_water;                
 
82
        uint16 failed_alloc;              
 
83
        uint16 flags;                     
 
84
 
 
85
        union {
 
86
                bcm_mp_prealloc_pool_t p;  
 
87
                bcm_mp_heap_pool_t     h;  
 
88
        } u;
 
89
} bcm_mp_pool_t;
 
90
 
 
91
#define BCM_MP_TYPE_MASK     0x0003 
 
92
#define BCM_MP_TYPE_HEAP     0      
 
93
#define BCM_MP_TYPE_PREALLOC 1      
 
94
 
 
95
#define BCM_MP_GET_POOL_TYPE(pool) (((pool)->flags) & BCM_MP_TYPE_MASK)
 
96
#define BCM_MP_SET_POOL_TYPE(pool, type) ((pool)->flags = ((pool)->flags & ~BCM_MP_TYPE_MASK) \
 
97
                                                           | (type))
 
98
 
 
99
#define BCM_MP_POOL_IN_USE_MASK 0x0004
 
100
 
 
101
#define BCM_MP_SET_IN_USE(pool) ((pool)->flags |= BCM_MP_POOL_IN_USE_MASK)
 
102
#define BCM_MP_CLEAR_IN_USE(pool) ((pool)->flags &= ~BCM_MP_POOL_IN_USE_MASK)
 
103
#define BCM_MP_IS_IN_USE(pool) (((pool)->flags & BCM_MP_POOL_IN_USE_MASK) == \
 
104
                                                 BCM_MP_POOL_IN_USE_MASK)
 
105
 
 
106
typedef struct bcm_mpm_mgr {
 
107
        bcm_mp_pool_t      *pool_objs;   
 
108
        bcm_mp_free_list_t *free_pools;  
 
109
        uint16             npools;       
 
110
        uint16             max_pools;    
 
111
        osl_t              *osh;         
 
112
} bcm_mpm_mgr_t;
 
113
 
 
114
#endif