2 * ASIX AX88172/AX88772/AX88178 USB 2.0 Ethernet Driver.
3 * Copyright (c) 2008, 2011 S.Zharski <imker@gmx.li>
4 * Distributed under the terms of the MIT license.
6 * Heavily based on code of the
7 * Driver for USB Ethernet Control Model devices
8 * Copyright (C) 2008 Michael Lotz <mmlr@mlotz.ch>
9 * Distributed under the terms of the MIT license.
12 #ifndef _USB_ASIX_DEVICE_H_
13 #define _USB_ASIX_DEVICE_H_
16 #include <ether_driver.h>
17 #include <util/Vector.h>
36 inline uint16
VendorId() { return fIds
[0]; }
37 inline uint16
ProductId() { return fIds
[1]; }
38 inline uint32
Key() { return fIds
[0] << 16 | fIds
[1]; }
44 ASIXDevice(usb_device device
, DeviceInfo
& devInfo
);
45 virtual ~ASIXDevice();
47 status_t
InitCheck() { return fStatus
; };
49 status_t
Open(uint32 flags
);
50 bool IsOpen() { return fOpen
; };
55 status_t
Read(uint8
*buffer
, size_t *numBytes
);
56 status_t
Write(const uint8
*buffer
, size_t *numBytes
);
57 status_t
Control(uint32 op
, void *buffer
, size_t length
);
60 bool IsRemoved() { return fRemoved
; };
62 status_t
CompareAndReattach(usb_device device
);
63 virtual status_t
SetupDevice(bool deviceReplugged
);
66 static void _ReadCallback(void *cookie
, int32 status
,
67 void *data
, size_t actualLength
);
68 static void _WriteCallback(void *cookie
, int32 status
,
69 void *data
, size_t actualLength
);
70 static void _NotifyCallback(void *cookie
, int32 status
,
71 void *data
, size_t actualLength
);
73 status_t
_SetupEndpoints();
77 virtual status_t
StartDevice() = 0;
78 virtual status_t
StopDevice();
79 virtual status_t
OnNotify(uint32 actualLength
) = 0;
80 virtual status_t
GetLinkState(ether_link_state
*state
) = 0;
81 virtual status_t
SetPromiscuousMode(bool bOn
);
82 uint32
EthernetCRC32(const uint8
* buffer
, size_t length
);
83 virtual status_t
ModifyMulticastTable(bool add
,
84 ether_address_t
* group
);
85 virtual status_t
ReadMACAddress(ether_address_t
*address
);
86 status_t
ReadRXControlRegister(uint16
*rxcontrol
);
87 status_t
WriteRXControlRegister(uint16 rxcontrol
);
91 DeviceInfo fDeviceInfo
;
92 ether_address_t fMACAddress
;
102 // interface and device infos
105 // pipes for notifications and data io
106 usb_pipe fNotifyEndpoint
;
107 usb_pipe fReadEndpoint
;
108 usb_pipe fWriteEndpoint
;
110 // data stores for async usb transfers
111 uint32 fActualLengthRead
;
112 uint32 fActualLengthWrite
;
115 sem_id fNotifyReadSem
;
116 sem_id fNotifyWriteSem
;
118 uint8
* fNotifyBuffer
;
119 uint32 fNotifyBufferLength
;
120 sem_id fLinkStateChangeSem
;
128 uint8 fReadNodeIDRequest
;
129 Vector
<uint32
> fMulticastHashes
;
132 #endif // _USB_ASIX_DEVICE_H_