Date: Thu, 11 Jun 2020 09:38:51 +0000 (UTC) From: Hans Petter Selasky <hselasky@FreeBSD.org> 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 Message-ID: <202006110938.05B9cpdE031155@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202006110938.05B9cpdE031155>