From owner-svn-src-head@FreeBSD.ORG Mon Jun 9 02:45:54 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 5526AE18; Mon, 9 Jun 2014 02:45:54 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 423A4207A; Mon, 9 Jun 2014 02:45:54 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s592jsqC015202; Mon, 9 Jun 2014 02:45:54 GMT (envelope-from bryanv@svn.freebsd.org) Received: (from bryanv@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s592jspf015201; Mon, 9 Jun 2014 02:45:54 GMT (envelope-from bryanv@svn.freebsd.org) Message-Id: <201406090245.s592jspf015201@svn.freebsd.org> From: Bryan Venteicher Date: Mon, 9 Jun 2014 02:45:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r267253 - head/sys/dev/vmware/vmxnet3 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Jun 2014 02:45:54 -0000 Author: bryanv Date: Mon Jun 9 02:45:53 2014 New Revision: 267253 URL: http://svnweb.freebsd.org/changeset/base/267253 Log: Fix TSO support on VMware Fusion Apparently for VMware Fusion (and presumably VMware Workstation/Player since the PR states TSO is broken there too, but I cannot test), the TCP header pseudo checksum calculated should only include the protocol (IPPROTO_TCP) value, not also the lengths as the stack does instead. VMware ESXi seems to ignore whatever value is in the TCP header checksum, and it is a bit surprising there is a different behavior between the VMware products. And it is unfortunate that on ESXi we are forced to do this extra bit of work. PR: kern/185849 MFC after: 3 days Modified: head/sys/dev/vmware/vmxnet3/if_vmx.c Modified: head/sys/dev/vmware/vmxnet3/if_vmx.c ============================================================================== --- head/sys/dev/vmware/vmxnet3/if_vmx.c Mon Jun 9 02:39:05 2014 (r267252) +++ head/sys/dev/vmware/vmxnet3/if_vmx.c Mon Jun 9 02:45:53 2014 (r267253) @@ -57,6 +57,8 @@ __FBSDID("$FreeBSD$"); #include #include +#include + #include #include #include @@ -2604,6 +2606,12 @@ vmxnet3_txq_offload_ctx(struct vmxnet3_t { struct ether_vlan_header *evh; int offset; +#if defined(INET) + struct ip *ip, iphdr; +#endif +#if defined(INET6) + struct ip6_hdr *ip6, ip6hdr; +#endif evh = mtod(m, struct ether_vlan_header *); if (evh->evl_encap_proto == htons(ETHERTYPE_VLAN)) { @@ -2617,8 +2625,7 @@ vmxnet3_txq_offload_ctx(struct vmxnet3_t switch (*etype) { #if defined(INET) - case ETHERTYPE_IP: { - struct ip *ip, iphdr; + case ETHERTYPE_IP: if (__predict_false(m->m_len < offset + sizeof(struct ip))) { m_copydata(m, offset, sizeof(struct ip), (caddr_t) &iphdr); @@ -2628,10 +2635,16 @@ vmxnet3_txq_offload_ctx(struct vmxnet3_t *proto = ip->ip_p; *start = offset + (ip->ip_hl << 2); break; - } #endif #if defined(INET6) case ETHERTYPE_IPV6: + if (__predict_false(m->m_len < + offset + sizeof(struct ip6_hdr))) { + m_copydata(m, offset, sizeof(struct ip6_hdr), + (caddr_t) &ip6hdr); + ip6 = &ip6hdr; + } else + ip6 = mtodo(m, offset); *proto = -1; *start = ip6_lasthdr(m, offset, IPPROTO_IPV6, proto); /* Assert the network stack sent us a valid packet. */ @@ -2646,6 +2659,7 @@ vmxnet3_txq_offload_ctx(struct vmxnet3_t if (m->m_pkthdr.csum_flags & CSUM_TSO) { struct tcphdr *tcp, tcphdr; + uint16_t sum; if (__predict_false(*proto != IPPROTO_TCP)) { /* Likely failed to correctly parse the mbuf. */ @@ -2654,16 +2668,38 @@ vmxnet3_txq_offload_ctx(struct vmxnet3_t txq->vxtxq_stats.vmtxs_tso++; - /* - * For TSO, the size of the protocol header is also - * included in the descriptor header size. - */ + switch (*etype) { +#if defined(INET) + case ETHERTYPE_IP: + sum = in_pseudo(ip->ip_src.s_addr, ip->ip_dst.s_addr, + htons(IPPROTO_TCP)); + break; +#endif +#if defined(INET6) + case ETHERTYPE_IPV6: + sum = in6_cksum_pseudo(ip6, 0, IPPROTO_TCP, 0); + break; +#endif + default: + sum = 0; + break; + } + if (m->m_len < *start + sizeof(struct tcphdr)) { - m_copydata(m, offset, sizeof(struct tcphdr), + m_copyback(m, *start + offsetof(struct tcphdr, th_sum), + sizeof(uint16_t), (caddr_t) &sum); + m_copydata(m, *start, sizeof(struct tcphdr), (caddr_t) &tcphdr); tcp = &tcphdr; - } else + } else { tcp = mtodo(m, *start); + tcp->th_sum = sum; + } + + /* + * For TSO, the size of the protocol header is also + * included in the descriptor header size. + */ *start += (tcp->th_off << 2); } else txq->vxtxq_stats.vmtxs_csum++;