]> git.karo-electronics.de Git - linux-beck.git/commitdiff
usb: gadget: u_ether: prepare for NCM
authorYauheni Kaliuta <yauheni.kaliuta@nokia.com>
Wed, 8 Dec 2010 11:12:04 +0000 (13:12 +0200)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 10 Dec 2010 22:29:42 +0000 (14:29 -0800)
NCM is a Network Control Model, subclass of USB CDC class,
specification is available at http://www.usb.org/developers/devclass_docs

This patch makes possible for u_ether to use multiply of wMaxPacketSize
predefined size transfers without ZLP (Zero Length Packet), required
by NCM spec.

Signed-off-by: Yauheni Kaliuta <yauheni.kaliuta@nokia.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/gadget/u_ether.c
drivers/usb/gadget/u_ether.h

index cb23355f52d3d8b5335dbdf1e5b07a32c77b281a..a7826a6dcd8cfe0c16cab3a3a41efcc72c617a45 100644 (file)
@@ -240,6 +240,9 @@ rx_submit(struct eth_dev *dev, struct usb_request *req, gfp_t gfp_flags)
        size += out->maxpacket - 1;
        size -= size % out->maxpacket;
 
+       if (dev->port_usb->is_fixed)
+               size = max(size, dev->port_usb->fixed_out_len);
+
        skb = alloc_skb(size + NET_IP_ALIGN, gfp_flags);
        if (skb == NULL) {
                DBG(dev, "no rx skb\n");
@@ -578,12 +581,19 @@ static netdev_tx_t eth_start_xmit(struct sk_buff *skb,
        req->context = skb;
        req->complete = tx_complete;
 
+       /* NCM requires no zlp if transfer is dwNtbInMaxSize */
+       if (dev->port_usb->is_fixed &&
+           length == dev->port_usb->fixed_in_len &&
+           (length % in->maxpacket) == 0)
+               req->zero = 0;
+       else
+               req->zero = 1;
+
        /* use zlp framing on tx for strict CDC-Ether conformance,
         * though any robust network rx path ignores extra padding.
         * and some hardware doesn't like to write zlps.
         */
-       req->zero = 1;
-       if (!dev->zlp && (length % in->maxpacket) == 0)
+       if (req->zero && !dev->zlp && (length % in->maxpacket) == 0)
                length++;
 
        req->length = length;
index 3c8c0c9f9d728dd7730ae4335a3f68a410adfbbf..75219708abb8c7daaeecdaacdf3fc5396fe898c5 100644 (file)
@@ -62,6 +62,10 @@ struct gether {
 
        /* hooks for added framing, as needed for RNDIS and EEM. */
        u32                             header_len;
+       /* NCM requires fixed size bundles */
+       bool                            is_fixed;
+       u32                             fixed_out_len;
+       u32                             fixed_in_len;
        struct sk_buff                  *(*wrap)(struct gether *port,
                                                struct sk_buff *skb);
        int                             (*unwrap)(struct gether *port,