event/sw: allow forward and release when out of credits
authorGage Eads <gage.eads@intel.com>
Fri, 8 Sep 2017 18:07:52 +0000 (13:07 -0500)
committerJerin Jacob <jerin.jacob@caviumnetworks.com>
Wed, 25 Oct 2017 12:03:43 +0000 (14:03 +0200)
When forwarding or releasing events, the operation would fail if the port
has 0 inflight credits and cannot acquire more, or the inflight count
exceeds the port's new event threshold.

This patch fixes that by counting the number of new events in the burst,
and applying the credit and new event threshold checks accordingly.

Signed-off-by: Gage Eads <gage.eads@intel.com>
Acked-by: Harry van Haaren <harry.van.haaren@intel.com>
drivers/event/sw/sw_evdev_worker.c

index d76d3d5..b3b3b17 100644 (file)
@@ -85,14 +85,18 @@ sw_event_enqueue_burst(void *port, const struct rte_event ev[], uint16_t num)
        struct sw_port *p = port;
        struct sw_evdev *sw = (void *)p->sw;
        uint32_t sw_inflights = rte_atomic32_read(&sw->inflights);
        struct sw_port *p = port;
        struct sw_evdev *sw = (void *)p->sw;
        uint32_t sw_inflights = rte_atomic32_read(&sw->inflights);
-
-       if (unlikely(p->inflight_max < sw_inflights))
-               return 0;
+       int new = 0;
 
        if (num > PORT_ENQUEUE_MAX_BURST_SIZE)
                num = PORT_ENQUEUE_MAX_BURST_SIZE;
 
 
        if (num > PORT_ENQUEUE_MAX_BURST_SIZE)
                num = PORT_ENQUEUE_MAX_BURST_SIZE;
 
-       if (p->inflight_credits < num) {
+       for (i = 0; i < num; i++)
+               new += (ev[i].op == RTE_EVENT_OP_NEW);
+
+       if (unlikely(new > 0 && p->inflight_max < sw_inflights))
+               return 0;
+
+       if (p->inflight_credits < new) {
                /* check if event enqueue brings port over max threshold */
                uint32_t credit_update_quanta = sw->credit_update_quanta;
                if (sw_inflights + credit_update_quanta > sw->nb_events_limit)
                /* check if event enqueue brings port over max threshold */
                uint32_t credit_update_quanta = sw->credit_update_quanta;
                if (sw_inflights + credit_update_quanta > sw->nb_events_limit)
@@ -101,7 +105,7 @@ sw_event_enqueue_burst(void *port, const struct rte_event ev[], uint16_t num)
                rte_atomic32_add(&sw->inflights, credit_update_quanta);
                p->inflight_credits += (credit_update_quanta);
 
                rte_atomic32_add(&sw->inflights, credit_update_quanta);
                p->inflight_credits += (credit_update_quanta);
 
-               if (p->inflight_credits < num)
+               if (p->inflight_credits < new)
                        return 0;
        }
 
                        return 0;
        }