net/af_packet: improve Tx statistics accuracy
Checks
Commit Message
When sendto call fails and ENOBUFS error is being set some of the
packets are actually successfully transmitted. There is no available
count of those packets, so in order to make the statistics more
accurate, all the previously enqueued packets will be considered
successful, even though this is not entirely correct.
Before:
testpmd Tx statistics:
TX-packets: 7529062 TX-errors: 3702150 TX-bytes: 451743720
pktgen Rx statistics:
Total Rx Pkts: 10700700
After:
testpmd TX statistics:
TX-packets: 11510625 TX-errors: 0 TX-bytes: 690637500
pktgen Rx statistics:
Total Rx Pkts: 10974307
Fixes: 74b7fc0a0ff1 ("net/af_packet: fix packet bytes counting")
Cc: ciwillia@brocade.com
Cc: stable@dpdk.org
Signed-off-by: Flavia Musatescu <flavia.musatescu@intel.com>
---
drivers/net/af_packet/rte_eth_af_packet.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
Comments
On Wed, 9 Oct 2019 16:29:09 +0100
Flavia Musatescu <flavia.musatescu@intel.com> wrote:
> + if (sendto(pkt_q->sockfd, NULL, 0, MSG_DONTWAIT, NULL, 0) == -1 &&
> + errno != ENOBUFS) {
> + /* Error sending.
> + * When sendto call fails and ENOBUFS error is being set
> + * some of the packets are actually successfully transmitted.
> + * There is no available count of those packets, so in order
> + * to make the statistics more accurate, all of the previously
> + * enqueued packets will be considered successful, even though
> + * this is not entirely correct.
> + */
Agree with the change, but please keep only add a small code comment.
Long comments are a personal pet peeve, it also tends to standout as
"some different developer who had an issue left this comment"
@@ -244,8 +244,16 @@ eth_af_packet_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
}
/* kick-off transmits */
- if (sendto(pkt_q->sockfd, NULL, 0, MSG_DONTWAIT, NULL, 0) == -1) {
- /* error sending -- no packets transmitted */
+ if (sendto(pkt_q->sockfd, NULL, 0, MSG_DONTWAIT, NULL, 0) == -1 &&
+ errno != ENOBUFS) {
+ /* Error sending.
+ * When sendto call fails and ENOBUFS error is being set
+ * some of the packets are actually successfully transmitted.
+ * There is no available count of those packets, so in order
+ * to make the statistics more accurate, all of the previously
+ * enqueued packets will be considered successful, even though
+ * this is not entirely correct.
+ */
num_tx = 0;
num_tx_bytes = 0;
}