Fill transmit prepare function.

Signed-off-by: Jiawen Wu <jiawe...@trustnetic.com>
---
 drivers/net/txgbe/txgbe_rxtx.c | 52 +++++++++++++++++++++++++++++++---
 drivers/net/txgbe/txgbe_rxtx.h |  2 ++
 2 files changed, 50 insertions(+), 4 deletions(-)

diff --git a/drivers/net/txgbe/txgbe_rxtx.c b/drivers/net/txgbe/txgbe_rxtx.c
index 0c35d3c9e..ef3d63b01 100644
--- a/drivers/net/txgbe/txgbe_rxtx.c
+++ b/drivers/net/txgbe/txgbe_rxtx.c
@@ -61,6 +61,9 @@ static const u64 TXGBE_TX_OFFLOAD_MASK = (
                PKT_TX_TUNNEL_MASK |
                PKT_TX_OUTER_IP_CKSUM);
 
+#define TXGBE_TX_OFFLOAD_NOTSUP_MASK \
+               (PKT_TX_OFFLOAD_MASK ^ TXGBE_TX_OFFLOAD_MASK)
+
 #if 1
 #define RTE_PMD_USE_PREFETCH
 #endif
@@ -959,14 +962,55 @@ txgbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
        return nb_tx;
 }
 
+/*********************************************************************
+ *
+ *  TX prep functions
+ *
+ **********************************************************************/
 uint16_t
 txgbe_prep_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 {
-       RTE_SET_USED(tx_queue);
-       RTE_SET_USED(tx_pkts);
-       RTE_SET_USED(nb_pkts);
+       int i, ret;
+       uint64_t ol_flags;
+       struct rte_mbuf *m;
+       struct txgbe_tx_queue *txq = (struct txgbe_tx_queue *)tx_queue;
 
-       return 0;
+       for (i = 0; i < nb_pkts; i++) {
+               m = tx_pkts[i];
+               ol_flags = m->ol_flags;
+
+               /**
+                * Check if packet meets requirements for number of segments
+                *
+                * NOTE: for txgbe it's always (40 - WTHRESH) for both TSO and
+                *       non-TSO
+                */
+
+               if (m->nb_segs > TXGBE_TX_MAX_SEG - txq->wthresh) {
+                       rte_errno = -EINVAL;
+                       return i;
+               }
+
+               if (ol_flags & TXGBE_TX_OFFLOAD_NOTSUP_MASK) {
+                       rte_errno = -ENOTSUP;
+                       return i;
+               }
+
+#ifdef RTE_LIBRTE_ETHDEV_DEBUG
+               ret = rte_validate_tx_offload(m);
+               if (ret != 0) {
+                       rte_errno = ret;
+                       return i;
+               }
+#endif
+               ret = rte_net_intel_cksum_prepare(m);
+               if (ret != 0) {
+                       rte_errno = ret;
+                       return i;
+               }
+       }
+
+       return i;
 }
 
 /*********************************************************************
diff --git a/drivers/net/txgbe/txgbe_rxtx.h b/drivers/net/txgbe/txgbe_rxtx.h
index f9abb5ab8..296e34475 100644
--- a/drivers/net/txgbe/txgbe_rxtx.h
+++ b/drivers/net/txgbe/txgbe_rxtx.h
@@ -248,6 +248,8 @@ struct txgbe_tx_desc {
 #define RTE_TXGBE_REGISTER_POLL_WAIT_10_MS  10
 #define RTE_TXGBE_WAIT_100_US               100
 
+#define TXGBE_TX_MAX_SEG                    40
+
 /**
  * Structure associated with each descriptor of the RX ring of a RX queue.
  */
-- 
2.18.4



Reply via email to