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>
16 #define DDF_CONFIGURED (1<<2) /* station address is configured */
17 #define DDF_ONLINE (1<<3) /* device is online */
18 #define DDF_OFFLINE (1<<4) /* device was put offline */
20 #define DROPPED (1<<0) /* Did the packet get dropped? */
21 #define PACKETFILTER (1<<1) /* Use the packet filter? */
23 /* Ethernet address bytesize
25 #define ETHER_ADDR_SIZE 6
27 #define ETHER_MIN_LEN 60 /* smallest amount that nic will accept */
28 #define ETHER_MAX_LEN 2048 /* largest legal amount for Ethernet */
30 /* Ethernet packet data sizes (maximum)
32 #define ETHERPKT_SIZE 1500
33 #define RAWPKT_SIZE 1514
35 /* MCS7830 based USB 2.0 Ethernet Devices */
37 #define UMCR_WRITE_REG 0x0d
38 #define UMCR_READ_REG 0x0e
39 #define UMCR_WRITE_REG_WITH_MASK 0x0f
41 /* Packet status error byte defines */
42 #define PKSF_UNDERRUN 0x01
43 #define PKSF_LENGTH_ERROR 0x02
44 #define PKSF_ALIGNMENT_ERROR 0x04
45 #define PKSF_CRC_ERROR 0x08
46 #define PKSF_OVERRUN 0x10
47 #define PKSF_NO_ERROR 0x20
49 #define MCREG_MCAST_ADDR 0x00
50 #define MCREG_IPG0 0x08
51 #define MCREG_IPG1 0x09
52 #define MCREG_PHY_DATA_LOW 0x0a
53 #define MCREG_PHY_DATA_HIGH 0x0b
54 #define MCREG_PHY_ADDR 0x0c /* lower 4 bits contain phy address */
55 #define MCREG_PHY_CTRL 0x0d /* lower 4 bits contain phy register */
56 #define MCREG_CFG 0x0e
57 #define MCREG_ETH_ID 0x0f
59 #define MCRF_PHY_WRITE 0x20
60 #define MCRF_PHY_READ 0x40
62 #define MCRF_PHY_PENDING 0x80
63 #define MCRF_PHY_READY 0x40
65 #define MCRF_CFG_PROM 0x01
66 #define MCRF_CFG_MCAST 0x02
67 #define MCRF_CFG_SLEEP 0x04
68 #define MCRF_CFG_TXEN 0x08
69 #define MCRF_CFG_DUPLEX 0x20
70 #define MCRF_CFG_SPEED100 0x40
71 #define MCRF_CFG_OVERRIDE 0x80
75 /* Generic MII registers. */
77 #define MII_BMCR 0x00 /* Basic mode control register */
78 #define MII_BMSR 0x01 /* Basic mode status register */
79 #define MII_PHYSID1 0x02 /* PHYS ID 1 */
80 #define MII_PHYSID2 0x03 /* PHYS ID 2 */
81 #define MII_ADVERTISE 0x04 /* Advertisement control reg */
82 #define MII_LPA 0x05 /* Link partner ability reg */
83 #define MII_EXPANSION 0x06 /* Expansion register */
84 #define MII_CTRL1000 0x09 /* 1000BASE-T control */
85 #define MII_STAT1000 0x0a /* 1000BASE-T status */
86 #define MII_ESTATUS 0x0f /* Extended Status */
87 #define MII_DCOUNTER 0x12 /* Disconnect counter */
88 #define MII_FCSCOUNTER 0x13 /* False carrier counter */
89 #define MII_NWAYTEST 0x14 /* N-way auto-neg test reg */
90 #define MII_RERRCOUNTER 0x15 /* Receive error counter */
91 #define MII_SREVISION 0x16 /* Silicon revision */
92 #define MII_RESV1 0x17 /* Reserved... */
93 #define MII_LBRERROR 0x18 /* Lpback, rx, bypass error */
94 #define MII_PHYADDR 0x19 /* PHY address */
95 #define MII_RESV2 0x1a /* Reserved... */
96 #define MII_TPISTATUS 0x1b /* TPI status for 10mbps */
97 #define MII_NCONFIG 0x1c /* Network interface config */
99 /* Basic mode control register. */
100 #define BMCR_RESV 0x003f /* Unused... */
101 #define BMCR_SPEED1000 0x0040 /* MSB of Speed (1000) */
102 #define BMCR_CTST 0x0080 /* Collision test */
103 #define BMCR_FULLDPLX 0x0100 /* Full duplex */
104 #define BMCR_ANRESTART 0x0200 /* Auto negotiation restart */
105 #define BMCR_ISOLATE 0x0400 /* Disconnect DP83840 from MII */
106 #define BMCR_PDOWN 0x0800 /* Powerdown the DP83840 */
107 #define BMCR_ANENABLE 0x1000 /* Enable auto negotiation */
108 #define BMCR_SPEED100 0x2000 /* Select 100Mbps */
109 #define BMCR_LOOPBACK 0x4000 /* TXD loopback bits */
110 #define BMCR_RESET 0x8000 /* Reset the DP83840 */
112 /* Basic mode status register. */
113 #define BMSR_ERCAP 0x0001 /* Ext-reg capability */
114 #define BMSR_JCD 0x0002 /* Jabber detected */
115 #define BMSR_LSTATUS 0x0004 /* Link status */
116 #define BMSR_ANEGCAPABLE 0x0008 /* Able to do auto-negotiation */
117 #define BMSR_RFAULT 0x0010 /* Remote fault detected */
118 #define BMSR_ANEGCOMPLETE 0x0020 /* Auto-negotiation complete */
119 #define BMSR_RESV 0x00c0 /* Unused... */
120 #define BMSR_ESTATEN 0x0100 /* Extended Status in R15 */
121 #define BMSR_100FULL2 0x0200 /* Can do 100BASE-T2 HDX */
122 #define BMSR_100HALF2 0x0400 /* Can do 100BASE-T2 FDX */
123 #define BMSR_10HALF 0x0800 /* Can do 10mbps, half-duplex */
124 #define BMSR_10FULL 0x1000 /* Can do 10mbps, full-duplex */
125 #define BMSR_100HALF 0x2000 /* Can do 100mbps, half-duplex */
126 #define BMSR_100FULL 0x4000 /* Can do 100mbps, full-duplex */
127 #define BMSR_100BASE4 0x8000 /* Can do 100mbps, 4k packets */
129 #define BMSR_MEDIA (BMSR_10HALF|BMSR_10FULL|BMSR_100HALF|BMSR_100FULL|BMSR_ANEGCAPABLE)
131 /* Advertisement control register. */
132 #define ADVERTISE_SLCT 0x001f /* Selector bits */
133 #define ADVERTISE_CSMA 0x0001 /* Only selector supported */
134 #define ADVERTISE_10HALF 0x0020 /* Try for 10mbps half-duplex */
135 #define ADVERTISE_10FULL 0x0040 /* Try for 10mbps full-duplex */
136 #define ADVERTISE_100HALF 0x0080 /* Try for 100mbps half-duplex */
137 #define ADVERTISE_100FULL 0x0100 /* Try for 100mbps full-duplex */
138 #define ADVERTISE_100BASE4 0x0200 /* Try for 100mbps 4k packets */
139 #define ADVERTISE_PAUSE_CAP 0x0400 /* Try for pause */
140 #define ADVERTISE_PAUSE_ASYM 0x0800 /* Try for asymetric pause */
141 #define ADVERTISE_RESV 0x1000 /* Unused... */
142 #define ADVERTISE_RFAULT 0x2000 /* Say we can detect faults */
143 #define ADVERTISE_LPACK 0x4000 /* Ack link partners response */
144 #define ADVERTISE_NPAGE 0x8000 /* Next page bit */
146 #define ADVERTISE_FULL (ADVERTISE_100FULL | ADVERTISE_10FULL | \
148 #define ADVERTISE_ALL (ADVERTISE_10HALF | ADVERTISE_10FULL | \
149 ADVERTISE_100HALF | ADVERTISE_100FULL)
151 #define MCS7830_MII_ADVERTISE (ADVERTISE_PAUSE_CAP | ADVERTISE_100FULL | \
152 ADVERTISE_100HALF | ADVERTISE_10FULL | \
153 ADVERTISE_10HALF | ADVERTISE_CSMA)
155 #define ID_ABOUT 0x55555555
156 #define ID_STORE_CONFIG 0xaaaaaaaa
157 #define ID_DEF_CONFIG 0xaaaaaaab
159 #define MT_AUTO 0x0000
160 #define MT_10BASE_T_HALF_DUP 0x0001
161 #define MT_10BASE_T_FULL_DUP 0x0002
162 #define MT_100BASE_TX_HALF_DUP 0x0003
163 #define MT_100BASE_TX_FULL_DUP 0x0004
169 ULONG cdc_DefaultUnit
;
173 #if defined(__GNUC__)
177 /* Structure of an ethernet packet - internal
180 struct EtherPacketHeader
182 UBYTE eph_Dest
[ETHER_ADDR_SIZE
]; /* 0 destination address */
183 UBYTE eph_Src
[ETHER_ADDR_SIZE
]; /* 6 originator address */
184 UWORD eph_Type
; /* 12 packet type */
187 /* Buffer management node - private
192 APTR bm_DMACopyFromBuf32
;
194 APTR bm_DMACopyToBuf32
;
196 APTR bm_PacketFilter
;
197 struct List bm_RXQueue
; /* read requests */
200 /* Multicast address range record - private
202 struct MulticastAddressRange
204 struct Node mar_Node
; /* 0 list node */
205 ULONG mar_UseCount
; /* 8 number of times used */
206 UBYTE mar_LowerAddr
[ETHER_ADDR_SIZE
]; /* 12 multicast address lower bound */
207 UBYTE mar_UpperAddr
[ETHER_ADDR_SIZE
]; /* 18 multicast address upper bound */
210 struct PacketTypeStats
212 struct Node pts_Node
;
213 ULONG pts_PacketType
;
214 struct Sana2PacketTypeStats pts_Stats
;
220 struct Library np_Library
; /* standard */
221 UWORD np_Flags
; /* various flags */
223 BPTR np_SegList
; /* device seglist */
224 struct NepEthBase
*np_ClsBase
; /* pointer to class base */
225 struct Library
*np_UtilityBase
; /* cached utilitybase */
230 struct Unit ncp_Unit
; /* Unit structure */
231 ULONG ncp_UnitNo
; /* Unit number */
232 ULONG ncp_OpenFlags
; /* Flags used to open the device */
233 struct NepEthBase
*ncp_ClsBase
; /* Up linkage */
234 struct NepEthDevBase
*ncp_DevBase
; /* Device base */
235 struct Library
*ncp_Base
; /* Poseidon base */
236 struct PsdDevice
*ncp_Device
; /* Up linkage */
237 struct PsdConfig
*ncp_Config
; /* Up linkage */
238 struct PsdInterface
*ncp_Interface
; /* Up linkage */
239 struct Task
*ncp_ReadySigTask
; /* Task to send ready signal to */
240 LONG ncp_ReadySignal
; /* Signal to send when ready */
241 struct Task
*ncp_Task
; /* Subtask */
242 struct MsgPort
*ncp_TaskMsgPort
; /* Message Port of Subtask */
244 struct PsdPipe
*ncp_EP0Pipe
; /* Endpoint 0 pipe */
245 struct PsdEndpoint
*ncp_EPOut
; /* Endpoint 1 */
246 struct PsdPipe
*ncp_EPOutPipe
[2]; /* Endpoint 1 pipes */
247 IPTR ncp_EPOutMaxPktSize
; /* Endpoint 1 max pkt size */
248 struct PsdEndpoint
*ncp_EPIn
; /* Endpoint 2 */
249 struct PsdPipe
*ncp_EPInPipe
; /* Endpoint 2 pipe */
250 struct MsgPort
*ncp_DevMsgPort
; /* Message Port for IOParReq */
251 UWORD ncp_UnitProdID
; /* ProductID of unit */
252 UWORD ncp_UnitVendorID
; /* VendorID of unit */
253 //BOOL ncp_DenyRequests; /* Do not accept further IO requests */
255 struct List ncp_BufManList
; /* Buffer Managers */
256 struct List ncp_EventList
; /* List for DoEvent */
257 struct List ncp_TrackList
; /* List of trackables */
258 struct List ncp_Multicasts
; /* List of multicast addresses */
259 UBYTE ncp_MacAddress
[ETHER_ADDR_SIZE
]; /* Current Mac Address */
260 UBYTE ncp_ROMAddress
[ETHER_ADDR_SIZE
]; /* ROM Mac Address */
261 ULONG ncp_PhyID
; /* ID of the PHY */
264 UBYTE ncp_MulticastArray
[8]; /* array for the multicast hashes */
265 ULONG ncp_StateFlags
; /* State of the unit */
267 ULONG ncp_Retries
; /* tx collision count */
268 ULONG ncp_BadMulticasts
; /* bad multicast count */
270 UBYTE
*ncp_ReadBuffer
[2]; /* Packet Double Buffered Read Buffer */
271 UBYTE
*ncp_WriteBuffer
[2]; /* Packet Write Buffer */
273 UWORD ncp_ReadBufNum
; /* Next Read Buffer to use */
274 UWORD ncp_WriteBufNum
; /* Next Write Buffer to use */
276 struct Sana2DeviceStats ncp_DeviceStats
; /* SANA Stats */
277 struct Sana2PacketTypeStats
*ncp_TypeStats2048
; /* IP protocol stats ptr, or NULL */
278 struct Sana2PacketTypeStats
*ncp_TypeStats2054
; /* ARP protocol stats ptr, or NULL */
280 UBYTE
*ncp_ReadPending
; /* read IORequest pending */
281 struct IOSana2Req
*ncp_WritePending
[2]; /* write IORequest pending */
282 struct List ncp_OrphanQueue
; /* List of orphan read requests */
283 struct List ncp_WriteQueue
; /* List of write requests */
285 UBYTE ncp_DevIDString
[128]; /* Device ID String */
287 BOOL ncp_UsingDefaultCfg
;
288 struct ClsDevCfg
*ncp_CDC
;
290 struct Library
*ncp_MUIBase
; /* MUI master base */
291 struct Library
*ncp_PsdBase
; /* Poseidon base */
292 struct Library
*ncp_IntBase
; /* Intuition base */
293 struct Task
*ncp_GUITask
; /* GUI Task */
294 struct NepClassHid
*ncp_GUIBinding
; /* Window of binding that's open */
297 Object
*ncp_MainWindow
;
300 Object
*ncp_MediaTypeObj
;
303 Object
*ncp_SetDefaultObj
;
304 Object
*ncp_CloseObj
;
308 Object
*ncp_SetDefaultMI
;
309 Object
*ncp_MUIPrefsMI
;
315 struct Library nh_Library
; /* standard */
316 UWORD nh_Flags
; /* various flags */
318 struct Library
*nh_UtilityBase
; /* utility base */
320 struct NepEthDevBase
*nh_DevBase
; /* base of device created */
321 struct List nh_Units
; /* List of units available */
323 struct NepClassEth nh_DummyNCP
; /* Dummy ncp for default config */
327 #endif /* MOSCHIPETH_H */