Home | History | Annotate | Line # | Download | only in marvell
if_gfevar.h revision 1.9.16.1
      1  1.9.16.1  uebayasi /*	$NetBSD: if_gfevar.h,v 1.9.16.1 2010/04/30 14:43:27 uebayasi Exp $	*/
      2       1.1      matt 
      3       1.1      matt /*
      4       1.1      matt  * Copyright (c) 2002 Allegro Networks, Inc., Wasabi Systems, Inc.
      5       1.1      matt  * All rights reserved.
      6       1.1      matt  *
      7       1.1      matt  * Redistribution and use in source and binary forms, with or without
      8       1.1      matt  * modification, are permitted provided that the following conditions
      9       1.1      matt  * are met:
     10       1.1      matt  * 1. Redistributions of source code must retain the above copyright
     11       1.1      matt  *    notice, this list of conditions and the following disclaimer.
     12       1.1      matt  * 2. Redistributions in binary form must reproduce the above copyright
     13       1.1      matt  *    notice, this list of conditions and the following disclaimer in the
     14       1.1      matt  *    documentation and/or other materials provided with the distribution.
     15       1.1      matt  * 3. All advertising materials mentioning features or use of this software
     16       1.1      matt  *    must display the following acknowledgement:
     17       1.1      matt  *      This product includes software developed for the NetBSD Project by
     18       1.1      matt  *      Allegro Networks, Inc., and Wasabi Systems, Inc.
     19       1.1      matt  * 4. The name of Allegro Networks, Inc. may not be used to endorse
     20       1.1      matt  *    or promote products derived from this software without specific prior
     21       1.1      matt  *    written permission.
     22       1.1      matt  * 5. The name of Wasabi Systems, Inc. may not be used to endorse
     23       1.1      matt  *    or promote products derived from this software without specific prior
     24       1.1      matt  *    written permission.
     25       1.1      matt  *
     26       1.1      matt  * THIS SOFTWARE IS PROVIDED BY ALLEGRO NETWORKS, INC. AND
     27       1.1      matt  * WASABI SYSTEMS, INC. ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
     28       1.1      matt  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
     29       1.1      matt  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     30       1.1      matt  * IN NO EVENT SHALL EITHER ALLEGRO NETWORKS, INC. OR WASABI SYSTEMS, INC.
     31       1.1      matt  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     32       1.1      matt  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     33       1.1      matt  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     34       1.1      matt  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     35       1.1      matt  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     36       1.1      matt  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     37       1.1      matt  * POSSIBILITY OF SUCH DAMAGE.
     38       1.1      matt  */
     39  1.9.16.1  uebayasi #ifndef _IF_GFEVAR_H_
     40  1.9.16.1  uebayasi #define _IF_GFEVAR_H_
     41       1.1      matt 
     42       1.4   thorpej #define	GE_RXDESC_MEMSIZE		(1 * PAGE_SIZE)
     43       1.1      matt #define	GE_RXDESC_MAX			64
     44       1.1      matt #define	GE_RXBUF_SIZE			2048
     45       1.1      matt #define	GE_RXBUF_MEMSIZE		(GE_RXDESC_MAX*GE_RXBUF_SIZE)
     46       1.4   thorpej #define	GE_RXBUF_NSEGS			((GE_RXBUF_MEMSIZE/PAGE_SIZE)+1)
     47       1.1      matt #define	GE_DMSEG_MAX			(GE_RXBUF_NSEGS)
     48       1.1      matt 
     49       1.1      matt struct gfe_dmamem {
     50       1.1      matt 	bus_dmamap_t gdm_map;		/* dmamem'ed memory */
     51       1.8  christos 	void *gdm_kva;		/* kva of tx memory */
     52       1.1      matt 	int gdm_nsegs;			/* # of segment in gdm_segs */
     53       1.1      matt 	int gdm_maxsegs;		/* maximum # of segments allowed */
     54       1.1      matt 	size_t gdm_size;		/* size of memory region */
     55       1.1      matt 	bus_dma_segment_t gdm_segs[GE_DMSEG_MAX]; /* dma segment of tx memory */
     56       1.1      matt };
     57       1.1      matt 
     58       1.1      matt /* With a 4096 page size, we get 256 descriptors per page.
     59       1.1      matt  */
     60       1.5      matt #define	GE_TXDESC_MEMSIZE		(1 * PAGE_SIZE)
     61       1.5      matt #define	GE_TXDESC_MAX			(GE_TXDESC_MEMSIZE / 16)
     62       1.4   thorpej #define	GE_TXBUF_SIZE			(4 * PAGE_SIZE)
     63       1.1      matt 
     64       1.1      matt struct gfe_txqueue {
     65       1.1      matt 	struct ifqueue txq_pendq;	/* these are ready to go to the GT */
     66       1.1      matt 	struct gfe_dmamem txq_desc_mem;	/* transmit descriptor memory */
     67       1.1      matt 	struct gfe_dmamem txq_buf_mem;	/* transmit buffer memory */
     68       1.1      matt 	unsigned int txq_lo;		/* next to be given to GT */
     69       1.1      matt 	unsigned int txq_fi; 		/* next to be returned to CPU */
     70       1.1      matt 	unsigned int txq_ei_gapcount;	/* counter until next EI */
     71       1.1      matt 	unsigned int txq_nactive;	/* number of active descriptors */
     72       1.1      matt 	unsigned int txq_outptr;	/* where to put next transmit packet */
     73       1.1      matt 	unsigned int txq_inptr;		/* start of 1st queued tx packet */
     74       1.1      matt 	uint32_t txq_intrbits;		/* bits to write to EIMR */
     75       1.1      matt 	uint32_t txq_esdcmrbits;	/* bits to write to ESDCMR */
     76       1.1      matt 	uint32_t txq_epsrbits;		/* bits to test with EPSR */
     77       1.1      matt 	volatile struct gt_eth_desc *txq_descs; /* ptr to tx descriptors */
     78       1.1      matt 	bus_addr_t txq_ectdp;		/* offset to cur. tx desc ptr reg */
     79       1.1      matt 	bus_addr_t txq_desc_busaddr;	/* bus addr of tx descriptors */
     80       1.1      matt 	bus_addr_t txq_buf_busaddr;	/* bus addr of tx buffers */
     81       1.1      matt };
     82       1.1      matt 
     83       1.1      matt /* With a 4096 page size, we get 256 descriptors per page.  We want 1024
     84       1.1      matt  * which will give us about 8ms of 64 byte packets (2ms for each priority
     85       1.1      matt  * queue).
     86       1.1      matt  */
     87       1.1      matt 
     88       1.1      matt struct gfe_rxbuf {
     89       1.9        he 	uint8_t	rxb_data[GE_RXBUF_SIZE];
     90       1.1      matt };
     91       1.1      matt 
     92       1.1      matt struct gfe_rxqueue {
     93       1.1      matt 	struct gfe_dmamem rxq_desc_mem;	/* receive descriptor memory */
     94       1.1      matt 	struct gfe_dmamem rxq_buf_mem;	/* receive buffer memory */
     95       1.1      matt 	struct mbuf *rxq_curpkt;	/* mbuf for current packet */
     96       1.1      matt 	volatile struct gt_eth_desc *rxq_descs;
     97       1.1      matt 	struct gfe_rxbuf *rxq_bufs;
     98       1.1      matt 	unsigned int rxq_fi; 		/* next to be returned to CPU */
     99       1.1      matt 	unsigned int rxq_active;	/* # of descriptors given to GT */
    100       1.1      matt 	uint32_t rxq_intrbits;		/* bits to write to EIMR */
    101       1.1      matt 	bus_addr_t rxq_desc_busaddr;	/* bus addr of rx descriptors */
    102       1.1      matt 	uint32_t rxq_cmdsts;		/* save cmdsts from first descriptor */
    103       1.1      matt 	bus_size_t rxq_efrdp;
    104       1.1      matt 	bus_size_t rxq_ecrdp;
    105       1.1      matt };
    106       1.1      matt 
    107       1.1      matt enum gfe_txprio {
    108       1.1      matt 	GE_TXPRIO_HI=1,
    109       1.1      matt 	GE_TXPRIO_LO=0,
    110       1.1      matt 	GE_TXPRIO_NONE=2
    111       1.1      matt };
    112       1.1      matt enum gfe_rxprio {
    113       1.1      matt 	GE_RXPRIO_HI=3,
    114       1.1      matt 	GE_RXPRIO_MEDHI=2,
    115       1.1      matt 	GE_RXPRIO_MEDLO=1,
    116       1.1      matt 	GE_RXPRIO_LO=0
    117       1.1      matt };
    118       1.1      matt 
    119  1.9.16.1  uebayasi struct gfec_softc {
    120  1.9.16.1  uebayasi 	device_t sc_dev;		/* must be first */
    121  1.9.16.1  uebayasi 
    122  1.9.16.1  uebayasi 	bus_space_tag_t sc_iot;
    123  1.9.16.1  uebayasi 	bus_space_handle_t sc_ioh;	/* subregion for ethernet */
    124  1.9.16.1  uebayasi 
    125  1.9.16.1  uebayasi 	kmutex_t sc_mtx;
    126  1.9.16.1  uebayasi };
    127  1.9.16.1  uebayasi 
    128       1.1      matt struct gfe_softc {
    129  1.9.16.1  uebayasi 	device_t sc_dev;		/* must be first */
    130       1.1      matt 	struct ethercom sc_ec;		/* common ethernet glue */
    131       1.1      matt 	struct callout sc_co;		/* resource recovery */
    132       1.1      matt 	mii_data_t sc_mii;		/* mii interface */
    133       1.1      matt 
    134  1.9.16.1  uebayasi 	bus_space_tag_t sc_memt;
    135       1.3      matt 	bus_space_handle_t sc_memh;	/* subregion for ethernet */
    136       1.1      matt 	bus_dma_tag_t sc_dmat;
    137       1.1      matt 	int sc_macno;			/* which mac? 0, 1, or 2 */
    138       1.1      matt 
    139       1.1      matt 	unsigned int sc_tickflags;
    140       1.1      matt #define	GE_TICK_TX_IFSTART	0x0001
    141       1.1      matt #define	GE_TICK_RX_RESTART	0x0002
    142       1.1      matt 	unsigned int sc_flags;
    143       1.1      matt #define	GE_ALLMULTI	0x0001
    144       1.1      matt #define	GE_PHYSTSCHG	0x0002
    145       1.1      matt #define	GE_RXACTIVE	0x0004
    146       1.5      matt #define	GE_NOFREE	0x0008		/* Don't free on disable */
    147       1.1      matt 	uint32_t sc_pcr;		/* current EPCR value */
    148       1.1      matt 	uint32_t sc_pcxr;		/* current EPCXR value */
    149       1.1      matt 	uint32_t sc_intrmask;		/* current EIMR value */
    150       1.1      matt 	uint32_t sc_idlemask;		/* suspended EIMR bits */
    151       1.1      matt 	size_t sc_max_frame_length;	/* maximum frame length */
    152       1.1      matt 
    153       1.1      matt 	/*
    154       1.1      matt 	 * Hash table related members
    155       1.1      matt 	 */
    156       1.1      matt 	struct gfe_dmamem sc_hash_mem;	/* dma'ble hash table */
    157       1.1      matt 	uint64_t *sc_hashtable;
    158       1.1      matt 	unsigned int sc_hashmask;	/* 0x1ff or 0x1fff */
    159       1.1      matt 
    160       1.1      matt 	/*
    161       1.1      matt 	 * Transmit related members
    162       1.1      matt 	 */
    163       1.5      matt 	struct gfe_txqueue sc_txq[2];	/* High & Low transmit queues */
    164       1.1      matt 
    165       1.1      matt 	/*
    166       1.1      matt 	 * Receive related members
    167       1.1      matt 	 */
    168       1.5      matt 	struct gfe_rxqueue sc_rxq[4];	/* Hi/MedHi/MedLo/Lo receive queues */
    169  1.9.16.1  uebayasi 
    170  1.9.16.1  uebayasi #if NRND > 0
    171  1.9.16.1  uebayasi 	rndsource_element_t sc_rnd_source;
    172  1.9.16.1  uebayasi #endif
    173       1.1      matt };
    174  1.9.16.1  uebayasi #endif	/* _IF_GFEVAR_H_ */
    175