Usbethernet data transfers, Name, Synopsis – Comtrol eCos User Manual

Page 735: Description, Usb-ethernet data transfers, Data transfer

Advertising
background image

USB-ethernet Data Transfers

Name

USB-ethernet Data Transfers

— Exchanging ethernet packets with the USB host

Synopsis

#include

<

cyg/io/usb/usbs_eth.h

>

void usbs_eth_start_rx(usbs_eth* usbseth, unsigned char* buffer, void (*)(usbs_eth*,

void*, int) complete_fn, void* complete_data);

void usbs_eth_start_tx(usbs_eth* usbseth, unsigned char* buffer, void (*)(usbs_eth*,

void*, int) complete_fn, void* complete_data);

Description

The USB-ethernet package provides two main modes of operation. In the first mode it provides a

network de-

vice driver

for use by a TCP/IP stack running inside the USB peripheral. All incoming ethernet packages should

be passed up the TCP/IP stack, and only the stack will generate outgoing packets. Apart from

initialization

and

possibly certain

control operations

, higher-level code will not interact with the USB-ethernet package directly.

In the second mode there is no TCP/IP stack running inside the USB peripheral. For example, a simple USB-
ethernet converter has an ethernet chip and a USB port: ethernet packets received by the ethernet chip need to be
forwarded to the USB host, and ethernet packets sent by the USB host need to be sent out of the ethernet chip.

usbs_eth_start_rx

and

usbs_eth_start_tx

allow for this lower-level access to the USB-ethernet package.

The two modes of operation are mutually exclusive. If the network device driver mode is enabled then application
code should communicate at the TCP/IP level, and not by using the lower-level functions. Instead, it is the network
device driver that will make use of these functions, and it assumes that it has exclusive access. The package does
not perform any locking.

The transmit and receive functions work in much the same way. The first argument identifies the usbs_eth structure
that should be used. For the majority of applications this will be

usbs_eth0

. The second argument specifies the

location of the ethernet packet; outgoing for

usbs_eth_start_tx

and incoming for

usbs_eth_start_rx

. This

buffer should correspond to the

protocol

:

1. Outgoing packets can consist of up to 1516 bytes, consisting of a two-byte header specific to USB-ethernet

followed by a standard ethernet frame (a header with 6-byte destination address, 6-byte source address and
a further two bytes, followed by a payload of up to 1500 bytes). The two-byte USB-ethernet header consists
simply of the size of the ethernet frame, i.e. the size of the rest of the packet not including the USB-ethernet
header, with the least significant byte first.

2. For incoming packets the supplied buffer should usually be at least 1516 bytes. There may be special cir-

cumstances in which a smaller buffer might be safe; for example, if the host-side device driver is modified
to support only smaller packets. Once the packet has been received the buffer will contain a two-byte header
specific to USB-ethernet, followed by a normal ethernet frame. The header gives the size of the ethernet frame,
excluding the header, with the least significant byte first.

631

Advertising