Skip to content

Commit 5c1168d

Browse files
Yauheni Kaliutagregkh
authored andcommitted
usb: gadget: u_ether: prepare for NCM
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 <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent ff176a4 commit 5c1168d

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

drivers/usb/gadget/u_ether.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,9 @@ rx_submit(struct eth_dev *dev, struct usb_request *req, gfp_t gfp_flags)
240240
size += out->maxpacket - 1;
241241
size -= size % out->maxpacket;
242242

243+
if (dev->port_usb->is_fixed)
244+
size = max(size, dev->port_usb->fixed_out_len);
245+
243246
skb = alloc_skb(size + NET_IP_ALIGN, gfp_flags);
244247
if (skb == NULL) {
245248
DBG(dev, "no rx skb\n");
@@ -578,12 +581,19 @@ static netdev_tx_t eth_start_xmit(struct sk_buff *skb,
578581
req->context = skb;
579582
req->complete = tx_complete;
580583

584+
/* NCM requires no zlp if transfer is dwNtbInMaxSize */
585+
if (dev->port_usb->is_fixed &&
586+
length == dev->port_usb->fixed_in_len &&
587+
(length % in->maxpacket) == 0)
588+
req->zero = 0;
589+
else
590+
req->zero = 1;
591+
581592
/* use zlp framing on tx for strict CDC-Ether conformance,
582593
* though any robust network rx path ignores extra padding.
583594
* and some hardware doesn't like to write zlps.
584595
*/
585-
req->zero = 1;
586-
if (!dev->zlp && (length % in->maxpacket) == 0)
596+
if (req->zero && !dev->zlp && (length % in->maxpacket) == 0)
587597
length++;
588598

589599
req->length = length;

drivers/usb/gadget/u_ether.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ struct gether {
6262

6363
/* hooks for added framing, as needed for RNDIS and EEM. */
6464
u32 header_len;
65+
/* NCM requires fixed size bundles */
66+
bool is_fixed;
67+
u32 fixed_out_len;
68+
u32 fixed_in_len;
6569
struct sk_buff *(*wrap)(struct gether *port,
6670
struct sk_buff *skb);
6771
int (*unwrap)(struct gether *port,

0 commit comments

Comments
 (0)