Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3746150pxb; Sun, 7 Feb 2021 21:42:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJw6FjU9uYjjNAcEf/3OhK4rk7dH5niDXs3g0qX3rEK2f2861Y7JAvxE+3lrlik1fyvH3foJ X-Received: by 2002:a17:906:af41:: with SMTP id ly1mr14886259ejb.525.1612762946262; Sun, 07 Feb 2021 21:42:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612762946; cv=none; d=google.com; s=arc-20160816; b=tMtfCfvW7baOvs1ltVhgJsuInp6zxYDRveYGSdYajGxiUkNeRp84hDhujOL7ZFVi5k hyjfHDD6jHoxYNqVwwDYwCHDdrsIGvGUqI4fUU7skbRP9GVmwHt/vIDvm9BZmxBf3lXI 0h7y74AtVwutXaV12ZRz04mo9QwH2W1oiRIgZgi1Hfiqw5STGNijva/yHnPYlzbvZb8w LOGNX0zW0eof0fjZQ+CCVQRGyC1qC3n5BNpx5O5gpxNI9pqzpTK87kck1SG7+xSmhB3v n9gB8HoCa5rRnVxEY7l5l7WBJYDlKqBA5/aWJZibUP9Kzw/7tUjtFow9JS0sTy7OfHvK 6pSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:dkim-signature:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=kJv37owGshrcok8ORA1NrOtxbQmJyzVIQ92qZvpDxbc=; b=nxERCj78DPWPoTItCGtETGpkF0FJ2HYBRYsJHZZGelNZbPSNuIkR4Tft/VGSH8ws7L vZYTFAdZdLayWw62vJO52J0PNT1mWfw8QHwe9F16Cyr5mF7idXAGVfuzIQsKtEW4SLIp ZuWimJZAc5bzRjsiaqqmPKXgKyEi6VuWUVyTQp8cwHcoWD7IvgFVogz5xnnNBhenoBgD MY4j7GoKF+D/RAIWx4soXFO9DYlMfAhMVyRoMMQk8RpTkBrMColPsJDeudF6HogohP1k HBa5LTe12vkbZZfnkR5RaTZz7qZ3Wv5GP8pwCruTI6/yeS/uZMdZ8EuOs4ySellZAhbO i1BQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=ZL+RYN+q; 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=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y1si11425313edp.72.2021.02.07.21.42.02; Sun, 07 Feb 2021 21:42:26 -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=@nvidia.com header.s=n1 header.b=ZL+RYN+q; 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=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229725AbhBHFgz (ORCPT + 99 others); Mon, 8 Feb 2021 00:36:55 -0500 Received: from hqnvemgate26.nvidia.com ([216.228.121.65]:8772 "EHLO hqnvemgate26.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229609AbhBHFgh (ORCPT ); Mon, 8 Feb 2021 00:36:37 -0500 Received: from hqmail.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate26.nvidia.com (using TLS: TLSv1.2, AES256-SHA) id ; Sun, 07 Feb 2021 21:35:56 -0800 Received: from mtl-vdi-166.wap.labs.mlnx (172.20.145.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Mon, 8 Feb 2021 05:35:54 +0000 Date: Mon, 8 Feb 2021 07:35:50 +0200 From: Eli Cohen To: Si-Wei Liu CC: , , , , Subject: Re: [PATCH 1/3] mlx5_vdpa: should exclude header length and fcs from mtu Message-ID: <20210208053550.GB137517@mtl-vdi-166.wap.labs.mlnx> References: <1612614564-4220-1-git-send-email-si-wei.liu@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <1612614564-4220-1-git-send-email-si-wei.liu@oracle.com> User-Agent: Mutt/1.9.5 (bf161cf53efb) (2018-04-13) X-Originating-IP: [172.20.145.6] X-ClientProxiedBy: HQMAIL105.nvidia.com (172.20.187.12) To HQMAIL107.nvidia.com (172.20.187.13) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1612762556; bh=kJv37owGshrcok8ORA1NrOtxbQmJyzVIQ92qZvpDxbc=; h=Date:From:To:CC:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To:User-Agent: X-Originating-IP:X-ClientProxiedBy; b=ZL+RYN+qth0RK4hfvlutVouAx1iQ4udUTeAa7NcOi1MLpPTcAbMg0wPZmMQC35hDi Oj/eS4gaUErkjdZ39qRhlx3GwTunaUwVpsYRO6aZnCjVyxtgE2Gqn8D3InuCJEBBHS zitjPi10A6+QOG/nJ1pe5JYKvBgIwVEL5JGzzIToIvJ679MmThK46HDqMDPMQkg2UI QJtjVbgmViQcg0fx+B+vbDp6Dxw1T+8lzRTlwtSAVJmJC8laTu1CREy5fZJ8rsYah3 rxFnUI+7TYi8TK+i5asWB/iloLQA0JndTi5pLyikwIsWHwkDO2BlMPNK9xMb2O0Zc/ J9yOZSIuJAerQ== Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Feb 06, 2021 at 04:29:22AM -0800, 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: Eli Cohen > --- > 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; > > -- > 1.8.3.1 >