summaryrefslogtreecommitdiffstats
path: root/src/svm
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2018-04-09 09:24:52 -0700
committerDamjan Marion <dmarion.lists@gmail.com>2018-04-18 07:23:46 +0000
commit7fb0fe1f6972a7a35146fa9115b866ba29a6fbb7 (patch)
tree46f1236450ae918383bf56204b98a68199d28501 /src/svm
parent684d08c7e5378af5310346e9219a79ef1d901084 (diff)
udp/session: refactor to support dgram mode
- adds session layer support for datagram based protocols - updates udp to work in pure connectionless and datagram mode. The existing connected mode is now 'accessible' for apps as a dummy UDPC, as in, connected udp, protocol. - updates udp_echo, echo client, echo server code to work in datagram mode. Change-Id: I2960c0d2d246cb166005f545794ec31fe0d546dd Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/svm')
-rw-r--r--src/svm/svm_fifo.c19
-rw-r--r--src/svm/svm_fifo.h6
2 files changed, 24 insertions, 1 deletions
diff --git a/src/svm/svm_fifo.c b/src/svm/svm_fifo.c
index b2c8e5bdb16..3552192a768 100644
--- a/src/svm/svm_fifo.c
+++ b/src/svm/svm_fifo.c
@@ -169,6 +169,9 @@ format_svm_fifo (u8 * s, va_list * args)
svm_fifo_t *f = va_arg (*args, svm_fifo_t *);
int verbose = va_arg (*args, int);
+ if (!s)
+ return s;
+
s = format (s, "cursize %u nitems %u has_event %d\n",
f->cursize, f->nitems, f->has_event);
s = format (s, " head %d tail %d\n", f->head, f->tail);
@@ -459,7 +462,7 @@ svm_fifo_enqueue_internal (svm_fifo_t * f, u32 max_bytes,
f->ooos_newest = OOO_SEGMENT_INVALID_INDEX;
if (PREDICT_FALSE (cursize == f->nitems))
- return -2; /* fifo stuffed */
+ return SVM_FIFO_FULL;
nitems = f->nitems;
@@ -615,6 +618,20 @@ svm_fifo_enqueue_with_offset (svm_fifo_t * f,
copy_from_here);
}
+void
+svm_fifo_overwrite_head (svm_fifo_t * f, u8 * data, u32 len)
+{
+ u32 first_chunk;
+ ASSERT (len <= f->nitems);
+ if (len < f->nitems - f->head)
+ clib_memcpy (&f->data[f->head], data, len);
+ else
+ {
+ first_chunk = len - (f->nitems - f->head);
+ clib_memcpy (&f->data[f->head], data, first_chunk);
+ clib_memcpy (f->data, data + first_chunk, len - first_chunk);
+ }
+}
static int
svm_fifo_dequeue_internal (svm_fifo_t * f, u32 max_bytes, u8 * copy_here)
diff --git a/src/svm/svm_fifo.h b/src/svm/svm_fifo.h
index d06d77a42f7..39cdcc06a0c 100644
--- a/src/svm/svm_fifo.h
+++ b/src/svm/svm_fifo.h
@@ -80,6 +80,11 @@ typedef struct _svm_fifo
CLIB_CACHE_LINE_ALIGN_MARK (data);
} svm_fifo_t;
+typedef enum
+{
+ SVM_FIFO_FULL = -2,
+} svm_fifo_err_t;
+
#if SVM_FIFO_TRACE
#define svm_fifo_trace_add(_f, _s, _l, _t) \
{ \
@@ -150,6 +155,7 @@ int svm_fifo_dequeue_drop (svm_fifo_t * f, u32 max_bytes);
u32 svm_fifo_number_ooo_segments (svm_fifo_t * f);
ooo_segment_t *svm_fifo_first_ooo_segment (svm_fifo_t * f);
void svm_fifo_init_pointers (svm_fifo_t * f, u32 pointer);
+void svm_fifo_overwrite_head (svm_fifo_t * f, u8 * data, u32 len);
format_function_t format_svm_fifo;