From patchwork Fri Apr 14 00:25:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bobby Eshleman X-Patchwork-Id: 83151 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp36347vqo; Thu, 13 Apr 2023 17:35:49 -0700 (PDT) X-Google-Smtp-Source: AKy350aJFtXgicmMuLn/5Qhe+TVy66YM+d9uWVxzcOBR9q6eHSk6FUCrDp4Dpvz5XGFzDd0Pjgbp X-Received: by 2002:a17:902:e550:b0:1a2:8c7e:f31f with SMTP id n16-20020a170902e55000b001a28c7ef31fmr1065604plf.11.1681432549431; Thu, 13 Apr 2023 17:35:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681432549; cv=none; d=google.com; s=arc-20160816; b=G2nHhJbqPWTBQxpeecoDYFvpkcM3Liu1OMEiWWzwqk4t9xwq7CSLlETB/gyq+DEs2p +5zUM/z/CAkyDW2DhXLte7WI5VRiLQX/CF9OO2gGllFU0Vl0SqSv4gBLgHrs5nAwwpMr 2TnnSSvpuD0jr4h5Ehb+0TvchqMfbwHzTZtbWwavsX78FjKgtfGh4qUM/tkJuuqzNCVF 2u8unwpEq1UOcezNWPda4jqzB+DCjhBjEB/g4/p+KwTGs0EtgqR7K3S6m3R/vJEWHkLV Wu13+OrjmwG2f/9ebWi2b7FU0pOwqBWKW05MaFWCU8Xq1C0viO5DwG6aacgY07arDPcX wrKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=AeXK+YZDfGvT8N4veEQBLmfTPDbV8HnwPoAG/KMc8uk=; b=lrB0ITOhi+XknBLTpq2EvoP8ta7w2qpHpgBfwWtiA4t9YnUg8Oe0W88+pmI8r4augH KlBbTVOhuAYI9P/opuYS4zkbv6mX6P4epgUaphTNy9DabauMgkk8VXbx9FV6v6l2OZP5 0HLuvnWR8JZ6EzKynfLMo7CBtFg/DgWOFx/RFrBG3oCbEUMx9v5gBln0b4D/70mQM/AW HoXJ0jBeFe1BR6u+BGzbD1aQVuciGUptNkJKQHUrg2sTPEhj9c5xT9W69LP6Cnc8WE9u tt0Jmxiu0/3M1S4c0fOqCY+ELOkxkb3scXHf2zMQAYD9Up1Sk+E4HB3HsKn+aL6zzFT+ 19pQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=iD1ON+CS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jw19-20020a170903279300b001a66ed4f67fsi3056443plb.292.2023.04.13.17.35.36; Thu, 13 Apr 2023 17:35:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=iD1ON+CS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230115AbjDNA0q (ORCPT + 99 others); Thu, 13 Apr 2023 20:26:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230369AbjDNA0f (ORCPT ); Thu, 13 Apr 2023 20:26:35 -0400 Received: from mail-qt1-x82f.google.com (mail-qt1-x82f.google.com [IPv6:2607:f8b0:4864:20::82f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5FCA4449A for ; Thu, 13 Apr 2023 17:26:03 -0700 (PDT) Received: by mail-qt1-x82f.google.com with SMTP id w38so2901120qtc.11 for ; Thu, 13 Apr 2023 17:26:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1681431962; x=1684023962; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=AeXK+YZDfGvT8N4veEQBLmfTPDbV8HnwPoAG/KMc8uk=; b=iD1ON+CSjyn81I5bfynPry8dYmrIhVjqo5HWLzEzkZ6dnmyhVxXAdkm7p3eeiX66HB DQHd+o7rWvxU+9qUm4cUP0y6v1T+sv1KY7yh8CmIyiU/gMfZkAPvM9THGLaxmgdSxpBx z/mgaMHMGYu2o1foiw3CWeJVXMgTDnem4qea2bLHVZIFQTqTpoZJfjRNyu99oCHT/eMe A/6uOHJA5jvuIqcatCtZ7njmoRC8Hodyvc1dwULspIeiZWwFjyZhK/llGoHH/6GXSgCH oHUx90wAae9PmSbE9xsHGVMz+YUKEJOvdzjkfgaVIagvX5PD+1OHiWawzNstzWBST6uv 6vag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681431962; x=1684023962; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AeXK+YZDfGvT8N4veEQBLmfTPDbV8HnwPoAG/KMc8uk=; b=SQtof0T4um1I2+xrpkvDHfMKaUfTZNdzJOtg4MIbD41weBU0Zh7e0ZY9MoSmYI0n4O djaZWiQIVmJhSssYoNfVU375fGO2biP2n3AMpY4vmW5CXFuGDVjJkP4ztXg+FVWTv9Lo JNgg2S5tMLKginE0MmkZRBB48d5JJp4H6INwGXmhDU8UQ8lHhQjHyEBVuhd2A6dAMycb lsrl3DO/fM0LcBpg+hIm0o1L+hb1VCn2JAMNbCeANitL0Tf2HWGvAhsMmwZNAfTP4xnz b7ykli+EWRmWL+5YKlEuHOTFosDluZkwXzGlQ2SDVUWBsWxMam8zjfqEyz+pqP7mmVaf 8kwg== X-Gm-Message-State: AAQBX9cvReFR1jH7uAnQOK+K2gU02+UEU1LX6pCZUT2/S220uszolB+4 Bqgu4jb+2zUckn36M5WdYcta8A== X-Received: by 2002:a05:622a:154:b0:3c0:3b79:9fb0 with SMTP id v20-20020a05622a015400b003c03b799fb0mr6558318qtw.47.1681431962311; Thu, 13 Apr 2023 17:26:02 -0700 (PDT) Received: from [172.17.0.3] ([130.44.215.122]) by smtp.gmail.com with ESMTPSA id a1-20020ac844a1000000b003eabcc29132sm309928qto.29.2023.04.13.17.26.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Apr 2023 17:26:02 -0700 (PDT) From: Bobby Eshleman Date: Fri, 14 Apr 2023 00:25:58 +0000 Subject: [PATCH RFC net-next v2 2/4] virtio/vsock: add VIRTIO_VSOCK_F_DGRAM feature bit MIME-Version: 1.0 Message-Id: <20230413-b4-vsock-dgram-v2-2-079cc7cee62e@bytedance.com> References: <20230413-b4-vsock-dgram-v2-0-079cc7cee62e@bytedance.com> In-Reply-To: <20230413-b4-vsock-dgram-v2-0-079cc7cee62e@bytedance.com> To: Stefan Hajnoczi , Stefano Garzarella , "Michael S. Tsirkin" , Jason Wang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Bryan Tan , Vishnu Dasa , VMware PV-Drivers Reviewers Cc: kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hyperv@vger.kernel.org, Bobby Eshleman , Jiang Wang X-Mailer: b4 0.12.2 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763109817220620913?= X-GMAIL-MSGID: =?utf-8?q?1763109817220620913?= This commit adds a feature bit for virtio vsock to support datagrams. This commit should not be applied without first applying the commit that implements datagrams for virtio. Signed-off-by: Jiang Wang Signed-off-by: Bobby Eshleman --- drivers/vhost/vsock.c | 3 ++- include/uapi/linux/virtio_vsock.h | 1 + net/vmw_vsock/virtio_transport.c | 8 ++++++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/vhost/vsock.c b/drivers/vhost/vsock.c index dff6ee1c479b..028cf079225e 100644 --- a/drivers/vhost/vsock.c +++ b/drivers/vhost/vsock.c @@ -32,7 +32,8 @@ enum { VHOST_VSOCK_FEATURES = VHOST_FEATURES | (1ULL << VIRTIO_F_ACCESS_PLATFORM) | - (1ULL << VIRTIO_VSOCK_F_SEQPACKET) + (1ULL << VIRTIO_VSOCK_F_SEQPACKET) | + (1ULL << VIRTIO_VSOCK_F_DGRAM) }; enum { diff --git a/include/uapi/linux/virtio_vsock.h b/include/uapi/linux/virtio_vsock.h index 331be28b1d30..0975b9c88292 100644 --- a/include/uapi/linux/virtio_vsock.h +++ b/include/uapi/linux/virtio_vsock.h @@ -40,6 +40,7 @@ /* The feature bitmap for virtio vsock */ #define VIRTIO_VSOCK_F_SEQPACKET 1 /* SOCK_SEQPACKET supported */ +#define VIRTIO_VSOCK_F_DGRAM 2 /* Host support dgram vsock */ struct virtio_vsock_config { __le64 guest_cid; diff --git a/net/vmw_vsock/virtio_transport.c b/net/vmw_vsock/virtio_transport.c index 582c6c0f788f..bb43eea9a6f9 100644 --- a/net/vmw_vsock/virtio_transport.c +++ b/net/vmw_vsock/virtio_transport.c @@ -29,6 +29,7 @@ static struct virtio_transport virtio_transport; /* forward declaration */ struct virtio_vsock { struct virtio_device *vdev; struct virtqueue *vqs[VSOCK_VQ_MAX]; + bool has_dgram; /* Virtqueue processing is deferred to a workqueue */ struct work_struct tx_work; @@ -640,7 +641,6 @@ static int virtio_vsock_probe(struct virtio_device *vdev) } vsock->vdev = vdev; - vsock->rx_buf_nr = 0; vsock->rx_buf_max_nr = 0; atomic_set(&vsock->queued_replies, 0); @@ -657,6 +657,9 @@ static int virtio_vsock_probe(struct virtio_device *vdev) if (virtio_has_feature(vdev, VIRTIO_VSOCK_F_SEQPACKET)) vsock->seqpacket_allow = true; + if (virtio_has_feature(vdev, VIRTIO_VSOCK_F_DGRAM)) + vsock->has_dgram = true; + vdev->priv = vsock; ret = virtio_vsock_vqs_init(vsock); @@ -749,7 +752,8 @@ static struct virtio_device_id id_table[] = { }; static unsigned int features[] = { - VIRTIO_VSOCK_F_SEQPACKET + VIRTIO_VSOCK_F_SEQPACKET, + VIRTIO_VSOCK_F_DGRAM }; static struct virtio_driver virtio_vsock_driver = {