From owner-svn-src-all@freebsd.org Thu Jun 7 13:03:08 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 41D05FE6DF8; Thu, 7 Jun 2018 13:03:08 +0000 (UTC) (envelope-from erj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E79DA8F70B; Thu, 7 Jun 2018 13:03:07 +0000 (UTC) (envelope-from erj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C7FF4207E9; Thu, 7 Jun 2018 13:03:07 +0000 (UTC) (envelope-from erj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w57D37ww020738; Thu, 7 Jun 2018 13:03:07 GMT (envelope-from erj@FreeBSD.org) Received: (from erj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w57D37Hq020737; Thu, 7 Jun 2018 13:03:07 GMT (envelope-from erj@FreeBSD.org) Message-Id: <201806071303.w57D37Hq020737@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: erj set sender to erj@FreeBSD.org using -f From: Eric Joyner Date: Thu, 7 Jun 2018 13:03:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r334779 - head/sys/net X-SVN-Group: head X-SVN-Commit-Author: erj X-SVN-Commit-Paths: head/sys/net X-SVN-Commit-Revision: 334779 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Jun 2018 13:03:08 -0000 Author: erj Date: Thu Jun 7 13:03:07 2018 New Revision: 334779 URL: https://svnweb.freebsd.org/changeset/base/334779 Log: iflib: Record TCP checksum info in iflib when TCP checksum is requested ixl(4) (when it switches over to using iflib) devices need the TCP header length in order to do TCP checksum offload. Reviewed by: gallatin@, shurd@ MFC after: 1 week Sponsored by: Intel Corporation Differential Revision: https://reviews.freebsd.org/D15558 Modified: head/sys/net/iflib.c Modified: head/sys/net/iflib.c ============================================================================== --- head/sys/net/iflib.c Thu Jun 7 11:44:11 2018 (r334778) +++ head/sys/net/iflib.c Thu Jun 7 13:03:07 2018 (r334779) @@ -2822,7 +2822,9 @@ print_pkt(if_pkt_info_t pi) #endif #define IS_TSO4(pi) ((pi)->ipi_csum_flags & CSUM_IP_TSO) +#define IS_TX_OFFLOAD4(pi) ((pi)->ipi_csum_flags & (CSUM_IP_TCP | CSUM_IP_TSO)) #define IS_TSO6(pi) ((pi)->ipi_csum_flags & CSUM_IP6_TSO) +#define IS_TX_OFFLOAD6(pi) ((pi)->ipi_csum_flags & (CSUM_IP6_TCP | CSUM_IP6_TSO)) static int iflib_parse_header(iflib_txq_t txq, if_pkt_info_t pi, struct mbuf **mp) @@ -2908,8 +2910,9 @@ iflib_parse_header(iflib_txq_t txq, if_pkt_info_t pi, if ((sctx->isc_flags & IFLIB_NEED_ZERO_CSUM) && (pi->ipi_csum_flags & CSUM_IP)) ip->ip_sum = 0; - if (IS_TSO4(pi)) { - if (pi->ipi_ipproto == IPPROTO_TCP) { + /* TCP checksum offload may require TCP header length */ + if (IS_TX_OFFLOAD4(pi)) { + if (__predict_true(pi->ipi_ipproto == IPPROTO_TCP)) { if (__predict_false(th == NULL)) { txq->ift_pullups++; if (__predict_false((m = m_pullup(m, (ip->ip_hl << 2) + sizeof(*th))) == NULL)) @@ -2920,14 +2923,16 @@ iflib_parse_header(iflib_txq_t txq, if_pkt_info_t pi, pi->ipi_tcp_hlen = th->th_off << 2; pi->ipi_tcp_seq = th->th_seq; } - if (__predict_false(ip->ip_p != IPPROTO_TCP)) - return (ENXIO); - th->th_sum = in_pseudo(ip->ip_src.s_addr, - ip->ip_dst.s_addr, htons(IPPROTO_TCP)); - pi->ipi_tso_segsz = m->m_pkthdr.tso_segsz; - if (sctx->isc_flags & IFLIB_TSO_INIT_IP) { - ip->ip_sum = 0; - ip->ip_len = htons(pi->ipi_ip_hlen + pi->ipi_tcp_hlen + pi->ipi_tso_segsz); + if (IS_TSO4(pi)) { + if (__predict_false(ip->ip_p != IPPROTO_TCP)) + return (ENXIO); + th->th_sum = in_pseudo(ip->ip_src.s_addr, + ip->ip_dst.s_addr, htons(IPPROTO_TCP)); + pi->ipi_tso_segsz = m->m_pkthdr.tso_segsz; + if (sctx->isc_flags & IFLIB_TSO_INIT_IP) { + ip->ip_sum = 0; + ip->ip_len = htons(pi->ipi_ip_hlen + pi->ipi_tcp_hlen + pi->ipi_tso_segsz); + } } } break; @@ -2950,26 +2955,30 @@ iflib_parse_header(iflib_txq_t txq, if_pkt_info_t pi, pi->ipi_ipproto = ip6->ip6_nxt; pi->ipi_flags |= IPI_TX_IPV6; - if (IS_TSO6(pi)) { + /* TCP checksum offload may require TCP header length */ + if (IS_TX_OFFLOAD6(pi)) { if (pi->ipi_ipproto == IPPROTO_TCP) { if (__predict_false(m->m_len < pi->ipi_ehdrlen + sizeof(struct ip6_hdr) + sizeof(struct tcphdr))) { + txq->ift_pullups++; if (__predict_false((m = m_pullup(m, pi->ipi_ehdrlen + sizeof(struct ip6_hdr) + sizeof(struct tcphdr))) == NULL)) return (ENOMEM); } pi->ipi_tcp_hflags = th->th_flags; pi->ipi_tcp_hlen = th->th_off << 2; + pi->ipi_tcp_seq = th->th_seq; } - - if (__predict_false(ip6->ip6_nxt != IPPROTO_TCP)) - return (ENXIO); - /* - * The corresponding flag is set by the stack in the IPv4 - * TSO case, but not in IPv6 (at least in FreeBSD 10.2). - * So, set it here because the rest of the flow requires it. - */ - pi->ipi_csum_flags |= CSUM_TCP_IPV6; - th->th_sum = in6_cksum_pseudo(ip6, 0, IPPROTO_TCP, 0); - pi->ipi_tso_segsz = m->m_pkthdr.tso_segsz; + if (IS_TSO6(pi)) { + if (__predict_false(ip6->ip6_nxt != IPPROTO_TCP)) + return (ENXIO); + /* + * The corresponding flag is set by the stack in the IPv4 + * TSO case, but not in IPv6 (at least in FreeBSD 10.2). + * So, set it here because the rest of the flow requires it. + */ + pi->ipi_csum_flags |= CSUM_IP6_TCP; + th->th_sum = in6_cksum_pseudo(ip6, 0, IPPROTO_TCP, 0); + pi->ipi_tso_segsz = m->m_pkthdr.tso_segsz; + } } break; }