Read rx errors from the driver stats array and add the pcs counters

This commit is contained in:
flamingcow
2026-08-04 11:27:30 -07:00
parent 5eea6856fb
commit 49a1a2f829
3 changed files with 219 additions and 44 deletions
+14 -1
View File
@@ -48,6 +48,7 @@ type direction struct {
probeSpec *frameSpec
probeTxFD int
probeRxFD int
statFD int
cable *cableStats
// Guards everything the sampler touches. The counters are read on their own
@@ -456,7 +457,18 @@ func buildDirection(label string, tx, rx endpoint, sizes []int, cfg config) (*di
streams: newLossWindows(cfg.streams),
cable: newCableStats(),
}
d.poller = &nicPoller{txName: tx.name, rxName: rx.name, total: &d.nic}
// Held open for the life of the run: the stats ioctl is issued five times a
// second and reopening a socket for each one is pure overhead.
statFD, err := unix.Socket(unix.AF_INET, unix.SOCK_DGRAM, 0)
if err != nil {
return nil, fmt.Errorf("%s stats socket: %w", label, err)
}
d.statFD = statFD
d.poller, err = newNICPoller(statFD, tx.name, rx.name, &d.nic)
if err != nil {
return nil, fmt.Errorf("%s: %w", label, err)
}
d.win = newRateWindow(int(rateWindowSpan/sampleInterval) + 1)
for i := 0; i < cfg.streams; i++ {
@@ -563,6 +575,7 @@ func (d *direction) close() {
}
unix.Close(d.probeTxFD)
unix.Close(d.probeRxFD)
unix.Close(d.statFD)
}
type config struct {