2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-22 09:58:01 +00:00

dp-packet: Avoid checks while preparing non-offloading packets.

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.

Acked-by: Mike Pattrick <mkp@redhat.com>
Acked-by: Simon Horman <horms@ovn.org>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
This commit is contained in:
Ilya Maximets 2024-01-18 17:38:19 +01:00
parent 335a5deac3
commit bacd2c304a
2 changed files with 16 additions and 0 deletions

View File

@ -576,6 +576,11 @@ dp_packet_ol_send_prepare(struct dp_packet *p, uint64_t flags)
{ {
bool tnl_inner = false; 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) || if (dp_packet_hwol_is_tunnel_geneve(p) ||
dp_packet_hwol_is_tunnel_vxlan(p)) { dp_packet_hwol_is_tunnel_vxlan(p)) {
tnl_inner = true; tnl_inner = true;

View File

@ -131,6 +131,10 @@ enum dp_packet_offload_mask {
#define DP_PACKET_OL_TX_L4_MASK (DP_PACKET_OL_TX_TCP_CKSUM | \ #define DP_PACKET_OL_TX_L4_MASK (DP_PACKET_OL_TX_TCP_CKSUM | \
DP_PACKET_OL_TX_UDP_CKSUM | \ DP_PACKET_OL_TX_UDP_CKSUM | \
DP_PACKET_OL_TX_SCTP_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 | \ #define DP_PACKET_OL_RX_IP_CKSUM_MASK (DP_PACKET_OL_RX_IP_CKSUM_GOOD | \
DP_PACKET_OL_RX_IP_CKSUM_BAD) DP_PACKET_OL_RX_IP_CKSUM_BAD)
#define DP_PACKET_OL_RX_L4_CKSUM_MASK (DP_PACKET_OL_RX_L4_CKSUM_GOOD | \ #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); 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 static inline void
dp_packet_hwol_reset_tx_l4_csum(struct dp_packet *p) dp_packet_hwol_reset_tx_l4_csum(struct dp_packet *p)
{ {