Skip to content

Commit

Permalink
net/tap: fix L4 checksum offloading
Browse files Browse the repository at this point in the history
[ upstream commit 0bbafe48ae0a35e306b1cd91b0e7726ae4451f9a ]

The L4 checksum offloading API does not require l4_len to be set.
Make the driver discover the L4 headers size by itself.

Fixes: 6546e76 ("net/tap: calculate checksums of multi segs packets")

Signed-off-by: David Marchand <david.marchand@redhat.com>
Tested-by: Ales Musil <amusil@redhat.com>
Acked-by: Ferruh Yigit <ferruh.yigit@amd.com>
  • Loading branch information
david-marchand authored and kevintraynor committed Nov 16, 2023
1 parent c2404cb commit 8b094ad
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Aleksandr Miloshenko <a.miloshenko@f5.com>
Aleksey Baulin <aleksey.baulin@gmail.com>
Aleksey Katargin <gureedo@gmail.com>
Ales Musil <amusil@redhat.com>
Alexander Bechikov <asb.tyum@gmail.com>
Alexander Belyakov <abelyako@gmail.com>
Alexander Chernavin <achernavin@netgate.com>
Expand Down
13 changes: 11 additions & 2 deletions drivers/net/tap/rte_eth_tap.c
Original file line number Diff line number Diff line change
Expand Up @@ -631,13 +631,22 @@ tap_write_mbufs(struct tx_queue *txq, uint16_t num_mbufs,
((mbuf->ol_flags & (RTE_MBUF_F_TX_IP_CKSUM | RTE_MBUF_F_TX_IPV4) ||
(mbuf->ol_flags & RTE_MBUF_F_TX_L4_MASK) == RTE_MBUF_F_TX_UDP_CKSUM ||
(mbuf->ol_flags & RTE_MBUF_F_TX_L4_MASK) == RTE_MBUF_F_TX_TCP_CKSUM))) {
unsigned int l4_len = 0;

is_cksum = 1;

if ((mbuf->ol_flags & RTE_MBUF_F_TX_L4_MASK) ==
RTE_MBUF_F_TX_UDP_CKSUM)
l4_len = sizeof(struct rte_udp_hdr);
else if ((mbuf->ol_flags & RTE_MBUF_F_TX_L4_MASK) ==
RTE_MBUF_F_TX_TCP_CKSUM)
l4_len = sizeof(struct rte_tcp_hdr);

/* Support only packets with at least layer 4
* header included in the first segment
*/
seg_len = rte_pktmbuf_data_len(mbuf);
l234_hlen = mbuf->l2_len + mbuf->l3_len + mbuf->l4_len;
l234_hlen = mbuf->l2_len + mbuf->l3_len + l4_len;
if (seg_len < l234_hlen)
return -1;

Expand All @@ -647,7 +656,7 @@ tap_write_mbufs(struct tx_queue *txq, uint16_t num_mbufs,
rte_memcpy(m_copy, rte_pktmbuf_mtod(mbuf, void *),
l234_hlen);
tap_tx_l3_cksum(m_copy, mbuf->ol_flags,
mbuf->l2_len, mbuf->l3_len, mbuf->l4_len,
mbuf->l2_len, mbuf->l3_len, l4_len,
&l4_cksum, &l4_phdr_cksum,
&l4_raw_cksum);
iovecs[k].iov_base = m_copy;
Expand Down

0 comments on commit 8b094ad

Please sign in to comment.