* [PATCH 00/11] usbnet: usbnet: handle link change
@ 2013-04-11 14:40 Ming Lei
2013-04-11 14:40 ` [PATCH 01/11] usbnet: introduce usbnet_link_change API Ming Lei
` (11 more replies)
0 siblings, 12 replies; 18+ messages in thread
From: Ming Lei @ 2013-04-11 14:40 UTC (permalink / raw)
To: David S. Miller, Greg Kroah-Hartman; +Cc: Oliver Neukum, netdev, linux-usb
Hi,
This patch set introduces usbnet_link_change() API and applies
it on all usbnet drivers, then handle the link change centrally
to stop bulk transfer when link becomes off and restart bulk
transfer when link becomes on.
With the change, ~10% performance boost on bulk transfer
of another device on the same bus can be obtained when link
is off. Also, stopping bulk transfer when link becomes off
may disable asynchonous schedule of host controller, power
might be saved probabally.
drivers/net/usb/asix_devices.c | 6 +-----
drivers/net/usb/ax88179_178a.c | 12 ++++-------
drivers/net/usb/cdc_ether.c | 5 +----
drivers/net/usb/cdc_ncm.c | 9 +++-----
drivers/net/usb/dm9601.c | 7 +------
drivers/net/usb/mcs7830.c | 6 +-----
drivers/net/usb/sierra_net.c | 3 +--
drivers/net/usb/usbnet.c | 45 +++++++++++++++++++++++++++++++++++++++-
include/linux/usb/usbnet.h | 2 ++
9 files changed, 58 insertions(+), 37 deletions(-)
Thanks,
--
Ming Lei
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 01/11] usbnet: introduce usbnet_link_change API
2013-04-11 14:40 [PATCH 00/11] usbnet: usbnet: handle link change Ming Lei
@ 2013-04-11 14:40 ` Ming Lei
2013-04-11 14:40 ` [PATCH 02/11] usbnet: mcs7830: don't reset link Ming Lei
` (10 subsequent siblings)
11 siblings, 0 replies; 18+ messages in thread
From: Ming Lei @ 2013-04-11 14:40 UTC (permalink / raw)
To: David S. Miller, Greg Kroah-Hartman
Cc: Oliver Neukum, netdev, linux-usb, Ming Lei
This patch introduces the API of usbnet_link_change, so that
usbnet can handle link change centrally, which may help to
implement killing traffic URBs for saving USB bus bandwidth
and host controller power.
Signed-off-by: Ming Lei <ming.lei@canonical.com>
---
drivers/net/usb/usbnet.c | 13 +++++++++++++
include/linux/usb/usbnet.h | 1 +
2 files changed, 14 insertions(+)
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 51f3192..40e4237 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -1653,6 +1653,19 @@ int usbnet_manage_power(struct usbnet *dev, int on)
}
EXPORT_SYMBOL(usbnet_manage_power);
+void usbnet_link_change(struct usbnet *dev, bool link, bool need_reset)
+{
+ /* update link after link is reseted */
+ if (link && !need_reset)
+ netif_carrier_on(dev->net);
+ else
+ netif_carrier_off(dev->net);
+
+ if (need_reset && link)
+ usbnet_defer_kevent(dev, EVENT_LINK_RESET);
+}
+EXPORT_SYMBOL(usbnet_link_change);
+
/*-------------------------------------------------------------------------*/
static int __usbnet_read_cmd(struct usbnet *dev, u8 cmd, u8 reqtype,
u16 value, u16 index, void *data, u16 size)
diff --git a/include/linux/usb/usbnet.h b/include/linux/usb/usbnet.h
index 0e5ac93..eb021b8 100644
--- a/include/linux/usb/usbnet.h
+++ b/include/linux/usb/usbnet.h
@@ -245,5 +245,6 @@ extern void usbnet_get_drvinfo(struct net_device *, struct ethtool_drvinfo *);
extern int usbnet_nway_reset(struct net_device *net);
extern int usbnet_manage_power(struct usbnet *, int);
+extern void usbnet_link_change(struct usbnet *, bool, bool);
#endif /* __LINUX_USB_USBNET_H */
--
1.7.9.5
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 02/11] usbnet: mcs7830: don't reset link
2013-04-11 14:40 [PATCH 00/11] usbnet: usbnet: handle link change Ming Lei
2013-04-11 14:40 ` [PATCH 01/11] usbnet: introduce usbnet_link_change API Ming Lei
@ 2013-04-11 14:40 ` Ming Lei
2013-04-11 14:40 ` [PATCH 03/11] usbnet: mcs7830: apply usbnet_link_change Ming Lei
` (9 subsequent siblings)
11 siblings, 0 replies; 18+ messages in thread
From: Ming Lei @ 2013-04-11 14:40 UTC (permalink / raw)
To: David S. Miller, Greg Kroah-Hartman
Cc: Oliver Neukum, netdev, linux-usb, Ming Lei
The driver doesn't implement link_reset() callback, so it needn't
to send link reset event.
Signed-off-by: Ming Lei <ming.lei@canonical.com>
---
drivers/net/usb/mcs7830.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/net/usb/mcs7830.c b/drivers/net/usb/mcs7830.c
index 3f3f566..e1c00e9 100644
--- a/drivers/net/usb/mcs7830.c
+++ b/drivers/net/usb/mcs7830.c
@@ -576,10 +576,9 @@ static void mcs7830_status(struct usbnet *dev, struct urb *urb)
*/
if (data->link_counter > 20) {
data->link_counter = 0;
- if (link) {
+ if (link)
netif_carrier_on(dev->net);
- usbnet_defer_kevent(dev, EVENT_LINK_RESET);
- } else
+ else
netif_carrier_off(dev->net);
netdev_dbg(dev->net, "Link Status is: %d\n", link);
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 03/11] usbnet: mcs7830: apply usbnet_link_change
2013-04-11 14:40 [PATCH 00/11] usbnet: usbnet: handle link change Ming Lei
2013-04-11 14:40 ` [PATCH 01/11] usbnet: introduce usbnet_link_change API Ming Lei
2013-04-11 14:40 ` [PATCH 02/11] usbnet: mcs7830: don't reset link Ming Lei
@ 2013-04-11 14:40 ` Ming Lei
2013-04-11 14:40 ` [PATCH 04/11] usbnet: cdc_ncm: " Ming Lei
` (8 subsequent siblings)
11 siblings, 0 replies; 18+ messages in thread
From: Ming Lei @ 2013-04-11 14:40 UTC (permalink / raw)
To: David S. Miller, Greg Kroah-Hartman
Cc: Oliver Neukum, netdev, linux-usb, Ming Lei
This patch uses the introduced usbnet_link_change() to handle
link change.
Signed-off-by: Ming Lei <ming.lei@canonical.com>
---
drivers/net/usb/mcs7830.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/net/usb/mcs7830.c b/drivers/net/usb/mcs7830.c
index e1c00e9..03832d3 100644
--- a/drivers/net/usb/mcs7830.c
+++ b/drivers/net/usb/mcs7830.c
@@ -576,10 +576,7 @@ static void mcs7830_status(struct usbnet *dev, struct urb *urb)
*/
if (data->link_counter > 20) {
data->link_counter = 0;
- if (link)
- netif_carrier_on(dev->net);
- else
- netif_carrier_off(dev->net);
+ usbnet_link_change(dev, link, 0);
netdev_dbg(dev->net, "Link Status is: %d\n", link);
}
} else
--
1.7.9.5
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 04/11] usbnet: cdc_ncm: apply usbnet_link_change
2013-04-11 14:40 [PATCH 00/11] usbnet: usbnet: handle link change Ming Lei
` (2 preceding siblings ...)
2013-04-11 14:40 ` [PATCH 03/11] usbnet: mcs7830: apply usbnet_link_change Ming Lei
@ 2013-04-11 14:40 ` Ming Lei
2013-04-11 14:40 ` [PATCH 05/11] usbnet: asix: " Ming Lei
` (7 subsequent siblings)
11 siblings, 0 replies; 18+ messages in thread
From: Ming Lei @ 2013-04-11 14:40 UTC (permalink / raw)
To: David S. Miller, Greg Kroah-Hartman
Cc: Oliver Neukum, netdev, linux-usb, Ming Lei
Use the introduced usbnet_link_change to handle link change.
Signed-off-by: Ming Lei <ming.lei@canonical.com>
---
drivers/net/usb/cdc_ncm.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index 67012cb..43afde8 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -610,7 +610,7 @@ static int cdc_ncm_bind(struct usbnet *dev, struct usb_interface *intf)
* (carrier is OFF) during attach, so the IP network stack does not
* start IPv6 negotiation and more.
*/
- netif_carrier_off(dev->net);
+ usbnet_link_change(dev, 0, 0);
return ret;
}
@@ -1106,12 +1106,9 @@ static void cdc_ncm_status(struct usbnet *dev, struct urb *urb)
" %sconnected\n",
ctx->netdev->name, ctx->connected ? "" : "dis");
- if (ctx->connected)
- netif_carrier_on(dev->net);
- else {
- netif_carrier_off(dev->net);
+ usbnet_link_change(dev, ctx->connected, 0);
+ if (!ctx->connected)
ctx->tx_speed = ctx->rx_speed = 0;
- }
break;
case USB_CDC_NOTIFY_SPEED_CHANGE:
--
1.7.9.5
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 05/11] usbnet: asix: apply usbnet_link_change
2013-04-11 14:40 [PATCH 00/11] usbnet: usbnet: handle link change Ming Lei
` (3 preceding siblings ...)
2013-04-11 14:40 ` [PATCH 04/11] usbnet: cdc_ncm: " Ming Lei
@ 2013-04-11 14:40 ` Ming Lei
2013-04-11 14:40 ` [PATCH 06/11] usbnet: ax88179_1781: " Ming Lei
` (6 subsequent siblings)
11 siblings, 0 replies; 18+ messages in thread
From: Ming Lei @ 2013-04-11 14:40 UTC (permalink / raw)
To: David S. Miller, Greg Kroah-Hartman
Cc: Oliver Neukum, netdev, linux-usb, Ming Lei
Use usbnet_link_change to handle link change centrally.
Signed-off-by: Ming Lei <ming.lei@canonical.com>
---
drivers/net/usb/asix_devices.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/drivers/net/usb/asix_devices.c b/drivers/net/usb/asix_devices.c
index 7097534..ad5d1e4 100644
--- a/drivers/net/usb/asix_devices.c
+++ b/drivers/net/usb/asix_devices.c
@@ -55,11 +55,7 @@ static void asix_status(struct usbnet *dev, struct urb *urb)
event = urb->transfer_buffer;
link = event->link & 0x01;
if (netif_carrier_ok(dev->net) != link) {
- if (link) {
- netif_carrier_on(dev->net);
- usbnet_defer_kevent (dev, EVENT_LINK_RESET );
- } else
- netif_carrier_off(dev->net);
+ usbnet_link_change(dev, link, 1);
netdev_dbg(dev->net, "Link Status is: %d\n", link);
}
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 06/11] usbnet: ax88179_1781: apply usbnet_link_change
2013-04-11 14:40 [PATCH 00/11] usbnet: usbnet: handle link change Ming Lei
` (4 preceding siblings ...)
2013-04-11 14:40 ` [PATCH 05/11] usbnet: asix: " Ming Lei
@ 2013-04-11 14:40 ` Ming Lei
2013-04-11 14:40 ` [PATCH 07/11] usbnet: cdc-ether: " Ming Lei
` (5 subsequent siblings)
11 siblings, 0 replies; 18+ messages in thread
From: Ming Lei @ 2013-04-11 14:40 UTC (permalink / raw)
To: David S. Miller, Greg Kroah-Hartman
Cc: Oliver Neukum, netdev, linux-usb, Ming Lei
Use usbnet_link_change to handle link change centrally.
Signed-off-by: Ming Lei <ming.lei@canonical.com>
---
drivers/net/usb/ax88179_178a.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
index 71c27d8..bd8758f 100644
--- a/drivers/net/usb/ax88179_178a.c
+++ b/drivers/net/usb/ax88179_178a.c
@@ -352,11 +352,7 @@ static void ax88179_status(struct usbnet *dev, struct urb *urb)
link = (((__force u32)event->intdata1) & AX_INT_PPLS_LINK) >> 16;
if (netif_carrier_ok(dev->net) != link) {
- if (link)
- usbnet_defer_kevent(dev, EVENT_LINK_RESET);
- else
- netif_carrier_off(dev->net);
-
+ usbnet_link_change(dev, link, 1);
netdev_info(dev->net, "ax88179 - Link status is: %d\n", link);
}
}
@@ -455,7 +451,7 @@ static int ax88179_resume(struct usb_interface *intf)
u16 tmp16;
u8 tmp8;
- netif_carrier_off(dev->net);
+ usbnet_link_change(dev, 0, 0);
/* Power up ethernet PHY */
tmp16 = 0;
@@ -1068,7 +1064,7 @@ static int ax88179_bind(struct usbnet *dev, struct usb_interface *intf)
/* Restart autoneg */
mii_nway_restart(&dev->mii);
- netif_carrier_off(dev->net);
+ usbnet_link_change(dev, 0, 0);
return 0;
}
@@ -1356,7 +1352,7 @@ static int ax88179_reset(struct usbnet *dev)
/* Restart autoneg */
mii_nway_restart(&dev->mii);
- netif_carrier_off(dev->net);
+ usbnet_link_change(dev, 0, 0);
return 0;
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 07/11] usbnet: cdc-ether: apply usbnet_link_change
2013-04-11 14:40 [PATCH 00/11] usbnet: usbnet: handle link change Ming Lei
` (5 preceding siblings ...)
2013-04-11 14:40 ` [PATCH 06/11] usbnet: ax88179_1781: " Ming Lei
@ 2013-04-11 14:40 ` Ming Lei
2013-04-11 14:40 ` [PATCH 08/11] usbnet: dm9601: " Ming Lei
` (4 subsequent siblings)
11 siblings, 0 replies; 18+ messages in thread
From: Ming Lei @ 2013-04-11 14:40 UTC (permalink / raw)
To: David S. Miller, Greg Kroah-Hartman
Cc: Oliver Neukum, netdev, linux-usb, Ming Lei
Use usbnet_link_change to handle link change centrally.
Signed-off-by: Ming Lei <ming.lei@canonical.com>
---
drivers/net/usb/cdc_ether.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/net/usb/cdc_ether.c b/drivers/net/usb/cdc_ether.c
index 57136dc..e965806 100644
--- a/drivers/net/usb/cdc_ether.c
+++ b/drivers/net/usb/cdc_ether.c
@@ -406,10 +406,7 @@ void usbnet_cdc_status(struct usbnet *dev, struct urb *urb)
case USB_CDC_NOTIFY_NETWORK_CONNECTION:
netif_dbg(dev, timer, dev->net, "CDC: carrier %s\n",
event->wValue ? "on" : "off");
- if (event->wValue)
- netif_carrier_on(dev->net);
- else
- netif_carrier_off(dev->net);
+ usbnet_link_change(dev, event->wValue, 0);
break;
case USB_CDC_NOTIFY_SPEED_CHANGE: /* tx/rx rates */
netif_dbg(dev, timer, dev->net, "CDC: speed change (len %d)\n",
--
1.7.9.5
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 08/11] usbnet: dm9601: apply usbnet_link_change
2013-04-11 14:40 [PATCH 00/11] usbnet: usbnet: handle link change Ming Lei
` (6 preceding siblings ...)
2013-04-11 14:40 ` [PATCH 07/11] usbnet: cdc-ether: " Ming Lei
@ 2013-04-11 14:40 ` Ming Lei
[not found] ` <1365691240-816-9-git-send-email-ming.lei-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
2013-04-11 14:40 ` [PATCH 10/11] usbnet: " Ming Lei
` (3 subsequent siblings)
11 siblings, 1 reply; 18+ messages in thread
From: Ming Lei @ 2013-04-11 14:40 UTC (permalink / raw)
To: David S. Miller, Greg Kroah-Hartman
Cc: Oliver Neukum, netdev, linux-usb, Ming Lei, Peter Korsgaard
Use usbnet_link_change to handle link change centrally.
Cc: Peter Korsgaard <jacmet@sunsite.dk>
Signed-off-by: Ming Lei <ming.lei@canonical.com>
---
drivers/net/usb/dm9601.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/drivers/net/usb/dm9601.c b/drivers/net/usb/dm9601.c
index 174e5ec..2dbb946 100644
--- a/drivers/net/usb/dm9601.c
+++ b/drivers/net/usb/dm9601.c
@@ -524,12 +524,7 @@ static void dm9601_status(struct usbnet *dev, struct urb *urb)
link = !!(buf[0] & 0x40);
if (netif_carrier_ok(dev->net) != link) {
- if (link) {
- netif_carrier_on(dev->net);
- usbnet_defer_kevent (dev, EVENT_LINK_RESET);
- }
- else
- netif_carrier_off(dev->net);
+ usbnet_link_change(dev, link, 1);
netdev_dbg(dev->net, "Link Status is: %d\n", link);
}
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 09/11] usbnet: sierra: apply usbnet_link_change
[not found] ` <1365691240-816-1-git-send-email-ming.lei-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
@ 2013-04-11 14:40 ` Ming Lei
2013-04-11 19:58 ` [PATCH 00/11] usbnet: usbnet: handle link change David Miller
1 sibling, 0 replies; 18+ messages in thread
From: Ming Lei @ 2013-04-11 14:40 UTC (permalink / raw)
To: David S. Miller, Greg Kroah-Hartman
Cc: Oliver Neukum, netdev-u79uwXL29TY76Z2rM5mHXA,
linux-usb-u79uwXL29TY76Z2rM5mHXA, Ming Lei
Use usbnet_link_change to handle link change centrally.
Signed-off-by: Ming Lei <ming.lei-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
---
drivers/net/usb/sierra_net.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/net/usb/sierra_net.c b/drivers/net/usb/sierra_net.c
index 79ab243..a923d61 100644
--- a/drivers/net/usb/sierra_net.c
+++ b/drivers/net/usb/sierra_net.c
@@ -413,11 +413,10 @@ static void sierra_net_handle_lsi(struct usbnet *dev, char *data,
if (link_up) {
sierra_net_set_ctx_index(priv, hh->msgspecific.byte);
priv->link_up = 1;
- netif_carrier_on(dev->net);
} else {
priv->link_up = 0;
- netif_carrier_off(dev->net);
}
+ usbnet_link_change(dev, link_up, 0);
}
static void sierra_net_dosync(struct usbnet *dev)
--
1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 10/11] usbnet: apply usbnet_link_change
2013-04-11 14:40 [PATCH 00/11] usbnet: usbnet: handle link change Ming Lei
` (7 preceding siblings ...)
2013-04-11 14:40 ` [PATCH 08/11] usbnet: dm9601: " Ming Lei
@ 2013-04-11 14:40 ` Ming Lei
2013-04-11 14:40 ` [PATCH 11/11] usbnet: handle link change Ming Lei
` (2 subsequent siblings)
11 siblings, 0 replies; 18+ messages in thread
From: Ming Lei @ 2013-04-11 14:40 UTC (permalink / raw)
To: David S. Miller, Greg Kroah-Hartman
Cc: Oliver Neukum, netdev, linux-usb, Ming Lei
Use usbnet_link_change to handle link change centrally.
Signed-off-by: Ming Lei <ming.lei@canonical.com>
---
drivers/net/usb/usbnet.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 40e4237..34e4252 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -1521,7 +1521,7 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
netif_device_attach (net);
if (dev->driver_info->flags & FLAG_LINK_INTR)
- netif_carrier_off(net);
+ usbnet_link_change(dev, 0, 0);
return 0;
--
1.7.9.5
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 11/11] usbnet: handle link change
2013-04-11 14:40 [PATCH 00/11] usbnet: usbnet: handle link change Ming Lei
` (8 preceding siblings ...)
2013-04-11 14:40 ` [PATCH 10/11] usbnet: " Ming Lei
@ 2013-04-11 14:40 ` Ming Lei
2013-04-11 14:52 ` Ming Lei
2013-04-11 15:18 ` [PATCH 00/11] usbnet: " Jussi Kivilinna
[not found] ` <1365691240-816-1-git-send-email-ming.lei-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
11 siblings, 1 reply; 18+ messages in thread
From: Ming Lei @ 2013-04-11 14:40 UTC (permalink / raw)
To: David S. Miller, Greg Kroah-Hartman
Cc: Oliver Neukum, netdev, linux-usb, Ming Lei
The link change is detected via the interrupt pipe, and bulk
pipes are responsible for transfering packets, so it is reasonable
to stop bulk transfer after link is reported as off.
Two adavantages may be obtained with stopping bulk transfer
after link becomes off:
- USB bus bandwidth is saved(USB bus is shared bus except for
USB3.0), for example, lots of 'IN' token packets and 'NYET'
handshake packets is transfered on 2.0 bus.
- probabaly power might be saved for usb host controller since
cancelling bulk transfer may disable the asynchronous schedule of
host controller.
With this patch, when link becomes off, about ~10% performance
boost can be found on bulk transfer of anther usb device which
is attached to same bus with the usbnet device, see below
test on next-20130410:
- read from usb mass storage(Sandisk Extreme USB 3.0) on pandaboard
with below command after unplugging ethernet cable:
dd if=/dev/sda iflag=direct of=/dev/null bs=1M count=500
- without the patch
1, 838860800 bytes (839 MB) copied, 36.2216 s, 23.2 MB/s
2, 838860800 bytes (839 MB) copied, 35.8368 s, 23.4 MB/s
3, 838860800 bytes (839 MB) copied, 35.823 s, 23.4 MB/s
4, 838860800 bytes (839 MB) copied, 35.937 s, 23.3 MB/s
5, 838860800 bytes (839 MB) copied, 35.7365 s, 23.5 MB/s
average: 23.6MB/s
- with the patch
1, 838860800 bytes (839 MB) copied, 32.3817 s, 25.9 MB/s
2, 838860800 bytes (839 MB) copied, 31.7389 s, 26.4 MB/s
3, 838860800 bytes (839 MB) copied, 32.438 s, 25.9 MB/s
4, 838860800 bytes (839 MB) copied, 32.5492 s, 25.8 MB/s
5, 838860800 bytes (839 MB) copied, 31.6178 s, 26.5 MB/s
average: 26.1MB/s
Signed-off-by: Ming Lei <ming.lei@canonical.com>
---
drivers/net/usb/usbnet.c | 30 ++++++++++++++++++++++++++++++
include/linux/usb/usbnet.h | 1 +
2 files changed, 31 insertions(+)
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 34e4252..1e5a9b7 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -938,6 +938,27 @@ static const struct ethtool_ops usbnet_ethtool_ops = {
/*-------------------------------------------------------------------------*/
+static void __handle_link_change(struct usbnet *dev)
+{
+ if (!test_bit(EVENT_DEV_OPEN, &dev->flags))
+ return;
+
+ if (!netif_carrier_ok(dev->net)) {
+ /* kill URBs for reading packets to save bus bandwidth */
+ unlink_urbs(dev, &dev->rxq);
+
+ /*
+ * tx_timeout will unlink URBs for sending packets and
+ * tx queue is stopped by netcore after link becomes off
+ */
+ } else {
+ /* submitting URBs for reading packets */
+ tasklet_schedule(&dev->bh);
+ }
+
+ clear_bit(EVENT_LINK_CHANGE, &dev->flags);
+}
+
/* work that cannot be done in interrupt context uses keventd.
*
* NOTE: with 2.5 we could do more of this using completion callbacks,
@@ -1035,8 +1056,14 @@ skip_reset:
} else {
usb_autopm_put_interface(dev->intf);
}
+
+ /* handle link change from link resetting */
+ __handle_link_change(dev);
}
+ if (test_bit (EVENT_LINK_CHANGE, &dev->flags))
+ __handle_link_change(dev);
+
if (dev->flags)
netdev_dbg(dev->net, "kevent done, flags = 0x%lx\n", dev->flags);
}
@@ -1286,6 +1313,7 @@ static void usbnet_bh (unsigned long param)
// or are we maybe short a few urbs?
} else if (netif_running (dev->net) &&
netif_device_present (dev->net) &&
+ netif_carrier_ok(dev->net) &&
!timer_pending (&dev->delay) &&
!test_bit (EVENT_RX_HALT, &dev->flags)) {
int temp = dev->rxq.qlen;
@@ -1663,6 +1691,8 @@ void usbnet_link_change(struct usbnet *dev, bool link, bool need_reset)
if (need_reset && link)
usbnet_defer_kevent(dev, EVENT_LINK_RESET);
+ else
+ usbnet_defer_kevent(dev, EVENT_LINK_CHANGE);
}
EXPORT_SYMBOL(usbnet_link_change);
diff --git a/include/linux/usb/usbnet.h b/include/linux/usb/usbnet.h
index eb021b8..da46327 100644
--- a/include/linux/usb/usbnet.h
+++ b/include/linux/usb/usbnet.h
@@ -72,6 +72,7 @@ struct usbnet {
# define EVENT_DEVICE_REPORT_IDLE 8
# define EVENT_NO_RUNTIME_PM 9
# define EVENT_RX_KILL 10
+# define EVENT_LINK_CHANGE 11
};
static inline struct usb_driver *driver_of(struct usb_interface *intf)
--
1.7.9.5
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [PATCH 11/11] usbnet: handle link change
2013-04-11 14:40 ` [PATCH 11/11] usbnet: handle link change Ming Lei
@ 2013-04-11 14:52 ` Ming Lei
2013-04-11 19:58 ` David Miller
0 siblings, 1 reply; 18+ messages in thread
From: Ming Lei @ 2013-04-11 14:52 UTC (permalink / raw)
To: David S. Miller, Greg Kroah-Hartman
Cc: Oliver Neukum, netdev, linux-usb, Ming Lei
On Thu, Apr 11, 2013 at 10:40 PM, Ming Lei <ming.lei@canonical.com> wrote:
> The link change is detected via the interrupt pipe, and bulk
> pipes are responsible for transfering packets, so it is reasonable
> to stop bulk transfer after link is reported as off.
>
> Two adavantages may be obtained with stopping bulk transfer
> after link becomes off:
>
> - USB bus bandwidth is saved(USB bus is shared bus except for
> USB3.0), for example, lots of 'IN' token packets and 'NYET'
> handshake packets is transfered on 2.0 bus.
>
> - probabaly power might be saved for usb host controller since
> cancelling bulk transfer may disable the asynchronous schedule of
> host controller.
>
> With this patch, when link becomes off, about ~10% performance
> boost can be found on bulk transfer of anther usb device which
> is attached to same bus with the usbnet device, see below
> test on next-20130410:
>
> - read from usb mass storage(Sandisk Extreme USB 3.0) on pandaboard
> with below command after unplugging ethernet cable:
>
> dd if=/dev/sda iflag=direct of=/dev/null bs=1M count=500
Sorry, the above should be:
dd if=/dev/sda iflag=direct of=/dev/null bs=1M count=800
>
> - without the patch
> 1, 838860800 bytes (839 MB) copied, 36.2216 s, 23.2 MB/s
> 2, 838860800 bytes (839 MB) copied, 35.8368 s, 23.4 MB/s
> 3, 838860800 bytes (839 MB) copied, 35.823 s, 23.4 MB/s
> 4, 838860800 bytes (839 MB) copied, 35.937 s, 23.3 MB/s
> 5, 838860800 bytes (839 MB) copied, 35.7365 s, 23.5 MB/s
> average: 23.6MB/s
>
> - with the patch
> 1, 838860800 bytes (839 MB) copied, 32.3817 s, 25.9 MB/s
> 2, 838860800 bytes (839 MB) copied, 31.7389 s, 26.4 MB/s
> 3, 838860800 bytes (839 MB) copied, 32.438 s, 25.9 MB/s
> 4, 838860800 bytes (839 MB) copied, 32.5492 s, 25.8 MB/s
> 5, 838860800 bytes (839 MB) copied, 31.6178 s, 26.5 MB/s
> average: 26.1MB/s
>
> Signed-off-by: Ming Lei <ming.lei@canonical.com>
> ---
> drivers/net/usb/usbnet.c | 30 ++++++++++++++++++++++++++++++
> include/linux/usb/usbnet.h | 1 +
> 2 files changed, 31 insertions(+)
>
> diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
> index 34e4252..1e5a9b7 100644
> --- a/drivers/net/usb/usbnet.c
> +++ b/drivers/net/usb/usbnet.c
> @@ -938,6 +938,27 @@ static const struct ethtool_ops usbnet_ethtool_ops = {
>
> /*-------------------------------------------------------------------------*/
>
> +static void __handle_link_change(struct usbnet *dev)
> +{
> + if (!test_bit(EVENT_DEV_OPEN, &dev->flags))
> + return;
> +
> + if (!netif_carrier_ok(dev->net)) {
> + /* kill URBs for reading packets to save bus bandwidth */
> + unlink_urbs(dev, &dev->rxq);
> +
> + /*
> + * tx_timeout will unlink URBs for sending packets and
> + * tx queue is stopped by netcore after link becomes off
> + */
> + } else {
> + /* submitting URBs for reading packets */
> + tasklet_schedule(&dev->bh);
> + }
> +
> + clear_bit(EVENT_LINK_CHANGE, &dev->flags);
> +}
> +
> /* work that cannot be done in interrupt context uses keventd.
> *
> * NOTE: with 2.5 we could do more of this using completion callbacks,
> @@ -1035,8 +1056,14 @@ skip_reset:
> } else {
> usb_autopm_put_interface(dev->intf);
> }
> +
> + /* handle link change from link resetting */
> + __handle_link_change(dev);
> }
>
> + if (test_bit (EVENT_LINK_CHANGE, &dev->flags))
> + __handle_link_change(dev);
> +
> if (dev->flags)
> netdev_dbg(dev->net, "kevent done, flags = 0x%lx\n", dev->flags);
> }
> @@ -1286,6 +1313,7 @@ static void usbnet_bh (unsigned long param)
> // or are we maybe short a few urbs?
> } else if (netif_running (dev->net) &&
> netif_device_present (dev->net) &&
> + netif_carrier_ok(dev->net) &&
> !timer_pending (&dev->delay) &&
> !test_bit (EVENT_RX_HALT, &dev->flags)) {
> int temp = dev->rxq.qlen;
> @@ -1663,6 +1691,8 @@ void usbnet_link_change(struct usbnet *dev, bool link, bool need_reset)
>
> if (need_reset && link)
> usbnet_defer_kevent(dev, EVENT_LINK_RESET);
> + else
> + usbnet_defer_kevent(dev, EVENT_LINK_CHANGE);
> }
> EXPORT_SYMBOL(usbnet_link_change);
>
> diff --git a/include/linux/usb/usbnet.h b/include/linux/usb/usbnet.h
> index eb021b8..da46327 100644
> --- a/include/linux/usb/usbnet.h
> +++ b/include/linux/usb/usbnet.h
> @@ -72,6 +72,7 @@ struct usbnet {
> # define EVENT_DEVICE_REPORT_IDLE 8
> # define EVENT_NO_RUNTIME_PM 9
> # define EVENT_RX_KILL 10
> +# define EVENT_LINK_CHANGE 11
> };
>
> static inline struct usb_driver *driver_of(struct usb_interface *intf)
> --
> 1.7.9.5
>
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 00/11] usbnet: usbnet: handle link change
2013-04-11 14:40 [PATCH 00/11] usbnet: usbnet: handle link change Ming Lei
` (9 preceding siblings ...)
2013-04-11 14:40 ` [PATCH 11/11] usbnet: handle link change Ming Lei
@ 2013-04-11 15:18 ` Jussi Kivilinna
[not found] ` <5166D431.4080400-X3B1VOXEql0@public.gmane.org>
[not found] ` <1365691240-816-1-git-send-email-ming.lei-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
11 siblings, 1 reply; 18+ messages in thread
From: Jussi Kivilinna @ 2013-04-11 15:18 UTC (permalink / raw)
To: Ming Lei
Cc: David S. Miller, Greg Kroah-Hartman, Oliver Neukum, netdev,
linux-usb
On 11.04.2013 17:40, Ming Lei wrote:
> Hi,
>
> This patch set introduces usbnet_link_change() API and applies
> it on all usbnet drivers, then handle the link change centrally
> to stop bulk transfer when link becomes off and restart bulk
> transfer when link becomes on.
Should 'rndis_wlan' be changed to use this too?
-Jussi
>
> With the change, ~10% performance boost on bulk transfer
> of another device on the same bus can be obtained when link
> is off. Also, stopping bulk transfer when link becomes off
> may disable asynchonous schedule of host controller, power
> might be saved probabally.
>
> drivers/net/usb/asix_devices.c | 6 +-----
> drivers/net/usb/ax88179_178a.c | 12 ++++-------
> drivers/net/usb/cdc_ether.c | 5 +----
> drivers/net/usb/cdc_ncm.c | 9 +++-----
> drivers/net/usb/dm9601.c | 7 +------
> drivers/net/usb/mcs7830.c | 6 +-----
> drivers/net/usb/sierra_net.c | 3 +--
> drivers/net/usb/usbnet.c | 45 +++++++++++++++++++++++++++++++++++++++-
> include/linux/usb/usbnet.h | 2 ++
> 9 files changed, 58 insertions(+), 37 deletions(-)
>
>
> Thanks,
> --
> Ming Lei
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 08/11] usbnet: dm9601: apply usbnet_link_change
[not found] ` <1365691240-816-9-git-send-email-ming.lei-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
@ 2013-04-11 15:18 ` Peter Korsgaard
0 siblings, 0 replies; 18+ messages in thread
From: Peter Korsgaard @ 2013-04-11 15:18 UTC (permalink / raw)
To: Ming Lei
Cc: David S. Miller, Greg Kroah-Hartman, Oliver Neukum,
netdev-u79uwXL29TY76Z2rM5mHXA, linux-usb-u79uwXL29TY76Z2rM5mHXA
>>>>> "Ming" == Ming Lei <ming.lei-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org> writes:
Ming> Use usbnet_link_change to handle link change centrally.
Acked-by: Peter Korsgaard <jacmet-OfajU3CKLf1/SzgSGea1oA@public.gmane.org>
Ming> Cc: Peter Korsgaard <jacmet-OfajU3CKLf1/SzgSGea1oA@public.gmane.org>
Ming> Signed-off-by: Ming Lei <ming.lei-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
Ming> ---
Ming> drivers/net/usb/dm9601.c | 7 +------
Ming> 1 file changed, 1 insertion(+), 6 deletions(-)
Ming> diff --git a/drivers/net/usb/dm9601.c b/drivers/net/usb/dm9601.c
Ming> index 174e5ec..2dbb946 100644
Ming> --- a/drivers/net/usb/dm9601.c
Ming> +++ b/drivers/net/usb/dm9601.c
Ming> @@ -524,12 +524,7 @@ static void dm9601_status(struct usbnet *dev, struct urb *urb)
Ming> link = !!(buf[0] & 0x40);
Ming> if (netif_carrier_ok(dev->net) != link) {
Ming> - if (link) {
Ming> - netif_carrier_on(dev->net);
Ming> - usbnet_defer_kevent (dev, EVENT_LINK_RESET);
Ming> - }
Ming> - else
Ming> - netif_carrier_off(dev->net);
Ming> + usbnet_link_change(dev, link, 1);
Ming> netdev_dbg(dev->net, "Link Status is: %d\n", link);
Ming> }
Ming> }
Ming> --
Ming> 1.7.9.5
--
Bye, Peter Korsgaard
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 00/11] usbnet: usbnet: handle link change
[not found] ` <5166D431.4080400-X3B1VOXEql0@public.gmane.org>
@ 2013-04-11 15:27 ` Ming Lei
0 siblings, 0 replies; 18+ messages in thread
From: Ming Lei @ 2013-04-11 15:27 UTC (permalink / raw)
To: Jussi Kivilinna
Cc: David S. Miller, Greg Kroah-Hartman, Oliver Neukum,
netdev-u79uwXL29TY76Z2rM5mHXA, linux-usb-u79uwXL29TY76Z2rM5mHXA
On Thu, Apr 11, 2013 at 11:18 PM, Jussi Kivilinna
<jussi.kivilinna-X3B1VOXEql0@public.gmane.org> wrote:
> On 11.04.2013 17:40, Ming Lei wrote:
>> Hi,
>>
>> This patch set introduces usbnet_link_change() API and applies
>> it on all usbnet drivers, then handle the link change centrally
>> to stop bulk transfer when link becomes off and restart bulk
>> transfer when link becomes on.
>
> Should 'rndis_wlan' be changed to use this too?
If link detection of 'rndis_wlan' doesn't depend on
bulk transfer, it can benefit from the change. Otherwise,
it needn't the change, but the patch won't have side-effect
on 'rndis_wlan'.
Thanks,
--
Ming Lei
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 11/11] usbnet: handle link change
2013-04-11 14:52 ` Ming Lei
@ 2013-04-11 19:58 ` David Miller
0 siblings, 0 replies; 18+ messages in thread
From: David Miller @ 2013-04-11 19:58 UTC (permalink / raw)
To: ming.lei; +Cc: gregkh, oneukum, netdev, linux-usb
From: Ming Lei <ming.lei@canonical.com>
Date: Thu, 11 Apr 2013 22:52:29 +0800
> On Thu, Apr 11, 2013 at 10:40 PM, Ming Lei <ming.lei@canonical.com> wrote:
>> dd if=/dev/sda iflag=direct of=/dev/null bs=1M count=500
>
> Sorry, the above should be:
>
> dd if=/dev/sda iflag=direct of=/dev/null bs=1M count=800
I'll fix this up when I apply this patch series.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 00/11] usbnet: usbnet: handle link change
[not found] ` <1365691240-816-1-git-send-email-ming.lei-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
2013-04-11 14:40 ` [PATCH 09/11] usbnet: sierra: apply usbnet_link_change Ming Lei
@ 2013-04-11 19:58 ` David Miller
1 sibling, 0 replies; 18+ messages in thread
From: David Miller @ 2013-04-11 19:58 UTC (permalink / raw)
To: ming.lei-Z7WLFzj8eWMS+FvcfC7Uqw
Cc: gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r, oneukum-l3A5Bk7waGM,
netdev-u79uwXL29TY76Z2rM5mHXA, linux-usb-u79uwXL29TY76Z2rM5mHXA
From: Ming Lei <ming.lei-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
Date: Thu, 11 Apr 2013 22:40:29 +0800
> This patch set introduces usbnet_link_change() API and applies
> it on all usbnet drivers, then handle the link change centrally
> to stop bulk transfer when link becomes off and restart bulk
> transfer when link becomes on.
>
> With the change, ~10% performance boost on bulk transfer
> of another device on the same bus can be obtained when link
> is off. Also, stopping bulk transfer when link becomes off
> may disable asynchonous schedule of host controller, power
> might be saved probabally.
Series applied, thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2013-04-11 19:58 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-11 14:40 [PATCH 00/11] usbnet: usbnet: handle link change Ming Lei
2013-04-11 14:40 ` [PATCH 01/11] usbnet: introduce usbnet_link_change API Ming Lei
2013-04-11 14:40 ` [PATCH 02/11] usbnet: mcs7830: don't reset link Ming Lei
2013-04-11 14:40 ` [PATCH 03/11] usbnet: mcs7830: apply usbnet_link_change Ming Lei
2013-04-11 14:40 ` [PATCH 04/11] usbnet: cdc_ncm: " Ming Lei
2013-04-11 14:40 ` [PATCH 05/11] usbnet: asix: " Ming Lei
2013-04-11 14:40 ` [PATCH 06/11] usbnet: ax88179_1781: " Ming Lei
2013-04-11 14:40 ` [PATCH 07/11] usbnet: cdc-ether: " Ming Lei
2013-04-11 14:40 ` [PATCH 08/11] usbnet: dm9601: " Ming Lei
[not found] ` <1365691240-816-9-git-send-email-ming.lei-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
2013-04-11 15:18 ` Peter Korsgaard
2013-04-11 14:40 ` [PATCH 10/11] usbnet: " Ming Lei
2013-04-11 14:40 ` [PATCH 11/11] usbnet: handle link change Ming Lei
2013-04-11 14:52 ` Ming Lei
2013-04-11 19:58 ` David Miller
2013-04-11 15:18 ` [PATCH 00/11] usbnet: " Jussi Kivilinna
[not found] ` <5166D431.4080400-X3B1VOXEql0@public.gmane.org>
2013-04-11 15:27 ` Ming Lei
[not found] ` <1365691240-816-1-git-send-email-ming.lei-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
2013-04-11 14:40 ` [PATCH 09/11] usbnet: sierra: apply usbnet_link_change Ming Lei
2013-04-11 19:58 ` [PATCH 00/11] usbnet: usbnet: handle link change David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).