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.
Alexander Motin
mav at FreeBSD.org
Thu Jan 7 18:20:44 UTC 2021
The branch stable/12 has been updated by mav:
URL: https://cgit.FreeBSD.org/src/commit/?id=896ccd678d1837f7c39b4c0a617a081f2c168443
commit 896ccd678d1837f7c39b4c0a617a081f2c168443
Author: Marko Zec <zec at FreeBSD.org>
AuthorDate: 2019-06-19 08:39:19 +0000
Commit: Alexander Motin <mav at 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
}
More information about the dev-commits-src-all
mailing list