netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Bjørn Mork" <bjorn@mork.no>
To: netdev@vger.kernel.org
Cc: linux-usb@vger.kernel.org, "Oliver Neukum" <oliver@neukum.org>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Alexey Orishko" <alexey.orishko@gmail.com>,
	"Greg Suarez" <gpsuarez2512@gmail.com>,
	"Fangxiaozhi (Franko)" <fangxiaozhi@huawei.com>,
	"Dan Williams" <dcbw@redhat.com>,
	"Aleksander Morgado" <aleksander@lanedo.com>,
	"Bjørn Mork" <bjorn@mork.no>,
	"Greg Suarez" <gsuarez@smithmicro.com>
Subject: [PATCH net-next 12/14] net: cdc_ncm: do not bind to NCM compatible MBIM devices
Date: Thu, 18 Oct 2012 22:41:05 +0200	[thread overview]
Message-ID: <1350592867-25651-13-git-send-email-bjorn@mork.no> (raw)
In-Reply-To: <1350592867-25651-1-git-send-email-bjorn@mork.no>

The MBIM specification allows a MBIM device to disguise
itself as NCM for backwards compatibility, using additional
altsettings with different subclass (control) or protocol
(data):

C:* #Ifs= 2 Cfg#= 1 Atr=80 MxPwr=100mA
I:  If#= 0 Alt= 0 #EPs= 1 Cls=02(comm.) Sub=0d Prot=00 Driver=cdc_mbim
E:  Ad=81(I) Atr=03(Int.) MxPS=  64 Ivl=7ms
I:* If#= 0 Alt= 1 #EPs= 1 Cls=02(comm.) Sub=0e Prot=00 Driver=cdc_mbim
E:  Ad=81(I) Atr=03(Int.) MxPS=  64 Ivl=7ms
I:  If#= 1 Alt= 0 #EPs= 0 Cls=0a(data ) Sub=00 Prot=01 Driver=cdc_mbim
I:  If#= 1 Alt= 1 #EPs= 2 Cls=0a(data ) Sub=00 Prot=01 Driver=cdc_mbim
E:  Ad=81(I) Atr=02(Bulk) MxPS=  64 Ivl=0ms
E:  Ad=02(O) Atr=02(Bulk) MxPS=  64 Ivl=0ms
I:* If#= 1 Alt= 2 #EPs= 2 Cls=0a(data ) Sub=00 Prot=02 Driver=cdc_mbim
E:  Ad=81(I) Atr=02(Bulk) MxPS=  64 Ivl=0ms
E:  Ad=02(O) Atr=02(Bulk) MxPS=  64 Ivl=0ms

If the MBIM driver is enabled then that should have priority
for devices providing such a NCM 1.0 backward compatibility
mode.

Signed-off-by: Bjørn Mork <bjorn@mork.no>
Signed-off-by: Greg Suarez <gsuarez@smithmicro.com>
---
 drivers/net/usb/cdc_ncm.c |   27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index 0c941ef..a4d61a3 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -587,6 +587,33 @@ static int cdc_ncm_bind(struct usbnet *dev, struct usb_interface *intf)
 {
 	int ret;
 
+	/* The MBIM spec defines a NCM compatible default altsetting,
+	 * which we may have matched:
+	 *
+	 *  "Functions that implement both NCM 1.0 and MBIM (an
+	 *   “NCM/MBIM function”) according to this recommendation
+	 *   shall provide two alternate settings for the
+	 *   Communication Interface.  Alternate setting 0, and the
+	 *   associated class and endpoint descriptors, shall be
+	 *   constructed according to the rules given for the
+	 *   Communication Interface in section 5 of [USBNCM10].
+	 *   Alternate setting 1, and the associated class and
+	 *   endpoint descriptors, shall be constructed according to
+	 *   the rules given in section 6 (USB Device Model) of this
+	 *   specification."
+	 *
+	 * Do not bind to such interfaces, allowing cdc_mbim to handle
+	 * them
+	 */
+#if IS_ENABLED(CONFIG_USB_NET_CDC_MBIM)
+	if ((intf->num_altsetting == 2) &&
+	    !usb_set_interface(dev->udev,
+			       intf->cur_altsetting->desc.bInterfaceNumber,
+			       CDC_NCM_COMM_ALTSETTING_MBIM) &&
+	    cdc_ncm_comm_intf_is_mbim(intf->cur_altsetting))
+		return -ENODEV;
+#endif
+
 	/* NCM data altsetting is always 1 */
 	ret = cdc_ncm_bind_common(dev, intf, 1);
 
-- 
1.7.10.4

  parent reply	other threads:[~2012-10-18 20:42 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-18 20:40 [PATCH net-next 00/14] Adding a USB CDC MBIM driver Bjørn Mork
2012-10-18 20:40 ` [PATCH net-next 01/14] net: usbnet: make sure the queue lenght is at least 1 Bjørn Mork
2012-10-18 20:40 ` [PATCH net-next 02/14] net: cdc_ncm: use device rx_max value if update failed Bjørn Mork
     [not found]   ` <1350592867-25651-3-git-send-email-bjorn-yOkvZcmFvRU@public.gmane.org>
2012-10-18 21:45     ` Oliver Neukum
2012-10-18 22:09       ` Bjørn Mork
2012-10-18 23:30         ` Alexey Orishko
2012-10-19  6:41           ` Bjørn Mork
2012-10-19  9:30             ` Bjørn Mork
     [not found]               ` <871uguvmfy.fsf-lbf33ChDnrE/G1V5fR+Y7Q@public.gmane.org>
2012-10-19 10:01                 ` Alexey Orishko
     [not found]                   ` <CAL_Kpj3QX_bpLh5yX5VXKaqq+TSO9+aVxt+1TrU9e1BamKdFkA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-10-19 10:30                     ` Bjørn Mork
     [not found]                       ` <87vce6u52w.fsf-lbf33ChDnrE/G1V5fR+Y7Q@public.gmane.org>
2012-10-19 11:36                         ` [RFC] net: cdc_ncm: workaround NTB input size firmware bug Bjørn Mork
2012-10-19 12:18                     ` [PATCH net-next 02/14] net: cdc_ncm: use device rx_max value if update failed Bjørn Mork
     [not found]                       ` <878vb2u03g.fsf-lbf33ChDnrE/G1V5fR+Y7Q@public.gmane.org>
2012-10-19 13:53                         ` Alexey Orishko
     [not found]                           ` <CAL_Kpj3tT6qfcD-Tpeqgof-k-PX-EPv_cMFo_NeEdLHfyN8Qfw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-10-19 14:09                             ` Bjørn Mork
2012-10-18 20:40 ` [PATCH net-next 04/14] net: cdc_ncm: adding MBIM support to ncm_setup Bjørn Mork
2012-10-18 20:40 ` [PATCH net-next 06/14] net: cdc_ncm: process chained NDPs Bjørn Mork
2012-10-18 20:41 ` [PATCH net-next 08/14] net: cdc_ncm: refactoring for tx multiplexing Bjørn Mork
     [not found] ` <1350592867-25651-1-git-send-email-bjorn-yOkvZcmFvRU@public.gmane.org>
2012-10-18 20:40   ` [PATCH net-next 03/14] USB: cdc: add MBIM constants and structures Bjørn Mork
     [not found]     ` <1350592867-25651-4-git-send-email-bjorn-yOkvZcmFvRU@public.gmane.org>
2012-10-18 21:14       ` Greg Kroah-Hartman
2012-10-18 20:40   ` [PATCH net-next 05/14] net: cdc_ncm: refactor bind preparing for MBIM support Bjørn Mork
2012-10-18 20:41   ` [PATCH net-next 07/14] net: cdc_ncm: splitting rx_fixup for code reuse Bjørn Mork
2012-10-18 20:41   ` [PATCH net-next 09/14] net: cdc_ncm: export shared symbols and definitions Bjørn Mork
2012-10-18 20:41   ` [PATCH net-next 10/14] net: cdc_mbim: adding MBIM driver Bjørn Mork
2012-10-18 20:41   ` [PATCH net-next 13/14] net: cdc_ncm: map MBIM IPS SessionID to VLAN ID Bjørn Mork
2012-10-18 21:04   ` [PATCH net-next 00/14] Adding a USB CDC MBIM driver David Miller
2012-10-18 21:08     ` Bjørn Mork
2012-10-18 20:41 ` [PATCH net-next 11/14] net: cdc_mbim: build the " Bjørn Mork
2012-10-18 20:41 ` Bjørn Mork [this message]
2012-10-18 20:41 ` [PATCH net-next 14/14] net: cdc_mbim: Device Service Stream support Bjørn Mork
2012-10-18 21:16 ` [PATCH net-next 00/14] Adding a USB CDC MBIM driver 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=1350592867-25651-13-git-send-email-bjorn@mork.no \
    --to=bjorn@mork.no \
    --cc=aleksander@lanedo.com \
    --cc=alexey.orishko@gmail.com \
    --cc=dcbw@redhat.com \
    --cc=fangxiaozhi@huawei.com \
    --cc=gpsuarez2512@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=gsuarez@smithmicro.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=oliver@neukum.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).