Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/sgimips/mace Rename if_mec_mace.c -> if_mec.c.
details: https://anonhg.NetBSD.org/src/rev/bbb54538567a
branches: trunk
changeset: 570094:bbb54538567a
user: tsutsui <tsutsui%NetBSD.org@localhost>
date: Thu Sep 23 14:45:20 2004 +0000
description:
Rename if_mec_mace.c -> if_mec.c.
This file contains not only an attachment but whole driver functions.
diffstat:
sys/arch/sgimips/mace/files.mace | 4 +-
sys/arch/sgimips/mace/if_mec.c | 1472 +++++++++++++++++++++++++++++++++++
sys/arch/sgimips/mace/if_mec_mace.c | 1472 -----------------------------------
3 files changed, 1474 insertions(+), 1474 deletions(-)
diffs (truncated from 2970 to 300 lines):
diff -r a149da408af1 -r bbb54538567a sys/arch/sgimips/mace/files.mace
--- a/sys/arch/sgimips/mace/files.mace Thu Sep 23 12:54:58 2004 +0000
+++ b/sys/arch/sgimips/mace/files.mace Thu Sep 23 14:45:20 2004 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.mace,v 1.2 2004/01/20 19:58:00 jdolecek Exp $
+# $NetBSD: files.mace,v 1.3 2004/09/23 14:45:20 tsutsui Exp $
device mace {[offset = -1], [intr = -1], [intrmask = 0] }
attach mace at mainbus
@@ -19,7 +19,7 @@
device mec: arp, ether, ifnet, mii
attach mec at mace
-file arch/sgimips/mace/if_mec_mace.c mec
+file arch/sgimips/mace/if_mec.c mec
device macau: audiobus, ad1848, auconv
attach macau at mace with macau
diff -r a149da408af1 -r bbb54538567a sys/arch/sgimips/mace/if_mec.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/sgimips/mace/if_mec.c Thu Sep 23 14:45:20 2004 +0000
@@ -0,0 +1,1472 @@
+/* $NetBSD: if_mec.c,v 1.1 2004/09/23 14:45:20 tsutsui Exp $ */
+
+/*
+ * Copyright (c) 2004 Izumi Tsutsui.
+ * 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. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
+ */
+
+/*
+ * Copyright (c) 2003 Christopher SEKIYA
+ * 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 for the
+ * NetBSD Project. See http://www.NetBSD.org/ for
+ * information about NetBSD.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
+ */
+
+/*
+ * MACE MAC-110 ethernet driver
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: if_mec.c,v 1.1 2004/09/23 14:45:20 tsutsui Exp $");
+
+#include "opt_ddb.h"
+#include "bpfilter.h"
+#include "rnd.h"
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/device.h>
+#include <sys/callout.h>
+#include <sys/mbuf.h>
+#include <sys/malloc.h>
+#include <sys/kernel.h>
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+#include <sys/errno.h>
+
+#if NRND > 0
+#include <sys/rnd.h>
+#endif
+
+#include <net/if.h>
+#include <net/if_dl.h>
+#include <net/if_media.h>
+#include <net/if_ether.h>
+
+#if NBPFILTER > 0
+#include <net/bpf.h>
+#endif
+
+#include <machine/bus.h>
+#include <machine/intr.h>
+#include <machine/machtype.h>
+
+#include <dev/mii/mii.h>
+#include <dev/mii/miivar.h>
+
+#include <sgimips/mace/macevar.h>
+#include <sgimips/mace/if_mecreg.h>
+
+#include <dev/arcbios/arcbios.h>
+#include <dev/arcbios/arcbiosvar.h>
+
+/* #define MEC_DEBUG */
+
+#ifdef MEC_DEBUG
+#define MEC_DEBUG_RESET 0x01
+#define MEC_DEBUG_START 0x02
+#define MEC_DEBUG_STOP 0x04
+#define MEC_DEBUG_INTR 0x08
+#define MEC_DEBUG_RXINTR 0x10
+#define MEC_DEBUG_TXINTR 0x20
+uint32_t mec_debug = 0;
+#define DPRINTF(x, y) if (mec_debug & (x)) printf y
+#else
+#define DPRINTF(x, y) /* nothing */
+#endif
+
+/*
+ * Transmit descriptor list size
+ */
+#define MEC_NTXDESC 64
+#define MEC_NTXDESC_MASK (MEC_NTXDESC - 1)
+#define MEC_NEXTTX(x) (((x) + 1) & MEC_NTXDESC_MASK)
+
+/*
+ * software state for TX
+ */
+struct mec_txsoft {
+ struct mbuf *txs_mbuf; /* head of our mbuf chain */
+ bus_dmamap_t txs_dmamap; /* our DMA map */
+ uint32_t txs_flags;
+#define MEC_TXS_BUFLEN_MASK 0x0000007f /* data len in txd_buf */
+#define MEC_TXS_TXDBUF 0x00000080 /* txd_buf is used */
+#define MEC_TXS_TXDPTR1 0x00000100 /* txd_ptr[0] is used */
+};
+
+/*
+ * Transmit buffer descriptor
+ */
+#define MEC_TXDESCSIZE 128
+#define MEC_NTXPTR 3
+#define MEC_TXD_BUFOFFSET \
+ (sizeof(uint64_t) + MEC_NTXPTR * sizeof(uint64_t))
+#define MEC_TXD_BUFSIZE (MEC_TXDESCSIZE - MEC_TXD_BUFOFFSET)
+#define MEC_TXD_BUFSTART(len) (MEC_TXD_BUFSIZE - (len))
+#define MEC_TXD_ALIGN 8
+#define MEC_TXD_ROUNDUP(addr) \
+ (((addr) + (MEC_TXD_ALIGN - 1)) & ~((uint64_t)MEC_TXD_ALIGN - 1))
+
+struct mec_txdesc {
+ volatile uint64_t txd_cmd;
+#define MEC_TXCMD_DATALEN 0x000000000000ffff /* data length */
+#define MEC_TXCMD_BUFSTART 0x00000000007f0000 /* start byte offset */
+#define TXCMD_BUFSTART(x) ((x) << 16)
+#define MEC_TXCMD_TERMDMA 0x0000000000800000 /* stop DMA on abort */
+#define MEC_TXCMD_TXINT 0x0000000001000000 /* INT after TX done */
+#define MEC_TXCMD_PTR1 0x0000000002000000 /* valid 1st txd_ptr */
+#define MEC_TXCMD_PTR2 0x0000000004000000 /* valid 2nd txd_ptr */
+#define MEC_TXCMD_PTR3 0x0000000008000000 /* valid 3rd txd_ptr */
+#define MEC_TXCMD_UNUSED 0xfffffffff0000000ULL /* should be zero */
+
+#define txd_stat txd_cmd
+#define MEC_TXSTAT_LEN 0x000000000000ffff /* TX length */
+#define MEC_TXSTAT_COLCNT 0x00000000000f0000 /* collision count */
+#define MEC_TXSTAT_COLCNT_SHIFT 16
+#define MEC_TXSTAT_LATE_COL 0x0000000000100000 /* late collision */
+#define MEC_TXSTAT_CRCERROR 0x0000000000200000 /* */
+#define MEC_TXSTAT_DEFERRED 0x0000000000400000 /* */
+#define MEC_TXSTAT_SUCCESS 0x0000000000800000 /* TX complete */
+#define MEC_TXSTAT_TOOBIG 0x0000000001000000 /* */
+#define MEC_TXSTAT_UNDERRUN 0x0000000002000000 /* */
+#define MEC_TXSTAT_COLLISIONS 0x0000000004000000 /* */
+#define MEC_TXSTAT_EXDEFERRAL 0x0000000008000000 /* */
+#define MEC_TXSTAT_COLLIDED 0x0000000010000000 /* */
+#define MEC_TXSTAT_UNUSED 0x7fffffffe0000000ULL /* should be zero */
+#define MEC_TXSTAT_SENT 0x8000000000000000ULL /* packet sent */
+
+ uint64_t txd_ptr[MEC_NTXPTR];
+#define MEC_TXPTR_UNUSED2 0x0000000000000007 /* should be zero */
+#define MEC_TXPTR_DMAADDR 0x00000000fffffff8 /* TX DMA address */
+#define MEC_TXPTR_LEN 0x0000ffff00000000ULL /* buffer length */
+#define TXPTR_LEN(x) ((uint64_t)(x) << 32)
+#define MEC_TXPTR_UNUSED1 0xffff000000000000ULL /* should be zero */
+
+ uint8_t txd_buf[MEC_TXD_BUFSIZE];
+};
+
+/*
+ * Receive buffer size
+ */
+#define MEC_NRXDESC 16
+#define MEC_NRXDESC_MASK (MEC_NRXDESC - 1)
+#define MEC_NEXTRX(x) (((x) + 1) & MEC_NRXDESC_MASK)
+
+/*
+ * Receive buffer description
+ */
+#define MEC_RXDESCSIZE 4096 /* umm, should be 4kbyte aligned */
+#define MEC_RXD_NRXPAD 3
+#define MEC_RXD_DMAOFFSET (1 + MEC_RXD_NRXPAD)
+#define MEC_RXD_BUFOFFSET (MEC_RXD_DMAOFFSET * sizeof(uint64_t))
+#define MEC_RXD_BUFSIZE (MEC_RXDESCSIZE - MEC_RXD_BUFOFFSET)
+
+struct mec_rxdesc {
+ volatile uint64_t rxd_stat;
+#define MEC_RXSTAT_LEN 0x000000000000ffff /* data length */
+#define MEC_RXSTAT_VIOLATION 0x0000000000010000 /* code violation (?) */
+#define MEC_RXSTAT_UNUSED2 0x0000000000020000 /* unknown (?) */
+#define MEC_RXSTAT_CRCERROR 0x0000000000040000 /* CRC error */
+#define MEC_RXSTAT_MULTICAST 0x0000000000080000 /* multicast packet */
+#define MEC_RXSTAT_BROADCAST 0x0000000000100000 /* broadcast packet */
+#define MEC_RXSTAT_INVALID 0x0000000000200000 /* invalid preamble */
+#define MEC_RXSTAT_LONGEVENT 0x0000000000400000 /* long packet */
+#define MEC_RXSTAT_BADPACKET 0x0000000000800000 /* bad packet */
+#define MEC_RXSTAT_CAREVENT 0x0000000001000000 /* carrier event */
+#define MEC_RXSTAT_MATCHMCAST 0x0000000002000000 /* match multicast */
+#define MEC_RXSTAT_MATCHMAC 0x0000000004000000 /* match MAC */
+#define MEC_RXSTAT_SEQNUM 0x00000000f8000000 /* sequence number */
+#define MEC_RXSTAT_CKSUM 0x0000ffff00000000ULL /* IP checksum */
+#define MEC_RXSTAT_UNUSED1 0x7fff000000000000ULL /* should be zero */
+#define MEC_RXSTAT_RECEIVED 0x8000000000000000ULL /* set to 1 on RX */
+ uint64_t rxd_pad1[MEC_RXD_NRXPAD];
+ uint8_t rxd_buf[MEC_RXD_BUFSIZE];
+};
+
+/*
+ * control structures for DMA ops
+ */
+struct mec_control_data {
+ /*
+ * TX descriptors and buffers
+ */
+ struct mec_txdesc mcd_txdesc[MEC_NTXDESC];
+
+ /*
+ * RX descriptors and buffers
+ */
+ struct mec_rxdesc mcd_rxdesc[MEC_NRXDESC];
+};
+
+/*
+ * It _seems_ there are some restrictions on descriptor address:
+ *
+ * - Base address of txdescs should be 8kbyte aligned
+ * - Each txdesc should be 128byte aligned
+ * - Each rxdesc should be 4kbyte aligned
+ *
+ * So we should specify 64k align to allocalte txdescs.
+ * In this case, sizeof(struct mec_txdesc) * MEC_NTXDESC is 8192
+ * so rxdescs are also allocated at 4kbyte aligned.
+ */
+#define MEC_CONTROL_DATA_ALIGN (8 * 1024)
+
+#define MEC_CDOFF(x) offsetof(struct mec_control_data, x)
+#define MEC_CDTXOFF(x) MEC_CDOFF(mcd_txdesc[(x)])
+#define MEC_CDRXOFF(x) MEC_CDOFF(mcd_rxdesc[(x)])
+
+/*
+ * software state per device
+ */
+struct mec_softc {
+ struct device sc_dev; /* generic device structures */
+
+ bus_space_tag_t sc_st; /* bus_space tag */
+ bus_space_handle_t sc_sh; /* bus_space handle */
+ bus_dma_tag_t sc_dmat; /* bus_dma tag */
+ void *sc_sdhook; /* shoutdown hook */
+
+ struct ethercom sc_ethercom; /* Ethernet common part */
+
+ struct mii_data sc_mii; /* MII/media information */
Home |
Main Index |
Thread Index |
Old Index