[openfirmware] [commit] r3557 - cpu/arm/olpc/cl4 dev ofw/wifi

repository service svn at openfirmware.info
Mon Feb 18 08:31:19 CET 2013


Author: quozl
Date: Mon Feb 18 08:31:19 2013
New Revision: 3557
URL: http://tracker.coreboot.org/trac/openfirmware/changeset/3557

Log:
OLPC - libertas, add support for 802.11n 5 GHz networks on 8787.  Due to a firmware limit of 14 channels in a scan request, the scan logic was heavily changed.  During association a specific channel scan order is followed, and the first match stops further scanning.  The LEDs test was also changed to reduce the time taken.  #12552.

Modified:
   cpu/arm/olpc/cl4/leds.fth
   dev/libertas.fth
   ofw/wifi/data.fth
   ofw/wifi/eapol.fth

Modified: cpu/arm/olpc/cl4/leds.fth
==============================================================================
--- cpu/arm/olpc/cl4/leds.fth	Mon Feb 18 01:01:24 2013	(r3556)
+++ cpu/arm/olpc/cl4/leds.fth	Mon Feb 18 08:31:19 2013	(r3557)
@@ -30,7 +30,7 @@
    ols-led-on
    d# 100 ms
    hdd-led-on
-   " /wlan:quiet" test-dev
+   " led-blink" $call-wlan
    d# 100 ms
    ols-led-off
    ols-led-ec-control
@@ -42,13 +42,16 @@
 ;
 
 : (selftest)
+   0 to wlan-ih
+   " /wlan:force" open-dev ?dup  if  to wlan-ih  then
    get-msecs d# 10000 +                 ( limit )
    begin
       (cycle)
-      key?  if  drop exit  then
+      key?  if  drop  wlan-ih close-dev  exit  then
       dup get-msecs -  0<               ( limit timeout? )
    until                                ( limit )
    drop                                 ( )
+   wlan-ih close-dev
 ;
 
 : selftest  ( -- error? )

Modified: dev/libertas.fth
==============================================================================
--- dev/libertas.fth	Mon Feb 18 01:01:24 2013	(r3556)
+++ dev/libertas.fth	Mon Feb 18 08:31:19 2013	(r3557)
@@ -105,6 +105,8 @@
 : ssid$  ( -- $ )  ssid /ssid  ;
 
 0 value channel
+0 value 802.11n?                \ Hardware is 802.11n capable
+: channel-is-5ghz?  ( chan# -- )  d# 14 >  ;
 
 d# 80 buffer: wpa-ie		\ WPA IE saved for EAPOL phases
 0 value /wpa-ie
@@ -707,6 +709,11 @@
 : set-fw-params  ( -- )
    get-hw-spec  0=  if   ( adr )
 
+      \ is 802.11n capable?
+      dup d# 34 + le-l@ h# 800 and  if
+         true to 802.11n?
+      then ( adr )
+
       \ The 4-byte FWReleaseNumber field starts at offset d# 18.
       \ Firmware version 2.3.4.p1 is represented in that field
       \ as 04 03 02 01, i.e. the first three bytes are little-endian,
@@ -1138,19 +1145,16 @@
 
 h# 7ffe instance value channel-mask
 
-: +chan-list-tlv  ( -- )
+: +chan-tlv  ( channel# -- )
    h# 101 +xw
-   0 +xw  'x >r       ( r: 'payload )
-   #channels 1+  1  do
-      1 i lshift  channel-mask  and  if
-         0 +xb            \ Radio type
-         i +xb            \ Channel #
-         scan-type +xb    \ Scan type - 0:active  or  1:passive
-         d# 100 +xw       \ Min scan time
-         d# 100 +xw       \ Max scan time
-      then
-   loop
-   'x r@ -  r> 2- le-w!
+   0 +xw  'x >r                                 ( channel#  r: payload' )
+   dup channel-is-5ghz?  if 1 else 0 then       ( channel# band# )
+   +xb                          \ Band #
+   +xb                          \ Channel #
+   scan-type +xb                \ Scan type - 0:active  or  1:passive
+   d# 100 +xw                   \ Min scan time
+   d# 100 +xw                   \ Max scan time ( r: payload' )
+   'x r@ -  r> 2- le-w!                         ( )
 ;
 
 : +probes-tlv  ( -- )
@@ -1167,19 +1171,32 @@
    then
 ;
 
-: (scan)  ( -- error? | adr len 0 )
+: (scan)  ( chan -- error? | adr len 0 )
+
+   \ forge success for 2.4 ghz channels disabled in the channel-mask
+   dup channel-is-5ghz?  0=  if                 ( chan )
+      1 over lshift channel-mask and  0=  if    ( chan )
+         drop respbuf 0 0 exit
+      then
+   then                                         ( chan )
+
+   \ forge success for 5 ghz channels if the device lacks support
+   dup channel-is-5ghz?  802.11n?  0=  and  if
+      drop respbuf 0 0 exit
+   then
+
    6 ( CMD_802_11_SCAN ) start-cmd
    resp-wait-long to resp-wait
 
    BSS_ANY +xb
    6 +xerase           \ BSS ID
 
-   +chan-list-tlv
+   +chan-tlv
    +probes-tlv
    +ssid-tlv
 
-   finish-cmd outbuf-wait  dup  0=  if 	       ( error? )
-      respbuf /respbuf /fw-cmd /string  rot    ( adr len 0 )
+   finish-cmd outbuf-wait  dup  0=  if          ( error? )
+      respbuf /respbuf /fw-cmd /string  rot     ( adr len 0 )
    then
 ;
 
@@ -1200,14 +1217,21 @@
    d# 32 min  scan-ssid pack drop
 ;
 
-: scan  ( adr len -- actual )
-\   (scan)
-   begin  (scan)  dup 1 =  while  drop d# 1000 ms  repeat  \ Retry while busy
-   if  2drop 0 exit  then               ( adr len scan-adr scan-len )
-   rot min >r                           ( adr scan-adr r: len )
-   swap r@ move			        ( r: len )
-   r>
+: scan  ( adr len chan -- actual )
+   dup channel-is-5ghz?  802.11n?  0=  and  if  3drop 0 exit  then
+   >r                           ( adr len r: chan )
+   begin
+      r@ (scan)  dup 1 =
+   while
+      drop d# 1000 ms           \ retry while busy
+   repeat                       ( adr len scan-adr scan-len err? r: chan )
+   r> drop                      ( adr len scan-adr scan-len err? )
+   if  2drop 0 exit  then       ( adr len scan-adr scan-len )
+   rot min >r                   ( adr scan-adr r: actual )
+   swap r@ move                 ( r: actual )
+   r>                           ( actual )
 ;
+
 headers
 
 \ =========================================================================
@@ -1550,7 +1574,7 @@
    \ DS param
    3      +xw				\ element ID = DS param set
    1      +xw				\ len
-   ( ch ) +xb				\ channel
+   dup    +xb				\ channel
 
    \ CF param
    4 +xw				\ element ID = CF param set
@@ -1599,6 +1623,9 @@
       /x save-wpa-ie			\ Save IE in wpa-ie
    then
 
+   \ associating with a 5 GHz channel requires the band to be specified
+   802.11n?  if  +chan-tlv  else  drop  then   ( )
+
    \ XXX power (optional)
    \ XXX supported channels set (802.11h only)
    \ XXX pass thru IEs (optional)
@@ -2327,57 +2354,21 @@
    " target-mac$" $call-supplicant disassociate
 ;
 
-\ adr len  is the result of (scan) - a list of APs and their characteristics
-: test-association  ( adr len -- error? )
-   " OLPCOFW" " select-ssid?" $call-supplicant  if   ( )
-      " (do-associate)" $call-supplicant  if         ( )
-	 \ Success
-         do-disassociate
-         " true to ssid-reset?" ['] evaluate catch  if  2drop  then
-	 false
-      else
-	 true
-      then
-   else
-      \ There is no OLPCOFW access point, so we don't try associating
-      false
-   then
-;
-
 : (scan-wifi)  ( -- error? )
    true to force-open?
    open
    false to force-open?
    0=  if  ." Can't open Marvell wireless" cr true close  exit  then
-
-   (scan)  if
-      ." Failed to scan" true cr
-   else    ( adr len )
-\     drop .scan false
-      diagnostic-mode?  if  ( adr len )
-         drop 2+ c@  if     ( )
-            false
-         else
-            ." ERROR: No access points seen" cr
-            true
-         then
-      else                    ( adr len )
-	 \ Quiet mode is for the benefit of the LEDs test, so we can flash
-         \ the WLAN LEDS without distracting messages appearing on the screen
-         quiet?  if           ( adr len )
-            2drop false       ( error? )
-         else
-            2dup .ssids       ( adr len )
-            test-association  ( error? )
-         then                 ( error? )
-      then
-   then
-
+   " scan-all" $call-supplicant  ( error? )
    close
 ;
 
 : scan-wifi  ( -- )  (scan-wifi) drop  ;
 
+: led-blink  ( -- )
+   d# 6  (scan)  0=  if 2drop then
+;
+
 : reassociate  ( -- )
    do-disassociate
    do-associate  if  ." succeeded"  else  ." failed"  then  cr
@@ -2454,8 +2445,7 @@
 
 : ta-scan  ( -- )
    ." scan"  cr
-   (scan)                               ( adr len error? )
-   0=  if  .ssids cr  then              ( )
+   (scan-all) drop
 ;
 
 : ta-n  ( n -- )

Modified: ofw/wifi/data.fth
==============================================================================
--- ofw/wifi/data.fth	Mon Feb 18 01:01:24 2013	(r3556)
+++ ofw/wifi/data.fth	Mon Feb 18 08:31:19 2013	(r3557)
@@ -8,7 +8,7 @@
 : wpa-ie$   ( -- adr len )  " wpa-ie$" $call-parent  ;
 : write-force  ( adr len -- actual )  " write-force" $call-parent  ;
 : read-force   ( adr len -- actual )  " read-force"  $call-parent  ;
-: scan   ( adr len -- actual )  " scan"  $call-parent  ;
+: scan  ( adr len chan -- actual )  " scan"  $call-parent  ;
 : enable-rsn   ( -- )  " enable-rsn"  $call-parent drop  ;
 : disable-rsn  ( -- )  " disable-rsn" $call-parent drop  ;
 : disable-wep  ( -- )  " disable-wep" $call-parent drop  ;

Modified: ofw/wifi/eapol.fth
==============================================================================
--- ofw/wifi/eapol.fth	Mon Feb 18 01:01:24 2013	(r3556)
+++ ofw/wifi/eapol.fth	Mon Feb 18 08:31:19 2013	(r3557)
@@ -922,19 +922,62 @@
    ssid$ (select-ssid?)                  ( found? )
 ;
 
+create scan-order
+   d#  6 c, d#  1 c, d# 11 c,
+
+   d#  2 c, d#  3 c, d#  4 c, d#  5 c, d#  7 c, d#  8 c,
+   d#  9 c, d# 10 c, d# 12 c, d# 13 c, d# 14 c,
+
+   d# 36 c, d# 40 c, d# 44 c, d# 48 c,
+   d# 52 c, d# 56 c, d# 60 c, d# 64 c,
+
+   d# 100 c, d# 104 c, d# 108 c,
+   d# 112 c, d# 116 c, d# 132 c, d# 136 c,
+
+   d# 140 c, d# 149 c, d# 153 c,
+   d# 157 c, d# 161 c, d# 165 c,
+here scan-order - constant /scan-order
+
+: test-association  ( adr len -- error? )
+   " OLPCOFW" select-ssid?  if
+      (do-associate)  if
+         target-mac$ " disassociate" $call-parent
+         true to ssid-reset?
+      then
+   then
+;
+
+: scan-all  ( -- error? )
+   scan-order /scan-order bounds do           ( )
+      scanbuf /buf  i c@                      ( adr len chan )
+      scan  dup if                            ( actual )
+         scanbuf swap                         ( adr len )
+         2dup .ssids                          ( adr len )
+         test-association
+      else                                    ( actual )
+         drop unloop true exit
+      then
+   loop
+   false
+;
+
 : scan-ssid?  ( ssid$ -- found? )
    dup 0=  if  2drop false exit  then         ( ssid$ )
    ssid!                                      ( )
    ssid$  " set-ssid" $call-parent            ( )
    ??cr ." Scan for: " ssid$ type space       ( )
-   scanbuf /buf scan  if                      ( )
-      debug?  if  scanbuf .scan  then         ( )
-      ssid$ (select-ssid?)                    ( found? )
-      dup  if  ." found"  else  ." failed"  then  cr
-   else                                       ( )
-      ." not found"  cr  false                ( found? )
-   then                                       ( found? )
+
+   scan-order /scan-order bounds do           ( )
+      scanbuf /buf  i c@                      ( adr len chan )
+      scan  if                                ( )
+         debug?  if  scanbuf .scan  then      ( )
+         ssid$ (select-ssid?)                 ( found? )
+         if  ." found"  cr unloop true exit  then
+      then
+   loop
+   ." not found"  cr  false                  ( found? )
 ;
+
 : try-scan  ( -- okay? )
    wifi-ssid$  scan-ssid?  if  true exit  then
    default-ssids  begin  dup  while   ( rem$ )



More information about the openfirmware mailing list