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
This commit is contained in:
Marko Zec 2019-06-19 08:39:19 +00:00
parent da761f3b1f
commit 6aee0bfa85
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=349185

View File

@ -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
}