Skip to content

Commit

Permalink
(get_configuration_state, restore_configuration_state): New functions.
Browse files Browse the repository at this point in the history
(selftest): Save and restore configuration test around the test.
Notably, this will normally deactivate loopback mode again.
  • Loading branch information
Simon Leinen committed Apr 7, 2013
1 parent b44c0fb commit b80d3dc
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/intel10g.lua
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,15 @@ end

function linkup () return bitset(r.LINKS(), 30) end

function get_configuration_state ()
return { AUTOC = r.AUTOC(), HLREG0 = r.HLREG0() }
end

function restore_configuration_state (saved_state)
r.AUTOC(saved_state.AUTOC)
r.HLREG0(saved_state.HLREG0)
end

function enable_mac_loopback ()
r.AUTOC:set(bits({ForceLinkUp=0, LMS10G=13}))
r.HLREG0:set(bits({Loop=15}))
Expand Down Expand Up @@ -209,6 +218,7 @@ end
function selftest ()
print("intel10g")
open()
local saved_state = get_configuration_state()
enable_mac_loopback()
test.waitfor("linkup", linkup, 20, 250000)
local finished = lib.timer(1e9)
Expand All @@ -220,6 +230,7 @@ function selftest ()
sync()
-- C.usleep(1)
until finished()
restore_configuration_state(saved_state)
assert(buffers[40960]==99)
C.usleep(1000)
print "stats"
Expand Down

0 comments on commit b80d3dc

Please sign in to comment.