bus/fslmc: set the dpaa2 device name
[dpdk.git] / examples / quota_watermark / qw / main.c
index 57df8ef..d4fcfde 100644 (file)
@@ -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)