[ovs-dev] [PATCH v4 1/7] netdev-dpdk: Validate packets burst before Tx.

Michal Obrembski michalx.obrembski at intel.com
Wed Sep 11 14:09:59 UTC 2019


From: Tiago Lam <tiago.lam at intel.com>

Given that multi-segment mbufs might be sent between interfaces that
support different capabilities, and may even support different layouts
of mbufs, outgoing packets should be validated before sent on the egress
interface. Thus, netdev_dpdk_eth_tx_burst() now calls DPDK's
rte_eth_tx_prepare() function, if and only multi-segments is enbaled, in
order to validate the following (taken from the DPDK documentation), on
a device specific manner:
- Check if packet meets devices requirements for tx offloads.
- Check limitations about number of segments.
- Check additional requirements when debug is enabled.
- Update and/or reset required checksums when tx offload is set for
packet.

Signed-off-by: Tiago Lam <tiago.lam at intel.com>
---
 lib/netdev-dpdk.c | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index 084a54e..6797081 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -2106,6 +2106,10 @@ netdev_dpdk_rxq_dealloc(struct netdev_rxq *rxq)
 
 /* Tries to transmit 'pkts' to txq 'qid' of device 'dev'.  Takes ownership of
  * 'pkts', even in case of failure.
+ * In case multi-segment mbufs / TSO is being used, it also prepares. In such
+ * cases, only the prepared packets will be sent to Tx burst, meaning that if
+ * an invalid packet appears in 'pkts'[3] only the validated packets in indices
+ * 0, 1 and 2 will be sent.
  *
  * Returns the number of packets that weren't transmitted. */
 static inline int
@@ -2113,11 +2117,24 @@ netdev_dpdk_eth_tx_burst(struct netdev_dpdk *dev, int qid,
                          struct rte_mbuf **pkts, int cnt)
 {
     uint32_t nb_tx = 0;
+    uint16_t nb_prep = cnt;
+
+    /* If multi-segments is enabled, validate the burst of packets for Tx. */
+    if (OVS_UNLIKELY(dpdk_multi_segment_mbufs)) {
+        nb_prep = rte_eth_tx_prepare(dev->port_id, qid, pkts, cnt);
+        if (nb_prep != cnt) {
+            VLOG_WARN_RL(&rl, "%s: Preparing packet tx burst failed (%u/%u "
+                         "packets valid): %s", dev->up.name, nb_prep, cnt,
+                         rte_strerror(rte_errno));
+        }
+    }
 
-    while (nb_tx != cnt) {
+    /* Tx the validated burst of packets only. */
+    while (nb_tx != nb_prep) {
         uint32_t ret;
 
-        ret = rte_eth_tx_burst(dev->port_id, qid, pkts + nb_tx, cnt - nb_tx);
+        ret = rte_eth_tx_burst(dev->port_id, qid, pkts + nb_tx,
+                               nb_prep - nb_tx);
         if (!ret) {
             break;
         }
-- 
2.7.4



More information about the dev mailing list