4 #include <intuition/intuition.h>
5 #include <intuition/intuitionbase.h>
6 #include <libraries/mui.h>
7 #include <libraries/gadtools.h>
8 #include <devices/sana2.h>
9 #include <devices/sana2specialstats.h>
10 #include <exec/devices.h>
17 #define PF_PEG2 0x0002
18 #define PF_CHIP_8513 0x0004
20 #define DDF_CONFIGURED (1<<2) /* station address is configured */
21 #define DDF_ONLINE (1<<3) /* device is online */
22 #define DDF_OFFLINE (1<<4) /* device was put offline */
24 #define DROPPED (1<<0) /* Did the packet get dropped? */
25 #define PACKETFILTER (1<<1) /* Use the packet filter? */
27 /* Ethernet address bytesize
29 #define ETHER_ADDR_SIZE 6
31 #define ETHER_MIN_LEN 60 /* smallest amount that nic will accept */
32 #define ETHER_MAX_LEN 1536 /* largest legal amount for Ethernet */
34 /* Ethernet packet data sizes (maximum)
36 #define ETHERPKT_SIZE 1500
37 #define RAWPKT_SIZE 1514
39 #define EEPROM_WRITE 0x01
40 #define EEPROM_READ 0x02
41 #define EEPROM_DONE 0x04
42 #define EEPROM_WR_ENABLE 0x10
43 #define EEPROM_LOAD 0x20
47 #define PHY_WRITE 0x20
48 #define DEFAULT_GPIO_RESET 0x24
49 #define DEFAULT_GPIO_SET 0x26
51 #define RX_MULTICAST 0x02
52 #define RX_PROMISCUOUS 0x04
54 #define TX_UNDERRUN 0x80
55 #define EXCESSIVE_COL 0x40
57 #define NO_CARRIER 0x10
58 #define LOSS_CARRIER 0x08
59 #define JABBER_TIMEOUT 0x04
61 #define LINK_STATUS 0x01
63 /* USB Control Pipe Commands */
64 #define UPGR_GET_REGS 0xf0
65 #define UPGR_SET_REGS 0xf1
68 #define PEGREG_ETH_CTRL0 0x00
69 #define PEGREG_ETH_CTRL1 0x01
70 #define PEGREG_ETH_CTRL2 0x02
71 #define PEGREG_MCAST 0x08
72 #define PEGREG_ETH_ID 0x10
73 #define PEGREG_REG_1D 0x1d
74 #define PEGREG_EEPROM_OFFSET 0x20
75 #define PEGREG_EEPROM_DATA_LOW 0x21
76 #define PEGREG_EEPROM_DATA_HIGH 0x22
77 #define PEGREG_EEPROM_CTRL 0x23
78 #define PEGREG_PHY_ADDR 0x25
79 #define PEGREG_PHY_DATA_LOW 0x26
80 #define PEGREG_PHY_DATA_HIGH 0x27
81 #define PEGREG_PHY_CTRL 0x28
82 #define PEGREG_USB_STATUS 0x2a
83 #define PEGREG_ETH_TX_STAT0 0x2b
84 #define PEGREG_ETH_TX_STAT1 0x2c
85 #define PEGREG_ETH_RX_STAT 0x2d
86 #define PEGREG_WAKEUP_CTRL 0x78
87 #define PEGREG_REG_7B 0x7b
88 #define PEGREG_GPIO0 0x7e
89 #define PEGREG_GPIO1 0x7f
90 #define PEGREG_REG_80 0x80
91 #define PEGREG_REG_81 0x81
92 #define PEGREG_REG_83 0x83
93 #define PEGREG_REG_84 0x84
97 /* Generic MII registers. */
99 #define MII_BMCR 0x00 /* Basic mode control register */
100 #define MII_BMSR 0x01 /* Basic mode status register */
101 #define MII_PHYSID1 0x02 /* PHYS ID 1 */
102 #define MII_PHYSID2 0x03 /* PHYS ID 2 */
103 #define MII_ADVERTISE 0x04 /* Advertisement control reg */
104 #define MII_LPA 0x05 /* Link partner ability reg */
105 #define MII_EXPANSION 0x06 /* Expansion register */
106 #define MII_CTRL1000 0x09 /* 1000BASE-T control */
107 #define MII_STAT1000 0x0a /* 1000BASE-T status */
108 #define MII_ESTATUS 0x0f /* Extended Status */
109 #define MII_DCOUNTER 0x12 /* Disconnect counter */
110 #define MII_FCSCOUNTER 0x13 /* False carrier counter */
111 #define MII_NWAYTEST 0x14 /* N-way auto-neg test reg */
112 #define MII_RERRCOUNTER 0x15 /* Receive error counter */
113 #define MII_SREVISION 0x16 /* Silicon revision */
114 #define MII_RESV1 0x17 /* Reserved... */
115 #define MII_LBRERROR 0x18 /* Lpback, rx, bypass error */
116 #define MII_PHYADDR 0x19 /* PHY address */
117 #define MII_RESV2 0x1a /* Reserved... */
118 #define MII_TPISTATUS 0x1b /* TPI status for 10mbps */
119 #define MII_NCONFIG 0x1c /* Network interface config */
121 /* Basic mode control register. */
122 #define BMCR_RESV 0x003f /* Unused... */
123 #define BMCR_SPEED1000 0x0040 /* MSB of Speed (1000) */
124 #define BMCR_CTST 0x0080 /* Collision test */
125 #define BMCR_FULLDPLX 0x0100 /* Full duplex */
126 #define BMCR_ANRESTART 0x0200 /* Auto negotiation restart */
127 #define BMCR_ISOLATE 0x0400 /* Disconnect DP83840 from MII */
128 #define BMCR_PDOWN 0x0800 /* Powerdown the DP83840 */
129 #define BMCR_ANENABLE 0x1000 /* Enable auto negotiation */
130 #define BMCR_SPEED100 0x2000 /* Select 100Mbps */
131 #define BMCR_LOOPBACK 0x4000 /* TXD loopback bits */
132 #define BMCR_RESET 0x8000 /* Reset the DP83840 */
134 /* Basic mode status register. */
135 #define BMSR_ERCAP 0x0001 /* Ext-reg capability */
136 #define BMSR_JCD 0x0002 /* Jabber detected */
137 #define BMSR_LSTATUS 0x0004 /* Link status */
138 #define BMSR_ANEGCAPABLE 0x0008 /* Able to do auto-negotiation */
139 #define BMSR_RFAULT 0x0010 /* Remote fault detected */
140 #define BMSR_ANEGCOMPLETE 0x0020 /* Auto-negotiation complete */
141 #define BMSR_RESV 0x00c0 /* Unused... */
142 #define BMSR_ESTATEN 0x0100 /* Extended Status in R15 */
143 #define BMSR_100FULL2 0x0200 /* Can do 100BASE-T2 HDX */
144 #define BMSR_100HALF2 0x0400 /* Can do 100BASE-T2 FDX */
145 #define BMSR_10HALF 0x0800 /* Can do 10mbps, half-duplex */
146 #define BMSR_10FULL 0x1000 /* Can do 10mbps, full-duplex */
147 #define BMSR_100HALF 0x2000 /* Can do 100mbps, half-duplex */
148 #define BMSR_100FULL 0x4000 /* Can do 100mbps, full-duplex */
149 #define BMSR_100BASE4 0x8000 /* Can do 100mbps, 4k packets */
151 #define BMSR_MEDIA (BMSR_10HALF|BMSR_10FULL|BMSR_100HALF|BMSR_100FULL|BMSR_ANEGCAPABLE)
153 /* Advertisement control register. */
154 #define ADVERTISE_SLCT 0x001f /* Selector bits */
155 #define ADVERTISE_CSMA 0x0001 /* Only selector supported */
156 #define ADVERTISE_10HALF 0x0020 /* Try for 10mbps half-duplex */
157 #define ADVERTISE_10FULL 0x0040 /* Try for 10mbps full-duplex */
158 #define ADVERTISE_100HALF 0x0080 /* Try for 100mbps half-duplex */
159 #define ADVERTISE_100FULL 0x0100 /* Try for 100mbps full-duplex */
160 #define ADVERTISE_100BASE4 0x0200 /* Try for 100mbps 4k packets */
161 #define ADVERTISE_PAUSE_CAP 0x0400 /* Try for pause */
162 #define ADVERTISE_PAUSE_ASYM 0x0800 /* Try for asymetric pause */
163 #define ADVERTISE_RESV 0x1000 /* Unused... */
164 #define ADVERTISE_RFAULT 0x2000 /* Say we can detect faults */
165 #define ADVERTISE_LPACK 0x4000 /* Ack link partners response */
166 #define ADVERTISE_NPAGE 0x8000 /* Next page bit */
170 #define VENDOR_3COM 0x0506
171 #define VENDOR_ABOCOM 0x07b8
172 #define VENDOR_ACCTON 0x083a
173 #define VENDOR_ADMTEK 0x07a6
174 #define VENDOR_AEILAB 0x3334
175 #define VENDOR_ALLIEDTEL 0x07c9
176 #define VENDOR_ATEN 0x0557
177 #define VENDOR_BELKIN 0x050d
178 #define VENDOR_BILLIONTON 0x08dd
179 #define VENDOR_COMPAQ 0x049f
180 #define VENDOR_COREGA 0x07aa
181 #define VENDOR_DLINK 0x2001
182 #define VENDOR_ELCON 0x0db7
183 #define VENDOR_ELECOM 0x056e
184 #define VENDOR_ELSA 0x05cc
185 #define VENDOR_GIGABYTE 0x1044
186 #define VENDOR_HAWKING 0x0e66
187 #define VENDOR_HP 0x03f0
188 #define VENDOR_IODATA 0x04bb
189 #define VENDOR_KINGSTON 0x0951
190 #define VENDOR_LANEED 0x056e
191 #define VENDOR_LINKSYS 0x066b
192 #define VENDOR_LINKSYS2 0x077b
193 #define VENDOR_MELCO 0x0411
194 #define VENDOR_MICROSOFT 0x045e
195 #define VENDOR_MOBILITY 0x1342
196 #define VENDOR_NETGEAR 0x0846
197 #define VENDOR_OCT 0x0b39
198 #define VENDOR_SMARTBRIDGES 0x08d1
199 #define VENDOR_SMC 0x0707
200 #define VENDOR_SOHOWARE 0x15e8
201 #define VENDOR_SIEMENS 0x067c
203 #define ID_ABOUT 0x55555555
204 #define ID_STORE_CONFIG 0xaaaaaaaa
205 #define ID_DEF_CONFIG 0xaaaaaaab
207 #define MT_AUTO 0x0000
208 #define MT_10BASE_T_HALF_DUP 0x0001
209 #define MT_10BASE_T_FULL_DUP 0x0002
210 #define MT_100BASE_TX_HALF_DUP 0x0003
211 #define MT_100BASE_TX_FULL_DUP 0x0004
217 ULONG cdc_DefaultUnit
;
221 #if defined(__GNUC__)
225 /* Structure of an ethernet packet - internal
228 struct EtherPacketHeader
230 UBYTE eph_Dest
[ETHER_ADDR_SIZE
]; /* 0 destination address */
231 UBYTE eph_Src
[ETHER_ADDR_SIZE
]; /* 6 originator address */
232 UWORD eph_Type
; /* 12 packet type */
235 /* Buffer management node - private
240 APTR bm_DMACopyFromBuf32
;
242 APTR bm_DMACopyToBuf32
;
244 APTR bm_PacketFilter
;
245 struct List bm_RXQueue
; /* read requests */
248 /* Multicast address range record - private
250 struct MulticastAddressRange
252 struct Node mar_Node
; /* 0 list node */
253 ULONG mar_UseCount
; /* 8 number of times used */
254 UBYTE mar_LowerAddr
[ETHER_ADDR_SIZE
]; /* 12 multicast address lower bound */
255 UBYTE mar_UpperAddr
[ETHER_ADDR_SIZE
]; /* 18 multicast address upper bound */
258 struct PacketTypeStats
260 struct Node pts_Node
;
261 ULONG pts_PacketType
;
262 struct Sana2PacketTypeStats pts_Stats
;
268 struct Library np_Library
; /* standard */
269 UWORD np_Flags
; /* various flags */
271 BPTR np_SegList
; /* device seglist */
272 struct NepEthBase
*np_ClsBase
; /* pointer to class base */
273 struct Library
*np_UtilityBase
; /* cached utilitybase */
278 struct Unit ncp_Unit
; /* Unit structure */
279 ULONG ncp_UnitNo
; /* Unit number */
280 ULONG ncp_OpenFlags
; /* Flags used to open the device */
281 struct NepEthBase
*ncp_ClsBase
; /* Up linkage */
282 struct NepEthDevBase
*ncp_DevBase
; /* Device base */
283 struct Library
*ncp_Base
; /* Poseidon base */
284 struct PsdDevice
*ncp_Device
; /* Up linkage */
285 struct PsdConfig
*ncp_Config
; /* Up linkage */
286 struct PsdInterface
*ncp_Interface
; /* Up linkage */
287 struct Task
*ncp_ReadySigTask
; /* Task to send ready signal to */
288 LONG ncp_ReadySignal
; /* Signal to send when ready */
289 struct Task
*ncp_Task
; /* Subtask */
290 struct MsgPort
*ncp_TaskMsgPort
; /* Message Port of Subtask */
292 struct PsdPipe
*ncp_EP0Pipe
; /* Endpoint 0 pipe */
293 struct PsdEndpoint
*ncp_EPOut
; /* Endpoint 1 */
294 struct PsdPipe
*ncp_EPOutPipe
[2]; /* Endpoint 1 pipes */
295 IPTR ncp_EPOutMaxPktSize
; /* Endpoint 1 max pkt size */
296 struct PsdEndpoint
*ncp_EPIn
; /* Endpoint 2 */
297 struct PsdPipe
*ncp_EPInPipe
; /* Endpoint 2 pipe */
298 struct MsgPort
*ncp_DevMsgPort
; /* Message Port for IOParReq */
299 UWORD ncp_UnitProdID
; /* ProductID of unit */
300 UWORD ncp_UnitVendorID
; /* VendorID of unit */
301 //BOOL ncp_DenyRequests; /* Do not accept further IO requests */
303 struct List ncp_BufManList
; /* Buffer Managers */
304 struct List ncp_EventList
; /* List for DoEvent */
305 struct List ncp_TrackList
; /* List of trackables */
306 struct List ncp_Multicasts
; /* List of multicast addresses */
307 ULONG ncp_PatchFlags
; /* Patchflags */
308 UBYTE ncp_MacAddress
[ETHER_ADDR_SIZE
]; /* Current Mac Address */
309 UBYTE ncp_ROMAddress
[ETHER_ADDR_SIZE
]; /* ROM Mac Address */
310 UBYTE ncp_EthCtrl
[4]; /* shadow of the control registers (one byte padding) */
311 ULONG ncp_PhyID
; /* ID of the PHY */
312 UBYTE ncp_MulticastArray
[8]; /* array for the multicast hashes */
313 ULONG ncp_StateFlags
; /* State of the unit */
315 ULONG ncp_Retries
; /* tx collision count */
316 ULONG ncp_BadMulticasts
; /* bad multicast count */
318 UBYTE
*ncp_ReadBuffer
[2]; /* Packet Double Buffered Read Buffer */
319 UBYTE
*ncp_WriteBuffer
[2]; /* Packet Write Buffer */
321 UWORD ncp_ReadBufNum
; /* Next Read Buffer to use */
322 UWORD ncp_WriteBufNum
; /* Next Write Buffer to use */
324 struct Sana2DeviceStats ncp_DeviceStats
; /* SANA Stats */
325 struct Sana2PacketTypeStats
*ncp_TypeStats2048
; /* IP protocol stats ptr, or NULL */
326 struct Sana2PacketTypeStats
*ncp_TypeStats2054
; /* ARP protocol stats ptr, or NULL */
328 UBYTE
*ncp_ReadPending
; /* read IORequest pending */
329 struct IOSana2Req
*ncp_WritePending
[2]; /* write IORequest pending */
330 struct List ncp_OrphanQueue
; /* List of orphan read requests */
331 struct List ncp_WriteQueue
; /* List of write requests */
333 UBYTE ncp_DevIDString
[128]; /* Device ID String */
335 BOOL ncp_UsingDefaultCfg
;
336 struct ClsDevCfg
*ncp_CDC
;
338 struct Library
*ncp_MUIBase
; /* MUI master base */
339 struct Library
*ncp_PsdBase
; /* Poseidon base */
340 struct Library
*ncp_IntBase
; /* Intuition base */
341 struct Task
*ncp_GUITask
; /* GUI Task */
342 struct NepClassHid
*ncp_GUIBinding
; /* Window of binding that's open */
345 Object
*ncp_MainWindow
;
348 Object
*ncp_MediaTypeObj
;
351 Object
*ncp_SetDefaultObj
;
352 Object
*ncp_CloseObj
;
356 Object
*ncp_SetDefaultMI
;
357 Object
*ncp_MUIPrefsMI
;
363 struct Library nh_Library
; /* standard */
364 UWORD nh_Flags
; /* various flags */
366 struct Library
*nh_UtilityBase
; /* utility base */
368 struct NepEthDevBase
*nh_DevBase
; /* base of device created */
369 struct List nh_Units
; /* List of units available */
371 struct NepClassEth nh_DummyNCP
; /* Dummy ncp for default config */
375 #endif /* PEGASUS_H */