DPDK patches and discussions
 help / color / mirror / Atom feed
From: David Marchand <david.marchand@redhat.com>
To: Harold Huang <baymaxhuang@gmail.com>,
	Olivier Matz <olivier.matz@6wind.com>
Cc: dev <dev@dpdk.org>, Maxime Coquelin <maxime.coquelin@redhat.com>,
	 Chenbo Xia <chenbo.xia@intel.com>
Subject: Re: [PATCH] net/virtio: include ipv4 cksum to support cksum offload capability
Date: Tue, 15 Feb 2022 21:08:43 +0100	[thread overview]
Message-ID: <CAJFAV8wqKidAWO9V1pZFPDsy0LQ_DEVzLpnknb7o_ajpY9wJFg@mail.gmail.com> (raw)
In-Reply-To: <20220107115312.280036-1-baymaxhuang@gmail.com>

Adding Olivier who, iirc, worked on those offloads a long time ago.

On Fri, Jan 7, 2022 at 12:54 PM Harold Huang <baymaxhuang@gmail.com> wrote:
>
> Device cksum offload capability usually include ipv4 cksum, tcp and udp
> cksum offload capability. The application such as OVS usually negotiate
> with the drive like this to enable cksum offload.

OVS checksum offloading is still being worked on.
By this, I mean neither that it is fully functional nor completely broken.
But important to keep in mind that it is still a work in progress.


>
> Signed-off-by: Harold Huang <baymaxhuang@gmail.com>
> ---
>  drivers/net/virtio/virtio_ethdev.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
> index c2588369b2..65b03bf0e4 100644
> --- a/drivers/net/virtio/virtio_ethdev.c
> +++ b/drivers/net/virtio/virtio_ethdev.c
> @@ -3041,6 +3041,7 @@ virtio_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
>                 dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_SCATTER;
>         if (host_features & (1ULL << VIRTIO_NET_F_GUEST_CSUM)) {
>                 dev_info->rx_offload_capa |=
> +                       RTE_ETH_RX_OFFLOAD_IPV4_CKSUM |
>                         RTE_ETH_RX_OFFLOAD_TCP_CKSUM |
>                         RTE_ETH_RX_OFFLOAD_UDP_CKSUM;
>         }

Adding this capability alone probably has no effect visible to a dpdk
application.

For L3, virtio rx handlers never sets anything but
RTE_MBUF_F_RX_IP_CKSUM_UNKNOWN.
https://git.dpdk.org/dpdk/tree/drivers/net/virtio/virtio_rxtx.c#n920

As a consequence, the application can't tell if the ip checksum is
correct and the application must validate the checksum of packets on
its own.
Maybe we could add some RTE_MBUF_F_RX_IP_CKSUM_GOOD in case of TCP/UDP (?)
https://git.dpdk.org/dpdk/tree/drivers/net/virtio/virtio_rxtx.c#n932


But simply reporting the capability looks wrong to me.


> @@ -3055,6 +3056,7 @@ virtio_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
>                                     RTE_ETH_TX_OFFLOAD_VLAN_INSERT;
>         if (host_features & (1ULL << VIRTIO_NET_F_CSUM)) {
>                 dev_info->tx_offload_capa |=
> +                       RTE_ETH_TX_OFFLOAD_IPV4_CKSUM |
>                         RTE_ETH_TX_OFFLOAD_UDP_CKSUM |
>                         RTE_ETH_TX_OFFLOAD_TCP_CKSUM;
>         }

For the tx part, I am a bit unsure, but here is what I understand.


With such a capability, the application may think it can send the
packet with no checksum, neither ip, nor tcp.
The virtio specification writes that the driver must make sure the ip
checksum is correct if it wants to ask for L4 checksum.

"""
If the VIRTIO_NET_F_CSUM feature has been negotiated, the driver MAY
set the VIRTIO_NET_HDR_F_NEEDS_CSUM bit in flags, if so:

the driver MUST validate the packet checksum at offset csum_offset
from csum_start as well as all preceding offsets;
the driver MUST set the packet checksum stored in the buffer to the
TCP/UDP pseudo header;
the driver MUST set csum_start and csum_offset such that calculating a
ones’ complement checksum from csum_start up until the end of the
packet and storing the result at offset csum_offset from csum_start
will result in a fully checksummed packet;
"""

But, nothing in the virtio tx handlers deals with ip cheksum offloading.
https://git.dpdk.org/dpdk/tree/drivers/net/virtio/virtqueue.h#n664

So here too, I think it is wrong to report such a capability.


-- 
David Marchand


      parent reply	other threads:[~2022-02-15 20:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-07 11:53 Harold Huang
2022-01-31 10:03 ` Maxime Coquelin
2022-02-07  2:54   ` Harold Huang
2022-02-15 20:08 ` David Marchand [this message]

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=CAJFAV8wqKidAWO9V1pZFPDsy0LQ_DEVzLpnknb7o_ajpY9wJFg@mail.gmail.com \
    --to=david.marchand@redhat.com \
    --cc=baymaxhuang@gmail.com \
    --cc=chenbo.xia@intel.com \
    --cc=dev@dpdk.org \
    --cc=maxime.coquelin@redhat.com \
    --cc=olivier.matz@6wind.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).