[usb] Allow usb_stream() to enforce a terminating short packet

Some USB endpoints require that a short packet be used to terminate
transfers, since they have no other way to determine message
boundaries.  If the message length happens to be an exact multiple of
the USB packet size, then this requires the use of an additional
zero-length packet.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2015-02-10 13:45:57 +00:00
parent 17aceb34da
commit 58c3e7f747
5 changed files with 28 additions and 14 deletions

View File

@@ -145,7 +145,7 @@ static int ncm_rx_refill ( struct ncm_device *ncm, struct ncm_rx_ring *ring ) {
iob_put ( iobuf, ( ring->mtu - iob_len ( iobuf ) ) );
/* Enqueue I/O buffer */
if ( ( rc = usb_stream ( &ring->ep, iobuf ) ) != 0 ) {
if ( ( rc = usb_stream ( &ring->ep, iobuf, 0 ) ) != 0 ) {
DBGC ( ncm, "NCM %p could not enqueue %s: %s\n", ncm,
ncm_rx_name ( ncm, ring ), strerror ( rc ) );
/* Leave in recycled list and wait for next refill */
@@ -548,7 +548,7 @@ static int ncm_out_transmit ( struct ncm_device *ncm,
memset ( &header->desc[1], 0, sizeof ( header->desc[1] ) );
/* Enqueue I/O buffer */
if ( ( rc = usb_stream ( &ncm->out.ep, iobuf ) ) != 0 )
if ( ( rc = usb_stream ( &ncm->out.ep, iobuf, 0 ) ) != 0 )
return rc;
/* Increment sequence number */