add nfe driver and manpage from OpenBSD.

This commit is contained in:
chs 2006-03-12 22:40:42 +00:00
parent abfe2afbd4
commit 388c5496c2
6 changed files with 2145 additions and 3 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: mi,v 1.862 2006/03/06 22:21:25 agc Exp $
# $NetBSD: mi,v 1.863 2006/03/12 22:40:42 chs Exp $
./etc/mtree/set.man man-sys-root
./usr/share/info/am-utils.info man-amd-info info
./usr/share/info/as.info man-computil-info bfd,info
@ -1068,6 +1068,7 @@
./usr/share/man/cat4/netsmb.0 man-sys-catman .cat
./usr/share/man/cat4/networking.0 man-sys-catman .cat
./usr/share/man/cat4/njs.0 man-sys-catman .cat
./usr/share/man/cat4/nfe.0 man-sys-catman .cat
./usr/share/man/cat4/ns.0 man-sys-catman .cat
./usr/share/man/cat4/nsclpcsio.0 man-sys-catman .cat
./usr/share/man/cat4/nsip.0 man-sys-catman .cat
@ -3374,6 +3375,7 @@
./usr/share/man/man4/netintro.4 man-sys-man .man
./usr/share/man/man4/netsmb.4 man-sys-man .man
./usr/share/man/man4/networking.4 man-sys-man .man
./usr/share/man/man4/nfe.4 man-sys-man .man
./usr/share/man/man4/njs.4 man-sys-man .man
./usr/share/man/man4/ns.4 man-sys-man .man
./usr/share/man/man4/nsclpcsio.4 man-sys-man .man

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.376 2006/03/06 18:35:24 bouyer Exp $
# $NetBSD: Makefile,v 1.377 2006/03/12 22:40:42 chs Exp $
# @(#)Makefile 8.1 (Berkeley) 6/18/93
MAN= aac.4 ac97.4 acardide.4 aceride.4 acphy.4 adc.4 adt7467c.4 adv.4 \
@ -25,7 +25,7 @@ MAN= aac.4 ac97.4 acardide.4 aceride.4 acphy.4 adc.4 adt7467c.4 adv.4 \
kttcp.4 lc.4 ld.4 lkm.4 lo.4 lxtphy.4 mainbus.4 makphy.4 \
mbe.4 mca.4 mcclock.4 md.4 mfb.4 mhzc.4 midi.4 \
mii.4 mk48txx.4 mlx.4 mly.4 mpt.4 mpu.4 mtd.4 \
mtio.4 multicast.4 ne.4 neo.4 netintro.4 njs.4 ns.4 \
mtio.4 multicast.4 ne.4 neo.4 netintro.4 nfe.4 njs.4 ns.4 \
nsclpcsio.4 nsip.4 nsphy.4 nsphyter.4 ntwoc.4 \
null.4 nsmb.4 oak.4 oosiop.4 opl.4 options.4 \
optiide.4 osiop.4 pas.4 pcdisplay.4 pciide.4 \

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

@ -0,0 +1,84 @@
.\" $NetBSD: nfe.4,v 1.1 2006/03/12 22:40:42 chs Exp $
.\" $OpenBSD: nfe.4,v 1.8 2006/03/04 04:35:24 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.
.\"
.Dd March 12, 2006
.Dt NFE 4
.Os
.Sh NAME
.Nm nfe
.Nd NVIDIA nForce MCP Ethernet driver
.Sh SYNOPSIS
.Cd "nfe* at pci?"
.Cd "ciphy* at mii?"
.Cd "icsphy* at mii?"
.Cd "makphy* at mii?"
.Cd "rlphy* at mii?"
.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 ciphy 4 ,
.Xr eephy 4 ,
.Xr icsphy 4 ,
.Xr ifmedia 4 ,
.Xr intro 4 ,
.Xr netintro 4 ,
.Xr pci 4 ,
.Xr rlphy 4 ,
.Xr hostname.if 5 ,
.Xr ifconfig 8
.Sh HISTORY
The
.Nm
device driver first appeared in
.Ox 3.9 .
It was added to
.Nx 4.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 .
.Sh CAVEATS
NVIDIA refuse to release any documentation on their products.

1781
sys/dev/pci/if_nfe.c Normal file

File diff suppressed because it is too large Load Diff

182
sys/dev/pci/if_nfereg.h Normal file
View File

@ -0,0 +1,182 @@
/* $NetBSD: if_nfereg.h,v 1.1 2006/03/12 22:40:42 chs Exp $ */
/* $OpenBSD: if_nfereg.h,v 1.16 2006/02/22 19:23:44 damien Exp $ */
/*-
* Copyright (c) 2005 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.
*/
#define NFE_PCI_BA 0x10
#define NFE_RX_RING_COUNT 128
#define NFE_TX_RING_COUNT 64
#define ETHER_ALIGN 2
#define NFE_JBYTES (ETHER_MAX_LEN_JUMBO + ETHER_ALIGN)
#define NFE_JPOOL_COUNT (NFE_RX_RING_COUNT + 64)
#define NFE_JPOOL_SIZE (NFE_JPOOL_COUNT * NFE_JBYTES)
#define NFE_MAX_SCATTER (NFE_TX_RING_COUNT - 2)
#define NFE_IRQ_STATUS 0x000
#define NFE_IRQ_MASK 0x004
#define NFE_SETUP_R6 0x008
#define NFE_IMTIMER 0x00c
#define NFE_MISC1 0x080
#define NFE_TX_CTL 0x084
#define NFE_TX_STATUS 0x088
#define NFE_RXFILTER 0x08c
#define NFE_RXBUFSZ 0x090
#define NFE_RX_CTL 0x094
#define NFE_RX_STATUS 0x098
#define NFE_RNDSEED 0x09c
#define NFE_SETUP_R1 0x0a0
#define NFE_SETUP_R2 0x0a4
#define NFE_MACADDR_HI 0x0a8
#define NFE_MACADDR_LO 0x0ac
#define NFE_MULTIADDR_HI 0x0b0
#define NFE_MULTIADDR_LO 0x0b4
#define NFE_MULTIMASK_HI 0x0b8
#define NFE_MULTIMASK_LO 0x0bc
#define NFE_PHY_IFACE 0x0c0
#define NFE_TX_RING_ADDR_LO 0x100
#define NFE_RX_RING_ADDR_LO 0x104
#define NFE_RING_SIZE 0x108
#define NFE_TX_UNK 0x10c
#define NFE_LINKSPEED 0x110
#define NFE_SETUP_R5 0x130
#define NFE_SETUP_R3 0x13C
#define NFE_SETUP_R7 0x140
#define NFE_RXTX_CTL 0x144
#define NFE_TX_RING_ADDR_HI 0x148
#define NFE_RX_RING_ADDR_HI 0x14c
#define NFE_PHY_STATUS 0x180
#define NFE_SETUP_R4 0x184
#define NFE_STATUS 0x188
#define NFE_PHY_SPEED 0x18c
#define NFE_PHY_CTL 0x190
#define NFE_PHY_DATA 0x194
#define NFE_WOL_CTL 0x200
#define NFE_PATTERN_CRC 0x204
#define NFE_PATTERN_MASK 0x208
#define NFE_PWR_CAP 0x268
#define NFE_PWR_STATE 0x26c
#define NFE_VTAG_CTL 0x300
#define NFE_PHY_ERROR 0x00001
#define NFE_PHY_WRITE 0x00400
#define NFE_PHY_BUSY 0x08000
#define NFE_PHYADD_SHIFT 5
#define NFE_STATUS_MAGIC 0x140000
#define NFE_R1_MAGIC 0x16070f
#define NFE_R2_MAGIC 0x16
#define NFE_R4_MAGIC 0x08
#define NFE_R6_MAGIC 0x03
#define NFE_WOL_MAGIC 0x7770
#define NFE_RX_START 0x01
#define NFE_TX_START 0x01
#define NFE_IRQ_RXERR 0x0001
#define NFE_IRQ_RX 0x0002
#define NFE_IRQ_RX_NOBUF 0x0004
#define NFE_IRQ_TXERR 0x0008
#define NFE_IRQ_TX_DONE 0x0010
#define NFE_IRQ_TIMER 0x0020
#define NFE_IRQ_LINK 0x0040
#define NFE_IRQ_TXERR2 0x0080
#define NFE_IRQ_TX1 0x0100
#define NFE_IRQ_WANTED \
(NFE_IRQ_RXERR | NFE_IRQ_RX_NOBUF | NFE_IRQ_RX | \
NFE_IRQ_TXERR | NFE_IRQ_TXERR2 | NFE_IRQ_TX_DONE | \
NFE_IRQ_LINK)
#define NFE_RXTX_KICKTX 0x0001
#define NFE_RXTX_BIT1 0x0002
#define NFE_RXTX_BIT2 0x0004
#define NFE_RXTX_RESET 0x0010
#define NFE_RXTX_VTAG_STRIP 0x0040
#define NFE_RXTX_VTAG_INSERT 0x0080
#define NFE_RXTX_RXCSUM 0x0400
#define NFE_RXTX_V2MAGIC 0x2100
#define NFE_RXTX_V3MAGIC 0x2200
#define NFE_RXFILTER_MAGIC 0x007f0008
#define NFE_U2M (1 << 5)
#define NFE_PROMISC (1 << 7)
/* default interrupt moderation timer of 128us */
#define NFE_IM_DEFAULT ((128 * 100) / 1024)
#define NFE_VTAG_ENABLE (1 << 13)
#define NFE_PWR_VALID (1 << 8)
#define NFE_PWR_WAKEUP (1 << 15)
#define NFE_MEDIA_SET 0x10000
#define NFE_MEDIA_1000T 0x00032
#define NFE_MEDIA_100TX 0x00064
#define NFE_MEDIA_10T 0x003e8
#define NFE_PHY_100TX (1 << 0)
#define NFE_PHY_1000T (1 << 1)
#define NFE_PHY_HDX (1 << 8)
#define NFE_MISC1_MAGIC 0x003b0f3c
#define NFE_MISC1_HDX (1 << 1)
#define NFE_SEED_MASK 0x0003ff00
#define NFE_SEED_10T 0x00007f00
#define NFE_SEED_100TX 0x00002d00
#define NFE_SEED_1000T 0x00007400
/* Rx/Tx descriptor */
struct nfe_desc32 {
uint32_t physaddr;
uint16_t length;
uint16_t flags;
#define NFE_RX_FIXME_V1 0x6004
#define NFE_RX_VALID_V1 (1 << 0)
#define NFE_TX_ERROR_V1 0x7808
#define NFE_TX_LASTFRAG_V1 (1 << 0)
} __packed;
/* V2 Rx/Tx descriptor */
struct nfe_desc64 {
uint32_t physaddr[2];
uint32_t vtag;
#define NFE_RX_VTAG (1 << 16)
#define NFE_TX_VTAG (1 << 18)
uint16_t length;
uint16_t flags;
#define NFE_RX_FIXME_V2 0x4300
#define NFE_RX_VALID_V2 (1 << 13)
#define NFE_TX_ERROR_V2 0x5c04
#define NFE_TX_LASTFRAG_V2 (1 << 13)
} __packed;
/* flags common to V1/V2 descriptors */
#define NFE_RX_CSUMOK 0x1c00
#define NFE_RX_ERROR (1 << 14)
#define NFE_RX_READY (1 << 15)
#define NFE_TX_TCP_CSUM (1 << 10)
#define NFE_TX_IP_CSUM (1 << 11)
#define NFE_TX_VALID (1 << 15)
#define NFE_READ(sc, reg) \
bus_space_read_4((sc)->sc_memt, (sc)->sc_memh, (reg))
#define NFE_WRITE(sc, reg, val) \
bus_space_write_4((sc)->sc_memt, (sc)->sc_memh, (reg), (val))

93
sys/dev/pci/if_nfevar.h Normal file
View File

@ -0,0 +1,93 @@
/* $NetBSD: if_nfevar.h,v 1.1 2006/03/12 22:40:42 chs Exp $ */
/* $OpenBSD: if_nfevar.h,v 1.11 2006/02/19 13:57:02 damien Exp $ */
/*-
* Copyright (c) 2005 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.
*/
#define NFE_IFQ_MAXLEN 64
struct nfe_tx_data {
bus_dmamap_t map;
bus_dmamap_t active;
struct mbuf *m;
};
struct nfe_tx_ring {
bus_dmamap_t map;
bus_dma_segment_t seg;
bus_addr_t physaddr;
struct nfe_desc32 *desc32;
struct nfe_desc64 *desc64;
struct nfe_tx_data data[NFE_TX_RING_COUNT];
int queued;
int cur;
int next;
};
struct nfe_jbuf {
caddr_t buf;
bus_addr_t physaddr;
SLIST_ENTRY(nfe_jbuf) jnext;
};
struct nfe_rx_data {
bus_dmamap_t map;
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_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 ethercom sc_ethercom;
uint8_t sc_enaddr[ETHER_ADDR_LEN];
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 callout sc_tick_ch;
void *sc_powerhook;
int sc_if_flags;
u_int sc_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;
struct nfe_tx_ring txq;
struct nfe_rx_ring rxq;
};