Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/pci Add driver for SysKonnect SK-9821 and 3COM 3C940...
details: https://anonhg.NetBSD.org/src/rev/32c46c2eed78
branches: trunk
changeset: 550988:32c46c2eed78
user: jdolecek <jdolecek%NetBSD.org@localhost>
date: Tue Aug 26 21:11:00 2003 +0000
description:
Add driver for SysKonnect SK-9821 and 3COM 3C940 gigabit ethernet boards
>From FreeBSD via OpenBSD, port to NetBSD done by Stephen Degler
Changes relative to submitted version:
* yukonreg.h and xmaciireg.h merged into if_skreg.h
* bhack[] constified + other small editing changes
* use 'Ethernet address' rather than 'address' in attach message
XXX completely untested by me, needs further cleanup
Driver provided in PR kern/22511 by Stephen Degler
diffstat:
sys/dev/pci/files.pci | 9 +-
sys/dev/pci/if_sk.c | 2566 ++++++++++++++++++++++++++++++++++++++++++++++++
sys/dev/pci/if_skreg.h | 1899 +++++++++++++++++++++++++++++++++++
sys/dev/pci/if_skvar.h | 211 +++
4 files changed, 4684 insertions(+), 1 deletions(-)
diffs (truncated from 4708 to 300 lines):
diff -r 85b631c112fb -r 32c46c2eed78 sys/dev/pci/files.pci
--- a/sys/dev/pci/files.pci Tue Aug 26 21:02:22 2003 +0000
+++ b/sys/dev/pci/files.pci Tue Aug 26 21:11:00 2003 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.pci,v 1.190 2003/08/08 20:46:09 jonathan Exp $
+# $NetBSD: files.pci,v 1.191 2003/08/26 21:11:00 jdolecek Exp $
#
# Config file and device description for machine-independent PCI code.
# Included by ports that need it. Requires that the SCSI files be
@@ -605,3 +605,10 @@
device txp: ether, ifnet, arp
attach txp at pci
file dev/pci/if_txp.c txp
+
+# SysKonnect
+device skc { }
+attach skc at pci
+device sk: ether, ifnet, arp, mii
+attach sk at skc
+file dev/pci/if_sk.c skc | sk
diff -r 85b631c112fb -r 32c46c2eed78 sys/dev/pci/if_sk.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/dev/pci/if_sk.c Tue Aug 26 21:11:00 2003 +0000
@@ -0,0 +1,2566 @@
+/* $NetBSD: if_sk.c,v 1.1 2003/08/26 21:11:00 jdolecek Exp $ */
+
+/*-
+ * Copyright (c) 2003 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * 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.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+ */
+
+/* $OpenBSD: if_sk.c,v 1.33 2003/08/12 05:23:06 nate Exp $ */
+
+/*
+ * Copyright (c) 1997, 1998, 1999, 2000
+ * Bill Paul <wpaul%ctr.columbia.edu@localhost>. All rights reserved.
+ *
+ * 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.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Bill Paul.
+ * 4. Neither the name of the author nor the names of any co-contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Bill Paul 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 Bill Paul OR THE VOICES IN HIS HEAD
+ * 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: /c/ncvs/src/sys/pci/if_sk.c,v 1.20 2000/04/22 02:16:37 wpaul Exp $
+ */
+
+/*
+ * Copyright (c) 2003 Nathan L. Binkert <binkertn%umich.edu@localhost>
+ *
+ * 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.
+ */
+
+/*
+ * SysKonnect SK-NET gigabit ethernet driver for FreeBSD. Supports
+ * the SK-984x series adapters, both single port and dual port.
+ * References:
+ * The XaQti XMAC II datasheet,
+ * http://www.freebsd.org/~wpaul/SysKonnect/xmacii_datasheet_rev_c_9-29.pdf
+ * The SysKonnect GEnesis manual, http://www.syskonnect.com
+ *
+ * Note: XaQti has been acquired by Vitesse, and Vitesse does not have the
+ * XMAC II datasheet online. I have put my copy at people.freebsd.org as a
+ * convenience to others until Vitesse corrects this problem:
+ *
+ * http://people.freebsd.org/~wpaul/SysKonnect/xmacii_datasheet_rev_c_9-29.pdf
+ *
+ * Written by Bill Paul <wpaul%ee.columbia.edu@localhost>
+ * Department of Electrical Engineering
+ * Columbia University, New York City
+ */
+
+/*
+ * The SysKonnect gigabit ethernet adapters consist of two main
+ * components: the SysKonnect GEnesis controller chip and the XaQti Corp.
+ * XMAC II gigabit ethernet MAC. The XMAC provides all of the MAC
+ * components and a PHY while the GEnesis controller provides a PCI
+ * interface with DMA support. Each card may have between 512K and
+ * 2MB of SRAM on board depending on the configuration.
+ *
+ * The SysKonnect GEnesis controller can have either one or two XMAC
+ * chips connected to it, allowing single or dual port NIC configurations.
+ * SysKonnect has the distinction of being the only vendor on the market
+ * with a dual port gigabit ethernet NIC. The GEnesis provides dual FIFOs,
+ * dual DMA queues, packet/MAC/transmit arbiters and direct access to the
+ * XMAC registers. This driver takes advantage of these features to allow
+ * both XMACs to operate as independent interfaces.
+ */
+
+#include "bpfilter.h"
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/sockio.h>
+#include <sys/mbuf.h>
+#include <sys/malloc.h>
+#include <sys/kernel.h>
+#include <sys/socket.h>
+#include <sys/device.h>
+#include <sys/queue.h>
+#include <sys/callout.h>
+
+#include <net/if.h>
+#include <net/if_dl.h>
+#include <net/if_types.h>
+
+#ifdef INET
+#include <netinet/in.h>
+#include <netinet/in_systm.h>
+#include <netinet/in_var.h>
+#include <netinet/ip.h>
+#include <netinet/if_ether.h>
+#endif
+
+#include <net/if_media.h>
+
+#if NBPFILTER > 0
+#include <net/bpf.h>
+#endif
+
+#include <dev/mii/mii.h>
+#include <dev/mii/miivar.h>
+#include <dev/mii/brgphyreg.h>
+
+#include <dev/pci/pcireg.h>
+#include <dev/pci/pcivar.h>
+#include <dev/pci/pcidevs.h>
+
+#define SK_VERBOSE
+/* #define SK_USEIOSPACE */
+
+#include <dev/pci/if_skreg.h>
+#include <dev/pci/if_skvar.h>
+
+int skc_probe(struct device *, struct cfdata *, void *);
+void skc_attach(struct device *, struct device *self, void *aux);
+int sk_probe(struct device *, struct cfdata *, void *);
+void sk_attach(struct device *, struct device *self, void *aux);
+int skcprint(void *, const char *);
+int sk_intr(void *);
+void sk_intr_bcom(struct sk_if_softc *);
+void sk_intr_xmac(struct sk_if_softc *);
+void sk_intr_yukon(struct sk_if_softc *);
+void sk_rxeof(struct sk_if_softc *);
+void sk_txeof(struct sk_if_softc *);
+int sk_encap(struct sk_if_softc *, struct mbuf *, u_int32_t *);
+void sk_start(struct ifnet *);
+int sk_ioctl(struct ifnet *, u_long, caddr_t);
+int sk_init(struct ifnet *);
+void sk_init_xmac(struct sk_if_softc *);
+void sk_init_yukon(struct sk_if_softc *);
+void sk_stop(struct ifnet *, int);
+void sk_watchdog(struct ifnet *);
+void sk_shutdown(void *);
+int sk_ifmedia_upd(struct ifnet *);
+void sk_ifmedia_sts(struct ifnet *, struct ifmediareq *);
+void sk_reset(struct sk_softc *);
+int sk_newbuf(struct sk_if_softc *, int, struct mbuf *, bus_dmamap_t);
+int sk_init_rx_ring(struct sk_if_softc *);
+int sk_init_tx_ring(struct sk_if_softc *);
+u_int8_t sk_vpd_readbyte(struct sk_softc *, int);
+void sk_vpd_read_res(struct sk_softc *,
+ struct vpd_res *, int);
+void sk_vpd_read(struct sk_softc *);
+
+int sk_xmac_miibus_readreg(struct device *, int, int);
+void sk_xmac_miibus_writereg(struct device *, int, int, int);
+void sk_xmac_miibus_statchg(struct device *);
+
+int sk_marv_miibus_readreg(struct device *, int, int);
+void sk_marv_miibus_writereg(struct device *, int, int, int);
+void sk_marv_miibus_statchg(struct device *);
+
+u_int32_t sk_calchash(caddr_t);
+void sk_setfilt(struct sk_if_softc *, caddr_t, int);
+void sk_setmulti(struct sk_if_softc *);
+void sk_tick(void *);
+
+/* #define SK_DEBUG 2 */
+#ifdef SK_DEBUG
+#define DPRINTF(x) if (skdebug) printf x
+#define DPRINTFN(n,x) if (skdebug >= (n)) printf x
+int skdebug = SK_DEBUG;
+
+void sk_dump_txdesc(struct sk_tx_desc *, int);
+void sk_dump_mbuf(struct mbuf *);
+void sk_dump_bytes(const char *, int);
+#else
+#define DPRINTF(x)
+#define DPRINTFN(n,x)
+#endif
+
+#define SK_SETBIT(sc, reg, x) \
+ CSR_WRITE_4(sc, reg, CSR_READ_4(sc, reg) | x)
+
+#define SK_CLRBIT(sc, reg, x) \
+ CSR_WRITE_4(sc, reg, CSR_READ_4(sc, reg) & ~x)
+
+#define SK_WIN_SETBIT_4(sc, reg, x) \
+ sk_win_write_4(sc, reg, sk_win_read_4(sc, reg) | x)
+
+#define SK_WIN_CLRBIT_4(sc, reg, x) \
+ sk_win_write_4(sc, reg, sk_win_read_4(sc, reg) & ~x)
+
+#define SK_WIN_SETBIT_2(sc, reg, x) \
+ sk_win_write_2(sc, reg, sk_win_read_2(sc, reg) | x)
+
+#define SK_WIN_CLRBIT_2(sc, reg, x) \
+ sk_win_write_2(sc, reg, sk_win_read_2(sc, reg) & ~x)
+
+/* supported device vendors */
+static const struct sk_product {
+ pci_vendor_id_t sk_vendor;
+ pci_product_id_t sk_product;
+} sk_products[] = {
+ { PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3C940, },
+ { PCI_VENDOR_SCHNEIDERKOCH, PCI_PRODUCT_SCHNEIDERKOCH_SKNET_GE, },
+ { PCI_VENDOR_SCHNEIDERKOCH, PCI_PRODUCT_SCHNEIDERKOCH_SK9821v2, },
+ { 0, 0, }
+};
+
+static inline u_int32_t
+sk_win_read_4(struct sk_softc *sc, u_int32_t reg)
+{
+#ifdef SK_USEIOSPACE
+ CSR_WRITE_4(sc, SK_RAP, SK_WIN(reg));
+ return CSR_READ_4(sc, SK_WIN_BASE + SK_REG(reg));
+#else
+ return CSR_READ_4(sc, reg);
+#endif
+}
+
+static inline u_int16_t
+sk_win_read_2(struct sk_softc *sc, u_int32_t reg)
+{
+#ifdef SK_USEIOSPACE
+ CSR_WRITE_4(sc, SK_RAP, SK_WIN(reg));
+ return CSR_READ_2(sc, SK_WIN_BASE + SK_REG(reg));
+#else
+ return CSR_READ_2(sc, reg);
+#endif
+}
Home |
Main Index |
Thread Index |
Old Index