STRUCT MXL862XX_PORT_STATS(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… struct mxl862xx_port_stats(9) β€” the Kernel API Manual page you didn't know you needed

okay so bestie, welcome to section 9 of the Kernel API Manual, where we're talking about struct mxl862xx_port_stats and honestly? it's a whole vibe. it's the 64-bit accumulated hardware port statistics struct, and it is carrying the entire counters operation on its back. 🫢


✨ NAME ✨

struct mxl862xx_port_stats β€” 64-bit accumulated hardware port statistics. that's it, that's the girl. πŸ’…


🌸 SYNOPSIS 🌸

struct mxl862xx_port_stats {
    u64 rx_packets;
    u64 tx_packets;
    u64 rx_bytes;
    u64 tx_bytes;
    u64 rx_errors;
    u64 tx_errors;
    u64 rx_dropped;
    u64 tx_dropped;
    u64 multicast;
    u64 collisions;
    u64 rx_length_errors;
    u64 rx_crc_errors;
    u64 rx_frame_errors;
    u32 prev_rx_good_pkts;
    u32 prev_tx_good_pkts;
    u64 prev_rx_good_bytes;
    u64 prev_tx_good_bytes;
    u32 prev_rx_fcserror_pkts;
    u32 prev_rx_under_size_error_pkts;
    u32 prev_rx_oversize_error_pkts;
    u32 prev_rx_align_error_pkts;
    u32 prev_tx_dropped_pkts;
    u32 prev_rx_dropped_pkts;
    u32 prev_rx_evlan_discard_pkts;
    u32 prev_mtu_exceed_discard_pkts;
    u32 prev_tx_acm_dropped_pkts;
    u32 prev_rx_multicast_pkts;
    u32 prev_tx_coll_count;
};

look at all those fields. ✨ twenty eight of them. she's thorough, she's organized, she has a prev_ section like a notes app with folders. iykyk.


πŸ¦‹ MEMBERS πŸ¦‹

the main character counters πŸ‘‘

  • rx_packets β€” total received packets πŸŽ€
  • tx_packets β€” total transmitted packets πŸŽ€
  • rx_bytes β€” total received bytes
  • tx_bytes β€” total transmitted bytes
  • rx_errors β€” total receive errors. not slay, but we count them anyway 😭
  • tx_errors β€” total transmit errors
  • rx_dropped β€” total received packets that got dropped
  • tx_dropped β€” total transmitted packets that got dropped
  • multicast β€” total received multicast packets
  • collisions β€” total transmit collisions πŸ’€

the error girlies 🩹

  • rx_length_errors β€” received length errors (undersize + oversize)
  • rx_crc_errors β€” received FCS errors
  • rx_frame_errors β€” received alignment errors

the prev_ snapshots (the receipts) πŸ“Έ

so these are all previous snapshots β€” the raw counter value from last time we looked, so we can do the math on the delta later. literally the "before" picture.

  • prev_rx_good_pkts β€” previous snapshot of rx good packet counter
  • prev_tx_good_pkts β€” previous snapshot of tx good packet counter
  • prev_rx_good_bytes β€” previous snapshot of rx good byte counter
  • prev_tx_good_bytes β€” previous snapshot of tx good byte counter
  • prev_rx_fcserror_pkts β€” previous snapshot of rx FCS error counter
  • prev_rx_under_size_error_pkts β€” previous snapshot of rx undersize error counter
  • prev_rx_oversize_error_pkts β€” previous snapshot of rx oversize error counter
  • prev_rx_align_error_pkts β€” previous snapshot of rx alignment error counter
  • prev_tx_dropped_pkts β€” previous snapshot of tx dropped counter
  • prev_rx_dropped_pkts β€” previous snapshot of rx dropped counter
  • prev_rx_evlan_discard_pkts β€” previous snapshot of extended VLAN discard counter
  • prev_mtu_exceed_discard_pkts β€” previous snapshot of MTU exceed discard counter
  • prev_tx_acm_dropped_pkts β€” previous snapshot of tx ACM dropped counter
  • prev_rx_multicast_pkts β€” previous snapshot of rx multicast counter
  • prev_tx_coll_count β€” previous snapshot of tx collision counter

πŸ’œ DESCRIPTION πŸ’œ

okay so here's the lore, and it's genuinely iconic:

the firmware RMON counters are 32-bit free-running (and they're 64-bit for byte counters, because bytes are extra like that πŸ’…). this structure holds 64-bit accumulators alongside the previous raw snapshot so that deltas can be computed across polls.

and the way it handles 32-bit wrap correctly? via unsigned subtraction. no cap. that's the whole trick. the counter rolls over, you subtract, the unsigned math Just Worksβ„’, and your numbers stay correct. periodt. πŸ‘‘

ngl this is the part people mess up β€” the wrap handling is the reason the prev_* fields exist. respect the design. 🌈

πŸ‘€ SEE ALSO πŸ‘€

the kernel file lives at ./drivers/net/dsa/mxl862xx/mxl862xx.h β€” go read it, bestie, it's giving source of truth πŸ’–

and the whole friend group:


mwah πŸ’‹ this page came to you from ./drivers/net/dsa/mxl862xx, dated October 2026, and it's a struct mxl862xx_port_stats(9) situation through and through. go forth and poll your counters, queen. πŸŽ€βœ¨πŸ¦‹

πŸ“¦ where this page comes from