Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp7010064rwb; Mon, 5 Dec 2022 23:04:00 -0800 (PST) X-Google-Smtp-Source: AA0mqf5MRUBArhYXzcOw4wblgNFs41a98g6wvVKpI9tsQMEzmvt1qQOBUSCHMD+9ThCKPcCTxxa2 X-Received: by 2002:a63:d356:0:b0:477:1a2:390e with SMTP id u22-20020a63d356000000b0047701a2390emr77718123pgi.83.1670310240076; Mon, 05 Dec 2022 23:04:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670310240; cv=none; d=google.com; s=arc-20160816; b=ozlgHcFoS66KRoEW+loLZ5LIczZp4KXrq5ThPOKnw+eCHoINtOAAw9j9MNnID+cwIr OBk+IEVwyaBIKT3oEtYkmOz3lOeB+tJlB+yLMVKWOnqUOx7quGsYES2YUqnW7MaINIx9 hSU8ZKA97Gk/hPw+poE2nc8JJPUxNiV737peebpVCs8YtrVpKxTVN34oYaZKdp+wHISY 1yMocU0YJ69DGvv254t9HbjEB4GXPvXhrDjjoh/EN71cu54CvT6G4Dr3jviDxWu9GYg+ 1EAW57YGlmYjUxJg0AnGIt+GdoOPrEjdbRrKxjlYtCcxdJ8rhhFjm/Ui/Au8szfariOn OWVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=qmeF+cGEc/z2Nj6/HPcoeLZPAHM8b40fEf8SlnmDTLU=; b=XCegyWHpUgIjeslgZh6/N74NaR+A6oxrqeYHCE6EDSkc2j6q/i52xzxpmiWpgFz19F +MIcTbp8hwwvCgCM/SkqTd8cf+M5xKu0M8475v13qh1wQIA/sRWlrZ3TcN6g29ccVwj0 CEX4olikgYgvnL0BPqcuG0GbeGKfzRxj4KZ5sYLw30TWAhmvY6jMbjw/30actkysvmBi 0+BXNEAcDl07/vVUx+vXKB28SUJe75opaJEgb2GBwqWwCS+ay69yutK3FSPG1gF37xR9 MJKLvaAOE0YzcLfNeiVzXi29B11TtWX2QaM6uTJUsxXpw9ihtW7ZKPcsI7iCG9+IoGes 7RaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=aHuBepdw; 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=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hk1-20020a17090b224100b00219c3bb5a63si6918944pjb.38.2022.12.05.23.03.49; Mon, 05 Dec 2022 23:04:00 -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=@intel.com header.s=Intel header.b=aHuBepdw; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233317AbiLFF6k (ORCPT + 79 others); Tue, 6 Dec 2022 00:58:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233338AbiLFF6g (ORCPT ); Tue, 6 Dec 2022 00:58:36 -0500 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E50C24F28; Mon, 5 Dec 2022 21:58:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1670306315; x=1701842315; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9tscb8eIosHw9BslFqEXbDs27VxieMXwgkEh6RsBQDE=; b=aHuBepdwiqmRB6NerVm44L6r7YWbGKK1kQGiyivS//+h3RfVSE+hwTGc TkbAk71WZwmMamn3kyDZrX8tmS9/+0uXOQvlkogI2BeOx3xdr804pgh7k lABz2NklRnytnEifZCkM/ZdejZ/9qL05XPbtdui6GHhRHd87HXddj0t9Z GkccAXwK22Su2jL2sCfgQIpJYjt05IDSOttuwpaC8gAoAdi6r0uu9v+1H QLUt0uv+iwww3tyF7YEi1rh7XuVzGVYFymQSw8XYRmrG9da7dTpySpf2W iEO7sEeGZWHp/qLQ9aDyp3kp4CM5LsyC8H/tSsJrxfLIRTqjUQ6bXyOpq g==; X-IronPort-AV: E=McAfee;i="6500,9779,10552"; a="378706621" X-IronPort-AV: E=Sophos;i="5.96,220,1665471600"; d="scan'208";a="378706621" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Dec 2022 21:58:34 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10552"; a="648211267" X-IronPort-AV: E=Sophos;i="5.96,220,1665471600"; d="scan'208";a="648211267" Received: from leirao-pc.bj.intel.com ([10.238.156.101]) by fmsmga007.fm.intel.com with ESMTP; 05 Dec 2022 21:58:29 -0800 From: Lei Rao To: kbusch@kernel.org, axboe@fb.com, kch@nvidia.com, hch@lst.de, sagi@grimberg.me, alex.williamson@redhat.com, cohuck@redhat.com, jgg@ziepe.ca, yishaih@nvidia.com, shameerali.kolothum.thodi@huawei.com, kevin.tian@intel.com, mjrosato@linux.ibm.com, linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org, kvm@vger.kernel.org Cc: eddie.dong@intel.com, yadong.li@intel.com, yi.l.liu@intel.com, Konrad.wilk@oracle.com, stephen@eideticom.com, hang.yuan@intel.com, Lei Rao Subject: [RFC PATCH 1/5] nvme-pci: add function nvme_submit_vf_cmd to issue admin commands for VF driver. Date: Tue, 6 Dec 2022 13:58:12 +0800 Message-Id: <20221206055816.292304-2-lei.rao@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221206055816.292304-1-lei.rao@intel.com> References: <20221206055816.292304-1-lei.rao@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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 The new function nvme_submit_vf_cmd() helps the host VF driver to issue VF admin commands. It's helpful in some cases that the host NVMe driver does not control VF's admin queue. For example, in the virtualization device pass-through case, the VF controller's admin queue is governed by the Guest NVMe driver. Host VF driver relies on PF device's admin queue to control VF devices like vendor-specific live migration commands. Signed-off-by: Lei Rao Signed-off-by: Yadong Li Signed-off-by: Chaitanya Kulkarni Reviewed-by: Eddie Dong Reviewed-by: Hang Yuan --- drivers/nvme/host/pci.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index 488ad7dabeb8..3d9c54d8e7fc 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -3585,6 +3585,24 @@ static struct pci_driver nvme_driver = { .err_handler = &nvme_err_handler, }; +int nvme_submit_vf_cmd(struct pci_dev *dev, struct nvme_command *cmd, + size_t *result, void *buffer, unsigned int bufflen) +{ + struct nvme_dev *ndev = NULL; + union nvme_result res = { }; + int ret; + + ndev = pci_iov_get_pf_drvdata(dev, &nvme_driver); + if (IS_ERR(ndev)) + return PTR_ERR(ndev); + ret = __nvme_submit_sync_cmd(ndev->ctrl.admin_q, cmd, &res, buffer, bufflen, + NVME_QID_ANY, 0, 0); + if (ret >= 0 && result) + *result = le32_to_cpu(res.u32); + return ret; +} +EXPORT_SYMBOL_GPL(nvme_submit_vf_cmd); + static int __init nvme_init(void) { BUILD_BUG_ON(sizeof(struct nvme_create_cq) != 64); -- 2.34.1