From patchwork Thu Jun 2 02:38:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhu, Lingshan" X-Patchwork-Id: 12867452 X-Patchwork-Delegate: kuba@kernel.org 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 12367CCA473 for ; Thu, 2 Jun 2022 02:48:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233358AbiFBCsX (ORCPT ); Wed, 1 Jun 2022 22:48:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233352AbiFBCsW (ORCPT ); Wed, 1 Jun 2022 22:48:22 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD3951D5198 for ; Wed, 1 Jun 2022 19:48:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1654138100; x=1685674100; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=zjM2lpnVEzgr9EqxgfBHSEFdupKbJYQ6DivWQeNJjbk=; b=NfMU6GqjtGr4saBXM2ISsNPoitjLQAShWod2faT6ytdPHDfTBeN0ZX1G mt7n24MZTlYYVyFFZByMBAMq08gT4+7uyTLVX+CjvAbFEoi1YJcAhx3yC FBcfzm3fGWbpbpcBXBvUNyDv+DVf6qh3l3J3AWaKh1pLuI2gVE41bKKFQ oB4MCSxHROfiD/ySlCrr1fAuSCXuvRue+1bd/AFcqfvGMD4ID4wdlxKEX wm+whLCw04EuSfsrgTmb2nR7NKztO7Ak0lPaWBp4xL8FU+7sYlgD5GHRY WaJHW6PBldRygeX+kQDJl0ELuVPbrmGnGMU9soWBW9UFTNxBgElSUTf0C g==; X-IronPort-AV: E=McAfee;i="6400,9594,10365"; a="275874623" X-IronPort-AV: E=Sophos;i="5.91,270,1647327600"; d="scan'208";a="275874623" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2022 19:48:20 -0700 X-IronPort-AV: E=Sophos;i="5.91,270,1647327600"; d="scan'208";a="612608872" Received: from unknown (HELO ocsbesrhlrepo01.amr.corp.intel.com) ([10.240.193.73]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2022 19:48:18 -0700 From: Zhu Lingshan To: jasowang@redhat.com, mst@redhat.com Cc: virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, Zhu Lingshan Subject: [PATCH 2/6] vDPA/ifcvf: support userspace to query features and MQ of a management device Date: Thu, 2 Jun 2022 10:38:41 +0800 Message-Id: <20220602023845.2596397-3-lingshan.zhu@intel.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220602023845.2596397-1-lingshan.zhu@intel.com> References: <20220602023845.2596397-1-lingshan.zhu@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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) {