Use larger queue sizes for faster NICs
authorAndrew Gallatin <gallatin@google.com>
Fri, 6 Jun 2014 18:31:06 +0000 (11:31 -0700)
committerAndrew Gallatin <gallatin@google.com>
Mon, 9 Jun 2014 14:37:11 +0000 (07:37 -0700)
Use larger queue sizes for 1GbE and 10GbE interfaces.  This fixes
soft overflow drops on a 10GbE interface I've been using.

Signed-off-by: Andrew Gallatin <gallatin@google.com>
kern/drivers/dev/ether.c

index 2637485..b7c4d4c 100644 (file)
@@ -636,7 +636,7 @@ int parseether(uint8_t * to, char *from)
 static void etherreset(void)
 {
        struct ether *ether;
 static void etherreset(void)
 {
        struct ether *ether;
-       int i, n, ctlrno;
+       int i, n, ctlrno, qsize;
        char name[KNAMELEN], buf[128];
 
        for (ether = 0, ctlrno = 0; ctlrno < MaxEther; ctlrno++) {
        char name[KNAMELEN], buf[128];
 
        for (ether = 0, ctlrno = 0; ctlrno < MaxEther; ctlrno++) {
@@ -701,15 +701,23 @@ static void etherreset(void)
                        snprintf(buf + i, sizeof(buf) - i, "\n");
                        printk(buf);
 
                        snprintf(buf + i, sizeof(buf) - i, "\n");
                        printk(buf);
 
-                       if (ether->netif.mbps == 100) {
-                               netifinit(&ether->netif, name, Ntypes, 256 * 1024);
-                               if (ether->oq == 0)
-                                       ether->oq = qopen(256 * 1024, Qmsg, 0, 0);
-                       } else {
-                               netifinit(&ether->netif, name, Ntypes, 64 * 1024);
-                               if (ether->oq == 0)
-                                       ether->oq = qopen(64 * 1024, Qmsg, 0, 0);
+                       switch (ether->netif.mbps) {
+
+                       case 1 ... 99:
+                               qsize = 64 * 1024;
+                               break;
+                       case 100 ... 999:
+                               qsize = 256 * 1024;
+                               break;
+                       case 1000 ... 9999:
+                               qsize = 1024 * 1024;
+                               break;
+                       default:
+                               qsize = 8 * 1024 * 1024;
                        }
                        }
+                       netifinit(&ether->netif, name, Ntypes, qsize);
+                       if (ether->oq == 0)
+                               ether->oq = qopen(qsize, Qmsg, 0, 0);
                        if (ether->oq == 0)
                                panic("etherreset %s", name);
                        ether->netif.alen = Eaddrlen;
                        if (ether->oq == 0)
                                panic("etherreset %s", name);
                        ether->netif.alen = Eaddrlen;