From patchwork Mon Jan 30 20:30:39 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: 50508 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2410424wrn; Mon, 30 Jan 2023 13:43:56 -0800 (PST) X-Google-Smtp-Source: AMrXdXsgDiu4f0wKv+mLaLYgqHWPvCDw/hYcwdfE/bfiOojr6RZgfeiSK2VajoATv2e7L/NWlkR3 X-Received: by 2002:a17:906:7050:b0:872:b17a:9b59 with SMTP id r16-20020a170906705000b00872b17a9b59mr51969072ejj.38.1675115036564; Mon, 30 Jan 2023 13:43:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675115036; cv=none; d=google.com; s=arc-20160816; b=PGPJbxFOzK+Zj2o4ifVz6q4sSXzZbEx/u0TPP7rlIRxhj9mnzW0YZH7bQRP2cWiDzK QlT0PyxNd8YxkIFcnRSnXe1GK9LyQsNC+wB/zzUk3M0hFuCm1WWazKae5JZcv/qN8sa7 skFQPWk1upBlKvgPKh78UmDxrPvBNTrI3475VQWVMvdV6vZT8ErVTy6LfCBpCVXYxaO5 +WMEy1pAlIKH7pD34R8sYJvrchEwqdRxKxDBZg7b9ey/CrrynpF91rqLlkcynneQaeh1 SJLwBV7xEqfrLCcekpn/0vVzFpXSv+bs5Ltg+yKMOZhFP+yGeVsCpHyzDWleiv1a52JU f31Q== 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=uNARmj9DqSK4eCVCfxVvrQGxRGB/k+87LR5p1WvHgfk=; b=oM2N8xdFor5Trczgs+SyvmEojwQcreQjgBRXOOUjpH5TQea/YLR+jwMkYIX/SHawJy yCGTDuyRrSMDDrbDwE/Oj/RTaFfkAsrwEuZXKtDre1a/s6acdYEatTJk93lprCTz+N8B Py8n+7h46b1o8HrNTIjXFZjHEoVq1nEASM/VWpAOI4vFj6ybWufalYN9TVvoGnKF7dnL VNTBMjwv3XfOk5tdNHXcWdbGkuwLVJhdfad4i6vDCTlq2MN7wiKhBGJjT1gW2irQIDrC UoGD8QPSBF+rDge1FAM8i4JPgnQv/L1qa1FWMB4Jt6OHiRezZDDuQqnTUqAFJjQtARvo awIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=a1xcZxUU; 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 fk25-20020a056402399900b0049d3f37b767si15523701edb.268.2023.01.30.13.43.33; Mon, 30 Jan 2023 13:43:56 -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=a1xcZxUU; 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 S230502AbjA3Vh3 (ORCPT + 99 others); Mon, 30 Jan 2023 16:37:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229797AbjA3Vh1 (ORCPT ); Mon, 30 Jan 2023 16:37:27 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4DFE35B9B for ; Mon, 30 Jan 2023 13:37:26 -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 30UL3pq0014361; Mon, 30 Jan 2023 21:37:21 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=uNARmj9DqSK4eCVCfxVvrQGxRGB/k+87LR5p1WvHgfk=; b=a1xcZxUUX4B1CUwszH/kqhkAjo3TarhMHYY22BWP4RhXBWDhdGcsUsBmrPItxik70Pqw oKC/vjAXoGEP8MP8+OBFMuWrzd86xZ61Ep5CiG4+cYsyd/9I/MsFunHnqfHVXo1zkmpN 9vlrWx4FODotvqtp/GZqla2RaOhd28HhSbR2Qiq/crGXaPSuLFvE54us4HpuH2RD4t7w Nujs7GdTbmNu8qFmyh/h42IvJuVTgI2UFLJsM3LC0KmhGLutuLPwsmV0jwz68GbT6PjM ojrp381PeFnTLEBF2OyKJ9qt2TWjHtjqOa5rIz/z9bDar9lHlWmpPloC/+qeP+l9asR3 Mg== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3ncvmhm28h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 30 Jan 2023 21:37:21 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 30UK8hq0031798; Mon, 30 Jan 2023 21:37:20 GMT Received: from ban25x6uut24.us.oracle.com (ban25x6uut24.us.oracle.com [10.153.73.24]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3nct54qa7f-3; Mon, 30 Jan 2023 21:37:20 +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 2/6] vdpa: conditionally read STATUS in config space Date: Mon, 30 Jan 2023 12:30:39 -0800 Message-Id: <1675110643-28143-3-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1675110643-28143-1-git-send-email-si-wei.liu@oracle.com> References: <1675110643-28143-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-01-30_17,2023-01-30_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 adultscore=0 malwarescore=0 spamscore=0 phishscore=0 mlxlogscore=999 suspectscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301300200 X-Proofpoint-ORIG-GUID: 3ltj96ZDoRqd1SzWA8vopKolyb1VRO1F X-Proofpoint-GUID: 3ltj96ZDoRqd1SzWA8vopKolyb1VRO1F 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?1756485424349538699?= X-GMAIL-MSGID: =?utf-8?q?1756485424349538699?= 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: 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 5e57935..5f4883b 100644 --- a/drivers/vdpa/vdpa.c +++ b/drivers/vdpa/vdpa.c @@ -848,18 +848,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, @@ -872,6 +879,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); }