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
        }
 
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to