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