Megacommit to straigthen out ETHER_ mess.

I'm pretty convinced after looking at this that the majority of our
drivers are confused about the in/exclusion of ETHER_CRC_LEN :-(
This commit is contained in:
Poul-Henning Kamp 1996-08-06 21:14:36 +00:00
parent 590dbfbf6a
commit 26a8b0bf7e
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=17455
25 changed files with 156 additions and 209 deletions

View File

@ -24,7 +24,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: if_ed.c,v 1.101 1996/06/25 20:30:05 bde Exp $
* $Id: if_ed.c,v 1.102 1996/08/04 10:57:29 phk Exp $
*/
/*
@ -325,11 +325,6 @@ static unsigned short ed_790_intr_mask[] = {
IRQ15
};
#define ETHER_MIN_LEN 60
#define ETHER_MAX_LEN 1514
#define ETHER_ADDR_LEN 6
#define ETHER_HDR_SIZE 14
static struct kern_devconf kdc_ed_template = {
0, 0, 0, /* filled in by dev_attach */
"ed", 0, { MDDT_ISA, 0, "net" },
@ -1944,7 +1939,7 @@ ed_start(ifp)
goto outloop;
}
sc->txb_len[sc->txb_new] = max(len, ETHER_MIN_LEN);
sc->txb_len[sc->txb_new] = max(len, (ETHER_MIN_LEN-ETHER_CRC_LEN));
sc->txb_inuse++;
@ -2020,8 +2015,8 @@ ed_rint(sc)
ed_pio_readmem(sc, (int)packet_ptr, (char *) &packet_hdr,
sizeof(packet_hdr));
len = packet_hdr.count;
if (len > (ETHER_MAX_LEN + sizeof(struct ed_ring)) ||
len < (ETHER_HDR_SIZE + sizeof(struct ed_ring))) {
if (len > (ETHER_MAX_LEN - ETHER_CRC_LEN + sizeof(struct ed_ring)) ||
len < (ETHER_MIN_LEN - ETHER_CRC_LEN + sizeof(struct ed_ring))) {
/*
* Length is a wild value. There's a good chance that
* this was caused by the NIC being old and buggy.

View File

@ -31,7 +31,7 @@
*/
/*
* $Id: if_epreg.h,v 1.14 1996/06/14 22:11:38 nate Exp $
* $Id: if_epreg.h,v 1.15 1996/07/19 13:20:05 amurai Exp $
*
* Promiscuous mode added and interrupt logic slightly changed
* to reduce the number of adapter failures. Transceiver select
@ -107,10 +107,6 @@ struct ep_board {
/*
* Some global constants
*/
#define ETHER_MIN_LEN 64
#define ETHER_MAX_LEN 1518
#define ETHER_ADDR_LEN 6
#define TX_INIT_RATE 16
#define TX_INIT_MAX_RATE 64
#define RX_INIT_LATENCY 64
@ -455,8 +451,6 @@ struct ep_board {
#define BNC 0x2
#define UTP 0x4
#define ETHER_ADDR_LEN 6
#define ETHER_MAX 1536
#define RX_BYTES_MASK (u_short) (0x07ff)
extern struct ep_board ep_board[];

View File

@ -21,7 +21,7 @@
*/
/*
* $Id: if_fe.c,v 1.15 1996/06/12 05:03:40 gpalmer Exp $
* $Id: if_fe.c,v 1.16 1996/06/18 01:22:21 bde Exp $
*
* Device driver for Fujitsu MB86960A/MB86965A based Ethernet cards.
* To be used with FreeBSD 2.x
@ -272,14 +272,6 @@ static void fe_loadmar ( struct fe_softc * );
static void fe_dump ( int, struct fe_softc *, char * );
#endif
/* Ethernet constants. To be defined in if_ehter.h? FIXME. */
#define ETHER_MIN_LEN 60 /* with header, without CRC. */
#define ETHER_MAX_LEN 1514 /* with header, without CRC. */
#define ETHER_ADDR_LEN 6 /* number of bytes in an address. */
#define ETHER_TYPE_LEN 2 /* number of bytes in a data type field. */
#define ETHER_HDR_SIZE 14 /* src addr, dst addr, and data type. */
#define ETHER_CRC_LEN 4 /* number of bytes in CRC field. */
/* Driver struct used in the config code. This must be public (external.) */
struct isa_driver fedriver =
{
@ -1826,7 +1818,7 @@ fe_start ( struct ifnet *ifp )
* (i.e., minimum packet sized) packets rapidly. An 8KB
* buffer can hold 130 blocks of 62 bytes long...
*/
if ( sc->txb_free < ETHER_MAX_LEN + FE_DATA_LEN_LEN ) {
if ( sc->txb_free < ETHER_MAX_LEN - ETHER_CRC_LEN + FE_DATA_LEN_LEN ) {
/* No room. */
goto indicate_active;
}
@ -2125,12 +2117,12 @@ fe_rint ( struct fe_softc * sc, u_char rstat )
*
* Is this statement true? FIXME.
*/
if ( len > ETHER_MAX_LEN || len < ETHER_HDR_SIZE ) {
if ( len > ETHER_MAX_LEN - ETHER_CRC_LEN || len < ETHER_MIN_LEN- ETHER_CRC_LEN ) {
#if FE_DEBUG >= 2
log( LOG_WARNING,
"fe%d: received a %s packet? (%u bytes)\n",
sc->sc_unit,
len < ETHER_HDR_SIZE ? "partial" : "big",
len < ETHER_MIN_SIZE- ETHER_CRC_SIZE ? "partial" : "big",
len );
#endif
sc->sc_if.if_ierrors++;
@ -2145,7 +2137,7 @@ fe_rint ( struct fe_softc * sc, u_char rstat )
* if it carries data for upper layer.
*/
#if FE_DEBUG >= 2
if ( len < ETHER_MIN_LEN ) {
if ( len < ETHER_MIN_LEN - ETHER_CRC_LEN) {
log( LOG_WARNING,
"fe%d: received a short packet? (%u bytes)\n",
sc->sc_unit, len );
@ -2505,7 +2497,7 @@ fe_get_packet ( struct fe_softc * sc, u_short len )
* however. If the following #error message were printed upon
* compile, you need to rewrite this function.
*/
#if ( MCLBYTES < ETHER_MAX_LEN + NFS_MAGIC_OFFSET )
#if ( MCLBYTES < ETHER_MAX_LEN - ETHER_CRC_LEN + NFS_MAGIC_OFFSET )
#error "Too small MCLBYTES to use fe driver."
#endif
@ -2658,11 +2650,10 @@ fe_write_mbufs ( struct fe_softc *sc, struct mbuf *m )
* it should be a bug of upper layer. We just ignore it.
* ... Partial (too short) packets, neither.
*/
if ( length > ETHER_MAX_LEN || length < ETHER_HDR_SIZE ) {
if ( ETHER_IS_VALID_LEN(length + ETHER_CRC_LEN)) {
log( LOG_ERR,
"fe%d: got a %s packet (%u bytes) to send\n",
sc->sc_unit,
length < ETHER_HDR_SIZE ? "partial" : "big", length );
"fe%d: got a out-of-spes packet (%u bytes) to send\n",
sc->sc_unit, length );
sc->sc_if.if_oerrors++;
return;
}
@ -2676,14 +2667,14 @@ fe_write_mbufs ( struct fe_softc *sc, struct mbuf *m )
* packet in the transmission buffer, we can skip the
* padding process. It may gain performance slightly. FIXME.
*/
outw( addr_bmpr8, max( length, ETHER_MIN_LEN ) );
outw( addr_bmpr8, max( length, ETHER_MIN_LEN - ETHER_CRC_LEN ) );
/*
* Update buffer status now.
* Truncate the length up to an even number, since we use outw().
*/
length = ( length + 1 ) & ~1;
sc->txb_free -= FE_DATA_LEN_LEN + max( length, ETHER_MIN_LEN );
sc->txb_free -= FE_DATA_LEN_LEN + max( length, ETHER_MIN_LEN - ETHER_CRC_LEN);
sc->txb_count++;
/*

View File

@ -68,10 +68,7 @@
/* Some defines that should really be in generic locations */
#define FCS_LEN 4
#define ETHER_ADDR_LEN 6
#define ETHER_HDR_LEN 14
#define MULTICAST_FILTER_LEN 8
#define ETHER_MIN_LEN 64
#include <sys/param.h>
#include <sys/systm.h>

View File

@ -18,7 +18,7 @@ Author: Martin Renters.
3c509 support added by Serge Babkin (babkin@hq.icb.chel.su)
$Id: 3c509.c,v 1.1 1995/04/12 20:14:56 martin Exp $
$Id: 3c509.c,v 1.2 1995/05/30 07:58:52 rgrimes Exp $
***************************************************************************/
@ -48,7 +48,7 @@ static get_e();
/**************************************************************************
The following two variables are used externally
***************************************************************************/
char packet[ETH_MAX_PACKET];
char packet[ETHER_MAX_LEN];
int packetlen;
/*********************** Name of driver *********************************/
@ -480,7 +480,7 @@ eth_poll()
struct arprequest *arpreq;
unsigned long reqip;
arpreq = (struct arprequest *)&packet[ETHER_HDR_SIZE];
arpreq = (struct arprequest *)&packet[ETHER_HDR_LEN];
#ifdef EDEBUG
printf("(ARP %I->%I)",ntohl(*(int*)arpreq->sipaddr),
@ -502,7 +502,7 @@ eth_poll()
} else if(type==IP) {
struct iphdr *iph;
iph = (struct iphdr *)&packet[ETHER_HDR_SIZE];
iph = (struct iphdr *)&packet[ETHER_HDR_LEN];
#ifdef EDEBUG
printf("(IP %I-%d->%I)",ntohl(*(int*)iph->src),
ntohs(iph->protocol),ntohl(*(int*)iph->dest));

View File

@ -37,9 +37,6 @@
/*
* Some global constants
*/
#define ETHER_MIN_LEN 64
#define ETHER_MAX_LEN 1518
#define ETHER_ADDR_LEN 6
#define TX_INIT_RATE 16
#define TX_INIT_MAX_RATE 64
@ -379,8 +376,6 @@
#define BNC 0x2
#define UTP 0x4
#define ETHER_ADDR_LEN 6
#define ETHER_MAX 1536
#define RX_BYTES_MASK (u_short) (0x07ff)
/* EISA support */

View File

@ -389,19 +389,19 @@ udp_transmit(destip, srcsock, destsock, len, buf)
printf("%I is not in my arp table!\n");
return(0);
}
for (i = 0; i<ETHER_ADDR_SIZE; i++)
for (i = 0; i<ETHER_ADDR_LEN; i++)
if (arptable[arpentry].node[i]) break;
if (i == ETHER_ADDR_SIZE) { /* Need to do arp request */
if (i == ETHER_ADDR_LEN) { /* Need to do arp request */
arpreq.hwtype = htons(1);
arpreq.protocol = htons(IP);
arpreq.hwlen = ETHER_ADDR_SIZE;
arpreq.hwlen = ETHER_ADDR_LEN;
arpreq.protolen = 4;
arpreq.opcode = htons(ARP_REQUEST);
bcopy(arptable[ARP_CLIENT].node, arpreq.shwaddr,
ETHER_ADDR_SIZE);
ETHER_ADDR_LEN);
convert_ipaddr(arpreq.sipaddr,
&arptable[ARP_CLIENT].ipaddr);
bzero(arpreq.thwaddr, ETHER_ADDR_SIZE);
bzero(arpreq.thwaddr, ETHER_ADDR_LEN);
convert_ipaddr(arpreq.tipaddr, &destip);
while (retry--) {
eth_transmit(broadcast, ARP, sizeof(arpreq),
@ -438,7 +438,7 @@ tftp(name)
if (!udp_transmit(arptable[ARP_SERVER].ipaddr, isocket, osocket,
len, &tp)) return(0);
if (await_reply(AWAIT_TFTP, isocket, NULL)) {
tr = (struct tftp_t *)&packet[ETHER_HDR_SIZE];
tr = (struct tftp_t *)&packet[ETHER_HDR_LEN];
if (tr->opcode == ntohs(TFTP_ERROR)) {
printf("TFTP error %d (%s)\r\n",
ntohs(tr->u.err.errcode),
@ -476,9 +476,9 @@ bootp()
bzero(&bp, sizeof(struct bootp_t));
bp.bp_op = BOOTP_REQUEST;
bp.bp_htype = 1;
bp.bp_hlen = ETHER_ADDR_SIZE;
bp.bp_hlen = ETHER_ADDR_LEN;
bp.bp_xid = starttime = currticks();
bcopy(arptable[ARP_CLIENT].node, bp.bp_hwaddr, ETHER_ADDR_SIZE);
bcopy(arptable[ARP_CLIENT].node, bp.bp_hwaddr, ETHER_ADDR_LEN);
while(retry--) {
udp_transmit(IP_BROADCAST, 0, BOOTP_SERVER,
sizeof(struct bootp_t), &bp);
@ -504,7 +504,7 @@ await_reply(type, ival, ptr)
struct bootp_t *bootpreply;
struct rpc_t *rpc;
int protohdrlen = ETHER_HDR_SIZE + sizeof(struct iphdr) +
int protohdrlen = ETHER_HDR_LEN + sizeof(struct iphdr) +
sizeof(struct udphdr);
time = currticks() + TIMEOUT;
while(time > currticks()) {
@ -512,16 +512,16 @@ await_reply(type, ival, ptr)
if (eth_poll()) { /* We have something! */
/* Check for ARP - No IP hdr */
if ((type == AWAIT_ARP) &&
(packetlen >= ETHER_HDR_SIZE +
(packetlen >= ETHER_HDR_LEN +
sizeof(struct arprequest)) &&
(((packet[12] << 8) | packet[13]) == ARP)) {
arpreply = (struct arprequest *)
&packet[ETHER_HDR_SIZE];
&packet[ETHER_HDR_LEN];
if ((arpreply->opcode == ntohs(ARP_REPLY)) &&
bcompare(arpreply->sipaddr, ptr, 4)) {
bcopy(arpreply->shwaddr,
arptable[ival].node,
ETHER_ADDR_SIZE);
ETHER_ADDR_LEN);
return(1);
}
continue;
@ -530,17 +530,17 @@ await_reply(type, ival, ptr)
/* Anything else has IP header */
if ((packetlen < protohdrlen) ||
(((packet[12] << 8) | packet[13]) != IP)) continue;
ip = (struct iphdr *)&packet[ETHER_HDR_SIZE];
ip = (struct iphdr *)&packet[ETHER_HDR_LEN];
if ((ip->verhdrlen != 0x45) ||
ipchksum(ip, sizeof(struct iphdr)) ||
(ip->protocol != IP_UDP)) continue;
udp = (struct udphdr *)&packet[ETHER_HDR_SIZE +
udp = (struct udphdr *)&packet[ETHER_HDR_LEN +
sizeof(struct iphdr)];
/* BOOTP ? */
bootpreply = (struct bootp_t *)&packet[ETHER_HDR_SIZE];
bootpreply = (struct bootp_t *)&packet[ETHER_HDR_LEN];
if ((type == AWAIT_BOOTP) &&
(packetlen >= (ETHER_HDR_SIZE +
(packetlen >= (ETHER_HDR_LEN +
sizeof(struct bootp_t))) &&
(ntohs(udp->dest) == BOOTP_CLIENT) &&
(bootpreply->bp_op == BOOTP_REPLY)) {
@ -550,11 +550,11 @@ await_reply(type, ival, ptr)
convert_ipaddr(&arptable[ARP_SERVER].ipaddr,
bootpreply->bp_siaddr);
bzero(arptable[ARP_SERVER].node,
ETHER_ADDR_SIZE); /* Kill arp */
ETHER_ADDR_LEN); /* Kill arp */
convert_ipaddr(&arptable[ARP_GATEWAY].ipaddr,
bootpreply->bp_giaddr);
bzero(arptable[ARP_GATEWAY].node,
ETHER_ADDR_SIZE); /* Kill arp */
ETHER_ADDR_LEN); /* Kill arp */
if (bootpreply->bp_file[0]) {
bcopy(bootpreply->bp_file,
kernel_buf, 128);
@ -569,7 +569,7 @@ await_reply(type, ival, ptr)
(ntohs(udp->dest) == ival)) return(1);
/* RPC */
rpc = (struct rpc_t *)&packet[ETHER_HDR_SIZE];
rpc = (struct rpc_t *)&packet[ETHER_HDR_LEN];
if ((type == AWAIT_RPC) &&
(ntohs(udp->dest) == RPC_SOCKET) &&
(ntohl(rpc->u.reply.id) == ival) &&

View File

@ -13,6 +13,7 @@ Author: Martin Renters
#include <sys/param.h>
#include <sys/socket.h>
#include <sys/mount.h>
#include <net/ethernet.h>
#include <net/if.h>
#include <netinet/in.h>
#include <nfs/nfsv2.h>
@ -53,11 +54,6 @@ Author: Martin Renters
#define TRUE 1
#define FALSE 0
#define ETHER_ADDR_SIZE 6 /* Size of Ethernet address */
#define ETHER_HDR_SIZE 14 /* Size of ethernet header */
#define ETH_MIN_PACKET 64
#define ETH_MAX_PACKET 1518
#define VENDOR_NONE 0
#define VENDOR_WD 1
#define VENDOR_NOVELL 2

View File

@ -43,7 +43,7 @@ unsigned char *eth_node_addr;
The following two variables are used externally
**************************************************************************/
char eth_driver[] = "ed0";
char packet[ETH_MAX_PACKET];
char packet[ETHER_MAX_LEN];
int packetlen;
#ifdef INCLUDE_NE
@ -418,7 +418,7 @@ eth_transmit(d,t,s,p)
*(eth_bmem+13) = t;
bcopy(p, eth_bmem+14, s);
s += 14;
while (s < ETH_MIN_PACKET) *(eth_bmem+(s++)) = 0;
while (s < ETHER_MIN_LAN) *(eth_bmem+(s++)) = 0;
}
#endif
#ifdef INCLUDE_WD
@ -438,7 +438,7 @@ eth_transmit(d,t,s,p)
*(eth_bmem+13) = t;
bcopy(p, eth_bmem+14, s);
s += 14;
while (s < ETH_MIN_PACKET) *(eth_bmem+(s++)) = 0;
while (s < ETHER_MIN_LAN) *(eth_bmem+(s++)) = 0;
if (eth_flags & FLAG_790) {
outb(eth_asic_base + WD_MSR, 0);
inb(0x84);
@ -458,7 +458,7 @@ eth_transmit(d,t,s,p)
eth_pio_write(&type, (eth_tx_start<<8)+12, 2);
eth_pio_write(p, (eth_tx_start<<8)+14, s);
s += 14;
if (s < ETH_MIN_PACKET) s = ETH_MIN_PACKET;
if (s < ETHER_MIN_LEN) s = ETHER_MIN_LEN;
}
#endif
twiddle();
@ -565,7 +565,7 @@ eth_poll()
if (ret && (type == ARP)) {
struct arprequest *arpreq;
unsigned long reqip;
arpreq = (struct arprequest *)&packet[ETHER_HDR_SIZE];
arpreq = (struct arprequest *)&packet[ETHER_HDR_LEN];
convert_ipaddr(&reqip, arpreq->tipaddr);
if ((ntohs(arpreq->opcode) == ARP_REQUEST) &&
(reqip == arptable[ARP_CLIENT].ipaddr)) {

View File

@ -31,7 +31,7 @@ rpclookup(addr, prog, ver)
udp_transmit(arptable[addr].ipaddr, RPC_SOCKET,
SUNRPC, rpcptr - (char *)&buf, &buf);
if (await_reply(AWAIT_RPC, rpc_id, NULL)) {
rpc = (struct rpc_t *)&packet[ETHER_HDR_SIZE];
rpc = (struct rpc_t *)&packet[ETHER_HDR_LEN];
if (rpc->u.reply.rstatus == rpc->u.reply.verifier ==
rpc->u.reply.astatus == 0)
return(ntohl(rpc->u.reply.data[0]));
@ -66,7 +66,7 @@ nfs_mount(server, port, path, fh)
udp_transmit(arptable[server].ipaddr, RPC_SOCKET,
port, rpcptr - (char *)&buf, &buf);
if (await_reply(AWAIT_RPC, rpc_id, NULL)) {
rpc = (struct rpc_t *)&packet[ETHER_HDR_SIZE];
rpc = (struct rpc_t *)&packet[ETHER_HDR_LEN];
if (rpc->u.reply.rstatus || rpc->u.reply.verifier ||
rpc->u.reply.astatus || rpc->u.reply.data[0]) {
rpc_err(rpc);
@ -104,7 +104,7 @@ nfs_lookup(server, port, fh, path, file_fh)
udp_transmit(arptable[server].ipaddr, RPC_SOCKET,
port, rpcptr - (char *)&buf, &buf);
if (await_reply(AWAIT_RPC, rpc_id, NULL)) {
rpc = (struct rpc_t *)&packet[ETHER_HDR_SIZE];
rpc = (struct rpc_t *)&packet[ETHER_HDR_LEN];
if (rpc->u.reply.rstatus || rpc->u.reply.verifier ||
rpc->u.reply.astatus || rpc->u.reply.data[0]) {
rpc_err(rpc);
@ -143,7 +143,7 @@ nfs_read(server, port, fh, offset, len, buffer)
udp_transmit(arptable[server].ipaddr, RPC_SOCKET,
port, rpcptr - (char *)&buf, &buf);
if (await_reply(AWAIT_RPC, rpc_id, NULL)) {
rpc = (struct rpc_t *)&packet[ETHER_HDR_SIZE];
rpc = (struct rpc_t *)&packet[ETHER_HDR_LEN];
if (rpc->u.reply.rstatus || rpc->u.reply.verifier ||
rpc->u.reply.astatus || rpc->u.reply.data[0]) {
rpc_err(rpc);

View File

@ -24,7 +24,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: if_ed.c,v 1.101 1996/06/25 20:30:05 bde Exp $
* $Id: if_ed.c,v 1.102 1996/08/04 10:57:29 phk Exp $
*/
/*
@ -325,11 +325,6 @@ static unsigned short ed_790_intr_mask[] = {
IRQ15
};
#define ETHER_MIN_LEN 60
#define ETHER_MAX_LEN 1514
#define ETHER_ADDR_LEN 6
#define ETHER_HDR_SIZE 14
static struct kern_devconf kdc_ed_template = {
0, 0, 0, /* filled in by dev_attach */
"ed", 0, { MDDT_ISA, 0, "net" },
@ -1944,7 +1939,7 @@ ed_start(ifp)
goto outloop;
}
sc->txb_len[sc->txb_new] = max(len, ETHER_MIN_LEN);
sc->txb_len[sc->txb_new] = max(len, (ETHER_MIN_LEN-ETHER_CRC_LEN));
sc->txb_inuse++;
@ -2020,8 +2015,8 @@ ed_rint(sc)
ed_pio_readmem(sc, (int)packet_ptr, (char *) &packet_hdr,
sizeof(packet_hdr));
len = packet_hdr.count;
if (len > (ETHER_MAX_LEN + sizeof(struct ed_ring)) ||
len < (ETHER_HDR_SIZE + sizeof(struct ed_ring))) {
if (len > (ETHER_MAX_LEN - ETHER_CRC_LEN + sizeof(struct ed_ring)) ||
len < (ETHER_MIN_LEN - ETHER_CRC_LEN + sizeof(struct ed_ring))) {
/*
* Length is a wild value. There's a good chance that
* this was caused by the NIC being old and buggy.

View File

@ -27,7 +27,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: if_eg.c,v 1.15 1996/08/04 10:58:16 phk Exp $
* $Id: if_eg.c,v 1.16 1996/08/04 20:04:11 phk Exp $
*
* Support for 3Com 3c505 Etherlink+ card.
*/
@ -88,10 +88,6 @@
#define dprintf(x)
#endif
#define ETHER_MIN_LEN 64
#define ETHER_MAX_LEN 1518
#define ETHER_ADDR_LEN 6
#define EG_INLEN 10
#define EG_BUFLEN 0x0670

View File

@ -6,7 +6,7 @@
*
* Questions, comments, bug reports and fixes to kimmel@cs.umass.edu.
*
* $Id: if_el.c,v 1.23 1996/02/06 18:50:40 wollman Exp $
* $Id: if_el.c,v 1.24 1996/06/18 01:22:20 bde Exp $
*/
/* Except of course for the portions of code lifted from other FreeBSD
* drivers (mainly elread, elget and el_ioctl)
@ -64,9 +64,6 @@
#include <i386/isa/isa_device.h>
#include <i386/isa/if_elreg.h>
#define ETHER_MIN_LEN 64
#define ETHER_MAX_LEN 1518
/* For debugging convenience */
#ifdef EL_DEBUG
#define dprintf(x) printf x

View File

@ -4,7 +4,7 @@
* of the software, derivative works or modified versions, and any
* portions thereof.
*
* $Id: if_elreg.h,v 1.2 1994/08/02 07:39:34 davidg Exp $
* $Id: if_elreg.h,v 1.3 1996/01/30 22:55:41 mpp Exp $
*/
/* 3COM Etherlink 3C501 Register Definitions */
@ -74,5 +74,3 @@
/* Packet buffer size */
#define EL_BUFSIZ 2048
#define ETHER_ADDR_LEN 6

View File

@ -31,7 +31,7 @@
*/
/*
* $Id: if_epreg.h,v 1.14 1996/06/14 22:11:38 nate Exp $
* $Id: if_epreg.h,v 1.15 1996/07/19 13:20:05 amurai Exp $
*
* Promiscuous mode added and interrupt logic slightly changed
* to reduce the number of adapter failures. Transceiver select
@ -107,10 +107,6 @@ struct ep_board {
/*
* Some global constants
*/
#define ETHER_MIN_LEN 64
#define ETHER_MAX_LEN 1518
#define ETHER_ADDR_LEN 6
#define TX_INIT_RATE 16
#define TX_INIT_MAX_RATE 64
#define RX_INIT_LATENCY 64
@ -455,8 +451,6 @@ struct ep_board {
#define BNC 0x2
#define UTP 0x4
#define ETHER_ADDR_LEN 6
#define ETHER_MAX 1536
#define RX_BYTES_MASK (u_short) (0x07ff)
extern struct ep_board ep_board[];

View File

@ -21,7 +21,7 @@
*/
/*
* $Id: if_fe.c,v 1.15 1996/06/12 05:03:40 gpalmer Exp $
* $Id: if_fe.c,v 1.16 1996/06/18 01:22:21 bde Exp $
*
* Device driver for Fujitsu MB86960A/MB86965A based Ethernet cards.
* To be used with FreeBSD 2.x
@ -272,14 +272,6 @@ static void fe_loadmar ( struct fe_softc * );
static void fe_dump ( int, struct fe_softc *, char * );
#endif
/* Ethernet constants. To be defined in if_ehter.h? FIXME. */
#define ETHER_MIN_LEN 60 /* with header, without CRC. */
#define ETHER_MAX_LEN 1514 /* with header, without CRC. */
#define ETHER_ADDR_LEN 6 /* number of bytes in an address. */
#define ETHER_TYPE_LEN 2 /* number of bytes in a data type field. */
#define ETHER_HDR_SIZE 14 /* src addr, dst addr, and data type. */
#define ETHER_CRC_LEN 4 /* number of bytes in CRC field. */
/* Driver struct used in the config code. This must be public (external.) */
struct isa_driver fedriver =
{
@ -1826,7 +1818,7 @@ fe_start ( struct ifnet *ifp )
* (i.e., minimum packet sized) packets rapidly. An 8KB
* buffer can hold 130 blocks of 62 bytes long...
*/
if ( sc->txb_free < ETHER_MAX_LEN + FE_DATA_LEN_LEN ) {
if ( sc->txb_free < ETHER_MAX_LEN - ETHER_CRC_LEN + FE_DATA_LEN_LEN ) {
/* No room. */
goto indicate_active;
}
@ -2125,12 +2117,12 @@ fe_rint ( struct fe_softc * sc, u_char rstat )
*
* Is this statement true? FIXME.
*/
if ( len > ETHER_MAX_LEN || len < ETHER_HDR_SIZE ) {
if ( len > ETHER_MAX_LEN - ETHER_CRC_LEN || len < ETHER_MIN_LEN- ETHER_CRC_LEN ) {
#if FE_DEBUG >= 2
log( LOG_WARNING,
"fe%d: received a %s packet? (%u bytes)\n",
sc->sc_unit,
len < ETHER_HDR_SIZE ? "partial" : "big",
len < ETHER_MIN_SIZE- ETHER_CRC_SIZE ? "partial" : "big",
len );
#endif
sc->sc_if.if_ierrors++;
@ -2145,7 +2137,7 @@ fe_rint ( struct fe_softc * sc, u_char rstat )
* if it carries data for upper layer.
*/
#if FE_DEBUG >= 2
if ( len < ETHER_MIN_LEN ) {
if ( len < ETHER_MIN_LEN - ETHER_CRC_LEN) {
log( LOG_WARNING,
"fe%d: received a short packet? (%u bytes)\n",
sc->sc_unit, len );
@ -2505,7 +2497,7 @@ fe_get_packet ( struct fe_softc * sc, u_short len )
* however. If the following #error message were printed upon
* compile, you need to rewrite this function.
*/
#if ( MCLBYTES < ETHER_MAX_LEN + NFS_MAGIC_OFFSET )
#if ( MCLBYTES < ETHER_MAX_LEN - ETHER_CRC_LEN + NFS_MAGIC_OFFSET )
#error "Too small MCLBYTES to use fe driver."
#endif
@ -2658,11 +2650,10 @@ fe_write_mbufs ( struct fe_softc *sc, struct mbuf *m )
* it should be a bug of upper layer. We just ignore it.
* ... Partial (too short) packets, neither.
*/
if ( length > ETHER_MAX_LEN || length < ETHER_HDR_SIZE ) {
if ( ETHER_IS_VALID_LEN(length + ETHER_CRC_LEN)) {
log( LOG_ERR,
"fe%d: got a %s packet (%u bytes) to send\n",
sc->sc_unit,
length < ETHER_HDR_SIZE ? "partial" : "big", length );
"fe%d: got a out-of-spes packet (%u bytes) to send\n",
sc->sc_unit, length );
sc->sc_if.if_oerrors++;
return;
}
@ -2676,14 +2667,14 @@ fe_write_mbufs ( struct fe_softc *sc, struct mbuf *m )
* packet in the transmission buffer, we can skip the
* padding process. It may gain performance slightly. FIXME.
*/
outw( addr_bmpr8, max( length, ETHER_MIN_LEN ) );
outw( addr_bmpr8, max( length, ETHER_MIN_LEN - ETHER_CRC_LEN ) );
/*
* Update buffer status now.
* Truncate the length up to an even number, since we use outw().
*/
length = ( length + 1 ) & ~1;
sc->txb_free -= FE_DATA_LEN_LEN + max( length, ETHER_MIN_LEN );
sc->txb_free -= FE_DATA_LEN_LEN + max( length, ETHER_MIN_LEN - ETHER_CRC_LEN);
sc->txb_count++;
/*

View File

@ -28,7 +28,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: if_ix.c,v 1.20 1996/06/12 05:03:41 gpalmer Exp $
* $Id: if_ix.c,v 1.21 1996/06/25 20:30:18 bde Exp $
*/
#include "ix.h"
@ -598,8 +598,8 @@ ixattach(struct isa_device *dvp) {
ifp->if_ioctl = ixioctl;
ifp->if_watchdog = ixwatchdog;
ifp->if_type = IFT_ETHER;
ifp->if_addrlen = ETHER_ADDRESS_LENGTH;
ifp->if_hdrlen = ETHER_HEADER_LENGTH;
ifp->if_addrlen = ETHER_ADDR_LEN;
ifp->if_hdrlen = ETHER_HDR_LEN;
#ifdef IXCOUNTERS
/*
* ZZZ more counters added, but bzero gets them
@ -751,7 +751,7 @@ ixinit(int unit) {
cb_ias->common.status = 0;
cb_ias->common.command = CB_CMD_EL | CB_CMD_IAS;
bcopy(sc->arpcom.ac_enaddr, cb_ias->source, ETHER_ADDRESS_LENGTH);
bcopy(sc->arpcom.ac_enaddr, cb_ias->source, ETHER_ADDR_LEN);
scb->command = SCB_CUC_START;
ixchannel_attention(unit);
status |= ix_cb_wait((cb_t *)cb_ias, "IAS");
@ -1385,9 +1385,9 @@ ixstart(struct ifnet *ifp) {
length += m_temp->m_len;
}
m_freem(m);
if (length < ETHER_MIN_LENGTH) length = ETHER_MIN_LENGTH;
if (length < ETHER_MIN_LEN) length = ETHER_MIN_LEN;
#ifdef DIAGNOSTIC
if (length > ETHER_MAX_LENGTH) {
if (length > ETHER_MAX_LEN) {
/* XXX
* This should never ever happen, if it does
* we probable screwed up all sorts of board data
@ -1396,7 +1396,7 @@ ixstart(struct ifnet *ifp) {
* something is real wrong
*/
printf("ix%d: ixstart: Packet length=%d > MTU=%d\n",
unit, length, ETHER_MAX_LENGTH);
unit, length, ETHER_MAX_LEN);
}
#endif /* DIAGNOSTIC */
tbd->act_count = TBD_STAT_EOF | length;

View File

@ -28,21 +28,13 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: if_ixreg.h,v 1.6 1995/05/30 08:02:17 rgrimes Exp $
* $Id: if_ixreg.h,v 1.7 1996/01/30 22:55:52 mpp Exp $
*/
/*
* These really belong some place else, but I can't find them right
* now. I'll look again latter
*/
#define ETHER_ADDRESS_LENGTH 6 /* Length of an ethernet address */
#define ETHER_HEADER_LENGTH 14 /* Length of an ethernet header */
#define ETHER_DATA_LENGTH ETHERMTU
#define ETHER_CRC_LENGTH 4
#define ETHER_MIN_LENGTH 64 /* Minimum length of an ethernet packet */
#define ETHER_MAX_LENGTH (ETHER_HEADER_LENGTH + \
ETHERMTU + \
ETHER_CRC_LENGTH)
#define IX_IO_PORTS 16 /* Number of I/O ports used, note
* this is not true, due to shadow
@ -134,14 +126,14 @@
#define SCB_ADDR (ISCP_ADDR - sizeof(scb_t))
#define TB_COUNT 3 /* How many transfer buffers in the TFA */
#define TB_SIZE (ETHER_MAX_LENGTH) /* size of transmit buffer */
#define TB_SIZE (ETHER_MAX_LEN) /* size of transmit buffer */
#define TFA_START 0x0000 /* Start of the TFA */
#define TFA_SIZE (TB_COUNT * \
(sizeof(cb_transmit_t) + sizeof(tbd_t) + TB_SIZE))
#define RFA_START (TFA_SIZE)
#define RFA_SIZE (SCP_ADDR - RFA_START)
#define RB_SIZE (ETHER_MAX_LENGTH) /* size of receive buffer */
#define RB_SIZE (ETHER_MAX_LEN) /* size of receive buffer */
typedef struct /* System Configuration Pointer */
{
@ -250,7 +242,7 @@ typedef struct /* command block - nop (also the common part of cb's */
typedef struct /* command block - individual address setup command */
{
cb_t common; /* common part of all command blocks */
u_char source[ETHER_ADDRESS_LENGTH];
u_char source[ETHER_ADDR_LEN];
/* ethernet hardware address */
} cb_ias_t;
@ -269,7 +261,7 @@ typedef struct /* command block - transmit command */
{
cb_t common; /* common part of all command blocks */
u_short tbd_offset; /* transmit buffer descriptor offset */
u_char destination[ETHER_ADDRESS_LENGTH];
u_char destination[ETHER_ADDR_LEN];
/* ethernet destination address field */
u_short length; /* ethernet length field */
u_char byte[16]; /* XXX stupid fill tell I fix the ixinit

View File

@ -68,10 +68,7 @@
/* Some defines that should really be in generic locations */
#define FCS_LEN 4
#define ETHER_ADDR_LEN 6
#define ETHER_HDR_LEN 14
#define MULTICAST_FILTER_LEN 8
#define ETHER_MIN_LEN 64
#include <sys/param.h>
#include <sys/systm.h>

View File

@ -47,7 +47,7 @@
*/
/*
* $Id: if_ze.c,v 1.31 1996/06/25 20:30:30 bde Exp $
* $Id: if_ze.c,v 1.32 1996/07/12 04:11:23 bde Exp $
*/
#include "ze.h"
@ -173,11 +173,6 @@ struct isa_driver zedriver = {
"ze"
};
#define ETHER_MIN_LEN 64
#define ETHER_MAX_LEN 1518
#define ETHER_ADDR_LEN 6
#define ETHER_HDR_SIZE 14
static unsigned char enet_addr[6];
static unsigned char card_info[256];

View File

@ -34,7 +34,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* From: if_ep.c,v 1.9 1994/01/25 10:46:29 deraadt Exp $
* $Id: if_zp.c,v 1.22 1996/06/25 20:30:34 bde Exp $
* $Id: if_zp.c,v 1.23 1996/07/12 04:11:24 bde Exp $
*/
/*-
* TODO:
@ -155,11 +155,6 @@
#include <machine/apm_bios.h>
#endif /* NAPM > 0 */
#define ETHER_MIN_LEN 64
#define ETHER_MAX_LEN 1518
#define ETHER_ADDR_LEN 6
/*****************************************************************************
* Driver for Ethernet Adapter *

View File

@ -21,7 +21,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: if_zpreg.h,v 1.2 1995/05/30 08:02:33 rgrimes Exp $
* $Id: if_zpreg.h,v 1.3 1996/01/30 22:55:55 mpp Exp $
*/
/**************************************************************************
* *
@ -288,8 +288,6 @@
#define EEPROM_BUSY (1<<15)
#define EEPROM_TST_MODE (1<<14)
#define READ_EEPROM (1<<7)
#define ETHER_ADDR_LEN 6
#define ETHER_MAX 1536
#define ENABLE_UTP 0xc0
#define DISABLE_UTP 0x0
#define RX_BYTES_MASK (u_short) (0x07ff)

View File

@ -1,13 +1,63 @@
/*
* Fundamental constants relating to ethernet.
*
* $Id$
* $Id: ethernet.h,v 1.1 1996/08/05 14:02:38 phk Exp $
*
*/
#ifndef _NET_ETHERNET_H_
#define _NET_ETHERNET_H_
/*
* The number of bytes in an ethernet (MAC) address.
*/
#define ETHER_ADDR_LEN 6
#define ETHER_TYPE_LEN 2
#define ETHER_CRC_LENGTH 4
#define ETHER_HDR_SIZE (ETHER_ADDR_LEN*2+ETHER_TYPE_LEN)
#define ETHER_MIN_LEN 64
#define ETHER_MAX_LEN 1518
/*
* The number of bytes in the type field.
*/
#define ETHER_TYPE_LEN 2
/*
* The number of bytes in the trailing CRC field.
*/
#define ETHER_CRC_LEN 4
/*
* The length of the combined header.
*/
#define ETHER_HDR_LEN (ETHER_ADDR_LEN*2+ETHER_TYPE_LEN)
/*
* The minimum packet length.
*/
#define ETHER_MIN_LEN 64
/*
* The maximum packet length.
*/
#define ETHER_MAX_LEN 1518
/*
* A macro to validate a length with
*/
#define ETHER_IS_VALID_LEN(foo) \
((foo) >= ETHER_MIN_LEN && (foo) <= ETHER_MAX_LEN)
/*
* Structure of a 10Mb/s Ethernet header.
*/
struct ether_header {
u_char ether_dhost[ETHER_ADDR_LEN];
u_char ether_shost[ETHER_ADDR_LEN];
u_short ether_type;
};
/*
* Structure of a 48-bit Ethernet address.
*/
struct ether_addr {
u_char octet[ETHER_ADDR_LEN];
};
#endif

View File

@ -31,27 +31,13 @@
* SUCH DAMAGE.
*
* @(#)if_ether.h 8.3 (Berkeley) 5/2/95
* $Id: if_ether.h,v 1.13 1995/12/09 16:06:54 phk Exp $
* $Id: if_ether.h,v 1.14 1996/03/23 01:32:30 fenner Exp $
*/
#ifndef _NETINET_IF_ETHER_H_
#define _NETINET_IF_ETHER_H_
/*
* Structure of a 10Mb/s Ethernet header.
*/
struct ether_header {
u_char ether_dhost[6];
u_char ether_shost[6];
u_short ether_type;
};
/*
* Structure of a 48-bit Ethernet address.
*/
struct ether_addr {
u_char octet[6];
};
#include <net/ethernet.h>
#define ETHERTYPE_PUP 0x0200 /* PUP protocol */
#define ETHERTYPE_IP 0x0800 /* IP protocol */
@ -66,8 +52,8 @@ struct ether_addr {
#define ETHERTYPE_TRAIL 0x1000 /* Trailer packet */
#define ETHERTYPE_NTRAILER 16
#define ETHERMTU 1500
#define ETHERMIN (60-14)
#define ETHERMTU (ETHER_MAX_LEN-ETHER_HDR_LEN-ETHER_CRC_LEN)
#define ETHERMIN (ETHER_MIN_LEN-ETHER_HDR_LEN-ETHER_CRC_LEN)
#ifdef KERNEL
/*
@ -77,7 +63,7 @@ struct ether_addr {
*/
#define ETHER_MAP_IP_MULTICAST(ipaddr, enaddr) \
/* struct in_addr *ipaddr; */ \
/* u_char enaddr[6]; */ \
/* u_char enaddr[ETHER_ADDR_LEN]; */ \
{ \
(enaddr)[0] = 0x01; \
(enaddr)[1] = 0x00; \
@ -97,9 +83,9 @@ struct ether_addr {
*/
struct ether_arp {
struct arphdr ea_hdr; /* fixed-size header */
u_char arp_sha[6]; /* sender hardware address */
u_char arp_sha[ETHER_ADDR_LEN]; /* sender hardware address */
u_char arp_spa[4]; /* sender protocol address */
u_char arp_tha[6]; /* target hardware address */
u_char arp_tha[ETHER_ADDR_LEN]; /* target hardware address */
u_char arp_tpa[4]; /* target protocol address */
};
#define arp_hrd ea_hdr.ar_hrd
@ -119,7 +105,7 @@ struct arpcom {
* The ifnet struct _must_ be at the head of this structure.
*/
struct ifnet ac_if; /* network-visible interface */
u_char ac_enaddr[6]; /* ethernet hardware address */
u_char ac_enaddr[ETHER_ADDR_LEN]; /* ethernet hardware address */
struct ether_multi *ac_multiaddrs; /* list of ether multicast addrs */
int ac_multicnt; /* length of ac_multiaddrs list */
};
@ -141,9 +127,9 @@ struct sockaddr_inarp {
#define RTF_ANNOUNCE RTF_PROTO2 /* announce new arp entry */
#ifdef KERNEL
extern u_char etherbroadcastaddr[6];
extern u_char ether_ipmulticast_min[6];
extern u_char ether_ipmulticast_max[6];
extern u_char etherbroadcastaddr[ETHER_ADDR_LEN];
extern u_char ether_ipmulticast_min[ETHER_ADDR_LEN];
extern u_char ether_ipmulticast_max[ETHER_ADDR_LEN];
extern struct ifqueue arpintrq;
int arpresolve __P((struct arpcom *, struct rtentry *, struct mbuf *,
@ -161,8 +147,8 @@ int ether_delmulti __P((struct ifreq *, struct arpcom *));
* the minimally-disrupting place to put it.)
*/
struct ether_multi {
u_char enm_addrlo[6]; /* low or only address of range */
u_char enm_addrhi[6]; /* high or only address of range */
u_char enm_addrlo[ETHER_ADDR_LEN]; /* low or only address of range */
u_char enm_addrhi[ETHER_ADDR_LEN]; /* high or only address of range */
struct arpcom *enm_ac; /* back pointer to arpcom */
u_int enm_refcount; /* no. claims to this addr/range */
struct ether_multi *enm_next; /* ptr to next ether_multi */
@ -182,15 +168,15 @@ struct ether_multistep {
* record is found, "enm" returns NULL.
*/
#define ETHER_LOOKUP_MULTI(addrlo, addrhi, ac, enm) \
/* u_char addrlo[6]; */ \
/* u_char addrhi[6]; */ \
/* u_char addrlo[ETHER_ADDR_LEN]; */ \
/* u_char addrhi[ETHER_ADDR_LEN]; */ \
/* struct arpcom *ac; */ \
/* struct ether_multi *enm; */ \
{ \
for ((enm) = (ac)->ac_multiaddrs; \
(enm) != NULL && \
(bcmp((enm)->enm_addrlo, (addrlo), 6) != 0 || \
bcmp((enm)->enm_addrhi, (addrhi), 6) != 0); \
(bcmp((enm)->enm_addrlo, (addrlo), ETHER_ADDR_LEN) != 0 || \
bcmp((enm)->enm_addrhi, (addrhi), ETHER_ADDR_LEN) != 0); \
(enm) = (enm)->enm_next); \
}

View File

@ -85,9 +85,6 @@ struct vx_softc {
/*
* Some global constants
*/
#define ETHER_MIN_LEN 64
#define ETHER_MAX_LEN 1518
#define ETHER_ADDR_LEN 6
#define TX_INIT_RATE 16
#define TX_INIT_MAX_RATE 64
@ -423,8 +420,6 @@ struct vx_softc {
#define BNC 0x2
#define UTP 0x4
#define ETHER_ADDR_LEN 6
#define ETHER_MAX 1536
#define RX_BYTES_MASK (u_short) (0x07ff)
/* EISA support */