X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=examples%2Fquota_watermark%2Fqw%2Fmain.c;h=d4fcfde488dc8911de650bc72e4e5984930b239b;hb=de85636da0d8cd2d08b80599f4398cd4113543a5;hp=57df8efdb6417df754a27256b9bd8ae49e859c8d;hpb=a0ffcb257ab8c99cf2b0c84baae8631e219fe77a;p=dpdk.git diff --git a/examples/quota_watermark/qw/main.c b/examples/quota_watermark/qw/main.c index 57df8efdb6..d4fcfde488 100644 --- a/examples/quota_watermark/qw/main.c +++ b/examples/quota_watermark/qw/main.c @@ -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; @@ -247,16 +250,18 @@ 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; /* 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, @@ -305,7 +310,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? */ @@ -321,7 +326,7 @@ main(int argc, char **argv) uint8_t port_id; - rte_set_log_level(RTE_LOG_INFO); + rte_log_set_global_level(RTE_LOG_INFO); ret = rte_eal_init(argc, argv); if (ret < 0)