Date: Fri, 27 Sep 1996 16:14:56 +0900 (JST) From: Naoki Hamada <nao@sbl.cl.nec.co.jp> To: Guido.vanRooij@nl.cis.philips.com Cc: freebsd-hackers@FreeBSD.org Subject: Re: new if_vx driver in incoming on freefal Message-ID: <199609270714.QAA20879@sirius.sbl.cl.nec.co.jp> In-Reply-To: Guido van Rooij's message of "Fri, 27 Sep 1996 08:52:51 %2B0200 (MET DST)" <199609270652.IAA27301@spooky.lss.cp.philips.com> References: <199609270652.IAA27301@spooky.lss.cp.philips.com>
next in thread | previous in thread | raw e-mail | index | archive | help
Guido wrote: >> Your new vx driver do not work properly when ifconfig'ed with >> link[012] options, and what is worse, the fast ethernet connector of a >> 3C595 adapter is completely ignored. > >Oh? I thought I had just copies the stuff from the old one in freebsd. The old vx driver failed to work with link[012] options. You copied the stuff, so the new one also fails. The following is today's snapshot. How do you like it? -nao --- ../newvx/if_vx.c Wed Sep 25 17:12:26 1996 +++ if_vx.c Fri Sep 27 16:09:36 1996 @@ -146,8 +146,6 @@ return NULL; } -static char *vx_conn_type[] = {"UTP", "AUI", "???", "BNC"}; - static void vx_pci_attach( pcici_t config_id, @@ -155,8 +153,7 @@ { struct vx_softc *sc; struct ifnet *ifp; - u_short i, *p; - u_long j; + u_short k, i, n; if (unit >= NVX) { printf("vx%d: not configured; kernel is built for only %d device%s.\n", @@ -174,31 +171,26 @@ DELAY(1000); sc->vx_connectors = 0; - i = pci_conf_read(config_id, 0x48); - GO_WINDOW(3); - j = (inl(BASE + VX_W3_INTERNAL_CFG) & INTERNAL_CONNECTOR_MASK) - >> INTERNAL_CONNECTOR_BITS; - if (i & RS_AUI) { - printf("aui"); - sc->vx_connectors |= AUI; - } - if (i & RS_BNC) { - if (sc->vx_connectors) - printf("/"); - printf("bnc"); - sc->vx_connectors |= BNC; - } - if (i & RS_UTP) { - if (sc->vx_connectors) - printf("/"); - printf("utp"); - sc->vx_connectors |= UTP; + /* Reset Options */ + sc->vx_connectors = pci_conf_read(config_id, 0x48) & 0x0000007f; + for (n = 0, k = 0; k < VX_CONNECTORS; k++) { + if (sc->vx_connectors & connector_table[k].bit) { + if (n > 0) { + printf("/"); + } + printf(connector_table[k].name); + n++; + } } - if (!(sc->vx_connectors & 7)) + if (sc->vx_connectors == 0) { printf("no connectors!"); - else - printf("[*%s*]", vx_conn_type[j]); - + } else { + GO_WINDOW(3); + sc->vx_connector = (inl(BASE + VX_W3_INTERNAL_CFG) + & INTERNAL_CONNECTOR_MASK) + >> INTERNAL_CONNECTOR_BITS; + printf("[*%s*]", connector_table[sc->vx_connector].name); + } /* * Read the station address from the eeprom @@ -216,13 +208,7 @@ sc->arpcom.ac_enaddr[(i << 1) + 1] = x; } - printf(" address %x:%x:%x:%x:%x:%x\n", - sc->arpcom.ac_enaddr[0], - sc->arpcom.ac_enaddr[1], - sc->arpcom.ac_enaddr[2], - sc->arpcom.ac_enaddr[3], - sc->arpcom.ac_enaddr[4], - sc->arpcom.ac_enaddr[5]); + printf(" address %6D\n", sc->arpcom.ac_enaddr, ":"); /* Still in window 0 */ if (vxbusyeeprom(unit)) @@ -279,7 +265,7 @@ { register struct vx_softc *sc = &vx_softc[unit]; register struct ifnet *ifp = &sc->arpcom.ac_if; - int s, i, j; + int i; while (inw(BASE + VX_STATUS) & S_COMMAND_IN_PROGRESS); @@ -342,7 +328,7 @@ { register struct vx_softc *sc = &vx_softc[unit]; register struct ifnet *ifp = &sc->arpcom.ac_if; - int j; + int i, j; /* * S.B. @@ -360,38 +346,49 @@ * connector specified in the EEPROM is used * (if present on card or AUI if not). */ - GO_WINDOW(4); - if(ifp->if_flags & IFF_LINK0 && sc->vx_connectors & AUI) { - /* nothing */ - } - else if(ifp->if_flags & IFF_LINK1 && sc->vx_connectors & BNC) { - outw(BASE + VX_COMMAND, START_TRANSCEIVER); - DELAY(1000); - } else if(ifp->if_flags & IFF_LINK2 && sc->vx_connectors & UTP) { - outw(BASE + VX_W4_MEDIA_TYPE, ENABLE_UTP); + /* Set the xcvr. */ + if(ifp->if_flags & IFF_LINK0 && sc->vx_connectors & CONNECTOR_AUI) { + i = CONNECTOR_AUI; + } else if(ifp->if_flags & IFF_LINK1 && sc->vx_connectors & CONNECTOR_BNC) { + i = CONNECTOR_BNC; + } else if(ifp->if_flags & IFF_LINK2 && sc->vx_connectors & CONNECTOR_UTP) { + i = CONNECTOR_UTP; } else { - GO_WINDOW(3); - j = (inl(BASE + VX_W3_INTERNAL_CFG) & INTERNAL_CONNECTOR_MASK) - >> INTERNAL_CONNECTOR_BITS; - switch(j) { - case ACF_CONNECTOR_UTP: - GO_WINDOW(4); - outw(BASE + VX_W4_MEDIA_TYPE, ENABLE_UTP); - break; - case ACF_CONNECTOR_BNC: - if(sc->vx_connectors & BNC) { - outw(BASE + VX_COMMAND, START_TRANSCEIVER); - DELAY(1000); - } - break; - case ACF_CONNECTOR_AUI: - /* nothing to do */ - break; - default: - printf("vx%d: strange connector type in EEPROM: assuming AUI\n", - unit); - break; + i = sc->vx_connector; + } + GO_WINDOW(3); + j = inl(BASE + VX_W3_INTERNAL_CFG) & ~INTERNAL_CONNECTOR_MASK; + outl(BASE + VX_W3_INTERNAL_CFG, j + | (connector_table[i].bit <<INTERNAL_CONNECTOR_BITS)); + switch(i) { + case CONNECTOR_UTP: + if(sc->vx_connectors & connector_table[CONNECTOR_UTP].bit) { + GO_WINDOW(4); + outw(BASE + VX_W4_MEDIA_TYPE, ENABLE_UTP); + } + break; + case CONNECTOR_BNC: + if(sc->vx_connectors & connector_table[CONNECTOR_BNC].bit) { + outw(BASE + VX_COMMAND, START_TRANSCEIVER); + DELAY(1000); } + break; + case CONNECTOR_TX: + if(sc->vx_connectors & connector_table[CONNECTOR_TX].bit) { + GO_WINDOW(4); + outw(BASE + VX_W4_MEDIA_TYPE, LINKBEAT_ENABLE); + } + break; + case CONNECTOR_FX: + if(sc->vx_connectors & connector_table[CONNECTOR_FX].bit) { + GO_WINDOW(4); + outw(BASE + VX_W4_MEDIA_TYPE, LINKBEAT_ENABLE); + } + break; + default: + printf("vx%d: strange connector type in EEPROM: assuming AUI\n", + unit); + break; } GO_WINDOW(1); } @@ -479,6 +476,7 @@ splx(sh); ++ifp->if_opackets; + ifp->if_timer = 1; readcheck: if ((inw(BASE + VX_W1_RX_STATUS) & ERR_INCOMPLETE) == 0) { @@ -601,7 +599,6 @@ register short status; register struct vx_softc *sc = &vx_softc[unit]; struct ifnet *ifp = &sc->arpcom.ac_if; - int ret = 0; for (;;) { outw(BASE + VX_COMMAND, C_INTR_LATCH); @@ -623,15 +620,18 @@ if (status & S_RX_COMPLETE) vxread(unit); if (status & S_TX_AVAIL) { + ifp->if_timer = 0; sc->arpcom.ac_if.if_flags &= ~IFF_OACTIVE; vxstart(&sc->arpcom.ac_if); } if (status & S_CARD_FAILURE) { printf("vx%d: adapter failure (%x)\n", unit, status); + ifp->if_timer = 0; vxreset(unit); return; } if (status & S_TX_COMPLETE) { + ifp->if_timer = 0; vxtxstat(unit); vxstart(ifp); } @@ -989,10 +989,9 @@ { register struct vx_softc *sc = &vx_softc[unit]; - log(LOG_ERR, "vx%d: device timeout\n", unit); - ++sc->arpcom.ac_if.if_oerrors; - - vxreset(unit); + ifp->if_flags &= ~IFF_OACTIVE; + vxstart(ifp); + vxintr(ifp->if_unit); } static void @@ -1033,10 +1032,6 @@ } if (!i) { printf("\nvx%d: eeprom failed to come ready\n", unit); - return (1); - } - if (j & EEPROM_TST_MODE) { - printf("\nvx%d: erase pencil mark, or disable plug-n-play mode!\n", unit); return (1); } return (0); --- ../newvx/if_vxreg.h Tue Sep 24 22:40:04 1996 +++ if_vxreg.h Thu Sep 26 09:35:11 1996 @@ -56,6 +56,7 @@ int next_mb; /* Which mbuf to use next. */ int last_mb; /* Last mbuf. */ char vx_connectors; /* Connectors on this card. */ + char vx_connector; /* Connector to use. */ short tx_start_thresh; /* Current TX_start_thresh. */ int tx_succ_ok; /* # packets sent in sequence */ /* w/o underrun */ @@ -93,7 +94,6 @@ #define EEPROM_CMD_EWEN 0x0030 /* Erase/Write Enable: No data required */ #define EEPROM_BUSY (1<<15) -#define EEPROM_TST_MODE (1<<14) /* * Some short functions, worth to let them be a macro @@ -374,6 +374,11 @@ #define RS_AUI (1<<5) #define RS_BNC (1<<4) #define RS_UTP (1<<3) +#define RS_T4 (1<<0) +#define RS_TX (1<<1) +#define RS_FX (1<<2) +#define RS_MII (1<<6) + /* * FIFO Status (Window 4) @@ -426,17 +431,38 @@ #define AUI 0x1 #define BNC 0x2 #define UTP 0x4 -#define IS_AUI (1<<13) -#define IS_BNC (1<<12) -#define IS_UTP (1<<9) +#define T4 0x8 +#define TX 0x10 +#define FX 0x20 +#define MII 0x40 #define EEPROM_BUSY (1<<15) #define EEPROM_TST_MODE (1<<14) #define READ_EEPROM (1<<7) -#define ENABLE_UTP 0xc0 +#define JABBER_GUARD_ENABLE 0x40 +#define LINKBEAT_ENABLE 0x80 +#define ENABLE_UTP (JABBER_GUARD_ENABLE | LINKBEAT_ENABLE) #define DISABLE_UTP 0x0 #define RX_BYTES_MASK (u_short) (0x07ff) #define TX_INDICATE 1<<15 -#define IS_PCI_AUI (1<<5) -#define IS_PCI_BNC (1<<4) -#define IS_PCI_UTP (1<<3) +#define VX_CONNECTORS 7 + +struct connector_entry { + int bit; + char *name; +} connector_table[VX_CONNECTORS] = { +#define CONNECTOR_UTP 0 + { 0x08, "utp"}, +#define CONNECTOR_AUI 1 + { 0x20, "aui"}, +/* dummy */ + { 0, 0}, +#define CONNECTOR_BNC 3 + { 0x10, "bnc"}, +#define CONNECTOR_TX 4 + { 0x02, "tx"}, +#define CONNECTOR_FX 5 + { 0x04, "fx"}, +#define CONNECTOR_MII 6 + { 0x40, "mii"} +};
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199609270714.QAA20879>