lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <68d1d356-3a3e-7254-6127-297fc48cf197@nvidia.com>
Date:   Thu, 14 Oct 2021 12:08:28 +0300
From:   Yishai Hadas <yishaih@...dia.com>
To:     Bjorn Helgaas <helgaas@...nel.org>
CC:     <alex.williamson@...hat.com>, <bhelgaas@...gle.com>,
        <jgg@...dia.com>, <saeedm@...dia.com>, <linux-pci@...r.kernel.org>,
        <kvm@...r.kernel.org>, <netdev@...r.kernel.org>, <kuba@...nel.org>,
        <leonro@...dia.com>, <kwankhede@...dia.com>,
        <mgurtovoy@...dia.com>, <maorg@...dia.com>
Subject: Re: [PATCH V1 mlx5-next 01/13] PCI/IOV: Provide internal VF index

On 10/13/2021 9:14 PM, Bjorn Helgaas wrote:
> On Wed, Oct 13, 2021 at 12:46:55PM +0300, Yishai Hadas wrote:
>> From: Jason Gunthorpe <jgg@...dia.com>
>>
>> The PCI core uses the VF index internally, often called the vf_id,
>> during the setup of the VF, eg pci_iov_add_virtfn().
>>
>> This index is needed for device drivers that implement live migration
>> for their internal operations that configure/control their VFs.
>>
>> Specifically, mlx5_vfio_pci driver that is introduced in coming patches
>> from this series needs it and not the bus/device/function which is
>> exposed today.
>>
>> Add pci_iov_vf_id() which computes the vf_id by reversing the math that
>> was used to create the bus/device/function.
>>
>> Signed-off-by: Yishai Hadas <yishaih@...dia.com>
>> Signed-off-by: Jason Gunthorpe <jgg@...dia.com>
>> Signed-off-by: Leon Romanovsky <leonro@...dia.com>
> I already acked this:
>
>    https://lore.kernel.org/r/20210922215930.GA231505@bhelgaas
>
> Saves me time if you carry the ack so I don't have to look at this
> again.  But since I *am* looking at it again, I think it's nice if the
> subject line includes the actual interface you're adding, e.g.,
>
>    PCI/IOV: Add pci_iov_vf_id() to get VF index


Sure, will change as part of V2 and add your Acked-by.

>> ---
>>   drivers/pci/iov.c   | 14 ++++++++++++++
>>   include/linux/pci.h |  8 +++++++-
>>   2 files changed, 21 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
>> index dafdc652fcd0..e7751fa3fe0b 100644
>> --- a/drivers/pci/iov.c
>> +++ b/drivers/pci/iov.c
>> @@ -33,6 +33,20 @@ int pci_iov_virtfn_devfn(struct pci_dev *dev, int vf_id)
>>   }
>>   EXPORT_SYMBOL_GPL(pci_iov_virtfn_devfn);
>>   
>> +int pci_iov_vf_id(struct pci_dev *dev)
>> +{
>> +	struct pci_dev *pf;
>> +
>> +	if (!dev->is_virtfn)
>> +		return -EINVAL;
>> +
>> +	pf = pci_physfn(dev);
>> +	return (((dev->bus->number << 8) + dev->devfn) -
>> +		((pf->bus->number << 8) + pf->devfn + pf->sriov->offset)) /
>> +	       pf->sriov->stride;
>> +}
>> +EXPORT_SYMBOL_GPL(pci_iov_vf_id);
>> +
>>   /*
>>    * Per SR-IOV spec sec 3.3.10 and 3.3.11, First VF Offset and VF Stride may
>>    * change when NumVFs changes.
>> diff --git a/include/linux/pci.h b/include/linux/pci.h
>> index cd8aa6fce204..2337512e67f0 100644
>> --- a/include/linux/pci.h
>> +++ b/include/linux/pci.h
>> @@ -2153,7 +2153,7 @@ void __iomem *pci_ioremap_wc_bar(struct pci_dev *pdev, int bar);
>>   #ifdef CONFIG_PCI_IOV
>>   int pci_iov_virtfn_bus(struct pci_dev *dev, int id);
>>   int pci_iov_virtfn_devfn(struct pci_dev *dev, int id);
>> -
>> +int pci_iov_vf_id(struct pci_dev *dev);
>>   int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn);
>>   void pci_disable_sriov(struct pci_dev *dev);
>>   
>> @@ -2181,6 +2181,12 @@ static inline int pci_iov_virtfn_devfn(struct pci_dev *dev, int id)
>>   {
>>   	return -ENOSYS;
>>   }
>> +
>> +static inline int pci_iov_vf_id(struct pci_dev *dev)
>> +{
>> +	return -ENOSYS;
>> +}
>> +
>>   static inline int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn)
>>   { return -ENODEV; }
>>   
>> -- 
>> 2.18.1
>>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ