ss if_vx through indent, and use ANSI function definitions, prior to adding

if_media and DMA support to the driver.  The previous style was inconsistent
making it difficult to emulate existing style.
This commit is contained in:
Justin T. Gibbs 2004-08-18 16:56:54 +00:00
parent 28b31df727
commit 4187cdf189
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=133980
5 changed files with 959 additions and 987 deletions

File diff suppressed because it is too large Load diff

View file

@ -63,121 +63,117 @@ __FBSDID("$FreeBSD$");
static const char *vx_match(eisa_id_t type);
static const char*
static const char *
vx_match(eisa_id_t type)
{
switch (type) {
case EISA_DEVICE_ID_3COM_3C592:
return "3Com 3C592 Network Adapter";
case EISA_DEVICE_ID_3COM_3C597_TX:
return "3Com 3C597-TX Network Adapter";
case EISA_DEVICE_ID_3COM_3C597_T4:
return "3Com 3C597-T4 Network Adapter";
case EISA_DEVICE_ID_3COM_3C597_MII:
return "3Com 3C597-MII Network Adapter";
default:
break;
}
return (NULL);
switch (type) {
case EISA_DEVICE_ID_3COM_3C592:
return "3Com 3C592 Network Adapter";
case EISA_DEVICE_ID_3COM_3C597_TX:
return "3Com 3C597-TX Network Adapter";
case EISA_DEVICE_ID_3COM_3C597_T4:
return "3Com 3C597-T4 Network Adapter";
case EISA_DEVICE_ID_3COM_3C597_MII:
return "3Com 3C597-MII Network Adapter";
default:
break;
}
return (NULL);
}
static int
vx_eisa_probe(device_t dev)
{
const char *desc;
u_long iobase;
u_long port;
const char *desc;
u_long iobase;
u_long port;
desc = vx_match(eisa_get_id(dev));
if (!desc)
return (ENXIO);
device_set_desc(dev, desc);
desc = vx_match(eisa_get_id(dev));
if (!desc)
return (ENXIO);
device_set_desc(dev, desc);
port = eisa_get_slot(dev) * EISA_SLOT_SIZE;
iobase = port + VX_EISA_SLOT_OFFSET;
port = eisa_get_slot(dev) * EISA_SLOT_SIZE;
iobase = port + VX_EISA_SLOT_OFFSET;
eisa_add_iospace(dev, iobase, VX_EISA_IOSIZE, RESVADDR_NONE);
eisa_add_iospace(dev, port, VX_IOSIZE, RESVADDR_NONE);
eisa_add_iospace(dev, iobase, VX_EISA_IOSIZE, RESVADDR_NONE);
eisa_add_iospace(dev, port, VX_IOSIZE, RESVADDR_NONE);
/* Set irq */
eisa_add_intr(dev, inw(iobase + VX_RESOURCE_CONFIG) >> 12,
EISA_TRIGGER_EDGE);
/* Set irq */
eisa_add_intr(dev, inw(iobase + VX_RESOURCE_CONFIG) >> 12,
EISA_TRIGGER_EDGE);
return (0);
return (0);
}
static int
vx_eisa_attach(device_t dev)
{
struct vx_softc *sc;
struct resource *io = 0;
struct resource *eisa_io = 0;
struct resource *irq = 0;
int rid;
void *ih;
struct vx_softc *sc;
struct resource *io = 0;
struct resource *eisa_io = 0;
struct resource *irq = 0;
int rid;
void *ih;
/*
* The addresses are sorted in increasing order
* so we know the port to pass to the core ep
* driver comes first.
*/
rid = 0;
io = bus_alloc_resource_any(dev, SYS_RES_IOPORT, &rid, RF_ACTIVE);
if (!io) {
device_printf(dev, "No I/O space?!\n");
goto bad;
}
/*
* The addresses are sorted in increasing order
* so we know the port to pass to the core ep
* driver comes first.
*/
rid = 0;
io = bus_alloc_resource_any(dev, SYS_RES_IOPORT, &rid, RF_ACTIVE);
if (!io) {
device_printf(dev, "No I/O space?!\n");
goto bad;
}
rid = 1;
eisa_io = bus_alloc_resource_any(dev, SYS_RES_IOPORT, &rid, RF_ACTIVE);
if (!eisa_io) {
device_printf(dev, "No I/O space?!\n");
goto bad;
}
sc = device_get_softc(dev);
rid = 1;
eisa_io = bus_alloc_resource_any(dev, SYS_RES_IOPORT, &rid, RF_ACTIVE);
if (!eisa_io) {
device_printf(dev, "No I/O space?!\n");
goto bad;
}
sc->vx_res = io;
sc->bst = rman_get_bustag(io);
sc->bsh = rman_get_bushandle(io);
sc = device_get_softc(dev);
rid = 0;
irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_ACTIVE);
if (!irq) {
device_printf(dev, "No irq?!\n");
goto bad;
}
sc->vx_irq = irq;
sc->vx_res = io;
sc->bst = rman_get_bustag(io);
sc->bsh = rman_get_bushandle(io);
/* Now the registers are availible through the lower ioport */
rid = 0;
irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_ACTIVE);
if (!irq) {
device_printf(dev, "No irq?!\n");
goto bad;
}
vxattach(dev);
sc->vx_irq = irq;
if (bus_setup_intr(dev, irq, INTR_TYPE_NET, vxintr, sc, &ih))
goto bad;
/* Now the registers are availible through the lower ioport */
sc->vx_intrhand = ih;
vxattach(dev);
return 0;
if (bus_setup_intr(dev, irq, INTR_TYPE_NET, vxintr, sc, &ih)) {
goto bad;
}
sc->vx_intrhand = ih;
return 0;
bad:
if (io)
bus_release_resource(dev, SYS_RES_IOPORT, 0, io);
if (eisa_io)
bus_release_resource(dev, SYS_RES_IOPORT, 0, eisa_io);
if (irq)
bus_release_resource(dev, SYS_RES_IRQ, 0, irq);
return -1;
bad:
if (io)
bus_release_resource(dev, SYS_RES_IOPORT, 0, io);
if (eisa_io)
bus_release_resource(dev, SYS_RES_IOPORT, 0, eisa_io);
if (irq)
bus_release_resource(dev, SYS_RES_IRQ, 0, irq);
return -1;
}
static device_method_t vx_eisa_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, vx_eisa_probe),
DEVMETHOD(device_attach, vx_eisa_attach),
DEVMETHOD(device_probe, vx_eisa_probe),
DEVMETHOD(device_attach, vx_eisa_attach),
{ 0, 0 }
{0, 0}
};
static driver_t vx_eisa_driver = {

View file

@ -57,11 +57,11 @@ static int vx_pci_attach(device_t);
static device_method_t vx_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, vx_pci_probe),
DEVMETHOD(device_attach, vx_pci_attach),
DEVMETHOD(device_shutdown, vx_pci_shutdown),
DEVMETHOD(device_probe, vx_pci_probe),
DEVMETHOD(device_attach, vx_pci_attach),
DEVMETHOD(device_shutdown, vx_pci_shutdown),
{ 0, 0 }
{0, 0}
};
static driver_t vx_driver = {
@ -77,106 +77,100 @@ MODULE_DEPEND(vx, pci, 1, 1, 1);
MODULE_DEPEND(vx, ether, 1, 1, 1);
static void
vx_pci_shutdown(
device_t dev)
vx_pci_shutdown(device_t dev)
{
struct vx_softc *sc;
struct vx_softc *sc;
sc = device_get_softc(dev);
vxstop(sc);
return;
sc = device_get_softc(dev);
vxstop(sc);
}
static int
vx_pci_probe(
device_t dev)
vx_pci_probe(device_t dev)
{
u_int32_t device_id;
u_int32_t device_id;
device_id = pci_read_config(dev, PCIR_DEVVENDOR, 4);
device_id = pci_read_config(dev, PCIR_DEVVENDOR, 4);
if(device_id == 0x590010b7ul) {
device_set_desc(dev, "3COM 3C590 Etherlink III PCI");
return(0);
}
if(device_id == 0x595010b7ul || device_id == 0x595110b7ul ||
device_id == 0x595210b7ul) {
device_set_desc(dev, "3COM 3C595 Etherlink III PCI");
return(0);
}
if (device_id == 0x590010b7ul) {
device_set_desc(dev, "3COM 3C590 Etherlink III PCI");
return (0);
}
if (device_id == 0x595010b7ul || device_id == 0x595110b7ul ||
device_id == 0x595210b7ul) {
device_set_desc(dev, "3COM 3C595 Etherlink III PCI");
return (0);
}
/*
* The (Fast) Etherlink XL adapters are now supported by
* the xl driver, which uses bus master DMA and is much
* faster. (And which also supports the 3c905B.
*/
#ifdef VORTEX_ETHERLINK_XL
if(device_id == 0x900010b7ul || device_id == 0x900110b7ul) {
device_set_desc(dev, "3COM 3C900 Etherlink XL PCI");
return(0);
}
if(device_id == 0x905010b7ul || device_id == 0x905110b7ul) {
device_set_desc(dev, "3COM 3C905 Etherlink XL PCI");
return(0);
}
if (device_id == 0x900010b7ul || device_id == 0x900110b7ul) {
device_set_desc(dev, "3COM 3C900 Etherlink XL PCI");
return (0);
}
if (device_id == 0x905010b7ul || device_id == 0x905110b7ul) {
device_set_desc(dev, "3COM 3C905 Etherlink XL PCI");
return (0);
}
#endif
return (ENXIO);
return (ENXIO);
}
static int
vx_pci_attach(
device_t dev)
static int
vx_pci_attach(device_t dev)
{
struct vx_softc *sc;
int rid;
struct vx_softc *sc;
int rid;
sc = device_get_softc(dev);
sc = device_get_softc(dev);
rid = PCIR_BAR(0);
sc->vx_res = bus_alloc_resource_any(dev, SYS_RES_IOPORT, &rid, RF_ACTIVE);
rid = PCIR_BAR(0);
sc->vx_res =
bus_alloc_resource_any(dev, SYS_RES_IOPORT, &rid, RF_ACTIVE);
if (sc->vx_res == NULL)
goto bad;
if (sc->vx_res == NULL)
goto bad;
sc->bst = rman_get_bustag(sc->vx_res);
sc->bsh = rman_get_bushandle(sc->vx_res);
sc->bst = rman_get_bustag(sc->vx_res);
sc->bsh = rman_get_bushandle(sc->vx_res);
rid = 0;
sc->vx_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid,
RF_SHAREABLE | RF_ACTIVE);
rid = 0;
sc->vx_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid,
RF_SHAREABLE | RF_ACTIVE);
if (sc->vx_irq == NULL)
goto bad;
if (sc->vx_irq == NULL)
goto bad;
if (bus_setup_intr(dev, sc->vx_irq, INTR_TYPE_NET,
vxintr, sc, &sc->vx_intrhand))
goto bad;
if (bus_setup_intr(dev, sc->vx_irq, INTR_TYPE_NET,
vxintr, sc, &sc->vx_intrhand))
goto bad;
if (vxattach(dev) == 0) {
goto bad;
}
if (vxattach(dev) == 0)
goto bad;
/* defect check for 3C590 */
if ((pci_read_config(dev, PCIR_DEVVENDOR, 4) >> 16) == 0x5900) {
GO_WINDOW(0);
if (vxbusyeeprom(sc))
goto bad;
CSR_WRITE_2(sc, VX_W0_EEPROM_COMMAND,
EEPROM_CMD_RD | EEPROM_SOFTINFO2);
if (vxbusyeeprom(sc))
goto bad;
if (!(CSR_READ_2(sc, VX_W0_EEPROM_DATA) & NO_RX_OVN_ANOMALY)) {
printf("Warning! Defective early revision adapter!\n");
/* defect check for 3C590 */
if ((pci_read_config(dev, PCIR_DEVVENDOR, 4) >> 16) == 0x5900) {
GO_WINDOW(0);
if (vxbusyeeprom(sc))
goto bad;
CSR_WRITE_2(sc, VX_W0_EEPROM_COMMAND,
EEPROM_CMD_RD | EEPROM_SOFTINFO2);
if (vxbusyeeprom(sc))
goto bad;
if (!(CSR_READ_2(sc, VX_W0_EEPROM_DATA) & NO_RX_OVN_ANOMALY))
printf("Warning! Defective early revision adapter!\n");
}
}
return(0);
return (0);
bad:
if (sc->vx_intrhand != NULL)
bus_teardown_intr(dev, sc->vx_irq, sc->vx_intrhand);
if (sc->vx_res != NULL)
bus_release_resource(dev, SYS_RES_IOPORT, 0, sc->vx_res);
if (sc->vx_irq != NULL)
bus_release_resource(dev, SYS_RES_IRQ, 0, sc->vx_irq);
return(ENXIO);
if (sc->vx_intrhand != NULL)
bus_teardown_intr(dev, sc->vx_irq, sc->vx_intrhand);
if (sc->vx_res != NULL)
bus_release_resource(dev, SYS_RES_IOPORT, 0, sc->vx_res);
if (sc->vx_irq != NULL)
bus_release_resource(dev, SYS_RES_IRQ, 0, sc->vx_irq);
return (ENXIO);
}

View file

@ -31,17 +31,17 @@
* Some global constants
*/
#define TX_INIT_RATE 16
#define TX_INIT_MAX_RATE 64
#define RX_INIT_LATENCY 64
#define RX_INIT_EARLY_THRESH 64
#define MIN_RX_EARLY_THRESHF 16 /* not less than ether_header */
#define MIN_RX_EARLY_THRESHL 4
#define TX_INIT_RATE 16
#define TX_INIT_MAX_RATE 64
#define RX_INIT_LATENCY 64
#define RX_INIT_EARLY_THRESH 64
#define MIN_RX_EARLY_THRESHF 16 /* not less than ether_header */
#define MIN_RX_EARLY_THRESHL 4
#define EEPROMSIZE 0x40
#define MAX_EEPROMBUSY 1000
#define VX_LAST_TAG 0xd7
#define VX_MAX_BOARDS 16
#define EEPROMSIZE 0x40
#define MAX_EEPROMBUSY 1000
#define VX_LAST_TAG 0xd7
#define VX_MAX_BOARDS 16
/*
* Commands to read/write EEPROM trough EEPROM command register (Window 0,
@ -111,14 +111,11 @@
#define NO_RX_OVN_ANOMALY (1<<5)
/**************************************************************************
* *
* These are the registers for the 3Com 3c509 and their bit patterns when *
* applicable. They have been taken out the the "EtherLink III Parallel *
* Tasking EISA and ISA Technical Reference" "Beta Draft 10/30/92" manual *
* from 3com. *
* *
**************************************************************************/
#define VX_COMMAND 0x0e /* Write. BASE+0x0e is always a
* command reg. */
#define VX_STATUS 0x0e /* Read. BASE+0x0e is always status
@ -134,7 +131,7 @@
#define VX_W0_RESOURCE_CFG 0x08
#define VX_W0_ADDRESS_CFG 0x06
#define VX_W0_CONFIG_CTRL 0x04
/* Read */
/* Read */
#define VX_W0_PRODUCT_ID 0x02
#define VX_W0_MFG_ID 0x00
@ -243,25 +240,25 @@
#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.
* 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_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_MULTICAST (u_short) (0x02)
# define FIL_BRDCST (u_short) (0x04)
# define FIL_PROMISC (u_short) (0x08)
#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)
@ -299,7 +296,7 @@
#define VX_BUSY_WAIT while (CSR_READ_2(sc, VX_STATUS) & S_COMMAND_IN_PROGRESS)
/* Address Config. Register.
/* Address Config. Register.
* Window 0/Port 06
*/
@ -307,7 +304,7 @@
#define ACF_CONNECTOR_UTP 0
#define ACF_CONNECTOR_AUI 1
#define ACF_CONNECTOR_BNC 3
#define INTERNAL_CONNECTOR_BITS 20
#define INTERNAL_CONNECTOR_MASK 0x01700000
@ -338,7 +335,7 @@
#define ERR_DRIBBLE (u_short) (0x1000)
/*
* TX Status.
* TX Status.
*
* Reports the transmit status of a completed transmission. Writing this
* register pops the transmit completion stack.
@ -415,15 +412,15 @@
#define TAG_ADAPTER 0xd0
#define ACTIVATE_ADAPTER_TO_CONFIG 0xff
#define ENABLE_DRQ_IRQ 0x0001
#define MFG_ID 0x506d /* `TCM' */
#define MFG_ID 0x506d /* `TCM' */
#define PROD_ID 0x5090
#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 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 VX_IOSIZE 0x20
#define VX_IOSIZE 0x20
#define VX_CONNECTORS 8

View file

@ -35,24 +35,24 @@
* Ethernet software status per interface.
*/
struct vx_softc {
struct arpcom arpcom; /* Ethernet common part */
int unit; /* unit number */
bus_space_tag_t bst;
bus_space_handle_t bsh;
void *vx_intrhand;
struct resource *vx_irq;
struct resource *vx_res;
#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 */
struct callout_handle ch; /* Callout handle for timeouts */
int buffill_pending;
struct arpcom arpcom; /* Ethernet common part */
int unit; /* unit number */
bus_space_tag_t bst;
bus_space_handle_t bsh;
void *vx_intrhand;
struct resource *vx_irq;
struct resource *vx_res;
#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 */
struct callout_handle ch; /* Callout handle for timeouts */
int buffill_pending;
};
#define CSR_WRITE_4(sc, reg, val) \