Fix numerous spelling mistakes.
[dragonfly.git] / sys / dev / netif / sk / if_skvar.h
1 /*-
2  * Copyright (c) 2003 The NetBSD Foundation, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  * 3. All advertising materials mentioning features or use of this software
14  *    must display the following acknowledgement:
15  *      This product includes software developed by the NetBSD
16  *      Foundation, Inc. and its contributors.
17  * 4. Neither the name of The NetBSD Foundation nor the names of its
18  *    contributors may be used to endorse or promote products derived
19  *    from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
22  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
23  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
25  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31  * POSSIBILITY OF SUCH DAMAGE.
32  */
33
34 /*
35  * Copyright (c) 1997, 1998, 1999, 2000
36  *      Bill Paul <wpaul@ctr.columbia.edu>.  All rights reserved.
37  *
38  * Redistribution and use in source and binary forms, with or without
39  * modification, are permitted provided that the following conditions
40  * are met:
41  * 1. Redistributions of source code must retain the above copyright
42  *    notice, this list of conditions and the following disclaimer.
43  * 2. Redistributions in binary form must reproduce the above copyright
44  *    notice, this list of conditions and the following disclaimer in the
45  *    documentation and/or other materials provided with the distribution.
46  * 3. All advertising materials mentioning features or use of this software
47  *    must display the following acknowledgement:
48  *      This product includes software developed by Bill Paul.
49  * 4. Neither the name of the author nor the names of any co-contributors
50  *    may be used to endorse or promote products derived from this software
51  *    without specific prior written permission.
52  *
53  * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
54  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
55  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
56  * ARE DISCLAIMED.  IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
57  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
58  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
59  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
60  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
61  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
62  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
63  * THE POSSIBILITY OF SUCH DAMAGE.
64  *
65  *
66  * $FreeBSD: /c/ncvs/src/sys/pci/if_skreg.h,v 1.9 2000/04/22 02:16:37 wpaul Exp $
67  * $NetBSD: if_skvar.h,v 1.6 2005/05/30 04:35:22 christos Exp $
68  * $OpenBSD: if_skvar.h,v 1.2 2005/12/22 20:54:47 brad Exp $
69  * $DragonFly: src/sys/dev/netif/sk/if_skvar.h,v 1.2 2006/12/21 14:13:04 sephe Exp $
70  */
71
72 /*
73  * Copyright (c) 2003 Nathan L. Binkert <binkertn@umich.edu>
74  *
75  * Permission to use, copy, modify, and distribute this software for any
76  * purpose with or without fee is hereby granted, provided that the above
77  * copyright notice and this permission notice appear in all copies.
78  *
79  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
80  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
81  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
82  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
83  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
84  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
85  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
86  */
87
88 #ifndef _IF_SKVAR_H_
89 #define _IF_SKVAR_H_
90
91 struct sk_jpool_entry {
92         struct sk_if_softc      *sc_if;
93         int                     inuse;
94         int                     slot;
95         void                    *buf;
96         bus_addr_t              paddr;
97         SLIST_ENTRY(sk_jpool_entry) entry_next;
98 };
99
100 /*
101  * Number of DMA segments in a TxCB. Note that this is carefully
102  * chosen to make the total struct size an even power of two. It's
103  * critical that no TxCB be split across a page boundary since
104  * no attempt is made to allocate physically contiguous memory.
105  */
106 #define SK_NTXSEG      30
107
108 struct sk_chain_data {
109         struct mbuf             *sk_tx_mbuf[SK_TX_RING_CNT];
110         bus_dma_tag_t           sk_tx_dtag;
111         bus_dmamap_t            sk_tx_dmap[SK_TX_RING_CNT];
112         int                     sk_tx_prod;
113         int                     sk_tx_cons;
114         int                     sk_tx_cnt;
115
116         struct mbuf             *sk_rx_mbuf[SK_RX_RING_CNT];
117         bus_dma_tag_t           sk_rx_dtag;
118         bus_dmamap_t            sk_rx_dmap[SK_RX_RING_CNT];
119         bus_dmamap_t            sk_rx_dmap_tmp;
120         int                     sk_rx_prod;
121         int                     sk_rx_cons;
122         int                     sk_rx_cnt;
123
124         struct lwkt_serialize   sk_jpool_serializer;
125         bus_dma_tag_t           sk_jpool_dtag;
126         bus_dmamap_t            sk_jpool_dmap;
127         void                    *sk_jpool;
128         struct sk_jpool_entry   sk_jpool_ent[SK_JSLOTS];
129         SLIST_HEAD(, sk_jpool_entry) sk_jpool_free_ent;
130 };
131
132 struct sk_ring_data {
133         struct sk_tx_desc       sk_tx_ring[SK_TX_RING_CNT];
134         struct sk_rx_desc       sk_rx_ring[SK_RX_RING_CNT];
135 };
136
137 #define SK_TX_RING_ADDR(sc, i)  \
138     ((sc)->sk_rdata_paddr + offsetof(struct sk_ring_data, sk_tx_ring[(i)]))
139
140 #define SK_RX_RING_ADDR(sc, i)  \
141     ((sc)->sk_rdata_paddr + offsetof(struct sk_ring_data, sk_rx_ring[(i)]))
142
143 struct sk_bcom_hack {
144         int                     reg;
145         int                     val;
146 };
147
148 #define SK_INC(x, y)    (x) = (x + 1) % y
149
150 /* Forward decl. */
151 struct sk_if_softc;
152
153 /* Softc for the GEnesis controller. */
154 struct sk_softc {
155         int                     sk_res_rid;
156         struct resource         *sk_res;
157         bus_space_handle_t      sk_bhandle;     /* bus space handle */
158         bus_space_tag_t         sk_btag;        /* bus space tag */
159
160         int                     sk_irq_rid;
161         struct resource         *sk_irq;
162         void                    *sk_intrhand;   /* irq handler handle */
163
164         uint8_t                 sk_coppertype;
165         uint8_t                 sk_pmd;         /* physical media type */
166         uint8_t                 sk_type;
167         uint8_t                 sk_rev;
168         uint8_t                 sk_macs;        /* # of MACs */
169         uint32_t                sk_rboff;       /* RAMbuffer offset */
170         uint32_t                sk_ramsize;     /* amount of RAM on NIC */
171         uint32_t                sk_intrmask;
172         struct lwkt_serialize   sk_serializer;
173         struct sk_if_softc      *sk_if[2];
174         device_t                sk_devs[2];
175 };
176
177 /* Softc for each logical interface */
178 struct sk_if_softc {
179         struct arpcom           arpcom;         /* interface info */
180         device_t                sk_miibus;
181         uint8_t                 sk_port;        /* port # on controller */
182         uint8_t                 sk_xmac_rev;    /* XMAC chip rev (B2 or C1) */
183         uint32_t                sk_rx_ramstart;
184         uint32_t                sk_rx_ramend;
185         uint32_t                sk_tx_ramstart;
186         uint32_t                sk_tx_ramend;
187         uint8_t                 sk_phytype;
188         int                     sk_phyaddr;
189         int                     sk_cnt;
190         int                     sk_link;
191         struct callout          sk_tick_timer;
192         struct sk_chain_data    sk_cdata;
193         struct sk_ring_data     *sk_rdata;
194         bus_dma_tag_t           sk_rdata_dtag;
195         bus_dmamap_t            sk_rdata_dmap;
196         bus_addr_t              sk_rdata_paddr;
197         struct sk_softc         *sk_softc;      /* parent controller */
198         int                     sk_tx_bmu;      /* TX BMU register */
199         int                     sk_if_flags;
200         int                     sk_use_jumbo;
201 };
202
203 struct sk_dma_ctx {
204         int                     nsegs;
205         bus_dma_segment_t       *segs;
206 };
207
208 #endif /* !_IF_SKVAR_H_ */