/*
 * Copyright (c) 2015 Cisco and/or its affiliates.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at:
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/*
  Copyright (c) 2001, 2002, 2003 Eliot Dresselhaus

  Permission is hereby granted, free of charge, to any person obtaining
  a copy of this software and associated documentation files (the
  "Software"), to deal in the Software without restriction, including
  without limitation the rights to use, copy, modify, merge, publish,
  distribute, sublicense, and/or sell copies of the Software, and to
  permit persons to whom the Software is furnished to do so, subject to
  the following conditions:

  The above copyright notice and this permission notice shall be
  included in all copies or substantial portions of the Software.

  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

/* Heaps of objects of type T (e.g. int, struct foo, ...).

   Usage.  To declare a null heap:

     T * heap = 0;

   To allocate:

     offset = heap_alloc (heap, size, handle);

   New object is heap[offset] ... heap[offset + size]
   Handle is used to free/query object.

   To free object:

     heap_dealloc (heap, handle);

   To query the size of an object:

     heap_size (heap, handle)

*/

#ifndef included_heap_h
#define included_heap_h

#include <vppinfra/clib.h>
#include <vppinfra/cache.h>
#include <vppinfra/hash.h>
#include <vppinfra/format.h>
#include <vppinfra/bitmap.h>

/* Doubly linked list of elements. */
typedef struct
{
  /* Offset of this element (plus free bit).
     If element is free, data at offset contains pointer to free list. */
  u32 offset;

  /* Index of next and previous elements relative to current element. */
  i32 next, prev;
} heap_elt_t;

/* Use high bit of offset as free bit. */
#define HEAP_ELT_FREE_BIT	(1 << 31)

always_inline uword
heap_is_free (heap_elt_t * e)
{
  return (e->offset & HEAP_ELT_FREE_BIT) != 0;
}

always_inline uword
heap_offset (heap_elt_t * e)
{
  return e->offset & ~HEAP_ELT_FREE_BIT;
}

always_inline heap_elt_t *
heap_next (heap_elt_t * e)
{
  return e + e->next;
}

always_inline heap_elt_t *
heap_prev (heap_elt_t * e)
{
  return e + e->prev;
}

always_inline uword
heap_elt_size (void *v, heap_elt_t * e)
{
  heap_elt_t *n = heap_next (e);
  uword next_offset = n != e ? heap_offset (n) : vec_len (v);
  return next_offset - heap_offset (e);
}

/* Sizes are binned.  Sizes 1 to 2^log2_small_bins have their
   own free lists.  Larger sizes are grouped in powers of two. */
#define HEAP_LOG2_SMALL_BINS	(5)
#define HEAP_SMALL_BINS		(1 << HEAP_LOG2_SMALL_BINS)
#define HEAP_N_BINS		(2 * HEAP_SMALL_BINS)

/* Header for heaps. */
typedef struct
{
  /* Vector of used and free elements. */
  heap_elt_t *elts;

  /* For elt_bytes < sizeof (u32) we need some extra space
     per elt to store free list index. */
  u32 *small_free_elt_free_index;

  /* Vector of free indices of elts array. */
  u32 *free_elts;

  /* Indices of free elts indexed by size bin. */
  u32 **free_lists;

  format_function_t *format_elt;

  /* Used for validation/debugging. */
  uword *used_elt_bitmap;

  /* First and last element of doubly linked chain of elements. */
  u32 head, tail;

  u32 used_count, max_len;

  /* Number of bytes in a help element. */
  u32 elt_bytes;

  u32 flags;
  /* Static heaps are made from external memory given to
     us by user and are not re-sizable vectors. */
#define HEAP_IS_STATIC (1)
} heap_header_t;

/* Start of heap elements is always cache aligned. */
#define HEAP_DATA_ALIGN (CLIB_CACHE_LINE_BYTES)

always_inline heap_header_t *
heap_header (void *v)
{
  return vec_header (v);
}

always_inline void
heap_dup_header (heap_header_t * old, heap_header_t * new)
{
  uword i;

  new[0] = old[0];
  new->elts = vec_dup (new->elts);
  new->free_elts = vec_dup (new->free_elts);
  new->free_lists = vec_dup (new->free_lists);
  for (i = 0; i < vec_len (new->free_lists); i++)
    new->free_lists[i] = vec_dup (new->free_lists[i]);
  new->used_elt_bitmap = clib_bitmap_dup (new->used_elt_bitmap);
  new->small_free_elt_free_index = vec_dup (new->small_free_elt_free_index);
}

/* Make a duplicate copy of a heap. */
#define heap_dup(v) _heap_dup(v, vec_len (v) * sizeof (v[0]))

always_inline void *
_heap_dup (void *v_old, uword v_bytes)
{
  heap_header_t *h_old, *h_new;
  vec_attr_t va = { .align = HEAP_DATA_ALIGN,
		    .hdr_sz = sizeof (heap_header_t),
		    .elt_sz = 1 };
  void *v_new;

  h_old = heap_header (v_old);

  if (!v_old)
    return v_old;

  v_new = _vec_alloc_internal (_vec_len (v_old), &va);
  h_new = heap_header (v_new);
  heap_dup_header (h_old, h_new);
  clib_memcpy_fast (v_new, v_old, v_bytes);
  return v_new;
}

always_inline uword
heap_elts (void *v)
{
  heap_header_t *h = heap_header (v);
  return h->used_count;
}

uword heap_bytes (void *v);

always_inline void *
_heap_new (u32 len, u32 n_elt_bytes)
{
  vec_attr_t va = { .align = HEAP_DATA_ALIGN,
		    .hdr_sz = sizeof (heap_header_t),
		    .elt_sz = n_elt_bytes };
  void *v = _vec_alloc_internal (len, &va);
  heap_header (v)->elt_bytes = n_elt_bytes;
  return v;
}

#define heap_new(v) (v) = _heap_new (0, sizeof ((v)[0]))

always_inline void
heap_set_format (void *v, format_function_t * format_elt)
{
  ASSERT (v);
  heap_header (v)->format_elt = format_elt;
}

always_inline void
heap_set_max_len (void *v, uword max_len)
{
  ASSERT (v);
  heap_header (v)->max_len = max_len;
}

always_inline uword
heap_get_max_len (void *v)
{
  return v ? heap_header (v)->max_len : 0;
}

/* Execute BODY for each allocated heap element. */
#define heap_foreach(var,len,heap,body)			\
do {							\
  if (vec_len (heap) > 0)				\
    {							\
      heap_header_t * _h = heap_header (heap);		\
      heap_elt_t * _e   = _h->elts + _h->head;		\
      heap_elt_t * _end = _h->elts + _h->tail;		\
      while (1)						\
	{						\
	  if (! heap_is_free (_e))			\
	    {						\
	      (var) = (heap) + heap_offset (_e);	\
	      (len) = heap_elt_size ((heap), _e);	\
	      do { body; } while (0);			\
	    }						\
	  if (_e == _end)				\
	    break;					\
	  _e = heap_next (_e);				\
	}						\
    }							\
} while (0)

#define heap_elt_at_index(v,index) vec_elt_at_index(v,index)

always_inline heap_elt_t *
heap_get_elt (void *v, uword handle)
{
  heap_header_t *h = heap_header (v);
  heap_elt_t *e = vec_elt_at_index (h->elts, handle);
  ASSERT (!heap_is_free (e));
  return e;
}

#define heap_elt_with_handle(v,handle)			\
({							\
  heap_elt_t * _e = heap_get_elt ((v), (handle));	\
  (v) + heap_offset (_e);				\
})

always_inline uword
heap_is_free_handle (void *v, uword heap_handle)
{
  heap_header_t *h = heap_header (v);
  heap_elt_t *e = vec_elt_at_index (h->elts, heap_handle);
  return heap_is_free (e);
}

extern uword heap_len (void *v, word handle);

/* Low level allocation call. */
extern void *_heap_alloc (void *v, uword size, uword alignment,
			  uword elt_bytes, uword * offset, uword * handle);

#define heap_alloc_aligned(v,size,align,handle)			\
({								\
  uword _o, _h;							\
  uword _a = (align);						\
  uword _s = (size);						\
  (v) = _heap_alloc ((v), _s, _a, sizeof ((v)[0]), &_o, &_h);	\
  (handle) = _h;						\
  _o;								\
})

#define heap_alloc(v,size,handle) heap_alloc_aligned((v),(size),0,(handle))

extern void heap_dealloc (void *v, uword handle);
extern void heap_validate (void *v);

/* Format heap internal data structures as string. */
extern u8 *format_heap (u8 * s, va_list * va);

void *_heap_free (void *v);

#define heap_free(v) (v)=_heap_free(v)

#endif /* included_heap_h */

/*
 * fd.io coding-style-patch-verification: ON
 *
 * Local Variables:
 * eval: (c-set-style "gnu")
 * End:
 */
