Skip to content

Commit

Permalink
Merge pull request #52 from sleinen/clean-up-after-selftest
Browse files Browse the repository at this point in the history
(intel10g): Restore adapter configuration state after selftest.
  • Loading branch information
lukego committed Apr 8, 2013
2 parents b44c0fb + b80d3dc commit ce81685
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 ce81685

Please sign in to comment.