From patchwork Fri May 13 08:39:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhu, Lingshan" X-Patchwork-Id: 12848506 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 059D9C433EF for ; Fri, 13 May 2022 08:48:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378551AbiEMIsT (ORCPT ); Fri, 13 May 2022 04:48:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348408AbiEMIsR (ORCPT ); Fri, 13 May 2022 04:48:17 -0400 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45D3613C4F8 for ; Fri, 13 May 2022 01:48:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652431696; x=1683967696; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=SJaPkf8Mk7kpG7XQCleu+n6NzoT1H5nVd6tbpV/3If8=; b=XtbDPAsJznzEKIoISy5EEjC26CX/kaxlcMXSip0Alvm9My3EQCyMzgCl SzNmuG0dQIA++PJDvTkjvH3KXfMxoFaxxYRtNcznGa2FQ/XL+NfFhN6np efeUPPziPPyOztVvGOeFDQBbgIbVi9F09wTpo6GixpEFuql6KejXv6M66 7N005mOItf/P27Pa+4/QjIIM0uDgOJWsBkJ5bdLwDlggrQPGzcesduAqp bydDkrhGpR1mozWFc33uR9EFKx1h8vUhNmZBgtoDLhFh97H94uhTLUdpq oO30X7yFvhVR/iBnI7LMusWYhQk+av1ugIF1oyiZ+hZil9C8SosguDIMe w==; X-IronPort-AV: E=McAfee;i="6400,9594,10345"; a="356682846" X-IronPort-AV: E=Sophos;i="5.91,221,1647327600"; d="scan'208";a="356682846" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 May 2022 01:48:05 -0700 X-IronPort-AV: E=Sophos;i="5.91,221,1647327600"; d="scan'208";a="595122609" Received: from unknown (HELO ocsbesrhlrepo01.amr.corp.intel.com) ([10.240.193.73]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 May 2022 01:48:03 -0700 From: Zhu Lingshan To: jasowang@redhat.com, mst@redhat.com Cc: virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, Zhu Lingshan Subject: [RFC 1/6] vDPA/ifcvf: get_config_size should return a value no greater than dev implementation Date: Fri, 13 May 2022 16:39:30 +0800 Message-Id: <20220513083935.1253031-2-lingshan.zhu@intel.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220513083935.1253031-1-lingshan.zhu@intel.com> References: <20220513083935.1253031-1-lingshan.zhu@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-State: RFC ifcvf_get_config_size() should return a virtio device type specific value, however the ret_value should not be greater than the onboard size of the device implementation. E.g., for virtio_net, config_size should be the minimum value of sizeof(struct virtio_net_config) and the onboard cap size. Signed-off-by: Zhu Lingshan --- drivers/vdpa/ifcvf/ifcvf_base.c | 8 ++++++-- drivers/vdpa/ifcvf/ifcvf_base.h | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/vdpa/ifcvf/ifcvf_base.c b/drivers/vdpa/ifcvf/ifcvf_base.c index 48c4dadb0c7c..6bccc8291c26 100644 --- a/drivers/vdpa/ifcvf/ifcvf_base.c +++ b/drivers/vdpa/ifcvf/ifcvf_base.c @@ -128,6 +128,7 @@ int ifcvf_init_hw(struct ifcvf_hw *hw, struct pci_dev *pdev) break; case VIRTIO_PCI_CAP_DEVICE_CFG: hw->dev_cfg = get_cap_addr(hw, &cap); + hw->cap_dev_config_size = le32_to_cpu(cap.length); IFCVF_DBG(pdev, "hw->dev_cfg = %p\n", hw->dev_cfg); break; } @@ -233,15 +234,18 @@ int ifcvf_verify_min_features(struct ifcvf_hw *hw, u64 features) u32 ifcvf_get_config_size(struct ifcvf_hw *hw) { struct ifcvf_adapter *adapter; + u32 net_config_size = sizeof(struct virtio_net_config); + u32 blk_config_size = sizeof(struct virtio_blk_config); + u32 cap_size = hw->cap_dev_config_size; u32 config_size; adapter = vf_to_adapter(hw); switch (hw->dev_type) { case VIRTIO_ID_NET: - config_size = sizeof(struct virtio_net_config); + config_size = cap_size >= net_config_size ? net_config_size : cap_size; break; case VIRTIO_ID_BLOCK: - config_size = sizeof(struct virtio_blk_config); + config_size = cap_size >= blk_config_size ? blk_config_size : cap_size; break; default: config_size = 0; diff --git a/drivers/vdpa/ifcvf/ifcvf_base.h b/drivers/vdpa/ifcvf/ifcvf_base.h index 115b61f4924b..f5563f665cc6 100644 --- a/drivers/vdpa/ifcvf/ifcvf_base.h +++ b/drivers/vdpa/ifcvf/ifcvf_base.h @@ -87,6 +87,8 @@ struct ifcvf_hw { int config_irq; int vqs_reused_irq; u16 nr_vring; + /* VIRTIO_PCI_CAP_DEVICE_CFG size */ + u32 cap_dev_config_size; }; struct ifcvf_adapter { From patchwork Fri May 13 08:39:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhu, Lingshan" X-Patchwork-Id: 12848507 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1580DC433FE for ; Fri, 13 May 2022 08:48:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378544AbiEMIsV (ORCPT ); Fri, 13 May 2022 04:48:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378374AbiEMIsR (ORCPT ); Fri, 13 May 2022 04:48:17 -0400 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B7786A044 for ; Fri, 13 May 2022 01:48:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652431696; x=1683967696; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=zjM2lpnVEzgr9EqxgfBHSEFdupKbJYQ6DivWQeNJjbk=; b=kKfW8OjlD1WV3bQpAN6VsNWtg+SitPb0RZPFHSwWX5cWwXYs8W1DBv+l nwtuQV84AZKKPyuB+JuRosRtSHJn4XDr22/mScTtHydEnRhkIEK/Vl1/f QDpHKI+gz4KaRKuB1tjK8q7nvLyWcCXhHcEE1Qj9GfwtfS/UE/STWgu19 9fzGTEJZx+4dPkOpOVOoLN/DR0uBp5bUmaoH+ccpSVD5bxAEYof+SzuxK NPjDn2Da4OPxaJSmTKnkD99uOMbq+/F6wHALI8aOB2YP8nMoGQLhVYVP5 H4fWrDdxA9iNfCDHsL1bdBrEWMfwxTqkLQf7nBJuA8rkWp2cxNIB4iAZ4 Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10345"; a="356682848" X-IronPort-AV: E=Sophos;i="5.91,221,1647327600"; d="scan'208";a="356682848" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 May 2022 01:48:07 -0700 X-IronPort-AV: E=Sophos;i="5.91,221,1647327600"; d="scan'208";a="595122619" Received: from unknown (HELO ocsbesrhlrepo01.amr.corp.intel.com) ([10.240.193.73]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 May 2022 01:48:05 -0700 From: Zhu Lingshan To: jasowang@redhat.com, mst@redhat.com Cc: virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, Zhu Lingshan Subject: [RFC 2/6] vDPA/ifcvf: support userspace to query features and MQ of a management device Date: Fri, 13 May 2022 16:39:31 +0800 Message-Id: <20220513083935.1253031-3-lingshan.zhu@intel.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220513083935.1253031-1-lingshan.zhu@intel.com> References: <20220513083935.1253031-1-lingshan.zhu@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-State: RFC Adapting to current netlink interfaces, this commit allows userspace to query feature bits and MQ capability of a management device. Signed-off-by: Zhu Lingshan --- drivers/vdpa/ifcvf/ifcvf_base.c | 12 ++++++++++++ drivers/vdpa/ifcvf/ifcvf_base.h | 1 + drivers/vdpa/ifcvf/ifcvf_main.c | 3 +++ 3 files changed, 16 insertions(+) diff --git a/drivers/vdpa/ifcvf/ifcvf_base.c b/drivers/vdpa/ifcvf/ifcvf_base.c index 6bccc8291c26..7be703b5d1f4 100644 --- a/drivers/vdpa/ifcvf/ifcvf_base.c +++ b/drivers/vdpa/ifcvf/ifcvf_base.c @@ -341,6 +341,18 @@ int ifcvf_set_vq_state(struct ifcvf_hw *hw, u16 qid, u16 num) return 0; } +u16 ifcvf_get_max_vq_pairs(struct ifcvf_hw *hw) +{ + struct virtio_net_config __iomem *config; + u16 val, mq; + + config = (struct virtio_net_config __iomem *)hw->dev_cfg; + val = vp_ioread16((__le16 __iomem *)&config->max_virtqueue_pairs); + mq = le16_to_cpu((__force __le16)val); + + return mq; +} + static int ifcvf_hw_enable(struct ifcvf_hw *hw) { struct virtio_pci_common_cfg __iomem *cfg; diff --git a/drivers/vdpa/ifcvf/ifcvf_base.h b/drivers/vdpa/ifcvf/ifcvf_base.h index f5563f665cc6..d54a1bed212e 100644 --- a/drivers/vdpa/ifcvf/ifcvf_base.h +++ b/drivers/vdpa/ifcvf/ifcvf_base.h @@ -130,6 +130,7 @@ u64 ifcvf_get_hw_features(struct ifcvf_hw *hw); int ifcvf_verify_min_features(struct ifcvf_hw *hw, u64 features); u16 ifcvf_get_vq_state(struct ifcvf_hw *hw, u16 qid); int ifcvf_set_vq_state(struct ifcvf_hw *hw, u16 qid, u16 num); +u16 ifcvf_get_max_vq_pairs(struct ifcvf_hw *hw); struct ifcvf_adapter *vf_to_adapter(struct ifcvf_hw *hw); int ifcvf_probed_virtio_net(struct ifcvf_hw *hw); u32 ifcvf_get_config_size(struct ifcvf_hw *hw); diff --git a/drivers/vdpa/ifcvf/ifcvf_main.c b/drivers/vdpa/ifcvf/ifcvf_main.c index 4366320fb68d..0c3af30b297e 100644 --- a/drivers/vdpa/ifcvf/ifcvf_main.c +++ b/drivers/vdpa/ifcvf/ifcvf_main.c @@ -786,6 +786,9 @@ static int ifcvf_vdpa_dev_add(struct vdpa_mgmt_dev *mdev, const char *name, vf->hw_features = ifcvf_get_hw_features(vf); vf->config_size = ifcvf_get_config_size(vf); + ifcvf_mgmt_dev->mdev.max_supported_vqs = ifcvf_get_max_vq_pairs(vf); + ifcvf_mgmt_dev->mdev.supported_features = vf->hw_features; + adapter->vdpa.mdev = &ifcvf_mgmt_dev->mdev; ret = _vdpa_register_device(&adapter->vdpa, vf->nr_vring); if (ret) { From patchwork Fri May 13 08:39:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhu, Lingshan" X-Patchwork-Id: 12848508 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3C865C433F5 for ; Fri, 13 May 2022 08:48:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378533AbiEMIsZ (ORCPT ); Fri, 13 May 2022 04:48:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378525AbiEMIsS (ORCPT ); Fri, 13 May 2022 04:48:18 -0400 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39B7E13C4FC for ; Fri, 13 May 2022 01:48:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652431697; x=1683967697; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=yeBPPguXS1ls/KOV59s8KPqSu7LlsXtGMOSdmZuYr68=; b=UR4iNnbGfkzPy7Pi/anv88ClwR03ufrH33F4pMoYb+6in0TbJvFH8r64 /G0jPzmLfF1X7TdAPBCAW3XWSthsxNwmGXrgO2RM3neSFBRW4RzPJGsXW 4sY3H7RdMXqoo0BEO8CHLLuSFJ2LLy94Ohq86HhIKukbhyZvHgUnA7clw 4ipdeOH/UJZi39s49PwBwkJSm5QFnSWNakLI9+0YX1g13tu2Mu9mjFRr5 4Yas3y46CgjcEUR4KQTSnc+1k+CTf2xWm2SndjfZOFwbPRsNuQnMf3tGQ FuM5znFIsyY5VUIpbJ8osezSaAy6TrxkMv+Ge9DnfrjlAblrxjvJrFSc/ w==; X-IronPort-AV: E=McAfee;i="6400,9594,10345"; a="356682854" X-IronPort-AV: E=Sophos;i="5.91,221,1647327600"; d="scan'208";a="356682854" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 May 2022 01:48:09 -0700 X-IronPort-AV: E=Sophos;i="5.91,221,1647327600"; d="scan'208";a="595122638" Received: from unknown (HELO ocsbesrhlrepo01.amr.corp.intel.com) ([10.240.193.73]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 May 2022 01:48:07 -0700 From: Zhu Lingshan To: jasowang@redhat.com, mst@redhat.com Cc: virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, Zhu Lingshan Subject: [RFC 3/6] vDPA/ifcvf: support userspace to query device feature bits Date: Fri, 13 May 2022 16:39:32 +0800 Message-Id: <20220513083935.1253031-4-lingshan.zhu@intel.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220513083935.1253031-1-lingshan.zhu@intel.com> References: <20220513083935.1253031-1-lingshan.zhu@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-State: RFC This commit supports userspace to query device feature bits by filling the relevant netlink attribute. There are two types of netlink attributes: VDPA_ATTR_DEV_XXXX work for virtio devices config space, and VDPA_ATTR_MGMTDEV_XXXX work for the management devices. This commit fixes a misuse of VDPA_ATTR_DEV_SUPPORTED_FEATURES, this attr is for a virtio device, not management devices. Thus VDPA_ATTR_MGMTDEV_SUPPORTED_FEATURES is introduced for reporting management device features, and VDPA_ATTR_DEV_SUPPORTED_FEATURES for virtio devices feature bits. Signed-off-by: Zhu Lingshan --- drivers/vdpa/vdpa.c | 15 ++++++++++----- include/uapi/linux/vdpa.h | 1 + 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/vdpa/vdpa.c b/drivers/vdpa/vdpa.c index 2b75c00b1005..c820dd2b0307 100644 --- a/drivers/vdpa/vdpa.c +++ b/drivers/vdpa/vdpa.c @@ -508,7 +508,7 @@ static int vdpa_mgmtdev_fill(const struct vdpa_mgmt_dev *mdev, struct sk_buff *m err = -EMSGSIZE; goto msg_err; } - if (nla_put_u64_64bit(msg, VDPA_ATTR_DEV_SUPPORTED_FEATURES, + if (nla_put_u64_64bit(msg, VDPA_ATTR_MGMTDEV_SUPPORTED_FEATURES, mdev->supported_features, VDPA_ATTR_PAD)) { err = -EMSGSIZE; goto msg_err; @@ -827,7 +827,7 @@ static int vdpa_dev_net_mq_config_fill(struct vdpa_device *vdev, static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *msg) { struct virtio_net_config config = {}; - u64 features; + u64 features_device, features_driver; u16 val_u16; vdpa_get_config_unlocked(vdev, 0, &config, sizeof(config)); @@ -844,12 +844,17 @@ static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *ms if (nla_put_u16(msg, VDPA_ATTR_DEV_NET_CFG_MTU, val_u16)) return -EMSGSIZE; - features = vdev->config->get_driver_features(vdev); - if (nla_put_u64_64bit(msg, VDPA_ATTR_DEV_NEGOTIATED_FEATURES, features, + features_driver = vdev->config->get_driver_features(vdev); + if (nla_put_u64_64bit(msg, VDPA_ATTR_DEV_NEGOTIATED_FEATURES, features_driver, VDPA_ATTR_PAD)) return -EMSGSIZE; - return vdpa_dev_net_mq_config_fill(vdev, msg, features, &config); + features_device = vdev->config->get_device_features(vdev); + if (nla_put_u64_64bit(msg, VDPA_ATTR_DEV_SUPPORTED_FEATURES, features_device, + VDPA_ATTR_PAD)) + return -EMSGSIZE; + + return vdpa_dev_net_mq_config_fill(vdev, msg, features_device, &config); } static int diff --git a/include/uapi/linux/vdpa.h b/include/uapi/linux/vdpa.h index 1061d8d2d09d..70a3672c288f 100644 --- a/include/uapi/linux/vdpa.h +++ b/include/uapi/linux/vdpa.h @@ -30,6 +30,7 @@ enum vdpa_attr { VDPA_ATTR_MGMTDEV_BUS_NAME, /* string */ VDPA_ATTR_MGMTDEV_DEV_NAME, /* string */ VDPA_ATTR_MGMTDEV_SUPPORTED_CLASSES, /* u64 */ + VDPA_ATTR_MGMTDEV_SUPPORTED_FEATURES, /* u64 */ VDPA_ATTR_DEV_NAME, /* string */ VDPA_ATTR_DEV_ID, /* u32 */ From patchwork Fri May 13 08:39:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhu, Lingshan" X-Patchwork-Id: 12848511 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 60CD2C433FE for ; Fri, 13 May 2022 08:48:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378534AbiEMIsb (ORCPT ); Fri, 13 May 2022 04:48:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378536AbiEMIsS (ORCPT ); Fri, 13 May 2022 04:48:18 -0400 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7EE1B13C4F8 for ; Fri, 13 May 2022 01:48:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652431697; x=1683967697; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5XiD0TDFUhUOH+XaPpecKMkFXnKyE6TM6h/zfwHWyJ4=; b=ACV72cFUY4o+XHFMSuu/i5yHxCAsnc3uEK+/28Snx2wm9C60XRePyeyT YKROFb0alriYAywqzGa+4tk2W5EZy1rk54YNMWuEdatRI2NEGks+SnDe+ a+VwInhHGoLfJ7oybanmm7GmxyywcP6vFFJaodwZMwTQkKz1aI0Bqvj0a 6HNPwWBpuPmIv828WBz2prnZ6SqlDN/cOajIdsjIipXm/iFepEs42ZXcB R1i3JHObEB83b297VtsKvopYyuQppGmC3wstlg6W1RUtuKkNxSS0KD051 lxu3lr6l/raF304iLptpn1IIvYlBGW962jAi2ZBzJyTMs3bgbFNyRiFim A==; X-IronPort-AV: E=McAfee;i="6400,9594,10345"; a="356682858" X-IronPort-AV: E=Sophos;i="5.91,221,1647327600"; d="scan'208";a="356682858" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 May 2022 01:48:11 -0700 X-IronPort-AV: E=Sophos;i="5.91,221,1647327600"; d="scan'208";a="595122646" Received: from unknown (HELO ocsbesrhlrepo01.amr.corp.intel.com) ([10.240.193.73]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 May 2022 01:48:09 -0700 From: Zhu Lingshan To: jasowang@redhat.com, mst@redhat.com Cc: virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, Zhu Lingshan Subject: [RFC 4/6] vDPA: !FEATURES_OK should not block querying device config space Date: Fri, 13 May 2022 16:39:33 +0800 Message-Id: <20220513083935.1253031-5-lingshan.zhu@intel.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220513083935.1253031-1-lingshan.zhu@intel.com> References: <20220513083935.1253031-1-lingshan.zhu@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-State: RFC Users may want to query the config space of a vDPA device, to choose a appropriate one for a certain guest. This means the users need to read the config space before FEATURES_OK, and the existence of config space contents does not depend on FEATURES_OK. This commit removes FEATURES_OK blocker in vdpa_dev_config_fill() which calls vdpa_dev_net_config_fill() for virtio-net Signed-off-by: Zhu Lingshan --- drivers/vdpa/vdpa.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/drivers/vdpa/vdpa.c b/drivers/vdpa/vdpa.c index c820dd2b0307..030d96bdeed2 100644 --- a/drivers/vdpa/vdpa.c +++ b/drivers/vdpa/vdpa.c @@ -863,17 +863,9 @@ vdpa_dev_config_fill(struct vdpa_device *vdev, struct sk_buff *msg, u32 portid, { u32 device_id; void *hdr; - u8 status; int err; mutex_lock(&vdev->cf_mutex); - status = vdev->config->get_status(vdev); - if (!(status & VIRTIO_CONFIG_S_FEATURES_OK)) { - NL_SET_ERR_MSG_MOD(extack, "Features negotiation not completed"); - err = -EAGAIN; - goto out; - } - hdr = genlmsg_put(msg, portid, seq, &vdpa_nl_family, flags, VDPA_CMD_DEV_CONFIG_GET); if (!hdr) { From patchwork Fri May 13 08:39:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhu, Lingshan" X-Patchwork-Id: 12848509 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 47B1AC433F5 for ; Fri, 13 May 2022 08:48:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378529AbiEMIs1 (ORCPT ); Fri, 13 May 2022 04:48:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378547AbiEMIsS (ORCPT ); Fri, 13 May 2022 04:48:18 -0400 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9139013CA31 for ; Fri, 13 May 2022 01:48:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652431697; x=1683967697; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=JHOt+B+/ynJYw1lbcMJasr1MkUyzKCtam36/u54HyEY=; b=P4Dj5FKTSeJVN1x1dI3PC9SwHlmCky34oYRI82tcn+VKi45PR4uMNfUi +qibugwwroQ1WUwuA4eoKk/sqrXGAPjfTFm2qUNd0UxmVak7Y6nTyXA2P EvWSsSLaNnu9fXPoOMjvzSdQMWZMlqHt5SQwxceWNjcl7hvuR3+RQwvyj t3b1mnl5B8VzTGJXP6cPwZg0S0xJwhiYvRZRzK8pjfZJFHM+k8yU92fYB CkRE5fXIqXSUj6w/Q5C2oDpmif4ly7hLVDwYhN+9i+vlpqBsY6EZPDF2c hcxXX92Ru55q1amy9Avxpcj91/7oz/SFao8trayHHaAL205OSxdIwoI8W w==; X-IronPort-AV: E=McAfee;i="6400,9594,10345"; a="356682861" X-IronPort-AV: E=Sophos;i="5.91,221,1647327600"; d="scan'208";a="356682861" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 May 2022 01:48:13 -0700 X-IronPort-AV: E=Sophos;i="5.91,221,1647327600"; d="scan'208";a="595122657" Received: from unknown (HELO ocsbesrhlrepo01.amr.corp.intel.com) ([10.240.193.73]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 May 2022 01:48:11 -0700 From: Zhu Lingshan To: jasowang@redhat.com, mst@redhat.com Cc: virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, Zhu Lingshan Subject: [RFC 5/6] vDPA: answer num of queue pairs = 1 to userspace when VIRTIO_NET_F_MQ == 0 Date: Fri, 13 May 2022 16:39:34 +0800 Message-Id: <20220513083935.1253031-6-lingshan.zhu@intel.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220513083935.1253031-1-lingshan.zhu@intel.com> References: <20220513083935.1253031-1-lingshan.zhu@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-State: RFC If VIRTIO_NET_F_MQ == 0, the virtio device should have one queue pair, so when userspace querying queue pair numbers, it should return mq=1 than zero Signed-off-by: Zhu Lingshan --- drivers/vdpa/vdpa.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/vdpa/vdpa.c b/drivers/vdpa/vdpa.c index 030d96bdeed2..50a11ece603e 100644 --- a/drivers/vdpa/vdpa.c +++ b/drivers/vdpa/vdpa.c @@ -818,9 +818,10 @@ static int vdpa_dev_net_mq_config_fill(struct vdpa_device *vdev, u16 val_u16; if ((features & BIT_ULL(VIRTIO_NET_F_MQ)) == 0) - return 0; + val_u16 = 1; + else + val_u16 = le16_to_cpu((__force __le16)config->max_virtqueue_pairs); - val_u16 = le16_to_cpu(config->max_virtqueue_pairs); return nla_put_u16(msg, VDPA_ATTR_DEV_NET_CFG_MAX_VQP, val_u16); } From patchwork Fri May 13 08:39:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhu, Lingshan" X-Patchwork-Id: 12848510 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 212C3C433EF for ; Fri, 13 May 2022 08:48:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378512AbiEMIs2 (ORCPT ); Fri, 13 May 2022 04:48:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378546AbiEMIsS (ORCPT ); Fri, 13 May 2022 04:48:18 -0400 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F242913D149 for ; Fri, 13 May 2022 01:48:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652431697; x=1683967697; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=kLUq46zVK743yTschuwvLfc05xi0p506NfSw+A8rRIQ=; b=bG4EqXHN7S2x+HAwQ1rtQCifoRKcRj3t/l+IKDsuRp1jUt4jn+Iyb9ru JEX1/NlffJ7vKIpjLqby0BrH6dHpGY/+2xA1DAED+fwCYHMmjt1wTB1/Z 5/42pNStuuGE2IehXmhIhzJVCuN/cWCrLPTMoukl+2A/zyYHCxUKmxeji ajf2L76zxUl5a69/Qx7zLC93i4S/DVZFudUSLkMsjsuOBhTvkG/pSIua+ +jjDHuCNgCqIdsDMK5Ssconw2Rk0+vV5Sr0dnKnUe+Jj8Zv1vtoJCaoYo qvnuEOxHZIXeVPlKiYZtQccMD954uttfgHgYho+n/H+zf0+V+Q9kK/Jng Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10345"; a="356682865" X-IronPort-AV: E=Sophos;i="5.91,221,1647327600"; d="scan'208";a="356682865" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 May 2022 01:48:14 -0700 X-IronPort-AV: E=Sophos;i="5.91,221,1647327600"; d="scan'208";a="595122677" Received: from unknown (HELO ocsbesrhlrepo01.amr.corp.intel.com) ([10.240.193.73]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 May 2022 01:48:13 -0700 From: Zhu Lingshan To: jasowang@redhat.com, mst@redhat.com Cc: virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, Zhu Lingshan Subject: [RFC 6/6] vDPA: fix 'cast to restricted le16' warnings in vdpa_dev_net_config_fill() Date: Fri, 13 May 2022 16:39:35 +0800 Message-Id: <20220513083935.1253031-7-lingshan.zhu@intel.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220513083935.1253031-1-lingshan.zhu@intel.com> References: <20220513083935.1253031-1-lingshan.zhu@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-State: RFC This commit fixes spars warnings: cast to restricted __le16 in function vdpa_dev_net_config_fill() Signed-off-by: Zhu Lingshan --- drivers/vdpa/vdpa.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/vdpa/vdpa.c b/drivers/vdpa/vdpa.c index 50a11ece603e..2719ce9962fc 100644 --- a/drivers/vdpa/vdpa.c +++ b/drivers/vdpa/vdpa.c @@ -837,11 +837,11 @@ static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *ms config.mac)) return -EMSGSIZE; - val_u16 = le16_to_cpu(config.status); + val_u16 = le16_to_cpu((__force __le16)config.status); if (nla_put_u16(msg, VDPA_ATTR_DEV_NET_STATUS, val_u16)) return -EMSGSIZE; - val_u16 = le16_to_cpu(config.mtu); + val_u16 = le16_to_cpu((__force __le16)config.mtu); if (nla_put_u16(msg, VDPA_ATTR_DEV_NET_CFG_MTU, val_u16)) return -EMSGSIZE;