/*
 * Copyright (c) 2016-2019 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_fifo_segment_h__
#define __included_fifo_segment_h__

#include <svm/ssvm.h>
#include <svm/fifo_types.h>
#include <svm/message_queue.h>
#include <svm/svm_fifo.h>

#define FIFO_SEGMENT_ALLOC_OVERHEAD (2 * clib_mem_get_page_size ())

typedef enum
{
  FIFO_SEGMENT_FTYPE_NONE = -1,
  FIFO_SEGMENT_RX_FIFO = 0,
  FIFO_SEGMENT_TX_FIFO,
  FIFO_SEGMENT_N_FTYPES
} fifo_segment_ftype_t;

#define FIFO_SEGMENT_MIN_LOG2_FIFO_SIZE 12	/**< 4kB min fifo size */
#define FIFO_SEGMENT_MIN_FIFO_SIZE 4096		/**< 4kB min fifo size */
#define FIFO_SEGMENT_MAX_FIFO_SIZE (2ULL << 30)	/**< 2GB max fifo size */
#define FIFO_SEGMENT_ALLOC_BATCH_SIZE 32	/* Allocation quantum */

typedef enum fifo_segment_flags_
{
  FIFO_SEGMENT_F_IS_PREALLOCATED = 1 << 0,
  FIFO_SEGMENT_F_WILL_DELETE = 1 << 1,
  FIFO_SEGMENT_F_MEM_LIMIT = 1 << 2,
  FIFO_SEGMENT_F_CUSTOM_USE = 1 << 3,
} fifo_segment_flags_t;

#define foreach_segment_mem_status	\
_(NO_PRESSURE, "No pressure")		\
_(LOW_PRESSURE, "Low pressure")		\
_(HIGH_PRESSURE, "High pressure")	\
_(NO_MEMORY, "No memory")

typedef enum
{
#define _(sym,str)  MEMORY_PRESSURE_##sym,
  foreach_segment_mem_status
#undef _
    MEMORY_N_PRESSURE,
} fifo_segment_mem_status_t;

#if 0
typedef enum fifo_segment_mem_status_
{
  MEMORY_PRESSURE_NO_PRESSURE,
  MEMORY_PRESSURE_LOW_PRESSURE,
  MEMORY_PRESSURE_HIGH_PRESSURE,
  MEMORY_PRESSURE_NO_MEMORY,
} fifo_segment_mem_status_t;
#endif

typedef struct
{
  ssvm_private_t ssvm;		/**< ssvm segment data */
  fifo_segment_header_t *h;	/**< fifo segment data */
  fifo_slice_private_t *slices; /**< private slice information */
  svm_msg_q_t *mqs;		/**< private vec of attached mqs */
  uword max_byte_index;		/**< max byte index for segment */
  u32 sm_index;			/**< owner segment manager index */
  u32 fs_index;			/**< fs index in sm pool */
  u8 n_slices;			/**< number of fifo segment slices */
  u8 flags;			/**< private fifo segment flags */
  u8 high_watermark;		/**< memory pressure watermark high */
  u8 low_watermark;		/**< memory pressure watermark low */
} fifo_segment_t;

typedef struct
{
  fifo_segment_t *segments;	/**< pool of fifo segments */
  uword next_baseva;		/**< Where to put the next one */
  u32 timeout_in_seconds;	/**< Time to wait during attach */
} fifo_segment_main_t;

typedef struct
{
  ssvm_segment_type_t segment_type;	/**< type of segment requested */
  u32 segment_size;			/**< size of the segment */
  int memfd_fd;				/**< fd for memfd segments */
  char *segment_name;			/**< segment name */
  u32 *new_segment_indices;		/**< return vec of new seg indices */
} fifo_segment_create_args_t;

#define fifo_segment_flags(_fs) _fs->flags

int fifo_segment_init (fifo_segment_t * fs);
int fifo_segment_create (fifo_segment_main_t * sm,
			 fifo_segment_create_args_t * a);
int fifo_segment_attach (fifo_segment_main_t * sm,
			 fifo_segment_create_args_t * a);
void fifo_segment_delete (fifo_segment_main_t * sm, fifo_segment_t * fs);
void fifo_segment_cleanup (fifo_segment_t *fs);
fifo_segment_t *fifo_segment_get_segment (fifo_segment_main_t * sm,
					  u32 fs_index);
fifo_segment_t *fifo_segment_get_segment_if_valid (fifo_segment_main_t *sm,
						   u32 segment_index);
u32 fifo_segment_index (fifo_segment_main_t * sm, fifo_segment_t * fs);
void fifo_segment_info (fifo_segment_t * seg, char **address, size_t * size);

always_inline void *
fifo_segment_ptr (fifo_segment_t *fs, uword offset)
{
  return (void *) ((u8 *) fs->h + offset);
}

always_inline uword
fifo_segment_offset (fifo_segment_t *fs, void *p)
{
  return (uword) ((u8 *) p - (u8 *) fs->h);
}

/**
 * Allocate fifo in fifo segment
 *
 * @param fs		fifo segment for fifo
 * @param data_bytes	size of default fifo chunk in bytes
 * @param ftype		fifo type @ref fifo_segment_ftype_t
 * @return		new fifo or 0 if alloc failed
 */
svm_fifo_t *fifo_segment_alloc_fifo_w_slice (fifo_segment_t * fs,
					     u32 slice_index,
					     u32 data_bytes,
					     fifo_segment_ftype_t ftype);
svm_fifo_t *fifo_segment_alloc_fifo_w_offset (fifo_segment_t *fs,
					      uword offset);
svm_fifo_t *fifo_segment_duplicate_fifo (fifo_segment_t *fs, svm_fifo_t *f);

/**
 * Free fifo allocated in fifo segment
 *
 * @param fs		fifo segment for fifo
 * @param f		fifo to be freed
 */
void fifo_segment_free_fifo (fifo_segment_t * fs, svm_fifo_t * f);

/**
 * Free fifo allocated by external applications
 *
 * @params fs		fifo segment for fifo
 * @param f		fifo to be freed
 */
void fifo_segment_free_client_fifo (fifo_segment_t *fs, svm_fifo_t *f);

void fifo_segment_detach_fifo (fifo_segment_t *fs, svm_fifo_t **f);
void fifo_segment_attach_fifo (fifo_segment_t *fs, svm_fifo_t **f,
			       u32 slice_index);
uword fifo_segment_fifo_offset (svm_fifo_t *f);

/**
 * Allocate message queue on segment
 *
 * @param fs		fifo segment for mq
 * @param mq_index	index in private mqs vector to use to attach
 * @param cfg		configuration for mq
 * @return		attached message queue
 */
svm_msg_q_t *fifo_segment_msg_q_alloc (fifo_segment_t *fs, u32 mq_index,
				       svm_msg_q_cfg_t *cfg);

/**
 *  Attach message queue at fifo segment offset
 *
 *  @param fs		fifo segment for mq
 *  @param offset	offset for shared mq on the segment
 *  @param mq_index	index in private mqs vector to use to attach
 *  @return		attached message queue
 */
svm_msg_q_t *fifo_segment_msg_q_attach (fifo_segment_t *fs, uword offset,
					u32 mq_index);

/**
 *  Discover mqs on mq only segment
 *
 *  @param fs		fifo segment for mq
 *  @param fds  	array of fds is mqs use eventfds
 *  @param n_fds	number of fds
 */
void fifo_segment_msg_qs_discover (fifo_segment_t *fs, int *fds, u32 n_fds);

/**
 * Message queue offset on segment
 *
 * @param fs		fifo segment for mq
 * @param mq_index	index of mq in private mqs vector
 * @return		offset of the shared mq the private mq is attached to
 */
uword fifo_segment_msg_q_offset (fifo_segment_t *fs, u32 mq_index);

/**
 * Try to preallocate fifo headers
 *
 * Tries to preallocate fifo headers and adds them to freelist.
 *
 * @param fs		fifo segment
 * @param batch_size	number of chunks to be allocated
 * @return		0 on success, negative number otherwise
 */
int fifo_segment_prealloc_fifo_hdrs (fifo_segment_t * fs, u32 slice_index,
				     u32 batch_size);

/**
 * Try to preallocate fifo chunks on segment
 *
 * Tries to preallocate chunks of requested size on segment and adds them
 * to chunk freelist.
 *
 * @param fs		fifo segment
 * @param chunk_size	size of chunks to be allocated in bytes
 * @param batch_size	number of chunks to be allocated
 * @return		0 on success, negative number otherwise
 */
int fifo_segment_prealloc_fifo_chunks (fifo_segment_t * fs, u32 slice_index,
				       u32 chunk_size, u32 batch_size);
/**
 * Pre-allocates fifo pairs in fifo segment
 *
 * The number of fifos pre-allocated is the minimum of the requested number
 * of pairs and the maximum number that fit within the segment. If the maximum
 * is hit, the number of fifo pairs requested is updated by subtracting the
 * number of fifos that have been successfully allocated.
 *
 * @param fs		fifo segment for fifo
 * @param rx_fifo_size	data size of rx fifos
 * @param tx_fifo_size	data size of tx fifos
 * @param n_fifo_pairs	number of pairs requested. Prior to returning, this
 * 			is decremented by the the number of pairs allocated.
 */
void fifo_segment_preallocate_fifo_pairs (fifo_segment_t * fs,
					  u32 rx_fifo_size,
					  u32 tx_fifo_size,
					  u32 * n_fifo_pairs);

/**
 * Allocate chunks in fifo segment
 *
 * @param fsh		fifo segment header
 * @param slice_index	slice where chunks should be alocated
 * @param chunk_size	chunk size needed
 * @return		chunk (or chunks) that cover at least chunk_size bytes
 * 			on success, 0 on failure.
 */
svm_fifo_chunk_t *fsh_alloc_chunk (fifo_segment_header_t * fsh,
				   u32 slice_index, u32 chunk_size);

/**
 * Return chunks to fifo segment
 *
 * @param fsh		fifo segment header
 * @param slice_index	slice where chunks should be returned
 * @param c		pointer to first chunk in 0 terminated linked list
 */
void fsh_collect_chunks (fifo_segment_header_t * fsh, u32 slice_index,
			 svm_fifo_chunk_t * c);

/**
 * Fifo segment reset mem limit flag
 *
 * @param fs            fifo segment
 * @param size		size requested
 * @return		pointer to memory allocated or 0
 */
void *fifo_segment_alloc (fifo_segment_t *fs, uword size);
/**
 * Fifo segment allocated size
 *
 * Returns fifo segment's allocated size
 *
 * @param fs            fifo segment
 * @return              allocated size in bytes
 */
uword fifo_segment_size (fifo_segment_t * fs);

/**
 * Fifo segment estimate of number of free bytes
 *
 * Returns fifo segment's internal estimate of the number of free bytes.
 * To force a synchronization between the segment and the underlying
 * memory allocator, call @ref fifo_segment_update_free_bytes
 *
 * @param fs		fifo segment
 * @return		free bytes estimate
 */
uword fifo_segment_free_bytes (fifo_segment_t * fs);

/**
 * Fifo segment number of cached bytes
 *
 * Returns fifo segment's number of cached bytes.
 *
 * @param fs            fifo segment
 * @return              cached bytes
 */
uword fifo_segment_cached_bytes (fifo_segment_t * fs);

uword fifo_segment_available_bytes (fifo_segment_t * fs);

/**
 * Number of bytes on chunk free lists
 *
 * @param fs		fifo segment
 * @return		free bytes on chunk free lists
 */
uword fifo_segment_fl_chunk_bytes (fifo_segment_t * fs);
u8 fifo_segment_has_fifos (fifo_segment_t * fs);
svm_fifo_t *fifo_segment_get_slice_fifo_list (fifo_segment_t * fs,
					      u32 slice_index);
u32 fifo_segment_num_fifos (fifo_segment_t * fs);
u32 fifo_segment_num_free_fifos (fifo_segment_t * fs);

svm_fifo_chunk_t *fifo_segment_alloc_chunk_w_slice (fifo_segment_t *fs,
						    u32 slice_index,
						    u32 chunk_size);
void fifo_segment_collect_chunk (fifo_segment_t *fs, u32 slice_index,
				 svm_fifo_chunk_t *c);
uword fifo_segment_chunk_offset (fifo_segment_t *fs, svm_fifo_chunk_t *c);

/**
 * Find number of free chunks of given size
 *
 * @param fs	fifo segment
 * @param size	chunk size of interest or ~0 if all should be counted
 * @return	number of chunks of given size
 */
u32 fifo_segment_num_free_chunks (fifo_segment_t * fs, u32 size);

u8 fifo_segment_get_mem_usage (fifo_segment_t * fs);
fifo_segment_mem_status_t fifo_segment_get_mem_status (fifo_segment_t * fs);

void fifo_segment_main_init (fifo_segment_main_t * sm, u64 baseva,
			     u32 timeout_in_seconds);

format_function_t format_fifo_segment;
format_function_t format_fifo_segment_type;

#endif /* __included_fifo_segment_h__ */

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