From: Somnath Kotur Date: Mon, 30 Nov 2020 02:54:45 +0000 (+0530) Subject: dpdk: do not use TSO for small packets X-Git-Tag: v21.10-rc0~673 X-Git-Url: https://gerrit.fd.io/r/gitweb?a=commitdiff_plain;h=09332e9bc09748dd7eea564cb47f70863374ebf8;p=vpp.git dpdk: do not use TSO for small packets 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 Change-Id: I7830ae8474581c8e518fb4910f7863e10346bb62 Signed-off-by: Somnath Kotur --- diff --git a/src/plugins/dpdk/device/device.c b/src/plugins/dpdk/device/device.c index 4d26abde214..ec33f6a4461 100644 --- a/src/plugins/dpdk/device/device.c +++ b/src/plugins/dpdk/device/device.c @@ -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;