Lines Matching refs:ecm
375 static void ecm_do_notify(struct f_ecm *ecm)
377 struct usb_request *req = ecm->notify_req;
379 struct usb_composite_dev *cdev = ecm->port.func.config->cdev;
384 if (atomic_read(&ecm->notify_count))
388 switch (ecm->notify_state) {
394 if (ecm->is_open)
402 ecm->is_open ? "true" : "false");
403 ecm->notify_state = ECM_NOTIFY_SPEED;
418 ecm->notify_state = ECM_NOTIFY_NONE;
422 event->wIndex = cpu_to_le16(ecm->ctrl_id);
424 atomic_inc(&ecm->notify_count);
425 status = usb_ep_queue(ecm->notify, req, GFP_ATOMIC);
427 atomic_dec(&ecm->notify_count);
432 static void ecm_notify(struct f_ecm *ecm)
439 ecm->notify_state = ECM_NOTIFY_CONNECT;
440 ecm_do_notify(ecm);
445 struct f_ecm *ecm = req->context;
446 struct usb_composite_dev *cdev = ecm->port.func.config->cdev;
452 atomic_dec(&ecm->notify_count);
456 atomic_set(&ecm->notify_count, 0);
457 ecm->notify_state = ECM_NOTIFY_NONE;
462 atomic_dec(&ecm->notify_count);
465 ecm_do_notify(ecm);
470 struct f_ecm *ecm = func_to_ecm(f);
487 if (w_length != 0 || w_index != ecm->ctrl_id)
494 ecm->port.cdc_filter = w_value;
516 DBG(cdev, "ecm req%02x.%02x v%04x i%04x l%d\n",
523 ERROR(cdev, "ecm req %02x.%02x response err %d\n",
535 struct f_ecm *ecm = func_to_ecm(f);
539 if (intf == ecm->ctrl_id) {
543 VDBG(cdev, "reset ecm control %d\n", intf);
544 usb_ep_disable(ecm->notify);
545 if (!(ecm->notify->desc)) {
546 VDBG(cdev, "init ecm ctrl %d\n", intf);
547 if (config_ep_by_speed(cdev->gadget, f, ecm->notify))
550 usb_ep_enable(ecm->notify);
553 } else if (intf == ecm->data_id) {
557 if (ecm->port.in_ep->enabled) {
558 DBG(cdev, "reset ecm\n");
559 gether_disconnect(&ecm->port);
562 if (!ecm->port.in_ep->desc ||
563 !ecm->port.out_ep->desc) {
564 DBG(cdev, "init ecm\n");
566 ecm->port.in_ep) ||
568 ecm->port.out_ep)) {
569 ecm->port.in_ep->desc = NULL;
570 ecm->port.out_ep->desc = NULL;
584 ecm->port.is_zlp_ok =
586 ecm->port.cdc_filter = DEFAULT_FILTER;
587 DBG(cdev, "activate ecm\n");
588 net = gether_connect(&ecm->port);
599 ecm_notify(ecm);
613 struct f_ecm *ecm = func_to_ecm(f);
615 if (intf == ecm->ctrl_id)
617 return ecm->port.in_ep->enabled ? 1 : 0;
622 struct f_ecm *ecm = func_to_ecm(f);
625 DBG(cdev, "ecm deactivated\n");
627 if (ecm->port.in_ep->enabled) {
628 gether_disconnect(&ecm->port);
630 ecm->port.in_ep->desc = NULL;
631 ecm->port.out_ep->desc = NULL;
634 usb_ep_disable(ecm->notify);
635 ecm->notify->desc = NULL;
660 struct f_ecm *ecm = func_to_ecm(&geth->func);
662 DBG(ecm->port.func.config->cdev, "%s\n", __func__);
664 ecm->is_open = true;
665 ecm_notify(ecm);
670 struct f_ecm *ecm = func_to_ecm(&geth->func);
672 DBG(ecm->port.func.config->cdev, "%s\n", __func__);
674 ecm->is_open = false;
675 ecm_notify(ecm);
686 struct f_ecm *ecm = func_to_ecm(f);
715 ecm_string_defs[1].s = ecm->ethaddr;
730 ecm->ctrl_id = status;
739 ecm->data_id = status;
751 ecm->port.in_ep = ep;
756 ecm->port.out_ep = ep;
765 ecm->notify = ep;
770 ecm->notify_req = usb_ep_alloc_request(ep, GFP_KERNEL);
771 if (!ecm->notify_req)
773 ecm->notify_req->buf = kmalloc(ECM_STATUS_BYTECOUNT, GFP_KERNEL);
774 if (!ecm->notify_req->buf)
776 ecm->notify_req->context = ecm;
777 ecm->notify_req->complete = ecm_notify_complete;
803 ecm->port.open = ecm_open;
804 ecm->port.close = ecm_close;
809 ecm->port.in_ep->name, ecm->port.out_ep->name,
810 ecm->notify->name);
814 if (ecm->notify_req) {
815 kfree(ecm->notify_req->buf);
816 usb_ep_free_request(ecm->notify, ecm->notify_req);
831 USB_ETHERNET_CONFIGFS_ITEM(ecm);
834 USB_ETHERNET_CONFIGFS_ITEM_ATTR_DEV_ADDR(ecm);
837 USB_ETHERNET_CONFIGFS_ITEM_ATTR_HOST_ADDR(ecm);
840 USB_ETHERNET_CONFIGFS_ITEM_ATTR_QMULT(ecm);
843 USB_ETHERNET_CONFIGFS_ITEM_ATTR_IFNAME(ecm);
894 struct f_ecm *ecm;
897 ecm = func_to_ecm(f);
899 kfree(ecm);
907 struct f_ecm *ecm = func_to_ecm(f);
909 DBG(c->cdev, "ecm unbind\n");
913 if (atomic_read(&ecm->notify_count)) {
914 usb_ep_dequeue(ecm->notify, ecm->notify_req);
915 atomic_set(&ecm->notify_count, 0);
918 kfree(ecm->notify_req->buf);
919 usb_ep_free_request(ecm->notify, ecm->notify_req);
924 struct f_ecm *ecm;
929 ecm = kzalloc(sizeof(*ecm), GFP_KERNEL);
930 if (!ecm)
938 status = gether_get_host_addr_cdc(opts->net, ecm->ethaddr,
939 sizeof(ecm->ethaddr));
941 kfree(ecm);
946 ecm->port.ioport = netdev_priv(opts->net);
948 ecm->port.cdc_filter = DEFAULT_FILTER;
950 ecm->port.func.name = "cdc_ethernet";
952 ecm->port.func.bind = ecm_bind;
953 ecm->port.func.unbind = ecm_unbind;
954 ecm->port.func.set_alt = ecm_set_alt;
955 ecm->port.func.get_alt = ecm_get_alt;
956 ecm->port.func.setup = ecm_setup;
957 ecm->port.func.disable = ecm_disable;
958 ecm->port.func.free_func = ecm_free;
960 return &ecm->port.func;
963 DECLARE_USB_FUNCTION_INIT(ecm, ecm_alloc_inst, ecm_alloc);