[PATCH experimental 0/6] Using cdc-wdm as a subdriver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is coded up in a couple of hours, so it's a bit rough. Even worse than 
my average code...

And it's not exactly tested.  But I have *tried* it with success. So
it is sort of a demo of how little really is necessary to make this
concept fly.

I tested it using the "Windows mode" of my Huawei modem.  This makes the
wwan/qmi interface look like this:

    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        3
      bAlternateSetting       0
      bNumEndpoints           3
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass      1 
      bInterfaceProtocol     17 
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x85  EP 5 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               5
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x86  EP 6 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval              32
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x04  EP 4 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval              32


binding:

Jan 24 00:33:30 nemi kernel: [ 3097.680318] usb 2-1: new high-speed USB device number 6 using ehci_hcd
Jan 24 00:33:30 nemi kernel: [ 3097.815574] usb 2-1: New USB device found, idVendor=12d1, idProduct=1506
Jan 24 00:33:30 nemi kernel: [ 3097.815585] usb 2-1: New USB device strings: Mfr=3, Product=2, SerialNumber=0
Jan 24 00:33:30 nemi kernel: [ 3097.815592] usb 2-1: Product: HUAWEI Mobile
Jan 24 00:33:30 nemi kernel: [ 3097.815598] usb 2-1: Manufacturer: Huawei Technologies
Jan 24 00:33:30 nemi kernel: [ 3097.818088] option 2-1:1.0: GSM modem (1-port) converter detected
Jan 24 00:33:30 nemi kernel: [ 3097.818371] usb 2-1: GSM modem (1-port) converter now attached to ttyUSB0
Jan 24 00:33:30 nemi kernel: [ 3097.818624] option 2-1:1.1: GSM modem (1-port) converter detected
Jan 24 00:33:30 nemi kernel: [ 3097.818843] usb 2-1: GSM modem (1-port) converter now attached to ttyUSB1
Jan 24 00:33:30 nemi kernel: [ 3097.819061] option 2-1:1.2: GSM modem (1-port) converter detected
Jan 24 00:33:30 nemi kernel: [ 3097.819253] usb 2-1: GSM modem (1-port) converter now attached to ttyUSB2
Jan 24 00:33:30 nemi kernel: [ 3097.819657] qmi_wwan 2-1:1.3: cdc-wdm2: USB WDM device
Jan 24 00:33:30 nemi kernel: [ 3097.822481] qmi_wwan 2-1:1.3: wwan1: register 'qmi_wwan' at usb-0000:00:1d.7-1, QMI speaking wwan device with combined interface, 0e:b8:5e:cd:9c:78
Jan 24 00:33:30 nemi kernel: [ 3097.823777] scsi8 : usb-storage 2-1:1.4
Jan 24 00:33:30 nemi kernel: [ 3097.824601] scsi9 : usb-storage 2-1:1.5
Jan 24 00:33:31 nemi kernel: [ 3098.827129] scsi 9:0:0:0: Direct-Access     HUAWEI   SD Storage       2.31 PQ: 0 ANSI: 2
Jan 24 00:33:31 nemi kernel: [ 3098.827142] scsi 8:0:0:0: CD-ROM            HUAWEI   Mass Storage     2.31 PQ: 0 ANSI: 0
Jan 24 00:33:32 nemi kernel: [ 3098.832089] sd 9:0:0:0: [sdb] Attached SCSI removable disk
Jan 24 00:33:32 nemi kernel: [ 3098.858700] sr1: scsi-1 drive
Jan 24 00:33:32 nemi kernel: [ 3098.859251] sr 8:0:0:0: Attached scsi CD-ROM sr1

Connecting:

nemi:/home/bjorn# ifup wwan1
wwan1: will use /dev/cdc-wdm2 for management
wwan1: Manufacturer: QUALCOMM INCORPORATED
wwan1: Revision: M9200B-SCAQDBZD-3.0.350025T  1  [Aug 11 2011 02:00:00]
wwan1: QMI_WDS cid=1, wds_handle=0x00000000
wwan1: PIN1 status: enabled, not verified, verify_left: 3, unblock_left: 10
wwan1: PIN2 status: enabled, not verified, verify_left: 2, unblock_left: 10
wwan1: less than 3 verification attempts left for PIN2 - must be entered manually!
wwan1: connecting...
wwan1: got QMI_WDS handle 0x021590e8
wwan1: not releasing QMI_WDS cid=1 while connected
wwan1: released QMI_DMS cid=1 with status=0
Internet Systems Consortium DHCP Client 4.1.1-P1
Copyright 2004-2010 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/

Listening on LPF/wwan1/0e:b8:5e:cd:9c:78
Sending on   LPF/wwan1/0e:b8:5e:cd:9c:78
Sending on   Socket/fallback
DHCPDISCOVER on wwan1 to 255.255.255.255 port 67 interval 4
DHCPOFFER from 10.152.3.57
DHCPREQUEST on wwan1 to 255.255.255.255 port 67
DHCPACK from 10.152.3.57
bound to 10.152.3.59 -- renewal in 3546 seconds.


with some related kernel log messages:

Jan 24 00:35:06 nemi kernel: [ 3193.653155] qmi_wwan 2-1:1.3: NOTIFY_RESPONSE_AVAILABLE received: index 3 len 0
Jan 24 00:35:06 nemi kernel: [ 3193.653167] qmi_wwan 2-1:1.3: wdm_int_callback: usb_submit_urb 0
Jan 24 00:35:06 nemi kernel: [ 3193.655155] qmi_wwan 2-1:1.3: NOTIFY_RESPONSE_AVAILABLE received: index 3 len 0
Jan 24 00:35:06 nemi kernel: [ 3193.655164] qmi_wwan 2-1:1.3: wdm_int_callback: usb_submit_urb 0
Jan 24 00:35:06 nemi kernel: [ 3193.657171] qmi_wwan 2-1:1.3: NOTIFY_RESPONSE_AVAILABLE received: index 3 len 0
Jan 24 00:35:06 nemi kernel: [ 3193.657180] qmi_wwan 2-1:1.3: wdm_int_callback: usb_submit_urb 0
Jan 24 00:35:06 nemi kernel: [ 3193.659153] qmi_wwan 2-1:1.3: NOTIFY_RESPONSE_AVAILABLE received: index 3 len 0
Jan 24 00:35:06 nemi kernel: [ 3193.659160] qmi_wwan 2-1:1.3: wdm_int_callback: usb_submit_urb 0
Jan 24 00:35:06 nemi kernel: [ 3193.661173] qmi_wwan 2-1:1.3: NOTIFY_RESPONSE_AVAILABLE received: index 3 len 0
Jan 24 00:35:06 nemi kernel: [ 3193.661182] qmi_wwan 2-1:1.3: wdm_int_callback: usb_submit_urb 0
Jan 24 00:35:06 nemi kernel: [ 3193.663153] qmi_wwan 2-1:1.3: NOTIFY_RESPONSE_AVAILABLE received: index 3 len 0
Jan 24 00:35:06 nemi kernel: [ 3193.663160] qmi_wwan 2-1:1.3: wdm_int_callback: usb_submit_urb 0
Jan 24 00:35:06 nemi kernel: [ 3193.665172] qmi_wwan 2-1:1.3: NOTIFY_RESPONSE_AVAILABLE received: index 3 len 0
Jan 24 00:35:06 nemi kernel: [ 3193.665180] qmi_wwan 2-1:1.3: wdm_int_callback: usb_submit_urb 0
Jan 24 00:35:07 nemi kernel: [ 3193.665205] qmi_wwan 2-1:1.3: Tx URB has been submitted index=3
Jan 24 00:35:07 nemi kernel: [ 3194.665609] qmi_wwan 2-1:1.3: wdm_release: cleanup
Jan 24 00:35:07 nemi kernel: [ 3194.665961] wdm_get_device_by_minor: looking at 2-1:1.3 (ffff88022fef8400)
Jan 24 00:35:07 nemi kernel: [ 3194.665969] wdm_get_device_by_minor: returning desc->intf=ffff88022fef8400 for minor=2
Jan 24 00:35:07 nemi kernel: [ 3194.666143] qmi_wwan 2-1:1.3: Tx URB has been submitted index=3
Jan 24 00:35:07 nemi kernel: [ 3194.669191] qmi_wwan 2-1:1.3: NOTIFY_RESPONSE_AVAILABLE received: index 3 len 0
Jan 24 00:35:07 nemi kernel: [ 3194.669208] qmi_wwan 2-1:1.3: wdm_int_callback: usb_submit_urb 0
Jan 24 00:35:07 nemi kernel: [ 3194.669854] qmi_wwan 2-1:1.3: wdm_release: cleanup
Jan 24 00:35:07 nemi kernel: [ 3194.670096] wdm_get_device_by_minor: looking at 2-1:1.3 (ffff88022fef8400)
Jan 24 00:35:07 nemi kernel: [ 3194.670104] wdm_get_device_by_minor: returning desc->intf=ffff88022fef8400 for minor=2
Jan 24 00:35:07 nemi kernel: [ 3194.670259] qmi_wwan 2-1:1.3: Tx URB has been submitted index=3
Jan 24 00:35:07 nemi kernel: [ 3194.675171] qmi_wwan 2-1:1.3: NOTIFY_RESPONSE_AVAILABLE received: index 3 len 0
Jan 24 00:35:07 nemi kernel: [ 3194.675186] qmi_wwan 2-1:1.3: wdm_int_callback: usb_submit_urb 0
Jan 24 00:35:07 nemi kernel: [ 3194.675808] qmi_wwan 2-1:1.3: wdm_release: cleanup
Jan 24 00:35:07 nemi kernel: [ 3194.676085] wdm_get_device_by_minor: looking at 2-1:1.3 (ffff88022fef8400)
Jan 24 00:35:07 nemi kernel: [ 3194.676093] wdm_get_device_by_minor: returning desc->intf=ffff88022fef8400 for minor=2
Jan 24 00:35:07 nemi kernel: [ 3194.676321] qmi_wwan 2-1:1.3: Tx URB has been submitted index=3
Jan 24 00:35:07 nemi kernel: [ 3194.679168] qmi_wwan 2-1:1.3: NOTIFY_RESPONSE_AVAILABLE received: index 3 len 0
Jan 24 00:35:07 nemi kernel: [ 3194.679181] qmi_wwan 2-1:1.3: wdm_int_callback: usb_submit_urb 0
Jan 24 00:35:07 nemi kernel: [ 3194.679794] qmi_wwan 2-1:1.3: wdm_release: cleanup
Jan 24 00:35:07 nemi kernel: [ 3194.680056] wdm_get_device_by_minor: looking at 2-1:1.3 (ffff88022fef8400)
Jan 24 00:35:07 nemi kernel: [ 3194.680064] wdm_get_device_by_minor: returning desc->intf=ffff88022fef8400 for minor=2
Jan 24 00:35:07 nemi kernel: [ 3194.680190] qmi_wwan 2-1:1.3: Tx URB has been submitted index=3
Jan 24 00:35:07 nemi kernel: [ 3194.683182] qmi_wwan 2-1:1.3: NOTIFY_RESPONSE_AVAILABLE received: index 3 len 0
Jan 24 00:35:07 nemi kernel: [ 3194.683195] qmi_wwan 2-1:1.3: wdm_int_callback: usb_submit_urb 0
Jan 24 00:35:07 nemi kernel: [ 3194.683806] qmi_wwan 2-1:1.3: wdm_release: cleanup
Jan 24 00:35:07 nemi kernel: [ 3194.684200] wdm_get_device_by_minor: looking at 2-1:1.3 (ffff88022fef8400)
Jan 24 00:35:07 nemi kernel: [ 3194.684209] wdm_get_device_by_minor: returning desc->intf=ffff88022fef8400 for minor=2
Jan 24 00:35:07 nemi kernel: [ 3194.684333] qmi_wwan 2-1:1.3: Tx URB has been submitted index=3
Jan 24 00:35:07 nemi kernel: [ 3194.687169] qmi_wwan 2-1:1.3: NOTIFY_RESPONSE_AVAILABLE received: index 3 len 0
Jan 24 00:35:07 nemi kernel: [ 3194.687183] qmi_wwan 2-1:1.3: wdm_int_callback: usb_submit_urb 0
Jan 24 00:35:07 nemi kernel: [ 3194.687787] qmi_wwan 2-1:1.3: wdm_release: cleanup
Jan 24 00:35:07 nemi kernel: [ 3194.687973] wdm_get_device_by_minor: looking at 2-1:1.3 (ffff88022fef8400)
Jan 24 00:35:07 nemi kernel: [ 3194.687981] wdm_get_device_by_minor: returning desc->intf=ffff88022fef8400 for minor=2
Jan 24 00:35:07 nemi kernel: [ 3194.688121] qmi_wwan 2-1:1.3: Tx URB has been submitted index=3
Jan 24 00:35:07 nemi kernel: [ 3194.691169] qmi_wwan 2-1:1.3: NOTIFY_RESPONSE_AVAILABLE received: index 3 len 0
Jan 24 00:35:07 nemi kernel: [ 3194.691183] qmi_wwan 2-1:1.3: wdm_int_callback: usb_submit_urb 0
Jan 24 00:35:07 nemi kernel: [ 3194.691792] qmi_wwan 2-1:1.3: wdm_release: cleanup
Jan 24 00:35:07 nemi kernel: [ 3194.692106] wdm_get_device_by_minor: looking at 2-1:1.3 (ffff88022fef8400)
Jan 24 00:35:07 nemi kernel: [ 3194.692114] wdm_get_device_by_minor: returning desc->intf=ffff88022fef8400 for minor=2
Jan 24 00:35:07 nemi kernel: [ 3194.693048] qmi_wwan 2-1:1.3: Tx URB has been submitted index=3


Looking at the sysfs:

nemi:/home/bjorn# ls -l /sys/bus/usb/devices/2-1:1.3/
total 0
-r--r--r-- 1 root root 4096 Jan 24 00:34 bAlternateSetting
-r--r--r-- 1 root root 4096 Jan 24 00:33 bInterfaceClass
-r--r--r-- 1 root root 4096 Jan 24 00:33 bInterfaceNumber
-r--r--r-- 1 root root 4096 Jan 24 00:34 bInterfaceProtocol
-r--r--r-- 1 root root 4096 Jan 24 00:34 bInterfaceSubClass
-r--r--r-- 1 root root 4096 Jan 24 00:34 bNumEndpoints
lrwxrwxrwx 1 root root    0 Jan 24 00:33 driver -> ../../../../../../bus/usb/drivers/qmi_wwan
drwxr-xr-x 3 root root    0 Jan 24 00:34 ep_04
drwxr-xr-x 3 root root    0 Jan 24 00:34 ep_85
drwxr-xr-x 3 root root    0 Jan 24 00:34 ep_86
-r--r--r-- 1 root root 4096 Jan 24 00:34 modalias
drwxr-xr-x 3 root root    0 Jan 24 00:33 net
drwxr-xr-x 2 root root    0 Jan 24 00:34 power
lrwxrwxrwx 1 root root    0 Jan 24 00:33 subsystem -> ../../../../../../bus/usb
-r--r--r-- 1 root root 4096 Jan 24 00:34 supports_autosuspend
-rw-r--r-- 1 root root 4096 Jan 24 00:33 uevent
drwxr-xr-x 3 root root    0 Jan 24 00:33 usb

nemi:/home/bjorn# ls -l /sys/bus/usb/devices/2-1:1.3/{net,usb}
/sys/bus/usb/devices/2-1:1.3/net:
total 0
drwxr-xr-x 5 root root 0 Jan 24 00:33 wwan1

/sys/bus/usb/devices/2-1:1.3/usb:
total 0
drwxr-xr-x 3 root root 0 Jan 24 00:33 cdc-wdm2


What do you think?  Continue with something like this or not?


Oh, yeah, the Ericsson modem isn't broken either:

bjorn@nemi:~$ echo -e "ATI\r" >/dev/cdc-wdm0 && cat /dev/cdc-wdm0

*EMRDY: 1
ATI
F3507g

OK
ATI
F3507g

OK
^C



Bjørn Mork (6):
  usb: cdc-wdm: split out reusable parts of probe and destroy
  usb: cdc-wdm: prepare endpoint detection for interfaces with > 1
    endpoint
  usb: cdc-wdm: create an extra indirection when looking up device data
  usb: cdc-wdm: adding interface => wdm_device list lookup
  usb: cdc-wdm: adding register/deregister
  net: usb: qmi_wwan: add support for devices sharing interface for QMI
    and wwan

 drivers/net/usb/qmi_wwan.c  |   44 ++++++++
 drivers/usb/class/cdc-wdm.c |  239 ++++++++++++++++++++++++++++++++-----------
 drivers/usb/class/cdc-wdm.h |   10 ++
 3 files changed, 232 insertions(+), 61 deletions(-)
 create mode 100644 drivers/usb/class/cdc-wdm.h

-- 
1.7.8.3

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux