From: Vlad Yasevich <vyasevic@redhat.com>
To: "Michael S. Tsirkin" <mst@redhat.com>,
Vladislav Yasevich <vyasevich@gmail.com>
Cc: netdev@vger.kernel.org, linux-sctp@vger.kernel.org,
virtualization@lists.linux-foundation.org, jasowang@redhat.com,
nhorman@tuxdriver.com
Subject: Re: [PATCH net-next 1/5] virtio: Add support for SCTP checksum offloading
Date: Mon, 16 Apr 2018 09:45:48 -0400 [thread overview]
Message-ID: <f5655ab8-f24f-a5a5-d000-2bbb90ecc552@redhat.com> (raw)
In-Reply-To: <20180412014548-mutt-send-email-mst@kernel.org>
On 04/11/2018 06:49 PM, Michael S. Tsirkin wrote:
> On Mon, Apr 02, 2018 at 09:40:02AM -0400, Vladislav Yasevich wrote:
>> To support SCTP checksum offloading, we need to add a new feature
>> to virtio_net, so we can negotiate support between the hypervisor
>> and the guest.
>>
>> The signalling to the guest that an alternate checksum needs to
>> be used is done via a new flag in the virtio_net_hdr. If the
>> flag is set, the host will know to perform an alternate checksum
>> calculation, which right now is only CRC32c.
>>
>> Signed-off-by: Vladislav Yasevich <vyasevic@redhat.com>
>> ---
>> drivers/net/virtio_net.c | 11 ++++++++---
>> include/linux/virtio_net.h | 6 ++++++
>> include/uapi/linux/virtio_net.h | 2 ++
>> 3 files changed, 16 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
>> index 7b187ec..b601294 100644
>> --- a/drivers/net/virtio_net.c
>> +++ b/drivers/net/virtio_net.c
>> @@ -2724,9 +2724,14 @@ static int virtnet_probe(struct virtio_device *vdev)
>> /* Do we support "hardware" checksums? */
>> if (virtio_has_feature(vdev, VIRTIO_NET_F_CSUM)) {
>> /* This opens up the world of extra features. */
>> - dev->hw_features |= NETIF_F_HW_CSUM | NETIF_F_SG;
>> + netdev_features_t sctp = 0;
>> +
>> + if (virtio_has_feature(vdev, VIRTIO_NET_F_SCTP_CSUM))
>> + sctp |= NETIF_F_SCTP_CRC;
>> +
>> + dev->hw_features |= NETIF_F_HW_CSUM | NETIF_F_SG | sctp;
>> if (csum)
>> - dev->features |= NETIF_F_HW_CSUM | NETIF_F_SG;
>> + dev->features |= NETIF_F_HW_CSUM | NETIF_F_SG | sctp;
>>
>> if (virtio_has_feature(vdev, VIRTIO_NET_F_GSO)) {
>> dev->hw_features |= NETIF_F_TSO
>> @@ -2952,7 +2957,7 @@ static struct virtio_device_id id_table[] = {
>> };
>>
>> #define VIRTNET_FEATURES \
>> - VIRTIO_NET_F_CSUM, VIRTIO_NET_F_GUEST_CSUM, \
>> + VIRTIO_NET_F_CSUM, VIRTIO_NET_F_GUEST_CSUM, VIRTIO_NET_F_SCTP_CSUM, \
>> VIRTIO_NET_F_MAC, \
>> VIRTIO_NET_F_HOST_TSO4, VIRTIO_NET_F_HOST_UFO, VIRTIO_NET_F_HOST_TSO6, \
>> VIRTIO_NET_F_HOST_ECN, VIRTIO_NET_F_GUEST_TSO4, VIRTIO_NET_F_GUEST_TSO6, \
>> diff --git a/include/linux/virtio_net.h b/include/linux/virtio_net.h
>> index f144216..2e7a64a 100644
>> --- a/include/linux/virtio_net.h
>> +++ b/include/linux/virtio_net.h
>> @@ -39,6 +39,9 @@ static inline int virtio_net_hdr_to_skb(struct sk_buff *skb,
>>
>> if (!skb_partial_csum_set(skb, start, off))
>> return -EINVAL;
>> +
>> + if (hdr->flags & VIRTIO_NET_HDR_F_CSUM_NOT_INET)
>> + skb->csum_not_inet = 1;
>> }
>>
>> if (hdr->gso_type != VIRTIO_NET_HDR_GSO_NONE) {
>> @@ -96,6 +99,9 @@ static inline int virtio_net_hdr_from_skb(const struct sk_buff *skb,
>> hdr->flags = VIRTIO_NET_HDR_F_DATA_VALID;
>> } /* else everything is zero */
>>
>> + if (skb->csum_not_inet)
>> + hdr->flags &= VIRTIO_NET_HDR_F_CSUM_NOT_INET;
>> +
>> return 0;
>> }
>>
>> diff --git a/include/uapi/linux/virtio_net.h b/include/uapi/linux/virtio_net.h
>> index 5de6ed3..3f279c8 100644
>> --- a/include/uapi/linux/virtio_net.h
>> +++ b/include/uapi/linux/virtio_net.h
>> @@ -36,6 +36,7 @@
>> #define VIRTIO_NET_F_GUEST_CSUM 1 /* Guest handles pkts w/ partial csum */
>> #define VIRTIO_NET_F_CTRL_GUEST_OFFLOADS 2 /* Dynamic offload configuration. */
>> #define VIRTIO_NET_F_MTU 3 /* Initial MTU advice */
>> +#define VIRTIO_NET_F_SCTP_CSUM 4 /* SCTP checksum offload support */
>> #define VIRTIO_NET_F_MAC 5 /* Host has given MAC address. */
>> #define VIRTIO_NET_F_GUEST_TSO4 7 /* Guest can handle TSOv4 in. */
>> #define VIRTIO_NET_F_GUEST_TSO6 8 /* Guest can handle TSOv6 in. */
>
> Is this a guest or a host checksum? We should differenciate between the
> two.
I suppose this is HOST checksum, since it behaves like VIRTIO_NET_F_CSUM only for
SCTP. I couldn't find the use for the GUEST side flag, since there technically
isn't any validations and there is no additional mappings from VIRTIO flag to a
NETIF flag.
If the feature is negotiated, the guest ends up generating partially check-summed
packets, and the host turns on appropriate flags on it's side. The host will
also make sure the checksum if fixed up if the guest doesn't support it.
So 1 flag is currently all that is needed.
-vlad
>
>
>> @@ -101,6 +102,7 @@ struct virtio_net_config {
>> struct virtio_net_hdr_v1 {
>> #define VIRTIO_NET_HDR_F_NEEDS_CSUM 1 /* Use csum_start, csum_offset */
>> #define VIRTIO_NET_HDR_F_DATA_VALID 2 /* Csum is valid */
>> +#define VIRTIO_NET_HDR_F_CSUM_NOT_INET 4 /* Checksum is not inet */
>> __u8 flags;
>> #define VIRTIO_NET_HDR_GSO_NONE 0 /* Not a GSO frame */
>> #define VIRTIO_NET_HDR_GSO_TCPV4 1 /* GSO frame, IPv4 TCP (TSO) */
>> --
>> 2.9.5
next prev parent reply other threads:[~2018-04-16 13:46 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-02 13:40 [PATCH net-next 0/5] virtio-net: Add SCTP checksum offload support Vladislav Yasevich
2018-04-02 13:40 ` [PATCH net-next 1/5] virtio: Add support for SCTP checksum offloading Vladislav Yasevich
2018-04-10 3:17 ` Jason Wang
2018-04-11 22:39 ` Marcelo Ricardo Leitner
2018-04-11 22:49 ` Michael S. Tsirkin
2018-04-16 13:45 ` Vlad Yasevich [this message]
2018-04-16 15:52 ` Michael S. Tsirkin
2018-04-16 17:09 ` Michael S. Tsirkin
2018-04-17 19:06 ` Vlad Yasevich
2018-04-16 17:07 ` Michael S. Tsirkin
2018-04-02 13:40 ` [PATCH net-next 2/5] sctp: Handle sctp packets with CHECKSUM_PARTIAL Vladislav Yasevich
2018-04-02 13:40 ` [PATCH net-next 3/5] sctp: Build sctp offload support into the base kernel Vladislav Yasevich
2018-04-02 13:40 ` [PATCH net-next 4/5] tun: Add support for SCTP checksum offload Vladislav Yasevich
2018-04-03 0:49 ` kbuild test robot
2018-04-16 17:12 ` Michael S. Tsirkin
2018-04-02 13:40 ` [PATCH net-next 5/5] macvlan/macvtap: " Vladislav Yasevich
2018-04-04 15:31 ` Davide Caratti
2018-04-16 17:14 ` Michael S. Tsirkin
2018-04-02 14:16 ` [PATCH net-next 0/5] virtio-net: Add SCTP checksum offload support David Miller
2018-04-02 14:47 ` Marcelo Ricardo Leitner
2018-04-17 20:35 ` Vlad Yasevich
2018-04-18 1:33 ` Marcelo Ricardo Leitner
2018-04-18 6:57 ` Xin Long
2018-04-18 14:06 ` Michael S. Tsirkin
2018-04-20 17:22 ` Marcelo Ricardo Leitner
2018-04-20 18:32 ` Michael S. Tsirkin
2018-04-23 13:17 ` Vlad Yasevich
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=f5655ab8-f24f-a5a5-d000-2bbb90ecc552@redhat.com \
--to=vyasevic@redhat.com \
--cc=jasowang@redhat.com \
--cc=linux-sctp@vger.kernel.org \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=nhorman@tuxdriver.com \
--cc=virtualization@lists.linux-foundation.org \
--cc=vyasevich@gmail.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).