Skip to content

Commit 7b8076c

Browse files
dnlplmdavem330
authored andcommitted
NET: usb: cdc_mbim: add quirk for supporting Telit LE922A
Telit LE922A MBIM based composition does not work properly with altsetting toggle done in cdc_ncm_bind_common. This patch adds CDC_MBIM_FLAG_AVOID_ALTSETTING_TOGGLE quirk to avoid this procedure that, instead, is mandatory for other modems. Signed-off-by: Daniele Palmas <dnlplm@gmail.com> Reviewed-by: Bjørn Mork <bjorn@mork.no> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent ec988ad commit 7b8076c

3 files changed

Lines changed: 32 additions & 6 deletions

File tree

drivers/net/usb/cdc_mbim.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,21 @@ static const struct driver_info cdc_mbim_info_ndp_to_end = {
602602
.data = CDC_NCM_FLAG_NDP_TO_END,
603603
};
604604

605+
/* Some modems (e.g. Telit LE922A6) do not work properly with altsetting
606+
* toggle done in cdc_ncm_bind_common. CDC_MBIM_FLAG_AVOID_ALTSETTING_TOGGLE
607+
* flag is used to avoid this procedure.
608+
*/
609+
static const struct driver_info cdc_mbim_info_avoid_altsetting_toggle = {
610+
.description = "CDC MBIM",
611+
.flags = FLAG_NO_SETINT | FLAG_MULTI_PACKET | FLAG_WWAN,
612+
.bind = cdc_mbim_bind,
613+
.unbind = cdc_mbim_unbind,
614+
.manage_power = cdc_mbim_manage_power,
615+
.rx_fixup = cdc_mbim_rx_fixup,
616+
.tx_fixup = cdc_mbim_tx_fixup,
617+
.data = CDC_MBIM_FLAG_AVOID_ALTSETTING_TOGGLE,
618+
};
619+
605620
static const struct usb_device_id mbim_devs[] = {
606621
/* This duplicate NCM entry is intentional. MBIM devices can
607622
* be disguised as NCM by default, and this is necessary to
@@ -626,6 +641,12 @@ static const struct usb_device_id mbim_devs[] = {
626641
{ USB_VENDOR_AND_INTERFACE_INFO(0x12d1, USB_CLASS_COMM, USB_CDC_SUBCLASS_MBIM, USB_CDC_PROTO_NONE),
627642
.driver_info = (unsigned long)&cdc_mbim_info_ndp_to_end,
628643
},
644+
645+
/* Telit LE922A6 in MBIM composition */
646+
{ USB_DEVICE_AND_INTERFACE_INFO(0x1bc7, 0x1041, USB_CLASS_COMM, USB_CDC_SUBCLASS_MBIM, USB_CDC_PROTO_NONE),
647+
.driver_info = (unsigned long)&cdc_mbim_info_avoid_altsetting_toggle,
648+
},
649+
629650
/* default entry */
630651
{ USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_MBIM, USB_CDC_PROTO_NONE),
631652
.driver_info = (unsigned long)&cdc_mbim_info_zlp,

drivers/net/usb/cdc_ncm.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -839,11 +839,18 @@ int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_
839839

840840
iface_no = ctx->data->cur_altsetting->desc.bInterfaceNumber;
841841

842+
/* Device-specific flags */
843+
ctx->drvflags = drvflags;
844+
842845
/* Reset data interface. Some devices will not reset properly
843846
* unless they are configured first. Toggle the altsetting to
844-
* force a reset
847+
* force a reset.
848+
* Some other devices do not work properly with this procedure
849+
* that can be avoided using quirk CDC_MBIM_FLAG_AVOID_ALTSETTING_TOGGLE
845850
*/
846-
usb_set_interface(dev->udev, iface_no, data_altsetting);
851+
if (!(ctx->drvflags & CDC_MBIM_FLAG_AVOID_ALTSETTING_TOGGLE))
852+
usb_set_interface(dev->udev, iface_no, data_altsetting);
853+
847854
temp = usb_set_interface(dev->udev, iface_no, 0);
848855
if (temp) {
849856
dev_dbg(&intf->dev, "set interface failed\n");
@@ -890,9 +897,6 @@ int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_
890897
/* finish setting up the device specific data */
891898
cdc_ncm_setup(dev);
892899

893-
/* Device-specific flags */
894-
ctx->drvflags = drvflags;
895-
896900
/* Allocate the delayed NDP if needed. */
897901
if (ctx->drvflags & CDC_NCM_FLAG_NDP_TO_END) {
898902
ctx->delayed_ndp16 = kzalloc(ctx->max_ndp_size, GFP_KERNEL);

include/linux/usb/cdc_ncm.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@
8181
#define CDC_NCM_TIMER_INTERVAL_MAX (U32_MAX / NSEC_PER_USEC)
8282

8383
/* Driver flags */
84-
#define CDC_NCM_FLAG_NDP_TO_END 0x02 /* NDP is placed at end of frame */
84+
#define CDC_NCM_FLAG_NDP_TO_END 0x02 /* NDP is placed at end of frame */
85+
#define CDC_MBIM_FLAG_AVOID_ALTSETTING_TOGGLE 0x04 /* Avoid altsetting toggle during init */
8586

8687
#define cdc_ncm_comm_intf_is_mbim(x) ((x)->desc.bInterfaceSubClass == USB_CDC_SUBCLASS_MBIM && \
8788
(x)->desc.bInterfaceProtocol == USB_CDC_PROTO_NONE)

0 commit comments

Comments
 (0)