I have the following ral(4):

ral0 at pci0 dev 13 function 0 "Ralink RT2561S" rev 0x00: irq 5, address 
00:1d:7d:49:28:92
ral0: MAC/BBP RT2561C, RF RT2527

After a commit from August 2010 (see
http://marc.info/?l=openbsd-cvs&m=128095139804862) the ral stopped
working: clients could not associate with it in hostap mode and it could
not detect other APs with "ifconfig scan".

After a hint from damien@ I came up with the following diff which brings
back some of the code that was removed by the commit mentioned above.

damien@ suggested I post the diff here. If you have an RT2561 or RT2661,
please test it.

Regards,
Tim

Index: rt2661.c
===================================================================
RCS file: /cvs/src/sys/dev/ic/rt2661.c,v
retrieving revision 1.64
diff -p -u rt2661.c
--- rt2661.c    22 Feb 2011 20:05:03 -0000      1.64
+++ rt2661.c    10 Mar 2011 16:23:11 -0000
@@ -396,8 +396,10 @@ rt2661_suspend(void *xsc)
        struct rt2661_softc *sc = xsc;
        struct ifnet *ifp = &sc->sc_ic.ic_if;
 
-       if (ifp->if_flags & IFF_RUNNING)
+       if (ifp->if_flags & IFF_RUNNING) {
                rt2661_stop(ifp, 1);
+               sc->sc_flags &= ~RT2661_FWLOADED;
+       }
 }
 
 void
@@ -2464,11 +2466,14 @@ rt2661_init(struct ifnet *ifp)
 
        rt2661_stop(ifp, 0);
 
-       if (rt2661_load_microcode(sc) != 0) {
-               printf("%s: could not load 8051 microcode\n",
-                   sc->sc_dev.dv_xname);
-               rt2661_stop(ifp, 1);
-               return EIO;
+       if (!(sc->sc_flags & RT2661_FWLOADED)) {
+               if (rt2661_load_microcode(sc) != 0) {
+                       printf("%s: could not load 8051 microcode\n",
+                           sc->sc_dev.dv_xname);
+                       rt2661_stop(ifp, 1);
+                       return EIO;
+               }
+               sc->sc_flags |= RT2661_FWLOADED;
        }
 
        /* initialize Tx rings */
@@ -2631,7 +2636,7 @@ rt2661_stop(struct ifnet *ifp, int disable)
        if (disable && sc->sc_disable != NULL) {
                if (sc->sc_flags & RT2661_ENABLED) {
                        (*sc->sc_disable)(sc);
-                       sc->sc_flags &= ~RT2661_ENABLED;
+                       sc->sc_flags &= ~(RT2661_ENABLED | RT2661_FWLOADED);
                }
        }
 }
Index: rt2661var.h
===================================================================
RCS file: /cvs/src/sys/dev/ic/rt2661var.h,v
retrieving revision 1.13
diff -p -u rt2661var.h
--- rt2661var.h 7 Sep 2010 16:21:42 -0000       1.13
+++ rt2661var.h 10 Mar 2011 16:23:11 -0000
@@ -110,6 +110,7 @@ struct rt2661_softc {
 #define RT2661_ENABLED         (1 << 0)
 #define RT2661_UPDATE_SLOT     (1 << 1)
 #define RT2661_SET_SLOTTIME    (1 << 2)
+#define RT2661_FWLOADED                (1 << 3)
 
        int                             sc_tx_timer;

Reply via email to