Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 19 Jun 2019 08:39:19 +0000 (UTC)
From:      Marko Zec <zec@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r349185 - head/sys/net
Message-ID:  <201906190839.x5J8dJIA068027@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: zec
Date: Wed Jun 19 08:39:19 2019
New Revision: 349185
URL: https://svnweb.freebsd.org/changeset/base/349185

Log:
  Evaluating htons() at compile time is more efficient than doing ntohs()
  at runtime.  This change removes a dependency on a barrel shifter pass
  before branch resolution, while reducing the instruction stream size
  by 9 bytes on amd64.
  
  MFC after:	3 days

Modified:
  head/sys/net/iflib.c

Modified: head/sys/net/iflib.c
==============================================================================
--- head/sys/net/iflib.c	Wed Jun 19 06:41:07 2019	(r349184)
+++ head/sys/net/iflib.c	Wed Jun 19 08:39:19 2019	(r349185)
@@ -2705,18 +2705,16 @@ static bool
 iflib_check_lro_possible(struct mbuf *m, bool v4_forwarding, bool v6_forwarding)
 {
 	struct ether_header *eh;
-	uint16_t eh_type;
 
 	eh = mtod(m, struct ether_header *);
-	eh_type = ntohs(eh->ether_type);
-	switch (eh_type) {
+	switch (eh->ether_type) {
 #if defined(INET6)
-		case ETHERTYPE_IPV6:
-			return !v6_forwarding;
+		case htons(ETHERTYPE_IPV6):
+			return (!v6_forwarding);
 #endif
 #if defined (INET)
-		case ETHERTYPE_IP:
-			return !v4_forwarding;
+		case htons(ETHERTYPE_IP):
+			return (!v4_forwarding);
 #endif
 	}
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201906190839.x5J8dJIA068027>