Currently, dp_packet_ol_send_prepare() performs multiple checks for each offloading flag separately. That takes a noticeable amount of extra cycles for packets that do not have any offloading flags set.
Skip most of the work if no checksumming flags are set. The change improves performance of direct forwarding between two virtio-user ports (V2V) by ~2.5 % and offsets all the negative effects of TSO support introduced recently. It adds an extra check to the offloading path, but it is not a default configuration and also should take much smaller hit due to lower number of larger packets. Signed-off-by: Ilya Maximets <i.maxim...@ovn.org> --- Would be great to have performance numbers confirmed independently on this one. Better if with some physical ports as well. I didn't list 'Fixes' tags since it's a little bit of a boiled frog situation. But I think this should be backported to branch-3.3 at least. lib/dp-packet.c | 5 +++++ lib/dp-packet.h | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/lib/dp-packet.c b/lib/dp-packet.c index 9635cac8b..0e23c766e 100644 --- a/lib/dp-packet.c +++ b/lib/dp-packet.c @@ -576,6 +576,11 @@ dp_packet_ol_send_prepare(struct dp_packet *p, uint64_t flags) { bool tnl_inner = false; + if (!dp_packet_hwol_tx_is_any_csum(p)) { + /* Only checksumming needs actions. */ + return; + } + if (dp_packet_hwol_is_tunnel_geneve(p) || dp_packet_hwol_is_tunnel_vxlan(p)) { tnl_inner = true; diff --git a/lib/dp-packet.h b/lib/dp-packet.h index 52e52b914..939bec5c8 100644 --- a/lib/dp-packet.h +++ b/lib/dp-packet.h @@ -131,6 +131,10 @@ enum dp_packet_offload_mask { #define DP_PACKET_OL_TX_L4_MASK (DP_PACKET_OL_TX_TCP_CKSUM | \ DP_PACKET_OL_TX_UDP_CKSUM | \ DP_PACKET_OL_TX_SCTP_CKSUM) +#define DP_PACKET_OL_TX_ANY_CKSUM (DP_PACKET_OL_TX_L4_MASK | \ + DP_PACKET_OL_TX_IP_CKSUM | \ + DP_PACKET_OL_TX_OUTER_IP_CKSUM | \ + DP_PACKET_OL_TX_OUTER_UDP_CKSUM) #define DP_PACKET_OL_RX_IP_CKSUM_MASK (DP_PACKET_OL_RX_IP_CKSUM_GOOD | \ DP_PACKET_OL_RX_IP_CKSUM_BAD) #define DP_PACKET_OL_RX_L4_CKSUM_MASK (DP_PACKET_OL_RX_L4_CKSUM_GOOD | \ @@ -1189,6 +1193,13 @@ dp_packet_hwol_is_outer_udp_cksum(struct dp_packet *b) return !!(*dp_packet_ol_flags_ptr(b) & DP_PACKET_OL_TX_OUTER_UDP_CKSUM); } +/* Returns 'true' if packet 'b' is marked for any checksum offload. */ +static inline bool +dp_packet_hwol_tx_is_any_csum(struct dp_packet *b) +{ + return !!(*dp_packet_ol_flags_ptr(b) & DP_PACKET_OL_TX_ANY_CKSUM); +} + static inline void dp_packet_hwol_reset_tx_l4_csum(struct dp_packet *p) { -- 2.43.0 _______________________________________________ dev mailing list d...@openvswitch.org https://mail.openvswitch.org/mailman/listinfo/ovs-dev