From 6e4972118a056b0fc9e35e26a8ff56d250e8ff93 Mon Sep 17 00:00:00 2001 From: msmith Date: Thu, 27 Aug 1998 22:41:18 +0000 Subject: Enable duplex autodetection if UTP media are autodetected. Add a sysctl 'machdep.cs_recv_delay' to specify how long to wait after receiving a packet in order to check for a subsequent (back-to-back) packet. The cs8900 has a very small receive buffer, so this helps avoid overflows at the cost of some extra CPU overhead. Submitted by: Oleg Sharoiko , MIHIRA "Sanpei" Yoshiro --- sys/dev/cs/if_cs.c | 23 ++++++++++++----------- sys/i386/isa/if_cs.c | 23 ++++++++++++----------- 2 files changed, 24 insertions(+), 22 deletions(-) (limited to 'sys') diff --git a/sys/dev/cs/if_cs.c b/sys/dev/cs/if_cs.c index 1a81c66..feb395c 100644 --- a/sys/dev/cs/if_cs.c +++ b/sys/dev/cs/if_cs.c @@ -27,7 +27,7 @@ */ /* - * $Id: if_cs.c,v 1.2 1998/08/12 18:02:48 bde Exp $ + * $Id: if_cs.c,v 1.3 1998/08/13 20:31:17 msmith Exp $ * * Device driver for Crystal Semiconductor CS8920 based ethernet * adapters. By Maxim Bolotin and Oleg Sharoiko, 27-April-1997 @@ -44,6 +44,7 @@ #include #include #include +#include #include #include @@ -72,10 +73,6 @@ #define CS_DMA_BUFFER_SIZE 16384 #endif -#ifndef CS_WAIT_NEXT_PACKET -#define CS_WAIT_NEXT_PACKET 570 -#endif - /* * cs_softc: per line info and status */ @@ -105,8 +102,11 @@ static struct cs_softc { static u_long cs_unit = NCS; -static int cs_attach __P((struct cs_softc *, int, int)); -static int cs_attach_isa __P((struct isa_device *)); +static int cs_recv_delay = 570; +SYSCTL_INT(_machdep, OID_AUTO, cs_recv_delay, CTLFLAG_RW, &cs_recv_delay, 0, ""); + +static int cs_attach __P((struct cs_softc *, int, int)); +static int cs_attach_isa __P((struct isa_device *)); static void cs_init __P((void *)); static int cs_ioctl __P((struct ifnet *, u_long, caddr_t)); static int cs_probe __P((struct isa_device *)); @@ -799,7 +799,7 @@ cs_get_packet(struct cs_softc *sc) ifp->if_ipackets++; if (length==ETHER_MAX_LEN-ETHER_CRC_LEN) - DELAY( CS_WAIT_NEXT_PACKET ); + DELAY( cs_recv_delay ); } else { m_freem(m); } @@ -1212,9 +1212,10 @@ cs_mediaset(struct cs_softc *sc, int media) switch (IFM_SUBTYPE(media)) { default: case IFM_AUTO: - if (error=enable_tp(sc)) - if (error=enable_bnc(sc)) - error=enable_aui(sc); + if ((error=enable_tp(sc))==0) + error = cs_duplex_auto(sc); + else if (error=enable_bnc(sc)) + error = enable_aui(sc); break; case IFM_10_T: if (error=enable_tp(sc)) diff --git a/sys/i386/isa/if_cs.c b/sys/i386/isa/if_cs.c index 1a81c66..feb395c 100644 --- a/sys/i386/isa/if_cs.c +++ b/sys/i386/isa/if_cs.c @@ -27,7 +27,7 @@ */ /* - * $Id: if_cs.c,v 1.2 1998/08/12 18:02:48 bde Exp $ + * $Id: if_cs.c,v 1.3 1998/08/13 20:31:17 msmith Exp $ * * Device driver for Crystal Semiconductor CS8920 based ethernet * adapters. By Maxim Bolotin and Oleg Sharoiko, 27-April-1997 @@ -44,6 +44,7 @@ #include #include #include +#include #include #include @@ -72,10 +73,6 @@ #define CS_DMA_BUFFER_SIZE 16384 #endif -#ifndef CS_WAIT_NEXT_PACKET -#define CS_WAIT_NEXT_PACKET 570 -#endif - /* * cs_softc: per line info and status */ @@ -105,8 +102,11 @@ static struct cs_softc { static u_long cs_unit = NCS; -static int cs_attach __P((struct cs_softc *, int, int)); -static int cs_attach_isa __P((struct isa_device *)); +static int cs_recv_delay = 570; +SYSCTL_INT(_machdep, OID_AUTO, cs_recv_delay, CTLFLAG_RW, &cs_recv_delay, 0, ""); + +static int cs_attach __P((struct cs_softc *, int, int)); +static int cs_attach_isa __P((struct isa_device *)); static void cs_init __P((void *)); static int cs_ioctl __P((struct ifnet *, u_long, caddr_t)); static int cs_probe __P((struct isa_device *)); @@ -799,7 +799,7 @@ cs_get_packet(struct cs_softc *sc) ifp->if_ipackets++; if (length==ETHER_MAX_LEN-ETHER_CRC_LEN) - DELAY( CS_WAIT_NEXT_PACKET ); + DELAY( cs_recv_delay ); } else { m_freem(m); } @@ -1212,9 +1212,10 @@ cs_mediaset(struct cs_softc *sc, int media) switch (IFM_SUBTYPE(media)) { default: case IFM_AUTO: - if (error=enable_tp(sc)) - if (error=enable_bnc(sc)) - error=enable_aui(sc); + if ((error=enable_tp(sc))==0) + error = cs_duplex_auto(sc); + else if (error=enable_bnc(sc)) + error = enable_aui(sc); break; case IFM_10_T: if (error=enable_tp(sc)) -- cgit v1.1