Author: wmb Date: 2010-01-13 01:39:17 +0100 (Wed, 13 Jan 2010) New Revision: 1669
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: Added promiscuous and multicast reception capability to USB Ethernet drivers.
Modified: dev/usb2/device/net/ax8817x.fth =================================================================== --- dev/usb2/device/net/ax8817x.fth 2010-01-13 00:38:24 UTC (rev 1668) +++ dev/usb2/device/net/ax8817x.fth 2010-01-13 00:39:17 UTC (rev 1669) @@ -215,12 +215,21 @@
0 value has-internal-loopback?
-h# 88 constant def-rx-ctl \ SO (MAC ON) and AB (accept broadcast) +h# 88 value def-rx-ctl \ SO (MAC ON) and AB (accept broadcast)
: ax-start-nic ( -- ) ax-auto-neg-wait - def-rx-ctl my-args " promiscuous" $= if 1 or then rx-ctl! + h# 88 + use-promiscuous? if + 1 or + else + use-multicast? if 2 or then + then + to def-rx-ctl + def-rx-ctl rx-ctl! ; +: 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-init-nic ( -- ) \ Per ax8817x_bind @@ -273,6 +282,8 @@ ['] ax-mii-hw to }mii ['] ax-loopback{ to loopback{ ['] ax-}loopback to }loopback + ['] ax-promiscuous to promiscuous + ['] ax-set-multicast to set-multicast
vid h# 2001 = pid h# 1a00 = and if h# 009f.9d9f to ax-gpio then vid h# 07b8 = pid h# 420a = and if h# 001f.1d1f to ax-gpio then
Modified: dev/usb2/device/net/common.fth =================================================================== --- dev/usb2/device/net/common.fth 2010-01-13 00:38:24 UTC (rev 1668) +++ dev/usb2/device/net/common.fth 2010-01-13 00:39:17 UTC (rev 1669) @@ -14,6 +14,9 @@ 6 constant /mac-adr : mac-adr$ ( -- adr len ) mac-adr /mac-adr ;
+false value use-promiscuous? +false value use-multicast? + defer init-nic ( -- ) ' noop to init-nic defer wrap-msg ( adr len -- adr' len' ) ' noop to wrap-msg defer unwrap-msg ( adr len -- adr' len' ) ' noop to unwrap-msg @@ -25,6 +28,10 @@ defer }mii ( -- ) ' noop to }mii \ Release defer mii@ ( reg -- val ) ' noop to mii@ defer mii! ( val reg -- ) ' drop to mii@ +external +defer promiscuous ( -- ) ' noop to promiscuous +defer set-multicast ( adr len -- ) ' 2drop to set-multicast +headers
: phy-loopback{ ( -- ) mii{ 0 mii@ h# 4000 or 0 mii! }mii
Modified: dev/usb2/device/net/ethernet.fth =================================================================== --- dev/usb2/device/net/ethernet.fth 2010-01-13 00:38:24 UTC (rev 1668) +++ dev/usb2/device/net/ethernet.fth 2010-01-13 00:39:17 UTC (rev 1669) @@ -201,6 +201,19 @@ false ;
+: parse-args ( -- ) + false to use-promiscuous? + false to use-multicast? + my-args + begin ?dup while + ascii , left-parse-string + 2dup " debug" $= if debug-on then + 2dup " promiscuous" $= if true to use-promiscuous? then + 2dup " multicast" $= if true to use-multicast? then + 2drop + repeat drop +; + external
: close ( -- ) @@ -209,7 +222,7 @@ ;
: open ( -- ok? ) - my-args " debug" $= if debug-on then + parse-args device set-target
opencount @ 0= if
Modified: dev/usb2/device/net/pegasus.fth =================================================================== --- dev/usb2/device/net/pegasus.fth 2010-01-13 00:38:24 UTC (rev 1668) +++ dev/usb2/device/net/pegasus.fth 2010-01-13 00:39:17 UTC (rev 1669) @@ -9,9 +9,9 @@ h# f1 constant SET_REG
\ Select register definitions -: ec0 0 ; -: ec1 1 ; -: ec2 2 ; +: ectl0 0 ; +: ectl1 1 ; +: ectl2 2 ; : gpio10c h# 7e ; : gpio32c h# 7f ; : phya h# 25 ; @@ -97,8 +97,8 @@
: pg-link-up? ( -- flag ) 1 pg-mii@ 4 and 0<> ;
-: pg-reset-mac ( -- ) 8 ec1 pg-reg-c! ; -: pg-mac-reset? ( -- ) ec1 pg-reg-c@ 8 and 0= ; +: pg-reset-mac ( -- ) 8 ectl1 pg-reg-c! ; +: pg-mac-reset? ( -- ) ectl1 pg-reg-c@ 8 and 0= ;
: pg-init-mac ( -- ) pg-reset-mac begin pg-mac-reset? until @@ -130,11 +130,19 @@ : pg-start-nic ( -- ) pg-sync-link-status \ force 100Mbps full-duplex - h# 0130c9 ec0 3 pg-write-reg + h# 0130c9 + use-promiscuous? if + h# 040000 or + else + use-multicast? if 2 or then + then + ectl0 3 pg-write-reg ; +: 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 ( -- ) - 0 ec0 2 pg-write-reg + 0 ectl0 2 pg-write-reg ;
\ Process the length header that's inlined after the frame @@ -153,6 +161,8 @@ ['] pg-unwrap-msg to unwrap-msg ['] pg-mii@ to mii@ ['] pg-mii! to mii! + ['] pg-promiscuous to promiscuous + ['] pg-set-multicast to set-multicast ;
: init ( -- ) init vid pid pegasus? if init-pegasus then ;
openfirmware@openfirmware.info