[openfirmware] r1675 - dev/usb2/device/net

svn at openfirmware.info svn at openfirmware.info
Fri Jan 15 03:48:24 CET 2010


Author: wmb
Date: 2010-01-15 03:48:23 +0100 (Fri, 15 Jan 2010)
New Revision: 1675

Modified:
   dev/usb2/device/net/ax8817x.fth
   dev/usb2/device/net/common.fth
   dev/usb2/device/net/ethernet.fth
   dev/usb2/device/net/pegasus.fth
Log:
OLPC trac 9691 - changed the order of some steps in the USB ethernet start
code in hopes of eliminating the "lost first receive packet" syndrome.
With these changes, the two Asix-based adapters that I have in hand both
start reliably with no DHCP retries.


Modified: dev/usb2/device/net/ax8817x.fth
===================================================================
--- dev/usb2/device/net/ax8817x.fth	2010-01-14 06:27:28 UTC (rev 1674)
+++ dev/usb2/device/net/ax8817x.fth	2010-01-15 02:48:23 UTC (rev 1675)
@@ -217,8 +217,7 @@
 
 h# 88 value def-rx-ctl   \ SO (MAC ON) and AB (accept broadcast)
 
-: ax-start-nic  ( -- )
-   ax-auto-neg-wait
+: ax-start-mac  ( -- )
    h# 88
    use-promiscuous?  if
       1 or
@@ -228,9 +227,13 @@
    to def-rx-ctl
    def-rx-ctl rx-ctl!
 ;
+
+: ax-start-phy  ( -- )
+   ax-auto-neg-wait
+;
 : ax-promiscuous  ( -- )  rx-ctl@  1 or  rx-ctl!  ;
 : ax-set-multicast  ( adr len -- )  2drop rx-ctl@  2 or  rx-ctl!  ;
-: ax-stop-nic  ( -- )  0 rx-ctl!  ;
+: ax-stop-mac  ( -- )  0 rx-ctl!  ;
 
 : ax-init-nic  ( -- )		\ Per ax8817x_bind
    bulk-out-pipe 3 >  if
@@ -249,8 +252,7 @@
    ax-toggle-gpio
    ax-get-phyid
    select-phy
-   h# 80 rx-ctl!  \ Turn off receiver during setup
-   \ ax-stop-nic
+   ax-stop-mac
    ax-get-mac-address  2drop
    ax-set-ipg
    ax-init-mii
@@ -273,8 +275,9 @@
 : init-ax  ( -- )
    ['] ax-init-nic  to init-nic
    ['] ax-link-up?  to link-up?
-   ['] ax-start-nic to start-nic
-   ['] ax-stop-nic  to stop-nic
+   ['] ax-start-mac to start-mac
+   ['] ax-start-phy to start-phy
+   ['] ax-stop-mac  to stop-mac
    ['] ax-get-mac-address to get-mac-address
    ['] ax-mii@ to mii@
    ['] ax-mii! to mii!

Modified: dev/usb2/device/net/common.fth
===================================================================
--- dev/usb2/device/net/common.fth	2010-01-14 06:27:28 UTC (rev 1674)
+++ dev/usb2/device/net/common.fth	2010-01-15 02:48:23 UTC (rev 1675)
@@ -18,12 +18,13 @@
 false value use-multicast?
 
 defer init-nic         ( -- )			' noop to init-nic
+defer reset-nic        ( -- )			' noop to reset-nic
 defer wrap-msg         ( adr len -- adr' len' )	' noop to wrap-msg
 defer unwrap-msg       ( adr len -- adr' len' )	' noop to unwrap-msg
 defer link-up?	       ( -- up? )		' true to link-up?
-defer reset-nic        ( -- )			' noop to reset-nic
-defer start-nic        ( -- )			' noop to start-nic
-defer stop-nic         ( -- )			' noop to stop-nic
+defer start-phy        ( -- )			' noop to start-phy
+defer start-mac        ( -- ) 			' noop to start-mac
+defer stop-mac         ( -- )			' noop to stop-mac
 defer mii{             ( -- )                   ' noop to mii{  \ Acquire
 defer }mii             ( -- )                   ' noop to }mii  \ Release
 defer mii@             ( reg -- val )           ' noop to mii@
@@ -80,7 +81,7 @@
 
 : property-or-abort  ( name$ -- n )
    2dup get-my-property  if          ( name$ )
-      ." Can't find property " type cr  stop-nic abort
+      ." Can't find property " type cr  stop-mac abort
    then                              ( name$ value$ )
    2swap 2drop  decode-int  nip nip  ( n )
 ;

Modified: dev/usb2/device/net/ethernet.fth
===================================================================
--- dev/usb2/device/net/ethernet.fth	2010-01-14 06:27:28 UTC (rev 1674)
+++ dev/usb2/device/net/ethernet.fth	2010-01-15 02:48:23 UTC (rev 1675)
@@ -28,7 +28,7 @@
 ;
 
 : stop-net  ( -- )
-   stop-nic
+   stop-mac
    end-bulk-in
    free-buf
 ;
@@ -41,7 +41,7 @@
 
 : copy-packet  ( adr len -- len' )
    dup multi-packet?  if  4 +  then   ( adr len len' )
-   /outbuf >  if  ." USB Ethernet write packet too long" cr  stop-nic abort  then  ( adr len )
+   /outbuf >  if  ." USB Ethernet write packet too long" cr  stop-mac abort  then  ( adr len )
 
    multi-packet?  if       ( adr len )
       dup wbsplit          ( adr len len.low len.high )
@@ -71,7 +71,7 @@
 \ The data format is:
 \  length.leword  ~length.leword  data  [ pad-to-even ]
 : extract-packet  ( -- data-adr len )
-   residue 4 <  if  ." Short residue from USB Ethernet" cr stop-nic  abort  then
+   residue 4 <  if  ." Short residue from USB Ethernet" cr stop-mac  abort  then
 
    pkt-adr dup 4 +  swap >r
    r@ c@     r@ 1+  c@ bwjoin   ( data-adr length )
@@ -130,7 +130,7 @@
       0					( adr 0 )
    then					( adr ihandle|0 )
 
-   dup  0=  if  ." Can't open obp-tftp support package" stop-nic abort  then
+   dup  0=  if  ." Can't open obp-tftp support package" stop-mac abort  then
 					( adr ihandle )
 
    >r
@@ -181,23 +181,25 @@
       clear-rx
       5 0  do  try-loopback?  ?leave  loop
    }loopback
+   d# 20 ms  \ Settling time after switching back
    scratch-buf d# 2000 free-mem
 ;
 
 : do-start?  ( -- error? )
-   start-nic
+   start-phy
 
    link-up? 0=  if
       ." Network not connected." cr
-      stop-nic
+      end-bulk-in
+      free-buf
       true exit
    then
 
    init-buf
    inbuf /inbuf bulk-in-pipe begin-bulk-in
+   start-mac
 
    loopback-test
-
    false
 ;
 

Modified: dev/usb2/device/net/pegasus.fth
===================================================================
--- dev/usb2/device/net/pegasus.fth	2010-01-14 06:27:28 UTC (rev 1674)
+++ dev/usb2/device/net/pegasus.fth	2010-01-15 02:48:23 UTC (rev 1675)
@@ -127,8 +127,7 @@
    pg-sync-link-status
 ;
 
-: pg-start-nic ( -- )
-   pg-sync-link-status
+: pg-start-mac  ( -- )
    \ force 100Mbps full-duplex
    h# 0130c9
    use-promiscuous?  if
@@ -138,10 +137,15 @@
    then
    ectl0 3 pg-write-reg
 ;
+
+: pg-start-phy ( -- )
+   pg-sync-link-status
+;
+
 : pg-promiscuous  ( -- )  ectl2 pg-reg-c@  4 or  ectl2 pg-reg-c!  ;
 : pg-set-multicast  ( -- )  ectl0 pg-reg-c@  2 or  ectl0 pg-reg-c!  ;
 
-: pg-stop-nic ( -- )
+: pg-stop-mac ( -- )
    0 ectl0 2 pg-write-reg
 ;
 
@@ -155,8 +159,9 @@
 : init-pegasus  ( -- )
    ['] pg-init-nic  to init-nic
    ['] pg-link-up?  to link-up?
-   ['] pg-start-nic to start-nic
-   ['] pg-stop-nic  to stop-nic
+   ['] pg-start-phy to start-phy
+   ['] pg-start-mac to start-mac
+   ['] pg-stop-mac  to stop-mac
    ['] pg-get-mac-address to get-mac-address
    ['] pg-unwrap-msg to unwrap-msg
    ['] pg-mii@ to mii@




More information about the openfirmware mailing list