RE: [RFC v4 6/8] crypto: hisilicon/qm: Add helper to retrieve the PF qm data

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




> -----Original Message-----
> From: Jason Gunthorpe [mailto:jgg@xxxxxxxxxx]
> Sent: 08 February 2022 14:25
> To: Shameerali Kolothum Thodi <shameerali.kolothum.thodi@xxxxxxxxxx>
> Cc: kvm@xxxxxxxxxxxxxxx; linux-kernel@xxxxxxxxxxxxxxx;
> linux-crypto@xxxxxxxxxxxxxxx; alex.williamson@xxxxxxxxxx;
> cohuck@xxxxxxxxxx; mgurtovoy@xxxxxxxxxx; yishaih@xxxxxxxxxx; Linuxarm
> <linuxarm@xxxxxxxxxx>; liulongfang <liulongfang@xxxxxxxxxx>; Zengtao (B)
> <prime.zeng@xxxxxxxxxxxxx>; Jonathan Cameron
> <jonathan.cameron@xxxxxxxxxx>; Wangzhou (B) <wangzhou1@xxxxxxxxxxxxx>
> 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



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux