From: "Bjørn Mork" <bjorn-yOkvZcmFvRU@public.gmane.org>
To: netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
"Bjørn Mork" <bjorn-yOkvZcmFvRU@public.gmane.org>,
"Greg Suarez" <gsuarez-AKjrjAf1O7qe8kRwQpwjMg@public.gmane.org>,
"Alexey Orishko"
<alexey.orishko-0IS4wlFg1OjSUeElwK9/Pw@public.gmane.org>
Subject: [PATCH net] net: cdc_ncm: workaround for missing CDC Union
Date: Fri, 18 Jan 2013 15:25:47 +0100 [thread overview]
Message-ID: <1358519147-10073-1-git-send-email-bjorn@mork.no> (raw)
Adding support for the MBIM mode in some Sierra Wireless devices.
Some Sierra Wireless firmwares support CDC MBIM but have no CDC
Union funtional descriptor. This violates the MBIM specification,
but we can easily work around the bug by looking at the Interface
Association Descriptor instead. This is most likely what
Windows uses too, which explains how the firmware bug has gone
unnoticed until now.
This change will not affect any currently supported device
conforming to the NCM or MBIM specifications, as they must have
the CDC Union descriptor.
Cc: Greg Suarez <gsuarez-AKjrjAf1O7qe8kRwQpwjMg@public.gmane.org>
Cc: Alexey Orishko <alexey.orishko-0IS4wlFg1OjSUeElwK9/Pw@public.gmane.org>
Signed-off-by: Bjørn Mork <bjorn-yOkvZcmFvRU@public.gmane.org>
---
drivers/net/usb/cdc_ncm.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index 71b6e92..5c1210f 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -344,6 +344,21 @@ static const struct ethtool_ops cdc_ncm_ethtool_ops = {
.nway_reset = usbnet_nway_reset,
};
+/* return first slave interface if an IAD matches the given master */
+static struct usb_interface *get_iad_slave(struct usb_device *udev,
+ struct usb_interface *master) {
+ int i;
+ struct usb_interface_assoc_descriptor *iad;
+ u8 mnum = master->cur_altsetting->desc.bInterfaceNumber;
+
+ for (i = 0; i < USB_MAXIADS; i++) {
+ iad = udev->actconfig->intf_assoc[i];
+ if (iad->bFirstInterface == mnum && iad->bInterfaceCount == 2)
+ return usb_ifnum_to_if(udev, mnum + 1);
+ }
+ return NULL;
+}
+
int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_altsetting)
{
struct cdc_ncm_ctx *ctx;
@@ -435,6 +450,16 @@ advance:
len -= temp;
}
+ /* some buggy devices have an IAD but no CDC Union */
+ if (!ctx->union_desc) {
+ dev_dbg(&intf->dev, "missing CDC Union descriptor\n");
+ ctx->data = get_iad_slave(dev->udev, intf);
+ if (ctx->data) {
+ ctx->control = intf;
+ dev_dbg(&intf->dev, "got slave from IAD\n");
+ }
+ }
+
/* check if we got everything */
if ((ctx->control == NULL) || (ctx->data == NULL) ||
((!ctx->mbim_desc) && ((ctx->ether_desc == NULL) || (ctx->control != intf))))
--
1.7.10.4
--
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 reply other threads:[~2013-01-18 14:25 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-18 14:25 Bjørn Mork [this message]
[not found] ` <1358519147-10073-1-git-send-email-bjorn-yOkvZcmFvRU@public.gmane.org>
2013-01-18 19:11 ` [PATCH net] net: cdc_ncm: workaround for missing CDC Union Oliver Neukum
[not found] ` <22276933.xSGyXJfOvq-7ztolUikljGernLeA6q8OA@public.gmane.org>
2013-01-18 21:17 ` Bjørn Mork
2013-01-20 0:21 ` Alexey Orishko
[not found] ` <CAL_Kpj1B=_+eN3Y0n3d9_r4JoeHD2LQFSU+b+taCZL0G4icu6A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-01-21 8:31 ` Bjørn Mork
2013-01-21 14:08 ` Bjørn Mork
2013-01-21 14:47 ` Bjørn Mork
[not found] ` <87mww2y4ni.fsf-lbf33ChDnrE/G1V5fR+Y7Q@public.gmane.org>
2013-01-21 14:55 ` Oliver Neukum
2013-01-21 15:28 ` Bjørn Mork
[not found] ` <87ip6qy2q7.fsf-lbf33ChDnrE/G1V5fR+Y7Q@public.gmane.org>
2013-01-22 8:50 ` Oliver Neukum
2013-01-22 10:35 ` Bjørn Mork
2013-01-21 17:59 ` Alexey ORISHKO
2013-01-22 9:07 ` Oliver Neukum
2013-01-22 9:32 ` Oliver Neukum
2013-01-19 12:18 ` Bjørn Mork
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=1358519147-10073-1-git-send-email-bjorn@mork.no \
--to=bjorn-yokvzcmfvru@public.gmane.org \
--cc=alexey.orishko-0IS4wlFg1OjSUeElwK9/Pw@public.gmane.org \
--cc=gsuarez-AKjrjAf1O7qe8kRwQpwjMg@public.gmane.org \
--cc=linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=netdev-u79uwXL29TY76Z2rM5mHXA@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).