[ovs-dev,v4,1/7] netdev-dpdk: Validate packets burst before Tx.
diff mbox series

Message ID 20190911081127.2140-2-michalx.obrembski@intel.com
State Superseded
Headers show
  • dpdk: Add support for TSO
Related show

Commit Message

Michal Obrembski Sept. 11, 2019, 8:11 a.m. UTC
From: Tiago Lam <tiago.lam@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

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


0-day Robot Sept. 11, 2019, 9:25 a.m. UTC | #1
Bleep bloop.  Greetings Obrembski, I am a robot and I have tried out your patch.
Thanks for your contribution.

I encountered some error that I wasn't expecting.  See the details below.

WARNING: Unexpected sign-offs from developers who are not authors or co-authors or committers: Michal Obrembski <michalx.obrembski@intel.com>
Lines checked: 69, Warnings: 1, Errors: 0

Please check this out.  If you feel there has been an error, please email aconole@redhat.com

0-day Robot

diff mbox series

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) {