aboutsummaryrefslogtreecommitdiffstats
path: root/lib/libtle_dring/tle_dring.h
diff options
context:
space:
mode:
authorKonstantin Ananyev <konstantin.ananyev@intel.com>2017-07-27 12:00:57 +0100
committerKonstantin Ananyev <konstantin.ananyev@intel.com>2017-07-27 20:24:53 +0100
commit7e18fa1bf263822c46d7431a911b41d6377d5f69 (patch)
treeddf5ce05545419d6d77bb9d8b3c48fc90d221a7a /lib/libtle_dring/tle_dring.h
parente151ee29d02d7802fab9e32b50ced54fd8d64160 (diff)
- Introduce tle_tcp_stream_readv() and tle_tcp_stream_writev().
- Introduce flags for tle_ctx_param. - Introduce TLE_CTX_FLAG_ST - indicates that given ctx will be used by single thread only. - Introduce new parameters for tcp context: timewait - allows user to configure max timeout in TCP_TIMEWAIT state. icw - allows user to specify desired initial congestion window for new connections. -Few optimisations: cache tx.ol_flags inside tle destination. calcualte and cache inside ctx cycles_to_ms shift value. reorder restoring SYN opts and filling TCB a bit. Change-Id: Ie05087783b3b7f1e4ce99d3555bc5bd098f83fe0 Signed-off-by: Konstantin Ananyev <konstantin.ananyev@intel.com> Signed-off-by: Mohammad Abdul Awal <mohammad.abdul.awal@intel.com>
Diffstat (limited to 'lib/libtle_dring/tle_dring.h')
-rw-r--r--lib/libtle_dring/tle_dring.h73
1 files changed, 71 insertions, 2 deletions
diff --git a/lib/libtle_dring/tle_dring.h b/lib/libtle_dring/tle_dring.h
index f589ece..9d3788a 100644
--- a/lib/libtle_dring/tle_dring.h
+++ b/lib/libtle_dring/tle_dring.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016 Intel Corporation.
+ * Copyright (c) 2016-2017 Intel Corporation.
* 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:
@@ -21,6 +21,7 @@
#include <rte_common.h>
#include <rte_atomic.h>
#include <rte_memory.h>
+#include <rte_ring.h>
#include <rte_debug.h>
#ifdef __cplusplus
@@ -68,11 +69,13 @@ struct tle_drb {
struct tle_dring {
uint32_t flags;
struct {
+ uint32_t single; /**< true if single producer */
volatile uint32_t head; /**< producer head */
volatile uint32_t tail; /**< producer tail */
struct tle_drb * volatile crb; /**< block to enqueue to */
} prod __rte_cache_aligned;
struct {
+ uint32_t single; /**< true if single consumer */
volatile uint32_t head; /**< consumer head */
volatile uint32_t tail; /**< consumer tail */
struct tle_drb * volatile crb; /**< block to dequeue from */
@@ -259,6 +262,36 @@ tle_dring_sp_enqueue(struct tle_dring *dr, const void * const objs[],
return nb_obj;
}
+/**
+ * Enqueue several objects on the dring.
+ * Note that it is a caller responsibility to provide enough drbs
+ * to enqueue all requested objects.
+ *
+ * @param dr
+ * A pointer to the ring structure.
+ * @param objs
+ * An array of pointers to objects to enqueue.
+ * @param nb_obj
+ * The number of objects to add to the dring from the objs[].
+ * @param drbs
+ * An array of pointers to the drbs that can be used by the dring
+ * to perform enqueue operation.
+ * @param nb_drb
+ * at input: number of elements in the drbs[] array.
+ * at output: number of unused by the dring elements in the drbs[] array.
+ * @return
+ * - number of enqueued objects.
+ */
+static inline uint32_t
+tle_dring_enqueue(struct tle_dring *dr, const void * const objs[],
+ uint32_t nb_obj, struct tle_drb *drbs[], uint32_t *nb_drb)
+{
+ if (dr->prod.single == 0)
+ return tle_dring_mp_enqueue(dr, objs, nb_obj, drbs, nb_drb);
+ else
+ return tle_dring_sp_enqueue(dr, objs, nb_obj, drbs, nb_drb);
+}
+
/*
* helper routine, to dequeue objects from the ring.
*/
@@ -429,6 +462,39 @@ tle_dring_sc_dequeue(struct tle_dring *dr, const void *objs[], uint32_t nb_obj,
}
/**
+ * Dequeue several objects from the dring.
+ * Note, that it is a caller responsibility to provide drbs[] large
+ * enough to store pointers to all drbs that might become unused
+ * after that dequeue operation. It is a caller responsibility to manage
+ * unused drbs after the dequeue operation is completed
+ * (i.e mark them as free/reusable again, etc.).
+ *
+ * @param dr
+ * A pointer to the ring structure.
+ * @param objs
+ * An array of pointers to objects that will be dequeued.
+ * @param nb_obj
+ * The number of objects to dequeue from the dring.
+ * @param drbs
+ * An array of pointers to the drbs that will become unused after that
+ * dequeue operation.
+ * @param nb_drb
+ * at input: number of elements in the drbs[] array.
+ * at output: number of filled entries in the drbs[] array.
+ * @return
+ * - number of dequeued objects.
+ */
+static inline uint32_t
+tle_dring_dequeue(struct tle_dring *dr, const void *objs[], uint32_t nb_obj,
+ struct tle_drb *drbs[], uint32_t *nb_drb)
+{
+ if (dr->cons.single == 0)
+ return tle_dring_mc_dequeue(dr, objs, nb_obj, drbs, nb_drb);
+ else
+ return tle_dring_sc_dequeue(dr, objs, nb_obj, drbs, nb_drb);
+}
+
+/**
* Reset given dring to the initial state.
* Note, that information about all queued objects will be lost.
*
@@ -436,11 +502,14 @@ tle_dring_sc_dequeue(struct tle_dring *dr, const void *objs[], uint32_t nb_obj,
* A pointer to the dring structure.
*/
static inline void
-tle_dring_reset(struct tle_dring *dr)
+tle_dring_reset(struct tle_dring *dr, uint32_t flags)
{
memset(dr, 0, sizeof(*dr));
dr->prod.crb = &dr->dummy;
dr->cons.crb = &dr->dummy;
+ dr->prod.single = ((flags & RING_F_SP_ENQ) != 0);
+ dr->cons.single = ((flags & RING_F_SC_DEQ) != 0);
+ dr->flags = flags;
}
/**