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

Re: [libvirt] [PATCH 1/4 v2] pci: Move some pci sriov helper code out of node device driver to util/pci





On 8/15/11 3:58 AM, "Stefan Berger" <stefanb linux vnet ibm com> wrote:

> On 08/12/2011 07:14 PM, Roopa Prabhu wrote:
>> 
>> -        get_physical_function(sysfs_path, d);
>> -        get_virtual_functions(sysfs_path, d);
>> +        if 
>> (!pciGetPhysicalFunction(sysfs_path,&d->pci_dev.physical_function))
>> +            d->pci_dev.flags |= VIR_NODE_DEV_CAP_FLAG_PCI_PHYSICAL_FUNCTION;
>> +
>> +        if 
>> (!pciGetVirtualFunctions(sysfs_path,&d->pci_dev.virtual_functions,
>> +&d->pci_dev.num_virtual_functions) ||
>> +            d->pci_dev.num_virtual_functions>  0)
>> +            d->pci_dev.flags |= VIR_NODE_DEV_CAP_FLAG_PCI_VIRTUAL_FUNCTION;
>> 
>>           VIR_FREE(sysfs_path);
>> 
> 
> [...]
>> diff --git a/src/util/pci.h b/src/util/pci.h
>> index a351baf..367881e 100644
>> --- a/src/util/pci.h
>> +++ b/src/util/pci.h
>> @@ -27,6 +27,13 @@
>>   typedef struct _pciDevice pciDevice;
>>   typedef struct _pciDeviceList pciDeviceList;
>> 
>> +struct pci_config_address {
>> +    unsigned int domain;
>> +    unsigned int bus;
>> +    unsigned int slot;
>> +    unsigned int function;
>> +};
>> +
>>   pciDevice *pciGetDevice      (unsigned       domain,
>>                                 unsigned       bus,
>>                                 unsigned       slot,
>> @@ -74,4 +81,22 @@ int pciDeviceIsAssignable(pciDevice *dev,
>>                             int strict_acs_check);
>>   int pciWaitForDeviceCleanup(pciDevice *dev, const char *matcher);
>> 
>> +#ifdef __linux__
>> +
>> +#  define pciGetPhysicalFunction(s,a) pciGetPhysicalFunctionLinux(s,a)
>> +int pciGetPhysicalFunctionLinux(const char *sysfs_path,
>> +                                struct pci_config_address **phys_fn);
>> +
>> +#  define pciGetVirtualFunctions(s,a,n) pciGetVirtualFunctionsLinux(s,a,n)
>> +int pciGetVirtualFunctionsLinux(const char *sysfs_path,
>> +                                struct pci_config_address
>> ***virtual_functions,
>> +                                unsigned int *num_virtual_functions);
>> +
>> +#else /* __linux__ */
>> +
>> +#  define pciGetPhysicalFunction(s,a)
>> +#  define pciGetVirtualFunctions(s,a,n)
>> +
> I don't think these #defines will produce compilable code if they are
> used above. You'll probably have to implement functions for them.
> 
Ok, I actually moved them from node_device driver as is with only name
changes. I can implement them returning -1 for non __linux__
Will resubmit. Thanks.


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