Date: Fri, 27 Sep 1996 23:04:22 +0200 (MET DST) From: guido@gvr.win.tue.nl (Guido van Rooij) To: nao@sbl.cl.nec.co.jp (Naoki Hamada) Cc: Guido.vanRooij@nl.cis.philips.com, freebsd-hackers@FreeBSD.org Subject: Re: new if_vx driver in incoming on freefal Message-ID: <199609272104.XAA02317@gvr.win.tue.nl> In-Reply-To: <199609270714.QAA20879@sirius.sbl.cl.nec.co.jp> from Naoki Hamada at "Sep 27, 96 04:14:56 pm"
next in thread | previous in thread | raw e-mail | index | archive | help
Naoki Hamada wrote: > 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? Here's an improved version. I am not able to compile it here, but apparently you didn't either (see the patch for the watchdog function). Btw: I moved the struct definition from the header to the source file as it is not good to allocate data from header files. -Guido --- if_vx.c.orig Wed Sep 25 10:12:26 1996 +++ if_vx.c Fri Sep 27 22:55:15 1996 @@ -104,6 +104,26 @@ #define ETHER_MAX_LEN 1518 #define ETHER_ADDR_LEN 6 +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"} +}; + static void vxtxstat __P((int unit)); static int vxstatus __P((int unit)); static void vxinit __P((int unit)); @@ -146,8 +166,6 @@ return NULL; } -static char *vx_conn_type[] = {"UTP", "AUI", "???", "BNC"}; - static void vx_pci_attach( pcici_t config_id, @@ -155,8 +173,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 +191,27 @@ 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) & 0x7f; + 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]); - + return; + } 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 @@ -208,7 +221,7 @@ int x; if (vxbusyeeprom(unit)) return; - outw(BASE + VX_W0_EEPROM_COMMAND, READ_EEPROM | i); + outw(BASE + VX_W0_EEPROM_COMMAND, EEPROM_CMD_RD | i); if (vxbusyeeprom(unit)) return; x = inw(BASE + VX_W0_EEPROM_DATA); @@ -216,18 +229,12 @@ 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)) return; - outw(BASE + VX_W0_EEPROM_COMMAND, READ_EEPROM | EEPROM_SOFT_INFO_2); + outw(BASE + VX_W0_EEPROM_COMMAND, EEPROM_CMD_RD | EEPROM_SOFT_INFO_2); if (vxbusyeeprom(unit)) return; if (!(inw(BASE + VX_W0_EEPROM_DATA) & NO_RX_OVN_ANOMALY)) { @@ -279,7 +286,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 +349,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 +367,52 @@ * 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; + case CONNECTOR_UTP: + /* nothing to do */ + break; + default: + printf("vx%d: strange connector type in EEPROM: assuming AUI\n", + unit); + break; } GO_WINDOW(1); } @@ -479,6 +500,7 @@ splx(sh); ++ifp->if_opackets; + ifp->if_timer = 1; readcheck: if ((inw(BASE + VX_W1_RX_STATUS) & ERR_INCOMPLETE) == 0) { @@ -601,7 +623,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 +644,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); } @@ -987,12 +1011,13 @@ vxwatchdog(unit) int unit; { - register struct vx_softc *sc = &vx_softc[unit]; - - log(LOG_ERR, "vx%d: device timeout\n", unit); - ++sc->arpcom.ac_if.if_oerrors; + struct ifnet *ifp = &vx_softc[unit].arpcom.ac_if; - vxreset(unit); + if (ifp->if_flags & IFF_DEBUG) + printf("vx%d: device timeout\n", unit); + ifp->if_flags &= ~IFF_OACTIVE; + vxstart(ifp); + vxintr(unit); } static void @@ -1022,7 +1047,7 @@ int unit; { struct vx_softc *sc = &vx_softc[unit] ; - int i = 100, j; + int i = 100; while (i--) { j = inw(BASE + VX_W0_EEPROM_COMMAND); @@ -1033,10 +1058,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); --- if_vxreg.h.orig Tue Sep 24 15:40:04 1996 +++ if_vxreg.h Fri Sep 27 22:54:51 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) @@ -423,20 +428,12 @@ #define MFG_ID 0x506d /* `TCM' */ #define PROD_ID 0x5090 #define GO_WINDOW(x) outw(BASE+VX_COMMAND, WINDOW_SELECT|(x)) -#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 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 +
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199609272104.XAA02317>