summaryrefslogtreecommitdiff
path: root/examples/kni/main.c
diff options
context:
space:
mode:
authorDan Gora <dg@adax.com>2018-10-24 19:26:31 -0300
committerThomas Monjalon <thomas@monjalon.net>2018-10-26 19:46:29 +0200
commit85fea26693d6a3cf04a197e5c914e96600672c20 (patch)
tree83a6c1f518b45ad10d97891a1b5a51d079b55e00 /examples/kni/main.c
parent0fdec35dba2c7fab5a2d488fe275010f63762bda (diff)
examples/kni: improve zeroing statistics
The worker threads incrementing the rx/tx_packets race with the signal handler from the main thread zeroing the entire statistics structure. This can cause the statistics to fail to be zeroed, even when there is no traffic on those interfaces. Improve zeroing the statistics by only incrementing rx/tx_packets in worker threads by a non-zero amount. This limits the race to the periods in which traffic is actually being received or transmitted. Signed-off-by: Dan Gora <dg@adax.com> Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Diffstat (limited to 'examples/kni/main.c')
-rw-r--r--examples/kni/main.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/examples/kni/main.c b/examples/kni/main.c
index 0e3b2a2f71..e37b1ad362 100644
--- a/examples/kni/main.c
+++ b/examples/kni/main.c
@@ -223,7 +223,8 @@ kni_ingress(struct kni_port_params *p)
}
/* Burst tx to kni */
num = rte_kni_tx_burst(p->kni[i], pkts_burst, nb_rx);
- kni_stats[port_id].rx_packets += num;
+ if (num)
+ kni_stats[port_id].rx_packets += num;
rte_kni_handle_request(p->kni[i]);
if (unlikely(num < nb_rx)) {
@@ -260,7 +261,8 @@ kni_egress(struct kni_port_params *p)
}
/* Burst tx to eth */
nb_tx = rte_eth_tx_burst(port_id, 0, pkts_burst, (uint16_t)num);
- kni_stats[port_id].tx_packets += nb_tx;
+ if (nb_tx)
+ kni_stats[port_id].tx_packets += nb_tx;
if (unlikely(nb_tx < num)) {
/* Free mbufs not tx to NIC */
kni_burst_free_mbufs(&pkts_burst[nb_tx], num - nb_tx);