From patchwork Mon Sep 28 03:39:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tonghao Zhang X-Patchwork-Id: 289511 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3C0DCC4727C for ; Mon, 28 Sep 2020 03:42:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 05AE420B80 for ; Mon, 28 Sep 2020 03:42:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DnEINd7v" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726558AbgI1Dl6 (ORCPT ); Sun, 27 Sep 2020 23:41:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726328AbgI1Dl6 (ORCPT ); Sun, 27 Sep 2020 23:41:58 -0400 Received: from mail-vs1-xe41.google.com (mail-vs1-xe41.google.com [IPv6:2607:f8b0:4864:20::e41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F499C0613CE for ; Sun, 27 Sep 2020 20:41:58 -0700 (PDT) Received: by mail-vs1-xe41.google.com with SMTP id z193so4997900vsz.10 for ; Sun, 27 Sep 2020 20:41:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=m9EtepEtVt3TGlrTSs3377Oy1G+hujBB1naLBHmKEMY=; b=DnEINd7vTZp2MLZJHSmRkhflGn+dhLAi3Stpt5pp2JgymWDTlLtnGvsGM7uelINWA3 Fj9EydJQSa7/r+BF03qQSU2i5Et/CiWDuLPSQNFk+tHaFXx0078GoJ6BZFIV884YDdqi Nmtj6gHk9GibPyJeTJ4veZZXTZ4xYO6oKce1ROLNRIuyijJeLBMZ748rzp6jX8pOuJWQ 2VkKx+Ug0cMPmOR3p96hWUZpdPL1H2coYSf0mNVP4+/izyBNzt13TFyfZLIZN5Psqmws ALncHlvaXJp7k7hDWeArk46isDQ6LJ3TOGxSVgzl1Mq/i0FinK+98pEltVYRHB9dev/D RxlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=m9EtepEtVt3TGlrTSs3377Oy1G+hujBB1naLBHmKEMY=; b=cRLVVgDuqpT4u+jO8kDSzMJ5MeTa9T7ATJMDvVF91Z5xB7uivj9LvoQspdOU/2A/xv XenBSyfKgnldMUW8HX/ZkirJ85mZBC3fjR2jPmDPLd8Op98FT+C4QSswD3Ph4wFVgUvE AoSeCyVbNKJFu7OrDTSs98eN60DhCbGKRbRVDYCcmP++O9hLtuZvjGwsXI0axfOrzUCD oe5obeUqWV9iOOxBnym1VXQ9IlzAvgG9PPOmqjdSF19b8UZHzlBLCQSfS+qjCvNcIOqy ihMi3ndOgXdEmTGGFKMYwIAcByV263/wAkntIBTN3vc8XDvQzGmhsmhHa62kKZM5ibh8 8ipw== X-Gm-Message-State: AOAM530sIe/QMGqGhWC0YW1IjvyxrGCB1CQDJNFtbz/Zeu6Ww5TvlDcV L/QskLhq1ZfZJJCcvXLZDSs= X-Google-Smtp-Source: ABdhPJyH04luJ1UTcCe5FefXF8GSyZT+ghdCCiFnxbXOZwhxxncbiFm+7K9a9+Db4daXaBfejL7Esw== X-Received: by 2002:a67:ea4e:: with SMTP id r14mr3944866vso.37.1601264517494; Sun, 27 Sep 2020 20:41:57 -0700 (PDT) Received: from localhost.localdomain ([50.236.19.102]) by smtp.gmail.com with ESMTPSA id e3sm1363499vsa.8.2020.09.27.20.41.51 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 27 Sep 2020 20:41:56 -0700 (PDT) From: xiangxia.m.yue@gmail.com To: jasowang@redhat.com, mst@redhat.com Cc: virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, Tonghao Zhang , Willem de Bruijn Subject: [PATCH 1/2] virtio-net: don't disable guest csum when disable LRO Date: Mon, 28 Sep 2020 11:39:14 +0800 Message-Id: <20200928033915.82810-1-xiangxia.m.yue@gmail.com> X-Mailer: git-send-email 2.15.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Tonghao Zhang Open vSwitch and Linux bridge will disable LRO of the interface when this interface added to them. Now when disable the LRO, the virtio-net csum is disable too. That drops the forwarding performance. Fixes: e59ff2c49ae1 ("virtio-net: disable guest csum during XDP set") Cc: Michael S. Tsirkin Cc: Jason Wang Cc: Willem de Bruijn Signed-off-by: Tonghao Zhang --- drivers/net/virtio_net.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 7145c83c6c8c..21b71148c532 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -63,6 +63,11 @@ static const unsigned long guest_offloads[] = { VIRTIO_NET_F_GUEST_CSUM }; +#define GUEST_OFFLOAD_LRO_MASK ((1ULL << VIRTIO_NET_F_GUEST_TSO4) | \ + (1ULL << VIRTIO_NET_F_GUEST_TSO6) | \ + (1ULL << VIRTIO_NET_F_GUEST_ECN) | \ + (1ULL << VIRTIO_NET_F_GUEST_UFO)) + struct virtnet_stat_desc { char desc[ETH_GSTRING_LEN]; size_t offset; @@ -2531,7 +2536,8 @@ static int virtnet_set_features(struct net_device *dev, if (features & NETIF_F_LRO) offloads = vi->guest_offloads_capable; else - offloads = 0; + offloads = vi->guest_offloads_capable & + ~GUEST_OFFLOAD_LRO_MASK; err = virtnet_set_guest_offloads(vi, offloads); if (err) From patchwork Mon Sep 28 03:39:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tonghao Zhang X-Patchwork-Id: 260050 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 24943C4727C for ; Mon, 28 Sep 2020 03:42:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E0E5220B80 for ; Mon, 28 Sep 2020 03:42:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="EM54iXaY" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726572AbgI1DmD (ORCPT ); Sun, 27 Sep 2020 23:42:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726328AbgI1DmC (ORCPT ); Sun, 27 Sep 2020 23:42:02 -0400 Received: from mail-ua1-x942.google.com (mail-ua1-x942.google.com [IPv6:2607:f8b0:4864:20::942]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B683C0613CE for ; Sun, 27 Sep 2020 20:42:02 -0700 (PDT) Received: by mail-ua1-x942.google.com with SMTP id o64so1711085uao.1 for ; Sun, 27 Sep 2020 20:42:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=5tf8R6j6ulK4E5b7bjR1T1ekmlta6QQ2PvHfvroeWjk=; b=EM54iXaY91q2HajRleaaczPoVQyPkZtt+3Gri/okZty+4lfRZAW3d1DE9IWUaD//L0 KS9SlffXVdNbk6k9iglE87hUakp9eIxohYsPYByuIpP4UobzGO+CN+5ZIJDOIwAcztuS GsHTyrnaWZf4w+/GJNgORSfMdELcFYFJUi4sPSbwPTwIJ1pGCMflFpHO2AWk9i+lW27G VxSDK8b/7yXJfMY8dqVEBdTXDaI/6fjFYgetywD825D1yjgq4eO+EjHqd8h58NvS9v2t udcmCAhZPAtzbvxBGDmw45S5ViIITYF3hR+OYQVbFZcI/OCsLWGUUby2EnXar/C4g9w4 BcmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=5tf8R6j6ulK4E5b7bjR1T1ekmlta6QQ2PvHfvroeWjk=; b=NrijqdG1F3/csIZTOdYx8a/zuBsRM3X1pFmaqbi+qf0dJV6EWUfth+1eLRQSEKC8+K 2thd/MEJgbigU8WsoZACoUb/FrGaBSaA5W8kpuqnN+CqtoPdcxoSEx8lme/IcMlJInm3 AxnbtUFJFkZhIzciAqfcySpwNAZUH1qYX78MMT/KTXRvYMuxx8In6Pf00dXOAcEaW68R VBmNk3vZxBtw7JJX9psQh9sJGil5DF4tbMx5UyIw1E/0EUCtNch1N21riabIltTCyxhh jbP9hOElhJkfEgEFnA9H0WW/x3cQwP8m3eU23BamA+XscVzcBblGUsiVnhf6uHS9Ob4s VaSg== X-Gm-Message-State: AOAM532Q57i3LkfbkGZwyi/dKrGmiRzmBSFlKuNWCkXRn8eyie/j6eP0 Bt20SB5v5/c1LaG+D4wt+Ek= X-Google-Smtp-Source: ABdhPJz4wgHxqorF8SymxYsgdMbcKMazO/YeVmbdARH513+nwqLFgXqj/M2+nsAmDOB16B58UweAiA== X-Received: by 2002:a9f:24d4:: with SMTP id 78mr4051625uar.47.1601264521635; Sun, 27 Sep 2020 20:42:01 -0700 (PDT) Received: from localhost.localdomain ([50.236.19.102]) by smtp.gmail.com with ESMTPSA id e3sm1363499vsa.8.2020.09.27.20.41.57 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 27 Sep 2020 20:42:01 -0700 (PDT) From: xiangxia.m.yue@gmail.com To: jasowang@redhat.com, mst@redhat.com Cc: virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, Tonghao Zhang Subject: [PATCH 2/2] virtio-net: ethtool configurable RXCSUM Date: Mon, 28 Sep 2020 11:39:15 +0800 Message-Id: <20200928033915.82810-2-xiangxia.m.yue@gmail.com> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20200928033915.82810-1-xiangxia.m.yue@gmail.com> References: <20200928033915.82810-1-xiangxia.m.yue@gmail.com> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Tonghao Zhang Allow user configuring RXCSUM separately with ethtool -K, reusing the existing virtnet_set_guest_offloads helper that configures RXCSUM for XDP. This is conditional on VIRTIO_NET_F_CTRL_GUEST_OFFLOADS. Cc: Michael S. Tsirkin Cc: Jason Wang Signed-off-by: Tonghao Zhang --- drivers/net/virtio_net.c | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 21b71148c532..2e3af0b2c281 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -68,6 +68,8 @@ static const unsigned long guest_offloads[] = { (1ULL << VIRTIO_NET_F_GUEST_ECN) | \ (1ULL << VIRTIO_NET_F_GUEST_UFO)) +#define GUEST_OFFLOAD_CSUM_MASK (1ULL << VIRTIO_NET_F_GUEST_CSUM) + struct virtnet_stat_desc { char desc[ETH_GSTRING_LEN]; size_t offset; @@ -2526,25 +2528,37 @@ static int virtnet_set_features(struct net_device *dev, netdev_features_t features) { struct virtnet_info *vi = netdev_priv(dev); - u64 offloads; + u64 offloads = vi->guest_offloads & + vi->guest_offloads_capable; int err; - if ((dev->features ^ features) & NETIF_F_LRO) { - if (vi->xdp_queue_pairs) - return -EBUSY; + /* Don't allow configuration while XDP is active. */ + if (vi->xdp_queue_pairs) + return -EBUSY; + if ((dev->features ^ features) & NETIF_F_LRO) { if (features & NETIF_F_LRO) - offloads = vi->guest_offloads_capable; + offloads |= GUEST_OFFLOAD_LRO_MASK; else - offloads = vi->guest_offloads_capable & - ~GUEST_OFFLOAD_LRO_MASK; + offloads &= ~GUEST_OFFLOAD_LRO_MASK; + } - err = virtnet_set_guest_offloads(vi, offloads); - if (err) - return err; - vi->guest_offloads = offloads; + if ((dev->features ^ features) & NETIF_F_RXCSUM) { + if (features & NETIF_F_RXCSUM) + offloads |= GUEST_OFFLOAD_CSUM_MASK; + else + offloads &= ~GUEST_OFFLOAD_CSUM_MASK; } + if (offloads == (vi->guest_offloads & + vi->guest_offloads_capable)) + return 0; + + err = virtnet_set_guest_offloads(vi, offloads); + if (err) + return err; + + vi->guest_offloads = offloads; return 0; } @@ -3013,8 +3027,10 @@ static int virtnet_probe(struct virtio_device *vdev) if (virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO4) || virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO6)) dev->features |= NETIF_F_LRO; - if (virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS)) + if (virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS)) { + dev->hw_features |= NETIF_F_RXCSUM; dev->hw_features |= NETIF_F_LRO; + } dev->vlan_features = dev->features;