usb_drv: Dimension queues for usbnet

+ Some code cleanup

Ref #773
This commit is contained in:
Sebastian Sumpf 2013-06-17 10:34:30 +02:00 committed by Norman Feske
parent c3537d175c
commit 71490e131b
4 changed files with 47 additions and 15 deletions

View File

@ -0,0 +1,37 @@
diff -r b5bc236d605e drivers/net/usb/usbnet.c
--- a/drivers/net/usb/usbnet.c Mon Jun 17 10:27:00 2013 +0200
+++ b/drivers/net/usb/usbnet.c Mon Jun 17 10:34:15 2013 +0200
@@ -64,10 +64,29 @@
* is required, under load. Jumbograms change the equation.
*/
#define RX_MAX_QUEUE_MEMORY (60 * 1518)
-#define RX_QLEN(dev) (((dev)->udev->speed == USB_SPEED_HIGH) ? \
- (RX_MAX_QUEUE_MEMORY/(dev)->rx_urb_size) : 4)
-#define TX_QLEN(dev) (((dev)->udev->speed == USB_SPEED_HIGH) ? \
- (RX_MAX_QUEUE_MEMORY/(dev)->hard_mtu) : 4)
+inline unsigned RX_QLEN(struct usbnet *dev)
+{
+ switch(dev->udev->speed) {
+ case USB_SPEED_HIGH:
+ return RX_MAX_QUEUE_MEMORY/dev->rx_urb_size;
+ case USB_SPEED_SUPER:
+ return 16;
+ default:
+ return 4;
+ }
+}
+
+inline unsigned TX_QLEN(struct usbnet *dev)
+{
+ switch(dev->udev->speed) {
+ case USB_SPEED_HIGH:
+ return RX_MAX_QUEUE_MEMORY/dev->hard_mtu;
+ case USB_SPEED_SUPER:
+ return 16;
+ default:
+ return 4;
+ }
+}
// reawaken network queue this soon after stopping; else watchdog barks
#define TX_TIMEOUT_JIFFIES (5*HZ)

View File

@ -171,6 +171,7 @@ namespace Nic {
} else {
/* send to driver */
_device->tx(virt, packet.size());
tx_cnt++;
}
counter.inc(packet.size());

View File

@ -314,6 +314,10 @@ int register_netdev(struct net_device *ndev)
if (ndev->netdev_ops->ndo_set_rx_mode)
ndev->netdev_ops->ndo_set_rx_mode(ndev);
/*
if(ndev->netdev_ops->ndo_change_mtu)
ndev->netdev_ops->ndo_change_mtu(ndev, 4000);
*/
_nic = nic;
env()->parent()->announce(ep_nic.manage(&root));
}
@ -399,7 +403,6 @@ struct sk_buff *alloc_skb(unsigned int size, gfp_t priority)
struct sk_buff *netdev_alloc_skb_ip_align(struct net_device *dev, unsigned int length)
{
struct usbnet *d = (usbnet *)netdev_priv(dev);
struct sk_buff *s = _alloc_skb(length + NET_IP_ALIGN, false);
s->data += NET_IP_ALIGN;
s->tail += NET_IP_ALIGN;

View File

@ -18,11 +18,10 @@ extern "C" {
#include <dde_kit/interrupt.h>
}
#include<timer_session/connection.h>
/* our local incarnation of sender and receiver */
static Signal_helper *_signal = 0;
static Genode::Lock _irq_sync(Genode::Lock::LOCKED);
static Genode::Lock _irq_wait(Genode::Lock::LOCKED);
/**
* This contains the Linux-driver handlers
@ -81,9 +80,6 @@ class Irq_context : public Driver_context,
static Genode::Lock handler_lock;
Genode::Lock::Guard guard(handler_lock);
/* unlock if main thread is waiting */
_irq_wait.unlock();
Irq_context *ctx = static_cast<Irq_context *>(irq);
/* set context & submit signal */
@ -124,7 +120,9 @@ class Irq_context : public Driver_context,
/* report IRQ to all clients */
for (Irq_handler *h = _handler_list.first(); h; h = h->next()) {
handled |= _handle_one(h);
if (_handle_one(h))
break;
dde_kit_log(DEBUG_IRQ, "IRQ: %u ret: %u h: %p dev: %p", _irq, handled, h->handler, h->dev);
}
@ -180,12 +178,6 @@ class Irq_context : public Driver_context,
return handled;
}
static void wait()
{
_irq_wait.lock();
check_irq();
}
};
@ -195,8 +187,7 @@ void Irq::init(Genode::Signal_receiver *recv) {
void Irq::check_irq()
{
if (!Irq_context::check_irq())
Irq_context::wait();
Irq_context::check_irq();
}