Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 85BE8C433F5 for ; Thu, 25 Nov 2021 07:33:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234665AbhKYHg1 (ORCPT ); Thu, 25 Nov 2021 02:36:27 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:43111 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235433AbhKYHe0 (ORCPT ); Thu, 25 Nov 2021 02:34:26 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637825475; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Y5eJI0pmeXq/S80YZOfzijUCY3OPnAMCMR2eYYY351o=; b=NjNse01S61GrR1fLb937yeZ6+A+VJbbT5uy6O1ZEDLdD9EMJDQ12FLfaWd2CxM0Hr0Tf2N stzNkJdeBHLViP+Z/pgcU/4iwWSoRMVsbmmJMlBqMYJUMb4PNU68h+JovOaNbh6XEak5Kd xj1oj77gMlOJhpr5jN8USenyAEQUexU= Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-37-sNbM51c-OSSEFQRrgZpWCw-1; Thu, 25 Nov 2021 02:31:13 -0500 X-MC-Unique: sNbM51c-OSSEFQRrgZpWCw-1 Received: by mail-ed1-f69.google.com with SMTP id m17-20020aa7d351000000b003e7c0bc8523so4704271edr.1 for ; Wed, 24 Nov 2021 23:31:13 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Y5eJI0pmeXq/S80YZOfzijUCY3OPnAMCMR2eYYY351o=; b=KYqHGl4Gg1CVdVOaDkgsXx8u/CDKb5YSzePnmux3XyMdaj2J4klupksY12pLOPJkQ0 nnzW0W7M2eBRZaNVd3x6vk5r/S5r5rEKcRy3/tZoYHS9UTL5pXgqY5hnAKfcT46A1Rfa zFhMd+SU8DIbUWP9RGIIfR/j4wK+oSYVpTQfu1kNRtaqltQgOs4Clg/raEgNDmSv2q96 xv1gTbnzx9gwN8yuu41kZLR2oMdAngvQ94hQwzzUkl3QA1sl0ngoUM/HAZ/3W4cdMzee 9hpnTN01Da2cUZ+ECEqTLr/6vC3d5nUVaomq4bX0TRVltBT1Jy41RjQYYfm8DQdOGsVy CQtg== X-Gm-Message-State: AOAM532Nv5VnE9jOoY4dYZdy1S7vVr41NfPKp1eH+5WPGnsI5JrNiaXx n/MhvEyBj9YzqOpa5VaU/rOo2eL1NJO7JDIccQa069FapJm5A8p9rBsNQ6aNA4J9BP+bnYqMko1 5n/SUmV62V0mTi3h6+adDFgqX X-Received: by 2002:a05:6402:1768:: with SMTP id da8mr25711401edb.252.1637825472115; Wed, 24 Nov 2021 23:31:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJyFdLw5OpKsVjX5SKIvWd83t+uIMlDFgJtQwFJcoac+GAXQ+szrPYXWa/3fjvXjeKAZDLCgeA== X-Received: by 2002:a05:6402:1768:: with SMTP id da8mr25711383edb.252.1637825471883; Wed, 24 Nov 2021 23:31:11 -0800 (PST) Received: from redhat.com ([45.15.18.67]) by smtp.gmail.com with ESMTPSA id n16sm1263656edt.67.2021.11.24.23.31.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Nov 2021 23:31:11 -0800 (PST) Date: Thu, 25 Nov 2021 02:31:05 -0500 From: "Michael S. Tsirkin" To: Jason Wang Cc: Eli Cohen , virtualization , netdev , linux-kernel Subject: Re: [PATCH net] virtio-net: enable big mode correctly Message-ID: <20211125022736-mutt-send-email-mst@kernel.org> References: <20211125060547.11961-1-jasowang@redhat.com> <20211125070939.GC211101@mtl-vdi-166.wap.labs.mlnx> <20211125072040.GA213301@mtl-vdi-166.wap.labs.mlnx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 25, 2021 at 03:26:22PM +0800, Jason Wang wrote: > On Thu, Nov 25, 2021 at 3:20 PM Eli Cohen wrote: > > > > On Thu, Nov 25, 2021 at 03:15:33PM +0800, Jason Wang wrote: > > > On Thu, Nov 25, 2021 at 3:09 PM Eli Cohen wrote: > > > > > > > > On Thu, Nov 25, 2021 at 02:05:47PM +0800, Jason Wang wrote: > > > > > When VIRTIO_NET_F_MTU feature is not negotiated, we assume a very > > > > > large max_mtu. In this case, using small packet mode is not correct > > > > > since it may breaks the networking when MTU is grater than > > > > > ETH_DATA_LEN. > > > > > > > > > > To have a quick fix, simply enable the big packet mode when > > > > > VIRTIO_NET_F_MTU is not negotiated. We can do optimization on top. > > > > > > > > > > Reported-by: Eli Cohen > > > > > Cc: Eli Cohen > > > > > Signed-off-by: Jason Wang > > > > > --- > > > > > drivers/net/virtio_net.c | 7 ++++--- > > > > > 1 file changed, 4 insertions(+), 3 deletions(-) > > > > > > > > > > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c > > > > > index 7c43bfc1ce44..83ae3ef5eb11 100644 > > > > > --- a/drivers/net/virtio_net.c > > > > > +++ b/drivers/net/virtio_net.c > > > > > @@ -3200,11 +3200,12 @@ static int virtnet_probe(struct virtio_device *vdev) > > > > > dev->mtu = mtu; > > > > > dev->max_mtu = mtu; > > > > > > > > > > - /* TODO: size buffers correctly in this case. */ > > > > > - if (dev->mtu > ETH_DATA_LEN) > > > > > - vi->big_packets = true; > > > > > } > > > > > > > > > > + /* TODO: size buffers correctly in this case. */ > > > > > + if (dev->max_mtu > ETH_DATA_LEN) > > > > > + vi->big_packets = true; > > > > > + > > > > > > > > If VIRTIO_NET_F_MTU is provided, then dev->max_mtu is going to equal > > > > ETH_DATA_LEN (will be set in ether_setup()) so I don't think it will set > > > > big_packets to true. > > > > > > I may miss something, the dev->max_mtu is just assigned to the mtu > > > value read from the config space in the code block above (inside the > > > feature check of VIRTIO_NET_F_MTU). > > > > Sorry, I meant "If VIRTIO_NET_F_MTU is ***NOT*** provided". In that case > > dev->max_mtu eauals ETH_DATA_LEN so you won't set vi->big_packets to > > true. > > I see but in this case, the above assignment: > > /* MTU range: 68 - 65535 */ > dev->min_mtu = MIN_MTU; > dev->max_mtu = MAX_MTU; > > happens after alloc_etherdev_mq() which calls ether_setup(), so we are > probably fine here. > > Thanks Actually the issue with VIRTIO_NET_F_MTU is that devices might be tempted to expose 9k here simply because they support jumbo frames, if they also don't support mergeable buffers this will force big packet mode. > > > > > > > > Thanks > > > > > > > > > > > > > > > > if (vi->any_header_sg) > > > > > dev->needed_headroom = vi->hdr_len; > > > > > > > > > > -- > > > > > 2.25.1 > > > > > > > > > > > > > >