Noise ripped out after the bench verdict (tightly-wrapped unshielded cables move victim SNR only 0.2-0.3 dB, recorded in measurement.md dead ends): noise.go deleted with the noiser, phase clock and panel lane; configureNoise/checkPrivFlag gone so the X710 pair is untouched; console noise column, NOISE links rows and lane colors removed; driverPair rehomed to system.go, carrierUp to phy.go; history anchors to run start (frame-rate sampling and draw-clock roll kept — they fix display latency for every lane); goals/hardware/state/nics docs updated; verified on hardware (20.00G, zero errors, ECD 41m, SNR +7.6)
This commit is contained in:
@@ -6,12 +6,39 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
"unsafe"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
// Kernel names shift with which drivers are built in, since ethN is handed out
|
||||
// in link order rather than by slot. The driver name is the one label a port
|
||||
// keeps across kernel configs, so pairs are found by it rather than named.
|
||||
func driverPair(driver string) (string, string, error) {
|
||||
ents, err := os.ReadDir("/sys/class/net")
|
||||
if err != nil {
|
||||
return "", "", err
|
||||
}
|
||||
var names []string
|
||||
for _, e := range ents {
|
||||
link, err := os.Readlink("/sys/class/net/" + e.Name() + "/device/driver")
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
if filepath.Base(link) == driver {
|
||||
names = append(names, e.Name())
|
||||
}
|
||||
}
|
||||
if len(names) != 2 {
|
||||
return "", "", fmt.Errorf("want 2 %s interfaces, found %d [%s]",
|
||||
driver, len(names), strings.Join(names, " "))
|
||||
}
|
||||
sort.Strings(names)
|
||||
return names[0], names[1], nil
|
||||
}
|
||||
|
||||
const (
|
||||
ethtoolGRXRINGS = 0x2d
|
||||
ethtoolGRXCLSRLCNT = 0x2e
|
||||
@@ -366,9 +393,8 @@ func getCoalesce(fd int, ifname string) (ethtoolCoalesce, error) {
|
||||
}
|
||||
|
||||
const (
|
||||
ethSSStats = 1
|
||||
ethSSPrivFlags = 2
|
||||
ethGstringLen = 32
|
||||
ethSSStats = 1
|
||||
ethGstringLen = 32
|
||||
)
|
||||
|
||||
// Each of these has a __u32 or __u8 tail the kernel fills past the end of the
|
||||
@@ -660,67 +686,6 @@ func withIoctlSocket(fn func(fd int) []checkResult) []checkResult {
|
||||
return fn(fd)
|
||||
}
|
||||
|
||||
type ethtoolValue struct {
|
||||
cmd uint32
|
||||
data uint32
|
||||
}
|
||||
|
||||
// i40e leaves the module transmitting when a port is closed, so the peer never
|
||||
// sees anything happen and the copper stays trained. This flag is what makes
|
||||
// an administrative down reach the wire, and the noise cycle is switched
|
||||
// entirely through it.
|
||||
func checkPrivFlag(fd int, ifname, flag string) checkResult {
|
||||
res := checkResult{item: ifname + " " + flag}
|
||||
names, err := stringSetNames(fd, ifname, ethSSPrivFlags)
|
||||
if err != nil {
|
||||
res.err = err
|
||||
return res
|
||||
}
|
||||
bit := -1
|
||||
for i, s := range names {
|
||||
if s == flag {
|
||||
bit = i
|
||||
break
|
||||
}
|
||||
}
|
||||
if bit < 0 {
|
||||
res.err = fmt.Errorf("driver has no private flag %q", flag)
|
||||
return res
|
||||
}
|
||||
v := ethtoolValue{cmd: unix.ETHTOOL_GPFLAGS}
|
||||
if err := ethtoolCall(fd, ifname, unsafe.Pointer(&v)); err != nil {
|
||||
res.err = err
|
||||
return res
|
||||
}
|
||||
if v.data&(1<<bit) != 0 {
|
||||
res.state = "on"
|
||||
return res
|
||||
}
|
||||
v.cmd = unix.ETHTOOL_SPFLAGS
|
||||
v.data |= 1 << bit
|
||||
if err := ethtoolCall(fd, ifname, unsafe.Pointer(&v)); err != nil {
|
||||
res.err = err
|
||||
res.state = "could not set"
|
||||
return res
|
||||
}
|
||||
res.fixed = true
|
||||
res.state = "was off, now on"
|
||||
return res
|
||||
}
|
||||
|
||||
// The noise ports get none of the test pair's tuning: nothing is measured on
|
||||
// them, so rings, coalescing and steering are all beside the point. All they
|
||||
// need is for a closed port to really drop the link.
|
||||
func configureNoise(ifnames []string) []checkResult {
|
||||
return withIoctlSocket(func(fd int) []checkResult {
|
||||
var out []checkResult
|
||||
for _, ifname := range ifnames {
|
||||
out = append(out, checkPrivFlag(fd, ifname, "link-down-on-close"))
|
||||
}
|
||||
return out
|
||||
})
|
||||
}
|
||||
|
||||
// Nothing here waits for a carrier: the two ports are the two ends of the cable
|
||||
// under test, so with no cable there is never going to be one.
|
||||
func configureSystem(ifnames []string, ethertypes []uint16) []checkResult {
|
||||
|
||||
Reference in New Issue
Block a user