net/iavf: fix Tx preparation

Message ID 20231102120504.1468111-1-qi.z.zhang@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Qi Zhang
Headers
Series net/iavf: fix Tx preparation |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/github-robot: build success github build: passed
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/intel-Functional success Functional PASS

Commit Message

Qi Zhang Nov. 2, 2023, 12:05 p.m. UTC
  1. check nb_segs > Tx ring size for TSO case.
2. report nb_mtu_seg_max and nb_seg_max in dev_info.

Fixes: a2b29a7733ef ("net/avf: enable basic Rx Tx")
Cc: stable@dpdk.org

Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
---
 drivers/net/iavf/iavf_ethdev.c | 2 ++
 drivers/net/iavf/iavf_rxtx.c   | 3 ++-
 2 files changed, 4 insertions(+), 1 deletion(-)
  

Comments

Qiming Yang Nov. 2, 2023, 6:44 a.m. UTC | #1
Hi, 

> -----Original Message-----
> From: Qi Zhang <qi.z.zhang@intel.com>
> Sent: Thursday, November 2, 2023 8:05 PM
> To: Xing, Beilei <beilei.xing@intel.com>
> Cc: dev@dpdk.org; Zhang, Qi Z <qi.z.zhang@intel.com>; stable@dpdk.org
> Subject: [PATCH] net/iavf: fix Tx preparation
> 
> 1. check nb_segs > Tx ring size for TSO case.
> 2. report nb_mtu_seg_max and nb_seg_max in dev_info.
> 
> Fixes: a2b29a7733ef ("net/avf: enable basic Rx Tx")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
> ---
>  drivers/net/iavf/iavf_ethdev.c | 2 ++
>  drivers/net/iavf/iavf_rxtx.c   | 3 ++-
>  2 files changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c
> index 98cc5c8ea8..0c6ab4ac5a 100644
> --- a/drivers/net/iavf/iavf_ethdev.c
> +++ b/drivers/net/iavf/iavf_ethdev.c
> @@ -1207,6 +1207,8 @@ iavf_dev_info_get(struct rte_eth_dev *dev, struct
> rte_eth_dev_info *dev_info)
>  		.nb_max = IAVF_MAX_RING_DESC,
>  		.nb_min = IAVF_MIN_RING_DESC,
>  		.nb_align = IAVF_ALIGN_RING_DESC,
> +		.nb_mtu_seg_max = IAVF_TX_MAX_MTU_SEG,
> +		.nb_seg_max = IAVF_MAX_RING_DESC,
>  	};
> 
>  	dev_info->err_handle_mode =
> RTE_ETH_ERROR_HANDLE_MODE_PASSIVE;
> diff --git a/drivers/net/iavf/iavf_rxtx.c b/drivers/net/iavf/iavf_rxtx.c index
> 610912f635..45f638c1d2 100644
> --- a/drivers/net/iavf/iavf_rxtx.c
> +++ b/drivers/net/iavf/iavf_rxtx.c
> @@ -3656,7 +3656,8 @@ iavf_prep_pkts(__rte_unused void *tx_queue,
> struct rte_mbuf **tx_pkts,
>  				return i;
>  			}
>  		} else if ((m->tso_segsz < IAVF_MIN_TSO_MSS) ||
> -			   (m->tso_segsz > IAVF_MAX_TSO_MSS)) {
> +			   (m->tso_segsz > IAVF_MAX_TSO_MSS) ||
> +			   (m->nb_segs > txq->nb_tx_desc)) {
>  			/* MSS outside the range are considered malicious */
>  			rte_errno = EINVAL;
>  			return i;
> --
> 2.31.1

Acked-by: Qiming Yang <qiming.yang@intel.com>
  
Qi Zhang Nov. 6, 2023, 1:40 a.m. UTC | #2
> -----Original Message-----
> From: Yang, Qiming <qiming.yang@intel.com>
> Sent: Thursday, November 2, 2023 2:45 PM
> To: Zhang, Qi Z <qi.z.zhang@intel.com>; Xing, Beilei <beilei.xing@intel.com>
> Cc: dev@dpdk.org; Zhang, Qi Z <qi.z.zhang@intel.com>; stable@dpdk.org
> Subject: RE: [PATCH] net/iavf: fix Tx preparation
> 
> Hi,
> 
> > -----Original Message-----
> > From: Qi Zhang <qi.z.zhang@intel.com>
> > Sent: Thursday, November 2, 2023 8:05 PM
> > To: Xing, Beilei <beilei.xing@intel.com>
> > Cc: dev@dpdk.org; Zhang, Qi Z <qi.z.zhang@intel.com>; stable@dpdk.org
> > Subject: [PATCH] net/iavf: fix Tx preparation
> >
> > 1. check nb_segs > Tx ring size for TSO case.
> > 2. report nb_mtu_seg_max and nb_seg_max in dev_info.
> >
> > Fixes: a2b29a7733ef ("net/avf: enable basic Rx Tx")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
> > ---
> >  drivers/net/iavf/iavf_ethdev.c | 2 ++
> >  drivers/net/iavf/iavf_rxtx.c   | 3 ++-
> >  2 files changed, 4 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/net/iavf/iavf_ethdev.c
> > b/drivers/net/iavf/iavf_ethdev.c index 98cc5c8ea8..0c6ab4ac5a 100644
> > --- a/drivers/net/iavf/iavf_ethdev.c
> > +++ b/drivers/net/iavf/iavf_ethdev.c
> > @@ -1207,6 +1207,8 @@ iavf_dev_info_get(struct rte_eth_dev *dev,
> > struct rte_eth_dev_info *dev_info)
> >  		.nb_max = IAVF_MAX_RING_DESC,
> >  		.nb_min = IAVF_MIN_RING_DESC,
> >  		.nb_align = IAVF_ALIGN_RING_DESC,
> > +		.nb_mtu_seg_max = IAVF_TX_MAX_MTU_SEG,
> > +		.nb_seg_max = IAVF_MAX_RING_DESC,
> >  	};
> >
> >  	dev_info->err_handle_mode =
> > RTE_ETH_ERROR_HANDLE_MODE_PASSIVE;
> > diff --git a/drivers/net/iavf/iavf_rxtx.c
> > b/drivers/net/iavf/iavf_rxtx.c index
> > 610912f635..45f638c1d2 100644
> > --- a/drivers/net/iavf/iavf_rxtx.c
> > +++ b/drivers/net/iavf/iavf_rxtx.c
> > @@ -3656,7 +3656,8 @@ iavf_prep_pkts(__rte_unused void *tx_queue,
> > struct rte_mbuf **tx_pkts,
> >  				return i;
> >  			}
> >  		} else if ((m->tso_segsz < IAVF_MIN_TSO_MSS) ||
> > -			   (m->tso_segsz > IAVF_MAX_TSO_MSS)) {
> > +			   (m->tso_segsz > IAVF_MAX_TSO_MSS) ||
> > +			   (m->nb_segs > txq->nb_tx_desc)) {
> >  			/* MSS outside the range are considered malicious */
> >  			rte_errno = EINVAL;
> >  			return i;
> > --
> > 2.31.1
> 
> Acked-by: Qiming Yang <qiming.yang@intel.com>

Applied to dpdk-next-net-intel.

Thanks
Qi
  

Patch

diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c
index 98cc5c8ea8..0c6ab4ac5a 100644
--- a/drivers/net/iavf/iavf_ethdev.c
+++ b/drivers/net/iavf/iavf_ethdev.c
@@ -1207,6 +1207,8 @@  iavf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 		.nb_max = IAVF_MAX_RING_DESC,
 		.nb_min = IAVF_MIN_RING_DESC,
 		.nb_align = IAVF_ALIGN_RING_DESC,
+		.nb_mtu_seg_max = IAVF_TX_MAX_MTU_SEG,
+		.nb_seg_max = IAVF_MAX_RING_DESC,
 	};
 
 	dev_info->err_handle_mode = RTE_ETH_ERROR_HANDLE_MODE_PASSIVE;
diff --git a/drivers/net/iavf/iavf_rxtx.c b/drivers/net/iavf/iavf_rxtx.c
index 610912f635..45f638c1d2 100644
--- a/drivers/net/iavf/iavf_rxtx.c
+++ b/drivers/net/iavf/iavf_rxtx.c
@@ -3656,7 +3656,8 @@  iavf_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts,
 				return i;
 			}
 		} else if ((m->tso_segsz < IAVF_MIN_TSO_MSS) ||
-			   (m->tso_segsz > IAVF_MAX_TSO_MSS)) {
+			   (m->tso_segsz > IAVF_MAX_TSO_MSS) ||
+			   (m->nb_segs > txq->nb_tx_desc)) {
 			/* MSS outside the range are considered malicious */
 			rte_errno = EINVAL;
 			return i;