Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 7 Jan 2021 18:20:44 GMT
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 896ccd678d18 - stable/12 - 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.
Message-ID:  <202101071820.107IKi6N073876@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/12 has been updated by mav:

URL: https://cgit.FreeBSD.org/src/commit/?id=896ccd678d1837f7c39b4c0a617a081f2c168443

commit 896ccd678d1837f7c39b4c0a617a081f2c168443
Author:     Marko Zec <zec@FreeBSD.org>
AuthorDate: 2019-06-19 08:39:19 +0000
Commit:     Alexander Motin <mav@FreeBSD.org>
CommitDate: 2021-01-07 17:41:12 +0000

    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.
    
    (cherry picked from commit 6aee0bfa85685017dbc5050ce36793f7dcd80f82)
---
 sys/net/iflib.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/sys/net/iflib.c b/sys/net/iflib.c
index 24f23a338411..4b5e73ce08e0 100644
--- a/sys/net/iflib.c
+++ b/sys/net/iflib.c
@@ -2784,18 +2784,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?202101071820.107IKi6N073876>