From owner-svn-src-all@freebsd.org Thu Jun 11 09:38:51 2020 Return-Path: Delivered-To: svn-src-all@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 E744F328753; Thu, 11 Jun 2020 09:38:51 +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 49jJhW5pjzz4K8w; Thu, 11 Jun 2020 09:38:51 +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 C2C9B16026; Thu, 11 Jun 2020 09:38:51 +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 05B9cpqB031156; Thu, 11 Jun 2020 09:38:51 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 05B9cpdE031155; Thu, 11 Jun 2020 09:38:51 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <202006110938.05B9cpdE031155@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Thu, 11 Jun 2020 09:38:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r362044 - head/sys/dev/mlx5/mlx5_en X-SVN-Group: head X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: head/sys/dev/mlx5/mlx5_en X-SVN-Commit-Revision: 362044 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.33 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, 11 Jun 2020 09:38:52 -0000 Author: hselasky Date: Thu Jun 11 09:38:51 2020 New Revision: 362044 URL: https://svnweb.freebsd.org/changeset/base/362044 Log: 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. MFC after: 1 week Sponsored by: Mellanox Technologies Modified: head/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c Modified: head/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c ============================================================================== --- head/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c Thu Jun 11 09:36:37 2020 (r362043) +++ head/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c Thu Jun 11 09:38:51 2020 (r362044) @@ -256,10 +256,10 @@ mlx5e_get_full_header_size(const struct mbuf *mb, cons 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)) goto failure; 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))) goto failure; eth_type = ntohs(eh->evl_proto); eth_hdr_len = ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN; @@ -271,7 +271,7 @@ mlx5e_get_full_header_size(const struct mbuf *mb, cons 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))) goto failure; switch (ip->ip_p) { case IPPROTO_TCP: @@ -289,7 +289,7 @@ mlx5e_get_full_header_size(const struct mbuf *mb, cons 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))) goto failure; switch (ip6->ip6_nxt) { case IPPROTO_TCP: @@ -307,7 +307,7 @@ mlx5e_get_full_header_size(const struct mbuf *mb, cons goto failure; } tcp_packet: - if (mb->m_len < eth_hdr_len + sizeof(*th)) + if (unlikely(mb->m_len < eth_hdr_len + sizeof(*th))) goto failure; th = (const struct tcphdr *)(mb->m_data + eth_hdr_len); tcp_hlen = th->th_off << 2; @@ -318,7 +318,7 @@ udp_packet: * 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)) goto failure; if (ppth != NULL) *ppth = th;