Add driver for Granch SBNI12-xx ISA and PCI network adapters.
MFC after: 1 week
This commit is contained in:
parent
c59af1e032
commit
ea38b939e8
@ -1723,6 +1723,7 @@ device miibus
|
||||
# Olicom PCI token-ring adapters OC-3136, OC-3137, OC-3139, OC-3140,
|
||||
# OC-3141, OC-3540, OC-3250
|
||||
# rdp: RealTek RTL 8002-based pocket ethernet adapters
|
||||
# sbni: Granch SBNI12-xx ISA and PCI adapters
|
||||
# pcn: Support for PCI fast ethernet adapters based on the AMD Am79c97x
|
||||
# chipsets, including the PCnet/FAST, PCnet/FAST+, PCnet/PRO and
|
||||
# PCnet/Home. These were previously handled by the lnc driver (and
|
||||
@ -1841,6 +1842,11 @@ hint.rdp.0.at="isa"
|
||||
hint.rdp.0.port="0x378"
|
||||
hint.rdp.0.irq="7"
|
||||
hint.rdp.0.flags="2"
|
||||
device sbni 1
|
||||
hint.sbni.0.at="isa"
|
||||
hint.sbni.0.port="0x210"
|
||||
hint.sbni.0.irq="0xefdead"
|
||||
hint.sbni.0.flags="0"
|
||||
device sr 1
|
||||
hint.sr.0.at="isa"
|
||||
hint.sr.0.port="0x300"
|
||||
|
@ -111,6 +111,9 @@ dev/kbd/kbd.c optional sc
|
||||
dev/kbd/kbd.c optional ukbd
|
||||
dev/kbd/kbd.c optional vt
|
||||
dev/lnc/if_lnc_isa.c optional lnc isa
|
||||
dev/sbni/if_sbni.c optional sbni
|
||||
dev/sbni/if_sbni_isa.c optional sbni isa
|
||||
dev/sbni/if_sbni_pci.c optional sbni pci
|
||||
dev/sio/sio.c optional sio
|
||||
dev/sio/sio_isa.c optional sio isa
|
||||
dev/sio/sio_pccard.c optional sio card
|
||||
|
1312
sys/dev/sbni/if_sbni.c
Normal file
1312
sys/dev/sbni/if_sbni.c
Normal file
File diff suppressed because it is too large
Load Diff
165
sys/dev/sbni/if_sbni_isa.c
Normal file
165
sys/dev/sbni/if_sbni_isa.c
Normal file
@ -0,0 +1,165 @@
|
||||
/*
|
||||
* Copyright (c) 1997-2001 Granch, Ltd. All rights reserved.
|
||||
* Author: Denis I.Timofeev <timofeev@granch.ru>
|
||||
*
|
||||
* Redistributon 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 unmodified, 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.
|
||||
*
|
||||
* 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 NEIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <sys/bus.h>
|
||||
#include <sys/bus_private.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/module.h>
|
||||
#include <machine/bus.h>
|
||||
#include <machine/resource.h>
|
||||
#include <sys/rman.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/ethernet.h>
|
||||
#include <net/if_arp.h>
|
||||
|
||||
#include <isa/isavar.h>
|
||||
|
||||
#include <dev/sbni/if_sbnireg.h>
|
||||
#include <dev/sbni/if_sbnivar.h>
|
||||
|
||||
static int sbni_probe_isa(device_t);
|
||||
static int sbni_attach_isa(device_t);
|
||||
|
||||
static device_method_t sbni_isa_methods[] = {
|
||||
/* Device interface */
|
||||
DEVMETHOD(device_probe, sbni_probe_isa),
|
||||
DEVMETHOD(device_attach, sbni_attach_isa),
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
static driver_t sbni_isa_driver = {
|
||||
"sbni",
|
||||
sbni_isa_methods,
|
||||
sizeof(struct sbni_softc)
|
||||
};
|
||||
|
||||
static devclass_t sbni_isa_devclass;
|
||||
static struct isa_pnp_id sbni_ids[] = {
|
||||
{ 0, NULL } /* we have no pnp sbni cards atm. */
|
||||
};
|
||||
|
||||
DRIVER_MODULE(sbni, isa, sbni_isa_driver, sbni_isa_devclass, 0, 0);
|
||||
|
||||
|
||||
static int
|
||||
sbni_probe_isa(device_t dev)
|
||||
{
|
||||
struct sbni_softc *sc;
|
||||
int error;
|
||||
|
||||
error = ISA_PNP_PROBE(device_get_parent(dev), dev, sbni_ids);
|
||||
if (error && error != ENOENT)
|
||||
return (error);
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
bzero(sc, sizeof(struct sbni_softc));
|
||||
|
||||
sc->io_res = bus_alloc_resource(dev, SYS_RES_IOPORT, &sc->io_rid,
|
||||
0ul, ~0ul, SBNI_PORTS, RF_ACTIVE);
|
||||
if (!sc->io_res) {
|
||||
printf("sbni: cannot allocate io ports!\n");
|
||||
return (ENOENT);
|
||||
}
|
||||
|
||||
sc->base_addr = rman_get_start(sc->io_res);
|
||||
if (sbni_probe(sc) != 0) {
|
||||
bus_release_resource(dev, SYS_RES_IOPORT,
|
||||
sc->io_rid, sc->io_res);
|
||||
return (ENXIO);
|
||||
}
|
||||
|
||||
device_quiet(dev);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
sbni_attach_isa(device_t dev)
|
||||
{
|
||||
struct sbni_softc *sc;
|
||||
struct sbni_flags flags;
|
||||
int error;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
|
||||
printf("sbni%d: <Granch SBNI12/ISA adapter> port 0x%x",
|
||||
next_sbni_unit, sc->base_addr);
|
||||
sc->irq_res = bus_alloc_resource(dev, SYS_RES_IRQ, &sc->irq_rid,
|
||||
0ul, ~0ul, 1, RF_ACTIVE);
|
||||
|
||||
if (sc->irq_res) {
|
||||
printf(" irq %ld\n", rman_get_start(sc->irq_res));
|
||||
error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET,
|
||||
sbni_intr, sc, &sc->irq_handle);
|
||||
if (error) {
|
||||
printf("sbni%d: bus_setup_intr\n", next_sbni_unit);
|
||||
bus_release_resource(dev, SYS_RES_IOPORT,
|
||||
sc->io_rid, sc->io_res);
|
||||
return (error);
|
||||
}
|
||||
|
||||
#ifndef SBNI_DUAL_COMPOUND
|
||||
|
||||
} else {
|
||||
printf("\nsbni%d: irq conflict!\n", next_sbni_unit);
|
||||
bus_release_resource(dev, SYS_RES_IOPORT,
|
||||
sc->io_rid, sc->io_res);
|
||||
return (ENOENT);
|
||||
}
|
||||
|
||||
#else /* SBNI_DUAL_COMPOUND */
|
||||
|
||||
sc->link = headlist;
|
||||
headlist = sc;
|
||||
} else {
|
||||
struct sbni_softc *master;
|
||||
|
||||
if ((master = connect_to_master(sc)) == 0) {
|
||||
printf("\nsbni%d: failed to alloc irq\n",
|
||||
next_sbni_unit);
|
||||
bus_release_resource(dev, SYS_RES_IOPORT,
|
||||
sc->io_rid, sc->io_res);
|
||||
return (ENXIO);
|
||||
} else
|
||||
printf(" shared irq with sbni%d\n",
|
||||
master->arpcom.ac_if.if_unit);
|
||||
}
|
||||
#endif /* SBNI_DUAL_COMPOUND */
|
||||
|
||||
*(u_int32_t*)&flags = device_get_flags(dev);
|
||||
|
||||
sbni_attach(sc, next_sbni_unit++, flags);
|
||||
return (0);
|
||||
}
|
163
sys/dev/sbni/if_sbni_pci.c
Normal file
163
sys/dev/sbni/if_sbni_pci.c
Normal file
@ -0,0 +1,163 @@
|
||||
/*
|
||||
* Copyright (c) 1997-2001 Granch, Ltd. All rights reserved.
|
||||
* Author: Denis I.Timofeev <timofeev@granch.ru>
|
||||
*
|
||||
* Redistributon 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 unmodified, 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.
|
||||
*
|
||||
* 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 NEIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/bus.h>
|
||||
#include <sys/bus_private.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/module.h>
|
||||
#include <machine/bus.h>
|
||||
#include <machine/resource.h>
|
||||
#include <sys/rman.h>
|
||||
#include <sys/malloc.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/ethernet.h>
|
||||
#include <net/if_arp.h>
|
||||
|
||||
#include <pci/pcivar.h>
|
||||
#include <pci/pcireg.h>
|
||||
|
||||
#include <dev/sbni/if_sbnireg.h>
|
||||
#include <dev/sbni/if_sbnivar.h>
|
||||
|
||||
static int sbni_pci_probe(device_t);
|
||||
static int sbni_pci_attach(device_t);
|
||||
|
||||
static device_method_t sbni_pci_methods[] = {
|
||||
/* Device interface */
|
||||
DEVMETHOD(device_probe, sbni_pci_probe),
|
||||
DEVMETHOD(device_attach, sbni_pci_attach),
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
static driver_t sbni_pci_driver = {
|
||||
"sbni",
|
||||
sbni_pci_methods,
|
||||
sizeof(struct sbni_softc)
|
||||
};
|
||||
|
||||
static devclass_t sbni_pci_devclass;
|
||||
|
||||
DRIVER_MODULE(sbni, pci, sbni_pci_driver, sbni_pci_devclass, 0, 0);
|
||||
|
||||
|
||||
static int
|
||||
sbni_pci_probe(device_t dev)
|
||||
{
|
||||
struct sbni_softc *sc;
|
||||
u_int32_t ports;
|
||||
|
||||
ports = SBNI_PORTS;
|
||||
if (pci_get_vendor(dev) != SBNI_PCI_VENDOR
|
||||
|| pci_get_device(dev) != SBNI_PCI_DEVICE)
|
||||
return (ENXIO);
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
bzero(sc, sizeof(struct sbni_softc));
|
||||
if (pci_get_subdevice(dev) == 2) {
|
||||
ports <<= 1;
|
||||
sc->slave_sc = malloc(sizeof(struct sbni_softc),
|
||||
M_DEVBUF, M_NOWAIT);
|
||||
if (!sc->slave_sc)
|
||||
return (ENOMEM);
|
||||
bzero(sc->slave_sc, sizeof(struct sbni_softc));
|
||||
device_set_desc(dev, "Granch SBNI12/PCI Dual adapter");
|
||||
} else
|
||||
device_set_desc(dev, "Granch SBNI12/PCI adapter");
|
||||
|
||||
sc->io_rid = PCIR_MAPS;
|
||||
sc->io_res = bus_alloc_resource(dev, SYS_RES_IOPORT, &sc->io_rid,
|
||||
0ul, ~0ul, ports, RF_ACTIVE);
|
||||
if (!sc->io_res) {
|
||||
printf("sbni: cannot allocate io ports!\n");
|
||||
if (sc->slave_sc)
|
||||
free(sc->slave_sc, M_DEVBUF);
|
||||
return (ENOENT);
|
||||
}
|
||||
|
||||
sc->base_addr = rman_get_start(sc->io_res);
|
||||
if (sc->slave_sc)
|
||||
sc->slave_sc->base_addr = sc->base_addr + 4;
|
||||
if (sbni_probe(sc) != 0) {
|
||||
bus_release_resource(dev, SYS_RES_IOPORT,
|
||||
sc->io_rid, sc->io_res);
|
||||
if (sc->slave_sc)
|
||||
free(sc->slave_sc, M_DEVBUF);
|
||||
return (ENXIO);
|
||||
}
|
||||
|
||||
device_quiet(dev);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
sbni_pci_attach(device_t dev)
|
||||
{
|
||||
struct sbni_softc *sc;
|
||||
struct sbni_flags flags;
|
||||
int error;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
|
||||
printf("sbni%d: <Granch SBNI12/PCI%sadapter> port 0x%x",
|
||||
next_sbni_unit, sc->slave_sc ? " Dual " : " ", sc->base_addr);
|
||||
sc->irq_res = bus_alloc_resource(dev, SYS_RES_IRQ, &sc->irq_rid,
|
||||
0ul, ~0ul, 1, RF_SHAREABLE);
|
||||
|
||||
if (sc->irq_res) {
|
||||
printf(" irq %ld\n", rman_get_start(sc->irq_res));
|
||||
error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET,
|
||||
sbni_intr, sc, &sc->irq_handle);
|
||||
if (error) {
|
||||
printf("sbni%d: bus_setup_intr\n", next_sbni_unit);
|
||||
goto attach_failed;
|
||||
}
|
||||
} else {
|
||||
printf("\nsbni%d: cannot claim irq!\n", next_sbni_unit);
|
||||
error = ENOENT;
|
||||
goto attach_failed;
|
||||
}
|
||||
|
||||
*(u_int32_t*)&flags = 0;
|
||||
|
||||
sbni_attach(sc, next_sbni_unit++, flags);
|
||||
if (sc->slave_sc)
|
||||
sbni_attach(sc->slave_sc, next_sbni_unit++, flags);
|
||||
return (0);
|
||||
|
||||
attach_failed:
|
||||
bus_release_resource(dev, SYS_RES_IOPORT, sc->io_rid, sc->io_res);
|
||||
if (sc->slave_sc)
|
||||
free(sc->slave_sc, M_DEVBUF);
|
||||
return (error);
|
||||
}
|
106
sys/dev/sbni/if_sbnireg.h
Normal file
106
sys/dev/sbni/if_sbnireg.h
Normal file
@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Copyright (c) 1997-2001 Granch, Ltd. All rights reserved.
|
||||
* Author: Denis I.Timofeev <timofeev@granch.ru>
|
||||
*
|
||||
* Redistributon 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 unmodified, 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.
|
||||
*
|
||||
* 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 NEIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
/*
|
||||
* We don't have registered vendor id yet...
|
||||
*/
|
||||
#define SBNI_PCI_VENDOR 0x55
|
||||
#define SBNI_PCI_DEVICE 0x9f
|
||||
|
||||
#define ISA_MODE 0x00
|
||||
#define PCI_MODE 0x01
|
||||
|
||||
#define SBNI_PORTS 4
|
||||
|
||||
enum sbni_reg {
|
||||
CSR0 = 0,
|
||||
CSR1 = 1,
|
||||
DAT = 2
|
||||
};
|
||||
|
||||
/* CSR0 mapping */
|
||||
enum {
|
||||
BU_EMP = 0x02,
|
||||
RC_CHK = 0x04,
|
||||
CT_ZER = 0x08,
|
||||
TR_REQ = 0x10,
|
||||
TR_RDY = 0x20,
|
||||
EN_INT = 0x40,
|
||||
RC_RDY = 0x80
|
||||
};
|
||||
|
||||
|
||||
/* CSR1 mapping */
|
||||
#define PR_RES 0x80
|
||||
|
||||
struct sbni_csr1 {
|
||||
unsigned rxl : 5;
|
||||
unsigned rate : 2;
|
||||
unsigned : 1;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#define FRAME_ACK_MASK (u_int16_t)0x7000
|
||||
#define FRAME_LEN_MASK (u_int16_t)0x03FF
|
||||
#define FRAME_FIRST (u_int16_t)0x8000
|
||||
#define FRAME_RETRY (u_int16_t)0x0800
|
||||
|
||||
#define FRAME_SENT_BAD (u_int16_t)0x4000
|
||||
#define FRAME_SENT_OK (u_int16_t)0x3000
|
||||
|
||||
|
||||
enum {
|
||||
FL_WAIT_ACK = 1,
|
||||
FL_NEED_RESEND = 2,
|
||||
FL_PREV_OK = 4,
|
||||
FL_SLOW_MODE = 8
|
||||
};
|
||||
|
||||
|
||||
enum {
|
||||
DEFAULT_IOBASEADDR = 0x210,
|
||||
DEFAULT_INTERRUPTNUMBER = 5,
|
||||
DEFAULT_RATE = 0,
|
||||
DEFAULT_FRAME_LEN = 1012
|
||||
};
|
||||
|
||||
#define DEF_RXL_DELTA -1
|
||||
#define DEF_RXL 0xf
|
||||
|
||||
#define SBNI_SIG 0x5a
|
||||
|
||||
#define SBNI_MIN_LEN (ETHER_MIN_LEN - 4)
|
||||
#define SBNI_MAX_FRAME 1023
|
||||
|
||||
#define SBNI_HZ 18 /* ticks to wait for pong or packet */
|
||||
/* sbni watchdog called SBNI_HZ times per sec. */
|
||||
|
||||
#define TR_ERROR_COUNT 32
|
||||
#define CHANGE_LEVEL_START_TICKS 4
|
152
sys/dev/sbni/if_sbnivar.h
Normal file
152
sys/dev/sbni/if_sbnivar.h
Normal file
@ -0,0 +1,152 @@
|
||||
/*
|
||||
* Copyright (c) 1997-2001 Granch, Ltd. All rights reserved.
|
||||
* Author: Denis I.Timofeev <timofeev@granch.ru>
|
||||
*
|
||||
* Redistributon 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 unmodified, 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.
|
||||
*
|
||||
* 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 NEIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
/*
|
||||
* SBNI12 definitions
|
||||
*/
|
||||
|
||||
/*
|
||||
* CONFIGURATION PARAMETER:
|
||||
*
|
||||
* Uncomment this if you want to use model SBNI12D-11/ISA with same IRQ
|
||||
* for both first and second channels.
|
||||
*/
|
||||
#define SBNI_DUAL_COMPOUND 1
|
||||
|
||||
#define SBNI_DEBUG 0
|
||||
|
||||
#if SBNI_DEBUG
|
||||
#define DP(A) A
|
||||
#else
|
||||
#define DP(A)
|
||||
#endif
|
||||
|
||||
struct sbni_in_stats {
|
||||
u_int32_t all_rx_number;
|
||||
u_int32_t bad_rx_number;
|
||||
u_int32_t timeout_number;
|
||||
u_int32_t all_tx_number;
|
||||
u_int32_t resend_tx_number;
|
||||
};
|
||||
|
||||
struct sbni_flags {
|
||||
u_int mac_addr : 24;
|
||||
u_int rxl : 4;
|
||||
u_int rate : 2;
|
||||
u_int fixed_rxl : 1;
|
||||
u_int fixed_rate : 1;
|
||||
};
|
||||
|
||||
|
||||
#ifdef _KERNEL /* to avoid compile this decls with sbniconfig */
|
||||
|
||||
struct sbni_softc {
|
||||
struct arpcom arpcom; /* ethernet common */
|
||||
|
||||
int base_addr;
|
||||
int irq;
|
||||
int io_rid;
|
||||
int irq_rid;
|
||||
struct resource *io_res;
|
||||
struct resource *irq_res;
|
||||
void *irq_handle;
|
||||
|
||||
struct mbuf *rx_buf_p; /* receive buffer ptr */
|
||||
struct mbuf *tx_buf_p; /* transmit buffer ptr */
|
||||
|
||||
u_int pktlen; /* length of transmitting pkt */
|
||||
u_int framelen; /* current frame length */
|
||||
u_int maxframe; /* maximum valid frame length */
|
||||
u_int state;
|
||||
u_int inppos; /* positions in rx/tx buffers */
|
||||
u_int outpos; /* positions in rx/tx buffers */
|
||||
|
||||
/* transmitting frame number - from frames qty to 1 */
|
||||
u_int tx_frameno;
|
||||
|
||||
/* expected number of next receiving frame */
|
||||
u_int wait_frameno;
|
||||
|
||||
/* count of failed attempts to frame send - 32 attempts do before
|
||||
error - while receiver tunes on opposite side of wire */
|
||||
u_int trans_errors;
|
||||
|
||||
/* idle time; send pong when limit exceeded */
|
||||
u_int timer_ticks;
|
||||
|
||||
/* fields used for receive level autoselection */
|
||||
int delta_rxl;
|
||||
u_int cur_rxl_index;
|
||||
u_int timeout_rxl;
|
||||
u_int32_t cur_rxl_rcvd;
|
||||
u_int32_t prev_rxl_rcvd;
|
||||
|
||||
struct sbni_csr1 csr1; /* current value of CSR1 */
|
||||
struct sbni_in_stats in_stats; /* internal statistics */
|
||||
|
||||
struct callout_handle wch;
|
||||
|
||||
struct sbni_softc *slave_sc;
|
||||
|
||||
#ifdef SBNI_DUAL_COMPOUND
|
||||
struct sbni_softc *link;
|
||||
#endif
|
||||
};
|
||||
|
||||
void sbni_intr(void *);
|
||||
int sbni_probe(struct sbni_softc *);
|
||||
void sbni_attach(struct sbni_softc *, int, struct sbni_flags);
|
||||
|
||||
extern u_int32_t next_sbni_unit;
|
||||
|
||||
#ifdef SBNI_DUAL_COMPOUND
|
||||
extern struct sbni_softc *headlist;
|
||||
|
||||
struct sbni_softc *connect_to_master(struct sbni_softc *);
|
||||
#endif
|
||||
#endif /* _KERNEL */
|
||||
|
||||
/*
|
||||
* SBNI socket ioctl params
|
||||
*/
|
||||
#define SIOCGHWFLAGS _IOWR('i', 62, struct ifreq) /* get flags */
|
||||
#define SIOCSHWFLAGS _IOWR('i', 61, struct ifreq) /* set flags */
|
||||
#define SIOCGINSTATS _IOWR('i', 60, struct ifreq) /* get internal stats */
|
||||
#define SIOCRINSTATS _IOWR('i', 63, struct ifreq) /* reset internal stats */
|
||||
|
||||
|
||||
/*
|
||||
* CRC-32 stuff
|
||||
*/
|
||||
#define CRC32(c,crc) (crc32tab[((size_t)(crc) ^ (c)) & 0xff] ^ (((crc) >> 8) & 0x00ffffff))
|
||||
/* CRC generator EDB88320 */
|
||||
/* CRC remainder 2144DF1C */
|
||||
/* CRC initial value 0 */
|
||||
#define CRC32_REMAINDER 0x2144df1c
|
||||
#define CRC32_INITIAL 0x00000000
|
@ -1723,6 +1723,7 @@ device miibus
|
||||
# Olicom PCI token-ring adapters OC-3136, OC-3137, OC-3139, OC-3140,
|
||||
# OC-3141, OC-3540, OC-3250
|
||||
# rdp: RealTek RTL 8002-based pocket ethernet adapters
|
||||
# sbni: Granch SBNI12-xx ISA and PCI adapters
|
||||
# pcn: Support for PCI fast ethernet adapters based on the AMD Am79c97x
|
||||
# chipsets, including the PCnet/FAST, PCnet/FAST+, PCnet/PRO and
|
||||
# PCnet/Home. These were previously handled by the lnc driver (and
|
||||
@ -1841,6 +1842,11 @@ hint.rdp.0.at="isa"
|
||||
hint.rdp.0.port="0x378"
|
||||
hint.rdp.0.irq="7"
|
||||
hint.rdp.0.flags="2"
|
||||
device sbni 1
|
||||
hint.sbni.0.at="isa"
|
||||
hint.sbni.0.port="0x210"
|
||||
hint.sbni.0.irq="0xefdead"
|
||||
hint.sbni.0.flags="0"
|
||||
device sr 1
|
||||
hint.sr.0.at="isa"
|
||||
hint.sr.0.port="0x300"
|
||||
|
@ -133,6 +133,7 @@ SUBDIR+=aac \
|
||||
pecoff \
|
||||
ray \
|
||||
s3 \
|
||||
sbni \
|
||||
splash \
|
||||
sr \
|
||||
streams \
|
||||
|
10
sys/modules/sbni/Makefile
Normal file
10
sys/modules/sbni/Makefile
Normal file
@ -0,0 +1,10 @@
|
||||
# $FreeBSD$
|
||||
|
||||
.PATH: ${.CURDIR}/../../dev/sbni
|
||||
|
||||
KMOD= if_sbni
|
||||
SRCS= if_sbni.c if_sbni_isa.c if_sbni_pci.c
|
||||
|
||||
SRCS+= bus_if.h device_if.h isa_if.h pci_if.h
|
||||
|
||||
.include <bsd.kmod.mk>
|
Loading…
x
Reference in New Issue
Block a user