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