From owner-freebsd-usb@FreeBSD.ORG Thu Feb 5 08:17:43 2015 Return-Path: Delivered-To: freebsd-usb@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id A40B5FF0 for ; Thu, 5 Feb 2015 08:17:43 +0000 (UTC) Received: from pzwet.vanderzwet.net (pzwet.vanderzwet.net [IPv6:2a01:4f8:190:8221::1:1]) by mx1.freebsd.org (Postfix) with ESMTP id 328A32EF for ; Thu, 5 Feb 2015 08:17:42 +0000 (UTC) Received: from [192.168.178.55] (5ED2ABEE.cm-7-3c.dynamic.ziggo.nl [94.210.171.238]) by pzwet.vanderzwet.net (Postfix) with ESMTPSA id 72323AF2BE6 for ; Thu, 5 Feb 2015 08:17:40 +0000 (UTC) Message-ID: <54D32724.60307@rickvanderzwet.nl> Date: Thu, 05 Feb 2015 09:17:40 +0100 From: Rick van der Zwet User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: freebsd-usb@freebsd.org Subject: Realtek RTL8152 driver attempt Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham autolearn_force=no version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pzwet.vanderzwet.net X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Feb 2015 08:17:43 -0000 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@vbsd101 /usr/src]# usbconfig -d ugen1.2 dump_device_desc ugen1.2: 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 iProduct = 0x0002 iSerialNumber = 0x0003 <64D1A3318180> bNumConfigurations = 0x0002 [root@vbsd101 /usr/src]# usbconfig -d ugen1.2 dump_all_config_desc ugen1.2: 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 bmAttributes = 0x00a0 bMaxPower = 0x0032 Interface 0 bLength = 0x0009 bDescriptorType = 0x0004 bInterfaceNumber = 0x0000 bAlternateSetting = 0x0000 bNumEndpoints = 0x0003 bInterfaceClass = 0x00ff bInterfaceSubClass = 0x00ff bInterfaceProtocol = 0x0000 iInterface = 0x0000 Endpoint 0 bLength = 0x0007 bDescriptorType = 0x0005 bEndpointAddress = 0x0081 bmAttributes = 0x0002 wMaxPacketSize = 0x0200 bInterval = 0x0000 bRefresh = 0x0000 bSynchAddress = 0x0000 Endpoint 1 bLength = 0x0007 bDescriptorType = 0x0005 bEndpointAddress = 0x0002 bmAttributes = 0x0002 wMaxPacketSize = 0x0200 bInterval = 0x0000 bRefresh = 0x0000 bSynchAddress = 0x0000 Endpoint 2 bLength = 0x0007 bDescriptorType = 0x0005 bEndpointAddress = 0x0083 bmAttributes = 0x0003 wMaxPacketSize = 0x0002 bInterval = 0x0008 bRefresh = 0x0000 bSynchAddress = 0x0000 Configuration index 1 bLength = 0x0009 bDescriptorType = 0x0002 wTotalLength = 0x0050 bNumInterfaces = 0x0002 bConfigurationValue = 0x0002 iConfiguration = 0x0000 bmAttributes = 0x00a0 bMaxPower = 0x0032 Interface 0 bLength = 0x0009 bDescriptorType = 0x0004 bInterfaceNumber = 0x0000 bAlternateSetting = 0x0000 bNumEndpoints = 0x0001 bInterfaceClass = 0x0002 bInterfaceSubClass = 0x0006 bInterfaceProtocol = 0x0000 iInterface = 0x0005 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 bmAttributes = 0x0003 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 Interface 1 Alt 1 bLength = 0x0009 bDescriptorType = 0x0004 bInterfaceNumber = 0x0001 bAlternateSetting = 0x0001 bNumEndpoints = 0x0002 bInterfaceClass = 0x000a bInterfaceSubClass = 0x0000 bInterfaceProtocol = 0x0000 iInterface = 0x0004 Endpoint 0 bLength = 0x0007 bDescriptorType = 0x0005 bEndpointAddress = 0x0081 bmAttributes = 0x0002 wMaxPacketSize = 0x0200 bInterval = 0x0000 bRefresh = 0x0000 bSynchAddress = 0x0000 Endpoint 1 bLength = 0x0007 bDescriptorType = 0x0005 bEndpointAddress = 0x0002 bmAttributes = 0x0002 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@vbsd101 /usr/src]# usbconfig -d ugen1.2 set_config 1 [root@vbsd101 /usr/src]# tail -4 /var/log/messages Feb 5 08:58:12 vbsd101 kernel: cdce0: on usbus1 Feb 5 08:58:12 vbsd101 kernel: ue0: 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@vbsd101 /usr/src]# ifconfig ue0 ue0: flags=8843 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 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