Skip to contentSkip to conversation

net/i40e: fix Tx fn selection when using new ethdev offloads

PATCH Superseded Bruce Richardson 4 participants 12 messages May 1, 2018 – May 2, 2018 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/i40e: fix Tx fn selection when using new ethdev offloads

The Tx function selection code in the driver only used the older txq flags values to check whether the scalar or vector functions should be used. This caused performance regressions with testpmd io-fwd as the scalar path rather than the vector one was being used in the default case. Fix this by changing the code to take account of new offloads and deleting the defines used for the old ones.

Fixes 7497d3e2f777 ("net/i40e: convert to new Tx offloads API")
---
 drivers/net/i40e/i40e_rxtx.c | 45 +++++++++++++++++++++++---------------------
 1 file changed, 24 insertions(+), 21 deletions(-)
drivers/net/i40e/i40e_rxtx.c +24 -21
index ec1ce54ca..c523af575 100644
@@ -40,9 +40,6 @@
 /* Base address of the HW descriptor ring should be 128B aligned. */
 #define I40E_RING_BASE_ALIGN	128
 
-#define I40E_SIMPLE_FLAGS ((uint32_t)ETH_TXQ_FLAGS_NOMULTSEGS | \
-					ETH_TXQ_FLAGS_NOOFFLOADS)
-
 #define I40E_TXD_CMD (I40E_TX_DESC_CMD_EOP | I40E_TX_DESC_CMD_RS)
 
 #ifdef RTE_LIBRTE_IEEE1588
@@ -70,6 +67,12 @@
 #define I40E_TX_OFFLOAD_NOTSUP_MASK \
 		(PKT_TX_OFFLOAD_MASK ^ I40E_TX_OFFLOAD_MASK)
 
+static const uint64_t i40e_simple_ol_mask = (DEV_TX_OFFLOAD_MULTI_SEGS |
+		DEV_TX_OFFLOAD_VLAN_INSERT |
+		DEV_TX_OFFLOAD_SCTP_CKSUM |
+		DEV_TX_OFFLOAD_UDP_CKSUM |
+		DEV_TX_OFFLOAD_TCP_CKSUM);
+
 static inline void
 i40e_rxd_to_vlan_tci(struct rte_mbuf *mb, volatile union i40e_rx_desc *rxdp)
 {
@@ -2108,11 +2111,9 @@ i40e_dev_tx_queue_setup_runtime(struct rte_eth_dev *dev,
 				 dev->data->nb_tx_queues)) {
 		/**
 		 * If it is the first queue to setup,
-		 * set all flags to default and call
+		 * set all flags and call
 		 * i40e_set_tx_function.
 		 */
-		ad->tx_simple_allowed = true;
-		ad->tx_vec_allowed = true;
 		i40e_set_tx_function_flag(dev, txq);
 		i40e_set_tx_function(dev);
 		return 0;
@@ -2128,9 +2129,8 @@ i40e_dev_tx_queue_setup_runtime(struct rte_eth_dev *dev,
 	}
 	/* check simple tx conflict */
 	if (ad->tx_simple_allowed) {
-		if (((txq->txq_flags & I40E_SIMPLE_FLAGS) !=
-		     I40E_SIMPLE_FLAGS) ||
-		    txq->tx_rs_thresh < RTE_PMD_I40E_TX_MAX_BURST) {
+		if ((txq->offloads & i40e_simple_ol_mask) != 0 ||
+				txq->tx_rs_thresh < RTE_PMD_I40E_TX_MAX_BURST) {
 			PMD_DRV_LOG(ERR, "No-simple tx is required.");
 			return -EINVAL;
 		}
@@ -3080,18 +3080,21 @@ i40e_set_tx_function_flag(struct rte_eth_dev *dev, struct i40e_tx_queue *txq)
 		I40E_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
 
 	/* Use a simple Tx queue (no offloads, no multi segs) if possible */
-	if (((txq->txq_flags & I40E_SIMPLE_FLAGS) == I40E_SIMPLE_FLAGS)
-			&& (txq->tx_rs_thresh >= RTE_PMD_I40E_TX_MAX_BURST)) {
-		if (txq->tx_rs_thresh <= RTE_I40E_TX_MAX_FREE_BUF_SZ) {
-			PMD_INIT_LOG(DEBUG, "Vector tx"
-				     " can be enabled on this txq.");
-
-		} else {
-			ad->tx_vec_allowed = false;
-		}
-	} else {
-		ad->tx_simple_allowed = false;
-	}
+	ad->tx_simple_allowed = ((txq->offloads & i40e_simple_ol_mask) == 0 &&
+			txq->tx_rs_thresh >= RTE_PMD_I40E_TX_MAX_BURST);
+	ad->tx_vec_allowed = (ad->tx_simple_allowed &&
+			txq->tx_rs_thresh <= RTE_I40E_TX_MAX_FREE_BUF_SZ);
+
+	if (ad->tx_vec_allowed)
+		PMD_INIT_LOG(DEBUG, "Vector Tx can be enabled on Tx queue %u.",
+				txq->queue_id);
+	else if (ad->tx_simple_allowed)
+		PMD_INIT_LOG(DEBUG, "Simple Tx can be enabled on Tx queue %u.",
+				txq->queue_id);
+	else
+		PMD_INIT_LOG(DEBUG,
+				"Neither simple nor vector Tx enabled on Tx queue %u\n",
+				txq->queue_id);
 }
 
 void __attribute__((cold))
Signature · 1 line
2.14.3
#1 lore raw

Hi Bruce,

Quoted 30 lines

The Tx function selection code in the driver only used the older txq flags values to check whether the scalar or vector functions should be used. This caused performance regressions with testpmd io-fwd as the scalar path rather than the vector one was being used in the default case. Fix this by changing the code to take account of new offloads and deleting the defines used for the old ones.

Fixes 7497d3e2f777 ("net/i40e: convert to new Tx offloads API")
---
 drivers/net/i40e/i40e_rxtx.c | 45 +++++++++++++++++++++++---------------------
 1 file changed, 24 insertions(+), 21 deletions(-)
drivers/net/i40e/i40e_rxtx.c +0 -3
index ec1ce54ca..c523af575 100644
@@ -40,9 +40,6 @@
 /* Base address of the HW descriptor ring should be 128B aligned. */
 #define I40E_RING_BASE_ALIGN	128
 
-#define I40E_SIMPLE_FLAGS ((uint32_t)ETH_TXQ_FLAGS_NOMULTSEGS | \
-					ETH_TXQ_FLAGS_NOOFFLOADS)
-
 #define I40E_TXD_CMD (I40E_TX_DESC_CMD_EOP | I40E_TX_DESC_CMD_RS)
 
 #ifdef RTE_LIBRTE_IEEE1588

drivers/net/i40e/i40e_rxtx.c line 75

Quoted 9 lines
drivers/net/i40e/i40e_rxtx.c +6 -0
@@ -70,6 +67,12 @@
 #define I40E_TX_OFFLOAD_NOTSUP_MASK \
 		(PKT_TX_OFFLOAD_MASK ^ I40E_TX_OFFLOAD_MASK)
 
+static const uint64_t i40e_simple_ol_mask = (DEV_TX_OFFLOAD_MULTI_SEGS |
+		DEV_TX_OFFLOAD_VLAN_INSERT |
+		DEV_TX_OFFLOAD_SCTP_CKSUM |
+		DEV_TX_OFFLOAD_UDP_CKSUM |
+		DEV_TX_OFFLOAD_TCP_CKSUM);
+

Seems incomplete.

Quoted 1 line

From i40e_ethdev.c full-featured tx supports:

dev_info->tx_offload_capa =

                DEV_TX_OFFLOAD_VLAN_INSERT |
                DEV_TX_OFFLOAD_QINQ_INSERT |
                DEV_TX_OFFLOAD_IPV4_CKSUM |
                DEV_TX_OFFLOAD_UDP_CKSUM |
                DEV_TX_OFFLOAD_TCP_CKSUM |
                DEV_TX_OFFLOAD_SCTP_CKSUM |
                DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM |
                DEV_TX_OFFLOAD_TCP_TSO |
                DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
                DEV_TX_OFFLOAD_GRE_TNL_TSO |
                DEV_TX_OFFLOAD_IPIP_TNL_TSO |
                DEV_TX_OFFLOAD_GENEVE_TNL_TSO;

So we probably need the same here plus multiseg.
BTW, it is really strange that we don't have multiseg in tx_offload_capa. Should be present I think.
Might be worse to create a new define for it, or just use dev_info->tx_offload_capa directly. Konstantin

Quoted 64 lines

static inline void
i40e_rxd_to_vlan_tci(struct rte_mbuf *mb, volatile union i40e_rx_desc *rxdp) {

drivers/net/i40e/i40e_rxtx.c +18 -19
@@ -2108,11 +2111,9 @@ i40e_dev_tx_queue_setup_runtime(struct rte_eth_dev *dev,
 				 dev->data->nb_tx_queues)) {
 		/**
 		 * If it is the first queue to setup,
-		 * set all flags to default and call
+		 * set all flags and call
 		 * i40e_set_tx_function.
 		 */
-		ad->tx_simple_allowed = true;
-		ad->tx_vec_allowed = true;
 		i40e_set_tx_function_flag(dev, txq);
 		i40e_set_tx_function(dev);
 		return 0;
@@ -2128,9 +2129,8 @@ i40e_dev_tx_queue_setup_runtime(struct rte_eth_dev *dev,
 	}
 	/* check simple tx conflict */
 	if (ad->tx_simple_allowed) {
-		if (((txq->txq_flags & I40E_SIMPLE_FLAGS) !=
-		     I40E_SIMPLE_FLAGS) ||
-		    txq->tx_rs_thresh < RTE_PMD_I40E_TX_MAX_BURST) {
+		if ((txq->offloads & i40e_simple_ol_mask) != 0 ||
+				txq->tx_rs_thresh < RTE_PMD_I40E_TX_MAX_BURST) {
 			PMD_DRV_LOG(ERR, "No-simple tx is required.");
 			return -EINVAL;
 		}
@@ -3080,18 +3080,21 @@ i40e_set_tx_function_flag(struct rte_eth_dev *dev, struct i40e_tx_queue *txq)
 		I40E_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
 
 	/* Use a simple Tx queue (no offloads, no multi segs) if possible */
-	if (((txq->txq_flags & I40E_SIMPLE_FLAGS) == I40E_SIMPLE_FLAGS)
-			&& (txq->tx_rs_thresh >= RTE_PMD_I40E_TX_MAX_BURST)) {
-		if (txq->tx_rs_thresh <= RTE_I40E_TX_MAX_FREE_BUF_SZ) {
-			PMD_INIT_LOG(DEBUG, "Vector tx"
-				     " can be enabled on this txq.");
-
-		} else {
-			ad->tx_vec_allowed = false;
-		}
-	} else {
-		ad->tx_simple_allowed = false;
-	}
+	ad->tx_simple_allowed = ((txq->offloads & i40e_simple_ol_mask) == 0 &&
+			txq->tx_rs_thresh >= RTE_PMD_I40E_TX_MAX_BURST);
+	ad->tx_vec_allowed = (ad->tx_simple_allowed &&
+			txq->tx_rs_thresh <= RTE_I40E_TX_MAX_FREE_BUF_SZ);
+
+	if (ad->tx_vec_allowed)
+		PMD_INIT_LOG(DEBUG, "Vector Tx can be enabled on Tx queue %u.",
+				txq->queue_id);
+	else if (ad->tx_simple_allowed)
+		PMD_INIT_LOG(DEBUG, "Simple Tx can be enabled on Tx queue %u.",
+				txq->queue_id);
+	else
+		PMD_INIT_LOG(DEBUG,
+				"Neither simple nor vector Tx enabled on Tx queue %u\n",
+				txq->queue_id);
 }
 
 void __attribute__((cold))
--

2.14.3

#2 lore raw
Quoted 58 lines · Konstantin

Hi Bruce,

Quoted 30 lines

The Tx function selection code in the driver only used the older txq flags values to check whether the scalar or vector functions should be used. This caused performance regressions with testpmd io-fwd as the scalar path rather than the vector one was being used in the default case. Fix this by changing the code to take account of new offloads and deleting the defines used for the old ones.

Fixes 7497d3e2f777 ("net/i40e: convert to new Tx offloads API")
---
 drivers/net/i40e/i40e_rxtx.c | 45 +++++++++++++++++++++++---------------------
 1 file changed, 24 insertions(+), 21 deletions(-)
drivers/net/i40e/i40e_rxtx.c +0 -3
index ec1ce54ca..c523af575 100644
@@ -40,9 +40,6 @@
 /* Base address of the HW descriptor ring should be 128B aligned. */
 #define I40E_RING_BASE_ALIGN	128
 
-#define I40E_SIMPLE_FLAGS ((uint32_t)ETH_TXQ_FLAGS_NOMULTSEGS | \
-					ETH_TXQ_FLAGS_NOOFFLOADS)
-
 #define I40E_TXD_CMD (I40E_TX_DESC_CMD_EOP | I40E_TX_DESC_CMD_RS)
 
 #ifdef RTE_LIBRTE_IEEE1588

drivers/net/i40e/i40e_rxtx.c line 75

Quoted 9 lines
drivers/net/i40e/i40e_rxtx.c +6 -0
@@ -70,6 +67,12 @@
 #define I40E_TX_OFFLOAD_NOTSUP_MASK \
 		(PKT_TX_OFFLOAD_MASK ^ I40E_TX_OFFLOAD_MASK)
 
+static const uint64_t i40e_simple_ol_mask = (DEV_TX_OFFLOAD_MULTI_SEGS |
+		DEV_TX_OFFLOAD_VLAN_INSERT |
+		DEV_TX_OFFLOAD_SCTP_CKSUM |
+		DEV_TX_OFFLOAD_UDP_CKSUM |
+		DEV_TX_OFFLOAD_TCP_CKSUM);
+

Seems incomplete.
From i40e_ethdev.c full-featured tx supports:
dev_info->tx_offload_capa =

                DEV_TX_OFFLOAD_VLAN_INSERT |
                DEV_TX_OFFLOAD_QINQ_INSERT |
                DEV_TX_OFFLOAD_IPV4_CKSUM |
                DEV_TX_OFFLOAD_UDP_CKSUM |
                DEV_TX_OFFLOAD_TCP_CKSUM |
                DEV_TX_OFFLOAD_SCTP_CKSUM |
                DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM |
                DEV_TX_OFFLOAD_TCP_TSO |
                DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
                DEV_TX_OFFLOAD_GRE_TNL_TSO |
                DEV_TX_OFFLOAD_IPIP_TNL_TSO |
                DEV_TX_OFFLOAD_GENEVE_TNL_TSO;
Quoted 6 lines

So we probably need the same here plus multiseg.
BTW, it is really strange that we don't have multiseg in tx_offload_capa. Should be present I think.
Might be worse to create a new define for it, or just use dev_info->tx_offload_capa directly. Konstantin

Thanks, good point, I never thought to check the advertised capabilities. I just translated what was being used by the old code txq_flags translation function. I'll clean this up and do a V2.

/Bruce

#3 lore raw
In reply to Ananyev, Konstantin
Quoted 58 lines · Konstantin

Hi Bruce,

Quoted 30 lines

The Tx function selection code in the driver only used the older txq flags values to check whether the scalar or vector functions should be used. This caused performance regressions with testpmd io-fwd as the scalar path rather than the vector one was being used in the default case. Fix this by changing the code to take account of new offloads and deleting the defines used for the old ones.

Fixes 7497d3e2f777 ("net/i40e: convert to new Tx offloads API")
---
 drivers/net/i40e/i40e_rxtx.c | 45 +++++++++++++++++++++++---------------------
 1 file changed, 24 insertions(+), 21 deletions(-)
drivers/net/i40e/i40e_rxtx.c +0 -3
index ec1ce54ca..c523af575 100644
@@ -40,9 +40,6 @@
 /* Base address of the HW descriptor ring should be 128B aligned. */
 #define I40E_RING_BASE_ALIGN	128
 
-#define I40E_SIMPLE_FLAGS ((uint32_t)ETH_TXQ_FLAGS_NOMULTSEGS | \
-					ETH_TXQ_FLAGS_NOOFFLOADS)
-
 #define I40E_TXD_CMD (I40E_TX_DESC_CMD_EOP | I40E_TX_DESC_CMD_RS)
 
 #ifdef RTE_LIBRTE_IEEE1588

drivers/net/i40e/i40e_rxtx.c line 75

Quoted 9 lines
drivers/net/i40e/i40e_rxtx.c +6 -0
@@ -70,6 +67,12 @@
 #define I40E_TX_OFFLOAD_NOTSUP_MASK \
 		(PKT_TX_OFFLOAD_MASK ^ I40E_TX_OFFLOAD_MASK)
 
+static const uint64_t i40e_simple_ol_mask = (DEV_TX_OFFLOAD_MULTI_SEGS |
+		DEV_TX_OFFLOAD_VLAN_INSERT |
+		DEV_TX_OFFLOAD_SCTP_CKSUM |
+		DEV_TX_OFFLOAD_UDP_CKSUM |
+		DEV_TX_OFFLOAD_TCP_CKSUM);
+

Seems incomplete.
From i40e_ethdev.c full-featured tx supports:
dev_info->tx_offload_capa =

                DEV_TX_OFFLOAD_VLAN_INSERT |
                DEV_TX_OFFLOAD_QINQ_INSERT |
                DEV_TX_OFFLOAD_IPV4_CKSUM |
                DEV_TX_OFFLOAD_UDP_CKSUM |
                DEV_TX_OFFLOAD_TCP_CKSUM |
                DEV_TX_OFFLOAD_SCTP_CKSUM |
                DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM |
                DEV_TX_OFFLOAD_TCP_TSO |
                DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
                DEV_TX_OFFLOAD_GRE_TNL_TSO |
                DEV_TX_OFFLOAD_IPIP_TNL_TSO |
                DEV_TX_OFFLOAD_GENEVE_TNL_TSO;
Quoted 6 lines

So we probably need the same here plus multiseg.
BTW, it is really strange that we don't have multiseg in tx_offload_capa. Should be present I think.
Might be worse to create a new define for it, or just use dev_info->tx_offload_capa directly. Konstantin

Thinking about this more, it seems that right now we don't need a masks at all. Any bits set in the offloads is going to cause us to use the scalar path or to error out with an invalid offload requested. Yes, it's not future-proofed in that it will need to be changed if we do end up supporting some offloads with the vector path in future, but then the same problem would occur if we just re-use the advertised capabilities too, like you suggest.

Therefore I think for V2 we'll just check for a non-zero offloads value.

/Bruce

#4 lore raw
Quoted 82 lines

-----Original Message-----
From: Richardson, Bruce
Sent: Tuesday, May 1, 2018 2:53 PM
To: Ananyev, Konstantin <[email protected]>
Cc: Xing, Beilei <[email protected]>; Zhang, Qi Z <[email protected]>; [email protected]; Yigit, Ferruh <[email protected]>
Subject: Re: [dpdk-dev] [PATCH] net/i40e: fix Tx fn selection when using new ethdev offloads

Quoted 58 lines · Konstantin

Hi Bruce,

Quoted 30 lines

The Tx function selection code in the driver only used the older txq flags values to check whether the scalar or vector functions should be used. This caused performance regressions with testpmd io-fwd as the scalar path rather than the vector one was being used in the default case. Fix this by changing the code to take account of new offloads and deleting the defines used for the old ones.

Fixes 7497d3e2f777 ("net/i40e: convert to new Tx offloads API")
---
 drivers/net/i40e/i40e_rxtx.c | 45 +++++++++++++++++++++++---------------------
 1 file changed, 24 insertions(+), 21 deletions(-)
drivers/net/i40e/i40e_rxtx.c +0 -3
index ec1ce54ca..c523af575 100644
@@ -40,9 +40,6 @@
 /* Base address of the HW descriptor ring should be 128B aligned. */
 #define I40E_RING_BASE_ALIGN	128
 
-#define I40E_SIMPLE_FLAGS ((uint32_t)ETH_TXQ_FLAGS_NOMULTSEGS | \
-					ETH_TXQ_FLAGS_NOOFFLOADS)
-
 #define I40E_TXD_CMD (I40E_TX_DESC_CMD_EOP | I40E_TX_DESC_CMD_RS)
 
 #ifdef RTE_LIBRTE_IEEE1588

drivers/net/i40e/i40e_rxtx.c line 75

Quoted 9 lines
drivers/net/i40e/i40e_rxtx.c +6 -0
@@ -70,6 +67,12 @@
 #define I40E_TX_OFFLOAD_NOTSUP_MASK \
 		(PKT_TX_OFFLOAD_MASK ^ I40E_TX_OFFLOAD_MASK)
 
+static const uint64_t i40e_simple_ol_mask = (DEV_TX_OFFLOAD_MULTI_SEGS |
+		DEV_TX_OFFLOAD_VLAN_INSERT |
+		DEV_TX_OFFLOAD_SCTP_CKSUM |
+		DEV_TX_OFFLOAD_UDP_CKSUM |
+		DEV_TX_OFFLOAD_TCP_CKSUM);
+

Seems incomplete.
From i40e_ethdev.c full-featured tx supports:
dev_info->tx_offload_capa =

                DEV_TX_OFFLOAD_VLAN_INSERT |
                DEV_TX_OFFLOAD_QINQ_INSERT |
                DEV_TX_OFFLOAD_IPV4_CKSUM |
                DEV_TX_OFFLOAD_UDP_CKSUM |
                DEV_TX_OFFLOAD_TCP_CKSUM |
                DEV_TX_OFFLOAD_SCTP_CKSUM |
                DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM |
                DEV_TX_OFFLOAD_TCP_TSO |
                DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
                DEV_TX_OFFLOAD_GRE_TNL_TSO |
                DEV_TX_OFFLOAD_IPIP_TNL_TSO |
                DEV_TX_OFFLOAD_GENEVE_TNL_TSO;
Quoted 6 lines

So we probably need the same here plus multiseg.
BTW, it is really strange that we don't have multiseg in tx_offload_capa. Should be present I think.
Might be worse to create a new define for it, or just use dev_info->tx_offload_capa directly. Konstantin

Thinking about this more, it seems that right now we don't need a masks at all. Any bits set in the offloads is going to cause us to use the scalar path or to error out with an invalid offload requested. Yes, it's not future-proofed in that it will need to be changed if we do end up supporting some offloads with the vector path in future, but then the same problem would occur if we just re-use the advertised capabilities too, like you suggest.

Quoted 1 line

Therefore I think for V2 we'll just check for a non-zero offloads value.

Ok by me.
Konstantin

#5 lore raw

PATCH v2 1/1 net/i40e: fix Tx fn selection when using new ethdev offloads

In reply to Bruce Richardson

The Tx function selection code in the driver only used the older txq flags values to check whether the scalar or vector functions should be used. This caused performance regressions with testpmd io-fwd as the scalar path rather than the vector one was being used in the default case. Fix this by changing the code to take account of new offloads and deleting the defines used for the old ones.

Fixes 7497d3e2f777 ("net/i40e: convert to new Tx offloads API")
---
 drivers/net/i40e/i40e_rxtx.c | 39 ++++++++++++++++++---------------------
 1 file changed, 18 insertions(+), 21 deletions(-)
drivers/net/i40e/i40e_rxtx.c +18 -21
index ec1ce54ca..006f5b846 100644
@@ -40,9 +40,6 @@
 /* Base address of the HW descriptor ring should be 128B aligned. */
 #define I40E_RING_BASE_ALIGN	128
 
-#define I40E_SIMPLE_FLAGS ((uint32_t)ETH_TXQ_FLAGS_NOMULTSEGS | \
-					ETH_TXQ_FLAGS_NOOFFLOADS)
-
 #define I40E_TXD_CMD (I40E_TX_DESC_CMD_EOP | I40E_TX_DESC_CMD_RS)
 
 #ifdef RTE_LIBRTE_IEEE1588
@@ -2108,11 +2105,9 @@ i40e_dev_tx_queue_setup_runtime(struct rte_eth_dev *dev,
 				 dev->data->nb_tx_queues)) {
 		/**
 		 * If it is the first queue to setup,
-		 * set all flags to default and call
+		 * set all flags and call
 		 * i40e_set_tx_function.
 		 */
-		ad->tx_simple_allowed = true;
-		ad->tx_vec_allowed = true;
 		i40e_set_tx_function_flag(dev, txq);
 		i40e_set_tx_function(dev);
 		return 0;
@@ -2128,9 +2123,8 @@ i40e_dev_tx_queue_setup_runtime(struct rte_eth_dev *dev,
 	}
 	/* check simple tx conflict */
 	if (ad->tx_simple_allowed) {
-		if (((txq->txq_flags & I40E_SIMPLE_FLAGS) !=
-		     I40E_SIMPLE_FLAGS) ||
-		    txq->tx_rs_thresh < RTE_PMD_I40E_TX_MAX_BURST) {
+		if (txq->offloads != 0 ||
+				txq->tx_rs_thresh < RTE_PMD_I40E_TX_MAX_BURST) {
 			PMD_DRV_LOG(ERR, "No-simple tx is required.");
 			return -EINVAL;
 		}
@@ -3080,18 +3074,21 @@ i40e_set_tx_function_flag(struct rte_eth_dev *dev, struct i40e_tx_queue *txq)
 		I40E_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
 
 	/* Use a simple Tx queue (no offloads, no multi segs) if possible */
-	if (((txq->txq_flags & I40E_SIMPLE_FLAGS) == I40E_SIMPLE_FLAGS)
-			&& (txq->tx_rs_thresh >= RTE_PMD_I40E_TX_MAX_BURST)) {
-		if (txq->tx_rs_thresh <= RTE_I40E_TX_MAX_FREE_BUF_SZ) {
-			PMD_INIT_LOG(DEBUG, "Vector tx"
-				     " can be enabled on this txq.");
-
-		} else {
-			ad->tx_vec_allowed = false;
-		}
-	} else {
-		ad->tx_simple_allowed = false;
-	}
+	ad->tx_simple_allowed = (txq->offloads == 0 &&
+			txq->tx_rs_thresh >= RTE_PMD_I40E_TX_MAX_BURST);
+	ad->tx_vec_allowed = (ad->tx_simple_allowed &&
+			txq->tx_rs_thresh <= RTE_I40E_TX_MAX_FREE_BUF_SZ);
+
+	if (ad->tx_vec_allowed)
+		PMD_INIT_LOG(DEBUG, "Vector Tx can be enabled on Tx queue %u.",
+				txq->queue_id);
+	else if (ad->tx_simple_allowed)
+		PMD_INIT_LOG(DEBUG, "Simple Tx can be enabled on Tx queue %u.",
+				txq->queue_id);
+	else
+		PMD_INIT_LOG(DEBUG,
+				"Neither simple nor vector Tx enabled on Tx queue %u\n",
+				txq->queue_id);
 }
 
 void __attribute__((cold))
Signature · 1 line
2.14.3
#6 lore raw
Quoted 11 lines · Bruce Richardson

The Tx function selection code in the driver only used the older txq flags values to check whether the scalar or vector functions should be used. This caused performance regressions with testpmd io-fwd as the scalar path rather than the vector one was being used in the default case. Fix this by changing the code to take account of new offloads and deleting the defines used for the old ones.

Fixes 7497d3e2f777 ("net/i40e: convert to new Tx offloads API")

---

Apologies: forgot to add:

v2: eliminate mask for offload flags, and use vector path only if

    offloads == 0
Reviewed-by
#7 lore raw
Quoted 8 lines · Bruce Richardson
Quoted 7 lines · Bruce Richardson

The Tx function selection code in the driver only used the older txq flags values to check whether the scalar or vector functions should be used. This caused performance regressions with testpmd io-fwd as the scalar path rather than the vector one was being used in the default case. Fix this by changing the code to take account of new offloads and deleting the defines used for the old ones.

Quoted 9 lines
Quoted 4 lines
Fixes 7497d3e2f777 ("net/i40e: convert to new Tx offloads API")

---

Apologies: forgot to add:

v2: eliminate mask for offload flags, and use vector path only if

    offloads == 0
Applied
#8 lore raw
Quoted 13 lines · Ferruh Yigit
Quoted 12 lines · Bruce Richardson
Quoted 11 lines · Bruce Richardson

The Tx function selection code in the driver only used the older txq flags values to check whether the scalar or vector functions should be used. This caused performance regressions with testpmd io-fwd as the scalar path rather than the vector one was being used in the default case. Fix this by changing the code to take account of new offloads and deleting the defines used for the old ones.

Fixes 7497d3e2f777 ("net/i40e: convert to new Tx offloads API")

---

Quoted 7 lines
Quoted 5 lines

Apologies: forgot to add:

v2: eliminate mask for offload flags, and use vector path only if

    offloads == 0

Applied to dpdk-next-net/master, thanks.

#9 lore raw
In reply to Bruce Richardson
Quoted 71 lines

-----Original Message-----
From: Richardson, Bruce
Sent: Tuesday, May 1, 2018 3:14 PM
To: Xing, Beilei <[email protected]>; Zhang, Qi Z <[email protected]>
Cc: [email protected]; Yigit, Ferruh <[email protected]>; Ananyev, Konstantin <[email protected]>; Richardson, Bruce <[email protected]>
Subject: [PATCH v2] net/i40e: fix Tx fn selection when using new ethdev offloads

The Tx function selection code in the driver only used the older txq flags values to check whether the scalar or vector functions should be used. This caused performance regressions with testpmd io-fwd as the scalar path rather than the vector one was being used in the default case. Fix this by changing the code to take account of new offloads and deleting the defines used for the old ones.

Fixes 7497d3e2f777 ("net/i40e: convert to new Tx offloads API")
---
 drivers/net/i40e/i40e_rxtx.c | 39 ++++++++++++++++++---------------------
 1 file changed, 18 insertions(+), 21 deletions(-)
drivers/net/i40e/i40e_rxtx.c +3 -13
index ec1ce54ca..006f5b846 100644
@@ -40,9 +40,6 @@
 /* Base address of the HW descriptor ring should be 128B aligned. */
 #define I40E_RING_BASE_ALIGN	128
 
-#define I40E_SIMPLE_FLAGS ((uint32_t)ETH_TXQ_FLAGS_NOMULTSEGS | \
-					ETH_TXQ_FLAGS_NOOFFLOADS)
-
 #define I40E_TXD_CMD (I40E_TX_DESC_CMD_EOP | I40E_TX_DESC_CMD_RS)
 
 #ifdef RTE_LIBRTE_IEEE1588
@@ -2108,11 +2105,9 @@ i40e_dev_tx_queue_setup_runtime(struct rte_eth_dev *dev,
 				 dev->data->nb_tx_queues)) {
 		/**
 		 * If it is the first queue to setup,
-		 * set all flags to default and call
+		 * set all flags and call
 		 * i40e_set_tx_function.
 		 */
-		ad->tx_simple_allowed = true;
-		ad->tx_vec_allowed = true;
 		i40e_set_tx_function_flag(dev, txq);
 		i40e_set_tx_function(dev);
 		return 0;
@@ -2128,9 +2123,8 @@ i40e_dev_tx_queue_setup_runtime(struct rte_eth_dev *dev,
 	}
 	/* check simple tx conflict */
 	if (ad->tx_simple_allowed) {
-		if (((txq->txq_flags & I40E_SIMPLE_FLAGS) !=
-		     I40E_SIMPLE_FLAGS) ||
-		    txq->tx_rs_thresh < RTE_PMD_I40E_TX_MAX_BURST) {
+		if (txq->offloads != 0 ||
+				txq->tx_rs_thresh < RTE_PMD_I40E_TX_MAX_BURST) {
 			PMD_DRV_LOG(ERR, "No-simple tx is required.");
 			return -EINVAL;
 		}
@@ -3080,18 +3074,21 @@ i40e_set_tx_function_flag(struct rte_eth_dev *dev, struct i40e_tx_queue *txq)
 		I40E_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
 
 	/* Use a simple Tx queue (no offloads, no multi segs) if possible */
-	if (((txq->txq_flags & I40E_SIMPLE_FLAGS) == I40E_SIMPLE_FLAGS)
-			&& (txq->tx_rs_thresh >= RTE_PMD_I40E_TX_MAX_BURST)) {
-		if (txq->tx_rs_thresh <= RTE_I40E_TX_MAX_FREE_BUF_SZ) {
-			PMD_INIT_LOG(DEBUG, "Vector tx"

drivers/net/i40e/i40e_rxtx.c i40e_set_tx_function_flag(struct rte_eth_dev *dev, struct i40e_tx_queue *txq) · line 3078

Quoted 10 lines
drivers/net/i40e/i40e_rxtx.c +2 -8
-				     " can be enabled on this txq.");
-
-		} else {
-			ad->tx_vec_allowed = false;
-		}
-	} else {
-		ad->tx_simple_allowed = false;
-	}
+	ad->tx_simple_allowed = (txq->offloads == 0 &&
+			txq->tx_rs_thresh >= RTE_PMD_I40E_TX_MAX_BURST);

Actually after another thought - who setup txq->offloads? I did a quick scan, through i40e code and seems no one does. So now it seems not possible to enable TX offloads at all. Konstantin

BTW, seems like rxq->offloads are not properly initialised too.

Quoted 18 lines
drivers/net/i40e/i40e_rxtx.c +13 -1
+	ad->tx_vec_allowed = (ad->tx_simple_allowed &&
+			txq->tx_rs_thresh <= RTE_I40E_TX_MAX_FREE_BUF_SZ);
+
+	if (ad->tx_vec_allowed)
+		PMD_INIT_LOG(DEBUG, "Vector Tx can be enabled on Tx queue %u.",
+				txq->queue_id);
+	else if (ad->tx_simple_allowed)
+		PMD_INIT_LOG(DEBUG, "Simple Tx can be enabled on Tx queue %u.",
+				txq->queue_id);
+	else
+		PMD_INIT_LOG(DEBUG,
+				"Neither simple nor vector Tx enabled on Tx queue %u\n",
+				txq->queue_id);
 }
 
 void __attribute__((cold))
--

2.14.3

#10 lore raw
Quoted 87 lines · Konstantin
Quoted 71 lines

-----Original Message-----
From: Richardson, Bruce
Sent: Tuesday, May 1, 2018 3:14 PM
To: Xing, Beilei <[email protected]>; Zhang, Qi Z <[email protected]>
Cc: [email protected]; Yigit, Ferruh <[email protected]>; Ananyev, Konstantin <[email protected]>; Richardson, Bruce <[email protected]>
Subject: [PATCH v2] net/i40e: fix Tx fn selection when using new ethdev offloads

The Tx function selection code in the driver only used the older txq flags values to check whether the scalar or vector functions should be used. This caused performance regressions with testpmd io-fwd as the scalar path rather than the vector one was being used in the default case. Fix this by changing the code to take account of new offloads and deleting the defines used for the old ones.

Fixes 7497d3e2f777 ("net/i40e: convert to new Tx offloads API")
---
 drivers/net/i40e/i40e_rxtx.c | 39 ++++++++++++++++++---------------------
 1 file changed, 18 insertions(+), 21 deletions(-)
drivers/net/i40e/i40e_rxtx.c +3 -13
index ec1ce54ca..006f5b846 100644
@@ -40,9 +40,6 @@
 /* Base address of the HW descriptor ring should be 128B aligned. */
 #define I40E_RING_BASE_ALIGN	128
 
-#define I40E_SIMPLE_FLAGS ((uint32_t)ETH_TXQ_FLAGS_NOMULTSEGS | \
-					ETH_TXQ_FLAGS_NOOFFLOADS)
-
 #define I40E_TXD_CMD (I40E_TX_DESC_CMD_EOP | I40E_TX_DESC_CMD_RS)
 
 #ifdef RTE_LIBRTE_IEEE1588
@@ -2108,11 +2105,9 @@ i40e_dev_tx_queue_setup_runtime(struct rte_eth_dev *dev,
 				 dev->data->nb_tx_queues)) {
 		/**
 		 * If it is the first queue to setup,
-		 * set all flags to default and call
+		 * set all flags and call
 		 * i40e_set_tx_function.
 		 */
-		ad->tx_simple_allowed = true;
-		ad->tx_vec_allowed = true;
 		i40e_set_tx_function_flag(dev, txq);
 		i40e_set_tx_function(dev);
 		return 0;
@@ -2128,9 +2123,8 @@ i40e_dev_tx_queue_setup_runtime(struct rte_eth_dev *dev,
 	}
 	/* check simple tx conflict */
 	if (ad->tx_simple_allowed) {
-		if (((txq->txq_flags & I40E_SIMPLE_FLAGS) !=
-		     I40E_SIMPLE_FLAGS) ||
-		    txq->tx_rs_thresh < RTE_PMD_I40E_TX_MAX_BURST) {
+		if (txq->offloads != 0 ||
+				txq->tx_rs_thresh < RTE_PMD_I40E_TX_MAX_BURST) {
 			PMD_DRV_LOG(ERR, "No-simple tx is required.");
 			return -EINVAL;
 		}
@@ -3080,18 +3074,21 @@ i40e_set_tx_function_flag(struct rte_eth_dev *dev, struct i40e_tx_queue *txq)
 		I40E_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
 
 	/* Use a simple Tx queue (no offloads, no multi segs) if possible */
-	if (((txq->txq_flags & I40E_SIMPLE_FLAGS) == I40E_SIMPLE_FLAGS)
-			&& (txq->tx_rs_thresh >= RTE_PMD_I40E_TX_MAX_BURST)) {
-		if (txq->tx_rs_thresh <= RTE_I40E_TX_MAX_FREE_BUF_SZ) {
-			PMD_INIT_LOG(DEBUG, "Vector tx"

drivers/net/i40e/i40e_rxtx.c i40e_set_tx_function_flag(struct rte_eth_dev *dev, struct i40e_tx_queue *txq) · line 3078

Quoted 10 lines
drivers/net/i40e/i40e_rxtx.c +2 -8
-				     " can be enabled on this txq.");
-
-		} else {
-			ad->tx_vec_allowed = false;
-		}
-	} else {
-		ad->tx_simple_allowed = false;
-	}
+	ad->tx_simple_allowed = (txq->offloads == 0 &&
+			txq->tx_rs_thresh >= RTE_PMD_I40E_TX_MAX_BURST);

Actually after another thought - who setup txq->offloads? I did a quick scan, through i40e code and seems no one does. So now it seems not possible to enable TX offloads at all. Konstantin

Quoted 2 lines

BTW, seems like rxq->offloads are not properly initialised too.

The offloads value should come from the app, no?

#11 lore raw
Quoted 109 lines

-----Original Message-----
From: Richardson, Bruce
Sent: Wednesday, May 2, 2018 4:25 PM
To: Ananyev, Konstantin <[email protected]>
Cc: Xing, Beilei <[email protected]>; Zhang, Qi Z <[email protected]>; [email protected]; Yigit, Ferruh <[email protected]>
Subject: Re: [PATCH v2] net/i40e: fix Tx fn selection when using new ethdev offloads

Quoted 36 lines · Konstantin
Quoted 36 lines

-----Original Message-----
From: Richardson, Bruce
Sent: Tuesday, May 1, 2018 3:14 PM
To: Xing, Beilei <[email protected]>; Zhang, Qi Z <[email protected]>
Cc: [email protected]; Yigit, Ferruh <[email protected]>; Ananyev, Konstantin <[email protected]>; Richardson, Bruce <[email protected]>
Subject: [PATCH v2] net/i40e: fix Tx fn selection when using new ethdev offloads

The Tx function selection code in the driver only used the older txq flags values to check whether the scalar or vector functions should be used. This caused performance regressions with testpmd io-fwd as the scalar path rather than the vector one was being used in the default case. Fix this by changing the code to take account of new offloads and deleting the defines used for the old ones.

Fixes 7497d3e2f777 ("net/i40e: convert to new Tx offloads API")
---
 drivers/net/i40e/i40e_rxtx.c | 39
++++++++++++++++++---------------------
 1 file changed, 18 insertions(+), 21 deletions(-)
(quoted diff) +0 -0

b/drivers/net/i40e/i40e_rxtx.c index ec1ce54ca..006f5b846 100644

drivers/net/i40e/i40e_rxtx.c +0 -0
@@ -40,9 +40,6 @@
 /* Base address of the HW descriptor ring should be 128B aligned. */
 #define I40E_RING_BASE_ALIGN	128
 
Quoted 1 line

drivers/net/i40e/i40e_rxtx.c line 43

Quoted 1 line
drivers/net/i40e/i40e_rxtx.c +0 -1
-#define I40E_SIMPLE_FLAGS ((uint32_t)ETH_TXQ_FLAGS_NOMULTSEGS

| \

Quoted 3 lines

drivers/net/i40e/i40e_rxtx.c

Quoted 3 lines
drivers/net/i40e/i40e_rxtx.c +0 -2
-					ETH_TXQ_FLAGS_NOOFFLOADS)
-
 #define I40E_TXD_CMD (I40E_TX_DESC_CMD_EOP |

I40E_TX_DESC_CMD_RS)

Quoted 3 lines

drivers/net/i40e/i40e_rxtx.c i40e_dev_tx_queue_setup_runtime(struct

Quoted 3 lines
drivers/net/i40e/i40e_rxtx.c +0 -0
 #ifdef RTE_LIBRTE_IEEE1588
@@ -2108,11 +2105,9 @@ i40e_dev_tx_queue_setup_runtime(struct

rte_eth_dev *dev,

Quoted 5 lines
Quoted 5 lines
drivers/net/i40e/i40e_rxtx.c +1 -1
 				 dev->data->nb_tx_queues)) {
 		/**
 		 * If it is the first queue to setup,
-		 * set all flags to default and call
+		 * set all flags and call
Quoted 8 lines

drivers/net/i40e/i40e_rxtx.c i40e_dev_tx_queue_setup_runtime(struct

Quoted 8 lines
drivers/net/i40e/i40e_rxtx.c +0 -2
 		 * i40e_set_tx_function.
 		 */
-		ad->tx_simple_allowed = true;
-		ad->tx_vec_allowed = true;
 		i40e_set_tx_function_flag(dev, txq);
 		i40e_set_tx_function(dev);
 		return 0;
@@ -2128,9 +2123,8 @@ i40e_dev_tx_queue_setup_runtime(struct

rte_eth_dev *dev,

Quoted 8 lines

drivers/net/i40e/i40e_rxtx.c i40e_dev_tx_queue_setup_runtime(struct rte_eth_dev *dev,

Quoted 8 lines
drivers/net/i40e/i40e_rxtx.c +2 -3
 	}
 	/* check simple tx conflict */
 	if (ad->tx_simple_allowed) {
-		if (((txq->txq_flags & I40E_SIMPLE_FLAGS) !=
-		     I40E_SIMPLE_FLAGS) ||
-		    txq->tx_rs_thresh < RTE_PMD_I40E_TX_MAX_BURST) {
+		if (txq->offloads != 0 ||
+				txq->tx_rs_thresh < RTE_PMD_I40E_TX_MAX_BURST)

{

Quoted 4 lines

drivers/net/i40e/i40e_rxtx.c i40e_set_tx_function_flag(struct

Quoted 4 lines
drivers/net/i40e/i40e_rxtx.c +0 -0
 			PMD_DRV_LOG(ERR, "No-simple tx is required.");
 			return -EINVAL;
 		}
@@ -3080,18 +3074,21 @@ i40e_set_tx_function_flag(struct

rte_eth_dev *dev, struct i40e_tx_queue *txq)

Quoted 23 lines
Quoted 7 lines
drivers/net/i40e/i40e_rxtx.c +0 -4
 		I40E_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
 
 	/* Use a simple Tx queue (no offloads, no multi segs) if possible */
-	if (((txq->txq_flags & I40E_SIMPLE_FLAGS) == I40E_SIMPLE_FLAGS)
-			&& (txq->tx_rs_thresh >= RTE_PMD_I40E_TX_MAX_BURST)) {
-		if (txq->tx_rs_thresh <= RTE_I40E_TX_MAX_FREE_BUF_SZ) {
-			PMD_INIT_LOG(DEBUG, "Vector tx"

drivers/net/i40e/i40e_rxtx.c i40e_set_tx_function_flag(struct rte_eth_dev *dev, struct i40e_tx_queue *txq) · line 3078

Quoted 10 lines
drivers/net/i40e/i40e_rxtx.c +2 -8
-				     " can be enabled on this txq.");
-
-		} else {
-			ad->tx_vec_allowed = false;
-		}
-	} else {
-		ad->tx_simple_allowed = false;
-	}
+	ad->tx_simple_allowed = (txq->offloads == 0 &&
+			txq->tx_rs_thresh >= RTE_PMD_I40E_TX_MAX_BURST);

Actually after another thought - who setup txq->offloads? I did a quick scan, through i40e code and seems no one does. So now it seems not possible to enable TX offloads at all. Konstantin

Quoted 3 lines
Quoted 2 lines

BTW, seems like rxq->offloads are not properly initialised too.

The offloads value should come from the app, no?

This should be a separate issue, I have submit the fix.

http://dpdk.org/dev/patchwork/patch/39229/

Regard
Qi