Overview
CDC EEM represents the "glue" between the USB domain and the Ethernet domain. The USB device stack along with the CDC EEM subclass is seen as the physical layer by the network stack. A simple driver is needed to interface the network stack to the CDC EEM subclass. shows the architecture and interactions of a network device using the CDC EEM subclass.
Buffer management
The CDC EEM subclass implementation offers a queuing mechanism for receive and transmit buffers.
Transmit buffers
The CDC EEM subclass allows the network driver to submit multiple transmit buffers. Once submitted by the network driver, a EEM header will be prepended in the first two bytes of the buffer. The CDC EEM subclass will then submit them through the Bulk IN endpoint in a First In First Out (FIFO) order. Once the transmission over the Bulk IN endpoint is completed, the buffer will be freed back to the network driver.
Receive buffers
The CDC EEM subclass will submit 1 to N buffers to the Bulk OUT endpoint in order to always be able to receive packets from the host. Using only one USB receive buffer will be enough, however not always optimal.
The number of buffers submitted to the USB device core can be configured. See CDC EEM Subclass Configuration for more information about how to configure the number of USB receive buffers.
Once an EEM message is received, the header is parsed. If it contains an Ethernet frame, a receive buffer is requested from the network driver. The content of the Ethernet frame is copied and the buffer is placed in the receive queue. Finally, the network driver is notified of the availability of a receive buffer and it will get it when possible. Note that if no receive buffer is available from the network stack at the moment of the reception, the packet will be lost.
The USB EEM receive buffers should NOT be confused with the receive buffers from the network stack. Having only one USB receive buffer is normally safe and appropriate for most of the applications. However, the number of network receive buffers should normally be larger as network stacks are likely to hold the buffers for a longer period of time before marking them as free.