From b80d3dc777bb5c40df557104d7604e0bb1782d92 Mon Sep 17 00:00:00 2001 From: Simon Leinen Date: Sun, 7 Apr 2013 14:36:38 +0200 Subject: [PATCH] (get_configuration_state, restore_configuration_state): New functions. (selftest): Save and restore configuration test around the test. Notably, this will normally deactivate loopback mode again. --- src/intel10g.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/intel10g.lua b/src/intel10g.lua index c7c0e718ad..7350a3950c 100644 --- a/src/intel10g.lua +++ b/src/intel10g.lua @@ -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})) @@ -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) @@ -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"