diff options
author | Bruce Richardson <bruce.richardson@intel.com> | 2017-03-29 16:21:23 +0100 |
---|---|---|
committer | Thomas Monjalon <thomas.monjalon@6wind.com> | 2017-03-29 22:25:37 +0200 |
commit | cfa7c9e6fc1f7b248d8f250966851bdd19d7b9c2 (patch) | |
tree | 7a90acd3cde39e289628d6d4993216b7513f2981 /examples/multi_process/client_server_mp | |
parent | 77dd3064270c1fbb930aaecec70492c9e96ec404 (diff) | |
download | dpdk-cfa7c9e6fc1f7b248d8f250966851bdd19d7b9c2.zip dpdk-cfa7c9e6fc1f7b248d8f250966851bdd19d7b9c2.tar.gz dpdk-cfa7c9e6fc1f7b248d8f250966851bdd19d7b9c2.tar.xz |
ring: make bulk and burst return values consistent
The 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 <bruce.richardson@intel.com>
Reviewed-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Olivier Matz <olivier.matz@6wind.com>
Diffstat (limited to 'examples/multi_process/client_server_mp')
-rw-r--r-- | examples/multi_process/client_server_mp/mp_client/client.c | 8 | ||||
-rw-r--r-- | examples/multi_process/client_server_mp/mp_server/main.c | 2 |
2 files changed, 3 insertions, 7 deletions
diff --git a/examples/multi_process/client_server_mp/mp_client/client.c b/examples/multi_process/client_server_mp/mp_client/client.c index d4f9ca3..dca9eb9 100644 --- a/examples/multi_process/client_server_mp/mp_client/client.c +++ b/examples/multi_process/client_server_mp/mp_client/client.c @@ -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) diff --git a/examples/multi_process/client_server_mp/mp_server/main.c b/examples/multi_process/client_server_mp/mp_server/main.c index a6dc12d..19c95b2 100644 --- a/examples/multi_process/client_server_mp/mp_server/main.c +++ b/examples/multi_process/client_server_mp/mp_server/main.c @@ -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; |