diff options
author | dg <dg@FreeBSD.org> | 1994-11-24 14:29:38 +0000 |
---|---|---|
committer | dg <dg@FreeBSD.org> | 1994-11-24 14:29:38 +0000 |
commit | 68acac5e7669e7382032efb3be686d7d31127ff7 (patch) | |
tree | f24c94cbed7412ca371d1f76bc07b9dfdcdbc432 /sys/dev/ep | |
parent | 72223a20dbcc102ebb53c5b477fb878dadf67674 (diff) | |
download | FreeBSD-src-68acac5e7669e7382032efb3be686d7d31127ff7.zip FreeBSD-src-68acac5e7669e7382032efb3be686d7d31127ff7.tar.gz |
Moved conversion of ether_type to host byte order out of ethernet drivers
and into ether_input(). It was silly to have bpf want this one way and
ether_input want it another way. Ripped out trailer support from the few
remaining drivers that still had it.
Diffstat (limited to 'sys/dev/ep')
-rw-r--r-- | sys/dev/ep/if_ep.c | 94 |
1 files changed, 1 insertions, 93 deletions
diff --git a/sys/dev/ep/if_ep.c b/sys/dev/ep/if_ep.c index 9534182..f73c9a6 100644 --- a/sys/dev/ep/if_ep.c +++ b/sys/dev/ep/if_ep.c @@ -52,10 +52,6 @@ * used while working on this driver and the program that displays this * information (epstat). * - * NB 2: About trailers, I didn't care if this implementation was OK, I just - * adapted it to have the same behaviour as in the original driver (donne - * just for epread()). - * * * Some driver statistics can be viewed with the epstat utility. In order to * use this, you have to compile if_ep.c with @@ -812,62 +808,7 @@ startagain: #if NBPFILTER > 0 if (sc->bpf) { - u_short etype; - int off, datasize, resid; - struct ether_header *eh; - struct trailer_header { - u_short ether_type; - u_short ether_residual; - } trailer_header; - char ether_packet[ETHER_MAX_LEN]; - char *ep; - - ep = ether_packet; - - /* - * We handle trailers below: Copy ether header first, then residual - * data, then data. Put all this in a temporary buffer 'ether_packet' - * and send off to bpf. Since the system has generated this packet, - * we assume that all of the offsets in the packet are correct; if - * they're not, the system will almost certainly crash in m_copydata. - * We make no assumptions about how the data is arranged in the mbuf - * chain (i.e. how much data is in each mbuf, if mbuf clusters are - * used, etc.), which is why we use m_copydata to get the ether - * header rather than assume that this is located in the first mbuf. - */ - /* copy ether header */ - m_copydata(top, 0, sizeof(struct ether_header), ep); - eh = (struct ether_header *) ep; - ep += sizeof(struct ether_header); - eh->ether_type = etype = ntohs(eh->ether_type); - if (etype >= ETHERTYPE_TRAIL && - etype < ETHERTYPE_TRAIL + ETHERTYPE_NTRAILER) { - datasize = ((etype - ETHERTYPE_TRAIL) << 9); - off = datasize + sizeof(struct ether_header); - - /* copy trailer_header into a data structure */ - m_copydata(top, off, sizeof(struct trailer_header), - (caddr_t) & trailer_header.ether_type); - - /* copy residual data */ - resid = trailer_header.ether_residual - - sizeof(struct trailer_header); - resid = ntohs(resid); - m_copydata(top, off + sizeof(struct trailer_header), - resid, ep); - ep += resid; - - /* copy data */ - m_copydata(top, sizeof(struct ether_header), - datasize, ep); - ep += datasize; - - /* restore original ether packet type */ - eh->ether_type = trailer_header.ether_type; - - bpf_tap(sc->bpf, ether_packet, ep - ether_packet); - } else - bpf_mtap(sc->bpf, top); + bpf_mtap(sc->bpf, top); } #endif @@ -998,12 +939,7 @@ epread(sc) short rx_fifo2, status; register short delta; register short rx_fifo; - u_short etype; - /* - * XXX I have just adapted the code for the protocol trailing processing - * as programed in the original driver. FreeBSD 1.1.5.1 release - */ status = inw(BASE + EP_W1_RX_STATUS); read_again: @@ -1050,34 +986,6 @@ read_again: top->m_len = sizeof(struct ether_header); rx_fifo -= sizeof(struct ether_header); sc->cur_len = rx_fifo2; - - /* - * Test for trailers. - * I didn't care if this implementation was OK, I just adapted it to - * have the same behaviour as in the original driver - */ - eh = mtod(top, struct ether_header *); - etype = eh->ether_type = ntohs((u_short) eh->ether_type); - if (etype >= ETHERTYPE_TRAIL && - etype < ETHERTYPE_TRAIL + ETHERTYPE_NTRAILER) { - if ((etype - ETHERTYPE_TRAIL) * 512 >= ETHERMTU) - goto out; - m->m_data = m->m_dat; /* Convert back to regular mbuf. */ - m->m_flags = 0; /* This sucks but non-trailers are the norm */ - m->m_data += 2 * sizeof(u_short); /* Get rid of type & len */ - - sc->cur_len = sizeof(struct ether_header); - ep_fset(F_RX_TRAILER); - - /* in the case of trailers, we prefer to have the packet complete */ - if (status & ERR_RX_INCOMPLETE) { - ep_frst(F_RX_FIRST); - outw(BASE + EP_COMMAND, SET_RX_EARLY_THRESH | 2032); /* disable */ - return; - } else - /* We don't read the trailer, next we are reading the data */ - rx_fifo -= sizeof(struct ether_header); - } } else { /* come here if we didn't have a complete packet last time */ top = sc->top; |