From: Boleslav Stankevich <Boleslav.Stankevich@oktetlabs.ru>
To: Maxime Coquelin <maxime.coquelin@redhat.com>, dev@dpdk.org
Cc: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>,
Chenbo Xia <chenbo.xia@intel.com>
Subject: Re: [PATCH] net/virtio: deduce IP length for Virtio TSO checksum
Date: Fri, 3 Mar 2023 14:17:41 +0300 [thread overview]
Message-ID: <e216d1be-cdf0-f69e-5426-6dd928a1e775@oktetlabs.ru> (raw)
In-Reply-To: <7c0037ad-91b8-4413-8d3a-f0191161c0e1@redhat.com>
Hi, Maxime!
Yes, it is a fix and will add missing tags in v2.
Thanks,
Boleslav
On 02/03/2023 13:25, Maxime Coquelin wrote:
> Hi Boleslav,
>
> On 2/16/23 13:35, Boleslav Stankevich wrote:
>> The length of TSO payload could not fit into 16 bits provided by the
>> IPv4 total length and IPv6 payload length fields. Thus, deduce it
>> from the length of the packet.
>
> My understanding is this is a fix.
> If so could you please add the Fixes tag and Cc: stable@dpdk.org?
>
> Thanks,
> Maxime
>
>> Signed-off-by: Boleslav Stankevich <boleslav.stankevich@oktetlabs.ru>
>> Reviewed-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
>> ---
>> drivers/net/virtio/virtio_rxtx.c | 25 ++++++++++++++++---------
>> 1 file changed, 16 insertions(+), 9 deletions(-)
>>
>> diff --git a/drivers/net/virtio/virtio_rxtx.c
>> b/drivers/net/virtio/virtio_rxtx.c
>> index 2d0afd3302..e48ff3cca7 100644
>> --- a/drivers/net/virtio/virtio_rxtx.c
>> +++ b/drivers/net/virtio/virtio_rxtx.c
>> @@ -404,29 +404,36 @@ virtio_tso_fix_cksum(struct rte_mbuf *m)
>> if (likely(rte_pktmbuf_data_len(m) >= m->l2_len + m->l3_len +
>> m->l4_len)) {
>> struct rte_ipv4_hdr *iph;
>> - struct rte_ipv6_hdr *ip6h;
>> struct rte_tcp_hdr *th;
>> - uint16_t prev_cksum, new_cksum, ip_len, ip_paylen;
>> + uint16_t prev_cksum, new_cksum;
>> + uint32_t ip_paylen;
>> uint32_t tmp;
>> iph = rte_pktmbuf_mtod_offset(m,
>> struct rte_ipv4_hdr *, m->l2_len);
>> th = RTE_PTR_ADD(iph, m->l3_len);
>> +
>> + /*
>> + * Calculate IPv4 header checksum with current total length
>> value
>> + * (whatever it is) to have correct checksum after update on
>> edits
>> + * done by TSO.
>> + */
>> if ((iph->version_ihl >> 4) == 4) {
>> iph->hdr_checksum = 0;
>> iph->hdr_checksum = rte_ipv4_cksum(iph);
>> - ip_len = iph->total_length;
>> - ip_paylen = rte_cpu_to_be_16(rte_be_to_cpu_16(ip_len) -
>> - m->l3_len);
>> - } else {
>> - ip6h = (struct rte_ipv6_hdr *)iph;
>> - ip_paylen = ip6h->payload_len;
>> }
>> + /*
>> + * Do not use IPv4 total length and IPv6 payload length
>> fields to get
>> + * TSO payload length since it could not fit into 16 bits.
>> + */
>> + ip_paylen = rte_cpu_to_be_32(rte_pktmbuf_pkt_len(m) -
>> m->l2_len -
>> + m->l3_len);
>> +
>> /* calculate the new phdr checksum not including ip_paylen */
>> prev_cksum = th->cksum;
>> tmp = prev_cksum;
>> - tmp += ip_paylen;
>> + tmp += (ip_paylen & 0xffff) + (ip_paylen >> 16);
>> tmp = (tmp & 0xffff) + (tmp >> 16);
>> new_cksum = tmp;
>
next prev parent reply other threads:[~2023-03-03 11:17 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-16 12:35 Boleslav Stankevich
2023-02-16 12:35 ` Boleslav Stankevich
2023-03-02 10:25 ` Maxime Coquelin
2023-03-03 11:17 ` Boleslav Stankevich [this message]
2023-03-03 11:19 ` [PATCH v2] " Boleslav Stankevich
2023-03-03 15:13 ` Andrew Rybchenko
2023-03-06 6:17 ` Xia, Chenbo
2023-03-06 10:57 ` Maxime Coquelin
2023-03-06 14:13 ` Maxime Coquelin
2023-03-06 14:20 ` Maxime Coquelin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e216d1be-cdf0-f69e-5426-6dd928a1e775@oktetlabs.ru \
--to=boleslav.stankevich@oktetlabs.ru \
--cc=andrew.rybchenko@oktetlabs.ru \
--cc=chenbo.xia@intel.com \
--cc=dev@dpdk.org \
--cc=maxime.coquelin@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).