BCM module diagnostics replace timestamp probes: bringup forces EEE off and runs ECD (re-run on every reset, re-baselining past its blip), 1 Hz SNR margin + corrected counters on panel and console; X520 bench divergences bypassed and tracked in open-questions

This commit is contained in:
flamingcow
2026-08-13 07:10:39 -07:00
parent a00f2216b7
commit 979dc7a772
18 changed files with 1240 additions and 416 deletions
+48 -17
View File
@@ -1,7 +1,9 @@
package main
import (
"fmt"
"os"
"path/filepath"
"strconv"
"strings"
"sync/atomic"
@@ -28,22 +30,43 @@ var nicTxFields = []string{
// Receiving is the hardware's, and is taken from the driver's own array, which
// sysfs both flattens and overlaps: ice folds crc errors and jabbers into
// rx_errors, so the old sum of rx_errors alongside rx_crc_errors charged every
// bad frame check twice. Named individually here, so nothing contains anything
// else in the list.
var nicRxStats = []string{
"rx_crc_errors.nic",
"rx_jabber.nic",
"rx_undersize.nic",
"rx_oversize.nic",
"rx_fragments.nic",
"rx_dropped.nic",
// Below the frame: a 64b/66b block that decoded to no legal symbol, and the
// fault ordered sets the pcs sends when it loses sync. A cable going
// marginal moves these while every frame still arrives intact, which is as
// close to a bit error rate as this link will report.
"illegal_bytes.nic",
"mac_local_faults.nic",
"mac_remote_faults.nic",
// bad frame check twice. Named individually per driver, so nothing contains
// anything else in its list.
var nicRxStatsByDriver = map[string][]string{
// The reference set (E810). Below the frame: illegal_bytes is a 64b/66b
// block that decoded to no legal symbol, and the faults are the ordered
// sets the pcs sends when it loses sync. A cable going marginal moves
// these while every frame still arrives intact, which is as close to a
// bit error rate as this link will report.
"ice": {
"rx_crc_errors.nic",
"rx_jabber.nic",
"rx_undersize.nic",
"rx_oversize.nic",
"rx_fragments.nic",
"rx_dropped.nic",
"illegal_bytes.nic",
"mac_local_faults.nic",
"mac_remote_faults.nic",
},
// The 82599 exposes no jabber, fragment, illegal-byte or fault counters
// through ethtool — this is the closest bench set, and one of the X520
// divergences listed in docs/open-questions.md.
"ixgbe": {
"rx_crc_errors",
"rx_missed_errors",
"rx_length_errors",
"rx_long_length_errors",
"rx_short_length_errors",
},
}
func ifDriver(name string) (string, error) {
link, err := os.Readlink("/sys/class/net/" + name + "/device/driver")
if err != nil {
return "", err
}
return filepath.Base(link), nil
}
func readUint(path string) (uint64, bool) {
@@ -93,7 +116,15 @@ type nicPoller struct {
}
func newNICPoller(fd int, txName, rxName string, total *atomic.Uint64) (*nicPoller, error) {
rx, err := newStatReader(fd, rxName, nicRxStats)
drv, err := ifDriver(rxName)
if err != nil {
return nil, err
}
want, ok := nicRxStatsByDriver[drv]
if !ok {
return nil, fmt.Errorf("%s: no rx error statistic set for driver %s", rxName, drv)
}
rx, err := newStatReader(fd, rxName, want)
if err != nil {
return nil, err
}