dpdk: do not use TSO for small packets 88/30188/12
authorSomnath Kotur <somnath.kotur@broadcom.com>
Mon, 30 Nov 2020 02:54:45 +0000 (08:24 +0530)
committerDamjan Marion <dmarion@me.com>
Thu, 21 Jan 2021 13:40:42 +0000 (13:40 +0000)
Asking for TSO (TCP Segmentation Offload) on packets that are already
smaller than (headers + MSS) does not make sense and may not work
on some HW.
Fix to only set the TSO flag when a segmentation offload is
really required, i.e when packet is large enough.

Type: improvement

Signed-off-by: Somnath Kotur <somnath.kotur@broadcom.com>
Change-Id: I7830ae8474581c8e518fb4910f7863e10346bb62
Signed-off-by: Somnath Kotur <somnath.kotur@broadcom.com>
src/plugins/dpdk/device/device.c

index 4d26abd..ec33f6a 100644 (file)
@@ -222,7 +222,7 @@ dpdk_buffer_tx_offload (dpdk_device_t * xd, vlib_buffer_t * b,
   u32 tcp_cksum = b->flags & VNET_BUFFER_F_OFFLOAD_TCP_CKSUM;
   u32 udp_cksum = b->flags & VNET_BUFFER_F_OFFLOAD_UDP_CKSUM;
   int is_ip4 = b->flags & VNET_BUFFER_F_IS_IP4;
-  u32 tso = b->flags & VNET_BUFFER_F_GSO;
+  u32 tso = b->flags & VNET_BUFFER_F_GSO, max_pkt_len;
   u64 ol_flags;
 
   /* Is there any work for us? */
@@ -238,12 +238,15 @@ dpdk_buffer_tx_offload (dpdk_device_t * xd, vlib_buffer_t * b,
   ol_flags |= ip_cksum ? PKT_TX_IP_CKSUM : 0;
   ol_flags |= tcp_cksum ? PKT_TX_TCP_CKSUM : 0;
   ol_flags |= udp_cksum ? PKT_TX_UDP_CKSUM : 0;
-  ol_flags |= tso ? (tcp_cksum ? PKT_TX_TCP_SEG : PKT_TX_UDP_SEG) : 0;
 
   if (tso)
     {
       mb->l4_len = vnet_buffer2 (b)->gso_l4_hdr_sz;
       mb->tso_segsz = vnet_buffer2 (b)->gso_size;
+      /* ensure packet is large enough to require tso */
+      max_pkt_len = mb->l2_len + mb->l3_len + mb->l4_len + mb->tso_segsz;
+      if (mb->tso_segsz != 0 && mb->pkt_len > max_pkt_len)
+       ol_flags |= (tcp_cksum ? PKT_TX_TCP_SEG : PKT_TX_UDP_SEG);
     }
 
   mb->ol_flags |= ol_flags;