@@ -51,7 +51,7 @@ static int loopback_close(pktio_entry_t *pktio_entry)
static int loopback_recv(pktio_entry_t *pktio_entry, odp_packet_t pkts[],
unsigned len)
{
- int nbr, i, j;
+ int nbr, i;
odp_buffer_hdr_t *hdr_tbl[QUEUE_MULTI_MAX];
queue_entry_t *qentry;
odp_packet_hdr_t *pkt_hdr;
@@ -64,7 +64,8 @@ static int loopback_recv(pktio_entry_t *pktio_entry, odp_packet_t pkts[],
nbr = queue_deq_multi(qentry, hdr_tbl, len);
if (pktio_cls_enabled(pktio_entry)) {
- for (i = 0, j = 0; i < nbr; i++) {
+ int failed = 0;
+ for (i = 0; i < nbr; i++) {
pkt = _odp_packet_from_buffer(odp_hdr_to_buf
(hdr_tbl[i]));
pkt_hdr = odp_packet_hdr(pkt);
@@ -74,11 +75,12 @@ static int loopback_recv(pktio_entry_t *pktio_entry, odp_packet_t pkts[],
pktio_entry->s.stats.in_octets +=
odp_packet_len(pkt);
} else {
- pktio_entry->s.stats.in_errors +=
- odp_packet_len(pkt);
+ failed--;
}
}
- nbr = j;
+ pktio_entry->s.stats.in_errors += failed;
+ pktio_entry->s.stats.in_ucast_pkts += nbr - failed;
+ return failed;
} else {
for (i = 0; i < nbr; ++i) {
pkts[i] = _odp_packet_from_buffer(odp_hdr_to_buf
@@ -89,11 +91,9 @@ static int loopback_recv(pktio_entry_t *pktio_entry, odp_packet_t pkts[],
pktio_entry->s.stats.in_octets +=
odp_packet_len(pkts[i]);
}
+ pktio_entry->s.stats.in_ucast_pkts += nbr;
+ return nbr;
}
-
- pktio_entry->s.stats.in_ucast_pkts += nbr;
-
- return nbr;
}
static int loopback_send(pktio_entry_t *pktio_entry, odp_packet_t pkt_tbl[],
Several minor changes: - remove 'int j' as it no longer has function - add 'int failed' to count errors, and return it (or 0 if no failure) - in_errors counts the packet numbers, not the octets - in_ucast_pkts should not count these failed packets - as a side effect, separate this code path from normal handling completely Signed-off-by: Zoltan Kiss <zoltan.kiss@linaro.org> --- platform/linux-generic/pktio/loop.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)