1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-10-19 02:29:40 +00:00

New vx driver for:

3COM 3C590 Etherlink III PCI,
        3COM 3C595 Fast Etherlink PCI,
        3COM 3C592 Etherlink III EISA,
        3COM 3C590 Fast Etherlink EISA,
        3COM 3C900 Etherlink XL PCI and
        3COM 3C905 Fast Etherlink XL PCI.

This driver is based on OpenBSD's driver. I modified it to run under FreeBSd
and made it actually work usefully.
Afterwards, nao@tom-yam.or.jp (HAMADA Naoki) added EISA support as well as
early support for 3C900 Etherlink XL PCI and 3C905 Fast Etherlink XL PCI.
He also split up the driver in a bus independant and bus dependant parts.

Especially the 3c59X support should be pretty stable now.

Submitted by:	partly nao@tom-yam.or.jp (HAMADA Naoki)
Obtained from:partly OpenBSD
This commit is contained in:
Guido van Rooij 1996-11-04 22:17:20 +00:00
parent b20d9ed2e7
commit b3ac88f13f
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=19410
10 changed files with 1870 additions and 1269 deletions

View File

@ -17,6 +17,7 @@ ddb/db_watch.c optional ddb
ddb/db_write_cmd.c optional ddb
dev/ccd/ccd.c optional ccd device-driver
dev/vn/vn.c optional vn
dev/vx/if_vx.c optional vx device-driver
gnu/ext2fs/ext2_alloc.c optional ext2fs
gnu/ext2fs/ext2_balloc.c optional ext2fs
gnu/ext2fs/ext2_inode.c optional ext2fs
@ -308,7 +309,7 @@ pci/if_lnc_p.c optional lnc device-driver
pci/if_pdq.c optional fea device-driver
pci/if_pdq.c optional fpa device-driver
pci/if_sr_p.c optional sr device-driver
pci/if_vx.c optional vx device-driver
pci/if_vx_pci.c optional vx device-driver
pci/meteor.c optional meteor device-driver
pci/ncr.c optional ncr device-driver
pci/pci.c optional pci device-driver

View File

@ -1,7 +1,7 @@
# This file tells config what files go into building a kernel,
# files marked standard are always included.
#
# $Id: files.i386,v 1.140 1996/09/11 19:53:30 phk Exp $
# $Id: files.i386,v 1.141 1996/10/17 19:31:45 bde Exp $
#
aic7xxx_asm optional ahc device-driver \
dependency "$S/dev/aic7xxx/aic7xxx_asm.c" \
@ -35,6 +35,7 @@ i386/eisa/aic7770.c optional ahc device-driver
i386/eisa/aha1742.c optional ahb device-driver
i386/eisa/bt74x.c optional bt device-driver
i386/eisa/eisaconf.c optional eisa
i386/eisa/if_vx_eisa.c optional vx device-driver
i386/i386/autoconf.c standard device-driver
i386/i386/cons.c standard
i386/i386/db_disasm.c optional ddb

1074
sys/dev/vx/if_vx.c Normal file

File diff suppressed because it is too large Load Diff

188
sys/dev/vx/if_vx_eisa.c Normal file
View File

@ -0,0 +1,188 @@
/*
* Copyright (C) 1996 Naoki Hamada <nao@tom-yam.or.jp>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the author nor the names of any co-contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
#include "eisa.h"
#if NEISA > 0
#include "vx.h"
#if NVX > 0
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/socket.h>
#include <net/if.h>
#ifdef INET
#include <netinet/in.h>
#include <netinet/if_ether.h>
#endif
#ifdef NS
#include <netns/ns.h>
#include <netns/ns_if.h>
#endif
#include <machine/clock.h>
#include <i386/eisa/eisaconf.h>
#include <dev/vx/if_vxreg.h>
#define EISA_DEVICE_ID_3COM_3C592 0x506d5920
#define EISA_DEVICE_ID_3COM_3C597_TX 0x506d5970
#define EISA_DEVICE_ID_3COM_3C597_T4 0x506d5971
#define EISA_DEVICE_ID_3COM_3C597_MII 0x506d5972
#define VX_EISA_SLOT_OFFSET 0x0c80
#define VX_EISA_IOSIZE 0x000a
#define VX_RESOURCE_CONFIG 0x0008
static char *vx_match __P((eisa_id_t type));
static int vx_eisa_probe __P((void));
static int vx_eisa_attach __P((struct eisa_device *));
struct eisa_driver vx_eisa_driver = {
"vx",
vx_eisa_probe,
vx_eisa_attach,
/* shutdown */ NULL,
&vx_count
};
DATA_SET(eisadriver_set, vx_eisa_driver);
static char*
vx_match(type)
eisa_id_t type;
{
switch (type) {
case EISA_DEVICE_ID_3COM_3C592:
return "3Com 3C592 Network Adapter";
break;
case EISA_DEVICE_ID_3COM_3C597_TX:
return "3Com 3C597-TX Network Adapter";
break;
case EISA_DEVICE_ID_3COM_3C597_T4:
return "3Com 3C597-T4 Network Adapter";
break;
case EISA_DEVICE_ID_3COM_3C597_MII:
return "3Com 3C597-MII Network Adapter";
break;
default:
break;
}
return (NULL);
}
static int
vx_eisa_probe(void)
{
u_long iobase;
struct eisa_device *e_dev = NULL;
int count;
count = 0;
while ((e_dev = eisa_match_dev(e_dev, vx_match))) {
u_long port;
port = e_dev->ioconf.slot * EISA_SLOT_SIZE;
iobase = port + VX_EISA_SLOT_OFFSET;
eisa_add_iospace(e_dev, iobase, VX_EISA_IOSIZE, RESVADDR_NONE);
eisa_add_iospace(e_dev, port, VX_IOSIZE, RESVADDR_NONE);
/* Set irq */
eisa_add_intr(e_dev, inw(iobase + VX_RESOURCE_CONFIG) >> 12);
eisa_registerdev(e_dev, &vx_eisa_driver);
count++;
}
return count;
}
static int
vx_eisa_attach(e_dev)
struct eisa_device *e_dev;
{
struct vx_softc *sc;
int unit = e_dev->unit;
int irq = ffs(e_dev->ioconf.irq) - 1;
resvaddr_t *ioport;
resvaddr_t *eisa_ioport;
u_char level_intr;
ioport = e_dev->ioconf.ioaddrs.lh_first;
if (!ioport)
return -1;
eisa_ioport = ioport->links.le_next;
if (!eisa_ioport)
return -1;
eisa_reg_start(e_dev);
if (eisa_reg_iospace(e_dev, ioport))
return -1;
if (eisa_reg_iospace(e_dev, eisa_ioport))
return -1;
if ((sc = vxalloc(unit)) == NULL)
return -1;
sc->vx_io_addr = ioport->addr;
level_intr = FALSE;
if (eisa_reg_intr(e_dev, irq, (void *) vxintr, (void *) sc, &net_imask,
/* shared == */ level_intr)) {
vxfree(sc);
return -1;
}
eisa_reg_end(e_dev);
/* Now the registers are availible through the lower ioport */
vxattach(sc);
if (eisa_enable_intr(e_dev, irq)) {
vxfree(sc);
eisa_release_intr(e_dev, irq, (void *) vxintr);
return -1;
}
return 0;
}
#endif /* NVX > 0 */
#endif /* NEISA > 0 */

145
sys/dev/vx/if_vx_pci.c Normal file
View File

@ -0,0 +1,145 @@
/*
* Copyright (C) 1996 Naoki Hamada <nao@tom-yam.or.jp>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the author nor the names of any co-contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
#include "pci.h"
#if NPCI > 0
#include "vx.h"
#if NVX > 0
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/socket.h>
#include <net/if.h>
#ifdef INET
#include <netinet/in.h>
#include <netinet/if_ether.h>
#endif
#ifdef NS
#include <netns/ns.h>
#include <netns/ns_if.h>
#endif
#include <machine/clock.h>
#include <pci/pcivar.h>
#include <dev/vx/if_vxreg.h>
static void vx_pci_shutdown(int, void *);
static char *vx_pci_probe(pcici_t, pcidi_t);
static void vx_pci_attach(pcici_t, int unit);
static void
vx_pci_shutdown(
int howto,
void *sc)
{
vxstop(sc);
vxfree(sc);
}
static char*
vx_pci_probe(
pcici_t config_id,
pcidi_t device_id)
{
if(device_id == 0x590010b7ul)
return "3COM 3C590 Etherlink III PCI";
if(device_id == 0x595010b7ul || device_id == 0x595110b7ul ||
device_id == 0x595210b7ul)
return "3COM 3C595 Fast Etherlink III PCI";
if(device_id == 0x900010b7ul || device_id == 0x900110b7ul)
return "3COM 3C900 Etherlink XL PCI";
if(device_id == 0x905010b7ul || device_id == 0x905110b7ul)
return "3COM 3C595 Fast Etherlink XL PCI";
return NULL;
}
static void
vx_pci_attach(
pcici_t config_id,
int unit)
{
struct vx_softc *sc;
if (unit >= NVX) {
printf("vx%d: not configured; kernel is built for only %d device%s.\n",
unit, NVX, NVX == 1 ? "" : "s");
return;
}
sc = vxalloc(unit);
sc->vx_io_addr = pci_conf_read(config_id, 0x10) & 0xffffffe0;
if (vxattach(sc) == 0) {
return;
}
/* defect check for 3C590 */
if ((pci_conf_read(config_id, 0) >> 16) == 0x5900) {
GO_WINDOW(0);
if (vxbusyeeprom(sc))
return;
outw(BASE + VX_W0_EEPROM_COMMAND, EEPROM_CMD_RD | EEPROM_SOFT_INFO_2);
if (vxbusyeeprom(sc))
return;
if (!(inw(BASE + VX_W0_EEPROM_DATA) & NO_RX_OVN_ANOMALY)) {
printf("Warning! Defective early revision adapter!\n");
}
}
/*
* Add shutdown hook so that DMA is disabled prior to reboot. Not
* doing do could allow DMA to corrupt kernel memory during the
* reboot before the driver initializes.
*/
at_shutdown(vx_pci_shutdown, sc, SHUTDOWN_POST_SYNC);
pci_map_int(config_id, (void *) vxintr, (void *) sc, &net_imask);
}
static struct pci_device vxdevice = {
"vx",
vx_pci_probe,
vx_pci_attach,
&vx_count,
NULL
};
DATA_SET (pcidevice_set, vxdevice);
#endif /* NVX */
#endif /* NPCI */

View File

@ -49,38 +49,18 @@
* Ethernet software status per interface.
*/
struct vx_softc {
struct arpcom arpcom; /* Ethernet common part */
short vx_io_addr; /* i/o bus address */
#define MAX_MBS 8 /* # of mbufs we keep around */
struct mbuf *mb[MAX_MBS]; /* spare mbuf storage. */
int next_mb; /* Which mbuf to use next. */
int last_mb; /* Last mbuf. */
struct mbuf *top, *mcur;
short tx_start_thresh; /* Current TX_start_thresh. */
short tx_rate;
short tx_counter;
short rx_early_thresh; /* Current RX_early_thresh. */
short rx_latency;
short rx_avg_pkt;
short cur_len;
u_short vx_connectors; /* Connectors on this card. */
int stat; /* some flags */
#define F_RX_FIRST 0x1
#define F_WAIT_TRAIL 0x2
#define F_RX_TRAILER 0x4
#define F_PROMISC 0x8
#define F_ALLMULTI 0x10
#define F_ACCESS_32_BITS 0x100
#ifdef VX_LOCAL_STATS
short tx_underrun;
short rx_no_first;
short rx_no_mbuf;
short rx_bpf_disc;
short rx_overrunf;
short rx_overrunl;
#endif
int unit; /* unit number */
struct arpcom arpcom; /* Ethernet common part */
u_int vx_io_addr; /* i/o bus address */
#define MAX_MBS 8 /* # of mbufs we keep around */
struct mbuf *mb[MAX_MBS]; /* spare mbuf storage. */
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 */
};
/*
@ -115,13 +95,10 @@ struct vx_softc {
#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
*/
#define is_eeprom_busy(b) (inw((b)+VX_W0_EEPROM_COMMAND)&EEPROM_BUSY)
#define GO_WINDOW(x) outw(BASE+VX_COMMAND, WINDOW_SELECT|(x))
/**************************************************************************
* *
@ -140,6 +117,9 @@ struct vx_softc {
#define EEPROM_MFG_ID 0x7 /* 0x6d50 */
#define EEPROM_ADDR_CFG 0x8 /* Base addr */
#define EEPROM_RESOURCE_CFG 0x9 /* IRQ. Bits 12-15 */
#define EEPROM_OEM_ADDR_0 0xa /* Word */
#define EEPROM_OEM_ADDR_1 0xb /* Word */
#define EEPROM_OEM_ADDR_2 0xc /* Word */
#define EEPROM_SOFT_INFO_2 0xf /* Software information 2 */
#define NO_RX_OVN_ANOMALY (1<<5)
@ -165,6 +145,13 @@ struct vx_softc {
/* Write */
#define VX_W0_EEPROM_DATA 0x0c
#define VX_W0_EEPROM_COMMAND 0x0a
#define VX_W0_RESOURCE_CFG 0x08
#define VX_W0_ADDRESS_CFG 0x06
#define VX_W0_CONFIG_CTRL 0x04
/* Read */
#define VX_W0_PRODUCT_ID 0x02
#define VX_W0_MFG_ID 0x00
/*
* Window 1 registers. Operating Set.
@ -192,7 +179,7 @@ struct vx_softc {
#define VX_W2_ADDR_0 0x00
/*
* Window 3 registers.
* Window 3 registers. FIFO Management.
*/
/* Read */
#define VX_W3_INTERNAL_CFG 0x00
@ -270,33 +257,32 @@ struct vx_softc {
#define TX_DISABLE (u_short) (0xa<<11)
#define TX_RESET (u_short) (0xb<<11)
#define REQ_INTR (u_short) (0xc<<11)
/*
* The following C_* acknowledge the various interrupts. Some of them don't
* do anything. See the manual.
*/
#define ACK_INTR (u_short) (0x6800)
# define C_INTR_LATCH (u_short) (ACK_INTR|0x1)
# define C_CARD_FAILURE (u_short) (ACK_INTR|0x2)
# define C_TX_COMPLETE (u_short) (ACK_INTR|0x4)
# define C_TX_AVAIL (u_short) (ACK_INTR|0x8)
# define C_RX_COMPLETE (u_short) (ACK_INTR|0x10)
# define C_RX_EARLY (u_short) (ACK_INTR|0x20)
# define C_INT_RQD (u_short) (ACK_INTR|0x40)
# define C_UPD_STATS (u_short) (ACK_INTR|0x80)
#define SET_INTR_MASK (u_short) (0xe<<11)
#define SET_RD_0_MASK (u_short) (0xf<<11)
#define SET_RX_FILTER (u_short) (0x10<<11)
#define FIL_INDIVIDUAL (u_short) (0x1)
#define FIL_GROUP (u_short) (0x2)
#define FIL_BRDCST (u_short) (0x4)
#define FIL_ALL (u_short) (0x8)
# define FIL_INDIVIDUAL (u_short) (0x1)
# define FIL_MULTICAST (u_short) (0x02)
# define FIL_BRDCST (u_short) (0x04)
# define FIL_PROMISC (u_short) (0x08)
#define SET_RX_EARLY_THRESH (u_short) (0x11<<11)
#define SET_TX_AVAIL_THRESH (u_short) (0x12<<11)
#define SET_TX_START_THRESH (u_short) (0x13<<11)
#define STATS_ENABLE (u_short) (0x15<<11)
#define STATS_DISABLE (u_short) (0x16<<11)
#define STOP_TRANSCEIVER (u_short) (0x17<<11)
/*
* The following C_* acknowledge the various interrupts. Some of them don't
* do anything. See the manual.
*/
#define ACK_INTR (u_short) (0x6800)
#define C_INTR_LATCH (u_short) (ACK_INTR|0x1)
#define C_CARD_FAILURE (u_short) (ACK_INTR|0x2)
#define C_TX_COMPLETE (u_short) (ACK_INTR|0x4)
#define C_TX_AVAIL (u_short) (ACK_INTR|0x8)
#define C_RX_COMPLETE (u_short) (ACK_INTR|0x10)
#define C_RX_EARLY (u_short) (ACK_INTR|0x20)
#define C_INT_RQD (u_short) (ACK_INTR|0x40)
#define C_UPD_STATS (u_short) (ACK_INTR|0x80)
#define C_MASK (u_short) 0xFF /* mask of C_* */
/*
* Status register. All windows.
@ -324,33 +310,24 @@ struct vx_softc {
#define S_RX_EARLY (u_short) (0x20)
#define S_INT_RQD (u_short) (0x40)
#define S_UPD_STATS (u_short) (0x80)
#define S_MASK (u_short) 0xFF /* mask of S_* */
#define S_5_INTS (S_CARD_FAILURE|S_TX_COMPLETE|\
S_TX_AVAIL|S_RX_COMPLETE|S_RX_EARLY)
#define S_COMMAND_IN_PROGRESS (u_short) (0x1000)
/* Address Config. Register.
#define VX_BUSY_WAIT while (inw(BASE + VX_STATUS) & S_COMMAND_IN_PROGRESS)
/* Address Config. Register.
* Window 0/Port 06
*/
#define ACF_CONNECTOR_BITS 14
#define ACF_CONNECTOR_BITS 14
#define ACF_CONNECTOR_UTP 0
#define ACF_CONNECTOR_AUI 1
#define ACF_CONNECTOR_BNC 3
#define INTERNAL_CONNECTOR_BITS 20
#define INTERNAL_CONNECTOR_MASK 0x00700000
/* Resource configuration register.
* Window 0/Port 08
*
*/
#define SET_IRQ(i) (((i)<<12) | 0xF00) /* set IRQ i */
#define INTERNAL_CONNECTOR_MASK 0x01700000
/*
* FIFO Registers.
* RX Status. Window 1/Port 08
* FIFO Registers. RX Status.
*
* 15: Incomplete or FIFO empty.
* 14: 1: Error in RX Packet 0: Incomplete or no error.
@ -365,18 +342,18 @@ struct vx_softc {
*
* 10-0: RX Bytes (0-1514)
*/
#define ERR_RX_INCOMPLETE (u_short) (0x1<<15)
#define ERR_RX (u_short) (0x1<<14)
#define ERR_RX_OVERRUN (u_short) (0x8<<11)
#define ERR_RX_RUN_PKT (u_short) (0xb<<11)
#define ERR_RX_ALIGN (u_short) (0xc<<11)
#define ERR_RX_CRC (u_short) (0xd<<11)
#define ERR_RX_OVERSIZE (u_short) (0x9<<11)
#define ERR_RX_DRIBBLE (u_short) (0x2<<11)
#define ERR_INCOMPLETE (u_short) (0x8000)
#define ERR_RX (u_short) (0x4000)
#define ERR_MASK (u_short) (0x7800)
#define ERR_OVERRUN (u_short) (0x4000)
#define ERR_RUNT (u_short) (0x5800)
#define ERR_ALIGNMENT (u_short) (0x6000)
#define ERR_CRC (u_short) (0x6800)
#define ERR_OVERSIZE (u_short) (0x4800)
#define ERR_DRIBBLE (u_short) (0x1000)
/*
* FIFO Registers.
* TX Status. Window 1/Port 0B
* TX Status.
*
* Reports the transmit status of a completed transmission. Writing this
* register pops the transmit completion stack.
@ -393,36 +370,85 @@ struct vx_softc {
*
*/
#define TXS_COMPLETE 0x80
#define TXS_SUCCES_INTR_REQ 0x40
#define TXS_INTR_REQ 0x40
#define TXS_JABBER 0x20
#define TXS_UNDERRUN 0x10
#define TXS_MAX_COLLISION 0x8
#define TXS_STATUS_OVERFLOW 0x4
#define RS_AUI (1<<5)
#define RS_BNC (1<<4)
#define RS_UTP (1<<3)
#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)
/*
* Media type and status.
* Window 4/Port 0A
* FIFO Status (Window 4)
*
* Supports FIFO diagnostics
*
* Window 4/Port 0x04.1
*
* 15: 1=RX receiving (RO). Set when a packet is being received
* into the RX FIFO.
* 14: Reserved
* 13: 1=RX underrun (RO). Generates Adapter Failure interrupt.
* Requires RX Reset or Global Reset command to recover.
* It is generated when you read past the end of a packet -
* reading past what has been received so far will give bad
* data.
* 12: 1=RX status overrun (RO). Set when there are already 8
* packets in the RX FIFO. While this bit is set, no additional
* packets are received. Requires no action on the part of
* the host. The condition is cleared once a packet has been
* read out of the RX FIFO.
* 11: 1=RX overrun (RO). Set when the RX FIFO is full (there
* may not be an overrun packet yet). While this bit is set,
* no additional packets will be received (some additional
* bytes can still be pending between the wire and the RX
* FIFO). Requires no action on the part of the host. The
* condition is cleared once a few bytes have been read out
* from the RX FIFO.
* 10: 1=TX overrun (RO). Generates adapter failure interrupt.
* Requires TX Reset or Global Reset command to recover.
* Disables Transmitter.
* 9-8: Unassigned.
* 7-0: Built in self test bits for the RX and TX FIFO's.
*/
#define ENABLE_UTP 0xc0
#define DISABLE_UTP 0x0
#define FIFOS_RX_RECEIVING (u_short) 0x8000
#define FIFOS_RX_UNDERRUN (u_short) 0x2000
#define FIFOS_RX_STATUS_OVERRUN (u_short) 0x1000
#define FIFOS_RX_OVERRUN (u_short) 0x0800
#define FIFOS_TX_OVERRUN (u_short) 0x0400
/*
* Misc defines for various things.
*/
#define ACTIVATE_ADAPTER_TO_CONFIG 0xff /* to the id_port */
#define MFG_ID 0x6d50 /* in EEPROM and W0 ADDR_CONFIG */
#define PROD_ID 0x9150
#define TAG_ADAPTER 0xd0
#define ACTIVATE_ADAPTER_TO_CONFIG 0xff
#define ENABLE_DRQ_IRQ 0x0001
#define MFG_ID 0x506d /* `TCM' */
#define PROD_ID 0x5090
#define GO_WINDOW(x) outw(BASE+VX_COMMAND, WINDOW_SELECT|(x))
#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 AUI 0x1
#define BNC 0x2
#define UTP 0x4
#define VX_IOSIZE 0x20
#define RX_BYTES_MASK (u_short) (0x07ff)
#define VX_CONNECTORS 8
/* EISA support */
#define VX_EISA_START 0x1000
#define VX_EISA_W0 0x0c80
extern struct vx_softc *vx_softc[];
extern u_long vx_count;
extern struct vx_softc *vxalloc __P((int));
extern void vxfree __P((struct vx_softc *));
extern int vxattach __P((struct vx_softc *));
extern void vxstop __P((struct vx_softc *));
extern void vxintr __P((struct vx_softc *));
extern int vxbusyeeprom __P((struct vx_softc *));

View File

@ -1,7 +1,7 @@
# This file tells config what files go into building a kernel,
# files marked standard are always included.
#
# $Id: files.i386,v 1.140 1996/09/11 19:53:30 phk Exp $
# $Id: files.i386,v 1.141 1996/10/17 19:31:45 bde Exp $
#
aic7xxx_asm optional ahc device-driver \
dependency "$S/dev/aic7xxx/aic7xxx_asm.c" \
@ -35,6 +35,7 @@ i386/eisa/aic7770.c optional ahc device-driver
i386/eisa/aha1742.c optional ahb device-driver
i386/eisa/bt74x.c optional bt device-driver
i386/eisa/eisaconf.c optional eisa
i386/eisa/if_vx_eisa.c optional vx device-driver
i386/i386/autoconf.c standard device-driver
i386/i386/cons.c standard
i386/i386/db_disasm.c optional ddb

188
sys/i386/eisa/if_vx_eisa.c Normal file
View File

@ -0,0 +1,188 @@
/*
* Copyright (C) 1996 Naoki Hamada <nao@tom-yam.or.jp>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the author nor the names of any co-contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
#include "eisa.h"
#if NEISA > 0
#include "vx.h"
#if NVX > 0
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/socket.h>
#include <net/if.h>
#ifdef INET
#include <netinet/in.h>
#include <netinet/if_ether.h>
#endif
#ifdef NS
#include <netns/ns.h>
#include <netns/ns_if.h>
#endif
#include <machine/clock.h>
#include <i386/eisa/eisaconf.h>
#include <dev/vx/if_vxreg.h>
#define EISA_DEVICE_ID_3COM_3C592 0x506d5920
#define EISA_DEVICE_ID_3COM_3C597_TX 0x506d5970
#define EISA_DEVICE_ID_3COM_3C597_T4 0x506d5971
#define EISA_DEVICE_ID_3COM_3C597_MII 0x506d5972
#define VX_EISA_SLOT_OFFSET 0x0c80
#define VX_EISA_IOSIZE 0x000a
#define VX_RESOURCE_CONFIG 0x0008
static char *vx_match __P((eisa_id_t type));
static int vx_eisa_probe __P((void));
static int vx_eisa_attach __P((struct eisa_device *));
struct eisa_driver vx_eisa_driver = {
"vx",
vx_eisa_probe,
vx_eisa_attach,
/* shutdown */ NULL,
&vx_count
};
DATA_SET(eisadriver_set, vx_eisa_driver);
static char*
vx_match(type)
eisa_id_t type;
{
switch (type) {
case EISA_DEVICE_ID_3COM_3C592:
return "3Com 3C592 Network Adapter";
break;
case EISA_DEVICE_ID_3COM_3C597_TX:
return "3Com 3C597-TX Network Adapter";
break;
case EISA_DEVICE_ID_3COM_3C597_T4:
return "3Com 3C597-T4 Network Adapter";
break;
case EISA_DEVICE_ID_3COM_3C597_MII:
return "3Com 3C597-MII Network Adapter";
break;
default:
break;
}
return (NULL);
}
static int
vx_eisa_probe(void)
{
u_long iobase;
struct eisa_device *e_dev = NULL;
int count;
count = 0;
while ((e_dev = eisa_match_dev(e_dev, vx_match))) {
u_long port;
port = e_dev->ioconf.slot * EISA_SLOT_SIZE;
iobase = port + VX_EISA_SLOT_OFFSET;
eisa_add_iospace(e_dev, iobase, VX_EISA_IOSIZE, RESVADDR_NONE);
eisa_add_iospace(e_dev, port, VX_IOSIZE, RESVADDR_NONE);
/* Set irq */
eisa_add_intr(e_dev, inw(iobase + VX_RESOURCE_CONFIG) >> 12);
eisa_registerdev(e_dev, &vx_eisa_driver);
count++;
}
return count;
}
static int
vx_eisa_attach(e_dev)
struct eisa_device *e_dev;
{
struct vx_softc *sc;
int unit = e_dev->unit;
int irq = ffs(e_dev->ioconf.irq) - 1;
resvaddr_t *ioport;
resvaddr_t *eisa_ioport;
u_char level_intr;
ioport = e_dev->ioconf.ioaddrs.lh_first;
if (!ioport)
return -1;
eisa_ioport = ioport->links.le_next;
if (!eisa_ioport)
return -1;
eisa_reg_start(e_dev);
if (eisa_reg_iospace(e_dev, ioport))
return -1;
if (eisa_reg_iospace(e_dev, eisa_ioport))
return -1;
if ((sc = vxalloc(unit)) == NULL)
return -1;
sc->vx_io_addr = ioport->addr;
level_intr = FALSE;
if (eisa_reg_intr(e_dev, irq, (void *) vxintr, (void *) sc, &net_imask,
/* shared == */ level_intr)) {
vxfree(sc);
return -1;
}
eisa_reg_end(e_dev);
/* Now the registers are availible through the lower ioport */
vxattach(sc);
if (eisa_enable_intr(e_dev, irq)) {
vxfree(sc);
eisa_release_intr(e_dev, irq, (void *) vxintr);
return -1;
}
return 0;
}
#endif /* NVX > 0 */
#endif /* NEISA > 0 */

File diff suppressed because it is too large Load Diff

145
sys/pci/if_vx_pci.c Normal file
View File

@ -0,0 +1,145 @@
/*
* Copyright (C) 1996 Naoki Hamada <nao@tom-yam.or.jp>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the author nor the names of any co-contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
#include "pci.h"
#if NPCI > 0
#include "vx.h"
#if NVX > 0
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/socket.h>
#include <net/if.h>
#ifdef INET
#include <netinet/in.h>
#include <netinet/if_ether.h>
#endif
#ifdef NS
#include <netns/ns.h>
#include <netns/ns_if.h>
#endif
#include <machine/clock.h>
#include <pci/pcivar.h>
#include <dev/vx/if_vxreg.h>
static void vx_pci_shutdown(int, void *);
static char *vx_pci_probe(pcici_t, pcidi_t);
static void vx_pci_attach(pcici_t, int unit);
static void
vx_pci_shutdown(
int howto,
void *sc)
{
vxstop(sc);
vxfree(sc);
}
static char*
vx_pci_probe(
pcici_t config_id,
pcidi_t device_id)
{
if(device_id == 0x590010b7ul)
return "3COM 3C590 Etherlink III PCI";
if(device_id == 0x595010b7ul || device_id == 0x595110b7ul ||
device_id == 0x595210b7ul)
return "3COM 3C595 Fast Etherlink III PCI";
if(device_id == 0x900010b7ul || device_id == 0x900110b7ul)
return "3COM 3C900 Etherlink XL PCI";
if(device_id == 0x905010b7ul || device_id == 0x905110b7ul)
return "3COM 3C595 Fast Etherlink XL PCI";
return NULL;
}
static void
vx_pci_attach(
pcici_t config_id,
int unit)
{
struct vx_softc *sc;
if (unit >= NVX) {
printf("vx%d: not configured; kernel is built for only %d device%s.\n",
unit, NVX, NVX == 1 ? "" : "s");
return;
}
sc = vxalloc(unit);
sc->vx_io_addr = pci_conf_read(config_id, 0x10) & 0xffffffe0;
if (vxattach(sc) == 0) {
return;
}
/* defect check for 3C590 */
if ((pci_conf_read(config_id, 0) >> 16) == 0x5900) {
GO_WINDOW(0);
if (vxbusyeeprom(sc))
return;
outw(BASE + VX_W0_EEPROM_COMMAND, EEPROM_CMD_RD | EEPROM_SOFT_INFO_2);
if (vxbusyeeprom(sc))
return;
if (!(inw(BASE + VX_W0_EEPROM_DATA) & NO_RX_OVN_ANOMALY)) {
printf("Warning! Defective early revision adapter!\n");
}
}
/*
* Add shutdown hook so that DMA is disabled prior to reboot. Not
* doing do could allow DMA to corrupt kernel memory during the
* reboot before the driver initializes.
*/
at_shutdown(vx_pci_shutdown, sc, SHUTDOWN_POST_SYNC);
pci_map_int(config_id, (void *) vxintr, (void *) sc, &net_imask);
}
static struct pci_device vxdevice = {
"vx",
vx_pci_probe,
vx_pci_attach,
&vx_count,
NULL
};
DATA_SET (pcidevice_set, vxdevice);
#endif /* NVX */
#endif /* NPCI */