This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "".
The branch, master has been updated via 6ac9ea26a82c8f71b989d4dc6af22e3e5df62d48 (commit) via a061f94424cd9cb434a203a04aec4c437dabf251 (commit) from f7c03ade975b018be0766d5fea300d03642b4b12 (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- commit 6ac9ea26a82c8f71b989d4dc6af22e3e5df62d48 Author: Matias Elo matias.elo@nokia.com Date: Thu Jul 5 12:14:07 2018 +0300
linux-gen: pktio: ring: guarantee enq/deq variable load order
Fix ___ring_mp_do_enqueue() and ___ring_mc_do_dequeue failing on weak memory order architectures.
Signed-off-by: Matias Elo matias.elo@nokia.com Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/platform/linux-generic/pktio/ring.c b/platform/linux-generic/pktio/ring.c index 332bb46b..bb0d6780 100644 --- a/platform/linux-generic/pktio/ring.c +++ b/platform/linux-generic/pktio/ring.c @@ -250,7 +250,7 @@ int ___ring_mp_do_enqueue(_ring_t *r, void * const *obj_table, /* Reset n to the initial burst count */ n = max;
- prod_head = __atomic_load_n(&r->prod.head, __ATOMIC_RELAXED); + prod_head = __atomic_load_n(&r->prod.head, __ATOMIC_ACQUIRE); cons_tail = __atomic_load_n(&r->cons.tail, __ATOMIC_ACQUIRE); /* The subtraction is done between two unsigned 32bits value * (the result is always modulo 32 bits even if we have @@ -313,7 +313,7 @@ int ___ring_mc_do_dequeue(_ring_t *r, void **obj_table, /* Restore n as it may change every loop */ n = max;
- cons_head = __atomic_load_n(&r->cons.head, __ATOMIC_RELAXED); + cons_head = __atomic_load_n(&r->cons.head, __ATOMIC_ACQUIRE); prod_tail = __atomic_load_n(&r->prod.tail, __ATOMIC_ACQUIRE); /* The subtraction is done between two unsigned 32bits value * (the result is always modulo 32 bits even if we have
commit a061f94424cd9cb434a203a04aec4c437dabf251 Author: Matias Elo matias.elo@nokia.com Date: Thu Jul 5 10:11:32 2018 +0300
linux-gen: pktio: remove unused ring operations
Remove unused ring operations and water marking support to speed-up testing and remove potential bugs with weak memory order architectures.
Signed-off-by: Matias Elo matias.elo@nokia.com Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/platform/linux-generic/include/odp_packet_io_ring_internal.h b/platform/linux-generic/include/odp_packet_io_ring_internal.h index e459e3a5..889a6559 100644 --- a/platform/linux-generic/include/odp_packet_io_ring_internal.h +++ b/platform/linux-generic/include/odp_packet_io_ring_internal.h @@ -133,8 +133,6 @@ typedef struct _ring {
/** @private Producer */ struct ODP_ALIGNED_CACHE _prod { - uint32_t watermark; /* Maximum items */ - uint32_t sp_enqueue; /* True, if single producer. */ uint32_t size; /* Size of ring. */ uint32_t mask; /* Mask (size-1) of ring. */ volatile uint32_t head; /* Producer head. */ @@ -143,7 +141,6 @@ typedef struct _ring {
/** @private Consumer */ struct ODP_ALIGNED_CACHE _cons { - uint32_t sc_dequeue; /* True, if single consumer. */ uint32_t size; /* Size of the ring. */ uint32_t mask; /* Mask (size-1) of ring. */ volatile uint32_t head; /* Consumer head. */ @@ -163,8 +160,6 @@ typedef struct _ring { #define _RING_SHM_PROC (1 << 2) /* Do not link ring to linked list. */ #define _RING_NO_LIST (1 << 3) -/* Quota exceed for burst ops */ -#define _RING_QUOT_EXCEED (1 << 31) /* Ring size mask */ #define _RING_SZ_MASK (unsigned)(0x0fffffff)
@@ -172,9 +167,8 @@ typedef struct _ring { * Create a new ring named *name* in memory. * * This function uses odp_shm_reserve() to allocate memory. Its size is - * set to *count*, which must be a power of two. Water marking is - * disabled by default. Note that the real usable ring size is count-1 - * instead of count. + * set to *count*, which must be a power of two. Note that the real usable + * ring size is count-1 instead of count. * * @param name * The name of the ring. @@ -207,23 +201,6 @@ _ring_t *_ring_create(const char *name, unsigned count, */ int _ring_destroy(const char *name);
-/** - * Change the high water mark. - * - * If *count* is 0, water marking is disabled. Otherwise, it is set to the - * *count* value. The *count* value must be greater than 0 and less - * than the ring size. - * - * This function can be called at any time (not necessarily at - * initialization). - * - * @param r Pointer to the ring structure. - * @param count New water mark value. - * @return 0: Success; water mark changed. - * -EINVAL: Invalid water mark value. - */ -int _ring_set_water_mark(_ring_t *r, unsigned count); - /** * Dump the status of the ring to the console. * @@ -250,8 +227,6 @@ void _ring_dump(const _ring_t *r); * Depend on the behavior value * if behavior = ODPH_RING_QUEUE_FIXED * - 0: Success; objects enqueue. - * - -EDQUOT: Quota exceeded. The objects have been enqueued, but the - * high water mark is exceeded. * - -ENOBUFS: Not enough room in the ring to enqueue, no object is enqueued. * if behavior = ODPH_RING_QUEUE_VARIABLE * - n: Actual number of objects enqueued. @@ -260,32 +235,6 @@ int ___ring_mp_do_enqueue(_ring_t *r, void * const *obj_table, unsigned n, enum _ring_queue_behavior behavior);
-/** - * Enqueue several objects on a ring (NOT multi-producers safe). - * - * @param r - * A pointer to the ring structure. - * @param obj_table - * A pointer to a table of void * pointers (objects). - * @param n - * The number of objects to add in the ring from the obj_table. - * @param behavior - * ODPH_RING_QUEUE_FIXED: Enqueue a fixed number of items from a ring - * ODPH_RING_QUEUE_VARIABLE: Enqueue as many items a possible from ring - * @return - * Depend on the behavior value - * if behavior = ODPH_RING_QUEUE_FIXED - * - 0: Success; objects enqueue. - * - -EDQUOT: Quota exceeded. The objects have been enqueued, but the - * high water mark is exceeded. - * - -ENOBUFS: Not enough room in the ring to enqueue, no object is enqueued. - * if behavior = ODPH_RING_QUEUE_VARIABLE - * - n: Actual number of objects enqueued. - */ -int ___ring_sp_do_enqueue(_ring_t *r, void * const *obj_table, - unsigned n, - enum _ring_queue_behavior behavior); - /** * Dequeue several objects from a ring (multi-consumers safe). When * the request objects are more than the available objects, only dequeue the @@ -317,33 +266,6 @@ int ___ring_mc_do_dequeue(_ring_t *r, void **obj_table, unsigned n, enum _ring_queue_behavior behavior);
-/** - * Dequeue several objects from a ring (NOT multi-consumers safe). - * When the request objects are more than the available objects, only dequeue - * the actual number of objects - * - * @param r - * A pointer to the ring structure. - * @param obj_table - * A pointer to a table of void * pointers (objects) that will be filled. - * @param n - * The number of objects to dequeue from the ring to the obj_table. - * @param behavior - * ODPH_RING_QUEUE_FIXED: Dequeue a fixed number of items from a ring - * ODPH_RING_QUEUE_VARIABLE: Dequeue as many items a possible from ring - * @return - * Depend on the behavior value - * if behavior = ODPH_RING_QUEUE_FIXED - * - 0: Success; objects dequeued. - * - -ENOENT: Not enough entries in the ring to dequeue; no object is - * dequeued. - * if behavior = ODPH_RING_QUEUE_VARIABLE - * - n: Actual number of objects dequeued. - */ -int ___ring_sc_do_dequeue(_ring_t *r, void **obj_table, - unsigned n, - enum _ring_queue_behavior behavior); - /** * Enqueue several objects on the ring (multi-producers safe). * @@ -365,24 +287,6 @@ int ___ring_sc_do_dequeue(_ring_t *r, void **obj_table, int _ring_mp_enqueue_bulk(_ring_t *r, void * const *obj_table, unsigned n);
-/** - * Enqueue several objects on a ring (NOT multi-producers safe). - * - * @param r - * A pointer to the ring structure. - * @param obj_table - * A pointer to a table of void * pointers (objects). - * @param n - * The number of objects to add in the ring from the obj_table. - * @return - * - 0: Success; objects enqueued. - * - -EDQUOT: Quota exceeded. The objects have been enqueued, but the - * high water mark is exceeded. - * - -ENOBUFS: Not enough room in the ring to enqueue; no object is enqueued. - */ -int _ring_sp_enqueue_bulk(_ring_t *r, void * const *obj_table, - unsigned n); - /** * Dequeue several objects from a ring (multi-consumers safe). * @@ -402,23 +306,6 @@ int _ring_sp_enqueue_bulk(_ring_t *r, void * const *obj_table, */ int _ring_mc_dequeue_bulk(_ring_t *r, void **obj_table, unsigned n);
-/** - * Dequeue several objects from a ring (NOT multi-consumers safe). - * - * @param r - * A pointer to the ring structure. - * @param obj_table - * A pointer to a table of void * pointers (objects) that will be filled. - * @param n - * The number of objects to dequeue from the ring to the obj_table, - * must be strictly positive. - * @return - * - 0: Success; objects dequeued. - * - -ENOENT: Not enough entries in the ring to dequeue; no object is - * dequeued. - */ -int _ring_sc_dequeue_bulk(_ring_t *r, void **obj_table, unsigned n); - /** * Test if a ring is full. * @@ -486,39 +373,6 @@ _ring_t *_ring_lookup(const char *name); int _ring_mp_enqueue_burst(_ring_t *r, void * const *obj_table, unsigned n);
-/** - * Enqueue several objects on a ring (NOT multi-producers safe). - * - * @param r - * A pointer to the ring structure. - * @param obj_table - * A pointer to a table of void * pointers (objects). - * @param n - * The number of objects to add in the ring from the obj_table. - * @return - * - n: Actual number of objects enqueued. - */ -int _ring_sp_enqueue_burst(_ring_t *r, void * const *obj_table, - unsigned n); -/** - * Enqueue several objects on a ring. - * - * This function calls the multi-producer or the single-producer - * version depending on the default behavior that was specified at - * ring creation time (see flags). - * - * @param r - * A pointer to the ring structure. - * @param obj_table - * A pointer to a table of void * pointers (objects). - * @param n - * The number of objects to add in the ring from the obj_table. - * @return - * - n: Actual number of objects enqueued. - */ -int _ring_enqueue_burst(_ring_t *r, void * const *obj_table, - unsigned n); - /** * Dequeue several objects from a ring (multi-consumers safe). When the request * objects are more than the available objects, only dequeue the actual number @@ -538,40 +392,6 @@ int _ring_enqueue_burst(_ring_t *r, void * const *obj_table, */ int _ring_mc_dequeue_burst(_ring_t *r, void **obj_table, unsigned n);
-/** - * Dequeue several objects from a ring (NOT multi-consumers safe).When the - * request objects are more than the available objects, only dequeue the - * actual number of objects - * - * @param r - * A pointer to the ring structure. - * @param obj_table - * A pointer to a table of void * pointers (objects) that will be filled. - * @param n - * The number of objects to dequeue from the ring to the obj_table. - * @return - * - n: Actual number of objects dequeued, 0 if ring is empty - */ -int _ring_sc_dequeue_burst(_ring_t *r, void **obj_table, unsigned n); - -/** - * Dequeue multiple objects from a ring up to a maximum number. - * - * This function calls the multi-consumers or the single-consumer - * version, depending on the default behaviour that was specified at - * ring creation time (see flags). - * - * @param r - * A pointer to the ring structure. - * @param obj_table - * A pointer to a table of void * pointers (objects) that will be filled. - * @param n - * The number of objects to dequeue from the ring to the obj_table. - * @return - * - Number of objects dequeued, or a negative error code on error - */ -int _ring_dequeue_burst(_ring_t *r, void **obj_table, unsigned n); - /** * dump the status of all rings on the console */ diff --git a/platform/linux-generic/pktio/ring.c b/platform/linux-generic/pktio/ring.c index 518d940e..332bb46b 100644 --- a/platform/linux-generic/pktio/ring.c +++ b/platform/linux-generic/pktio/ring.c @@ -195,9 +195,6 @@ _ring_create(const char *name, unsigned count, unsigned flags) /* init the ring structure */ snprintf(r->name, sizeof(r->name), "%s", name); r->flags = flags; - r->prod.watermark = count; - r->prod.sp_enqueue = !!(flags & _RING_F_SP_ENQ); - r->cons.sc_dequeue = !!(flags & _RING_F_SC_DEQ); r->prod.size = count; r->cons.size = count; r->prod.mask = count - 1; @@ -235,23 +232,6 @@ int _ring_destroy(const char *name) return 0; }
-/* - * change the high water mark. If *count* is 0, water marking is - * disabled - */ -int _ring_set_water_mark(_ring_t *r, unsigned count) -{ - if (count >= r->prod.size) - return -EINVAL; - - /* if count is 0, disable the watermarking */ - if (count == 0) - count = r->prod.size; - - r->prod.watermark = count; - return 0; -} - /** * Enqueue several objects on the ring (multi-producers safe). */ @@ -264,7 +244,6 @@ int ___ring_mp_do_enqueue(_ring_t *r, void * const *obj_table, int success; unsigned i; uint32_t mask = r->prod.mask; - int ret;
/* move prod.head atomically */ do { @@ -302,14 +281,6 @@ int ___ring_mp_do_enqueue(_ring_t *r, void * const *obj_table, /* write entries in ring */ ENQUEUE_PTRS();
- /* if we exceed the watermark */ - if (odp_unlikely(((mask + 1) - free_entries + n) > r->prod.watermark)) { - ret = (behavior == _RING_QUEUE_FIXED) ? -EDQUOT : - (int)(n | _RING_QUOT_EXCEED); - } else { - ret = (behavior == _RING_QUEUE_FIXED) ? 0 : n; - } - /* * If there are other enqueues in progress that preceded us, * we need to wait for them to complete @@ -320,57 +291,7 @@ int ___ring_mp_do_enqueue(_ring_t *r, void * const *obj_table,
/* Release our entries and the memory they refer to */ __atomic_store_n(&r->prod.tail, prod_next, __ATOMIC_RELEASE); - return ret; -} - -/** - * Enqueue several objects on a ring (NOT multi-producers safe). - */ -int ___ring_sp_do_enqueue(_ring_t *r, void * const *obj_table, - unsigned n, enum _ring_queue_behavior behavior) -{ - uint32_t prod_head, cons_tail; - uint32_t prod_next, free_entries; - unsigned i; - uint32_t mask = r->prod.mask; - int ret; - - prod_head = r->prod.head; - cons_tail = __atomic_load_n(&r->cons.tail, __ATOMIC_ACQUIRE); - /* The subtraction is done between two unsigned 32bits value - * (the result is always modulo 32 bits even if we have - * prod_head > cons_tail). So 'free_entries' is always between 0 - * and size(ring)-1. */ - free_entries = mask + cons_tail - prod_head; - - /* check that we have enough room in ring */ - if (odp_unlikely(n > free_entries)) { - if (behavior == _RING_QUEUE_FIXED) - return -ENOBUFS; - /* No free entry available */ - if (odp_unlikely(free_entries == 0)) - return 0; - - n = free_entries; - } - - prod_next = prod_head + n; - r->prod.head = prod_next; - - /* write entries in ring */ - ENQUEUE_PTRS(); - - /* if we exceed the watermark */ - if (odp_unlikely(((mask + 1) - free_entries + n) > r->prod.watermark)) { - ret = (behavior == _RING_QUEUE_FIXED) ? -EDQUOT : - (int)(n | _RING_QUOT_EXCEED); - } else { - ret = (behavior == _RING_QUEUE_FIXED) ? 0 : n; - } - - /* Release our entries and the memory they refer to */ - __atomic_store_n(&r->prod.tail, prod_next, __ATOMIC_RELEASE); - return ret; + return (behavior == _RING_QUEUE_FIXED) ? 0 : n; }
/** @@ -436,45 +357,6 @@ int ___ring_mc_do_dequeue(_ring_t *r, void **obj_table, return behavior == _RING_QUEUE_FIXED ? 0 : n; }
-/** - * Dequeue several objects from a ring (NOT multi-consumers safe). - */ -int ___ring_sc_do_dequeue(_ring_t *r, void **obj_table, - unsigned n, enum _ring_queue_behavior behavior) -{ - uint32_t cons_head, prod_tail; - uint32_t cons_next, entries; - unsigned i; - uint32_t mask = r->prod.mask; - - cons_head = r->cons.head; - prod_tail = __atomic_load_n(&r->prod.tail, __ATOMIC_ACQUIRE); - /* The subtraction is done between two unsigned 32bits value - * (the result is always modulo 32 bits even if we have - * cons_head > prod_tail). So 'entries' is always between 0 - * and size(ring)-1. */ - entries = prod_tail - cons_head; - - if (n > entries) { - if (behavior == _RING_QUEUE_FIXED) - return -ENOENT; - if (odp_unlikely(entries == 0)) - return 0; - - n = entries; - } - - cons_next = cons_head + n; - r->cons.head = cons_next; - - /* Acquire the pointers and the memory they refer to */ - /* copy in table */ - DEQUEUE_PTRS(); - - __atomic_store_n(&r->cons.tail, cons_next, __ATOMIC_RELEASE); - return behavior == _RING_QUEUE_FIXED ? 0 : n; -} - /** * Enqueue several objects on the ring (multi-producers safe). */ @@ -485,16 +367,6 @@ int _ring_mp_enqueue_bulk(_ring_t *r, void * const *obj_table, _RING_QUEUE_FIXED); }
-/** - * Enqueue several objects on a ring (NOT multi-producers safe). - */ -int _ring_sp_enqueue_bulk(_ring_t *r, void * const *obj_table, - unsigned n) -{ - return ___ring_sp_do_enqueue(r, obj_table, n, - _RING_QUEUE_FIXED); -} - /** * Dequeue several objects from a ring (multi-consumers safe). */ @@ -504,15 +376,6 @@ int _ring_mc_dequeue_bulk(_ring_t *r, void **obj_table, unsigned n) _RING_QUEUE_FIXED); }
-/** - * Dequeue several objects from a ring (NOT multi-consumers safe). - */ -int _ring_sc_dequeue_bulk(_ring_t *r, void **obj_table, unsigned n) -{ - return ___ring_sc_do_dequeue(r, obj_table, n, - _RING_QUEUE_FIXED); -} - /** * Test if a ring is full. */ @@ -569,10 +432,6 @@ void _ring_dump(const _ring_t *r) ODP_DBG(" ph=%" PRIu32 "\n", r->prod.head); ODP_DBG(" used=%u\n", _ring_count(r)); ODP_DBG(" avail=%u\n", _ring_free_count(r)); - if (r->prod.watermark == r->prod.size) - ODP_DBG(" watermark=0\n"); - else - ODP_DBG(" watermark=%" PRIu32 "\n", r->prod.watermark); }
/* dump the status of all rings on the console */ @@ -614,28 +473,6 @@ int _ring_mp_enqueue_burst(_ring_t *r, void * const *obj_table, _RING_QUEUE_VARIABLE); }
-/** - * Enqueue several objects on a ring (NOT multi-producers safe). - */ -int _ring_sp_enqueue_burst(_ring_t *r, void * const *obj_table, - unsigned n) -{ - return ___ring_sp_do_enqueue(r, obj_table, n, - _RING_QUEUE_VARIABLE); -} - -/** - * Enqueue several objects on a ring. - */ -int _ring_enqueue_burst(_ring_t *r, void * const *obj_table, - unsigned n) -{ - if (r->prod.sp_enqueue) - return _ring_sp_enqueue_burst(r, obj_table, n); - else - return _ring_mp_enqueue_burst(r, obj_table, n); -} - /** * Dequeue several objects from a ring (multi-consumers safe). */ @@ -644,23 +481,3 @@ int _ring_mc_dequeue_burst(_ring_t *r, void **obj_table, unsigned n) return ___ring_mc_do_dequeue(r, obj_table, n, _RING_QUEUE_VARIABLE); } - -/** - * Dequeue several objects from a ring (NOT multi-consumers safe). - */ -int _ring_sc_dequeue_burst(_ring_t *r, void **obj_table, unsigned n) -{ - return ___ring_sc_do_dequeue(r, obj_table, n, - _RING_QUEUE_VARIABLE); -} - -/** - * Dequeue multiple objects from a ring up to a maximum number. - */ -int _ring_dequeue_burst(_ring_t *r, void **obj_table, unsigned n) -{ - if (r->cons.sc_dequeue) - return _ring_sc_dequeue_burst(r, obj_table, n); - else - return _ring_mc_dequeue_burst(r, obj_table, n); -} diff --git a/platform/linux-generic/test/ring/ring_basic.c b/platform/linux-generic/test/ring/ring_basic.c index 87fb18c3..6b17d8e5 100644 --- a/platform/linux-generic/test/ring/ring_basic.c +++ b/platform/linux-generic/test/ring/ring_basic.c @@ -26,20 +26,14 @@ /* labor functions declaration */ static void __do_basic_burst(_ring_t *r); static void __do_basic_bulk(_ring_t *r); -static void __do_basic_watermark(_ring_t *r);
/* dummy object pointers for enqueue and dequeue testing */ static void **test_enq_data; static void **test_deq_data;
-/* create two rings: one for single thread usage scenario - * and another for multiple thread usage scenario. - * st - single thread usage scenario - * mt - multiple thread usage scenario - */ -static const char *st_ring_name = "ST basic ring"; +/* create multiple thread test ring */ static const char *mt_ring_name = "MT basic ring"; -static _ring_t *st_ring, *mt_ring; +static _ring_t *mt_ring;
int ring_test_basic_start(void) { @@ -69,7 +63,6 @@ int ring_test_basic_start(void)
int ring_test_basic_end(void) { - _ring_destroy(st_ring_name); _ring_destroy(mt_ring_name);
free(test_enq_data); @@ -81,17 +74,10 @@ int ring_test_basic_end(void) void ring_test_basic_create(void) { /* prove illegal size shall fail */ - st_ring = _ring_create(st_ring_name, ILLEGAL_SIZE, 0); - CU_ASSERT(NULL == st_ring); + mt_ring = _ring_create(mt_ring_name, ILLEGAL_SIZE, 0); + CU_ASSERT(NULL == mt_ring); CU_ASSERT(EINVAL == __odp_errno);
- /* create ring for single thread usage scenario */ - st_ring = _ring_create(st_ring_name, RING_SIZE, - _RING_F_SP_ENQ | _RING_F_SC_DEQ); - - CU_ASSERT(NULL != st_ring); - CU_ASSERT(_ring_lookup(st_ring_name) == st_ring); - /* create ring for multiple thread usage scenario */ mt_ring = _ring_create(mt_ring_name, RING_SIZE, _RING_SHM_PROC); @@ -102,25 +88,14 @@ void ring_test_basic_create(void)
void ring_test_basic_burst(void) { - /* two rounds to cover both single - * thread and multiple thread APIs - */ - __do_basic_burst(st_ring); __do_basic_burst(mt_ring); }
void ring_test_basic_bulk(void) { - __do_basic_bulk(st_ring); __do_basic_bulk(mt_ring); }
-void ring_test_basic_watermark(void) -{ - __do_basic_watermark(st_ring); - __do_basic_watermark(mt_ring); -} - /* labor functions definition */ static void __do_basic_burst(_ring_t *r) { @@ -136,17 +111,17 @@ static void __do_basic_burst(_ring_t *r) CU_ASSERT(1 == _ring_empty(r));
/* enqueue 1 object */ - result = _ring_enqueue_burst(r, enq, 1); + result = _ring_mp_enqueue_burst(r, enq, 1); enq += 1; CU_ASSERT(1 == (result & _RING_SZ_MASK));
/* enqueue 2 objects */ - result = _ring_enqueue_burst(r, enq, 2); + result = _ring_mp_enqueue_burst(r, enq, 2); enq += 2; CU_ASSERT(2 == (result & _RING_SZ_MASK));
/* enqueue HALF_BULK objects */ - result = _ring_enqueue_burst(r, enq, HALF_BULK); + result = _ring_mp_enqueue_burst(r, enq, HALF_BULK); enq += HALF_BULK; CU_ASSERT(HALF_BULK == (result & _RING_SZ_MASK));
@@ -162,23 +137,23 @@ static void __do_basic_burst(_ring_t *r) CU_ASSERT(count == _ring_free_count(r));
/* exceed the size, enquene as many as possible */ - result = _ring_enqueue_burst(r, enq, HALF_BULK); + result = _ring_mp_enqueue_burst(r, enq, HALF_BULK); enq += count; CU_ASSERT(count == (result & _RING_SZ_MASK)); CU_ASSERT(1 == _ring_full(r));
/* dequeue 1 object */ - result = _ring_dequeue_burst(r, deq, 1); + result = _ring_mc_dequeue_burst(r, deq, 1); deq += 1; CU_ASSERT(1 == (result & _RING_SZ_MASK));
/* dequeue 2 objects */ - result = _ring_dequeue_burst(r, deq, 2); + result = _ring_mc_dequeue_burst(r, deq, 2); deq += 2; CU_ASSERT(2 == (result & _RING_SZ_MASK));
/* dequeue HALF_BULK objects */ - result = _ring_dequeue_burst(r, deq, HALF_BULK); + result = _ring_mc_dequeue_burst(r, deq, HALF_BULK); deq += HALF_BULK; CU_ASSERT(HALF_BULK == (result & _RING_SZ_MASK));
@@ -190,7 +165,7 @@ static void __do_basic_burst(_ring_t *r) CU_ASSERT(count == _ring_count(r));
/* underrun the size, dequeue as many as possible */ - result = _ring_dequeue_burst(r, deq, HALF_BULK); + result = _ring_mc_dequeue_burst(r, deq, HALF_BULK); deq += count; CU_ASSERT(count == (result & _RING_SZ_MASK)); CU_ASSERT(1 == _ring_empty(r)); @@ -208,19 +183,13 @@ static void __do_basic_burst(_ring_t *r) static inline int __ring_enqueue_bulk( _ring_t *r, void * const *objects, unsigned bulk) { - if (r->prod.sp_enqueue) - return _ring_sp_enqueue_bulk(r, objects, bulk); - else - return _ring_mp_enqueue_bulk(r, objects, bulk); + return _ring_mp_enqueue_bulk(r, objects, bulk); }
static inline int __ring_dequeue_bulk( _ring_t *r, void **objects, unsigned bulk) { - if (r->cons.sc_dequeue) - return _ring_sc_dequeue_bulk(r, objects, bulk); - else - return _ring_mc_dequeue_bulk(r, objects, bulk); + return _ring_mc_dequeue_bulk(r, objects, bulk); }
static void __do_basic_bulk(_ring_t *r) @@ -310,55 +279,3 @@ static void __do_basic_bulk(_ring_t *r) /* reset dequeue data */ memset(test_deq_data, 0, RING_SIZE * 2 * sizeof(void *)); } - -void __do_basic_watermark(_ring_t *r) -{ - int result = 0; - void * const *source = test_enq_data; - void * const *dest = test_deq_data; - void **enq = NULL, **deq = NULL; - - enq = test_enq_data; deq = test_deq_data; - - /* bulk = 3/4 watermark to trigger alarm on 2nd enqueue */ - const unsigned watermark = PIECE_BULK; - const unsigned bulk = (watermark / 4) * 3; - - /* watermark cannot exceed ring size */ - result = _ring_set_water_mark(r, ILLEGAL_SIZE); - CU_ASSERT(-EINVAL == result); - - /* set watermark */ - result = _ring_set_water_mark(r, watermark); - CU_ASSERT(0 == result); - - /* 1st enqueue shall succeed */ - result = __ring_enqueue_bulk(r, enq, bulk); - enq += bulk; - CU_ASSERT(0 == result); - - /* 2nd enqueue shall succeed but return -EDQUOT */ - result = __ring_enqueue_bulk(r, enq, bulk); - enq += bulk; - CU_ASSERT(-EDQUOT == result); - - /* dequeue 1st bulk */ - result = __ring_dequeue_bulk(r, deq, bulk); - deq += bulk; - CU_ASSERT(0 == result); - - /* dequeue 2nd bulk */ - result = __ring_dequeue_bulk(r, deq, bulk); - deq += bulk; - CU_ASSERT(0 == result); - - /* check data */ - CU_ASSERT(0 == memcmp(source, dest, deq - dest)); - - /* reset watermark */ - result = _ring_set_water_mark(r, 0); - CU_ASSERT(0 == result); - - /* reset dequeue data */ - memset(test_deq_data, 0, RING_SIZE * 2 * sizeof(void *)); -} diff --git a/platform/linux-generic/test/ring/ring_suites.c b/platform/linux-generic/test/ring/ring_suites.c index baecba6e..5f195777 100644 --- a/platform/linux-generic/test/ring/ring_suites.c +++ b/platform/linux-generic/test/ring/ring_suites.c @@ -36,7 +36,6 @@ static odp_testinfo_t ring_suite_basic[] = { ODP_TEST_INFO(ring_test_basic_create), ODP_TEST_INFO(ring_test_basic_burst), ODP_TEST_INFO(ring_test_basic_bulk), - ODP_TEST_INFO(ring_test_basic_watermark), ODP_TEST_INFO_NULL, };
diff --git a/platform/linux-generic/test/ring/ring_suites.h b/platform/linux-generic/test/ring/ring_suites.h index 1735f2d7..d56ab784 100644 --- a/platform/linux-generic/test/ring/ring_suites.h +++ b/platform/linux-generic/test/ring/ring_suites.h @@ -18,7 +18,6 @@ int ring_test_basic_end(void); void ring_test_basic_create(void); void ring_test_basic_burst(void); void ring_test_basic_bulk(void); -void ring_test_basic_watermark(void);
/* test suite start and stop */ int ring_test_stress_start(void);
-----------------------------------------------------------------------
Summary of changes: .../include/odp_packet_io_ring_internal.h | 184 +------------------- platform/linux-generic/pktio/ring.c | 189 +-------------------- platform/linux-generic/test/ring/ring_basic.c | 111 ++---------- platform/linux-generic/test/ring/ring_suites.c | 1 - platform/linux-generic/test/ring/ring_suites.h | 1 - 5 files changed, 19 insertions(+), 467 deletions(-)
hooks/post-receive