[v2] net/af_packet: improve Tx statistics accuracy
diff mbox series

Message ID 1570728870-26668-1-git-send-email-flavia.musatescu@intel.com
State Superseded
Delegated to: Ferruh Yigit
Headers show
Series
  • [v2] net/af_packet: improve Tx statistics accuracy
Related show

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-compilation success Compile Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/Intel-compilation success Compilation OK
ci/iol-mellanox-Performance success Performance Testing PASS

Commit Message

Flavia Musatescu Oct. 10, 2019, 5:34 p.m. UTC
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>

---
v2:
* Changed the comment
---
 drivers/net/af_packet/rte_eth_af_packet.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Stephen Hemminger Oct. 10, 2019, 6:35 p.m. UTC | #1
On Thu, 10 Oct 2019 18:34:30 +0100
Flavia Musatescu <flavia.musatescu@intel.com> wrote:

> 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>
> 
> ---
> v2:
> * Changed the comment
> ---
>  drivers/net/af_packet/rte_eth_af_packet.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c
> index 6df09f2..df281bf 100644
> --- a/drivers/net/af_packet/rte_eth_af_packet.c
> +++ b/drivers/net/af_packet/rte_eth_af_packet.c
> @@ -244,8 +244,12 @@ 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) {
> +		/*
> +		 * In case of a ENOBUFS error all of the enqueued packets will
> +		 * be considered successful even though only some are sent.
> +		 */
>  		num_tx = 0;
>  		num_tx_bytes = 0;
>  	}

What about EINTR or EAGAIN?
Flavia Musatescu Oct. 11, 2019, 5:13 p.m. UTC | #2
On 10/10/2019 19:35, Stephen Hemminger wrote:
> On Thu, 10 Oct 2019 18:34:30 +0100
> Flavia Musatescu <flavia.musatescu@intel.com> wrote:
>
>> 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>
>>
>> ---
>> v2:
>> * Changed the comment
>> ---
>>   drivers/net/af_packet/rte_eth_af_packet.c | 8 ++++++--
>>   1 file changed, 6 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c
>> index 6df09f2..df281bf 100644
>> --- a/drivers/net/af_packet/rte_eth_af_packet.c
>> +++ b/drivers/net/af_packet/rte_eth_af_packet.c
>> @@ -244,8 +244,12 @@ 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) {
>> +		/*
>> +		 * In case of a ENOBUFS error all of the enqueued packets will
>> +		 * be considered successful even though only some are sent.
>> +		 */
>>   		num_tx = 0;
>>   		num_tx_bytes = 0;
>>   	}
> What about EINTR or EAGAIN?
Hi Stephen,

I agree with EAGAIN error case as I was able to test this scenario and 
check the statistics.

Can we get an EINTR error in case of a nonblocking operation 
(MSG_DONTWAIT flag is being used)? Is this a common situation and will 
the gain justify the cost of an additional check? Do you have any 
suggestions for how I could test this scenario?

Thanks,
Flavia

Patch
diff mbox series

diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c
index 6df09f2..df281bf 100644
--- a/drivers/net/af_packet/rte_eth_af_packet.c
+++ b/drivers/net/af_packet/rte_eth_af_packet.c
@@ -244,8 +244,12 @@  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) {
+		/*
+		 * In case of a ENOBUFS error all of the enqueued packets will
+		 * be considered successful even though only some are sent.
+		 */
 		num_tx = 0;
 		num_tx_bytes = 0;
 	}