-/* $OpenBSD: if_ed.c,v 1.9 1997/01/16 09:24:40 niklas Exp $ */
+/* $OpenBSD: if_ed.c,v 1.10 1997/02/21 11:08:48 niklas Exp $ */
/* $NetBSD: if_ed.c,v 1.24 1996/12/23 09:10:16 veego Exp $ */
/*
* the author responsible for the proper functioning of this software, nor does
* the author assume any responsibility for damages incurred with its use.
*
- * Currently supports the Hydra Systems ethernet card.
+ * Currently supports the Hydra Systems and ASDG ethernet cards.
*/
#include "bpfilter.h"
void ed_getmcaf __P((struct arpcom *, u_long *));
u_short ed_put __P((struct ed_softc *, struct mbuf *, caddr_t));
-#define inline /* XXX for debugging porpoises */
+#define inline /* XXX for debugging purposes */
void ed_get_packet __P((struct ed_softc *, caddr_t, u_short));
static inline void ed_rint __P((struct ed_softc *));
{
u_int8_t boundary, current;
u_int16_t len;
- u_int16_t count;
u_int8_t nlen;
+ u_int8_t next_packet; /* pointer to next packet */
+ u_int16_t count; /* bytes in packet (length + 4) */
u_int8_t packet_hdr[ED_RING_HDRSZ];
caddr_t packet_ptr;
* the NIC.
*/
bcopy(packet_ptr, packet_hdr, ED_RING_HDRSZ);
+ next_packet = packet_hdr[ED_RING_NEXT_PACKET];
len = count = packet_hdr[ED_RING_COUNT] +
256 * packet_hdr[ED_RING_COUNT + 1];
/*
*
* NOTE: sc->next_packet is pointing at the current packet.
*/
- if (packet_hdr[ED_RING_NEXT_PACKET] >= sc->next_packet)
- nlen = (packet_hdr[ED_RING_NEXT_PACKET] -
- sc->next_packet);
+ if (next_packet >= sc->next_packet)
+ nlen = next_packet - sc->next_packet;
else
- nlen = ((packet_hdr[ED_RING_NEXT_PACKET] -
- sc->rec_page_start) + (sc->rec_page_stop -
- sc->next_packet));
+ nlen = next_packet - sc->rec_page_start +
+ sc->rec_page_stop - sc->next_packet;
--nlen;
if ((len & ED_PAGE_MASK) + ED_RING_HDRSZ > ED_PAGE_SIZE)
--nlen;
* important is that we have a length that will fit into one
* mbuf cluster or less; the upper layer protocols can then
* figure out the length from their own length field(s).
- *
- * MCLBYTES may be less than a valid packet len. Thus
- * we use a constant that is large enough.
*/
- if (len <= 2048 &&
- packet_hdr[ED_RING_NEXT_PACKET] >= sc->rec_page_start &&
- packet_hdr[ED_RING_NEXT_PACKET] < sc->rec_page_stop) {
+ if (len <= MCLBYTES && next_packet >= sc->rec_page_start &&
+ next_packet < sc->rec_page_stop) {
/* Go get packet. */
ed_get_packet(sc, packet_ptr + ED_RING_HDRSZ,
len - ED_RING_HDRSZ);
}
/* Update next packet pointer. */
- sc->next_packet = packet_hdr[ED_RING_NEXT_PACKET];
+ sc->next_packet = next_packet;
/*
* Update NIC boundary pointer - being careful to keep it one