hd64570var.h revision 1.1 1 /* $Id: hd64570var.h,v 1.1 1998/07/26 03:26:57 explorer Exp $ */
2
3 /*
4 * Copyright (c) 1998 Vixie Enterprises
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. Neither the name of Vixie Enterprises nor the names
17 * of its contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY VIXIE ENTERPRISES AND
21 * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
22 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
23 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 * DISCLAIMED. IN NO EVENT SHALL VIXIE ENTERPRISES OR
25 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
28 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
29 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
31 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 *
34 * This software has been written for Vixie Enterprises by Michael Graff
35 * <explorer (at) flame.org>. To learn more about Vixie Enterprises, see
36 * ``http://www.vix.com''.
37 */
38
39 #ifndef _HD64570VAR_H_
40 #define _HD64570VAR_H_
41
42 #include "bpfilter.h"
43
44 #define SCA_USE_FASTQ /* use a split queue, one for fast traffic */
45
46 struct sca_softc;
47 typedef struct sca_port sca_port_t;
48 typedef struct sca_desc sca_desc_t;
49
50 /*
51 * device DMA descriptor
52 */
53 struct sca_desc {
54 u_int16_t cp; /* chain pointer */
55 u_int16_t bp; /* buffer pointer (low bits) */
56 u_int8_t bpb; /* buffer pointer (high bits) */
57 u_int8_t unused0;
58 u_int16_t len; /* total length */
59 u_int8_t stat; /* status */
60 u_int8_t unused1;
61 };
62 #define SCA_DESC_EOT 0x01
63 #define SCA_DESC_CRC 0x04
64 #define SCA_DESC_OVRN 0x08
65 #define SCA_DESC_RESD 0x10
66 #define SCA_DESC_ABORT 0x20
67 #define SCA_DESC_SHRTFRM 0x40
68 #define SCA_DESC_EOM 0x80
69 #define SCA_DESC_ERRORS 0x7C
70
71 /*
72 * softc structure for each port
73 */
74 struct sca_port {
75 u_int msci_off; /* offset for msci address for this port */
76 u_int dmac_off; /* offset of dmac address for this port */
77
78 u_int sp_port;
79
80 /*
81 * CISCO keepalive stuff
82 */
83 u_int32_t cka_lasttx;
84 u_int32_t cka_lastrx;
85
86 /*
87 * start of each important bit of information for transmit and
88 * receive buffers.
89 */
90 u_int32_t txdesc_p;
91 sca_desc_t *txdesc;
92 u_int32_t txbuf_p;
93 u_int8_t *txbuf;
94 volatile u_int txcur; /* last descriptor in chain */
95 volatile u_int txinuse; /* descriptors in use */
96 volatile u_int txstart; /* start descriptor */
97
98 u_int32_t rxdesc_p;
99 sca_desc_t *rxdesc;
100 u_int32_t rxbuf_p;
101 u_int8_t *rxbuf;
102 u_int rxstart; /* index of first descriptor */
103 u_int rxend; /* index of last descriptor */
104
105 struct ifnet sp_if; /* the network information */
106 struct ifqueue linkq; /* link-level packets are high prio */
107 #ifdef SCA_USE_FASTQ
108 struct ifqueue fastq; /* interactive packets */
109 #endif
110
111 #if NBPFILTER > 0
112 caddr_t sp_bpf; /* hook for BPF */
113 #endif
114
115 struct sca_softc *sca; /* pointer to parent */
116 };
117
118 /*
119 * softc structure for the chip itself
120 */
121 struct sca_softc {
122 struct device *parent; /* our parent device, or NULL */
123 int sc_numports; /* number of ports present */
124
125 /*
126 * a callback into the parent, since the SCA chip has no control
127 * over DTR, we have to make a callback into the parent, which
128 * might know about DTR.
129 *
130 * If the function pointer is NULL, no callback is specified.
131 */
132 void (*dtr_callback) __P((void *aux, int port, int state));
133 void *dtr_aux;
134
135 sca_port_t sc_ports[2];
136 bus_space_handle_t sc_ioh;
137 bus_space_tag_t sc_iot;
138
139 bus_dma_tag_t sc_dmat; /* bus dma tag */
140 bus_dmamap_t sc_dmam; /* bus dma map */
141 bus_dma_segment_t sc_seg; /* bus dma segment allocated */
142 caddr_t sc_dma_addr; /* kva address of segment */
143 u_long sc_allocsize; /* size of region */
144 };
145
146
147 int sca_init(struct sca_softc *, u_int);
148 void sca_port_attach(struct sca_softc *, u_int);
149 int sca_hardintr(struct sca_softc *);
150 void sca_shutdown(struct sca_softc *);
151
152 #endif /* _HD64570VAR_H_ */
153