Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F168586784
D58641.id183375.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D58641.id183375.diff
View Options
diff --git a/sys/dev/usb/net/if_umb.c b/sys/dev/usb/net/if_umb.c
--- a/sys/dev/usb/net/if_umb.c
+++ b/sys/dev/usb/net/if_umb.c
@@ -170,6 +170,7 @@
static device_detach_t umb_detach;
static device_suspend_t umb_suspend;
static device_resume_t umb_resume;
+static int umb_find_iad_data_interface(struct usb_device *, uint8_t);
static void umb_attach_task(struct usb_proc_msg *);
static usb_handle_request_t umb_handle_request;
static int umb_deactivate(device_t);
@@ -398,6 +399,63 @@
return (ENXIO);
}
+static int
+umb_find_iad_data_interface(struct usb_device *udev, uint8_t ctrl_ifaceno)
+{
+ const usb_config_descriptor_t *cd;
+ const usb_descriptor_t *desc;
+ const usb_interface_assoc_descriptor_t *iad;
+ usb_interface_descriptor_t *id;
+ struct usb_interface *iface;
+ const uint8_t *end;
+ uint8_t first, count;
+ int i;
+
+ cd = usbd_get_config_descriptor(udev);
+ if (cd == NULL)
+ return (-1);
+
+ first = count = 0;
+ end = (const uint8_t *)cd + UGETW(cd->wTotalLength);
+ for (desc = (const usb_descriptor_t *)cd;
+ (const uint8_t *)desc + sizeof(*desc) <= end &&
+ desc->bLength >= sizeof(*desc) &&
+ (const uint8_t *)desc + desc->bLength <= end;
+ desc = (const usb_descriptor_t *)
+ ((const uint8_t *)desc + desc->bLength)) {
+ if (desc->bDescriptorType != UDESC_IFACE_ASSOC ||
+ desc->bLength < sizeof(*iad))
+ continue;
+
+ iad = (const usb_interface_assoc_descriptor_t *)desc;
+ if (ctrl_ifaceno >= iad->bFirstInterface &&
+ ctrl_ifaceno <
+ iad->bFirstInterface + iad->bInterfaceCount) {
+ first = iad->bFirstInterface;
+ count = iad->bInterfaceCount;
+ break;
+ }
+ }
+ if (count == 0)
+ return (-1);
+
+ for (i = 0; i < udev->ifaces_max; i++) {
+ iface = usbd_get_iface(udev, i);
+ if (iface == NULL)
+ continue;
+ id = usbd_get_interface_descriptor(iface);
+ if (id == NULL || id->bAlternateSetting != 0)
+ continue;
+ if (id->bInterfaceNumber < first ||
+ id->bInterfaceNumber >= first + count)
+ continue;
+ if (id->bInterfaceClass == UICLASS_CDC_DATA)
+ return (id->bInterfaceNumber);
+ }
+
+ return (-1);
+}
+
static int
umb_attach(device_t dev)
{
@@ -436,9 +494,11 @@
ud = usbd_find_descriptor(sc->sc_udev, id, uaa->info.bIfaceIndex,
UDESC_CS_INTERFACE, 0xff, UDESCSUB_CDC_UNION, 0xff);
- if (ud != NULL) {
+ if (ud != NULL)
data_ifaceno = ud->bSlaveInterface[0];
- }
+ else
+ data_ifaceno = umb_find_iad_data_interface(sc->sc_udev,
+ sc->sc_ctrl_ifaceno);
md = usbd_find_descriptor(sc->sc_udev, id, uaa->info.bIfaceIndex,
UDESC_CS_INTERFACE, 0xff, UDESCSUB_MBIM, 0xff);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Aug 30, 3:43 AM (9 h, 10 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
36033912
Default Alt Text
D58641.id183375.diff (2 KB)
Attached To
Mode
D58641: usb: umb: locate MBIM data interface using IAD
Attached
Detach File
Event Timeline
Log In to Comment