Commit 8d88bbff authored by Octavian Purdila's avatar Octavian Purdila Committed by David S. Miller

usbnet: mcs7830: rework link state detection

Even with the quirks in commit dabdaf0c (mcs7830: Fix link state
detection) there are still spurious link-down events for some chips
where the false link-down events count go over a few hundreds.

This patch takes a more conservative approach and only looks at
link-down events where the link-down state is not combined with other
states (e.g. half/full speed, pending frames in SRAM or TX status
information valid). In all other cases we assume the link is up.

Tested on MCS7830CV-DA (USB ID 9710:7830).

Cc: Ondrej Zary <linux@rainbow-software.org>
Cc: Michael Leun <lkml20120218@newton.leun.net>
Cc: Ming Lei <ming.lei@canonical.com>
Signed-off-by: default avatarOctavian Purdila <octavian.purdila@intel.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 2205369a
...@@ -117,7 +117,6 @@ enum { ...@@ -117,7 +117,6 @@ enum {
struct mcs7830_data { struct mcs7830_data {
u8 multi_filter[8]; u8 multi_filter[8];
u8 config; u8 config;
u8 link_counter;
}; };
static const char driver_name[] = "MOSCHIP usb-ethernet driver"; static const char driver_name[] = "MOSCHIP usb-ethernet driver";
...@@ -561,26 +560,16 @@ static void mcs7830_status(struct usbnet *dev, struct urb *urb) ...@@ -561,26 +560,16 @@ static void mcs7830_status(struct usbnet *dev, struct urb *urb)
{ {
u8 *buf = urb->transfer_buffer; u8 *buf = urb->transfer_buffer;
bool link, link_changed; bool link, link_changed;
struct mcs7830_data *data = mcs7830_get_data(dev);
if (urb->actual_length < 16) if (urb->actual_length < 16)
return; return;
link = !(buf[1] & 0x20); link = !(buf[1] == 0x20);
link_changed = netif_carrier_ok(dev->net) != link; link_changed = netif_carrier_ok(dev->net) != link;
if (link_changed) { if (link_changed) {
data->link_counter++;
/*
track link state 20 times to guard against erroneous
link state changes reported sometimes by the chip
*/
if (data->link_counter > 20) {
data->link_counter = 0;
usbnet_link_change(dev, link, 0); usbnet_link_change(dev, link, 0);
netdev_dbg(dev->net, "Link Status is: %d\n", link); netdev_dbg(dev->net, "Link Status is: %d\n", link);
} }
} else
data->link_counter = 0;
} }
static const struct driver_info moschip_info = { static const struct driver_info moschip_info = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment