[dpdk-dev] [RFC 0/1] lib/ring: add scatter gather and serial dequeue APIs

Honnappa Nagarahalli honnappa.nagarahalli at arm.com
Mon Feb 24 21:39:30 CET 2020


Cover-letter:
RCU defer queue (DQ) APIs place 3 requirements on rte_ring library.
1) Multiple entities are responsible for providing/consuming the
   data in a single element of the DQ. Existing rte_ring APIs
   require an intermediate memcpy in such cases.

   RCU DQ API, rte_rcu_qsbr_dq_enqueue, has to store the token
   (generated by the RCU DQ APIs) and the application data
   (provided by the application) in each element of the DQ.

2) Dequeue the data from DQ only if it meets certain criteria.
   i.e. data needs to be accessed before it can be dequeued.

   RCU DQ API, rte_rcu_qsbr_dq_reclaim, can dequeue the
   element from DQ, only if the token at the head of
   the DQ can be reclaimed. If the token cannot be reclaimed
   the reserved elements need to be discarded.

3) While dequeuing from DQ, only one thread should be allowed
   to reserve elements.

   In order to make rte_rcu_qsbr_dq_reclaim API lock free, the
   'reserve elements in DQ, reclaim the token and revert/commit
   elements in DQ' process needs to be atomic.

The first requirement is satisfied by providing scatter-gather APIs
in rte_ring library. The enqueue/dequeue operations are split
into 3 parts:
a) Move produer's/consumer's head index. i.e. reserve elements in
   the ring and return the pointer in the ring to where the data
   needs to be copied to/from.
b) The application copies the data to/from the pointer.
c) Move producer's/consumer's tail index. i.e. indicate that
   the reserved elements are successfully consumed.
RCU DQ APIs require single element, multiple producer enqueue
operations. 'rte_ring_mp_enqueue_elem_reserve' and
'rte_ring_mp_enqueue_elem_commit' APIs are provided to address
these requirements.

The second and third requirements are satisfied by providing
rte_ring APIs for:
a) Move consumer's head index only if there are no elements
   reserved on the ring.
b) Reset the consumer's head index to its original value.
   i.e. discard the reserved elements.

In this case, RCU DQ APIs require single element, single consumer
dequeue operations. 'rte_ring_dequeue_elem_reserve_serial',
'rte_ring_dequeue_elem_commit' and
'rte_ring_dequeue_elem_revert_serial' APIs are provided to address
these requirements.

Honnappa Nagarahalli (1):
  lib/ring: add scatter gather and serial dequeue APIs

 lib/librte_ring/Makefile           |   1 +
 lib/librte_ring/meson.build        |   1 +
 lib/librte_ring/rte_ring_c11_mem.h |  98 +++++++
 lib/librte_ring/rte_ring_elem_sg.h | 417 +++++++++++++++++++++++++++++
 lib/librte_ring/rte_ring_generic.h |  93 +++++++
 5 files changed, 610 insertions(+)
 create mode 100644 lib/librte_ring/rte_ring_elem_sg.h

-- 
2.17.1



More information about the dev mailing list