Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1356182pxb; Tue, 8 Feb 2022 15:37:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJzTLOF1BKVK3sIycGyltezFupgGJIif9NXJyyLRSKlxlaYi41lMnnZoK0ukUjJmPcxqTOmm X-Received: by 2002:a17:902:bcc6:: with SMTP id o6mr7022918pls.116.1644363420853; Tue, 08 Feb 2022 15:37:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644363420; cv=none; d=google.com; s=arc-20160816; b=kWYbMpMl6COVpD30ScQnePfR6CmhwAtngE85DNts71CyBtcwvIOMop/L4oUC5VMt/D n1DYU2aQjF9SgqE7P0QP5ZGkxbcIKOkFi5mvOxiCMvKVaT9GCp3pFqxEFdhwIJ0a1srB Am4vcGHgFx3uW7WQwR+gNFjOonCjNqpIbNe3brOmR4yiqihfTRFIPak74ErzAJlb8l/m skABFOQK5MO0BBBtzfUUKAEaZpJY5Q57myScXMSFUTBPrj8km/dyV9w4kZdmgA0jDbgZ 1ova1aBI4pAg1eqHaBHS6U3p0VHbrHyhtryskom04R619BT4+jVeDigIEMWdvhSdSeM/ YD5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from; bh=FiYazqJwsE9MeFfs3ER+NtHOccuj6pNPjkLYoLkhQMQ=; b=YQs1+ZGszFTrnScfg9yCP0TIqZwYbt2AEbc6YDNhljJDjrm1xuIk+jxZYmzzvGczRH RDcsfvTS7V+UEdvMy555/5NSOSBSsUjBoTXnFwyRw6NmVHzgl+KbywlUvHJNunvYnJhK Qj75KpTKDcFvQKa9CXOa6RFu3uzD5GJ5jQJUnFmPOO+nxVaeR5/oGhzzmQDRt0lwtdkN +wVHu17N0tUZGyqds+aPPYJ9+ur9eKBotFc5mB6A3j/sgofvtmNlhziiUJWQZCjunbc3 sXczB6s/XEM2BiQ/xyiId+vkbuqVocAhobwQ9yfpnY15DS0wRTULytiR7BClkXgwowJg EIGg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o12si16443015plg.212.2022.02.08.15.36.32; Tue, 08 Feb 2022 15:37:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto-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; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347959AbiBHOty convert rfc822-to-8bit (ORCPT + 99 others); Tue, 8 Feb 2022 09:49:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229577AbiBHOtx (ORCPT ); Tue, 8 Feb 2022 09:49:53 -0500 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3DB48C061576; Tue, 8 Feb 2022 06:49:52 -0800 (PST) Received: from fraeml742-chm.china.huawei.com (unknown [172.18.147.201]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4JtQmS54Rhz6801q; Tue, 8 Feb 2022 22:45:44 +0800 (CST) Received: from lhreml717-chm.china.huawei.com (10.201.108.68) by fraeml742-chm.china.huawei.com (10.206.15.223) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Tue, 8 Feb 2022 15:49:49 +0100 Received: from lhreml710-chm.china.huawei.com (10.201.108.61) by lhreml717-chm.china.huawei.com (10.201.108.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Tue, 8 Feb 2022 14:49:49 +0000 Received: from lhreml710-chm.china.huawei.com ([169.254.81.184]) by lhreml710-chm.china.huawei.com ([169.254.81.184]) with mapi id 15.01.2308.021; Tue, 8 Feb 2022 14:49:48 +0000 From: Shameerali Kolothum Thodi To: Jason Gunthorpe CC: "kvm@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-crypto@vger.kernel.org" , "alex.williamson@redhat.com" , "cohuck@redhat.com" , "mgurtovoy@nvidia.com" , "yishaih@nvidia.com" , Linuxarm , liulongfang , "Zengtao (B)" , Jonathan Cameron , "Wangzhou (B)" Subject: RE: [RFC v4 6/8] crypto: hisilicon/qm: Add helper to retrieve the PF qm data Thread-Topic: [RFC v4 6/8] crypto: hisilicon/qm: Add helper to retrieve the PF qm data Thread-Index: AQHYHPDtLJcNOLWDh0OuZhX3BN5rGayJtYqAgAAE/IA= Date: Tue, 8 Feb 2022 14:49:48 +0000 Message-ID: <05460d58380b435fb629d2e04a83a1aa@huawei.com> References: <20220208133425.1096-1-shameerali.kolothum.thodi@huawei.com> <20220208133425.1096-7-shameerali.kolothum.thodi@huawei.com> <20220208142525.GE4160@nvidia.com> In-Reply-To: <20220208142525.GE4160@nvidia.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.202.227.178] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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-crypto@vger.kernel.org > -----Original Message----- > From: Jason Gunthorpe [mailto:jgg@nvidia.com] > Sent: 08 February 2022 14:25 > To: Shameerali Kolothum Thodi > Cc: kvm@vger.kernel.org; linux-kernel@vger.kernel.org; > linux-crypto@vger.kernel.org; alex.williamson@redhat.com; > cohuck@redhat.com; mgurtovoy@nvidia.com; yishaih@nvidia.com; Linuxarm > ; liulongfang ; Zengtao (B) > ; Jonathan Cameron > ; Wangzhou (B) > Subject: Re: [RFC v4 6/8] crypto: hisilicon/qm: Add helper to retrieve the PF > qm data > > On Tue, Feb 08, 2022 at 01:34:23PM +0000, Shameer Kolothum wrote: > > > +struct hisi_qm *hisi_qm_get_pf_qm(struct pci_dev *pdev) > > +{ > > + struct hisi_qm *pf_qm; > > + struct pci_driver *(*fn)(void) = NULL; > > + > > + if (!pdev->is_virtfn) > > + return NULL; > > + > > + switch (pdev->device) { > > + case PCI_DEVICE_ID_HUAWEI_SEC_VF: > > + fn = symbol_get(hisi_sec_get_pf_driver); > > + break; > > + case PCI_DEVICE_ID_HUAWEI_HPRE_VF: > > + fn = symbol_get(hisi_hpre_get_pf_driver); > > + break; > > + case PCI_DEVICE_ID_HUAWEI_ZIP_VF: > > + fn = symbol_get(hisi_zip_get_pf_driver); > > + break; > > + default: > > + return NULL; > > + } > > + > > + if (!fn) > > + return NULL; > > + > > + pf_qm = pci_iov_get_pf_drvdata(pdev, fn()); > > + > > + if (pdev->device == PCI_DEVICE_ID_HUAWEI_SEC_VF) > > + symbol_put(hisi_sec_get_pf_driver); > > + else if (pdev->device == PCI_DEVICE_ID_HUAWEI_HPRE_VF) > > + symbol_put(hisi_hpre_get_pf_driver); > > + else > > + symbol_put(hisi_zip_get_pf_driver); > > + > > + return !IS_ERR(pf_qm) ? pf_qm : NULL; > > +} > > +EXPORT_SYMBOL_GPL(hisi_qm_get_pf_qm); > > Why put this in this driver, why not in the vfio driver? And why use > symbol_get ? QM driver provides a generic common interface for all HiSilicon ACC drivers. So thought of placing it here. And symbol_get/put is used to avoid having dependency of all the ACC drivers being built along with the vfio driver. Is there a better way to retrieve the struct pci_driver * associated with each ACC PF driver? Please let me know. Thanks, Shameer