@@ -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;
@@ -72,7 +72,8 @@ static int loopback_recv(pktio_entry_t *pktio_entry, odp_packet_t pkts[],
}
if (pktio_cls_enabled(pktio_entry)) {
- for (i = 0, j = 0; i < nbr; i++) {
+ int failed = 0, discarded = 0;
+ for (i = 0; i < nbr; i++) {
int ret;
pkt = _odp_packet_from_buffer(odp_hdr_to_buf
(hdr_tbl[i]));
@@ -87,18 +88,19 @@ static int loopback_recv(pktio_entry_t *pktio_entry, odp_packet_t pkts[],
odp_packet_len(pkt);
break;
case -ENOENT:
- pktio_entry->s.stats.in_discards +=
- odp_packet_len(pkt);
+ discarded++;
break;
case -EFAULT:
- pktio_entry->s.stats.in_errors +=
- odp_packet_len(pkt);
+ failed++;
break;
default:
ret = queue_enq(qentry, hdr_tbl[i], 0);
}
}
- nbr = j;
+ pktio_entry->s.stats.in_errors += failed;
+ pktio_entry->s.stats.in_discards += discarded;
+ pktio_entry->s.stats.in_ucast_pkts += nbr - failed - discarded;
+ return -failed;
} else {
for (i = 0; i < nbr; ++i) {
pkts[i] = _odp_packet_from_buffer(odp_hdr_to_buf
@@ -110,11 +112,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,
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_discards the same, count it with 'discarded' - in_ucast_pkts should not count these packets - as a side effect, separate this code path from normal handling completely Signed-off-by: Zoltan Kiss <zoltan.kiss@linaro.org> --- v2: - rebase - fixs discards as well platform/linux-generic/pktio/loop.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)