rmacielalves wrote:Hello folks.
I have a WR842ND v1 running CC 15.05.1 and a DWM-157 USB 3G dongle connected using '3g' (serial) protocol.
I got bored and looking for some fun tried to switch to a faster and stable protocol. After researching I found something about QMI/NCM/MBIM protocol and found that my dongle works in MBIM mode (also Windows 10 use that mode natively).
Installed all necessary packages into my router but unfortunately I can't get any valid answer from any commands sent to modem like I do in Ubuntu (mbimcli -d /dev/cdc-wdm0 --query-packet-service-state).
Almost every command returns same data:
root@OpenWrt:~# umbim -n -v -d /dev/cdc-wdm0 caps
sending (16): 01 00 00 00 10 00 00 00 01 00 00 00 00 04 00 00
header_type: 0001
header_length: 0010
header_transaction: 0001
reading (16): 04 00 00 80 10 00 00 00 01 00 00 00 08 00 00 00
header_type: 80000004
header_length: 0010
header_transaction: 0001
sending (16): 02 00 00 00 10 00 00 00 02 00 00 00 08 00 00 00
header_type: 0002
header_length: 0010
header_transaction: 0002
reading (16): 02 00 00 80 10 00 00 00 02 00 00 00 02 00 00 00
header_type: 80000002
header_length: 0010
header_transaction: 0002
Looks like I have a lot to lean about it, where do I start?
Downloading the current MBIM spec from http://www.usb.org/developers/docs/devc … 073013.zip and use it to a a bit more verbose error messages to umbim would be a great start
The "header_type: 80000004" is MBIM_FUNCTION_ERROR_MSG, and the last 4 bytes of that message is the error code in le32 (which is the only integer type in MBIM messages). Error code 8 is MBIM_ERROR_MAX_TRANSFER, which "Shall be sent if the function does not support the maximum control transfer the host supports."
So the problem is that the modem doesn't support the requested message size. That's the last 4 bytes of the open message: 0x00000400, or 1024 in decimal, which is hardcoded in umbim (MBIM_BUFFER_SIZE). This is not the right way to do that. We should pick the message size from the MBIM descriptor. For convenience, the driver also provides it through an ioctl. A nice fix would be to add support for that in umbim.
For a quickfix, I suggest checking the value of your modem: run "lsusb -v" and look for the MBIM descriptor:
CDC MBIM:
bcdMBIMVersion 1.00
wMaxControlMessage 4096
bNumberFilters 16
bMaxFilterSize 128
wMaxSegmentSize 1430
bmNetworkCapabilities 0x20
8-byte ntb input size
The value you are after is the wMaxControlMessage. Yours is probably significantly smaller. I'm guessing 512. Then change
#define MBIM_BUFFER_SIZE 1024
to
#define MBIM_BUFFER_SIZE 512
in mbim.h and rebuild umbim. This should make it work. But the real fix is to make it automatically match the value set by the modem. In theory a smaller value can always be used, but I'm not sure all MBIM firmwares expect anything else than their preferred value.