Skip to content

Commit

Permalink
dp-packet: Avoid checks while preparing non-offloading packets.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
igsilya committed Jan 19, 2024
1 parent 335a5de commit bacd2c3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/dp-packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
11 changes: 11 additions & 0 deletions lib/dp-packet.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 | \
Expand Down Expand Up @@ -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)
{
Expand Down

0 comments on commit bacd2c3

Please sign in to comment.