From owner-svn-src-stable@freebsd.org Thu Jun 18 10:20:16 2020 Return-Path: Delivered-To: svn-src-stable@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BC93834B409; Thu, 18 Jun 2020 10:20:16 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49ndH44YN7z4SKW; Thu, 18 Jun 2020 10:20:16 +0000 (UTC) (envelope-from hselasky@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 9787A2FBCD; Thu, 18 Jun 2020 10:20:16 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 05IAKGUs063555; Thu, 18 Jun 2020 10:20:16 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 05IAKGr5063554; Thu, 18 Jun 2020 10:20:16 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <202006181020.05IAKGr5063554@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Thu, 18 Jun 2020 10:20:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r362309 - stable/11/sys/dev/mlx5/mlx5_en X-SVN-Group: stable-11 X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: stable/11/sys/dev/mlx5/mlx5_en X-SVN-Commit-Revision: 362309 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Jun 2020 10:20:16 -0000 Author: hselasky Date: Thu Jun 18 10:20:16 2020 New Revision: 362309 URL: https://svnweb.freebsd.org/changeset/base/362309 Log: MFC r362044: Extend use of unlikely() in the fast path, in mlx5en(4). Typically the TCP/IP headers fit within the first mbuf and should not trigger any of the error cases. Use unlikely() for these cases. No functional change. Sponsored by: Mellanox Technologies Modified: stable/11/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c ============================================================================== --- stable/11/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c Thu Jun 18 10:19:37 2020 (r362308) +++ stable/11/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c Thu Jun 18 10:20:16 2020 (r362309) @@ -193,10 +193,10 @@ mlx5e_get_full_header_size(const struct mbuf *mb) int eth_hdr_len; eh = mtod(mb, const struct ether_vlan_header *); - if (mb->m_len < ETHER_HDR_LEN) + if (unlikely(mb->m_len < ETHER_HDR_LEN)) return (0); if (eh->evl_encap_proto == htons(ETHERTYPE_VLAN)) { - if (mb->m_len < (ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN)) + if (unlikely(mb->m_len < (ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN))) return (0); eth_type = ntohs(eh->evl_proto); eth_hdr_len = ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN; @@ -207,7 +207,7 @@ mlx5e_get_full_header_size(const struct mbuf *mb) switch (eth_type) { case ETHERTYPE_IP: ip = (const struct ip *)(mb->m_data + eth_hdr_len); - if (mb->m_len < eth_hdr_len + sizeof(*ip)) + if (unlikely(mb->m_len < eth_hdr_len + sizeof(*ip))) return (0); switch (ip->ip_p) { case IPPROTO_TCP: @@ -224,7 +224,7 @@ mlx5e_get_full_header_size(const struct mbuf *mb) break; case ETHERTYPE_IPV6: ip6 = (const struct ip6_hdr *)(mb->m_data + eth_hdr_len); - if (mb->m_len < eth_hdr_len + sizeof(*ip6)) + if (unlikely(mb->m_len < eth_hdr_len + sizeof(*ip6))) return (0); switch (ip6->ip6_nxt) { case IPPROTO_TCP: @@ -240,7 +240,7 @@ mlx5e_get_full_header_size(const struct mbuf *mb) default: return (0); } - if (mb->m_len < eth_hdr_len + sizeof(*th)) + if (unlikely(mb->m_len < eth_hdr_len + sizeof(*th))) return (0); th = (const struct tcphdr *)(mb->m_data + eth_hdr_len); tcp_hlen = th->th_off << 2; @@ -251,7 +251,7 @@ done: * does not need to reside within the first m_len bytes of * data: */ - if (mb->m_pkthdr.len < eth_hdr_len) + if (unlikely(mb->m_pkthdr.len < eth_hdr_len)) return (0); return (eth_hdr_len); }