/*
 *------------------------------------------------------------------
 * Copyright (c) 2017 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 _MEMIF_H_
#define _MEMIF_H_

#ifndef MEMIF_CACHELINE_SIZE
#define MEMIF_CACHELINE_SIZE 64
#endif

#define MEMIF_COOKIE		0x3E31F10
#define MEMIF_VERSION_MAJOR	1
#define MEMIF_VERSION_MINOR	0
#define MEMIF_VERSION		((MEMIF_VERSION_MAJOR << 8) | MEMIF_VERSION_MINOR)

/*
 *  Type definitions
 */

typedef enum memif_msg_type
{
  MEMIF_MSG_TYPE_NONE = 0,
  MEMIF_MSG_TYPE_ACK = 1,
  MEMIF_MSG_TYPE_HELLO = 2,
  MEMIF_MSG_TYPE_INIT = 3,
  MEMIF_MSG_TYPE_ADD_REGION = 4,
  MEMIF_MSG_TYPE_ADD_RING = 5,
  MEMIF_MSG_TYPE_CONNECT = 6,
  MEMIF_MSG_TYPE_CONNECTED = 7,
  MEMIF_MSG_TYPE_DISCONNECT = 8,
} memif_msg_type_t;

typedef enum
{
  MEMIF_RING_S2M = 0,
  MEMIF_RING_M2S = 1
} memif_ring_type_t;

typedef enum
{
  MEMIF_INTERFACE_MODE_ETHERNET = 0,
  MEMIF_INTERFACE_MODE_IP = 1,
  MEMIF_INTERFACE_MODE_PUNT_INJECT = 2,
} memif_interface_mode_t;

typedef uint16_t memif_region_index_t;
typedef uint64_t memif_region_offset_t;
typedef uint64_t memif_region_size_t;
typedef uint16_t memif_ring_index_t;
typedef uint32_t memif_interface_id_t;
typedef uint16_t memif_version_t;
typedef uint8_t memif_log2_ring_size_t;

/*
 *  Socket messages
 */

typedef struct __attribute__ ((packed))
{
  uint8_t name[32];
  memif_version_t min_version;
  memif_version_t max_version;
  memif_region_index_t max_region;
  memif_ring_index_t max_m2s_ring;
  memif_ring_index_t max_s2m_ring;
  memif_log2_ring_size_t max_log2_ring_size;
} memif_msg_hello_t;

typedef struct __attribute__ ((packed))
{
  memif_version_t version;
  memif_interface_id_t id;
  memif_interface_mode_t mode:8;
  uint8_t secret[24];
  uint8_t name[32];
} memif_msg_init_t;

typedef struct __attribute__ ((packed))
{
  memif_region_index_t index;
  memif_region_size_t size;
} memif_msg_add_region_t;

typedef struct __attribute__ ((packed))
{
  uint16_t flags;
#define MEMIF_MSG_ADD_RING_FLAG_S2M	(1 << 0)
  memif_ring_index_t index;
  memif_region_index_t region;
  memif_region_offset_t offset;
  memif_log2_ring_size_t log2_ring_size;
} memif_msg_add_ring_t;

typedef struct __attribute__ ((packed))
{
  uint8_t if_name[32];
} memif_msg_connect_t;

typedef struct __attribute__ ((packed))
{
  uint8_t if_name[32];
} memif_msg_connected_t;

typedef struct __attribute__ ((packed))
{
  uint32_t code;
  uint8_t string[96];
} memif_msg_disconnect_t;

typedef struct __attribute__ ((packed, aligned (128)))
{
  memif_msg_type_t type:16;
  union
  {
    memif_msg_hello_t hello;
    memif_msg_init_t init;
    memif_msg_add_region_t add_region;
    memif_msg_add_ring_t add_ring;
    memif_msg_connect_t connect;
    memif_msg_connected_t connected;
    memif_msg_disconnect_t disconnect;
  };
} memif_msg_t;

_Static_assert (sizeof (memif_msg_t) == 128,
		"Size of memif_msg_t must be 128");

/*
 *  Ring and Descriptor Layout
 */

typedef struct __attribute__ ((packed))
{
  uint16_t flags;
#define MEMIF_DESC_FLAG_NEXT (1 << 0)
  memif_region_index_t region;
  uint32_t buffer_length;
  uint32_t length;
  uint8_t reserved[4];
  memif_region_offset_t offset;
  uint64_t metadata;
} memif_desc_t;

_Static_assert (sizeof (memif_desc_t) == 32,
		"Size of memif_dsct_t must be 32");

#define MEMIF_CACHELINE_ALIGN_MARK(mark) \
  uint8_t mark[0] __attribute__((aligned(MEMIF_CACHELINE_SIZE)))

typedef struct
{
  MEMIF_CACHELINE_ALIGN_MARK (cacheline0);
  uint32_t cookie;
  uint16_t flags;
#define MEMIF_RING_FLAG_MASK_INT 1
  volatile uint16_t head;
    MEMIF_CACHELINE_ALIGN_MARK (cacheline1);
  volatile uint16_t tail;
    MEMIF_CACHELINE_ALIGN_MARK (cacheline2);
  memif_desc_t desc[0];
} memif_ring_t;

#endif /* _MEMIF_H_ */

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