Skip to contentSkip to conversation

net/ice: fix scalar Rx and Tx path segment

PATCH Superseded Mingjin Ye 4 participants 22 messages Nov 3, 2022 – Sep 27, 2023 Network drivers

lore
Share & tools
lore

Mingjin Ye

author
#0 lore raw

PATCH 1/1 net/ice: fix scalar Rx and Tx path segment

CRC is stripped by the hardware in the scattered Rx path. If the last buffer packet length is '0', the scalar Tx path would send empty buffer that causes the Tx queue to overflow.

This patch adds a judgment for the last buffer length to fix this issue, so that it would free the mbuf associated to the last one if the last buffer is empty.

Fixes 6eac0b7fde95 ("net/ice: support advance Rx/Tx")
---
 drivers/net/ice/ice_rxtx.c | 53 ++++++++++++++++++++++++++++++++++++--
 1 file changed, 51 insertions(+), 2 deletions(-)
drivers/net/ice/ice_rxtx.c +51 -2
index 0a2b0376ac..4f9c29eaf6 100644
@@ -2111,6 +2111,10 @@ ice_recv_scattered_pkts(void *rx_queue,
 			} else
 				rxm->data_len = (uint16_t)(rx_packet_len -
 							   RTE_ETHER_CRC_LEN);
+		} else if (rx_packet_len == 0) {
+			rte_pktmbuf_free_seg(rxm);
+			first_seg->nb_segs--;
+			last_seg->next = NULL;
 		}
 
 		first_seg->port = rxq->port_id;
@@ -2903,6 +2907,35 @@ ice_calc_pkt_desc(struct rte_mbuf *tx_pkt)
 	return count;
 }
 
+/*Check the number of valid mbufs and free the invalid mbufs*/
+static inline uint16_t
+ice_check_mbuf(struct rte_mbuf *tx_pkt)
+{
+	struct rte_mbuf *txd = tx_pkt;
+	struct rte_mbuf *txd_removal = NULL;
+	struct rte_mbuf *txd_pre = NULL;
+	uint16_t count = 0;
+	uint16_t removal = 0;
+
+	while (txd != NULL) {
+		if (removal == 1 || txd->data_len == 0) {
+			txd_removal = txd;
+			txd = txd->next;
+			if (removal == 0) {
+				removal = 1;
+				txd_pre->next = NULL;
+			}
+			rte_pktmbuf_free_seg(txd_removal);
+		} else {
+			++count;
+			txd_pre = txd;
+			txd = txd->next;
+		}
+	}
+
+	return count;
+}
+
 uint16_t
 ice_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 {
@@ -2960,11 +2993,27 @@ ice_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 		 * the mbuf data size exceeds max data size that hw allows
 		 * per tx desc.
 		 */
-		if (ol_flags & RTE_MBUF_F_TX_TCP_SEG)
+		if (ol_flags & RTE_MBUF_F_TX_TCP_SEG) {
 			nb_used = (uint16_t)(ice_calc_pkt_desc(tx_pkt) +
 					     nb_ctx);
-		else
+		} else {
+			nb_used = ice_check_mbuf(tx_pkt);
+			if (nb_used == 0) {
+				PMD_TX_LOG(ERR,
+				"Check packets is empty "
+				"(port=%d queue=%d)\n",
+				txq->port_id, txq->queue_id);
+				continue;
+			} else if (nb_used < tx_pkt->nb_segs) {
+				PMD_TX_LOG(WRINING,
+				"Check packets valid num ="
+				"%4u total num = %4u (port=%d queue=%d)\n",
+				nb_used, tx_pkt->nb_segs, txq->port_id, txq->queue_id);
+				tx_pkt->nb_segs = nb_used;
+			}
 			nb_used = (uint16_t)(tx_pkt->nb_segs + nb_ctx);
+		}
+
 		tx_last = (uint16_t)(tx_id + nb_used - 1);
 
 		/* Circular ring */
Signature · 1 line
2.34.1
Tested-by on v1 1/1
#1 lore raw
Quoted 16 lines

-----Original Message-----
From: Mingjin Ye <[email protected]>
Sent: Friday, November 4, 2022 1:21 AM
To: [email protected]
Cc: [email protected]; Zhou, YidingX <[email protected]>; Ye, MingjinX <[email protected]>; Yang, Qiming <[email protected]>; Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Lu, Wenzhuo <[email protected]>; Ferruh Yigit <[email protected]>; Li, Xiaoyun <[email protected]>
Subject: [PATCH] net/ice: fix scalar Rx and Tx path segment

CRC is stripped by the hardware in the scattered Rx path. If the last buffer packet length is '0', the scalar Tx path would send empty buffer that causes the Tx queue to overflow.

Quoted 7 lines

This patch adds a judgment for the last buffer length to fix this issue, so that it would free the mbuf associated to the last one if the last buffer is empty.

Fixes 6eac0b7fde95 ("net/ice: support advance Rx/Tx")

V1 patch verified and passed. Remains some compile errors to fix for redhat.

Quoted 4 lines
---
 drivers/net/ice/ice_rxtx.c | 53 ++++++++++++++++++++++++++++++++++++--
 1 file changed, 51 insertions(+), 2 deletions(-)
author
#2 lore raw

PATCH v2 1/1 net/ice: fix scalar Rx and Tx path segment

In reply to Mingjin Ye

CRC is stripped by the hardware in the scattered Rx path. If the last buffer packet length is '0', the scalar Tx path would send empty buffer that causes the Tx queue to overflow.

This patch adds a judgment for the last buffer length to fix this issue, so that it would free the mbuf associated to the last one if the last buffer is empty.

Fixes 6eac0b7fde95 ("net/ice: support advance Rx/Tx")

v2:
* Fix log level in ice_rxtx.c source file.

---
 drivers/net/ice/ice_rxtx.c | 53 ++++++++++++++++++++++++++++++++++++--
 1 file changed, 51 insertions(+), 2 deletions(-)
drivers/net/ice/ice_rxtx.c +51 -2
index 0a2b0376ac..b181f66aad 100644
@@ -2111,6 +2111,10 @@ ice_recv_scattered_pkts(void *rx_queue,
 			} else
 				rxm->data_len = (uint16_t)(rx_packet_len -
 							   RTE_ETHER_CRC_LEN);
+		} else if (rx_packet_len == 0) {
+			rte_pktmbuf_free_seg(rxm);
+			first_seg->nb_segs--;
+			last_seg->next = NULL;
 		}
 
 		first_seg->port = rxq->port_id;
@@ -2903,6 +2907,35 @@ ice_calc_pkt_desc(struct rte_mbuf *tx_pkt)
 	return count;
 }
 
+/*Check the number of valid mbufs and free the invalid mbufs*/
+static inline uint16_t
+ice_check_mbuf(struct rte_mbuf *tx_pkt)
+{
+	struct rte_mbuf *txd = tx_pkt;
+	struct rte_mbuf *txd_removal = NULL;
+	struct rte_mbuf *txd_pre = NULL;
+	uint16_t count = 0;
+	uint16_t removal = 0;
+
+	while (txd != NULL) {
+		if (removal == 1 || txd->data_len == 0) {
+			txd_removal = txd;
+			txd = txd->next;
+			if (removal == 0) {
+				removal = 1;
+				txd_pre->next = NULL;
+			}
+			rte_pktmbuf_free_seg(txd_removal);
+		} else {
+			++count;
+			txd_pre = txd;
+			txd = txd->next;
+		}
+	}
+
+	return count;
+}
+
 uint16_t
 ice_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 {
@@ -2960,11 +2993,27 @@ ice_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 		 * the mbuf data size exceeds max data size that hw allows
 		 * per tx desc.
 		 */
-		if (ol_flags & RTE_MBUF_F_TX_TCP_SEG)
+		if (ol_flags & RTE_MBUF_F_TX_TCP_SEG) {
 			nb_used = (uint16_t)(ice_calc_pkt_desc(tx_pkt) +
 					     nb_ctx);
-		else
+		} else {
+			nb_used = ice_check_mbuf(tx_pkt);
+			if (nb_used == 0) {
+				PMD_TX_LOG(ERR,
+				"Check packets is empty "
+				"(port=%d queue=%d)\n",
+				txq->port_id, txq->queue_id);
+				continue;
+			} else if (nb_used < tx_pkt->nb_segs) {
+				PMD_TX_LOG(DEBUG,
+				"Check packets valid num ="
+				"%4u total num = %4u (port=%d queue=%d)\n",
+				nb_used, tx_pkt->nb_segs, txq->port_id, txq->queue_id);
+				tx_pkt->nb_segs = nb_used;
+			}
 			nb_used = (uint16_t)(tx_pkt->nb_segs + nb_ctx);
+		}
+
 		tx_last = (uint16_t)(tx_id + nb_used - 1);
 
 		/* Circular ring */
Signature · 1 line
2.34.1
Tested-by on v2 1/1
#3 lore raw
Quoted 15 lines

-----Original Message-----
From: Mingjin Ye <[email protected]>
Sent: Wednesday, November 9, 2022 8:56 PM
To: [email protected]
Cc: Yang, Qiming <[email protected]>; [email protected]; Zhou, YidingX <[email protected]>; Ye, MingjinX <[email protected]>; Zhang, Qi Z <[email protected]>; Lu, Wenzhuo <[email protected]>; Wu, Jingjing <[email protected]>; Li, Xiaoyun <[email protected]>; Ferruh Yigit <[email protected]>
Subject: [PATCH v2] net/ice: fix scalar Rx and Tx path segment

CRC is stripped by the hardware in the scattered Rx path. If the last buffer packet length is '0', the scalar Tx path would send empty buffer that causes the Tx queue to overflow.

Quoted 7 lines

This patch adds a judgment for the last buffer length to fix this issue, so that it would free the mbuf associated to the last one if the last buffer is empty.

Fixes 6eac0b7fde95 ("net/ice: support advance Rx/Tx")

Tested and passed.

Quoted 7 lines

v2:
* Fix log level in ice_rxtx.c source file.

---
 drivers/net/ice/ice_rxtx.c | 53 ++++++++++++++++++++++++++++++++++++--
 1 file changed, 51 insertions(+), 2 deletions(-)
#4 lore raw
In reply to Mingjin Ye
Quoted 13 lines

-----Original Message-----
From: Ye, MingjinX <[email protected]>
Sent: Wednesday, November 9, 2022 8:56 PM
To: [email protected]
Cc: Yang, Qiming <[email protected]>; [email protected]; Zhou, YidingX <[email protected]>; Ye, MingjinX <[email protected]>; Zhang, Qi Z <[email protected]>; Lu, Wenzhuo <[email protected]>; Wu, Jingjing <[email protected]>; Li, Xiaoyun <[email protected]>; Ferruh Yigit <[email protected]>
Subject: [PATCH v2] net/ice: fix scalar Rx and Tx path segment

Quoted 3 lines

CRC is stripped by the hardware in the scattered Rx path. If the last buffer packet length is '0', the scalar Tx path would send empty buffer that causes the Tx queue to overflow.

Please separate this patch into two, one for Rx and one for Tx, they are independent.

For the Tx implementation, I think we can move them into tx_prepare where is place to check Tx violation.

Quoted 99 lines

This patch adds a judgment for the last buffer length to fix this issue, so that it would free the mbuf associated to the last one if the last buffer is empty.

Fixes 6eac0b7fde95 ("net/ice: support advance Rx/Tx")

v2:
* Fix log level in ice_rxtx.c source file.

---
 drivers/net/ice/ice_rxtx.c | 53 ++++++++++++++++++++++++++++++++++++--
 1 file changed, 51 insertions(+), 2 deletions(-)
drivers/net/ice/ice_rxtx.c index renamed from drivers/net/ice/ice_rxtx.c +0 -0

0a2b0376ac..b181f66aad 100644

drivers/net/ice/ice_rxtx.c +4 -0
@@ -2111,6 +2111,10 @@ ice_recv_scattered_pkts(void *rx_queue,
 			} else
 				rxm->data_len = (uint16_t)(rx_packet_len -
 
 RTE_ETHER_CRC_LEN);
+		} else if (rx_packet_len == 0) {
+			rte_pktmbuf_free_seg(rxm);
+			first_seg->nb_segs--;
+			last_seg->next = NULL;
 		}
 
drivers/net/ice/ice_rxtx.c +27 -0
 		first_seg->port = rxq->port_id;
@@ -2903,6 +2907,35 @@ ice_calc_pkt_desc(struct rte_mbuf *tx_pkt)
 	return count;
 }
 
+/*Check the number of valid mbufs and free the invalid mbufs*/ static
+inline uint16_t ice_check_mbuf(struct rte_mbuf *tx_pkt) {
+	struct rte_mbuf *txd = tx_pkt;
+	struct rte_mbuf *txd_removal = NULL;
+	struct rte_mbuf *txd_pre = NULL;
+	uint16_t count = 0;
+	uint16_t removal = 0;
+
+	while (txd != NULL) {
+		if (removal == 1 || txd->data_len == 0) {
+			txd_removal = txd;
+			txd = txd->next;
+			if (removal == 0) {
+				removal = 1;
+				txd_pre->next = NULL;
+			}
+			rte_pktmbuf_free_seg(txd_removal);
+		} else {
+			++count;
+			txd_pre = txd;
+			txd = txd->next;
+		}
+	}
+
+	return count;
+}
+
 uint16_t
 ice_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)

{ @@ -2960,11 +2993,27 @@ ice_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)

drivers/net/ice/ice_rxtx.c +13 -2
 		 * the mbuf data size exceeds max data size that hw allows
 		 * per tx desc.
 		 */
-		if (ol_flags & RTE_MBUF_F_TX_TCP_SEG)
+		if (ol_flags & RTE_MBUF_F_TX_TCP_SEG) {
 			nb_used = (uint16_t)(ice_calc_pkt_desc(tx_pkt) +
 					     nb_ctx);
-		else
+		} else {
+			nb_used = ice_check_mbuf(tx_pkt);
+			if (nb_used == 0) {
+				PMD_TX_LOG(ERR,
+				"Check packets is empty "
+				"(port=%d queue=%d)\n",
+				txq->port_id, txq->queue_id);
+				continue;
+			} else if (nb_used < tx_pkt->nb_segs) {
+				PMD_TX_LOG(DEBUG,
+				"Check packets valid num ="
+				"%4u total num = %4u (port=%d

queue=%d)\n",

drivers/net/ice/ice_rxtx.c +1 -0
+				nb_used, tx_pkt->nb_segs, txq->port_id, txq-
Quoted 1 line

queue_id);

drivers/net/ice/ice_rxtx.c +4 -1
+				tx_pkt->nb_segs = nb_used;
+			}
 			nb_used = (uint16_t)(tx_pkt->nb_segs + nb_ctx);
+		}
+
 		tx_last = (uint16_t)(tx_id + nb_used - 1);
 
 		/* Circular ring */
--

2.34.1

#5 lore raw
Quoted 30 lines

-----Original Message-----
From: Zhang, Qi Z <[email protected]>
Sent: 2022年11月10日 18:37
To: Ye, MingjinX <[email protected]>; [email protected]
Cc: Yang, Qiming <[email protected]>; [email protected]; Zhou, YidingX <[email protected]>; Lu, Wenzhuo <[email protected]>; Wu, Jingjing <[email protected]>; Li, Xiaoyun <[email protected]>; Ferruh Yigit <[email protected]>
Subject: RE: [PATCH v2] net/ice: fix scalar Rx and Tx path segment

Quoted 12 lines

-----Original Message-----
From: Ye, MingjinX <[email protected]>
Sent: Wednesday, November 9, 2022 8:56 PM
To: [email protected]
Cc: Yang, Qiming <[email protected]>; [email protected]; Zhou, YidingX <[email protected]>; Ye, MingjinX <[email protected]>; Zhang, Qi Z <[email protected]>; Lu, Wenzhuo <[email protected]>; Wu, Jingjing <[email protected]>; Li, Xiaoyun <[email protected]>; Ferruh Yigit <[email protected]>
Subject: [PATCH v2] net/ice: fix scalar Rx and Tx path segment

Quoted 3 lines

CRC is stripped by the hardware in the scattered Rx path. If the last buffer packet length is '0', the scalar Tx path would send empty buffer that causes the Tx queue to overflow.

Quoted 5 lines

Please separate this patch into two, one for Rx and one for Tx, they are independent.

For the Tx implementation, I think we can move them into tx_prepare where is place to check Tx violation.

Thanks for your suggestion, I will provide 2 new patches according to the new scheme and promote it to the community.

Quoted 103 lines
Quoted 4 lines

This patch adds a judgment for the last buffer length to fix this issue, so that it would free the mbuf associated to the last one if the last

buffer is empty.

Quoted 85 lines
Fixes 6eac0b7fde95 ("net/ice: support advance Rx/Tx")

v2:
* Fix log level in ice_rxtx.c source file.

---
 drivers/net/ice/ice_rxtx.c | 53
++++++++++++++++++++++++++++++++++++--
 1 file changed, 51 insertions(+), 2 deletions(-)
drivers/net/ice/ice_rxtx.c +4 -0
index 0a2b0376ac..b181f66aad 100644
@@ -2111,6 +2111,10 @@ ice_recv_scattered_pkts(void *rx_queue,
 			} else
 				rxm->data_len = (uint16_t)(rx_packet_len -
 
 RTE_ETHER_CRC_LEN);
+		} else if (rx_packet_len == 0) {
+			rte_pktmbuf_free_seg(rxm);
+			first_seg->nb_segs--;
+			last_seg->next = NULL;
 		}
 
drivers/net/ice/ice_rxtx.c +27 -0
 		first_seg->port = rxq->port_id;
@@ -2903,6 +2907,35 @@ ice_calc_pkt_desc(struct rte_mbuf *tx_pkt)
 	return count;
 }
 
+/*Check the number of valid mbufs and free the invalid mbufs*/ static
+inline uint16_t ice_check_mbuf(struct rte_mbuf *tx_pkt) {
+	struct rte_mbuf *txd = tx_pkt;
+	struct rte_mbuf *txd_removal = NULL;
+	struct rte_mbuf *txd_pre = NULL;
+	uint16_t count = 0;
+	uint16_t removal = 0;
+
+	while (txd != NULL) {
+		if (removal == 1 || txd->data_len == 0) {
+			txd_removal = txd;
+			txd = txd->next;
+			if (removal == 0) {
+				removal = 1;
+				txd_pre->next = NULL;
+			}
+			rte_pktmbuf_free_seg(txd_removal);
+		} else {
+			++count;
+			txd_pre = txd;
+			txd = txd->next;
+		}
+	}
+
+	return count;
+}
+
 uint16_t
 ice_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t
 nb_pkts) { @@ -2960,11 +2993,27 @@ ice_xmit_pkts(void *tx_queue,

struct rte_mbuf **tx_pkts, uint16_t nb_pkts)

drivers/net/ice/ice_rxtx.c +13 -2
 		 * the mbuf data size exceeds max data size that hw allows
 		 * per tx desc.
 		 */
-		if (ol_flags & RTE_MBUF_F_TX_TCP_SEG)
+		if (ol_flags & RTE_MBUF_F_TX_TCP_SEG) {
 			nb_used = (uint16_t)(ice_calc_pkt_desc(tx_pkt) +
 					     nb_ctx);
-		else
+		} else {
+			nb_used = ice_check_mbuf(tx_pkt);
+			if (nb_used == 0) {
+				PMD_TX_LOG(ERR,
+				"Check packets is empty "
+				"(port=%d queue=%d)\n",
+				txq->port_id, txq->queue_id);
+				continue;
+			} else if (nb_used < tx_pkt->nb_segs) {
+				PMD_TX_LOG(DEBUG,
+				"Check packets valid num ="
+				"%4u total num = %4u (port=%d

queue=%d)\n",

drivers/net/ice/ice_rxtx.c

Quoted 1 line
drivers/net/ice/ice_rxtx.c +1 -0
+				nb_used, tx_pkt->nb_segs, txq->port_id,

txq-

Quoted 11 lines
Quoted 1 line

queue_id);

drivers/net/ice/ice_rxtx.c +4 -1
+				tx_pkt->nb_segs = nb_used;
+			}
 			nb_used = (uint16_t)(tx_pkt->nb_segs + nb_ctx);
+		}
+
 		tx_last = (uint16_t)(tx_id + nb_used - 1);
 
 		/* Circular ring */
--

2.34.1

author
#6 lore raw

PATCH v3 1/2 net/ice: fix scalar Rx path segment

In reply to Mingjin Ye

CRC is stripped by the hardware in the scattered Rx path. The last buffer is invalid if it's packet length is zero.

This patch adds a judgment for the last buffer length to fix this issue, it would free the mbuf associated to the last one if the last buffer is empty.

Fixes 6eac0b7fde95 ("net/ice: support advance Rx/Tx")
---
 drivers/net/ice/ice_rxtx.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/net/ice/ice_rxtx.c +4 -0
index 0a2b0376ac..e6ddd2513d 100644
@@ -2111,6 +2111,10 @@ ice_recv_scattered_pkts(void *rx_queue,
 			} else
 				rxm->data_len = (uint16_t)(rx_packet_len -
 							   RTE_ETHER_CRC_LEN);
+		} else if (rx_packet_len == 0) {
+			rte_pktmbuf_free_seg(rxm);
+			first_seg->nb_segs--;
+			last_seg->next = NULL;
 		}
 
 		first_seg->port = rxq->port_id;
Signature · 1 line
2.34.1
author
#7 lore raw

PATCH v3 2/2 net/ice: fix scalar Tx path segment

The scalar Tx path would send empty buffer that causes the Tx queue to overflow.

This patch adds the last buffer length judgment in tx_prepare to fix this issue, rte_errno will be set to EINVAL and returned if the last buffer is empty.

Fixes 17c7d0f9d6a4 ("net/ice: support basic Rx/Tx")
Fixes ccf33dccf7aa ("net/ice: check illegal packet sizes")
---
 drivers/net/ice/ice_rxtx.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
drivers/net/ice/ice_rxtx.c +24 -0
index e6ddd2513d..69358f6a3a 100644
@@ -3643,6 +3643,22 @@ ice_set_tx_function_flag(struct rte_eth_dev *dev, struct ice_tx_queue *txq)
 #define ICE_MIN_TSO_MSS            64
 #define ICE_MAX_TSO_MSS            9728
 #define ICE_MAX_TSO_FRAME_SIZE     262144
+
+/*Check for invalid mbuf*/
+static inline uint16_t
+ice_check_mbuf(struct rte_mbuf *tx_pkt)
+{
+	struct rte_mbuf *txd = tx_pkt;
+
+	while (txd != NULL) {
+		if (txd->data_len == 0)
+			return -1;
+		txd = txd->next;
+	}
+
+	return 0;
+}
+
 uint16_t
 ice_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts,
 	      uint16_t nb_pkts)
@@ -3653,6 +3669,7 @@ ice_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts,
 	struct ice_tx_queue *txq = tx_queue;
 	struct rte_eth_dev *dev = &rte_eth_devices[txq->port_id];
 	uint16_t max_frame_size = dev->data->mtu + ICE_ETH_OVERHEAD;
+	uint16_t nb_used;
 
 	for (i = 0; i < nb_pkts; i++) {
 		m = tx_pkts[i];
@@ -3689,6 +3706,13 @@ ice_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts,
 			rte_errno = -ret;
 			return i;
 		}
+
+		if (!(ol_flags & RTE_MBUF_F_TX_TCP_SEG) &&
+			ice_check_mbuf(m)) {
+			rte_errno = EINVAL;
+			PMD_DRV_LOG(ERR, "INVALID mbuf:	last mbuf data_len=[0]");
+			return i;
+		}
 	}
 	return i;
 }
Signature · 1 line
2.34.1
#8 lore raw

RE: [PATCH v3 2/2] net/ice: fix scalar Tx path segment

Quoted 33 lines

-----Original Message-----
From: Ye, MingjinX <[email protected]>
Sent: Friday, November 11, 2022 8:04 PM
To: [email protected]
Cc: Yang, Qiming <[email protected]>; [email protected]; Zhou, YidingX <[email protected]>; Ye, MingjinX <[email protected]>; Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Lu, Wenzhuo <[email protected]>; Ferruh Yigit <[email protected]>; Li, Xiaoyun <[email protected]>; Liu, KevinX <[email protected]>
Subject: [PATCH v3 2/2] net/ice: fix scalar Tx path segment

The scalar Tx path would send empty buffer that causes the Tx queue to overflow.

This patch adds the last buffer length judgment in tx_prepare to fix this issue, rte_errno will be set to EINVAL and returned if the last buffer is empty.

Fixes 17c7d0f9d6a4 ("net/ice: support basic Rx/Tx")
Fixes ccf33dccf7aa ("net/ice: check illegal packet sizes")
---
 drivers/net/ice/ice_rxtx.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
drivers/net/ice/ice_rxtx.c index renamed from drivers/net/ice/ice_rxtx.c +0 -0

e6ddd2513d..69358f6a3a 100644

drivers/net/ice/ice_rxtx.c ice_set_tx_function_flag(struct rte_eth_dev *dev, · line 3650

Quoted 8 lines
drivers/net/ice/ice_rxtx.c +4 -0
@@ -3643,6 +3643,22 @@ ice_set_tx_function_flag(struct rte_eth_dev *dev,
 struct ice_tx_queue *txq)
 #define ICE_MIN_TSO_MSS            64
 #define ICE_MAX_TSO_MSS            9728
 #define ICE_MAX_TSO_FRAME_SIZE     262144
+
+/*Check for invalid mbuf*/
+static inline uint16_t
+ice_check_mbuf(struct rte_mbuf *tx_pkt) {

Better to name the function to exactly match what it does. e.g.: ice_check_emtpy_mbuf
and also declare it as inline.

Quoted 24 lines
drivers/net/ice/ice_rxtx.c +12 -0
+	struct rte_mbuf *txd = tx_pkt;
+
+	while (txd != NULL) {
+		if (txd->data_len == 0)
+			return -1;
+		txd = txd->next;
+	}
+
+	return 0;
+}
+
 uint16_t
 ice_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts,
 	      uint16_t nb_pkts)
@@ -3653,6 +3669,7 @@ ice_prep_pkts(__rte_unused void *tx_queue,
 struct rte_mbuf **tx_pkts,
 	struct ice_tx_queue *txq = tx_queue;
 	struct rte_eth_dev *dev = &rte_eth_devices[txq->port_id];
 	uint16_t max_frame_size = dev->data->mtu + ICE_ETH_OVERHEAD;
+	uint16_t nb_used;
 
 	for (i = 0; i < nb_pkts; i++) {
drivers/net/ice/ice_rxtx.c +0 -0
 		m = tx_pkts[i];

drivers/net/ice/ice_rxtx.c ice_prep_pkts(__rte_unused void *tx_queue, · line 3712

Quoted 7 lines
drivers/net/ice/ice_rxtx.c +3 -0
@@ -3689,6 +3706,13 @@ ice_prep_pkts(__rte_unused void *tx_queue,
 struct rte_mbuf **tx_pkts,
 			rte_errno = -ret;
 			return i;
 		}
+
+		if (!(ol_flags & RTE_MBUF_F_TX_TCP_SEG) &&
+			ice_check_mbuf(m)) {

Why "!(ol_flags & RTE_MBUF_F_TX_TCP_SEG)" is needed here? A empty mbuf with TSO enabled is still acceptable?

Quoted 10 lines
drivers/net/ice/ice_rxtx.c +4 -0
+			rte_errno = EINVAL;
+			PMD_DRV_LOG(ERR, "INVALID mbuf:	last mbuf
 data_len=[0]");
+			return i;
+		}
 	}

return i;
}
--
2.34.1

#9 lore raw

RE: [PATCH v3 2/2] net/ice: fix scalar Tx path segment

Quoted 51 lines

-----Original Message-----
From: Zhang, Qi Z <[email protected]>
Sent: 2022年11月11日 13:09
To: Ye, MingjinX <[email protected]>; [email protected]
Cc: Yang, Qiming <[email protected]>; [email protected]; Zhou, YidingX <[email protected]>; Wu, Jingjing <[email protected]>; Lu, Wenzhuo <[email protected]>; Ferruh Yigit <[email protected]>; Li, Xiaoyun <[email protected]>; Liu, KevinX <[email protected]>
Subject: RE: [PATCH v3 2/2] net/ice: fix scalar Tx path segment

Quoted 12 lines

-----Original Message-----
From: Ye, MingjinX <[email protected]>
Sent: Friday, November 11, 2022 8:04 PM
To: [email protected]
Cc: Yang, Qiming <[email protected]>; [email protected]; Zhou, YidingX <[email protected]>; Ye, MingjinX <[email protected]>; Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Lu, Wenzhuo <[email protected]>; Ferruh Yigit <[email protected]>; Li, Xiaoyun <[email protected]>; Liu, KevinX <[email protected]>
Subject: [PATCH v3 2/2] net/ice: fix scalar Tx path segment

Quoted 5 lines

The scalar Tx path would send empty buffer that causes the Tx queue to overflow.

This patch adds the last buffer length judgment in tx_prepare to fix this issue, rte_errno will be set to EINVAL and returned if the last buffer is

empty.

Quoted 19 lines
Fixes 17c7d0f9d6a4 ("net/ice: support basic Rx/Tx")
Fixes ccf33dccf7aa ("net/ice: check illegal packet sizes")
---
 drivers/net/ice/ice_rxtx.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
drivers/net/ice/ice_rxtx.c +0 -0
index e6ddd2513d..69358f6a3a 100644
@@ -3643,6 +3643,22 @@ ice_set_tx_function_flag(struct rte_eth_dev
 *dev, struct ice_tx_queue *txq)
 #define ICE_MIN_TSO_MSS            64
 #define ICE_MAX_TSO_MSS            9728
 #define ICE_MAX_TSO_FRAME_SIZE     262144
Quoted 8 lines

drivers/net/ice/ice_rxtx.c ice_set_tx_function_flag(struct rte_eth_dev *dev, struct ice_tx_queue *txq)

Quoted 4 lines
drivers/net/ice/ice_rxtx.c +4 -0
+
+/*Check for invalid mbuf*/
+static inline uint16_t
+ice_check_mbuf(struct rte_mbuf *tx_pkt) {

Better to name the function to exactly match what it does. e.g.: ice_check_emtpy_mbuf
and also declare it as inline.

will optimize.

Quoted 22 lines
Quoted 22 lines
drivers/net/ice/ice_rxtx.c +12 -0
+	struct rte_mbuf *txd = tx_pkt;
+
+	while (txd != NULL) {
+		if (txd->data_len == 0)
+			return -1;
+		txd = txd->next;
+	}
+
+	return 0;
+}
+
 uint16_t
 ice_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts,
 	      uint16_t nb_pkts)
@@ -3653,6 +3669,7 @@ ice_prep_pkts(__rte_unused void *tx_queue,
 struct rte_mbuf **tx_pkts,
 	struct ice_tx_queue *txq = tx_queue;
 	struct rte_eth_dev *dev = &rte_eth_devices[txq->port_id];
 	uint16_t max_frame_size = dev->data->mtu + ICE_ETH_OVERHEAD;
+	uint16_t nb_used;
 
Quoted 13 lines

drivers/net/ice/ice_rxtx.c ice_prep_pkts(__rte_unused void *tx_queue, · line 3712

Quoted 10 lines
drivers/net/ice/ice_rxtx.c +0 -0
 	for (i = 0; i < nb_pkts; i++) {
drivers/net/ice/ice_rxtx.c +3 -0
 		m = tx_pkts[i];
@@ -3689,6 +3706,13 @@ ice_prep_pkts(__rte_unused void *tx_queue,
 struct rte_mbuf **tx_pkts,
 			rte_errno = -ret;
 			return i;
 		}
+
+		if (!(ol_flags & RTE_MBUF_F_TX_TCP_SEG) &&
+			ice_check_mbuf(m)) {

Why "!(ol_flags & RTE_MBUF_F_TX_TCP_SEG)" is needed here? A empty mbuf with TSO enabled is still acceptable?

Should not be expected to be implemented in test-pmd, should detect.

Quoted 11 lines
Quoted 11 lines
drivers/net/ice/ice_rxtx.c +4 -0
+			rte_errno = EINVAL;
+			PMD_DRV_LOG(ERR, "INVALID mbuf:	last mbuf
 data_len=[0]");
+			return i;
+		}
 	}

return i;
}
--
2.34.1

#10 lore raw

RE: [PATCH v3 2/2] net/ice: fix scalar Tx path segment

Quoted 109 lines

-----Original Message-----
From: Ye, MingjinX <[email protected]>
Sent: Friday, November 11, 2022 4:31 PM
To: Zhang, Qi Z <[email protected]>; [email protected]
Cc: Yang, Qiming <[email protected]>; [email protected]; Zhou, YidingX <[email protected]>; Wu, Jingjing <[email protected]>; Lu, Wenzhuo <[email protected]>; Ferruh Yigit <[email protected]>; Li, Xiaoyun <[email protected]>; Liu, KevinX <[email protected]>
Subject: RE: [PATCH v3 2/2] net/ice: fix scalar Tx path segment

Quoted 51 lines

-----Original Message-----
From: Zhang, Qi Z <[email protected]>
Sent: 2022年11月11日 13:09
To: Ye, MingjinX <[email protected]>; [email protected]
Cc: Yang, Qiming <[email protected]>; [email protected]; Zhou, YidingX <[email protected]>; Wu, Jingjing <[email protected]>; Lu, Wenzhuo <[email protected]>; Ferruh Yigit <[email protected]>; Li, Xiaoyun <[email protected]>; Liu, KevinX <[email protected]>
Subject: RE: [PATCH v3 2/2] net/ice: fix scalar Tx path segment

Quoted 12 lines

-----Original Message-----
From: Ye, MingjinX <[email protected]>
Sent: Friday, November 11, 2022 8:04 PM
To: [email protected]
Cc: Yang, Qiming <[email protected]>; [email protected]; Zhou, YidingX <[email protected]>; Ye, MingjinX <[email protected]>; Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Lu, Wenzhuo <[email protected]>; Ferruh Yigit <[email protected]>; Li, Xiaoyun <[email protected]>; Liu, KevinX <[email protected]>
Subject: [PATCH v3 2/2] net/ice: fix scalar Tx path segment

Quoted 6 lines

The scalar Tx path would send empty buffer that causes the Tx queue to overflow.

This patch adds the last buffer length judgment in tx_prepare to fix this issue, rte_errno will be set to EINVAL and returned if the last buffer is

empty.

Quoted 19 lines
Fixes 17c7d0f9d6a4 ("net/ice: support basic Rx/Tx")
Fixes ccf33dccf7aa ("net/ice: check illegal packet sizes")
---
 drivers/net/ice/ice_rxtx.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
drivers/net/ice/ice_rxtx.c +0 -0
index e6ddd2513d..69358f6a3a 100644
@@ -3643,6 +3643,22 @@ ice_set_tx_function_flag(struct rte_eth_dev
 *dev, struct ice_tx_queue *txq)
 #define ICE_MIN_TSO_MSS            64
 #define ICE_MAX_TSO_MSS            9728
 #define ICE_MAX_TSO_FRAME_SIZE     262144
Quoted 8 lines

drivers/net/ice/ice_rxtx.c ice_set_tx_function_flag(struct rte_eth_dev *dev, struct ice_tx_queue *txq)

Quoted 4 lines
drivers/net/ice/ice_rxtx.c +4 -0
+
+/*Check for invalid mbuf*/
+static inline uint16_t
+ice_check_mbuf(struct rte_mbuf *tx_pkt) {

Better to name the function to exactly match what it does. e.g.: ice_check_emtpy_mbuf
and also declare it as inline.

will optimize.

Quoted 22 lines
Quoted 22 lines
drivers/net/ice/ice_rxtx.c +12 -0
+	struct rte_mbuf *txd = tx_pkt;
+
+	while (txd != NULL) {
+		if (txd->data_len == 0)
+			return -1;
+		txd = txd->next;
+	}
+
+	return 0;
+}
+
 uint16_t
 ice_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts,
 	      uint16_t nb_pkts)
@@ -3653,6 +3669,7 @@ ice_prep_pkts(__rte_unused void *tx_queue,
 struct rte_mbuf **tx_pkts,
 	struct ice_tx_queue *txq = tx_queue;
 	struct rte_eth_dev *dev = &rte_eth_devices[txq->port_id];
 	uint16_t max_frame_size = dev->data->mtu + ICE_ETH_OVERHEAD;
+	uint16_t nb_used;
 
Quoted 13 lines

drivers/net/ice/ice_rxtx.c ice_prep_pkts(__rte_unused void *tx_queue, · line 3712

Quoted 10 lines
drivers/net/ice/ice_rxtx.c +0 -0
 	for (i = 0; i < nb_pkts; i++) {
drivers/net/ice/ice_rxtx.c +3 -0
 		m = tx_pkts[i];
@@ -3689,6 +3706,13 @@ ice_prep_pkts(__rte_unused void *tx_queue,
 struct rte_mbuf **tx_pkts,
 			rte_errno = -ret;
 			return i;
 		}
+
+		if (!(ol_flags & RTE_MBUF_F_TX_TCP_SEG) &&
+			ice_check_mbuf(m)) {

Why "!(ol_flags & RTE_MBUF_F_TX_TCP_SEG)" is needed here? A empty mbuf with TSO enabled is still acceptable?

Quoted 1 line

Should not be expected to be implemented in test-pmd, should detect.

Why related with testpmd?, testpmd is not the only application, this is the question for how to identify a violated mbuf.

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
drivers/net/ice/ice_rxtx.c +4 -0
+			rte_errno = EINVAL;
+			PMD_DRV_LOG(ERR, "INVALID mbuf:	last mbuf
 data_len=[0]");
+			return i;
+		}
 	}

return i;
}
--
2.34.1

author
#11 lore raw

PATCH v4 1/2 net/ice: fix scalar Rx path segment

In reply to Mingjin Ye

CRC is stripped by the hardware in the scattered Rx path. The last buffer is invalid if it's packet length is zero.

This patch adds a judgment for the last buffer length to fix this issue, it would free the mbuf associated to the last one if the last buffer is empty.

Fixes 6eac0b7fde95 ("net/ice: support advance Rx/Tx")
---
 drivers/net/ice/ice_rxtx.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/net/ice/ice_rxtx.c +4 -0
index 0a2b0376ac..e6ddd2513d 100644
@@ -2111,6 +2111,10 @@ ice_recv_scattered_pkts(void *rx_queue,
 			} else
 				rxm->data_len = (uint16_t)(rx_packet_len -
 							   RTE_ETHER_CRC_LEN);
+		} else if (rx_packet_len == 0) {
+			rte_pktmbuf_free_seg(rxm);
+			first_seg->nb_segs--;
+			last_seg->next = NULL;
 		}
 
 		first_seg->port = rxq->port_id;
Signature · 1 line
2.34.1
author
#12 lore raw

PATCH v4 2/2 net/ice: fix scalar Tx path segment

The scalar Tx path would send empty buffer that causes the Tx queue to overflow.

This patch adds the last buffer length judgment in tx_prepare to fix this issue, rte_errno will be set to EINVAL and returned if the last buffer is empty.

Fixes 17c7d0f9d6a4 ("net/ice: support basic Rx/Tx")
Fixes ccf33dccf7aa ("net/ice: check illegal packet sizes")

v3:
* delete unused variable.

---
 drivers/net/ice/ice_rxtx.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
drivers/net/ice/ice_rxtx.c +22 -0
index e6ddd2513d..c1cde65a39 100644
@@ -3643,6 +3643,22 @@ ice_set_tx_function_flag(struct rte_eth_dev *dev, struct ice_tx_queue *txq)
 #define ICE_MIN_TSO_MSS            64
 #define ICE_MAX_TSO_MSS            9728
 #define ICE_MAX_TSO_FRAME_SIZE     262144
+
+/*Check for emtpy mbuf*/
+static inline uint16_t
+ice_check_emtpy_mbuf(struct rte_mbuf *tx_pkt)
+{
+	struct rte_mbuf *txd = tx_pkt;
+
+	while (txd != NULL) {
+		if (txd->data_len == 0)
+			return -1;
+		txd = txd->next;
+	}
+
+	return 0;
+}
+
 uint16_t
 ice_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts,
 	      uint16_t nb_pkts)
@@ -3689,6 +3705,12 @@ ice_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts,
 			rte_errno = -ret;
 			return i;
 		}
+
+		if (ice_check_emtpy_mbuf(m) != 0) {
+			rte_errno = EINVAL;
+			PMD_DRV_LOG(ERR, "INVALID mbuf:	last mbuf data_len=[0]");
+			return i;
+		}
 	}
 	return i;
 }
Signature · 1 line
2.34.1
author
#13 lore raw

PATCH v4 1/2 net/ice: fix scalar Rx path segment

In reply to Mingjin Ye

CRC is stripped by the hardware in the scattered Rx path. The last buffer is invalid if it's packet length is zero.

This patch adds a judgment for the last buffer length to fix this issue, it would free the mbuf associated to the last one if the last buffer is empty.

Fixes 6eac0b7fde95 ("net/ice: support advance Rx/Tx")
---
 drivers/net/ice/ice_rxtx.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/net/ice/ice_rxtx.c +4 -0
index 0a2b0376ac..e6ddd2513d 100644
@@ -2111,6 +2111,10 @@ ice_recv_scattered_pkts(void *rx_queue,
 			} else
 				rxm->data_len = (uint16_t)(rx_packet_len -
 							   RTE_ETHER_CRC_LEN);
+		} else if (rx_packet_len == 0) {
+			rte_pktmbuf_free_seg(rxm);
+			first_seg->nb_segs--;
+			last_seg->next = NULL;
 		}
 
 		first_seg->port = rxq->port_id;
Signature · 1 line
2.34.1
author
#14 lore raw

PATCH v4 2/2 net/ice: fix scalar Tx path segment

The scalar Tx path would send empty buffer that causes the Tx queue to overflow.

This patch adds the last buffer length judgment in tx_prepare to fix this issue, rte_errno will be set to EINVAL and returned if the last buffer is empty.

Fixes 17c7d0f9d6a4 ("net/ice: support basic Rx/Tx")
Fixes ccf33dccf7aa ("net/ice: check illegal packet sizes")

v3:
* delete unused variable.
* Full detection of mbufs.

---
 drivers/net/ice/ice_rxtx.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
drivers/net/ice/ice_rxtx.c +22 -0
index e6ddd2513d..9017353943 100644
@@ -3643,6 +3643,22 @@ ice_set_tx_function_flag(struct rte_eth_dev *dev, struct ice_tx_queue *txq)
 #define ICE_MIN_TSO_MSS            64
 #define ICE_MAX_TSO_MSS            9728
 #define ICE_MAX_TSO_FRAME_SIZE     262144
+
+/*Check for empty mbuf*/
+static inline uint16_t
+ice_check_empty_mbuf(struct rte_mbuf *tx_pkt)
+{
+	struct rte_mbuf *txd = tx_pkt;
+
+	while (txd != NULL) {
+		if (txd->data_len == 0)
+			return -1;
+		txd = txd->next;
+	}
+
+	return 0;
+}
+
 uint16_t
 ice_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts,
 	      uint16_t nb_pkts)
@@ -3689,6 +3705,12 @@ ice_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts,
 			rte_errno = -ret;
 			return i;
 		}
+
+		if (ice_check_empty_mbuf(m) != 0) {
+			rte_errno = EINVAL;
+			PMD_DRV_LOG(ERR, "INVALID mbuf:	last mbuf data_len=[0]");
+			return i;
+		}
 	}
 	return i;
 }
Signature · 1 line
2.34.1
Acked-by on v4 2/2 Applied
#15 lore raw

RE: [PATCH v4 2/2] net/ice: fix scalar Tx path segment

Quoted 16 lines

-----Original Message-----
From: Ye, MingjinX <[email protected]>
Sent: Saturday, November 12, 2022 12:13 AM
To: [email protected]
Cc: Yang, Qiming <[email protected]>; [email protected]; Zhou, YidingX <[email protected]>; Ye, MingjinX <[email protected]>; Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Ferruh Yigit <[email protected]>; Lu, Wenzhuo <[email protected]>; Liu, KevinX <[email protected]>
Subject: [PATCH v4 2/2] net/ice: fix scalar Tx path segment

The scalar Tx path would send empty buffer that causes the Tx queue to overflow.

Quoted 8 lines

This patch adds the last buffer length judgment in tx_prepare to fix this issue, rte_errno will be set to EINVAL and returned if the last buffer is empty.

Fixes 17c7d0f9d6a4 ("net/ice: support basic Rx/Tx")
Fixes ccf33dccf7aa ("net/ice: check illegal packet sizes")

Applied to dpdk-next-net-intel.

Thanks
Qi

Tested-by
#16 lore raw

RE: [PATCH v4 2/2] net/ice: fix scalar Tx path segment

Quoted 37 lines

-----Original Message-----
From: Zhang, Qi Z <[email protected]>
Sent: Friday, November 11, 2022 5:02 PM
To: Ye, MingjinX <[email protected]>; [email protected]
Cc: Yang, Qiming <[email protected]>; [email protected]; Zhou, YidingX <[email protected]>; Wu, Jingjing <[email protected]>; Ferruh Yigit <[email protected]>; Lu, Wenzhuo <[email protected]>; Liu, KevinX <[email protected]>
Subject: RE: [PATCH v4 2/2] net/ice: fix scalar Tx path segment

Quoted 12 lines

-----Original Message-----
From: Ye, MingjinX <[email protected]>
Sent: Saturday, November 12, 2022 12:13 AM
To: [email protected]
Cc: Yang, Qiming <[email protected]>; [email protected]; Zhou, YidingX <[email protected]>; Ye, MingjinX <[email protected]>; Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Ferruh Yigit <[email protected]>; Lu, Wenzhuo <[email protected]>; Liu, KevinX <[email protected]>
Subject: [PATCH v4 2/2] net/ice: fix scalar Tx path segment

Quoted 5 lines

The scalar Tx path would send empty buffer that causes the Tx queue to overflow.

This patch adds the last buffer length judgment in tx_prepare to fix this issue, rte_errno will be set to EINVAL and returned if the last buffer is

empty.

Quoted 5 lines
Fixes 17c7d0f9d6a4 ("net/ice: support basic Rx/Tx")
Fixes ccf33dccf7aa ("net/ice: check illegal packet sizes")
Quoted 8 lines
Quoted 1 line

Applied to dpdk-next-net-intel.

Thanks
Qi

Tested and passed.

#17 lore raw

Re: [PATCH v4 2/2] net/ice: fix scalar Tx path segment

In reply to Mingjin Ye

Hello,

Replying on this old thread, as it seems no in depth review was done but I need more info before fixing a bug added by ccf33dccf7aa ("net/ice: check illegal packet sizes").

Quoted 3 lines · Mingjin Ye

The scalar Tx path would send empty buffer that causes the Tx queue to overflow.

This is too vague.
Please describe the exact issue.
Is it a sw (read net/ice driver) bug? a hw bug?

Quoted 2 lines

This patch adds the last buffer length judgment in tx_prepare to fix this

This reads odd.

The added code will stop and return an error when the last segment *that is evaluated by the code* is empty.
But on the other hand, it is easier to understand that the check is to catch the *first* empty segment of a packet.

Quoted 21 lines

issue, rte_errno will be set to EINVAL and returned if the last buffer is empty.

Fixes 17c7d0f9d6a4 ("net/ice: support basic Rx/Tx")
Fixes ccf33dccf7aa ("net/ice: check illegal packet sizes")

v3:
* delete unused variable.
* Full detection of mbufs.

---
 drivers/net/ice/ice_rxtx.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
drivers/net/ice/ice_rxtx.c +0 -0
index e6ddd2513d..9017353943 100644

drivers/net/ice/ice_rxtx.c ice_set_tx_function_flag(struct rte_eth_dev *dev, struct ice_tx_queue *txq) · line 3647

Quoted 5 lines
drivers/net/ice/ice_rxtx.c +2 -0
@@ -3643,6 +3643,22 @@ ice_set_tx_function_flag(struct rte_eth_dev *dev, struct ice_tx_queue *txq)
 #define ICE_MIN_TSO_MSS            64
 #define ICE_MAX_TSO_MSS            9728
 #define ICE_MAX_TSO_FRAME_SIZE     262144
+
+/*Check for empty mbuf*/

Missing spaces.

drivers/net/ice/ice_rxtx.c ice_set_tx_function_flag(struct rte_eth_dev *dev, struct ice_tx_queue *txq) · line 3649

Quoted 2 lines
drivers/net/ice/ice_rxtx.c +2 -0
+static inline uint16_t
+ice_check_empty_mbuf(struct rte_mbuf *tx_pkt)

This function name is confusing.

In dpdk, a mbuf can be both a segment descriptor (part of a packet) or a packet descriptor (in which case, it overlaps the first segment descriptor).
So it is better to be explicit with "segment" or "packet" when referring to a mbuf.

drivers/net/ice/ice_rxtx.c ice_set_tx_function_flag(struct rte_eth_dev *dev, struct ice_tx_queue *txq) · line 3657

Quoted 8 lines
drivers/net/ice/ice_rxtx.c +8 -0
+{
+       struct rte_mbuf *txd = tx_pkt;
+
+       while (txd != NULL) {
+               if (txd->data_len == 0)
+                       return -1;
+               txd = txd->next;
+       }

There is nothing in the API that says that an empty segment is faulty.

With the current description, I understand that any empty segment could lead to a bug, regardless of asking offloads (which ice_prep_pkts is all about).
So a more valid fix is probably to skip empty segments in the tx handler function(s) and not reject packets in ice_prep_pkts. Another option could be to fix this "overflow" mentionned in the commitlog.

Looking fwd to explanations.

Quoted 7 lines
drivers/net/ice/ice_rxtx.c +4 -0
+
+       return 0;
+}
+
 uint16_t
 ice_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts,
              uint16_t nb_pkts)
Signature · 1 line
David Marchand
#18 lore raw

Re: [PATCH v4 2/2] net/ice: fix scalar Tx path segment

Quoted 79 lines · David Marchand

Replying on this old thread, as it seems no in depth review was done but I need more info before fixing a bug added by ccf33dccf7aa ("net/ice: check illegal packet sizes").

Quoted 3 lines · Mingjin Ye

The scalar Tx path would send empty buffer that causes the Tx queue to overflow.

This is too vague.
Please describe the exact issue.
Is it a sw (read net/ice driver) bug? a hw bug?

Quoted 2 lines

This patch adds the last buffer length judgment in tx_prepare to fix this

This reads odd.

The added code will stop and return an error when the last segment *that is evaluated by the code* is empty.
But on the other hand, it is easier to understand that the check is to catch the *first* empty segment of a packet.

Quoted 21 lines

issue, rte_errno will be set to EINVAL and returned if the last buffer is empty.

Fixes 17c7d0f9d6a4 ("net/ice: support basic Rx/Tx")
Fixes ccf33dccf7aa ("net/ice: check illegal packet sizes")

v3:
* delete unused variable.
* Full detection of mbufs.

---
 drivers/net/ice/ice_rxtx.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
drivers/net/ice/ice_rxtx.c +0 -0
index e6ddd2513d..9017353943 100644

drivers/net/ice/ice_rxtx.c ice_set_tx_function_flag(struct rte_eth_dev *dev, struct ice_tx_queue *txq) · line 3647

Quoted 5 lines
drivers/net/ice/ice_rxtx.c +2 -0
@@ -3643,6 +3643,22 @@ ice_set_tx_function_flag(struct rte_eth_dev *dev, struct ice_tx_queue *txq)
 #define ICE_MIN_TSO_MSS            64
 #define ICE_MAX_TSO_MSS            9728
 #define ICE_MAX_TSO_FRAME_SIZE     262144
+
+/*Check for empty mbuf*/

Missing spaces.

drivers/net/ice/ice_rxtx.c ice_set_tx_function_flag(struct rte_eth_dev *dev, struct ice_tx_queue *txq) · line 3649

Quoted 2 lines
drivers/net/ice/ice_rxtx.c +2 -0
+static inline uint16_t
+ice_check_empty_mbuf(struct rte_mbuf *tx_pkt)

This function name is confusing.

In dpdk, a mbuf can be both a segment descriptor (part of a packet) or a packet descriptor (in which case, it overlaps the first segment descriptor).
So it is better to be explicit with "segment" or "packet" when referring to a mbuf.

drivers/net/ice/ice_rxtx.c ice_set_tx_function_flag(struct rte_eth_dev *dev, struct ice_tx_queue *txq) · line 3657

Quoted 8 lines
drivers/net/ice/ice_rxtx.c +8 -0
+{
+       struct rte_mbuf *txd = tx_pkt;
+
+       while (txd != NULL) {
+               if (txd->data_len == 0)
+                       return -1;
+               txd = txd->next;
+       }

There is nothing in the API that says that an empty segment is faulty.

Quoted 8 lines

With the current description, I understand that any empty segment could lead to a bug, regardless of asking offloads (which ice_prep_pkts is all about).
So a more valid fix is probably to skip empty segments in the tx handler function(s) and not reject packets in ice_prep_pkts. Another option could be to fix this "overflow" mentionned in the commitlog.

Looking fwd to explanations.

Ping.

Signature · 1 line
David Marchand
#19 lore raw

RE: [PATCH v4 1/2] net/ice: fix scalar Rx path segment

In reply to Mingjin Ye
Quoted 16 lines

-----Original Message-----
From: Ye, MingjinX <[email protected]>
Sent: Saturday, November 12, 2022 12:13 AM
To: [email protected]
Cc: Yang, Qiming <[email protected]>; [email protected]; Zhou, YidingX <[email protected]>; Ye, MingjinX <[email protected]>; Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Ferruh Yigit <[email protected]>; Lu, Wenzhuo <[email protected]>; Li, Xiaoyun <[email protected]>
Subject: [PATCH v4 1/2] net/ice: fix scalar Rx path segment

CRC is stripped by the hardware in the scattered Rx path. The last buffer is invalid if it's packet length is zero.

Quoted 7 lines

This patch adds a judgment for the last buffer length to fix this issue, it would free the mbuf associated to the last one if the last buffer is empty.

Fixes 6eac0b7fde95 ("net/ice: support advance Rx/Tx")

v3 already be applied, no new change on v4, will ignore this patch.

Tested-by
#20 lore raw

RE: [PATCH v4 1/2] net/ice: fix scalar Rx path segment

Quoted 31 lines

-----Original Message-----
From: Zhang, Qi Z <[email protected]>
Sent: Friday, November 11, 2022 5:03 PM
To: Ye, MingjinX <[email protected]>; [email protected]
Cc: Yang, Qiming <[email protected]>; [email protected]; Zhou, YidingX <[email protected]>; Wu, Jingjing <[email protected]>; Ferruh Yigit <[email protected]>; Lu, Wenzhuo <[email protected]>; Li, Xiaoyun <[email protected]>
Subject: RE: [PATCH v4 1/2] net/ice: fix scalar Rx path segment

Quoted 12 lines

-----Original Message-----
From: Ye, MingjinX <[email protected]>
Sent: Saturday, November 12, 2022 12:13 AM
To: [email protected]
Cc: Yang, Qiming <[email protected]>; [email protected]; Zhou, YidingX <[email protected]>; Ye, MingjinX <[email protected]>; Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Ferruh Yigit <[email protected]>; Lu, Wenzhuo <[email protected]>; Li, Xiaoyun <[email protected]>
Subject: [PATCH v4 1/2] net/ice: fix scalar Rx path segment

Quoted 5 lines

CRC is stripped by the hardware in the scattered Rx path. The last buffer is invalid if it's packet length is zero.

This patch adds a judgment for the last buffer length to fix this issue, it would free the mbuf associated to the last one if the last buffer is

Quoted 8 lines

empty.

Quoted 5 lines
Fixes 6eac0b7fde95 ("net/ice: support advance Rx/Tx")

v3 already be applied, no new change on v4, will ignore this patch.

Tested with v4 patch, passed.

Acked-by on v3 1/2 Applied
#21 lore raw

RE: [PATCH v3 1/2] net/ice: fix scalar Rx path segment

In reply to Mingjin Ye
Quoted 16 lines

-----Original Message-----
From: Ye, MingjinX <[email protected]>
Sent: Friday, November 11, 2022 8:04 PM
To: [email protected]
Cc: Yang, Qiming <[email protected]>; [email protected]; Zhou, YidingX <[email protected]>; Ye, MingjinX <[email protected]>; Zhang, Qi Z <[email protected]>; Ferruh Yigit <[email protected]>; Wu, Jingjing <[email protected]>; Lu, Wenzhuo <[email protected]>; Li, Xiaoyun <[email protected]>
Subject: [PATCH v3 1/2] net/ice: fix scalar Rx path segment

CRC is stripped by the hardware in the scattered Rx path. The last buffer is invalid if it's packet length is zero.

Quoted 7 lines

This patch adds a judgment for the last buffer length to fix this issue, it would free the mbuf associated to the last one if the last buffer is empty.

Fixes 6eac0b7fde95 ("net/ice: support advance Rx/Tx")

Applied to dpdk-next-net-intel.

Thanks
Qi