Home | History | Annotate | Line # | Download | only in ic
dp8390var.h revision 1.20
      1 /*	$NetBSD: dp8390var.h,v 1.20 2000/09/28 10:56:57 tsutsui Exp $	*/
      2 
      3 /*
      4  * Device driver for National Semiconductor DS8390/WD83C690 based ethernet
      5  * adapters.
      6  *
      7  * Copyright (c) 1994, 1995 Charles M. Hannum.  All rights reserved.
      8  *
      9  * Copyright (C) 1993, David Greenman.  This software may be used, modified,
     10  * copied, distributed, and sold, in both source and binary form provided that
     11  * the above copyright and these terms are retained.  Under no circumstances is
     12  * the author responsible for the proper functioning of this software, nor does
     13  * the author assume any responsibility for damages incurred with its use.
     14  */
     15 
     16 #include "rnd.h"
     17 #if NRND > 0
     18 #include <sys/rnd.h>
     19 #endif
     20 
     21 #define INTERFACE_NAME_LEN	32
     22 
     23 /*
     24  * dp8390_softc: per line info and status
     25  */
     26 struct dp8390_softc {
     27 	struct device	sc_dev;
     28 	void	*sc_ih;
     29 	int	sc_flags;		/* interface flags, from config */
     30 
     31 	struct ethercom sc_ec;		/* ethernet common */
     32 	struct ifmedia sc_media;	/* supported media information */
     33 
     34 	bus_space_tag_t	sc_regt;	/* NIC register space tag */
     35 	bus_space_handle_t sc_regh;	/* NIC register space handle */
     36 	bus_space_tag_t	sc_buft;	/* Buffer space tag */
     37 	bus_space_handle_t sc_bufh;	/* Buffer space handle */
     38 
     39 	bus_size_t sc_reg_map[16];	/* register map (offsets) */
     40 
     41 	int	is790;		/* NIC is a 790 */
     42 
     43 	u_int8_t cr_proto;	/* values always set in CR */
     44 	u_int8_t rcr_proto;	/* values always set in RCR */
     45 	u_int8_t dcr_reg;	/* override DCR iff LS is set */
     46 
     47 	int	mem_start;	/* offset of NIC memory */
     48 	int	mem_end;	/* offset of NIC memory end */
     49 	int	mem_size;	/* total shared memory size */
     50 	int	mem_ring;	/* offset of start of RX ring-buffer */
     51 
     52 	u_short	txb_cnt;	/* Number of transmit buffers */
     53 	u_short	txb_inuse;	/* number of transmit buffers active */
     54 
     55 	u_short	txb_new;	/* pointer to where new buffer will be added */
     56 	u_short	txb_next_tx;	/* pointer to next buffer ready to xmit */
     57 	u_short	txb_len[8];	/* buffered xmit buffer lengths */
     58 	u_short	tx_page_start;	/* first page of TX buffer area */
     59 	u_short	rec_page_start; /* first page of RX ring-buffer */
     60 	u_short	rec_page_stop;	/* last page of RX ring-buffer */
     61 	u_short	next_packet;	/* pointer to next unread RX packet */
     62 
     63 	u_int8_t sc_enaddr[ETHER_ADDR_LEN];	/* storage for MAC address */
     64 
     65 	int	sc_enabled;	/* boolean; power enabled on interface */
     66 
     67 #if NRND > 0
     68 	rndsource_element_t rnd_source; /* random source */
     69 #endif
     70 
     71 	int	(*test_mem) __P((struct dp8390_softc *));
     72 	void	(*init_card) __P((struct dp8390_softc *));
     73 	void	(*read_hdr) __P((struct dp8390_softc *,
     74 		    int, struct dp8390_ring *));
     75 	void	(*recv_int) __P((struct dp8390_softc *));
     76 	int	(*ring_copy) __P((struct dp8390_softc *,
     77 		    int, caddr_t, u_short));
     78 	int	(*write_mbuf) __P((struct dp8390_softc *, struct mbuf *, int));
     79 
     80 	int	(*sc_enable) __P((struct dp8390_softc *));
     81 	void	(*sc_disable) __P((struct dp8390_softc *));
     82 
     83 	int	(*sc_mediachange) __P((struct dp8390_softc *));
     84 	void	(*sc_mediastatus) __P((struct dp8390_softc *,
     85 		    struct ifmediareq *));
     86 };
     87 
     88 /*
     89  * Vendor types
     90  */
     91 #define DP8390_VENDOR_UNKNOWN	0xff	/* Unknown network card */
     92 #define DP8390_VENDOR_WD_SMC	0x00	/* Western Digital/SMC */
     93 #define DP8390_VENDOR_3COM	0x01	/* 3Com */
     94 #define DP8390_VENDOR_NOVELL	0x02	/* Novell */
     95 #define DP8390_VENDOR_APPLE	0x10	/* Apple Ethernet card */
     96 #define DP8390_VENDOR_INTERLAN	0x11	/* Interlan A310 card (GatorCard) */
     97 #define DP8390_VENDOR_DAYNA	0x12	/* DaynaPORT E/30s (and others?) */
     98 #define DP8390_VENDOR_ASANTE	0x13	/* Asante MacCon II/E */
     99 #define DP8390_VENDOR_FARALLON	0x14	/* Farallon EtherMac II-TP */
    100 #define DP8390_VENDOR_FOCUS	0x15	/* FOCUS Enhancements EtherLAN */
    101 #define DP8390_VENDOR_KINETICS	0x16	/* Kinetics EtherPort SE/30 */
    102 #define DP8390_VENDOR_CABLETRON	0x17	/* Cabletron Ethernet */
    103 
    104 /*
    105  * Compile-time config flags
    106  */
    107 /*
    108  * This sets the default for enabling/disablng the tranceiver.
    109  */
    110 #define DP8390_DISABLE_TRANCEIVER	0x0001
    111 
    112 /*
    113  * This forces the board to be used in 8/16-bit mode even if it autoconfigs
    114  * differently.
    115  */
    116 #define DP8390_FORCE_8BIT_MODE		0x0002
    117 #define DP8390_FORCE_16BIT_MODE		0x0004
    118 
    119 /*
    120  * This disables the use of multiple transmit buffers.
    121  */
    122 #define DP8390_NO_MULTI_BUFFERING	0x0008
    123 
    124 /*
    125  * This forces all operations with the NIC memory to use Programmed I/O (i.e.
    126  * not via shared memory).
    127  */
    128 #define DP8390_FORCE_PIO		0x0010
    129 
    130 /*
    131  * The chip is ASIX AX88190 and needs work around.
    132  */
    133 #define	DP8390_DO_AX88190_WORKAROUND	0x0020
    134 
    135 #define DP8390_ATTACHED			0x0040	/* attach has succeeded */
    136 
    137 /*
    138  * NIC register access macros
    139  */
    140 #define NIC_GET(t, h, reg)	bus_space_read_1(t, h,			\
    141 				    ((sc)->sc_reg_map[reg]))
    142 #define NIC_PUT(t, h, reg, val)	bus_space_write_1(t, h,			\
    143 				    ((sc)->sc_reg_map[reg]), (val))
    144 #define	NIC_BARRIER(t, h)	bus_space_barrier(t, h, 0, 0x10,	\
    145 			    BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE)
    146 
    147 int	dp8390_config __P((struct dp8390_softc *, int *, int, int));
    148 int	dp8390_intr __P((void *));
    149 int	dp8390_ioctl __P((struct ifnet *, u_long, caddr_t));
    150 void	dp8390_start __P((struct ifnet *));
    151 void	dp8390_watchdog __P((struct ifnet *));
    152 void	dp8390_reset __P((struct dp8390_softc *));
    153 void	dp8390_init __P((struct dp8390_softc *));
    154 void	dp8390_stop __P((struct dp8390_softc *));
    155 
    156 void	dp8390_rint __P((struct dp8390_softc *));
    157 
    158 void	dp8390_getmcaf __P((struct ethercom *, u_int8_t *));
    159 struct mbuf *dp8390_get __P((struct dp8390_softc *, int, u_short));
    160 void	dp8390_read __P((struct dp8390_softc *, int, u_short));
    161 
    162 int	dp8390_enable __P((struct dp8390_softc *));
    163 void	dp8390_disable __P((struct dp8390_softc *));
    164 
    165 int	dp8390_activate __P((struct device *, enum devact));
    166 
    167 int	dp8390_detach __P((struct dp8390_softc *, int));
    168 
    169 #ifdef IPKDB_DP8390
    170 int	dp8390_ipkdb_attach __P((struct ipkdb_if *));
    171 #endif
    172