]> git.lizzy.rs Git - plan9front.git/blobdiff - sys/src/9/pc/ethervt6105m.c
devether: mux bridges, portable netconsole
[plan9front.git] / sys / src / 9 / pc / ethervt6105m.c
index e91c7241aee7065adb251b1115f356f28c8c7f76..10c047d5db9c11b063a3f56e994cf35159e7c145 100644 (file)
@@ -20,8 +20,8 @@
 #include "io.h"
 #include "../port/error.h"
 #include "../port/netif.h"
+#include "../port/etherif.h"
 
-#include "etherif.h"
 #include "ethermii.h"
 
 enum {
@@ -547,6 +547,8 @@ vt6105Mlproc(void* arg)
 
        edev = arg;
        ctlr = edev->ctlr;
+       while(waserror())
+               ;
        for(;;){
                if(ctlr->mii == nil || ctlr->mii->curphy == nil)
                        break;
@@ -595,7 +597,6 @@ vt6105Mrballoc(void)
        if((bp = vt6105Mrbpool) != nil){
                vt6105Mrbpool = bp->next;
                bp->next = nil;
-               _xinc(&bp->ref);        /* prevent bp from being freed */
        }
        iunlock(&vt6105Mrblock);
 
@@ -610,7 +611,6 @@ static void
 vt6105Mattach(Ether* edev)
 {
        Ctlr *ctlr;
-//     MiiPhy *phy;
        uchar *alloc;
        Ds *ds, *prev;
        int dsz, i, timeo;
@@ -865,7 +865,7 @@ vt6105Mreceive(Ether* edev)
                        }
                        len = ((ds->status & LengthMASK)>>LengthSHIFT)-4;
                        ds->bp->wp = ds->bp->rp+len;
-                       etheriq(edev, ds->bp, 1);
+                       etheriq(edev, ds->bp);
                        bp->rp = (uchar*)ROUNDUP((ulong)bp->rp, 4);
                        ds->addr = PCIWADDR(bp->rp);
                        ds->bp = bp;
@@ -949,7 +949,7 @@ vt6105Minterrupt(Ureg*, void* arg)
                        ctlr->tintr++;
                }
                if(isr)
-                       panic("vt6105M: isr %4.4uX\n", isr);
+                       panic("vt6105M: isr %4.4uX", isr);
        }
        ctlr->imr = imr;
        csr16w(ctlr, Imr, ctlr->imr);
@@ -1026,12 +1026,13 @@ vt6105Mdetach(Ctlr* ctlr)
         */
        csr16w(ctlr, Cr, Stop);
        csr16w(ctlr, Cr, Stop|Sfrst);
-       for(timeo = 0; timeo < 10000; timeo++){
+       /* limit used to be 10000, but that wasn't enough for our Soekris 5501s */
+       for(timeo = 0; timeo < 100000; timeo++){
                if(!(csr16r(ctlr, Cr) & Sfrst))
                        break;
                microdelay(1);
        }
-       if(timeo >= 1000)
+       if(timeo >= 100000)
                return -1;
 
        return 0;
@@ -1052,12 +1053,13 @@ vt6105Mreset(Ctlr* ctlr)
         */
        r = csr8r(ctlr, Eecsr);
        csr8w(ctlr, Eecsr, Autold|r);
-       for(timeo = 0; timeo < 100; timeo++){
+       /* limit used to be 100, but that wasn't enough for our Soekris 5501s */
+       for(timeo = 0; timeo < 100000; timeo++){
                if(!(csr8r(ctlr, Cr) & Autold))
                        break;
                microdelay(1);
        }
-       if(timeo >= 100)
+       if(timeo >= 100000)
                return -1;
 
        for(i = 0; i < Eaddrlen; i++)
@@ -1142,12 +1144,6 @@ vt6105Mpci(void)
                if((cls = pcicfgr8(p, PciCLS)) == 0 || cls == 0xFF)
                        cls = 0x10;
                ctlr->cls = cls*4;
-               if(ctlr->cls < sizeof(Ds)){
-                       print("vt6105M: cls %d < sizeof(Ds)\n", ctlr->cls);
-                       iofree(port);
-                       free(ctlr);
-                       continue;
-               }
                ctlr->tft = CtftSAF;
 
                if(vt6105Mreset(ctlr)){
@@ -1204,7 +1200,6 @@ vt6105Mpnp(Ether* edev)
         */
        edev->attach = vt6105Mattach;
        edev->transmit = vt6105Mtransmit;
-       edev->interrupt = vt6105Minterrupt;
        edev->ifstat = vt6105Mifstat;
        edev->ctl = nil;
 
@@ -1214,6 +1209,8 @@ vt6105Mpnp(Ether* edev)
 
        edev->maxmtu = ETHERMAXTU+Bslop;
 
+       intrenable(edev->irq, vt6105Minterrupt, edev, edev->tbdf, edev->name);
+
        return 0;
 }