[v2] net/i40e: add Tx preparation for simple Tx data path

Message ID 20210419083622.83717-1-leyi.rong@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Qi Zhang
Headers
Series [v2] net/i40e: add Tx preparation for simple Tx data path |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/travis-robot success travis build: passed
ci/github-robot success github build: passed
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS

Commit Message

Leyi Rong April 19, 2021, 8:36 a.m. UTC
  Introduce i40e_simple_prep_pkts() as the preparation function for
simple Tx data path, as it's for sanity check for simple Tx.

Suggested-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
Signed-off-by: Leyi Rong <leyi.rong@intel.com>
---
 drivers/net/i40e/i40e_rxtx.c | 42 +++++++++++++++++++++++++++++++++++-
 drivers/net/i40e/i40e_rxtx.h |  2 ++
 2 files changed, 43 insertions(+), 1 deletion(-)
  

Comments

Qi Zhang April 19, 2021, 9:36 a.m. UTC | #1
> -----Original Message-----
> From: Rong, Leyi <leyi.rong@intel.com>
> Sent: Monday, April 19, 2021 4:36 PM
> To: Zhang, Qi Z <qi.z.zhang@intel.com>; Ananyev, Konstantin
> <konstantin.ananyev@intel.com>
> Cc: dev@dpdk.org; Rong, Leyi <leyi.rong@intel.com>
> Subject: [PATCH v2] net/i40e: add Tx preparation for simple Tx data path
> 
> Introduce i40e_simple_prep_pkts() as the preparation function for simple Tx
> data path, as it's for sanity check for simple Tx.
> 
> Suggested-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
> Signed-off-by: Leyi Rong <leyi.rong@intel.com>

Acked-by: Qi Zhang <qi.z.zhang@intel.com>

Applied to dpdk-next-net-intel.

Thanks
Qi
  
Ananyev, Konstantin April 19, 2021, 10:59 a.m. UTC | #2
Hi Leyi,

> Introduce i40e_simple_prep_pkts() as the preparation function for
> simple Tx data path, as it's for sanity check for simple Tx.
> 
> Suggested-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
> Signed-off-by: Leyi Rong <leyi.rong@intel.com>
> ---
>  drivers/net/i40e/i40e_rxtx.c | 42 +++++++++++++++++++++++++++++++++++-
>  drivers/net/i40e/i40e_rxtx.h |  2 ++
>  2 files changed, 43 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c
> index 3c7686c3f4..282eb5924b 100644
> --- a/drivers/net/i40e/i40e_rxtx.c
> +++ b/drivers/net/i40e/i40e_rxtx.c
> @@ -1479,6 +1479,46 @@ i40e_xmit_pkts_vec(void *tx_queue, struct rte_mbuf **tx_pkts,
>  	return nb_tx;
>  }
> 
> +/*********************************************************************
> + *
> + *  TX simple prep functions
> + *
> + **********************************************************************/
> +uint16_t
> +i40e_simple_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts,
> +		      uint16_t nb_pkts)
> +{
> +	int i;
> +	uint64_t ol_flags;
> +	struct rte_mbuf *m;
> +	struct i40e_tx_queue *txq = (struct i40e_tx_queue *)tx_queue;
> +
> +	for (i = 0; i < nb_pkts; i++) {
> +		m = tx_pkts[i];
> +		ol_flags = m->ol_flags;
> +
> +		if (!(txq->offloads ==
> +			(txq->offloads & DEV_TX_OFFLOAD_MBUF_FAST_FREE) &&
> +			m->nb_segs == 1)) {

I think we don't need to check  txq->offloads here,
they should be already checked at setup phase.
I suppose:
if (m->nb_segs != 1) {...}
should be enough here. 

> +			rte_errno = EINVAL;
> +			return i;
> +		}
> +
> +		if (ol_flags & I40E_TX_OFFLOAD_NOTSUP_MASK) {

It would return OK for the packet with any supported by any i40e TX offload (full-featured path).
Probably we need here instead:
if (ol_flags & PKT_TX_OFFLOAD_MASK)  {...}

> +			rte_errno = ENOTSUP;
> +			return i;
> +		}
> +
> +		/* check the size of packet */
> +		if (m->pkt_len < I40E_TX_MIN_PKT_LEN ||
> +		    m->pkt_len > I40E_FRAME_SIZE_MAX) {
> +			rte_errno = EINVAL;
> +			return i;
> +		}
> +	}
> +	return i;
> +}
> +
>  /*********************************************************************
>   *
>   *  TX prep functions
> @@ -3412,7 +3452,7 @@ i40e_set_tx_function(struct rte_eth_dev *dev)
>  			PMD_INIT_LOG(DEBUG, "Simple tx finally be used.");
>  			dev->tx_pkt_burst = i40e_xmit_pkts_simple;
>  		}
> -		dev->tx_pkt_prepare = NULL;
> +		dev->tx_pkt_prepare = i40e_simple_prep_pkts;
>  	} else {
>  		PMD_INIT_LOG(DEBUG, "Xmit tx finally be used.");
>  		dev->tx_pkt_burst = i40e_xmit_pkts;
> diff --git a/drivers/net/i40e/i40e_rxtx.h b/drivers/net/i40e/i40e_rxtx.h
> index 3447a58c82..5ccf5773e8 100644
> --- a/drivers/net/i40e/i40e_rxtx.h
> +++ b/drivers/net/i40e/i40e_rxtx.h
> @@ -208,6 +208,8 @@ uint16_t i40e_recv_scattered_pkts(void *rx_queue,
>  uint16_t i40e_xmit_pkts(void *tx_queue,
>  			struct rte_mbuf **tx_pkts,
>  			uint16_t nb_pkts);
> +uint16_t i40e_simple_prep_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
> +			       uint16_t nb_pkts);
>  uint16_t i40e_prep_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
>  		uint16_t nb_pkts);
>  int i40e_tx_queue_init(struct i40e_tx_queue *txq);
> --
> 2.17.1
  
Leyi Rong April 20, 2021, 5:31 a.m. UTC | #3
> -----Original Message-----
> From: Ananyev, Konstantin <konstantin.ananyev@intel.com>
> Sent: Monday, April 19, 2021 6:59 PM
> To: Rong, Leyi <leyi.rong@intel.com>; Zhang, Qi Z <qi.z.zhang@intel.com>
> Cc: dev@dpdk.org
> Subject: RE: [PATCH v2] net/i40e: add Tx preparation for simple Tx data path
> 
> Hi Leyi,
> 
> > Introduce i40e_simple_prep_pkts() as the preparation function for
> > simple Tx data path, as it's for sanity check for simple Tx.
> >
> > Suggested-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
> > Signed-off-by: Leyi Rong <leyi.rong@intel.com>
> > ---
> >  drivers/net/i40e/i40e_rxtx.c | 42
> > +++++++++++++++++++++++++++++++++++-
> >  drivers/net/i40e/i40e_rxtx.h |  2 ++
> >  2 files changed, 43 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/net/i40e/i40e_rxtx.c
> > b/drivers/net/i40e/i40e_rxtx.c index 3c7686c3f4..282eb5924b 100644
> > --- a/drivers/net/i40e/i40e_rxtx.c
> > +++ b/drivers/net/i40e/i40e_rxtx.c
> > @@ -1479,6 +1479,46 @@ i40e_xmit_pkts_vec(void *tx_queue, struct
> rte_mbuf **tx_pkts,
> >  	return nb_tx;
> >  }
> >
> >
> +/***************************************************************
> *****
> > +*
> > + *
> > + *  TX simple prep functions
> > + *
> > +
> >
> +****************************************************************
> *****
> > +*/
> > +uint16_t
> > +i40e_simple_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf
> **tx_pkts,
> > +		      uint16_t nb_pkts)
> > +{
> > +	int i;
> > +	uint64_t ol_flags;
> > +	struct rte_mbuf *m;
> > +	struct i40e_tx_queue *txq = (struct i40e_tx_queue *)tx_queue;
> > +
> > +	for (i = 0; i < nb_pkts; i++) {
> > +		m = tx_pkts[i];
> > +		ol_flags = m->ol_flags;
> > +
> > +		if (!(txq->offloads ==
> > +			(txq->offloads & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
> &&
> > +			m->nb_segs == 1)) {
> 
> I think we don't need to check  txq->offloads here, they should be already
> checked at setup phase.
> I suppose:
> if (m->nb_segs != 1) {...}
> should be enough here.
> 
> > +			rte_errno = EINVAL;
> > +			return i;
> > +		}
> > +
> > +		if (ol_flags & I40E_TX_OFFLOAD_NOTSUP_MASK) {
> 
> It would return OK for the packet with any supported by any i40e TX offload
> (full-featured path).
> Probably we need here instead:
> if (ol_flags & PKT_TX_OFFLOAD_MASK)  {...}
> 
> > +			rte_errno = ENOTSUP;
> > +			return i;
> > +		}

Hi Konstantin,

Got your points, will be fixed in v3, thanks!
  

Patch

diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c
index 3c7686c3f4..282eb5924b 100644
--- a/drivers/net/i40e/i40e_rxtx.c
+++ b/drivers/net/i40e/i40e_rxtx.c
@@ -1479,6 +1479,46 @@  i40e_xmit_pkts_vec(void *tx_queue, struct rte_mbuf **tx_pkts,
 	return nb_tx;
 }
 
+/*********************************************************************
+ *
+ *  TX simple prep functions
+ *
+ **********************************************************************/
+uint16_t
+i40e_simple_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts,
+		      uint16_t nb_pkts)
+{
+	int i;
+	uint64_t ol_flags;
+	struct rte_mbuf *m;
+	struct i40e_tx_queue *txq = (struct i40e_tx_queue *)tx_queue;
+
+	for (i = 0; i < nb_pkts; i++) {
+		m = tx_pkts[i];
+		ol_flags = m->ol_flags;
+
+		if (!(txq->offloads ==
+			(txq->offloads & DEV_TX_OFFLOAD_MBUF_FAST_FREE) &&
+			m->nb_segs == 1)) {
+			rte_errno = EINVAL;
+			return i;
+		}
+
+		if (ol_flags & I40E_TX_OFFLOAD_NOTSUP_MASK) {
+			rte_errno = ENOTSUP;
+			return i;
+		}
+
+		/* check the size of packet */
+		if (m->pkt_len < I40E_TX_MIN_PKT_LEN ||
+		    m->pkt_len > I40E_FRAME_SIZE_MAX) {
+			rte_errno = EINVAL;
+			return i;
+		}
+	}
+	return i;
+}
+
 /*********************************************************************
  *
  *  TX prep functions
@@ -3412,7 +3452,7 @@  i40e_set_tx_function(struct rte_eth_dev *dev)
 			PMD_INIT_LOG(DEBUG, "Simple tx finally be used.");
 			dev->tx_pkt_burst = i40e_xmit_pkts_simple;
 		}
-		dev->tx_pkt_prepare = NULL;
+		dev->tx_pkt_prepare = i40e_simple_prep_pkts;
 	} else {
 		PMD_INIT_LOG(DEBUG, "Xmit tx finally be used.");
 		dev->tx_pkt_burst = i40e_xmit_pkts;
diff --git a/drivers/net/i40e/i40e_rxtx.h b/drivers/net/i40e/i40e_rxtx.h
index 3447a58c82..5ccf5773e8 100644
--- a/drivers/net/i40e/i40e_rxtx.h
+++ b/drivers/net/i40e/i40e_rxtx.h
@@ -208,6 +208,8 @@  uint16_t i40e_recv_scattered_pkts(void *rx_queue,
 uint16_t i40e_xmit_pkts(void *tx_queue,
 			struct rte_mbuf **tx_pkts,
 			uint16_t nb_pkts);
+uint16_t i40e_simple_prep_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
+			       uint16_t nb_pkts);
 uint16_t i40e_prep_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 		uint16_t nb_pkts);
 int i40e_tx_queue_init(struct i40e_tx_queue *txq);