Page MenuHomeFreeBSD

Support IFCOUNTER_OBYTES and IFCOUNTER_OMCASTS even with VTNET_LEGACY_TX defined
AcceptedPublic

Authored by joyul_juniper.net on Apr 16 2024, 8:42 PM.
Tags
None
Referenced Files
Unknown Object (File)
May 5 2024, 12:22 AM
Unknown Object (File)
Apr 27 2024, 9:18 PM
Unknown Object (File)
Apr 26 2024, 5:15 AM
Unknown Object (File)
Apr 20 2024, 5:12 PM
Subscribers

Details

Reviewers
glebius
zlei
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

Lint
Lint Skipped
Unit
Tests Skipped

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