1 <!-- Copyright (C) 2001 Red Hat, Inc. -->
2 <!-- This material may be distributed only subject to the terms -->
3 <!-- and conditions set forth in the Open Publication License, v1.0 -->
4 <!-- or later (the latest version is presently available at -->
5 <!-- http://www.opencontent.org/openpub/). -->
6 <!-- Distribution of substantively modified versions of this -->
7 <!-- document is prohibited without the explicit permission of the -->
8 <!-- copyright holder. -->
9 <!-- Distribution of the work or derivative of the work in any -->
10 <!-- standard (paper) book form is prohibited unless prior -->
11 <!-- permission is obtained from the copyright holder. -->
15 >Communication Protocol</TITLE
18 CONTENT="Modular DocBook HTML Stylesheet Version 1.64
21 TITLE="eCos Support for Developing USB-ethernet Peripherals"
22 HREF="io-usb-slave-eth.html"><LINK
24 TITLE="Example Host-side Device Driver"
25 HREF="usbseth-host.html"></HEAD
44 >eCos Support for Developing USB-ethernet Peripherals</TH
52 HREF="usbseth-host.html"
72 NAME="USBSETH-PROTOCOL"
73 >Communication Protocol</A
82 >Communication Protocol -- Protocol used between the host-side device driver and the eCos
83 USB-ethernet package </DIV
92 >There is a USB standard for the protocol to be used between the host
93 and a class of communication devices, including ethernet. However, the
94 eCos USB-ethernet package does not implement this protocol: the target
95 hardware for which the package was first developed had certain
96 limitations, and could not implement the standard. Instead, the package
97 implements a simple new protocol.</P
99 >A USB-ethernet peripheral involves bulk transfers on two endpoints:
100 one endpoint will be used for packets from host to peripheral and the
101 other will be used for the opposite direction. Transfers in both
102 directions are variable length, with a lower limit of 16 bytes and an
103 upper limit of 1516 bytes. The first two bytes of each transfer
104 constitute a header specific to USB-ethernet. The next 14 bytes form
105 the normal header for an ethernet frame: destination MAC address,
106 source MAC address, and a protocol field. The remaining data, up to
107 1500 bytes, are the payload. The first two bytes give the size of the
108 ethernet frame, least significant byte first, with a value between 14
111 >For example an ARP request from host to peripheral involves an
112 ethernet frame of 42 bytes (0x002A), with the usual 14-byte header and
113 a 28-byte payload. The destination is the broadcast address
114 0xFFFFFFFFFFFF. The source depends on the MAC address specified for
115 the host in the call to <A
116 HREF="usbseth-init.html"
122 0x405D90A9BC02. The remaining data is as specified by the appropriate
124 HREF="http://www.ietf.org"
128 USB transfer involves the following sequence of 44 bytes:</P
137 >2a 00 ff ff ff ff ff ff 40 5d 90 a9 bc 02 08 06
138 00 01 08 00 06 04 00 01 40 5d 90 a9 bc 02 0a 00
139 00 01 00 00 00 00 00 00 0a 00 00 02</PRE
144 >In addition there are two control messages. These will be sent by the
145 host to endpoint 0, the control endpoint, and by default they will
147 HREF="usbseth-control.html"
150 >usbs_eth_class_control_handler</TT
153 control messages are intercepted by other code then it is the
154 responsibility of that code to invoke the USB-ethernet handler when
157 >The first control message can be used by the host to obtain a MAC
166 CLASS="PROGRAMLISTING"
167 >#define ECOS_USBETH_CONTROL_GET_MAC_ADDRESS 0x01</PRE
172 >The control message's type field should specify IN as the direction.
173 The request field should be <TT
177 should specify a size of 6 bytes. The remaining fields of the control
178 message will be ignored by the USB-ethernet package. The response
179 consists of the 6-byte MAC address supplied by the initialization call
181 HREF="usbseth-init.html"
188 >The second control message can be used by the host to enable or
189 disable promiscuous mode.</P
197 CLASS="PROGRAMLISTING"
198 >#define ECOS_USBETH_CONTROL_SET_PROMISCUOUS_MODE 0x02</PRE
203 >This control message involves no further data so the length field
204 should be set to 0. The value field should be non-zero to enable
205 promiscuous mode, zero to disable it. The request field should be
209 >. The remaining fields in the control message
210 will be ignored. It is the responsibility of the host-side device
211 driver to keep track of whether or not promiscuous mode is currently
212 enabled. It will be disabled when the peripheral changes to
213 Configured state, typically at the point where the host-side device
214 driver has been activated.</P
231 HREF="usbseth-host.html"
239 HREF="io-usb-slave-eth.html"
253 >Example Host-side Device Driver</TD