Home | History | Annotate | Line # | Download | only in dev
octeon_gmxvar.h revision 1.2
      1  1.2  christos /*	$NetBSD: octeon_gmxvar.h,v 1.2 2018/04/19 21:50:06 christos Exp $	*/
      2  1.1    hikaru 
      3  1.1    hikaru /*
      4  1.1    hikaru  * Copyright (c) 2007 Internet Initiative Japan, Inc.
      5  1.1    hikaru  * All rights reserved.
      6  1.1    hikaru  *
      7  1.1    hikaru  * Redistribution and use in source and binary forms, with or without
      8  1.1    hikaru  * modification, are permitted provided that the following conditions
      9  1.1    hikaru  * are met:
     10  1.1    hikaru  * 1. Redistributions of source code must retain the above copyright
     11  1.1    hikaru  *    notice, this list of conditions and the following disclaimer.
     12  1.1    hikaru  * 2. Redistributions in binary form must reproduce the above copyright
     13  1.1    hikaru  *    notice, this list of conditions and the following disclaimer in the
     14  1.1    hikaru  *    documentation and/or other materials provided with the distribution.
     15  1.1    hikaru  *
     16  1.1    hikaru  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     17  1.1    hikaru  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     18  1.1    hikaru  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     19  1.1    hikaru  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     20  1.1    hikaru  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     21  1.1    hikaru  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     22  1.1    hikaru  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     23  1.1    hikaru  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     24  1.1    hikaru  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     25  1.1    hikaru  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     26  1.1    hikaru  * SUCH DAMAGE.
     27  1.1    hikaru  */
     28  1.1    hikaru 
     29  1.1    hikaru #ifndef _OCTEON_GMXVAR_H_
     30  1.1    hikaru #define _OCTEON_GMXVAR_H_
     31  1.1    hikaru 
     32  1.1    hikaru #include "opt_octeon.h"
     33  1.1    hikaru 
     34  1.1    hikaru #include <net/if.h>
     35  1.1    hikaru #include <net/if_media.h>
     36  1.1    hikaru #include <net/if_ether.h>
     37  1.1    hikaru #include <dev/mii/mii.h>
     38  1.1    hikaru #include <dev/mii/miivar.h>
     39  1.1    hikaru 
     40  1.1    hikaru #define GMX_MII_PORT	1
     41  1.1    hikaru #define GMX_GMII_PORT	2
     42  1.1    hikaru #define GMX_RGMII_PORT	3
     43  1.1    hikaru #define GMX_SPI42_PORT	4
     44  1.1    hikaru 
     45  1.1    hikaru #define GMX_FRM_MAX_SIZ	0x600
     46  1.1    hikaru 
     47  1.1    hikaru enum OCTEON_ETH_QUIRKS {
     48  1.1    hikaru 	OCTEON_ETH_QUIRKS_NO_RX_INBND = 1 << 0,
     49  1.1    hikaru 	OCTEON_ETH_QUIRKS_NO_PRE_ALIGN = 1 << 1,
     50  1.1    hikaru };
     51  1.1    hikaru 
     52  1.1    hikaru #if 1
     53  1.1    hikaru struct octeon_gmx_softc;
     54  1.1    hikaru struct octeon_gmx_port_softc;
     55  1.1    hikaru 
     56  1.1    hikaru struct octeon_gmx_port_softc {
     57  1.1    hikaru 	struct octeon_gmx_softc	*sc_port_gmx;
     58  1.1    hikaru 	bus_space_handle_t	sc_port_regh;
     59  1.1    hikaru 	int			sc_port_no;	/* GMX0:0, GMX0:1, ... */
     60  1.1    hikaru 	int			sc_port_type;
     61  1.1    hikaru 	uint64_t		sc_mac;
     62  1.1    hikaru 	int			sc_quirks;
     63  1.1    hikaru 	uint64_t		sc_link;
     64  1.1    hikaru 	struct mii_data		*sc_port_mii;
     65  1.1    hikaru 	struct ethercom		*sc_port_ec;
     66  1.1    hikaru 	struct octeon_gmx_port_ops
     67  1.1    hikaru 				*sc_port_ops;
     68  1.1    hikaru 	struct octeon_asx_softc	*sc_port_asx;
     69  1.1    hikaru 	struct octeon_ipd_softc	*sc_ipd;
     70  1.1    hikaru 	int			sc_port_flowflags;
     71  1.1    hikaru 
     72  1.1    hikaru #if defined(OCTEON_DEBUG) || defined(OCTEON_ETH_DEBUG)
     73  1.1    hikaru #if 0
     74  1.1    hikaru 	/* XXX */
     75  1.1    hikaru 	struct evcnt		sc_ev_pausedrp;
     76  1.1    hikaru 	struct evcnt		sc_ev_phydupx;
     77  1.1    hikaru 	struct evcnt		sc_ev_physpd;
     78  1.1    hikaru 	struct evcnt		sc_ev_phylink;
     79  1.1    hikaru #endif
     80  1.1    hikaru 	struct evcnt		sc_ev_ifgerr;
     81  1.1    hikaru 	struct evcnt		sc_ev_coldet;
     82  1.1    hikaru 	struct evcnt		sc_ev_falerr;
     83  1.1    hikaru 	struct evcnt		sc_ev_rcverr;
     84  1.1    hikaru 	struct evcnt		sc_ev_rsverr;
     85  1.1    hikaru 	struct evcnt		sc_ev_pckterr;
     86  1.1    hikaru 	struct evcnt		sc_ev_ovrerr;
     87  1.1    hikaru 	struct evcnt		sc_ev_niberr;
     88  1.1    hikaru 	struct evcnt		sc_ev_skperr;
     89  1.1    hikaru 	struct evcnt		sc_ev_lenerr;
     90  1.1    hikaru 	struct evcnt		sc_ev_alnerr;
     91  1.1    hikaru 	struct evcnt		sc_ev_fcserr;
     92  1.1    hikaru 	struct evcnt		sc_ev_jabber;
     93  1.1    hikaru 	struct evcnt		sc_ev_maxerr;
     94  1.1    hikaru 	struct evcnt		sc_ev_carext;
     95  1.1    hikaru 	struct evcnt		sc_ev_minerr;
     96  1.1    hikaru #endif
     97  1.1    hikaru };
     98  1.1    hikaru 
     99  1.1    hikaru struct octeon_gmx_softc {
    100  1.1    hikaru 	device_t		sc_dev;
    101  1.1    hikaru 
    102  1.1    hikaru 	bus_space_tag_t		sc_regt;
    103  1.1    hikaru 	bus_space_handle_t	sc_regh;
    104  1.1    hikaru 	int			sc_unitno;	/* GMX0, GMX1, ... */
    105  1.1    hikaru 	int			sc_nports;
    106  1.1    hikaru 	int			sc_port_types[4/* XXX */];
    107  1.1    hikaru 
    108  1.1    hikaru 	struct octeon_gmx_port_softc
    109  1.1    hikaru 				*sc_ports;
    110  1.1    hikaru 
    111  1.1    hikaru #if defined(OCTEON_DEBUG) || defined(OCTEON_ETH_DEBUG)
    112  1.1    hikaru 	struct evcnt		sc_ev_latecol;
    113  1.1    hikaru 	struct evcnt		sc_ev_xsdef;
    114  1.1    hikaru 	struct evcnt		sc_ev_xscol;
    115  1.1    hikaru 	struct evcnt		sc_ev_undflw;
    116  1.1    hikaru 	struct evcnt		sc_ev_pkonxa;
    117  1.1    hikaru #endif
    118  1.1    hikaru };
    119  1.1    hikaru #endif
    120  1.1    hikaru 
    121  1.1    hikaru struct octeon_gmx_attach_args {
    122  1.1    hikaru         bus_space_tag_t         ga_regt;
    123  1.1    hikaru 	bus_addr_t		ga_addr;
    124  1.1    hikaru 	const char		*ga_name;
    125  1.1    hikaru 	int			ga_portno;
    126  1.1    hikaru 	int			ga_port_type;
    127  1.1    hikaru 
    128  1.1    hikaru 	struct octeon_gmx_softc *ga_gmx;
    129  1.1    hikaru 	struct octeon_gmx_port_softc
    130  1.1    hikaru 				*ga_gmx_port;
    131  1.1    hikaru };
    132  1.1    hikaru 
    133  1.1    hikaru #define	CN30XXGMX_FILTER_NADDRS_MAX	8	/* XXX elsewhere */
    134  1.1    hikaru 
    135  1.1    hikaru enum CN30XXGMX_FILTER_POLICY {
    136  1.1    hikaru 	CN30XXGMX_FILTER_POLICY_ACCEPT_ALL,
    137  1.1    hikaru 	CN30XXGMX_FILTER_POLICY_ACCEPT,
    138  1.1    hikaru 	CN30XXGMX_FILTER_POLICY_REJECT,
    139  1.1    hikaru 	CN30XXGMX_FILTER_POLICY_REJECT_ALL
    140  1.1    hikaru };
    141  1.1    hikaru 
    142  1.1    hikaru int		octeon_gmx_link_enable(struct octeon_gmx_port_softc *, int);
    143  1.1    hikaru int		octeon_gmx_tx_stats_rd_clr(struct octeon_gmx_port_softc *, int);
    144  1.1    hikaru int		octeon_gmx_rx_stats_rd_clr(struct octeon_gmx_port_softc *, int);
    145  1.1    hikaru void		octeon_gmx_rx_stats_dec_bad(struct octeon_gmx_port_softc *);
    146  1.1    hikaru int		octeon_gmx_stats_init(struct octeon_gmx_port_softc *);
    147  1.1    hikaru void		octeon_gmx_tx_int_enable(struct octeon_gmx_port_softc *, int);
    148  1.1    hikaru void		octeon_gmx_rx_int_enable(struct octeon_gmx_port_softc *, int);
    149  1.1    hikaru int		octeon_gmx_setfilt(struct octeon_gmx_port_softc *,
    150  1.1    hikaru 		    enum CN30XXGMX_FILTER_POLICY, size_t, uint8_t **);
    151  1.1    hikaru int		octeon_gmx_rx_frm_ctl_enable(struct octeon_gmx_port_softc *,
    152  1.1    hikaru 		    uint64_t rx_frm_ctl);
    153  1.1    hikaru int		octeon_gmx_rx_frm_ctl_disable(struct octeon_gmx_port_softc *,
    154  1.1    hikaru 		    uint64_t rx_frm_ctl);
    155  1.1    hikaru int		octeon_gmx_tx_thresh(struct octeon_gmx_port_softc *, int);
    156  1.1    hikaru int		octeon_gmx_set_mac_addr(struct octeon_gmx_port_softc *, uint8_t *);
    157  1.1    hikaru int		octeon_gmx_set_filter(struct octeon_gmx_port_softc *);
    158  1.1    hikaru int		octeon_gmx_port_enable(struct octeon_gmx_port_softc *, int);
    159  1.1    hikaru int		octeon_gmx_reset_speed(struct octeon_gmx_port_softc *);
    160  1.1    hikaru int		octeon_gmx_reset_flowctl(struct octeon_gmx_port_softc *);
    161  1.1    hikaru int		octeon_gmx_reset_timing(struct octeon_gmx_port_softc *);
    162  1.1    hikaru int		octeon_gmx_reset_board(struct octeon_gmx_port_softc *);
    163  1.1    hikaru void		octeon_gmx_stats(struct octeon_gmx_port_softc *);
    164  1.1    hikaru uint64_t	octeon_gmx_get_rx_int_reg(struct octeon_gmx_port_softc *sc);
    165  1.1    hikaru uint64_t	octeon_gmx_get_tx_int_reg(struct octeon_gmx_port_softc *sc);
    166  1.2  christos static __inline int	octeon_gmx_link_status(struct octeon_gmx_port_softc *);
    167  1.1    hikaru 
    168  1.1    hikaru /* XXX RGMII specific */
    169  1.2  christos static __inline int
    170  1.1    hikaru octeon_gmx_link_status(struct octeon_gmx_port_softc *sc)
    171  1.1    hikaru {
    172  1.1    hikaru 	return (sc->sc_link & RXN_RX_INBND_STATUS) ? 1 : 0;
    173  1.1    hikaru }
    174  1.1    hikaru 
    175  1.1    hikaru #endif
    176