Realtek RTL8152 driver attempt
Rick van der Zwet
info at rickvanderzwet.nl
Thu Feb 5 08:17:43 UTC 2015
Hi Folks,
I have been trying to write a FreeBSD driver (if_rtl) for the Realtek
RTL8152 chipset, which is a USB to Ethernet dongle (using the Sitecom
LN-030 v3).
Some more details on the device:
[root at vbsd101 /usr/src]# usbconfig -d ugen1.2 dump_device_desc
ugen1.2: <USB 10100 LAN Realtek> at usbus1, cfg=0 md=HOST spd=HIGH
(480Mbps) pwr=ON (100mA)
bLength = 0x0012
bDescriptorType = 0x0001
bcdUSB = 0x0210
bDeviceClass = 0x0000
bDeviceSubClass = 0x0000
bDeviceProtocol = 0x0000
bMaxPacketSize0 = 0x0040
idVendor = 0x0bda
idProduct = 0x8152
bcdDevice = 0x2000
iManufacturer = 0x0001 <Realtek>
iProduct = 0x0002 <USB 10/100 LAN>
iSerialNumber = 0x0003 <64D1A3318180>
bNumConfigurations = 0x0002
[root at vbsd101 /usr/src]# usbconfig -d ugen1.2 dump_all_config_desc
ugen1.2: <USB 10100 LAN Realtek> at usbus1, cfg=0 md=HOST spd=HIGH
(480Mbps) pwr=ON (100mA)
Configuration index 0
bLength = 0x0009
bDescriptorType = 0x0002
wTotalLength = 0x0027
bNumInterfaces = 0x0001
bConfigurationValue = 0x0001
iConfiguration = 0x0000 <no string>
bmAttributes = 0x00a0
bMaxPower = 0x0032
Interface 0
bLength = 0x0009
bDescriptorType = 0x0004
bInterfaceNumber = 0x0000
bAlternateSetting = 0x0000
bNumEndpoints = 0x0003
bInterfaceClass = 0x00ff
bInterfaceSubClass = 0x00ff
bInterfaceProtocol = 0x0000
iInterface = 0x0000 <no string>
Endpoint 0
bLength = 0x0007
bDescriptorType = 0x0005
bEndpointAddress = 0x0081 <IN>
bmAttributes = 0x0002 <BULK>
wMaxPacketSize = 0x0200
bInterval = 0x0000
bRefresh = 0x0000
bSynchAddress = 0x0000
Endpoint 1
bLength = 0x0007
bDescriptorType = 0x0005
bEndpointAddress = 0x0002 <OUT>
bmAttributes = 0x0002 <BULK>
wMaxPacketSize = 0x0200
bInterval = 0x0000
bRefresh = 0x0000
bSynchAddress = 0x0000
Endpoint 2
bLength = 0x0007
bDescriptorType = 0x0005
bEndpointAddress = 0x0083 <IN>
bmAttributes = 0x0003 <INTERRUPT>
wMaxPacketSize = 0x0002
bInterval = 0x0008
bRefresh = 0x0000
bSynchAddress = 0x0000
Configuration index 1
bLength = 0x0009
bDescriptorType = 0x0002
wTotalLength = 0x0050
bNumInterfaces = 0x0002
bConfigurationValue = 0x0002
iConfiguration = 0x0000 <no string>
bmAttributes = 0x00a0
bMaxPower = 0x0032
Interface 0
bLength = 0x0009
bDescriptorType = 0x0004
bInterfaceNumber = 0x0000
bAlternateSetting = 0x0000
bNumEndpoints = 0x0001
bInterfaceClass = 0x0002
bInterfaceSubClass = 0x0006
bInterfaceProtocol = 0x0000
iInterface = 0x0005 <CDC Communications Control>
Additional Descriptor
bLength = 0x05
bDescriptorType = 0x24
bDescriptorSubType = 0x00
RAW dump:
0x00 | 0x05, 0x24, 0x00, 0x10, 0x01
Additional Descriptor
bLength = 0x05
bDescriptorType = 0x24
bDescriptorSubType = 0x06
RAW dump:
0x00 | 0x05, 0x24, 0x06, 0x00, 0x01
Additional Descriptor
bLength = 0x0d
bDescriptorType = 0x24
bDescriptorSubType = 0x0f
RAW dump:
0x00 | 0x0d, 0x24, 0x0f, 0x03, 0x00, 0x00, 0x00, 0x00,
0x08 | 0xea, 0x05, 0x00, 0x00, 0x00
Endpoint 0
bLength = 0x0007
bDescriptorType = 0x0005
bEndpointAddress = 0x0083 <IN>
bmAttributes = 0x0003 <INTERRUPT>
wMaxPacketSize = 0x0010
bInterval = 0x0008
bRefresh = 0x0000
bSynchAddress = 0x0000
Interface 1
bLength = 0x0009
bDescriptorType = 0x0004
bInterfaceNumber = 0x0001
bAlternateSetting = 0x0000
bNumEndpoints = 0x0000
bInterfaceClass = 0x000a
bInterfaceSubClass = 0x0000
bInterfaceProtocol = 0x0000
iInterface = 0x0000 <no string>
Interface 1 Alt 1
bLength = 0x0009
bDescriptorType = 0x0004
bInterfaceNumber = 0x0001
bAlternateSetting = 0x0001
bNumEndpoints = 0x0002
bInterfaceClass = 0x000a
bInterfaceSubClass = 0x0000
bInterfaceProtocol = 0x0000
iInterface = 0x0004 <Ethernet Data>
Endpoint 0
bLength = 0x0007
bDescriptorType = 0x0005
bEndpointAddress = 0x0081 <IN>
bmAttributes = 0x0002 <BULK>
wMaxPacketSize = 0x0200
bInterval = 0x0000
bRefresh = 0x0000
bSynchAddress = 0x0000
Endpoint 1
bLength = 0x0007
bDescriptorType = 0x0005
bEndpointAddress = 0x0002 <OUT>
bmAttributes = 0x0002 <BULK>
wMaxPacketSize = 0x0200
bInterval = 0x0000
bRefresh = 0x0000
bSynchAddress = 0x0000
Unfortunately there is no datasheet available, I quote ``` Due to
company policy, we only release Datasheet to our ODM/OEM (which have
signed a company to company NDA with Realtek). Please follow the linux
source code for porting, thanks.''' so I am stuck with 'reverse'
engineering and best guessing.
When looking at the usb trace on Linux with wireshark
(https://rickvanderzwet.nl/svn/personal/freebsd-rtl-driver/linux-trace.pcapng.gz)
I see a "CDC" like packets passing by, the description of the chipset
also hints something in this way: "Supports CDC-ECM".
[root at vbsd101 /usr/src]# usbconfig -d ugen1.2 set_config 1
[root at vbsd101 /usr/src]# tail -4 /var/log/messages
Feb 5 08:58:12 vbsd101 kernel: cdce0: <CDC Communications Control> on
usbus1
Feb 5 08:58:12 vbsd101 kernel: ue0: <USB Ethernet> on cdce0
Feb 5 08:58:12 vbsd101 kernel: ue0: Ethernet address: 64:d1:a3:31:81:80
Feb 5 08:58:12 vbsd101 devd: Executing '/etc/pccard_ether ue0 start'
[root at vbsd101 /usr/src]# ifconfig ue0
ue0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
ether 64:d1:a3:31:81:80
inet 192.168.5.200 netmask 0xffffff00 broadcast 192.168.5.255
nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
How-ever there is no traffic possible and also no bulk requests are done.
Looking at the if_rue(4) and the linux r8152.c code, basically I got
this far in porting but yet no working code:
https://rickvanderzwet.nl/svn/personal/freebsd-rtl-driver/
There are no bulk out and in packets passing trough, so I am basically
stuck now, not knowing how-to continue this journey. Could anybody give
me an hint on how-to get this train going again?
Thanks in advance!
/Rick
More information about the freebsd-usb
mailing list