Page MenuHomeFreeBSD

bridge: Add checksum offloading
AcceptedPublic

Authored by timo.voelker_fh-muenster.de on Thu, Jan 29, 8:40 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Feb 16, 2:49 AM
Unknown Object (File)
Tue, Feb 10, 6:19 AM
Unknown Object (File)
Sun, Feb 8, 11:40 PM
Unknown Object (File)
Sun, Feb 1, 11:53 AM
Unknown Object (File)
Fri, Jan 30, 4:46 PM
Unknown Object (File)
Fri, Jan 30, 8:09 AM
Unknown Object (File)
Fri, Jan 30, 4:25 AM
Unknown Object (File)
Fri, Jan 30, 3:15 AM

Details

Summary

Add transmission checksum offloading capabilities (IFCAP_TXCSUM, IFCAP_TXCSUM_IPV6, IFCAP_VLAN_HWCSUM) to the bridge and remove synchronization of IFCAP_TXCSUM and IFCAP_TXCSUM_IPV6 between member interfaces. For an outgoing packet with the checksum offloading flag set, the bridge now checks if the designated outgoing interface supports checksum offloading for the corresponding protocol. If not, it computes and inserts the checksum before passing the packet to the outgoing interface.

I see two use cases.

  1. If the bridge is the source interface, the network stack won't compute the checksum in software anymore and, thus, can make use of the checksum offloading capability of the physical outgoing interface.
  2. A virtual interface like epair can use checksum offloading more reliably. If the other epair end is in a bridge and the outgoing interface does not support checksum offloading for the chosen protocol, the bridge will take care of it.
Test Plan

If <IF> is your main network interface and <IP> the configured IP address on that interface. Add a bridge like this:

ifconfig bridge0 create
ifconfig <IF> inet <IP> -alias
ifconfig bridge0 addm <IF>
ifconfig bridge0 inet <IP>

The source interface of outgoing packet for the FreeBSD IP stack is now bridge0 (and not <IF> anymore).

Before this patch:
The FreeBSD IP stack stops using checksum offloading and computes checksums in software.

After this patch:
The FreeBSD IP stack keeps using checksum offloading.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

sys/net/if_bridge.c
2418

style.9: return (NULL);

2442

style.9: return (m);

2452

style.9: return (m);

2460

style.9: return (NULL);

2496

style.9: return (m);

2503

style.9: return (m);

2524

style.9: return (m);

Might be off-topic. I have ever had an idea, that introducing SOFT checksum offload to all soft interfaces. The upper stack will see this and hand over the calculating of the checksums to the interfaces. The soft interfaces may calculate the checksums when absolutely necessary, or let the edge physical interfaces do the stuff when the packets are leaving the host. Then we can benefits the hardware checksum, or we have better icache locality ( batch processing the mbufs ) when doing soft checksum.

What do you think ?

Might be off-topic. I have ever had an idea, that introducing SOFT checksum offload to all soft interfaces. The upper stack will see this and hand over the calculating of the checksums to the interfaces. The soft interfaces may calculate the checksums when absolutely necessary, or let the edge physical interfaces do the stuff when the packets are leaving the host. Then we can benefits the hardware checksum, or we have better icache locality ( batch processing the mbufs ) when doing soft checksum.

What do you think ?

Does this sound similar to https://wiki.freebsd.org/Networking/ChecksumOffloading ?

I do remember and thanks for the link! This is something that needs to be rebased and used for that.

Might be off-topic. I have ever had an idea, that introducing SOFT checksum offload to all soft interfaces. The upper stack will see this and hand over the calculating of the checksums to the interfaces. The soft interfaces may calculate the checksums when absolutely necessary, or let the edge physical interfaces do the stuff when the packets are leaving the host. Then we can benefits the hardware checksum, or we have better icache locality ( batch processing the mbufs ) when doing soft checksum.

What do you think ?

Does this sound similar to https://wiki.freebsd.org/Networking/ChecksumOffloading ?

Ah, I did not know the plan exists. Yes, my idea is almost the same with that.

Allow enabling/disabling the new capabilities: IFCAP_TXCSUM, IFCAP_TXCSUM_IPV6, and IFCAP_VLAN_HWCSUM.

Seems like progress to me. Would be good to get a pass from @ivy who did a lot in bridge lately. It would be a good idea to do present quick A/B test to make sure there are no unexpected perf issues. I don't think there is any reason to delay for GSO (unrelated) or a rework flippening offloads which can progress at its own pace.

sys/net/if_bridge.c
2420

something like this should eventually move to shared net code

This revision is now accepted and ready to land.Wed, Feb 18, 10:07 PM