DPDK patches and discussions
 help / color / mirror / Atom feed
* RE: [PATCH v2] net/ice: fix Tx preparation
  2023-11-02 14:22 ` [PATCH v2] net/ice: fix Tx preparation Qi Zhang
@ 2023-11-02  6:41   ` Yang, Qiming
  2023-11-06  1:40     ` Zhang, Qi Z
  0 siblings, 1 reply; 4+ messages in thread
From: Yang, Qiming @ 2023-11-02  6:41 UTC (permalink / raw)
  To: Zhang, Qi Z; +Cc: dev, stable

Hi,

> -----Original Message-----
> From: Zhang, Qi Z <qi.z.zhang@intel.com>
> Sent: Thursday, November 2, 2023 10:22 PM
> To: Yang, Qiming <qiming.yang@intel.com>
> Cc: dev@dpdk.org; Zhang, Qi Z <qi.z.zhang@intel.com>; stable@dpdk.org
> Subject: [PATCH v2] net/ice: fix Tx preparation
> 
> 1. Check nb_segs > 8 for NO TSO case
> 2. Check nb_segs > Tx ring size for TSO case 3. report nb_mtu_seg_max and
> nb_seg_max in dev_info.
> 
> Fixes: 17c7d0f9d6a4 ("net/ice: support basic Rx/Tx")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
> ---
>  drivers/net/ice/ice_ethdev.c |  2 ++
>  drivers/net/ice/ice_rxtx.c   | 18 ++++++++++++++++--
>  drivers/net/ice/ice_rxtx.h   |  2 ++
>  3 files changed, 20 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c index
> 6ef06b9926..3ccba4db80 100644
> --- a/drivers/net/ice/ice_ethdev.c
> +++ b/drivers/net/ice/ice_ethdev.c
> @@ -3918,6 +3918,8 @@ ice_dev_info_get(struct rte_eth_dev *dev, struct
> rte_eth_dev_info *dev_info)
>  		.nb_max = ICE_MAX_RING_DESC,
>  		.nb_min = ICE_MIN_RING_DESC,
>  		.nb_align = ICE_ALIGN_RING_DESC,
> +		.nb_mtu_seg_max = ICE_TX_MTU_SEG_MAX,
> +		.nb_seg_max = ICE_MAX_RING_DESC,
>  	};
> 
>  	dev_info->speed_capa = RTE_ETH_LINK_SPEED_10M | diff --git
> a/drivers/net/ice/ice_rxtx.c b/drivers/net/ice/ice_rxtx.c index
> ee9cb7b955..73e47ae92d 100644
> --- a/drivers/net/ice/ice_rxtx.c
> +++ b/drivers/net/ice/ice_rxtx.c
> @@ -3679,7 +3679,7 @@ ice_check_empty_mbuf(struct rte_mbuf *tx_pkt)  }
> 
>  uint16_t
> -ice_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts,
> +ice_prep_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
>  	      uint16_t nb_pkts)
>  {
>  	int i, ret;
> @@ -3690,9 +3690,23 @@ ice_prep_pkts(__rte_unused void *tx_queue,
> struct rte_mbuf **tx_pkts,
>  		m = tx_pkts[i];
>  		ol_flags = m->ol_flags;
> 
> -		if (ol_flags & RTE_MBUF_F_TX_TCP_SEG &&
> +		if (!(ol_flags & RTE_MBUF_F_TX_TCP_SEG) &&
> +		    /**
> +		     * No TSO case: nb->segs, pkt_len to not exceed
> +		     * the limites.
> +		     */
> +		    (m->nb_segs > ICE_TX_MTU_SEG_MAX ||
> +		     m->pkt_len > ICE_FRAME_SIZE_MAX)) {
> +			rte_errno = EINVAL;
> +			return i;
> +		} else if (ol_flags & RTE_MBUF_F_TX_TCP_SEG &&
> +		    /** TSO case: tso_segsz, nb_segs, pkt_len not exceed
> +		     * the limits.
> +		     */
>  		    (m->tso_segsz < ICE_MIN_TSO_MSS ||
>  		     m->tso_segsz > ICE_MAX_TSO_MSS ||
> +		     m->nb_segs >
> +			((struct ice_tx_queue *)tx_queue)->nb_tx_desc ||
>  		     m->pkt_len > ICE_MAX_TSO_FRAME_SIZE)) {
>  			/**
>  			 * MSS outside the range are considered malicious
> diff --git a/drivers/net/ice/ice_rxtx.h b/drivers/net/ice/ice_rxtx.h index
> 268289716e..bd2c4abec9 100644
> --- a/drivers/net/ice/ice_rxtx.h
> +++ b/drivers/net/ice/ice_rxtx.h
> @@ -56,6 +56,8 @@ extern int ice_timestamp_dynfield_offset;
> 
>  #define ICE_HEADER_SPLIT_ENA   BIT(0)
> 
> +#define ICE_TX_MTU_SEG_MAX	8
> +
>  typedef void (*ice_rx_release_mbufs_t)(struct ice_rx_queue *rxq);  typedef
> void (*ice_tx_release_mbufs_t)(struct ice_tx_queue *txq);  typedef void
> (*ice_rxd_to_pkt_fields_t)(struct ice_rx_queue *rxq,
> --
> 2.31.1

Acked-by: Qiming Yang <qiming.yang@intel.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] net/ice: fix Tx Prepareation
@ 2023-11-02 10:12 Qi Zhang
  2023-11-02 14:22 ` [PATCH v2] net/ice: fix Tx preparation Qi Zhang
  0 siblings, 1 reply; 4+ messages in thread
From: Qi Zhang @ 2023-11-02 10:12 UTC (permalink / raw)
  To: qiming.yang; +Cc: dev, Qi Zhang, stable

1. Check nb_segs > 8 for NO TSO case
2. Check nb_segs > Tx ring size for TSO case
3. report nb_mtu_seg_max and nb_seg_max in dev_info.

Fixes: 17c7d0f9d6a4 ("net/ice: support basic Rx/Tx")
Cc: stable@dpdk.org

Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
---
 drivers/net/ice/ice_ethdev.c |  2 ++
 drivers/net/ice/ice_rxtx.c   | 16 +++++++++++++++-
 drivers/net/ice/ice_rxtx.h   |  2 ++
 3 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
index 6ef06b9926..3ccba4db80 100644
--- a/drivers/net/ice/ice_ethdev.c
+++ b/drivers/net/ice/ice_ethdev.c
@@ -3918,6 +3918,8 @@ ice_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 		.nb_max = ICE_MAX_RING_DESC,
 		.nb_min = ICE_MIN_RING_DESC,
 		.nb_align = ICE_ALIGN_RING_DESC,
+		.nb_mtu_seg_max = ICE_TX_MTU_SEG_MAX,
+		.nb_seg_max = ICE_MAX_RING_DESC,
 	};
 
 	dev_info->speed_capa = RTE_ETH_LINK_SPEED_10M |
diff --git a/drivers/net/ice/ice_rxtx.c b/drivers/net/ice/ice_rxtx.c
index ee9cb7b955..868ee59933 100644
--- a/drivers/net/ice/ice_rxtx.c
+++ b/drivers/net/ice/ice_rxtx.c
@@ -3690,9 +3690,23 @@ ice_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts,
 		m = tx_pkts[i];
 		ol_flags = m->ol_flags;
 
-		if (ol_flags & RTE_MBUF_F_TX_TCP_SEG &&
+		if (!(ol_flags & RTE_MBUF_F_TX_TCP_SEG) &&
+		    /**
+		     * No TSO case: nb->segs, pkt_len to not exceed
+		     * the limites.
+		     */
+		    (m->nb_segs > ICE_TX_MTU_SEG_MAX ||
+		     m->pkt_len > ICE_FRAME_SIZE_MAX)) {
+			rte_errno = EINVAL;
+			return i;
+		} else if (ol_flags & RTE_MBUF_F_TX_TCP_SEG &&
+		    /** TSO case: tso_segsz, nb_segs, pkt_len not exceed
+		     * the limits.
+		     */
 		    (m->tso_segsz < ICE_MIN_TSO_MSS ||
 		     m->tso_segsz > ICE_MAX_TSO_MSS ||
+		     m->nb_segs >
+			((struct ice_tx_queue *)tx_queue)->nb_tx_desc ||
 		     m->pkt_len > ICE_MAX_TSO_FRAME_SIZE)) {
 			/**
 			 * MSS outside the range are considered malicious
diff --git a/drivers/net/ice/ice_rxtx.h b/drivers/net/ice/ice_rxtx.h
index 268289716e..bd2c4abec9 100644
--- a/drivers/net/ice/ice_rxtx.h
+++ b/drivers/net/ice/ice_rxtx.h
@@ -56,6 +56,8 @@ extern int ice_timestamp_dynfield_offset;
 
 #define ICE_HEADER_SPLIT_ENA   BIT(0)
 
+#define ICE_TX_MTU_SEG_MAX	8
+
 typedef void (*ice_rx_release_mbufs_t)(struct ice_rx_queue *rxq);
 typedef void (*ice_tx_release_mbufs_t)(struct ice_tx_queue *txq);
 typedef void (*ice_rxd_to_pkt_fields_t)(struct ice_rx_queue *rxq,
-- 
2.31.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2] net/ice: fix Tx preparation
  2023-11-02 10:12 [PATCH] net/ice: fix Tx Prepareation Qi Zhang
@ 2023-11-02 14:22 ` Qi Zhang
  2023-11-02  6:41   ` Yang, Qiming
  0 siblings, 1 reply; 4+ messages in thread
From: Qi Zhang @ 2023-11-02 14:22 UTC (permalink / raw)
  To: qiming.yang; +Cc: dev, Qi Zhang, stable

1. Check nb_segs > 8 for NO TSO case
2. Check nb_segs > Tx ring size for TSO case
3. report nb_mtu_seg_max and nb_seg_max in dev_info.

Fixes: 17c7d0f9d6a4 ("net/ice: support basic Rx/Tx")
Cc: stable@dpdk.org

Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
---
 drivers/net/ice/ice_ethdev.c |  2 ++
 drivers/net/ice/ice_rxtx.c   | 18 ++++++++++++++++--
 drivers/net/ice/ice_rxtx.h   |  2 ++
 3 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
index 6ef06b9926..3ccba4db80 100644
--- a/drivers/net/ice/ice_ethdev.c
+++ b/drivers/net/ice/ice_ethdev.c
@@ -3918,6 +3918,8 @@ ice_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 		.nb_max = ICE_MAX_RING_DESC,
 		.nb_min = ICE_MIN_RING_DESC,
 		.nb_align = ICE_ALIGN_RING_DESC,
+		.nb_mtu_seg_max = ICE_TX_MTU_SEG_MAX,
+		.nb_seg_max = ICE_MAX_RING_DESC,
 	};
 
 	dev_info->speed_capa = RTE_ETH_LINK_SPEED_10M |
diff --git a/drivers/net/ice/ice_rxtx.c b/drivers/net/ice/ice_rxtx.c
index ee9cb7b955..73e47ae92d 100644
--- a/drivers/net/ice/ice_rxtx.c
+++ b/drivers/net/ice/ice_rxtx.c
@@ -3679,7 +3679,7 @@ ice_check_empty_mbuf(struct rte_mbuf *tx_pkt)
 }
 
 uint16_t
-ice_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts,
+ice_prep_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 	      uint16_t nb_pkts)
 {
 	int i, ret;
@@ -3690,9 +3690,23 @@ ice_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts,
 		m = tx_pkts[i];
 		ol_flags = m->ol_flags;
 
-		if (ol_flags & RTE_MBUF_F_TX_TCP_SEG &&
+		if (!(ol_flags & RTE_MBUF_F_TX_TCP_SEG) &&
+		    /**
+		     * No TSO case: nb->segs, pkt_len to not exceed
+		     * the limites.
+		     */
+		    (m->nb_segs > ICE_TX_MTU_SEG_MAX ||
+		     m->pkt_len > ICE_FRAME_SIZE_MAX)) {
+			rte_errno = EINVAL;
+			return i;
+		} else if (ol_flags & RTE_MBUF_F_TX_TCP_SEG &&
+		    /** TSO case: tso_segsz, nb_segs, pkt_len not exceed
+		     * the limits.
+		     */
 		    (m->tso_segsz < ICE_MIN_TSO_MSS ||
 		     m->tso_segsz > ICE_MAX_TSO_MSS ||
+		     m->nb_segs >
+			((struct ice_tx_queue *)tx_queue)->nb_tx_desc ||
 		     m->pkt_len > ICE_MAX_TSO_FRAME_SIZE)) {
 			/**
 			 * MSS outside the range are considered malicious
diff --git a/drivers/net/ice/ice_rxtx.h b/drivers/net/ice/ice_rxtx.h
index 268289716e..bd2c4abec9 100644
--- a/drivers/net/ice/ice_rxtx.h
+++ b/drivers/net/ice/ice_rxtx.h
@@ -56,6 +56,8 @@ extern int ice_timestamp_dynfield_offset;
 
 #define ICE_HEADER_SPLIT_ENA   BIT(0)
 
+#define ICE_TX_MTU_SEG_MAX	8
+
 typedef void (*ice_rx_release_mbufs_t)(struct ice_rx_queue *rxq);
 typedef void (*ice_tx_release_mbufs_t)(struct ice_tx_queue *txq);
 typedef void (*ice_rxd_to_pkt_fields_t)(struct ice_rx_queue *rxq,
-- 
2.31.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [PATCH v2] net/ice: fix Tx preparation
  2023-11-02  6:41   ` Yang, Qiming
@ 2023-11-06  1:40     ` Zhang, Qi Z
  0 siblings, 0 replies; 4+ messages in thread
From: Zhang, Qi Z @ 2023-11-06  1:40 UTC (permalink / raw)
  To: Yang, Qiming; +Cc: dev, stable



> -----Original Message-----
> From: Yang, Qiming <qiming.yang@intel.com>
> Sent: Thursday, November 2, 2023 2:41 PM
> To: Zhang, Qi Z <qi.z.zhang@intel.com>
> Cc: dev@dpdk.org; stable@dpdk.org
> Subject: RE: [PATCH v2] net/ice: fix Tx preparation
> 
> Hi,
> 
> > -----Original Message-----
> > From: Zhang, Qi Z <qi.z.zhang@intel.com>
> > Sent: Thursday, November 2, 2023 10:22 PM
> > To: Yang, Qiming <qiming.yang@intel.com>
> > Cc: dev@dpdk.org; Zhang, Qi Z <qi.z.zhang@intel.com>; stable@dpdk.org
> > Subject: [PATCH v2] net/ice: fix Tx preparation
> >
> > 1. Check nb_segs > 8 for NO TSO case
> > 2. Check nb_segs > Tx ring size for TSO case 3. report nb_mtu_seg_max
> > and nb_seg_max in dev_info.
> >
> > Fixes: 17c7d0f9d6a4 ("net/ice: support basic Rx/Tx")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
> > ---
> >  drivers/net/ice/ice_ethdev.c |  2 ++
> >  drivers/net/ice/ice_rxtx.c   | 18 ++++++++++++++++--
> >  drivers/net/ice/ice_rxtx.h   |  2 ++
> >  3 files changed, 20 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/net/ice/ice_ethdev.c
> > b/drivers/net/ice/ice_ethdev.c index
> > 6ef06b9926..3ccba4db80 100644
> > --- a/drivers/net/ice/ice_ethdev.c
> > +++ b/drivers/net/ice/ice_ethdev.c
> > @@ -3918,6 +3918,8 @@ ice_dev_info_get(struct rte_eth_dev *dev, struct
> > rte_eth_dev_info *dev_info)
> >  		.nb_max = ICE_MAX_RING_DESC,
> >  		.nb_min = ICE_MIN_RING_DESC,
> >  		.nb_align = ICE_ALIGN_RING_DESC,
> > +		.nb_mtu_seg_max = ICE_TX_MTU_SEG_MAX,
> > +		.nb_seg_max = ICE_MAX_RING_DESC,
> >  	};
> >
> >  	dev_info->speed_capa = RTE_ETH_LINK_SPEED_10M | diff --git
> > a/drivers/net/ice/ice_rxtx.c b/drivers/net/ice/ice_rxtx.c index
> > ee9cb7b955..73e47ae92d 100644
> > --- a/drivers/net/ice/ice_rxtx.c
> > +++ b/drivers/net/ice/ice_rxtx.c
> > @@ -3679,7 +3679,7 @@ ice_check_empty_mbuf(struct rte_mbuf
> *tx_pkt)  }
> >
> >  uint16_t
> > -ice_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts,
> > +ice_prep_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
> >  	      uint16_t nb_pkts)
> >  {
> >  	int i, ret;
> > @@ -3690,9 +3690,23 @@ ice_prep_pkts(__rte_unused void *tx_queue,
> > struct rte_mbuf **tx_pkts,
> >  		m = tx_pkts[i];
> >  		ol_flags = m->ol_flags;
> >
> > -		if (ol_flags & RTE_MBUF_F_TX_TCP_SEG &&
> > +		if (!(ol_flags & RTE_MBUF_F_TX_TCP_SEG) &&
> > +		    /**
> > +		     * No TSO case: nb->segs, pkt_len to not exceed
> > +		     * the limites.
> > +		     */
> > +		    (m->nb_segs > ICE_TX_MTU_SEG_MAX ||
> > +		     m->pkt_len > ICE_FRAME_SIZE_MAX)) {
> > +			rte_errno = EINVAL;
> > +			return i;
> > +		} else if (ol_flags & RTE_MBUF_F_TX_TCP_SEG &&
> > +		    /** TSO case: tso_segsz, nb_segs, pkt_len not exceed
> > +		     * the limits.
> > +		     */
> >  		    (m->tso_segsz < ICE_MIN_TSO_MSS ||
> >  		     m->tso_segsz > ICE_MAX_TSO_MSS ||
> > +		     m->nb_segs >
> > +			((struct ice_tx_queue *)tx_queue)->nb_tx_desc ||
> >  		     m->pkt_len > ICE_MAX_TSO_FRAME_SIZE)) {
> >  			/**
> >  			 * MSS outside the range are considered malicious diff
> --git
> > a/drivers/net/ice/ice_rxtx.h b/drivers/net/ice/ice_rxtx.h index
> > 268289716e..bd2c4abec9 100644
> > --- a/drivers/net/ice/ice_rxtx.h
> > +++ b/drivers/net/ice/ice_rxtx.h
> > @@ -56,6 +56,8 @@ extern int ice_timestamp_dynfield_offset;
> >
> >  #define ICE_HEADER_SPLIT_ENA   BIT(0)
> >
> > +#define ICE_TX_MTU_SEG_MAX	8
> > +
> >  typedef void (*ice_rx_release_mbufs_t)(struct ice_rx_queue *rxq);
> > typedef void (*ice_tx_release_mbufs_t)(struct ice_tx_queue *txq);
> > typedef void (*ice_rxd_to_pkt_fields_t)(struct ice_rx_queue *rxq,
> > --
> > 2.31.1
> 
> Acked-by: Qiming Yang <qiming.yang@intel.com>


Applied to dpdk-next-net-intel.

Thanks
Qi

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-11-06  1:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-02 10:12 [PATCH] net/ice: fix Tx Prepareation Qi Zhang
2023-11-02 14:22 ` [PATCH v2] net/ice: fix Tx preparation Qi Zhang
2023-11-02  6:41   ` Yang, Qiming
2023-11-06  1:40     ` Zhang, Qi Z

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).