svn commit: r362308 - stable/12/sys/dev/mlx5/mlx5_en

Hans Petter Selasky hselasky at FreeBSD.org
Thu Jun 18 10:19:37 UTC 2020


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);
 }


More information about the svn-src-stable mailing list