distributor: fix flushing in flight packets
authorLukasz Wojciechowski <l.wojciechow@partner.samsung.com>
Sat, 17 Oct 2020 03:06:58 +0000 (05:06 +0200)
committerDavid Marchand <david.marchand@redhat.com>
Mon, 19 Oct 2020 08:57:17 +0000 (10:57 +0200)
rte_distributor_flush() is using total_outstanding()
function to calculate if it should still wait
for processing packets. However in burst mode
only backlog packets were counted.

This patch fixes that issue by counting also in flight
packets. There are also sum fixes to properly keep
count of in flight packets for each worker in bufs[].count.

Fixes: 775003ad2f96 ("distributor: add new burst-capable library")
Cc: stable@dpdk.org
Signed-off-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
Acked-by: David Hunt <david.hunt@intel.com>
lib/librte_distributor/rte_distributor.c

index 9fea3f6..fb4e9d9 100644 (file)
@@ -465,6 +465,7 @@ rte_distributor_process(struct rte_distributor *d,
                        /* Sync with worker on GET_BUF flag. */
                        if (__atomic_load_n(&(d->bufs[wid].bufptr64[0]),
                                __ATOMIC_ACQUIRE) & RTE_DISTRIB_GET_BUF) {
+                               d->bufs[wid].count = 0;
                                release(d, wid);
                                handle_returns(d, wid);
                        }
@@ -479,11 +480,6 @@ rte_distributor_process(struct rte_distributor *d,
                uint16_t matches[RTE_DIST_BURST_SIZE];
                unsigned int pkts;
 
-               /* Sync with worker on GET_BUF flag. */
-               if (__atomic_load_n(&(d->bufs[wkr].bufptr64[0]),
-                       __ATOMIC_ACQUIRE) & RTE_DISTRIB_GET_BUF)
-                       d->bufs[wkr].count = 0;
-
                if ((num_mbufs - next_idx) < RTE_DIST_BURST_SIZE)
                        pkts = num_mbufs - next_idx;
                else
@@ -603,8 +599,10 @@ rte_distributor_process(struct rte_distributor *d,
        for (wid = 0 ; wid < d->num_workers; wid++)
                /* Sync with worker on GET_BUF flag. */
                if ((__atomic_load_n(&(d->bufs[wid].bufptr64[0]),
-                       __ATOMIC_ACQUIRE) & RTE_DISTRIB_GET_BUF))
+                       __ATOMIC_ACQUIRE) & RTE_DISTRIB_GET_BUF)) {
+                       d->bufs[wid].count = 0;
                        release(d, wid);
+               }
 
        return num_mbufs;
 }
@@ -647,7 +645,7 @@ total_outstanding(const struct rte_distributor *d)
        unsigned int wkr, total_outstanding = 0;
 
        for (wkr = 0; wkr < d->num_workers; wkr++)
-               total_outstanding += d->backlog[wkr].count;
+               total_outstanding += d->backlog[wkr].count + d->bufs[wkr].count;
 
        return total_outstanding;
 }