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