[v7,2/3] pcap: support MTU set for linux interfaces TX enhancment

Message ID 20220619093034.26891-3-ido@cgstowernetworks.com (mailing list archive)
State Superseded, archived
Delegated to: Andrew Rybchenko
Headers
Series pcap: support MTU set for linux interfaces |

Checks

Context Check Description
ci/checkpatch warning coding style issues

Commit Message

Ido Goshen June 19, 2022, 9:30 a.m. UTC
  Drop only the oversized packets and not its entrie burst
mbuf will be freed and will be counted as oerror

Signed-off-by: Ido Goshen <ido@cgstowernetworks.com>
---
 drivers/net/pcap/pcap_ethdev.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
  

Comments

Stephen Hemminger June 20, 2022, 10:52 p.m. UTC | #1
On Sun, 19 Jun 2022 12:30:33 +0300
Ido Goshen <ido@cgstowernetworks.com> wrote:

> Drop only the oversized packets and not its entrie burst
> mbuf will be freed and will be counted as oerror
> 
> Signed-off-by: Ido Goshen <ido@cgstowernetworks.com>
> ---
>  drivers/net/pcap/pcap_ethdev.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/pcap/pcap_ethdev.c b/drivers/net/pcap/pcap_ethdev.c
> index 2221c53051..ff98762058 100644
> --- a/drivers/net/pcap/pcap_ethdev.c
> +++ b/drivers/net/pcap/pcap_ethdev.c
> @@ -494,8 +494,14 @@ eth_pcap_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
>  		 */
>  		ret = pcap_sendpacket(pcap,
>  			rte_pktmbuf_read(mbuf, 0, len, temp_data), len);
> -		if (unlikely(ret != 0))
> -			break;
> +		if (unlikely(ret != 0)) {
> +			if (errno == EMSGSIZE) {

Will this show up in tx_errors?

> +				rte_pktmbuf_free(mbuf);
> +				continue;
> +			} else {
> +				break;
> +			}
else is not needed here.

> +		}
>  		num_tx++;
>  		tx_bytes += len;
>  		rte_pktmbuf_free(mbuf);
  
Ido Goshen June 21, 2022, 9:07 a.m. UTC | #2
> -----Original Message-----
> From: Stephen Hemminger <stephen@networkplumber.org>
> Sent: Tuesday, 21 June 2022 1:53
> To: Ido Goshen <Ido@cgstowernetworks.com>
> Cc: ferruh.yigit@xilinx.com; dev@dpdk.org
> Subject: Re: [PATCH v7 2/3] pcap: support MTU set for linux interfaces TX
> enhancment
> 
> On Sun, 19 Jun 2022 12:30:33 +0300
> Ido Goshen <ido@cgstowernetworks.com> wrote:
> 
> > Drop only the oversized packets and not its entrie burst mbuf will be
> > freed and will be counted as oerror
> >
> > Signed-off-by: Ido Goshen <ido@cgstowernetworks.com>
> > ---
> >  drivers/net/pcap/pcap_ethdev.c | 10 ++++++++--
> >  1 file changed, 8 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/net/pcap/pcap_ethdev.c
> > b/drivers/net/pcap/pcap_ethdev.c index 2221c53051..ff98762058 100644
> > --- a/drivers/net/pcap/pcap_ethdev.c
> > +++ b/drivers/net/pcap/pcap_ethdev.c
> > @@ -494,8 +494,14 @@ eth_pcap_tx(void *queue, struct rte_mbuf **bufs,
> uint16_t nb_pkts)
> >  		 */
> >  		ret = pcap_sendpacket(pcap,
> >  			rte_pktmbuf_read(mbuf, 0, len, temp_data), len);
> > -		if (unlikely(ret != 0))
> > -			break;
> > +		if (unlikely(ret != 0)) {
> > +			if (errno == EMSGSIZE) {
> 
> Will this show up in tx_errors?
>

[idog] yes
It will be counted few lines below by
	'dumper_q->tx_stat.err_pkts += nb_pkts - num_tx;'
as this case doesn't increment the 'num_tx'

test example:

build/app/dpdk-testpmd --no-huge -m1024 -l 0-2  --vdev='net_pcap0,iface=veth0' --vdev='net_pcap1,iface=veth1' -- -i
...
testpmd> port config mtu 0 9400
testpmd> port config mtu 1 1500
testpmd> start
...
testpmd> stop
Telling cores to stop...
Waiting for lcores to finish...

  ---------------------- Forward statistics for port 0  ----------------------
  RX-packets: 1              RX-dropped: 0             RX-total: 1
  TX-packets: 0              TX-dropped: 0             TX-total: 0
  ----------------------------------------------------------------------------

  ---------------------- Forward statistics for port 1  ----------------------
  RX-packets: 0              RX-dropped: 0             RX-total: 0
  TX-packets: 0              TX-dropped: 0             TX-total: 0
  ----------------------------------------------------------------------------

  +++++++++++++++ Accumulated forward statistics for all ports+++++++++++++++
  RX-packets: 1              RX-dropped: 0             RX-total: 1
  TX-packets: 0              TX-dropped: 1             TX-total: 1
  ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Done.
testpmd> show  port stats all

  ######################## NIC statistics for port 0  ########################
  RX-packets: 1          RX-missed: 0          RX-bytes:  8996
  RX-errors: 0
  RX-nombuf:  0         
  TX-packets: 0          TX-errors: 0          TX-bytes:  0

  Throughput (since last show)
  Rx-pps:            0          Rx-bps:            0
  Tx-pps:            0          Tx-bps:            0
  ############################################################################

  ######################## NIC statistics for port 1  ########################
  RX-packets: 0          RX-missed: 0          RX-bytes:  0
  RX-errors: 0
  RX-nombuf:  0         
  TX-packets: 0          TX-errors: 1          TX-bytes:  0

  Throughput (since last show)
  Rx-pps:            0          Rx-bps:            0
  Tx-pps:            0          Tx-bps:            0
  ############################################################################

> > +				rte_pktmbuf_free(mbuf);
> > +				continue;
> > +			} else {
> > +				break;
> > +			}
> else is not needed here.

[idog] ok
 
> > +		}
> >  		num_tx++;
> >  		tx_bytes += len;
> >  		rte_pktmbuf_free(mbuf);
  

Patch

diff --git a/drivers/net/pcap/pcap_ethdev.c b/drivers/net/pcap/pcap_ethdev.c
index 2221c53051..ff98762058 100644
--- a/drivers/net/pcap/pcap_ethdev.c
+++ b/drivers/net/pcap/pcap_ethdev.c
@@ -494,8 +494,14 @@  eth_pcap_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 		 */
 		ret = pcap_sendpacket(pcap,
 			rte_pktmbuf_read(mbuf, 0, len, temp_data), len);
-		if (unlikely(ret != 0))
-			break;
+		if (unlikely(ret != 0)) {
+			if (errno == EMSGSIZE) {
+				rte_pktmbuf_free(mbuf);
+				continue;
+			} else {
+				break;
+			}
+		}
 		num_tx++;
 		tx_bytes += len;
 		rte_pktmbuf_free(mbuf);