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 $ 69ce17751aSSepherosa Ziehau */ 70ce17751aSSepherosa Ziehau 71ce17751aSSepherosa Ziehau /* 72ce17751aSSepherosa Ziehau * Copyright (c) 2003 Nathan L. Binkert <binkertn@umich.edu> 73ce17751aSSepherosa Ziehau * 74ce17751aSSepherosa Ziehau * Permission to use, copy, modify, and distribute this software for any 75ce17751aSSepherosa Ziehau * purpose with or without fee is hereby granted, provided that the above 76ce17751aSSepherosa Ziehau * copyright notice and this permission notice appear in all copies. 77ce17751aSSepherosa Ziehau * 78ce17751aSSepherosa Ziehau * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 79ce17751aSSepherosa Ziehau * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 80ce17751aSSepherosa Ziehau * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 81ce17751aSSepherosa Ziehau * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 82ce17751aSSepherosa Ziehau * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 83ce17751aSSepherosa Ziehau * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 84ce17751aSSepherosa Ziehau * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 85ce17751aSSepherosa Ziehau */ 86ce17751aSSepherosa Ziehau 87ce17751aSSepherosa Ziehau #ifndef _IF_SKVAR_H_ 88ce17751aSSepherosa Ziehau #define _IF_SKVAR_H_ 89ce17751aSSepherosa Ziehau 90ce17751aSSepherosa Ziehau struct sk_jpool_entry { 91ce17751aSSepherosa Ziehau struct sk_if_softc *sc_if; 92ce17751aSSepherosa Ziehau int inuse; 93ce17751aSSepherosa Ziehau int slot; 94ce17751aSSepherosa Ziehau void *buf; 95ce17751aSSepherosa Ziehau bus_addr_t paddr; 96ce17751aSSepherosa Ziehau SLIST_ENTRY(sk_jpool_entry) entry_next; 97ce17751aSSepherosa Ziehau }; 98ce17751aSSepherosa Ziehau 99ce17751aSSepherosa Ziehau /* 100ce17751aSSepherosa Ziehau * Number of DMA segments in a TxCB. Note that this is carefully 101ce17751aSSepherosa Ziehau * chosen to make the total struct size an even power of two. It's 102ce17751aSSepherosa Ziehau * critical that no TxCB be split across a page boundary since 103ce17751aSSepherosa Ziehau * no attempt is made to allocate physically contiguous memory. 104ce17751aSSepherosa Ziehau */ 105ce17751aSSepherosa Ziehau #define SK_NTXSEG 30 106ce17751aSSepherosa Ziehau 107ce17751aSSepherosa Ziehau struct sk_chain_data { 108*105b9b5dSSepherosa Ziehau bus_dma_tag_t sk_buf_dtag; 109*105b9b5dSSepherosa Ziehau 110ff7f301dSSepherosa Ziehau struct mbuf *sk_tx_mbuf[SK_TX_RING_CNT]; 111ce17751aSSepherosa Ziehau bus_dma_tag_t sk_tx_dtag; 112ce17751aSSepherosa Ziehau bus_dmamap_t sk_tx_dmap[SK_TX_RING_CNT]; 113ce17751aSSepherosa Ziehau int sk_tx_prod; 114ce17751aSSepherosa Ziehau int sk_tx_cons; 115ce17751aSSepherosa Ziehau int sk_tx_cnt; 116ce17751aSSepherosa Ziehau 117ff7f301dSSepherosa Ziehau struct mbuf *sk_rx_mbuf[SK_RX_RING_CNT]; 118ff7f301dSSepherosa Ziehau bus_dma_tag_t sk_rx_dtag; 119ff7f301dSSepherosa Ziehau bus_dmamap_t sk_rx_dmap[SK_RX_RING_CNT]; 120ff7f301dSSepherosa Ziehau bus_dmamap_t sk_rx_dmap_tmp; 121ce17751aSSepherosa Ziehau int sk_rx_prod; 122ce17751aSSepherosa Ziehau int sk_rx_cons; 123ce17751aSSepherosa Ziehau int sk_rx_cnt; 124ce17751aSSepherosa Ziehau 125ce17751aSSepherosa Ziehau struct lwkt_serialize sk_jpool_serializer; 126ce17751aSSepherosa Ziehau bus_dma_tag_t sk_jpool_dtag; 127ce17751aSSepherosa Ziehau bus_dmamap_t sk_jpool_dmap; 128ce17751aSSepherosa Ziehau void *sk_jpool; 129ce17751aSSepherosa Ziehau struct sk_jpool_entry sk_jpool_ent[SK_JSLOTS]; 130ce17751aSSepherosa Ziehau SLIST_HEAD(, sk_jpool_entry) sk_jpool_free_ent; 131ce17751aSSepherosa Ziehau }; 132ce17751aSSepherosa Ziehau 133ce17751aSSepherosa Ziehau struct sk_ring_data { 134*105b9b5dSSepherosa Ziehau bus_dma_tag_t sk_ring_dtag; 135*105b9b5dSSepherosa Ziehau 136*105b9b5dSSepherosa Ziehau bus_dma_tag_t sk_tx_ring_dtag; 137*105b9b5dSSepherosa Ziehau bus_dmamap_t sk_tx_ring_dmap; 138*105b9b5dSSepherosa Ziehau bus_addr_t sk_tx_ring_paddr; 139*105b9b5dSSepherosa Ziehau struct sk_tx_desc *sk_tx_ring; 140*105b9b5dSSepherosa Ziehau 141*105b9b5dSSepherosa Ziehau bus_dma_tag_t sk_rx_ring_dtag; 142*105b9b5dSSepherosa Ziehau bus_dmamap_t sk_rx_ring_dmap; 143*105b9b5dSSepherosa Ziehau bus_addr_t sk_rx_ring_paddr; 144*105b9b5dSSepherosa Ziehau struct sk_rx_desc *sk_rx_ring; 145ce17751aSSepherosa Ziehau }; 146ce17751aSSepherosa Ziehau 147ce17751aSSepherosa Ziehau struct sk_bcom_hack { 148ce17751aSSepherosa Ziehau int reg; 149ce17751aSSepherosa Ziehau int val; 150ce17751aSSepherosa Ziehau }; 151ce17751aSSepherosa Ziehau 152ce17751aSSepherosa Ziehau #define SK_INC(x, y) (x) = (x + 1) % y 153ce17751aSSepherosa Ziehau 154ce17751aSSepherosa Ziehau /* Forward decl. */ 155ce17751aSSepherosa Ziehau struct sk_if_softc; 156ce17751aSSepherosa Ziehau 157ce17751aSSepherosa Ziehau /* Softc for the GEnesis controller. */ 158ce17751aSSepherosa Ziehau struct sk_softc { 159720cce88SSepherosa Ziehau device_t sk_dev; 160ce17751aSSepherosa Ziehau int sk_res_rid; 161ce17751aSSepherosa Ziehau struct resource *sk_res; 162ce17751aSSepherosa Ziehau bus_space_handle_t sk_bhandle; /* bus space handle */ 163ce17751aSSepherosa Ziehau bus_space_tag_t sk_btag; /* bus space tag */ 164ce17751aSSepherosa Ziehau 165ce17751aSSepherosa Ziehau int sk_irq_rid; 166ce17751aSSepherosa Ziehau struct resource *sk_irq; 167ce17751aSSepherosa Ziehau void *sk_intrhand; /* irq handler handle */ 168ce17751aSSepherosa Ziehau 169ce17751aSSepherosa Ziehau uint8_t sk_coppertype; 170ce17751aSSepherosa Ziehau uint8_t sk_pmd; /* physical media type */ 171ce17751aSSepherosa Ziehau uint8_t sk_type; 172ce17751aSSepherosa Ziehau uint8_t sk_rev; 173ce17751aSSepherosa Ziehau uint8_t sk_macs; /* # of MACs */ 174ce17751aSSepherosa Ziehau uint32_t sk_rboff; /* RAMbuffer offset */ 175ce17751aSSepherosa Ziehau uint32_t sk_ramsize; /* amount of RAM on NIC */ 176ce17751aSSepherosa Ziehau uint32_t sk_intrmask; 177dbe44a55SSepherosa Ziehau uint32_t sk_imtimer_ticks; 178dbe44a55SSepherosa Ziehau int sk_imtime; 179ce17751aSSepherosa Ziehau struct lwkt_serialize sk_serializer; 180ce17751aSSepherosa Ziehau struct sk_if_softc *sk_if[2]; 181ce17751aSSepherosa Ziehau device_t sk_devs[2]; 182ce17751aSSepherosa Ziehau }; 183ce17751aSSepherosa Ziehau 184ce17751aSSepherosa Ziehau /* Softc for each logical interface */ 185ce17751aSSepherosa Ziehau struct sk_if_softc { 186ce17751aSSepherosa Ziehau struct arpcom arpcom; /* interface info */ 187ce17751aSSepherosa Ziehau device_t sk_miibus; 188ce17751aSSepherosa Ziehau uint8_t sk_port; /* port # on controller */ 189ce17751aSSepherosa Ziehau uint8_t sk_xmac_rev; /* XMAC chip rev (B2 or C1) */ 190ce17751aSSepherosa Ziehau uint32_t sk_rx_ramstart; 191ce17751aSSepherosa Ziehau uint32_t sk_rx_ramend; 192ce17751aSSepherosa Ziehau uint32_t sk_tx_ramstart; 193ce17751aSSepherosa Ziehau uint32_t sk_tx_ramend; 194ce17751aSSepherosa Ziehau uint8_t sk_phytype; 195ce17751aSSepherosa Ziehau int sk_phyaddr; 196ce17751aSSepherosa Ziehau int sk_cnt; 197ce17751aSSepherosa Ziehau int sk_link; 198ce17751aSSepherosa Ziehau struct callout sk_tick_timer; 199ce17751aSSepherosa Ziehau struct sk_chain_data sk_cdata; 200*105b9b5dSSepherosa Ziehau struct sk_ring_data sk_rdata; 201*105b9b5dSSepherosa Ziehau bus_dma_tag_t sk_parent_dtag; 202ce17751aSSepherosa Ziehau struct sk_softc *sk_softc; /* parent controller */ 203ce17751aSSepherosa Ziehau int sk_tx_bmu; /* TX BMU register */ 204ce17751aSSepherosa Ziehau int sk_if_flags; 205ff7f301dSSepherosa Ziehau int sk_use_jumbo; 206ce17751aSSepherosa Ziehau }; 207ce17751aSSepherosa Ziehau 208fcbf2fb6SSepherosa Ziehau #define SK_NDESC_RESERVE 2 209fcbf2fb6SSepherosa Ziehau #define SK_NDESC_SPARE 5 210fcbf2fb6SSepherosa Ziehau 211fcbf2fb6SSepherosa Ziehau #define SK_IS_OACTIVE(sc_if) \ 212fcbf2fb6SSepherosa Ziehau ((sc_if)->sk_cdata.sk_tx_cnt + SK_NDESC_RESERVE + SK_NDESC_SPARE > \ 213fcbf2fb6SSepherosa Ziehau SK_TX_RING_CNT) 214fcbf2fb6SSepherosa Ziehau 215ce17751aSSepherosa Ziehau #endif /* !_IF_SKVAR_H_ */ 216