All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next v4 0/2] adjust MTU as indicated by MBIM extended functional descriptor
@ 2014-03-19 21:00 Ben Chan
  2014-03-19 21:00 ` [PATCH net-next v4 1/2] USB: cdc: add MBIM extended functional descriptor structure Ben Chan
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Ben Chan @ 2014-03-19 21:00 UTC (permalink / raw)
  To: linux-kernel, linux-usb, netdev, Oliver Neukum
  Cc: Greg Kroah-Hartman, David Miller, Bjørn Mork, Greg Suarez

The MBIM extended functional descriptor, defined in "Universal Serial Bus
Communications Class Subclass Specification for Mobile Broadband Interface
Model, Revision 1.0, Errata-1" by USB-IF, indicates the operator preferred MTU
value via a wMTU field.

This patch set ensures that the initial MTU value set by cdc_ncm on a MBIM net
device does not exceed the wMTU value, provided the MBIM device exposes a MBIM
extended functional descriptor.

* Changelog
v2: Fixed a le16_to_cpu conversion issue in patch 2/2 pointed out by
    Bjørn Mork <bjorn@mork.no>
v3: No code changes. Resubmitted to include patch 1/2 as suggested by
    David Miller <davem@davemloft.net>
v4: No code changes. Resubmitted as suggested by David Miller:
    - Added a summary of the patch set
    - Carried the ACK from Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    - Added a specified the tree (net-next) to apply the patch set to

Ben Chan (2):
  USB: cdc: add MBIM extended functional descriptor structure
  net: cdc_ncm: respect operator preferred MTU reported by MBIM

 drivers/net/usb/cdc_ncm.c    | 17 +++++++++++++++++
 include/linux/usb/cdc_ncm.h  |  1 +
 include/uapi/linux/usb/cdc.h | 12 ++++++++++++
 3 files changed, 30 insertions(+)

-- 
1.9.0.279.gdc9e3eb


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

* [PATCH net-next v4 1/2] USB: cdc: add MBIM extended functional descriptor structure
  2014-03-19 21:00 [PATCH net-next v4 0/2] adjust MTU as indicated by MBIM extended functional descriptor Ben Chan
@ 2014-03-19 21:00 ` Ben Chan
  2014-03-19 21:00 ` [PATCH net-next v4 2/2] net: cdc_ncm: respect operator preferred MTU reported by MBIM Ben Chan
  2014-03-20 20:58 ` [PATCH net-next v4 0/2] adjust MTU as indicated by MBIM extended functional descriptor David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Ben Chan @ 2014-03-19 21:00 UTC (permalink / raw)
  To: linux-kernel, linux-usb, netdev, Oliver Neukum
  Cc: Greg Kroah-Hartman, David Miller, Bjørn Mork, Greg Suarez

This patch adds the MBIM extended functional descriptor structure
defined in "Universal Serial Bus Communications Class Subclass
Specification for Mobile Broadband Interface Model, Revision 1.0,
Errata-1" published by USB-IF.

Signed-off-by: Ben Chan <benchan@chromium.org>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 include/uapi/linux/usb/cdc.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/include/uapi/linux/usb/cdc.h b/include/uapi/linux/usb/cdc.h
index f35aa0a..b6a9cdd 100644
--- a/include/uapi/linux/usb/cdc.h
+++ b/include/uapi/linux/usb/cdc.h
@@ -56,6 +56,7 @@
 #define USB_CDC_OBEX_TYPE		0x15
 #define USB_CDC_NCM_TYPE		0x1a
 #define USB_CDC_MBIM_TYPE		0x1b
+#define USB_CDC_MBIM_EXTENDED_TYPE	0x1c
 
 /* "Header Functional Descriptor" from CDC spec  5.2.3.1 */
 struct usb_cdc_header_desc {
@@ -205,6 +206,17 @@ struct usb_cdc_mbim_desc {
 	__u8    bmNetworkCapabilities;
 } __attribute__ ((packed));
 
+/* "MBIM Extended Functional Descriptor" from CDC MBIM spec 1.0 errata-1 */
+struct usb_cdc_mbim_extended_desc {
+	__u8	bLength;
+	__u8	bDescriptorType;
+	__u8	bDescriptorSubType;
+
+	__le16	bcdMBIMExtendedVersion;
+	__u8	bMaxOutstandingCommandMessages;
+	__le16	wMTU;
+} __attribute__ ((packed));
+
 /*-------------------------------------------------------------------------*/
 
 /*
-- 
1.9.0.279.gdc9e3eb


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

* [PATCH net-next v4 2/2] net: cdc_ncm: respect operator preferred MTU reported by MBIM
  2014-03-19 21:00 [PATCH net-next v4 0/2] adjust MTU as indicated by MBIM extended functional descriptor Ben Chan
  2014-03-19 21:00 ` [PATCH net-next v4 1/2] USB: cdc: add MBIM extended functional descriptor structure Ben Chan
@ 2014-03-19 21:00 ` Ben Chan
  2014-03-20 20:58 ` [PATCH net-next v4 0/2] adjust MTU as indicated by MBIM extended functional descriptor David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Ben Chan @ 2014-03-19 21:00 UTC (permalink / raw)
  To: linux-kernel, linux-usb, netdev, Oliver Neukum
  Cc: Greg Kroah-Hartman, David Miller, Bjørn Mork, Greg Suarez

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@chromium.org>
---
 drivers/net/usb/cdc_ncm.c   | 17 +++++++++++++++++
 include/linux/usb/cdc_ncm.h |  1 +
 2 files changed, 18 insertions(+)

diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index dbff290..e8711a8 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -74,6 +74,7 @@ static int cdc_ncm_setup(struct usbnet *dev)
 	u8 iface_no;
 	int err;
 	int eth_hlen;
+	u16 mbim_mtu;
 	u16 ntb_fmt_supported;
 	__le16 max_datagram_size;
 
@@ -261,6 +262,14 @@ 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) {
+		mbim_mtu = le16_to_cpu(ctx->mbim_extended_desc->wMTU);
+		if (mbim_mtu != 0 && mbim_mtu < dev->net->mtu)
+			dev->net->mtu = mbim_mtu;
+	}
+
 	return 0;
 }
 
@@ -399,6 +408,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


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

* Re: [PATCH net-next v4 0/2] adjust MTU as indicated by MBIM extended functional descriptor
  2014-03-19 21:00 [PATCH net-next v4 0/2] adjust MTU as indicated by MBIM extended functional descriptor Ben Chan
  2014-03-19 21:00 ` [PATCH net-next v4 1/2] USB: cdc: add MBIM extended functional descriptor structure Ben Chan
  2014-03-19 21:00 ` [PATCH net-next v4 2/2] net: cdc_ncm: respect operator preferred MTU reported by MBIM Ben Chan
@ 2014-03-20 20:58 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2014-03-20 20:58 UTC (permalink / raw)
  To: benchan; +Cc: linux-kernel, linux-usb, netdev, oliver, gregkh, bjorn, gsuarez

From: Ben Chan <benchan@chromium.org>
Date: Wed, 19 Mar 2014 14:00:04 -0700

> The MBIM extended functional descriptor, defined in "Universal Serial Bus
> Communications Class Subclass Specification for Mobile Broadband Interface
> Model, Revision 1.0, Errata-1" by USB-IF, indicates the operator preferred MTU
> value via a wMTU field.
> 
> This patch set ensures that the initial MTU value set by cdc_ncm on a MBIM net
> device does not exceed the wMTU value, provided the MBIM device exposes a MBIM
> extended functional descriptor.
> 
> * Changelog
> v2: Fixed a le16_to_cpu conversion issue in patch 2/2 pointed out by
>     Bjørn Mork <bjorn@mork.no>
> v3: No code changes. Resubmitted to include patch 1/2 as suggested by
>     David Miller <davem@davemloft.net>
> v4: No code changes. Resubmitted as suggested by David Miller:
>     - Added a summary of the patch set
>     - Carried the ACK from Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>     - Added a specified the tree (net-next) to apply the patch set to

Series applied to net-next, thanks Ben.

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

end of thread, other threads:[~2014-03-20 20:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-19 21:00 [PATCH net-next v4 0/2] adjust MTU as indicated by MBIM extended functional descriptor Ben Chan
2014-03-19 21:00 ` [PATCH net-next v4 1/2] USB: cdc: add MBIM extended functional descriptor structure Ben Chan
2014-03-19 21:00 ` [PATCH net-next v4 2/2] net: cdc_ncm: respect operator preferred MTU reported by MBIM Ben Chan
2014-03-20 20:58 ` [PATCH net-next v4 0/2] adjust MTU as indicated by MBIM extended functional descriptor David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.