1 /* $OpenBSD: hmevar.h,v 1.9 2006/12/21 22:13:36 jason Exp $ */
2 /* $NetBSD: hmevar.h,v 1.6 2000/09/28 10:56:57 tsutsui Exp $ */
3
4 /*-
5 * Copyright (c) 1999 The NetBSD Foundation, Inc.
6 * All rights reserved.
7 *
8 * This code is derived from software contributed to The NetBSD Foundation
9 * by Paul Kranenburg.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. All advertising materials mentioning features or use of this software
20 * must display the following acknowledgement:
21 * This product includes software developed by the NetBSD
22 * Foundation, Inc. and its contributors.
23 * 4. Neither the name of The NetBSD Foundation nor the names of its
24 * contributors may be used to endorse or promote products derived
25 * from this software without specific prior written permission.
26 *
27 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
28 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
29 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
31 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 * POSSIBILITY OF SUCH DAMAGE.
38 */
39
40 #include <sys/timeout.h>
41
42 #define HME_TX_RING_SIZE 64
43 #define HME_RX_RING_SIZE 64
44 #define HME_RX_RING_MAX 256
45 #define HME_TX_RING_MAX 256
46 #define HME_RX_PKTSIZE 1600
47
48 struct hme_sxd {
49 struct mbuf *sd_mbuf; /* descriptor mbuf */
50 bus_dmamap_t sd_map; /* descriptor dmamap */
51 int sd_loaded; /* descriptor dmamap loaded? */
52 };
53
54 struct hme_ring {
55 /* Ring Descriptors */
56 caddr_t rb_membase; /* Packet buffer: CPU address */
57 bus_addr_t rb_dmabase; /* Packet buffer: DMA address */
58 caddr_t rb_txd; /* Transmit descriptors */
59 bus_addr_t rb_txddma; /* DMA address of same */
60 caddr_t rb_rxd; /* Receive descriptors */
61 bus_addr_t rb_rxddma; /* DMA address of same */
62 };
63
64 struct hme_softc {
65 struct device sc_dev; /* boilerplate device view */
66 struct arpcom sc_arpcom; /* Ethernet common part */
67 struct mii_data sc_mii; /* MII media control */
68 #define sc_media sc_mii.mii_media/* shorthand */
69 struct timeout sc_tick_ch; /* tick callout */
70
71 /* The following bus handles are to be provided by the bus front-end */
72 bus_space_tag_t sc_bustag; /* bus tag */
73 bus_dma_tag_t sc_dmatag; /* bus dma tag */
74 bus_dmamap_t sc_dmamap; /* bus dma handle */
75 bus_space_handle_t sc_seb; /* HME Global registers */
76 bus_space_handle_t sc_erx; /* HME ERX registers */
77 bus_space_handle_t sc_etx; /* HME ETX registers */
78 bus_space_handle_t sc_mac; /* HME MAC registers */
79 bus_space_handle_t sc_mif; /* HME MIF registers */
80 int sc_burst; /* DVMA burst size in effect */
81 int sc_phys[2]; /* MII instance -> PHY map */
82
83 int sc_pci; /* XXXXX -- PCI buses are LE. */
84
85 /* Ring descriptor */
86 struct hme_ring sc_rb;
87
88 int sc_debug;
89 void *sc_sh; /* shutdownhook cookie */
90 short sc_if_flags;
91
92 /* Special hardware hooks */
93 void (*sc_hwreset)(struct hme_softc *);
94 void (*sc_hwinit)(struct hme_softc *);
95
96 struct hme_sxd sc_txd[HME_TX_RING_MAX], sc_rxd[HME_RX_RING_MAX];
97 bus_dmamap_t sc_rxmap_spare;
98 int sc_tx_cnt, sc_tx_prod, sc_tx_cons;
99 int sc_last_rd;
100 u_int32_t sc_tcvr;
101 };
102
103
104 void hme_config(struct hme_softc *);
105 void hme_reset(struct hme_softc *);
106 int hme_intr(void *);