Home | History | Annotate | Line # | Download | only in imx
if_enetvar.h revision 1.2.4.2
      1  1.2.4.2  jdolecek /*	$NetBSD: if_enetvar.h,v 1.2.4.2 2017/12/03 11:35:53 jdolecek Exp $	*/
      2  1.2.4.2  jdolecek 
      3  1.2.4.2  jdolecek /*
      4  1.2.4.2  jdolecek  * Copyright (c) 2014 Ryo Shimizu <ryo (at) nerv.org>
      5  1.2.4.2  jdolecek  * All rights reserved.
      6  1.2.4.2  jdolecek  *
      7  1.2.4.2  jdolecek  * Redistribution and use in source and binary forms, with or without
      8  1.2.4.2  jdolecek  * modification, are permitted provided that the following conditions
      9  1.2.4.2  jdolecek  * are met:
     10  1.2.4.2  jdolecek  * 1. Redistributions of source code must retain the above copyright
     11  1.2.4.2  jdolecek  *    notice, this list of conditions and the following disclaimer.
     12  1.2.4.2  jdolecek  * 2. Redistributions in binary form must reproduce the above copyright
     13  1.2.4.2  jdolecek  *    notice, this list of conditions and the following disclaimer in the
     14  1.2.4.2  jdolecek  *    documentation and/or other materials provided with the distribution.
     15  1.2.4.2  jdolecek  *
     16  1.2.4.2  jdolecek  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     17  1.2.4.2  jdolecek  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     18  1.2.4.2  jdolecek  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
     19  1.2.4.2  jdolecek  * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
     20  1.2.4.2  jdolecek  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     21  1.2.4.2  jdolecek  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     22  1.2.4.2  jdolecek  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     23  1.2.4.2  jdolecek  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     24  1.2.4.2  jdolecek  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
     25  1.2.4.2  jdolecek  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     26  1.2.4.2  jdolecek  * POSSIBILITY OF SUCH DAMAGE.
     27  1.2.4.2  jdolecek  */
     28  1.2.4.2  jdolecek 
     29  1.2.4.2  jdolecek #ifndef _ARM_IMX_IF_ENETVAR_H_
     30  1.2.4.2  jdolecek #define _ARM_IMX_IF_ENETVAR_H_
     31  1.2.4.2  jdolecek 
     32  1.2.4.2  jdolecek #include <sys/rndsource.h>
     33  1.2.4.2  jdolecek #include <net/if.h>
     34  1.2.4.2  jdolecek #include <net/if_media.h>
     35  1.2.4.2  jdolecek #include <net/if_ether.h>
     36  1.2.4.2  jdolecek #include <dev/mii/miivar.h>
     37  1.2.4.2  jdolecek 
     38  1.2.4.2  jdolecek #define ENET_TX_RING_CNT	256
     39  1.2.4.2  jdolecek #define ENET_RX_RING_CNT	256
     40  1.2.4.2  jdolecek 
     41  1.2.4.2  jdolecek struct enet_txsoft {
     42  1.2.4.2  jdolecek 	struct mbuf *txs_mbuf;		/* head of our mbuf chain */
     43  1.2.4.2  jdolecek 	bus_dmamap_t txs_dmamap;	/* our DMA map */
     44  1.2.4.2  jdolecek };
     45  1.2.4.2  jdolecek 
     46  1.2.4.2  jdolecek struct enet_rxsoft {
     47  1.2.4.2  jdolecek 	struct mbuf *rxs_mbuf;		/* head of our mbuf chain */
     48  1.2.4.2  jdolecek 	bus_dmamap_t rxs_dmamap;	/* our DMA map */
     49  1.2.4.2  jdolecek };
     50  1.2.4.2  jdolecek 
     51  1.2.4.2  jdolecek struct enet_softc {
     52  1.2.4.2  jdolecek 	device_t sc_dev;
     53  1.2.4.2  jdolecek 
     54  1.2.4.2  jdolecek 	bus_addr_t sc_addr;
     55  1.2.4.2  jdolecek 	bus_space_tag_t sc_iot;
     56  1.2.4.2  jdolecek 	bus_space_handle_t sc_ioh;
     57  1.2.4.2  jdolecek 	bus_dma_tag_t sc_dmat;
     58  1.2.4.2  jdolecek 
     59  1.2.4.2  jdolecek 	int sc_unit;
     60  1.2.4.2  jdolecek 	int sc_imxtype;
     61  1.2.4.2  jdolecek 	int sc_rgmii;
     62  1.2.4.2  jdolecek 	unsigned int sc_pllclock;
     63  1.2.4.2  jdolecek 
     64  1.2.4.2  jdolecek 	/* interrupts */
     65  1.2.4.2  jdolecek 	void *sc_ih;
     66  1.2.4.2  jdolecek 	void *sc_ih2;	/* for i.MX7 */
     67  1.2.4.2  jdolecek 	void *sc_ih3;	/* for i.MX7 */
     68  1.2.4.2  jdolecek 	callout_t sc_tick_ch;
     69  1.2.4.2  jdolecek 	bool sc_stopping;
     70  1.2.4.2  jdolecek 
     71  1.2.4.2  jdolecek 	/* TX */
     72  1.2.4.2  jdolecek 	struct enet_txdesc *sc_txdesc_ring;	/* [ENET_TX_RING_CNT] */
     73  1.2.4.2  jdolecek 	bus_dmamap_t sc_txdesc_dmamap;
     74  1.2.4.2  jdolecek 	struct enet_rxdesc *sc_rxdesc_ring;	/* [ENET_RX_RING_CNT] */
     75  1.2.4.2  jdolecek 	bus_dmamap_t sc_rxdesc_dmamap;
     76  1.2.4.2  jdolecek 	struct enet_txsoft sc_txsoft[ENET_TX_RING_CNT];
     77  1.2.4.2  jdolecek 	int sc_tx_considx;
     78  1.2.4.2  jdolecek 	int sc_tx_prodidx;
     79  1.2.4.2  jdolecek 	int sc_tx_free;
     80  1.2.4.2  jdolecek 
     81  1.2.4.2  jdolecek 	/* RX */
     82  1.2.4.2  jdolecek 	struct enet_rxsoft sc_rxsoft[ENET_RX_RING_CNT];
     83  1.2.4.2  jdolecek 	int sc_rx_readidx;
     84  1.2.4.2  jdolecek 
     85  1.2.4.2  jdolecek 	/* misc */
     86  1.2.4.2  jdolecek 	int sc_if_flags;			/* local copy of if_flags */
     87  1.2.4.2  jdolecek 	int sc_flowflags;			/* 802.3x flow control flags */
     88  1.2.4.2  jdolecek 	struct ethercom sc_ethercom;		/* interface info */
     89  1.2.4.2  jdolecek 	struct mii_data sc_mii;
     90  1.2.4.2  jdolecek 	uint8_t sc_enaddr[ETHER_ADDR_LEN];
     91  1.2.4.2  jdolecek 	krndsource_t sc_rnd_source;
     92  1.2.4.2  jdolecek 
     93  1.2.4.2  jdolecek #ifdef ENET_EVENT_COUNTER
     94  1.2.4.2  jdolecek 	struct evcnt sc_ev_t_drop;
     95  1.2.4.2  jdolecek 	struct evcnt sc_ev_t_packets;
     96  1.2.4.2  jdolecek 	struct evcnt sc_ev_t_bc_pkt;
     97  1.2.4.2  jdolecek 	struct evcnt sc_ev_t_mc_pkt;
     98  1.2.4.2  jdolecek 	struct evcnt sc_ev_t_crc_align;
     99  1.2.4.2  jdolecek 	struct evcnt sc_ev_t_undersize;
    100  1.2.4.2  jdolecek 	struct evcnt sc_ev_t_oversize;
    101  1.2.4.2  jdolecek 	struct evcnt sc_ev_t_frag;
    102  1.2.4.2  jdolecek 	struct evcnt sc_ev_t_jab;
    103  1.2.4.2  jdolecek 	struct evcnt sc_ev_t_col;
    104  1.2.4.2  jdolecek 	struct evcnt sc_ev_t_p64;
    105  1.2.4.2  jdolecek 	struct evcnt sc_ev_t_p65to127n;
    106  1.2.4.2  jdolecek 	struct evcnt sc_ev_t_p128to255n;
    107  1.2.4.2  jdolecek 	struct evcnt sc_ev_t_p256to511;
    108  1.2.4.2  jdolecek 	struct evcnt sc_ev_t_p512to1023;
    109  1.2.4.2  jdolecek 	struct evcnt sc_ev_t_p1024to2047;
    110  1.2.4.2  jdolecek 	struct evcnt sc_ev_t_p_gte2048;
    111  1.2.4.2  jdolecek 	struct evcnt sc_ev_t_octets;
    112  1.2.4.2  jdolecek 	struct evcnt sc_ev_r_packets;
    113  1.2.4.2  jdolecek 	struct evcnt sc_ev_r_bc_pkt;
    114  1.2.4.2  jdolecek 	struct evcnt sc_ev_r_mc_pkt;
    115  1.2.4.2  jdolecek 	struct evcnt sc_ev_r_crc_align;
    116  1.2.4.2  jdolecek 	struct evcnt sc_ev_r_undersize;
    117  1.2.4.2  jdolecek 	struct evcnt sc_ev_r_oversize;
    118  1.2.4.2  jdolecek 	struct evcnt sc_ev_r_frag;
    119  1.2.4.2  jdolecek 	struct evcnt sc_ev_r_jab;
    120  1.2.4.2  jdolecek 	struct evcnt sc_ev_r_p64;
    121  1.2.4.2  jdolecek 	struct evcnt sc_ev_r_p65to127;
    122  1.2.4.2  jdolecek 	struct evcnt sc_ev_r_p128to255;
    123  1.2.4.2  jdolecek 	struct evcnt sc_ev_r_p256to511;
    124  1.2.4.2  jdolecek 	struct evcnt sc_ev_r_p512to1023;
    125  1.2.4.2  jdolecek 	struct evcnt sc_ev_r_p1024to2047;
    126  1.2.4.2  jdolecek 	struct evcnt sc_ev_r_p_gte2048;
    127  1.2.4.2  jdolecek 	struct evcnt sc_ev_r_octets;
    128  1.2.4.2  jdolecek #endif /* ENET_EVENT_COUNTER */
    129  1.2.4.2  jdolecek };
    130  1.2.4.2  jdolecek 
    131  1.2.4.2  jdolecek void enet_attach_common(device_t, bus_space_tag_t, bus_dma_tag_t,
    132  1.2.4.2  jdolecek     bus_addr_t, bus_size_t, int);
    133  1.2.4.2  jdolecek int enet_match(device_t, cfdata_t, void *);
    134  1.2.4.2  jdolecek void enet_attach(device_t, device_t, void *);
    135  1.2.4.2  jdolecek 
    136  1.2.4.2  jdolecek #endif /* _ARM_IMX_IF_ENETVAR_H_ */
    137