net/i40e: add Tx preparation for simple Tx datapath
authorLeyi Rong <leyi.rong@intel.com>
Tue, 20 Apr 2021 05:29:45 +0000 (13:29 +0800)
committerQi Zhang <qi.z.zhang@intel.com>
Tue, 20 Apr 2021 14:01:15 +0000 (16:01 +0200)
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: Konstantin Ananyev <konstantin.ananyev@intel.com>
drivers/net/i40e/i40e_rxtx.c
drivers/net/i40e/i40e_rxtx.h

index 3c7686c..86a9eae 100644 (file)
@@ -1479,6 +1479,43 @@ 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;
+
+       for (i = 0; i < nb_pkts; i++) {
+               m = tx_pkts[i];
+               ol_flags = m->ol_flags;
+
+               if (m->nb_segs != 1) {
+                       rte_errno = EINVAL;
+                       return i;
+               }
+
+               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 +3449,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;
index 3447a58..5ccf577 100644 (file)
@@ -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);