From patchwork Fri Feb 3 05:01:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Si-Wei Liu X-Patchwork-Id: 52309 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp649663wrn; Thu, 2 Feb 2023 21:06:47 -0800 (PST) X-Google-Smtp-Source: AK7set8hUIiqjHlWR/T2vJC+/bZ2/P52Us1yO4GPX/riRjp+MDJlDTLbZpFMe18Ps3sYTaDREZ+C X-Received: by 2002:a17:907:2130:b0:87b:daf7:cf3b with SMTP id qo16-20020a170907213000b0087bdaf7cf3bmr8822320ejb.47.1675400807332; 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=xEuCQ1Xp/wW3e6ltzbKOqw8ipJok7yhADoWGeK22dq/Be3faMbuezJr61I+Kgk/f/C KMVmaUe8+kyMS1+A0qlXGPTIzTwaSjus2gsqU68SCBExOES20urRtKA09szqUNbFsvO1 euXzzWWcXkgtUwCf1MgIYA3Xvk1xPt2XtvY3Fnvu8mhAxMc+N9/lw/V5NpZYoXB1UR8w sMwQBLuWXf/P0JCY5LeScSmH47iRzi346tUQi9/9ep8nDAedMpdDEovSvxibY2v2GlMt Su35OxKDufQ1Ghga7e0/exvv9BWaB4doGCXVT80aEPxjdq93n2++jZ0hRpGPe8Ikr+kf TzJg== 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=Ejnp7C0WH2CJJTjLdJGDsNeQ6ndq2k8gOgYfgezuMYI=; b=bDz/egeNtx8GJjx+NOwziLMLr/H3CHpJ+ITC1FOYfiOypbv9/Vb2Ey1VAlUisxDZAj T0trnuFibOxHhQDoi+b9cIZbb1j2aFHXQbOzRwxHUW8fQTmcUWGHe/SZgXYYUwgrmRDD Bmqu/IkNIpNW2bPLmUQmLCz33q+SsvfShJ2EYMMvMJzKwl0iSp5Qtw42fdfgSHiWFY1F akFD/LQFyTMQhOvaSdIEg+KY096ODSyWsRXjM3Tykoy3459M7rC/4RU/F3KBcFDMv3xg ondcn+NjRIz6YMy4fMKPD8sz8k6T4c5KzTZpGMGpbEmBRwD5qHTcSYxfJc5y5dVMWeAw lIfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=DTdhMRo9; 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 v16-20020a17090610d000b007c0c7c42636si2370967ejv.683.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=DTdhMRo9; 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 S231905AbjBCFDJ (ORCPT + 99 others); Fri, 3 Feb 2023 00:03:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230180AbjBCFCg (ORCPT ); Fri, 3 Feb 2023 00:02:36 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B163374C3A for ; Thu, 2 Feb 2023 21:02:28 -0800 (PST) Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3130NY0q028366; Fri, 3 Feb 2023 05:02:24 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=Ejnp7C0WH2CJJTjLdJGDsNeQ6ndq2k8gOgYfgezuMYI=; b=DTdhMRo9NUiVkb9cq3QUMo/6+I/PxI5E9p4oAOZ6XtS2JHsPU9VkkyCSfsdo4dUtjdH5 qNz1LaTHKqlDo2EznEckKj/uistnuglkYqBf0q1MoBKWueUluis8jOxNqC5Gqi61mP97 3/EhXgsyPVrLHoUCvD6ubS43a3Nwr/1xOtFAmACSaTOM+wTpI4fVCJtaGZR975vFj3TV bMFruvPg5oi3agP9ezqc1/4o03qEpWYzbY8aJf6IvycL6ETbsvBPC9DsoSTViWyZ+1kn 4LfrdCsb5z8jdsY1fROQIAB5oR0lHo56fGW1sOazdueK+rDT0/7aaIuQpvniVaTvICBG yg== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3nfn9ymrqr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 03 Feb 2023 05:02:24 +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 31340RuN006053; Fri, 3 Feb 2023 05:02:23 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-3; Fri, 03 Feb 2023 05:02:23 +0000 From: Si-Wei Liu 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 2/6] vdpa: conditionally read STATUS in config space Date: Thu, 2 Feb 2023 21:01:59 -0800 Message-Id: <1675400523-12519-3-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-ORIG-GUID: g8pWt_9SIT-4NKne5pO83jvaFbB6N3jM X-Proofpoint-GUID: g8pWt_9SIT-4NKne5pO83jvaFbB6N3jM 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756785076795683175?= X-GMAIL-MSGID: =?utf-8?q?1756785076795683175?= The spec says: status only exists if VIRTIO_NET_F_STATUS is set Similar to MAC and MTU, vdpa_dev_net_config_fill() should read STATUS conditionally depending on the feature bits. Signed-off-by: Si-Wei Liu Reviewed-by: Parav Pandit Reviewed-by: Eli Cohen --- drivers/vdpa/vdpa.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/drivers/vdpa/vdpa.c b/drivers/vdpa/vdpa.c index 3a82ca78..21c8aa3 100644 --- a/drivers/vdpa/vdpa.c +++ b/drivers/vdpa/vdpa.c @@ -843,18 +843,25 @@ static int vdpa_dev_net_mac_config_fill(struct sk_buff *msg, u64 features, sizeof(config->mac), config->mac); } +static int vdpa_dev_net_status_config_fill(struct sk_buff *msg, u64 features, + const struct virtio_net_config *config) +{ + u16 val_u16; + + if ((features & BIT_ULL(VIRTIO_NET_F_STATUS)) == 0) + return 0; + + val_u16 = __virtio16_to_cpu(true, config->status); + return nla_put_u16(msg, VDPA_ATTR_DEV_NET_STATUS, val_u16); +} + static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *msg) { struct virtio_net_config config = {}; u64 features_device; - u16 val_u16; vdev->config->get_config(vdev, 0, &config, sizeof(config)); - val_u16 = __virtio16_to_cpu(true, config.status); - if (nla_put_u16(msg, VDPA_ATTR_DEV_NET_STATUS, val_u16)) - return -EMSGSIZE; - features_device = vdev->config->get_device_features(vdev); if (nla_put_u64_64bit(msg, VDPA_ATTR_DEV_FEATURES, features_device, @@ -867,6 +874,9 @@ static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *ms if (vdpa_dev_net_mac_config_fill(msg, features_device, &config)) return -EMSGSIZE; + if (vdpa_dev_net_status_config_fill(msg, features_device, &config)) + return -EMSGSIZE; + return vdpa_dev_net_mq_config_fill(msg, features_device, &config); }