• Home
  • Raw
  • Download

Lines Matching refs:ncm

435 static inline void ncm_reset_values(struct f_ncm *ncm)  in ncm_reset_values()  argument
437 ncm->parser_opts = &ndp16_opts; in ncm_reset_values()
438 ncm->is_crc = false; in ncm_reset_values()
439 ncm->port.cdc_filter = DEFAULT_FILTER; in ncm_reset_values()
442 ncm->port.header_len = 0; in ncm_reset_values()
444 ncm->port.fixed_out_len = le32_to_cpu(ntb_parameters.dwNtbOutMaxSize); in ncm_reset_values()
445 ncm->port.fixed_in_len = NTB_DEFAULT_IN_SIZE; in ncm_reset_values()
451 static void ncm_do_notify(struct f_ncm *ncm) in ncm_do_notify() argument
453 struct usb_request *req = ncm->notify_req; in ncm_do_notify()
455 struct usb_composite_dev *cdev = ncm->port.func.config->cdev; in ncm_do_notify()
464 switch (ncm->notify_state) { in ncm_do_notify()
470 if (ncm->is_open) in ncm_do_notify()
478 ncm->is_open ? "true" : "false"); in ncm_do_notify()
479 ncm->notify_state = NCM_NOTIFY_NONE; in ncm_do_notify()
494 ncm->notify_state = NCM_NOTIFY_CONNECT; in ncm_do_notify()
498 event->wIndex = cpu_to_le16(ncm->ctrl_id); in ncm_do_notify()
500 ncm->notify_req = NULL; in ncm_do_notify()
506 spin_unlock(&ncm->lock); in ncm_do_notify()
507 status = usb_ep_queue(ncm->notify, req, GFP_ATOMIC); in ncm_do_notify()
508 spin_lock(&ncm->lock); in ncm_do_notify()
510 ncm->notify_req = req; in ncm_do_notify()
518 static void ncm_notify(struct f_ncm *ncm) in ncm_notify() argument
530 ncm->notify_state = NCM_NOTIFY_SPEED; in ncm_notify()
531 ncm_do_notify(ncm); in ncm_notify()
536 struct f_ncm *ncm = req->context; in ncm_notify_complete() local
537 struct usb_composite_dev *cdev = ncm->port.func.config->cdev; in ncm_notify_complete()
540 spin_lock(&ncm->lock); in ncm_notify_complete()
548 ncm->notify_state = NCM_NOTIFY_NONE; in ncm_notify_complete()
555 ncm->notify_req = req; in ncm_notify_complete()
556 ncm_do_notify(ncm); in ncm_notify_complete()
557 spin_unlock(&ncm->lock); in ncm_notify_complete()
565 struct f_ncm *ncm = func_to_ncm(f); in ncm_ep0out_complete() local
581 ncm->port.fixed_in_len = in_size; in ncm_ep0out_complete()
592 struct f_ncm *ncm = func_to_ncm(f); in ncm_setup() local
611 if (w_length != 0 || w_index != ncm->ctrl_id) in ncm_setup()
619 ncm->port.cdc_filter = w_value; in ncm_setup()
635 if (w_length == 0 || w_value != 0 || w_index != ncm->ctrl_id) in ncm_setup()
646 if (w_length < 4 || w_value != 0 || w_index != ncm->ctrl_id) in ncm_setup()
648 put_unaligned_le32(ncm->port.fixed_in_len, req->buf); in ncm_setup()
651 ncm->port.fixed_in_len); in ncm_setup()
657 if (w_length != 4 || w_value != 0 || w_index != ncm->ctrl_id) in ncm_setup()
672 if (w_length < 2 || w_value != 0 || w_index != ncm->ctrl_id) in ncm_setup()
674 format = (ncm->parser_opts == &ndp16_opts) ? 0x0000 : 0x0001; in ncm_setup()
684 if (w_length != 0 || w_index != ncm->ctrl_id) in ncm_setup()
688 ncm->parser_opts = &ndp16_opts; in ncm_setup()
692 ncm->parser_opts = &ndp32_opts; in ncm_setup()
706 if (w_length < 2 || w_value != 0 || w_index != ncm->ctrl_id) in ncm_setup()
708 is_crc = ncm->is_crc ? 0x0001 : 0x0000; in ncm_setup()
720 if (w_length != 0 || w_index != ncm->ctrl_id) in ncm_setup()
724 ncm->is_crc = false; in ncm_setup()
729 ncm->is_crc = true; in ncm_setup()
736 ncm->ndp_sign = ncm->parser_opts->ndp_sign | ndp_hdr_crc; in ncm_setup()
775 struct f_ncm *ncm = func_to_ncm(f); in ncm_set_alt() local
779 if (intf == ncm->ctrl_id) { in ncm_set_alt()
783 if (ncm->notify->driver_data) { in ncm_set_alt()
785 usb_ep_disable(ncm->notify); in ncm_set_alt()
788 if (!(ncm->notify->desc)) { in ncm_set_alt()
790 if (config_ep_by_speed(cdev->gadget, f, ncm->notify)) in ncm_set_alt()
793 usb_ep_enable(ncm->notify); in ncm_set_alt()
794 ncm->notify->driver_data = ncm; in ncm_set_alt()
797 } else if (intf == ncm->data_id) { in ncm_set_alt()
801 if (ncm->port.in_ep->driver_data) { in ncm_set_alt()
803 gether_disconnect(&ncm->port); in ncm_set_alt()
804 ncm_reset_values(ncm); in ncm_set_alt()
814 if (!ncm->port.in_ep->desc || in ncm_set_alt()
815 !ncm->port.out_ep->desc) { in ncm_set_alt()
818 ncm->port.in_ep) || in ncm_set_alt()
820 ncm->port.out_ep)) { in ncm_set_alt()
821 ncm->port.in_ep->desc = NULL; in ncm_set_alt()
822 ncm->port.out_ep->desc = NULL; in ncm_set_alt()
831 ncm->port.is_zlp_ok = !( in ncm_set_alt()
834 ncm->port.cdc_filter = DEFAULT_FILTER; in ncm_set_alt()
836 net = gether_connect(&ncm->port); in ncm_set_alt()
841 spin_lock(&ncm->lock); in ncm_set_alt()
842 ncm_notify(ncm); in ncm_set_alt()
843 spin_unlock(&ncm->lock); in ncm_set_alt()
858 struct f_ncm *ncm = func_to_ncm(f); in ncm_get_alt() local
860 if (intf == ncm->ctrl_id) in ncm_get_alt()
862 return ncm->port.in_ep->driver_data ? 1 : 0; in ncm_get_alt()
868 struct f_ncm *ncm = func_to_ncm(&port->func); in ncm_wrap_ntb() local
877 unsigned max_size = ncm->port.fixed_in_len; in ncm_wrap_ntb()
878 const struct ndp_parser_opts *opts = ncm->parser_opts; in ncm_wrap_ntb()
879 unsigned crc_len = ncm->is_crc ? sizeof(uint32_t) : 0; in ncm_wrap_ntb()
924 put_unaligned_le32(ncm->ndp_sign, tmp); /* dwSignature */ in ncm_wrap_ntb()
933 if (ncm->is_crc) { in ncm_wrap_ntb()
960 struct f_ncm *ncm = func_to_ncm(&port->func); in ncm_unwrap_ntb() local
968 const struct ndp_parser_opts *opts = ncm->parser_opts; in ncm_unwrap_ntb()
969 unsigned crc_len = ncm->is_crc ? sizeof(uint32_t) : 0; in ncm_unwrap_ntb()
1005 if (get_unaligned_le32(tmp) != ncm->ndp_sign) { in ncm_unwrap_ntb()
1040 if (ncm->is_crc) { in ncm_unwrap_ntb()
1092 struct f_ncm *ncm = func_to_ncm(f); in ncm_disable() local
1097 if (ncm->port.in_ep->driver_data) in ncm_disable()
1098 gether_disconnect(&ncm->port); in ncm_disable()
1100 if (ncm->notify->driver_data) { in ncm_disable()
1101 usb_ep_disable(ncm->notify); in ncm_disable()
1102 ncm->notify->driver_data = NULL; in ncm_disable()
1103 ncm->notify->desc = NULL; in ncm_disable()
1129 struct f_ncm *ncm = func_to_ncm(&geth->func); in ncm_open() local
1131 DBG(ncm->port.func.config->cdev, "%s\n", __func__); in ncm_open()
1133 spin_lock(&ncm->lock); in ncm_open()
1134 ncm->is_open = true; in ncm_open()
1135 ncm_notify(ncm); in ncm_open()
1136 spin_unlock(&ncm->lock); in ncm_open()
1141 struct f_ncm *ncm = func_to_ncm(&geth->func); in ncm_close() local
1143 DBG(ncm->port.func.config->cdev, "%s\n", __func__); in ncm_close()
1145 spin_lock(&ncm->lock); in ncm_close()
1146 ncm->is_open = false; in ncm_close()
1147 ncm_notify(ncm); in ncm_close()
1148 spin_unlock(&ncm->lock); in ncm_close()
1159 struct f_ncm *ncm = func_to_ncm(f); in ncm_bind() local
1167 ncm->ctrl_id = status; in ncm_bind()
1176 ncm->data_id = status; in ncm_bind()
1188 ncm->port.in_ep = ep; in ncm_bind()
1194 ncm->port.out_ep = ep; in ncm_bind()
1200 ncm->notify = ep; in ncm_bind()
1206 ncm->notify_req = usb_ep_alloc_request(ep, GFP_KERNEL); in ncm_bind()
1207 if (!ncm->notify_req) in ncm_bind()
1209 ncm->notify_req->buf = kmalloc(NCM_STATUS_BYTECOUNT, GFP_KERNEL); in ncm_bind()
1210 if (!ncm->notify_req->buf) in ncm_bind()
1212 ncm->notify_req->context = ncm; in ncm_bind()
1213 ncm->notify_req->complete = ncm_notify_complete; in ncm_bind()
1233 ncm->port.open = ncm_open; in ncm_bind()
1234 ncm->port.close = ncm_close; in ncm_bind()
1238 ncm->port.in_ep->name, ncm->port.out_ep->name, in ncm_bind()
1239 ncm->notify->name); in ncm_bind()
1244 if (ncm->notify_req) { in ncm_bind()
1245 kfree(ncm->notify_req->buf); in ncm_bind()
1246 usb_ep_free_request(ncm->notify, ncm->notify_req); in ncm_bind()
1250 if (ncm->notify) in ncm_bind()
1251 ncm->notify->driver_data = NULL; in ncm_bind()
1252 if (ncm->port.out_ep) in ncm_bind()
1253 ncm->port.out_ep->driver_data = NULL; in ncm_bind()
1254 if (ncm->port.in_ep) in ncm_bind()
1255 ncm->port.in_ep->driver_data = NULL; in ncm_bind()
1265 struct f_ncm *ncm = func_to_ncm(f); in ncm_unbind() local
1272 kfree(ncm->notify_req->buf); in ncm_unbind()
1273 usb_ep_free_request(ncm->notify, ncm->notify_req); in ncm_unbind()
1275 kfree(ncm); in ncm_unbind()
1293 struct f_ncm *ncm; in ncm_bind_config() local
1315 ncm = kzalloc(sizeof *ncm, GFP_KERNEL); in ncm_bind_config()
1316 if (!ncm) in ncm_bind_config()
1320 snprintf(ncm->ethaddr, sizeof ncm->ethaddr, "%pm", ethaddr); in ncm_bind_config()
1321 ncm_string_defs[STRING_MAC_IDX].s = ncm->ethaddr; in ncm_bind_config()
1323 spin_lock_init(&ncm->lock); in ncm_bind_config()
1324 ncm_reset_values(ncm); in ncm_bind_config()
1325 ncm->port.ioport = dev; in ncm_bind_config()
1326 ncm->port.is_fixed = true; in ncm_bind_config()
1328 ncm->port.func.name = "cdc_network"; in ncm_bind_config()
1329 ncm->port.func.strings = ncm_strings; in ncm_bind_config()
1331 ncm->port.func.bind = ncm_bind; in ncm_bind_config()
1332 ncm->port.func.unbind = ncm_unbind; in ncm_bind_config()
1333 ncm->port.func.set_alt = ncm_set_alt; in ncm_bind_config()
1334 ncm->port.func.get_alt = ncm_get_alt; in ncm_bind_config()
1335 ncm->port.func.setup = ncm_setup; in ncm_bind_config()
1336 ncm->port.func.disable = ncm_disable; in ncm_bind_config()
1338 ncm->port.wrap = ncm_wrap_ntb; in ncm_bind_config()
1339 ncm->port.unwrap = ncm_unwrap_ntb; in ncm_bind_config()
1341 status = usb_add_function(c, &ncm->port.func); in ncm_bind_config()
1343 kfree(ncm); in ncm_bind_config()