Add a pure open source nForce Ethernet driver, under BSDL.

This driver was ported from OpenBSD by Shigeaki Tagashira
<shigeaki@se.hiroshima-u.ac.jp> and posted at
http://www.se.hiroshima-u.ac.jp/~shigeaki/software/freebsd-nfe.html
It was additionally cleaned up by me.
It is still a work-in-progress and thus is purposefully not in GENERIC.
And it conflicts with nve(4), so only one should be loaded.
This commit is contained in:
David E. O'Brien 2006-06-26 23:41:07 +00:00
parent 0956028163
commit bfc788c283
11 changed files with 1636 additions and 1034 deletions

View File

@ -174,6 +174,7 @@ MAN= aac.4 \
ncv.4 \
netgraph.4 \
netintro.4 \
${_nfe.4} \
${_nfsmb.4} \
ng_async.4 \
ng_atm.4 \
@ -457,6 +458,7 @@ MLINKS+=mxge.4 if_mxge.4
MLINKS+=my.4 if_my.4
MLINKS+=netintro.4 net.4 \
netintro.4 networking.4
MLINKS+=${_nfe.4} ${_if_nfe.4}
MLINKS+=nge.4 if_nge.4
MLINKS+=${_nve.4} ${_if_nve.4}
MLINKS+=oldcard.4 card.4
@ -509,9 +511,11 @@ MLINKS+=xl.4 if_xl.4
.if ${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "i386"
_acpi_dock.4= acpi_dock.4
_amdsmb.4= amdsmb.4
_if_nfe.4= if_nfe.4
_if_nve.4= if_nve.4
_ipmi.4= ipmi.4
_nfsmb.4= nfsmb.4
_nfe.4= nfe.4
_nve.4= nve.4
_rr232x.4= rr232x.4
_spkr.4= spkr.4

96
share/man/man4/nfe.4 Normal file
View File

@ -0,0 +1,96 @@
.\" $OpenBSD: nfe.4,v 1.7 2006/02/28 08:13:47 jsg Exp $
.\"
.\" Copyright (c) 2006 Jonathan Gray <jsg@openbsd.org>
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.\" $FreeBSD$
.\"
.Dd February 6, 2006
.Dt NFE 4
.Os
.Sh NAME
.Nm nfe
.Nd "NVIDIA nForce MCP Ethernet driver"
.Sh SYNOPSIS
To compile this driver into the kernel,
place the following lines in your
kernel configuration file:
.Bd -ragged -offset indent
.Cd "device miibus"
.Cd "device nve"
.Ed
.Pp
Alternatively, to load the driver as a
module at boot time, place the following line in
.Xr loader.conf 5 :
.Bd -literal -offset indent
if_nfe_load="YES"
.Ed
.Sh DESCRIPTION
The
.Nm
driver supports PCI Ethernet adapters based on the NVIDIA
nForce Media and Communications Processors (MCP), such as
the nForce, nForce 2, nForce 3, CK804, MCP04, MCP51 and MCP55
Ethernet controller chips.
.Pp
The
.Nm
driver supports the following
.Ar media
types:
.Pp
.Bl -tag -width autoselect -compact
.It Cm autoselect
Enable autoselection of the media type and options.
.It Cm 10baseT
Set 10Mbps operation.
.It Cm 100baseTX
Set 100Mbps (Fast Ethernet) operation.
.It Cm 1000baseT
Set 1000Mbps (Gigabit Ethernet) operation (recent models only).
.El
.Sh SEE ALSO
.Xr arp 4 ,
.Xr intro 4 ,
.Xr miibus 4 ,
.Xr netintro 4 ,
.Xr pci 4 ,
.Xr ifconfig 8
.Sh HISTORY
The
.Nm
device driver first appeared in
.Ox 3.9 ,
and then in
.Fx 6.0 .
.Sh AUTHORS
.An -nosplit
The
.Nm
driver was written by
.An Jonathan Gray
.Aq jsg@openbsd.org
and
.An Damien Bergamini
.Aq damien@openbsd.org .
The
.Nm
driver was ported to
.Fx
by
.An Shigeaki Tagashira
.Aq shigeaki@se.hiroshima-u.ac.jp .
.Sh CAVEATS
NVIDIA refuse to release any documentation on their products.

View File

@ -223,6 +223,7 @@ options DRM_DEBUG # Include debug printfs (slow)
# (requires miibus)
# ipw: Intel PRO/Wireless 2100 IEEE 802.11 adapter
# iwi: Intel PRO/Wireless 2200BG/2225BG/2915ABG IEEE 802.11 adapters
# 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
# ural: Ralink Technology RT2500USB IEEE 802.11 wireless adapter
@ -233,6 +234,7 @@ options ED_HPP
options ED_SIC
device iwi
device ipw
device nfe # nVidia nForce MCP on-board Ethernet Networking
device nve # nVidia nForce MCP on-board Ethernet Networking
device ral
device ural

View File

@ -177,6 +177,7 @@ dev/hwpmc/hwpmc_piv.c optional hwpmc
dev/hwpmc/hwpmc_x86.c optional hwpmc
dev/kbd/kbd.c optional atkbd | sc | ukbd
dev/mem/memutil.c optional mem
dev/nfe/if_nfe.c optional nfe pci
dev/nve/if_nve.c optional nve pci
dev/rr232x/os_bsd.c optional rr232x
dev/rr232x/osm_bsd.c optional rr232x

View File

@ -198,6 +198,7 @@ dev/le/if_le_isa.c optional le isa
dev/mem/memutil.c optional mem
dev/mse/mse.c optional mse
dev/mse/mse_isa.c optional mse isa
dev/nfe/if_nfe.c optional nfe pci
dev/nve/if_nve.c optional nve pci
dev/pcf/pcf_isa.c optional pcf
dev/random/nehemiah.c optional random

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
/* $OpenBSD: if_nfereg.h,v 1.18 2006/05/01 15:59:31 brad Exp $ */
/* $OpenBSD: if_nfereg.h,v 1.16 2006/02/22 19:23:44 damien Exp $ */
/*-
* Copyright (c) 2005 Jonathan Gray <jsg@openbsd.org>
@ -14,6 +14,8 @@
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* $FreeBSD$
*/
#define NFE_PCI_BA 0x10
@ -149,6 +151,10 @@ struct nfe_desc32 {
#define NFE_RX_VALID_V1 (1 << 0)
#define NFE_TX_ERROR_V1 0x7808
#define NFE_TX_LASTFRAG_V1 (1 << 0)
#define NFE_RX_ERROR1_V1 (1<<7)
#define NFE_RX_ERROR2_V1 (1<<8)
#define NFE_RX_ERROR3_V1 (1<<9)
#define NFE_RX_ERROR4_V1 (1<<10)
} __packed;
#define NFE_V1_TXERR "\020" \
@ -167,6 +173,13 @@ struct nfe_desc64 {
#define NFE_RX_VALID_V2 (1 << 13)
#define NFE_TX_ERROR_V2 0x5c04
#define NFE_TX_LASTFRAG_V2 (1 << 13)
#define NFE_RX_IP_CSUMOK_V2 0x1000
#define NFE_RX_UDP_CSUMOK_V2 0x1400
#define NFE_RX_TCP_CSUMOK_V2 0x1800
#define NFE_RX_ERROR1_V2 (1<<2)
#define NFE_RX_ERROR2_V2 (1<<3)
#define NFE_RX_ERROR3_V2 (1<<4)
#define NFE_RX_ERROR4_V2 (1<<5)
} __packed;
#define NFE_V2_TXERR "\020" \
@ -181,7 +194,47 @@ struct nfe_desc64 {
#define NFE_TX_VALID (1 << 15)
#define NFE_READ(sc, reg) \
bus_space_read_4((sc)->sc_memt, (sc)->sc_memh, (reg))
bus_space_read_4((sc)->nfe_memt, (sc)->nfe_memh, (reg))
#define NFE_WRITE(sc, reg, val) \
bus_space_write_4((sc)->sc_memt, (sc)->sc_memh, (reg), (val))
bus_space_write_4((sc)->nfe_memt, (sc)->nfe_memh, (reg), (val))
#ifndef PCI_VENDOR_NVIDIA
#define PCI_VENDOR_NVIDIA 0x10DE
#endif
#define PCI_PRODUCT_NVIDIA_NFORCE_LAN 0x01C3
#define PCI_PRODUCT_NVIDIA_NFORCE2_LAN 0x0066
#define PCI_PRODUCT_NVIDIA_NFORCE3_LAN1 0x00D6
#define PCI_PRODUCT_NVIDIA_NFORCE2_400_LAN1 0x0086
#define PCI_PRODUCT_NVIDIA_NFORCE2_400_LAN2 0x008C
#define PCI_PRODUCT_NVIDIA_NFORCE3_250_LAN 0x00E6
#define PCI_PRODUCT_NVIDIA_NFORCE3_LAN4 0x00DF
#define PCI_PRODUCT_NVIDIA_NFORCE4_LAN1 0x0056
#define PCI_PRODUCT_NVIDIA_NFORCE4_LAN2 0x0057
#define PCI_PRODUCT_NVIDIA_MCP04_LAN1 0x0037
#define PCI_PRODUCT_NVIDIA_MCP04_LAN2 0x0038
#define PCI_PRODUCT_NVIDIA_NFORCE430_LAN1 0x0268
#define PCI_PRODUCT_NVIDIA_NFORCE430_LAN2 0x0269
#define PCI_PRODUCT_NVIDIA_MCP55_LAN1 0x0372
#define PCI_PRODUCT_NVIDIA_MCP55_LAN2 0x0373
#define PCI_PRODUCT_NVIDIA_NFORCE3_LAN2 PCI_PRODUCT_NVIDIA_NFORCE2_400_LAN1
#define PCI_PRODUCT_NVIDIA_NFORCE3_LAN3 PCI_PRODUCT_NVIDIA_NFORCE2_400_LAN2
#define PCI_PRODUCT_NVIDIA_NFORCE3_LAN5 PCI_PRODUCT_NVIDIA_NFORCE3_250_LAN
#define PCI_PRODUCT_NVIDIA_CK804_LAN1 PCI_PRODUCT_NVIDIA_NFORCE4_LAN1
#define PCI_PRODUCT_NVIDIA_CK804_LAN2 PCI_PRODUCT_NVIDIA_NFORCE4_LAN2
#define PCI_PRODUCT_NVIDIA_MCP51_LAN1 PCI_PRODUCT_NVIDIA_NFORCE430_LAN1
#define PCI_PRODUCT_NVIDIA_MCP51_LAN2 PCI_PRODUCT_NVIDIA_NFORCE430_LAN2
#define NFE_DEBUG 0x0000
#define NFE_DEBUG_INIT 0x0001
#define NFE_DEBUG_RUNNING 0x0002
#define NFE_DEBUG_DEINIT 0x0004
#define NFE_DEBUG_IOCTL 0x0008
#define NFE_DEBUG_INTERRUPT 0x0010
#define NFE_DEBUG_API 0x0020
#define NFE_DEBUG_LOCK 0x0040
#define NFE_DEBUG_BROKEN 0x0080
#define NFE_DEBUG_MII 0x0100
#define NFE_DEBUG_ALL 0xFFFF

View File

@ -14,19 +14,22 @@
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* $FreeBSD$
*/
#define NFE_IFQ_MAXLEN 64
struct nfe_tx_data {
bus_dmamap_t map;
bus_dmamap_t tx_data_map;
bus_dmamap_t active;
int nsegs;
struct mbuf *m;
};
struct nfe_tx_ring {
bus_dmamap_t map;
bus_dma_segment_t seg;
bus_dmamap_t tx_desc_map;
bus_dma_segment_t tx_desc_segs;
bus_addr_t physaddr;
struct nfe_desc32 *desc32;
struct nfe_desc64 *desc64;
@ -34,6 +37,10 @@ struct nfe_tx_ring {
int queued;
int cur;
int next;
bus_addr_t tx_desc_addr;
bus_addr_t tx_data_addr;
bus_dma_tag_t tx_desc_tag;
bus_dma_tag_t tx_data_tag;
};
struct nfe_jbuf {
@ -43,49 +50,78 @@ struct nfe_jbuf {
};
struct nfe_rx_data {
bus_dmamap_t map;
bus_dmamap_t rx_data_map;
bus_dma_tag_t rx_data_tag;
bus_addr_t rx_data_addr;
bus_dma_segment_t rx_data_segs;
struct mbuf *m;
};
struct nfe_rx_ring {
bus_dmamap_t map;
bus_dma_segment_t seg;
bus_dmamap_t jmap;
bus_dma_segment_t jseg;
bus_dmamap_t rx_desc_map;
bus_dma_segment_t rx_desc_segs;
bus_dma_tag_t rx_desc_tag;
bus_addr_t rx_desc_addr;
#ifndef JMBUF
bus_dmamap_t rx_jumbo_map;
bus_dma_segment_t rx_jumbo_segs;
bus_dma_tag_t rx_jumbo_tag;
bus_addr_t rx_jumbo_addr;
caddr_t jpool;
struct nfe_jbuf jbuf[NFE_JPOOL_COUNT];
SLIST_HEAD(, nfe_jbuf) jfreelist;
#endif
bus_addr_t physaddr;
struct nfe_desc32 *desc32;
struct nfe_desc64 *desc64;
caddr_t jpool;
struct nfe_rx_data data[NFE_RX_RING_COUNT];
struct nfe_jbuf jbuf[NFE_JPOOL_COUNT];
SLIST_HEAD(, nfe_jbuf) jfreelist;
int bufsz;
int cur;
int next;
};
struct nfe_softc {
struct device sc_dev;
struct arpcom sc_arpcom;
bus_space_handle_t sc_memh;
bus_space_tag_t sc_memt;
void *sc_ih;
bus_dma_tag_t sc_dmat;
struct mii_data sc_mii;
struct timeout sc_tick_ch;
void *sc_powerhook;
struct ifnet *nfe_ifp;
device_t nfe_dev;
device_t nfe_miibus;
struct mtx nfe_mtx;
bus_space_handle_t nfe_memh;
bus_space_tag_t nfe_memt;
struct resource *nfe_res;
struct resource *nfe_irq;
void *nfe_intrhand;
struct mii_data nfe_mii;
u_int8_t nfe_unit;
struct callout nfe_stat_ch;
int sc_if_flags;
u_int sc_flags;
struct arpcom nfe_arpcom;
bus_dma_tag_t nfe_parent_tag;
/* struct timeout nfe_tick_ch; */
void *nfe_powerhook;
int nfe_if_flags;
u_int nfe_flags;
#define NFE_JUMBO_SUP 0x01
#define NFE_40BIT_ADDR 0x02
#define NFE_HW_CSUM 0x04
#define NFE_HW_VLAN 0x08
#define NFE_USE_JUMBO 0x10
uint32_t rxtxctl;
uint8_t mii_phyaddr;
u_int32_t rxtxctl;
u_int8_t mii_phyaddr;
u_char eaddr[ETHER_ADDR_LEN];
struct task nfe_txtask;
int nfe_link;
struct nfe_tx_ring txq;
struct nfe_rx_ring rxq;
#ifdef DEVICE_POLLING
int rxcycles;
#endif
};
struct nfe_type {
u_int16_t vid_id;
u_int16_t dev_id;
char *name;
};

View File

@ -500,6 +500,7 @@ hint.mse.0.irq="5"
# Intel EtherExpress
# ipw: Intel PRO/Wireless 2100 IEEE 802.11 adapter
# iwi: Intel PRO/Wireless 2200BG/2225BG/2915ABG IEEE 802.11 adapters
# nfe: nVidia nForce MCP on-board Ethernet Networking (BSD open source)
# nve: nVidia nForce MCP on-board Ethernet Networking
# oltr: Olicom ISA token-ring adapters OC-3115, OC-3117, OC-3118 and OC-3133.
# Olicom PCI token-ring adapters OC-3136, OC-3137, OC-3139, OC-3140,
@ -557,6 +558,7 @@ hint.le.0.at="isa"
hint.le.0.port="0x280"
hint.le.0.irq="10"
hint.le.0.drq="0"
device nfe # nVidia nForce MCP on-board Ethernet Networking
device nve # nVidia nForce MCP on-board Ethernet Networking
device oltr
hint.oltr.0.at="isa"

View File

@ -166,6 +166,7 @@ SUBDIR= ${_3dfx} \
${_ncv} \
${_ndis} \
netgraph \
${_nfe} \
nfsclient \
nfsserver \
nge \
@ -415,6 +416,7 @@ _ipw= ipw
_iwi= iwi
_mly= mly
_mxge= mxge
_nfe= nfe
_nve= nve
.if ${MK_CRYPT} != "no" || defined(ALL_MODULES)
.if exists(${.CURDIR}/../crypto/via)
@ -473,6 +475,7 @@ _iwi= iwi
_mly= mly
_mxge= mxge
_ndis= ndis
_nfe= nfe
_nve= nve
_pccard= pccard
_rr232x= rr232x

8
sys/modules/nfe/Makefile Normal file
View File

@ -0,0 +1,8 @@
# $FreeBSD$
.PATH: ${.CURDIR}/../../dev/nfe
KMOD= if_nfe
SRCS= if_nfe.c opt_bdg.h device_if.h bus_if.h pci_if.h miibus_if.h
.include <bsd.kmod.mk>