app/testpmd: perform SW IP checksum for GRO packets
PATCH 1/1 app/testpmd: perform SW IP checksum for GRO packets
The GRO library doesn't re-calculate checksums for merged packets. If users want the merged packets to have correct IP checksums, they should select HW IP checksum calculation for the port which the merged packets are transmitted to. But if the port doesn't support HW IP checksum, users may perform a SW IP checksum. This patch add the code about it.
--- app/test-pmd/csumonly.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
app/test-pmd/csumonly.c +12 -0
@@ -824,6 +824,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)void **gro_ctx;uint16_t gro_pkts_num;uint8_t gro_enable; +struct rte_ipv4_hdr *ipv4_hdr;#endif uint16_t nb_rx;uint16_t nb_tx;
@@ -1098,6 +1099,17 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) fs->gro_times = 0; } } + +for (i =0 ; i < nb_rx; i++) { +if ((pkts_burst[i]->ol_flags &RTE_MBUF_F_TX_IPV4 ) && + (tx_offloads &RTE_ETH_TX_OFFLOAD_IPV4_CKSUM ) ==0 ) { + ipv4_hdr =rte_pktmbuf_mtod_offset (pkts_burst[i], + struct rte_ipv4_hdr *, + pkts_burst[i]->l2_len); + ipv4_hdr->hdr_checksum =0 ; + ipv4_hdr->hdr_checksum =rte_ipv4_cksum (ipv4_hdr); + } + } }#endif
Signature · 1 line
2.25.1
Quoted 8 lines · Wenwu Ma
The GRO library doesn't re-calculate checksums for merged packets. If users want the merged packets to have correct IP checksums, they should select HW IP checksum calculation for the port which the merged packets are transmitted to. But if the port doesn't support HW IP checksum, users may perform a SW IP checksum. This patch add the code about it.
It looks like a fix, please add a Fixes: line.
Out of curiosity, would there be an issue too when using the gso library?
Quoted 2 lines
Signed-off-by Wenwu Ma <[email protected]>
Signature · 1 line
David Marchand
Quoted 16 lines
-----Original Message-----
From: David Marchand <[email protected]>
Sent: 2022年5月11日 15:28
To: Ma, WenwuX <[email protected]>
Cc: Li, Xiaoyun <[email protected]>; Singh, Aman Deep <[email protected]>; Zhang, Yuying <[email protected]>; dev <[email protected]>; Hu, Jiayu <[email protected]>; Wang, Yinan <[email protected]>; He, Xingguang <[email protected]>
Subject: Re: [PATCH] app/testpmd: perform SW IP checksum for GRO packetsQuoted 1 line · Wenwu Ma
Quoted 8 lines
Quoted 6 lines
The GRO library doesn't re-calculate checksums for merged packets. If users want the merged packets to have correct IP checksums, they should select HW IP checksum calculation for the port which the merged packets are transmitted to. But if the port doesn't support HW IP checksum, users may perform a SW IP checksum. This patch add the code about it.
It looks like a fix, please add a Fixes: line.
ok
Quoted 2 lines
Out of curiosity, would there be an issue too when using the gso library?
yes, gso library has the same issue. IP checksum need to be re-calculated for fragmented packets
Quoted 6 lines
Quoted 2 lines
Signed-off-by Wenwu Ma <[email protected]>--
David Marchand
PATCH v2 1/1 app/testpmd: perform SW IP checksum for GRO/GSO packets
In reply to Wenwu MaThe GRO/GSO library doesn't re-calculate checksums for merged/fragmented packets. If users want the packets to have correct IP checksums, they should select HW IP checksum calculation for the port which the packets are transmitted to. But if the port doesn't support HW IP checksum, users may perform a SW IP checksum. This patch add the code about it.
--- app/test-pmd/csumonly.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
app/test-pmd/csumonly.c +24 -0
@@ -778,6 +778,26 @@ pkt_copy_split(const struct rte_mbuf *pkt)return md[0 ]; } +/* +* Re-calculate IP checksum for merged/fragmented packets. +*/ +static void +pkts_ip_csum_recalc (struct rte_mbuf **pkts_burst,const uint16_t nb_pkts,uint64_t tx_offloads) +{ +int i; +struct rte_ipv4_hdr *ipv4_hdr; +for (i =0 ; i < nb_pkts; i++) { +if ((pkts_burst[i]->ol_flags &RTE_MBUF_F_TX_IPV4 ) && + (tx_offloads &RTE_ETH_TX_OFFLOAD_IPV4_CKSUM ) ==0 ) { + ipv4_hdr =rte_pktmbuf_mtod_offset (pkts_burst[i], + struct rte_ipv4_hdr *, + pkts_burst[i]->l2_len); + ipv4_hdr->hdr_checksum =0 ; + ipv4_hdr->hdr_checksum =rte_ipv4_cksum (ipv4_hdr); + } + } +} +/* * Receive a burst of packets, and for each packet: * - parse packet, and try to recognize a supported packet type (1)
@@ -1098,6 +1118,8 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) fs->gro_times = 0; } } + +pkts_ip_csum_recalc (pkts_burst, nb_rx, tx_offloads); }#endif
@@ -1131,6 +1153,8 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) tx_pkts_burst = gso_segments; nb_rx = nb_segments; + +pkts_ip_csum_recalc (tx_pkts_burst, nb_rx, tx_offloads); } else#endif tx_pkts_burst = pkts_burst;
Signature · 1 line
2.25.1
PATCH v3 1/1 app/testpmd: perform SW IP checksum for GRO/GSO packets
In reply to Wenwu MaThe GRO/GSO library doesn't re-calculate checksums for merged/fragmented packets. If users want the packets to have correct IP checksums, they should select HW IP checksum calculation for the port which the packets are transmitted to. But if the port doesn't support HW IP checksum, users may perform a SW IP checksum. This patch add the code about it.
--- app/test-pmd/csumonly.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
app/test-pmd/csumonly.c +26 -0
@@ -778,6 +778,28 @@ pkt_copy_split(const struct rte_mbuf *pkt)return md[0 ]; } +#if defined(RTE_LIB_GRO ) || defined(RTE_LIB_GSO ) +/* +* Re-calculate IP checksum for merged/fragmented packets. +*/ +static void +pkts_ip_csum_recalc (struct rte_mbuf **pkts_burst,const uint16_t nb_pkts,uint64_t tx_offloads) +{ +int i; +struct rte_ipv4_hdr *ipv4_hdr; +for (i =0 ; i < nb_pkts; i++) { +if ((pkts_burst[i]->ol_flags &RTE_MBUF_F_TX_IPV4 ) && + (tx_offloads &RTE_ETH_TX_OFFLOAD_IPV4_CKSUM ) ==0 ) { + ipv4_hdr =rte_pktmbuf_mtod_offset (pkts_burst[i], + struct rte_ipv4_hdr *, + pkts_burst[i]->l2_len); + ipv4_hdr->hdr_checksum =0 ; + ipv4_hdr->hdr_checksum =rte_ipv4_cksum (ipv4_hdr); + } + } +} +#endif +/* * Receive a burst of packets, and for each packet: * - parse packet, and try to recognize a supported packet type (1)
@@ -1098,6 +1120,8 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) fs->gro_times = 0; } } + +pkts_ip_csum_recalc (pkts_burst, nb_rx, tx_offloads); }#endif
@@ -1131,6 +1155,8 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) tx_pkts_burst = gso_segments; nb_rx = nb_segments; + +pkts_ip_csum_recalc (tx_pkts_burst, nb_rx, tx_offloads); } else#endif tx_pkts_burst = pkts_burst;
Signature · 1 line
2.25.1
RE: [PATCH v3] app/testpmd: perform SW IP checksum for GRO/GSO packets
Quoted 82 lines
-----Original Message-----
From: Ma, WenwuX <[email protected]>
Sent: Thursday, May 12, 2022 9:08 AM
To: Li, Xiaoyun <[email protected]>; Singh, Aman Deep <[email protected]>; Zhang, Yuying <[email protected]>; [email protected]
Cc: Hu, Jiayu <[email protected]>; Wang, Yinan <[email protected]>; He, Xingguang <[email protected]>; Ma, WenwuX <[email protected]>; [email protected]
Subject: [PATCH v3] app/testpmd: perform SW IP checksum for GRO/GSO packetsThe GRO/GSO library doesn't re-calculate checksums for merged/fragmented packets. If users want the packets to have correct IP checksums, they should select HW IP checksum calculation for the port which the packets are transmitted to. But if the port doesn't support HW IP checksum, users may perform a SW IP checksum. This patch add the code about it.
Fixes b7091f1dcfbc ("app/testpmd: enable the heavyweight mode TCP/IPv4GRO")
Fixes 52f38a2055ed ("app/testpmd: enable TCP/IPv4 VxLAN and GRE GSO")Signed-off-by Wenwu Ma <[email protected]>--- app/test-pmd/csumonly.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)app/test-pmd/csumonly.c index renamed from app/test-pmd/csumonly.c +0
-0
8b6665d6f3..2498ee88a2100644app/test-pmd/csumonly.c +22
-0@@ -778,6 +778,28 @@ pkt_copy_split(const struct rte_mbuf *pkt)return md[0 ]; } +#if defined(RTE_LIB_GRO ) || defined(RTE_LIB_GSO ) +/* +* Re-calculate IP checksum for merged/fragmented packets. +*/ +static void +pkts_ip_csum_recalc (struct rte_mbuf **pkts_burst,const uint16_t +nb_pkts,uint64_t tx_offloads) { +int i; +struct rte_ipv4_hdr *ipv4_hdr; +for (i =0 ; i < nb_pkts; i++) { +if ((pkts_burst[i]->ol_flags &RTE_MBUF_F_TX_IPV4 ) && + (tx_offloads &RTE_ETH_TX_OFFLOAD_IPV4_CKSUM ) ==0 ) { + ipv4_hdr =rte_pktmbuf_mtod_offset (pkts_burst[i], + struct rte_ipv4_hdr *, + pkts_burst[i]->l2_len); + ipv4_hdr->hdr_checksum =0 ; + ipv4_hdr->hdr_checksum =rte_ipv4_cksum (ipv4_hdr); + } + } +} +#endif +/* * Receive a burst of packets, and for each packet:
* - parse packet, and try to recognize a supported packet type (1) @@ -
1098,6 +1120,8 @@pkt_burst_checksum_forward(struct fwd_stream *fs)app/test-pmd/csumonly.c +4
-0fs->gro_times = 0; } } + +pkts_ip_csum_recalc (pkts_burst, nb_rx, tx_offloads); }#endif @@ -1131,6 +1155,8 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) tx_pkts_burst = gso_segments; nb_rx = nb_segments; + +pkts_ip_csum_recalc (tx_pkts_burst, nb_rx, tx_offloads); } else#endif
Quoted 3 lines
tx_pkts_burst=pkts_burst;
--
2.25.1
Thanks,
Jiayu
RE: [PATCH v3] app/testpmd: perform SW IP checksum for GRO/GSO packets
In reply to Wenwu MaQuoted 19 lines
-----Original Message-----
From: Wenwu Ma <[email protected]>
Sent: Thursday, May 12, 2022 9:08 AM
To: Li, Xiaoyun <[email protected]>; Singh, Aman Deep <[email protected]>; Zhang, Yuying <[email protected]>; [email protected]
Cc: Hu, Jiayu <[email protected]>; Wang, Yinan <[email protected]>; He, Xingguang <[email protected]>; Ma, WenwuX <[email protected]>; [email protected]
Subject: [PATCH v3] app/testpmd: perform SW IP checksum for GRO/GSO packetsThe GRO/GSO library doesn't re-calculate checksums for merged/fragmented packets. If users want the packets to have correct IP checksums, they should select HW IP checksum calculation for the port which the packets are transmitted to. But if the port doesn't support HW IP checksum, users may perform a SW IP checksum. This patch add the code about it.
Quoted 7 lines
Fixes b7091f1dcfbc ("app/testpmd: enable the heavyweight mode TCP/IPv4GRO")
Fixes 52f38a2055ed ("app/testpmd: enable TCP/IPv4 VxLAN and GRE GSO")Signed-off-by Wenwu Ma <[email protected]>---
RE: [PATCH v3] app/testpmd: perform SW IP checksum for GRO/GSO packets
In reply to Wenwu MaHi Wenwu,
LGTM.
Quoted 18 lines
-----Original Message-----
From: Ma, WenwuX <[email protected]>
Sent: Thursday, May 12, 2022 9:08 AM
To: Li, Xiaoyun <[email protected]>; Singh, Aman Deep <[email protected]>; Zhang, Yuying <[email protected]>; [email protected]
Cc: Hu, Jiayu <[email protected]>; Wang, Yinan <[email protected]>; He, Xingguang <[email protected]>; Ma, WenwuX <[email protected]>; [email protected]
Subject: [PATCH v3] app/testpmd: perform SW IP checksum for GRO/GSO packetsThe GRO/GSO library doesn't re-calculate checksums for merged/fragmented packets. If users want the packets to have correct IP checksums, they should select HW IP checksum calculation for the port which the packets are transmitted to. But if the port doesn't support HW IP checksum, users may perform a SW IP checksum. This patch add the code about it.
Quoted 6 lines
Fixes b7091f1dcfbc ("app/testpmd: enable the heavyweight mode TCP/IPv4GRO")
Fixes 52f38a2055ed ("app/testpmd: enable TCP/IPv4 VxLAN and GRE GSO")Signed-off-by Wenwu Ma <[email protected]>
Quoted 60 lines
--- app/test-pmd/csumonly.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)app/test-pmd/csumonly.c index renamed from app/test-pmd/csumonly.c +0
-0
8b6665d6f3..2498ee88a2100644app/test-pmd/csumonly.c +22
-0@@ -778,6 +778,28 @@ pkt_copy_split(const struct rte_mbuf *pkt)return md[0 ]; } +#if defined(RTE_LIB_GRO ) || defined(RTE_LIB_GSO ) +/* +* Re-calculate IP checksum for merged/fragmented packets. +*/ +static void +pkts_ip_csum_recalc (struct rte_mbuf **pkts_burst,const uint16_t +nb_pkts,uint64_t tx_offloads) { +int i; +struct rte_ipv4_hdr *ipv4_hdr; +for (i =0 ; i < nb_pkts; i++) { +if ((pkts_burst[i]->ol_flags &RTE_MBUF_F_TX_IPV4 ) && + (tx_offloads &RTE_ETH_TX_OFFLOAD_IPV4_CKSUM ) ==0 ) { + ipv4_hdr =rte_pktmbuf_mtod_offset (pkts_burst[i], + struct rte_ipv4_hdr *, + pkts_burst[i]->l2_len); + ipv4_hdr->hdr_checksum =0 ; + ipv4_hdr->hdr_checksum =rte_ipv4_cksum (ipv4_hdr); + } + } +} +#endif +/* * Receive a burst of packets, and for each packet:
* - parse packet, and try to recognize a supported packet type (1) @@ -
1098,6 +1120,8 @@pkt_burst_checksum_forward(struct fwd_stream *fs)app/test-pmd/csumonly.c +4
-0fs->gro_times = 0; } } + +pkts_ip_csum_recalc (pkts_burst, nb_rx, tx_offloads); }#endif @@ -1131,6 +1155,8 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) tx_pkts_burst = gso_segments; nb_rx = nb_segments; + +pkts_ip_csum_recalc (tx_pkts_burst, nb_rx, tx_offloads); } else#endif
tx_pkts_burst=pkts_burst;
--
2.25.1
Andrew Rybchenko
AppliedRe: [PATCH v3] app/testpmd: perform SW IP checksum for GRO/GSO packets
Quoted 21 lines · Yuying
Hi Wenwu,
LGTM.Quoted 18 lines
-----Original Message-----
From: Ma, WenwuX <[email protected]>
Sent: Thursday, May 12, 2022 9:08 AM
To: Li, Xiaoyun <[email protected]>; Singh, Aman Deep <[email protected]>; Zhang, Yuying <[email protected]>; [email protected]
Cc: Hu, Jiayu <[email protected]>; Wang, Yinan <[email protected]>; He, Xingguang <[email protected]>; Ma, WenwuX <[email protected]>; [email protected]
Subject: [PATCH v3] app/testpmd: perform SW IP checksum for GRO/GSO packetsThe GRO/GSO library doesn't re-calculate checksums for merged/fragmented packets. If users want the packets to have correct IP checksums, they should select HW IP checksum calculation for the port which the packets are transmitted to. But if the port doesn't support HW IP checksum, users may perform a SW IP checksum. This patch add the code about it.
Quoted 8 lines
Quoted 6 lines
Fixes b7091f1dcfbc ("app/testpmd: enable the heavyweight mode TCP/IPv4GRO")
Fixes 52f38a2055ed ("app/testpmd: enable TCP/IPv4 VxLAN and GRE GSO")Signed-off-by Wenwu Ma <[email protected]>Acked-by Yuying Zhang <[email protected]>
Since CI is happy with the patch now [1].
[1] https://lab.dpdk.org/results/dashboard/patchsets/22087/
Applied, thanks.