55#define USBETH_TRACE( x, y ... ) xprintf( x, ##y )
57#define USBETH_TRACE( x, y ... ) ((void)0)
63#define ALIGN(n,align) (((n)+((align)-1)) & ~((align)-1))
65#define usb_dma_alloc(n) (KMALLOC(ALIGN((n),CACHE_ALIGN),CACHE_ALIGN))
66#define usb_dma_free(p) (KFREE(p))
77static void hexdump(
unsigned char *src,
int srclen,
int rowlen,
int rows )
79 unsigned char *rowptr;
80 unsigned char *srcstp;
81 unsigned char *byteptr;
83 srcstp = src + srclen;
85 for( rowptr = src; rowptr < src + rowlen * rows; rowptr += rowlen ) {
86 for( byteptr = rowptr; byteptr < rowptr + rowlen && byteptr < srcstp; byteptr++ ) {
94#define hexdump(src,srclen,rowlen,rows) ((void)0)
103static const char *VENDOR_NAMES[] = {
104 "?",
"Linksys-100M",
"Yikes!"
107static const int ID_TBL[] = {
127static int rtek_send_eth_frame(
void *ctx,
hsaddr_t buf,
int len );
128static int rtek_get_eth_frame(
void *ctx,
hsaddr_t buf );
129static int rtek_data_rx(
void *ctx );
130static int rtek_get_dev_addr(
void *ctx,
hsaddr_t mac_addr );
157 return rtek_get_reg( dev,
R_RTEK_MAC, mac_addr, 6 );
164 const int *
ptr=ID_TBL;
174 while( *
ptr != -1 ) {
175 if( (vendor_id ==
ptr[0]) && (product_id ==
ptr[1]) ) {
182 xprintf(
"Unrecognized Realtek USB-Ethernet device\n" );
188 for( i = 0; i < 10; ++i ) {
197 for( i = 0; i < 50; ++i ) {
205 rtek_get_mac_addr( dev, softc->
mac_addr );
208 xprintf(
"%s USB-Ethernet Adapter (%a)\n",
214static int rtek_get_dev_addr(
void *ctx,
hsaddr_t mac_addr )
217 hs_memcpy_to_hs( mac_addr, softc->
mac_addr, 6 );
229static int rtek_data_rx(
void *ctx )
236static int rtek_get_eth_frame(
void *ctx,
hsaddr_t buf )
243 rxbuf = softc->
rxbuf;
247 xprintf(
"Incoming packet :\n" );
248 hexdump( rxbuf, len, 16, len / 16 + 1 );
250 hs_memcpy_to_hs( buf, rxbuf, len );
253 rtek_queue_rx( softc );
256 xprintf(
"Bulk data is not available yet!\n" );
261static int rtek_send_eth_frame(
void *ctx,
hsaddr_t buf,
int len )
266 unsigned char *txbuf;
271 else if( !(txlen % 64) )
275 hs_memcpy_from_hs( txbuf, buf, txlen );
278 xprintf(
"Outgoing packet :\n" );
279 hexdump( txbuf, txlen, 16, txlen / 16 + 1 );
299 rtek_queue_rx( softc );
346 if( softc ==
NULL ) {
347 xprintf(
"Failed to allocate softc memory.\n" );
355 if (ifdscr ==
NULL) {
356 xprintf(
"USBETH: ERROR...no interace descriptor\n");
360 for (idx = 0; idx < 2; idx++) {
368 if (!indscr || !outdscr) {
373 xprintf(
"USBETH: ERROR...no endpoint descriptors\n");
381 if (rtek_init_device(softc) < 0)
392 rtek_open_device( softc );
412static int rtek_detach(
usbdev_t *dev)
418 rtek_close_device( softc );
#define hexdump(src, srclen, rowlen, rows)
struct rtek_softc_s rtek_softc_t
usb_driver_t usbrtek_driver
const cfe_driver_t usbrtekdrv
#define KMALLOC(size, align)
uint8_t bConfigurationValue
usb_config_descr_t * ud_cfgdescr
#define USBREQ_TYPE_VENDOR
#define USB_ENDPOINT_DESCRIPTOR_TYPE
#define USB_ENDPOINT_DIR_OUT(addr)
#define USB_INTERFACE_DESCRIPTOR_TYPE
void * usb_find_cfg_descr(usbdev_t *dev, int dtype, int idx)
int usb_std_request(usbdev_t *dev, uint8_t bmRequestType, uint8_t bRequest, uint16_t wValue, uint16_t wIndex, uint8_t *buffer, int length)
int usb_sync_request(usbreq_t *ur)
usbreq_t * usb_make_request(usbdev_t *dev, int epaddr, uint8_t *buf, int length, int flags)
void usb_free_request(usbreq_t *ur)
void usb_poll(usbbus_t *bus)
int usb_queue_request(usbreq_t *ur)
int usb_get_device_descriptor(usbdev_t *dev, usb_device_descr_t *dscr, int smallflg)
void usb_delay_ms(usbbus_t *bus, int ms)
int usb_set_configuration(usbdev_t *dev, int config)
int usb_open_pipe(usbdev_t *dev, usb_endpoint_descr_t *epdesc)
int usbeth_register(usbeth_disp_t *disp, void *softc)
void usbeth_unregister(void *softc)