From: "Michael S. Tsirkin" <mst@redhat.com>
To: Vladislav Yasevich <vyasevich@gmail.com>
Cc: virtio-dev@lists.oasis-open.org, marcelo.leitner@gmail.com,
nhorman@tuxdriver.com, netdev@vger.kernel.org,
virtualization@lists.linux-foundation.org,
linux-sctp@vger.kernel.org
Subject: Re: [PATCH V2 net-next 1/6] virtio: Add support for SCTP checksum offloading
Date: Wed, 2 May 2018 06:16:45 +0300 [thread overview]
Message-ID: <20180502061520-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20180502020739.19239-2-vyasevic@redhat.com>
On Tue, May 01, 2018 at 10:07:34PM -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 HOST feature bit signifies offloading support for transmit and
> enables device offload features.
> The GUEST feature bit signifies offloading support of recieve and
> is currently only used by the driver in case of xdp.
>
> That patch also adds an addition virtio_net header flag which
> mirrors the skb->csum_not_inet flag. This flags is used to indicate
> that is this an SCTP packet that needs its checksum computed by the
> lower layer. In this case, the lower layer is the host hypervisor or
> possibly HW nic that supporst CRC32c offload.
>
> In the case that GUEST feature bit is flag, it will be possible to
> receive a virtio_net header with this bit set, which will set the
> corresponding skb bit. SCTP protocol will be updated to correctly
> deal with it.
>
> Signed-off-by: Vladislav Yasevich <vyasevic@redhat.com>
> ---
> drivers/net/virtio_net.c | 14 +++++++++++++-
> include/linux/virtio_net.h | 6 ++++++
> include/uapi/linux/virtio_net.h | 5 +++++
> 3 files changed, 24 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index 7b187ec..34af280 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -2148,6 +2148,8 @@ static int virtnet_clear_guest_offloads(struct virtnet_info *vi)
>
> if (virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_CSUM))
> offloads = 1ULL << VIRTIO_NET_F_GUEST_CSUM;
> + if (virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_SCTP_CSUM))
> + offloads |= 1ULL << VIRTIO_NET_F_GUEST_SCTP_CSUM;
>
> return virtnet_set_guest_offloads(vi, offloads);
> }
> @@ -2160,6 +2162,8 @@ static int virtnet_restore_guest_offloads(struct virtnet_info *vi)
> return 0;
> if (virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_CSUM))
> offloads |= 1ULL << VIRTIO_NET_F_GUEST_CSUM;
> + if (virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_SCTP_CSUM))
> + offloads |= 1ULL << VIRTIO_NET_F_GUEST_SCTP_CSUM;
>
> return virtnet_set_guest_offloads(vi, offloads);
> }
> @@ -2724,6 +2728,7 @@ 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;
> if (csum)
> dev->features |= NETIF_F_HW_CSUM | NETIF_F_SG;
> @@ -2746,9 +2751,15 @@ static int virtnet_probe(struct virtio_device *vdev)
> dev->features |= dev->hw_features & NETIF_F_ALL_TSO;
> /* (!csum && gso) case will be fixed by register_netdev() */
> }
> +
> if (virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_CSUM))
> dev->features |= NETIF_F_RXCSUM;
>
> + if (virtio_has_feature(vdev, VIRTIO_NET_F_HOST_SCTP_CSUM)) {
> + dev->hw_features |= NETIF_F_SCTP_CRC;
> + dev->features |= NETIF_F_SCTP_CRC;
> + }
> +
> dev->vlan_features = dev->features;
>
> /* MTU range: 68 - 65535 */
> @@ -2962,7 +2973,8 @@ static struct virtio_device_id id_table[] = {
> VIRTIO_NET_F_GUEST_ANNOUNCE, VIRTIO_NET_F_MQ, \
> VIRTIO_NET_F_CTRL_MAC_ADDR, \
> VIRTIO_NET_F_MTU, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS, \
> - VIRTIO_NET_F_SPEED_DUPLEX
> + VIRTIO_NET_F_SPEED_DUPLEX, \
> + VIRTIO_NET_F_HOST_SCTP_CSUM, VIRTIO_NET_F_GUEST_SCTP_CSUM
>
> static unsigned int features[] = {
> VIRTNET_FEATURES,
> diff --git a/include/linux/virtio_net.h b/include/linux/virtio_net.h
> index f144216..28fffdc 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) {
> @@ -91,6 +94,9 @@ static inline int virtio_net_hdr_from_skb(const struct sk_buff *skb,
> skb_checksum_start_offset(skb));
> hdr->csum_offset = __cpu_to_virtio16(little_endian,
> skb->csum_offset);
> +
> + if (skb->csum_not_inet)
> + hdr->flags |= VIRTIO_NET_HDR_F_CSUM_NOT_INET;
> } else if (has_data_valid &&
> skb->ip_summed == CHECKSUM_UNNECESSARY) {
> hdr->flags = VIRTIO_NET_HDR_F_DATA_VALID;
> diff --git a/include/uapi/linux/virtio_net.h b/include/uapi/linux/virtio_net.h
> index 5de6ed3..9dfca1a 100644
> --- a/include/uapi/linux/virtio_net.h
> +++ b/include/uapi/linux/virtio_net.h
> @@ -57,6 +57,10 @@
> * Steering */
> #define VIRTIO_NET_F_CTRL_MAC_ADDR 23 /* Set MAC address */
>
> +#define VIRTIO_NET_F_GUEST_SCTP_CSUM 61 /* Guest handles SCTP pks w/ partial
> + * csum */
> +#define VIRTIO_NET_F_HOST_SCTP_CSUM 62 /* HOST handles SCTP pkts w/ partial
> + * csum */
> #define VIRTIO_NET_F_SPEED_DUPLEX 63 /* Device set linkspeed and duplex */
>
> #ifndef VIRTIO_NET_NO_LEGACY
> @@ -101,6 +105,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 */
Both comment and name are not very informative.
How about just saying CRC32c ?
> __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-05-02 3:16 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-02 2:07 [PATCH V2 net-next 0/6] virtio-net: Add SCTP checksum offload support Vladislav Yasevich
2018-05-02 2:07 ` [PATCH V2 net-next 1/6] virtio: Add support for SCTP checksum offloading Vladislav Yasevich
2018-05-02 3:16 ` Michael S. Tsirkin [this message]
2018-05-02 14:14 ` Marcelo Ricardo Leitner
2018-05-02 14:21 ` Michael S. Tsirkin
2018-05-02 14:34 ` Marcelo Ricardo Leitner
2018-05-02 2:07 ` [PATCH V2 net-next 2/6] sctp: Handle sctp packets with CHECKSUM_PARTIAL Vladislav Yasevich
2018-05-02 14:38 ` Marcelo Ricardo Leitner
2018-08-20 14:54 ` Marcelo Ricardo Leitner
2018-08-20 15:39 ` David Laight
2018-05-02 2:07 ` [PATCH V2 net-next 3/6] sctp: Build sctp offload support into the base kernel Vladislav Yasevich
2018-05-02 2:07 ` [PATCH V2 net-next 4/6] tun: Add support for SCTP checksum offload Vladislav Yasevich
2018-05-02 14:53 ` Marcelo Ricardo Leitner
2018-05-02 14:56 ` Marcelo Ricardo Leitner
2018-05-02 17:17 ` Vlad Yasevich
2018-05-02 2:07 ` [PATCH V2 net-next 5/6] macvlan/macvtap: " Vladislav Yasevich
2018-05-02 3:24 ` Michael S. Tsirkin
2018-05-02 13:27 ` Vlad Yasevich
2018-05-02 13:46 ` Michael S. Tsirkin
2018-05-02 14:00 ` Vlad Yasevich
2018-05-02 14:17 ` Michael S. Tsirkin
2018-05-02 14:25 ` Vlad Yasevich
2018-05-02 2:07 ` [PATCH V2 net-next 6/6] ipvlan: " Vladislav Yasevich
2018-05-02 8:12 ` Davide Caratti
2018-05-02 21:57 ` [PATCH V2 net-next 0/6] virtio-net: Add SCTP checksum offload support Marcelo Ricardo Leitner
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=20180502061520-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=linux-sctp@vger.kernel.org \
--cc=marcelo.leitner@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=nhorman@tuxdriver.com \
--cc=virtio-dev@lists.oasis-open.org \
--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).