netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* PATCH:  usbnet: doc updates
@ 2010-09-06  0:06 David Brownell
  2010-09-06  0:12 ` David Miller
  0 siblings, 1 reply; 7+ messages in thread
From: David Brownell @ 2010-09-06  0:06 UTC (permalink / raw)
  To: netdev; +Cc: Ondrej Zary

[-- Attachment #1: Type: text/plain, Size: 135 bytes --]

Apologies in advance for sending this as an
attachment, but I think it's less likely to get
angled (except quoted-printable?) this way.

[-- Attachment #2: rxfix --]
[-- Type: application/octet-stream, Size: 2461 bytes --]

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Subject: usbnet: doc updates

Provide more documentation about the rx_fixup() calling convention,
to help reduce some recently-observed confusion.

Also summarize the equivalence of USB and network TX/RX queues, to
help highlight the roles of the fixup() routines with link protocols
using the CPU-intensive packet batching models.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
---


 include/linux/usb/usbnet.h |   30 ++++++++++++++++++++++++++++--
 1 file changed, 28 insertions(+), 2 deletions(-)

--- a/include/linux/usb/usbnet.h
+++ b/include/linux/usb/usbnet.h
@@ -22,8 +22,20 @@
 #ifndef	__LINUX_USB_USBNET_H
 #define	__LINUX_USB_USBNET_H
 
-/* interface from usbnet core to each USB networking link we handle */
+/** interface from usbnet core to each USB networking link we handle
+ *
+ * Note that the design center for usbnet has one IEEE packet per URB, and
+maps network TX and RX queues directly to the USB hardware TX/RX queues,
+ * , minimizing software and hardware overhead.  Some link protocols
+ * (like RNDIS and CDC NCM) promote  less efficient designs which involve
+ * batching multiple IEEE packets in each URB, with increased TX overhead
+to copy IEEE packets into TX URBs' data buffer in tx_fixup() routines,
+plus unbatching work in rx_fixup() as well.  Sometimes the TX overhead can
+be minimized on Linux by not batching, but this usually won't work for RX
+because of the need to interoperate with implementations which batch on TX.
+ */
 struct usbnet {
+
 	/* housekeeping */
 	struct usb_device	*udev;
 	struct usb_interface	*intf;
@@ -121,7 +133,21 @@ struct driver_info {
 	/* link reset handling, called from defer_kevent */
 	int	(*link_reset)(struct usbnet *);
 
-	/* fixup rx packet (strip framing) */
+	/* fixup rx packet ( by stripping framing from URB/SKB.
+	 *
+	 - If SKB batches one or more packets, pass all but one of them
+	   up the stack (clone SKB and fixup each clone before netif_rx)).
+
+
+
+	 - When you leave one packet in SKB (intended usage), return
+	 nonzero and ensure skb-len is nonzero.  the packet will be passed
+	 up the network stack and accounted properly.
+
+	- return zero to indicate errors such as too much
+	header or data, or a bad checksum; the packet will be dropped
+	and accounted as an error.
+	*/
 	int	(*rx_fixup)(struct usbnet *dev, struct sk_buff *skb);
 
 	/* fixup tx packet (add framing) */

^ permalink raw reply	[flat|nested] 7+ messages in thread
* Re: PATCH: usbnet: doc updates
@ 2010-09-06  4:48 David Brownell
  2010-09-06  4:57 ` David Miller
  0 siblings, 1 reply; 7+ messages in thread
From: David Brownell @ 2010-09-06  4:48 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, linux

[-- Attachment #1: Type: text/plain, Size: 890 bytes --]

--- On Sun, 9/5/10, David Miller <davem@davemloft.net> wrote:

> From: David Miller <davem@davemloft.net>
> Subject: Re: PATCH: usbnet: doc updates
> To: david-b@pacbell.net
> Cc: netdev@vger.kernel.org, linux@rainbow-software.org
> Date: Sunday, September 5, 2010, 5:12 PM
> From: David Brownell <david-b@pacbell.net>
> Date: Sun, 5 Sep 2010 17:06:10 -0700 (PDT)
> 
> > Apologies in advance for sending this as an
> > attachment, but I think it's less likely to get
> > angled (except quoted-printable?) this way.
> 
> Well, patchwork didn't grok it at all, and this means your
> patch is a
> lot more work for me.

If I had my normal mail access, I'd send this
patch inline; but I don't.


> 
> Actually looking at the patch, the comment formatting is
> not all
> that pretty:


I guess you don't like

    /*
     preformatted text ...
    */

as a comment style.  Fixed in the attached.

[-- Attachment #2: rxfix --]
[-- Type: application/octet-stream, Size: 2492 bytes --]

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Subject: usbnet: doc updates

Provide more documentation about the rx_fixup() calling convention,
to help reduce some recently-observed confusion.

Also summarize the equivalence of USB and network TX/RX queues, to
help highlight the roles of the fixup() routines with link protocols
using the CPU-intensive packet batching models.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
---


 include/linux/usb/usbnet.h |   31 +++++++++++++++++++++++++++++--
 1 file changed, 29 insertions(+), 2 deletions(-)

--- a/include/linux/usb/usbnet.h
+++ b/include/linux/usb/usbnet.h
@@ -22,8 +22,22 @@
 #ifndef	__LINUX_USB_USBNET_H
 #define	__LINUX_USB_USBNET_H
 
-/* interface from usbnet core to each USB networking link we handle */
+/** interface from usbnet core to each USB networking link we handle.
+ *
+ * Note that the design center for usbnet has one IEEE packet per URB,
+ * and maps network TX and RX queues directly to the
+ * USB hardware TX/RX queues, minimizing software and hardware overhead.
+ * Some link protocols (like RNDIS and CDC NCM) promote  less efficient
+ * designs which involve batching multiple IEEE packets in each URB,
+ * with increased TX overhead to copy IEEE packets into TX URBs' data
+ * buffers in tx_fixup() routines, plus unbatching work in rx_fixup() too.
+ * Sometimes the TX overhead can be minimized on Linux by not batching, but
+ * this usually won't work for RX because of the need to interoperate with
+ * implementations which batch on TX.
+ */
+
 struct usbnet {
+
 	/* housekeeping */
 	struct usb_device	*udev;
 	struct usb_interface	*intf;
@@ -113,7 +127,20 @@ struct driver_info {
 	/* link reset handling, called from defer_kevent */
 	int	(*link_reset)(struct usbnet *);
 
-	/* fixup rx packet (strip framing) */
+	/* fixup rx packet ( by stripping framing from URB/SKB.
+	 *
+	 * If SKB batches one or more packets, pass all but one of them
+	 * up the stack (clone SKB and fixup each clone before netif_rx)).
+	 *
+
+	 * When you leave one packet in SKB (intended usage), return
+	 * nonzero and ensure skb-len is nonzero.  the packet will be
+	 * passed up the network stack and accounted properly.
+	 *
+	 * return zero to indicate errors such as too much header or
+	 * data, or a bad checksum; the packet will be dropped
+	 * and accounted as an error.
+	*/
 	int	(*rx_fixup)(struct usbnet *dev, struct sk_buff *skb);
 
 	/* fixup tx packet (add framing) */

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

end of thread, other threads:[~2010-09-06 19:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-06  0:06 PATCH: usbnet: doc updates David Brownell
2010-09-06  0:12 ` David Miller
2010-09-06  4:38   ` David Brownell
  -- strict thread matches above, loose matches on Subject: below --
2010-09-06  4:48 David Brownell
2010-09-06  4:57 ` David Miller
2010-09-06 18:28   ` David Brownell
2010-09-06 19:57     ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).