From: Ben Chan <benchan-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
To: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Oliver Neukum <oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org>
Cc: "Greg Kroah-Hartman"
<gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org>,
"Bjørn Mork" <bjorn-yOkvZcmFvRU@public.gmane.org>,
"Greg Suarez" <gsuarez-AKjrjAf1O7qe8kRwQpwjMg@public.gmane.org>
Subject: [PATCH 2/2] net: cdc_ncm: respect operator preferred MTU reported by MBIM
Date: Sat, 15 Mar 2014 23:49:10 -0700 [thread overview]
Message-ID: <1394952550-9308-2-git-send-email-benchan@chromium.org> (raw)
In-Reply-To: <1394952550-9308-1-git-send-email-benchan-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
According to "Universal Serial Bus Communications Class Subclass
Specification for Mobile Broadband Interface Model, Revision 1.0,
Errata-1" published by USB-IF, the wMTU field of the MBIM extended
functional descriptor indicates the operator preferred MTU for IP data
streams.
This patch modifies cdc_ncm_setup to ensure that the MTU value set on
the usbnet device does not exceed the operator preferred MTU indicated
by wMTU if the MBIM device exposes a MBIM extended functional
descriptor.
Signed-off-by: Ben Chan <benchan-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
---
drivers/net/usb/cdc_ncm.c | 15 +++++++++++++++
include/linux/usb/cdc_ncm.h | 1 +
2 files changed, 16 insertions(+)
diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index dbff290..0b036ed 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -261,6 +261,13 @@ out:
/* set MTU to max supported by the device if necessary */
if (dev->net->mtu > ctx->max_datagram_size - eth_hlen)
dev->net->mtu = ctx->max_datagram_size - eth_hlen;
+
+ /* do not exceed operater preferred MTU */
+ if (ctx->mbim_extended_desc &&
+ ctx->mbim_extended_desc->wMTU != 0 &&
+ dev->net->mtu > ctx->mbim_extended_desc->wMTU)
+ dev->net->mtu = ctx->mbim_extended_desc->wMTU;
+
return 0;
}
@@ -399,6 +406,14 @@ int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_
ctx->mbim_desc = (const struct usb_cdc_mbim_desc *)buf;
break;
+ case USB_CDC_MBIM_EXTENDED_TYPE:
+ if (buf[0] < sizeof(*(ctx->mbim_extended_desc)))
+ break;
+
+ ctx->mbim_extended_desc =
+ (const struct usb_cdc_mbim_extended_desc *)buf;
+ break;
+
default:
break;
}
diff --git a/include/linux/usb/cdc_ncm.h b/include/linux/usb/cdc_ncm.h
index c3fa807..bdf05fb 100644
--- a/include/linux/usb/cdc_ncm.h
+++ b/include/linux/usb/cdc_ncm.h
@@ -93,6 +93,7 @@ struct cdc_ncm_ctx {
const struct usb_cdc_ncm_desc *func_desc;
const struct usb_cdc_mbim_desc *mbim_desc;
+ const struct usb_cdc_mbim_extended_desc *mbim_extended_desc;
const struct usb_cdc_ether_desc *ether_desc;
struct usb_interface *control;
--
1.9.0.279.gdc9e3eb
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2014-03-16 6:49 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-16 6:49 [PATCH 1/2] USB: cdc: add MBIM extended functional descriptor structure Ben Chan
[not found] ` <1394952550-9308-1-git-send-email-benchan-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2014-03-16 6:49 ` Ben Chan [this message]
2014-03-17 9:42 ` [PATCH 2/2] net: cdc_ncm: respect operator preferred MTU reported by MBIM Bjørn Mork
2014-03-17 19:11 ` Ben Chan
2014-03-17 21:27 ` Bjørn Mork
2014-03-18 0:46 ` Ben Chan
2014-03-18 1:41 ` David Miller
2014-03-18 4:00 ` Ben Chan
2014-03-19 20:04 ` David Miller
2014-03-17 23:07 ` [PATCH 1/2] USB: cdc: add MBIM extended functional descriptor structure Greg Kroah-Hartman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1394952550-9308-2-git-send-email-benchan@chromium.org \
--to=benchan-f7+t8e8rja9g9huczpvpmw@public.gmane.org \
--cc=bjorn-yOkvZcmFvRU@public.gmane.org \
--cc=gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org \
--cc=gsuarez-AKjrjAf1O7qe8kRwQpwjMg@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).