Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2752664pxb; Sat, 6 Feb 2021 06:41:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJxl3TJ8xD5eMgS3HX6HjOuzMvlo4A0eh18dMrP5s7xSyV7rZLRFLLWFEJBWCTShHhUp2gUo X-Received: by 2002:aa7:c884:: with SMTP id p4mr8780695eds.212.1612622472005; Sat, 06 Feb 2021 06:41:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612622471; cv=none; d=google.com; s=arc-20160816; b=H0HI9ZEMXh872PqCsGWdMAAQ3cHIQPvLT+JX78GH4+xROJyrfATqFk0kbNzcywcqHW YRbo6yv91T/X1VpROZuZnYVqoj5jJ0Ee0g6mXN8SLi5UkY4zKCFnOQthohUS5+3+wbBg omMDKR3OxQJPjSQkmB1eoG6j5El/UzYylPm6J/7uZKCrH/yp+SZNz9ccqGWv8NDRbXz+ 0N6xA/XA2nmi8gEFlYswc0gx/h3oM8jIstQytPLP91kB9Je+jxA2LfXxejhXTtsTrSYC 5teEoQ8/ow0VAqRB7yladrtRzcEOZ8S/SmKnM6hwwo6m6KPX/vCmB0SPy7HwrnnmhTVF Rq4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:subject:cc:to:from :date:message-id:mime-version:dkim-signature; bh=o3THMT3JVYvgXz8IFwi9kLOWhVsX51RrtTOYVjA1hGI=; b=Yvko+OpFvgyeSSZFp6y2h+lkmKqmWgKqWBMPY2QKE5CZ3MQTaVQIFNJ7RxMl5M0A/J oKdL/QzvuV7Yn/Q2KDVCrUqk1HJsCspKRBUAt91+VPst5M/qTY4E7B99DqA+uhnhWXOa +KmIjxy5nmuffaPqL/rxp7otyD8Te7dzrzIXT7n9tqZb+aezgw3h5r5laOVYzQf9ro6u TDhSwhG9BApzzR++shlyKJWv9y5jmfxGm4yNP43ySWADEG2ebKr2TWxoPtlt/1O1IrFD Toj7O2VNgvYb/TERD5vxaTvGAQ8/e5+JYztysjEVlCy9uuPYk2iZaXuwcNyeLF8WN/0e 4Tdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=Y3cO8rQc; 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=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k8si7225275ejr.335.2021.02.06.06.40.46; Sat, 06 Feb 2021 06:41:11 -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=@oracle.com header.s=corp-2020-01-29 header.b=Y3cO8rQc; 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=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230055AbhBFNSD (ORCPT + 99 others); Sat, 6 Feb 2021 08:18:03 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:34884 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229545AbhBFNSB (ORCPT ); Sat, 6 Feb 2021 08:18:01 -0500 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 116DDS6H182707; Sat, 6 Feb 2021 13:17:11 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=mime-version : message-id : date : from : to : cc : subject : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=o3THMT3JVYvgXz8IFwi9kLOWhVsX51RrtTOYVjA1hGI=; b=Y3cO8rQc2Es13Tu/DiAALKGY53sNXRia1fo5o/ETv6lsuKDbeTwdtU8WK3Xb7c+wvqDU LYLPxZg7dYs6hvtHG9yN6LZntxwZOZVuLTuIIt8yavtpFbfQDCIIpDCkIzqrneJTOTvd sQYOjYHAc6sWHEhqUW0TgK0CMMJUVHoGKztiKqPYnOfwsSDoLf0gDA7JWJMfEZ0i+M4H HZVq7x1W00O+pThjRUHyF9sTakz6V/aSleYCnBbf4I7I5SD6CDQ85oeyi+oGLH7vnN4s MZW7FhiXJST2OMXekNnCNSfCqkbwfW/2vIhogzfiXNUNwv3S2pAqpSpqx7d8MPZmEmI4 0g== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 36hk2k8mbu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 06 Feb 2021 13:17:11 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 116DAmSQ054100; Sat, 6 Feb 2021 13:17:09 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3030.oracle.com with ESMTP id 36hg7rfas6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 06 Feb 2021 13:17:09 +0000 Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 116DH8FU027788; Sat, 6 Feb 2021 13:17:08 GMT Received: from ban25x6uut24.us.oracle.com (/10.153.73.24) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 06 Feb 2021 05:16:16 -0800 MIME-Version: 1.0 Message-ID: <1612614564-4220-1-git-send-email-si-wei.liu@oracle.com> Date: Sat, 6 Feb 2021 04:29:22 -0800 (PST) From: Si-Wei Liu To: mst@redhat.com, jasowang@redhat.com, elic@nvidia.com Cc: linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, si-wei.liu@oracle.com Subject: [PATCH 1/3] mlx5_vdpa: should exclude header length and fcs from mtu X-Mailer: git-send-email 1.8.3.1 Content-Type: text/plain; charset=ascii Content-Transfer-Encoding: 7bit X-Proofpoint-IMR: 1 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9886 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxscore=0 phishscore=0 malwarescore=0 mlxlogscore=999 suspectscore=0 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102060093 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9886 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 malwarescore=0 priorityscore=1501 clxscore=1015 impostorscore=0 lowpriorityscore=0 bulkscore=0 suspectscore=0 spamscore=0 mlxlogscore=999 adultscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102060093 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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