Page MenuHomeFreeBSD

Support IFCOUNTER_OBYTES and IFCOUNTER_OMCASTS even with VTNET_LEGACY_TX defined
ClosedPublic

Authored by joyul_juniper.net on Apr 16 2024, 8:42 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Oct 11, 6:48 AM
Unknown Object (File)
Sat, Oct 11, 6:48 AM
Unknown Object (File)
Sat, Oct 11, 6:48 AM
Unknown Object (File)
Fri, Oct 10, 11:31 PM
Unknown Object (File)
Thu, Oct 9, 2:28 PM
Unknown Object (File)
Sun, Sep 28, 3:21 AM
Unknown Object (File)
Sep 13 2025, 2:08 PM
Unknown Object (File)
Sep 12 2025, 5:42 AM
Subscribers

Details

Summary

vtxs_obytes and vtxs_omcasts are updated in vtnet_txq_eof, which is not bound with VTNET_LEGACY_TX. Thus, both should be supported regardless of whether VTNET_LEGACY_TX is defined or not.

Test Plan

Use if_get_counter API with IFCOUNTER_OBYTES and make sure output byte counts are updated.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

joyul_juniper.net created this revision.

Looks like driver does "hardware" accounting and software accounting at the same time. That's why we see correct counts without your patches. If vtnet_accum_stats() provides us with all what we need, then the driver should declare IFCAP_HWSTATS in its capabilities. That will turn off software accounting by the network stack. May I ask you to add this and also combine D44816 and D44817 into a single review?

zlei requested changes to this revision.Apr 18 2024, 7:49 AM
zlei added inline comments.
sys/dev/virtio/network/if_vtnet.c
3015

I believe the condition is intentional.

VTNET_LEGACY_TX is defined when ALTQ is enabled [1]. ALTQ will do statistics by itself [2].

So this removal will end up double accounting of IFCOUNTER_OBYTES and IFCOUNTER_OMCASTS ( when ALTQ is enabled ).

  1. https://cgit.freebsd.org/src/tree/sys/dev/virtio/network/if_vtnetvar.h#n33
  2. https://cgit.freebsd.org/src/tree/sys/net/ifq.h#n251
This revision now requires changes to proceed.Apr 18 2024, 7:49 AM

Looks like driver does "hardware" accounting and software accounting at the same time. That's why we see correct counts without your patches. If vtnet_accum_stats() provides us with all what we need, then the driver should declare IFCAP_HWSTATS in its capabilities. That will turn off software accounting by the network stack. May I ask you to add this and also combine D44816 and D44817 into a single review?

Looks like driver does "hardware" accounting and software accounting at the same time. That's why we see correct counts without your patches. If vtnet_accum_stats() provides us with all what we need, then the driver should declare IFCAP_HWSTATS in its capabilities. That will turn off software accounting by the network stack. May I ask you to add this and also combine D44816 and D44817 into a single review?

sys/dev/virtio/network/if_vtnet.c
3015

I believe the condition is intentional.

VTNET_LEGACY_TX is defined when ALTQ is enabled [1]. ALTQ will do statistics by itself [2].

So this removal will end up double accounting of IFCOUNTER_OBYTES and IFCOUNTER_OMCASTS ( when ALTQ is enabled ).

I must be drunk. That should be harmless regardless ALTQ. vtnet_accum_stats() accounts hardware statistics only. No double accounting indeed.

  1. https://cgit.freebsd.org/src/tree/sys/dev/virtio/network/if_vtnetvar.h#n33
  2. https://cgit.freebsd.org/src/tree/sys/net/ifq.h#n251

@glebius
Currently IFCAP_HWSTATS is only for inbound packets. Shall we extend it also for outbound packets ?

This revision is now accepted and ready to land.Apr 18 2024, 9:21 AM

I'd like to commit this before branching stable/15. @glebius Any thoughs ?

Currently IFCAP_HWSTATS is only for inbound packets. Shall we extend it also for outbound packets ?

This is historical misfeature of the BSD stack. In the software mode drivers are expected to increment the outbound counters themselves, while inbound is incremented in ether_input_internal().

I'll appreciate if you handle this submission before stable/15. Please address the IFCAP_HWSTATS, too. Thanks!