USB: cdc: add MBIM extended functional descriptor structure
Subsystems (5)
PATCH v3 1/2 USB: cdc: add MBIM extended functional descriptor structure
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.
---
No changes from patch v1.
include/uapi/linux/usb/cdc.h | 12 ++++++++++++ 1 file changed, 12 insertions(+)
include/uapi/linux/usb/cdc.h +12 -0
@@ -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)); +/*-------------------------------------------------------------------------*/ /*
Signature · 1 line
1.9.0.279.gdc9e3eb
PATCH v3 2/2 net: cdc_ncm: respect operator preferred MTU reported by MBIM
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.
---
Patch v3 (which is same as v2) adds the le16_to_cpu conversion on ctx->mbim_extended_desc->wMTU as pointed out and suggested by 'Bjørn Mork <[email protected]>'.
drivers/net/usb/cdc_ncm.c | 17 +++++++++++++++++ include/linux/usb/cdc_ncm.h | 1 + 2 files changed, 18 insertions(+)
drivers/net/usb/cdc_ncm.c +17 -0
@@ -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 ; }
include/linux/usb/cdc_ncm.h +1 -0
@@ -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;
Signature · 1 line
1.9.0.279.gdc9e3eb
Re: [PATCH v3 2/2] net: cdc_ncm: respect operator preferred MTU reported by MBIM
Quoted 11 lines · Ben Chan
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_setupto 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.
Quoted 5 lines
Signed-off-by Ben Chan <[email protected]>---
Patch v3 (which is same as v2) adds thele16_to_cpuconversion onctx->mbim_extended_desc->wMTUas pointed out and suggested by 'Bjørn Mork <[email protected]>'.
Looks good to me FWIW.
I was worried that I might have created a merge conflict here by posting the unrelated cdc_ncm fix, touching the same function. But we're in
luck: That fix and your patch applies cleanly on top of each other in any order.
Bjørn
Quoted 8 lines · Ben Chan
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 <[email protected]>---
No changes from patch v1.
I believe you could have included Greg KH's ack then, to make sure it is recorded. Or will patchwork keep track of tags across different patch versions?
Bjørn
David Miller
maintainerFrom: Bjørn Mork <[email protected]>
Date: Tue, 18 Mar 2014 09:35:57 +0100
Quoted 2 lines
Or will patchwork keep track of tags across different patch versions?
It doesn't, and should not. It has no idea if the patch changed or not, the ACK'er might not still agree with the patch if any changes were made.