X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=examples%2Fquota_watermark%2Fqw%2Fmain.c;fp=examples%2Fquota_watermark%2Fqw%2Fmain.c;h=bdb8a43994313e8c8d9747ff9cf1b24c02f7eafc;hb=eb4562714f9fd9e284977207eb1a78066dc4b9f8;hp=2dcddea6c215cbba78dde875c4bdddc41f8a5989;hpb=ecaed092b677d09b4b8645a3ddc38aac0ea929f7;p=dpdk.git diff --git a/examples/quota_watermark/qw/main.c b/examples/quota_watermark/qw/main.c index 2dcddea6c2..bdb8a43994 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; @@ -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,