aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKristian Evensen <kristian.evensen@gmail.com>2016-12-01 08:23:17 -0500
committerDavid S. Miller <davem@davemloft.net>2016-12-02 13:40:09 -0500
commitd5c83d0d1d83b3798c71e0c8b7c3624d39c91d88 (patch)
treecc8f88ed714afb50bb8132dd80089c1d4676a4a0
parent6b6ebb6b01c873d0cfe3449e8a1219ee6e5fc022 (diff)
cdc_ether: Fix handling connection notification
Commit bfe9b9d2df66 ("cdc_ether: Improve ZTE MF823/831/910 handling") introduced a work-around in usbnet_cdc_status() for devices that exported cdc carrier on twice on connect. Before the commit, this behavior caused the link state to be incorrect. It was assumed that all CDC Ethernet devices would either export this behavior, or send one off and then one on notification (which seems to be the default behavior). Unfortunately, it turns out multiple devices sends a connection notification multiple times per second (via an interrupt), even when connection state does not change. This has been observed with several different USB LAN dongles (at least), for example 13b1:0041 (Linksys). After bfe9b9d2df66, the link state has been set as down and then up for each notification. This has caused a flood of Netlink NEWLINK messages and syslog to be flooded with messages similar to: cdc_ether 2-1:2.0 eth1: kevent 12 may have been dropped This commit fixes the behavior by reverting usbnet_cdc_status() to how it was before bfe9b9d2df66. The work-around has been moved to a separate status-function which is only called when a known, affect device is detected. v1->v2: * Do not open-code netif_carrier_ok() (thanks Henning Schild). * Call netif_carrier_off() instead of usb_link_change(). This prevents calling schedule_work() twice without giving the work queue a chance to be processed (thanks Bjørn Mork). Fixes: bfe9b9d2df66 ("cdc_ether: Improve ZTE MF823/831/910 handling") Reported-by: Henning Schild <henning.schild@siemens.com> Signed-off-by: Kristian Evensen <kristian.evensen@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/usb/cdc_ether.c38
1 files changed, 31 insertions, 7 deletions
diff --git a/drivers/net/usb/cdc_ether.c b/drivers/net/usb/cdc_ether.c
index c47ec0a04c8e..dd623f674487 100644
--- a/drivers/net/usb/cdc_ether.c
+++ b/drivers/net/usb/cdc_ether.c
@@ -388,12 +388,6 @@ void usbnet_cdc_status(struct usbnet *dev, struct urb *urb)
388 case USB_CDC_NOTIFY_NETWORK_CONNECTION: 388 case USB_CDC_NOTIFY_NETWORK_CONNECTION:
389 netif_dbg(dev, timer, dev->net, "CDC: carrier %s\n", 389 netif_dbg(dev, timer, dev->net, "CDC: carrier %s\n",
390 event->wValue ? "on" : "off"); 390 event->wValue ? "on" : "off");
391
392 /* Work-around for devices with broken off-notifications */
393 if (event->wValue &&
394 !test_bit(__LINK_STATE_NOCARRIER, &dev->net->state))
395 usbnet_link_change(dev, 0, 0);
396
397 usbnet_link_change(dev, !!event->wValue, 0); 391 usbnet_link_change(dev, !!event->wValue, 0);
398 break; 392 break;
399 case USB_CDC_NOTIFY_SPEED_CHANGE: /* tx/rx rates */ 393 case USB_CDC_NOTIFY_SPEED_CHANGE: /* tx/rx rates */
@@ -466,6 +460,36 @@ static int usbnet_cdc_zte_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
466 return 1; 460 return 1;
467} 461}
468 462
463/* Ensure correct link state
464 *
465 * Some devices (ZTE MF823/831/910) export two carrier on notifications when
466 * connected. This causes the link state to be incorrect. Work around this by
467 * always setting the state to off, then on.
468 */
469void usbnet_cdc_zte_status(struct usbnet *dev, struct urb *urb)
470{
471 struct usb_cdc_notification *event;
472
473 if (urb->actual_length < sizeof(*event))
474 return;
475
476 event = urb->transfer_buffer;
477
478 if (event->bNotificationType != USB_CDC_NOTIFY_NETWORK_CONNECTION) {
479 usbnet_cdc_status(dev, urb);
480 return;
481 }
482
483 netif_dbg(dev, timer, dev->net, "CDC: carrier %s\n",
484 event->wValue ? "on" : "off");
485
486 if (event->wValue &&
487 netif_carrier_ok(dev->net))
488 netif_carrier_off(dev->net);
489
490 usbnet_link_change(dev, !!event->wValue, 0);
491}
492
469static const struct driver_info cdc_info = { 493static const struct driver_info cdc_info = {
470 .description = "CDC Ethernet Device", 494 .description = "CDC Ethernet Device",
471 .flags = FLAG_ETHER | FLAG_POINTTOPOINT, 495 .flags = FLAG_ETHER | FLAG_POINTTOPOINT,
@@ -481,7 +505,7 @@ static const struct driver_info zte_cdc_info = {
481 .flags = FLAG_ETHER | FLAG_POINTTOPOINT, 505 .flags = FLAG_ETHER | FLAG_POINTTOPOINT,
482 .bind = usbnet_cdc_zte_bind, 506 .bind = usbnet_cdc_zte_bind,
483 .unbind = usbnet_cdc_unbind, 507 .unbind = usbnet_cdc_unbind,
484 .status = usbnet_cdc_status, 508 .status = usbnet_cdc_zte_status,
485 .set_rx_mode = usbnet_cdc_update_filter, 509 .set_rx_mode = usbnet_cdc_update_filter,
486 .manage_power = usbnet_manage_power, 510 .manage_power = usbnet_manage_power,
487 .rx_fixup = usbnet_cdc_zte_rx_fixup, 511 .rx_fixup = usbnet_cdc_zte_rx_fixup,