public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* usbnet transmit path problems
@ 2013-09-11  9:10 David Laight
  2013-09-11 10:11 ` Oliver Neukum
  0 siblings, 1 reply; 10+ messages in thread
From: David Laight @ 2013-09-11  9:10 UTC (permalink / raw)
  To: netdev

I've been looking at the code in drivers/net/usb/usbnet.c that
processes tx data after the tx_fixup() function has run.

The code currently looks like:

	usb_fill_bulk_urb (urb, dev->udev, dev->out,
			skb->data, skb->len, tx_complete, skb);
	if (dev->can_dma_sg) {
		if (build_dma_sg(skb, urb) < 0)
			goto drop;
	}
	entry->length = length = urb->transfer_buffer_length;

	/* don't assume the hardware handles USB_ZERO_PACKET
	 * NOTE:  strictly conforming cdc-ether devices should expect
	 * the ZLP here, but ignore the one-byte packet.
	 * NOTE2: CDC NCM specification is different from CDC ECM when
	 * handling ZLP/short packets, so cdc_ncm driver will make short
	 * packet itself if needed.
	 */
	if (length % dev->maxpacket == 0) {
		if (!(info->flags & FLAG_SEND_ZLP)) {
			if (!(info->flags & FLAG_MULTI_PACKET)) {
				urb->transfer_buffer_length++;
				if (skb_tailroom(skb)) {
					skb->data[skb->len] = 0;
					__skb_put(skb, 1);
				}
			}
		} else
			urb->transfer_flags |= URB_ZERO_PACKET;
	}

1) I can't see where skb_linearize() gets called if 'can_dma_sg' is unset.

2) If 'length % dev->maxpacket == 0' for a multi-fragment packet then
   the extra byte isn't added correctly (the code probably falls off
   the end of the scatter-gather list).

3) If 'length % dev->maxpacket == 0' for a single-fragment packet then
   shouldn't there be a check that the skb isn't shared before modifying it?
   Also if there is no tailroom increasing the usb transfer length might
   result in reading an unmapped memory location.

Have I missed something, or is all this code in the wrong order?

4) I read that USB3 has a different scheme for terminating bulk data
   that is a multiple of the packet size.
   Does this mean that the pad byte isn't needed for USB3?
   (Or are USB3 controllers/targets just as buggy?)

	David

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2013-09-16 12:38 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-11  9:10 usbnet transmit path problems David Laight
2013-09-11 10:11 ` Oliver Neukum
2013-09-11 11:34   ` Ming Lei
2013-09-11 12:56     ` David Laight
2013-09-11 15:11       ` Ming Lei
     [not found]         ` <CACVXFVN6ZHLesrsMVNMWrikRs1mMbk=aZD9qZybNn1gB7aFTZQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-09-11 16:05           ` David Laight
2013-09-12  1:56             ` Ming Lei
     [not found]               ` <CACVXFVNrbeEthBH0vGKN2gymoSwu3jTkcGicKNU1-Oez8bNhvg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-09-16  8:13                 ` Oliver Neukum
     [not found]                   ` <1379319193.15916.1.camel-B2T3B9s34ElbnMAlSieJcQ@public.gmane.org>
2013-09-16 12:38                     ` Ming Lei
2013-09-11 13:00   ` David Laight

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox