Loading drivers/usb/gadget/f_qc_ecm.c +93 −0 Original line number Diff line number Diff line Loading @@ -282,6 +282,78 @@ static struct usb_descriptor_header *ecm_qc_hs_function[] = { NULL, }; static struct usb_endpoint_descriptor ecm_qc_ss_notify_desc = { .bLength = USB_DT_ENDPOINT_SIZE, .bDescriptorType = USB_DT_ENDPOINT, .bEndpointAddress = USB_DIR_IN, .bmAttributes = USB_ENDPOINT_XFER_INT, .wMaxPacketSize = cpu_to_le16(ECM_QC_STATUS_BYTECOUNT), .bInterval = ECM_QC_LOG2_STATUS_INTERVAL_MSEC + 4, }; static struct usb_ss_ep_comp_descriptor ecm_qc_ss_notify_comp_desc = { .bLength = sizeof(ecm_qc_ss_notify_comp_desc), .bDescriptorType = USB_DT_SS_ENDPOINT_COMP, /* the following 3 values can be tweaked if necessary */ /* .bMaxBurst = 0, */ /* .bmAttributes = 0, */ .wBytesPerInterval = cpu_to_le16(ECM_QC_STATUS_BYTECOUNT), }; static struct usb_endpoint_descriptor ecm_qc_ss_in_desc = { .bLength = USB_DT_ENDPOINT_SIZE, .bDescriptorType = USB_DT_ENDPOINT, .bEndpointAddress = USB_DIR_IN, .bmAttributes = USB_ENDPOINT_XFER_BULK, .wMaxPacketSize = __constant_cpu_to_le16(1024), }; static struct usb_ss_ep_comp_descriptor ecm_qc_ss_in_comp_desc = { .bLength = sizeof(ecm_qc_ss_in_comp_desc), .bDescriptorType = USB_DT_SS_ENDPOINT_COMP, /* the following 2 values can be tweaked if necessary */ /* .bMaxBurst = 0, */ /* .bmAttributes = 0, */ }; static struct usb_endpoint_descriptor ecm_qc_ss_out_desc = { .bLength = USB_DT_ENDPOINT_SIZE, .bDescriptorType = USB_DT_ENDPOINT, .bEndpointAddress = USB_DIR_OUT, .bmAttributes = USB_ENDPOINT_XFER_BULK, .wMaxPacketSize = __constant_cpu_to_le16(1024), }; static struct usb_ss_ep_comp_descriptor ecm_qc_ss_out_comp_desc = { .bLength = sizeof(ecm_qc_ss_out_comp_desc), .bDescriptorType = USB_DT_SS_ENDPOINT_COMP, /* the following 2 values can be tweaked if necessary */ /* .bMaxBurst = 0, */ /* .bmAttributes = 0, */ }; static struct usb_descriptor_header *ecm_qc_ss_function[] = { /* CDC ECM control descriptors */ (struct usb_descriptor_header *) &ecm_qc_control_intf, (struct usb_descriptor_header *) &ecm_qc_header_desc, (struct usb_descriptor_header *) &ecm_qc_union_desc, (struct usb_descriptor_header *) &ecm_qc_desc, /* NOTE: status endpoint might need to be removed */ (struct usb_descriptor_header *) &ecm_qc_ss_notify_desc, (struct usb_descriptor_header *) &ecm_qc_ss_notify_comp_desc, /* data interface, altsettings 0 and 1 */ (struct usb_descriptor_header *) &ecm_qc_data_nop_intf, (struct usb_descriptor_header *) &ecm_qc_data_intf, (struct usb_descriptor_header *) &ecm_qc_ss_in_desc, (struct usb_descriptor_header *) &ecm_qc_ss_in_comp_desc, (struct usb_descriptor_header *) &ecm_qc_ss_out_desc, (struct usb_descriptor_header *) &ecm_qc_ss_out_comp_desc, NULL, }; /* string descriptors: */ static struct usb_string ecm_qc_string_defs[] = { Loading Loading @@ -881,6 +953,19 @@ ecm_qc_bind(struct usb_configuration *c, struct usb_function *f) goto fail; } if (gadget_is_superspeed(c->cdev->gadget)) { ecm_qc_ss_in_desc.bEndpointAddress = ecm_qc_fs_in_desc.bEndpointAddress; ecm_qc_ss_out_desc.bEndpointAddress = ecm_qc_fs_out_desc.bEndpointAddress; ecm_qc_ss_notify_desc.bEndpointAddress = ecm_qc_fs_notify_desc.bEndpointAddress; f->ss_descriptors = usb_copy_descriptors(ecm_qc_ss_function); if (!f->hs_descriptors) goto fail; } /* NOTE: all that is done without knowing or caring about * the network link ... which is unavailable to this code * until we're activated via set_alt(). Loading @@ -896,6 +981,11 @@ ecm_qc_bind(struct usb_configuration *c, struct usb_function *f) return 0; fail: if (f->ss_descriptors) usb_free_descriptors(f->ss_descriptors); if (f->hs_descriptors) usb_free_descriptors(f->hs_descriptors); if (f->fs_descriptors) usb_free_descriptors(f->fs_descriptors); Loading Loading @@ -925,6 +1015,9 @@ ecm_qc_unbind(struct usb_configuration *c, struct usb_function *f) DBG(c->cdev, "ecm unbind\n"); bam_data_destroy(0); if (gadget_is_superspeed(c->cdev->gadget)) usb_free_descriptors(f->ss_descriptors); if (gadget_is_dualspeed(c->cdev->gadget)) usb_free_descriptors(f->hs_descriptors); usb_free_descriptors(f->fs_descriptors); Loading Loading
drivers/usb/gadget/f_qc_ecm.c +93 −0 Original line number Diff line number Diff line Loading @@ -282,6 +282,78 @@ static struct usb_descriptor_header *ecm_qc_hs_function[] = { NULL, }; static struct usb_endpoint_descriptor ecm_qc_ss_notify_desc = { .bLength = USB_DT_ENDPOINT_SIZE, .bDescriptorType = USB_DT_ENDPOINT, .bEndpointAddress = USB_DIR_IN, .bmAttributes = USB_ENDPOINT_XFER_INT, .wMaxPacketSize = cpu_to_le16(ECM_QC_STATUS_BYTECOUNT), .bInterval = ECM_QC_LOG2_STATUS_INTERVAL_MSEC + 4, }; static struct usb_ss_ep_comp_descriptor ecm_qc_ss_notify_comp_desc = { .bLength = sizeof(ecm_qc_ss_notify_comp_desc), .bDescriptorType = USB_DT_SS_ENDPOINT_COMP, /* the following 3 values can be tweaked if necessary */ /* .bMaxBurst = 0, */ /* .bmAttributes = 0, */ .wBytesPerInterval = cpu_to_le16(ECM_QC_STATUS_BYTECOUNT), }; static struct usb_endpoint_descriptor ecm_qc_ss_in_desc = { .bLength = USB_DT_ENDPOINT_SIZE, .bDescriptorType = USB_DT_ENDPOINT, .bEndpointAddress = USB_DIR_IN, .bmAttributes = USB_ENDPOINT_XFER_BULK, .wMaxPacketSize = __constant_cpu_to_le16(1024), }; static struct usb_ss_ep_comp_descriptor ecm_qc_ss_in_comp_desc = { .bLength = sizeof(ecm_qc_ss_in_comp_desc), .bDescriptorType = USB_DT_SS_ENDPOINT_COMP, /* the following 2 values can be tweaked if necessary */ /* .bMaxBurst = 0, */ /* .bmAttributes = 0, */ }; static struct usb_endpoint_descriptor ecm_qc_ss_out_desc = { .bLength = USB_DT_ENDPOINT_SIZE, .bDescriptorType = USB_DT_ENDPOINT, .bEndpointAddress = USB_DIR_OUT, .bmAttributes = USB_ENDPOINT_XFER_BULK, .wMaxPacketSize = __constant_cpu_to_le16(1024), }; static struct usb_ss_ep_comp_descriptor ecm_qc_ss_out_comp_desc = { .bLength = sizeof(ecm_qc_ss_out_comp_desc), .bDescriptorType = USB_DT_SS_ENDPOINT_COMP, /* the following 2 values can be tweaked if necessary */ /* .bMaxBurst = 0, */ /* .bmAttributes = 0, */ }; static struct usb_descriptor_header *ecm_qc_ss_function[] = { /* CDC ECM control descriptors */ (struct usb_descriptor_header *) &ecm_qc_control_intf, (struct usb_descriptor_header *) &ecm_qc_header_desc, (struct usb_descriptor_header *) &ecm_qc_union_desc, (struct usb_descriptor_header *) &ecm_qc_desc, /* NOTE: status endpoint might need to be removed */ (struct usb_descriptor_header *) &ecm_qc_ss_notify_desc, (struct usb_descriptor_header *) &ecm_qc_ss_notify_comp_desc, /* data interface, altsettings 0 and 1 */ (struct usb_descriptor_header *) &ecm_qc_data_nop_intf, (struct usb_descriptor_header *) &ecm_qc_data_intf, (struct usb_descriptor_header *) &ecm_qc_ss_in_desc, (struct usb_descriptor_header *) &ecm_qc_ss_in_comp_desc, (struct usb_descriptor_header *) &ecm_qc_ss_out_desc, (struct usb_descriptor_header *) &ecm_qc_ss_out_comp_desc, NULL, }; /* string descriptors: */ static struct usb_string ecm_qc_string_defs[] = { Loading Loading @@ -881,6 +953,19 @@ ecm_qc_bind(struct usb_configuration *c, struct usb_function *f) goto fail; } if (gadget_is_superspeed(c->cdev->gadget)) { ecm_qc_ss_in_desc.bEndpointAddress = ecm_qc_fs_in_desc.bEndpointAddress; ecm_qc_ss_out_desc.bEndpointAddress = ecm_qc_fs_out_desc.bEndpointAddress; ecm_qc_ss_notify_desc.bEndpointAddress = ecm_qc_fs_notify_desc.bEndpointAddress; f->ss_descriptors = usb_copy_descriptors(ecm_qc_ss_function); if (!f->hs_descriptors) goto fail; } /* NOTE: all that is done without knowing or caring about * the network link ... which is unavailable to this code * until we're activated via set_alt(). Loading @@ -896,6 +981,11 @@ ecm_qc_bind(struct usb_configuration *c, struct usb_function *f) return 0; fail: if (f->ss_descriptors) usb_free_descriptors(f->ss_descriptors); if (f->hs_descriptors) usb_free_descriptors(f->hs_descriptors); if (f->fs_descriptors) usb_free_descriptors(f->fs_descriptors); Loading Loading @@ -925,6 +1015,9 @@ ecm_qc_unbind(struct usb_configuration *c, struct usb_function *f) DBG(c->cdev, "ecm unbind\n"); bam_data_destroy(0); if (gadget_is_superspeed(c->cdev->gadget)) usb_free_descriptors(f->ss_descriptors); if (gadget_is_dualspeed(c->cdev->gadget)) usb_free_descriptors(f->hs_descriptors); usb_free_descriptors(f->fs_descriptors); Loading