1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/netwerk/sctp/src/user_uma.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,98 @@ 1.4 +/*- 1.5 + * Copyright (c) 2009-2010 Brad Penoff 1.6 + * Copyright (c) 2009-2010 Humaira Kamal 1.7 + * Copyright (c) 2011-2012 Irene Ruengeler 1.8 + * Copyright (c) 2011-2012 Michael Tuexen 1.9 + * 1.10 + * All rights reserved. 1.11 + * 1.12 + * Redistribution and use in source and binary forms, with or without 1.13 + * modification, are permitted provided that the following conditions 1.14 + * are met: 1.15 + * 1. Redistributions of source code must retain the above copyright 1.16 + * notice, this list of conditions and the following disclaimer. 1.17 + * 2. Redistributions in binary form must reproduce the above copyright 1.18 + * notice, this list of conditions and the following disclaimer in the 1.19 + * documentation and/or other materials provided with the distribution. 1.20 + * 1.21 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1.22 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1.23 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1.24 + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1.25 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 1.26 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 1.27 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 1.28 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 1.29 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 1.30 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 1.31 + * SUCH DAMAGE. 1.32 + */ 1.33 + 1.34 +#ifndef _USER_UMA_H_ 1.35 +#define _USER_UMA_H_ 1.36 + 1.37 +#define UMA_ZFLAG_FULL 0x40000000 /* Reached uz_maxpages */ 1.38 +#define UMA_ALIGN_PTR (sizeof(void *) - 1) /* Alignment fit for ptr */ 1.39 + 1.40 +/* __Userspace__ All these definitions will change for 1.41 +userspace Universal Memory Allocator (UMA). These are included 1.42 +for reference purposes and to avoid compile errors for the time being. 1.43 +*/ 1.44 +typedef int (*uma_ctor)(void *mem, int size, void *arg, int flags); 1.45 +typedef void (*uma_dtor)(void *mem, int size, void *arg); 1.46 +typedef int (*uma_init)(void *mem, int size, int flags); 1.47 +typedef void (*uma_fini)(void *mem, int size); 1.48 +typedef struct uma_zone * uma_zone_t; 1.49 +typedef struct uma_keg * uma_keg_t; 1.50 + 1.51 +struct uma_cache { 1.52 + int stub; /* TODO __Userspace__ */ 1.53 +}; 1.54 + 1.55 +struct uma_keg { 1.56 + int stub; /* TODO __Userspace__ */ 1.57 +}; 1.58 + 1.59 +struct uma_zone { 1.60 + char *uz_name; /* Text name of the zone */ 1.61 + struct mtx *uz_lock; /* Lock for the zone (keg's lock) */ 1.62 + uma_keg_t uz_keg; /* Our underlying Keg */ 1.63 + 1.64 + LIST_ENTRY(uma_zone) uz_link; /* List of all zones in keg */ 1.65 + LIST_HEAD(,uma_bucket) uz_full_bucket; /* full buckets */ 1.66 + LIST_HEAD(,uma_bucket) uz_free_bucket; /* Buckets for frees */ 1.67 + 1.68 + uma_ctor uz_ctor; /* Constructor for each allocation */ 1.69 + uma_dtor uz_dtor; /* Destructor */ 1.70 + uma_init uz_init; /* Initializer for each item */ 1.71 + uma_fini uz_fini; /* Discards memory */ 1.72 + 1.73 + u_int64_t uz_allocs; /* Total number of allocations */ 1.74 + u_int64_t uz_frees; /* Total number of frees */ 1.75 + u_int64_t uz_fails; /* Total number of alloc failures */ 1.76 + uint16_t uz_fills; /* Outstanding bucket fills */ 1.77 + uint16_t uz_count; /* Highest value ub_ptr can have */ 1.78 + 1.79 + /* 1.80 + * This HAS to be the last item because we adjust the zone size 1.81 + * based on NCPU and then allocate the space for the zones. 1.82 + */ 1.83 + struct uma_cache uz_cpu[1]; /* Per cpu caches */ 1.84 +}; 1.85 + 1.86 +/* Prototype */ 1.87 +uma_zone_t 1.88 +uma_zcreate(char *name, size_t size, uma_ctor ctor, uma_dtor dtor, 1.89 + uma_init uminit, uma_fini fini, int align, u_int32_t flags); 1.90 + 1.91 + 1.92 +#define uma_zone_set_max(zone, number) /* stub TODO __Userspace__ */ 1.93 + 1.94 +uma_zone_t 1.95 +uma_zcreate(char *name, size_t size, uma_ctor ctor, uma_dtor dtor, 1.96 + uma_init uminit, uma_fini fini, int align, u_int32_t flags) 1.97 +{ 1.98 + return NULL; /* stub TODO __Userspace__. Also place implementation in a separate .c file */ 1.99 + 1.100 +} 1.101 +#endif