[dpdk-dev] net/pcap: set rte_errno on TX error

Message ID 1469452240-1204-1-git-send-email-zoltan.kiss@schaman.hu (mailing list archive)
State Rejected, archived
Delegated to: Bruce Richardson
Headers

Commit Message

Zoltan Kiss July 25, 2016, 1:10 p.m. UTC
  This returns the error code provided by pcap_sendpacket()

Signed-off-by: Zoltan Kiss <zoltan.kiss@schaman.hu>
  

Comments

Ferruh Yigit July 25, 2016, 1:33 p.m. UTC | #1
On 7/25/2016 2:10 PM, Zoltan Kiss wrote:
> This returns the error code provided by pcap_sendpacket()

Although this is good idea, this adds undocumented side effect to
rte_eth_tx_burst().

I am not able to find any information in rte_eth_tx_burst() that it can
alter rte_errno.

Since rte_errno is shared resource, it shouldn't be updated without
documented.

> 
> Signed-off-by: Zoltan Kiss <zoltan.kiss@schaman.hu>
> 
> diff --git a/drivers/net/pcap/rte_eth_pcap.c b/drivers/net/pcap/rte_eth_pcap.c
> index 7e213eb..0899bac 100644
> --- a/drivers/net/pcap/rte_eth_pcap.c
> +++ b/drivers/net/pcap/rte_eth_pcap.c
> @@ -41,6 +41,7 @@
>  #include <rte_cycles.h>
>  #include <rte_kvargs.h>
>  #include <rte_dev.h>
> +#include <rte_errno.h>
>  
>  #include <net/if.h>
>  
> @@ -360,8 +361,10 @@ eth_pcap_tx(void *queue,
>  			}
>  		}
>  
> -		if (unlikely(ret != 0))
> +		if (unlikely(ret != 0)) {
> +			rte_errno = ret;
>  			break;
> +		}
>  		num_tx++;
>  		tx_bytes += mbuf->pkt_len;
>  		rte_pktmbuf_free(mbuf);
>
  
Thomas Monjalon July 25, 2016, 1:43 p.m. UTC | #2
2016-07-25 14:33, Ferruh Yigit:
> On 7/25/2016 2:10 PM, Zoltan Kiss wrote:
> > This returns the error code provided by pcap_sendpacket()
> 
> Although this is good idea, this adds undocumented side effect to
> rte_eth_tx_burst().
> 
> I am not able to find any information in rte_eth_tx_burst() that it can
> alter rte_errno.
> 
> Since rte_errno is shared resource, it shouldn't be updated without
> documented.

That's something I was looking into.
Maybe we should generalize the use of rte_errno in 16.11?
  

Patch

diff --git a/drivers/net/pcap/rte_eth_pcap.c b/drivers/net/pcap/rte_eth_pcap.c
index 7e213eb..0899bac 100644
--- a/drivers/net/pcap/rte_eth_pcap.c
+++ b/drivers/net/pcap/rte_eth_pcap.c
@@ -41,6 +41,7 @@ 
 #include <rte_cycles.h>
 #include <rte_kvargs.h>
 #include <rte_dev.h>
+#include <rte_errno.h>
 
 #include <net/if.h>
 
@@ -360,8 +361,10 @@  eth_pcap_tx(void *queue,
 			}
 		}
 
-		if (unlikely(ret != 0))
+		if (unlikely(ret != 0)) {
+			rte_errno = ret;
 			break;
+		}
 		num_tx++;
 		tx_bytes += mbuf->pkt_len;
 		rte_pktmbuf_free(mbuf);