refactor and cleanup of rte_ring
Subsystems (3)
PATCH v4 8/14 ring: allow enqueue fns to return free space value
In reply to Bruce RichardsonAdd an extra parameter to the ring enqueue burst/bulk functions so that those functions can optionally return the amount of free space in the ring. This information can be used by applications in a number of ways, for instance, with single-producer queues, it provides a max enqueue size which is guaranteed to work. It can also be used to implement watermark functionality in apps, replacing the older functionality with a more flexible version, which enables apps to implement multiple watermark thresholds, rather than just one.
---
V4: Added missing updates to crypto PMDs
--- doc/guides/rel_notes/release_17_05.rst | 3 + doc/guides/sample_app_ug/server_node_efd.rst | 2 +- drivers/crypto/armv8/rte_armv8_pmd.c | 6 +- drivers/crypto/kasumi/rte_kasumi_pmd.c | 4 +- drivers/crypto/snow3g/rte_snow3g_pmd.c | 4 +- drivers/crypto/zuc/rte_zuc_pmd.c | 2 +- drivers/net/ring/rte_eth_ring.c | 2 +- examples/distributor/main.c | 3 +- examples/load_balancer/runtime.c | 12 ++- .../client_server_mp/mp_server/main.c | 2 +- examples/packet_ordering/main.c | 7 +- examples/qos_sched/app_thread.c | 4 +- examples/server_node_efd/server/main.c | 2 +- lib/librte_hash/rte_cuckoo_hash.c | 2 +- lib/librte_mempool/rte_mempool_ring.c | 4 +- lib/librte_pdump/rte_pdump.c | 2 +- lib/librte_port/rte_port_ras.c | 2 +- lib/librte_port/rte_port_ring.c | 28 ++++--- lib/librte_ring/rte_ring.h | 89 +++++++++++----------- test/test-pipeline/pipeline_hash.c | 3 +- test/test-pipeline/runtime.c | 5 +- test/test/test_link_bonding_mode4.c | 3 +- test/test/test_pmd_ring_perf.c | 5 +- test/test/test_ring.c | 55 ++++++------- test/test/test_ring_perf.c | 16 ++-- test/test/test_table_ports.c | 4 +- test/test/virtual_pmd.c | 4 +- 27 files changed, 149 insertions(+), 126 deletions(-)
doc/guides/rel_notes/release_17_05.rst +3 -0
@@ -137,6 +137,9 @@ API Changes * removed the build-time setting ``CONFIG_RTE_RING_PAUSE_REP_COUNT`` * removed the function ``rte_ring_set_water_mark`` as part of a general removal of watermarks support in the library. + * added an extra parameter to the burst/bulk enqueue functions to + return the number of free spaces in the ring after enqueue. This can + be used by an application to implement its own watermark functionality. * changed the return value of the enqueue and dequeue bulk functions to match that of the burst equivalents. In all cases, ring functions which operate on multiple packets now return the number of elements enqueued
doc/guides/sample_app_ug/server_node_efd.rst +1 -1
@@ -286,7 +286,7 @@ repeated infinitely. cl = &nodes[node]; if (rte_ring_enqueue_bulk(cl->rx_q, (void **)cl_rx_buf[node].buffer, - cl_rx_buf[node].count) != cl_rx_buf[node].count){ + cl_rx_buf[node].count, NULL) != cl_rx_buf[node].count){ for (j = 0; j < cl_rx_buf[node].count; j++) rte_pktmbuf_free(cl_rx_buf[node].buffer[j]); cl->stats.rx_drop += cl_rx_buf[node].count;
drivers/crypto/armv8/rte_armv8_pmd.c +4 -2
@@ -739,13 +739,15 @@ armv8_crypto_pmd_enqueue_burst(void *queue_pair, struct rte_crypto_op **ops, goto enqueue_err; } - retval =rte_ring_enqueue_burst (qp->processed_ops, (void *)ops, i); + retval =rte_ring_enqueue_burst (qp->processed_ops, (void *)ops, i, +NULL ); qp->stats.enqueued_count += retval;return retval; enqueue_err: - retval =rte_ring_enqueue_burst (qp->processed_ops, (void *)ops, i); + retval =rte_ring_enqueue_burst (qp->processed_ops, (void *)ops, i, +NULL );if (ops[i] !=NULL ) ops[i]->status =RTE_CRYPTO_OP_STATUS_INVALID_ARGS ;
drivers/crypto/kasumi/rte_kasumi_pmd.c +2 -2
@@ -359,7 +359,7 @@ process_ops(struct rte_crypto_op **ops, struct kasumi_session *session, } enqueued_ops =rte_ring_enqueue_burst (qp->processed_ops, - (void **)ops, processed_ops); + (void **)ops, processed_ops,NULL ); qp->qp_stats.enqueued_count += enqueued_ops; *accumulated_enqueued_ops += enqueued_ops;
@@ -410,7 +410,7 @@ process_op_bit(struct rte_crypto_op *op, struct kasumi_session *session, } enqueued_op =rte_ring_enqueue_burst (qp->processed_ops, (void **)&op, - processed_op); + processed_op,NULL ); qp->qp_stats.enqueued_count += enqueued_op; *accumulated_enqueued_ops += enqueued_op;
drivers/crypto/snow3g/rte_snow3g_pmd.c +2 -2
@@ -363,7 +363,7 @@ process_ops(struct rte_crypto_op **ops, struct snow3g_session *session, } enqueued_ops =rte_ring_enqueue_burst (qp->processed_ops, - (void **)ops, processed_ops); + (void **)ops, processed_ops,NULL ); qp->qp_stats.enqueued_count += enqueued_ops; *accumulated_enqueued_ops += enqueued_ops;
@@ -414,7 +414,7 @@ process_op_bit(struct rte_crypto_op *op, struct snow3g_session *session, } enqueued_op =rte_ring_enqueue_burst (qp->processed_ops, - (void **)&op, processed_op); + (void **)&op, processed_op,NULL ); qp->qp_stats.enqueued_count += enqueued_op; *accumulated_enqueued_ops += enqueued_op;
drivers/crypto/zuc/rte_zuc_pmd.c +1 -1
@@ -339,7 +339,7 @@ process_ops(struct rte_crypto_op **ops, struct zuc_session *session, } enqueued_ops =rte_ring_enqueue_burst (qp->processed_ops, - (void **)ops, processed_ops); + (void **)ops, processed_ops,NULL ); qp->qp_stats.enqueued_count += enqueued_ops; *accumulated_enqueued_ops += enqueued_ops;
drivers/net/ring/rte_eth_ring.c +1 -1
@@ -102,7 +102,7 @@ eth_ring_tx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs)void **ptrs = (void *)&bufs[0 ];struct ring_queue *r = q;const uint16_t nb_tx = (uint16_t )rte_ring_enqueue_burst (r->rng, - ptrs, nb_bufs); + ptrs, nb_bufs,NULL );if (r->rng->flags &RING_F_SP_ENQ ) { r->tx_pkts.cnt += nb_tx; r->err_pkts.cnt += nb_bufs - nb_tx;
examples/distributor/main.c +2 -1
@@ -238,7 +238,8 @@ lcore_rx(struct lcore_params *p)continue ; } -uint16_t sent =rte_ring_enqueue_burst (r, (void *)bufs, nb_ret); +uint16_t sent =rte_ring_enqueue_burst (r, (void *)bufs, + nb_ret,NULL ); app_stats.rx.enqueued_pkts += sent;if (unlikely (sent < nb_ret)) { RTE_LOG_DP(DEBUG, DISTRAPP,
examples/load_balancer/runtime.c +8 -4
@@ -144,7 +144,8 @@ app_lcore_io_rx_buffer_to_send ( ret =rte_ring_sp_enqueue_bulk ( lp->rx.rings[worker], (void **) lp->rx.mbuf_out[worker].array, - bsz); + bsz, +NULL );if (unlikely (ret ==0 )) {uint32_t k;
@@ -310,7 +311,8 @@ app_lcore_io_rx_flush(struct app_lcore_params_io *lp, uint32_t n_workers) ret =rte_ring_sp_enqueue_bulk ( lp->rx.rings[worker], (void **) lp->rx.mbuf_out[worker].array, - lp->rx.mbuf_out[worker].n_mbufs); + lp->rx.mbuf_out[worker].n_mbufs, +NULL );if (unlikely (ret ==0 )) {uint32_t k;
@@ -553,7 +555,8 @@ app_lcore_worker( ret =rte_ring_sp_enqueue_bulk ( lp->rings_out[port], (void **) lp->mbuf_out[port].array, - bsz_wr); + bsz_wr, +NULL );#if APP_STATS lp->rings_out_iters[port] ++;
@@ -605,7 +608,8 @@ app_lcore_worker_flush(struct app_lcore_params_worker *lp) ret =rte_ring_sp_enqueue_bulk ( lp->rings_out[port], (void **) lp->mbuf_out[port].array, - lp->mbuf_out[port].n_mbufs); + lp->mbuf_out[port].n_mbufs, +NULL );if (unlikely (ret ==0 )) {uint32_t k;
examples/multi_process/client_server_mp/mp_server/main.c +1 -1
@@ -227,7 +227,7 @@ flush_rx_queue(uint16_t client) cl = &clients[client];if (rte_ring_enqueue_bulk (cl->rx_q, (void **)cl_rx_buf[client].buffer, - cl_rx_buf[client].count) ==0 ){ + cl_rx_buf[client].count,NULL ) ==0 ){for (j =0 ; j < cl_rx_buf[client].count; j++)rte_pktmbuf_free (cl_rx_buf[client].buffer[j]); cl->stats.rx_drop += cl_rx_buf[client].count;
examples/packet_ordering/main.c +4 -3
@@ -421,8 +421,8 @@ rx_thread(struct rte_ring *ring_out) pkts[i++]->seqn = seqn++;/* enqueue to rx_to_workers ring */ - ret =rte_ring_enqueue_burst (ring_out, (void *) pkts, - nb_rx_pkts); + ret =rte_ring_enqueue_burst (ring_out, + (void *)pkts, nb_rx_pkts,NULL ); app_stats.rx.enqueue_pkts += ret;if (unlikely (ret < nb_rx_pkts)) { app_stats.rx.enqueue_failed_pkts +=
@@ -473,7 +473,8 @@ worker_thread(void *args_ptr) burst_buffer[i++]->port ^= xor_val;/* enqueue the modified mbufs to workers_to_tx ring */ - ret =rte_ring_enqueue_burst (ring_out, (void *)burst_buffer, burst_size); + ret =rte_ring_enqueue_burst (ring_out, (void *)burst_buffer, + burst_size,NULL );__sync_fetch_and_add (&app_stats.wkr.enqueue_pkts, ret);if (unlikely (ret < burst_size)) {/* Return the mbufs to their respective pool, dropping packets */
examples/qos_sched/app_thread.c +2 -2
@@ -107,7 +107,7 @@ app_rx_thread(struct thread_conf **confs) }if (unlikely (rte_ring_sp_enqueue_bulk (conf->rx_ring, - (void **)rx_mbufs, nb_rx) ==0 )) { + (void **)rx_mbufs, nb_rx,NULL ) ==0 )) {for (i =0 ; i < nb_rx; i++) {rte_pktmbuf_free (rx_mbufs[i]);
@@ -231,7 +231,7 @@ app_worker_thread(struct thread_conf **confs) burst_conf.qos_dequeue);if (likely (nb_pkt >0 ))while (rte_ring_sp_enqueue_bulk (conf->tx_ring, - (void **)mbufs, nb_pkt) ==0 ) + (void **)mbufs, nb_pkt,NULL ) ==0 ) ;/* empty body */ conf_idx++;
examples/server_node_efd/server/main.c +1 -1
@@ -247,7 +247,7 @@ flush_rx_queue(uint16_t node) cl = &nodes[node];if (rte_ring_enqueue_bulk (cl->rx_q, (void **)cl_rx_buf[node].buffer, - cl_rx_buf[node].count) != cl_rx_buf[node].count){ + cl_rx_buf[node].count,NULL ) != cl_rx_buf[node].count){for (j =0 ; j < cl_rx_buf[node].count; j++)rte_pktmbuf_free (cl_rx_buf[node].buffer[j]); cl->stats.rx_drop += cl_rx_buf[node].count;
lib/librte_hash/rte_cuckoo_hash.c +1 -1
@@ -808,7 +808,7 @@ remove_entry(const struct rte_hash *h, struct rte_hash_bucket *bkt, unsigned i)/* Need to enqueue the free slots in global ring. */ n_slots =rte_ring_mp_enqueue_burst (h->free_slots, cached_free_slots->objs, -LCORE_CACHE_SIZE ); +LCORE_CACHE_SIZE ,NULL ); cached_free_slots->len -= n_slots; }/* Put index of new free slot in cache. */
lib/librte_mempool/rte_mempool_ring.c +2 -2
@@ -43,7 +43,7 @@ common_ring_mp_enqueue(struct rte_mempool *mp, void * const *obj_table, unsigned n) {return rte_ring_mp_enqueue_bulk (mp->pool_data, - obj_table, n) ==0 ? -ENOBUFS :0 ; + obj_table, n,NULL ) ==0 ? -ENOBUFS :0 ; } static int
@@ -51,7 +51,7 @@ common_ring_sp_enqueue(struct rte_mempool *mp, void * const *obj_table, unsigned n) {return rte_ring_sp_enqueue_bulk (mp->pool_data, - obj_table, n) ==0 ? -ENOBUFS :0 ; + obj_table, n,NULL ) ==0 ? -ENOBUFS :0 ; } static int
lib/librte_pdump/rte_pdump.c +1 -1
@@ -197,7 +197,7 @@ pdump_copy(struct rte_mbuf **pkts, uint16_t nb_pkts, void *user_params) dup_bufs[d_pkts++] = p; } - ring_enq =rte_ring_enqueue_burst (ring, (void *)dup_bufs, d_pkts); + ring_enq =rte_ring_enqueue_burst (ring, (void *)dup_bufs, d_pkts,NULL );if (unlikely (ring_enq < d_pkts)) {RTE_LOG (DEBUG ,PDUMP ,"only %d of packets enqueued to ring\n" , ring_enq);
lib/librte_port/rte_port_ras.c +1 -1
@@ -167,7 +167,7 @@ send_burst(struct rte_port_ring_writer_ras *p)uint32_t nb_tx; nb_tx =rte_ring_sp_enqueue_burst (p->ring, (void **)p->tx_buf, - p->tx_buf_count); + p->tx_buf_count,NULL );RTE_PORT_RING_WRITER_RAS_STATS_PKTS_DROP_ADD (p, p->tx_buf_count - nb_tx);for ( ; nb_tx < p->tx_buf_count; nb_tx++)
lib/librte_port/rte_port_ring.c +16 -12
@@ -241,7 +241,7 @@ send_burst(struct rte_port_ring_writer *p)uint32_t nb_tx; nb_tx =rte_ring_sp_enqueue_burst (p->ring, (void **)p->tx_buf, - p->tx_buf_count); + p->tx_buf_count,NULL );RTE_PORT_RING_WRITER_STATS_PKTS_DROP_ADD (p, p->tx_buf_count - nb_tx);for ( ; nb_tx < p->tx_buf_count; nb_tx++)
@@ -256,7 +256,7 @@ send_burst_mp(struct rte_port_ring_writer *p)uint32_t nb_tx; nb_tx =rte_ring_mp_enqueue_burst (p->ring, (void **)p->tx_buf, - p->tx_buf_count); + p->tx_buf_count,NULL );RTE_PORT_RING_WRITER_STATS_PKTS_DROP_ADD (p, p->tx_buf_count - nb_tx);for ( ; nb_tx < p->tx_buf_count; nb_tx++)
@@ -318,11 +318,11 @@ rte_port_ring_writer_tx_bulk_internal(void *port,RTE_PORT_RING_WRITER_STATS_PKTS_IN_ADD (p, n_pkts);if (is_multi) - n_pkts_ok =rte_ring_mp_enqueue_burst (p->ring, (void **)pkts, - n_pkts); + n_pkts_ok =rte_ring_mp_enqueue_burst (p->ring, + (void **)pkts, n_pkts,NULL );else - n_pkts_ok =rte_ring_sp_enqueue_burst (p->ring, (void **)pkts, - n_pkts); + n_pkts_ok =rte_ring_sp_enqueue_burst (p->ring, + (void **)pkts, n_pkts,NULL );RTE_PORT_RING_WRITER_STATS_PKTS_DROP_ADD (p, n_pkts - n_pkts_ok);for ( ; n_pkts_ok < n_pkts; n_pkts_ok++) {
@@ -517,7 +517,7 @@ send_burst_nodrop(struct rte_port_ring_writer_nodrop *p)uint32_t nb_tx =0 , i; nb_tx =rte_ring_sp_enqueue_burst (p->ring, (void **)p->tx_buf, - p->tx_buf_count); + p->tx_buf_count,NULL );/* We sent all the packets in a first try */ if (nb_tx >= p->tx_buf_count) {
@@ -527,7 +527,8 @@ send_burst_nodrop(struct rte_port_ring_writer_nodrop *p)for (i =0 ; i < p->n_retries; i++) { nb_tx +=rte_ring_sp_enqueue_burst (p->ring, - (void **) (p->tx_buf + nb_tx), p->tx_buf_count - nb_tx); + (void **) (p->tx_buf + nb_tx), + p->tx_buf_count - nb_tx,NULL );/* We sent all the packets in more than one try */ if (nb_tx >= p->tx_buf_count) {
@@ -550,7 +551,7 @@ send_burst_mp_nodrop(struct rte_port_ring_writer_nodrop *p)uint32_t nb_tx =0 , i; nb_tx =rte_ring_mp_enqueue_burst (p->ring, (void **)p->tx_buf, - p->tx_buf_count); + p->tx_buf_count,NULL );/* We sent all the packets in a first try */ if (nb_tx >= p->tx_buf_count) {
@@ -560,7 +561,8 @@ send_burst_mp_nodrop(struct rte_port_ring_writer_nodrop *p)for (i =0 ; i < p->n_retries; i++) { nb_tx +=rte_ring_mp_enqueue_burst (p->ring, - (void **) (p->tx_buf + nb_tx), p->tx_buf_count - nb_tx); + (void **) (p->tx_buf + nb_tx), + p->tx_buf_count - nb_tx,NULL );/* We sent all the packets in more than one try */ if (nb_tx >= p->tx_buf_count) {
@@ -633,10 +635,12 @@ rte_port_ring_writer_nodrop_tx_bulk_internal(void *port,RTE_PORT_RING_WRITER_NODROP_STATS_PKTS_IN_ADD (p, n_pkts);if (is_multi) n_pkts_ok = -rte_ring_mp_enqueue_burst (p->ring, (void **)pkts, n_pkts); +rte_ring_mp_enqueue_burst (p->ring, + (void **)pkts, n_pkts,NULL );else n_pkts_ok = -rte_ring_sp_enqueue_burst (p->ring, (void **)pkts, n_pkts); +rte_ring_sp_enqueue_burst (p->ring, + (void **)pkts, n_pkts,NULL );if (n_pkts_ok >= n_pkts)return 0 ;
lib/librte_ring/rte_ring.h +44 -45
196 lines not on this page · raw message
test/test-pipeline/pipeline_hash.c +2 -1
@@ -546,7 +546,8 @@ app_main_loop_rx_metadata(void) { ret =rte_ring_sp_enqueue_bulk ( app.rings_rx[i], (void **) app.mbuf_rx.array, - n_mbufs); + n_mbufs, +NULL ); }while (ret ==0 ); } }
test/test-pipeline/runtime.c +3 -2
@@ -97,7 +97,7 @@ app_main_loop_rx(void) { ret =rte_ring_sp_enqueue_bulk ( app.rings_rx[i], (void **) app.mbuf_rx.array, - n_mbufs); + n_mbufs,NULL ); }while (ret ==0 ); } }
@@ -130,7 +130,8 @@ app_main_loop_worker(void) { ret =rte_ring_sp_enqueue_bulk ( app.rings_tx[i ^1 ], (void **) worker_mbuf->array, - app.burst_size_worker_write); + app.burst_size_worker_write, +NULL ); }while (ret ==0 ); } }
test/test/test_link_bonding_mode4.c +2 -1
@@ -206,7 +206,8 @@ slave_get_pkts(struct slave_conf *slave, struct rte_mbuf **buf, uint16_t size)static int slave_put_pkts (struct slave_conf *slave,struct rte_mbuf **buf,uint16_t size) { -return rte_ring_enqueue_burst (slave->rx_queue, (void **)buf, size); +return rte_ring_enqueue_burst (slave->rx_queue, (void **)buf, + size,NULL ); } static uint16_t
test/test/test_pmd_ring_perf.c +3 -2
@@ -98,7 +98,7 @@ test_single_enqueue_dequeue(void)const uint64_t sc_start =rte_rdtsc_precise ();rte_compiler_barrier ();for (i =0 ; i < iterations; i++) { -rte_ring_enqueue_bulk (r, &burst,1 ); +rte_ring_enqueue_bulk (r, &burst,1 ,NULL );rte_ring_dequeue_bulk (r, &burst,1 ); }const uint64_t sc_end =rte_rdtsc_precise ();
@@ -131,7 +131,8 @@ test_bulk_enqueue_dequeue(void)for (sz =0 ; sz <sizeof (bulk_sizes)/sizeof (bulk_sizes[0 ]); sz++) {const uint64_t sc_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) { -rte_ring_sp_enqueue_bulk (r, (void *)burst, bulk_sizes[sz]); +rte_ring_sp_enqueue_bulk (r, (void *)burst, + bulk_sizes[sz],NULL );rte_ring_sc_dequeue_bulk (r, (void *)burst, bulk_sizes[sz]); }const uint64_t sc_end =rte_rdtsc ();
test/test/test_ring.c +28 -27
203 lines not on this page · raw message
test/test/test_ring_perf.c +10 -6
@@ -195,13 +195,13 @@ enqueue_bulk(void *p)const uint64_t sp_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) -while (rte_ring_sp_enqueue_bulk (r, burst, size) ==0 ) +while (rte_ring_sp_enqueue_bulk (r, burst, size,NULL ) ==0 )rte_pause ();const uint64_t sp_end =rte_rdtsc ();const uint64_t mp_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) -while (rte_ring_mp_enqueue_bulk (r, burst, size) ==0 ) +while (rte_ring_mp_enqueue_bulk (r, burst, size,NULL ) ==0 )rte_pause ();const uint64_t mp_end =rte_rdtsc ();
@@ -323,14 +323,16 @@ test_burst_enqueue_dequeue(void)for (sz =0 ; sz <sizeof (bulk_sizes)/sizeof (bulk_sizes[0 ]); sz++) {const uint64_t sc_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) { -rte_ring_sp_enqueue_burst (r, burst, bulk_sizes[sz]); +rte_ring_sp_enqueue_burst (r, burst, + bulk_sizes[sz],NULL );rte_ring_sc_dequeue_burst (r, burst, bulk_sizes[sz]); }const uint64_t sc_end =rte_rdtsc ();const uint64_t mc_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) { -rte_ring_mp_enqueue_burst (r, burst, bulk_sizes[sz]); +rte_ring_mp_enqueue_burst (r, burst, + bulk_sizes[sz],NULL );rte_ring_mc_dequeue_burst (r, burst, bulk_sizes[sz]); }const uint64_t mc_end =rte_rdtsc ();
@@ -357,14 +359,16 @@ test_bulk_enqueue_dequeue(void)for (sz =0 ; sz <sizeof (bulk_sizes)/sizeof (bulk_sizes[0 ]); sz++) {const uint64_t sc_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) { -rte_ring_sp_enqueue_bulk (r, burst, bulk_sizes[sz]); +rte_ring_sp_enqueue_bulk (r, burst, + bulk_sizes[sz],NULL );rte_ring_sc_dequeue_bulk (r, burst, bulk_sizes[sz]); }const uint64_t sc_end =rte_rdtsc ();const uint64_t mc_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) { -rte_ring_mp_enqueue_bulk (r, burst, bulk_sizes[sz]); +rte_ring_mp_enqueue_bulk (r, burst, + bulk_sizes[sz],NULL );rte_ring_mc_dequeue_bulk (r, burst, bulk_sizes[sz]); }const uint64_t mc_end =rte_rdtsc ();
test/test/test_table_ports.c +2 -2
@@ -80,7 +80,7 @@ test_port_ring_reader(void) mbuf[0 ] = (void *)rte_pktmbuf_alloc (pool); expected_pkts =rte_ring_sp_enqueue_burst (port_ring_reader_params.ring, - mbuf,1 ); + mbuf,1 ,NULL ); received_pkts = rte_port_ring_reader_ops.f_rx (port, res_mbuf,1 );if (received_pkts < expected_pkts)
@@ -93,7 +93,7 @@ test_port_ring_reader(void) mbuf[i] =rte_pktmbuf_alloc (pool); expected_pkts =rte_ring_sp_enqueue_burst (port_ring_reader_params.ring, - (void *const *) mbuf,RTE_PORT_IN_BURST_SIZE_MAX ); + (void *const *) mbuf,RTE_PORT_IN_BURST_SIZE_MAX ,NULL ); received_pkts = rte_port_ring_reader_ops.f_rx (port, res_mbuf,RTE_PORT_IN_BURST_SIZE_MAX );
test/test/virtual_pmd.c +2 -2
@@ -380,7 +380,7 @@ virtual_ethdev_tx_burst_success(void *queue, struct rte_mbuf **bufs, nb_pkts =0 ; else nb_pkts =rte_ring_enqueue_burst (dev_private->tx_queue, (void **)bufs, - nb_pkts); + nb_pkts,NULL );/* increment opacket count */ dev_private->eth_stats.opackets += nb_pkts;
@@ -496,7 +496,7 @@ virtual_ethdev_add_mbufs_to_rx_queue(uint8_t port_id, vrtl_eth_dev->data->dev_private;return rte_ring_enqueue_burst (dev_private->rx_queue, (void **)pkt_burst, - burst_length); + burst_length,NULL ); }int
Signature · 1 line
2.9.3
PATCH v4 9/14 ring: allow dequeue fns to return remaining entry count
In reply to Bruce RichardsonAdd an extra parameter to the ring dequeue burst/bulk functions so that those functions can optionally return the amount of remaining objs in the ring. This information can be used by applications in a number of ways, for instance, with single-consumer queues, it provides a max dequeue size which is guaranteed to work.
---
v4: added in missing updates to crypto PMDs
--- app/pdump/main.c | 2 +- doc/guides/prog_guide/writing_efficient_code.rst | 2 +- doc/guides/rel_notes/release_17_05.rst | 8 ++ drivers/crypto/aesni_gcm/aesni_gcm_pmd.c | 2 +- drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c | 2 +- drivers/crypto/armv8/rte_armv8_pmd.c | 2 +- drivers/crypto/kasumi/rte_kasumi_pmd.c | 2 +- drivers/crypto/null/null_crypto_pmd.c | 2 +- drivers/crypto/openssl/rte_openssl_pmd.c | 2 +- drivers/crypto/snow3g/rte_snow3g_pmd.c | 2 +- drivers/crypto/zuc/rte_zuc_pmd.c | 2 +- drivers/net/bonding/rte_eth_bond_pmd.c | 3 +- drivers/net/ring/rte_eth_ring.c | 2 +- examples/distributor/main.c | 2 +- examples/load_balancer/runtime.c | 6 +- .../client_server_mp/mp_client/client.c | 3 +- examples/packet_ordering/main.c | 6 +- examples/qos_sched/app_thread.c | 6 +- examples/quota_watermark/qw/main.c | 5 +- examples/server_node_efd/node/node.c | 2 +- lib/librte_hash/rte_cuckoo_hash.c | 3 +- lib/librte_mempool/rte_mempool_ring.c | 4 +- lib/librte_port/rte_port_frag.c | 3 +- lib/librte_port/rte_port_ring.c | 6 +- lib/librte_ring/rte_ring.h | 90 +++++++++++----------- test/test-pipeline/runtime.c | 6 +- test/test/test_link_bonding_mode4.c | 3 +- test/test/test_pmd_ring_perf.c | 7 +- test/test/test_ring.c | 54 ++++++------- test/test/test_ring_perf.c | 20 +++-- test/test/test_table_acl.c | 2 +- test/test/test_table_pipeline.c | 2 +- test/test/test_table_ports.c | 8 +- test/test/virtual_pmd.c | 4 +- 34 files changed, 153 insertions(+), 122 deletions(-)
app/pdump/main.c +1 -1
@@ -496,7 +496,7 @@ pdump_rxtx(struct rte_ring *ring, uint8_t vdev_id, struct pdump_stats *stats)/* first dequeue packets from ring of primary process */ const uint16_t nb_in_deq =rte_ring_dequeue_burst (ring, - (void *)rxtx_bufs,BURST_SIZE ); + (void *)rxtx_bufs,BURST_SIZE ,NULL ); stats->dequeue_pkts += nb_in_deq;if (nb_in_deq) {
doc/guides/prog_guide/writing_efficient_code.rst +1 -1
@@ -124,7 +124,7 @@ The code algorithm that dequeues messages may be something similar to the follow while (1) { /* Process as many elements as can be dequeued. */ - count = rte_ring_dequeue_burst(ring, obj_table, MAX_BULK); + count = rte_ring_dequeue_burst(ring, obj_table, MAX_BULK, NULL); if (unlikely(count == 0)) continue;
doc/guides/rel_notes/release_17_05.rst +8 -0
@@ -140,6 +140,8 @@ API Changes * added an extra parameter to the burst/bulk enqueue functions to return the number of free spaces in the ring after enqueue. This can be used by an application to implement its own watermark functionality. + * added an extra parameter to the burst/bulk dequeue functions to return + the number elements remaining in the ring after dequeue. * changed the return value of the enqueue and dequeue bulk functions to match that of the burst equivalents. In all cases, ring functions which operate on multiple packets now return the number of elements enqueued
@@ -152,6 +154,12 @@ API Changes - ``rte_ring_sc_dequeue_bulk`` - ``rte_ring_dequeue_bulk`` + NOTE: the above functions all have different parameters as well as + different return values, due to the other listed changes above. This + means that all instances of the functions in existing code will be + flagged by the compiler. The return value usage should be checked + while fixing the compiler error due to the extra parameter. + ABI Changes -----------
drivers/crypto/aesni_gcm/aesni_gcm_pmd.c +1 -1
@@ -420,7 +420,7 @@ aesni_gcm_pmd_dequeue_burst(void *queue_pair,unsigned nb_dequeued; nb_dequeued =rte_ring_dequeue_burst (qp->processed_pkts, - (void **)ops, nb_ops); + (void **)ops, nb_ops,NULL ); qp->qp_stats.dequeued_count += nb_dequeued;return nb_dequeued;
drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c +1 -1
@@ -622,7 +622,7 @@ aesni_mb_pmd_dequeue_burst(void *queue_pair, struct rte_crypto_op **ops,unsigned nb_dequeued; nb_dequeued =rte_ring_dequeue_burst (qp->processed_ops, - (void **)ops, nb_ops); + (void **)ops, nb_ops,NULL ); qp->stats.dequeued_count += nb_dequeued;return nb_dequeued;
drivers/crypto/armv8/rte_armv8_pmd.c +1 -1
@@ -765,7 +765,7 @@ armv8_crypto_pmd_dequeue_burst(void *queue_pair, struct rte_crypto_op **ops,unsigned int nb_dequeued =0 ; nb_dequeued =rte_ring_dequeue_burst (qp->processed_ops, - (void **)ops, nb_ops); + (void **)ops, nb_ops,NULL ); qp->stats.dequeued_count += nb_dequeued;return nb_dequeued;
drivers/crypto/kasumi/rte_kasumi_pmd.c +1 -1
@@ -542,7 +542,7 @@ kasumi_pmd_dequeue_burst(void *queue_pair,unsigned nb_dequeued; nb_dequeued =rte_ring_dequeue_burst (qp->processed_ops, - (void **)c_ops, nb_ops); + (void **)c_ops, nb_ops,NULL ); qp->qp_stats.dequeued_count += nb_dequeued;return nb_dequeued;
drivers/crypto/null/null_crypto_pmd.c +1 -1
@@ -155,7 +155,7 @@ null_crypto_pmd_dequeue_burst(void *queue_pair, struct rte_crypto_op **ops,unsigned nb_dequeued; nb_dequeued =rte_ring_dequeue_burst (qp->processed_pkts, - (void **)ops, nb_ops); + (void **)ops, nb_ops,NULL ); qp->qp_stats.dequeued_count += nb_dequeued;return nb_dequeued;
drivers/crypto/openssl/rte_openssl_pmd.c +1 -1
@@ -1119,7 +1119,7 @@ openssl_pmd_dequeue_burst(void *queue_pair, struct rte_crypto_op **ops,unsigned int nb_dequeued =0 ; nb_dequeued =rte_ring_dequeue_burst (qp->processed_ops, - (void **)ops, nb_ops); + (void **)ops, nb_ops,NULL ); qp->stats.dequeued_count += nb_dequeued;return nb_dequeued;
drivers/crypto/snow3g/rte_snow3g_pmd.c +1 -1
@@ -533,7 +533,7 @@ snow3g_pmd_dequeue_burst(void *queue_pair,unsigned nb_dequeued; nb_dequeued =rte_ring_dequeue_burst (qp->processed_ops, - (void **)c_ops, nb_ops); + (void **)c_ops, nb_ops,NULL ); qp->qp_stats.dequeued_count += nb_dequeued;return nb_dequeued;
drivers/crypto/zuc/rte_zuc_pmd.c +1 -1
@@ -433,7 +433,7 @@ zuc_pmd_dequeue_burst(void *queue_pair,unsigned nb_dequeued; nb_dequeued =rte_ring_dequeue_burst (qp->processed_ops, - (void **)c_ops, nb_ops); + (void **)c_ops, nb_ops,NULL ); qp->qp_stats.dequeued_count += nb_dequeued;return nb_dequeued;
drivers/net/bonding/rte_eth_bond_pmd.c +2 -1
@@ -1008,7 +1008,8 @@ bond_ethdev_tx_burst_8023ad(void *queue, struct rte_mbuf **bufs,struct port *port = &mode_8023ad_ports[slaves[i]]; slave_slow_nb_pkts[i] =rte_ring_dequeue_burst (port->tx_ring, - slow_pkts,BOND_MODE_8023AX_SLAVE_TX_PKTS ); + slow_pkts,BOND_MODE_8023AX_SLAVE_TX_PKTS , +NULL ); slave_nb_pkts[i] = slave_slow_nb_pkts[i];for (j =0 ; j < slave_slow_nb_pkts[i]; j++)
drivers/net/ring/rte_eth_ring.c +1 -1
@@ -88,7 +88,7 @@ eth_ring_rx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs)void **ptrs = (void *)&bufs[0 ];struct ring_queue *r = q;const uint16_t nb_rx = (uint16_t )rte_ring_dequeue_burst (r->rng, - ptrs, nb_bufs); + ptrs, nb_bufs,NULL );if (r->rng->flags &RING_F_SC_DEQ ) r->rx_pkts.cnt += nb_rx;else
examples/distributor/main.c +1 -1
@@ -330,7 +330,7 @@ lcore_tx(struct rte_ring *in_r)struct rte_mbuf *bufs[BURST_SIZE ];const uint16_t nb_rx =rte_ring_dequeue_burst (in_r, - (void *)bufs,BURST_SIZE ); + (void *)bufs,BURST_SIZE ,NULL ); app_stats.tx.dequeue_pkts += nb_rx;/* if we get no traffic, flush anything we have */
examples/load_balancer/runtime.c +4 -2
@@ -349,7 +349,8 @@ app_lcore_io_tx( ret =rte_ring_sc_dequeue_bulk ( ring, (void **) &lp->tx.mbuf_out[port].array[n_mbufs], - bsz_rd); + bsz_rd, +NULL );if (unlikely (ret ==0 ))continue ;
@@ -504,7 +505,8 @@ app_lcore_worker( ret =rte_ring_sc_dequeue_bulk ( ring_in, (void **) lp->mbuf_in.array, - bsz_rd); + bsz_rd, +NULL );if (unlikely (ret ==0 ))continue ;
examples/multi_process/client_server_mp/mp_client/client.c +2 -1
@@ -279,7 +279,8 @@ main(int argc, char *argv[])uint16_t i, rx_pkts;uint8_t port; - rx_pkts =rte_ring_dequeue_burst (rx_ring, pkts,PKT_READ_SIZE ); + rx_pkts =rte_ring_dequeue_burst (rx_ring, pkts, +PKT_READ_SIZE ,NULL );if (unlikely (rx_pkts ==0 )){if (need_flush)
examples/packet_ordering/main.c +3 -3
@@ -462,7 +462,7 @@ worker_thread(void *args_ptr)/* dequeue the mbufs from rx_to_workers ring */ burst_size =rte_ring_dequeue_burst (ring_in, - (void *)burst_buffer,MAX_PKTS_BURST ); + (void *)burst_buffer,MAX_PKTS_BURST ,NULL );if (unlikely (burst_size ==0 ))continue ;
@@ -510,7 +510,7 @@ send_thread(struct send_thread_args *args)/* deque the mbufs from workers_to_tx ring */ nb_dq_mbufs =rte_ring_dequeue_burst (args->ring_in, - (void *)mbufs,MAX_PKTS_BURST ); + (void *)mbufs,MAX_PKTS_BURST ,NULL );if (unlikely (nb_dq_mbufs ==0 ))continue ;
@@ -595,7 +595,7 @@ tx_thread(struct rte_ring *ring_in)/* deque the mbufs from workers_to_tx ring */ dqnum =rte_ring_dequeue_burst (ring_in, - (void *)mbufs,MAX_PKTS_BURST ); + (void *)mbufs,MAX_PKTS_BURST ,NULL );if (unlikely (dqnum ==0 ))continue ;
examples/qos_sched/app_thread.c +3 -3
@@ -179,7 +179,7 @@ app_tx_thread(struct thread_conf **confs)while ((conf = confs[conf_idx])) { retval =rte_ring_sc_dequeue_bulk (conf->tx_ring, (void **)mbufs, - burst_conf.qos_dequeue); + burst_conf.qos_dequeue,NULL );if (likely (retval !=0 )) {app_send_packets (conf, mbufs, burst_conf.qos_dequeue);
@@ -218,7 +218,7 @@ app_worker_thread(struct thread_conf **confs)/* Read packet from the ring */ nb_pkt =rte_ring_sc_dequeue_burst (conf->rx_ring, (void **)mbufs, - burst_conf.ring_burst); + burst_conf.ring_burst,NULL );if (likely (nb_pkt)) {int nb_sent =rte_sched_port_enqueue (conf->sched_port, mbufs, nb_pkt);
@@ -254,7 +254,7 @@ app_mixed_thread(struct thread_conf **confs)/* Read packet from the ring */ nb_pkt =rte_ring_sc_dequeue_burst (conf->rx_ring, (void **)mbufs, - burst_conf.ring_burst); + burst_conf.ring_burst,NULL );if (likely (nb_pkt)) {int nb_sent =rte_sched_port_enqueue (conf->sched_port, mbufs, nb_pkt);
examples/quota_watermark/qw/main.c +3 -2
@@ -247,7 +247,8 @@ pipeline_stage(__attribute__((unused)) void *args) }/* Dequeue up to quota mbuf from rx */ - nb_dq_pkts =rte_ring_dequeue_burst (rx, pkts, *quota); + nb_dq_pkts =rte_ring_dequeue_burst (rx, pkts, + *quota,NULL );if (unlikely (nb_dq_pkts <0 ))continue ;
@@ -305,7 +306,7 @@ send_stage(__attribute__((unused)) void *args)/* Dequeue packets from tx and send them */ nb_dq_pkts = (uint16_t )rte_ring_dequeue_burst (tx, - (void *) tx_pkts, *quota); + (void *) tx_pkts, *quota,NULL );rte_eth_tx_burst (dest_port_id,0 , tx_pkts, nb_dq_pkts);/* TODO: Check if nb_dq_pkts == nb_tx_pkts? */
examples/server_node_efd/node/node.c +1 -1
@@ -392,7 +392,7 @@ main(int argc, char *argv[])*/ while (rx_pkts >0 &&unlikely (rte_ring_dequeue_bulk (rx_ring, pkts, - rx_pkts) ==0 )) + rx_pkts,NULL ) ==0 )) rx_pkts = (uint16_t )RTE_MIN (rte_ring_count (rx_ring),PKT_READ_SIZE );
lib/librte_hash/rte_cuckoo_hash.c +2 -1
@@ -536,7 +536,8 @@ __rte_hash_add_key_with_hash(const struct rte_hash *h, const void *key,if (cached_free_slots->len ==0 ) {/* Need to get another burst of free slots from global ring */ n_slots =rte_ring_mc_dequeue_burst (h->free_slots, - cached_free_slots->objs,LCORE_CACHE_SIZE ); + cached_free_slots->objs, +LCORE_CACHE_SIZE ,NULL );if (n_slots ==0 )return -ENOSPC ;
lib/librte_mempool/rte_mempool_ring.c +2 -2
@@ -58,14 +58,14 @@ static int common_ring_mc_dequeue(struct rte_mempool *mp, void **obj_table, unsigned n) { return rte_ring_mc_dequeue_bulk(mp->pool_data, - obj_table, n) == 0 ? -ENOBUFS : 0; + obj_table, n, NULL) == 0 ? -ENOBUFS : 0; } static int common_ring_sc_dequeue(struct rte_mempool *mp, void **obj_table, unsigned n) { return rte_ring_sc_dequeue_bulk(mp->pool_data, - obj_table, n) == 0 ? -ENOBUFS : 0; + obj_table, n, NULL) == 0 ? -ENOBUFS : 0; } static unsigned
lib/librte_port/rte_port_frag.c +2 -1
@@ -186,7 +186,8 @@ rte_port_ring_reader_frag_rx(void *port,/* If "pkts" buffer is empty, read packet burst from ring */ if (p->n_pkts ==0 ) { p->n_pkts =rte_ring_sc_dequeue_burst (p->ring, - (void **) p->pkts,RTE_PORT_IN_BURST_SIZE_MAX ); + (void **) p->pkts,RTE_PORT_IN_BURST_SIZE_MAX , +NULL );RTE_PORT_RING_READER_FRAG_STATS_PKTS_IN_ADD (p, p->n_pkts);if (p->n_pkts ==0 )return n_pkts_out;
lib/librte_port/rte_port_ring.c +4 -2
@@ -111,7 +111,8 @@ rte_port_ring_reader_rx(void *port, struct rte_mbuf **pkts, uint32_t n_pkts)struct rte_port_ring_reader *p = (struct rte_port_ring_reader *) port;uint32_t nb_rx; - nb_rx =rte_ring_sc_dequeue_burst (p->ring, (void **) pkts, n_pkts); + nb_rx =rte_ring_sc_dequeue_burst (p->ring, (void **) pkts, + n_pkts,NULL );RTE_PORT_RING_READER_STATS_PKTS_IN_ADD (p, nb_rx);return nb_rx;
@@ -124,7 +125,8 @@ rte_port_ring_multi_reader_rx(void *port, struct rte_mbuf **pkts,struct rte_port_ring_reader *p = (struct rte_port_ring_reader *) port;uint32_t nb_rx; - nb_rx =rte_ring_mc_dequeue_burst (p->ring, (void **) pkts, n_pkts); + nb_rx =rte_ring_mc_dequeue_burst (p->ring, (void **) pkts, + n_pkts,NULL );RTE_PORT_RING_READER_STATS_PKTS_IN_ADD (p, nb_rx);return nb_rx;
lib/librte_ring/rte_ring.h +47 -43
196 lines not on this page · raw message
test/test-pipeline/runtime.c +4 -2
@@ -121,7 +121,8 @@ app_main_loop_worker(void) { ret =rte_ring_sc_dequeue_bulk ( app.rings_rx[i], (void **) worker_mbuf->array, - app.burst_size_worker_read); + app.burst_size_worker_read, +NULL );if (ret ==0 )continue ;
@@ -151,7 +152,8 @@ app_main_loop_tx(void) { ret =rte_ring_sc_dequeue_bulk ( app.rings_tx[i], (void **) &app.mbuf_tx[i].array[n_mbufs], - app.burst_size_tx_read); + app.burst_size_tx_read, +NULL );if (ret ==0 )continue ;
test/test/test_link_bonding_mode4.c +2 -1
@@ -193,7 +193,8 @@ static uint8_t lacpdu_rx_count[RTE_MAX_ETHPORTS] = {0, };static int slave_get_pkts (struct slave_conf *slave,struct rte_mbuf **buf,uint16_t size) { -return rte_ring_dequeue_burst (slave->tx_queue, (void **)buf, size); +return rte_ring_dequeue_burst (slave->tx_queue, (void **)buf, + size,NULL ); }/*
test/test/test_pmd_ring_perf.c +4 -3
@@ -67,7 +67,7 @@ test_empty_dequeue(void)const uint64_t sc_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) -rte_ring_sc_dequeue_bulk (r, burst, bulk_sizes[0 ]); +rte_ring_sc_dequeue_bulk (r, burst, bulk_sizes[0 ],NULL );const uint64_t sc_end =rte_rdtsc ();const uint64_t eth_start =rte_rdtsc ();
@@ -99,7 +99,7 @@ test_single_enqueue_dequeue(void)rte_compiler_barrier ();for (i =0 ; i < iterations; i++) {rte_ring_enqueue_bulk (r, &burst,1 ,NULL ); -rte_ring_dequeue_bulk (r, &burst,1 ); +rte_ring_dequeue_bulk (r, &burst,1 ,NULL ); }const uint64_t sc_end =rte_rdtsc_precise ();rte_compiler_barrier ();
@@ -133,7 +133,8 @@ test_bulk_enqueue_dequeue(void)for (i =0 ; i < iterations; i++) {rte_ring_sp_enqueue_bulk (r, (void *)burst, bulk_sizes[sz],NULL ); -rte_ring_sc_dequeue_bulk (r, (void *)burst, bulk_sizes[sz]); +rte_ring_sc_dequeue_bulk (r, (void *)burst, + bulk_sizes[sz],NULL ); }const uint64_t sc_end =rte_rdtsc ();
test/test/test_ring.c +28 -26
197 lines not on this page · raw message
test/test/test_ring_perf.c +12 -8
@@ -152,12 +152,12 @@ test_empty_dequeue(void)const uint64_t sc_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) -rte_ring_sc_dequeue_bulk (r, burst, bulk_sizes[0 ]); +rte_ring_sc_dequeue_bulk (r, burst, bulk_sizes[0 ],NULL );const uint64_t sc_end =rte_rdtsc ();const uint64_t mc_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) -rte_ring_mc_dequeue_bulk (r, burst, bulk_sizes[0 ]); +rte_ring_mc_dequeue_bulk (r, burst, bulk_sizes[0 ],NULL );const uint64_t mc_end =rte_rdtsc (); printf("SC empty dequeue: %.2F\n",
@@ -230,13 +230,13 @@ dequeue_bulk(void *p)const uint64_t sc_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) -while (rte_ring_sc_dequeue_bulk (r, burst, size) ==0 ) +while (rte_ring_sc_dequeue_bulk (r, burst, size,NULL ) ==0 )rte_pause ();const uint64_t sc_end =rte_rdtsc ();const uint64_t mc_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) -while (rte_ring_mc_dequeue_bulk (r, burst, size) ==0 ) +while (rte_ring_mc_dequeue_bulk (r, burst, size,NULL ) ==0 )rte_pause ();const uint64_t mc_end =rte_rdtsc ();
@@ -325,7 +325,8 @@ test_burst_enqueue_dequeue(void)for (i =0 ; i < iterations; i++) {rte_ring_sp_enqueue_burst (r, burst, bulk_sizes[sz],NULL ); -rte_ring_sc_dequeue_burst (r, burst, bulk_sizes[sz]); +rte_ring_sc_dequeue_burst (r, burst, + bulk_sizes[sz],NULL ); }const uint64_t sc_end =rte_rdtsc ();
@@ -333,7 +334,8 @@ test_burst_enqueue_dequeue(void)for (i =0 ; i < iterations; i++) {rte_ring_mp_enqueue_burst (r, burst, bulk_sizes[sz],NULL ); -rte_ring_mc_dequeue_burst (r, burst, bulk_sizes[sz]); +rte_ring_mc_dequeue_burst (r, burst, + bulk_sizes[sz],NULL ); }const uint64_t mc_end =rte_rdtsc ();
@@ -361,7 +363,8 @@ test_bulk_enqueue_dequeue(void)for (i =0 ; i < iterations; i++) {rte_ring_sp_enqueue_bulk (r, burst, bulk_sizes[sz],NULL ); -rte_ring_sc_dequeue_bulk (r, burst, bulk_sizes[sz]); +rte_ring_sc_dequeue_bulk (r, burst, + bulk_sizes[sz],NULL ); }const uint64_t sc_end =rte_rdtsc ();
@@ -369,7 +372,8 @@ test_bulk_enqueue_dequeue(void)for (i =0 ; i < iterations; i++) {rte_ring_mp_enqueue_bulk (r, burst, bulk_sizes[sz],NULL ); -rte_ring_mc_dequeue_bulk (r, burst, bulk_sizes[sz]); +rte_ring_mc_dequeue_bulk (r, burst, + bulk_sizes[sz],NULL ); }const uint64_t mc_end =rte_rdtsc ();
test/test/test_table_acl.c +1 -1
@@ -713,7 +713,7 @@ test_pipeline_single_filter(int expected_count)void *objs[RING_TX_SIZE ];struct rte_mbuf *mbuf; - ret =rte_ring_sc_dequeue_burst (rings_tx[i], objs,10 ); + ret =rte_ring_sc_dequeue_burst (rings_tx[i], objs,10 ,NULL );if (ret <=0 ) {printf ("Got no objects from ring %d - error code %d\n" , i, ret);
test/test/test_table_pipeline.c +1 -1
@@ -494,7 +494,7 @@ test_pipeline_single_filter(int test_type, int expected_count)void *objs[RING_TX_SIZE ];struct rte_mbuf *mbuf; - ret =rte_ring_sc_dequeue_burst (rings_tx[i], objs,10 ); + ret =rte_ring_sc_dequeue_burst (rings_tx[i], objs,10 ,NULL );if (ret <=0 )printf ("Got no objects from ring %d - error code %d\n" , i, ret);
test/test/test_table_ports.c +4 -4
@@ -163,7 +163,7 @@ test_port_ring_writer(void) rte_port_ring_writer_ops.f_flush (port); expected_pkts =1 ; received_pkts =rte_ring_sc_dequeue_burst (port_ring_writer_params.ring, - (void **)res_mbuf, port_ring_writer_params.tx_burst_sz); + (void **)res_mbuf, port_ring_writer_params.tx_burst_sz,NULL );if (received_pkts < expected_pkts)return -7 ;
@@ -178,7 +178,7 @@ test_port_ring_writer(void) expected_pkts =RTE_PORT_IN_BURST_SIZE_MAX ; received_pkts =rte_ring_sc_dequeue_burst (port_ring_writer_params.ring, - (void **)res_mbuf, port_ring_writer_params.tx_burst_sz); + (void **)res_mbuf, port_ring_writer_params.tx_burst_sz,NULL );if (received_pkts < expected_pkts)return -8 ;
@@ -193,7 +193,7 @@ test_port_ring_writer(void) expected_pkts =RTE_PORT_IN_BURST_SIZE_MAX ; received_pkts =rte_ring_sc_dequeue_burst (port_ring_writer_params.ring, - (void **)res_mbuf, port_ring_writer_params.tx_burst_sz); + (void **)res_mbuf, port_ring_writer_params.tx_burst_sz,NULL );if (received_pkts < expected_pkts)return -8 ;
@@ -208,7 +208,7 @@ test_port_ring_writer(void) expected_pkts =RTE_PORT_IN_BURST_SIZE_MAX ; received_pkts =rte_ring_sc_dequeue_burst (port_ring_writer_params.ring, - (void **)res_mbuf, port_ring_writer_params.tx_burst_sz); + (void **)res_mbuf, port_ring_writer_params.tx_burst_sz,NULL );if (received_pkts < expected_pkts)return -9 ;
test/test/virtual_pmd.c +2 -2
@@ -342,7 +342,7 @@ virtual_ethdev_rx_burst_success(void *queue __rte_unused, dev_private = vrtl_eth_dev->data->dev_private; rx_count =rte_ring_dequeue_burst (dev_private->rx_queue, (void **) bufs, - nb_pkts); + nb_pkts,NULL );/* increments ipackets count */ dev_private->eth_stats.ipackets += rx_count;
@@ -508,7 +508,7 @@ virtual_ethdev_get_mbufs_from_tx_queue(uint8_t port_id, dev_private = vrtl_eth_dev->data->dev_private;return rte_ring_dequeue_burst (dev_private->tx_queue, (void **)pkt_burst, - burst_length); + burst_length,NULL ); } static uint8_t
Signature · 1 line
2.9.3
PATCH v4 10/14 examples/quota_watermark: use ring space for watermarks
In reply to Bruce RichardsonNow that the enqueue function returns the amount of space in the ring, we can use that to replace the old watermark functionality. Update the example app to do so, and re-enable it in the examples Makefile.
---
v4: updated rst doc to match the code changes
--- doc/guides/sample_app_ug/quota_watermark.rst | 148 ++++++++++++++++----------- examples/Makefile | 2 +- examples/quota_watermark/qw/init.c | 5 +- examples/quota_watermark/qw/main.c | 16 +-- examples/quota_watermark/qw/main.h | 1 + examples/quota_watermark/qwctl/commands.c | 4 +- examples/quota_watermark/qwctl/qwctl.c | 2 + examples/quota_watermark/qwctl/qwctl.h | 1 + 8 files changed, 106 insertions(+), 73 deletions(-)
doc/guides/sample_app_ug/quota_watermark.rst +86 -62
@@ -1,5 +1,5 @@ .. BSD LICENSE - Copyright(c) 2010-2014 Intel Corporation. All rights reserved. + Copyright(c) 2010-2017 Intel Corporation. All rights reserved. All rights reserved. Redistribution and use in source and binary forms, with or without
@@ -31,11 +31,13 @@ Quota and Watermark Sample Application ====================================== -The Quota and Watermark sample application is a simple example of packet processing using Data Plane Development Kit (DPDK) that -showcases the use of a quota as the maximum number of packets enqueue/dequeue at a time and low and high watermarks -to signal low and high ring usage respectively. +The Quota and Watermark sample application is a simple example of packet +processing using Data Plane Development Kit (DPDK) that showcases the use +of a quota as the maximum number of packets enqueue/dequeue at a time and +low and high thresholds, or watermarks, to signal low and high ring usage +respectively. -Additionally, it shows how ring watermarks can be used to feedback congestion notifications to data producers by +Additionally, it shows how the thresholds can be used to feedback congestion notifications to data producers by temporarily stopping processing overloaded rings and sending Ethernet flow control frames. This sample application is split in two parts:
@@ -64,7 +66,7 @@ each stage of which being connected by rings, as shown in :numref:`figure_pipeli An adjustable quota value controls how many packets are being moved through the pipeline per enqueue and dequeue. -Adjustable watermark values associated with the rings control a back-off mechanism that +Adjustable threshold values associated with the rings control a back-off mechanism that tries to prevent the pipeline from being overloaded by: * Stopping enqueuing on rings for which the usage has crossed the high watermark threshold
@@ -216,25 +218,26 @@ in the *DPDK Getting Started Guide* and the *DPDK API Reference*. Shared Variables Setup ^^^^^^^^^^^^^^^^^^^^^^ -The quota and low_watermark shared variables are put into an rte_memzone using a call to setup_shared_variables(): +The quota and high and low watermark shared variables are put into an rte_memzone using a call to setup_shared_variables(): .. code-block:: c void setup_shared_variables(void) { - const struct rte_memzone *qw_memzone; - - qw_memzone = rte_memzone_reserve(QUOTA_WATERMARK_MEMZONE_NAME, 2 * sizeof(int), rte_socket_id(), RTE_MEMZONE_2MB); + const struct rte_memzone *qw_memzone; - if (qw_memzone == NULL) - rte_exit(EXIT_FAILURE, "%s\n", rte_strerror(rte_errno)); + qw_memzone = rte_memzone_reserve(QUOTA_WATERMARK_MEMZONE_NAME, + 3 * sizeof(int), rte_socket_id(), 0); + if (qw_memzone == NULL) + rte_exit(EXIT_FAILURE, "%s\n", rte_strerror(rte_errno)); - quota = qw_memzone->addr; - low_watermark = (unsigned int *) qw_memzone->addr + sizeof(int); - } + quota = qw_memzone->addr; + low_watermark = (unsigned int *) qw_memzone->addr + 1; + high_watermark = (unsigned int *) qw_memzone->addr + 2; + } -These two variables are initialized to a default value in main() and +These three variables are initialized to a default value in main() and can be changed while qw is running using the qwctl control program. Application Arguments
@@ -349,27 +352,37 @@ This is done using the following code: /* Process each port round robin style */ for (port_id = 0; port_id < RTE_MAX_ETHPORTS; port_id++) { - if (!is_bit_set(port_id, portmask)) - continue; - - ring = rings[lcore_id][port_id]; - - if (ring_state[port_id] != RING_READY) { - if (rte_ring_count(ring) > *low_watermark) - continue; - else - ring_state[port_id] = RING_READY; - } - - /* Enqueue received packets on the RX ring */ - - nb_rx_pkts = rte_eth_rx_burst(port_id, 0, pkts, *quota); - - ret = rte_ring_enqueue_bulk(ring, (void *) pkts, nb_rx_pkts); - if (ret == -EDQUOT) { - ring_state[port_id] = RING_OVERLOADED; - send_pause_frame(port_id, 1337); - } + if (!is_bit_set(port_id, portmask)) + continue; + + ring = rings[lcore_id][port_id]; + + if (ring_state[port_id] != RING_READY) { + if (rte_ring_count(ring) > *low_watermark) + continue; + else + ring_state[port_id] = RING_READY; + } + + /* Enqueue received packets on the RX ring */ + nb_rx_pkts = rte_eth_rx_burst(port_id, 0, pkts, + (uint16_t) *quota); + ret = rte_ring_enqueue_bulk(ring, (void *) pkts, + nb_rx_pkts, &free); + if (RING_SIZE - free > *high_watermark) { + ring_state[port_id] = RING_OVERLOADED; + send_pause_frame(port_id, 1337); + } + + if (ret == 0) { + + /* + * Return mbufs to the pool, + * effectively dropping packets + */ + for (i = 0; i < nb_rx_pkts; i++) + rte_pktmbuf_free(pkts[i]); + } } For each port in the port mask, the corresponding ring's pointer is fetched into ring and that ring's state is checked:
@@ -390,30 +403,40 @@ This thread is running on most of the logical cores to create and arbitrarily lo previous_lcore_id = get_previous_lcore_id(lcore_id); for (port_id = 0; port_id < RTE_MAX_ETHPORTS; port_id++) { - if (!is_bit_set(port_id, portmask)) - continue; - - tx = rings[lcore_id][port_id]; - rx = rings[previous_lcore_id][port_id]; - if (ring_state[port_id] != RING_READY) { - if (rte_ring_count(tx) > *low_watermark) - continue; - else - ring_state[port_id] = RING_READY; - } - - /* Dequeue up to quota mbuf from rx */ - - nb_dq_pkts = rte_ring_dequeue_burst(rx, pkts, *quota); - - if (unlikely(nb_dq_pkts < 0)) - continue; - - /* Enqueue them on tx */ - - ret = rte_ring_enqueue_bulk(tx, pkts, nb_dq_pkts); - if (ret == -EDQUOT) - ring_state[port_id] = RING_OVERLOADED; + if (!is_bit_set(port_id, portmask)) + continue; + + tx = rings[lcore_id][port_id]; + rx = rings[previous_lcore_id][port_id]; + + if (ring_state[port_id] != RING_READY) { + if (rte_ring_count(tx) > *low_watermark) + continue; + else + ring_state[port_id] = RING_READY; + } + + /* Dequeue up to quota mbuf from rx */ + nb_dq_pkts = rte_ring_dequeue_burst(rx, pkts, + *quota, NULL); + if (unlikely(nb_dq_pkts < 0)) + continue; + + /* Enqueue them on tx */ + ret = rte_ring_enqueue_bulk(tx, pkts, + nb_dq_pkts, &free); + if (RING_SIZE - free > *high_watermark) + ring_state[port_id] = RING_OVERLOADED; + + if (ret == 0) { + + /* + * Return mbufs to the pool, + * effectively dropping packets + */ + for (i = 0; i < nb_dq_pkts; i++) + rte_pktmbuf_free(pkts[i]); + } } The thread's logic works mostly like receive_stage(),
@@ -482,5 +505,6 @@ low_watermark from the rte_memzone previously created by qw. quota = qw_memzone->addr; - low_watermark = (unsigned int *) qw_memzone->addr + sizeof(int); + low_watermark = (unsigned int *) qw_memzone->addr + 1; + high_watermark = (unsigned int *) qw_memzone->addr + 2; }
examples/Makefile +1 -1
@@ -81,7 +81,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_REORDER) += packet_ordering DIRS-$(CONFIG_RTE_LIBRTE_IEEE1588) += ptpclient DIRS-$(CONFIG_RTE_LIBRTE_METER) += qos_meter DIRS-$(CONFIG_RTE_LIBRTE_SCHED) += qos_sched -#DIRS-y += quota_watermark +DIRS-y += quota_watermark DIRS-$(CONFIG_RTE_ETHDEV_RXTX_CALLBACKS) += rxtx_callbacks DIRS-y += skeleton ifeq ($(CONFIG_RTE_LIBRTE_HASH),y)
examples/quota_watermark/qw/init.c +3 -2
@@ -140,7 +140,7 @@ void init_ring(int lcore_id, uint8_t port_id)if (ring ==NULL )rte_exit (EXIT_FAILURE ,"%s\n" ,rte_strerror (rte_errno)); -rte_ring_set_water_mark (ring,80 *RING_SIZE /100 ); + *high_watermark =80 *RING_SIZE /100 ; rings[lcore_id][port_id] = ring; }
@@ -168,10 +168,11 @@ setup_shared_variables(void)const struct rte_memzone *qw_memzone; qw_memzone =rte_memzone_reserve (QUOTA_WATERMARK_MEMZONE_NAME , -2 *sizeof (int ),rte_socket_id (),0 ); +3 *sizeof (int ),rte_socket_id (),0 );if (qw_memzone ==NULL )rte_exit (EXIT_FAILURE ,"%s\n" ,rte_strerror (rte_errno)); quota = qw_memzone->addr; low_watermark = (unsigned int *) qw_memzone->addr +1 ; + high_watermark = (unsigned int *) qw_memzone->addr +2 ; }
examples/quota_watermark/qw/main.c +10 -6
@@ -67,6 +67,7 @@ struct ether_fc_frame {int *quota;unsigned int *low_watermark; +unsigned int *high_watermark;uint8_t port_pairs[RTE_MAX_ETHPORTS ];
@@ -158,6 +159,7 @@ receive_stage(__attribute__((unused)) void *args)uint16_t nb_rx_pkts;unsigned int lcore_id; +unsigned int free;struct rte_mbuf *pkts[MAX_PKT_QUOTA ];struct rte_ring *ring;
@@ -189,13 +191,13 @@ receive_stage(__attribute__((unused)) void *args) nb_rx_pkts =rte_eth_rx_burst (port_id,0 , pkts, (uint16_t ) *quota); ret =rte_ring_enqueue_bulk (ring, (void *) pkts, - nb_rx_pkts); -if (ret == -EDQUOT ) { + nb_rx_pkts, &free); +if (RING_SIZE - free > *high_watermark) { ring_state[port_id] =RING_OVERLOADED ;send_pause_frame (port_id,1337 ); } -else if (ret == -ENOBUFS ) { +if (ret ==0 ) {/* * Return mbufs to the pool,
@@ -217,6 +219,7 @@ pipeline_stage(__attribute__((unused)) void *args)uint8_t port_id;unsigned int lcore_id, previous_lcore_id; +unsigned int free;void *pkts[MAX_PKT_QUOTA ];struct rte_ring *rx, *tx;
@@ -253,11 +256,12 @@ pipeline_stage(__attribute__((unused)) void *args)continue ;/* Enqueue them on tx */ - ret =rte_ring_enqueue_bulk (tx, pkts, nb_dq_pkts); -if (ret == -EDQUOT ) + ret =rte_ring_enqueue_bulk (tx, pkts, + nb_dq_pkts, &free); +if (RING_SIZE - free > *high_watermark) ring_state[port_id] =RING_OVERLOADED ; -else if (ret == -ENOBUFS ) { +if (ret ==0 ) {/* * Return mbufs to the pool,
examples/quota_watermark/qw/main.h +1 -0
@@ -43,6 +43,7 @@ enum ring_state {extern int *quota;extern unsigned int *low_watermark; +extern unsigned int *high_watermark;extern uint8_t port_pairs[RTE_MAX_ETHPORTS ];
examples/quota_watermark/qwctl/commands.c +2 -2
@@ -140,8 +140,8 @@ cmd_set_handler(__attribute__((unused)) void *parsed_result,else if (tokens->value >= *low_watermark *100 /RING_SIZE && tokens->value <=100 ) -rte_ring_set_water_mark (ring, - tokens->value *RING_SIZE /100 ); + *high_watermark = tokens->value * +RING_SIZE /100 ;else cmdline_printf(cl, "ring high watermark must be between %u%% and 100%%\n",
examples/quota_watermark/qwctl/qwctl.c +2 -0
@@ -55,6 +55,7 @@int *quota;unsigned int *low_watermark; +unsigned int *high_watermark; static void
@@ -68,6 +69,7 @@ setup_shared_variables(void) quota = qw_memzone->addr; low_watermark = (unsigned int *) qw_memzone->addr +1 ; + high_watermark = (unsigned int *) qw_memzone->addr +2 ; }int main (int argc,char **argv)
examples/quota_watermark/qwctl/qwctl.h +1 -0
@@ -36,5 +36,6 @@extern int *quota;extern unsigned int *low_watermark; +extern unsigned int *high_watermark;#endif /* _MAIN_H_ */
Signature · 1 line
2.9.3
PATCH v4 11/14 ring: reduce scope of local variables
In reply to Bruce RichardsonThe local variable i is only used for loop control so define it in the enqueue and dequeue blocks directly, rather than at the function level.
--- lib/librte_ring/rte_ring.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
lib/librte_ring/rte_ring.h +2 -4
@@ -285,6 +285,7 @@ void rte_ring_dump(FILE *f, const struct rte_ring *r);* Placed here since identical code needed in both * single and multi producer enqueue functions */ #define ENQUEUE_PTRS () do { \ + unsigned int i; \ const uint32_t size = r->size; \ uint32_t idx = prod_head & mask; \ if (likely(idx + n < size)) { \
@@ -311,6 +312,7 @@ void rte_ring_dump(FILE *f, const struct rte_ring *r);* Placed here since identical code needed in both * single and multi consumer dequeue functions */ #define DEQUEUE_PTRS () do { \ + unsigned int i; \ uint32_t idx = cons_head & mask; \ const uint32_t size = r->size; \ if (likely(idx + n < size)) { \
@@ -361,7 +363,6 @@ __rte_ring_mp_do_enqueue(struct rte_ring *r, void * const *obj_table,uint32_t cons_tail, free_entries;const unsigned int max = n;int success; -unsigned int i;uint32_t mask = r->mask;/* move prod.head atomically */
@@ -431,7 +432,6 @@ __rte_ring_sp_do_enqueue(struct rte_ring *r, void * const *obj_table, {uint32_t prod_head, cons_tail;uint32_t prod_next, free_entries; -unsigned int i;uint32_t mask = r->mask; prod_head = r->prod.head;
@@ -495,7 +495,6 @@ __rte_ring_mc_do_dequeue(struct rte_ring *r, void **obj_table,uint32_t cons_next, entries;const unsigned max = n;int success; -unsigned int i;uint32_t mask = r->mask;/* move cons.head atomically */
@@ -566,7 +565,6 @@ __rte_ring_sc_do_dequeue(struct rte_ring *r, void **obj_table, {uint32_t cons_head, prod_tail;uint32_t cons_next, entries; -unsigned int i;uint32_t mask = r->mask; cons_head = r->cons.head;
Signature · 1 line
2.9.3
PATCH v4 12/14 ring: separate out head index manipulation for enq/deq
In reply to Bruce RichardsonWe can write a single common function for head manipulation for enq and a common one for deq, allowing us to have a single worker function for enq and deq, rather than two of each. Update all other inline functions to use the new functions.
---
V3: renamed parameter "is_mp" in __rte_ring_do_dequeue to the correct "is_sc"
--- lib/librte_ring/rte_ring.c | 4 +- lib/librte_ring/rte_ring.h | 328 ++++++++++++++++++++------------------------- 2 files changed, 149 insertions(+), 183 deletions(-)
lib/librte_ring/rte_ring.c +2 -2
@@ -138,8 +138,8 @@ rte_ring_init(struct rte_ring *r, const char *name, unsigned count,if (ret <0 || ret >= (int )sizeof (r->name))return -ENAMETOOLONG ; r->flags = flags; - r->prod.single = !!(flags &RING_F_SP_ENQ ); - r->cons.single = !!(flags &RING_F_SC_DEQ ); + r->prod.single = (flags &RING_F_SP_ENQ ) ? __IS_SP : __IS_MP; + r->cons.single = (flags &RING_F_SC_DEQ ) ? __IS_SC : __IS_MC; r->size = count; r->mask = count -1 ; r->prod.head = r->cons.head =0 ;
lib/librte_ring/rte_ring.h +147 -181
528 lines not on this page · raw message
Signature · 1 line
2.9.3
PATCH v4 13/14 ring: create common function for updating tail idx
In reply to Bruce RichardsonBoth producer and consumer use the same logic for updating the tail index so merge into a single function.
---
V3: added check for "single" mode in tail update to buypass unneeded check
--- lib/librte_ring/rte_ring.h | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-)
lib/librte_ring/rte_ring.h +17 -17
@@ -341,6 +341,21 @@ void rte_ring_dump(FILE *f, const struct rte_ring *r); } \ }while (0 ) +static inline __attribute__((always_inline)) void +update_tail (struct rte_ring_headtail *ht,uint32_t old_val,uint32_t new_val, +uint32_t single) +{ +/* +* If there are other enqueues/dequeues in progress that preceded us, +* we need to wait for them to complete +*/ +if (!single) +while (unlikely (ht->tail != old_val)) +rte_pause (); + + ht->tail = new_val; +} +/** * @internal This function updates the producer head for enqueue *
@@ -440,15 +455,7 @@ __rte_ring_do_enqueue(struct rte_ring *r, void * const *obj_table,ENQUEUE_PTRS ();rte_smp_wmb (); -/* -* If there are other enqueues in progress that preceded us, -* we need to wait for them to complete -*/ -while (unlikely (r->prod.tail != prod_head)) -rte_pause (); - - r->prod.tail = prod_next; - +update_tail (&r->prod, prod_head, prod_next, is_sp); end:if (free_space !=NULL ) *free_space = free_entries - n;
@@ -553,14 +560,7 @@ __rte_ring_do_dequeue(struct rte_ring *r, void **obj_table,DEQUEUE_PTRS ();rte_smp_rmb (); -/* -* If there are other enqueues in progress that preceded us, -* we need to wait for them to complete -*/ -while (unlikely (r->cons.tail != cons_head)) -rte_pause (); - - r->cons.tail = cons_next; +update_tail (&r->cons, cons_head, cons_next, is_sc); end:if (available !=NULL )
Signature · 1 line
2.9.3
PATCH v4 14/14 ring: make ring struct and enq/deq macros type agnostic
In reply to Bruce RichardsonModify the enqueue and dequeue macros to support copying any type of object by passing in the exact object type. Rather than using the "ring" structure member of rte_ring, which is of type "array of void *", instead have the macros take the start of the ring a a pointer value, thereby leaving the rte_ring structure as purely a header value. This allows it to be reused by other future ring types which can add on extra fields if they want, or even to have the actual ring elements, of whatever type stored separate from the ring header.
--- lib/librte_ring/rte_ring.h | 68 ++++++++++++++++++++++++---------------------- 1 file changed, 36 insertions(+), 32 deletions(-)
lib/librte_ring/rte_ring.h +36 -32
@@ -159,11 +159,7 @@ struct rte_ring {/** Ring consumer status. */ struct rte_ring_headtail cons __rte_aligned(CONS_ALIGN); - - void *ring[] __rte_cache_aligned; /**< Memory space of ring starts here. -* not volatile so need to be careful -* about compiler re-ordering */ -}; +} __rte_cache_aligned;#define RING_F_SP_ENQ 0x0001/**< The default enqueue is "single-producer". */ #define RING_F_SC_DEQ 0x0002/**< The default dequeue is "single-consumer". */
@@ -290,54 +286,62 @@ void rte_ring_dump(FILE *f, const struct rte_ring *r);/* the actual enqueue of pointers on the ring. * Placed here since identical code needed in both * single and multi producer enqueue functions */ -#define ENQUEUE_PTRS () do { \ +#define ENQUEUE_PTRS (r, ring_start, prod_head, obj_table, n, obj_type) do { \ unsigned int i; \ - const uint32_t size = r->size; \ - uint32_t idx = prod_head & r->mask; \ + const uint32_t size = (r)->size; \ + uint32_t idx = prod_head & (r)->mask; \ + obj_type *ring = (void *)ring_start; \ if (likely(idx + n < size)) { \ for (i = 0; i < (n & ((~(unsigned)0x3))); i+=4, idx+=4) { \ - r->ring[idx] = obj_table[i]; \ - r->ring[idx+1] = obj_table[i+1]; \ - r->ring[idx+2] = obj_table[i+2]; \ - r->ring[idx+3] = obj_table[i+3]; \ + ring[idx] = obj_table[i]; \ + ring[idx+1] = obj_table[i+1]; \ + ring[idx+2] = obj_table[i+2]; \ + ring[idx+3] = obj_table[i+3]; \ } \ switch (n & 0x3) { \ - case 3: r->ring[idx++] = obj_table[i++]; \ - case 2: r->ring[idx++] = obj_table[i++]; \ - case 1: r->ring[idx++] = obj_table[i++]; \ + case 3: \ + ring[idx++] = obj_table[i++];/* fallthrough */ \ +case 2 : \ + ring[idx++] = obj_table[i++];/* fallthrough */ \ +case 1 : \ + ring[idx++] = obj_table[i++]; \ } \ } else { \for (i =0 ; idx < size; i++, idx++)\ - r->ring[idx] = obj_table[i]; \ + ring[idx] = obj_table[i]; \for (idx =0 ; i < n; i++, idx++) \ - r->ring[idx] = obj_table[i]; \ + ring[idx] = obj_table[i]; \ } \ -} while(0) +} while (0)/* the actual copy of pointers on the ring to obj_table. * Placed here since identical code needed in both * single and multi consumer dequeue functions */ -#define DEQUEUE_PTRS () do { \ +#define DEQUEUE_PTRS (r, ring_start, cons_head, obj_table, n, obj_type) do { \ unsigned int i; \ - uint32_t idx = cons_head & r->mask; \ - const uint32_t size = r->size; \ + uint32_t idx = cons_head & (r)->mask; \ + const uint32_t size = (r)->size; \ + obj_type *ring = (void *)ring_start; \ if (likely(idx + n < size)) { \ for (i = 0; i < (n & (~(unsigned)0x3)); i+=4, idx+=4) {\ - obj_table[i] = r->ring[idx]; \ - obj_table[i+1] = r->ring[idx+1]; \ - obj_table[i+2] = r->ring[idx+2]; \ - obj_table[i+3] = r->ring[idx+3]; \ + obj_table[i] = ring[idx]; \ + obj_table[i+1] = ring[idx+1]; \ + obj_table[i+2] = ring[idx+2]; \ + obj_table[i+3] = ring[idx+3]; \ } \ switch (n & 0x3) { \ - case 3: obj_table[i++] = r->ring[idx++]; \ - case 2: obj_table[i++] = r->ring[idx++]; \ - case 1: obj_table[i++] = r->ring[idx++]; \ + case 3: \ + obj_table[i++] = ring[idx++];/* fallthrough */ \ +case 2 : \ + obj_table[i++] = ring[idx++];/* fallthrough */ \ +case 1 : \ + obj_table[i++] = ring[idx++]; \ } \ } else { \for (i =0 ; idx < size; i++, idx++) \ - obj_table[i] = r->ring[idx]; \ + obj_table[i] = ring[idx]; \for (idx =0 ; i < n; i++, idx++) \ - obj_table[i] = r->ring[idx]; \ + obj_table[i] = ring[idx]; \ } \ } while (0)
@@ -452,7 +456,7 @@ __rte_ring_do_enqueue(struct rte_ring *r, void * const *obj_table,if (n ==0 ) goto end; -ENQUEUE_PTRS (); + ENQUEUE_PTRS(r, &r[1], prod_head, obj_table, n, void *);rte_smp_wmb ();update_tail (&r->prod, prod_head, prod_next, is_sp);
@@ -557,7 +561,7 @@ __rte_ring_do_dequeue(struct rte_ring *r, void **obj_table,if (n ==0 ) goto end; -DEQUEUE_PTRS (); + DEQUEUE_PTRS(r, &r[1], cons_head, obj_table, n, void *);rte_smp_rmb ();update_tail (&r->cons, cons_head, cons_next, is_sc);
Signature · 1 line
2.9.3
Quoted 6 lines · Bruce Richardson
This patchset make a set of, sometimes non-backward compatible, cleanup changes to the
rte_ringcode in order to improve it. The resulting code is shorter, since the existing functions are restructured to reduce code duplication, as well as being more consistent in behaviour. The specific changes made are explained in each patch which makes that change.
...
Quoted 1 line
52 files changed, 664 insertions(+), 1472 deletions(-)
^^^ ^^^^
Great rework!
Series Reviewed-by: Yuanhan Liu <[email protected]>
--yliu
v5 cover refactor and cleanup of rte_ring
In reply to Bruce RichardsonThis patchset make a set of, sometimes non-backward compatible, cleanup changes to the rte_ring code in order to improve it. The resulting code is shorter, since the existing functions are restructured to reduce code duplication, as well as being more consistent in behaviour. The specific changes made are explained in each patch which makes that change.
Changes in V5, p8 & p9 only:
* Fixed errors in performance-thread sample app due to missed updates to enqueue/dequeue calls.
* Added in missing doxygen comments for new API parameters
Changes in V4:
* Fixed errors in the crypto PMDs due to missed updates to their enqueue/dequeue calls (p8 & p9).
* Updated quota_watermarks documentation to match changed code (p10)
Changes in V3:
* removed anonymous union for sp_enqueue and sc_dequeue variables (p2)
* fixed parameter to dequeue function which was mistakenly named is_mp instead of is_sc (as described in the comments) (p12)
* skipped unneeded check in tail pointer update fn for sp/sc operation (p13)
Changes in V2:
* Eliminated extra cacheline padding where cachelines are 128B
* Renamed rte_ring_ht_ptr struct to rte_ring_headtail
* Removed missed references to ring watermarks in test code and docs
This patchset is largely the same as that posted previously on-list as an RFC:
http://dpdk.org/ml/archives/dev/2017-February/thread.html#56982
Changes in V1 from RFC:
* Included release notes updates as changes are made in each patch
* Fixed some missed comment updates when changing the code
* Separated some initial fixup patches from this set to send separately
* Dropped the final two patches for an rte_event_ring, as not relevant for this set. That can be done as a separate set later.
* The macros for copying the pointers have an extra parameter added, indicating the start of the ring buffer itself. This allows more flexibility for reusing them in other ring implementations.
Bruce Richardson (14):
ring: remove split cacheline build setting
ring: create common structure for prod and cons metadata
ring: eliminate duplication of size and mask fields
ring: remove debug setting
ring: remove the yield when waiting for tail update
ring: remove watermark support
ring: make bulk and burst fn return vals consistent
ring: allow enqueue fns to return free space value
ring: allow dequeue fns to return remaining entry count examples/quota_watermark: use ring space for watermarks
ring: reduce scope of local variables
ring: separate out head index manipulation for enq/deq
ring: create common function for updating tail idx
ring: make ring struct and enq/deq macros type agnostic
app/pdump/main.c | 2 +- config/common_base | 3 - doc/guides/prog_guide/env_abstraction_layer.rst | 5 - doc/guides/prog_guide/ring_lib.rst | 15 - doc/guides/prog_guide/writing_efficient_code.rst | 2 +- doc/guides/rel_notes/release_17_05.rst | 33 + doc/guides/sample_app_ug/quota_watermark.rst | 148 ++-- doc/guides/sample_app_ug/server_node_efd.rst | 2 +- drivers/crypto/aesni_gcm/aesni_gcm_pmd.c | 2 +- drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c | 2 +- drivers/crypto/armv8/rte_armv8_pmd.c | 8 +- drivers/crypto/kasumi/rte_kasumi_pmd.c | 6 +- drivers/crypto/null/null_crypto_pmd.c | 2 +- drivers/crypto/openssl/rte_openssl_pmd.c | 2 +- drivers/crypto/snow3g/rte_snow3g_pmd.c | 6 +- drivers/crypto/zuc/rte_zuc_pmd.c | 4 +- drivers/net/bonding/rte_eth_bond_pmd.c | 3 +- drivers/net/ring/rte_eth_ring.c | 4 +- examples/distributor/main.c | 5 +- examples/load_balancer/runtime.c | 34 +- .../client_server_mp/mp_client/client.c | 9 +- .../client_server_mp/mp_server/main.c | 2 +- examples/packet_ordering/main.c | 13 +- examples/performance-thread/l3fwd-thread/main.c | 8 +- examples/qos_sched/app_thread.c | 14 +- examples/quota_watermark/qw/init.c | 5 +- examples/quota_watermark/qw/main.c | 21 +- examples/quota_watermark/qw/main.h | 1 + examples/quota_watermark/qwctl/commands.c | 4 +- examples/quota_watermark/qwctl/qwctl.c | 2 + examples/quota_watermark/qwctl/qwctl.h | 1 + examples/server_node_efd/node/node.c | 2 +- examples/server_node_efd/server/main.c | 2 +- lib/librte_hash/rte_cuckoo_hash.c | 5 +- lib/librte_mempool/rte_mempool_ring.c | 12 +- lib/librte_pdump/rte_pdump.c | 4 +- lib/librte_port/rte_port_frag.c | 3 +- lib/librte_port/rte_port_ras.c | 2 +- lib/librte_port/rte_port_ring.c | 46 +- lib/librte_ring/rte_ring.c | 76 +- lib/librte_ring/rte_ring.h | 795 ++++++++------------- test/test-pipeline/pipeline_hash.c | 5 +- test/test-pipeline/runtime.c | 19 +- test/test/autotest_test_funcs.py | 7 - test/test/commands.c | 52 -- test/test/test_link_bonding_mode4.c | 6 +- test/test/test_pmd_ring_perf.c | 12 +- test/test/test_ring.c | 704 ++---------------- test/test/test_ring_perf.c | 36 +- test/test/test_table_acl.c | 2 +- test/test/test_table_pipeline.c | 2 +- test/test/test_table_ports.c | 12 +- test/test/virtual_pmd.c | 8 +- 53 files changed, 704 insertions(+), 1476 deletions(-)
Signature · 1 line
2.9.3
PATCH v5 1/14 ring: remove split cacheline build setting
Users compiling DPDK should not need to know or care about the arrangement of cachelines in the rte_ring structure. Therefore just remove the build option and set the structures to be always split. On platforms with 64B cachelines, for improved performance use 128B rather than 64B alignment since it stops the producer and consumer data being on adjacent cachelines.
---
V2: Limit the cacheline * 2 alignment to platforms with < 128B line size
--- config/common_base | 1 - doc/guides/rel_notes/release_17_05.rst | 7 +++++++ lib/librte_ring/rte_ring.c | 2 -- lib/librte_ring/rte_ring.h | 16 ++++++++++------ 4 files changed, 17 insertions(+), 9 deletions(-)
config/common_base +0 -1
@@ -453,7 +453,6 @@ CONFIG_RTE_LIBRTE_PMD_NULL_CRYPTO=y # CONFIG_RTE_LIBRTE_RING=y CONFIG_RTE_LIBRTE_RING_DEBUG=n -CONFIG_RTE_RING_SPLIT_PROD_CONS=n CONFIG_RTE_RING_PAUSE_REP_COUNT=0 #
doc/guides/rel_notes/release_17_05.rst +7 -0
@@ -127,6 +127,13 @@ API Changes * The LPM ``next_hop`` field is extended from 8 bits to 21 bits for IPv6 while keeping ABI compatibility. +* **Reworked rte_ring library** + + The rte_ring library has been reworked and updated. The following changes + have been made to it: + + * removed the build-time setting ``CONFIG_RTE_RING_SPLIT_PROD_CONS`` + ABI Changes -----------
lib/librte_ring/rte_ring.c +0 -2
@@ -127,10 +127,8 @@ rte_ring_init(struct rte_ring *r, const char *name, unsigned count,/* compilation-time checks */ RTE_BUILD_BUG_ON ((sizeof (struct rte_ring ) &RTE_CACHE_LINE_MASK ) !=0 ); -#ifdef RTE_RING_SPLIT_PROD_CONS RTE_BUILD_BUG_ON ((offsetof(struct rte_ring , cons) &RTE_CACHE_LINE_MASK ) !=0 ); -#endif RTE_BUILD_BUG_ON ((offsetof(struct rte_ring , prod) &RTE_CACHE_LINE_MASK ) !=0 );#ifdef RTE_LIBRTE_RING_DEBUG
lib/librte_ring/rte_ring.h +10 -6
@@ -139,6 +139,14 @@ struct rte_ring_debug_stats {struct rte_memzone ;/* forward declaration, so as not to require memzone.h */ +#if RTE_CACHE_LINE_SIZE <128 +#define PROD_ALIGN (RTE_CACHE_LINE_SIZE * 2) +#define CONS_ALIGN (RTE_CACHE_LINE_SIZE * 2) +#else +#define PROD_ALIGN RTE_CACHE_LINE_SIZE +#define CONS_ALIGN RTE_CACHE_LINE_SIZE +#endif +/** * An RTE ring structure. *
@@ -168,7 +176,7 @@ struct rte_ring {uint32_t mask;/**< Mask (size-1) of ring. */ volatile uint32_t head;/**< Producer head. */ volatile uint32_t tail;/**< Producer tail. */ - }prod __rte_cache_aligned; + }prod __rte_aligned (PROD_ALIGN );/** Ring consumer status. */ struct cons {
@@ -177,11 +185,7 @@ struct rte_ring {uint32_t mask;/**< Mask (size-1) of ring. */ volatile uint32_t head;/**< Consumer head. */ volatile uint32_t tail;/**< Consumer tail. */ -#ifdef RTE_RING_SPLIT_PROD_CONS - }cons __rte_cache_aligned; -#else - } cons; -#endif + }cons __rte_aligned (CONS_ALIGN );#ifdef RTE_LIBRTE_RING_DEBUG struct rte_ring_debug_stats stats[RTE_MAX_LCORE ];
Signature · 1 line
2.9.3
PATCH v5 2/14 ring: create common structure for prod and cons metadata
In reply to Bruce Richardsoncreate a common structure to hold the metadata for the producer and the consumer, since both need essentially the same information - the head and tail values, the ring size and mask.
---
V3: removed union and replaced with "single" variable
V2: renamed the shared structure based on maintainer feedback.
--- lib/librte_pdump/rte_pdump.c | 2 +- lib/librte_port/rte_port_ring.c | 12 ++++++------ lib/librte_ring/rte_ring.c | 4 ++-- lib/librte_ring/rte_ring.h | 41 +++++++++++++++++++---------------------- 4 files changed, 28 insertions(+), 31 deletions(-)
lib/librte_pdump/rte_pdump.c +1 -1
@@ -740,7 +740,7 @@ pdump_validate_ring_mp(struct rte_ring *ring, struct rte_mempool *mp) rte_errno =EINVAL ;return -1 ; } -if (ring->prod.sp_enqueue || ring->cons.sc_dequeue) { +if (ring->prod.single || ring->cons.single) {RTE_LOG (ERR ,PDUMP ,"ring with either SP or SC settings" " is not valid for pdump, should have MP and MC settings\n" ); rte_errno =EINVAL ;
lib/librte_port/rte_port_ring.c +6 -6
@@ -73,8 +73,8 @@ rte_port_ring_reader_create_internal(void *params, int socket_id,/* Check input parameters */ if ((conf ==NULL ) || (conf->ring ==NULL ) || - (conf->ring->cons.sc_dequeue && is_multi) || - (!(conf->ring->cons.sc_dequeue) && !is_multi)) { + (conf->ring->cons.single && is_multi) || + (!(conf->ring->cons.single) && !is_multi)) {RTE_LOG (ERR ,PORT ,"%s: Invalid Parameters\n" , __func__);return NULL ; }
@@ -198,8 +198,8 @@ rte_port_ring_writer_create_internal(void *params, int socket_id,/* Check input parameters */ if ((conf ==NULL ) || (conf->ring ==NULL ) || - (conf->ring->prod.sp_enqueue && is_multi) || - (!(conf->ring->prod.sp_enqueue) && !is_multi) || + (conf->ring->prod.single && is_multi) || + (!(conf->ring->prod.single) && !is_multi) || (conf->tx_burst_sz >RTE_PORT_IN_BURST_SIZE_MAX )) {RTE_LOG (ERR ,PORT ,"%s: Invalid Parameters\n" , __func__);return NULL ;
@@ -467,8 +467,8 @@ rte_port_ring_writer_nodrop_create_internal(void *params, int socket_id,/* Check input parameters */ if ((conf ==NULL ) || (conf->ring ==NULL ) || - (conf->ring->prod.sp_enqueue && is_multi) || - (!(conf->ring->prod.sp_enqueue) && !is_multi) || + (conf->ring->prod.single && is_multi) || + (!(conf->ring->prod.single) && !is_multi) || (conf->tx_burst_sz >RTE_PORT_IN_BURST_SIZE_MAX )) {RTE_LOG (ERR ,PORT ,"%s: Invalid Parameters\n" , __func__);return NULL ;
lib/librte_ring/rte_ring.c +2 -2
@@ -145,8 +145,8 @@ rte_ring_init(struct rte_ring *r, const char *name, unsigned count,return -ENAMETOOLONG ; 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.single = !!(flags &RING_F_SP_ENQ ); + r->cons.single = !!(flags &RING_F_SC_DEQ ); r->prod.size = r->cons.size = count; r->prod.mask = r->cons.mask = count-1 ; r->prod.head = r->cons.head =0 ;
lib/librte_ring/rte_ring.h +19 -22
97 lines not on this page · raw message
Signature · 1 line
2.9.3
PATCH v5 3/14 ring: eliminate duplication of size and mask fields
In reply to Bruce RichardsonThe size and mask fields are duplicated in both the producer and consumer data structures. Move them out of that into the top level structure so they are not duplicated.
--- lib/librte_ring/rte_ring.c | 20 ++++++++++---------- lib/librte_ring/rte_ring.h | 32 ++++++++++++++++---------------- test/test/test_ring.c | 6 +++--- 3 files changed, 29 insertions(+), 29 deletions(-)
lib/librte_ring/rte_ring.c +10 -10
@@ -144,11 +144,11 @@ rte_ring_init(struct rte_ring *r, const char *name, unsigned count,if (ret <0 || ret >= (int )sizeof (r->name))return -ENAMETOOLONG ; r->flags = flags; - r->prod.watermark = count; + r->watermark = count; r->prod.single = !!(flags &RING_F_SP_ENQ ); r->cons.single = !!(flags &RING_F_SC_DEQ ); - r->prod.size = r->cons.size = count; - r->prod.mask = r->cons.mask = count-1 ; + r->size = count; + r->mask = count -1 ; r->prod.head = r->cons.head =0 ; r->prod.tail = r->cons.tail =0 ;
@@ -269,14 +269,14 @@ rte_ring_free(struct rte_ring *r)int rte_ring_set_water_mark (struct rte_ring *r,unsigned count) { -if (count >= r->prod.size) +if (count >= r->size)return -EINVAL ;/* if count is 0, disable the watermarking */ if (count ==0 ) - count = r->prod.size; + count = r->size; - r->prod.watermark = count; + r->watermark = count;return 0 ; }
@@ -291,17 +291,17 @@ rte_ring_dump(FILE *f, const struct rte_ring *r)fprintf (f,"ring <%s>@%p\n" , r->name, r);fprintf (f," flags=%x\n" , r->flags); -fprintf (f," size=%" PRIu32"\n" , r->prod.size); +fprintf (f," size=%" PRIu32"\n" , r->size);fprintf (f," ct=%" PRIu32"\n" , r->cons.tail);fprintf (f," ch=%" PRIu32"\n" , r->cons.head);fprintf (f," pt=%" PRIu32"\n" , r->prod.tail);fprintf (f," ph=%" PRIu32"\n" , r->prod.head);fprintf (f," used=%u\n" ,rte_ring_count (r));fprintf (f," avail=%u\n" ,rte_ring_free_count (r)); -if (r->prod.watermark == r->prod.size) +if (r->watermark == r->size)fprintf (f," watermark=0\n" );else -fprintf (f," watermark=%" PRIu32"\n" , r->prod.watermark); +fprintf (f," watermark=%" PRIu32"\n" , r->watermark);/* sum and dump statistics */ #ifdef RTE_LIBRTE_RING_DEBUG
@@ -318,7 +318,7 @@ rte_ring_dump(FILE *f, const struct rte_ring *r) sum.deq_fail_bulk += r->stats[lcore_id].deq_fail_bulk; sum.deq_fail_objs += r->stats[lcore_id].deq_fail_objs; } -fprintf (f," size=%" PRIu32"\n" , r->prod.size); +fprintf (f," size=%" PRIu32"\n" , r->size);fprintf (f," enq_success_bulk=%" PRIu64"\n" , sum.enq_success_bulk);fprintf (f," enq_success_objs=%" PRIu64"\n" , sum.enq_success_objs);fprintf (f," enq_quota_bulk=%" PRIu64"\n" , sum.enq_quota_bulk);
lib/librte_ring/rte_ring.h +16 -16
@@ -151,10 +151,7 @@ struct rte_memzone; /* forward declaration, so as not to require memzone.h */struct rte_ring_headtail {volatile uint32_t head;/**< Prod/consumer head. */ volatile uint32_t tail;/**< Prod/consumer tail. */ -uint32_t size;/**< Size of ring. */ -uint32_t mask;/**< Mask (size-1) of ring. */ uint32_t single;/**< True if single prod/cons */ -uint32_t watermark;/**< Max items before EDQUOT in producer. */ };/**
@@ -174,9 +171,12 @@ struct rte_ring {* next time the ABI changes */ char name[RTE_MEMZONE_NAMESIZE ];/**< Name of the ring. */ -int flags;/**< Flags supplied at creation. */ +int flags;/**< Flags supplied at creation. */ const struct rte_memzone *memzone;/**< Memzone, if any, containing the rte_ring */ +uint32_t size;/**< Size of ring. */ +uint32_t mask;/**< Mask (size-1) of ring. */ +uint32_t watermark;/**< Max items before EDQUOT in producer. */ /** Ring producer status. */ struct rte_ring_headtail prod __rte_aligned(PROD_ALIGN);
@@ -355,7 +355,7 @@ void rte_ring_dump(FILE *f, const struct rte_ring *r);* Placed here since identical code needed in both * single and multi producer enqueue functions */ #define ENQUEUE_PTRS () do { \ - const uint32_t size = r->prod.size; \ + const uint32_t size = r->size; \ uint32_t idx = prod_head & mask; \ if (likely(idx + n < size)) { \ for (i = 0; i < (n & ((~(unsigned)0x3))); i+=4, idx+=4) { \
@@ -382,7 +382,7 @@ void rte_ring_dump(FILE *f, const struct rte_ring *r);* single and multi consumer dequeue functions */ #define DEQUEUE_PTRS () do { \ uint32_t idx = cons_head & mask; \ - const uint32_t size = r->cons.size; \ + const uint32_t size = r->size; \ if (likely(idx + n < size)) { \ for (i = 0; i < (n & (~(unsigned)0x3)); i+=4, idx+=4) {\ obj_table[i] = r->ring[idx]; \
@@ -437,7 +437,7 @@ __rte_ring_mp_do_enqueue(struct rte_ring *r, void * const *obj_table,const unsigned max = n;int success;unsigned i, rep =0 ; -uint32_t mask = r->prod.mask; +uint32_t mask = r->mask;int ret;/* Avoid the unnecessary cmpset operation below, which is also
@@ -485,7 +485,7 @@ __rte_ring_mp_do_enqueue(struct rte_ring *r, void * const *obj_table,rte_smp_wmb ();/* if we exceed the watermark */ -if (unlikely (((mask +1 ) - free_entries + n) > r->prod.watermark)) { +if (unlikely (((mask +1 ) - free_entries + n) > r->watermark)) { ret = (behavior ==RTE_RING_QUEUE_FIXED ) ? -EDQUOT : (int )(n |RTE_RING_QUOT_EXCEED );__RING_STAT_ADD (r, enq_quota, n);
@@ -544,7 +544,7 @@ __rte_ring_sp_do_enqueue(struct rte_ring *r, void * const *obj_table,uint32_t prod_head, cons_tail;uint32_t prod_next, free_entries;unsigned i; -uint32_t mask = r->prod.mask; +uint32_t mask = r->mask;int ret; prod_head = r->prod.head;
@@ -580,7 +580,7 @@ __rte_ring_sp_do_enqueue(struct rte_ring *r, void * const *obj_table,rte_smp_wmb ();/* if we exceed the watermark */ -if (unlikely (((mask +1 ) - free_entries + n) > r->prod.watermark)) { +if (unlikely (((mask +1 ) - free_entries + n) > r->watermark)) { ret = (behavior ==RTE_RING_QUEUE_FIXED ) ? -EDQUOT : (int )(n |RTE_RING_QUOT_EXCEED );__RING_STAT_ADD (r, enq_quota, n);
@@ -630,7 +630,7 @@ __rte_ring_mc_do_dequeue(struct rte_ring *r, void **obj_table,const unsigned max = n;int success;unsigned i, rep =0 ; -uint32_t mask = r->prod.mask; +uint32_t mask = r->mask;/* Avoid the unnecessary cmpset operation below, which is also * potentially harmful when n equals 0. */
@@ -727,7 +727,7 @@ __rte_ring_sc_do_dequeue(struct rte_ring *r, void **obj_table,uint32_t cons_head, prod_tail;uint32_t cons_next, entries;unsigned i; -uint32_t mask = r->prod.mask; +uint32_t mask = r->mask; cons_head = r->cons.head; prod_tail = r->prod.tail;
@@ -1056,7 +1056,7 @@ rte_ring_full(const struct rte_ring *r) {uint32_t prod_tail = r->prod.tail;uint32_t cons_tail = r->cons.tail; -return ((cons_tail - prod_tail -1 ) & r->prod.mask) ==0 ; +return ((cons_tail - prod_tail -1 ) & r->mask) ==0 ; }/**
@@ -1089,7 +1089,7 @@ rte_ring_count(const struct rte_ring *r) {uint32_t prod_tail = r->prod.tail;uint32_t cons_tail = r->cons.tail; -return (prod_tail - cons_tail) & r->prod.mask; +return (prod_tail - cons_tail) & r->mask; }/**
@@ -1105,7 +1105,7 @@ rte_ring_free_count(const struct rte_ring *r) {uint32_t prod_tail = r->prod.tail;uint32_t cons_tail = r->cons.tail; -return (cons_tail - prod_tail -1 ) & r->prod.mask; +return (cons_tail - prod_tail -1 ) & r->mask; }/**
@@ -1119,7 +1119,7 @@ rte_ring_free_count(const struct rte_ring *r)static inline unsigned int rte_ring_get_size (const struct rte_ring *r) { -return r->prod.size; +return r->size; }/**
test/test/test_ring.c +3 -3
@@ -148,7 +148,7 @@ check_live_watermark_change(__attribute__((unused)) void *dummy) }/* read watermark, the only change allowed is from 16 to 32 */ - watermark = r->prod.watermark; + watermark = r->watermark;if (watermark != watermark_old && (watermark_old !=16 || watermark !=32 )) { printf("Bad watermark change %u -> %u\n", watermark_old,
@@ -213,7 +213,7 @@ test_set_watermark( void ){printf (" ring lookup failed\n" ); goto error; } - count = r->prod.size*2 ; + count = r->size *2 ; setwm =rte_ring_set_water_mark (r, count);if (setwm != -EINVAL ){printf ("Test failed to detect invalid watermark count value\n" );
@@ -222,7 +222,7 @@ test_set_watermark( void ){ count =0 ;rte_ring_set_water_mark (r, count); -if (r->prod.watermark != r->prod.size) { +if (r->watermark != r->size) {printf ("Test failed to detect invalid watermark count value\n" ); goto error; }
Signature · 1 line
2.9.3
PATCH v5 4/14 ring: remove debug setting
In reply to Bruce RichardsonThe debug option only provided statistics to the user, most of which could be tracked by the application itself. Remove this as a compile time option, and feature, simplifying the code.
--- config/common_base | 1 - doc/guides/prog_guide/ring_lib.rst | 7 - doc/guides/rel_notes/release_17_05.rst | 1 + lib/librte_ring/rte_ring.c | 41 ---- lib/librte_ring/rte_ring.h | 97 +------- test/test/test_ring.c | 410 --------------------------------- 6 files changed, 13 insertions(+), 544 deletions(-)
config/common_base +0 -1
@@ -452,7 +452,6 @@ CONFIG_RTE_LIBRTE_PMD_NULL_CRYPTO=y # Compile librte_ring # CONFIG_RTE_LIBRTE_RING=y -CONFIG_RTE_LIBRTE_RING_DEBUG=n CONFIG_RTE_RING_PAUSE_REP_COUNT=0 #
doc/guides/prog_guide/ring_lib.rst +0 -7
@@ -110,13 +110,6 @@ Once an enqueue operation reaches the high water mark, the producer is notified, This mechanism can be used, for example, to exert a back pressure on I/O to inform the LAN to PAUSE. -Debug -~~~~~ - -When debug is enabled (CONFIG_RTE_LIBRTE_RING_DEBUG is set), -the library stores some per-ring statistic counters about the number of enqueues/dequeues. -These statistics are per-core to avoid concurrent accesses or atomic operations. - Use Cases ---------
doc/guides/rel_notes/release_17_05.rst +1 -0
@@ -133,6 +133,7 @@ API Changes have been made to it: * removed the build-time setting ``CONFIG_RTE_RING_SPLIT_PROD_CONS`` + * removed the build-time setting ``CONFIG_RTE_LIBRTE_RING_DEBUG`` ABI Changes -----------
lib/librte_ring/rte_ring.c +0 -41
59 lines not on this page · raw message
lib/librte_ring/rte_ring.h +12 -85
183 lines not on this page · raw message
test/test/test_ring.c +0 -410
422 lines not on this page · raw message
Signature · 1 line
2.9.3
PATCH v5 5/14 ring: remove the yield when waiting for tail update
In reply to Bruce RichardsonThere was a compile time setting to enable a ring to yield when it entered a loop in mp or mc rings waiting for the tail pointer update. Build time settings are not recommended for enabling/disabling features, and since this was off by default, remove it completely. If needed, a runtime enabled equivalent can be used.
--- config/common_base | 1 - doc/guides/prog_guide/env_abstraction_layer.rst | 5 ---- doc/guides/rel_notes/release_17_05.rst | 1 + lib/librte_ring/rte_ring.h | 35 +++++-------------------- 4 files changed, 7 insertions(+), 35 deletions(-)
config/common_base +0 -1
@@ -452,7 +452,6 @@ CONFIG_RTE_LIBRTE_PMD_NULL_CRYPTO=y # Compile librte_ring # CONFIG_RTE_LIBRTE_RING=y -CONFIG_RTE_RING_PAUSE_REP_COUNT=0 # # Compile librte_mempool
doc/guides/prog_guide/env_abstraction_layer.rst +0 -5
@@ -352,11 +352,6 @@ Known Issues 3. It MUST not be used by multi-producer/consumer pthreads, whose scheduling policies are SCHED_FIFO or SCHED_RR. - ``RTE_RING_PAUSE_REP_COUNT`` is defined for rte_ring to reduce contention. It's mainly for case 2, a yield is issued after number of times pause repeat. - - It adds a sched_yield() syscall if the thread spins for too long while waiting on the other thread to finish its operations on the ring. - This gives the preempted thread a chance to proceed and finish with the ring enqueue/dequeue operation. - + rte_timer Running ``rte_timer_manager()`` on a non-EAL pthread is not allowed. However, resetting/stopping the timer from a non-EAL pthread is allowed.
doc/guides/rel_notes/release_17_05.rst +1 -0
@@ -134,6 +134,7 @@ API Changes * removed the build-time setting ``CONFIG_RTE_RING_SPLIT_PROD_CONS`` * removed the build-time setting ``CONFIG_RTE_LIBRTE_RING_DEBUG`` + * removed the build-time setting ``CONFIG_RTE_RING_PAUSE_REP_COUNT`` ABI Changes -----------
lib/librte_ring/rte_ring.h +6 -29
@@ -114,11 +114,6 @@ enum rte_ring_queue_behavior {#define RTE_RING_NAMESIZE (RTE_MEMZONE_NAMESIZE - \ sizeof(RTE_RING_MZ_PREFIX) + 1) -#ifndef RTE_RING_PAUSE_REP_COUNT -#define RTE_RING_PAUSE_REP_COUNT 0/**< Yield after pause num of times, no yield -* if RTE_RING_PAUSE_REP not defined. */ -#endif -struct rte_memzone ;/* forward declaration, so as not to require memzone.h */ #if RTE_CACHE_LINE_SIZE <128
@@ -393,7 +388,7 @@ __rte_ring_mp_do_enqueue(struct rte_ring *r, void * const *obj_table,uint32_t cons_tail, free_entries;const unsigned max = n;int success; -unsigned i, rep =0 ; +unsigned int i;uint32_t mask = r->mask;int ret;
@@ -447,18 +442,9 @@ __rte_ring_mp_do_enqueue(struct rte_ring *r, void * const *obj_table,* If there are other enqueues in progress that preceded us, * we need to wait for them to complete */ -while (unlikely (r->prod.tail != prod_head)) { +while (unlikely (r->prod.tail != prod_head))rte_pause (); -/* Set RTE_RING_PAUSE_REP_COUNT to avoid spin too long waiting -* for other thread finish. It gives pre-empted thread a chance -* to proceed and finish with ring dequeue operation. */ -if (RTE_RING_PAUSE_REP_COUNT && - ++rep ==RTE_RING_PAUSE_REP_COUNT ) { - rep =0 ; -sched_yield (); - } - } r->prod.tail = prod_next;return ret; }
@@ -491,7 +477,7 @@ __rte_ring_sp_do_enqueue(struct rte_ring *r, void * const *obj_table, {uint32_t prod_head, cons_tail;uint32_t prod_next, free_entries; -unsigned i; +unsigned int i;uint32_t mask = r->mask;int ret;
@@ -568,7 +554,7 @@ __rte_ring_mc_do_dequeue(struct rte_ring *r, void **obj_table,uint32_t cons_next, entries;const unsigned max = n;int success; -unsigned i, rep =0 ; +unsigned int i;uint32_t mask = r->mask;/* Avoid the unnecessary cmpset operation below, which is also
@@ -613,18 +599,9 @@ __rte_ring_mc_do_dequeue(struct rte_ring *r, void **obj_table,* If there are other dequeues in progress that preceded us, * we need to wait for them to complete */ -while (unlikely (r->cons.tail != cons_head)) { +while (unlikely (r->cons.tail != cons_head))rte_pause (); -/* Set RTE_RING_PAUSE_REP_COUNT to avoid spin too long waiting -* for other thread finish. It gives pre-empted thread a chance -* to proceed and finish with ring dequeue operation. */ -if (RTE_RING_PAUSE_REP_COUNT && - ++rep ==RTE_RING_PAUSE_REP_COUNT ) { - rep =0 ; -sched_yield (); - } - } r->cons.tail = cons_next;return behavior ==RTE_RING_QUEUE_FIXED ?0 : n;
@@ -659,7 +636,7 @@ __rte_ring_sc_do_dequeue(struct rte_ring *r, void **obj_table, {uint32_t cons_head, prod_tail;uint32_t cons_next, entries; -unsigned i; +unsigned int i;uint32_t mask = r->mask; cons_head = r->cons.head;
Signature · 1 line
2.9.3
PATCH v5 6/14 ring: remove watermark support
In reply to Bruce RichardsonRemove the watermark support. A future commit will add support for having enqueue functions return the amount of free space in the ring, which will allow applications to implement their own watermark checks, while also being more useful to the app.
---
V2: fix missed references to watermarks in v1
--- doc/guides/prog_guide/ring_lib.rst | 8 -- doc/guides/rel_notes/release_17_05.rst | 2 + examples/Makefile | 2 +- lib/librte_ring/rte_ring.c | 23 ----- lib/librte_ring/rte_ring.h | 58 +------------ test/test/autotest_test_funcs.py | 7 -- test/test/commands.c | 52 ------------ test/test/test_ring.c | 149 +-------------------------------- 8 files changed, 8 insertions(+), 293 deletions(-)
doc/guides/prog_guide/ring_lib.rst +0 -8
@@ -102,14 +102,6 @@ Name A ring is identified by a unique name. It is not possible to create two rings with the same name (rte_ring_create() returns NULL if this is attempted). -Water Marking -~~~~~~~~~~~~~ - -The ring can have a high water mark (threshold). -Once an enqueue operation reaches the high water mark, the producer is notified, if the water mark is configured. - -This mechanism can be used, for example, to exert a back pressure on I/O to inform the LAN to PAUSE. - Use Cases ---------
doc/guides/rel_notes/release_17_05.rst +2 -0
@@ -135,6 +135,8 @@ API Changes * removed the build-time setting ``CONFIG_RTE_RING_SPLIT_PROD_CONS`` * removed the build-time setting ``CONFIG_RTE_LIBRTE_RING_DEBUG`` * removed the build-time setting ``CONFIG_RTE_RING_PAUSE_REP_COUNT`` + * removed the function ``rte_ring_set_water_mark`` as part of a general + removal of watermarks support in the library. ABI Changes -----------
examples/Makefile +1 -1
@@ -81,7 +81,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_REORDER) += packet_ordering DIRS-$(CONFIG_RTE_LIBRTE_IEEE1588) += ptpclient DIRS-$(CONFIG_RTE_LIBRTE_METER) += qos_meter DIRS-$(CONFIG_RTE_LIBRTE_SCHED) += qos_sched -DIRS-y += quota_watermark +#DIRS-y += quota_watermark DIRS-$(CONFIG_RTE_ETHDEV_RXTX_CALLBACKS) += rxtx_callbacks DIRS-y += skeleton ifeq ($(CONFIG_RTE_LIBRTE_HASH),y)
lib/librte_ring/rte_ring.c +0 -23
@@ -138,7 +138,6 @@ rte_ring_init(struct rte_ring *r, const char *name, unsigned count,if (ret <0 || ret >= (int )sizeof (r->name))return -ENAMETOOLONG ; r->flags = flags; - r->watermark = count; r->prod.single = !!(flags &RING_F_SP_ENQ ); r->cons.single = !!(flags &RING_F_SC_DEQ ); r->size = count;
@@ -256,24 +255,6 @@ rte_ring_free(struct rte_ring *r)rte_free (te); } -/* -* change the high water mark. If *count* is 0, water marking is -* disabled -*/ -int -rte_ring_set_water_mark (struct rte_ring *r,unsigned count) -{ -if (count >= r->size) -return -EINVAL ; - -/* if count is 0, disable the watermarking */ -if (count ==0 ) - count = r->size; - - r->watermark = count; -return 0 ; -} -/* dump the status of the ring on the console */ void rte_ring_dump (FILE *f,const struct rte_ring *r)
@@ -287,10 +268,6 @@ rte_ring_dump(FILE *f, const struct rte_ring *r)fprintf (f," ph=%" PRIu32"\n" , r->prod.head);fprintf (f," used=%u\n" ,rte_ring_count (r));fprintf (f," avail=%u\n" ,rte_ring_free_count (r)); -if (r->watermark == r->size) -fprintf (f," watermark=0\n" ); -else -fprintf (f," watermark=%" PRIu32"\n" , r->watermark); }/* dump the status of all rings on the console */
lib/librte_ring/rte_ring.h +2 -56
155 lines not on this page · raw message
test/test/autotest_test_funcs.py +0 -7
@@ -292,11 +292,4 @@ def ring_autotest(child, test_name): elif index == 2: return -1, "Fail [Timeout]" - child.sendline("set_watermark test 100") - child.sendline("dump_ring test") - index = child.expect([" watermark=100", - pexpect.TIMEOUT], timeout=1) - if index != 0: - return -1, "Fail [Bad watermark]" - return 0, "Success"
test/test/commands.c +0 -52
64 lines not on this page · raw message
test/test/test_ring.c +3 -146
179 lines not on this page · raw message
Signature · 1 line
2.9.3
PATCH v5 7/14 ring: make bulk and burst fn return vals consistent
In reply to Bruce RichardsonThe bulk fns for rings returns 0 for all elements enqueued and negative for no space. Change that to make them consistent with the burst functions in returning the number of elements enqueued/dequeued, i.e. 0 or N. This change also allows the return value from enq/deq to be used directly without a branch for error checking.
--- doc/guides/rel_notes/release_17_05.rst | 11 +++ doc/guides/sample_app_ug/server_node_efd.rst | 2 +- examples/load_balancer/runtime.c | 16 ++- .../client_server_mp/mp_client/client.c | 8 +- .../client_server_mp/mp_server/main.c | 2 +- examples/qos_sched/app_thread.c | 8 +- examples/server_node_efd/node/node.c | 2 +- examples/server_node_efd/server/main.c | 2 +- lib/librte_mempool/rte_mempool_ring.c | 12 ++- lib/librte_ring/rte_ring.h | 109 +++++++-------------- test/test-pipeline/pipeline_hash.c | 2 +- test/test-pipeline/runtime.c | 8 +- test/test/test_ring.c | 46 +++++---- test/test/test_ring_perf.c | 8 +- 14 files changed, 106 insertions(+), 130 deletions(-)
doc/guides/rel_notes/release_17_05.rst +11 -0
@@ -137,6 +137,17 @@ API Changes * removed the build-time setting ``CONFIG_RTE_RING_PAUSE_REP_COUNT`` * removed the function ``rte_ring_set_water_mark`` as part of a general removal of watermarks support in the library. + * changed the return value of the enqueue and dequeue bulk functions to + match that of the burst equivalents. In all cases, ring functions which + operate on multiple packets now return the number of elements enqueued + or dequeued, as appropriate. The updated functions are: + + - ``rte_ring_mp_enqueue_bulk`` + - ``rte_ring_sp_enqueue_bulk`` + - ``rte_ring_enqueue_bulk`` + - ``rte_ring_mc_dequeue_bulk`` + - ``rte_ring_sc_dequeue_bulk`` + - ``rte_ring_dequeue_bulk`` ABI Changes -----------
doc/guides/sample_app_ug/server_node_efd.rst +1 -1
@@ -286,7 +286,7 @@ repeated infinitely. cl = &nodes[node]; if (rte_ring_enqueue_bulk(cl->rx_q, (void **)cl_rx_buf[node].buffer, - cl_rx_buf[node].count) != 0){ + cl_rx_buf[node].count) != cl_rx_buf[node].count){ for (j = 0; j < cl_rx_buf[node].count; j++) rte_pktmbuf_free(cl_rx_buf[node].buffer[j]); cl->stats.rx_drop += cl_rx_buf[node].count;
examples/load_balancer/runtime.c +7 -9
@@ -146,7 +146,7 @@ app_lcore_io_rx_buffer_to_send ( (void **) lp->rx.mbuf_out[worker].array, bsz); -if (unlikely (ret == -ENOBUFS )) { +if (unlikely (ret ==0 )) {uint32_t k;for (k =0 ; k < bsz; k ++) {struct rte_mbuf *m = lp->rx.mbuf_out[worker].array[k];
@@ -312,7 +312,7 @@ app_lcore_io_rx_flush(struct app_lcore_params_io *lp, uint32_t n_workers) (void **) lp->rx.mbuf_out[worker].array, lp->rx.mbuf_out[worker].n_mbufs); -if (unlikely (ret <0 )) { +if (unlikely (ret ==0 )) {uint32_t k;for (k =0 ; k < lp->rx.mbuf_out[worker].n_mbufs; k ++) {struct rte_mbuf *pkt_to_free = lp->rx.mbuf_out[worker].array[k];
@@ -349,9 +349,8 @@ app_lcore_io_tx( (void **) &lp->tx.mbuf_out[port].array[n_mbufs], bsz_rd); -if (unlikely (ret == -ENOENT )) { +if (unlikely (ret ==0 ))continue ; - } n_mbufs += bsz_rd;
@@ -505,9 +504,8 @@ app_lcore_worker( (void **) lp->mbuf_in.array, bsz_rd); -if (unlikely (ret == -ENOENT )) { +if (unlikely (ret ==0 ))continue ; - }#if APP_WORKER_DROP_ALL_PACKETS for (j =0 ; j < bsz_rd; j ++) {
@@ -559,7 +557,7 @@ app_lcore_worker(#if APP_STATS lp->rings_out_iters[port] ++; -if (ret ==0 ) { +if (ret >0 ) { lp->rings_out_count[port] +=1 ; }if (lp->rings_out_iters[port] ==APP_STATS ){
@@ -572,7 +570,7 @@ app_lcore_worker( }#endif -if (unlikely (ret == -ENOBUFS )) { +if (unlikely (ret ==0 )) {uint32_t k;for (k =0 ; k < bsz_wr; k ++) {struct rte_mbuf *pkt_to_free = lp->mbuf_out[port].array[k];
@@ -609,7 +607,7 @@ app_lcore_worker_flush(struct app_lcore_params_worker *lp) (void **) lp->mbuf_out[port].array, lp->mbuf_out[port].n_mbufs); -if (unlikely (ret <0 )) { +if (unlikely (ret ==0 )) {uint32_t k;for (k =0 ; k < lp->mbuf_out[port].n_mbufs; k ++) {struct rte_mbuf *pkt_to_free = lp->mbuf_out[port].array[k];
examples/multi_process/client_server_mp/mp_client/client.c +2 -6
@@ -276,14 +276,10 @@ main(int argc, char *argv[])printf ("[Press Ctrl-C to quit ...]\n" );for (;;) { -uint16_t i, rx_pkts =PKT_READ_SIZE ; +uint16_t i, rx_pkts;uint8_t port; -/* try dequeuing max possible packets first, if that fails, get the -* most we can. Loop body should only execute once, maximum */ -while (rx_pkts >0 && -unlikely (rte_ring_dequeue_bulk (rx_ring, pkts, rx_pkts) !=0 )) - rx_pkts = (uint16_t )RTE_MIN (rte_ring_count (rx_ring),PKT_READ_SIZE ); + rx_pkts =rte_ring_dequeue_burst (rx_ring, pkts,PKT_READ_SIZE );if (unlikely (rx_pkts ==0 )){if (need_flush)
examples/multi_process/client_server_mp/mp_server/main.c +1 -1
@@ -227,7 +227,7 @@ flush_rx_queue(uint16_t client) cl = &clients[client];if (rte_ring_enqueue_bulk (cl->rx_q, (void **)cl_rx_buf[client].buffer, - cl_rx_buf[client].count) !=0 ){ + cl_rx_buf[client].count) ==0 ){for (j =0 ; j < cl_rx_buf[client].count; j++)rte_pktmbuf_free (cl_rx_buf[client].buffer[j]); cl->stats.rx_drop += cl_rx_buf[client].count;
examples/qos_sched/app_thread.c +5 -3
@@ -107,7 +107,7 @@ app_rx_thread(struct thread_conf **confs) }if (unlikely (rte_ring_sp_enqueue_bulk (conf->rx_ring, - (void **)rx_mbufs, nb_rx) !=0 )) { + (void **)rx_mbufs, nb_rx) ==0 )) {for (i =0 ; i < nb_rx; i++) {rte_pktmbuf_free (rx_mbufs[i]);
@@ -180,7 +180,7 @@ app_tx_thread(struct thread_conf **confs)while ((conf = confs[conf_idx])) { retval =rte_ring_sc_dequeue_bulk (conf->tx_ring, (void **)mbufs, burst_conf.qos_dequeue); -if (likely (retval ==0 )) { +if (likely (retval !=0 )) {app_send_packets (conf, mbufs, burst_conf.qos_dequeue); conf->counter =0 ;/* reset empty read loop counter */
@@ -230,7 +230,9 @@ app_worker_thread(struct thread_conf **confs) nb_pkt =rte_sched_port_dequeue (conf->sched_port, mbufs, burst_conf.qos_dequeue);if (likely (nb_pkt >0 )) -while (rte_ring_sp_enqueue_bulk (conf->tx_ring, (void **)mbufs, nb_pkt) !=0 ); +while (rte_ring_sp_enqueue_bulk (conf->tx_ring, + (void **)mbufs, nb_pkt) ==0 ) + ;/* empty body */ conf_idx++;if (confs[conf_idx] ==NULL )
examples/server_node_efd/node/node.c +1 -1
@@ -392,7 +392,7 @@ main(int argc, char *argv[])*/ while (rx_pkts >0 &&unlikely (rte_ring_dequeue_bulk (rx_ring, pkts, - rx_pkts) !=0 )) + rx_pkts) ==0 )) rx_pkts = (uint16_t )RTE_MIN (rte_ring_count (rx_ring),PKT_READ_SIZE );
examples/server_node_efd/server/main.c +1 -1
@@ -247,7 +247,7 @@ flush_rx_queue(uint16_t node) cl = &nodes[node];if (rte_ring_enqueue_bulk (cl->rx_q, (void **)cl_rx_buf[node].buffer, - cl_rx_buf[node].count) !=0 ){ + cl_rx_buf[node].count) != cl_rx_buf[node].count){for (j =0 ; j < cl_rx_buf[node].count; j++)rte_pktmbuf_free (cl_rx_buf[node].buffer[j]); cl->stats.rx_drop += cl_rx_buf[node].count;
lib/librte_mempool/rte_mempool_ring.c +8 -4
@@ -42,26 +42,30 @@ static int common_ring_mp_enqueue(struct rte_mempool *mp, void * const *obj_table, unsigned n) { - return rte_ring_mp_enqueue_bulk(mp->pool_data, obj_table, n); + return rte_ring_mp_enqueue_bulk(mp->pool_data, + obj_table, n) == 0 ? -ENOBUFS : 0; } static int common_ring_sp_enqueue(struct rte_mempool *mp, void * const *obj_table, unsigned n) { -return rte_ring_sp_enqueue_bulk (mp->pool_data, obj_table, n); + return rte_ring_sp_enqueue_bulk(mp->pool_data, + obj_table, n) == 0 ? -ENOBUFS : 0; } static int common_ring_mc_dequeue(struct rte_mempool *mp, void **obj_table, unsigned n) { -return rte_ring_mc_dequeue_bulk (mp->pool_data, obj_table, n); + return rte_ring_mc_dequeue_bulk(mp->pool_data, + obj_table, n) == 0 ? -ENOBUFS : 0; } static int common_ring_sc_dequeue(struct rte_mempool *mp, void **obj_table, unsigned n) { -return rte_ring_sc_dequeue_bulk (mp->pool_data, obj_table, n); + return rte_ring_sc_dequeue_bulk(mp->pool_data, + obj_table, n) == 0 ? -ENOBUFS : 0; } static unsigned
lib/librte_ring/rte_ring.h +38 -71
264 lines not on this page · raw message
test/test-pipeline/pipeline_hash.c +1 -1
@@ -547,6 +547,6 @@ app_main_loop_rx_metadata(void) { app.rings_rx[i], (void **) app.mbuf_rx.array, n_mbufs); - }while (ret <0 ); + }while (ret ==0 ); } }
test/test-pipeline/runtime.c +4 -4
@@ -98,7 +98,7 @@ app_main_loop_rx(void) { app.rings_rx[i], (void **) app.mbuf_rx.array, n_mbufs); - }while (ret <0 ); + }while (ret ==0 ); } }
@@ -123,7 +123,7 @@ app_main_loop_worker(void) { (void **) worker_mbuf->array, app.burst_size_worker_read); -if (ret == -ENOENT ) +if (ret ==0 )continue ; do {
@@ -131,7 +131,7 @@ app_main_loop_worker(void) { app.rings_tx[i ^1 ], (void **) worker_mbuf->array, app.burst_size_worker_write); - }while (ret <0 ); + }while (ret ==0 ); } }
@@ -152,7 +152,7 @@ app_main_loop_tx(void) { (void **) &app.mbuf_tx[i].array[n_mbufs], app.burst_size_tx_read); -if (ret == -ENOENT ) +if (ret ==0 )continue ; n_mbufs += app.burst_size_tx_read;
test/test/test_ring.c +22 -24
152 lines not on this page · raw message
test/test/test_ring_perf.c +4 -4
@@ -195,13 +195,13 @@ enqueue_bulk(void *p)const uint64_t sp_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) -while (rte_ring_sp_enqueue_bulk (r, burst, size) !=0 ) +while (rte_ring_sp_enqueue_bulk (r, burst, size) ==0 )rte_pause ();const uint64_t sp_end =rte_rdtsc ();const uint64_t mp_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) -while (rte_ring_mp_enqueue_bulk (r, burst, size) !=0 ) +while (rte_ring_mp_enqueue_bulk (r, burst, size) ==0 )rte_pause ();const uint64_t mp_end =rte_rdtsc ();
@@ -230,13 +230,13 @@ dequeue_bulk(void *p)const uint64_t sc_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) -while (rte_ring_sc_dequeue_bulk (r, burst, size) !=0 ) +while (rte_ring_sc_dequeue_bulk (r, burst, size) ==0 )rte_pause ();const uint64_t sc_end =rte_rdtsc ();const uint64_t mc_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) -while (rte_ring_mc_dequeue_bulk (r, burst, size) !=0 ) +while (rte_ring_mc_dequeue_bulk (r, burst, size) ==0 )rte_pause ();const uint64_t mc_end =rte_rdtsc ();
Signature · 1 line
2.9.3
Re: [PATCH v5 07/14] ring: make bulk and burst fn return vals consistent
Hi Bruce,
This patch changes the behavior and causes some existing code to malfunction, e.g. bond_ethdev_stop() will get stuck here:
while (rte_ring_dequeue(port->rx_ring, &pkt) != -ENOENT)
rte_pktmbuf_free(pkt);
Another example in test/test/virtual_pmd.c: virtual_ethdev_stop().
Thanks
Zhihong
Quoted 897 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Bruce Richardson
Sent: Wednesday, March 29, 2017 9:10 PM
To: [email protected]
Cc: [email protected]; Richardson, Bruce <[email protected]>
Subject: [dpdk-dev] [PATCH v5 07/14] ring: make bulk and burst fn return vals consistentThe bulk fns for rings returns 0 for all elements enqueued and negative for no space. Change that to make them consistent with the burst functions in returning the number of elements enqueued/dequeued, i.e. 0 or N. This change also allows the return value from enq/deq to be used directly without a branch for error checking.
Signed-off-by Bruce Richardson <[email protected]>Reviewed-by Yuanhan Liu <[email protected]>Acked-by Olivier Matz <[email protected]>--- doc/guides/rel_notes/release_17_05.rst | 11 +++ doc/guides/sample_app_ug/server_node_efd.rst | 2 +- examples/load_balancer/runtime.c | 16 ++- .../client_server_mp/mp_client/client.c | 8 +- .../client_server_mp/mp_server/main.c | 2 +- examples/qos_sched/app_thread.c | 8 +- examples/server_node_efd/node/node.c | 2 +- examples/server_node_efd/server/main.c | 2 +- lib/librte_mempool/rte_mempool_ring.c | 12 ++- lib/librte_ring/rte_ring.h | 109 +++++++-------------- test/test-pipeline/pipeline_hash.c | 2 +- test/test-pipeline/runtime.c | 8 +- test/test/test_ring.c | 46 +++++---- test/test/test_ring_perf.c | 8 +- 14 files changed, 106 insertions(+), 130 deletions(-)doc/guides/rel_notes/release_17_05.rst +0
-0@@ -137,6 +137,17 @@ API Changes * removed the build-time setting``CONFIG_RTE_RING_PAUSE_REP_COUNT``
* removed the function ``rte_ring_set_water_mark`` as part of a general removal of watermarks support in the library.doc/guides/rel_notes/release_17_05.rst +3
-0+ * changed the return value of the enqueue and dequeue bulk functions to + match that of the burst equivalents. In all cases, ring functions which + operate on multiple packets now return the number of elementsenqueued
doc/guides/rel_notes/release_17_05.rst +8
-0+ or dequeued, as appropriate. The updated functions are: + + - ``rte_ring_mp_enqueue_bulk`` + - ``rte_ring_sp_enqueue_bulk`` + - ``rte_ring_enqueue_bulk`` + - ``rte_ring_mc_dequeue_bulk`` + - ``rte_ring_sc_dequeue_bulk`` + - ``rte_ring_dequeue_bulk`` ABI Changes -----------doc/guides/sample_app_ug/server_node_efd.rst +1
-1@@ -286,7 +286,7 @@ repeated infinitely. cl = &nodes[node]; if (rte_ring_enqueue_bulk(cl->rx_q, (void **)cl_rx_buf[node].buffer, - cl_rx_buf[node].count) != 0){ + cl_rx_buf[node].count) != cl_rx_buf[node].count){ for (j = 0; j < cl_rx_buf[node].count; j++) rte_pktmbuf_free(cl_rx_buf[node].buffer[j]); cl->stats.rx_drop += cl_rx_buf[node].count;examples/load_balancer/runtime.c +1
-1@@ -146,7 +146,7 @@ app_lcore_io_rx_buffer_to_send ( (void **) lp->rx.mbuf_out[worker].array, bsz); -if (unlikely (ret == -ENOBUFS )) { +if (unlikely (ret ==0 )) {uint32_t k;for (k =0 ; k < bsz; k ++) { struct rte_mbuf *m = lp-Quoted 1 line
rx.mbuf_out[worker].array[k];
examples/load_balancer/runtime.c +2
-1@@ -312,7 +312,7 @@ app_lcore_io_rx_flush(struct app_lcore_params_io *lp, uint32_t n_workers) (void **) lp->rx.mbuf_out[worker].array, lp->rx.mbuf_out[worker].n_mbufs); - if (unlikely(ret < 0)) { +if (unlikely (ret ==0 )) {uint32_t k;for (k =0 ; k < lp->rx.mbuf_out[worker].n_mbufs; k ++) { struct rte_mbuf *pkt_to_free = lp-Quoted 1 line
rx.mbuf_out[worker].array[k];
examples/load_balancer/runtime.c +4
-6@@ -349,9 +349,8 @@ app_lcore_io_tx( (void **) &lp- >tx.mbuf_out[port].array[n_mbufs], bsz_rd); -if (unlikely (ret == -ENOENT )) { +if (unlikely (ret ==0 ))continue ; - } n_mbufs += bsz_rd;@@ -505,9 +504,8 @@ app_lcore_worker( (void **) lp->mbuf_in.array, bsz_rd); -if (unlikely (ret == -ENOENT )) { +if (unlikely (ret ==0 ))continue ; - }#if APP_WORKER_DROP_ALL_PACKETS for (j =0 ; j < bsz_rd; j ++) {@@ -559,7 +557,7 @@ app_lcore_worker(#if APP_STATS lp->rings_out_iters[port] ++; -if (ret ==0 ) { +if (ret >0 ) { lp->rings_out_count[port] +=1 ; }if (lp->rings_out_iters[port] ==APP_STATS ){@@ -572,7 +570,7 @@ app_lcore_worker( }#endif -if (unlikely (ret == -ENOBUFS )) { +if (unlikely (ret ==0 )) {uint32_t k;for (k =0 ; k < bsz_wr; k ++) { struct rte_mbuf *pkt_to_free = lp-Quoted 1 line
mbuf_out[port].array[k];
examples/load_balancer/runtime.c +1
-1@@ -609,7 +607,7 @@ app_lcore_worker_flush(struct app_lcore_params_worker *lp) (void **) lp->mbuf_out[port].array, lp->mbuf_out[port].n_mbufs); -if (unlikely (ret <0 )) { +if (unlikely (ret ==0 )) {uint32_t k;for (k =0 ; k < lp->mbuf_out[port].n_mbufs; k ++) {struct
rte_mbuf*pkt_to_free= lp-Quoted 1 line
mbuf_out[port].array[k];
examples/multi_process/client_server_mp/mp_client/client.c +1
-2@@ -276,14 +276,10 @@ main(int argc, char *argv[])printf ("[Press Ctrl-C to quit ...]\n" );for (;;) { -uint16_t i, rx_pkts =PKT_READ_SIZE ; +uint16_t i, rx_pkts;uint8_t port; -/* try dequeuing max possible packets first, if that fails, get the
examples/multi_process/client_server_mp/mp_client/client.c +0
-1-* most we can. Loop body should only execute once, maximum */
examples/multi_process/client_server_mp/mp_client/client.c +0
-2-while (rx_pkts >0 && - unlikely(rte_ring_dequeue_bulk(rx_ring,pkts,
rx_pkts) != 0))examples/multi_process/client_server_mp/mp_client/client.c +0
-1- rx_pkts =(uint16_t)RTE_MIN(rte_ring_count(rx_ring),
PKT_READ_SIZE);examples/multi_process/client_server_mp/mp_client/client.c +1
-0+ rx_pkts = rte_ring_dequeue_burst(rx_ring, pkts,
PKT_READ_SIZE);examples/multi_process/client_server_mp/mp_client/client.c +0
-0if (unlikely (rx_pkts ==0 )){if (need_flush)examples/multi_process/client_server_mp/mp_server/main.c +1
-1@@ -227,7 +227,7 @@ flush_rx_queue(uint16_t client) cl = &clients[client];if (rte_ring_enqueue_bulk (cl->rx_q, (void **)cl_rx_buf[client].buffer, - cl_rx_buf[client].count) !=0 ){ + cl_rx_buf[client].count) ==0 ){for (j =0 ; j < cl_rx_buf[client].count; j++)rte_pktmbuf_free (cl_rx_buf[client].buffer[j]);examples/multi_process/client_server_mp/mp_server/main.c +0
-0cl->stats.rx_drop += cl_rx_buf[client].count;examples/qos_sched/app_thread.c +2
-2@@ -107,7 +107,7 @@ app_rx_thread(struct thread_conf **confs) }if (unlikely (rte_ring_sp_enqueue_bulk (conf->rx_ring, - (void **)rx_mbufs, nb_rx) != 0)) { + (void **)rx_mbufs, nb_rx) == 0)) {for (i =0 ; i < nb_rx; i++) {rte_pktmbuf_free (rx_mbufs[i]);@@ -180,7 +180,7 @@ app_tx_thread(struct thread_conf **confs)while ((conf = confs[conf_idx])) { retval =rte_ring_sc_dequeue_bulk (conf->tx_ring, (void **)mbufs, burst_conf.qos_dequeue); -if (likely (retval ==0 )) { +if (likely (retval !=0 )) {app_send_packets (conf, mbufs, burst_conf.qos_dequeue);
conf->counter= 0; /* reset empty read loop counter
*/examples/qos_sched/app_thread.c +3
-1@@ -230,7 +230,9 @@ app_worker_thread(struct thread_conf **confs) nb_pkt =rte_sched_port_dequeue (conf->sched_port, mbufs, burst_conf.qos_dequeue);if (likely (nb_pkt >0 )) -while (rte_ring_sp_enqueue_bulk (conf->tx_ring, (void **)mbufs, nb_pkt) != 0); +while (rte_ring_sp_enqueue_bulk (conf->tx_ring, + (void **)mbufs, nb_pkt) ==0 ) + ;/* empty body */ examples/qos_sched/app_thread.c +0
-0conf_idx++;if (confs[conf_idx] ==NULL )examples/server_node_efd/node/node.c +1
-1@@ -392,7 +392,7 @@ main(int argc, char *argv[])*/ while (rx_pkts >0 &&unlikely (rte_ring_dequeue_bulk (rx_ring, pkts, - rx_pkts) !=0 )) + rx_pkts) ==0 )) rx_pkts = (uint16_t)RTE_MIN(rte_ring_count(rx_ring),examples/server_node_efd/node/node.c +0
-0PKT_READ_SIZE);examples/server_node_efd/server/main.c +1
-1@@ -247,7 +247,7 @@ flush_rx_queue(uint16_t node) cl = &nodes[node];if (rte_ring_enqueue_bulk (cl->rx_q, (void **)cl_rx_buf[node].buffer, - cl_rx_buf[node].count) !=0 ){ + cl_rx_buf[node].count) != cl_rx_buf[node].count){for (j =0 ; j < cl_rx_buf[node].count; j++)rte_pktmbuf_free (cl_rx_buf[node].buffer[j]);examples/server_node_efd/server/main.c +0
-0cl->stats.rx_drop += cl_rx_buf[node].count;lib/librte_mempool/rte_mempool_ring.c +8
-4@@ -42,26 +42,30 @@ static int common_ring_mp_enqueue(struct rte_mempool *mp, void * const *obj_table, unsigned n) { - return rte_ring_mp_enqueue_bulk(mp->pool_data, obj_table, n); + return rte_ring_mp_enqueue_bulk(mp->pool_data, + obj_table, n) == 0 ? -ENOBUFS : 0; } static int common_ring_sp_enqueue(struct rte_mempool *mp, void * const *obj_table, unsigned n) { -return rte_ring_sp_enqueue_bulk (mp->pool_data, obj_table, n); + return rte_ring_sp_enqueue_bulk(mp->pool_data, + obj_table, n) == 0 ? -ENOBUFS : 0; } static int common_ring_mc_dequeue(struct rte_mempool *mp, void **obj_table, unsigned n) { -return rte_ring_mc_dequeue_bulk (mp->pool_data, obj_table, n); + return rte_ring_mc_dequeue_bulk(mp->pool_data, + obj_table, n) == 0 ? -ENOBUFS : 0; } static int common_ring_sc_dequeue(struct rte_mempool *mp, void **obj_table, unsigned n) { -return rte_ring_sc_dequeue_bulk (mp->pool_data, obj_table, n); + return rte_ring_sc_dequeue_bulk(mp->pool_data, + obj_table, n) == 0 ? -ENOBUFS : 0; } static unsignedlib/librte_ring/rte_ring.h +0
-0@@ -349,14 +349,10 @@ void rte_ring_dump(FILE *f, const struct rte_ring *r); * RTE_RING_QUEUE_FIXED: Enqueue a fixed number of items from a ring * RTE_RING_QUEUE_VARIABLE: Enqueue as many items a possible fromring
* @return- * Depend on the behavior value - * if behavior = RTE_RING_QUEUE_FIXED - * - 0: Success; objects enqueue. - * - -ENOBUFS: Not enough room in the ring to enqueue, no object is enqueued. - * if behavior = RTE_RING_QUEUE_VARIABLE - * - n: Actual number of objects enqueued. + * Actual number of objects enqueued. + * If behavior == RTE_RING_QUEUE_FIXED, this will be 0 or n only.*/
lib/librte_ring/rte_ring.h +1
-1-static inline int __attribute__((always_inline)) +static inline unsigned int __attribute__((always_inline))__rte_ring_mp_do_enqueue (struct rte_ring *r,void *const *obj_table, unsigned n, enum rte_ring_queue_behaviorbehavior)
{lib/librte_ring/rte_ring.h +1
-1@@ -388,7 +384,7 @@ __rte_ring_mp_do_enqueue(struct rte_ring *r, void * const *obj_table,/* check that we have enough room in ring */ if (unlikely(n > free_entries)) {if (behavior ==RTE_RING_QUEUE_FIXED ) -return -ENOBUFS ; +return 0 ;else {/* No free entry available */ lib/librte_ring/rte_ring.h +1
-1if (unlikely (free_entries ==0 ))@@ -414,7 +410,7 @@ __rte_ring_mp_do_enqueue(struct rte_ring *r, void * const *obj_table,rte_pause (); r->prod.tail = prod_next; -return (behavior ==RTE_RING_QUEUE_FIXED ) ?0 : n; +return n; }/**
lib/librte_ring/rte_ring.h +0
-0@@ -430,14 +426,10 @@ __rte_ring_mp_do_enqueue(struct rte_ring *r,void *const *obj_table, * RTE_RING_QUEUE_FIXED: Enqueue a fixed number of items from a ring * RTE_RING_QUEUE_VARIABLE: Enqueue as many items a possible fromring
* @return- * Depend on the behavior value - * if behavior = RTE_RING_QUEUE_FIXED - * - 0: Success; objects enqueue. - * - -ENOBUFS: Not enough room in the ring to enqueue, no object is enqueued. - * if behavior = RTE_RING_QUEUE_VARIABLE - * - n: Actual number of objects enqueued. + * Actual number of objects enqueued. + * If behavior == RTE_RING_QUEUE_FIXED, this will be 0 or n only.*/
lib/librte_ring/rte_ring.h +1
-1-static inline int __attribute__((always_inline)) +static inline unsigned int __attribute__((always_inline))__rte_ring_sp_do_enqueue (struct rte_ring *r,void *const *obj_table, unsigned n, enum rte_ring_queue_behaviorbehavior)
{lib/librte_ring/rte_ring.h +1
-1@@ -457,7 +449,7 @@ __rte_ring_sp_do_enqueue(struct rte_ring *r, void * const *obj_table, /* check that we have enough room in ring */ if (unlikely(n > free_entries)) {if (behavior ==RTE_RING_QUEUE_FIXED ) -return -ENOBUFS ; +return 0 ;else {/* No free entry available */ lib/librte_ring/rte_ring.h +1
-1if (unlikely (free_entries ==0 ))@@ -474,7 +466,7 @@ __rte_ring_sp_do_enqueue(struct rte_ring *r, void * const *obj_table,rte_smp_wmb (); r->prod.tail = prod_next; -return (behavior ==RTE_RING_QUEUE_FIXED ) ?0 : n; +return n; }/**
lib/librte_ring/rte_ring.h +0
-0@@ -495,16 +487,11 @@ __rte_ring_sp_do_enqueue(struct rte_ring *r,void *const *obj_table, * RTE_RING_QUEUE_FIXED: Dequeue a fixed number of items from aring
*RTE_RING_QUEUE_VARIABLE: Dequeue as many items a possible from
ring
* @return- * Depend on the behavior value - * if behavior = RTE_RING_QUEUE_FIXED - * - 0: Success; objects dequeued. - * - -ENOENT: Not enough entries in the ring to dequeue; no object is - * dequeued. - * if behavior = RTE_RING_QUEUE_VARIABLE - * - n: Actual number of objects dequeued. + * - Actual number of objects dequeued.+ * If behavior ==
RTE_RING_QUEUE_FIXED, this will be 0 or n only.
*/lib/librte_ring/rte_ring.h +2
-2-static inline int __attribute__((always_inline)) +static inline unsigned int __attribute__((always_inline))__rte_ring_mc_do_dequeue (struct rte_ring *r,void **obj_table,unsigned n,enum rte_ring_queue_behavior behavior) {@@ -536,7 +523,7 @@ __rte_ring_mc_do_dequeue(struct rte_ring *r, void **obj_table,/* Set the actual entries for dequeue */ if (n > entries) {if (behavior ==RTE_RING_QUEUE_FIXED ) -return -ENOENT ; +return 0 ;else {if (unlikely (entries ==0 ))lib/librte_ring/rte_ring.h +1
-1return 0 ;@@ -562,7 +549,7 @@ __rte_ring_mc_do_dequeue(struct rte_ring *r, void **obj_table, r->cons.tail = cons_next; -return behavior ==RTE_RING_QUEUE_FIXED ?0 : n; +return n; }/**
lib/librte_ring/rte_ring.h +0
-0@@ -580,15 +567,10 @@ __rte_ring_mc_do_dequeue(struct rte_ring *r,void **obj_table, * RTE_RING_QUEUE_FIXED: Dequeue a fixed number of items from aring
*RTE_RING_QUEUE_VARIABLE: Dequeue as many items a possible from
ring
* @return- * Depend on the behavior value - * if behavior = RTE_RING_QUEUE_FIXED - * - 0: Success; objects dequeued. - * - -ENOENT: Not enough entries in the ring to dequeue; no object is - * dequeued. - * if behavior = RTE_RING_QUEUE_VARIABLE - * - n: Actual number of objects dequeued. + * - Actual number of objects dequeued.+ * If behavior ==
RTE_RING_QUEUE_FIXED, this will be 0 or n only.
*/lib/librte_ring/rte_ring.h +2
-2-static inline int __attribute__((always_inline)) +static inline unsigned int __attribute__((always_inline))__rte_ring_sc_do_dequeue (struct rte_ring *r,void **obj_table,unsigned n,enum rte_ring_queue_behavior behavior) {@@ -607,7 +589,7 @@ __rte_ring_sc_do_dequeue(struct rte_ring *r, void **obj_table, if (n > entries) {if (behavior ==RTE_RING_QUEUE_FIXED ) -return -ENOENT ; +return 0 ;else {if (unlikely (entries ==0 ))lib/librte_ring/rte_ring.h +1
-1return 0 ;@@ -623,7 +605,7 @@ __rte_ring_sc_do_dequeue(struct rte_ring *r, void **obj_table,rte_smp_rmb (); r->cons.tail = cons_next; -return behavior ==RTE_RING_QUEUE_FIXED ?0 : n; +return n; }/**
lib/librte_ring/rte_ring.h +0
-2@@ -639,10 +621,9 @@ __rte_ring_sc_do_dequeue(struct rte_ring *r, void **obj_table, * @param n * The number of objects to add in the ring from the obj_table. * @return - * - 0: Success; objects enqueue. - * - -ENOBUFS: Not enough room in the ring to enqueue, no object isenqueued.
+ * The number of objects enqueued, either 0 or n
*/lib/librte_ring/rte_ring.h +1
-3-static inline int __attribute__((always_inline)) +static inline unsigned int __attribute__((always_inline))rte_ring_mp_enqueue_bulk (struct rte_ring *r,void *const *obj_table,unsigned n) {@@ -659,10 +640,9 @@ rte_ring_mp_enqueue_bulk(struct rte_ring *r, void* const *obj_table, * @param n * The number of objects to add in the ring from the obj_table. * @return -* - 0: Success; objects enqueued. -* - -ENOBUFS: Not enough room in the ring to enqueue; no object is enqueued.
+ * The number of objects enqueued, either 0 or n
*/lib/librte_ring/rte_ring.h +1
-3-static inline int __attribute__((always_inline)) +static inline unsigned int __attribute__((always_inline))rte_ring_sp_enqueue_bulk (struct rte_ring *r,void *const *obj_table,unsigned n) {@@ -683,10 +663,9 @@ rte_ring_sp_enqueue_bulk(struct rte_ring *r, void * const *obj_table, * @param n * The number of objects to add in the ring from the obj_table. * @return - * - 0: Success; objects enqueued. - * - -ENOBUFS: Not enough room in the ring to enqueue; no object isenqueued.
+ * The number of objects enqueued, either 0 or n
*/lib/librte_ring/rte_ring.h +2
-2-static inline int __attribute__((always_inline)) +static inline unsigned int __attribute__((always_inline))rte_ring_enqueue_bulk (struct rte_ring *r,void *const *obj_table,unsigned n) {@@ -713,7 +692,7 @@ rte_ring_enqueue_bulk(struct rte_ring *r, void * const *obj_table, static inline int __attribute__((always_inline))rte_ring_mp_enqueue (struct rte_ring *r,void *obj) { -return rte_ring_mp_enqueue_bulk (r, &obj,1 ); +return rte_ring_mp_enqueue_bulk (r, &obj,1 ) ?0 : -ENOBUFS ; }/**
lib/librte_ring/rte_ring.h +4
-9@@ -730,7 +709,7 @@ rte_ring_mp_enqueue(struct rte_ring *r, void *obj)static inline int __attribute__((always_inline))rte_ring_sp_enqueue (struct rte_ring *r,void *obj) { -return rte_ring_sp_enqueue_bulk (r, &obj,1 ); +return rte_ring_sp_enqueue_bulk (r, &obj,1 ) ?0 : -ENOBUFS ; }/** @@ -751,10 +730,7 @@ rte_ring_sp_enqueue(struct rte_ring *r, void *obj)static inline int __attribute__((always_inline))rte_ring_enqueue (struct rte_ring *r,void *obj) { -if (r->prod.single) -return rte_ring_sp_enqueue (r, obj); -else -return rte_ring_mp_enqueue (r, obj); +return rte_ring_enqueue_bulk (r, &obj,1 ) ?0 : -ENOBUFS ; }/** @@ -770,11 +746,9 @@ rte_ring_enqueue(struct rte_ring *r, void *obj)* @param n * The number of objects to dequeue from the ring to the obj_table. * @return -* - 0: Success; objects dequeued. -* - -ENOENT: Not enough entries in the ring to dequeue; no object is -* dequeued. +* The number of objects dequeued, either 0 or n */ -static inline int __attribute__((always_inline)) +static inline unsigned int __attribute__((always_inline))rte_ring_mc_dequeue_bulk (struct rte_ring *r,void **obj_table,unsigned n) { return __rte_ring_mc_do_dequeue(r, obj_table, n,
RTE_RING_QUEUE_FIXED);lib/librte_ring/rte_ring.h +2
-4@@ -791,11 +765,9 @@ rte_ring_mc_dequeue_bulk(struct rte_ring *r, void**obj_table, unsigned 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. +* The number of objects dequeued, either 0 or n */ -static inline int __attribute__((always_inline)) +static inline unsigned int __attribute__((always_inline))rte_ring_sc_dequeue_bulk (struct rte_ring *r,void **obj_table,unsigned n) {return __rte_ring_sc_do_dequeue(r,
obj_table, n,RTE_RING_QUEUE_FIXED);lib/librte_ring/rte_ring.h +2
-4@@ -815,11 +787,9 @@ rte_ring_sc_dequeue_bulk(struct rte_ring *r, void**obj_table, unsigned n) * @param n * The number of objects to dequeue from the ring to the obj_table. * @return -* - 0: Success; objects dequeued. -* - -ENOENT: Not enough entries in the ring to dequeue, no object is -* dequeued. +* The number of objects dequeued, either 0 or n */ -static inline int __attribute__((always_inline)) +static inline unsigned int __attribute__((always_inline))rte_ring_dequeue_bulk (struct rte_ring *r,void **obj_table,unsigned n) {lib/librte_ring/rte_ring.h +1
-1if (r->cons.single)@@ -846,7 +816,7 @@ rte_ring_dequeue_bulk(struct rte_ring *r, void **obj_table, unsigned n)static inline int __attribute__((always_inline))rte_ring_mc_dequeue (struct rte_ring *r,void **obj_p) { -return rte_ring_mc_dequeue_bulk (r, obj_p,1 ); +return rte_ring_mc_dequeue_bulk (r, obj_p,1 ) ?0 : -ENOBUFS ; }/**
lib/librte_ring/rte_ring.h +1
-1@@ -864,7 +834,7 @@ rte_ring_mc_dequeue(struct rte_ring *r, void **obj_p)static inline int __attribute__((always_inline))rte_ring_sc_dequeue (struct rte_ring *r,void **obj_p) { -return rte_ring_sc_dequeue_bulk (r, obj_p,1 ); +return rte_ring_sc_dequeue_bulk (r, obj_p,1 ) ?0 : -ENOBUFS ; }/**
lib/librte_ring/rte_ring.h +1
-4@@ -886,10 +856,7 @@ rte_ring_sc_dequeue(struct rte_ring *r, void **obj_p)static inline int __attribute__((always_inline))rte_ring_dequeue (struct rte_ring *r,void **obj_p) { -if (r->cons.single) -return rte_ring_sc_dequeue (r, obj_p); -else -return rte_ring_mc_dequeue (r, obj_p); +return rte_ring_dequeue_bulk (r, obj_p,1 ) ?0 : -ENOBUFS ; }/**
test/test- renamed from test/test-pipeline/pipeline_hash.c +0
-0
pipeline/pipeline_hash.c
index 10d2869..1ac0aa8 100644test/test-pipeline/pipeline_hash.c +1
-1@@ -547,6 +547,6 @@ app_main_loop_rx_metadata(void) { app.rings_rx[i], (void **) app.mbuf_rx.array, n_mbufs); - }while (ret <0 ); + }while (ret ==0 ); } }test/test-pipeline/runtime.c +4
-4@@ -98,7 +98,7 @@ app_main_loop_rx(void) { app.rings_rx[i], (void **) app.mbuf_rx.array, n_mbufs); - }while (ret <0 ); + }while (ret ==0 ); } }@@ -123,7 +123,7 @@ app_main_loop_worker(void) { (void **) worker_mbuf->array, app.burst_size_worker_read); -if (ret == -ENOENT ) +if (ret ==0 )continue ; do {@@ -131,7 +131,7 @@ app_main_loop_worker(void) { app.rings_tx[i ^1 ], (void **) worker_mbuf->array, app.burst_size_worker_write); - }while (ret <0 ); + }while (ret ==0 ); } }@@ -152,7 +152,7 @@ app_main_loop_tx(void) { (void **) &app.mbuf_tx[i].array[n_mbufs], app.burst_size_tx_read); -if (ret == -ENOENT ) +if (ret ==0 )continue ; n_mbufs += app.burst_size_tx_read;test/test/test_ring.c +3
-5@@ -117,20 +117,18 @@ test_ring_basic_full_empty(void * const src[], void *dst[]) rand = RTE_MAX(rte_rand() % RING_SIZE, 1UL);printf ("%s: iteration %u, random shift: %u;\n" , __func__, i, rand); -TEST_RING_VERIFY (-ENOBUFS !=rte_ring_enqueue_bulk (r, src, - rand)); -TEST_RING_VERIFY (0 ==rte_ring_dequeue_bulk (r, dst, rand)); +TEST_RING_VERIFY (rte_ring_enqueue_bulk (r, src, rand) !=0 ); +TEST_RING_VERIFY (rte_ring_dequeue_bulk (r, dst, rand) == rand);/* fill the ring */ -TEST_RING_VERIFY (-ENOBUFS !=rte_ring_enqueue_bulk (r, src, - rsz)); +TEST_RING_VERIFY (rte_ring_enqueue_bulk (r, src, rsz) !=0 );TEST_RING_VERIFY (0 ==rte_ring_free_count (r));TEST_RING_VERIFY (rsz ==rte_ring_count (r));TEST_RING_VERIFY (rte_ring_full (r));TEST_RING_VERIFY (0 ==rte_ring_empty (r));test/test/test_ring.c +1
-1/* empty the ring */ -TEST_RING_VERIFY (0 ==rte_ring_dequeue_bulk (r, dst, rsz)); + TEST_RING_VERIFY(rte_ring_dequeue_bulk(r, dst, rsz) ==rsz);
test/test/test_ring.c +18
-18TEST_RING_VERIFY (rsz ==rte_ring_free_count (r));TEST_RING_VERIFY (0 ==rte_ring_count (r));TEST_RING_VERIFY (0 ==rte_ring_full (r));@@ -171,37 +169,37 @@ test_ring_basic(void)printf ("enqueue 1 obj\n" ); ret =rte_ring_sp_enqueue_bulk (r, cur_src,1 ); cur_src +=1 ; -if (ret !=0 ) +if (ret ==0 ) goto fail;printf ("enqueue 2 objs\n" ); ret =rte_ring_sp_enqueue_bulk (r, cur_src,2 ); cur_src +=2 ; -if (ret !=0 ) +if (ret ==0 ) goto fail;printf ("enqueue MAX_BULK objs\n" ); ret =rte_ring_sp_enqueue_bulk (r, cur_src,MAX_BULK ); cur_src +=MAX_BULK ; -if (ret !=0 ) +if (ret ==0 ) goto fail;printf ("dequeue 1 obj\n" ); ret =rte_ring_sc_dequeue_bulk (r, cur_dst,1 ); cur_dst +=1 ; -if (ret !=0 ) +if (ret ==0 ) goto fail;printf ("dequeue 2 objs\n" ); ret =rte_ring_sc_dequeue_bulk (r, cur_dst,2 ); cur_dst +=2 ; -if (ret !=0 ) +if (ret ==0 ) goto fail;printf ("dequeue MAX_BULK objs\n" ); ret =rte_ring_sc_dequeue_bulk (r, cur_dst,MAX_BULK ); cur_dst +=MAX_BULK ; -if (ret !=0 ) +if (ret ==0 ) goto fail;/* check data */ @@ -217,37 +215,37 @@ test_ring_basic(void)printf ("enqueue 1 obj\n" ); ret =rte_ring_mp_enqueue_bulk (r, cur_src,1 ); cur_src +=1 ; -if (ret !=0 ) +if (ret ==0 ) goto fail;printf ("enqueue 2 objs\n" ); ret =rte_ring_mp_enqueue_bulk (r, cur_src,2 ); cur_src +=2 ; -if (ret !=0 ) +if (ret ==0 ) goto fail;printf ("enqueue MAX_BULK objs\n" ); ret =rte_ring_mp_enqueue_bulk (r, cur_src,MAX_BULK ); cur_src +=MAX_BULK ; -if (ret !=0 ) +if (ret ==0 ) goto fail;printf ("dequeue 1 obj\n" ); ret =rte_ring_mc_dequeue_bulk (r, cur_dst,1 ); cur_dst +=1 ; -if (ret !=0 ) +if (ret ==0 ) goto fail;printf ("dequeue 2 objs\n" ); ret =rte_ring_mc_dequeue_bulk (r, cur_dst,2 ); cur_dst +=2 ; -if (ret !=0 ) +if (ret ==0 ) goto fail;printf ("dequeue MAX_BULK objs\n" ); ret =rte_ring_mc_dequeue_bulk (r, cur_dst,MAX_BULK ); cur_dst +=MAX_BULK ; -if (ret !=0 ) +if (ret ==0 ) goto fail;/* check data */ @@ -264,11 +262,11 @@ test_ring_basic(void)for (i =0 ; i<RING_SIZE /MAX_BULK ; i++) { ret =rte_ring_mp_enqueue_bulk (r, cur_src,MAX_BULK ); cur_src +=MAX_BULK ; -if (ret !=0 ) +if (ret ==0 ) goto fail; ret =rte_ring_mc_dequeue_bulk (r, cur_dst,MAX_BULK ); cur_dst +=MAX_BULK ; -if (ret !=0 ) +if (ret ==0 ) goto fail; }@@ -294,25 +292,25 @@ test_ring_basic(void) ret =rte_ring_enqueue_bulk (r, cur_src, num_elems); cur_src += num_elems; -if (ret !=0 ) { +if (ret ==0 ) {printf ("Cannot enqueue\n" ); goto fail; } ret =rte_ring_enqueue_bulk (r, cur_src, num_elems); cur_src += num_elems; -if (ret !=0 ) { +if (ret ==0 ) {printf ("Cannot enqueue\n" ); goto fail; } ret =rte_ring_dequeue_bulk (r, cur_dst, num_elems); cur_dst += num_elems; -if (ret !=0 ) { +if (ret ==0 ) {printf ("Cannot dequeue\n" ); goto fail; } ret =rte_ring_dequeue_bulk (r, cur_dst, num_elems); cur_dst += num_elems; -if (ret !=0 ) { +if (ret ==0 ) {printf ("Cannot dequeue2\n" ); goto fail; }test/test/test_ring_perf.c +4
-5@@ -195,13 +195,13 @@ enqueue_bulk(void *p)const uint64_t sp_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) -while (rte_ring_sp_enqueue_bulk (r, burst, size) !=0 ) +while (rte_ring_sp_enqueue_bulk (r, burst, size) ==0 )rte_pause ();const uint64_t sp_end =rte_rdtsc ();const uint64_t mp_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) -while (rte_ring_mp_enqueue_bulk (r, burst, size) !=0 ) +while (rte_ring_mp_enqueue_bulk (r, burst, size) ==0 )rte_pause ();const uint64_t mp_end =rte_rdtsc ();@@ -230,13 +230,13 @@ dequeue_bulk(void *p)const uint64_t sc_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) -while (rte_ring_sc_dequeue_bulk (r, burst, size) !=0 ) +while (rte_ring_sc_dequeue_bulk (r, burst, size) ==0 )rte_pause ();const uint64_t sc_end =rte_rdtsc ();const uint64_t mc_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) -while (rte_ring_mc_dequeue_bulk (r, burst, size) !=0 ) +while (rte_ring_mc_dequeue_bulk (r, burst, size) ==0 )rte_pause ();const uint64_t mc_end =rte_rdtsc (); --2.9.3
Re: [PATCH v5 07/14] ring: make bulk and burst fn return vals consistent
Quoted 5 lines · Zhihong
Hi Bruce,
This patch changes the behavior and causes some existing code to malfunction, e.g.
bond_ethdev_stop()will get stuck here:
Quoted 9 lines
while (
rte_ring_dequeue(port->rx_ring, &pkt)!=-ENOENT)rte_pktmbuf_free(pkt);Another example in
test/test/virtual_pmd.c:virtual_ethdev_stop().Thanks
Zhihong
Actually, the behaviour of dequeue function should not be changing, so this error initially confused me. However, it looks like a typo in my patchset, compare function API comment, vs implementation:
* @return
* - 0: Success, objects dequeued.
* - -ENOENT: Not enough entries in the ring to dequeue, no object is
* dequeued.
rte_ring_dequeue_bulk(r, obj_p, 1, NULL) ? 0 : -ENOBUFS;
So it looks like I put in ENOBUFS instead of ENOENT when modifying the line. I'll do up a patch to fix that.
/Bruce
PATCH v5 8/14 ring: allow enqueue fns to return free space value
In reply to Bruce RichardsonAdd an extra parameter to the ring enqueue burst/bulk functions so that those functions can optionally return the amount of free space in the ring. This information can be used by applications in a number of ways, for instance, with single-producer queues, it provides a max enqueue size which is guaranteed to work. It can also be used to implement watermark functionality in apps, replacing the older functionality with a more flexible version, which enables apps to implement multiple watermark thresholds, rather than just one.
---
V5: Added missing updates to perf thread example.
Added missing doxygen comments to new functions.
V4: Added missing updates to crypto PMDs.
--- doc/guides/rel_notes/release_17_05.rst | 3 + doc/guides/sample_app_ug/server_node_efd.rst | 2 +- drivers/crypto/armv8/rte_armv8_pmd.c | 6 +- drivers/crypto/kasumi/rte_kasumi_pmd.c | 4 +- drivers/crypto/snow3g/rte_snow3g_pmd.c | 4 +- drivers/crypto/zuc/rte_zuc_pmd.c | 2 +- drivers/net/ring/rte_eth_ring.c | 2 +- examples/distributor/main.c | 3 +- examples/load_balancer/runtime.c | 12 ++- .../client_server_mp/mp_server/main.c | 2 +- examples/packet_ordering/main.c | 7 +- examples/performance-thread/l3fwd-thread/main.c | 4 +- examples/qos_sched/app_thread.c | 4 +- examples/server_node_efd/server/main.c | 2 +- lib/librte_hash/rte_cuckoo_hash.c | 2 +- lib/librte_mempool/rte_mempool_ring.c | 4 +- lib/librte_pdump/rte_pdump.c | 2 +- lib/librte_port/rte_port_ras.c | 2 +- lib/librte_port/rte_port_ring.c | 28 +++--- lib/librte_ring/rte_ring.h | 107 ++++++++++++--------- test/test-pipeline/pipeline_hash.c | 3 +- test/test-pipeline/runtime.c | 5 +- test/test/test_link_bonding_mode4.c | 3 +- test/test/test_pmd_ring_perf.c | 5 +- test/test/test_ring.c | 55 +++++------ test/test/test_ring_perf.c | 16 +-- test/test/test_table_ports.c | 4 +- test/test/virtual_pmd.c | 4 +- 28 files changed, 169 insertions(+), 128 deletions(-)
doc/guides/rel_notes/release_17_05.rst +3 -0
@@ -137,6 +137,9 @@ API Changes * removed the build-time setting ``CONFIG_RTE_RING_PAUSE_REP_COUNT`` * removed the function ``rte_ring_set_water_mark`` as part of a general removal of watermarks support in the library. + * added an extra parameter to the burst/bulk enqueue functions to + return the number of free spaces in the ring after enqueue. This can + be used by an application to implement its own watermark functionality. * changed the return value of the enqueue and dequeue bulk functions to match that of the burst equivalents. In all cases, ring functions which operate on multiple packets now return the number of elements enqueued
doc/guides/sample_app_ug/server_node_efd.rst +1 -1
@@ -286,7 +286,7 @@ repeated infinitely. cl = &nodes[node]; if (rte_ring_enqueue_bulk(cl->rx_q, (void **)cl_rx_buf[node].buffer, - cl_rx_buf[node].count) != cl_rx_buf[node].count){ + cl_rx_buf[node].count, NULL) != cl_rx_buf[node].count){ for (j = 0; j < cl_rx_buf[node].count; j++) rte_pktmbuf_free(cl_rx_buf[node].buffer[j]); cl->stats.rx_drop += cl_rx_buf[node].count;
drivers/crypto/armv8/rte_armv8_pmd.c +4 -2
@@ -739,13 +739,15 @@ armv8_crypto_pmd_enqueue_burst(void *queue_pair, struct rte_crypto_op **ops, goto enqueue_err; } - retval =rte_ring_enqueue_burst (qp->processed_ops, (void *)ops, i); + retval =rte_ring_enqueue_burst (qp->processed_ops, (void *)ops, i, +NULL ); qp->stats.enqueued_count += retval;return retval; enqueue_err: - retval =rte_ring_enqueue_burst (qp->processed_ops, (void *)ops, i); + retval =rte_ring_enqueue_burst (qp->processed_ops, (void *)ops, i, +NULL );if (ops[i] !=NULL ) ops[i]->status =RTE_CRYPTO_OP_STATUS_INVALID_ARGS ;
drivers/crypto/kasumi/rte_kasumi_pmd.c +2 -2
@@ -359,7 +359,7 @@ process_ops(struct rte_crypto_op **ops, struct kasumi_session *session, } enqueued_ops =rte_ring_enqueue_burst (qp->processed_ops, - (void **)ops, processed_ops); + (void **)ops, processed_ops,NULL ); qp->qp_stats.enqueued_count += enqueued_ops; *accumulated_enqueued_ops += enqueued_ops;
@@ -410,7 +410,7 @@ process_op_bit(struct rte_crypto_op *op, struct kasumi_session *session, } enqueued_op =rte_ring_enqueue_burst (qp->processed_ops, (void **)&op, - processed_op); + processed_op,NULL ); qp->qp_stats.enqueued_count += enqueued_op; *accumulated_enqueued_ops += enqueued_op;
drivers/crypto/snow3g/rte_snow3g_pmd.c +2 -2
@@ -363,7 +363,7 @@ process_ops(struct rte_crypto_op **ops, struct snow3g_session *session, } enqueued_ops =rte_ring_enqueue_burst (qp->processed_ops, - (void **)ops, processed_ops); + (void **)ops, processed_ops,NULL ); qp->qp_stats.enqueued_count += enqueued_ops; *accumulated_enqueued_ops += enqueued_ops;
@@ -414,7 +414,7 @@ process_op_bit(struct rte_crypto_op *op, struct snow3g_session *session, } enqueued_op =rte_ring_enqueue_burst (qp->processed_ops, - (void **)&op, processed_op); + (void **)&op, processed_op,NULL ); qp->qp_stats.enqueued_count += enqueued_op; *accumulated_enqueued_ops += enqueued_op;
drivers/crypto/zuc/rte_zuc_pmd.c +1 -1
@@ -339,7 +339,7 @@ process_ops(struct rte_crypto_op **ops, struct zuc_session *session, } enqueued_ops =rte_ring_enqueue_burst (qp->processed_ops, - (void **)ops, processed_ops); + (void **)ops, processed_ops,NULL ); qp->qp_stats.enqueued_count += enqueued_ops; *accumulated_enqueued_ops += enqueued_ops;
drivers/net/ring/rte_eth_ring.c +1 -1
@@ -102,7 +102,7 @@ eth_ring_tx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs)void **ptrs = (void *)&bufs[0 ];struct ring_queue *r = q;const uint16_t nb_tx = (uint16_t )rte_ring_enqueue_burst (r->rng, - ptrs, nb_bufs); + ptrs, nb_bufs,NULL );if (r->rng->flags &RING_F_SP_ENQ ) { r->tx_pkts.cnt += nb_tx; r->err_pkts.cnt += nb_bufs - nb_tx;
examples/distributor/main.c +2 -1
@@ -238,7 +238,8 @@ lcore_rx(struct lcore_params *p)continue ; } -uint16_t sent =rte_ring_enqueue_burst (r, (void *)bufs, nb_ret); +uint16_t sent =rte_ring_enqueue_burst (r, (void *)bufs, + nb_ret,NULL ); app_stats.rx.enqueued_pkts += sent;if (unlikely (sent < nb_ret)) { RTE_LOG_DP(DEBUG, DISTRAPP,
examples/load_balancer/runtime.c +8 -4
@@ -144,7 +144,8 @@ app_lcore_io_rx_buffer_to_send ( ret =rte_ring_sp_enqueue_bulk ( lp->rx.rings[worker], (void **) lp->rx.mbuf_out[worker].array, - bsz); + bsz, +NULL );if (unlikely (ret ==0 )) {uint32_t k;
@@ -310,7 +311,8 @@ app_lcore_io_rx_flush(struct app_lcore_params_io *lp, uint32_t n_workers) ret =rte_ring_sp_enqueue_bulk ( lp->rx.rings[worker], (void **) lp->rx.mbuf_out[worker].array, - lp->rx.mbuf_out[worker].n_mbufs); + lp->rx.mbuf_out[worker].n_mbufs, +NULL );if (unlikely (ret ==0 )) {uint32_t k;
@@ -553,7 +555,8 @@ app_lcore_worker( ret =rte_ring_sp_enqueue_bulk ( lp->rings_out[port], (void **) lp->mbuf_out[port].array, - bsz_wr); + bsz_wr, +NULL );#if APP_STATS lp->rings_out_iters[port] ++;
@@ -605,7 +608,8 @@ app_lcore_worker_flush(struct app_lcore_params_worker *lp) ret =rte_ring_sp_enqueue_bulk ( lp->rings_out[port], (void **) lp->mbuf_out[port].array, - lp->mbuf_out[port].n_mbufs); + lp->mbuf_out[port].n_mbufs, +NULL );if (unlikely (ret ==0 )) {uint32_t k;
examples/multi_process/client_server_mp/mp_server/main.c +1 -1
@@ -227,7 +227,7 @@ flush_rx_queue(uint16_t client) cl = &clients[client];if (rte_ring_enqueue_bulk (cl->rx_q, (void **)cl_rx_buf[client].buffer, - cl_rx_buf[client].count) ==0 ){ + cl_rx_buf[client].count,NULL ) ==0 ){for (j =0 ; j < cl_rx_buf[client].count; j++)rte_pktmbuf_free (cl_rx_buf[client].buffer[j]); cl->stats.rx_drop += cl_rx_buf[client].count;
examples/packet_ordering/main.c +4 -3
@@ -421,8 +421,8 @@ rx_thread(struct rte_ring *ring_out) pkts[i++]->seqn = seqn++;/* enqueue to rx_to_workers ring */ - ret =rte_ring_enqueue_burst (ring_out, (void *) pkts, - nb_rx_pkts); + ret =rte_ring_enqueue_burst (ring_out, + (void *)pkts, nb_rx_pkts,NULL ); app_stats.rx.enqueue_pkts += ret;if (unlikely (ret < nb_rx_pkts)) { app_stats.rx.enqueue_failed_pkts +=
@@ -473,7 +473,8 @@ worker_thread(void *args_ptr) burst_buffer[i++]->port ^= xor_val;/* enqueue the modified mbufs to workers_to_tx ring */ - ret =rte_ring_enqueue_burst (ring_out, (void *)burst_buffer, burst_size); + ret =rte_ring_enqueue_burst (ring_out, (void *)burst_buffer, + burst_size,NULL );__sync_fetch_and_add (&app_stats.wkr.enqueue_pkts, ret);if (unlikely (ret < burst_size)) {/* Return the mbufs to their respective pool, dropping packets */
examples/performance-thread/l3fwd-thread/main.c +2 -2
@@ -2213,7 +2213,7 @@ lthread_rx(void *dummy) ret =rte_ring_sp_enqueue_burst ( rx_conf->ring[worker_id], (void **) pkts_burst, - nb_rx); + nb_rx,NULL ); new_len = old_len + ret;
@@ -2453,7 +2453,7 @@ pthread_rx(void *dummy)SET_CPU_BUSY (rx_conf,CPU_PROCESS ); worker_id = (worker_id +1 ) % rx_conf->n_ring; n =rte_ring_sp_enqueue_burst (rx_conf->ring[worker_id], - (void **)pkts_burst, nb_rx); + (void **)pkts_burst, nb_rx,NULL );if (unlikely (n != nb_rx)) {uint32_t k;
examples/qos_sched/app_thread.c +2 -2
@@ -107,7 +107,7 @@ app_rx_thread(struct thread_conf **confs) }if (unlikely (rte_ring_sp_enqueue_bulk (conf->rx_ring, - (void **)rx_mbufs, nb_rx) ==0 )) { + (void **)rx_mbufs, nb_rx,NULL ) ==0 )) {for (i =0 ; i < nb_rx; i++) {rte_pktmbuf_free (rx_mbufs[i]);
@@ -231,7 +231,7 @@ app_worker_thread(struct thread_conf **confs) burst_conf.qos_dequeue);if (likely (nb_pkt >0 ))while (rte_ring_sp_enqueue_bulk (conf->tx_ring, - (void **)mbufs, nb_pkt) ==0 ) + (void **)mbufs, nb_pkt,NULL ) ==0 ) ;/* empty body */ conf_idx++;
examples/server_node_efd/server/main.c +1 -1
@@ -247,7 +247,7 @@ flush_rx_queue(uint16_t node) cl = &nodes[node];if (rte_ring_enqueue_bulk (cl->rx_q, (void **)cl_rx_buf[node].buffer, - cl_rx_buf[node].count) != cl_rx_buf[node].count){ + cl_rx_buf[node].count,NULL ) != cl_rx_buf[node].count){for (j =0 ; j < cl_rx_buf[node].count; j++)rte_pktmbuf_free (cl_rx_buf[node].buffer[j]); cl->stats.rx_drop += cl_rx_buf[node].count;
lib/librte_hash/rte_cuckoo_hash.c +1 -1
@@ -808,7 +808,7 @@ remove_entry(const struct rte_hash *h, struct rte_hash_bucket *bkt, unsigned i)/* Need to enqueue the free slots in global ring. */ n_slots =rte_ring_mp_enqueue_burst (h->free_slots, cached_free_slots->objs, -LCORE_CACHE_SIZE ); +LCORE_CACHE_SIZE ,NULL ); cached_free_slots->len -= n_slots; }/* Put index of new free slot in cache. */
lib/librte_mempool/rte_mempool_ring.c +2 -2
@@ -43,7 +43,7 @@ common_ring_mp_enqueue(struct rte_mempool *mp, void * const *obj_table, unsigned n) {return rte_ring_mp_enqueue_bulk (mp->pool_data, - obj_table, n) ==0 ? -ENOBUFS :0 ; + obj_table, n,NULL ) ==0 ? -ENOBUFS :0 ; } static int
@@ -51,7 +51,7 @@ common_ring_sp_enqueue(struct rte_mempool *mp, void * const *obj_table, unsigned n) {return rte_ring_sp_enqueue_bulk (mp->pool_data, - obj_table, n) ==0 ? -ENOBUFS :0 ; + obj_table, n,NULL ) ==0 ? -ENOBUFS :0 ; } static int
lib/librte_pdump/rte_pdump.c +1 -1
@@ -197,7 +197,7 @@ pdump_copy(struct rte_mbuf **pkts, uint16_t nb_pkts, void *user_params) dup_bufs[d_pkts++] = p; } - ring_enq =rte_ring_enqueue_burst (ring, (void *)dup_bufs, d_pkts); + ring_enq =rte_ring_enqueue_burst (ring, (void *)dup_bufs, d_pkts,NULL );if (unlikely (ring_enq < d_pkts)) {RTE_LOG (DEBUG ,PDUMP ,"only %d of packets enqueued to ring\n" , ring_enq);
lib/librte_port/rte_port_ras.c +1 -1
@@ -167,7 +167,7 @@ send_burst(struct rte_port_ring_writer_ras *p)uint32_t nb_tx; nb_tx =rte_ring_sp_enqueue_burst (p->ring, (void **)p->tx_buf, - p->tx_buf_count); + p->tx_buf_count,NULL );RTE_PORT_RING_WRITER_RAS_STATS_PKTS_DROP_ADD (p, p->tx_buf_count - nb_tx);for ( ; nb_tx < p->tx_buf_count; nb_tx++)
lib/librte_port/rte_port_ring.c +16 -12
@@ -241,7 +241,7 @@ send_burst(struct rte_port_ring_writer *p)uint32_t nb_tx; nb_tx =rte_ring_sp_enqueue_burst (p->ring, (void **)p->tx_buf, - p->tx_buf_count); + p->tx_buf_count,NULL );RTE_PORT_RING_WRITER_STATS_PKTS_DROP_ADD (p, p->tx_buf_count - nb_tx);for ( ; nb_tx < p->tx_buf_count; nb_tx++)
@@ -256,7 +256,7 @@ send_burst_mp(struct rte_port_ring_writer *p)uint32_t nb_tx; nb_tx =rte_ring_mp_enqueue_burst (p->ring, (void **)p->tx_buf, - p->tx_buf_count); + p->tx_buf_count,NULL );RTE_PORT_RING_WRITER_STATS_PKTS_DROP_ADD (p, p->tx_buf_count - nb_tx);for ( ; nb_tx < p->tx_buf_count; nb_tx++)
@@ -318,11 +318,11 @@ rte_port_ring_writer_tx_bulk_internal(void *port,RTE_PORT_RING_WRITER_STATS_PKTS_IN_ADD (p, n_pkts);if (is_multi) - n_pkts_ok =rte_ring_mp_enqueue_burst (p->ring, (void **)pkts, - n_pkts); + n_pkts_ok =rte_ring_mp_enqueue_burst (p->ring, + (void **)pkts, n_pkts,NULL );else - n_pkts_ok =rte_ring_sp_enqueue_burst (p->ring, (void **)pkts, - n_pkts); + n_pkts_ok =rte_ring_sp_enqueue_burst (p->ring, + (void **)pkts, n_pkts,NULL );RTE_PORT_RING_WRITER_STATS_PKTS_DROP_ADD (p, n_pkts - n_pkts_ok);for ( ; n_pkts_ok < n_pkts; n_pkts_ok++) {
@@ -517,7 +517,7 @@ send_burst_nodrop(struct rte_port_ring_writer_nodrop *p)uint32_t nb_tx =0 , i; nb_tx =rte_ring_sp_enqueue_burst (p->ring, (void **)p->tx_buf, - p->tx_buf_count); + p->tx_buf_count,NULL );/* We sent all the packets in a first try */ if (nb_tx >= p->tx_buf_count) {
@@ -527,7 +527,8 @@ send_burst_nodrop(struct rte_port_ring_writer_nodrop *p)for (i =0 ; i < p->n_retries; i++) { nb_tx +=rte_ring_sp_enqueue_burst (p->ring, - (void **) (p->tx_buf + nb_tx), p->tx_buf_count - nb_tx); + (void **) (p->tx_buf + nb_tx), + p->tx_buf_count - nb_tx,NULL );/* We sent all the packets in more than one try */ if (nb_tx >= p->tx_buf_count) {
@@ -550,7 +551,7 @@ send_burst_mp_nodrop(struct rte_port_ring_writer_nodrop *p)uint32_t nb_tx =0 , i; nb_tx =rte_ring_mp_enqueue_burst (p->ring, (void **)p->tx_buf, - p->tx_buf_count); + p->tx_buf_count,NULL );/* We sent all the packets in a first try */ if (nb_tx >= p->tx_buf_count) {
@@ -560,7 +561,8 @@ send_burst_mp_nodrop(struct rte_port_ring_writer_nodrop *p)for (i =0 ; i < p->n_retries; i++) { nb_tx +=rte_ring_mp_enqueue_burst (p->ring, - (void **) (p->tx_buf + nb_tx), p->tx_buf_count - nb_tx); + (void **) (p->tx_buf + nb_tx), + p->tx_buf_count - nb_tx,NULL );/* We sent all the packets in more than one try */ if (nb_tx >= p->tx_buf_count) {
@@ -633,10 +635,12 @@ rte_port_ring_writer_nodrop_tx_bulk_internal(void *port,RTE_PORT_RING_WRITER_NODROP_STATS_PKTS_IN_ADD (p, n_pkts);if (is_multi) n_pkts_ok = -rte_ring_mp_enqueue_burst (p->ring, (void **)pkts, n_pkts); +rte_ring_mp_enqueue_burst (p->ring, + (void **)pkts, n_pkts,NULL );else n_pkts_ok = -rte_ring_sp_enqueue_burst (p->ring, (void **)pkts, n_pkts); +rte_ring_sp_enqueue_burst (p->ring, + (void **)pkts, n_pkts,NULL );if (n_pkts_ok >= n_pkts)return 0 ;
lib/librte_ring/rte_ring.h +62 -45
244 lines not on this page · raw message
test/test-pipeline/pipeline_hash.c +2 -1
@@ -546,7 +546,8 @@ app_main_loop_rx_metadata(void) { ret =rte_ring_sp_enqueue_bulk ( app.rings_rx[i], (void **) app.mbuf_rx.array, - n_mbufs); + n_mbufs, +NULL ); }while (ret ==0 ); } }
test/test-pipeline/runtime.c +3 -2
@@ -97,7 +97,7 @@ app_main_loop_rx(void) { ret =rte_ring_sp_enqueue_bulk ( app.rings_rx[i], (void **) app.mbuf_rx.array, - n_mbufs); + n_mbufs,NULL ); }while (ret ==0 ); } }
@@ -130,7 +130,8 @@ app_main_loop_worker(void) { ret =rte_ring_sp_enqueue_bulk ( app.rings_tx[i ^1 ], (void **) worker_mbuf->array, - app.burst_size_worker_write); + app.burst_size_worker_write, +NULL ); }while (ret ==0 ); } }
test/test/test_link_bonding_mode4.c +2 -1
@@ -206,7 +206,8 @@ slave_get_pkts(struct slave_conf *slave, struct rte_mbuf **buf, uint16_t size)static int slave_put_pkts (struct slave_conf *slave,struct rte_mbuf **buf,uint16_t size) { -return rte_ring_enqueue_burst (slave->rx_queue, (void **)buf, size); +return rte_ring_enqueue_burst (slave->rx_queue, (void **)buf, + size,NULL ); } static uint16_t
test/test/test_pmd_ring_perf.c +3 -2
@@ -98,7 +98,7 @@ test_single_enqueue_dequeue(void)const uint64_t sc_start =rte_rdtsc_precise ();rte_compiler_barrier ();for (i =0 ; i < iterations; i++) { -rte_ring_enqueue_bulk (r, &burst,1 ); +rte_ring_enqueue_bulk (r, &burst,1 ,NULL );rte_ring_dequeue_bulk (r, &burst,1 ); }const uint64_t sc_end =rte_rdtsc_precise ();
@@ -131,7 +131,8 @@ test_bulk_enqueue_dequeue(void)for (sz =0 ; sz <sizeof (bulk_sizes)/sizeof (bulk_sizes[0 ]); sz++) {const uint64_t sc_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) { -rte_ring_sp_enqueue_bulk (r, (void *)burst, bulk_sizes[sz]); +rte_ring_sp_enqueue_bulk (r, (void *)burst, + bulk_sizes[sz],NULL );rte_ring_sc_dequeue_bulk (r, (void *)burst, bulk_sizes[sz]); }const uint64_t sc_end =rte_rdtsc ();
test/test/test_ring.c +28 -27
203 lines not on this page · raw message
test/test/test_ring_perf.c +10 -6
@@ -195,13 +195,13 @@ enqueue_bulk(void *p)const uint64_t sp_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) -while (rte_ring_sp_enqueue_bulk (r, burst, size) ==0 ) +while (rte_ring_sp_enqueue_bulk (r, burst, size,NULL ) ==0 )rte_pause ();const uint64_t sp_end =rte_rdtsc ();const uint64_t mp_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) -while (rte_ring_mp_enqueue_bulk (r, burst, size) ==0 ) +while (rte_ring_mp_enqueue_bulk (r, burst, size,NULL ) ==0 )rte_pause ();const uint64_t mp_end =rte_rdtsc ();
@@ -323,14 +323,16 @@ test_burst_enqueue_dequeue(void)for (sz =0 ; sz <sizeof (bulk_sizes)/sizeof (bulk_sizes[0 ]); sz++) {const uint64_t sc_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) { -rte_ring_sp_enqueue_burst (r, burst, bulk_sizes[sz]); +rte_ring_sp_enqueue_burst (r, burst, + bulk_sizes[sz],NULL );rte_ring_sc_dequeue_burst (r, burst, bulk_sizes[sz]); }const uint64_t sc_end =rte_rdtsc ();const uint64_t mc_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) { -rte_ring_mp_enqueue_burst (r, burst, bulk_sizes[sz]); +rte_ring_mp_enqueue_burst (r, burst, + bulk_sizes[sz],NULL );rte_ring_mc_dequeue_burst (r, burst, bulk_sizes[sz]); }const uint64_t mc_end =rte_rdtsc ();
@@ -357,14 +359,16 @@ test_bulk_enqueue_dequeue(void)for (sz =0 ; sz <sizeof (bulk_sizes)/sizeof (bulk_sizes[0 ]); sz++) {const uint64_t sc_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) { -rte_ring_sp_enqueue_bulk (r, burst, bulk_sizes[sz]); +rte_ring_sp_enqueue_bulk (r, burst, + bulk_sizes[sz],NULL );rte_ring_sc_dequeue_bulk (r, burst, bulk_sizes[sz]); }const uint64_t sc_end =rte_rdtsc ();const uint64_t mc_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) { -rte_ring_mp_enqueue_bulk (r, burst, bulk_sizes[sz]); +rte_ring_mp_enqueue_bulk (r, burst, + bulk_sizes[sz],NULL );rte_ring_mc_dequeue_bulk (r, burst, bulk_sizes[sz]); }const uint64_t mc_end =rte_rdtsc ();
test/test/test_table_ports.c +2 -2
@@ -80,7 +80,7 @@ test_port_ring_reader(void) mbuf[0 ] = (void *)rte_pktmbuf_alloc (pool); expected_pkts =rte_ring_sp_enqueue_burst (port_ring_reader_params.ring, - mbuf,1 ); + mbuf,1 ,NULL ); received_pkts = rte_port_ring_reader_ops.f_rx (port, res_mbuf,1 );if (received_pkts < expected_pkts)
@@ -93,7 +93,7 @@ test_port_ring_reader(void) mbuf[i] =rte_pktmbuf_alloc (pool); expected_pkts =rte_ring_sp_enqueue_burst (port_ring_reader_params.ring, - (void *const *) mbuf,RTE_PORT_IN_BURST_SIZE_MAX ); + (void *const *) mbuf,RTE_PORT_IN_BURST_SIZE_MAX ,NULL ); received_pkts = rte_port_ring_reader_ops.f_rx (port, res_mbuf,RTE_PORT_IN_BURST_SIZE_MAX );
test/test/virtual_pmd.c +2 -2
@@ -380,7 +380,7 @@ virtual_ethdev_tx_burst_success(void *queue, struct rte_mbuf **bufs, nb_pkts =0 ; else nb_pkts =rte_ring_enqueue_burst (dev_private->tx_queue, (void **)bufs, - nb_pkts); + nb_pkts,NULL );/* increment opacket count */ dev_private->eth_stats.opackets += nb_pkts;
@@ -496,7 +496,7 @@ virtual_ethdev_add_mbufs_to_rx_queue(uint8_t port_id, vrtl_eth_dev->data->dev_private;return rte_ring_enqueue_burst (dev_private->rx_queue, (void **)pkt_burst, - burst_length); + burst_length,NULL ); }int
Signature · 1 line
2.9.3
PATCH v5 9/14 ring: allow dequeue fns to return remaining entry count
In reply to Bruce RichardsonAdd an extra parameter to the ring dequeue burst/bulk functions so that those functions can optionally return the amount of remaining objs in the ring. This information can be used by applications in a number of ways, for instance, with single-consumer queues, it provides a max dequeue size which is guaranteed to work.
---
V5: Added missing updates to perf thread example.
Added missing doxygen comments to new functions.
V4: added in missing updates to crypto PMDs
--- app/pdump/main.c | 2 +- doc/guides/prog_guide/writing_efficient_code.rst | 2 +- doc/guides/rel_notes/release_17_05.rst | 8 ++ drivers/crypto/aesni_gcm/aesni_gcm_pmd.c | 2 +- drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c | 2 +- drivers/crypto/armv8/rte_armv8_pmd.c | 2 +- drivers/crypto/kasumi/rte_kasumi_pmd.c | 2 +- drivers/crypto/null/null_crypto_pmd.c | 2 +- drivers/crypto/openssl/rte_openssl_pmd.c | 2 +- drivers/crypto/snow3g/rte_snow3g_pmd.c | 2 +- drivers/crypto/zuc/rte_zuc_pmd.c | 2 +- drivers/net/bonding/rte_eth_bond_pmd.c | 3 +- drivers/net/ring/rte_eth_ring.c | 2 +- examples/distributor/main.c | 2 +- examples/load_balancer/runtime.c | 6 +- .../client_server_mp/mp_client/client.c | 3 +- examples/packet_ordering/main.c | 6 +- examples/performance-thread/l3fwd-thread/main.c | 4 +- examples/qos_sched/app_thread.c | 6 +- examples/quota_watermark/qw/main.c | 5 +- examples/server_node_efd/node/node.c | 2 +- lib/librte_hash/rte_cuckoo_hash.c | 3 +- lib/librte_mempool/rte_mempool_ring.c | 4 +- lib/librte_port/rte_port_frag.c | 3 +- lib/librte_port/rte_port_ring.c | 6 +- lib/librte_ring/rte_ring.h | 108 +++++++++++++-------- test/test-pipeline/runtime.c | 6 +- test/test/test_link_bonding_mode4.c | 3 +- test/test/test_pmd_ring_perf.c | 7 +- test/test/test_ring.c | 54 ++++++----- test/test/test_ring_perf.c | 20 ++-- test/test/test_table_acl.c | 2 +- test/test/test_table_pipeline.c | 2 +- test/test/test_table_ports.c | 8 +- test/test/virtual_pmd.c | 4 +- 35 files changed, 173 insertions(+), 124 deletions(-)
app/pdump/main.c +1 -1
@@ -496,7 +496,7 @@ pdump_rxtx(struct rte_ring *ring, uint8_t vdev_id, struct pdump_stats *stats)/* first dequeue packets from ring of primary process */ const uint16_t nb_in_deq =rte_ring_dequeue_burst (ring, - (void *)rxtx_bufs,BURST_SIZE ); + (void *)rxtx_bufs,BURST_SIZE ,NULL ); stats->dequeue_pkts += nb_in_deq;if (nb_in_deq) {
doc/guides/prog_guide/writing_efficient_code.rst +1 -1
@@ -124,7 +124,7 @@ The code algorithm that dequeues messages may be something similar to the follow while (1) { /* Process as many elements as can be dequeued. */ - count = rte_ring_dequeue_burst(ring, obj_table, MAX_BULK); + count = rte_ring_dequeue_burst(ring, obj_table, MAX_BULK, NULL); if (unlikely(count == 0)) continue;
doc/guides/rel_notes/release_17_05.rst +8 -0
@@ -140,6 +140,8 @@ API Changes * added an extra parameter to the burst/bulk enqueue functions to return the number of free spaces in the ring after enqueue. This can be used by an application to implement its own watermark functionality. + * added an extra parameter to the burst/bulk dequeue functions to return + the number elements remaining in the ring after dequeue. * changed the return value of the enqueue and dequeue bulk functions to match that of the burst equivalents. In all cases, ring functions which operate on multiple packets now return the number of elements enqueued
@@ -152,6 +154,12 @@ API Changes - ``rte_ring_sc_dequeue_bulk`` - ``rte_ring_dequeue_bulk`` + NOTE: the above functions all have different parameters as well as + different return values, due to the other listed changes above. This + means that all instances of the functions in existing code will be + flagged by the compiler. The return value usage should be checked + while fixing the compiler error due to the extra parameter. + ABI Changes -----------
drivers/crypto/aesni_gcm/aesni_gcm_pmd.c +1 -1
@@ -420,7 +420,7 @@ aesni_gcm_pmd_dequeue_burst(void *queue_pair,unsigned nb_dequeued; nb_dequeued =rte_ring_dequeue_burst (qp->processed_pkts, - (void **)ops, nb_ops); + (void **)ops, nb_ops,NULL ); qp->qp_stats.dequeued_count += nb_dequeued;return nb_dequeued;
drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c +1 -1
@@ -622,7 +622,7 @@ aesni_mb_pmd_dequeue_burst(void *queue_pair, struct rte_crypto_op **ops,unsigned nb_dequeued; nb_dequeued =rte_ring_dequeue_burst (qp->processed_ops, - (void **)ops, nb_ops); + (void **)ops, nb_ops,NULL ); qp->stats.dequeued_count += nb_dequeued;return nb_dequeued;
drivers/crypto/armv8/rte_armv8_pmd.c +1 -1
@@ -765,7 +765,7 @@ armv8_crypto_pmd_dequeue_burst(void *queue_pair, struct rte_crypto_op **ops,unsigned int nb_dequeued =0 ; nb_dequeued =rte_ring_dequeue_burst (qp->processed_ops, - (void **)ops, nb_ops); + (void **)ops, nb_ops,NULL ); qp->stats.dequeued_count += nb_dequeued;return nb_dequeued;
drivers/crypto/kasumi/rte_kasumi_pmd.c +1 -1
@@ -542,7 +542,7 @@ kasumi_pmd_dequeue_burst(void *queue_pair,unsigned nb_dequeued; nb_dequeued =rte_ring_dequeue_burst (qp->processed_ops, - (void **)c_ops, nb_ops); + (void **)c_ops, nb_ops,NULL ); qp->qp_stats.dequeued_count += nb_dequeued;return nb_dequeued;
drivers/crypto/null/null_crypto_pmd.c +1 -1
@@ -155,7 +155,7 @@ null_crypto_pmd_dequeue_burst(void *queue_pair, struct rte_crypto_op **ops,unsigned nb_dequeued; nb_dequeued =rte_ring_dequeue_burst (qp->processed_pkts, - (void **)ops, nb_ops); + (void **)ops, nb_ops,NULL ); qp->qp_stats.dequeued_count += nb_dequeued;return nb_dequeued;
drivers/crypto/openssl/rte_openssl_pmd.c +1 -1
@@ -1119,7 +1119,7 @@ openssl_pmd_dequeue_burst(void *queue_pair, struct rte_crypto_op **ops,unsigned int nb_dequeued =0 ; nb_dequeued =rte_ring_dequeue_burst (qp->processed_ops, - (void **)ops, nb_ops); + (void **)ops, nb_ops,NULL ); qp->stats.dequeued_count += nb_dequeued;return nb_dequeued;
drivers/crypto/snow3g/rte_snow3g_pmd.c +1 -1
@@ -533,7 +533,7 @@ snow3g_pmd_dequeue_burst(void *queue_pair,unsigned nb_dequeued; nb_dequeued =rte_ring_dequeue_burst (qp->processed_ops, - (void **)c_ops, nb_ops); + (void **)c_ops, nb_ops,NULL ); qp->qp_stats.dequeued_count += nb_dequeued;return nb_dequeued;
drivers/crypto/zuc/rte_zuc_pmd.c +1 -1
@@ -433,7 +433,7 @@ zuc_pmd_dequeue_burst(void *queue_pair,unsigned nb_dequeued; nb_dequeued =rte_ring_dequeue_burst (qp->processed_ops, - (void **)c_ops, nb_ops); + (void **)c_ops, nb_ops,NULL ); qp->qp_stats.dequeued_count += nb_dequeued;return nb_dequeued;
drivers/net/bonding/rte_eth_bond_pmd.c +2 -1
@@ -1008,7 +1008,8 @@ bond_ethdev_tx_burst_8023ad(void *queue, struct rte_mbuf **bufs,struct port *port = &mode_8023ad_ports[slaves[i]]; slave_slow_nb_pkts[i] =rte_ring_dequeue_burst (port->tx_ring, - slow_pkts,BOND_MODE_8023AX_SLAVE_TX_PKTS ); + slow_pkts,BOND_MODE_8023AX_SLAVE_TX_PKTS , +NULL ); slave_nb_pkts[i] = slave_slow_nb_pkts[i];for (j =0 ; j < slave_slow_nb_pkts[i]; j++)
drivers/net/ring/rte_eth_ring.c +1 -1
@@ -88,7 +88,7 @@ eth_ring_rx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs)void **ptrs = (void *)&bufs[0 ];struct ring_queue *r = q;const uint16_t nb_rx = (uint16_t )rte_ring_dequeue_burst (r->rng, - ptrs, nb_bufs); + ptrs, nb_bufs,NULL );if (r->rng->flags &RING_F_SC_DEQ ) r->rx_pkts.cnt += nb_rx;else
examples/distributor/main.c +1 -1
@@ -330,7 +330,7 @@ lcore_tx(struct rte_ring *in_r)struct rte_mbuf *bufs[BURST_SIZE ];const uint16_t nb_rx =rte_ring_dequeue_burst (in_r, - (void *)bufs,BURST_SIZE ); + (void *)bufs,BURST_SIZE ,NULL ); app_stats.tx.dequeue_pkts += nb_rx;/* if we get no traffic, flush anything we have */
examples/load_balancer/runtime.c +4 -2
@@ -349,7 +349,8 @@ app_lcore_io_tx( ret =rte_ring_sc_dequeue_bulk ( ring, (void **) &lp->tx.mbuf_out[port].array[n_mbufs], - bsz_rd); + bsz_rd, +NULL );if (unlikely (ret ==0 ))continue ;
@@ -504,7 +505,8 @@ app_lcore_worker( ret =rte_ring_sc_dequeue_bulk ( ring_in, (void **) lp->mbuf_in.array, - bsz_rd); + bsz_rd, +NULL );if (unlikely (ret ==0 ))continue ;
examples/multi_process/client_server_mp/mp_client/client.c +2 -1
@@ -279,7 +279,8 @@ main(int argc, char *argv[])uint16_t i, rx_pkts;uint8_t port; - rx_pkts =rte_ring_dequeue_burst (rx_ring, pkts,PKT_READ_SIZE ); + rx_pkts =rte_ring_dequeue_burst (rx_ring, pkts, +PKT_READ_SIZE ,NULL );if (unlikely (rx_pkts ==0 )){if (need_flush)
examples/packet_ordering/main.c +3 -3
@@ -462,7 +462,7 @@ worker_thread(void *args_ptr)/* dequeue the mbufs from rx_to_workers ring */ burst_size =rte_ring_dequeue_burst (ring_in, - (void *)burst_buffer,MAX_PKTS_BURST ); + (void *)burst_buffer,MAX_PKTS_BURST ,NULL );if (unlikely (burst_size ==0 ))continue ;
@@ -510,7 +510,7 @@ send_thread(struct send_thread_args *args)/* deque the mbufs from workers_to_tx ring */ nb_dq_mbufs =rte_ring_dequeue_burst (args->ring_in, - (void *)mbufs,MAX_PKTS_BURST ); + (void *)mbufs,MAX_PKTS_BURST ,NULL );if (unlikely (nb_dq_mbufs ==0 ))continue ;
@@ -595,7 +595,7 @@ tx_thread(struct rte_ring *ring_in)/* deque the mbufs from workers_to_tx ring */ dqnum =rte_ring_dequeue_burst (ring_in, - (void *)mbufs,MAX_PKTS_BURST ); + (void *)mbufs,MAX_PKTS_BURST ,NULL );if (unlikely (dqnum ==0 ))continue ;
examples/performance-thread/l3fwd-thread/main.c +2 -2
@@ -2077,7 +2077,7 @@ lthread_tx_per_ring(void *dummy)*/ SET_CPU_BUSY (tx_conf,CPU_POLL ); nb_rx =rte_ring_sc_dequeue_burst (ring, (void **)pkts_burst, -MAX_PKT_BURST ); +MAX_PKT_BURST ,NULL );SET_CPU_IDLE (tx_conf,CPU_POLL );if (nb_rx >0 ) {
@@ -2381,7 +2381,7 @@ pthread_tx(void *dummy)*/ SET_CPU_BUSY (tx_conf,CPU_POLL ); nb_rx =rte_ring_sc_dequeue_burst (tx_conf->ring, - (void **)pkts_burst,MAX_PKT_BURST ); + (void **)pkts_burst,MAX_PKT_BURST ,NULL );SET_CPU_IDLE (tx_conf,CPU_POLL );if (unlikely (nb_rx ==0 )) {
examples/qos_sched/app_thread.c +3 -3
@@ -179,7 +179,7 @@ app_tx_thread(struct thread_conf **confs)while ((conf = confs[conf_idx])) { retval =rte_ring_sc_dequeue_bulk (conf->tx_ring, (void **)mbufs, - burst_conf.qos_dequeue); + burst_conf.qos_dequeue,NULL );if (likely (retval !=0 )) {app_send_packets (conf, mbufs, burst_conf.qos_dequeue);
@@ -218,7 +218,7 @@ app_worker_thread(struct thread_conf **confs)/* Read packet from the ring */ nb_pkt =rte_ring_sc_dequeue_burst (conf->rx_ring, (void **)mbufs, - burst_conf.ring_burst); + burst_conf.ring_burst,NULL );if (likely (nb_pkt)) {int nb_sent =rte_sched_port_enqueue (conf->sched_port, mbufs, nb_pkt);
@@ -254,7 +254,7 @@ app_mixed_thread(struct thread_conf **confs)/* Read packet from the ring */ nb_pkt =rte_ring_sc_dequeue_burst (conf->rx_ring, (void **)mbufs, - burst_conf.ring_burst); + burst_conf.ring_burst,NULL );if (likely (nb_pkt)) {int nb_sent =rte_sched_port_enqueue (conf->sched_port, mbufs, nb_pkt);
examples/quota_watermark/qw/main.c +3 -2
@@ -247,7 +247,8 @@ pipeline_stage(__attribute__((unused)) void *args) }/* Dequeue up to quota mbuf from rx */ - nb_dq_pkts =rte_ring_dequeue_burst (rx, pkts, *quota); + nb_dq_pkts =rte_ring_dequeue_burst (rx, pkts, + *quota,NULL );if (unlikely (nb_dq_pkts <0 ))continue ;
@@ -305,7 +306,7 @@ send_stage(__attribute__((unused)) void *args)/* Dequeue packets from tx and send them */ nb_dq_pkts = (uint16_t )rte_ring_dequeue_burst (tx, - (void *) tx_pkts, *quota); + (void *) tx_pkts, *quota,NULL );rte_eth_tx_burst (dest_port_id,0 , tx_pkts, nb_dq_pkts);/* TODO: Check if nb_dq_pkts == nb_tx_pkts? */
examples/server_node_efd/node/node.c +1 -1
@@ -392,7 +392,7 @@ main(int argc, char *argv[])*/ while (rx_pkts >0 &&unlikely (rte_ring_dequeue_bulk (rx_ring, pkts, - rx_pkts) ==0 )) + rx_pkts,NULL ) ==0 )) rx_pkts = (uint16_t )RTE_MIN (rte_ring_count (rx_ring),PKT_READ_SIZE );
lib/librte_hash/rte_cuckoo_hash.c +2 -1
@@ -536,7 +536,8 @@ __rte_hash_add_key_with_hash(const struct rte_hash *h, const void *key,if (cached_free_slots->len ==0 ) {/* Need to get another burst of free slots from global ring */ n_slots =rte_ring_mc_dequeue_burst (h->free_slots, - cached_free_slots->objs,LCORE_CACHE_SIZE ); + cached_free_slots->objs, +LCORE_CACHE_SIZE ,NULL );if (n_slots ==0 )return -ENOSPC ;
lib/librte_mempool/rte_mempool_ring.c +2 -2
@@ -58,14 +58,14 @@ static int common_ring_mc_dequeue(struct rte_mempool *mp, void **obj_table, unsigned n) { return rte_ring_mc_dequeue_bulk(mp->pool_data, - obj_table, n) == 0 ? -ENOBUFS : 0; + obj_table, n, NULL) == 0 ? -ENOBUFS : 0; } static int common_ring_sc_dequeue(struct rte_mempool *mp, void **obj_table, unsigned n) { return rte_ring_sc_dequeue_bulk(mp->pool_data, - obj_table, n) == 0 ? -ENOBUFS : 0; + obj_table, n, NULL) == 0 ? -ENOBUFS : 0; } static unsigned
lib/librte_port/rte_port_frag.c +2 -1
@@ -186,7 +186,8 @@ rte_port_ring_reader_frag_rx(void *port,/* If "pkts" buffer is empty, read packet burst from ring */ if (p->n_pkts ==0 ) { p->n_pkts =rte_ring_sc_dequeue_burst (p->ring, - (void **) p->pkts,RTE_PORT_IN_BURST_SIZE_MAX ); + (void **) p->pkts,RTE_PORT_IN_BURST_SIZE_MAX , +NULL );RTE_PORT_RING_READER_FRAG_STATS_PKTS_IN_ADD (p, p->n_pkts);if (p->n_pkts ==0 )return n_pkts_out;
lib/librte_port/rte_port_ring.c +4 -2
@@ -111,7 +111,8 @@ rte_port_ring_reader_rx(void *port, struct rte_mbuf **pkts, uint32_t n_pkts)struct rte_port_ring_reader *p = (struct rte_port_ring_reader *) port;uint32_t nb_rx; - nb_rx =rte_ring_sc_dequeue_burst (p->ring, (void **) pkts, n_pkts); + nb_rx =rte_ring_sc_dequeue_burst (p->ring, (void **) pkts, + n_pkts,NULL );RTE_PORT_RING_READER_STATS_PKTS_IN_ADD (p, nb_rx);return nb_rx;
@@ -124,7 +125,8 @@ rte_port_ring_multi_reader_rx(void *port, struct rte_mbuf **pkts,struct rte_port_ring_reader *p = (struct rte_port_ring_reader *) port;uint32_t nb_rx; - nb_rx =rte_ring_mc_dequeue_burst (p->ring, (void **) pkts, n_pkts); + nb_rx =rte_ring_mc_dequeue_burst (p->ring, (void **) pkts, + n_pkts,NULL );RTE_PORT_RING_READER_STATS_PKTS_IN_ADD (p, nb_rx);return nb_rx;
lib/librte_ring/rte_ring.h +65 -43
238 lines not on this page · raw message
test/test-pipeline/runtime.c +4 -2
@@ -121,7 +121,8 @@ app_main_loop_worker(void) { ret =rte_ring_sc_dequeue_bulk ( app.rings_rx[i], (void **) worker_mbuf->array, - app.burst_size_worker_read); + app.burst_size_worker_read, +NULL );if (ret ==0 )continue ;
@@ -151,7 +152,8 @@ app_main_loop_tx(void) { ret =rte_ring_sc_dequeue_bulk ( app.rings_tx[i], (void **) &app.mbuf_tx[i].array[n_mbufs], - app.burst_size_tx_read); + app.burst_size_tx_read, +NULL );if (ret ==0 )continue ;
test/test/test_link_bonding_mode4.c +2 -1
@@ -193,7 +193,8 @@ static uint8_t lacpdu_rx_count[RTE_MAX_ETHPORTS] = {0, };static int slave_get_pkts (struct slave_conf *slave,struct rte_mbuf **buf,uint16_t size) { -return rte_ring_dequeue_burst (slave->tx_queue, (void **)buf, size); +return rte_ring_dequeue_burst (slave->tx_queue, (void **)buf, + size,NULL ); }/*
test/test/test_pmd_ring_perf.c +4 -3
@@ -67,7 +67,7 @@ test_empty_dequeue(void)const uint64_t sc_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) -rte_ring_sc_dequeue_bulk (r, burst, bulk_sizes[0 ]); +rte_ring_sc_dequeue_bulk (r, burst, bulk_sizes[0 ],NULL );const uint64_t sc_end =rte_rdtsc ();const uint64_t eth_start =rte_rdtsc ();
@@ -99,7 +99,7 @@ test_single_enqueue_dequeue(void)rte_compiler_barrier ();for (i =0 ; i < iterations; i++) {rte_ring_enqueue_bulk (r, &burst,1 ,NULL ); -rte_ring_dequeue_bulk (r, &burst,1 ); +rte_ring_dequeue_bulk (r, &burst,1 ,NULL ); }const uint64_t sc_end =rte_rdtsc_precise ();rte_compiler_barrier ();
@@ -133,7 +133,8 @@ test_bulk_enqueue_dequeue(void)for (i =0 ; i < iterations; i++) {rte_ring_sp_enqueue_bulk (r, (void *)burst, bulk_sizes[sz],NULL ); -rte_ring_sc_dequeue_bulk (r, (void *)burst, bulk_sizes[sz]); +rte_ring_sc_dequeue_bulk (r, (void *)burst, + bulk_sizes[sz],NULL ); }const uint64_t sc_end =rte_rdtsc ();
test/test/test_ring.c +28 -26
197 lines not on this page · raw message
test/test/test_ring_perf.c +12 -8
@@ -152,12 +152,12 @@ test_empty_dequeue(void)const uint64_t sc_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) -rte_ring_sc_dequeue_bulk (r, burst, bulk_sizes[0 ]); +rte_ring_sc_dequeue_bulk (r, burst, bulk_sizes[0 ],NULL );const uint64_t sc_end =rte_rdtsc ();const uint64_t mc_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) -rte_ring_mc_dequeue_bulk (r, burst, bulk_sizes[0 ]); +rte_ring_mc_dequeue_bulk (r, burst, bulk_sizes[0 ],NULL );const uint64_t mc_end =rte_rdtsc (); printf("SC empty dequeue: %.2F\n",
@@ -230,13 +230,13 @@ dequeue_bulk(void *p)const uint64_t sc_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) -while (rte_ring_sc_dequeue_bulk (r, burst, size) ==0 ) +while (rte_ring_sc_dequeue_bulk (r, burst, size,NULL ) ==0 )rte_pause ();const uint64_t sc_end =rte_rdtsc ();const uint64_t mc_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) -while (rte_ring_mc_dequeue_bulk (r, burst, size) ==0 ) +while (rte_ring_mc_dequeue_bulk (r, burst, size,NULL ) ==0 )rte_pause ();const uint64_t mc_end =rte_rdtsc ();
@@ -325,7 +325,8 @@ test_burst_enqueue_dequeue(void)for (i =0 ; i < iterations; i++) {rte_ring_sp_enqueue_burst (r, burst, bulk_sizes[sz],NULL ); -rte_ring_sc_dequeue_burst (r, burst, bulk_sizes[sz]); +rte_ring_sc_dequeue_burst (r, burst, + bulk_sizes[sz],NULL ); }const uint64_t sc_end =rte_rdtsc ();
@@ -333,7 +334,8 @@ test_burst_enqueue_dequeue(void)for (i =0 ; i < iterations; i++) {rte_ring_mp_enqueue_burst (r, burst, bulk_sizes[sz],NULL ); -rte_ring_mc_dequeue_burst (r, burst, bulk_sizes[sz]); +rte_ring_mc_dequeue_burst (r, burst, + bulk_sizes[sz],NULL ); }const uint64_t mc_end =rte_rdtsc ();
@@ -361,7 +363,8 @@ test_bulk_enqueue_dequeue(void)for (i =0 ; i < iterations; i++) {rte_ring_sp_enqueue_bulk (r, burst, bulk_sizes[sz],NULL ); -rte_ring_sc_dequeue_bulk (r, burst, bulk_sizes[sz]); +rte_ring_sc_dequeue_bulk (r, burst, + bulk_sizes[sz],NULL ); }const uint64_t sc_end =rte_rdtsc ();
@@ -369,7 +372,8 @@ test_bulk_enqueue_dequeue(void)for (i =0 ; i < iterations; i++) {rte_ring_mp_enqueue_bulk (r, burst, bulk_sizes[sz],NULL ); -rte_ring_mc_dequeue_bulk (r, burst, bulk_sizes[sz]); +rte_ring_mc_dequeue_bulk (r, burst, + bulk_sizes[sz],NULL ); }const uint64_t mc_end =rte_rdtsc ();
test/test/test_table_acl.c +1 -1
@@ -713,7 +713,7 @@ test_pipeline_single_filter(int expected_count)void *objs[RING_TX_SIZE ];struct rte_mbuf *mbuf; - ret =rte_ring_sc_dequeue_burst (rings_tx[i], objs,10 ); + ret =rte_ring_sc_dequeue_burst (rings_tx[i], objs,10 ,NULL );if (ret <=0 ) {printf ("Got no objects from ring %d - error code %d\n" , i, ret);
test/test/test_table_pipeline.c +1 -1
@@ -494,7 +494,7 @@ test_pipeline_single_filter(int test_type, int expected_count)void *objs[RING_TX_SIZE ];struct rte_mbuf *mbuf; - ret =rte_ring_sc_dequeue_burst (rings_tx[i], objs,10 ); + ret =rte_ring_sc_dequeue_burst (rings_tx[i], objs,10 ,NULL );if (ret <=0 )printf ("Got no objects from ring %d - error code %d\n" , i, ret);
test/test/test_table_ports.c +4 -4
@@ -163,7 +163,7 @@ test_port_ring_writer(void) rte_port_ring_writer_ops.f_flush (port); expected_pkts =1 ; received_pkts =rte_ring_sc_dequeue_burst (port_ring_writer_params.ring, - (void **)res_mbuf, port_ring_writer_params.tx_burst_sz); + (void **)res_mbuf, port_ring_writer_params.tx_burst_sz,NULL );if (received_pkts < expected_pkts)return -7 ;
@@ -178,7 +178,7 @@ test_port_ring_writer(void) expected_pkts =RTE_PORT_IN_BURST_SIZE_MAX ; received_pkts =rte_ring_sc_dequeue_burst (port_ring_writer_params.ring, - (void **)res_mbuf, port_ring_writer_params.tx_burst_sz); + (void **)res_mbuf, port_ring_writer_params.tx_burst_sz,NULL );if (received_pkts < expected_pkts)return -8 ;
@@ -193,7 +193,7 @@ test_port_ring_writer(void) expected_pkts =RTE_PORT_IN_BURST_SIZE_MAX ; received_pkts =rte_ring_sc_dequeue_burst (port_ring_writer_params.ring, - (void **)res_mbuf, port_ring_writer_params.tx_burst_sz); + (void **)res_mbuf, port_ring_writer_params.tx_burst_sz,NULL );if (received_pkts < expected_pkts)return -8 ;
@@ -208,7 +208,7 @@ test_port_ring_writer(void) expected_pkts =RTE_PORT_IN_BURST_SIZE_MAX ; received_pkts =rte_ring_sc_dequeue_burst (port_ring_writer_params.ring, - (void **)res_mbuf, port_ring_writer_params.tx_burst_sz); + (void **)res_mbuf, port_ring_writer_params.tx_burst_sz,NULL );if (received_pkts < expected_pkts)return -9 ;
test/test/virtual_pmd.c +2 -2
@@ -342,7 +342,7 @@ virtual_ethdev_rx_burst_success(void *queue __rte_unused, dev_private = vrtl_eth_dev->data->dev_private; rx_count =rte_ring_dequeue_burst (dev_private->rx_queue, (void **) bufs, - nb_pkts); + nb_pkts,NULL );/* increments ipackets count */ dev_private->eth_stats.ipackets += rx_count;
@@ -508,7 +508,7 @@ virtual_ethdev_get_mbufs_from_tx_queue(uint8_t port_id, dev_private = vrtl_eth_dev->data->dev_private;return rte_ring_dequeue_burst (dev_private->tx_queue, (void **)pkt_burst, - burst_length); + burst_length,NULL ); } static uint8_t
Signature · 1 line
2.9.3
PATCH v5 10/14 examples/quota_watermark: use ring space for watermarks
In reply to Bruce RichardsonNow that the enqueue function returns the amount of space in the ring, we can use that to replace the old watermark functionality. Update the example app to do so, and re-enable it in the examples Makefile.
---
v4: updated rst doc to match the code changes
--- doc/guides/sample_app_ug/quota_watermark.rst | 148 ++++++++++++++++----------- examples/Makefile | 2 +- examples/quota_watermark/qw/init.c | 5 +- examples/quota_watermark/qw/main.c | 16 +-- examples/quota_watermark/qw/main.h | 1 + examples/quota_watermark/qwctl/commands.c | 4 +- examples/quota_watermark/qwctl/qwctl.c | 2 + examples/quota_watermark/qwctl/qwctl.h | 1 + 8 files changed, 106 insertions(+), 73 deletions(-)
doc/guides/sample_app_ug/quota_watermark.rst +86 -62
@@ -1,5 +1,5 @@ .. BSD LICENSE - Copyright(c) 2010-2014 Intel Corporation. All rights reserved. + Copyright(c) 2010-2017 Intel Corporation. All rights reserved. All rights reserved. Redistribution and use in source and binary forms, with or without
@@ -31,11 +31,13 @@ Quota and Watermark Sample Application ====================================== -The Quota and Watermark sample application is a simple example of packet processing using Data Plane Development Kit (DPDK) that -showcases the use of a quota as the maximum number of packets enqueue/dequeue at a time and low and high watermarks -to signal low and high ring usage respectively. +The Quota and Watermark sample application is a simple example of packet +processing using Data Plane Development Kit (DPDK) that showcases the use +of a quota as the maximum number of packets enqueue/dequeue at a time and +low and high thresholds, or watermarks, to signal low and high ring usage +respectively. -Additionally, it shows how ring watermarks can be used to feedback congestion notifications to data producers by +Additionally, it shows how the thresholds can be used to feedback congestion notifications to data producers by temporarily stopping processing overloaded rings and sending Ethernet flow control frames. This sample application is split in two parts:
@@ -64,7 +66,7 @@ each stage of which being connected by rings, as shown in :numref:`figure_pipeli An adjustable quota value controls how many packets are being moved through the pipeline per enqueue and dequeue. -Adjustable watermark values associated with the rings control a back-off mechanism that +Adjustable threshold values associated with the rings control a back-off mechanism that tries to prevent the pipeline from being overloaded by: * Stopping enqueuing on rings for which the usage has crossed the high watermark threshold
@@ -216,25 +218,26 @@ in the *DPDK Getting Started Guide* and the *DPDK API Reference*. Shared Variables Setup ^^^^^^^^^^^^^^^^^^^^^^ -The quota and low_watermark shared variables are put into an rte_memzone using a call to setup_shared_variables(): +The quota and high and low watermark shared variables are put into an rte_memzone using a call to setup_shared_variables(): .. code-block:: c void setup_shared_variables(void) { - const struct rte_memzone *qw_memzone; - - qw_memzone = rte_memzone_reserve(QUOTA_WATERMARK_MEMZONE_NAME, 2 * sizeof(int), rte_socket_id(), RTE_MEMZONE_2MB); + const struct rte_memzone *qw_memzone; - if (qw_memzone == NULL) - rte_exit(EXIT_FAILURE, "%s\n", rte_strerror(rte_errno)); + qw_memzone = rte_memzone_reserve(QUOTA_WATERMARK_MEMZONE_NAME, + 3 * sizeof(int), rte_socket_id(), 0); + if (qw_memzone == NULL) + rte_exit(EXIT_FAILURE, "%s\n", rte_strerror(rte_errno)); - quota = qw_memzone->addr; - low_watermark = (unsigned int *) qw_memzone->addr + sizeof(int); - } + quota = qw_memzone->addr; + low_watermark = (unsigned int *) qw_memzone->addr + 1; + high_watermark = (unsigned int *) qw_memzone->addr + 2; + } -These two variables are initialized to a default value in main() and +These three variables are initialized to a default value in main() and can be changed while qw is running using the qwctl control program. Application Arguments
@@ -349,27 +352,37 @@ This is done using the following code: /* Process each port round robin style */ for (port_id = 0; port_id < RTE_MAX_ETHPORTS; port_id++) { - if (!is_bit_set(port_id, portmask)) - continue; - - ring = rings[lcore_id][port_id]; - - if (ring_state[port_id] != RING_READY) { - if (rte_ring_count(ring) > *low_watermark) - continue; - else - ring_state[port_id] = RING_READY; - } - - /* Enqueue received packets on the RX ring */ - - nb_rx_pkts = rte_eth_rx_burst(port_id, 0, pkts, *quota); - - ret = rte_ring_enqueue_bulk(ring, (void *) pkts, nb_rx_pkts); - if (ret == -EDQUOT) { - ring_state[port_id] = RING_OVERLOADED; - send_pause_frame(port_id, 1337); - } + if (!is_bit_set(port_id, portmask)) + continue; + + ring = rings[lcore_id][port_id]; + + if (ring_state[port_id] != RING_READY) { + if (rte_ring_count(ring) > *low_watermark) + continue; + else + ring_state[port_id] = RING_READY; + } + + /* Enqueue received packets on the RX ring */ + nb_rx_pkts = rte_eth_rx_burst(port_id, 0, pkts, + (uint16_t) *quota); + ret = rte_ring_enqueue_bulk(ring, (void *) pkts, + nb_rx_pkts, &free); + if (RING_SIZE - free > *high_watermark) { + ring_state[port_id] = RING_OVERLOADED; + send_pause_frame(port_id, 1337); + } + + if (ret == 0) { + + /* + * Return mbufs to the pool, + * effectively dropping packets + */ + for (i = 0; i < nb_rx_pkts; i++) + rte_pktmbuf_free(pkts[i]); + } } For each port in the port mask, the corresponding ring's pointer is fetched into ring and that ring's state is checked:
@@ -390,30 +403,40 @@ This thread is running on most of the logical cores to create and arbitrarily lo previous_lcore_id = get_previous_lcore_id(lcore_id); for (port_id = 0; port_id < RTE_MAX_ETHPORTS; port_id++) { - if (!is_bit_set(port_id, portmask)) - continue; - - tx = rings[lcore_id][port_id]; - rx = rings[previous_lcore_id][port_id]; - if (ring_state[port_id] != RING_READY) { - if (rte_ring_count(tx) > *low_watermark) - continue; - else - ring_state[port_id] = RING_READY; - } - - /* Dequeue up to quota mbuf from rx */ - - nb_dq_pkts = rte_ring_dequeue_burst(rx, pkts, *quota); - - if (unlikely(nb_dq_pkts < 0)) - continue; - - /* Enqueue them on tx */ - - ret = rte_ring_enqueue_bulk(tx, pkts, nb_dq_pkts); - if (ret == -EDQUOT) - ring_state[port_id] = RING_OVERLOADED; + if (!is_bit_set(port_id, portmask)) + continue; + + tx = rings[lcore_id][port_id]; + rx = rings[previous_lcore_id][port_id]; + + if (ring_state[port_id] != RING_READY) { + if (rte_ring_count(tx) > *low_watermark) + continue; + else + ring_state[port_id] = RING_READY; + } + + /* Dequeue up to quota mbuf from rx */ + nb_dq_pkts = rte_ring_dequeue_burst(rx, pkts, + *quota, NULL); + if (unlikely(nb_dq_pkts < 0)) + continue; + + /* Enqueue them on tx */ + ret = rte_ring_enqueue_bulk(tx, pkts, + nb_dq_pkts, &free); + if (RING_SIZE - free > *high_watermark) + ring_state[port_id] = RING_OVERLOADED; + + if (ret == 0) { + + /* + * Return mbufs to the pool, + * effectively dropping packets + */ + for (i = 0; i < nb_dq_pkts; i++) + rte_pktmbuf_free(pkts[i]); + } } The thread's logic works mostly like receive_stage(),
@@ -482,5 +505,6 @@ low_watermark from the rte_memzone previously created by qw. quota = qw_memzone->addr; - low_watermark = (unsigned int *) qw_memzone->addr + sizeof(int); + low_watermark = (unsigned int *) qw_memzone->addr + 1; + high_watermark = (unsigned int *) qw_memzone->addr + 2; }
examples/Makefile +1 -1
@@ -81,7 +81,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_REORDER) += packet_ordering DIRS-$(CONFIG_RTE_LIBRTE_IEEE1588) += ptpclient DIRS-$(CONFIG_RTE_LIBRTE_METER) += qos_meter DIRS-$(CONFIG_RTE_LIBRTE_SCHED) += qos_sched -#DIRS-y += quota_watermark +DIRS-y += quota_watermark DIRS-$(CONFIG_RTE_ETHDEV_RXTX_CALLBACKS) += rxtx_callbacks DIRS-y += skeleton ifeq ($(CONFIG_RTE_LIBRTE_HASH),y)
examples/quota_watermark/qw/init.c +3 -2
@@ -140,7 +140,7 @@ void init_ring(int lcore_id, uint8_t port_id)if (ring ==NULL )rte_exit (EXIT_FAILURE ,"%s\n" ,rte_strerror (rte_errno)); -rte_ring_set_water_mark (ring,80 *RING_SIZE /100 ); + *high_watermark =80 *RING_SIZE /100 ; rings[lcore_id][port_id] = ring; }
@@ -168,10 +168,11 @@ setup_shared_variables(void)const struct rte_memzone *qw_memzone; qw_memzone =rte_memzone_reserve (QUOTA_WATERMARK_MEMZONE_NAME , -2 *sizeof (int ),rte_socket_id (),0 ); +3 *sizeof (int ),rte_socket_id (),0 );if (qw_memzone ==NULL )rte_exit (EXIT_FAILURE ,"%s\n" ,rte_strerror (rte_errno)); quota = qw_memzone->addr; low_watermark = (unsigned int *) qw_memzone->addr +1 ; + high_watermark = (unsigned int *) qw_memzone->addr +2 ; }
examples/quota_watermark/qw/main.c +10 -6
@@ -67,6 +67,7 @@ struct ether_fc_frame {int *quota;unsigned int *low_watermark; +unsigned int *high_watermark;uint8_t port_pairs[RTE_MAX_ETHPORTS ];
@@ -158,6 +159,7 @@ receive_stage(__attribute__((unused)) void *args)uint16_t nb_rx_pkts;unsigned int lcore_id; +unsigned int free;struct rte_mbuf *pkts[MAX_PKT_QUOTA ];struct rte_ring *ring;
@@ -189,13 +191,13 @@ receive_stage(__attribute__((unused)) void *args) nb_rx_pkts =rte_eth_rx_burst (port_id,0 , pkts, (uint16_t ) *quota); ret =rte_ring_enqueue_bulk (ring, (void *) pkts, - nb_rx_pkts); -if (ret == -EDQUOT ) { + nb_rx_pkts, &free); +if (RING_SIZE - free > *high_watermark) { ring_state[port_id] =RING_OVERLOADED ;send_pause_frame (port_id,1337 ); } -else if (ret == -ENOBUFS ) { +if (ret ==0 ) {/* * Return mbufs to the pool,
@@ -217,6 +219,7 @@ pipeline_stage(__attribute__((unused)) void *args)uint8_t port_id;unsigned int lcore_id, previous_lcore_id; +unsigned int free;void *pkts[MAX_PKT_QUOTA ];struct rte_ring *rx, *tx;
@@ -253,11 +256,12 @@ pipeline_stage(__attribute__((unused)) void *args)continue ;/* Enqueue them on tx */ - ret =rte_ring_enqueue_bulk (tx, pkts, nb_dq_pkts); -if (ret == -EDQUOT ) + ret =rte_ring_enqueue_bulk (tx, pkts, + nb_dq_pkts, &free); +if (RING_SIZE - free > *high_watermark) ring_state[port_id] =RING_OVERLOADED ; -else if (ret == -ENOBUFS ) { +if (ret ==0 ) {/* * Return mbufs to the pool,
examples/quota_watermark/qw/main.h +1 -0
@@ -43,6 +43,7 @@ enum ring_state {extern int *quota;extern unsigned int *low_watermark; +extern unsigned int *high_watermark;extern uint8_t port_pairs[RTE_MAX_ETHPORTS ];
examples/quota_watermark/qwctl/commands.c +2 -2
@@ -140,8 +140,8 @@ cmd_set_handler(__attribute__((unused)) void *parsed_result,else if (tokens->value >= *low_watermark *100 /RING_SIZE && tokens->value <=100 ) -rte_ring_set_water_mark (ring, - tokens->value *RING_SIZE /100 ); + *high_watermark = tokens->value * +RING_SIZE /100 ;else cmdline_printf(cl, "ring high watermark must be between %u%% and 100%%\n",
examples/quota_watermark/qwctl/qwctl.c +2 -0
@@ -55,6 +55,7 @@int *quota;unsigned int *low_watermark; +unsigned int *high_watermark; static void
@@ -68,6 +69,7 @@ setup_shared_variables(void) quota = qw_memzone->addr; low_watermark = (unsigned int *) qw_memzone->addr +1 ; + high_watermark = (unsigned int *) qw_memzone->addr +2 ; }int main (int argc,char **argv)
examples/quota_watermark/qwctl/qwctl.h +1 -0
@@ -36,5 +36,6 @@extern int *quota;extern unsigned int *low_watermark; +extern unsigned int *high_watermark;#endif /* _MAIN_H_ */
Signature · 1 line
2.9.3
PATCH v5 11/14 ring: reduce scope of local variables
In reply to Bruce RichardsonThe local variable i is only used for loop control so define it in the enqueue and dequeue blocks directly, rather than at the function level.
--- lib/librte_ring/rte_ring.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
lib/librte_ring/rte_ring.h +2 -4
@@ -285,6 +285,7 @@ void rte_ring_dump(FILE *f, const struct rte_ring *r);* Placed here since identical code needed in both * single and multi producer enqueue functions */ #define ENQUEUE_PTRS () do { \ + unsigned int i; \ const uint32_t size = r->size; \ uint32_t idx = prod_head & mask; \ if (likely(idx + n < size)) { \
@@ -311,6 +312,7 @@ void rte_ring_dump(FILE *f, const struct rte_ring *r);* Placed here since identical code needed in both * single and multi consumer dequeue functions */ #define DEQUEUE_PTRS () do { \ + unsigned int i; \ uint32_t idx = cons_head & mask; \ const uint32_t size = r->size; \ if (likely(idx + n < size)) { \
@@ -361,7 +363,6 @@ __rte_ring_mp_do_enqueue(struct rte_ring *r, void * const *obj_table,uint32_t cons_tail, free_entries;const unsigned int max = n;int success; -unsigned int i;uint32_t mask = r->mask;/* move prod.head atomically */
@@ -431,7 +432,6 @@ __rte_ring_sp_do_enqueue(struct rte_ring *r, void * const *obj_table, {uint32_t prod_head, cons_tail;uint32_t prod_next, free_entries; -unsigned int i;uint32_t mask = r->mask; prod_head = r->prod.head;
@@ -495,7 +495,6 @@ __rte_ring_mc_do_dequeue(struct rte_ring *r, void **obj_table,uint32_t cons_next, entries;const unsigned max = n;int success; -unsigned int i;uint32_t mask = r->mask;/* move cons.head atomically */
@@ -566,7 +565,6 @@ __rte_ring_sc_do_dequeue(struct rte_ring *r, void **obj_table, {uint32_t cons_head, prod_tail;uint32_t cons_next, entries; -unsigned int i;uint32_t mask = r->mask; cons_head = r->cons.head;
Signature · 1 line
2.9.3
PATCH v5 12/14 ring: separate out head index manipulation for enq/deq
In reply to Bruce RichardsonWe can write a single common function for head manipulation for enq and a common one for deq, allowing us to have a single worker function for enq and deq, rather than two of each. Update all other inline functions to use the new functions.
---
V3: renamed parameter "is_mp" in __rte_ring_do_dequeue to the correct "is_sc"
--- lib/librte_ring/rte_ring.c | 4 +- lib/librte_ring/rte_ring.h | 328 ++++++++++++++++++++------------------------- 2 files changed, 149 insertions(+), 183 deletions(-)
lib/librte_ring/rte_ring.c +2 -2
@@ -138,8 +138,8 @@ rte_ring_init(struct rte_ring *r, const char *name, unsigned count,if (ret <0 || ret >= (int )sizeof (r->name))return -ENAMETOOLONG ; r->flags = flags; - r->prod.single = !!(flags &RING_F_SP_ENQ ); - r->cons.single = !!(flags &RING_F_SC_DEQ ); + r->prod.single = (flags &RING_F_SP_ENQ ) ? __IS_SP : __IS_MP; + r->cons.single = (flags &RING_F_SC_DEQ ) ? __IS_SC : __IS_MC; r->size = count; r->mask = count -1 ; r->prod.head = r->cons.head =0 ;
lib/librte_ring/rte_ring.h +147 -181
528 lines not on this page · raw message
Signature · 1 line
2.9.3
PATCH v5 13/14 ring: create common function for updating tail idx
In reply to Bruce RichardsonBoth producer and consumer use the same logic for updating the tail index so merge into a single function.
---
V3: added check for "single" mode in tail update to buypass unneeded check
--- lib/librte_ring/rte_ring.h | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-)
lib/librte_ring/rte_ring.h +17 -17
@@ -341,6 +341,21 @@ void rte_ring_dump(FILE *f, const struct rte_ring *r); } \ }while (0 ) +static inline __attribute__((always_inline)) void +update_tail (struct rte_ring_headtail *ht,uint32_t old_val,uint32_t new_val, +uint32_t single) +{ +/* +* If there are other enqueues/dequeues in progress that preceded us, +* we need to wait for them to complete +*/ +if (!single) +while (unlikely (ht->tail != old_val)) +rte_pause (); + + ht->tail = new_val; +} +/** * @internal This function updates the producer head for enqueue *
@@ -440,15 +455,7 @@ __rte_ring_do_enqueue(struct rte_ring *r, void * const *obj_table,ENQUEUE_PTRS ();rte_smp_wmb (); -/* -* If there are other enqueues in progress that preceded us, -* we need to wait for them to complete -*/ -while (unlikely (r->prod.tail != prod_head)) -rte_pause (); - - r->prod.tail = prod_next; - +update_tail (&r->prod, prod_head, prod_next, is_sp); end:if (free_space !=NULL ) *free_space = free_entries - n;
@@ -553,14 +560,7 @@ __rte_ring_do_dequeue(struct rte_ring *r, void **obj_table,DEQUEUE_PTRS ();rte_smp_rmb (); -/* -* If there are other enqueues in progress that preceded us, -* we need to wait for them to complete -*/ -while (unlikely (r->cons.tail != cons_head)) -rte_pause (); - - r->cons.tail = cons_next; +update_tail (&r->cons, cons_head, cons_next, is_sc); end:if (available !=NULL )
Signature · 1 line
2.9.3
PATCH v5 14/14 ring: make ring struct and enq/deq macros type agnostic
In reply to Bruce RichardsonModify the enqueue and dequeue macros to support copying any type of object by passing in the exact object type. Rather than using the "ring" structure member of rte_ring, which is of type "array of void *", instead have the macros take the start of the ring a a pointer value, thereby leaving the rte_ring structure as purely a header value. This allows it to be reused by other future ring types which can add on extra fields if they want, or even to have the actual ring elements, of whatever type stored separate from the ring header.
--- lib/librte_ring/rte_ring.h | 68 ++++++++++++++++++++++++---------------------- 1 file changed, 36 insertions(+), 32 deletions(-)
lib/librte_ring/rte_ring.h +36 -32
@@ -159,11 +159,7 @@ struct rte_ring {/** Ring consumer status. */ struct rte_ring_headtail cons __rte_aligned(CONS_ALIGN); - - void *ring[] __rte_cache_aligned; /**< Memory space of ring starts here. -* not volatile so need to be careful -* about compiler re-ordering */ -}; +} __rte_cache_aligned;#define RING_F_SP_ENQ 0x0001/**< The default enqueue is "single-producer". */ #define RING_F_SC_DEQ 0x0002/**< The default dequeue is "single-consumer". */
@@ -290,54 +286,62 @@ void rte_ring_dump(FILE *f, const struct rte_ring *r);/* the actual enqueue of pointers on the ring. * Placed here since identical code needed in both * single and multi producer enqueue functions */ -#define ENQUEUE_PTRS () do { \ +#define ENQUEUE_PTRS (r, ring_start, prod_head, obj_table, n, obj_type) do { \ unsigned int i; \ - const uint32_t size = r->size; \ - uint32_t idx = prod_head & r->mask; \ + const uint32_t size = (r)->size; \ + uint32_t idx = prod_head & (r)->mask; \ + obj_type *ring = (void *)ring_start; \ if (likely(idx + n < size)) { \ for (i = 0; i < (n & ((~(unsigned)0x3))); i+=4, idx+=4) { \ - r->ring[idx] = obj_table[i]; \ - r->ring[idx+1] = obj_table[i+1]; \ - r->ring[idx+2] = obj_table[i+2]; \ - r->ring[idx+3] = obj_table[i+3]; \ + ring[idx] = obj_table[i]; \ + ring[idx+1] = obj_table[i+1]; \ + ring[idx+2] = obj_table[i+2]; \ + ring[idx+3] = obj_table[i+3]; \ } \ switch (n & 0x3) { \ - case 3: r->ring[idx++] = obj_table[i++]; \ - case 2: r->ring[idx++] = obj_table[i++]; \ - case 1: r->ring[idx++] = obj_table[i++]; \ + case 3: \ + ring[idx++] = obj_table[i++];/* fallthrough */ \ +case 2 : \ + ring[idx++] = obj_table[i++];/* fallthrough */ \ +case 1 : \ + ring[idx++] = obj_table[i++]; \ } \ } else { \for (i =0 ; idx < size; i++, idx++)\ - r->ring[idx] = obj_table[i]; \ + ring[idx] = obj_table[i]; \for (idx =0 ; i < n; i++, idx++) \ - r->ring[idx] = obj_table[i]; \ + ring[idx] = obj_table[i]; \ } \ -} while(0) +} while (0)/* the actual copy of pointers on the ring to obj_table. * Placed here since identical code needed in both * single and multi consumer dequeue functions */ -#define DEQUEUE_PTRS () do { \ +#define DEQUEUE_PTRS (r, ring_start, cons_head, obj_table, n, obj_type) do { \ unsigned int i; \ - uint32_t idx = cons_head & r->mask; \ - const uint32_t size = r->size; \ + uint32_t idx = cons_head & (r)->mask; \ + const uint32_t size = (r)->size; \ + obj_type *ring = (void *)ring_start; \ if (likely(idx + n < size)) { \ for (i = 0; i < (n & (~(unsigned)0x3)); i+=4, idx+=4) {\ - obj_table[i] = r->ring[idx]; \ - obj_table[i+1] = r->ring[idx+1]; \ - obj_table[i+2] = r->ring[idx+2]; \ - obj_table[i+3] = r->ring[idx+3]; \ + obj_table[i] = ring[idx]; \ + obj_table[i+1] = ring[idx+1]; \ + obj_table[i+2] = ring[idx+2]; \ + obj_table[i+3] = ring[idx+3]; \ } \ switch (n & 0x3) { \ - case 3: obj_table[i++] = r->ring[idx++]; \ - case 2: obj_table[i++] = r->ring[idx++]; \ - case 1: obj_table[i++] = r->ring[idx++]; \ + case 3: \ + obj_table[i++] = ring[idx++];/* fallthrough */ \ +case 2 : \ + obj_table[i++] = ring[idx++];/* fallthrough */ \ +case 1 : \ + obj_table[i++] = ring[idx++]; \ } \ } else { \for (i =0 ; idx < size; i++, idx++) \ - obj_table[i] = r->ring[idx]; \ + obj_table[i] = ring[idx]; \for (idx =0 ; i < n; i++, idx++) \ - obj_table[i] = r->ring[idx]; \ + obj_table[i] = ring[idx]; \ } \ } while (0)
@@ -452,7 +456,7 @@ __rte_ring_do_enqueue(struct rte_ring *r, void * const *obj_table,if (n ==0 ) goto end; -ENQUEUE_PTRS (); + ENQUEUE_PTRS(r, &r[1], prod_head, obj_table, n, void *);rte_smp_wmb ();update_tail (&r->prod, prod_head, prod_next, is_sp);
@@ -557,7 +561,7 @@ __rte_ring_do_dequeue(struct rte_ring *r, void **obj_table,if (n ==0 ) goto end; -DEQUEUE_PTRS (); + DEQUEUE_PTRS(r, &r[1], cons_head, obj_table, n, void *);rte_smp_rmb ();update_tail (&r->cons, cons_head, cons_next, is_sc);
Signature · 1 line
2.9.3
Thomas Monjalon
Applied2017-03-29 14:09, Bruce Richardson:
Quoted 7 lines
Bruce Richardson (14):
ring: remove split cacheline build setting
ring: create common structure for prod and cons metadata
ring: eliminate duplication of size and mask fields
ring: remove debug setting
ring: remove the yield when waiting for tail update
ring: remove watermark support
Quoted 8 lines
ring: make bulk and burst fn return vals consistent
ring: allow enqueue fns to return free space value
ring: allow dequeue fns to return remaining entry count examples/quota_watermark: use ring space for watermarks
ring: reduce scope of local variables
ring: separate out head index manipulation for enq/deq
ring: create common function for updating tail idx
ring: make ring struct and enq/deq macros type agnostic
Applied, thanks
Quoted 41 lines · Bruce Richardson
This patchset make a set of, sometimes non-backward compatible, cleanup changes to the
rte_ringcode in order to improve it. The resulting code is shorter, since the existing functions are restructured to reduce code duplication, as well as being more consistent in behaviour. The specific changes made are explained in each patch which makes that change.Changes in V5, p8 & p9 only:
* Fixed errors in performance-thread sample app due to missed updates to enqueue/dequeue calls.
* Added in missing doxygen comments for new API parametersChanges in V4:
* Fixed errors in the crypto PMDs due to missed updates to their enqueue/dequeue calls (p8 & p9).
* Updatedquota_watermarksdocumentation to match changed code (p10)Changes in V3:
* removed anonymous union forsp_enqueueandsc_dequeuevariables (p2)
* fixed parameter to dequeue function which was mistakenly namedis_mpinstead ofis_sc(as described in the comments) (p12)
* skipped unneeded check in tail pointer update fn for sp/sc operation (p13)Changes in V2:
* Eliminated extra cacheline padding where cachelines are 128B
* Renamedrte_ring_ht_ptrstruct torte_ring_headtail
* Removed missed references to ring watermarks in test code and docsThis patchset is largely the same as that posted previously on-list as an RFC:
http://dpdk.org/ml/archives/dev/2017-February/thread.html#56982Changes in V1 from RFC:
* Included release notes updates as changes are made in each patch
* Fixed some missed comment updates when changing the code
* Separated some initial fixup patches from this set to send separately
* Dropped the final two patches for anrte_event_ring, as not relevant for this set. That can be done as a separate set later.
* The macros for copying the pointers have an extra parameter added, indicating the start of the ring buffer itself. This allows more flexibility for reusing them in other ring implementations.
Quoted 15 lines
Bruce Richardson (14):
ring: remove split cacheline build setting
ring: create common structure for prod and cons metadata
ring: eliminate duplication of size and mask fields
ring: remove debug setting
ring: remove the yield when waiting for tail update
ring: remove watermark support
ring: make bulk and burst fn return vals consistent
ring: allow enqueue fns to return free space value
ring: allow dequeue fns to return remaining entry count examples/quota_watermark: use ring space for watermarks
ring: reduce scope of local variables
ring: separate out head index manipulation for enq/deq
ring: create common function for updating tail idx
ring: make ring struct and enq/deq macros type agnostic
Hi Bruce,
After latest master tree integrated into next-net, icc build throws following error, which I assume related to this patchset, FYI:
In file included from .../lib/librte_ring/rte_ring.c(90):
.../lib/librte_ring/rte_ring.h(162): error #1366: a reduction in alignment without the "packed" attribute is ignored
} __rte_cache_aligned;
^2017-03-31 15:37, Ferruh Yigit:
Quoted 8 lines
After latest master tree integrated into next-net, icc build throws following error, which I assume related to this patchset, FYI:
In file included from .../lib/librte_ring/rte_ring.c(90):
.../lib/librte_ring/rte_ring.h(162): error #1366: a reduction in alignment without the "packed" attribute is ignored} __rte_cache_aligned; ^
Any news about this build error, please?