Message ID | 1675400523-12519-6-git-send-email-si-wei.liu@oracle.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp649662wrn; Thu, 2 Feb 2023 21:06:47 -0800 (PST) X-Google-Smtp-Source: AK7set9902RaiEJkbEDmtWiURzCidtu/Jh2zo+mGdpCIiNYlIY3L9R8cpKM90jj6Q9FclapybDKa X-Received: by 2002:a17:907:c78a:b0:878:7349:5ce6 with SMTP id tz10-20020a170907c78a00b0087873495ce6mr10049912ejc.71.1675400807333; Thu, 02 Feb 2023 21:06:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675400807; cv=none; d=google.com; s=arc-20160816; b=EZQutY7Gg7bDC8N0UAibdTDtodk5ewoN3SPo8McNeyXlexXLuiCB9JpvVY8rGnaHZW k404b0Qbkzr1m1sjlvBKM5IYZpO1n5bH1QyAKF86m4YXmecUfTDJD2fZAymvnR3cDMz/ NuWz4iCWlhBX43TsZUWeOpJ4IzIbO5qy5+rGTHS5vCH7pnTbOiuR4kIIgJeXu/zg04CG 2CPpMtNhSLWYZGcGPmrSc8SqrEOXhKZzUhLH0ouSjr05aUBVtnOKB6j5ZaUdCs0S76FH qt+EMpF5ZT3keEodEkRSJgSR1WER4lfnJEUKeqNZZAAAq6KVe8OhgYsOibo3WQyAe+4c 96xw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=EAIkrvgOSInyby1SydfKYi7b+/iUp1Fgo8LJ0wjyTXo=; b=IEFsRKAJeezjgXVhc5cZR+6JXrKkRj578vtFFmN1IdU9Rqhja6s/L/ETh/C+f4Ims9 m3B45fTvQXU3dM2G+eYzrYUnoaWioWs6iIPQdF3yxV6bXccLt75ukXpzbBpcYPjymXmO aDHaTiagYhNsp+04m3JrlWx/iScyPpHIHzmTDldcL4Oq1g2xrEAHlBjISwVJLFfNqZqB qdomJCL/bIELaDvxSnP8a/+UhRXcZKRgGt7qy0geoY8lO0Xag+INpldN+V/pzG2S+yjK QHRQf5FDr3cZVmg3qxO6G029BeDA/VSfP/DcxkKzdBVVETRJIoBgU4RlBpi7Io/4VzlB F+Yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=sbckgEXl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 18-20020a170906001200b00864aa239277si2158253eja.896.2023.02.02.21.06.23; Thu, 02 Feb 2023 21:06:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=sbckgEXl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S230144AbjBCFDW (ORCPT <rfc822;il.mystafa@gmail.com> + 99 others); Fri, 3 Feb 2023 00:03:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231185AbjBCFCj (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 3 Feb 2023 00:02:39 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E67F74C03 for <linux-kernel@vger.kernel.org>; Thu, 2 Feb 2023 21:02:32 -0800 (PST) Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3130O26s005762; Fri, 3 Feb 2023 05:02:27 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2022-7-12; bh=EAIkrvgOSInyby1SydfKYi7b+/iUp1Fgo8LJ0wjyTXo=; b=sbckgEXlCfS+AtaDIYm78KncHEA68C0WAKQdH/DVVIdUQkpr+I+YaRmnW8sbO2lY38OX k9aLTks84outovHRAGUx3PSW3DRJoaZvTCUr9jbssV/Ga2UJ3BIXdvxYJH32UZn1z3fr GwD53eNgHnstJV4UDqcACdtV4WKLrTXPqbPNLQM0haWBdCgBNdMrbg8Kw/e77oQ6zT25 871yJFra2IaSORyM0Zhgdn7o3Cw836ZR/sHXsYpcn+ubno/Aepi0Y/QMunUR7ycpkg0M 5ghCmB1exuCxGVtMnyBVmsKX/T15pXyv0fLS1s+gf/mIYp+1734s8iohjhM9frppBd0I vA== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3nfkfe4wxh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 03 Feb 2023 05:02:27 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 31340RuQ006053; Fri, 3 Feb 2023 05:02:26 GMT Received: from ban25x6uut24.us.oracle.com (ban25x6uut24.us.oracle.com [10.153.73.24]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3nct5a2tm8-6; Fri, 03 Feb 2023 05:02:26 +0000 From: Si-Wei Liu <si-wei.liu@oracle.com> To: mst@redhat.com, jasowang@redhat.com, parav@nvidia.com, elic@nvidia.com Cc: virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 5/6] vdpa/mlx5: conditionally show MTU and STATUS in config space Date: Thu, 2 Feb 2023 21:02:02 -0800 Message-Id: <1675400523-12519-6-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1675400523-12519-1-git-send-email-si-wei.liu@oracle.com> References: <1675400523-12519-1-git-send-email-si-wei.liu@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-02-03_02,2023-02-02_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 suspectscore=0 mlxscore=0 spamscore=0 phishscore=0 bulkscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302030044 X-Proofpoint-GUID: DnnmqFI2u_S88diulMEjDHhehVM337lr X-Proofpoint-ORIG-GUID: DnnmqFI2u_S88diulMEjDHhehVM337lr X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756785076805895594?= X-GMAIL-MSGID: =?utf-8?q?1756785076805895594?= |
Series |
features provisioning fixes and mlx5_vdpa support
|
|
Commit Message
Si-Wei Liu
Feb. 3, 2023, 5:02 a.m. UTC
The spec says:
mtu only exists if VIRTIO_NET_F_MTU is set
status only exists if VIRTIO_NET_F_STATUS is set
We should only show MTU and STATUS conditionally depending on
the feature bits.
Signed-off-by: Si-Wei Liu <si-wei.liu@oracle.com>
---
drivers/vdpa/mlx5/net/mlx5_vnet.c | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)
Comments
On 03/02/2023 7:02, Si-Wei Liu wrote: > The spec says: > mtu only exists if VIRTIO_NET_F_MTU is set > status only exists if VIRTIO_NET_F_STATUS is set > > We should only show MTU and STATUS conditionally depending on > the feature bits. > > Signed-off-by: Si-Wei Liu <si-wei.liu@oracle.com> > --- > drivers/vdpa/mlx5/net/mlx5_vnet.c | 22 ++++++++++++++-------- > 1 file changed, 14 insertions(+), 8 deletions(-) > > diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c > index 3a6dbbc6..867ac18 100644 > --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c > +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c > @@ -3009,6 +3009,8 @@ static int event_handler(struct notifier_block *nb, unsigned long event, void *p > struct mlx5_vdpa_wq_ent *wqent; > > if (event == MLX5_EVENT_TYPE_PORT_CHANGE) { > + if (!(ndev->mvdev.actual_features & BIT_ULL(VIRTIO_NET_F_STATUS))) > + return NOTIFY_DONE; > switch (eqe->sub_type) { > case MLX5_PORT_CHANGE_SUBTYPE_DOWN: > case MLX5_PORT_CHANGE_SUBTYPE_ACTIVE: > @@ -3118,16 +3120,20 @@ static int mlx5_vdpa_dev_add(struct vdpa_mgmt_dev *v_mdev, const char *name, > goto err_alloc; > } > > - err = query_mtu(mdev, &mtu); > - if (err) > - goto err_alloc; > + if (ndev->mvdev.mlx_features & BIT_ULL(VIRTIO_NET_F_MTU)) { VIRTIO_NET_F_MTU is offered by the device. So conditional is always true. We are not done with feature negotiation at this stage so you may still set a value to device mtu if MTU won't be negotiated eventually. But that is not a problem because the spec says: VIRTIO_NET_F_MTU(3) Device maximum MTU reporting is supported. If offered by the device, device advises driver about the value of its maximum MTU. If negotiated, the driver uses mtu as the maximum MTU value. So the driver will use whatever value is there only if negotiated. > + err = query_mtu(mdev, &mtu); > + if (err) > + goto err_alloc; > > - ndev->config.mtu = cpu_to_mlx5vdpa16(mvdev, mtu); > + ndev->config.mtu = cpu_to_mlx5vdpa16(mvdev, mtu); > + } > > - if (get_link_state(mvdev)) > - ndev->config.status |= cpu_to_mlx5vdpa16(mvdev, VIRTIO_NET_S_LINK_UP); > - else > - ndev->config.status &= cpu_to_mlx5vdpa16(mvdev, ~VIRTIO_NET_S_LINK_UP); > + if (ndev->mvdev.mlx_features & BIT_ULL(VIRTIO_NET_F_STATUS)) { > + if (get_link_state(mvdev)) > + ndev->config.status |= cpu_to_mlx5vdpa16(mvdev, VIRTIO_NET_S_LINK_UP); > + else > + ndev->config.status &= cpu_to_mlx5vdpa16(mvdev, ~VIRTIO_NET_S_LINK_UP); > + } Same thing here. Feature negotiation is not complete yet and if VIRTIO_NET_F_STATUS ends up not being negotiated, the driver will ignore this value. > > if (add_config->mask & (1 << VDPA_ATTR_DEV_NET_CFG_MACADDR)) { > memcpy(ndev->config.mac, add_config->net.mac, ETH_ALEN);
On 2/5/2023 1:36 AM, Eli Cohen wrote: > > On 03/02/2023 7:02, Si-Wei Liu wrote: >> The spec says: >> mtu only exists if VIRTIO_NET_F_MTU is set >> status only exists if VIRTIO_NET_F_STATUS is set >> >> We should only show MTU and STATUS conditionally depending on >> the feature bits. >> >> Signed-off-by: Si-Wei Liu <si-wei.liu@oracle.com> >> --- >> drivers/vdpa/mlx5/net/mlx5_vnet.c | 22 ++++++++++++++-------- >> 1 file changed, 14 insertions(+), 8 deletions(-) >> >> diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c >> b/drivers/vdpa/mlx5/net/mlx5_vnet.c >> index 3a6dbbc6..867ac18 100644 >> --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c >> +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c >> @@ -3009,6 +3009,8 @@ static int event_handler(struct notifier_block >> *nb, unsigned long event, void *p >> struct mlx5_vdpa_wq_ent *wqent; >> if (event == MLX5_EVENT_TYPE_PORT_CHANGE) { >> + if (!(ndev->mvdev.actual_features & >> BIT_ULL(VIRTIO_NET_F_STATUS))) >> + return NOTIFY_DONE; >> switch (eqe->sub_type) { >> case MLX5_PORT_CHANGE_SUBTYPE_DOWN: >> case MLX5_PORT_CHANGE_SUBTYPE_ACTIVE: >> @@ -3118,16 +3120,20 @@ static int mlx5_vdpa_dev_add(struct >> vdpa_mgmt_dev *v_mdev, const char *name, >> goto err_alloc; >> } >> - err = query_mtu(mdev, &mtu); >> - if (err) >> - goto err_alloc; >> + if (ndev->mvdev.mlx_features & BIT_ULL(VIRTIO_NET_F_MTU)) { > > VIRTIO_NET_F_MTU is offered by the device. So conditional is always true. With the next patch in series that selectively provisions device features to mlx5_vdpa, this conditional will not be always true. That was the reason why I made patch 5 and 6 in a single commit, as this conditional will only be needed until feature provisioning is supported. Basically patch 5 and 6 are logically connected and technically should be separated out. I'm now puzzled, what was your thought then the change in patch 5 shouldn't be part of patch 6? > We are not done with feature negotiation at this stage so you 'You' are who? device, driver or guest user? > may still set a value to device mtu if MTU won't be negotiated > eventually. But that is not a problem because the spec says: > > VIRTIO_NET_F_MTU(3) Device maximum MTU reporting is supported. If > offered by the device, device > advises driver about the value of its maximum MTU. If negotiated, the > driver uses mtu as the maximum > > MTU value. > > So the driver will use whatever value is there only if negotiated. My understanding is that 'vdpa dev config' now displays user provisioned config, or default config value advertised by the device, rather than what config driver will actually use. > >> + err = query_mtu(mdev, &mtu); >> + if (err) >> + goto err_alloc; >> - ndev->config.mtu = cpu_to_mlx5vdpa16(mvdev, mtu); >> + ndev->config.mtu = cpu_to_mlx5vdpa16(mvdev, mtu); >> + } >> - if (get_link_state(mvdev)) >> - ndev->config.status |= cpu_to_mlx5vdpa16(mvdev, >> VIRTIO_NET_S_LINK_UP); >> - else >> - ndev->config.status &= cpu_to_mlx5vdpa16(mvdev, >> ~VIRTIO_NET_S_LINK_UP); >> + if (ndev->mvdev.mlx_features & BIT_ULL(VIRTIO_NET_F_STATUS)) { >> + if (get_link_state(mvdev)) >> + ndev->config.status |= cpu_to_mlx5vdpa16(mvdev, >> VIRTIO_NET_S_LINK_UP); >> + else >> + ndev->config.status &= cpu_to_mlx5vdpa16(mvdev, >> ~VIRTIO_NET_S_LINK_UP); >> + } > Same thing here. Feature negotiation is not complete yet and if > > VIRTIO_NET_F_STATUS ends up not being negotiated, the driver will > ignore this value. See above. With feature provisioning, whether the VIRTIO_NET_F_STATUS feature is advertised by device is subject to the device_features value provisioned by the host admin users. -Siwei > >> if (add_config->mask & (1 << VDPA_ATTR_DEV_NET_CFG_MACADDR)) { >> memcpy(ndev->config.mac, add_config->net.mac, ETH_ALEN);
On 06/02/2023 6:53, Si-Wei Liu wrote: > > > On 2/5/2023 1:36 AM, Eli Cohen wrote: >> >> On 03/02/2023 7:02, Si-Wei Liu wrote: >>> The spec says: >>> mtu only exists if VIRTIO_NET_F_MTU is set >>> status only exists if VIRTIO_NET_F_STATUS is set >>> >>> We should only show MTU and STATUS conditionally depending on >>> the feature bits. >>> >>> Signed-off-by: Si-Wei Liu <si-wei.liu@oracle.com> >>> --- >>> drivers/vdpa/mlx5/net/mlx5_vnet.c | 22 ++++++++++++++-------- >>> 1 file changed, 14 insertions(+), 8 deletions(-) >>> >>> diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c >>> b/drivers/vdpa/mlx5/net/mlx5_vnet.c >>> index 3a6dbbc6..867ac18 100644 >>> --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c >>> +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c >>> @@ -3009,6 +3009,8 @@ static int event_handler(struct notifier_block >>> *nb, unsigned long event, void *p >>> struct mlx5_vdpa_wq_ent *wqent; >>> if (event == MLX5_EVENT_TYPE_PORT_CHANGE) { >>> + if (!(ndev->mvdev.actual_features & >>> BIT_ULL(VIRTIO_NET_F_STATUS))) >>> + return NOTIFY_DONE; >>> switch (eqe->sub_type) { >>> case MLX5_PORT_CHANGE_SUBTYPE_DOWN: >>> case MLX5_PORT_CHANGE_SUBTYPE_ACTIVE: >>> @@ -3118,16 +3120,20 @@ static int mlx5_vdpa_dev_add(struct >>> vdpa_mgmt_dev *v_mdev, const char *name, >>> goto err_alloc; >>> } >>> - err = query_mtu(mdev, &mtu); >>> - if (err) >>> - goto err_alloc; >>> + if (ndev->mvdev.mlx_features & BIT_ULL(VIRTIO_NET_F_MTU)) { >> >> VIRTIO_NET_F_MTU is offered by the device. So conditional is always >> true. > With the next patch in series that selectively provisions device > features to mlx5_vdpa, this conditional will not be always true. That > was the reason why I made patch 5 and 6 in a single commit, as this > conditional will only be needed until feature provisioning is > supported. Basically patch 5 and 6 are logically connected and > technically should be separated out. I'm now puzzled, what was your > thought then the change in patch 5 shouldn't be part of patch 6? No, I think breaking into two patches is the right way to go. I missed the fact the for setting MTU and MAC you need the device to *offer* the feature and does not depend on negotiation. > >> We are not done with feature negotiation at this stage so you > 'You' are who? device, driver or guest user? > >> may still set a value to device mtu if MTU won't be negotiated >> eventually. But that is not a problem because the spec says: >> >> VIRTIO_NET_F_MTU(3) Device maximum MTU reporting is supported. If >> offered by the device, device >> advises driver about the value of its maximum MTU. If negotiated, the >> driver uses mtu as the maximum >> >> MTU value. >> >> So the driver will use whatever value is there only if negotiated. > My understanding is that 'vdpa dev config' now displays user > provisioned config, or default config value advertised by the device, > rather than what config driver will actually use. Reviewed-by: Eli Cohen <elic@nvidia.com> > >> >>> + err = query_mtu(mdev, &mtu); >>> + if (err) >>> + goto err_alloc; >>> - ndev->config.mtu = cpu_to_mlx5vdpa16(mvdev, mtu); >>> + ndev->config.mtu = cpu_to_mlx5vdpa16(mvdev, mtu); >>> + } >>> - if (get_link_state(mvdev)) >>> - ndev->config.status |= cpu_to_mlx5vdpa16(mvdev, >>> VIRTIO_NET_S_LINK_UP); >>> - else >>> - ndev->config.status &= cpu_to_mlx5vdpa16(mvdev, >>> ~VIRTIO_NET_S_LINK_UP); >>> + if (ndev->mvdev.mlx_features & BIT_ULL(VIRTIO_NET_F_STATUS)) { >>> + if (get_link_state(mvdev)) >>> + ndev->config.status |= cpu_to_mlx5vdpa16(mvdev, >>> VIRTIO_NET_S_LINK_UP); >>> + else >>> + ndev->config.status &= cpu_to_mlx5vdpa16(mvdev, >>> ~VIRTIO_NET_S_LINK_UP); >>> + } >> Same thing here. Feature negotiation is not complete yet and if >> >> VIRTIO_NET_F_STATUS ends up not being negotiated, the driver will >> ignore this value. > See above. With feature provisioning, whether the VIRTIO_NET_F_STATUS > feature is advertised by device is subject to the device_features > value provisioned by the host admin users. > > -Siwei > >> >>> if (add_config->mask & (1 << VDPA_ATTR_DEV_NET_CFG_MACADDR)) { >>> memcpy(ndev->config.mac, add_config->net.mac, ETH_ALEN); >
diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c index 3a6dbbc6..867ac18 100644 --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c @@ -3009,6 +3009,8 @@ static int event_handler(struct notifier_block *nb, unsigned long event, void *p struct mlx5_vdpa_wq_ent *wqent; if (event == MLX5_EVENT_TYPE_PORT_CHANGE) { + if (!(ndev->mvdev.actual_features & BIT_ULL(VIRTIO_NET_F_STATUS))) + return NOTIFY_DONE; switch (eqe->sub_type) { case MLX5_PORT_CHANGE_SUBTYPE_DOWN: case MLX5_PORT_CHANGE_SUBTYPE_ACTIVE: @@ -3118,16 +3120,20 @@ static int mlx5_vdpa_dev_add(struct vdpa_mgmt_dev *v_mdev, const char *name, goto err_alloc; } - err = query_mtu(mdev, &mtu); - if (err) - goto err_alloc; + if (ndev->mvdev.mlx_features & BIT_ULL(VIRTIO_NET_F_MTU)) { + err = query_mtu(mdev, &mtu); + if (err) + goto err_alloc; - ndev->config.mtu = cpu_to_mlx5vdpa16(mvdev, mtu); + ndev->config.mtu = cpu_to_mlx5vdpa16(mvdev, mtu); + } - if (get_link_state(mvdev)) - ndev->config.status |= cpu_to_mlx5vdpa16(mvdev, VIRTIO_NET_S_LINK_UP); - else - ndev->config.status &= cpu_to_mlx5vdpa16(mvdev, ~VIRTIO_NET_S_LINK_UP); + if (ndev->mvdev.mlx_features & BIT_ULL(VIRTIO_NET_F_STATUS)) { + if (get_link_state(mvdev)) + ndev->config.status |= cpu_to_mlx5vdpa16(mvdev, VIRTIO_NET_S_LINK_UP); + else + ndev->config.status &= cpu_to_mlx5vdpa16(mvdev, ~VIRTIO_NET_S_LINK_UP); + } if (add_config->mask & (1 << VDPA_ATTR_DEV_NET_CFG_MACADDR)) { memcpy(ndev->config.mac, add_config->net.mac, ETH_ALEN);