xref: /openbsd/sys/dev/ic/hmevar.h (revision 7b36286a)
1 /*	$OpenBSD: hmevar.h,v 1.10 2008/06/26 05:42:15 ray 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  *
20  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
21  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
24  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  * POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 #include <sys/timeout.h>
34 
35 #define	HME_TX_RING_SIZE	64
36 #define	HME_RX_RING_SIZE	64
37 #define	HME_RX_RING_MAX		256
38 #define	HME_TX_RING_MAX		256
39 #define	HME_RX_PKTSIZE		1600
40 
41 struct hme_sxd {
42 	struct mbuf *sd_mbuf;		/* descriptor mbuf */
43 	bus_dmamap_t sd_map;		/* descriptor dmamap */
44 	int sd_loaded;			/* descriptor dmamap loaded? */
45 };
46 
47 struct hme_ring {
48 	/* Ring Descriptors */
49 	caddr_t		rb_membase;	/* Packet buffer: CPU address */
50 	bus_addr_t	rb_dmabase;	/* Packet buffer: DMA address */
51 	caddr_t		rb_txd;		/* Transmit descriptors */
52 	bus_addr_t	rb_txddma;	/* DMA address of same */
53 	caddr_t		rb_rxd;		/* Receive descriptors */
54 	bus_addr_t	rb_rxddma;	/* DMA address of same */
55 };
56 
57 struct hme_softc {
58 	struct device	sc_dev;		/* boilerplate device view */
59 	struct arpcom	sc_arpcom;	/* Ethernet common part */
60 	struct mii_data	sc_mii;		/* MII media control */
61 #define sc_media	sc_mii.mii_media/* shorthand */
62 	struct timeout	sc_tick_ch;	/* tick callout */
63 
64 	/* The following bus handles are to be provided by the bus front-end */
65 	bus_space_tag_t	sc_bustag;	/* bus tag */
66 	bus_dma_tag_t	sc_dmatag;	/* bus dma tag */
67 	bus_dmamap_t	sc_dmamap;	/* bus dma handle */
68 	bus_space_handle_t sc_seb;	/* HME Global registers */
69 	bus_space_handle_t sc_erx;	/* HME ERX registers */
70 	bus_space_handle_t sc_etx;	/* HME ETX registers */
71 	bus_space_handle_t sc_mac;	/* HME MAC registers */
72 	bus_space_handle_t sc_mif;	/* HME MIF registers */
73 	int		sc_burst;	/* DVMA burst size in effect */
74 	int		sc_phys[2];	/* MII instance -> PHY map */
75 
76 	int		sc_pci;		/* XXXXX -- PCI buses are LE. */
77 
78 	/* Ring descriptor */
79 	struct hme_ring		sc_rb;
80 
81 	int			sc_debug;
82 	void			*sc_sh;		/* shutdownhook cookie */
83 	short			sc_if_flags;
84 
85 	/* Special hardware hooks */
86 	void	(*sc_hwreset)(struct hme_softc *);
87 	void	(*sc_hwinit)(struct hme_softc *);
88 
89 	struct hme_sxd sc_txd[HME_TX_RING_MAX], sc_rxd[HME_RX_RING_MAX];
90 	bus_dmamap_t	sc_rxmap_spare;
91 	int	sc_tx_cnt, sc_tx_prod, sc_tx_cons;
92 	int	sc_last_rd;
93 	u_int32_t sc_tcvr;
94 };
95 
96 
97 void	hme_config(struct hme_softc *);
98 void	hme_reset(struct hme_softc *);
99 int	hme_intr(void *);
100