static void cdc_ncm_status(struct usbnet *dev, struct urb *urb) { struct cdc_ncm_ctx *ctx; struct usb_cdc_notification *event; ctx = (struct cdc_ncm_ctx *)dev->data[0]; if (urb->actual_length < sizeof(*event)) return; /* test for split data in 8-byte chunks */ if (test_and_clear_bit(EVENT_STS_SPLIT, &dev->flags)) { cdc_ncm_speed_change(dev, (struct usb_cdc_speed_change *)urb->transfer_buffer); return; } event = urb->transfer_buffer; switch (event->bNotificationType) { case USB_CDC_NOTIFY_NETWORK_CONNECTION: /* * According to the CDC NCM specification ch.7.1 * USB_CDC_NOTIFY_NETWORK_CONNECTION notification shall be * sent by device after USB_CDC_NOTIFY_SPEED_CHANGE. */ ctx->connected = le16_to_cpu(event->wValue); printk(KERN_INFO KBUILD_MODNAME ": %s: network connection:" " %sconnected\n", dev->net->name, ctx->connected ? "" : "dis"); if (ctx->connected) netif_carrier_on(dev->net); else { netif_carrier_off(dev->net); } break; case USB_CDC_NOTIFY_RESPONSE_AVAILABLE: /* Not implemented yet */ dev_dbg(&dev->udev->dev, "NCM: ResponseAvailable - Value=%d, Index=%d\n", le16_to_cpu(event->wValue), le16_to_cpu(event->wIndex)); break; case USB_CDC_NOTIFY_SPEED_CHANGE: if (urb->actual_length < (sizeof(*event) + sizeof(struct usb_cdc_speed_change))) set_bit(EVENT_STS_SPLIT, &dev->flags); else cdc_ncm_speed_change(dev, (struct usb_cdc_speed_change *)&event[1]); break; default: dev_err(&dev->udev->dev, "NCM: unexpected " "notification 0x%02x!\n", event->bNotificationType); break; } }
static void cdc_ncm_status(struct if_usb_devdata *pipe_data, struct urb *urb) { struct cdc_ncm_ctx *ctx; struct usb_cdc_notification *event; ctx = (struct cdc_ncm_ctx *)pipe_data->sedata; if (urb->actual_length < sizeof(*event)) return; /* test for split data in 8-byte chunks */ if (test_and_clear_bit(EVENT_STS_SPLIT, &pipe_data->flags)) { cdc_ncm_speed_change(ctx, (struct usb_cdc_speed_change *)urb->transfer_buffer); return; } event = urb->transfer_buffer; mif_debug("event: %d by ep=%d\n", event->bNotificationType, usb_pipeendpoint(urb->pipe)); switch (event->bNotificationType) { case USB_CDC_NOTIFY_NETWORK_CONNECTION: /* * According to the CDC NCM specification ch.7.1 * USB_CDC_NOTIFY_NETWORK_CONNECTION notification shall be * sent by device after USB_CDC_NOTIFY_SPEED_CHANGE. */ ctx->connected = event->wValue; pipe_data->net_connected = (event->wValue) ? true : false; printk(KERN_INFO KBUILD_MODNAME ": network connection: %s connected\n", ctx->connected ? "" : "dis"); if (ctx->connected) netif_carrier_on(pipe_data->iod->ndev); else { netif_carrier_off(pipe_data->iod->ndev); ctx->tx_speed = ctx->rx_speed = 0; } break; case USB_CDC_NOTIFY_SPEED_CHANGE: if (urb->actual_length < (sizeof(*event) + sizeof(struct usb_cdc_speed_change))) set_bit(EVENT_STS_SPLIT, &pipe_data->flags); else cdc_ncm_speed_change(ctx, (struct usb_cdc_speed_change *) &event[1]); break; default: mif_err("unexpected notification 0x%02x!\n", event->bNotificationType); break; } }
static void cdc_ncm_status(struct usbnet *dev, struct urb *urb) { struct cdc_ncm_ctx *ctx; struct usb_cdc_notification *event; ctx = (struct cdc_ncm_ctx *)dev->data[0]; if (urb->actual_length < sizeof(*event)) return; /* test for split data in 8-byte chunks */ if (test_and_clear_bit(EVENT_STS_SPLIT, &dev->flags)) { cdc_ncm_speed_change(ctx, (struct usb_cdc_speed_change *)urb->transfer_buffer); return; } event = urb->transfer_buffer; switch (event->bNotificationType) { case USB_CDC_NOTIFY_NETWORK_CONNECTION: /* * According to the CDC NCM specification ch.7.1 * USB_CDC_NOTIFY_NETWORK_CONNECTION notification shall be * sent by device after USB_CDC_NOTIFY_SPEED_CHANGE. */ ctx->connected = le16_to_cpu(event->wValue); printk(KERN_INFO KBUILD_MODNAME ": %s: network connection:" " %sconnected\n", ctx->netdev->name, ctx->connected ? "" : "dis"); usbnet_link_change(dev, ctx->connected, 0); if (!ctx->connected) ctx->tx_speed = ctx->rx_speed = 0; break; case USB_CDC_NOTIFY_SPEED_CHANGE: if (urb->actual_length < (sizeof(*event) + sizeof(struct usb_cdc_speed_change))) set_bit(EVENT_STS_SPLIT, &dev->flags); else cdc_ncm_speed_change(ctx, (struct usb_cdc_speed_change *) &event[1]); break; default: dev_dbg(&dev->udev->dev, "NCM: unexpected notification 0x%02x!\n", event->bNotificationType); break; } }
void cdc_ncm_status(PMP_ADAPTER Adapter, PVOID buffer,NCMDWORD length) { PUSB_CDC_NOTIFICATION event; PMP_USBPIPE usbpipe=Adapter->UsbPipeForNIC; if (length< sizeof(USB_CDC_NOTIFICATION)) return; event =(PUSB_CDC_NOTIFICATION)buffer; switch (event->bNotificationType) { case USB_CDC_NOTIFY_NETWORK_CONNECTION: /* * According to the CDC NCM specification ch.7.1 * USB_CDC_NOTIFY_NETWORK_CONNECTION notification shall be * sent by device after USB_CDC_NOTIFY_SPEED_CHANGE. */ usbpipe->connected = le16_to_cpu(event->wValue); DEBUGP(MP_INFO,("network connection: %sconnected\n",usbpipe->connected ? "" : "dis")); if(usbpipe->connected) { MP_CLEAR_FLAG(Adapter,fMP_DISCONNECTED); }else { MP_SET_FLAG(Adapter,fMP_DISCONNECTED); } break; case USB_CDC_NOTIFY_SPEED_CHANGE: if (length>=(sizeof(USB_CDC_NOTIFICATION) +sizeof(USB_CDC_SPEED_CHANGE))) { cdc_ncm_speed_change(Adapter, ( PUSB_CDC_SPEED_CHANGE)(event+sizeof(USB_CDC_SPEED_CHANGE))); }else { DEBUGP(MP_INFO,("USB_CDC_NOTIFY_SPEED_CHANGE notify length is short:%d\n",length)); } break; default: DEBUGP(MP_ERROR,("NCM: unexpected notification 0x%02x!\n", event->bNotificationType) ); break; } }