Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3721848pxb; Sun, 7 Feb 2021 20:42:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJzHxBPexG3Mo0qu1GBJVJJUGlbjB57inl7odonn8jc8nRhqlngTeDHO3FqHag3EEXX5/70v X-Received: by 2002:a17:906:8159:: with SMTP id z25mr15125766ejw.270.1612759353201; Sun, 07 Feb 2021 20:42:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612759353; cv=none; d=google.com; s=arc-20160816; b=F9DmhSRJlBr6VYSs1beoUFvVuig5j7Ascg20E15o+4TShmUF5CQ6pytml2Q6bw+Vj7 K1zSyeMPcjtsT75oxsoplR1hPoVCgg03Y17pg3/1/S4CaVZvkXSBfS0hpQq31A4BkUxF 67yjpcxNr1UCcweIKcRyUAW0VfV/Kdi9tuRMXTvf93MQ/GbqbhW4OyoxzccB2qitT+sZ fgJ3FUycw0Isq49Vzn8jJ0LH/gsd2jzcHMYuTMlGtRZUCPqQ6a8iHxb08MpN27O7xXVQ ZBBLCc+VWaAZNAiS5PNzb+GNwf+JG8P7yPvr/JT0Mz5kt+HF20NFBSLFjd8O9h4gsPu7 sybg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=ua7Jkm4OPahNFhX/PVXIUgObMy5pUjSLw7j6xYHr7zs=; b=w8oBKDTlWUjALvvXmzb4vR+UyJA69DJZqQecRsuOrSiip91rTKkvLI0CMCnz556tqt +A8urfgif2JnW1hTFCyHlg40ORo6Nru4OO340Jk1glNUO3MbtRGo/gQrVJwIaYv2TrHg f1W/A5bgvXsiEgUMv/WS3PHgcwLlKfezV5T5r+znuG+FZAkvU/GdobIhMStdOXwWdOxW 4Bji/rUdWFjiOy2p+i/uvaZMyc8ViIvMeCX+AkL290cl7w+xgKm0ISYk4hDV/y/JYfhd 0IDMSY+3Q2cu4u4pPxDw4GqLGaf8057nNNQ+Tt73xbrHnmPZUOiZ0WFPoCMk8p/C6YDI 40Rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=SIzGShHF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l15si9712694eja.30.2021.02.07.20.42.10; Sun, 07 Feb 2021 20:42:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=SIzGShHF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229771AbhBHEkf (ORCPT + 99 others); Sun, 7 Feb 2021 23:40:35 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:32368 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229734AbhBHEkZ (ORCPT ); Sun, 7 Feb 2021 23:40:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612759138; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ua7Jkm4OPahNFhX/PVXIUgObMy5pUjSLw7j6xYHr7zs=; b=SIzGShHFNQg6+OkGw3LuVyPHAq7CPsjLXAfdmmXwXPCpln/7pnwQtKCbffq25JvdEWPtJo 6UhSJuxSZbxLb2E+bN81dEdp4Acgzt0QsMjEeRGNXu8MDBHpuKDWMFSpr0Qy7UWvcnFTEn o2esBT94VlpmJCe6w5J7ep+kHy23ORE= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-538-O8rd9CjoPXykP3ZI3MXqXQ-1; Sun, 07 Feb 2021 23:38:56 -0500 X-MC-Unique: O8rd9CjoPXykP3ZI3MXqXQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8B935801977; Mon, 8 Feb 2021 04:38:55 +0000 (UTC) Received: from [10.72.13.185] (ovpn-13-185.pek2.redhat.com [10.72.13.185]) by smtp.corp.redhat.com (Postfix) with ESMTP id 528A75B4B5; Mon, 8 Feb 2021 04:38:48 +0000 (UTC) Subject: Re: [PATCH 1/3] mlx5_vdpa: should exclude header length and fcs from mtu To: Si-Wei Liu , mst@redhat.com, elic@nvidia.com Cc: linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org References: <1612614564-4220-1-git-send-email-si-wei.liu@oracle.com> From: Jason Wang Message-ID: <735a1b40-09f0-4fec-4d59-98e7c650297d@redhat.com> Date: Mon, 8 Feb 2021 12:38:47 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <1612614564-4220-1-git-send-email-si-wei.liu@oracle.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/2/6 下午8:29, Si-Wei Liu wrote: > When feature VIRTIO_NET_F_MTU is negotiated on mlx5_vdpa, > 22 extra bytes worth of MTU length is shown in guest. > This is because the mlx5_query_port_max_mtu API returns > the "hardware" MTU value, which does not just contain the > Ethernet payload, but includes extra lengths starting > from the Ethernet header up to the FCS altogether. > > Fix the MTU so packets won't get dropped silently. > > Signed-off-by: Si-Wei Liu Acked-by: Jason Wang > --- > drivers/vdpa/mlx5/core/mlx5_vdpa.h | 4 ++++ > drivers/vdpa/mlx5/net/mlx5_vnet.c | 15 ++++++++++++++- > 2 files changed, 18 insertions(+), 1 deletion(-) > > diff --git a/drivers/vdpa/mlx5/core/mlx5_vdpa.h b/drivers/vdpa/mlx5/core/mlx5_vdpa.h > index 08f742f..b6cc53b 100644 > --- a/drivers/vdpa/mlx5/core/mlx5_vdpa.h > +++ b/drivers/vdpa/mlx5/core/mlx5_vdpa.h > @@ -4,9 +4,13 @@ > #ifndef __MLX5_VDPA_H__ > #define __MLX5_VDPA_H__ > > +#include > +#include > #include > #include > > +#define MLX5V_ETH_HARD_MTU (ETH_HLEN + VLAN_HLEN + ETH_FCS_LEN) > + > struct mlx5_vdpa_direct_mr { > u64 start; > u64 end; > diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c > index dc88559..b8416c4 100644 > --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c > +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c > @@ -1907,6 +1907,19 @@ static int mlx5_get_vq_irq(struct vdpa_device *vdv, u16 idx) > .free = mlx5_vdpa_free, > }; > > +static int query_mtu(struct mlx5_core_dev *mdev, u16 *mtu) > +{ > + u16 hw_mtu; > + int err; > + > + err = mlx5_query_nic_vport_mtu(mdev, &hw_mtu); > + if (err) > + return err; > + > + *mtu = hw_mtu - MLX5V_ETH_HARD_MTU; > + return 0; > +} > + > static int alloc_resources(struct mlx5_vdpa_net *ndev) > { > struct mlx5_vdpa_net_resources *res = &ndev->res; > @@ -1992,7 +2005,7 @@ static int mlx5v_probe(struct auxiliary_device *adev, > init_mvqs(ndev); > mutex_init(&ndev->reslock); > config = &ndev->config; > - err = mlx5_query_nic_vport_mtu(mdev, &ndev->mtu); > + err = query_mtu(mdev, &ndev->mtu); > if (err) > goto err_mtu; >