Resurrect the sbni(4) driver. Someone finally tested the MPSAFE patches and

the driver worked ok with them.

Tested by:	friends of yar
This commit is contained in:
John Baldwin 2008-09-10 18:36:58 +00:00
parent 7f1b527c00
commit 26e4688329
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=182912
15 changed files with 2153 additions and 6 deletions

View File

@ -53,11 +53,6 @@ OLD_FILES+=usr/share/man/man8/bsdlabel.8.gz
# 20080704: sbsh(4) removed
OLD_FILES+=usr/share/man/man4/if_sbsh.4.gz
OLD_FILES+=usr/share/man/man4/sbsh.4.gz
# 20080704: sbni(4) removed
.if ${TARGET_ARCH} == "i386"
OLD_FILES+=usr/share/man/man4/i386/if_sbni.4.gz
OLD_FILES+=usr/share/man/man4/i386/sbni.4.gz
.endif
# 20080704: cnw(4) removed
OLD_FILES+=usr/share/man/man4/if_cnw.4.gz
OLD_FILES+=usr/share/man/man4/cnw.4.gz

View File

@ -30,6 +30,7 @@ MAN= aic.4 \
pnp.4 \
pnpbios.4 \
ray.4 \
sbni.4 \
scd.4 \
smapi.4 \
snc.4 \
@ -43,6 +44,7 @@ MAN= aic.4 \
MLINKS= CPU_ELAN.4 CPU_SOEKRIS.4
MLINKS+=pae.4 PAE.4
MLINKS+=sbni.4 if_sbni.4
MANSUBDIR=/i386

View File

@ -0,0 +1,132 @@
.\" Written by Denis I. Timofeev, 2002.
.\"
.\" 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.
.\"
.\" 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.
.\"
.\" $FreeBSD$
.\"
.Dd January 8, 2002
.Dt SBNI 4 i386
.Os
.Sh NAME
.Nm sbni
.Nd Granch SBNI12 leased line modem driver
.Sh SYNOPSIS
.Cd "device sbni"
.Sh DESCRIPTION
The
.Nm
driver provides support for leased line modems of following models:
.Pp
.Bl -bullet -compact
.It
SBNI12-02, SBNI12D-02
.It
SBNI12-04, SBNI12D-04
.It
SBNI12-05, SBNI12D-05, ISA and PCI
.It
SBNI12-10, SBNI12D-10, ISA and PCI
.El
.Pp
and a kit for data link over a voice band:
.Bl -bullet
.It
SBNI12-11, SBNI12D-11, ISA and PCI.
.El
.Pp
In addition to the standard port and IRQ specifications, the
.Nm
driver also supports a number of
.Va flags
which can set baud rate, receive level, and low three bytes of Ethernet
MAC-address (high three are always
.Li 00:ff:01 ) ,
because Granch modems are
presented to the system as Ethernet-like network cards.
.Pp
The high byte of the
.Va flags
is a bit field, it is used to specify SBNI adapter receive level/baud rate:
.Bl -tag -width "Bits 0-3:" -offset indent
.It "Bits 0-3:"
receive level (0x00..0x0f)
.It "Bits 4-5:"
baud rate number:
.Pp
.Bl -inset -compact
.It "00 -"
0 baud rate (2Mb in fast mode/500kb in slow)
.It "01 -"
1 baud rate (1Mb/250kb)
.It "10 -"
2 baud rate (500kb/125kb)
.It "11 -"
3 baud rate (250kb/62.5kb)
.El
.It "Bit 6:"
use fixed receive level
.Pp
if bit 6 is set then receive level will be set according
to bits 0-3 value, otherwise receive level will be
autodetected
.It "Bit 7:"
use fixed baud rate
.Pp
if bit 7 is set then baud rate will be set according to
bits 4-5 value, otherwise baud rate is set to 2Mb
.El
.Sh FILES
The sources for the driver reside in:
.Pp
.Bl -tag -compact
.It Pa /sys/dev/sbni/if_sbni.c
.It Pa /sys/dev/sbni/if_sbnireg.h
.It Pa /sys/dev/sbni/if_sbnivar.h
.El
.Sh SEE ALSO
.Xr arp 4 ,
.Xr netintro 4 ,
.Xr ifconfig 8
.Sh HISTORY
The
.Nm
device driver first appeared in
.Fx 4.6 .
.Sh AUTHORS
.An -nosplit
The
.Nm
device driver for
.Fx
4.x was written by
.An Denis I. Timofeev ,
partially based on
.An David Greenman Ns 's
.Xr ed 4
driver.
Earlier versions (available on
.Pa ftp.granch.com )
were written by
.An Alexey V. Zverev .
.Pp
SBNI12 hardware was designed by
.An Alexey V. Chirkov .

View File

@ -260,6 +260,7 @@ if_ray_load="NO" # Raytheon Raylink/Webgear Aviator PCCard
if_re_load="NO" # RealTek 8139C+/8169/8169S/8110S
if_rl_load="NO" # RealTek 8129/8139
if_rue_load="NO" # RealTek RTL8150 USB to Fast Ethernet
if_sbni_load="NO" # Granch SBNI12 leased line adapters
if_sf_load="NO" # Adaptec Duralink PCI (AIC-6915 "starfire")
if_sis_load="NO" # Silicon Integrated Systems SiS 900/7016
if_sk_load="NO" # SysKonnect SK-984x series PCI Gigabit Ethernet

View File

@ -216,6 +216,9 @@ dev/nve/if_nve.c optional nve pci
dev/nvram/nvram.c optional nvram isa
dev/pcf/pcf_isa.c optional pcf
dev/random/nehemiah.c optional random
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 pccard

View File

@ -120,6 +120,8 @@ dev/le/if_le_cbus.c optional le isa
dev/mem/memutil.c optional mem
dev/mse/mse.c optional mse
dev/mse/mse_cbus.c optional mse isa
dev/sbni/if_sbni.c optional sbni
dev/sbni/if_sbni_pci.c optional sbni pci
dev/sio/sio_pccard.c optional sio pccard
dev/sio/sio_pci.c optional sio pci
dev/sio/sio_puc.c optional sio puc

1364
sys/dev/sbni/if_sbni.c Normal file

File diff suppressed because it is too large Load Diff

167
sys/dev/sbni/if_sbni_isa.c Normal file
View File

@ -0,0 +1,167 @@
/*-
* 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.
*
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/socket.h>
#include <sys/bus.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);
MODULE_DEPEND(sbni, isa, 1, 1, 1);
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);
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);
}
if (sbni_probe(sc) != 0) {
sbni_release_resources(sc);
return (ENXIO);
}
device_set_desc(dev, "Granch SBNI12/ISA adapter");
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);
sc->dev = dev;
sc->irq_res = bus_alloc_resource_any(
dev, SYS_RES_IRQ, &sc->irq_rid, RF_ACTIVE);
#ifndef SBNI_DUAL_COMPOUND
if (sc->irq_res == NULL) {
device_printf(dev, "irq conflict!\n");
sbni_release_resources(sc);
return (ENOENT);
}
#else /* SBNI_DUAL_COMPOUND */
if (sc->irq_res) {
sbni_add(sc);
} else {
struct sbni_softc *master;
if ((master = connect_to_master(sc)) == 0) {
device_printf(dev, "failed to alloc irq\n");
sbni_release_resources(sc);
return (ENXIO);
} else {
device_printf(dev, "shared irq with %s\n",
master->ifp->if_xname);
}
}
#endif /* SBNI_DUAL_COMPOUND */
*(u_int32_t*)&flags = device_get_flags(dev);
error = sbni_attach(sc, device_get_unit(dev) * 2, flags);
if (error) {
device_printf(dev, "cannot initialize driver\n");
sbni_release_resources(sc);
return (error);
}
if (sc->irq_res) {
error = bus_setup_intr(
dev, sc->irq_res, INTR_TYPE_NET | INTR_MPSAFE,
NULL, sbni_intr, sc, &sc->irq_handle);
if (error) {
device_printf(dev, "bus_setup_intr\n");
sbni_detach(sc);
sbni_release_resources(sc);
return (error);
}
}
return (0);
}

191
sys/dev/sbni/if_sbni_pci.c Normal file
View File

@ -0,0 +1,191 @@
/*-
* 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.
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/socket.h>
#include <sys/bus.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 <dev/pci/pcivar.h>
#include <dev/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 int sbni_pci_detach(device_t);
static device_method_t sbni_pci_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, sbni_pci_probe),
DEVMETHOD(device_attach, sbni_pci_attach),
DEVMETHOD(device_detach, sbni_pci_detach),
{ 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);
MODULE_DEPEND(sbni, pci, 1, 1, 1);
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);
if (pci_get_subdevice(dev) == 2) {
ports <<= 1;
sc->slave_sc = malloc(sizeof(struct sbni_softc),
M_DEVBUF, M_NOWAIT | M_ZERO);
if (!sc->slave_sc)
return (ENOMEM);
device_set_desc(dev, "Granch SBNI12/PCI Dual adapter");
} else
device_set_desc(dev, "Granch SBNI12/PCI adapter");
sc->io_rid = PCIR_BAR(0);
sc->io_res = bus_alloc_resource(dev, SYS_RES_IOPORT, &sc->io_rid,
0ul, ~0ul, ports, RF_ACTIVE);
if (!sc->io_res) {
device_printf(dev, "cannot allocate io ports!\n");
if (sc->slave_sc)
free(sc->slave_sc, M_DEVBUF);
return (ENOENT);
}
if (sc->slave_sc) {
sc->slave_sc->io_res = sc->io_res;
sc->slave_sc->io_off = 4;
}
if (sbni_probe(sc) != 0) {
sbni_release_resources(sc);
if (sc->slave_sc)
free(sc->slave_sc, M_DEVBUF);
return (ENXIO);
}
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);
sc->dev = dev;
sc->irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &sc->irq_rid,
RF_SHAREABLE);
if (sc->irq_res == NULL) {
device_printf(dev, "cannot claim irq!\n");
error = ENOENT;
goto attach_failed;
}
*(u_int32_t*)&flags = 0;
error = sbni_attach(sc, device_get_unit(dev) * 2, flags);
if (error) {
device_printf(dev, "cannot initialize driver\n");
goto attach_failed;
}
if (sc->slave_sc) {
error = sbni_attach(sc->slave_sc, device_get_unit(dev) * 2 + 1,
flags);
if (error) {
device_printf(dev, "cannot initialize slave\n");
sbni_detach(sc);
goto attach_failed;
}
}
if (sc->irq_res) {
error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET |
INTR_MPSAFE, NULL, sbni_intr, sc, &sc->irq_handle);
if (error) {
device_printf(dev, "bus_setup_intr\n");
sbni_detach(sc);
if (sc->slave_sc)
sbni_detach(sc);
goto attach_failed;
}
}
return (0);
attach_failed:
sbni_release_resources(sc);
if (sc->slave_sc)
free(sc->slave_sc, M_DEVBUF);
return (error);
}
static int
sbni_pci_detach(device_t dev)
{
struct sbni_softc *sc;
sc = device_get_softc(dev);
sbni_detach(sc);
if (sc->slave_sc)
sbni_detach(sc);
sbni_release_resources(sc);
if (sc->slave_sc)
free(sc->slave_sc, M_DEVBUF);
return (0);
}

106
sys/dev/sbni/if_sbnireg.h Normal file
View 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

160
sys/dev/sbni/if_sbnivar.h Normal file
View File

@ -0,0 +1,160 @@
/*-
* 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 ifnet *ifp;
device_t dev;
u_char enaddr[6];
int io_rid;
struct resource *io_res;
int io_off;
int irq_rid;
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 wch;
struct mtx lock;
struct sbni_softc *slave_sc;
#ifdef SBNI_DUAL_COMPOUND
struct sbni_softc *link;
#endif
};
#define SBNI_LOCK(sc) mtx_lock(&(sc)->lock)
#define SBNI_UNLOCK(sc) mtx_unlock(&(sc)->lock)
#define SBNI_ASSERT_LOCKED(sc) mtx_assert(&(sc)->lock, MA_OWNED)
void sbni_intr(void *);
int sbni_probe(struct sbni_softc *);
int sbni_attach(struct sbni_softc *, int, struct sbni_flags);
void sbni_detach(struct sbni_softc *);
void sbni_release_resources(struct sbni_softc *);
extern u_int32_t next_sbni_unit;
#ifdef SBNI_DUAL_COMPOUND
void sbni_add(struct sbni_softc *);
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

View File

@ -552,6 +552,7 @@ hint.mse.0.irq="5"
# nfe: nVidia nForce MCP on-board Ethernet Networking (BSD open source)
# nve: nVidia nForce MCP on-board Ethernet Networking
# ral: Ralink Technology IEEE 802.11 wireless adapter
# sbni: Granch SBNI12-xx ISA and PCI adapters
# sr: RISCom/N2 hdlc sync 1/2 port V.35/X.21 serial driver (requires sppp)
# ural: Ralink Technology RT2500USB IEEE 802.11 wireless adapter
# wl: Lucent Wavelan (ISA card only).
@ -599,6 +600,11 @@ hint.le.0.drq="0"
device nfe # nVidia nForce MCP on-board Ethernet Networking
device nve # nVidia nForce MCP on-board Ethernet Networking
device ral
device sbni
hint.sbni.0.at="isa"
hint.sbni.0.port="0x210"
hint.sbni.0.irq="0xefdead"
hint.sbni.0.flags="0"
device sr
hint.sr.0.at="isa"
hint.sr.0.port="0x300"

View File

@ -234,6 +234,7 @@ SUBDIR= ${_3dfx} \
rum \
${_s3} \
${_safe} \
${_sbni} \
scc \
scd \
${_scsi_low} \
@ -421,6 +422,7 @@ _pst= pst
_ray= ray
_rdma= rdma
_safe= safe
_sbni= sbni
_scsi_low= scsi_low
_smbfs= smbfs
_sound= sound
@ -574,7 +576,7 @@ _zfs= zfs
.if ${MACHINE_ARCH} == "ia64"
# Modules not enabled on ia64 (as compared to i386) include:
# aac acpi aout apm atspeaker drm ibcs2 linprocfs linux ncv
# nsp s3 stg vesa
# nsp s3 sbni stg vesa
# acpi is not enabled because it is broken as a module on ia64
_aic= aic
#_ar= ar not 64-bit clean

10
sys/modules/sbni/Makefile Normal file
View 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>

View File

@ -380,6 +380,7 @@ hint.mse.0.irq="13"
# ie: AT&T StarLAN 10 and EN100; 3Com 3C507; unknown NI5210;
# Intel EtherExpress
# ral: Ralink Technology IEEE 802.11 wireless adapter
# sbni: Granch SBNI12-xx ISA and PCI adapters
# sr: RISCom/N2 hdlc sync 1/2 port V.35/X.21 serial driver (requires sppp)
# ural: Ralink Technology RT2500USB IEEE 802.11 wireless adapter
@ -404,6 +405,11 @@ hint.le.0.at="isa"
hint.le.0.port="0x03d0"
hint.le.0.irq="6"
device ral
device sbni
hint.sbni.0.at="isa"
hint.sbni.0.port="0x210"
hint.sbni.0.irq="0xefdead"
hint.sbni.0.flags="0"
device snc
hint.snc.0.at="isa"
hint.snc.0.port="0x888"