MBIM backwards compatibility and user vs kernel policy
Subsystems (5)
Hello,
I just realized that our current strategy for MBIM backwards compatibility results in bad user experience by *forcing* the user to cdc_mbim if it is enabled at build time. There are legitimate reasons for a user to select cdc_ncm instead of cdc_mbim at runtime, and at the moment we prevent that. The most obvious and important reason is that the required MBIM userspace applications are not ready yet. But even in a future where these are available, I believe we should leave the choice up to the user.
So our current build time based decision will not do. But what will? Is a cdc_ncm module param setting MBIM vs NCM priority OK? We could still make the default depend on whether cdc_mbim is built. I don't think there are any reasons to complicate this with a per-device selection. It is really a system wide setting depending on whether MBIM is supported by the system.
What do you think?
This problem just came up as a result of a user failing to make Linux v3.8 work on a Lenovo Thinkpad X230 with an Ericsson H5321gw Mobile Broadband Device, while v3.7 appeared to work fine. The H5321gw firmware support NCM backwards compatibility, making it work fine with cdc_ncm in v3.7. But in v3.8 we select the cdc_mbim alternate setting instead, and ModemManager does not yet know how to handle that, making it fail.
The user noticed the new cdc_mbim module and tried blacklisting it, as one would find natural. But to no effect, as the problem is in the MBIM compatibility check in cdc_ncm. There appears to be no way to force the cdc_ncm driver in v3.8 to be used for this device if cdc_mbim is selected at build time. Which of course is a distro choice and not something most users will touch.
I believe we need to resolve this quickly, and I'll probably just cook up a proposed module param patch unless someone comes up with something better.
BTW, I am starting to hate the NCM backward compatibility. There were so many other ways this could have been solved. Changing class depending on the selected interface altsetting is ugly, IMHO.
Bjørn
RFC 1/1 net: cdc_ncm, cdc_mbim: allow user to prefer NCM for backwards compatibility
Devices implementing NCM backwards compatibility according to section 3.2 of the MBIM v1.0 specification allow either NCM or MBIM on a single USB function, using different altsettings. The cdc_ncm and cdc_mbim drivers will both probe such functions, and must agree on a common policy for selecting either MBIM or NCM. Until now, this policy has been set at build time based on CONFIG_USB_NET_CDC_MBIM.
Use a module parameter to set the system policy at runtime, allowing the user to prefer NCM on systems with the cdc_mbim driver.
---
Maybe something like this? I don't like the way this code looks, but I am unable to make it look more readable...
Does this still work as expected with all your devices? Does it allow you to use cdc_ncm on devices with compatibility mode? I still don't have any such device, except for my fake emulated kvm one.
Thanks for testing.
Bjørn
drivers/net/usb/cdc_mbim.c | 12 +---------- drivers/net/usb/cdc_ncm.c | 49 ++++++++++++++++++++++++++++--------------- include/linux/usb/cdc_ncm.h | 1 + 3 files changed, 34 insertions(+), 28 deletions(-)
drivers/net/usb/cdc_mbim.c +1 -11
@@ -62,24 +62,14 @@ static int cdc_mbim_wdm_manage_power(struct usb_interface *intf, int status)return cdc_mbim_manage_power (dev, status); } -static int cdc_mbim_bind (struct usbnet *dev,struct usb_interface *intf) {struct cdc_ncm_ctx *ctx;struct usb_driver *subdriver =ERR_PTR (-ENODEV );int ret = -ENODEV ; -u8 data_altsetting =CDC_NCM_DATA_ALTSETTING_NCM ; +u8 data_altsetting =cdc_ncm_select_altsetting (dev, intf);struct cdc_mbim_state *info = (void *)&dev->data; -/* see if interface supports MBIM alternate setting */ -if (intf->num_altsetting ==2 ) { -if (!cdc_ncm_comm_intf_is_mbim (intf->cur_altsetting)) -usb_set_interface (dev->udev, - intf->cur_altsetting->desc.bInterfaceNumber, -CDC_NCM_COMM_ALTSETTING_MBIM ); - data_altsetting =CDC_NCM_DATA_ALTSETTING_MBIM ; - } -/* Probably NCM, defer for cdc_ncm_bind */ if (!cdc_ncm_comm_intf_is_mbim (intf->cur_altsetting)) goto err;
drivers/net/usb/cdc_ncm.c +32 -17
70 lines not on this page · raw message
include/linux/usb/cdc_ncm.h +1 -0
@@ -127,6 +127,7 @@ struct cdc_ncm_ctx {u16 connected; }; +extern u8 cdc_ncm_select_altsetting (struct usbnet *dev,struct usb_interface *intf);extern int cdc_ncm_bind_common (struct usbnet *dev,struct usb_interface *intf,u8 data_altsetting);extern void cdc_ncm_unbind (struct usbnet *dev,struct usb_interface *intf);extern struct sk_buff *cdc_ncm_fill_tx_frame (struct cdc_ncm_ctx *ctx,struct sk_buff *skb,__le32 sign);
Signature · 1 line
1.7.10.4
Re: [RFC] net: cdc_ncm, cdc_mbim: allow user to prefer NCM for backwards compatibility
drivers/net/usb/cdc_ncm.c line 64
Quoted 7 lines · Bjørn Mork
drivers/net/usb/cdc_ncm.c +7
-0+#if IS_ENABLED (CONFIG_USB_NET_CDC_MBIM ) +static bool prefer_mbim = true; +#else +static bool prefer_mbim; +#endif +module_param (prefer_mbim, bool,S_IRUGO |S_IWUSR ); +MODULE_PARM_DESC (prefer_mbim,"Prefer MBIM on NCM/MBIM backwards compatible functions" );
So, noone wanting to comment on this? I am not sure how to interpret that. If I liked the solution myself I would just have taken it as an unanimous ack, but I don't...
Please, if your gut feeling is that this is the most stupid thing you've ever seen, then just say so. I can take it :)
Bjørn