Subject: dev/ic/am7990.c
To: None <thorpej@NetBSD.ORG>
From: Gordon W. Ross <gwr@mc.com>
List: tech-net
Date: 05/10/1996 13:17:20
Hi Jason,
In the file dev/ic/am7990.c your comment asks:
/* XXX what do we do about this?! --thorpej */
I'm pretty sure the following code will work on any machine
(even the sparc) because the memory addresses passed to this
are always aligned to at least a 2-byte boundary. Therefore,
we could just enable it for all machines. Alternatively, we
could make this a real MD function like oc_cksum() and such,
but I think using an inline like this will be faster.
Note that the avoidance of branches in this implementation is
largely responsible for reducing the generated code. My hope
was also to avoid pipelines stalls where that is an issue.
Does anyone see problems with enabling the code section below?
Should we include this in any other ethernet drivers?
Gordon
#if 0 /* XXX what do we do about this?! --thorpej */
static inline u_int16_t ether_cmp __P((void *, void *));
/*
* Compare two Ether/802 addresses for equality, inlined and
* unrolled for speed. I'd love to have an inline assembler
* version of this... XXX: Who wanted that? mycroft?
* I wrote one, but the following is just as efficient.
* This expands to 10 short m68k instructions! -gwr
* Note: use this like bcmp()
*/
static inline u_short
ether_cmp(one, two)
void *one, *two;
{
register u_int16_t *a = (u_short *) one;
register u_int16_t *b = (u_short *) two;
register u_int16_t diff;
diff = *a++ - *b++;
diff |= *a++ - *b++;
diff |= *a++ - *b++;
return (diff);
}
#define ETHER_CMP ether_cmp
#endif /* XXX */
#ifndef ETHER_CMP
#define ETHER_CMP(a, b) bcmp((a), (b), ETHER_ADDR_LEN)
#endif