/*
 * 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.
 */
#ifndef __included_ssvm_h__
#define __included_ssvm_h__

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <netinet/in.h>
#include <signal.h>
#include <pthread.h>
#include <unistd.h>
#include <time.h>
#include <fcntl.h>
#include <string.h>
#include <vppinfra/clib.h>
#include <vppinfra/vec.h>
#include <vppinfra/hash.h>
#include <vppinfra/bitmap.h>
#include <vppinfra/fifo.h>
#include <vppinfra/time.h>
#include <vppinfra/mheap.h>
#include <vppinfra/heap.h>
#include <vppinfra/pool.h>
#include <vppinfra/format.h>

#define MMAP_PAGESIZE (4<<10)
#define SSVM_N_OPAQUE 7

typedef struct {
  /* Spin-lock */
  volatile u32 lock;
  volatile u32 owner_pid;
  int recursion_count;
  u32 tag;                      /* for debugging */

  /* The allocation arena */
  void * heap;

  /* Segment must be mapped at this address, or no supper */
  u64 ssvm_va;
  /* The actual mmap size */
  u64 ssvm_size;
  u32 master_pid;
  u32 slave_pid;
  u8 * name;
  void * opaque [SSVM_N_OPAQUE];

  /* Set when the master application thinks it's time to make the donuts */
  volatile u32 ready;

  /* Needed to make unique MAC addresses, etc. */
  u32 master_index;
} ssvm_shared_header_t;

typedef struct {
  ssvm_shared_header_t * sh;
  u64 ssvm_size;
  u32 my_pid;
  u32 vlib_hw_if_index;
  u8 * name;
  u64 requested_va;
  int i_am_master;
  u32 per_interface_next_index;
  u32 * rx_queue;
} ssvm_private_t;

always_inline void ssvm_lock (ssvm_shared_header_t * h, u32 my_pid, u32 tag)
{
  if (h->owner_pid == my_pid)
    {
      h->recursion_count++;
      return;
    }
  
  while (__sync_lock_test_and_set (&h->lock, 1))
    ;
  
  h->owner_pid = my_pid;
  h->recursion_count = 1;
  h->tag = tag;
}

always_inline void ssvm_unlock (ssvm_shared_header_t * h)
{
  if (--h->recursion_count == 0)
    {
      h->owner_pid = 0;
      h->tag = 0;
      CLIB_MEMORY_BARRIER();
      h->lock = 0;
    }
}

static inline void *ssvm_push_heap (ssvm_shared_header_t *sh)
{
    u8 *oldheap;
    oldheap = clib_mem_set_heap(sh->heap);
    return ((void *) oldheap);
}

static inline void ssvm_pop_heap (void *oldheap)
{
    clib_mem_set_heap(oldheap);
}

#define foreach_ssvm_api_error                  \
_(NO_NAME, "No shared segment name", -10)       \
_(NO_SIZE, "Size not set (master)", -11)        \
_(CREATE_FAILURE, "Create failed", -12)		\
_(SET_SIZE, "Set size failed", -13)		\
_(MMAP, "mmap failed", -14)			\
_(SLAVE_TIMEOUT, "Slave map timeout", -15)

typedef enum {
#define _(n,s,c) SSVM_API_ERROR_##n = c,
  foreach_ssvm_api_error
#undef _
} ssvm_api_error_enum_t;

#define SSVM_API_ERROR_NO_NAME	(-10)

int ssvm_master_init (ssvm_private_t * ssvm, u32 master_index);
int ssvm_slave_init (ssvm_private_t * ssvm, int timeout_in_seconds);

#endif /* __included_ssvm_h__ */
