From owner-svn-src-stable-12@freebsd.org Thu Jun 18 10:19:37 2020 Return-Path: Delivered-To: svn-src-stable-12@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 9987934B1ED; Thu, 18 Jun 2020 10:19:37 +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 49ndGK3Y4tz4S3c; Thu, 18 Jun 2020 10:19:37 +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 7509C2FF85; Thu, 18 Jun 2020 10:19:37 +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 05IAJb6Q063425; Thu, 18 Jun 2020 10:19:37 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 05IAJbtv063424; Thu, 18 Jun 2020 10:19:37 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <202006181019.05IAJbtv063424@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:19:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r362308 - stable/12/sys/dev/mlx5/mlx5_en X-SVN-Group: stable-12 X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: stable/12/sys/dev/mlx5/mlx5_en X-SVN-Commit-Revision: 362308 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-12@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Jun 2020 10:19:37 -0000 Author: hselasky Date: Thu Jun 18 10:19:37 2020 New Revision: 362308 URL: https://svnweb.freebsd.org/changeset/base/362308 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/12/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c ============================================================================== --- stable/12/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c Thu Jun 18 10:17:36 2020 (r362307) +++ stable/12/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c Thu Jun 18 10:19:37 2020 (r362308) @@ -234,10 +234,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; @@ -248,7 +248,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: @@ -265,7 +265,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: @@ -281,7 +281,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; @@ -292,7 +292,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); }