Home | History | Annotate | Line # | Download | only in pci
if_skvar.h revision 1.7.2.1
      1  1.7.2.1      yamt /* $NetBSD: if_skvar.h,v 1.7.2.1 2006/02/18 15:39:08 yamt Exp $ */
      2      1.1  jdolecek 
      3      1.1  jdolecek /*-
      4      1.1  jdolecek  * Copyright (c) 2003 The NetBSD Foundation, Inc.
      5      1.1  jdolecek  * All rights reserved.
      6      1.1  jdolecek  *
      7      1.1  jdolecek  * Redistribution and use in source and binary forms, with or without
      8      1.1  jdolecek  * modification, are permitted provided that the following conditions
      9      1.1  jdolecek  * are met:
     10      1.1  jdolecek  * 1. Redistributions of source code must retain the above copyright
     11      1.1  jdolecek  *    notice, this list of conditions and the following disclaimer.
     12      1.1  jdolecek  * 2. Redistributions in binary form must reproduce the above copyright
     13      1.1  jdolecek  *    notice, this list of conditions and the following disclaimer in the
     14      1.1  jdolecek  *    documentation and/or other materials provided with the distribution.
     15      1.1  jdolecek  * 3. All advertising materials mentioning features or use of this software
     16      1.1  jdolecek  *    must display the following acknowledgement:
     17      1.1  jdolecek  *	This product includes software developed by the NetBSD
     18      1.1  jdolecek  *	Foundation, Inc. and its contributors.
     19      1.1  jdolecek  * 4. Neither the name of The NetBSD Foundation nor the names of its
     20      1.1  jdolecek  *    contributors may be used to endorse or promote products derived
     21      1.1  jdolecek  *    from this software without specific prior written permission.
     22      1.1  jdolecek  *
     23      1.1  jdolecek  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     24      1.1  jdolecek  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     25      1.1  jdolecek  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     26      1.1  jdolecek  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     27      1.1  jdolecek  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     28      1.1  jdolecek  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     29      1.1  jdolecek  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     30      1.1  jdolecek  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     31      1.1  jdolecek  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     32      1.1  jdolecek  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     33      1.1  jdolecek  * POSSIBILITY OF SUCH DAMAGE.
     34      1.1  jdolecek  */
     35      1.1  jdolecek /*	$OpenBSD: if_skreg.h,v 1.10 2003/08/12 05:23:06 nate Exp $	*/
     36      1.1  jdolecek 
     37      1.1  jdolecek /*
     38      1.1  jdolecek  * Copyright (c) 1997, 1998, 1999, 2000
     39      1.1  jdolecek  *	Bill Paul <wpaul (at) ctr.columbia.edu>.  All rights reserved.
     40      1.1  jdolecek  *
     41      1.1  jdolecek  * Redistribution and use in source and binary forms, with or without
     42      1.1  jdolecek  * modification, are permitted provided that the following conditions
     43      1.1  jdolecek  * are met:
     44      1.1  jdolecek  * 1. Redistributions of source code must retain the above copyright
     45      1.1  jdolecek  *    notice, this list of conditions and the following disclaimer.
     46      1.1  jdolecek  * 2. Redistributions in binary form must reproduce the above copyright
     47      1.1  jdolecek  *    notice, this list of conditions and the following disclaimer in the
     48      1.1  jdolecek  *    documentation and/or other materials provided with the distribution.
     49      1.1  jdolecek  * 3. All advertising materials mentioning features or use of this software
     50      1.1  jdolecek  *    must display the following acknowledgement:
     51      1.1  jdolecek  *	This product includes software developed by Bill Paul.
     52      1.1  jdolecek  * 4. Neither the name of the author nor the names of any co-contributors
     53      1.1  jdolecek  *    may be used to endorse or promote products derived from this software
     54      1.1  jdolecek  *    without specific prior written permission.
     55      1.1  jdolecek  *
     56      1.1  jdolecek  * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
     57      1.1  jdolecek  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     58      1.1  jdolecek  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     59      1.1  jdolecek  * ARE DISCLAIMED.  IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
     60      1.1  jdolecek  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     61      1.1  jdolecek  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     62      1.1  jdolecek  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     63      1.1  jdolecek  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     64      1.1  jdolecek  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     65      1.1  jdolecek  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
     66      1.1  jdolecek  * THE POSSIBILITY OF SUCH DAMAGE.
     67      1.1  jdolecek  *
     68      1.1  jdolecek  * $FreeBSD: /c/ncvs/src/sys/pci/if_skreg.h,v 1.9 2000/04/22 02:16:37 wpaul Exp $
     69      1.1  jdolecek  */
     70      1.1  jdolecek 
     71      1.1  jdolecek /*
     72      1.1  jdolecek  * Copyright (c) 2003 Nathan L. Binkert <binkertn (at) umich.edu>
     73      1.1  jdolecek  *
     74      1.1  jdolecek  * Permission to use, copy, modify, and distribute this software for any
     75      1.1  jdolecek  * purpose with or without fee is hereby granted, provided that the above
     76      1.1  jdolecek  * copyright notice and this permission notice appear in all copies.
     77      1.1  jdolecek  *
     78      1.1  jdolecek  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
     79      1.1  jdolecek  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
     80      1.1  jdolecek  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
     81      1.1  jdolecek  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
     82      1.1  jdolecek  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
     83      1.1  jdolecek  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
     84      1.1  jdolecek  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
     85      1.1  jdolecek  */
     86      1.1  jdolecek 
     87      1.1  jdolecek #ifndef _DEV_PCI_IF_SKVAR_H_
     88      1.1  jdolecek #define _DEV_PCI_IF_SKVAR_H_
     89      1.1  jdolecek 
     90  1.7.2.1      yamt #include "rnd.h"
     91  1.7.2.1      yamt 
     92  1.7.2.1      yamt #if NRND > 0
     93  1.7.2.1      yamt #include <sys/rnd.h>
     94  1.7.2.1      yamt #endif
     95  1.7.2.1      yamt 
     96      1.1  jdolecek struct sk_jslot {
     97      1.1  jdolecek 	caddr_t			sk_buf;
     98      1.1  jdolecek 	int			sk_inuse;
     99      1.1  jdolecek };
    100      1.1  jdolecek 
    101      1.1  jdolecek struct sk_jpool_entry {
    102      1.1  jdolecek 	int                             slot;
    103      1.1  jdolecek 	LIST_ENTRY(sk_jpool_entry)	jpool_entries;
    104      1.1  jdolecek };
    105      1.1  jdolecek 
    106      1.1  jdolecek struct sk_chain {
    107      1.1  jdolecek 	void			*sk_desc;
    108      1.1  jdolecek 	struct mbuf		*sk_mbuf;
    109      1.1  jdolecek 	struct sk_chain		*sk_next;
    110      1.1  jdolecek };
    111      1.1  jdolecek 
    112      1.1  jdolecek /*
    113      1.1  jdolecek  * Number of DMA segments in a TxCB. Note that this is carefully
    114      1.1  jdolecek  * chosen to make the total struct size an even power of two. It's
    115      1.3       wiz  * critical that no TxCB be split across a page boundary since
    116      1.1  jdolecek  * no attempt is made to allocate physically contiguous memory.
    117      1.5     perry  *
    118      1.1  jdolecek  */
    119      1.1  jdolecek #define SK_NTXSEG      30
    120      1.1  jdolecek 
    121      1.1  jdolecek struct sk_txmap_entry {
    122      1.1  jdolecek 	bus_dmamap_t			dmamap;
    123      1.4       skd 	SIMPLEQ_ENTRY(sk_txmap_entry)	link;
    124      1.1  jdolecek };
    125      1.1  jdolecek 
    126      1.1  jdolecek struct sk_chain_data {
    127      1.1  jdolecek 	struct sk_chain		sk_tx_chain[SK_TX_RING_CNT];
    128      1.1  jdolecek 	struct sk_chain		sk_rx_chain[SK_RX_RING_CNT];
    129      1.1  jdolecek 	struct sk_txmap_entry	*sk_tx_map[SK_TX_RING_CNT];
    130      1.1  jdolecek 	bus_dmamap_t		sk_rx_map[SK_RX_RING_CNT];
    131      1.1  jdolecek 	int			sk_tx_prod;
    132      1.1  jdolecek 	int			sk_tx_cons;
    133      1.1  jdolecek 	int			sk_tx_cnt;
    134      1.1  jdolecek 	int			sk_rx_prod;
    135      1.1  jdolecek 	int			sk_rx_cons;
    136      1.1  jdolecek 	int			sk_rx_cnt;
    137      1.1  jdolecek 	/* Stick the jumbo mem management stuff here too. */
    138      1.1  jdolecek 	struct sk_jslot		sk_jslots[SK_JSLOTS];
    139      1.1  jdolecek 	void			*sk_jumbo_buf;
    140      1.1  jdolecek 
    141      1.1  jdolecek };
    142      1.1  jdolecek 
    143      1.1  jdolecek struct sk_ring_data {
    144      1.1  jdolecek 	struct sk_tx_desc	sk_tx_ring[SK_TX_RING_CNT];
    145      1.1  jdolecek 	struct sk_rx_desc	sk_rx_ring[SK_RX_RING_CNT];
    146      1.1  jdolecek };
    147      1.1  jdolecek 
    148      1.1  jdolecek #define SK_TX_RING_ADDR(sc, i) \
    149      1.1  jdolecek     ((sc)->sk_ring_map->dm_segs[0].ds_addr + \
    150      1.1  jdolecek      offsetof(struct sk_ring_data, sk_tx_ring[(i)]))
    151      1.1  jdolecek 
    152      1.1  jdolecek #define SK_RX_RING_ADDR(sc, i) \
    153      1.1  jdolecek     ((sc)->sk_ring_map->dm_segs[0].ds_addr + \
    154      1.1  jdolecek      offsetof(struct sk_ring_data, sk_rx_ring[(i)]))
    155      1.2    briggs 
    156      1.2    briggs #define SK_CDOFF(x)	offsetof(struct sk_ring_data, x)
    157      1.2    briggs #define SK_CDTXOFF(x)	SK_CDOFF(sk_tx_ring[(x)])
    158      1.2    briggs #define SK_CDRXOFF(x)	SK_CDOFF(sk_rx_ring[(x)])
    159      1.2    briggs 
    160      1.2    briggs #define SK_CDTXSYNC(sc, x, n, ops)					\
    161      1.2    briggs do {									\
    162      1.2    briggs 	int __x, __n;							\
    163      1.2    briggs 									\
    164      1.2    briggs 	__x = (x);							\
    165      1.2    briggs 	__n = (n);							\
    166      1.2    briggs 									\
    167      1.2    briggs 	/* If it will wrap around, sync to the end of the ring. */	\
    168      1.2    briggs 	if ((__x + __n) > SK_TX_RING_CNT) {				\
    169      1.2    briggs 		bus_dmamap_sync((sc)->sk_softc->sc_dmatag,		\
    170      1.2    briggs 		    (sc)->sk_ring_map, SK_CDTXOFF(__x),			\
    171      1.2    briggs 		    sizeof(struct sk_tx_desc) *	 (SK_TX_RING_CNT - __x),\
    172      1.2    briggs 		    (ops));						\
    173      1.2    briggs 		__n -= (SK_TX_RING_CNT - __x);				\
    174      1.2    briggs 		__x = 0;						\
    175      1.2    briggs 	}								\
    176      1.2    briggs 									\
    177      1.2    briggs 	/* Now sync whatever is left. */				\
    178      1.2    briggs 	bus_dmamap_sync((sc)->sk_softc->sc_dmatag, (sc)->sk_ring_map,	\
    179      1.2    briggs 	    SK_CDTXOFF((__x)), sizeof(struct sk_tx_desc) * __n, (ops));	\
    180      1.2    briggs } while (/*CONSTCOND*/0)
    181      1.2    briggs 
    182      1.2    briggs #define SK_CDRXSYNC(sc, x, ops)						\
    183      1.2    briggs do {									\
    184      1.2    briggs 	bus_dmamap_sync((sc)->sk_softc->sc_dmatag, (sc)->sk_ring_map,	\
    185      1.2    briggs 	    SK_CDRXOFF((x)), sizeof(struct sk_rx_desc), (ops));		\
    186      1.2    briggs } while (/*CONSTCOND*/0)
    187      1.1  jdolecek 
    188      1.1  jdolecek struct sk_bcom_hack {
    189      1.1  jdolecek 	int			reg;
    190      1.1  jdolecek 	int			val;
    191      1.1  jdolecek };
    192      1.1  jdolecek 
    193      1.1  jdolecek #define SK_INC(x, y)	(x) = (x + 1) % y
    194      1.1  jdolecek 
    195      1.1  jdolecek /* Forward decl. */
    196      1.1  jdolecek struct sk_if_softc;
    197      1.1  jdolecek 
    198      1.1  jdolecek /* Softc for the GEnesis controller. */
    199      1.1  jdolecek struct sk_softc {
    200      1.1  jdolecek 	struct device		sk_dev;		/* generic device */
    201      1.1  jdolecek 	bus_space_handle_t	sk_bhandle;	/* bus space handle */
    202      1.1  jdolecek 	bus_space_tag_t		sk_btag;	/* bus space tag */
    203      1.1  jdolecek 	void			*sk_intrhand;	/* irq handler handle */
    204      1.1  jdolecek 	struct resource		*sk_irq;	/* IRQ resource handle */
    205      1.1  jdolecek 	struct resource		*sk_res;	/* I/O or shared mem handle */
    206      1.1  jdolecek 	u_int8_t		sk_type;
    207      1.4       skd 	u_int8_t		sk_rev;
    208      1.6  christos   	const char		*sk_name;
    209      1.1  jdolecek 	char			*sk_vpd_prodname;
    210      1.1  jdolecek 	char			*sk_vpd_readonly;
    211      1.1  jdolecek 	u_int32_t		sk_rboff;	/* RAMbuffer offset */
    212      1.1  jdolecek 	u_int32_t		sk_ramsize;	/* amount of RAM on NIC */
    213      1.1  jdolecek 	u_int32_t		sk_pmd;		/* physical media type */
    214      1.1  jdolecek 	u_int32_t		sk_intrmask;
    215  1.7.2.1      yamt 	struct sysctllog	*sk_clog;
    216  1.7.2.1      yamt 	int			sk_int_mod;
    217  1.7.2.1      yamt 	int			sk_int_mod_pending;
    218      1.1  jdolecek 	bus_dma_tag_t		sc_dmatag;
    219      1.1  jdolecek 	struct sk_if_softc	*sk_if[2];
    220  1.7.2.1      yamt #if NRND > 0
    221  1.7.2.1      yamt 	rndsource_element_t     rnd_source;
    222  1.7.2.1      yamt #endif
    223      1.1  jdolecek };
    224      1.1  jdolecek 
    225      1.1  jdolecek /* Softc for each logical interface */
    226      1.1  jdolecek struct sk_if_softc {
    227      1.1  jdolecek 	struct device		sk_dev;		/* generic device */
    228      1.1  jdolecek 	struct ethercom		sk_ethercom;	/* interface info */
    229      1.1  jdolecek 	struct mii_data		sk_mii;
    230      1.1  jdolecek 	u_int8_t                sk_enaddr[ETHER_ADDR_LEN]; /* station addr */
    231      1.1  jdolecek 	u_int8_t		sk_port;	/* port # on controller */
    232      1.1  jdolecek 	u_int8_t		sk_xmac_rev;	/* XMAC chip rev (B2 or C1) */
    233      1.1  jdolecek 	u_int32_t		sk_rx_ramstart;
    234      1.1  jdolecek 	u_int32_t		sk_rx_ramend;
    235      1.1  jdolecek 	u_int32_t		sk_tx_ramstart;
    236      1.1  jdolecek 	u_int32_t		sk_tx_ramend;
    237      1.1  jdolecek 	int			sk_phytype;
    238      1.1  jdolecek 	int			sk_phyaddr;
    239      1.1  jdolecek 	int			sk_cnt;
    240      1.1  jdolecek 	int			sk_link;
    241      1.1  jdolecek 	struct callout		sk_tick_ch;
    242      1.1  jdolecek 	struct sk_chain_data	sk_cdata;
    243      1.1  jdolecek 	struct sk_ring_data	*sk_rdata;
    244      1.1  jdolecek 	bus_dmamap_t		sk_ring_map;
    245      1.1  jdolecek 	struct sk_softc		*sk_softc;	/* parent controller */
    246      1.1  jdolecek 	int			sk_tx_bmu;	/* TX BMU register */
    247      1.1  jdolecek 	int			sk_if_flags;
    248      1.1  jdolecek 	LIST_HEAD(__sk_jfreehead, sk_jpool_entry)	sk_jfree_listhead;
    249      1.1  jdolecek 	LIST_HEAD(__sk_jinusehead, sk_jpool_entry)	sk_jinuse_listhead;
    250      1.4       skd 	SIMPLEQ_HEAD(__sk_txmaphead, sk_txmap_entry) sk_txmap_head;
    251      1.1  jdolecek };
    252      1.1  jdolecek 
    253      1.1  jdolecek struct skc_attach_args {
    254      1.1  jdolecek 	u_int16_t	skc_port;
    255      1.1  jdolecek };
    256      1.1  jdolecek 
    257      1.1  jdolecek #endif /* _DEV_PCI_IF_SKVAR_H_ */
    258